2 * linux/arch/arm/mach-pxa/cm-x300.c
4 * Support for the CompuLab CM-X300 modules
6 * Copyright (C) 2008,2009 CompuLab Ltd.
8 * Mike Rapoport <mike@compulab.co.il>
9 * Igor Grinberg <grinberg@compulab.co.il>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include <linux/module.h>
17 #include <linux/kernel.h>
18 #include <linux/interrupt.h>
19 #include <linux/init.h>
20 #include <linux/delay.h>
21 #include <linux/platform_device.h>
23 #include <linux/gpio.h>
24 #include <linux/dm9000.h>
25 #include <linux/leds.h>
26 #include <linux/rtc-v3020.h>
27 #include <linux/pwm_backlight.h>
29 #include <linux/i2c.h>
30 #include <linux/i2c/pca953x.h>
32 #include <linux/mfd/da903x.h>
33 #include <linux/power_supply.h>
34 #include <linux/apm-emulation.h>
36 #include <linux/spi/spi.h>
37 #include <linux/spi/spi_gpio.h>
38 #include <linux/spi/tdo24m.h>
40 #include <asm/mach-types.h>
41 #include <asm/mach/arch.h>
42 #include <asm/setup.h>
44 #include <mach/pxa300.h>
45 #include <mach/pxa27x-udc.h>
46 #include <mach/pxafb.h>
48 #include <mach/ohci.h>
50 #include <plat/pxa3xx_nand.h>
51 #include <mach/audio.h>
53 #include <asm/mach/map.h>
58 #define CM_X300_ETH_PHYS 0x08000010
60 #define GPIO82_MMC_IRQ (82)
61 #define GPIO85_MMC_WP (85)
63 #define CM_X300_MMC_IRQ IRQ_GPIO(GPIO82_MMC_IRQ)
65 #define GPIO95_RTC_CS (95)
66 #define GPIO96_RTC_WR (96)
67 #define GPIO97_RTC_RD (97)
68 #define GPIO98_RTC_IO (98)
70 static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
95 GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
97 GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
101 GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
104 GPIO23_AC97_nACRESET,
107 GPIO25_AC97_SDATA_IN_0,
108 GPIO27_AC97_SDATA_OUT,
112 GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
113 GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
114 GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
115 GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
116 GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
117 GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
118 GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
119 GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
129 GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
133 GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
137 GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
144 GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
149 GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
154 GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */
155 GPIO85_GPIO, /* MMC WP */
156 GPIO99_GPIO, /* Ethernet IRQ */
159 GPIO95_GPIO, /* RTC CS */
160 GPIO96_GPIO, /* RTC WR */
161 GPIO97_GPIO, /* RTC RD */
162 GPIO98_GPIO, /* RTC IO */
172 static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = {
174 GPIO79_GPIO, /* LED */
175 GPIO77_GPIO, /* WiFi reset */
176 GPIO78_GPIO, /* BT reset */
179 static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = {
181 GPIO76_GPIO, /* LED */
182 GPIO71_GPIO, /* WiFi reset */
183 GPIO70_GPIO, /* BT reset */
186 static mfp_cfg_t cm_x310_mfp_cfg[] __initdata = {
191 GPIO30_ULPI_DATA_OUT_0,
192 GPIO31_ULPI_DATA_OUT_1,
193 GPIO32_ULPI_DATA_OUT_2,
194 GPIO33_ULPI_DATA_OUT_3,
195 GPIO34_ULPI_DATA_OUT_4,
196 GPIO35_ULPI_DATA_OUT_5,
197 GPIO36_ULPI_DATA_OUT_6,
198 GPIO37_ULPI_DATA_OUT_7,
200 /* external PHY reset pin */
213 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
214 static struct resource dm9000_resources[] = {
216 .start = CM_X300_ETH_PHYS,
217 .end = CM_X300_ETH_PHYS + 0x3,
218 .flags = IORESOURCE_MEM,
221 .start = CM_X300_ETH_PHYS + 0x4,
222 .end = CM_X300_ETH_PHYS + 0x4 + 500,
223 .flags = IORESOURCE_MEM,
226 .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
227 .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
228 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
232 static struct dm9000_plat_data cm_x300_dm9000_platdata = {
233 .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
236 static struct platform_device dm9000_device = {
239 .num_resources = ARRAY_SIZE(dm9000_resources),
240 .resource = dm9000_resources,
242 .platform_data = &cm_x300_dm9000_platdata,
247 static void __init cm_x300_init_dm9000(void)
249 platform_device_register(&dm9000_device);
252 static inline void cm_x300_init_dm9000(void) {}
256 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
257 static struct pxafb_mode_info cm_x300_lcd_modes[] = {
286 static struct pxafb_mach_info cm_x300_lcd = {
287 .modes = cm_x300_lcd_modes,
288 .num_modes = ARRAY_SIZE(cm_x300_lcd_modes),
289 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
292 static void __init cm_x300_init_lcd(void)
294 set_pxa_fb_info(&cm_x300_lcd);
297 static inline void cm_x300_init_lcd(void) {}
300 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
301 static struct platform_pwm_backlight_data cm_x300_backlight_data = {
303 .max_brightness = 100,
304 .dft_brightness = 100,
305 .pwm_period_ns = 10000,
308 static struct platform_device cm_x300_backlight_device = {
309 .name = "pwm-backlight",
311 .parent = &pxa27x_device_pwm0.dev,
312 .platform_data = &cm_x300_backlight_data,
316 static void cm_x300_init_bl(void)
318 platform_device_register(&cm_x300_backlight_device);
321 static inline void cm_x300_init_bl(void) {}
324 #if defined(CONFIG_SPI_GPIO) || defined(CONFIG_SPI_GPIO_MODULE)
325 #define GPIO_LCD_BASE (144)
326 #define GPIO_LCD_DIN (GPIO_LCD_BASE + 8) /* aux_gpio3_0 */
327 #define GPIO_LCD_DOUT (GPIO_LCD_BASE + 9) /* aux_gpio3_1 */
328 #define GPIO_LCD_SCL (GPIO_LCD_BASE + 10) /* aux_gpio3_2 */
329 #define GPIO_LCD_CS (GPIO_LCD_BASE + 11) /* aux_gpio3_3 */
330 #define LCD_SPI_BUS_NUM (1)
332 static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata = {
334 .mosi = GPIO_LCD_DIN,
335 .miso = GPIO_LCD_DOUT,
339 static struct platform_device cm_x300_spi_gpio = {
341 .id = LCD_SPI_BUS_NUM,
343 .platform_data = &cm_x300_spi_gpio_pdata,
347 static struct tdo24m_platform_data cm_x300_tdo24m_pdata = {
351 static struct spi_board_info cm_x300_spi_devices[] __initdata = {
353 .modalias = "tdo24m",
354 .max_speed_hz = 1000000,
355 .bus_num = LCD_SPI_BUS_NUM,
357 .controller_data = (void *) GPIO_LCD_CS,
358 .platform_data = &cm_x300_tdo24m_pdata,
362 static void __init cm_x300_init_spi(void)
364 spi_register_board_info(cm_x300_spi_devices,
365 ARRAY_SIZE(cm_x300_spi_devices));
366 platform_device_register(&cm_x300_spi_gpio);
369 static inline void cm_x300_init_spi(void) {}
372 #if defined(CONFIG_SND_PXA2XX_LIB_AC97)
373 static void __init cm_x300_init_ac97(void)
375 pxa_set_ac97_info(NULL);
378 static inline void cm_x300_init_ac97(void) {}
381 #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
382 static struct mtd_partition cm_x300_nand_partitions[] = {
387 .mask_flags = MTD_WRITEABLE, /* force read-only */
391 .offset = MTDPART_OFS_APPEND,
393 .mask_flags = MTD_WRITEABLE, /* force read-only */
396 .name = "Environment",
397 .offset = MTDPART_OFS_APPEND,
402 .offset = MTDPART_OFS_APPEND,
403 .size = SZ_256K + SZ_1M,
404 .mask_flags = MTD_WRITEABLE, /* force read-only */
408 .offset = MTDPART_OFS_APPEND,
413 .offset = MTDPART_OFS_APPEND,
414 .size = MTDPART_SIZ_FULL,
418 static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
421 .parts = cm_x300_nand_partitions,
422 .nr_parts = ARRAY_SIZE(cm_x300_nand_partitions),
425 static void __init cm_x300_init_nand(void)
427 pxa3xx_set_nand_info(&cm_x300_nand_info);
430 static inline void cm_x300_init_nand(void) {}
433 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
434 static struct pxamci_platform_data cm_x300_mci_platform_data = {
436 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
437 .gpio_card_detect = GPIO82_MMC_IRQ,
438 .gpio_card_ro = GPIO85_MMC_WP,
442 /* The second MMC slot of CM-X300 is hardwired to Libertas card and has
443 no detection/ro pins */
444 static int cm_x300_mci2_init(struct device *dev,
445 irq_handler_t cm_x300_detect_int,
451 static void cm_x300_mci2_exit(struct device *dev, void *data)
455 static struct pxamci_platform_data cm_x300_mci2_platform_data = {
457 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
458 .init = cm_x300_mci2_init,
459 .exit = cm_x300_mci2_exit,
460 .gpio_card_detect = -1,
465 static void __init cm_x300_init_mmc(void)
467 pxa_set_mci_info(&cm_x300_mci_platform_data);
468 pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
471 static inline void cm_x300_init_mmc(void) {}
474 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
475 static int cm_x300_ohci_init(struct device *dev)
479 | UP2OCR_HXOE | UP2OCR_DMPDE | UP2OCR_DPPDE;
484 static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
485 .port_mode = PMM_PERPORT_MODE,
486 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW,
487 .init = cm_x300_ohci_init,
490 static void __init cm_x300_init_ohci(void)
492 pxa_set_ohci_info(&cm_x300_ohci_platform_data);
495 static inline void cm_x300_init_ohci(void) {}
498 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
499 static struct gpio_led cm_x300_leds[] = {
501 .name = "cm-x300:green",
502 .default_trigger = "heartbeat",
507 static struct gpio_led_platform_data cm_x300_gpio_led_pdata = {
508 .num_leds = ARRAY_SIZE(cm_x300_leds),
509 .leds = cm_x300_leds,
512 static struct platform_device cm_x300_led_device = {
516 .platform_data = &cm_x300_gpio_led_pdata,
520 static void __init cm_x300_init_leds(void)
522 if (system_rev < 130)
523 cm_x300_leds[0].gpio = 79;
525 cm_x300_leds[0].gpio = 76;
527 platform_device_register(&cm_x300_led_device);
530 static inline void cm_x300_init_leds(void) {}
533 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
535 static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = {
539 static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = {
543 static struct i2c_board_info cm_x300_gpio_ext_info[] = {
545 I2C_BOARD_INFO("pca9555", 0x24),
546 .platform_data = &cm_x300_gpio_ext_pdata_0,
549 I2C_BOARD_INFO("pca9555", 0x25),
550 .platform_data = &cm_x300_gpio_ext_pdata_1,
554 static void __init cm_x300_init_i2c(void)
556 pxa_set_i2c_info(NULL);
557 i2c_register_board_info(0, cm_x300_gpio_ext_info,
558 ARRAY_SIZE(cm_x300_gpio_ext_info));
561 static inline void cm_x300_init_i2c(void) {}
564 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
565 struct v3020_platform_data cm_x300_v3020_pdata = {
567 .gpio_cs = GPIO95_RTC_CS,
568 .gpio_wr = GPIO96_RTC_WR,
569 .gpio_rd = GPIO97_RTC_RD,
570 .gpio_io = GPIO98_RTC_IO,
573 static struct platform_device cm_x300_rtc_device = {
577 .platform_data = &cm_x300_v3020_pdata,
581 static void __init cm_x300_init_rtc(void)
583 platform_device_register(&cm_x300_rtc_device);
586 static inline void cm_x300_init_rtc(void) {}
590 struct power_supply_info cm_x300_psy_info = {
592 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
593 .voltage_max_design = 4200000,
594 .voltage_min_design = 3000000,
598 static void cm_x300_battery_low(void)
600 #if defined(CONFIG_APM_EMULATION)
601 apm_queue_event(APM_LOW_BATTERY);
605 static void cm_x300_battery_critical(void)
607 #if defined(CONFIG_APM_EMULATION)
608 apm_queue_event(APM_CRITICAL_SUSPEND);
612 struct da9030_battery_info cm_x300_battery_info = {
613 .battery_info = &cm_x300_psy_info,
615 .charge_milliamp = 1000,
616 .charge_millivolt = 4200,
620 .vbat_charge_start = 4100,
621 .vbat_charge_stop = 4200,
622 .vbat_charge_restart = 4000,
631 .batmon_interval = 0,
633 .battery_low = cm_x300_battery_low,
634 .battery_critical = cm_x300_battery_critical,
638 struct da903x_subdev_info cm_x300_da9030_subdevs[] = {
640 .name = "da903x-backlight",
641 .id = DA9030_ID_WLED,
644 .name = "da903x-battery",
646 .platform_data = &cm_x300_battery_info,
650 static struct da903x_platform_data cm_x300_da9030_info = {
651 .num_subdevs = ARRAY_SIZE(cm_x300_da9030_subdevs),
652 .subdevs = cm_x300_da9030_subdevs,
655 static struct i2c_board_info cm_x300_pmic_info = {
656 I2C_BOARD_INFO("da9030", 0x49),
658 .platform_data = &cm_x300_da9030_info,
661 static struct i2c_pxa_platform_data cm_x300_pwr_i2c_info = {
665 static void __init cm_x300_init_da9030(void)
667 pxa3xx_set_i2c_power_info(&cm_x300_pwr_i2c_info);
668 i2c_register_board_info(1, &cm_x300_pmic_info, 1);
671 static void __init cm_x300_init_wi2wi(void)
673 int bt_reset, wlan_en;
676 if (system_rev < 130) {
684 /* Libertas and CSR reset */
685 err = gpio_request(wlan_en, "wlan en");
687 pr_err("CM-X300: failed to request wlan en gpio: %d\n", err);
689 gpio_direction_output(wlan_en, 1);
693 err = gpio_request(bt_reset, "bt reset");
695 pr_err("CM-X300: failed to request bt reset gpio: %d\n", err);
697 gpio_direction_output(bt_reset, 1);
699 gpio_set_value(bt_reset, 0);
701 gpio_set_value(bt_reset, 1);
707 static void __init cm_x300_init_mfp(void)
709 /* board-processor specific GPIO initialization */
710 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg));
712 if (system_rev < 130)
713 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg));
715 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_ge130_mfp_cfg));
718 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x310_mfp_cfg));
721 static void __init cm_x300_init(void)
725 pxa_set_ffuart_info(NULL);
726 pxa_set_btuart_info(NULL);
727 pxa_set_stuart_info(NULL);
729 cm_x300_init_da9030();
730 cm_x300_init_dm9000();
740 cm_x300_init_wi2wi();
744 static void __init cm_x300_fixup(struct machine_desc *mdesc, struct tag *tags,
745 char **cmdline, struct meminfo *mi)
748 mi->bank[0].start = 0xa0000000;
749 mi->bank[0].node = 0;
750 mi->bank[0].size = (64*1024*1024);
751 mi->bank[1].start = 0xc0000000;
752 mi->bank[1].node = 0;
753 mi->bank[1].size = (64*1024*1024);
756 MACHINE_START(CM_X300, "CM-X300 module")
757 .phys_io = 0x40000000,
758 .boot_params = 0xa0000100,
759 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
760 .map_io = pxa_map_io,
761 .init_irq = pxa3xx_init_irq,
763 .init_machine = cm_x300_init,
764 .fixup = cm_x300_fixup,