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 <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/setup.h>
33 #include <mach/pxa300.h>
34 #include <mach/pxafb.h>
36 #include <mach/ohci.h>
38 #include <mach/pxa3xx_nand.h>
40 #include <asm/mach/map.h>
44 #define CM_X300_ETH_PHYS 0x08000010
46 #define GPIO82_MMC2_IRQ (82)
47 #define GPIO85_MMC2_WP (85)
49 #define CM_X300_MMC2_IRQ IRQ_GPIO(GPIO82_MMC2_IRQ)
51 #define GPIO95_RTC_CS (95)
52 #define GPIO96_RTC_WR (96)
53 #define GPIO97_RTC_RD (97)
54 #define GPIO98_RTC_IO (98)
56 static mfp_cfg_t cm_x300_mfp_cfg
[] __initdata
= {
81 GPIO112_UART2_RXD
| MFP_LPM_EDGE_FALL
,
83 GPIO114_UART2_CTS
| MFP_LPM_EDGE_BOTH
,
87 GPIO110_UART3_RXD
| MFP_LPM_EDGE_FALL
,
93 GPIO25_AC97_SDATA_IN_0
,
94 GPIO27_AC97_SDATA_OUT
,
98 GPIO115_KP_MKIN_0
| MFP_LPM_EDGE_BOTH
,
99 GPIO116_KP_MKIN_1
| MFP_LPM_EDGE_BOTH
,
100 GPIO117_KP_MKIN_2
| MFP_LPM_EDGE_BOTH
,
101 GPIO118_KP_MKIN_3
| MFP_LPM_EDGE_BOTH
,
102 GPIO119_KP_MKIN_4
| MFP_LPM_EDGE_BOTH
,
103 GPIO120_KP_MKIN_5
| MFP_LPM_EDGE_BOTH
,
104 GPIO2_2_KP_MKIN_6
| MFP_LPM_EDGE_BOTH
,
105 GPIO3_2_KP_MKIN_7
| MFP_LPM_EDGE_BOTH
,
115 GPIO4_MMC1_DAT1
| MFP_LPM_EDGE_BOTH
,
119 GPIO8_MMC1_CMD
, /* CMD0 for slot 0 */
123 GPIO10_MMC2_DAT1
| MFP_LPM_EDGE_BOTH
,
130 GPIO30_UART1_RXD
| MFP_LPM_EDGE_FALL
,
135 GPIO34_UART1_DSR
| MFP_LPM_EDGE_FALL
,
140 GPIO79_GPIO
, /* LED */
141 GPIO82_GPIO
| MFP_PULL_HIGH
, /* MMC CD */
142 GPIO85_GPIO
, /* MMC WP */
143 GPIO99_GPIO
, /* Ethernet IRQ */
146 GPIO95_GPIO
, /* RTC CS */
147 GPIO96_GPIO
, /* RTC WR */
148 GPIO97_GPIO
, /* RTC RD */
149 GPIO98_GPIO
, /* RTC IO */
156 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
157 static struct resource dm9000_resources
[] = {
159 .start
= CM_X300_ETH_PHYS
,
160 .end
= CM_X300_ETH_PHYS
+ 0x3,
161 .flags
= IORESOURCE_MEM
,
164 .start
= CM_X300_ETH_PHYS
+ 0x4,
165 .end
= CM_X300_ETH_PHYS
+ 0x4 + 500,
166 .flags
= IORESOURCE_MEM
,
169 .start
= IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99
)),
170 .end
= IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99
)),
171 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
175 static struct dm9000_plat_data cm_x300_dm9000_platdata
= {
176 .flags
= DM9000_PLATF_16BITONLY
| DM9000_PLATF_NO_EEPROM
,
179 static struct platform_device dm9000_device
= {
182 .num_resources
= ARRAY_SIZE(dm9000_resources
),
183 .resource
= dm9000_resources
,
185 .platform_data
= &cm_x300_dm9000_platdata
,
190 static void __init
cm_x300_init_dm9000(void)
192 platform_device_register(&dm9000_device
);
195 static inline void cm_x300_init_dm9000(void) {}
198 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
199 static struct pxafb_mode_info cm_x300_lcd_modes
[] = {
228 static struct pxafb_mach_info cm_x300_lcd
= {
229 .modes
= cm_x300_lcd_modes
,
231 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
234 static void __init
cm_x300_init_lcd(void)
236 set_pxa_fb_info(&cm_x300_lcd
);
239 static inline void cm_x300_init_lcd(void) {}
242 #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
243 static struct mtd_partition cm_x300_nand_partitions
[] = {
248 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
252 .offset
= MTDPART_OFS_APPEND
,
254 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
257 .name
= "Environment",
258 .offset
= MTDPART_OFS_APPEND
,
263 .offset
= MTDPART_OFS_APPEND
,
264 .size
= SZ_256K
+ SZ_1M
,
265 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
269 .offset
= MTDPART_OFS_APPEND
,
274 .offset
= MTDPART_OFS_APPEND
,
275 .size
= MTDPART_SIZ_FULL
,
279 static struct pxa3xx_nand_platform_data cm_x300_nand_info
= {
282 .parts
= cm_x300_nand_partitions
,
283 .nr_parts
= ARRAY_SIZE(cm_x300_nand_partitions
),
286 static void __init
cm_x300_init_nand(void)
288 pxa3xx_set_nand_info(&cm_x300_nand_info
);
291 static inline void cm_x300_init_nand(void) {}
294 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
295 /* The first MMC slot of CM-X300 is hardwired to Libertas card and has
296 no detection/ro pins */
297 static int cm_x300_mci_init(struct device
*dev
,
298 irq_handler_t cm_x300_detect_int
,
304 static void cm_x300_mci_exit(struct device
*dev
, void *data
)
308 static struct pxamci_platform_data cm_x300_mci_platform_data
= {
310 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
311 .init
= cm_x300_mci_init
,
312 .exit
= cm_x300_mci_exit
,
315 static int cm_x300_mci2_ro(struct device
*dev
)
317 return gpio_get_value(GPIO85_MMC2_WP
);
320 static int cm_x300_mci2_init(struct device
*dev
,
321 irq_handler_t cm_x300_detect_int
,
327 * setup GPIO for CM-X300 MMC controller
329 err
= gpio_request(GPIO82_MMC2_IRQ
, "mmc card detect");
332 gpio_direction_input(GPIO82_MMC2_IRQ
);
334 err
= gpio_request(GPIO85_MMC2_WP
, "mmc write protect");
337 gpio_direction_input(GPIO85_MMC2_WP
);
339 err
= request_irq(CM_X300_MMC2_IRQ
, cm_x300_detect_int
,
340 IRQF_TRIGGER_RISING
| IRQF_TRIGGER_FALLING
,
341 "MMC card detect", data
);
343 printk(KERN_ERR
"%s: MMC/SD/SDIO: "
344 "can't request card detect IRQ\n", __func__
);
345 goto err_request_irq
;
351 gpio_free(GPIO85_MMC2_WP
);
353 gpio_free(GPIO82_MMC2_IRQ
);
358 static void cm_x300_mci2_exit(struct device
*dev
, void *data
)
360 free_irq(CM_X300_MMC2_IRQ
, data
);
361 gpio_free(GPIO82_MMC2_IRQ
);
362 gpio_free(GPIO85_MMC2_WP
);
365 static struct pxamci_platform_data cm_x300_mci2_platform_data
= {
367 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
368 .init
= cm_x300_mci2_init
,
369 .exit
= cm_x300_mci2_exit
,
370 .get_ro
= cm_x300_mci2_ro
,
373 static void __init
cm_x300_init_mmc(void)
375 pxa_set_mci_info(&cm_x300_mci_platform_data
);
376 pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data
);
379 static inline void cm_x300_init_mmc(void) {}
382 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
383 static struct pxaohci_platform_data cm_x300_ohci_platform_data
= {
384 .port_mode
= PMM_PERPORT_MODE
,
385 .flags
= ENABLE_PORT1
| ENABLE_PORT2
| POWER_CONTROL_LOW
,
388 static void __init
cm_x300_init_ohci(void)
390 pxa_set_ohci_info(&cm_x300_ohci_platform_data
);
393 static inline void cm_x300_init_ohci(void) {}
396 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
397 static struct gpio_led cm_x300_leds
[] = {
399 .name
= "cm-x300:green",
400 .default_trigger
= "heartbeat",
406 static struct gpio_led_platform_data cm_x300_gpio_led_pdata
= {
407 .num_leds
= ARRAY_SIZE(cm_x300_leds
),
408 .leds
= cm_x300_leds
,
411 static struct platform_device cm_x300_led_device
= {
415 .platform_data
= &cm_x300_gpio_led_pdata
,
419 static void __init
cm_x300_init_leds(void)
421 platform_device_register(&cm_x300_led_device
);
424 static inline void cm_x300_init_leds(void) {}
427 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
429 static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0
= {
433 static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1
= {
437 static struct i2c_board_info cm_x300_gpio_ext_info
[] = {
439 I2C_BOARD_INFO("pca9555", 0x24),
440 .platform_data
= &cm_x300_gpio_ext_pdata_0
,
443 I2C_BOARD_INFO("pca9555", 0x25),
444 .platform_data
= &cm_x300_gpio_ext_pdata_1
,
448 static void __init
cm_x300_init_i2c(void)
450 pxa_set_i2c_info(NULL
);
451 i2c_register_board_info(0, cm_x300_gpio_ext_info
,
452 ARRAY_SIZE(cm_x300_gpio_ext_info
));
455 static inline void cm_x300_init_i2c(void) {}
458 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
459 struct v3020_platform_data cm_x300_v3020_pdata
= {
461 .gpio_cs
= GPIO95_RTC_CS
,
462 .gpio_wr
= GPIO96_RTC_WR
,
463 .gpio_rd
= GPIO97_RTC_RD
,
464 .gpio_io
= GPIO98_RTC_IO
,
467 static struct platform_device cm_x300_rtc_device
= {
471 .platform_data
= &cm_x300_v3020_pdata
,
475 static void __init
cm_x300_init_rtc(void)
477 platform_device_register(&cm_x300_rtc_device
);
480 static inline void cm_x300_init_rtc(void) {}
483 static void __init
cm_x300_init(void)
485 /* board-processor specific GPIO initialization */
486 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x300_mfp_cfg
));
488 cm_x300_init_dm9000();
498 static void __init
cm_x300_fixup(struct machine_desc
*mdesc
, struct tag
*tags
,
499 char **cmdline
, struct meminfo
*mi
)
502 mi
->bank
[0].start
= 0xa0000000;
503 mi
->bank
[0].node
= 0;
504 mi
->bank
[0].size
= (64*1024*1024);
505 mi
->bank
[1].start
= 0xc0000000;
506 mi
->bank
[1].node
= 0;
507 mi
->bank
[1].size
= (64*1024*1024);
510 MACHINE_START(CM_X300
, "CM-X300 module")
511 .phys_io
= 0x40000000,
512 .boot_params
= 0xa0000100,
513 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
514 .map_io
= pxa_map_io
,
515 .init_irq
= pxa3xx_init_irq
,
517 .init_machine
= cm_x300_init
,
518 .fixup
= cm_x300_fixup
,