[ARM] pxa: fix pxa27x_udc default pullup GPIO
[linux-2.6/mini2440.git] / arch / arm / mach-pxa / em-x270.c
blobbc0f73fbd4ca0ef0c26f56d760005b0c9bf85a0b
1 /*
2 * Support for CompuLab EM-X270 platform
4 * Copyright (C) 2007, 2008 CompuLab, Ltd.
5 * Author: Mike Rapoport <mike@compulab.co.il>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/irq.h>
13 #include <linux/platform_device.h>
14 #include <linux/delay.h>
16 #include <linux/dm9000.h>
17 #include <linux/rtc-v3020.h>
18 #include <linux/mtd/nand.h>
19 #include <linux/mtd/partitions.h>
20 #include <linux/mtd/physmap.h>
21 #include <linux/input.h>
22 #include <linux/gpio_keys.h>
23 #include <linux/gpio.h>
24 #include <linux/mfd/da903x.h>
25 #include <linux/regulator/machine.h>
26 #include <linux/spi/spi.h>
27 #include <linux/spi/tdo24m.h>
28 #include <linux/spi/libertas_spi.h>
29 #include <linux/power_supply.h>
30 #include <linux/apm-emulation.h>
32 #include <media/soc_camera.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
37 #include <mach/pxa27x.h>
38 #include <mach/pxa27x-udc.h>
39 #include <mach/audio.h>
40 #include <mach/pxafb.h>
41 #include <mach/ohci.h>
42 #include <mach/mmc.h>
43 #include <mach/pxa27x_keypad.h>
44 #include <mach/i2c.h>
45 #include <mach/camera.h>
46 #include <mach/pxa2xx_spi.h>
48 #include "generic.h"
49 #include "devices.h"
51 /* EM-X270 specific GPIOs */
52 #define GPIO13_MMC_CD (13)
53 #define GPIO95_MMC_WP (95)
54 #define GPIO56_NAND_RB (56)
56 /* eXeda specific GPIOs */
57 #define GPIO114_MMC_CD (114)
58 #define GPIO20_NAND_RB (20)
59 #define GPIO38_SD_PWEN (38)
61 /* common GPIOs */
62 #define GPIO11_NAND_CS (11)
63 #define GPIO93_CAM_RESET (93)
64 #define GPIO41_ETHIRQ (41)
65 #define EM_X270_ETHIRQ IRQ_GPIO(GPIO41_ETHIRQ)
66 #define GPIO115_WLAN_PWEN (115)
67 #define GPIO19_WLAN_STRAP (19)
69 static int mmc_cd;
70 static int nand_rb;
71 static int dm9000_flags;
73 static unsigned long common_pin_config[] = {
74 /* AC'97 */
75 GPIO28_AC97_BITCLK,
76 GPIO29_AC97_SDATA_IN_0,
77 GPIO30_AC97_SDATA_OUT,
78 GPIO31_AC97_SYNC,
79 GPIO98_AC97_SYSCLK,
80 GPIO113_AC97_nRESET,
82 /* BTUART */
83 GPIO42_BTUART_RXD,
84 GPIO43_BTUART_TXD,
85 GPIO44_BTUART_CTS,
86 GPIO45_BTUART_RTS,
88 /* STUART */
89 GPIO46_STUART_RXD,
90 GPIO47_STUART_TXD,
92 /* MCI controller */
93 GPIO32_MMC_CLK,
94 GPIO112_MMC_CMD,
95 GPIO92_MMC_DAT_0,
96 GPIO109_MMC_DAT_1,
97 GPIO110_MMC_DAT_2,
98 GPIO111_MMC_DAT_3,
100 /* LCD */
101 GPIO58_LCD_LDD_0,
102 GPIO59_LCD_LDD_1,
103 GPIO60_LCD_LDD_2,
104 GPIO61_LCD_LDD_3,
105 GPIO62_LCD_LDD_4,
106 GPIO63_LCD_LDD_5,
107 GPIO64_LCD_LDD_6,
108 GPIO65_LCD_LDD_7,
109 GPIO66_LCD_LDD_8,
110 GPIO67_LCD_LDD_9,
111 GPIO68_LCD_LDD_10,
112 GPIO69_LCD_LDD_11,
113 GPIO70_LCD_LDD_12,
114 GPIO71_LCD_LDD_13,
115 GPIO72_LCD_LDD_14,
116 GPIO73_LCD_LDD_15,
117 GPIO74_LCD_FCLK,
118 GPIO75_LCD_LCLK,
119 GPIO76_LCD_PCLK,
120 GPIO77_LCD_BIAS,
122 /* QCI */
123 GPIO84_CIF_FV,
124 GPIO25_CIF_LV,
125 GPIO53_CIF_MCLK,
126 GPIO54_CIF_PCLK,
127 GPIO81_CIF_DD_0,
128 GPIO55_CIF_DD_1,
129 GPIO51_CIF_DD_2,
130 GPIO50_CIF_DD_3,
131 GPIO52_CIF_DD_4,
132 GPIO48_CIF_DD_5,
133 GPIO17_CIF_DD_6,
134 GPIO12_CIF_DD_7,
136 /* I2C */
137 GPIO117_I2C_SCL,
138 GPIO118_I2C_SDA,
140 /* Keypad */
141 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
142 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
143 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
144 GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
145 GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
146 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
147 GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
148 GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
149 GPIO103_KP_MKOUT_0,
150 GPIO104_KP_MKOUT_1,
151 GPIO105_KP_MKOUT_2,
152 GPIO106_KP_MKOUT_3,
153 GPIO107_KP_MKOUT_4,
154 GPIO108_KP_MKOUT_5,
155 GPIO96_KP_MKOUT_6,
156 GPIO22_KP_MKOUT_7,
158 /* SSP1 */
159 GPIO26_SSP1_RXD,
160 GPIO23_SSP1_SCLK,
161 GPIO24_SSP1_SFRM,
162 GPIO57_SSP1_TXD,
164 /* SSP2 */
165 GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
166 GPIO14_GPIO,
167 GPIO89_SSP2_TXD,
168 GPIO88_SSP2_RXD,
170 /* SDRAM and local bus */
171 GPIO15_nCS_1,
172 GPIO78_nCS_2,
173 GPIO79_nCS_3,
174 GPIO80_nCS_4,
175 GPIO49_nPWE,
176 GPIO18_RDY,
178 /* GPIO */
179 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* sleep/resume button */
181 /* power controls */
182 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
183 GPIO93_GPIO | MFP_LPM_DRIVE_LOW, /* Camera reset */
184 GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
186 /* NAND controls */
187 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
189 /* interrupts */
190 GPIO41_GPIO, /* DM9000 interrupt */
193 static unsigned long em_x270_pin_config[] = {
194 GPIO13_GPIO, /* MMC card detect */
195 GPIO56_GPIO, /* NAND Ready/Busy */
196 GPIO95_GPIO, /* MMC Write protect */
199 static unsigned long exeda_pin_config[] = {
200 GPIO20_GPIO, /* NAND Ready/Busy */
201 GPIO38_GPIO | MFP_LPM_DRIVE_LOW, /* SD slot power */
202 GPIO114_GPIO, /* MMC card detect */
205 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
206 static struct resource em_x270_dm9000_resource[] = {
207 [0] = {
208 .start = PXA_CS2_PHYS,
209 .end = PXA_CS2_PHYS + 3,
210 .flags = IORESOURCE_MEM,
212 [1] = {
213 .start = PXA_CS2_PHYS + 8,
214 .end = PXA_CS2_PHYS + 8 + 0x3f,
215 .flags = IORESOURCE_MEM,
217 [2] = {
218 .start = EM_X270_ETHIRQ,
219 .end = EM_X270_ETHIRQ,
220 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
224 static struct dm9000_plat_data em_x270_dm9000_platdata = {
225 .flags = DM9000_PLATF_NO_EEPROM,
228 static struct platform_device em_x270_dm9000 = {
229 .name = "dm9000",
230 .id = 0,
231 .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
232 .resource = em_x270_dm9000_resource,
233 .dev = {
234 .platform_data = &em_x270_dm9000_platdata,
238 static void __init em_x270_init_dm9000(void)
240 em_x270_dm9000_platdata.flags |= dm9000_flags;
241 platform_device_register(&em_x270_dm9000);
243 #else
244 static inline void em_x270_init_dm9000(void) {}
245 #endif
247 /* V3020 RTC */
248 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
249 static struct resource em_x270_v3020_resource[] = {
250 [0] = {
251 .start = PXA_CS4_PHYS,
252 .end = PXA_CS4_PHYS + 3,
253 .flags = IORESOURCE_MEM,
257 static struct v3020_platform_data em_x270_v3020_platdata = {
258 .leftshift = 0,
261 static struct platform_device em_x270_rtc = {
262 .name = "v3020",
263 .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
264 .resource = em_x270_v3020_resource,
265 .id = -1,
266 .dev = {
267 .platform_data = &em_x270_v3020_platdata,
271 static void __init em_x270_init_rtc(void)
273 platform_device_register(&em_x270_rtc);
275 #else
276 static inline void em_x270_init_rtc(void) {}
277 #endif
279 /* NAND flash */
280 #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
281 static inline void nand_cs_on(void)
283 gpio_set_value(GPIO11_NAND_CS, 0);
286 static void nand_cs_off(void)
288 dsb();
290 gpio_set_value(GPIO11_NAND_CS, 1);
293 /* hardware specific access to control-lines */
294 static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
295 unsigned int ctrl)
297 struct nand_chip *this = mtd->priv;
298 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
300 dsb();
302 if (ctrl & NAND_CTRL_CHANGE) {
303 if (ctrl & NAND_ALE)
304 nandaddr |= (1 << 3);
305 else
306 nandaddr &= ~(1 << 3);
307 if (ctrl & NAND_CLE)
308 nandaddr |= (1 << 2);
309 else
310 nandaddr &= ~(1 << 2);
311 if (ctrl & NAND_NCE)
312 nand_cs_on();
313 else
314 nand_cs_off();
317 dsb();
318 this->IO_ADDR_W = (void __iomem *)nandaddr;
319 if (dat != NAND_CMD_NONE)
320 writel(dat, this->IO_ADDR_W);
322 dsb();
325 /* read device ready pin */
326 static int em_x270_nand_device_ready(struct mtd_info *mtd)
328 dsb();
330 return gpio_get_value(nand_rb);
333 static struct mtd_partition em_x270_partition_info[] = {
334 [0] = {
335 .name = "em_x270-0",
336 .offset = 0,
337 .size = SZ_4M,
339 [1] = {
340 .name = "em_x270-1",
341 .offset = MTDPART_OFS_APPEND,
342 .size = MTDPART_SIZ_FULL
346 static const char *em_x270_part_probes[] = { "cmdlinepart", NULL };
348 struct platform_nand_data em_x270_nand_platdata = {
349 .chip = {
350 .nr_chips = 1,
351 .chip_offset = 0,
352 .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
353 .partitions = em_x270_partition_info,
354 .chip_delay = 20,
355 .part_probe_types = em_x270_part_probes,
357 .ctrl = {
358 .hwcontrol = 0,
359 .dev_ready = em_x270_nand_device_ready,
360 .select_chip = 0,
361 .cmd_ctrl = em_x270_nand_cmd_ctl,
365 static struct resource em_x270_nand_resource[] = {
366 [0] = {
367 .start = PXA_CS1_PHYS,
368 .end = PXA_CS1_PHYS + 12,
369 .flags = IORESOURCE_MEM,
373 static struct platform_device em_x270_nand = {
374 .name = "gen_nand",
375 .num_resources = ARRAY_SIZE(em_x270_nand_resource),
376 .resource = em_x270_nand_resource,
377 .id = -1,
378 .dev = {
379 .platform_data = &em_x270_nand_platdata,
383 static void __init em_x270_init_nand(void)
385 int err;
387 err = gpio_request(GPIO11_NAND_CS, "NAND CS");
388 if (err) {
389 pr_warning("EM-X270: failed to request NAND CS gpio\n");
390 return;
393 gpio_direction_output(GPIO11_NAND_CS, 1);
395 err = gpio_request(nand_rb, "NAND R/B");
396 if (err) {
397 pr_warning("EM-X270: failed to request NAND R/B gpio\n");
398 gpio_free(GPIO11_NAND_CS);
399 return;
402 gpio_direction_input(nand_rb);
404 platform_device_register(&em_x270_nand);
406 #else
407 static inline void em_x270_init_nand(void) {}
408 #endif
410 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
411 static struct mtd_partition em_x270_nor_parts[] = {
413 .name = "Bootloader",
414 .offset = 0x00000000,
415 .size = 0x00050000,
416 .mask_flags = MTD_WRITEABLE /* force read-only */
417 }, {
418 .name = "Environment",
419 .offset = 0x00050000,
420 .size = 0x00010000,
421 }, {
422 .name = "Reserved",
423 .offset = 0x00060000,
424 .size = 0x00050000,
425 .mask_flags = MTD_WRITEABLE /* force read-only */
426 }, {
427 .name = "Splashscreen",
428 .offset = 0x000b0000,
429 .size = 0x00050000,
433 static struct physmap_flash_data em_x270_nor_data[] = {
434 [0] = {
435 .width = 2,
436 .parts = em_x270_nor_parts,
437 .nr_parts = ARRAY_SIZE(em_x270_nor_parts),
441 static struct resource em_x270_nor_flash_resource = {
442 .start = PXA_CS0_PHYS,
443 .end = PXA_CS0_PHYS + SZ_1M - 1,
444 .flags = IORESOURCE_MEM,
447 static struct platform_device em_x270_physmap_flash = {
448 .name = "physmap-flash",
449 .id = 0,
450 .num_resources = 1,
451 .resource = &em_x270_nor_flash_resource,
452 .dev = {
453 .platform_data = &em_x270_nor_data,
457 static void __init em_x270_init_nor(void)
459 platform_device_register(&em_x270_physmap_flash);
461 #else
462 static inline void em_x270_init_nor(void) {}
463 #endif
465 /* PXA27x OHCI controller setup */
466 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
467 static int em_x270_ohci_init(struct device *dev)
469 /* enable port 2 transiever */
470 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
472 return 0;
475 static struct pxaohci_platform_data em_x270_ohci_platform_data = {
476 .port_mode = PMM_PERPORT_MODE,
477 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
478 .init = em_x270_ohci_init,
481 static void __init em_x270_init_ohci(void)
483 pxa_set_ohci_info(&em_x270_ohci_platform_data);
485 #else
486 static inline void em_x270_init_ohci(void) {}
487 #endif
489 /* MCI controller setup */
490 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
491 static struct regulator *em_x270_sdio_ldo;
493 static int em_x270_mci_init(struct device *dev,
494 irq_handler_t em_x270_detect_int,
495 void *data)
497 int err;
499 em_x270_sdio_ldo = regulator_get(dev, "vcc sdio");
500 if (IS_ERR(em_x270_sdio_ldo)) {
501 dev_err(dev, "can't request SDIO power supply: %ld\n",
502 PTR_ERR(em_x270_sdio_ldo));
503 return PTR_ERR(em_x270_sdio_ldo);
506 err = request_irq(gpio_to_irq(mmc_cd), em_x270_detect_int,
507 IRQF_DISABLED | IRQF_TRIGGER_RISING |
508 IRQF_TRIGGER_FALLING,
509 "MMC card detect", data);
510 if (err) {
511 dev_err(dev, "can't request MMC card detect IRQ: %d\n", err);
512 goto err_irq;
515 if (machine_is_em_x270()) {
516 err = gpio_request(GPIO95_MMC_WP, "MMC WP");
517 if (err) {
518 dev_err(dev, "can't request MMC write protect: %d\n",
519 err);
520 goto err_gpio_wp;
522 gpio_direction_input(GPIO95_MMC_WP);
523 } else {
524 err = gpio_request(GPIO38_SD_PWEN, "sdio power");
525 if (err) {
526 dev_err(dev, "can't request MMC power control : %d\n",
527 err);
528 goto err_gpio_wp;
530 gpio_direction_output(GPIO38_SD_PWEN, 1);
533 return 0;
535 err_gpio_wp:
536 free_irq(gpio_to_irq(mmc_cd), data);
537 err_irq:
538 regulator_put(em_x270_sdio_ldo);
540 return err;
543 static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
545 struct pxamci_platform_data* p_d = dev->platform_data;
547 if ((1 << vdd) & p_d->ocr_mask) {
548 int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;
550 regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
551 regulator_enable(em_x270_sdio_ldo);
552 } else {
553 regulator_disable(em_x270_sdio_ldo);
557 static void em_x270_mci_exit(struct device *dev, void *data)
559 free_irq(gpio_to_irq(mmc_cd), data);
560 regulator_put(em_x270_sdio_ldo);
562 if (machine_is_em_x270())
563 gpio_free(GPIO95_MMC_WP);
564 else
565 gpio_free(GPIO38_SD_PWEN);
568 static int em_x270_mci_get_ro(struct device *dev)
570 return gpio_get_value(GPIO95_MMC_WP);
573 static struct pxamci_platform_data em_x270_mci_platform_data = {
574 .ocr_mask = MMC_VDD_20_21|MMC_VDD_21_22|MMC_VDD_22_23|
575 MMC_VDD_24_25|MMC_VDD_25_26|MMC_VDD_26_27|
576 MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
577 MMC_VDD_30_31|MMC_VDD_31_32,
578 .init = em_x270_mci_init,
579 .setpower = em_x270_mci_setpower,
580 .exit = em_x270_mci_exit,
583 static void __init em_x270_init_mmc(void)
585 if (machine_is_em_x270())
586 em_x270_mci_platform_data.get_ro = em_x270_mci_get_ro;
588 em_x270_mci_platform_data.detect_delay = msecs_to_jiffies(250);
589 pxa_set_mci_info(&em_x270_mci_platform_data);
591 #else
592 static inline void em_x270_init_mmc(void) {}
593 #endif
595 /* LCD */
596 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
597 static struct pxafb_mode_info em_x270_lcd_modes[] = {
598 [0] = {
599 .pixclock = 38250,
600 .bpp = 16,
601 .xres = 480,
602 .yres = 640,
603 .hsync_len = 8,
604 .vsync_len = 2,
605 .left_margin = 8,
606 .upper_margin = 2,
607 .right_margin = 24,
608 .lower_margin = 4,
609 .sync = 0,
611 [1] = {
612 .pixclock = 153800,
613 .bpp = 16,
614 .xres = 240,
615 .yres = 320,
616 .hsync_len = 8,
617 .vsync_len = 2,
618 .left_margin = 8,
619 .upper_margin = 2,
620 .right_margin = 88,
621 .lower_margin = 2,
622 .sync = 0,
626 static struct pxafb_mach_info em_x270_lcd = {
627 .modes = em_x270_lcd_modes,
628 .num_modes = 2,
629 .lcd_conn = LCD_COLOR_TFT_16BPP,
632 static void __init em_x270_init_lcd(void)
634 set_pxa_fb_info(&em_x270_lcd);
636 #else
637 static inline void em_x270_init_lcd(void) {}
638 #endif
640 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
641 static struct pxa2xx_spi_master em_x270_spi_info = {
642 .num_chipselect = 1,
645 static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
646 .rx_threshold = 1,
647 .tx_threshold = 1,
648 .gpio_cs = -1,
651 static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
652 .model = TDO35S,
655 static struct pxa2xx_spi_master em_x270_spi_2_info = {
656 .num_chipselect = 1,
657 .enable_dma = 1,
660 static struct pxa2xx_spi_chip em_x270_libertas_chip = {
661 .rx_threshold = 1,
662 .tx_threshold = 1,
663 .timeout = 1000,
666 static unsigned long em_x270_libertas_pin_config[] = {
667 /* SSP2 */
668 GPIO19_SSP2_SCLK,
669 GPIO14_GPIO,
670 GPIO89_SSP2_TXD,
671 GPIO88_SSP2_RXD,
674 static int em_x270_libertas_setup(struct spi_device *spi)
676 int err = gpio_request(GPIO115_WLAN_PWEN, "WLAN PWEN");
677 if (err)
678 return err;
680 gpio_direction_output(GPIO19_WLAN_STRAP, 1);
681 mdelay(100);
683 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_libertas_pin_config));
685 gpio_direction_output(GPIO115_WLAN_PWEN, 0);
686 mdelay(100);
687 gpio_set_value(GPIO115_WLAN_PWEN, 1);
688 mdelay(100);
690 spi->bits_per_word = 16;
691 spi_setup(spi);
693 return 0;
696 static int em_x270_libertas_teardown(struct spi_device *spi)
698 gpio_set_value(GPIO115_WLAN_PWEN, 0);
699 gpio_free(GPIO115_WLAN_PWEN);
701 return 0;
704 struct libertas_spi_platform_data em_x270_libertas_pdata = {
705 .use_dummy_writes = 1,
706 .gpio_cs = 14,
707 .setup = em_x270_libertas_setup,
708 .teardown = em_x270_libertas_teardown,
711 static struct spi_board_info em_x270_spi_devices[] __initdata = {
713 .modalias = "tdo24m",
714 .max_speed_hz = 1000000,
715 .bus_num = 1,
716 .chip_select = 0,
717 .controller_data = &em_x270_tdo24m_chip,
718 .platform_data = &em_x270_tdo24m_pdata,
721 .modalias = "libertas_spi",
722 .max_speed_hz = 13000000,
723 .bus_num = 2,
724 .irq = IRQ_GPIO(116),
725 .chip_select = 0,
726 .controller_data = &em_x270_libertas_chip,
727 .platform_data = &em_x270_libertas_pdata,
731 static void __init em_x270_init_spi(void)
733 pxa2xx_set_spi_info(1, &em_x270_spi_info);
734 pxa2xx_set_spi_info(2, &em_x270_spi_2_info);
735 spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
737 #else
738 static inline void em_x270_init_spi(void) {}
739 #endif
741 #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
742 static void __init em_x270_init_ac97(void)
744 pxa_set_ac97_info(NULL);
746 #else
747 static inline void em_x270_init_ac97(void) {}
748 #endif
750 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
751 static unsigned int em_x270_module_matrix_keys[] = {
752 KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
753 KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
754 KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
757 struct pxa27x_keypad_platform_data em_x270_module_keypad_info = {
758 /* code map for the matrix keys */
759 .matrix_key_rows = 3,
760 .matrix_key_cols = 3,
761 .matrix_key_map = em_x270_module_matrix_keys,
762 .matrix_key_map_size = ARRAY_SIZE(em_x270_module_matrix_keys),
765 static unsigned int em_x270_exeda_matrix_keys[] = {
766 KEY(0, 0, KEY_RIGHTSHIFT), KEY(0, 1, KEY_RIGHTCTRL),
767 KEY(0, 2, KEY_RIGHTALT), KEY(0, 3, KEY_SPACE),
768 KEY(0, 4, KEY_LEFTALT), KEY(0, 5, KEY_LEFTCTRL),
769 KEY(0, 6, KEY_ENTER), KEY(0, 7, KEY_SLASH),
771 KEY(1, 0, KEY_DOT), KEY(1, 1, KEY_M),
772 KEY(1, 2, KEY_N), KEY(1, 3, KEY_B),
773 KEY(1, 4, KEY_V), KEY(1, 5, KEY_C),
774 KEY(1, 6, KEY_X), KEY(1, 7, KEY_Z),
776 KEY(2, 0, KEY_LEFTSHIFT), KEY(2, 1, KEY_SEMICOLON),
777 KEY(2, 2, KEY_L), KEY(2, 3, KEY_K),
778 KEY(2, 4, KEY_J), KEY(2, 5, KEY_H),
779 KEY(2, 6, KEY_G), KEY(2, 7, KEY_F),
781 KEY(3, 0, KEY_D), KEY(3, 1, KEY_S),
782 KEY(3, 2, KEY_A), KEY(3, 3, KEY_TAB),
783 KEY(3, 4, KEY_BACKSPACE), KEY(3, 5, KEY_P),
784 KEY(3, 6, KEY_O), KEY(3, 7, KEY_I),
786 KEY(4, 0, KEY_U), KEY(4, 1, KEY_Y),
787 KEY(4, 2, KEY_T), KEY(4, 3, KEY_R),
788 KEY(4, 4, KEY_E), KEY(4, 5, KEY_W),
789 KEY(4, 6, KEY_Q), KEY(4, 7, KEY_MINUS),
791 KEY(5, 0, KEY_0), KEY(5, 1, KEY_9),
792 KEY(5, 2, KEY_8), KEY(5, 3, KEY_7),
793 KEY(5, 4, KEY_6), KEY(5, 5, KEY_5),
794 KEY(5, 6, KEY_4), KEY(5, 7, KEY_3),
796 KEY(6, 0, KEY_2), KEY(6, 1, KEY_1),
797 KEY(6, 2, KEY_ENTER), KEY(6, 3, KEY_END),
798 KEY(6, 4, KEY_DOWN), KEY(6, 5, KEY_UP),
799 KEY(6, 6, KEY_MENU), KEY(6, 7, KEY_F1),
801 KEY(7, 0, KEY_LEFT), KEY(7, 1, KEY_RIGHT),
802 KEY(7, 2, KEY_BACK), KEY(7, 3, KEY_HOME),
803 KEY(7, 4, 0), KEY(7, 5, 0),
804 KEY(7, 6, 0), KEY(7, 7, 0),
807 struct pxa27x_keypad_platform_data em_x270_exeda_keypad_info = {
808 /* code map for the matrix keys */
809 .matrix_key_rows = 8,
810 .matrix_key_cols = 8,
811 .matrix_key_map = em_x270_exeda_matrix_keys,
812 .matrix_key_map_size = ARRAY_SIZE(em_x270_exeda_matrix_keys),
815 static void __init em_x270_init_keypad(void)
817 if (machine_is_em_x270())
818 pxa_set_keypad_info(&em_x270_module_keypad_info);
819 else
820 pxa_set_keypad_info(&em_x270_exeda_keypad_info);
822 #else
823 static inline void em_x270_init_keypad(void) {}
824 #endif
826 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
827 static struct gpio_keys_button gpio_keys_button[] = {
828 [0] = {
829 .desc = "sleep/wakeup",
830 .code = KEY_SUSPEND,
831 .type = EV_PWR,
832 .gpio = 1,
833 .wakeup = 1,
837 static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
838 .buttons = gpio_keys_button,
839 .nbuttons = 1,
842 static struct platform_device em_x270_gpio_keys = {
843 .name = "gpio-keys",
844 .id = -1,
845 .dev = {
846 .platform_data = &em_x270_gpio_keys_data,
850 static void __init em_x270_init_gpio_keys(void)
852 platform_device_register(&em_x270_gpio_keys);
854 #else
855 static inline void em_x270_init_gpio_keys(void) {}
856 #endif
858 /* Quick Capture Interface and sensor setup */
859 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
860 static struct regulator *em_x270_camera_ldo;
862 static int em_x270_sensor_init(struct device *dev)
864 int ret;
866 ret = gpio_request(GPIO93_CAM_RESET, "camera reset");
867 if (ret)
868 return ret;
870 gpio_direction_output(GPIO93_CAM_RESET, 0);
872 em_x270_camera_ldo = regulator_get(NULL, "vcc cam");
873 if (em_x270_camera_ldo == NULL) {
874 gpio_free(GPIO93_CAM_RESET);
875 return -ENODEV;
878 ret = regulator_enable(em_x270_camera_ldo);
879 if (ret) {
880 regulator_put(em_x270_camera_ldo);
881 gpio_free(GPIO93_CAM_RESET);
882 return ret;
885 gpio_set_value(GPIO93_CAM_RESET, 1);
887 return 0;
890 struct pxacamera_platform_data em_x270_camera_platform_data = {
891 .init = em_x270_sensor_init,
892 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
893 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
894 .mclk_10khz = 2600,
897 static int em_x270_sensor_power(struct device *dev, int on)
899 int ret;
900 int is_on = regulator_is_enabled(em_x270_camera_ldo);
902 if (on == is_on)
903 return 0;
905 gpio_set_value(GPIO93_CAM_RESET, !on);
907 if (on)
908 ret = regulator_enable(em_x270_camera_ldo);
909 else
910 ret = regulator_disable(em_x270_camera_ldo);
912 if (ret)
913 return ret;
915 gpio_set_value(GPIO93_CAM_RESET, on);
917 return 0;
920 static struct soc_camera_link iclink = {
921 .bus_id = 0,
922 .power = em_x270_sensor_power,
925 static struct i2c_board_info em_x270_i2c_cam_info[] = {
927 I2C_BOARD_INFO("mt9m111", 0x48),
928 .platform_data = &iclink,
932 static struct i2c_pxa_platform_data em_x270_i2c_info = {
933 .fast_mode = 1,
936 static void __init em_x270_init_camera(void)
938 pxa_set_i2c_info(&em_x270_i2c_info);
939 i2c_register_board_info(0, ARRAY_AND_SIZE(em_x270_i2c_cam_info));
940 pxa_set_camera_info(&em_x270_camera_platform_data);
942 #else
943 static inline void em_x270_init_camera(void) {}
944 #endif
946 /* DA9030 related initializations */
947 #define REGULATOR_CONSUMER(_name, _dev, _supply) \
948 static struct regulator_consumer_supply _name##_consumers[] = { \
950 .dev = _dev, \
951 .supply = _supply, \
952 }, \
955 REGULATOR_CONSUMER(ldo3, NULL, "vcc gps");
956 REGULATOR_CONSUMER(ldo5, NULL, "vcc cam");
957 REGULATOR_CONSUMER(ldo10, &pxa_device_mci.dev, "vcc sdio");
958 REGULATOR_CONSUMER(ldo12, NULL, "vcc usb");
959 REGULATOR_CONSUMER(ldo19, NULL, "vcc gprs");
961 #define REGULATOR_INIT(_ldo, _min_uV, _max_uV, _ops_mask) \
962 static struct regulator_init_data _ldo##_data = { \
963 .constraints = { \
964 .min_uV = _min_uV, \
965 .max_uV = _max_uV, \
966 .state_mem = { \
967 .enabled = 0, \
968 }, \
969 .valid_ops_mask = _ops_mask, \
970 }, \
971 .num_consumer_supplies = ARRAY_SIZE(_ldo##_consumers), \
972 .consumer_supplies = _ldo##_consumers, \
975 REGULATOR_INIT(ldo3, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
976 REGULATOR_INIT(ldo5, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
977 REGULATOR_INIT(ldo10, 2000000, 3200000,
978 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE);
979 REGULATOR_INIT(ldo12, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
980 REGULATOR_INIT(ldo19, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
982 struct led_info em_x270_led_info = {
983 .name = "em-x270:orange",
984 .default_trigger = "battery-charging-or-full",
987 struct power_supply_info em_x270_psy_info = {
988 .name = "LP555597P6H-FPS",
989 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
990 .voltage_max_design = 4200000,
991 .voltage_min_design = 3000000,
992 .use_for_apm = 1,
995 static void em_x270_battery_low(void)
997 apm_queue_event(APM_LOW_BATTERY);
1000 static void em_x270_battery_critical(void)
1002 apm_queue_event(APM_CRITICAL_SUSPEND);
1005 struct da9030_battery_info em_x270_batterty_info = {
1006 .battery_info = &em_x270_psy_info,
1008 .charge_milliamp = 1000,
1009 .charge_millivolt = 4200,
1011 .vbat_low = 3600,
1012 .vbat_crit = 3400,
1013 .vbat_charge_start = 4100,
1014 .vbat_charge_stop = 4200,
1015 .vbat_charge_restart = 4000,
1017 .vcharge_min = 3200,
1018 .vcharge_max = 5500,
1020 .tbat_low = 197,
1021 .tbat_high = 78,
1022 .tbat_restart = 100,
1024 .batmon_interval = 0,
1026 .battery_low = em_x270_battery_low,
1027 .battery_critical = em_x270_battery_critical,
1030 #define DA9030_SUBDEV(_name, _id, _pdata) \
1032 .name = "da903x-" #_name, \
1033 .id = DA9030_ID_##_id, \
1034 .platform_data = _pdata, \
1037 #define DA9030_LDO(num) DA9030_SUBDEV(regulator, LDO##num, &ldo##num##_data)
1039 struct da903x_subdev_info em_x270_da9030_subdevs[] = {
1040 DA9030_LDO(3),
1041 DA9030_LDO(5),
1042 DA9030_LDO(10),
1043 DA9030_LDO(12),
1044 DA9030_LDO(19),
1046 DA9030_SUBDEV(led, LED_PC, &em_x270_led_info),
1047 DA9030_SUBDEV(backlight, WLED, &em_x270_led_info),
1048 DA9030_SUBDEV(battery, BAT, &em_x270_batterty_info),
1051 static struct da903x_platform_data em_x270_da9030_info = {
1052 .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
1053 .subdevs = em_x270_da9030_subdevs,
1056 static struct i2c_board_info em_x270_i2c_pmic_info = {
1057 I2C_BOARD_INFO("da9030", 0x49),
1058 .irq = IRQ_GPIO(0),
1059 .platform_data = &em_x270_da9030_info,
1062 static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
1063 .use_pio = 1,
1066 static void __init em_x270_init_da9030(void)
1068 pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
1069 i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
1072 static void __init em_x270_module_init(void)
1074 pr_info("%s\n", __func__);
1075 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
1077 mmc_cd = GPIO13_MMC_CD;
1078 nand_rb = GPIO56_NAND_RB;
1079 dm9000_flags = DM9000_PLATF_32BITONLY;
1082 static void __init em_x270_exeda_init(void)
1084 pr_info("%s\n", __func__);
1085 pxa2xx_mfp_config(ARRAY_AND_SIZE(exeda_pin_config));
1087 mmc_cd = GPIO114_MMC_CD;
1088 nand_rb = GPIO20_NAND_RB;
1089 dm9000_flags = DM9000_PLATF_16BITONLY;
1092 static void __init em_x270_init(void)
1094 pxa2xx_mfp_config(ARRAY_AND_SIZE(common_pin_config));
1096 if (machine_is_em_x270())
1097 em_x270_module_init();
1098 else if (machine_is_exeda())
1099 em_x270_exeda_init();
1100 else
1101 panic("Unsupported machine: %d\n", machine_arch_type);
1103 em_x270_init_da9030();
1104 em_x270_init_dm9000();
1105 em_x270_init_rtc();
1106 em_x270_init_nand();
1107 em_x270_init_nor();
1108 em_x270_init_lcd();
1109 em_x270_init_mmc();
1110 em_x270_init_ohci();
1111 em_x270_init_keypad();
1112 em_x270_init_gpio_keys();
1113 em_x270_init_ac97();
1114 em_x270_init_camera();
1115 em_x270_init_spi();
1118 MACHINE_START(EM_X270, "Compulab EM-X270")
1119 .boot_params = 0xa0000100,
1120 .phys_io = 0x40000000,
1121 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1122 .map_io = pxa_map_io,
1123 .init_irq = pxa27x_init_irq,
1124 .timer = &pxa_timer,
1125 .init_machine = em_x270_init,
1126 MACHINE_END
1128 MACHINE_START(EXEDA, "Compulab eXeda")
1129 .boot_params = 0xa0000100,
1130 .phys_io = 0x40000000,
1131 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1132 .map_io = pxa_map_io,
1133 .init_irq = pxa27x_init_irq,
1134 .timer = &pxa_timer,
1135 .init_machine = em_x270_init,
1136 MACHINE_END