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>
34 #include <media/soc_camera.h>
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
39 #include <mach/pxa27x.h>
40 #include <mach/pxa27x-udc.h>
41 #include <mach/audio.h>
42 #include <mach/pxafb.h>
43 #include <mach/ohci.h>
45 #include <mach/pxa27x_keypad.h>
47 #include <mach/camera.h>
48 #include <mach/pxa2xx_spi.h>
53 /* EM-X270 specific GPIOs */
54 #define GPIO13_MMC_CD (13)
55 #define GPIO95_MMC_WP (95)
56 #define GPIO56_NAND_RB (56)
57 #define GPIO93_CAM_RESET (93)
58 #define GPIO16_USB_HUB_RESET (16)
60 /* eXeda specific GPIOs */
61 #define GPIO114_MMC_CD (114)
62 #define GPIO20_NAND_RB (20)
63 #define GPIO38_SD_PWEN (38)
64 #define GPIO37_WLAN_RST (37)
65 #define GPIO95_TOUCHPAD_INT (95)
66 #define GPIO130_CAM_RESET (130)
67 #define GPIO10_USB_HUB_RESET (10)
70 #define GPIO11_NAND_CS (11)
71 #define GPIO41_ETHIRQ (41)
72 #define EM_X270_ETHIRQ IRQ_GPIO(GPIO41_ETHIRQ)
73 #define GPIO115_WLAN_PWEN (115)
74 #define GPIO19_WLAN_STRAP (19)
75 #define GPIO9_USB_VBUS_EN (9)
79 static int dm9000_flags;
81 static int usb_hub_reset;
83 static unsigned long common_pin_config[] = {
86 GPIO29_AC97_SDATA_IN_0,
87 GPIO30_AC97_SDATA_OUT,
151 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
152 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
153 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
154 GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
155 GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
156 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
157 GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
158 GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
175 GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
180 /* SDRAM and local bus */
189 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* sleep/resume button */
192 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
193 GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
196 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
199 GPIO41_GPIO, /* DM9000 interrupt */
202 static unsigned long em_x270_pin_config[] = {
203 GPIO13_GPIO, /* MMC card detect */
204 GPIO16_GPIO, /* USB hub reset */
205 GPIO56_GPIO, /* NAND Ready/Busy */
206 GPIO93_GPIO | MFP_LPM_DRIVE_LOW, /* Camera reset */
207 GPIO95_GPIO, /* MMC Write protect */
210 static unsigned long exeda_pin_config[] = {
211 GPIO10_GPIO, /* USB hub reset */
212 GPIO20_GPIO, /* NAND Ready/Busy */
213 GPIO38_GPIO | MFP_LPM_DRIVE_LOW, /* SD slot power */
214 GPIO95_GPIO, /* touchpad IRQ */
215 GPIO114_GPIO, /* MMC card detect */
218 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
219 static struct resource em_x270_dm9000_resource[] = {
221 .start = PXA_CS2_PHYS,
222 .end = PXA_CS2_PHYS + 3,
223 .flags = IORESOURCE_MEM,
226 .start = PXA_CS2_PHYS + 8,
227 .end = PXA_CS2_PHYS + 8 + 0x3f,
228 .flags = IORESOURCE_MEM,
231 .start = EM_X270_ETHIRQ,
232 .end = EM_X270_ETHIRQ,
233 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
237 static struct dm9000_plat_data em_x270_dm9000_platdata = {
238 .flags = DM9000_PLATF_NO_EEPROM,
241 static struct platform_device em_x270_dm9000 = {
244 .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
245 .resource = em_x270_dm9000_resource,
247 .platform_data = &em_x270_dm9000_platdata,
251 static void __init em_x270_init_dm9000(void)
253 em_x270_dm9000_platdata.flags |= dm9000_flags;
254 platform_device_register(&em_x270_dm9000);
257 static inline void em_x270_init_dm9000(void) {}
261 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
262 static struct resource em_x270_v3020_resource[] = {
264 .start = PXA_CS4_PHYS,
265 .end = PXA_CS4_PHYS + 3,
266 .flags = IORESOURCE_MEM,
270 static struct v3020_platform_data em_x270_v3020_platdata = {
274 static struct platform_device em_x270_rtc = {
276 .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
277 .resource = em_x270_v3020_resource,
280 .platform_data = &em_x270_v3020_platdata,
284 static void __init em_x270_init_rtc(void)
286 platform_device_register(&em_x270_rtc);
289 static inline void em_x270_init_rtc(void) {}
293 #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
294 static inline void nand_cs_on(void)
296 gpio_set_value(GPIO11_NAND_CS, 0);
299 static void nand_cs_off(void)
303 gpio_set_value(GPIO11_NAND_CS, 1);
306 /* hardware specific access to control-lines */
307 static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
310 struct nand_chip *this = mtd->priv;
311 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
315 if (ctrl & NAND_CTRL_CHANGE) {
317 nandaddr |= (1 << 3);
319 nandaddr &= ~(1 << 3);
321 nandaddr |= (1 << 2);
323 nandaddr &= ~(1 << 2);
331 this->IO_ADDR_W = (void __iomem *)nandaddr;
332 if (dat != NAND_CMD_NONE)
333 writel(dat, this->IO_ADDR_W);
338 /* read device ready pin */
339 static int em_x270_nand_device_ready(struct mtd_info *mtd)
343 return gpio_get_value(nand_rb);
346 static struct mtd_partition em_x270_partition_info[] = {
354 .offset = MTDPART_OFS_APPEND,
355 .size = MTDPART_SIZ_FULL
359 static const char *em_x270_part_probes[] = { "cmdlinepart", NULL };
361 struct platform_nand_data em_x270_nand_platdata = {
365 .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
366 .partitions = em_x270_partition_info,
368 .part_probe_types = em_x270_part_probes,
372 .dev_ready = em_x270_nand_device_ready,
374 .cmd_ctrl = em_x270_nand_cmd_ctl,
378 static struct resource em_x270_nand_resource[] = {
380 .start = PXA_CS1_PHYS,
381 .end = PXA_CS1_PHYS + 12,
382 .flags = IORESOURCE_MEM,
386 static struct platform_device em_x270_nand = {
388 .num_resources = ARRAY_SIZE(em_x270_nand_resource),
389 .resource = em_x270_nand_resource,
392 .platform_data = &em_x270_nand_platdata,
396 static void __init em_x270_init_nand(void)
400 err = gpio_request(GPIO11_NAND_CS, "NAND CS");
402 pr_warning("EM-X270: failed to request NAND CS gpio\n");
406 gpio_direction_output(GPIO11_NAND_CS, 1);
408 err = gpio_request(nand_rb, "NAND R/B");
410 pr_warning("EM-X270: failed to request NAND R/B gpio\n");
411 gpio_free(GPIO11_NAND_CS);
415 gpio_direction_input(nand_rb);
417 platform_device_register(&em_x270_nand);
420 static inline void em_x270_init_nand(void) {}
423 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
424 static struct mtd_partition em_x270_nor_parts[] = {
426 .name = "Bootloader",
427 .offset = 0x00000000,
429 .mask_flags = MTD_WRITEABLE /* force read-only */
431 .name = "Environment",
432 .offset = 0x00050000,
436 .offset = 0x00060000,
438 .mask_flags = MTD_WRITEABLE /* force read-only */
440 .name = "Splashscreen",
441 .offset = 0x000b0000,
446 static struct physmap_flash_data em_x270_nor_data[] = {
449 .parts = em_x270_nor_parts,
450 .nr_parts = ARRAY_SIZE(em_x270_nor_parts),
454 static struct resource em_x270_nor_flash_resource = {
455 .start = PXA_CS0_PHYS,
456 .end = PXA_CS0_PHYS + SZ_1M - 1,
457 .flags = IORESOURCE_MEM,
460 static struct platform_device em_x270_physmap_flash = {
461 .name = "physmap-flash",
464 .resource = &em_x270_nor_flash_resource,
466 .platform_data = &em_x270_nor_data,
470 static void __init em_x270_init_nor(void)
472 platform_device_register(&em_x270_physmap_flash);
475 static inline void em_x270_init_nor(void) {}
478 /* PXA27x OHCI controller setup */
479 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
480 static struct regulator *em_x270_usb_ldo;
482 static int em_x270_usb_hub_init(void)
486 em_x270_usb_ldo = regulator_get(NULL, "vcc usb");
487 if (IS_ERR(em_x270_usb_ldo))
488 return PTR_ERR(em_x270_usb_ldo);
490 err = gpio_request(GPIO9_USB_VBUS_EN, "vbus en");
492 goto err_free_usb_ldo;
494 err = gpio_request(usb_hub_reset, "hub rst");
496 goto err_free_vbus_gpio;
498 /* USB Hub power-on and reset */
499 gpio_direction_output(usb_hub_reset, 0);
500 regulator_enable(em_x270_usb_ldo);
501 gpio_set_value(usb_hub_reset, 1);
502 gpio_set_value(usb_hub_reset, 0);
503 regulator_disable(em_x270_usb_ldo);
504 regulator_enable(em_x270_usb_ldo);
505 gpio_set_value(usb_hub_reset, 1);
508 gpio_direction_output(GPIO9_USB_VBUS_EN, 1);
513 gpio_free(GPIO9_USB_VBUS_EN);
515 regulator_put(em_x270_usb_ldo);
520 static int em_x270_ohci_init(struct device *dev)
524 /* we don't want to entirely disable USB if the HUB init failed */
525 err = em_x270_usb_hub_init();
527 pr_err("USB Hub initialization failed: %d\n", err);
529 /* enable port 2 transiever */
530 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
535 static void em_x270_ohci_exit(struct device *dev)
537 gpio_free(usb_hub_reset);
538 gpio_free(GPIO9_USB_VBUS_EN);
540 if (!IS_ERR(em_x270_usb_ldo)) {
541 if (regulator_is_enabled(em_x270_usb_ldo))
542 regulator_disable(em_x270_usb_ldo);
544 regulator_put(em_x270_usb_ldo);
548 static struct pxaohci_platform_data em_x270_ohci_platform_data = {
549 .port_mode = PMM_PERPORT_MODE,
550 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
551 .init = em_x270_ohci_init,
552 .exit = em_x270_ohci_exit,
555 static void __init em_x270_init_ohci(void)
557 pxa_set_ohci_info(&em_x270_ohci_platform_data);
560 static inline void em_x270_init_ohci(void) {}
563 /* MCI controller setup */
564 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
565 static struct regulator *em_x270_sdio_ldo;
567 static int em_x270_mci_init(struct device *dev,
568 irq_handler_t em_x270_detect_int,
573 em_x270_sdio_ldo = regulator_get(dev, "vcc sdio");
574 if (IS_ERR(em_x270_sdio_ldo)) {
575 dev_err(dev, "can't request SDIO power supply: %ld\n",
576 PTR_ERR(em_x270_sdio_ldo));
577 return PTR_ERR(em_x270_sdio_ldo);
580 err = request_irq(gpio_to_irq(mmc_cd), em_x270_detect_int,
581 IRQF_DISABLED | IRQF_TRIGGER_RISING |
582 IRQF_TRIGGER_FALLING,
583 "MMC card detect", data);
585 dev_err(dev, "can't request MMC card detect IRQ: %d\n", err);
589 if (machine_is_em_x270()) {
590 err = gpio_request(GPIO95_MMC_WP, "MMC WP");
592 dev_err(dev, "can't request MMC write protect: %d\n",
596 gpio_direction_input(GPIO95_MMC_WP);
598 err = gpio_request(GPIO38_SD_PWEN, "sdio power");
600 dev_err(dev, "can't request MMC power control : %d\n",
604 gpio_direction_output(GPIO38_SD_PWEN, 1);
610 free_irq(gpio_to_irq(mmc_cd), data);
612 regulator_put(em_x270_sdio_ldo);
617 static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
619 struct pxamci_platform_data* p_d = dev->platform_data;
621 if ((1 << vdd) & p_d->ocr_mask) {
622 int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;
624 regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
625 regulator_enable(em_x270_sdio_ldo);
627 regulator_disable(em_x270_sdio_ldo);
631 static void em_x270_mci_exit(struct device *dev, void *data)
633 free_irq(gpio_to_irq(mmc_cd), data);
634 regulator_put(em_x270_sdio_ldo);
636 if (machine_is_em_x270())
637 gpio_free(GPIO95_MMC_WP);
639 gpio_free(GPIO38_SD_PWEN);
642 static int em_x270_mci_get_ro(struct device *dev)
644 return gpio_get_value(GPIO95_MMC_WP);
647 static struct pxamci_platform_data em_x270_mci_platform_data = {
648 .ocr_mask = MMC_VDD_20_21|MMC_VDD_21_22|MMC_VDD_22_23|
649 MMC_VDD_24_25|MMC_VDD_25_26|MMC_VDD_26_27|
650 MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
651 MMC_VDD_30_31|MMC_VDD_31_32,
652 .init = em_x270_mci_init,
653 .setpower = em_x270_mci_setpower,
654 .exit = em_x270_mci_exit,
657 static void __init em_x270_init_mmc(void)
659 if (machine_is_em_x270())
660 em_x270_mci_platform_data.get_ro = em_x270_mci_get_ro;
662 em_x270_mci_platform_data.detect_delay = msecs_to_jiffies(250);
663 pxa_set_mci_info(&em_x270_mci_platform_data);
666 static inline void em_x270_init_mmc(void) {}
670 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
671 static struct pxafb_mode_info em_x270_lcd_modes[] = {
700 static struct pxafb_mach_info em_x270_lcd = {
701 .modes = em_x270_lcd_modes,
703 .lcd_conn = LCD_COLOR_TFT_16BPP,
706 static void __init em_x270_init_lcd(void)
708 set_pxa_fb_info(&em_x270_lcd);
711 static inline void em_x270_init_lcd(void) {}
714 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
715 static struct pxa2xx_spi_master em_x270_spi_info = {
719 static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
725 static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
729 static struct pxa2xx_spi_master em_x270_spi_2_info = {
734 static struct pxa2xx_spi_chip em_x270_libertas_chip = {
740 static unsigned long em_x270_libertas_pin_config[] = {
748 static int em_x270_libertas_setup(struct spi_device *spi)
750 int err = gpio_request(GPIO115_WLAN_PWEN, "WLAN PWEN");
754 err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
758 if (machine_is_exeda()) {
759 err = gpio_request(GPIO37_WLAN_RST, "WLAN RST");
763 gpio_direction_output(GPIO37_WLAN_RST, 1);
767 gpio_direction_output(GPIO19_WLAN_STRAP, 1);
770 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_libertas_pin_config));
772 gpio_direction_output(GPIO115_WLAN_PWEN, 0);
774 gpio_set_value(GPIO115_WLAN_PWEN, 1);
777 spi->bits_per_word = 16;
783 gpio_free(GPIO19_WLAN_STRAP);
785 gpio_free(GPIO115_WLAN_PWEN);
790 static int em_x270_libertas_teardown(struct spi_device *spi)
792 gpio_set_value(GPIO115_WLAN_PWEN, 0);
793 gpio_free(GPIO115_WLAN_PWEN);
794 gpio_free(GPIO19_WLAN_STRAP);
796 if (machine_is_exeda()) {
797 gpio_set_value(GPIO37_WLAN_RST, 0);
798 gpio_free(GPIO37_WLAN_RST);
804 struct libertas_spi_platform_data em_x270_libertas_pdata = {
805 .use_dummy_writes = 1,
807 .setup = em_x270_libertas_setup,
808 .teardown = em_x270_libertas_teardown,
811 static struct spi_board_info em_x270_spi_devices[] __initdata = {
813 .modalias = "tdo24m",
814 .max_speed_hz = 1000000,
817 .controller_data = &em_x270_tdo24m_chip,
818 .platform_data = &em_x270_tdo24m_pdata,
821 .modalias = "libertas_spi",
822 .max_speed_hz = 13000000,
824 .irq = IRQ_GPIO(116),
826 .controller_data = &em_x270_libertas_chip,
827 .platform_data = &em_x270_libertas_pdata,
831 static void __init em_x270_init_spi(void)
833 pxa2xx_set_spi_info(1, &em_x270_spi_info);
834 pxa2xx_set_spi_info(2, &em_x270_spi_2_info);
835 spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
838 static inline void em_x270_init_spi(void) {}
841 #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
842 static void __init em_x270_init_ac97(void)
844 pxa_set_ac97_info(NULL);
847 static inline void em_x270_init_ac97(void) {}
850 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
851 static unsigned int em_x270_module_matrix_keys[] = {
852 KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
853 KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
854 KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
857 struct pxa27x_keypad_platform_data em_x270_module_keypad_info = {
858 /* code map for the matrix keys */
859 .matrix_key_rows = 3,
860 .matrix_key_cols = 3,
861 .matrix_key_map = em_x270_module_matrix_keys,
862 .matrix_key_map_size = ARRAY_SIZE(em_x270_module_matrix_keys),
865 static unsigned int em_x270_exeda_matrix_keys[] = {
866 KEY(0, 0, KEY_RIGHTSHIFT), KEY(0, 1, KEY_RIGHTCTRL),
867 KEY(0, 2, KEY_RIGHTALT), KEY(0, 3, KEY_SPACE),
868 KEY(0, 4, KEY_LEFTALT), KEY(0, 5, KEY_LEFTCTRL),
869 KEY(0, 6, KEY_ENTER), KEY(0, 7, KEY_SLASH),
871 KEY(1, 0, KEY_DOT), KEY(1, 1, KEY_M),
872 KEY(1, 2, KEY_N), KEY(1, 3, KEY_B),
873 KEY(1, 4, KEY_V), KEY(1, 5, KEY_C),
874 KEY(1, 6, KEY_X), KEY(1, 7, KEY_Z),
876 KEY(2, 0, KEY_LEFTSHIFT), KEY(2, 1, KEY_SEMICOLON),
877 KEY(2, 2, KEY_L), KEY(2, 3, KEY_K),
878 KEY(2, 4, KEY_J), KEY(2, 5, KEY_H),
879 KEY(2, 6, KEY_G), KEY(2, 7, KEY_F),
881 KEY(3, 0, KEY_D), KEY(3, 1, KEY_S),
882 KEY(3, 2, KEY_A), KEY(3, 3, KEY_TAB),
883 KEY(3, 4, KEY_BACKSPACE), KEY(3, 5, KEY_P),
884 KEY(3, 6, KEY_O), KEY(3, 7, KEY_I),
886 KEY(4, 0, KEY_U), KEY(4, 1, KEY_Y),
887 KEY(4, 2, KEY_T), KEY(4, 3, KEY_R),
888 KEY(4, 4, KEY_E), KEY(4, 5, KEY_W),
889 KEY(4, 6, KEY_Q), KEY(4, 7, KEY_MINUS),
891 KEY(5, 0, KEY_0), KEY(5, 1, KEY_9),
892 KEY(5, 2, KEY_8), KEY(5, 3, KEY_7),
893 KEY(5, 4, KEY_6), KEY(5, 5, KEY_5),
894 KEY(5, 6, KEY_4), KEY(5, 7, KEY_3),
896 KEY(6, 0, KEY_2), KEY(6, 1, KEY_1),
897 KEY(6, 2, KEY_ENTER), KEY(6, 3, KEY_END),
898 KEY(6, 4, KEY_DOWN), KEY(6, 5, KEY_UP),
899 KEY(6, 6, KEY_MENU), KEY(6, 7, KEY_F1),
901 KEY(7, 0, KEY_LEFT), KEY(7, 1, KEY_RIGHT),
902 KEY(7, 2, KEY_BACK), KEY(7, 3, KEY_HOME),
903 KEY(7, 4, 0), KEY(7, 5, 0),
904 KEY(7, 6, 0), KEY(7, 7, 0),
907 struct pxa27x_keypad_platform_data em_x270_exeda_keypad_info = {
908 /* code map for the matrix keys */
909 .matrix_key_rows = 8,
910 .matrix_key_cols = 8,
911 .matrix_key_map = em_x270_exeda_matrix_keys,
912 .matrix_key_map_size = ARRAY_SIZE(em_x270_exeda_matrix_keys),
915 static void __init em_x270_init_keypad(void)
917 if (machine_is_em_x270())
918 pxa_set_keypad_info(&em_x270_module_keypad_info);
920 pxa_set_keypad_info(&em_x270_exeda_keypad_info);
923 static inline void em_x270_init_keypad(void) {}
926 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
927 static struct gpio_keys_button gpio_keys_button[] = {
929 .desc = "sleep/wakeup",
937 static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
938 .buttons = gpio_keys_button,
942 static struct platform_device em_x270_gpio_keys = {
946 .platform_data = &em_x270_gpio_keys_data,
950 static void __init em_x270_init_gpio_keys(void)
952 platform_device_register(&em_x270_gpio_keys);
955 static inline void em_x270_init_gpio_keys(void) {}
958 /* Quick Capture Interface and sensor setup */
959 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
960 static struct regulator *em_x270_camera_ldo;
962 static int em_x270_sensor_init(struct device *dev)
966 ret = gpio_request(cam_reset, "camera reset");
970 gpio_direction_output(cam_reset, 0);
972 em_x270_camera_ldo = regulator_get(NULL, "vcc cam");
973 if (em_x270_camera_ldo == NULL) {
974 gpio_free(cam_reset);
978 ret = regulator_enable(em_x270_camera_ldo);
980 regulator_put(em_x270_camera_ldo);
981 gpio_free(cam_reset);
985 gpio_set_value(cam_reset, 1);
990 struct pxacamera_platform_data em_x270_camera_platform_data = {
991 .init = em_x270_sensor_init,
992 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
993 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
997 static int em_x270_sensor_power(struct device *dev, int on)
1000 int is_on = regulator_is_enabled(em_x270_camera_ldo);
1005 gpio_set_value(cam_reset, !on);
1008 ret = regulator_enable(em_x270_camera_ldo);
1010 ret = regulator_disable(em_x270_camera_ldo);
1015 gpio_set_value(cam_reset, on);
1020 static struct soc_camera_link iclink = {
1022 .power = em_x270_sensor_power,
1025 static struct i2c_board_info em_x270_i2c_cam_info[] = {
1027 I2C_BOARD_INFO("mt9m111", 0x48),
1028 .platform_data = &iclink,
1032 static void __init em_x270_init_camera(void)
1034 i2c_register_board_info(0, ARRAY_AND_SIZE(em_x270_i2c_cam_info));
1035 pxa_set_camera_info(&em_x270_camera_platform_data);
1038 static inline void em_x270_init_camera(void) {}
1041 /* DA9030 related initializations */
1042 #define REGULATOR_CONSUMER(_name, _dev, _supply) \
1043 static struct regulator_consumer_supply _name##_consumers[] = { \
1046 .supply = _supply, \
1050 REGULATOR_CONSUMER(ldo3, NULL, "vcc gps");
1051 REGULATOR_CONSUMER(ldo5, NULL, "vcc cam");
1052 REGULATOR_CONSUMER(ldo10, &pxa_device_mci.dev, "vcc sdio");
1053 REGULATOR_CONSUMER(ldo12, NULL, "vcc usb");
1054 REGULATOR_CONSUMER(ldo19, NULL, "vcc gprs");
1056 #define REGULATOR_INIT(_ldo, _min_uV, _max_uV, _ops_mask) \
1057 static struct regulator_init_data _ldo##_data = { \
1059 .min_uV = _min_uV, \
1060 .max_uV = _max_uV, \
1064 .valid_ops_mask = _ops_mask, \
1066 .num_consumer_supplies = ARRAY_SIZE(_ldo##_consumers), \
1067 .consumer_supplies = _ldo##_consumers, \
1070 REGULATOR_INIT(ldo3, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
1071 REGULATOR_INIT(ldo5, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1072 REGULATOR_INIT(ldo10, 2000000, 3200000,
1073 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE);
1074 REGULATOR_INIT(ldo12, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1075 REGULATOR_INIT(ldo19, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
1077 struct led_info em_x270_led_info = {
1078 .name = "em-x270:orange",
1079 .default_trigger = "battery-charging-or-full",
1082 struct power_supply_info em_x270_psy_info = {
1084 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
1085 .voltage_max_design = 4200000,
1086 .voltage_min_design = 3000000,
1090 static void em_x270_battery_low(void)
1092 apm_queue_event(APM_LOW_BATTERY);
1095 static void em_x270_battery_critical(void)
1097 apm_queue_event(APM_CRITICAL_SUSPEND);
1100 struct da9030_battery_info em_x270_batterty_info = {
1101 .battery_info = &em_x270_psy_info,
1103 .charge_milliamp = 1000,
1104 .charge_millivolt = 4200,
1108 .vbat_charge_start = 4100,
1109 .vbat_charge_stop = 4200,
1110 .vbat_charge_restart = 4000,
1112 .vcharge_min = 3200,
1113 .vcharge_max = 5500,
1117 .tbat_restart = 100,
1119 .batmon_interval = 0,
1121 .battery_low = em_x270_battery_low,
1122 .battery_critical = em_x270_battery_critical,
1125 #define DA9030_SUBDEV(_name, _id, _pdata) \
1127 .name = "da903x-" #_name, \
1128 .id = DA9030_ID_##_id, \
1129 .platform_data = _pdata, \
1132 #define DA9030_LDO(num) DA9030_SUBDEV(regulator, LDO##num, &ldo##num##_data)
1134 struct da903x_subdev_info em_x270_da9030_subdevs[] = {
1141 DA9030_SUBDEV(led, LED_PC, &em_x270_led_info),
1142 DA9030_SUBDEV(backlight, WLED, &em_x270_led_info),
1143 DA9030_SUBDEV(battery, BAT, &em_x270_batterty_info),
1146 static struct da903x_platform_data em_x270_da9030_info = {
1147 .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
1148 .subdevs = em_x270_da9030_subdevs,
1151 static struct i2c_board_info em_x270_i2c_pmic_info = {
1152 I2C_BOARD_INFO("da9030", 0x49),
1154 .platform_data = &em_x270_da9030_info,
1157 static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
1161 static void __init em_x270_init_da9030(void)
1163 pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
1164 i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
1167 static struct pca953x_platform_data exeda_gpio_ext_pdata = {
1171 static struct i2c_board_info exeda_i2c_info[] = {
1173 I2C_BOARD_INFO("pca9555", 0x21),
1174 .platform_data = &exeda_gpio_ext_pdata,
1178 static struct i2c_pxa_platform_data em_x270_i2c_info = {
1182 static void __init em_x270_init_i2c(void)
1184 pxa_set_i2c_info(&em_x270_i2c_info);
1186 if (machine_is_exeda())
1187 i2c_register_board_info(0, ARRAY_AND_SIZE(exeda_i2c_info));
1190 static void __init em_x270_module_init(void)
1192 pr_info("%s\n", __func__);
1193 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
1195 mmc_cd = GPIO13_MMC_CD;
1196 nand_rb = GPIO56_NAND_RB;
1197 dm9000_flags = DM9000_PLATF_32BITONLY;
1198 cam_reset = GPIO93_CAM_RESET;
1199 usb_hub_reset = GPIO16_USB_HUB_RESET;
1202 static void __init em_x270_exeda_init(void)
1204 pr_info("%s\n", __func__);
1205 pxa2xx_mfp_config(ARRAY_AND_SIZE(exeda_pin_config));
1207 mmc_cd = GPIO114_MMC_CD;
1208 nand_rb = GPIO20_NAND_RB;
1209 dm9000_flags = DM9000_PLATF_16BITONLY;
1210 cam_reset = GPIO130_CAM_RESET;
1211 usb_hub_reset = GPIO10_USB_HUB_RESET;
1214 static void __init em_x270_init(void)
1216 pxa2xx_mfp_config(ARRAY_AND_SIZE(common_pin_config));
1219 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
1222 if (machine_is_em_x270())
1223 em_x270_module_init();
1224 else if (machine_is_exeda())
1225 em_x270_exeda_init();
1227 panic("Unsupported machine: %d\n", machine_arch_type);
1229 em_x270_init_da9030();
1230 em_x270_init_dm9000();
1232 em_x270_init_nand();
1236 em_x270_init_ohci();
1237 em_x270_init_keypad();
1238 em_x270_init_gpio_keys();
1239 em_x270_init_ac97();
1242 em_x270_init_camera();
1245 MACHINE_START(EM_X270, "Compulab EM-X270")
1246 .boot_params = 0xa0000100,
1247 .phys_io = 0x40000000,
1248 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1249 .map_io = pxa_map_io,
1250 .init_irq = pxa27x_init_irq,
1251 .timer = &pxa_timer,
1252 .init_machine = em_x270_init,
1255 MACHINE_START(EXEDA, "Compulab eXeda")
1256 .boot_params = 0xa0000100,
1257 .phys_io = 0x40000000,
1258 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1259 .map_io = pxa_map_io,
1260 .init_irq = pxa27x_init_irq,
1261 .timer = &pxa_timer,
1262 .init_machine = em_x270_init,