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)
59 /* eXeda specific GPIOs */
60 #define GPIO114_MMC_CD (114)
61 #define GPIO20_NAND_RB (20)
62 #define GPIO38_SD_PWEN (38)
63 #define GPIO37_WLAN_RST (37)
64 #define GPIO95_TOUCHPAD_INT (95)
65 #define GPIO130_CAM_RESET (130)
68 #define GPIO11_NAND_CS (11)
69 #define GPIO41_ETHIRQ (41)
70 #define EM_X270_ETHIRQ IRQ_GPIO(GPIO41_ETHIRQ)
71 #define GPIO115_WLAN_PWEN (115)
72 #define GPIO19_WLAN_STRAP (19)
76 static int dm9000_flags
;
79 static unsigned long common_pin_config
[] = {
82 GPIO29_AC97_SDATA_IN_0
,
83 GPIO30_AC97_SDATA_OUT
,
147 GPIO100_KP_MKIN_0
| WAKEUP_ON_LEVEL_HIGH
,
148 GPIO101_KP_MKIN_1
| WAKEUP_ON_LEVEL_HIGH
,
149 GPIO102_KP_MKIN_2
| WAKEUP_ON_LEVEL_HIGH
,
150 GPIO34_KP_MKIN_3
| WAKEUP_ON_LEVEL_HIGH
,
151 GPIO39_KP_MKIN_4
| WAKEUP_ON_LEVEL_HIGH
,
152 GPIO99_KP_MKIN_5
| WAKEUP_ON_LEVEL_HIGH
,
153 GPIO91_KP_MKIN_6
| WAKEUP_ON_LEVEL_HIGH
,
154 GPIO36_KP_MKIN_7
| WAKEUP_ON_LEVEL_HIGH
,
171 GPIO19_GPIO
, /* SSP2 clock is used as GPIO for Libertas pin-strap */
176 /* SDRAM and local bus */
185 GPIO1_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* sleep/resume button */
188 GPIO20_GPIO
| MFP_LPM_DRIVE_LOW
, /* GPRS_PWEN */
189 GPIO115_GPIO
| MFP_LPM_DRIVE_LOW
, /* WLAN_PWEN */
192 GPIO11_GPIO
| MFP_LPM_DRIVE_HIGH
, /* NAND CE# */
195 GPIO41_GPIO
, /* DM9000 interrupt */
198 static unsigned long em_x270_pin_config
[] = {
199 GPIO13_GPIO
, /* MMC card detect */
200 GPIO56_GPIO
, /* NAND Ready/Busy */
201 GPIO93_GPIO
| MFP_LPM_DRIVE_LOW
, /* Camera reset */
202 GPIO95_GPIO
, /* MMC Write protect */
205 static unsigned long exeda_pin_config
[] = {
206 GPIO20_GPIO
, /* NAND Ready/Busy */
207 GPIO38_GPIO
| MFP_LPM_DRIVE_LOW
, /* SD slot power */
208 GPIO95_GPIO
, /* touchpad IRQ */
209 GPIO114_GPIO
, /* MMC card detect */
212 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
213 static struct resource em_x270_dm9000_resource
[] = {
215 .start
= PXA_CS2_PHYS
,
216 .end
= PXA_CS2_PHYS
+ 3,
217 .flags
= IORESOURCE_MEM
,
220 .start
= PXA_CS2_PHYS
+ 8,
221 .end
= PXA_CS2_PHYS
+ 8 + 0x3f,
222 .flags
= IORESOURCE_MEM
,
225 .start
= EM_X270_ETHIRQ
,
226 .end
= EM_X270_ETHIRQ
,
227 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
231 static struct dm9000_plat_data em_x270_dm9000_platdata
= {
232 .flags
= DM9000_PLATF_NO_EEPROM
,
235 static struct platform_device em_x270_dm9000
= {
238 .num_resources
= ARRAY_SIZE(em_x270_dm9000_resource
),
239 .resource
= em_x270_dm9000_resource
,
241 .platform_data
= &em_x270_dm9000_platdata
,
245 static void __init
em_x270_init_dm9000(void)
247 em_x270_dm9000_platdata
.flags
|= dm9000_flags
;
248 platform_device_register(&em_x270_dm9000
);
251 static inline void em_x270_init_dm9000(void) {}
255 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
256 static struct resource em_x270_v3020_resource
[] = {
258 .start
= PXA_CS4_PHYS
,
259 .end
= PXA_CS4_PHYS
+ 3,
260 .flags
= IORESOURCE_MEM
,
264 static struct v3020_platform_data em_x270_v3020_platdata
= {
268 static struct platform_device em_x270_rtc
= {
270 .num_resources
= ARRAY_SIZE(em_x270_v3020_resource
),
271 .resource
= em_x270_v3020_resource
,
274 .platform_data
= &em_x270_v3020_platdata
,
278 static void __init
em_x270_init_rtc(void)
280 platform_device_register(&em_x270_rtc
);
283 static inline void em_x270_init_rtc(void) {}
287 #if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
288 static inline void nand_cs_on(void)
290 gpio_set_value(GPIO11_NAND_CS
, 0);
293 static void nand_cs_off(void)
297 gpio_set_value(GPIO11_NAND_CS
, 1);
300 /* hardware specific access to control-lines */
301 static void em_x270_nand_cmd_ctl(struct mtd_info
*mtd
, int dat
,
304 struct nand_chip
*this = mtd
->priv
;
305 unsigned long nandaddr
= (unsigned long)this->IO_ADDR_W
;
309 if (ctrl
& NAND_CTRL_CHANGE
) {
311 nandaddr
|= (1 << 3);
313 nandaddr
&= ~(1 << 3);
315 nandaddr
|= (1 << 2);
317 nandaddr
&= ~(1 << 2);
325 this->IO_ADDR_W
= (void __iomem
*)nandaddr
;
326 if (dat
!= NAND_CMD_NONE
)
327 writel(dat
, this->IO_ADDR_W
);
332 /* read device ready pin */
333 static int em_x270_nand_device_ready(struct mtd_info
*mtd
)
337 return gpio_get_value(nand_rb
);
340 static struct mtd_partition em_x270_partition_info
[] = {
348 .offset
= MTDPART_OFS_APPEND
,
349 .size
= MTDPART_SIZ_FULL
353 static const char *em_x270_part_probes
[] = { "cmdlinepart", NULL
};
355 struct platform_nand_data em_x270_nand_platdata
= {
359 .nr_partitions
= ARRAY_SIZE(em_x270_partition_info
),
360 .partitions
= em_x270_partition_info
,
362 .part_probe_types
= em_x270_part_probes
,
366 .dev_ready
= em_x270_nand_device_ready
,
368 .cmd_ctrl
= em_x270_nand_cmd_ctl
,
372 static struct resource em_x270_nand_resource
[] = {
374 .start
= PXA_CS1_PHYS
,
375 .end
= PXA_CS1_PHYS
+ 12,
376 .flags
= IORESOURCE_MEM
,
380 static struct platform_device em_x270_nand
= {
382 .num_resources
= ARRAY_SIZE(em_x270_nand_resource
),
383 .resource
= em_x270_nand_resource
,
386 .platform_data
= &em_x270_nand_platdata
,
390 static void __init
em_x270_init_nand(void)
394 err
= gpio_request(GPIO11_NAND_CS
, "NAND CS");
396 pr_warning("EM-X270: failed to request NAND CS gpio\n");
400 gpio_direction_output(GPIO11_NAND_CS
, 1);
402 err
= gpio_request(nand_rb
, "NAND R/B");
404 pr_warning("EM-X270: failed to request NAND R/B gpio\n");
405 gpio_free(GPIO11_NAND_CS
);
409 gpio_direction_input(nand_rb
);
411 platform_device_register(&em_x270_nand
);
414 static inline void em_x270_init_nand(void) {}
417 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
418 static struct mtd_partition em_x270_nor_parts
[] = {
420 .name
= "Bootloader",
421 .offset
= 0x00000000,
423 .mask_flags
= MTD_WRITEABLE
/* force read-only */
425 .name
= "Environment",
426 .offset
= 0x00050000,
430 .offset
= 0x00060000,
432 .mask_flags
= MTD_WRITEABLE
/* force read-only */
434 .name
= "Splashscreen",
435 .offset
= 0x000b0000,
440 static struct physmap_flash_data em_x270_nor_data
[] = {
443 .parts
= em_x270_nor_parts
,
444 .nr_parts
= ARRAY_SIZE(em_x270_nor_parts
),
448 static struct resource em_x270_nor_flash_resource
= {
449 .start
= PXA_CS0_PHYS
,
450 .end
= PXA_CS0_PHYS
+ SZ_1M
- 1,
451 .flags
= IORESOURCE_MEM
,
454 static struct platform_device em_x270_physmap_flash
= {
455 .name
= "physmap-flash",
458 .resource
= &em_x270_nor_flash_resource
,
460 .platform_data
= &em_x270_nor_data
,
464 static void __init
em_x270_init_nor(void)
466 platform_device_register(&em_x270_physmap_flash
);
469 static inline void em_x270_init_nor(void) {}
472 /* PXA27x OHCI controller setup */
473 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
474 static int em_x270_ohci_init(struct device
*dev
)
476 /* enable port 2 transiever */
477 UP2OCR
= UP2OCR_HXS
| UP2OCR_HXOE
;
482 static struct pxaohci_platform_data em_x270_ohci_platform_data
= {
483 .port_mode
= PMM_PERPORT_MODE
,
484 .flags
= ENABLE_PORT1
| ENABLE_PORT2
| POWER_CONTROL_LOW
,
485 .init
= em_x270_ohci_init
,
488 static void __init
em_x270_init_ohci(void)
490 pxa_set_ohci_info(&em_x270_ohci_platform_data
);
493 static inline void em_x270_init_ohci(void) {}
496 /* MCI controller setup */
497 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
498 static struct regulator
*em_x270_sdio_ldo
;
500 static int em_x270_mci_init(struct device
*dev
,
501 irq_handler_t em_x270_detect_int
,
506 em_x270_sdio_ldo
= regulator_get(dev
, "vcc sdio");
507 if (IS_ERR(em_x270_sdio_ldo
)) {
508 dev_err(dev
, "can't request SDIO power supply: %ld\n",
509 PTR_ERR(em_x270_sdio_ldo
));
510 return PTR_ERR(em_x270_sdio_ldo
);
513 err
= request_irq(gpio_to_irq(mmc_cd
), em_x270_detect_int
,
514 IRQF_DISABLED
| IRQF_TRIGGER_RISING
|
515 IRQF_TRIGGER_FALLING
,
516 "MMC card detect", data
);
518 dev_err(dev
, "can't request MMC card detect IRQ: %d\n", err
);
522 if (machine_is_em_x270()) {
523 err
= gpio_request(GPIO95_MMC_WP
, "MMC WP");
525 dev_err(dev
, "can't request MMC write protect: %d\n",
529 gpio_direction_input(GPIO95_MMC_WP
);
531 err
= gpio_request(GPIO38_SD_PWEN
, "sdio power");
533 dev_err(dev
, "can't request MMC power control : %d\n",
537 gpio_direction_output(GPIO38_SD_PWEN
, 1);
543 free_irq(gpio_to_irq(mmc_cd
), data
);
545 regulator_put(em_x270_sdio_ldo
);
550 static void em_x270_mci_setpower(struct device
*dev
, unsigned int vdd
)
552 struct pxamci_platform_data
* p_d
= dev
->platform_data
;
554 if ((1 << vdd
) & p_d
->ocr_mask
) {
555 int vdd_uV
= (2000 + (vdd
- __ffs(MMC_VDD_20_21
)) * 100) * 1000;
557 regulator_set_voltage(em_x270_sdio_ldo
, vdd_uV
, vdd_uV
);
558 regulator_enable(em_x270_sdio_ldo
);
560 regulator_disable(em_x270_sdio_ldo
);
564 static void em_x270_mci_exit(struct device
*dev
, void *data
)
566 free_irq(gpio_to_irq(mmc_cd
), data
);
567 regulator_put(em_x270_sdio_ldo
);
569 if (machine_is_em_x270())
570 gpio_free(GPIO95_MMC_WP
);
572 gpio_free(GPIO38_SD_PWEN
);
575 static int em_x270_mci_get_ro(struct device
*dev
)
577 return gpio_get_value(GPIO95_MMC_WP
);
580 static struct pxamci_platform_data em_x270_mci_platform_data
= {
581 .ocr_mask
= MMC_VDD_20_21
|MMC_VDD_21_22
|MMC_VDD_22_23
|
582 MMC_VDD_24_25
|MMC_VDD_25_26
|MMC_VDD_26_27
|
583 MMC_VDD_27_28
|MMC_VDD_28_29
|MMC_VDD_29_30
|
584 MMC_VDD_30_31
|MMC_VDD_31_32
,
585 .init
= em_x270_mci_init
,
586 .setpower
= em_x270_mci_setpower
,
587 .exit
= em_x270_mci_exit
,
590 static void __init
em_x270_init_mmc(void)
592 if (machine_is_em_x270())
593 em_x270_mci_platform_data
.get_ro
= em_x270_mci_get_ro
;
595 em_x270_mci_platform_data
.detect_delay
= msecs_to_jiffies(250);
596 pxa_set_mci_info(&em_x270_mci_platform_data
);
599 static inline void em_x270_init_mmc(void) {}
603 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
604 static struct pxafb_mode_info em_x270_lcd_modes
[] = {
633 static struct pxafb_mach_info em_x270_lcd
= {
634 .modes
= em_x270_lcd_modes
,
636 .lcd_conn
= LCD_COLOR_TFT_16BPP
,
639 static void __init
em_x270_init_lcd(void)
641 set_pxa_fb_info(&em_x270_lcd
);
644 static inline void em_x270_init_lcd(void) {}
647 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
648 static struct pxa2xx_spi_master em_x270_spi_info
= {
652 static struct pxa2xx_spi_chip em_x270_tdo24m_chip
= {
658 static struct tdo24m_platform_data em_x270_tdo24m_pdata
= {
662 static struct pxa2xx_spi_master em_x270_spi_2_info
= {
667 static struct pxa2xx_spi_chip em_x270_libertas_chip
= {
673 static unsigned long em_x270_libertas_pin_config
[] = {
681 static int em_x270_libertas_setup(struct spi_device
*spi
)
683 int err
= gpio_request(GPIO115_WLAN_PWEN
, "WLAN PWEN");
687 err
= gpio_request(GPIO19_WLAN_STRAP
, "WLAN STRAP");
691 if (machine_is_exeda()) {
692 err
= gpio_request(GPIO37_WLAN_RST
, "WLAN RST");
696 gpio_direction_output(GPIO37_WLAN_RST
, 1);
700 gpio_direction_output(GPIO19_WLAN_STRAP
, 1);
703 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_libertas_pin_config
));
705 gpio_direction_output(GPIO115_WLAN_PWEN
, 0);
707 gpio_set_value(GPIO115_WLAN_PWEN
, 1);
710 spi
->bits_per_word
= 16;
716 gpio_free(GPIO19_WLAN_STRAP
);
718 gpio_free(GPIO115_WLAN_PWEN
);
723 static int em_x270_libertas_teardown(struct spi_device
*spi
)
725 gpio_set_value(GPIO115_WLAN_PWEN
, 0);
726 gpio_free(GPIO115_WLAN_PWEN
);
727 gpio_free(GPIO19_WLAN_STRAP
);
729 if (machine_is_exeda()) {
730 gpio_set_value(GPIO37_WLAN_RST
, 0);
731 gpio_free(GPIO37_WLAN_RST
);
737 struct libertas_spi_platform_data em_x270_libertas_pdata
= {
738 .use_dummy_writes
= 1,
740 .setup
= em_x270_libertas_setup
,
741 .teardown
= em_x270_libertas_teardown
,
744 static struct spi_board_info em_x270_spi_devices
[] __initdata
= {
746 .modalias
= "tdo24m",
747 .max_speed_hz
= 1000000,
750 .controller_data
= &em_x270_tdo24m_chip
,
751 .platform_data
= &em_x270_tdo24m_pdata
,
754 .modalias
= "libertas_spi",
755 .max_speed_hz
= 13000000,
757 .irq
= IRQ_GPIO(116),
759 .controller_data
= &em_x270_libertas_chip
,
760 .platform_data
= &em_x270_libertas_pdata
,
764 static void __init
em_x270_init_spi(void)
766 pxa2xx_set_spi_info(1, &em_x270_spi_info
);
767 pxa2xx_set_spi_info(2, &em_x270_spi_2_info
);
768 spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices
));
771 static inline void em_x270_init_spi(void) {}
774 #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
775 static void __init
em_x270_init_ac97(void)
777 pxa_set_ac97_info(NULL
);
780 static inline void em_x270_init_ac97(void) {}
783 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
784 static unsigned int em_x270_module_matrix_keys
[] = {
785 KEY(0, 0, KEY_A
), KEY(1, 0, KEY_UP
), KEY(2, 1, KEY_B
),
786 KEY(0, 2, KEY_LEFT
), KEY(1, 1, KEY_ENTER
), KEY(2, 0, KEY_RIGHT
),
787 KEY(0, 1, KEY_C
), KEY(1, 2, KEY_DOWN
), KEY(2, 2, KEY_D
),
790 struct pxa27x_keypad_platform_data em_x270_module_keypad_info
= {
791 /* code map for the matrix keys */
792 .matrix_key_rows
= 3,
793 .matrix_key_cols
= 3,
794 .matrix_key_map
= em_x270_module_matrix_keys
,
795 .matrix_key_map_size
= ARRAY_SIZE(em_x270_module_matrix_keys
),
798 static unsigned int em_x270_exeda_matrix_keys
[] = {
799 KEY(0, 0, KEY_RIGHTSHIFT
), KEY(0, 1, KEY_RIGHTCTRL
),
800 KEY(0, 2, KEY_RIGHTALT
), KEY(0, 3, KEY_SPACE
),
801 KEY(0, 4, KEY_LEFTALT
), KEY(0, 5, KEY_LEFTCTRL
),
802 KEY(0, 6, KEY_ENTER
), KEY(0, 7, KEY_SLASH
),
804 KEY(1, 0, KEY_DOT
), KEY(1, 1, KEY_M
),
805 KEY(1, 2, KEY_N
), KEY(1, 3, KEY_B
),
806 KEY(1, 4, KEY_V
), KEY(1, 5, KEY_C
),
807 KEY(1, 6, KEY_X
), KEY(1, 7, KEY_Z
),
809 KEY(2, 0, KEY_LEFTSHIFT
), KEY(2, 1, KEY_SEMICOLON
),
810 KEY(2, 2, KEY_L
), KEY(2, 3, KEY_K
),
811 KEY(2, 4, KEY_J
), KEY(2, 5, KEY_H
),
812 KEY(2, 6, KEY_G
), KEY(2, 7, KEY_F
),
814 KEY(3, 0, KEY_D
), KEY(3, 1, KEY_S
),
815 KEY(3, 2, KEY_A
), KEY(3, 3, KEY_TAB
),
816 KEY(3, 4, KEY_BACKSPACE
), KEY(3, 5, KEY_P
),
817 KEY(3, 6, KEY_O
), KEY(3, 7, KEY_I
),
819 KEY(4, 0, KEY_U
), KEY(4, 1, KEY_Y
),
820 KEY(4, 2, KEY_T
), KEY(4, 3, KEY_R
),
821 KEY(4, 4, KEY_E
), KEY(4, 5, KEY_W
),
822 KEY(4, 6, KEY_Q
), KEY(4, 7, KEY_MINUS
),
824 KEY(5, 0, KEY_0
), KEY(5, 1, KEY_9
),
825 KEY(5, 2, KEY_8
), KEY(5, 3, KEY_7
),
826 KEY(5, 4, KEY_6
), KEY(5, 5, KEY_5
),
827 KEY(5, 6, KEY_4
), KEY(5, 7, KEY_3
),
829 KEY(6, 0, KEY_2
), KEY(6, 1, KEY_1
),
830 KEY(6, 2, KEY_ENTER
), KEY(6, 3, KEY_END
),
831 KEY(6, 4, KEY_DOWN
), KEY(6, 5, KEY_UP
),
832 KEY(6, 6, KEY_MENU
), KEY(6, 7, KEY_F1
),
834 KEY(7, 0, KEY_LEFT
), KEY(7, 1, KEY_RIGHT
),
835 KEY(7, 2, KEY_BACK
), KEY(7, 3, KEY_HOME
),
836 KEY(7, 4, 0), KEY(7, 5, 0),
837 KEY(7, 6, 0), KEY(7, 7, 0),
840 struct pxa27x_keypad_platform_data em_x270_exeda_keypad_info
= {
841 /* code map for the matrix keys */
842 .matrix_key_rows
= 8,
843 .matrix_key_cols
= 8,
844 .matrix_key_map
= em_x270_exeda_matrix_keys
,
845 .matrix_key_map_size
= ARRAY_SIZE(em_x270_exeda_matrix_keys
),
848 static void __init
em_x270_init_keypad(void)
850 if (machine_is_em_x270())
851 pxa_set_keypad_info(&em_x270_module_keypad_info
);
853 pxa_set_keypad_info(&em_x270_exeda_keypad_info
);
856 static inline void em_x270_init_keypad(void) {}
859 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
860 static struct gpio_keys_button gpio_keys_button
[] = {
862 .desc
= "sleep/wakeup",
870 static struct gpio_keys_platform_data em_x270_gpio_keys_data
= {
871 .buttons
= gpio_keys_button
,
875 static struct platform_device em_x270_gpio_keys
= {
879 .platform_data
= &em_x270_gpio_keys_data
,
883 static void __init
em_x270_init_gpio_keys(void)
885 platform_device_register(&em_x270_gpio_keys
);
888 static inline void em_x270_init_gpio_keys(void) {}
891 /* Quick Capture Interface and sensor setup */
892 #if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
893 static struct regulator
*em_x270_camera_ldo
;
895 static int em_x270_sensor_init(struct device
*dev
)
899 ret
= gpio_request(cam_reset
, "camera reset");
903 gpio_direction_output(cam_reset
, 0);
905 em_x270_camera_ldo
= regulator_get(NULL
, "vcc cam");
906 if (em_x270_camera_ldo
== NULL
) {
907 gpio_free(cam_reset
);
911 ret
= regulator_enable(em_x270_camera_ldo
);
913 regulator_put(em_x270_camera_ldo
);
914 gpio_free(cam_reset
);
918 gpio_set_value(cam_reset
, 1);
923 struct pxacamera_platform_data em_x270_camera_platform_data
= {
924 .init
= em_x270_sensor_init
,
925 .flags
= PXA_CAMERA_MASTER
| PXA_CAMERA_DATAWIDTH_8
|
926 PXA_CAMERA_PCLK_EN
| PXA_CAMERA_MCLK_EN
,
930 static int em_x270_sensor_power(struct device
*dev
, int on
)
933 int is_on
= regulator_is_enabled(em_x270_camera_ldo
);
938 gpio_set_value(cam_reset
, !on
);
941 ret
= regulator_enable(em_x270_camera_ldo
);
943 ret
= regulator_disable(em_x270_camera_ldo
);
948 gpio_set_value(cam_reset
, on
);
953 static struct soc_camera_link iclink
= {
955 .power
= em_x270_sensor_power
,
958 static struct i2c_board_info em_x270_i2c_cam_info
[] = {
960 I2C_BOARD_INFO("mt9m111", 0x48),
961 .platform_data
= &iclink
,
965 static void __init
em_x270_init_camera(void)
967 i2c_register_board_info(0, ARRAY_AND_SIZE(em_x270_i2c_cam_info
));
968 pxa_set_camera_info(&em_x270_camera_platform_data
);
971 static inline void em_x270_init_camera(void) {}
974 /* DA9030 related initializations */
975 #define REGULATOR_CONSUMER(_name, _dev, _supply) \
976 static struct regulator_consumer_supply _name##_consumers[] = { \
983 REGULATOR_CONSUMER(ldo3
, NULL
, "vcc gps");
984 REGULATOR_CONSUMER(ldo5
, NULL
, "vcc cam");
985 REGULATOR_CONSUMER(ldo10
, &pxa_device_mci
.dev
, "vcc sdio");
986 REGULATOR_CONSUMER(ldo12
, NULL
, "vcc usb");
987 REGULATOR_CONSUMER(ldo19
, NULL
, "vcc gprs");
989 #define REGULATOR_INIT(_ldo, _min_uV, _max_uV, _ops_mask) \
990 static struct regulator_init_data _ldo##_data = { \
997 .valid_ops_mask = _ops_mask, \
999 .num_consumer_supplies = ARRAY_SIZE(_ldo##_consumers), \
1000 .consumer_supplies = _ldo##_consumers, \
1003 REGULATOR_INIT(ldo3
, 3200000, 3200000, REGULATOR_CHANGE_STATUS
);
1004 REGULATOR_INIT(ldo5
, 3000000, 3000000, REGULATOR_CHANGE_STATUS
);
1005 REGULATOR_INIT(ldo10
, 2000000, 3200000,
1006 REGULATOR_CHANGE_STATUS
| REGULATOR_CHANGE_VOLTAGE
);
1007 REGULATOR_INIT(ldo12
, 3000000, 3000000, REGULATOR_CHANGE_STATUS
);
1008 REGULATOR_INIT(ldo19
, 3200000, 3200000, REGULATOR_CHANGE_STATUS
);
1010 struct led_info em_x270_led_info
= {
1011 .name
= "em-x270:orange",
1012 .default_trigger
= "battery-charging-or-full",
1015 struct power_supply_info em_x270_psy_info
= {
1016 .name
= "LP555597P6H-FPS",
1017 .technology
= POWER_SUPPLY_TECHNOLOGY_LIPO
,
1018 .voltage_max_design
= 4200000,
1019 .voltage_min_design
= 3000000,
1023 static void em_x270_battery_low(void)
1025 apm_queue_event(APM_LOW_BATTERY
);
1028 static void em_x270_battery_critical(void)
1030 apm_queue_event(APM_CRITICAL_SUSPEND
);
1033 struct da9030_battery_info em_x270_batterty_info
= {
1034 .battery_info
= &em_x270_psy_info
,
1036 .charge_milliamp
= 1000,
1037 .charge_millivolt
= 4200,
1041 .vbat_charge_start
= 4100,
1042 .vbat_charge_stop
= 4200,
1043 .vbat_charge_restart
= 4000,
1045 .vcharge_min
= 3200,
1046 .vcharge_max
= 5500,
1050 .tbat_restart
= 100,
1052 .batmon_interval
= 0,
1054 .battery_low
= em_x270_battery_low
,
1055 .battery_critical
= em_x270_battery_critical
,
1058 #define DA9030_SUBDEV(_name, _id, _pdata) \
1060 .name = "da903x-" #_name, \
1061 .id = DA9030_ID_##_id, \
1062 .platform_data = _pdata, \
1065 #define DA9030_LDO(num) DA9030_SUBDEV(regulator, LDO##num, &ldo##num##_data)
1067 struct da903x_subdev_info em_x270_da9030_subdevs
[] = {
1074 DA9030_SUBDEV(led
, LED_PC
, &em_x270_led_info
),
1075 DA9030_SUBDEV(backlight
, WLED
, &em_x270_led_info
),
1076 DA9030_SUBDEV(battery
, BAT
, &em_x270_batterty_info
),
1079 static struct da903x_platform_data em_x270_da9030_info
= {
1080 .num_subdevs
= ARRAY_SIZE(em_x270_da9030_subdevs
),
1081 .subdevs
= em_x270_da9030_subdevs
,
1084 static struct i2c_board_info em_x270_i2c_pmic_info
= {
1085 I2C_BOARD_INFO("da9030", 0x49),
1087 .platform_data
= &em_x270_da9030_info
,
1090 static struct i2c_pxa_platform_data em_x270_pwr_i2c_info
= {
1094 static void __init
em_x270_init_da9030(void)
1096 pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info
);
1097 i2c_register_board_info(1, &em_x270_i2c_pmic_info
, 1);
1100 static struct pca953x_platform_data exeda_gpio_ext_pdata
= {
1104 static struct i2c_board_info exeda_i2c_info
[] = {
1106 I2C_BOARD_INFO("pca9555", 0x21),
1107 .platform_data
= &exeda_gpio_ext_pdata
,
1111 static struct i2c_pxa_platform_data em_x270_i2c_info
= {
1115 static void __init
em_x270_init_i2c(void)
1117 pxa_set_i2c_info(&em_x270_i2c_info
);
1119 if (machine_is_exeda())
1120 i2c_register_board_info(0, ARRAY_AND_SIZE(exeda_i2c_info
));
1123 static void __init
em_x270_module_init(void)
1125 pr_info("%s\n", __func__
);
1126 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config
));
1128 mmc_cd
= GPIO13_MMC_CD
;
1129 nand_rb
= GPIO56_NAND_RB
;
1130 dm9000_flags
= DM9000_PLATF_32BITONLY
;
1131 cam_reset
= GPIO93_CAM_RESET
;
1134 static void __init
em_x270_exeda_init(void)
1136 pr_info("%s\n", __func__
);
1137 pxa2xx_mfp_config(ARRAY_AND_SIZE(exeda_pin_config
));
1139 mmc_cd
= GPIO114_MMC_CD
;
1140 nand_rb
= GPIO20_NAND_RB
;
1141 dm9000_flags
= DM9000_PLATF_16BITONLY
;
1142 cam_reset
= GPIO130_CAM_RESET
;
1145 static void __init
em_x270_init(void)
1147 pxa2xx_mfp_config(ARRAY_AND_SIZE(common_pin_config
));
1149 if (machine_is_em_x270())
1150 em_x270_module_init();
1151 else if (machine_is_exeda())
1152 em_x270_exeda_init();
1154 panic("Unsupported machine: %d\n", machine_arch_type
);
1156 em_x270_init_da9030();
1157 em_x270_init_dm9000();
1159 em_x270_init_nand();
1163 em_x270_init_ohci();
1164 em_x270_init_keypad();
1165 em_x270_init_gpio_keys();
1166 em_x270_init_ac97();
1169 em_x270_init_camera();
1172 MACHINE_START(EM_X270
, "Compulab EM-X270")
1173 .boot_params
= 0xa0000100,
1174 .phys_io
= 0x40000000,
1175 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
1176 .map_io
= pxa_map_io
,
1177 .init_irq
= pxa27x_init_irq
,
1178 .timer
= &pxa_timer
,
1179 .init_machine
= em_x270_init
,
1182 MACHINE_START(EXEDA
, "Compulab eXeda")
1183 .boot_params
= 0xa0000100,
1184 .phys_io
= 0x40000000,
1185 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
1186 .map_io
= pxa_map_io
,
1187 .init_irq
= pxa27x_init_irq
,
1188 .timer
= &pxa_timer
,
1189 .init_machine
= em_x270_init
,