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/spi/pxa2xx_spi.h>
30 #include <linux/power_supply.h>
31 #include <linux/apm-emulation.h>
32 #include <linux/i2c.h>
33 #include <linux/platform_data/pca953x.h>
34 #include <linux/i2c/pxa-i2c.h>
35 #include <linux/regulator/userspace-consumer.h>
37 #include <media/soc_camera.h>
39 #include <asm/mach-types.h>
40 #include <asm/mach/arch.h>
42 #include <mach/pxa27x.h>
43 #include <mach/pxa27x-udc.h>
44 #include <mach/audio.h>
45 #include <linux/platform_data/video-pxafb.h>
46 #include <linux/platform_data/usb-ohci-pxa27x.h>
47 #include <linux/platform_data/mmc-pxamci.h>
48 #include <linux/platform_data/keypad-pxa27x.h>
49 #include <linux/platform_data/camera-pxa.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 PXA_GPIO_TO_IRQ(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,
112 GPIOxx_LCD_TFT_16BPP,
133 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
134 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
135 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
136 GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
137 GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
138 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
139 GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
140 GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
157 GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
162 /* SDRAM and local bus */
171 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* sleep/resume button */
174 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
175 GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
178 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
181 GPIO41_GPIO, /* DM9000 interrupt */
184 static unsigned long em_x270_pin_config[] = {
185 GPIO13_GPIO, /* MMC card detect */
186 GPIO16_GPIO, /* USB hub reset */
187 GPIO56_GPIO, /* NAND Ready/Busy */
188 GPIO93_GPIO | MFP_LPM_DRIVE_LOW, /* Camera reset */
189 GPIO95_GPIO, /* MMC Write protect */
192 static unsigned long exeda_pin_config[] = {
193 GPIO10_GPIO, /* USB hub reset */
194 GPIO20_GPIO, /* NAND Ready/Busy */
195 GPIO38_GPIO | MFP_LPM_DRIVE_LOW, /* SD slot power */
196 GPIO95_GPIO, /* touchpad IRQ */
197 GPIO114_GPIO, /* MMC card detect */
200 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
201 static struct resource em_x270_dm9000_resource[] = {
203 .start = PXA_CS2_PHYS,
204 .end = PXA_CS2_PHYS + 3,
205 .flags = IORESOURCE_MEM,
208 .start = PXA_CS2_PHYS + 8,
209 .end = PXA_CS2_PHYS + 8 + 0x3f,
210 .flags = IORESOURCE_MEM,
213 .start = EM_X270_ETHIRQ,
214 .end = EM_X270_ETHIRQ,
215 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
219 static struct dm9000_plat_data em_x270_dm9000_platdata = {
220 .flags = DM9000_PLATF_NO_EEPROM,
223 static struct platform_device em_x270_dm9000 = {
226 .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
227 .resource = em_x270_dm9000_resource,
229 .platform_data = &em_x270_dm9000_platdata,
233 static void __init em_x270_init_dm9000(void)
235 em_x270_dm9000_platdata.flags |= dm9000_flags;
236 platform_device_register(&em_x270_dm9000);
239 static inline void em_x270_init_dm9000(void) {}
243 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
244 static struct resource em_x270_v3020_resource[] = {
246 .start = PXA_CS4_PHYS,
247 .end = PXA_CS4_PHYS + 3,
248 .flags = IORESOURCE_MEM,
252 static struct v3020_platform_data em_x270_v3020_platdata = {
256 static struct platform_device em_x270_rtc = {
258 .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
259 .resource = em_x270_v3020_resource,
262 .platform_data = &em_x270_v3020_platdata,
266 static void __init em_x270_init_rtc(void)
268 platform_device_register(&em_x270_rtc);
271 static inline void em_x270_init_rtc(void) {}
275 #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
276 static inline void nand_cs_on(void)
278 gpio_set_value(GPIO11_NAND_CS, 0);
281 static void nand_cs_off(void)
285 gpio_set_value(GPIO11_NAND_CS, 1);
288 /* hardware specific access to control-lines */
289 static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
292 struct nand_chip *this = mtd->priv;
293 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
297 if (ctrl & NAND_CTRL_CHANGE) {
299 nandaddr |= (1 << 3);
301 nandaddr &= ~(1 << 3);
303 nandaddr |= (1 << 2);
305 nandaddr &= ~(1 << 2);
313 this->IO_ADDR_W = (void __iomem *)nandaddr;
314 if (dat != NAND_CMD_NONE)
315 writel(dat, this->IO_ADDR_W);
320 /* read device ready pin */
321 static int em_x270_nand_device_ready(struct mtd_info *mtd)
325 return gpio_get_value(nand_rb);
328 static struct mtd_partition em_x270_partition_info[] = {
336 .offset = MTDPART_OFS_APPEND,
337 .size = MTDPART_SIZ_FULL
341 struct platform_nand_data em_x270_nand_platdata = {
345 .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
346 .partitions = em_x270_partition_info,
351 .dev_ready = em_x270_nand_device_ready,
353 .cmd_ctrl = em_x270_nand_cmd_ctl,
357 static struct resource em_x270_nand_resource[] = {
359 .start = PXA_CS1_PHYS,
360 .end = PXA_CS1_PHYS + 12,
361 .flags = IORESOURCE_MEM,
365 static struct platform_device em_x270_nand = {
367 .num_resources = ARRAY_SIZE(em_x270_nand_resource),
368 .resource = em_x270_nand_resource,
371 .platform_data = &em_x270_nand_platdata,
375 static void __init em_x270_init_nand(void)
379 err = gpio_request(GPIO11_NAND_CS, "NAND CS");
381 pr_warning("EM-X270: failed to request NAND CS gpio\n");
385 gpio_direction_output(GPIO11_NAND_CS, 1);
387 err = gpio_request(nand_rb, "NAND R/B");
389 pr_warning("EM-X270: failed to request NAND R/B gpio\n");
390 gpio_free(GPIO11_NAND_CS);
394 gpio_direction_input(nand_rb);
396 platform_device_register(&em_x270_nand);
399 static inline void em_x270_init_nand(void) {}
402 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
403 static struct mtd_partition em_x270_nor_parts[] = {
405 .name = "Bootloader",
406 .offset = 0x00000000,
408 .mask_flags = MTD_WRITEABLE /* force read-only */
410 .name = "Environment",
411 .offset = 0x00050000,
415 .offset = 0x00060000,
417 .mask_flags = MTD_WRITEABLE /* force read-only */
419 .name = "Splashscreen",
420 .offset = 0x000b0000,
425 static struct physmap_flash_data em_x270_nor_data[] = {
428 .parts = em_x270_nor_parts,
429 .nr_parts = ARRAY_SIZE(em_x270_nor_parts),
433 static struct resource em_x270_nor_flash_resource = {
434 .start = PXA_CS0_PHYS,
435 .end = PXA_CS0_PHYS + SZ_1M - 1,
436 .flags = IORESOURCE_MEM,
439 static struct platform_device em_x270_physmap_flash = {
440 .name = "physmap-flash",
443 .resource = &em_x270_nor_flash_resource,
445 .platform_data = &em_x270_nor_data,
449 static void __init em_x270_init_nor(void)
451 platform_device_register(&em_x270_physmap_flash);
454 static inline void em_x270_init_nor(void) {}
457 /* PXA27x OHCI controller setup */
458 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
459 static struct regulator *em_x270_usb_ldo;
461 static int em_x270_usb_hub_init(void)
465 em_x270_usb_ldo = regulator_get(NULL, "vcc usb");
466 if (IS_ERR(em_x270_usb_ldo))
467 return PTR_ERR(em_x270_usb_ldo);
469 err = gpio_request(GPIO9_USB_VBUS_EN, "vbus en");
471 goto err_free_usb_ldo;
473 err = gpio_request(usb_hub_reset, "hub rst");
475 goto err_free_vbus_gpio;
477 /* USB Hub power-on and reset */
478 gpio_direction_output(usb_hub_reset, 1);
479 gpio_direction_output(GPIO9_USB_VBUS_EN, 0);
480 err = regulator_enable(em_x270_usb_ldo);
482 goto err_free_rst_gpio;
484 gpio_set_value(usb_hub_reset, 0);
485 gpio_set_value(usb_hub_reset, 1);
486 regulator_disable(em_x270_usb_ldo);
487 err = regulator_enable(em_x270_usb_ldo);
489 goto err_free_rst_gpio;
491 gpio_set_value(usb_hub_reset, 0);
492 gpio_set_value(GPIO9_USB_VBUS_EN, 1);
497 gpio_free(usb_hub_reset);
499 gpio_free(GPIO9_USB_VBUS_EN);
501 regulator_put(em_x270_usb_ldo);
506 static int em_x270_ohci_init(struct device *dev)
510 /* we don't want to entirely disable USB if the HUB init failed */
511 err = em_x270_usb_hub_init();
513 pr_err("USB Hub initialization failed: %d\n", err);
515 /* enable port 2 transiever */
516 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
521 static void em_x270_ohci_exit(struct device *dev)
523 gpio_free(usb_hub_reset);
524 gpio_free(GPIO9_USB_VBUS_EN);
526 if (!IS_ERR(em_x270_usb_ldo)) {
527 if (regulator_is_enabled(em_x270_usb_ldo))
528 regulator_disable(em_x270_usb_ldo);
530 regulator_put(em_x270_usb_ldo);
534 static struct pxaohci_platform_data em_x270_ohci_platform_data = {
535 .port_mode = PMM_PERPORT_MODE,
536 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
537 .init = em_x270_ohci_init,
538 .exit = em_x270_ohci_exit,
541 static void __init em_x270_init_ohci(void)
543 pxa_set_ohci_info(&em_x270_ohci_platform_data);
546 static inline void em_x270_init_ohci(void) {}
549 /* MCI controller setup */
550 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
551 static struct regulator *em_x270_sdio_ldo;
553 static int em_x270_mci_init(struct device *dev,
554 irq_handler_t em_x270_detect_int,
559 em_x270_sdio_ldo = regulator_get(dev, "vcc sdio");
560 if (IS_ERR(em_x270_sdio_ldo)) {
561 dev_err(dev, "can't request SDIO power supply: %ld\n",
562 PTR_ERR(em_x270_sdio_ldo));
563 return PTR_ERR(em_x270_sdio_ldo);
566 err = request_irq(gpio_to_irq(mmc_cd), em_x270_detect_int,
567 IRQF_DISABLED | IRQF_TRIGGER_RISING |
568 IRQF_TRIGGER_FALLING,
569 "MMC card detect", data);
571 dev_err(dev, "can't request MMC card detect IRQ: %d\n", err);
575 if (machine_is_em_x270()) {
576 err = gpio_request(GPIO95_MMC_WP, "MMC WP");
578 dev_err(dev, "can't request MMC write protect: %d\n",
582 gpio_direction_input(GPIO95_MMC_WP);
584 err = gpio_request(GPIO38_SD_PWEN, "sdio power");
586 dev_err(dev, "can't request MMC power control : %d\n",
590 gpio_direction_output(GPIO38_SD_PWEN, 1);
596 free_irq(gpio_to_irq(mmc_cd), data);
598 regulator_put(em_x270_sdio_ldo);
603 static int em_x270_mci_setpower(struct device *dev, unsigned int vdd)
605 struct pxamci_platform_data* p_d = dev->platform_data;
607 if ((1 << vdd) & p_d->ocr_mask) {
608 int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;
610 regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
611 return regulator_enable(em_x270_sdio_ldo);
613 regulator_disable(em_x270_sdio_ldo);
618 static void em_x270_mci_exit(struct device *dev, void *data)
620 free_irq(gpio_to_irq(mmc_cd), data);
621 regulator_put(em_x270_sdio_ldo);
623 if (machine_is_em_x270())
624 gpio_free(GPIO95_MMC_WP);
626 gpio_free(GPIO38_SD_PWEN);
629 static int em_x270_mci_get_ro(struct device *dev)
631 return gpio_get_value(GPIO95_MMC_WP);
634 static struct pxamci_platform_data em_x270_mci_platform_data = {
635 .detect_delay_ms = 250,
636 .ocr_mask = MMC_VDD_20_21|MMC_VDD_21_22|MMC_VDD_22_23|
637 MMC_VDD_24_25|MMC_VDD_25_26|MMC_VDD_26_27|
638 MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
639 MMC_VDD_30_31|MMC_VDD_31_32,
640 .init = em_x270_mci_init,
641 .setpower = em_x270_mci_setpower,
642 .exit = em_x270_mci_exit,
643 .gpio_card_detect = -1,
648 static void __init em_x270_init_mmc(void)
650 if (machine_is_em_x270())
651 em_x270_mci_platform_data.get_ro = em_x270_mci_get_ro;
653 pxa_set_mci_info(&em_x270_mci_platform_data);
656 static inline void em_x270_init_mmc(void) {}
660 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
661 static struct pxafb_mode_info em_x270_lcd_modes[] = {
690 static struct pxafb_mach_info em_x270_lcd = {
691 .modes = em_x270_lcd_modes,
693 .lcd_conn = LCD_COLOR_TFT_16BPP,
696 static void __init em_x270_init_lcd(void)
698 pxa_set_fb_info(NULL, &em_x270_lcd);
701 static inline void em_x270_init_lcd(void) {}
704 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
705 static struct pxa2xx_spi_master em_x270_spi_info = {
709 static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
715 static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
719 static struct pxa2xx_spi_master em_x270_spi_2_info = {
724 static struct pxa2xx_spi_chip em_x270_libertas_chip = {
731 static unsigned long em_x270_libertas_pin_config[] = {
739 static int em_x270_libertas_setup(struct spi_device *spi)
741 int err = gpio_request(GPIO115_WLAN_PWEN, "WLAN PWEN");
745 err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
749 if (machine_is_exeda()) {
750 err = gpio_request(GPIO37_WLAN_RST, "WLAN RST");
754 gpio_direction_output(GPIO37_WLAN_RST, 1);
758 gpio_direction_output(GPIO19_WLAN_STRAP, 1);
761 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_libertas_pin_config));
763 gpio_direction_output(GPIO115_WLAN_PWEN, 0);
765 gpio_set_value(GPIO115_WLAN_PWEN, 1);
768 spi->bits_per_word = 16;
774 gpio_free(GPIO19_WLAN_STRAP);
776 gpio_free(GPIO115_WLAN_PWEN);
781 static int em_x270_libertas_teardown(struct spi_device *spi)
783 gpio_set_value(GPIO115_WLAN_PWEN, 0);
784 gpio_free(GPIO115_WLAN_PWEN);
785 gpio_free(GPIO19_WLAN_STRAP);
787 if (machine_is_exeda()) {
788 gpio_set_value(GPIO37_WLAN_RST, 0);
789 gpio_free(GPIO37_WLAN_RST);
795 struct libertas_spi_platform_data em_x270_libertas_pdata = {
796 .use_dummy_writes = 1,
797 .setup = em_x270_libertas_setup,
798 .teardown = em_x270_libertas_teardown,
801 static struct spi_board_info em_x270_spi_devices[] __initdata = {
803 .modalias = "tdo24m",
804 .max_speed_hz = 1000000,
807 .controller_data = &em_x270_tdo24m_chip,
808 .platform_data = &em_x270_tdo24m_pdata,
811 .modalias = "libertas_spi",
812 .max_speed_hz = 13000000,
814 .irq = PXA_GPIO_TO_IRQ(116),
816 .controller_data = &em_x270_libertas_chip,
817 .platform_data = &em_x270_libertas_pdata,
821 static void __init em_x270_init_spi(void)
823 pxa2xx_set_spi_info(1, &em_x270_spi_info);
824 pxa2xx_set_spi_info(2, &em_x270_spi_2_info);
825 spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
828 static inline void em_x270_init_spi(void) {}
831 #if defined(CONFIG_SND_PXA2XX_LIB_AC97)
832 static pxa2xx_audio_ops_t em_x270_ac97_info = {
836 static void __init em_x270_init_ac97(void)
838 pxa_set_ac97_info(&em_x270_ac97_info);
841 static inline void em_x270_init_ac97(void) {}
844 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
845 static const unsigned int em_x270_module_matrix_keys[] = {
846 KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
847 KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
848 KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
851 static struct matrix_keymap_data em_x270_matrix_keymap_data = {
852 .keymap = em_x270_module_matrix_keys,
853 .keymap_size = ARRAY_SIZE(em_x270_module_matrix_keys),
856 struct pxa27x_keypad_platform_data em_x270_module_keypad_info = {
857 /* code map for the matrix keys */
858 .matrix_key_rows = 3,
859 .matrix_key_cols = 3,
860 .matrix_keymap_data = &em_x270_matrix_keymap_data,
863 static const unsigned int em_x270_exeda_matrix_keys[] = {
864 KEY(0, 0, KEY_RIGHTSHIFT), KEY(0, 1, KEY_RIGHTCTRL),
865 KEY(0, 2, KEY_RIGHTALT), KEY(0, 3, KEY_SPACE),
866 KEY(0, 4, KEY_LEFTALT), KEY(0, 5, KEY_LEFTCTRL),
867 KEY(0, 6, KEY_ENTER), KEY(0, 7, KEY_SLASH),
869 KEY(1, 0, KEY_DOT), KEY(1, 1, KEY_M),
870 KEY(1, 2, KEY_N), KEY(1, 3, KEY_B),
871 KEY(1, 4, KEY_V), KEY(1, 5, KEY_C),
872 KEY(1, 6, KEY_X), KEY(1, 7, KEY_Z),
874 KEY(2, 0, KEY_LEFTSHIFT), KEY(2, 1, KEY_SEMICOLON),
875 KEY(2, 2, KEY_L), KEY(2, 3, KEY_K),
876 KEY(2, 4, KEY_J), KEY(2, 5, KEY_H),
877 KEY(2, 6, KEY_G), KEY(2, 7, KEY_F),
879 KEY(3, 0, KEY_D), KEY(3, 1, KEY_S),
880 KEY(3, 2, KEY_A), KEY(3, 3, KEY_TAB),
881 KEY(3, 4, KEY_BACKSPACE), KEY(3, 5, KEY_P),
882 KEY(3, 6, KEY_O), KEY(3, 7, KEY_I),
884 KEY(4, 0, KEY_U), KEY(4, 1, KEY_Y),
885 KEY(4, 2, KEY_T), KEY(4, 3, KEY_R),
886 KEY(4, 4, KEY_E), KEY(4, 5, KEY_W),
887 KEY(4, 6, KEY_Q), KEY(4, 7, KEY_MINUS),
889 KEY(5, 0, KEY_0), KEY(5, 1, KEY_9),
890 KEY(5, 2, KEY_8), KEY(5, 3, KEY_7),
891 KEY(5, 4, KEY_6), KEY(5, 5, KEY_5),
892 KEY(5, 6, KEY_4), KEY(5, 7, KEY_3),
894 KEY(6, 0, KEY_2), KEY(6, 1, KEY_1),
895 KEY(6, 2, KEY_ENTER), KEY(6, 3, KEY_END),
896 KEY(6, 4, KEY_DOWN), KEY(6, 5, KEY_UP),
897 KEY(6, 6, KEY_MENU), KEY(6, 7, KEY_F1),
899 KEY(7, 0, KEY_LEFT), KEY(7, 1, KEY_RIGHT),
900 KEY(7, 2, KEY_BACK), KEY(7, 3, KEY_HOME),
901 KEY(7, 4, 0), KEY(7, 5, 0),
902 KEY(7, 6, 0), KEY(7, 7, 0),
905 static struct matrix_keymap_data em_x270_exeda_matrix_keymap_data = {
906 .keymap = em_x270_exeda_matrix_keys,
907 .keymap_size = ARRAY_SIZE(em_x270_exeda_matrix_keys),
910 struct pxa27x_keypad_platform_data em_x270_exeda_keypad_info = {
911 /* code map for the matrix keys */
912 .matrix_key_rows = 8,
913 .matrix_key_cols = 8,
914 .matrix_keymap_data = &em_x270_exeda_matrix_keymap_data,
917 static void __init em_x270_init_keypad(void)
919 if (machine_is_em_x270())
920 pxa_set_keypad_info(&em_x270_module_keypad_info);
922 pxa_set_keypad_info(&em_x270_exeda_keypad_info);
925 static inline void em_x270_init_keypad(void) {}
928 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
929 static struct gpio_keys_button gpio_keys_button[] = {
931 .desc = "sleep/wakeup",
939 static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
940 .buttons = gpio_keys_button,
944 static struct platform_device em_x270_gpio_keys = {
948 .platform_data = &em_x270_gpio_keys_data,
952 static void __init em_x270_init_gpio_keys(void)
954 platform_device_register(&em_x270_gpio_keys);
957 static inline void em_x270_init_gpio_keys(void) {}
960 /* Quick Capture Interface and sensor setup */
961 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
962 static struct regulator *em_x270_camera_ldo;
964 static int em_x270_sensor_init(void)
968 ret = gpio_request(cam_reset, "camera reset");
972 gpio_direction_output(cam_reset, 0);
974 em_x270_camera_ldo = regulator_get(NULL, "vcc cam");
975 if (em_x270_camera_ldo == NULL) {
976 gpio_free(cam_reset);
980 ret = regulator_enable(em_x270_camera_ldo);
982 regulator_put(em_x270_camera_ldo);
983 gpio_free(cam_reset);
987 gpio_set_value(cam_reset, 1);
992 struct pxacamera_platform_data em_x270_camera_platform_data = {
993 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
994 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
998 static int em_x270_sensor_power(struct device *dev, int on)
1001 int is_on = regulator_is_enabled(em_x270_camera_ldo);
1006 gpio_set_value(cam_reset, !on);
1009 ret = regulator_enable(em_x270_camera_ldo);
1011 ret = regulator_disable(em_x270_camera_ldo);
1016 gpio_set_value(cam_reset, on);
1021 static struct i2c_board_info em_x270_i2c_cam_info[] = {
1023 I2C_BOARD_INFO("mt9m111", 0x48),
1027 static struct soc_camera_link iclink = {
1029 .power = em_x270_sensor_power,
1030 .board_info = &em_x270_i2c_cam_info[0],
1031 .i2c_adapter_id = 0,
1034 static struct platform_device em_x270_camera = {
1035 .name = "soc-camera-pdrv",
1038 .platform_data = &iclink,
1042 static void __init em_x270_init_camera(void)
1044 if (em_x270_sensor_init() == 0) {
1045 pxa_set_camera_info(&em_x270_camera_platform_data);
1046 platform_device_register(&em_x270_camera);
1050 static inline void em_x270_init_camera(void) {}
1053 static struct regulator_bulk_data em_x270_gps_consumer_supply = {
1054 .supply = "vcc gps",
1057 static struct regulator_userspace_consumer_data em_x270_gps_consumer_data = {
1060 .supplies = &em_x270_gps_consumer_supply,
1063 static struct platform_device em_x270_gps_userspace_consumer = {
1064 .name = "reg-userspace-consumer",
1067 .platform_data = &em_x270_gps_consumer_data,
1071 static struct regulator_bulk_data em_x270_gprs_consumer_supply = {
1072 .supply = "vcc gprs",
1075 static struct regulator_userspace_consumer_data em_x270_gprs_consumer_data = {
1078 .supplies = &em_x270_gprs_consumer_supply
1081 static struct platform_device em_x270_gprs_userspace_consumer = {
1082 .name = "reg-userspace-consumer",
1085 .platform_data = &em_x270_gprs_consumer_data,
1089 static struct platform_device *em_x270_userspace_consumers[] = {
1090 &em_x270_gps_userspace_consumer,
1091 &em_x270_gprs_userspace_consumer,
1094 static void __init em_x270_userspace_consumers_init(void)
1096 platform_add_devices(ARRAY_AND_SIZE(em_x270_userspace_consumers));
1099 /* DA9030 related initializations */
1100 #define REGULATOR_CONSUMER(_name, _dev_name, _supply) \
1101 static struct regulator_consumer_supply _name##_consumers[] = { \
1102 REGULATOR_SUPPLY(_supply, _dev_name), \
1105 REGULATOR_CONSUMER(ldo3, "reg-userspace-consumer.0", "vcc gps");
1106 REGULATOR_CONSUMER(ldo5, NULL, "vcc cam");
1107 REGULATOR_CONSUMER(ldo10, "pxa2xx-mci", "vcc sdio");
1108 REGULATOR_CONSUMER(ldo12, NULL, "vcc usb");
1109 REGULATOR_CONSUMER(ldo19, "reg-userspace-consumer.1", "vcc gprs");
1110 REGULATOR_CONSUMER(buck2, NULL, "vcc_core");
1112 #define REGULATOR_INIT(_ldo, _min_uV, _max_uV, _ops_mask) \
1113 static struct regulator_init_data _ldo##_data = { \
1115 .min_uV = _min_uV, \
1116 .max_uV = _max_uV, \
1120 .valid_ops_mask = _ops_mask, \
1123 .num_consumer_supplies = ARRAY_SIZE(_ldo##_consumers), \
1124 .consumer_supplies = _ldo##_consumers, \
1127 REGULATOR_INIT(ldo3, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
1128 REGULATOR_INIT(ldo5, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1129 REGULATOR_INIT(ldo10, 2000000, 3200000,
1130 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE);
1131 REGULATOR_INIT(ldo12, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1132 REGULATOR_INIT(ldo19, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
1133 REGULATOR_INIT(buck2, 1000000, 1650000, REGULATOR_CHANGE_VOLTAGE);
1135 struct led_info em_x270_led_info = {
1136 .name = "em-x270:orange",
1137 .default_trigger = "battery-charging-or-full",
1140 struct power_supply_info em_x270_psy_info = {
1142 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
1143 .voltage_max_design = 4200000,
1144 .voltage_min_design = 3000000,
1148 static void em_x270_battery_low(void)
1150 #if defined(CONFIG_APM_EMULATION)
1151 apm_queue_event(APM_LOW_BATTERY);
1155 static void em_x270_battery_critical(void)
1157 #if defined(CONFIG_APM_EMULATION)
1158 apm_queue_event(APM_CRITICAL_SUSPEND);
1162 struct da9030_battery_info em_x270_batterty_info = {
1163 .battery_info = &em_x270_psy_info,
1165 .charge_milliamp = 1000,
1166 .charge_millivolt = 4200,
1170 .vbat_charge_start = 4100,
1171 .vbat_charge_stop = 4200,
1172 .vbat_charge_restart = 4000,
1174 .vcharge_min = 3200,
1175 .vcharge_max = 5500,
1179 .tbat_restart = 100,
1181 .batmon_interval = 0,
1183 .battery_low = em_x270_battery_low,
1184 .battery_critical = em_x270_battery_critical,
1187 #define DA9030_SUBDEV(_name, _id, _pdata) \
1189 .name = "da903x-" #_name, \
1190 .id = DA9030_ID_##_id, \
1191 .platform_data = _pdata, \
1194 #define DA9030_LDO(num) DA9030_SUBDEV(regulator, LDO##num, &ldo##num##_data)
1196 struct da903x_subdev_info em_x270_da9030_subdevs[] = {
1203 DA9030_SUBDEV(regulator, BUCK2, &buck2_data),
1205 DA9030_SUBDEV(led, LED_PC, &em_x270_led_info),
1206 DA9030_SUBDEV(backlight, WLED, &em_x270_led_info),
1207 DA9030_SUBDEV(battery, BAT, &em_x270_batterty_info),
1210 static struct da903x_platform_data em_x270_da9030_info = {
1211 .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
1212 .subdevs = em_x270_da9030_subdevs,
1215 static struct i2c_board_info em_x270_i2c_pmic_info = {
1216 I2C_BOARD_INFO("da9030", 0x49),
1217 .irq = PXA_GPIO_TO_IRQ(0),
1218 .platform_data = &em_x270_da9030_info,
1221 static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
1225 static void __init em_x270_init_da9030(void)
1227 pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
1228 i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
1231 static struct pca953x_platform_data exeda_gpio_ext_pdata = {
1235 static struct i2c_board_info exeda_i2c_info[] = {
1237 I2C_BOARD_INFO("pca9555", 0x21),
1238 .platform_data = &exeda_gpio_ext_pdata,
1242 static struct i2c_pxa_platform_data em_x270_i2c_info = {
1246 static void __init em_x270_init_i2c(void)
1248 pxa_set_i2c_info(&em_x270_i2c_info);
1250 if (machine_is_exeda())
1251 i2c_register_board_info(0, ARRAY_AND_SIZE(exeda_i2c_info));
1254 static void __init em_x270_module_init(void)
1256 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
1258 mmc_cd = GPIO13_MMC_CD;
1259 nand_rb = GPIO56_NAND_RB;
1260 dm9000_flags = DM9000_PLATF_32BITONLY;
1261 cam_reset = GPIO93_CAM_RESET;
1262 usb_hub_reset = GPIO16_USB_HUB_RESET;
1265 static void __init em_x270_exeda_init(void)
1267 pxa2xx_mfp_config(ARRAY_AND_SIZE(exeda_pin_config));
1269 mmc_cd = GPIO114_MMC_CD;
1270 nand_rb = GPIO20_NAND_RB;
1271 dm9000_flags = DM9000_PLATF_16BITONLY;
1272 cam_reset = GPIO130_CAM_RESET;
1273 usb_hub_reset = GPIO10_USB_HUB_RESET;
1276 static void __init em_x270_init(void)
1278 pxa2xx_mfp_config(ARRAY_AND_SIZE(common_pin_config));
1280 pxa_set_ffuart_info(NULL);
1281 pxa_set_btuart_info(NULL);
1282 pxa_set_stuart_info(NULL);
1285 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
1288 if (machine_is_em_x270())
1289 em_x270_module_init();
1290 else if (machine_is_exeda())
1291 em_x270_exeda_init();
1293 panic("Unsupported machine: %d\n", machine_arch_type);
1295 em_x270_init_da9030();
1296 em_x270_init_dm9000();
1298 em_x270_init_nand();
1302 em_x270_init_ohci();
1303 em_x270_init_keypad();
1304 em_x270_init_gpio_keys();
1305 em_x270_init_ac97();
1308 em_x270_init_camera();
1309 em_x270_userspace_consumers_init();
1312 MACHINE_START(EM_X270, "Compulab EM-X270")
1313 .atag_offset = 0x100,
1314 .map_io = pxa27x_map_io,
1315 .nr_irqs = PXA_NR_IRQS,
1316 .init_irq = pxa27x_init_irq,
1317 .handle_irq = pxa27x_handle_irq,
1318 .init_time = pxa_timer_init,
1319 .init_machine = em_x270_init,
1320 .restart = pxa_restart,
1323 MACHINE_START(EXEDA, "Compulab eXeda")
1324 .atag_offset = 0x100,
1325 .map_io = pxa27x_map_io,
1326 .nr_irqs = PXA_NR_IRQS,
1327 .init_irq = pxa27x_init_irq,
1328 .handle_irq = pxa27x_handle_irq,
1329 .init_time = pxa_timer_init,
1330 .init_machine = em_x270_init,
1331 .restart = pxa_restart,