Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *  linux/arch/arm/mach-pxa/mainstone.c
0004  *
0005  *  Support for the Intel HCDDBBVA0 Development Platform.
0006  *  (go figure how they came up with such name...)
0007  *
0008  *  Author: Nicolas Pitre
0009  *  Created:    Nov 05, 2002
0010  *  Copyright:  MontaVista Software Inc.
0011  */
0012 #include <linux/gpio.h>
0013 #include <linux/gpio/gpio-reg.h>
0014 #include <linux/gpio/machine.h>
0015 #include <linux/init.h>
0016 #include <linux/platform_device.h>
0017 #include <linux/syscore_ops.h>
0018 #include <linux/interrupt.h>
0019 #include <linux/sched.h>
0020 #include <linux/bitops.h>
0021 #include <linux/fb.h>
0022 #include <linux/ioport.h>
0023 #include <linux/mtd/mtd.h>
0024 #include <linux/mtd/partitions.h>
0025 #include <linux/input.h>
0026 #include <linux/gpio_keys.h>
0027 #include <linux/pwm.h>
0028 #include <linux/pwm_backlight.h>
0029 #include <linux/smc91x.h>
0030 #include <linux/platform_data/i2c-pxa.h>
0031 #include <linux/slab.h>
0032 #include <linux/leds.h>
0033 
0034 #include <asm/types.h>
0035 #include <asm/setup.h>
0036 #include <asm/memory.h>
0037 #include <asm/mach-types.h>
0038 #include <asm/irq.h>
0039 #include <linux/sizes.h>
0040 
0041 #include <asm/mach/arch.h>
0042 #include <asm/mach/map.h>
0043 #include <asm/mach/irq.h>
0044 #include <asm/mach/flash.h>
0045 
0046 #include "pxa27x.h"
0047 #include "mainstone.h"
0048 #include <linux/platform_data/asoc-pxa.h>
0049 #include <linux/platform_data/video-pxafb.h>
0050 #include <linux/platform_data/mmc-pxamci.h>
0051 #include <linux/platform_data/irda-pxaficp.h>
0052 #include <linux/platform_data/usb-ohci-pxa27x.h>
0053 #include <linux/platform_data/keypad-pxa27x.h>
0054 #include "addr-map.h"
0055 #include "smemc.h"
0056 
0057 #include "generic.h"
0058 #include "devices.h"
0059 
0060 static unsigned long mainstone_pin_config[] = {
0061     /* Chip Select */
0062     GPIO15_nCS_1,
0063 
0064     /* LCD - 16bpp Active TFT */
0065     GPIOxx_LCD_TFT_16BPP,
0066     GPIO16_PWM0_OUT,    /* Backlight */
0067 
0068     /* MMC */
0069     GPIO32_MMC_CLK,
0070     GPIO112_MMC_CMD,
0071     GPIO92_MMC_DAT_0,
0072     GPIO109_MMC_DAT_1,
0073     GPIO110_MMC_DAT_2,
0074     GPIO111_MMC_DAT_3,
0075 
0076     /* USB Host Port 1 */
0077     GPIO88_USBH1_PWR,
0078     GPIO89_USBH1_PEN,
0079 
0080     /* PC Card */
0081     GPIO48_nPOE,
0082     GPIO49_nPWE,
0083     GPIO50_nPIOR,
0084     GPIO51_nPIOW,
0085     GPIO85_nPCE_1,
0086     GPIO54_nPCE_2,
0087     GPIO79_PSKTSEL,
0088     GPIO55_nPREG,
0089     GPIO56_nPWAIT,
0090     GPIO57_nIOIS16,
0091 
0092     /* AC97 */
0093     GPIO28_AC97_BITCLK,
0094     GPIO29_AC97_SDATA_IN_0,
0095     GPIO30_AC97_SDATA_OUT,
0096     GPIO31_AC97_SYNC,
0097     GPIO45_AC97_SYSCLK,
0098 
0099     /* Keypad */
0100     GPIO93_KP_DKIN_0,
0101     GPIO94_KP_DKIN_1,
0102     GPIO95_KP_DKIN_2,
0103     GPIO100_KP_MKIN_0   | WAKEUP_ON_LEVEL_HIGH,
0104     GPIO101_KP_MKIN_1   | WAKEUP_ON_LEVEL_HIGH,
0105     GPIO102_KP_MKIN_2   | WAKEUP_ON_LEVEL_HIGH,
0106     GPIO97_KP_MKIN_3    | WAKEUP_ON_LEVEL_HIGH,
0107     GPIO98_KP_MKIN_4    | WAKEUP_ON_LEVEL_HIGH,
0108     GPIO99_KP_MKIN_5    | WAKEUP_ON_LEVEL_HIGH,
0109     GPIO103_KP_MKOUT_0,
0110     GPIO104_KP_MKOUT_1,
0111     GPIO105_KP_MKOUT_2,
0112     GPIO106_KP_MKOUT_3,
0113     GPIO107_KP_MKOUT_4,
0114     GPIO108_KP_MKOUT_5,
0115     GPIO96_KP_MKOUT_6,
0116 
0117     /* I2C */
0118     GPIO117_I2C_SCL,
0119     GPIO118_I2C_SDA,
0120 
0121     /* GPIO */
0122     GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
0123 };
0124 
0125 static struct resource smc91x_resources[] = {
0126     [0] = {
0127         .start  = (MST_ETH_PHYS + 0x300),
0128         .end    = (MST_ETH_PHYS + 0xfffff),
0129         .flags  = IORESOURCE_MEM,
0130     },
0131     [1] = {
0132         .start  = MAINSTONE_IRQ(3),
0133         .end    = MAINSTONE_IRQ(3),
0134         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
0135     }
0136 };
0137 
0138 static struct smc91x_platdata mainstone_smc91x_info = {
0139     .flags  = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
0140           SMC91X_NOWAIT | SMC91X_USE_DMA,
0141     .pxa_u16_align4 = true,
0142 };
0143 
0144 static struct platform_device smc91x_device = {
0145     .name       = "smc91x",
0146     .id     = 0,
0147     .num_resources  = ARRAY_SIZE(smc91x_resources),
0148     .resource   = smc91x_resources,
0149     .dev        = {
0150         .platform_data = &mainstone_smc91x_info,
0151     },
0152 };
0153 
0154 static int mst_audio_startup(struct snd_pcm_substream *substream, void *priv)
0155 {
0156     if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
0157         MST_MSCWR2 &= ~MST_MSCWR2_AC97_SPKROFF;
0158     return 0;
0159 }
0160 
0161 static void mst_audio_shutdown(struct snd_pcm_substream *substream, void *priv)
0162 {
0163     if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
0164         MST_MSCWR2 |= MST_MSCWR2_AC97_SPKROFF;
0165 }
0166 
0167 static long mst_audio_suspend_mask;
0168 
0169 static void mst_audio_suspend(void *priv)
0170 {
0171     mst_audio_suspend_mask = MST_MSCWR2;
0172     MST_MSCWR2 |= MST_MSCWR2_AC97_SPKROFF;
0173 }
0174 
0175 static void mst_audio_resume(void *priv)
0176 {
0177     MST_MSCWR2 &= mst_audio_suspend_mask | ~MST_MSCWR2_AC97_SPKROFF;
0178 }
0179 
0180 static pxa2xx_audio_ops_t mst_audio_ops = {
0181     .startup    = mst_audio_startup,
0182     .shutdown   = mst_audio_shutdown,
0183     .suspend    = mst_audio_suspend,
0184     .resume     = mst_audio_resume,
0185 };
0186 
0187 static struct resource flash_resources[] = {
0188     [0] = {
0189         .start  = PXA_CS0_PHYS,
0190         .end    = PXA_CS0_PHYS + SZ_64M - 1,
0191         .flags  = IORESOURCE_MEM,
0192     },
0193     [1] = {
0194         .start  = PXA_CS1_PHYS,
0195         .end    = PXA_CS1_PHYS + SZ_64M - 1,
0196         .flags  = IORESOURCE_MEM,
0197     },
0198 };
0199 
0200 static struct mtd_partition mainstoneflash0_partitions[] = {
0201     {
0202         .name =     "Bootloader",
0203         .size =     0x00040000,
0204         .offset =   0,
0205         .mask_flags =   MTD_WRITEABLE  /* force read-only */
0206     },{
0207         .name =     "Kernel",
0208         .size =     0x00400000,
0209         .offset =   0x00040000,
0210     },{
0211         .name =     "Filesystem",
0212         .size =     MTDPART_SIZ_FULL,
0213         .offset =   0x00440000
0214     }
0215 };
0216 
0217 static struct flash_platform_data mst_flash_data[2] = {
0218     {
0219         .map_name   = "cfi_probe",
0220         .parts      = mainstoneflash0_partitions,
0221         .nr_parts   = ARRAY_SIZE(mainstoneflash0_partitions),
0222     }, {
0223         .map_name   = "cfi_probe",
0224         .parts      = NULL,
0225         .nr_parts   = 0,
0226     }
0227 };
0228 
0229 static struct platform_device mst_flash_device[2] = {
0230     {
0231         .name       = "pxa2xx-flash",
0232         .id     = 0,
0233         .dev = {
0234             .platform_data = &mst_flash_data[0],
0235         },
0236         .resource = &flash_resources[0],
0237         .num_resources = 1,
0238     },
0239     {
0240         .name       = "pxa2xx-flash",
0241         .id     = 1,
0242         .dev = {
0243             .platform_data = &mst_flash_data[1],
0244         },
0245         .resource = &flash_resources[1],
0246         .num_resources = 1,
0247     },
0248 };
0249 
0250 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
0251 static struct pwm_lookup mainstone_pwm_lookup[] = {
0252     PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.0", NULL, 78770,
0253            PWM_POLARITY_NORMAL),
0254 };
0255 
0256 static struct platform_pwm_backlight_data mainstone_backlight_data = {
0257     .max_brightness = 1023,
0258     .dft_brightness = 1023,
0259 };
0260 
0261 static struct platform_device mainstone_backlight_device = {
0262     .name       = "pwm-backlight",
0263     .dev        = {
0264         .parent = &pxa27x_device_pwm0.dev,
0265         .platform_data = &mainstone_backlight_data,
0266     },
0267 };
0268 
0269 static void __init mainstone_backlight_register(void)
0270 {
0271     int ret;
0272 
0273     pwm_add_table(mainstone_pwm_lookup, ARRAY_SIZE(mainstone_pwm_lookup));
0274 
0275     ret = platform_device_register(&mainstone_backlight_device);
0276     if (ret) {
0277         printk(KERN_ERR "mainstone: failed to register backlight device: %d\n", ret);
0278         pwm_remove_table(mainstone_pwm_lookup,
0279                  ARRAY_SIZE(mainstone_pwm_lookup));
0280     }
0281 }
0282 #else
0283 #define mainstone_backlight_register()  do { } while (0)
0284 #endif
0285 
0286 static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
0287     .pixclock       = 50000,
0288     .xres           = 640,
0289     .yres           = 480,
0290     .bpp            = 16,
0291     .hsync_len      = 1,
0292     .left_margin        = 0x9f,
0293     .right_margin       = 1,
0294     .vsync_len      = 44,
0295     .upper_margin       = 0,
0296     .lower_margin       = 0,
0297     .sync           = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
0298 };
0299 
0300 static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
0301     .pixclock       = 110000,
0302     .xres           = 240,
0303     .yres           = 320,
0304     .bpp            = 16,
0305     .hsync_len      = 4,
0306     .left_margin        = 8,
0307     .right_margin       = 20,
0308     .vsync_len      = 3,
0309     .upper_margin       = 1,
0310     .lower_margin       = 10,
0311     .sync           = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
0312 };
0313 
0314 static struct pxafb_mach_info mainstone_pxafb_info = {
0315     .num_modes          = 1,
0316     .lcd_conn       = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
0317 };
0318 
0319 static int mainstone_mci_init(struct device *dev, irq_handler_t mstone_detect_int, void *data)
0320 {
0321     int err;
0322 
0323     /* make sure SD/Memory Stick multiplexer's signals
0324      * are routed to MMC controller
0325      */
0326     MST_MSCWR1 &= ~MST_MSCWR1_MS_SEL;
0327 
0328     err = request_irq(MAINSTONE_MMC_IRQ, mstone_detect_int, 0,
0329                  "MMC card detect", data);
0330     if (err)
0331         printk(KERN_ERR "mainstone_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
0332 
0333     return err;
0334 }
0335 
0336 static int mainstone_mci_setpower(struct device *dev, unsigned int vdd)
0337 {
0338     struct pxamci_platform_data* p_d = dev->platform_data;
0339 
0340     if (( 1 << vdd) & p_d->ocr_mask) {
0341         printk(KERN_DEBUG "%s: on\n", __func__);
0342         MST_MSCWR1 |= MST_MSCWR1_MMC_ON;
0343         MST_MSCWR1 &= ~MST_MSCWR1_MS_SEL;
0344     } else {
0345         printk(KERN_DEBUG "%s: off\n", __func__);
0346         MST_MSCWR1 &= ~MST_MSCWR1_MMC_ON;
0347     }
0348     return 0;
0349 }
0350 
0351 static void mainstone_mci_exit(struct device *dev, void *data)
0352 {
0353     free_irq(MAINSTONE_MMC_IRQ, data);
0354 }
0355 
0356 static struct pxamci_platform_data mainstone_mci_platform_data = {
0357     .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
0358     .init           = mainstone_mci_init,
0359     .setpower       = mainstone_mci_setpower,
0360     .exit           = mainstone_mci_exit,
0361 };
0362 
0363 static void mainstone_irda_transceiver_mode(struct device *dev, int mode)
0364 {
0365     unsigned long flags;
0366 
0367     local_irq_save(flags);
0368     if (mode & IR_SIRMODE) {
0369         MST_MSCWR1 &= ~MST_MSCWR1_IRDA_FIR;
0370     } else if (mode & IR_FIRMODE) {
0371         MST_MSCWR1 |= MST_MSCWR1_IRDA_FIR;
0372     }
0373     pxa2xx_transceiver_mode(dev, mode);
0374     if (mode & IR_OFF) {
0375         MST_MSCWR1 = (MST_MSCWR1 & ~MST_MSCWR1_IRDA_MASK) | MST_MSCWR1_IRDA_OFF;
0376     } else {
0377         MST_MSCWR1 = (MST_MSCWR1 & ~MST_MSCWR1_IRDA_MASK) | MST_MSCWR1_IRDA_FULL;
0378     }
0379     local_irq_restore(flags);
0380 }
0381 
0382 static struct pxaficp_platform_data mainstone_ficp_platform_data = {
0383     .gpio_pwdown        = -1,
0384     .transceiver_cap    = IR_SIRMODE | IR_FIRMODE | IR_OFF,
0385     .transceiver_mode   = mainstone_irda_transceiver_mode,
0386 };
0387 
0388 static struct gpio_keys_button gpio_keys_button[] = {
0389     [0] = {
0390         .desc   = "wakeup",
0391         .code   = KEY_SUSPEND,
0392         .type   = EV_KEY,
0393         .gpio   = 1,
0394         .wakeup = 1,
0395     },
0396 };
0397 
0398 static struct gpio_keys_platform_data mainstone_gpio_keys = {
0399     .buttons    = gpio_keys_button,
0400     .nbuttons   = 1,
0401 };
0402 
0403 static struct platform_device mst_gpio_keys_device = {
0404     .name       = "gpio-keys",
0405     .id     = -1,
0406     .dev        = {
0407         .platform_data  = &mainstone_gpio_keys,
0408     },
0409 };
0410 
0411 static struct resource mst_cplds_resources[] = {
0412     [0] = {
0413         .start  = MST_FPGA_PHYS + 0xc0,
0414         .end    = MST_FPGA_PHYS + 0xe0 - 1,
0415         .flags  = IORESOURCE_MEM,
0416     },
0417     [1] = {
0418         .start  = PXA_GPIO_TO_IRQ(0),
0419         .end    = PXA_GPIO_TO_IRQ(0),
0420         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
0421     },
0422     [2] = {
0423         .start  = MAINSTONE_IRQ(0),
0424         .end    = MAINSTONE_IRQ(15),
0425         .flags  = IORESOURCE_IRQ,
0426     },
0427 };
0428 
0429 static struct platform_device mst_cplds_device = {
0430     .name       = "pxa_cplds_irqs",
0431     .id     = -1,
0432     .resource   = &mst_cplds_resources[0],
0433     .num_resources  = 3,
0434 };
0435 
0436 static struct platform_device *platform_devices[] __initdata = {
0437     &smc91x_device,
0438     &mst_flash_device[0],
0439     &mst_flash_device[1],
0440     &mst_gpio_keys_device,
0441     &mst_cplds_device,
0442 };
0443 
0444 static struct pxaohci_platform_data mainstone_ohci_platform_data = {
0445     .port_mode  = PMM_PERPORT_MODE,
0446     .flags      = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
0447 };
0448 
0449 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
0450 static const unsigned int mainstone_matrix_keys[] = {
0451     KEY(0, 0, KEY_A), KEY(1, 0, KEY_B), KEY(2, 0, KEY_C),
0452     KEY(3, 0, KEY_D), KEY(4, 0, KEY_E), KEY(5, 0, KEY_F),
0453     KEY(0, 1, KEY_G), KEY(1, 1, KEY_H), KEY(2, 1, KEY_I),
0454     KEY(3, 1, KEY_J), KEY(4, 1, KEY_K), KEY(5, 1, KEY_L),
0455     KEY(0, 2, KEY_M), KEY(1, 2, KEY_N), KEY(2, 2, KEY_O),
0456     KEY(3, 2, KEY_P), KEY(4, 2, KEY_Q), KEY(5, 2, KEY_R),
0457     KEY(0, 3, KEY_S), KEY(1, 3, KEY_T), KEY(2, 3, KEY_U),
0458     KEY(3, 3, KEY_V), KEY(4, 3, KEY_W), KEY(5, 3, KEY_X),
0459     KEY(2, 4, KEY_Y), KEY(3, 4, KEY_Z),
0460 
0461     KEY(0, 4, KEY_DOT), /* . */
0462     KEY(1, 4, KEY_CLOSE),   /* @ */
0463     KEY(4, 4, KEY_SLASH),
0464     KEY(5, 4, KEY_BACKSLASH),
0465     KEY(0, 5, KEY_HOME),
0466     KEY(1, 5, KEY_LEFTSHIFT),
0467     KEY(2, 5, KEY_SPACE),
0468     KEY(3, 5, KEY_SPACE),
0469     KEY(4, 5, KEY_ENTER),
0470     KEY(5, 5, KEY_BACKSPACE),
0471 
0472     KEY(0, 6, KEY_UP),
0473     KEY(1, 6, KEY_DOWN),
0474     KEY(2, 6, KEY_LEFT),
0475     KEY(3, 6, KEY_RIGHT),
0476     KEY(4, 6, KEY_SELECT),
0477 };
0478 
0479 static struct matrix_keymap_data mainstone_matrix_keymap_data = {
0480     .keymap         = mainstone_matrix_keys,
0481     .keymap_size        = ARRAY_SIZE(mainstone_matrix_keys),
0482 };
0483 
0484 struct pxa27x_keypad_platform_data mainstone_keypad_info = {
0485     .matrix_key_rows    = 6,
0486     .matrix_key_cols    = 7,
0487     .matrix_keymap_data = &mainstone_matrix_keymap_data,
0488 
0489     .enable_rotary0     = 1,
0490     .rotary0_up_key     = KEY_UP,
0491     .rotary0_down_key   = KEY_DOWN,
0492 
0493     .debounce_interval  = 30,
0494 };
0495 
0496 static void __init mainstone_init_keypad(void)
0497 {
0498     pxa_set_keypad_info(&mainstone_keypad_info);
0499 }
0500 #else
0501 static inline void mainstone_init_keypad(void) {}
0502 #endif
0503 
0504 static int mst_pcmcia0_irqs[11] = {
0505     [0 ... 4] = -1,
0506     [5] = MAINSTONE_S0_CD_IRQ,
0507     [6 ... 7] = -1,
0508     [8] = MAINSTONE_S0_STSCHG_IRQ,
0509     [9] = -1,
0510     [10] = MAINSTONE_S0_IRQ,
0511 };
0512 
0513 static int mst_pcmcia1_irqs[11] = {
0514     [0 ... 4] = -1,
0515     [5] = MAINSTONE_S1_CD_IRQ,
0516     [6 ... 7] = -1,
0517     [8] = MAINSTONE_S1_STSCHG_IRQ,
0518     [9] = -1,
0519     [10] = MAINSTONE_S1_IRQ,
0520 };
0521 
0522 static struct gpiod_lookup_table mainstone_pcmcia_gpio_table = {
0523     .dev_id = "pxa2xx-pcmcia",
0524     .table = {
0525         GPIO_LOOKUP("mst-pcmcia0",  0, "a0vpp",   GPIO_ACTIVE_HIGH),
0526         GPIO_LOOKUP("mst-pcmcia0",  1, "a1vpp",   GPIO_ACTIVE_HIGH),
0527         GPIO_LOOKUP("mst-pcmcia0",  2, "a0vcc",   GPIO_ACTIVE_HIGH),
0528         GPIO_LOOKUP("mst-pcmcia0",  3, "a1vcc",   GPIO_ACTIVE_HIGH),
0529         GPIO_LOOKUP("mst-pcmcia0",  4, "areset",  GPIO_ACTIVE_HIGH),
0530         GPIO_LOOKUP("mst-pcmcia0",  5, "adetect", GPIO_ACTIVE_LOW),
0531         GPIO_LOOKUP("mst-pcmcia0",  6, "avs1",    GPIO_ACTIVE_LOW),
0532         GPIO_LOOKUP("mst-pcmcia0",  7, "avs2",    GPIO_ACTIVE_LOW),
0533         GPIO_LOOKUP("mst-pcmcia0",  8, "abvd1",   GPIO_ACTIVE_HIGH),
0534         GPIO_LOOKUP("mst-pcmcia0",  9, "abvd2",   GPIO_ACTIVE_HIGH),
0535         GPIO_LOOKUP("mst-pcmcia0", 10, "aready",  GPIO_ACTIVE_HIGH),
0536         GPIO_LOOKUP("mst-pcmcia1",  0, "b0vpp",   GPIO_ACTIVE_HIGH),
0537         GPIO_LOOKUP("mst-pcmcia1",  1, "b1vpp",   GPIO_ACTIVE_HIGH),
0538         GPIO_LOOKUP("mst-pcmcia1",  2, "b0vcc",   GPIO_ACTIVE_HIGH),
0539         GPIO_LOOKUP("mst-pcmcia1",  3, "b1vcc",   GPIO_ACTIVE_HIGH),
0540         GPIO_LOOKUP("mst-pcmcia1",  4, "breset",  GPIO_ACTIVE_HIGH),
0541         GPIO_LOOKUP("mst-pcmcia1",  5, "bdetect", GPIO_ACTIVE_LOW),
0542         GPIO_LOOKUP("mst-pcmcia1",  6, "bvs1",    GPIO_ACTIVE_LOW),
0543         GPIO_LOOKUP("mst-pcmcia1",  7, "bvs2",    GPIO_ACTIVE_LOW),
0544         GPIO_LOOKUP("mst-pcmcia1",  8, "bbvd1",   GPIO_ACTIVE_HIGH),
0545         GPIO_LOOKUP("mst-pcmcia1",  9, "bbvd2",   GPIO_ACTIVE_HIGH),
0546         GPIO_LOOKUP("mst-pcmcia1", 10, "bready",  GPIO_ACTIVE_HIGH),
0547         { },
0548     },
0549 };
0550 
0551 static struct gpiod_lookup_table mainstone_wm97xx_gpio_table = {
0552     .dev_id = "wm97xx-touch",
0553     .table = {
0554         GPIO_LOOKUP("gpio-pxa", 4, "touch", GPIO_ACTIVE_HIGH),
0555         { },
0556     },
0557 };
0558 
0559 static void __init mainstone_init(void)
0560 {
0561     int SW7 = 0;  /* FIXME: get from SCR (Mst doc section 3.2.1.1) */
0562 
0563     pxa2xx_mfp_config(ARRAY_AND_SIZE(mainstone_pin_config));
0564 
0565     /* Register board control register(s) as GPIOs */
0566     gpio_reg_init(NULL, (void __iomem *)&MST_PCMCIA0, -1, 11,
0567               "mst-pcmcia0", MST_PCMCIA_INPUTS, 0, NULL,
0568               NULL, mst_pcmcia0_irqs);
0569     gpio_reg_init(NULL, (void __iomem *)&MST_PCMCIA1, -1, 11,
0570               "mst-pcmcia1", MST_PCMCIA_INPUTS, 0, NULL,
0571               NULL, mst_pcmcia1_irqs);
0572     gpiod_add_lookup_table(&mainstone_pcmcia_gpio_table);
0573     gpiod_add_lookup_table(&mainstone_wm97xx_gpio_table);
0574 
0575     pxa_set_ffuart_info(NULL);
0576     pxa_set_btuart_info(NULL);
0577     pxa_set_stuart_info(NULL);
0578 
0579     mst_flash_data[0].width = (__raw_readl(BOOT_DEF) & 1) ? 2 : 4;
0580     mst_flash_data[1].width = 4;
0581 
0582     /* Compensate for SW7 which swaps the flash banks */
0583     mst_flash_data[SW7].name = "processor-flash";
0584     mst_flash_data[SW7 ^ 1].name = "mainboard-flash";
0585 
0586     printk(KERN_NOTICE "Mainstone configured to boot from %s\n",
0587            mst_flash_data[0].name);
0588 
0589     /* system bus arbiter setting
0590      * - Core_Park
0591      * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
0592      */
0593     ARB_CNTRL = ARB_CORE_PARK | 0x234;
0594 
0595     platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
0596 
0597     /* reading Mainstone's "Virtual Configuration Register"
0598        might be handy to select LCD type here */
0599     if (0)
0600         mainstone_pxafb_info.modes = &toshiba_ltm04c380k_mode;
0601     else
0602         mainstone_pxafb_info.modes = &toshiba_ltm035a776c_mode;
0603 
0604     pxa_set_fb_info(NULL, &mainstone_pxafb_info);
0605     mainstone_backlight_register();
0606 
0607     pxa_set_mci_info(&mainstone_mci_platform_data);
0608     pxa_set_ficp_info(&mainstone_ficp_platform_data);
0609     pxa_set_ohci_info(&mainstone_ohci_platform_data);
0610     pxa_set_i2c_info(NULL);
0611     pxa_set_ac97_info(&mst_audio_ops);
0612 
0613     mainstone_init_keypad();
0614 }
0615 
0616 
0617 static struct map_desc mainstone_io_desc[] __initdata = {
0618     {   /* CPLD */
0619         .virtual    =  MST_FPGA_VIRT,
0620         .pfn        = __phys_to_pfn(MST_FPGA_PHYS),
0621         .length     = 0x00100000,
0622         .type       = MT_DEVICE
0623     }
0624 };
0625 
0626 static void __init mainstone_map_io(void)
0627 {
0628     pxa27x_map_io();
0629     iotable_init(mainstone_io_desc, ARRAY_SIZE(mainstone_io_desc));
0630 
0631     /*  for use I SRAM as framebuffer.  */
0632     PSLR |= 0xF04;
0633     PCFR = 0x66;
0634 }
0635 
0636 /*
0637  * Driver for the 8 discrete LEDs available for general use:
0638  * Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
0639  * so be sure to not monkey with them here.
0640  */
0641 
0642 #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
0643 struct mainstone_led {
0644     struct led_classdev cdev;
0645     u8          mask;
0646 };
0647 
0648 /*
0649  * The triggers lines up below will only be used if the
0650  * LED triggers are compiled in.
0651  */
0652 static const struct {
0653     const char *name;
0654     const char *trigger;
0655 } mainstone_leds[] = {
0656     { "mainstone:D28", "default-on", },
0657     { "mainstone:D27", "cpu0", },
0658     { "mainstone:D26", "heartbeat" },
0659     { "mainstone:D25", },
0660     { "mainstone:D24", },
0661     { "mainstone:D23", },
0662     { "mainstone:D22", },
0663     { "mainstone:D21", },
0664 };
0665 
0666 static void mainstone_led_set(struct led_classdev *cdev,
0667                   enum led_brightness b)
0668 {
0669     struct mainstone_led *led = container_of(cdev,
0670                      struct mainstone_led, cdev);
0671     u32 reg = MST_LEDCTRL;
0672 
0673     if (b != LED_OFF)
0674         reg |= led->mask;
0675     else
0676         reg &= ~led->mask;
0677 
0678     MST_LEDCTRL = reg;
0679 }
0680 
0681 static enum led_brightness mainstone_led_get(struct led_classdev *cdev)
0682 {
0683     struct mainstone_led *led = container_of(cdev,
0684                      struct mainstone_led, cdev);
0685     u32 reg = MST_LEDCTRL;
0686 
0687     return (reg & led->mask) ? LED_FULL : LED_OFF;
0688 }
0689 
0690 static int __init mainstone_leds_init(void)
0691 {
0692     int i;
0693 
0694     if (!machine_is_mainstone())
0695         return -ENODEV;
0696 
0697     /* All ON */
0698     MST_LEDCTRL |= 0xff;
0699     for (i = 0; i < ARRAY_SIZE(mainstone_leds); i++) {
0700         struct mainstone_led *led;
0701 
0702         led = kzalloc(sizeof(*led), GFP_KERNEL);
0703         if (!led)
0704             break;
0705 
0706         led->cdev.name = mainstone_leds[i].name;
0707         led->cdev.brightness_set = mainstone_led_set;
0708         led->cdev.brightness_get = mainstone_led_get;
0709         led->cdev.default_trigger = mainstone_leds[i].trigger;
0710         led->mask = BIT(i);
0711 
0712         if (led_classdev_register(NULL, &led->cdev) < 0) {
0713             kfree(led);
0714             break;
0715         }
0716     }
0717 
0718     return 0;
0719 }
0720 
0721 /*
0722  * Since we may have triggers on any subsystem, defer registration
0723  * until after subsystem_init.
0724  */
0725 fs_initcall(mainstone_leds_init);
0726 #endif
0727 
0728 MACHINE_START(MAINSTONE, "Intel HCDDBBVA0 Development Platform (aka Mainstone)")
0729     /* Maintainer: MontaVista Software Inc. */
0730     .atag_offset    = 0x100,    /* BLOB boot parameter setting */
0731     .map_io     = mainstone_map_io,
0732     .nr_irqs    = MAINSTONE_NR_IRQS,
0733     .init_irq   = pxa27x_init_irq,
0734     .handle_irq = pxa27x_handle_irq,
0735     .init_time  = pxa_timer_init,
0736     .init_machine   = mainstone_init,
0737     .restart    = pxa_restart,
0738 MACHINE_END