2 * Support for CompuLab EM-X270 platform
4 * Copyright (C) 2007, 2008 CompuLab, Ltd.
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/platform_data/rtc-v3020.h>
18 #include <linux/mtd/platnand.h>
19 #include <linux/mtd/physmap.h>
20 #include <linux/input.h>
21 #include <linux/gpio_keys.h>
22 #include <linux/gpio.h>
23 #include <linux/gpio/machine.h>
24 #include <linux/mfd/da903x.h>
25 #include <linux/regulator/machine.h>
26 #include <linux/regulator/fixed.h>
27 #include <linux/spi/spi.h>
28 #include <linux/spi/tdo24m.h>
29 #include <linux/spi/libertas_spi.h>
30 #include <linux/spi/pxa2xx_spi.h>
31 #include <linux/power_supply.h>
32 #include <linux/apm-emulation.h>
33 #include <linux/i2c.h>
34 #include <linux/platform_data/pca953x.h>
35 #include <linux/platform_data/i2c-pxa.h>
36 #include <linux/regulator/userspace-consumer.h>
38 #include <asm/mach-types.h>
39 #include <asm/mach/arch.h>
42 #include "pxa27x-udc.h"
43 #include <mach/audio.h>
44 #include <linux/platform_data/video-pxafb.h>
45 #include <linux/platform_data/usb-ohci-pxa27x.h>
46 #include <linux/platform_data/mmc-pxamci.h>
47 #include <linux/platform_data/keypad-pxa27x.h>
48 #include <linux/platform_data/media/camera-pxa.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 PXA_GPIO_TO_IRQ(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,
111 GPIOxx_LCD_TFT_16BPP,
132 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
133 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
134 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
135 GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
136 GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
137 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
138 GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
139 GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
156 GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
161 /* SDRAM and local bus */
170 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* sleep/resume button */
173 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
174 GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
177 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
180 GPIO41_GPIO, /* DM9000 interrupt */
183 static unsigned long em_x270_pin_config[] = {
184 GPIO13_GPIO, /* MMC card detect */
185 GPIO16_GPIO, /* USB hub reset */
186 GPIO56_GPIO, /* NAND Ready/Busy */
187 GPIO93_GPIO | MFP_LPM_DRIVE_LOW, /* Camera reset */
188 GPIO95_GPIO, /* MMC Write protect */
191 static unsigned long exeda_pin_config[] = {
192 GPIO10_GPIO, /* USB hub reset */
193 GPIO20_GPIO, /* NAND Ready/Busy */
194 GPIO38_GPIO | MFP_LPM_DRIVE_LOW, /* SD slot power */
195 GPIO95_GPIO, /* touchpad IRQ */
196 GPIO114_GPIO, /* MMC card detect */
199 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
200 static struct resource em_x270_dm9000_resource[] = {
202 .start = PXA_CS2_PHYS,
203 .end = PXA_CS2_PHYS + 3,
204 .flags = IORESOURCE_MEM,
207 .start = PXA_CS2_PHYS + 8,
208 .end = PXA_CS2_PHYS + 8 + 0x3f,
209 .flags = IORESOURCE_MEM,
212 .start = EM_X270_ETHIRQ,
213 .end = EM_X270_ETHIRQ,
214 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
218 static struct dm9000_plat_data em_x270_dm9000_platdata = {
219 .flags = DM9000_PLATF_NO_EEPROM,
222 static struct platform_device em_x270_dm9000 = {
225 .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
226 .resource = em_x270_dm9000_resource,
228 .platform_data = &em_x270_dm9000_platdata,
232 static void __init em_x270_init_dm9000(void)
234 em_x270_dm9000_platdata.flags |= dm9000_flags;
235 platform_device_register(&em_x270_dm9000);
238 static inline void em_x270_init_dm9000(void) {}
242 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
243 static struct resource em_x270_v3020_resource[] = {
245 .start = PXA_CS4_PHYS,
246 .end = PXA_CS4_PHYS + 3,
247 .flags = IORESOURCE_MEM,
251 static struct v3020_platform_data em_x270_v3020_platdata = {
255 static struct platform_device em_x270_rtc = {
257 .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
258 .resource = em_x270_v3020_resource,
261 .platform_data = &em_x270_v3020_platdata,
265 static void __init em_x270_init_rtc(void)
267 platform_device_register(&em_x270_rtc);
270 static inline void em_x270_init_rtc(void) {}
274 #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
275 static inline void nand_cs_on(void)
277 gpio_set_value(GPIO11_NAND_CS, 0);
280 static void nand_cs_off(void)
284 gpio_set_value(GPIO11_NAND_CS, 1);
287 /* hardware specific access to control-lines */
288 static void em_x270_nand_cmd_ctl(struct nand_chip *this, int dat,
291 unsigned long nandaddr = (unsigned long)this->legacy.IO_ADDR_W;
295 if (ctrl & NAND_CTRL_CHANGE) {
297 nandaddr |= (1 << 3);
299 nandaddr &= ~(1 << 3);
301 nandaddr |= (1 << 2);
303 nandaddr &= ~(1 << 2);
311 this->legacy.IO_ADDR_W = (void __iomem *)nandaddr;
312 if (dat != NAND_CMD_NONE)
313 writel(dat, this->legacy.IO_ADDR_W);
318 /* read device ready pin */
319 static int em_x270_nand_device_ready(struct nand_chip *this)
323 return gpio_get_value(nand_rb);
326 static struct mtd_partition em_x270_partition_info[] = {
334 .offset = MTDPART_OFS_APPEND,
335 .size = MTDPART_SIZ_FULL
339 struct platform_nand_data em_x270_nand_platdata = {
343 .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
344 .partitions = em_x270_partition_info,
348 .dev_ready = em_x270_nand_device_ready,
350 .cmd_ctrl = em_x270_nand_cmd_ctl,
354 static struct resource em_x270_nand_resource[] = {
356 .start = PXA_CS1_PHYS,
357 .end = PXA_CS1_PHYS + 12,
358 .flags = IORESOURCE_MEM,
362 static struct platform_device em_x270_nand = {
364 .num_resources = ARRAY_SIZE(em_x270_nand_resource),
365 .resource = em_x270_nand_resource,
368 .platform_data = &em_x270_nand_platdata,
372 static void __init em_x270_init_nand(void)
376 err = gpio_request(GPIO11_NAND_CS, "NAND CS");
378 pr_warn("EM-X270: failed to request NAND CS gpio\n");
382 gpio_direction_output(GPIO11_NAND_CS, 1);
384 err = gpio_request(nand_rb, "NAND R/B");
386 pr_warn("EM-X270: failed to request NAND R/B gpio\n");
387 gpio_free(GPIO11_NAND_CS);
391 gpio_direction_input(nand_rb);
393 platform_device_register(&em_x270_nand);
396 static inline void em_x270_init_nand(void) {}
399 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
400 static struct mtd_partition em_x270_nor_parts[] = {
402 .name = "Bootloader",
403 .offset = 0x00000000,
405 .mask_flags = MTD_WRITEABLE /* force read-only */
407 .name = "Environment",
408 .offset = 0x00050000,
412 .offset = 0x00060000,
414 .mask_flags = MTD_WRITEABLE /* force read-only */
416 .name = "Splashscreen",
417 .offset = 0x000b0000,
422 static struct physmap_flash_data em_x270_nor_data[] = {
425 .parts = em_x270_nor_parts,
426 .nr_parts = ARRAY_SIZE(em_x270_nor_parts),
430 static struct resource em_x270_nor_flash_resource = {
431 .start = PXA_CS0_PHYS,
432 .end = PXA_CS0_PHYS + SZ_1M - 1,
433 .flags = IORESOURCE_MEM,
436 static struct platform_device em_x270_physmap_flash = {
437 .name = "physmap-flash",
440 .resource = &em_x270_nor_flash_resource,
442 .platform_data = &em_x270_nor_data,
446 static void __init em_x270_init_nor(void)
448 platform_device_register(&em_x270_physmap_flash);
451 static inline void em_x270_init_nor(void) {}
454 /* PXA27x OHCI controller setup */
455 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
456 static struct regulator *em_x270_usb_ldo;
458 static int em_x270_usb_hub_init(void)
462 em_x270_usb_ldo = regulator_get(NULL, "vcc usb");
463 if (IS_ERR(em_x270_usb_ldo))
464 return PTR_ERR(em_x270_usb_ldo);
466 err = gpio_request(GPIO9_USB_VBUS_EN, "vbus en");
468 goto err_free_usb_ldo;
470 err = gpio_request(usb_hub_reset, "hub rst");
472 goto err_free_vbus_gpio;
474 /* USB Hub power-on and reset */
475 gpio_direction_output(usb_hub_reset, 1);
476 gpio_direction_output(GPIO9_USB_VBUS_EN, 0);
477 err = regulator_enable(em_x270_usb_ldo);
479 goto err_free_rst_gpio;
481 gpio_set_value(usb_hub_reset, 0);
482 gpio_set_value(usb_hub_reset, 1);
483 regulator_disable(em_x270_usb_ldo);
484 err = regulator_enable(em_x270_usb_ldo);
486 goto err_free_rst_gpio;
488 gpio_set_value(usb_hub_reset, 0);
489 gpio_set_value(GPIO9_USB_VBUS_EN, 1);
494 gpio_free(usb_hub_reset);
496 gpio_free(GPIO9_USB_VBUS_EN);
498 regulator_put(em_x270_usb_ldo);
503 static int em_x270_ohci_init(struct device *dev)
507 /* we don't want to entirely disable USB if the HUB init failed */
508 err = em_x270_usb_hub_init();
510 pr_err("USB Hub initialization failed: %d\n", err);
512 /* enable port 2 transiever */
513 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
518 static void em_x270_ohci_exit(struct device *dev)
520 gpio_free(usb_hub_reset);
521 gpio_free(GPIO9_USB_VBUS_EN);
523 if (!IS_ERR(em_x270_usb_ldo)) {
524 if (regulator_is_enabled(em_x270_usb_ldo))
525 regulator_disable(em_x270_usb_ldo);
527 regulator_put(em_x270_usb_ldo);
531 static struct pxaohci_platform_data em_x270_ohci_platform_data = {
532 .port_mode = PMM_PERPORT_MODE,
533 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
534 .init = em_x270_ohci_init,
535 .exit = em_x270_ohci_exit,
538 static void __init em_x270_init_ohci(void)
540 pxa_set_ohci_info(&em_x270_ohci_platform_data);
543 static inline void em_x270_init_ohci(void) {}
546 /* MCI controller setup */
547 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
548 static struct regulator *em_x270_sdio_ldo;
550 static struct gpiod_lookup_table em_x270_mci_wp_gpio_table = {
551 .dev_id = "pxa2xx-mci.0",
553 /* Write protect on GPIO 95 */
554 GPIO_LOOKUP("gpio-pxa", GPIO95_MMC_WP, "wp", GPIO_ACTIVE_LOW),
559 static int em_x270_mci_init(struct device *dev,
560 irq_handler_t em_x270_detect_int,
565 em_x270_sdio_ldo = regulator_get(dev, "vcc sdio");
566 if (IS_ERR(em_x270_sdio_ldo)) {
567 dev_err(dev, "can't request SDIO power supply: %ld\n",
568 PTR_ERR(em_x270_sdio_ldo));
569 return PTR_ERR(em_x270_sdio_ldo);
572 err = request_irq(gpio_to_irq(mmc_cd), em_x270_detect_int,
573 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
574 "MMC card detect", data);
576 dev_err(dev, "can't request MMC card detect IRQ: %d\n", err);
580 if (!machine_is_em_x270()) {
581 err = gpio_request(GPIO38_SD_PWEN, "sdio power");
583 dev_err(dev, "can't request MMC power control : %d\n",
587 gpio_direction_output(GPIO38_SD_PWEN, 1);
593 free_irq(gpio_to_irq(mmc_cd), data);
595 regulator_put(em_x270_sdio_ldo);
600 static int em_x270_mci_setpower(struct device *dev, unsigned int vdd)
602 struct pxamci_platform_data* p_d = dev->platform_data;
604 if ((1 << vdd) & p_d->ocr_mask) {
605 int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;
607 regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
608 return regulator_enable(em_x270_sdio_ldo);
610 regulator_disable(em_x270_sdio_ldo);
615 static void em_x270_mci_exit(struct device *dev, void *data)
617 free_irq(gpio_to_irq(mmc_cd), data);
618 regulator_put(em_x270_sdio_ldo);
620 if (!machine_is_em_x270())
621 gpio_free(GPIO38_SD_PWEN);
624 static struct pxamci_platform_data em_x270_mci_platform_data = {
625 .detect_delay_ms = 250,
626 .ocr_mask = MMC_VDD_20_21|MMC_VDD_21_22|MMC_VDD_22_23|
627 MMC_VDD_24_25|MMC_VDD_25_26|MMC_VDD_26_27|
628 MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
629 MMC_VDD_30_31|MMC_VDD_31_32,
630 .init = em_x270_mci_init,
631 .setpower = em_x270_mci_setpower,
632 .exit = em_x270_mci_exit,
635 static void __init em_x270_init_mmc(void)
637 if (machine_is_em_x270())
638 gpiod_add_lookup_table(&em_x270_mci_wp_gpio_table);
640 pxa_set_mci_info(&em_x270_mci_platform_data);
643 static inline void em_x270_init_mmc(void) {}
647 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
648 static struct pxafb_mode_info em_x270_lcd_modes[] = {
677 static struct pxafb_mach_info em_x270_lcd = {
678 .modes = em_x270_lcd_modes,
680 .lcd_conn = LCD_COLOR_TFT_16BPP,
683 static void __init em_x270_init_lcd(void)
685 pxa_set_fb_info(NULL, &em_x270_lcd);
688 static inline void em_x270_init_lcd(void) {}
691 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
692 static struct pxa2xx_spi_controller em_x270_spi_info = {
696 static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
702 static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
706 static struct pxa2xx_spi_controller em_x270_spi_2_info = {
711 static struct pxa2xx_spi_chip em_x270_libertas_chip = {
718 static unsigned long em_x270_libertas_pin_config[] = {
726 static int em_x270_libertas_setup(struct spi_device *spi)
728 int err = gpio_request(GPIO115_WLAN_PWEN, "WLAN PWEN");
732 err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
736 if (machine_is_exeda()) {
737 err = gpio_request(GPIO37_WLAN_RST, "WLAN RST");
741 gpio_direction_output(GPIO37_WLAN_RST, 1);
745 gpio_direction_output(GPIO19_WLAN_STRAP, 1);
748 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_libertas_pin_config));
750 gpio_direction_output(GPIO115_WLAN_PWEN, 0);
752 gpio_set_value(GPIO115_WLAN_PWEN, 1);
755 spi->bits_per_word = 16;
761 gpio_free(GPIO19_WLAN_STRAP);
763 gpio_free(GPIO115_WLAN_PWEN);
768 static int em_x270_libertas_teardown(struct spi_device *spi)
770 gpio_set_value(GPIO115_WLAN_PWEN, 0);
771 gpio_free(GPIO115_WLAN_PWEN);
772 gpio_free(GPIO19_WLAN_STRAP);
774 if (machine_is_exeda()) {
775 gpio_set_value(GPIO37_WLAN_RST, 0);
776 gpio_free(GPIO37_WLAN_RST);
782 struct libertas_spi_platform_data em_x270_libertas_pdata = {
783 .use_dummy_writes = 1,
784 .setup = em_x270_libertas_setup,
785 .teardown = em_x270_libertas_teardown,
788 static struct spi_board_info em_x270_spi_devices[] __initdata = {
790 .modalias = "tdo24m",
791 .max_speed_hz = 1000000,
794 .controller_data = &em_x270_tdo24m_chip,
795 .platform_data = &em_x270_tdo24m_pdata,
798 .modalias = "libertas_spi",
799 .max_speed_hz = 13000000,
801 .irq = PXA_GPIO_TO_IRQ(116),
803 .controller_data = &em_x270_libertas_chip,
804 .platform_data = &em_x270_libertas_pdata,
808 static void __init em_x270_init_spi(void)
810 pxa2xx_set_spi_info(1, &em_x270_spi_info);
811 pxa2xx_set_spi_info(2, &em_x270_spi_2_info);
812 spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
815 static inline void em_x270_init_spi(void) {}
818 #if defined(CONFIG_SND_PXA2XX_LIB_AC97)
819 static pxa2xx_audio_ops_t em_x270_ac97_info = {
823 static void __init em_x270_init_ac97(void)
825 pxa_set_ac97_info(&em_x270_ac97_info);
828 static inline void em_x270_init_ac97(void) {}
831 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
832 static const unsigned int em_x270_module_matrix_keys[] = {
833 KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
834 KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
835 KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
838 static struct matrix_keymap_data em_x270_matrix_keymap_data = {
839 .keymap = em_x270_module_matrix_keys,
840 .keymap_size = ARRAY_SIZE(em_x270_module_matrix_keys),
843 struct pxa27x_keypad_platform_data em_x270_module_keypad_info = {
844 /* code map for the matrix keys */
845 .matrix_key_rows = 3,
846 .matrix_key_cols = 3,
847 .matrix_keymap_data = &em_x270_matrix_keymap_data,
850 static const unsigned int em_x270_exeda_matrix_keys[] = {
851 KEY(0, 0, KEY_RIGHTSHIFT), KEY(0, 1, KEY_RIGHTCTRL),
852 KEY(0, 2, KEY_RIGHTALT), KEY(0, 3, KEY_SPACE),
853 KEY(0, 4, KEY_LEFTALT), KEY(0, 5, KEY_LEFTCTRL),
854 KEY(0, 6, KEY_ENTER), KEY(0, 7, KEY_SLASH),
856 KEY(1, 0, KEY_DOT), KEY(1, 1, KEY_M),
857 KEY(1, 2, KEY_N), KEY(1, 3, KEY_B),
858 KEY(1, 4, KEY_V), KEY(1, 5, KEY_C),
859 KEY(1, 6, KEY_X), KEY(1, 7, KEY_Z),
861 KEY(2, 0, KEY_LEFTSHIFT), KEY(2, 1, KEY_SEMICOLON),
862 KEY(2, 2, KEY_L), KEY(2, 3, KEY_K),
863 KEY(2, 4, KEY_J), KEY(2, 5, KEY_H),
864 KEY(2, 6, KEY_G), KEY(2, 7, KEY_F),
866 KEY(3, 0, KEY_D), KEY(3, 1, KEY_S),
867 KEY(3, 2, KEY_A), KEY(3, 3, KEY_TAB),
868 KEY(3, 4, KEY_BACKSPACE), KEY(3, 5, KEY_P),
869 KEY(3, 6, KEY_O), KEY(3, 7, KEY_I),
871 KEY(4, 0, KEY_U), KEY(4, 1, KEY_Y),
872 KEY(4, 2, KEY_T), KEY(4, 3, KEY_R),
873 KEY(4, 4, KEY_E), KEY(4, 5, KEY_W),
874 KEY(4, 6, KEY_Q), KEY(4, 7, KEY_MINUS),
876 KEY(5, 0, KEY_0), KEY(5, 1, KEY_9),
877 KEY(5, 2, KEY_8), KEY(5, 3, KEY_7),
878 KEY(5, 4, KEY_6), KEY(5, 5, KEY_5),
879 KEY(5, 6, KEY_4), KEY(5, 7, KEY_3),
881 KEY(6, 0, KEY_2), KEY(6, 1, KEY_1),
882 KEY(6, 2, KEY_ENTER), KEY(6, 3, KEY_END),
883 KEY(6, 4, KEY_DOWN), KEY(6, 5, KEY_UP),
884 KEY(6, 6, KEY_MENU), KEY(6, 7, KEY_F1),
886 KEY(7, 0, KEY_LEFT), KEY(7, 1, KEY_RIGHT),
887 KEY(7, 2, KEY_BACK), KEY(7, 3, KEY_HOME),
888 KEY(7, 4, 0), KEY(7, 5, 0),
889 KEY(7, 6, 0), KEY(7, 7, 0),
892 static struct matrix_keymap_data em_x270_exeda_matrix_keymap_data = {
893 .keymap = em_x270_exeda_matrix_keys,
894 .keymap_size = ARRAY_SIZE(em_x270_exeda_matrix_keys),
897 struct pxa27x_keypad_platform_data em_x270_exeda_keypad_info = {
898 /* code map for the matrix keys */
899 .matrix_key_rows = 8,
900 .matrix_key_cols = 8,
901 .matrix_keymap_data = &em_x270_exeda_matrix_keymap_data,
904 static void __init em_x270_init_keypad(void)
906 if (machine_is_em_x270())
907 pxa_set_keypad_info(&em_x270_module_keypad_info);
909 pxa_set_keypad_info(&em_x270_exeda_keypad_info);
912 static inline void em_x270_init_keypad(void) {}
915 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
916 static struct gpio_keys_button gpio_keys_button[] = {
918 .desc = "sleep/wakeup",
926 static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
927 .buttons = gpio_keys_button,
931 static struct platform_device em_x270_gpio_keys = {
935 .platform_data = &em_x270_gpio_keys_data,
939 static void __init em_x270_init_gpio_keys(void)
941 platform_device_register(&em_x270_gpio_keys);
944 static inline void em_x270_init_gpio_keys(void) {}
947 /* Quick Capture Interface and sensor setup */
948 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
949 static int em_x270_sensor_init(void)
953 ret = gpio_request(cam_reset, "camera reset");
957 gpio_direction_output(cam_reset, 0);
958 gpio_set_value(cam_reset, 1);
963 static struct regulator_consumer_supply camera_dummy_supplies[] = {
964 REGULATOR_SUPPLY("vdd", "0-005d"),
967 static struct regulator_init_data camera_dummy_initdata = {
968 .consumer_supplies = camera_dummy_supplies,
969 .num_consumer_supplies = ARRAY_SIZE(camera_dummy_supplies),
971 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
975 static struct fixed_voltage_config camera_dummy_config = {
976 .supply_name = "camera_vdd",
977 .input_supply = "vcc cam",
978 .microvolts = 2800000,
979 .init_data = &camera_dummy_initdata,
982 static struct platform_device camera_supply_dummy_device = {
983 .name = "reg-fixed-voltage",
986 .platform_data = &camera_dummy_config,
990 struct pxacamera_platform_data em_x270_camera_platform_data = {
991 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
992 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
994 .sensor_i2c_adapter_id = 0,
995 .sensor_i2c_address = 0x5d,
998 static void __init em_x270_init_camera(void)
1000 if (em_x270_sensor_init() == 0)
1001 pxa_set_camera_info(&em_x270_camera_platform_data);
1002 platform_device_register(&camera_supply_dummy_device);
1005 static inline void em_x270_init_camera(void) {}
1008 static struct regulator_bulk_data em_x270_gps_consumer_supply = {
1009 .supply = "vcc gps",
1012 static struct regulator_userspace_consumer_data em_x270_gps_consumer_data = {
1015 .supplies = &em_x270_gps_consumer_supply,
1018 static struct platform_device em_x270_gps_userspace_consumer = {
1019 .name = "reg-userspace-consumer",
1022 .platform_data = &em_x270_gps_consumer_data,
1026 static struct regulator_bulk_data em_x270_gprs_consumer_supply = {
1027 .supply = "vcc gprs",
1030 static struct regulator_userspace_consumer_data em_x270_gprs_consumer_data = {
1033 .supplies = &em_x270_gprs_consumer_supply
1036 static struct platform_device em_x270_gprs_userspace_consumer = {
1037 .name = "reg-userspace-consumer",
1040 .platform_data = &em_x270_gprs_consumer_data,
1044 static struct platform_device *em_x270_userspace_consumers[] = {
1045 &em_x270_gps_userspace_consumer,
1046 &em_x270_gprs_userspace_consumer,
1049 static void __init em_x270_userspace_consumers_init(void)
1051 platform_add_devices(ARRAY_AND_SIZE(em_x270_userspace_consumers));
1054 /* DA9030 related initializations */
1055 #define REGULATOR_CONSUMER(_name, _dev_name, _supply) \
1056 static struct regulator_consumer_supply _name##_consumers[] = { \
1057 REGULATOR_SUPPLY(_supply, _dev_name), \
1060 REGULATOR_CONSUMER(ldo3, "reg-userspace-consumer.0", "vcc gps");
1061 REGULATOR_CONSUMER(ldo5, NULL, "vcc cam");
1062 REGULATOR_CONSUMER(ldo10, "pxa2xx-mci", "vcc sdio");
1063 REGULATOR_CONSUMER(ldo12, NULL, "vcc usb");
1064 REGULATOR_CONSUMER(ldo19, "reg-userspace-consumer.1", "vcc gprs");
1065 REGULATOR_CONSUMER(buck2, NULL, "vcc_core");
1067 #define REGULATOR_INIT(_ldo, _min_uV, _max_uV, _ops_mask) \
1068 static struct regulator_init_data _ldo##_data = { \
1070 .min_uV = _min_uV, \
1071 .max_uV = _max_uV, \
1075 .valid_ops_mask = _ops_mask, \
1078 .num_consumer_supplies = ARRAY_SIZE(_ldo##_consumers), \
1079 .consumer_supplies = _ldo##_consumers, \
1082 REGULATOR_INIT(ldo3, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
1083 REGULATOR_INIT(ldo5, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1084 REGULATOR_INIT(ldo10, 2000000, 3200000,
1085 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE);
1086 REGULATOR_INIT(ldo12, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1087 REGULATOR_INIT(ldo19, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
1088 REGULATOR_INIT(buck2, 1000000, 1650000, REGULATOR_CHANGE_VOLTAGE);
1090 struct led_info em_x270_led_info = {
1091 .name = "em-x270:orange",
1092 .default_trigger = "battery-charging-or-full",
1095 struct power_supply_info em_x270_psy_info = {
1097 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
1098 .voltage_max_design = 4200000,
1099 .voltage_min_design = 3000000,
1103 static void em_x270_battery_low(void)
1105 #if defined(CONFIG_APM_EMULATION)
1106 apm_queue_event(APM_LOW_BATTERY);
1110 static void em_x270_battery_critical(void)
1112 #if defined(CONFIG_APM_EMULATION)
1113 apm_queue_event(APM_CRITICAL_SUSPEND);
1117 struct da9030_battery_info em_x270_batterty_info = {
1118 .battery_info = &em_x270_psy_info,
1120 .charge_milliamp = 1000,
1121 .charge_millivolt = 4200,
1125 .vbat_charge_start = 4100,
1126 .vbat_charge_stop = 4200,
1127 .vbat_charge_restart = 4000,
1129 .vcharge_min = 3200,
1130 .vcharge_max = 5500,
1134 .tbat_restart = 100,
1136 .batmon_interval = 0,
1138 .battery_low = em_x270_battery_low,
1139 .battery_critical = em_x270_battery_critical,
1142 #define DA9030_SUBDEV(_name, _id, _pdata) \
1144 .name = "da903x-" #_name, \
1145 .id = DA9030_ID_##_id, \
1146 .platform_data = _pdata, \
1149 #define DA9030_LDO(num) DA9030_SUBDEV(regulator, LDO##num, &ldo##num##_data)
1151 struct da903x_subdev_info em_x270_da9030_subdevs[] = {
1158 DA9030_SUBDEV(regulator, BUCK2, &buck2_data),
1160 DA9030_SUBDEV(led, LED_PC, &em_x270_led_info),
1161 DA9030_SUBDEV(backlight, WLED, &em_x270_led_info),
1162 DA9030_SUBDEV(battery, BAT, &em_x270_batterty_info),
1165 static struct da903x_platform_data em_x270_da9030_info = {
1166 .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
1167 .subdevs = em_x270_da9030_subdevs,
1170 static struct i2c_board_info em_x270_i2c_pmic_info = {
1171 I2C_BOARD_INFO("da9030", 0x49),
1172 .irq = PXA_GPIO_TO_IRQ(0),
1173 .platform_data = &em_x270_da9030_info,
1176 static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
1180 static void __init em_x270_init_da9030(void)
1182 pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
1183 i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
1186 static struct pca953x_platform_data exeda_gpio_ext_pdata = {
1190 static struct i2c_board_info exeda_i2c_info[] = {
1192 I2C_BOARD_INFO("pca9555", 0x21),
1193 .platform_data = &exeda_gpio_ext_pdata,
1197 static struct i2c_pxa_platform_data em_x270_i2c_info = {
1201 static void __init em_x270_init_i2c(void)
1203 pxa_set_i2c_info(&em_x270_i2c_info);
1205 if (machine_is_exeda())
1206 i2c_register_board_info(0, ARRAY_AND_SIZE(exeda_i2c_info));
1209 static void __init em_x270_module_init(void)
1211 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
1213 mmc_cd = GPIO13_MMC_CD;
1214 nand_rb = GPIO56_NAND_RB;
1215 dm9000_flags = DM9000_PLATF_32BITONLY;
1216 cam_reset = GPIO93_CAM_RESET;
1217 usb_hub_reset = GPIO16_USB_HUB_RESET;
1220 static void __init em_x270_exeda_init(void)
1222 pxa2xx_mfp_config(ARRAY_AND_SIZE(exeda_pin_config));
1224 mmc_cd = GPIO114_MMC_CD;
1225 nand_rb = GPIO20_NAND_RB;
1226 dm9000_flags = DM9000_PLATF_16BITONLY;
1227 cam_reset = GPIO130_CAM_RESET;
1228 usb_hub_reset = GPIO10_USB_HUB_RESET;
1231 static void __init em_x270_init(void)
1233 pxa2xx_mfp_config(ARRAY_AND_SIZE(common_pin_config));
1235 pxa_set_ffuart_info(NULL);
1236 pxa_set_btuart_info(NULL);
1237 pxa_set_stuart_info(NULL);
1240 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
1243 if (machine_is_em_x270())
1244 em_x270_module_init();
1245 else if (machine_is_exeda())
1246 em_x270_exeda_init();
1248 panic("Unsupported machine: %d\n", machine_arch_type);
1250 em_x270_init_da9030();
1251 em_x270_init_dm9000();
1253 em_x270_init_nand();
1257 em_x270_init_ohci();
1258 em_x270_init_keypad();
1259 em_x270_init_gpio_keys();
1260 em_x270_init_ac97();
1263 em_x270_init_camera();
1264 em_x270_userspace_consumers_init();
1266 regulator_has_full_constraints();
1269 MACHINE_START(EM_X270, "Compulab EM-X270")
1270 .atag_offset = 0x100,
1271 .map_io = pxa27x_map_io,
1272 .nr_irqs = PXA_NR_IRQS,
1273 .init_irq = pxa27x_init_irq,
1274 .handle_irq = pxa27x_handle_irq,
1275 .init_time = pxa_timer_init,
1276 .init_machine = em_x270_init,
1277 .restart = pxa_restart,
1280 MACHINE_START(EXEDA, "Compulab eXeda")
1281 .atag_offset = 0x100,
1282 .map_io = pxa27x_map_io,
1283 .nr_irqs = PXA_NR_IRQS,
1284 .init_irq = pxa27x_init_irq,
1285 .handle_irq = pxa27x_handle_irq,
1286 .init_time = pxa_timer_init,
1287 .init_machine = em_x270_init,
1288 .restart = pxa_restart,