2 * linux/arch/arm/mach-pxa/cm-x300.c
4 * Support for the CompuLab CM-X300 modules
6 * Copyright (C) 2008 CompuLab Ltd.
8 * Mike Rapoport <mike@compulab.co.il>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/module.h>
16 #include <linux/kernel.h>
17 #include <linux/interrupt.h>
18 #include <linux/init.h>
19 #include <linux/platform_device.h>
21 #include <linux/gpio.h>
22 #include <linux/dm9000.h>
23 #include <linux/leds.h>
24 #include <linux/rtc-v3020.h>
26 #include <linux/i2c.h>
27 #include <linux/i2c/pca953x.h>
29 #include <linux/spi/spi.h>
30 #include <linux/spi/spi_gpio.h>
31 #include <linux/spi/tdo24m.h>
33 #include <asm/mach-types.h>
34 #include <asm/mach/arch.h>
35 #include <asm/setup.h>
37 #include <mach/pxa300.h>
38 #include <mach/pxafb.h>
40 #include <mach/ohci.h>
42 #include <plat/pxa3xx_nand.h>
43 #include <mach/audio.h>
45 #include <asm/mach/map.h>
49 #define CM_X300_ETH_PHYS 0x08000010
51 #define GPIO82_MMC_IRQ (82)
52 #define GPIO85_MMC_WP (85)
54 #define CM_X300_MMC_IRQ IRQ_GPIO(GPIO82_MMC_IRQ)
56 #define GPIO95_RTC_CS (95)
57 #define GPIO96_RTC_WR (96)
58 #define GPIO97_RTC_RD (97)
59 #define GPIO98_RTC_IO (98)
61 static mfp_cfg_t cm_x300_mfp_cfg
[] __initdata
= {
86 GPIO112_UART2_RXD
| MFP_LPM_EDGE_FALL
,
88 GPIO114_UART2_CTS
| MFP_LPM_EDGE_BOTH
,
92 GPIO110_UART3_RXD
| MFP_LPM_EDGE_FALL
,
98 GPIO25_AC97_SDATA_IN_0
,
99 GPIO27_AC97_SDATA_OUT
,
103 GPIO115_KP_MKIN_0
| MFP_LPM_EDGE_BOTH
,
104 GPIO116_KP_MKIN_1
| MFP_LPM_EDGE_BOTH
,
105 GPIO117_KP_MKIN_2
| MFP_LPM_EDGE_BOTH
,
106 GPIO118_KP_MKIN_3
| MFP_LPM_EDGE_BOTH
,
107 GPIO119_KP_MKIN_4
| MFP_LPM_EDGE_BOTH
,
108 GPIO120_KP_MKIN_5
| MFP_LPM_EDGE_BOTH
,
109 GPIO2_2_KP_MKIN_6
| MFP_LPM_EDGE_BOTH
,
110 GPIO3_2_KP_MKIN_7
| MFP_LPM_EDGE_BOTH
,
120 GPIO4_MMC1_DAT1
| MFP_LPM_EDGE_BOTH
,
124 GPIO8_MMC1_CMD
, /* CMD0 for slot 0 */
128 GPIO10_MMC2_DAT1
| MFP_LPM_EDGE_BOTH
,
135 GPIO30_UART1_RXD
| MFP_LPM_EDGE_FALL
,
140 GPIO34_UART1_DSR
| MFP_LPM_EDGE_FALL
,
145 GPIO82_GPIO
| MFP_PULL_HIGH
, /* MMC CD */
146 GPIO85_GPIO
, /* MMC WP */
147 GPIO99_GPIO
, /* Ethernet IRQ */
150 GPIO95_GPIO
, /* RTC CS */
151 GPIO96_GPIO
, /* RTC WR */
152 GPIO97_GPIO
, /* RTC RD */
153 GPIO98_GPIO
, /* RTC IO */
160 static mfp_cfg_t cm_x300_rev_lt130_mfp_cfg
[] __initdata
= {
162 GPIO79_GPIO
, /* LED */
163 GPIO77_GPIO
, /* WiFi reset */
164 GPIO78_GPIO
, /* BT reset */
167 static mfp_cfg_t cm_x300_rev_ge130_mfp_cfg
[] __initdata
= {
169 GPIO76_GPIO
, /* LED */
170 GPIO71_GPIO
, /* WiFi reset */
171 GPIO70_GPIO
, /* BT reset */
174 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
175 static struct resource dm9000_resources
[] = {
177 .start
= CM_X300_ETH_PHYS
,
178 .end
= CM_X300_ETH_PHYS
+ 0x3,
179 .flags
= IORESOURCE_MEM
,
182 .start
= CM_X300_ETH_PHYS
+ 0x4,
183 .end
= CM_X300_ETH_PHYS
+ 0x4 + 500,
184 .flags
= IORESOURCE_MEM
,
187 .start
= IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99
)),
188 .end
= IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99
)),
189 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
193 static struct dm9000_plat_data cm_x300_dm9000_platdata
= {
194 .flags
= DM9000_PLATF_16BITONLY
| DM9000_PLATF_NO_EEPROM
,
197 static struct platform_device dm9000_device
= {
200 .num_resources
= ARRAY_SIZE(dm9000_resources
),
201 .resource
= dm9000_resources
,
203 .platform_data
= &cm_x300_dm9000_platdata
,
208 static void __init
cm_x300_init_dm9000(void)
210 platform_device_register(&dm9000_device
);
213 static inline void cm_x300_init_dm9000(void) {}
217 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
218 static struct pxafb_mode_info cm_x300_lcd_modes
[] = {
247 static struct pxafb_mach_info cm_x300_lcd
= {
248 .modes
= cm_x300_lcd_modes
,
249 .num_modes
= ARRAY_SIZE(cm_x300_lcd_modes
),
250 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
253 static void __init
cm_x300_init_lcd(void)
255 set_pxa_fb_info(&cm_x300_lcd
);
258 static inline void cm_x300_init_lcd(void) {}
261 #if defined(CONFIG_SPI_GPIO) || defined(CONFIG_SPI_GPIO_MODULE)
262 #define GPIO_LCD_BASE (144)
263 #define GPIO_LCD_DIN (GPIO_LCD_BASE + 8) /* aux_gpio3_0 */
264 #define GPIO_LCD_DOUT (GPIO_LCD_BASE + 9) /* aux_gpio3_1 */
265 #define GPIO_LCD_SCL (GPIO_LCD_BASE + 10) /* aux_gpio3_2 */
266 #define GPIO_LCD_CS (GPIO_LCD_BASE + 11) /* aux_gpio3_3 */
267 #define LCD_SPI_BUS_NUM (1)
269 static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata
= {
271 .mosi
= GPIO_LCD_DIN
,
272 .miso
= GPIO_LCD_DOUT
,
276 static struct platform_device cm_x300_spi_gpio
= {
278 .id
= LCD_SPI_BUS_NUM
,
280 .platform_data
= &cm_x300_spi_gpio_pdata
,
284 static struct tdo24m_platform_data cm_x300_tdo24m_pdata
= {
288 static struct spi_board_info cm_x300_spi_devices
[] __initdata
= {
290 .modalias
= "tdo24m",
291 .max_speed_hz
= 1000000,
292 .bus_num
= LCD_SPI_BUS_NUM
,
294 .controller_data
= (void *) GPIO_LCD_CS
,
295 .platform_data
= &cm_x300_tdo24m_pdata
,
299 static void __init
cm_x300_init_spi(void)
301 spi_register_board_info(cm_x300_spi_devices
,
302 ARRAY_SIZE(cm_x300_spi_devices
));
303 platform_device_register(&cm_x300_spi_gpio
);
306 static inline void cm_x300_init_spi(void) {}
309 #if defined(CONFIG_SND_PXA2XX_LIB_AC97)
310 static void __init
cm_x300_init_ac97(void)
312 pxa_set_ac97_info(NULL
);
315 static inline void cm_x300_init_ac97(void) {}
318 #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
319 static struct mtd_partition cm_x300_nand_partitions
[] = {
324 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
328 .offset
= MTDPART_OFS_APPEND
,
330 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
333 .name
= "Environment",
334 .offset
= MTDPART_OFS_APPEND
,
339 .offset
= MTDPART_OFS_APPEND
,
340 .size
= SZ_256K
+ SZ_1M
,
341 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
345 .offset
= MTDPART_OFS_APPEND
,
350 .offset
= MTDPART_OFS_APPEND
,
351 .size
= MTDPART_SIZ_FULL
,
355 static struct pxa3xx_nand_platform_data cm_x300_nand_info
= {
358 .parts
= cm_x300_nand_partitions
,
359 .nr_parts
= ARRAY_SIZE(cm_x300_nand_partitions
),
362 static void __init
cm_x300_init_nand(void)
364 pxa3xx_set_nand_info(&cm_x300_nand_info
);
367 static inline void cm_x300_init_nand(void) {}
370 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
371 static struct pxamci_platform_data cm_x300_mci_platform_data
= {
373 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
374 .gpio_card_detect
= GPIO82_MMC_IRQ
,
375 .gpio_card_ro
= GPIO85_MMC_WP
,
379 /* The second MMC slot of CM-X300 is hardwired to Libertas card and has
380 no detection/ro pins */
381 static int cm_x300_mci2_init(struct device
*dev
,
382 irq_handler_t cm_x300_detect_int
,
388 static void cm_x300_mci2_exit(struct device
*dev
, void *data
)
392 static struct pxamci_platform_data cm_x300_mci2_platform_data
= {
394 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
395 .init
= cm_x300_mci2_init
,
396 .exit
= cm_x300_mci2_exit
,
397 .gpio_card_detect
= -1,
402 static void __init
cm_x300_init_mmc(void)
404 pxa_set_mci_info(&cm_x300_mci_platform_data
);
405 pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data
);
408 static inline void cm_x300_init_mmc(void) {}
411 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
412 static struct pxaohci_platform_data cm_x300_ohci_platform_data
= {
413 .port_mode
= PMM_PERPORT_MODE
,
414 .flags
= ENABLE_PORT1
| ENABLE_PORT2
| POWER_CONTROL_LOW
,
417 static void __init
cm_x300_init_ohci(void)
419 pxa_set_ohci_info(&cm_x300_ohci_platform_data
);
422 static inline void cm_x300_init_ohci(void) {}
425 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
426 static struct gpio_led cm_x300_leds
[] = {
428 .name
= "cm-x300:green",
429 .default_trigger
= "heartbeat",
434 static struct gpio_led_platform_data cm_x300_gpio_led_pdata
= {
435 .num_leds
= ARRAY_SIZE(cm_x300_leds
),
436 .leds
= cm_x300_leds
,
439 static struct platform_device cm_x300_led_device
= {
443 .platform_data
= &cm_x300_gpio_led_pdata
,
447 static void __init
cm_x300_init_leds(void)
449 if (system_rev
< 130)
450 cm_x300_leds
[0].gpio
= 79;
452 cm_x300_leds
[0].gpio
= 76;
454 platform_device_register(&cm_x300_led_device
);
457 static inline void cm_x300_init_leds(void) {}
460 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
462 static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0
= {
466 static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1
= {
470 static struct i2c_board_info cm_x300_gpio_ext_info
[] = {
472 I2C_BOARD_INFO("pca9555", 0x24),
473 .platform_data
= &cm_x300_gpio_ext_pdata_0
,
476 I2C_BOARD_INFO("pca9555", 0x25),
477 .platform_data
= &cm_x300_gpio_ext_pdata_1
,
481 static void __init
cm_x300_init_i2c(void)
483 pxa_set_i2c_info(NULL
);
484 i2c_register_board_info(0, cm_x300_gpio_ext_info
,
485 ARRAY_SIZE(cm_x300_gpio_ext_info
));
488 static inline void cm_x300_init_i2c(void) {}
491 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
492 struct v3020_platform_data cm_x300_v3020_pdata
= {
494 .gpio_cs
= GPIO95_RTC_CS
,
495 .gpio_wr
= GPIO96_RTC_WR
,
496 .gpio_rd
= GPIO97_RTC_RD
,
497 .gpio_io
= GPIO98_RTC_IO
,
500 static struct platform_device cm_x300_rtc_device
= {
504 .platform_data
= &cm_x300_v3020_pdata
,
508 static void __init
cm_x300_init_rtc(void)
510 platform_device_register(&cm_x300_rtc_device
);
513 static inline void cm_x300_init_rtc(void) {}
516 static void __init
cm_x300_init_mfp(void)
518 /* board-processor specific GPIO initialization */
519 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x300_mfp_cfg
));
521 if (system_rev
< 130)
522 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x300_rev_lt130_mfp_cfg
));
524 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x300_rev_ge130_mfp_cfg
));
527 static void __init
cm_x300_init(void)
531 pxa_set_ffuart_info(NULL
);
532 pxa_set_btuart_info(NULL
);
533 pxa_set_stuart_info(NULL
);
535 cm_x300_init_dm9000();
547 static void __init
cm_x300_fixup(struct machine_desc
*mdesc
, struct tag
*tags
,
548 char **cmdline
, struct meminfo
*mi
)
551 mi
->bank
[0].start
= 0xa0000000;
552 mi
->bank
[0].node
= 0;
553 mi
->bank
[0].size
= (64*1024*1024);
554 mi
->bank
[1].start
= 0xc0000000;
555 mi
->bank
[1].node
= 0;
556 mi
->bank
[1].size
= (64*1024*1024);
559 MACHINE_START(CM_X300
, "CM-X300 module")
560 .phys_io
= 0x40000000,
561 .boot_params
= 0xa0000100,
562 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
563 .map_io
= pxa_map_io
,
564 .init_irq
= pxa3xx_init_irq
,
566 .init_machine
= cm_x300_init
,
567 .fixup
= cm_x300_fixup
,