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>
31 #include <linux/i2c.h>
32 #include <linux/i2c/pca953x.h>
33 #include <linux/regulator/userspace-consumer.h>
35 #include <media/soc_camera.h>
37 #include <asm/mach-types.h>
38 #include <asm/mach/arch.h>
40 #include <mach/pxa27x.h>
41 #include <mach/pxa27x-udc.h>
42 #include <mach/audio.h>
43 #include <mach/pxafb.h>
44 #include <mach/ohci.h>
46 #include <mach/pxa27x_keypad.h>
48 #include <mach/camera.h>
49 #include <mach/pxa2xx_spi.h>
54 /* EM-X270 specific GPIOs */
55 #define GPIO13_MMC_CD (13)
56 #define GPIO95_MMC_WP (95)
57 #define GPIO56_NAND_RB (56)
58 #define GPIO93_CAM_RESET (93)
59 #define GPIO16_USB_HUB_RESET (16)
61 /* eXeda specific GPIOs */
62 #define GPIO114_MMC_CD (114)
63 #define GPIO20_NAND_RB (20)
64 #define GPIO38_SD_PWEN (38)
65 #define GPIO37_WLAN_RST (37)
66 #define GPIO95_TOUCHPAD_INT (95)
67 #define GPIO130_CAM_RESET (130)
68 #define GPIO10_USB_HUB_RESET (10)
71 #define GPIO11_NAND_CS (11)
72 #define GPIO41_ETHIRQ (41)
73 #define EM_X270_ETHIRQ IRQ_GPIO(GPIO41_ETHIRQ)
74 #define GPIO115_WLAN_PWEN (115)
75 #define GPIO19_WLAN_STRAP (19)
76 #define GPIO9_USB_VBUS_EN (9)
80 static int dm9000_flags;
82 static int usb_hub_reset;
84 static unsigned long common_pin_config[] = {
87 GPIO29_AC97_SDATA_IN_0,
88 GPIO30_AC97_SDATA_OUT,
152 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
153 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
154 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
155 GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
156 GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
157 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
158 GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
159 GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
176 GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
181 /* SDRAM and local bus */
190 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* sleep/resume button */
193 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
194 GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
197 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
200 GPIO41_GPIO, /* DM9000 interrupt */
203 static unsigned long em_x270_pin_config[] = {
204 GPIO13_GPIO, /* MMC card detect */
205 GPIO16_GPIO, /* USB hub reset */
206 GPIO56_GPIO, /* NAND Ready/Busy */
207 GPIO93_GPIO | MFP_LPM_DRIVE_LOW, /* Camera reset */
208 GPIO95_GPIO, /* MMC Write protect */
211 static unsigned long exeda_pin_config[] = {
212 GPIO10_GPIO, /* USB hub reset */
213 GPIO20_GPIO, /* NAND Ready/Busy */
214 GPIO38_GPIO | MFP_LPM_DRIVE_LOW, /* SD slot power */
215 GPIO95_GPIO, /* touchpad IRQ */
216 GPIO114_GPIO, /* MMC card detect */
219 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
220 static struct resource em_x270_dm9000_resource[] = {
222 .start = PXA_CS2_PHYS,
223 .end = PXA_CS2_PHYS + 3,
224 .flags = IORESOURCE_MEM,
227 .start = PXA_CS2_PHYS + 8,
228 .end = PXA_CS2_PHYS + 8 + 0x3f,
229 .flags = IORESOURCE_MEM,
232 .start = EM_X270_ETHIRQ,
233 .end = EM_X270_ETHIRQ,
234 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
238 static struct dm9000_plat_data em_x270_dm9000_platdata = {
239 .flags = DM9000_PLATF_NO_EEPROM,
242 static struct platform_device em_x270_dm9000 = {
245 .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
246 .resource = em_x270_dm9000_resource,
248 .platform_data = &em_x270_dm9000_platdata,
252 static void __init em_x270_init_dm9000(void)
254 em_x270_dm9000_platdata.flags |= dm9000_flags;
255 platform_device_register(&em_x270_dm9000);
258 static inline void em_x270_init_dm9000(void) {}
262 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
263 static struct resource em_x270_v3020_resource[] = {
265 .start = PXA_CS4_PHYS,
266 .end = PXA_CS4_PHYS + 3,
267 .flags = IORESOURCE_MEM,
271 static struct v3020_platform_data em_x270_v3020_platdata = {
275 static struct platform_device em_x270_rtc = {
277 .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
278 .resource = em_x270_v3020_resource,
281 .platform_data = &em_x270_v3020_platdata,
285 static void __init em_x270_init_rtc(void)
287 platform_device_register(&em_x270_rtc);
290 static inline void em_x270_init_rtc(void) {}
294 #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
295 static inline void nand_cs_on(void)
297 gpio_set_value(GPIO11_NAND_CS, 0);
300 static void nand_cs_off(void)
304 gpio_set_value(GPIO11_NAND_CS, 1);
307 /* hardware specific access to control-lines */
308 static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
311 struct nand_chip *this = mtd->priv;
312 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
316 if (ctrl & NAND_CTRL_CHANGE) {
318 nandaddr |= (1 << 3);
320 nandaddr &= ~(1 << 3);
322 nandaddr |= (1 << 2);
324 nandaddr &= ~(1 << 2);
332 this->IO_ADDR_W = (void __iomem *)nandaddr;
333 if (dat != NAND_CMD_NONE)
334 writel(dat, this->IO_ADDR_W);
339 /* read device ready pin */
340 static int em_x270_nand_device_ready(struct mtd_info *mtd)
344 return gpio_get_value(nand_rb);
347 static struct mtd_partition em_x270_partition_info[] = {
355 .offset = MTDPART_OFS_APPEND,
356 .size = MTDPART_SIZ_FULL
360 static const char *em_x270_part_probes[] = { "cmdlinepart", NULL };
362 struct platform_nand_data em_x270_nand_platdata = {
366 .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
367 .partitions = em_x270_partition_info,
369 .part_probe_types = em_x270_part_probes,
373 .dev_ready = em_x270_nand_device_ready,
375 .cmd_ctrl = em_x270_nand_cmd_ctl,
379 static struct resource em_x270_nand_resource[] = {
381 .start = PXA_CS1_PHYS,
382 .end = PXA_CS1_PHYS + 12,
383 .flags = IORESOURCE_MEM,
387 static struct platform_device em_x270_nand = {
389 .num_resources = ARRAY_SIZE(em_x270_nand_resource),
390 .resource = em_x270_nand_resource,
393 .platform_data = &em_x270_nand_platdata,
397 static void __init em_x270_init_nand(void)
401 err = gpio_request(GPIO11_NAND_CS, "NAND CS");
403 pr_warning("EM-X270: failed to request NAND CS gpio\n");
407 gpio_direction_output(GPIO11_NAND_CS, 1);
409 err = gpio_request(nand_rb, "NAND R/B");
411 pr_warning("EM-X270: failed to request NAND R/B gpio\n");
412 gpio_free(GPIO11_NAND_CS);
416 gpio_direction_input(nand_rb);
418 platform_device_register(&em_x270_nand);
421 static inline void em_x270_init_nand(void) {}
424 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
425 static struct mtd_partition em_x270_nor_parts[] = {
427 .name = "Bootloader",
428 .offset = 0x00000000,
430 .mask_flags = MTD_WRITEABLE /* force read-only */
432 .name = "Environment",
433 .offset = 0x00050000,
437 .offset = 0x00060000,
439 .mask_flags = MTD_WRITEABLE /* force read-only */
441 .name = "Splashscreen",
442 .offset = 0x000b0000,
447 static struct physmap_flash_data em_x270_nor_data[] = {
450 .parts = em_x270_nor_parts,
451 .nr_parts = ARRAY_SIZE(em_x270_nor_parts),
455 static struct resource em_x270_nor_flash_resource = {
456 .start = PXA_CS0_PHYS,
457 .end = PXA_CS0_PHYS + SZ_1M - 1,
458 .flags = IORESOURCE_MEM,
461 static struct platform_device em_x270_physmap_flash = {
462 .name = "physmap-flash",
465 .resource = &em_x270_nor_flash_resource,
467 .platform_data = &em_x270_nor_data,
471 static void __init em_x270_init_nor(void)
473 platform_device_register(&em_x270_physmap_flash);
476 static inline void em_x270_init_nor(void) {}
479 /* PXA27x OHCI controller setup */
480 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
481 static struct regulator *em_x270_usb_ldo;
483 static int em_x270_usb_hub_init(void)
487 em_x270_usb_ldo = regulator_get(NULL, "vcc usb");
488 if (IS_ERR(em_x270_usb_ldo))
489 return PTR_ERR(em_x270_usb_ldo);
491 err = gpio_request(GPIO9_USB_VBUS_EN, "vbus en");
493 goto err_free_usb_ldo;
495 err = gpio_request(usb_hub_reset, "hub rst");
497 goto err_free_vbus_gpio;
499 /* USB Hub power-on and reset */
500 gpio_direction_output(usb_hub_reset, 0);
501 regulator_enable(em_x270_usb_ldo);
502 gpio_set_value(usb_hub_reset, 1);
503 gpio_set_value(usb_hub_reset, 0);
504 regulator_disable(em_x270_usb_ldo);
505 regulator_enable(em_x270_usb_ldo);
506 gpio_set_value(usb_hub_reset, 1);
509 gpio_direction_output(GPIO9_USB_VBUS_EN, 1);
514 gpio_free(GPIO9_USB_VBUS_EN);
516 regulator_put(em_x270_usb_ldo);
521 static int em_x270_ohci_init(struct device *dev)
525 /* we don't want to entirely disable USB if the HUB init failed */
526 err = em_x270_usb_hub_init();
528 pr_err("USB Hub initialization failed: %d\n", err);
530 /* enable port 2 transiever */
531 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
536 static void em_x270_ohci_exit(struct device *dev)
538 gpio_free(usb_hub_reset);
539 gpio_free(GPIO9_USB_VBUS_EN);
541 if (!IS_ERR(em_x270_usb_ldo)) {
542 if (regulator_is_enabled(em_x270_usb_ldo))
543 regulator_disable(em_x270_usb_ldo);
545 regulator_put(em_x270_usb_ldo);
549 static struct pxaohci_platform_data em_x270_ohci_platform_data = {
550 .port_mode = PMM_PERPORT_MODE,
551 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
552 .init = em_x270_ohci_init,
553 .exit = em_x270_ohci_exit,
556 static void __init em_x270_init_ohci(void)
558 pxa_set_ohci_info(&em_x270_ohci_platform_data);
561 static inline void em_x270_init_ohci(void) {}
564 /* MCI controller setup */
565 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
566 static struct regulator *em_x270_sdio_ldo;
568 static int em_x270_mci_init(struct device *dev,
569 irq_handler_t em_x270_detect_int,
574 em_x270_sdio_ldo = regulator_get(dev, "vcc sdio");
575 if (IS_ERR(em_x270_sdio_ldo)) {
576 dev_err(dev, "can't request SDIO power supply: %ld\n",
577 PTR_ERR(em_x270_sdio_ldo));
578 return PTR_ERR(em_x270_sdio_ldo);
581 err = request_irq(gpio_to_irq(mmc_cd), em_x270_detect_int,
582 IRQF_DISABLED | IRQF_TRIGGER_RISING |
583 IRQF_TRIGGER_FALLING,
584 "MMC card detect", data);
586 dev_err(dev, "can't request MMC card detect IRQ: %d\n", err);
590 if (machine_is_em_x270()) {
591 err = gpio_request(GPIO95_MMC_WP, "MMC WP");
593 dev_err(dev, "can't request MMC write protect: %d\n",
597 gpio_direction_input(GPIO95_MMC_WP);
599 err = gpio_request(GPIO38_SD_PWEN, "sdio power");
601 dev_err(dev, "can't request MMC power control : %d\n",
605 gpio_direction_output(GPIO38_SD_PWEN, 1);
611 free_irq(gpio_to_irq(mmc_cd), data);
613 regulator_put(em_x270_sdio_ldo);
618 static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
620 struct pxamci_platform_data* p_d = dev->platform_data;
622 if ((1 << vdd) & p_d->ocr_mask) {
623 int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;
625 regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
626 regulator_enable(em_x270_sdio_ldo);
628 regulator_disable(em_x270_sdio_ldo);
632 static void em_x270_mci_exit(struct device *dev, void *data)
634 free_irq(gpio_to_irq(mmc_cd), data);
635 regulator_put(em_x270_sdio_ldo);
637 if (machine_is_em_x270())
638 gpio_free(GPIO95_MMC_WP);
640 gpio_free(GPIO38_SD_PWEN);
643 static int em_x270_mci_get_ro(struct device *dev)
645 return gpio_get_value(GPIO95_MMC_WP);
648 static struct pxamci_platform_data em_x270_mci_platform_data = {
649 .ocr_mask = MMC_VDD_20_21|MMC_VDD_21_22|MMC_VDD_22_23|
650 MMC_VDD_24_25|MMC_VDD_25_26|MMC_VDD_26_27|
651 MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
652 MMC_VDD_30_31|MMC_VDD_31_32,
653 .init = em_x270_mci_init,
654 .setpower = em_x270_mci_setpower,
655 .exit = em_x270_mci_exit,
656 .gpio_card_detect = -1,
661 static void __init em_x270_init_mmc(void)
663 if (machine_is_em_x270())
664 em_x270_mci_platform_data.get_ro = em_x270_mci_get_ro;
666 em_x270_mci_platform_data.detect_delay = msecs_to_jiffies(250);
667 pxa_set_mci_info(&em_x270_mci_platform_data);
670 static inline void em_x270_init_mmc(void) {}
674 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
675 static struct pxafb_mode_info em_x270_lcd_modes[] = {
704 static struct pxafb_mach_info em_x270_lcd = {
705 .modes = em_x270_lcd_modes,
707 .lcd_conn = LCD_COLOR_TFT_16BPP,
710 static void __init em_x270_init_lcd(void)
712 set_pxa_fb_info(&em_x270_lcd);
715 static inline void em_x270_init_lcd(void) {}
718 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
719 static struct pxa2xx_spi_master em_x270_spi_info = {
723 static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
729 static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
733 static struct pxa2xx_spi_master em_x270_spi_2_info = {
738 static struct pxa2xx_spi_chip em_x270_libertas_chip = {
745 static unsigned long em_x270_libertas_pin_config[] = {
753 static int em_x270_libertas_setup(struct spi_device *spi)
755 int err = gpio_request(GPIO115_WLAN_PWEN, "WLAN PWEN");
759 err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
763 if (machine_is_exeda()) {
764 err = gpio_request(GPIO37_WLAN_RST, "WLAN RST");
768 gpio_direction_output(GPIO37_WLAN_RST, 1);
772 gpio_direction_output(GPIO19_WLAN_STRAP, 1);
775 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_libertas_pin_config));
777 gpio_direction_output(GPIO115_WLAN_PWEN, 0);
779 gpio_set_value(GPIO115_WLAN_PWEN, 1);
782 spi->bits_per_word = 16;
788 gpio_free(GPIO19_WLAN_STRAP);
790 gpio_free(GPIO115_WLAN_PWEN);
795 static int em_x270_libertas_teardown(struct spi_device *spi)
797 gpio_set_value(GPIO115_WLAN_PWEN, 0);
798 gpio_free(GPIO115_WLAN_PWEN);
799 gpio_free(GPIO19_WLAN_STRAP);
801 if (machine_is_exeda()) {
802 gpio_set_value(GPIO37_WLAN_RST, 0);
803 gpio_free(GPIO37_WLAN_RST);
809 struct libertas_spi_platform_data em_x270_libertas_pdata = {
810 .use_dummy_writes = 1,
811 .setup = em_x270_libertas_setup,
812 .teardown = em_x270_libertas_teardown,
815 static struct spi_board_info em_x270_spi_devices[] __initdata = {
817 .modalias = "tdo24m",
818 .max_speed_hz = 1000000,
821 .controller_data = &em_x270_tdo24m_chip,
822 .platform_data = &em_x270_tdo24m_pdata,
825 .modalias = "libertas_spi",
826 .max_speed_hz = 13000000,
828 .irq = IRQ_GPIO(116),
830 .controller_data = &em_x270_libertas_chip,
831 .platform_data = &em_x270_libertas_pdata,
835 static void __init em_x270_init_spi(void)
837 pxa2xx_set_spi_info(1, &em_x270_spi_info);
838 pxa2xx_set_spi_info(2, &em_x270_spi_2_info);
839 spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
842 static inline void em_x270_init_spi(void) {}
845 #if defined(CONFIG_SND_PXA2XX_LIB_AC97)
846 static pxa2xx_audio_ops_t em_x270_ac97_info = {
850 static void __init em_x270_init_ac97(void)
852 pxa_set_ac97_info(&em_x270_ac97_info);
855 static inline void em_x270_init_ac97(void) {}
858 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
859 static unsigned int em_x270_module_matrix_keys[] = {
860 KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
861 KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
862 KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
865 struct pxa27x_keypad_platform_data em_x270_module_keypad_info = {
866 /* code map for the matrix keys */
867 .matrix_key_rows = 3,
868 .matrix_key_cols = 3,
869 .matrix_key_map = em_x270_module_matrix_keys,
870 .matrix_key_map_size = ARRAY_SIZE(em_x270_module_matrix_keys),
873 static unsigned int em_x270_exeda_matrix_keys[] = {
874 KEY(0, 0, KEY_RIGHTSHIFT), KEY(0, 1, KEY_RIGHTCTRL),
875 KEY(0, 2, KEY_RIGHTALT), KEY(0, 3, KEY_SPACE),
876 KEY(0, 4, KEY_LEFTALT), KEY(0, 5, KEY_LEFTCTRL),
877 KEY(0, 6, KEY_ENTER), KEY(0, 7, KEY_SLASH),
879 KEY(1, 0, KEY_DOT), KEY(1, 1, KEY_M),
880 KEY(1, 2, KEY_N), KEY(1, 3, KEY_B),
881 KEY(1, 4, KEY_V), KEY(1, 5, KEY_C),
882 KEY(1, 6, KEY_X), KEY(1, 7, KEY_Z),
884 KEY(2, 0, KEY_LEFTSHIFT), KEY(2, 1, KEY_SEMICOLON),
885 KEY(2, 2, KEY_L), KEY(2, 3, KEY_K),
886 KEY(2, 4, KEY_J), KEY(2, 5, KEY_H),
887 KEY(2, 6, KEY_G), KEY(2, 7, KEY_F),
889 KEY(3, 0, KEY_D), KEY(3, 1, KEY_S),
890 KEY(3, 2, KEY_A), KEY(3, 3, KEY_TAB),
891 KEY(3, 4, KEY_BACKSPACE), KEY(3, 5, KEY_P),
892 KEY(3, 6, KEY_O), KEY(3, 7, KEY_I),
894 KEY(4, 0, KEY_U), KEY(4, 1, KEY_Y),
895 KEY(4, 2, KEY_T), KEY(4, 3, KEY_R),
896 KEY(4, 4, KEY_E), KEY(4, 5, KEY_W),
897 KEY(4, 6, KEY_Q), KEY(4, 7, KEY_MINUS),
899 KEY(5, 0, KEY_0), KEY(5, 1, KEY_9),
900 KEY(5, 2, KEY_8), KEY(5, 3, KEY_7),
901 KEY(5, 4, KEY_6), KEY(5, 5, KEY_5),
902 KEY(5, 6, KEY_4), KEY(5, 7, KEY_3),
904 KEY(6, 0, KEY_2), KEY(6, 1, KEY_1),
905 KEY(6, 2, KEY_ENTER), KEY(6, 3, KEY_END),
906 KEY(6, 4, KEY_DOWN), KEY(6, 5, KEY_UP),
907 KEY(6, 6, KEY_MENU), KEY(6, 7, KEY_F1),
909 KEY(7, 0, KEY_LEFT), KEY(7, 1, KEY_RIGHT),
910 KEY(7, 2, KEY_BACK), KEY(7, 3, KEY_HOME),
911 KEY(7, 4, 0), KEY(7, 5, 0),
912 KEY(7, 6, 0), KEY(7, 7, 0),
915 struct pxa27x_keypad_platform_data em_x270_exeda_keypad_info = {
916 /* code map for the matrix keys */
917 .matrix_key_rows = 8,
918 .matrix_key_cols = 8,
919 .matrix_key_map = em_x270_exeda_matrix_keys,
920 .matrix_key_map_size = ARRAY_SIZE(em_x270_exeda_matrix_keys),
923 static void __init em_x270_init_keypad(void)
925 if (machine_is_em_x270())
926 pxa_set_keypad_info(&em_x270_module_keypad_info);
928 pxa_set_keypad_info(&em_x270_exeda_keypad_info);
931 static inline void em_x270_init_keypad(void) {}
934 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
935 static struct gpio_keys_button gpio_keys_button[] = {
937 .desc = "sleep/wakeup",
945 static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
946 .buttons = gpio_keys_button,
950 static struct platform_device em_x270_gpio_keys = {
954 .platform_data = &em_x270_gpio_keys_data,
958 static void __init em_x270_init_gpio_keys(void)
960 platform_device_register(&em_x270_gpio_keys);
963 static inline void em_x270_init_gpio_keys(void) {}
966 /* Quick Capture Interface and sensor setup */
967 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
968 static struct regulator *em_x270_camera_ldo;
970 static int em_x270_sensor_init(struct device *dev)
974 ret = gpio_request(cam_reset, "camera reset");
978 gpio_direction_output(cam_reset, 0);
980 em_x270_camera_ldo = regulator_get(NULL, "vcc cam");
981 if (em_x270_camera_ldo == NULL) {
982 gpio_free(cam_reset);
986 ret = regulator_enable(em_x270_camera_ldo);
988 regulator_put(em_x270_camera_ldo);
989 gpio_free(cam_reset);
993 gpio_set_value(cam_reset, 1);
998 struct pxacamera_platform_data em_x270_camera_platform_data = {
999 .init = em_x270_sensor_init,
1000 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
1001 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
1005 static int em_x270_sensor_power(struct device *dev, int on)
1008 int is_on = regulator_is_enabled(em_x270_camera_ldo);
1013 gpio_set_value(cam_reset, !on);
1016 ret = regulator_enable(em_x270_camera_ldo);
1018 ret = regulator_disable(em_x270_camera_ldo);
1023 gpio_set_value(cam_reset, on);
1028 static struct i2c_board_info em_x270_i2c_cam_info[] = {
1030 I2C_BOARD_INFO("mt9m111", 0x48),
1034 static struct soc_camera_link iclink = {
1036 .power = em_x270_sensor_power,
1037 .board_info = &em_x270_i2c_cam_info[0],
1038 .i2c_adapter_id = 0,
1039 .module_name = "mt9m111",
1042 static struct platform_device em_x270_camera = {
1043 .name = "soc-camera-pdrv",
1046 .platform_data = &iclink,
1050 static void __init em_x270_init_camera(void)
1052 pxa_set_camera_info(&em_x270_camera_platform_data);
1053 platform_device_register(&em_x270_camera);
1056 static inline void em_x270_init_camera(void) {}
1059 static struct regulator_bulk_data em_x270_gps_consumer_supply = {
1060 .supply = "vcc gps",
1063 static struct regulator_userspace_consumer_data em_x270_gps_consumer_data = {
1066 .supplies = &em_x270_gps_consumer_supply,
1069 static struct platform_device em_x270_gps_userspace_consumer = {
1070 .name = "reg-userspace-consumer",
1073 .platform_data = &em_x270_gps_consumer_data,
1077 static struct regulator_bulk_data em_x270_gprs_consumer_supply = {
1078 .supply = "vcc gprs",
1081 static struct regulator_userspace_consumer_data em_x270_gprs_consumer_data = {
1084 .supplies = &em_x270_gprs_consumer_supply
1087 static struct platform_device em_x270_gprs_userspace_consumer = {
1088 .name = "reg-userspace-consumer",
1091 .platform_data = &em_x270_gprs_consumer_data,
1095 static struct platform_device *em_x270_userspace_consumers[] = {
1096 &em_x270_gps_userspace_consumer,
1097 &em_x270_gprs_userspace_consumer,
1100 static void __init em_x270_userspace_consumers_init(void)
1102 platform_add_devices(ARRAY_AND_SIZE(em_x270_userspace_consumers));
1105 /* DA9030 related initializations */
1106 #define REGULATOR_CONSUMER(_name, _dev, _supply) \
1107 static struct regulator_consumer_supply _name##_consumers[] = { \
1110 .supply = _supply, \
1114 REGULATOR_CONSUMER(ldo3, &em_x270_gps_userspace_consumer.dev, "vcc gps");
1115 REGULATOR_CONSUMER(ldo5, NULL, "vcc cam");
1116 REGULATOR_CONSUMER(ldo10, &pxa_device_mci.dev, "vcc sdio");
1117 REGULATOR_CONSUMER(ldo12, NULL, "vcc usb");
1118 REGULATOR_CONSUMER(ldo19, &em_x270_gprs_userspace_consumer.dev, "vcc gprs");
1119 REGULATOR_CONSUMER(buck2, NULL, "vcc_core");
1121 #define REGULATOR_INIT(_ldo, _min_uV, _max_uV, _ops_mask) \
1122 static struct regulator_init_data _ldo##_data = { \
1124 .min_uV = _min_uV, \
1125 .max_uV = _max_uV, \
1129 .valid_ops_mask = _ops_mask, \
1132 .num_consumer_supplies = ARRAY_SIZE(_ldo##_consumers), \
1133 .consumer_supplies = _ldo##_consumers, \
1136 REGULATOR_INIT(ldo3, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
1137 REGULATOR_INIT(ldo5, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1138 REGULATOR_INIT(ldo10, 2000000, 3200000,
1139 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE);
1140 REGULATOR_INIT(ldo12, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1141 REGULATOR_INIT(ldo19, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
1142 REGULATOR_INIT(buck2, 1000000, 1650000, REGULATOR_CHANGE_VOLTAGE);
1144 struct led_info em_x270_led_info = {
1145 .name = "em-x270:orange",
1146 .default_trigger = "battery-charging-or-full",
1149 struct power_supply_info em_x270_psy_info = {
1151 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
1152 .voltage_max_design = 4200000,
1153 .voltage_min_design = 3000000,
1157 static void em_x270_battery_low(void)
1159 #if defined(CONFIG_APM_EMULATION)
1160 apm_queue_event(APM_LOW_BATTERY);
1164 static void em_x270_battery_critical(void)
1166 #if defined(CONFIG_APM_EMULATION)
1167 apm_queue_event(APM_CRITICAL_SUSPEND);
1171 struct da9030_battery_info em_x270_batterty_info = {
1172 .battery_info = &em_x270_psy_info,
1174 .charge_milliamp = 1000,
1175 .charge_millivolt = 4200,
1179 .vbat_charge_start = 4100,
1180 .vbat_charge_stop = 4200,
1181 .vbat_charge_restart = 4000,
1183 .vcharge_min = 3200,
1184 .vcharge_max = 5500,
1188 .tbat_restart = 100,
1190 .batmon_interval = 0,
1192 .battery_low = em_x270_battery_low,
1193 .battery_critical = em_x270_battery_critical,
1196 #define DA9030_SUBDEV(_name, _id, _pdata) \
1198 .name = "da903x-" #_name, \
1199 .id = DA9030_ID_##_id, \
1200 .platform_data = _pdata, \
1203 #define DA9030_LDO(num) DA9030_SUBDEV(regulator, LDO##num, &ldo##num##_data)
1205 struct da903x_subdev_info em_x270_da9030_subdevs[] = {
1212 DA9030_SUBDEV(regulator, BUCK2, &buck2_data),
1214 DA9030_SUBDEV(led, LED_PC, &em_x270_led_info),
1215 DA9030_SUBDEV(backlight, WLED, &em_x270_led_info),
1216 DA9030_SUBDEV(battery, BAT, &em_x270_batterty_info),
1219 static struct da903x_platform_data em_x270_da9030_info = {
1220 .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
1221 .subdevs = em_x270_da9030_subdevs,
1224 static struct i2c_board_info em_x270_i2c_pmic_info = {
1225 I2C_BOARD_INFO("da9030", 0x49),
1227 .platform_data = &em_x270_da9030_info,
1230 static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
1234 static void __init em_x270_init_da9030(void)
1236 pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
1237 i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
1240 static struct pca953x_platform_data exeda_gpio_ext_pdata = {
1244 static struct i2c_board_info exeda_i2c_info[] = {
1246 I2C_BOARD_INFO("pca9555", 0x21),
1247 .platform_data = &exeda_gpio_ext_pdata,
1251 static struct i2c_pxa_platform_data em_x270_i2c_info = {
1255 static void __init em_x270_init_i2c(void)
1257 pxa_set_i2c_info(&em_x270_i2c_info);
1259 if (machine_is_exeda())
1260 i2c_register_board_info(0, ARRAY_AND_SIZE(exeda_i2c_info));
1263 static void __init em_x270_module_init(void)
1265 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
1267 mmc_cd = GPIO13_MMC_CD;
1268 nand_rb = GPIO56_NAND_RB;
1269 dm9000_flags = DM9000_PLATF_32BITONLY;
1270 cam_reset = GPIO93_CAM_RESET;
1271 usb_hub_reset = GPIO16_USB_HUB_RESET;
1274 static void __init em_x270_exeda_init(void)
1276 pxa2xx_mfp_config(ARRAY_AND_SIZE(exeda_pin_config));
1278 mmc_cd = GPIO114_MMC_CD;
1279 nand_rb = GPIO20_NAND_RB;
1280 dm9000_flags = DM9000_PLATF_16BITONLY;
1281 cam_reset = GPIO130_CAM_RESET;
1282 usb_hub_reset = GPIO10_USB_HUB_RESET;
1285 static void __init em_x270_init(void)
1287 pxa2xx_mfp_config(ARRAY_AND_SIZE(common_pin_config));
1290 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
1293 if (machine_is_em_x270())
1294 em_x270_module_init();
1295 else if (machine_is_exeda())
1296 em_x270_exeda_init();
1298 panic("Unsupported machine: %d\n", machine_arch_type);
1300 em_x270_init_da9030();
1301 em_x270_init_dm9000();
1303 em_x270_init_nand();
1307 em_x270_init_ohci();
1308 em_x270_init_keypad();
1309 em_x270_init_gpio_keys();
1310 em_x270_init_ac97();
1313 em_x270_init_camera();
1314 em_x270_userspace_consumers_init();
1317 MACHINE_START(EM_X270, "Compulab EM-X270")
1318 .boot_params = 0xa0000100,
1319 .phys_io = 0x40000000,
1320 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1321 .map_io = pxa_map_io,
1322 .init_irq = pxa27x_init_irq,
1323 .timer = &pxa_timer,
1324 .init_machine = em_x270_init,
1327 MACHINE_START(EXEDA, "Compulab eXeda")
1328 .boot_params = 0xa0000100,
1329 .phys_io = 0x40000000,
1330 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1331 .map_io = pxa_map_io,
1332 .init_irq = pxa27x_init_irq,
1333 .timer = &pxa_timer,
1334 .init_machine = em_x270_init,