]>
Commit | Line | Data |
---|---|---|
cf75d8d2 MR |
1 | /* |
2 | * linux/arch/arm/mach-pxa/cm-x300.c | |
3 | * | |
4 | * Support for the CompuLab CM-X300 modules | |
5 | * | |
6 | * Copyright (C) 2008 CompuLab Ltd. | |
7 | * | |
8 | * Mike Rapoport <mike@compulab.co.il> | |
9 | * | |
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. | |
13 | */ | |
14 | ||
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> | |
20 | ||
21 | #include <linux/gpio.h> | |
22 | #include <linux/dm9000.h> | |
23 | #include <linux/leds.h> | |
24 | ||
25 | #include <linux/i2c.h> | |
26 | #include <linux/i2c/pca953x.h> | |
27 | ||
28 | #include <asm/mach-types.h> | |
29 | #include <asm/mach/arch.h> | |
30 | ||
31 | #include <mach/mfp-pxa300.h> | |
32 | ||
33 | #include <mach/hardware.h> | |
cf75d8d2 MR |
34 | #include <mach/pxafb.h> |
35 | #include <mach/mmc.h> | |
36 | #include <mach/ohci.h> | |
37 | #include <mach/i2c.h> | |
38 | #include <mach/pxa3xx_nand.h> | |
39 | ||
40 | #include <asm/mach/map.h> | |
41 | ||
42 | #include "generic.h" | |
43 | ||
44 | #define CM_X300_ETH_PHYS 0x08000010 | |
45 | ||
46 | #define GPIO82_MMC2_IRQ (82) | |
47 | #define GPIO85_MMC2_WP (85) | |
48 | ||
49 | #define CM_X300_MMC2_IRQ IRQ_GPIO(GPIO82_MMC2_IRQ) | |
50 | ||
51 | static mfp_cfg_t cm_x300_mfp_cfg[] __initdata = { | |
52 | /* LCD */ | |
53 | GPIO54_LCD_LDD_0, | |
54 | GPIO55_LCD_LDD_1, | |
55 | GPIO56_LCD_LDD_2, | |
56 | GPIO57_LCD_LDD_3, | |
57 | GPIO58_LCD_LDD_4, | |
58 | GPIO59_LCD_LDD_5, | |
59 | GPIO60_LCD_LDD_6, | |
60 | GPIO61_LCD_LDD_7, | |
61 | GPIO62_LCD_LDD_8, | |
62 | GPIO63_LCD_LDD_9, | |
63 | GPIO64_LCD_LDD_10, | |
64 | GPIO65_LCD_LDD_11, | |
65 | GPIO66_LCD_LDD_12, | |
66 | GPIO67_LCD_LDD_13, | |
67 | GPIO68_LCD_LDD_14, | |
68 | GPIO69_LCD_LDD_15, | |
69 | GPIO72_LCD_FCLK, | |
70 | GPIO73_LCD_LCLK, | |
71 | GPIO74_LCD_PCLK, | |
72 | GPIO75_LCD_BIAS, | |
73 | ||
74 | /* BTUART */ | |
75 | GPIO111_UART2_RTS, | |
76 | GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL, | |
77 | GPIO113_UART2_TXD, | |
78 | GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH, | |
79 | ||
80 | /* STUART */ | |
81 | GPIO109_UART3_TXD, | |
82 | GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL, | |
83 | ||
84 | /* AC97 */ | |
85 | GPIO23_AC97_nACRESET, | |
86 | GPIO24_AC97_SYSCLK, | |
87 | GPIO29_AC97_BITCLK, | |
88 | GPIO25_AC97_SDATA_IN_0, | |
89 | GPIO27_AC97_SDATA_OUT, | |
90 | GPIO28_AC97_SYNC, | |
91 | ||
92 | /* Keypad */ | |
93 | GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH, | |
94 | GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH, | |
95 | GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH, | |
96 | GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH, | |
97 | GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH, | |
98 | GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH, | |
99 | GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH, | |
100 | GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH, | |
101 | GPIO121_KP_MKOUT_0, | |
102 | GPIO122_KP_MKOUT_1, | |
103 | GPIO123_KP_MKOUT_2, | |
104 | GPIO124_KP_MKOUT_3, | |
105 | GPIO125_KP_MKOUT_4, | |
106 | GPIO4_2_KP_MKOUT_5, | |
107 | ||
108 | /* MMC1 */ | |
109 | GPIO3_MMC1_DAT0, | |
110 | GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH, | |
111 | GPIO5_MMC1_DAT2, | |
112 | GPIO6_MMC1_DAT3, | |
113 | GPIO7_MMC1_CLK, | |
114 | GPIO8_MMC1_CMD, /* CMD0 for slot 0 */ | |
115 | ||
116 | /* MMC2 */ | |
117 | GPIO9_MMC2_DAT0, | |
118 | GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH, | |
119 | GPIO11_MMC2_DAT2, | |
120 | GPIO12_MMC2_DAT3, | |
121 | GPIO13_MMC2_CLK, | |
122 | GPIO14_MMC2_CMD, | |
123 | ||
124 | /* FFUART */ | |
125 | GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL, | |
126 | GPIO31_UART1_TXD, | |
127 | GPIO32_UART1_CTS, | |
128 | GPIO37_UART1_RTS, | |
129 | GPIO33_UART1_DCD, | |
130 | GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL, | |
131 | GPIO35_UART1_RI, | |
132 | GPIO36_UART1_DTR, | |
133 | ||
134 | /* GPIOs */ | |
135 | GPIO79_GPIO, /* LED */ | |
136 | GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */ | |
137 | GPIO85_GPIO, /* MMC WP */ | |
138 | GPIO99_GPIO, /* Ethernet IRQ */ | |
6f584cfa EM |
139 | |
140 | /* Standard I2C */ | |
141 | GPIO21_I2C_SCL, | |
142 | GPIO22_I2C_SDA, | |
cf75d8d2 MR |
143 | }; |
144 | ||
145 | #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) | |
146 | static struct resource dm9000_resources[] = { | |
147 | [0] = { | |
148 | .start = CM_X300_ETH_PHYS, | |
149 | .end = CM_X300_ETH_PHYS + 0x3, | |
150 | .flags = IORESOURCE_MEM, | |
151 | }, | |
152 | [1] = { | |
153 | .start = CM_X300_ETH_PHYS + 0x4, | |
154 | .end = CM_X300_ETH_PHYS + 0x4 + 500, | |
155 | .flags = IORESOURCE_MEM, | |
156 | }, | |
157 | [2] = { | |
158 | .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)), | |
159 | .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)), | |
160 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, | |
161 | } | |
162 | }; | |
163 | ||
164 | static struct dm9000_plat_data cm_x300_dm9000_platdata = { | |
165 | .flags = DM9000_PLATF_16BITONLY, | |
166 | }; | |
167 | ||
168 | static struct platform_device dm9000_device = { | |
169 | .name = "dm9000", | |
170 | .id = 0, | |
171 | .num_resources = ARRAY_SIZE(dm9000_resources), | |
172 | .resource = dm9000_resources, | |
173 | .dev = { | |
174 | .platform_data = &cm_x300_dm9000_platdata, | |
175 | } | |
176 | ||
177 | }; | |
178 | ||
179 | static void __init cm_x300_init_dm9000(void) | |
180 | { | |
181 | platform_device_register(&dm9000_device); | |
182 | } | |
183 | #else | |
184 | static inline void cm_x300_init_dm9000(void) {} | |
185 | #endif | |
186 | ||
187 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) | |
188 | static struct pxafb_mode_info cm_x300_lcd_modes[] = { | |
189 | [0] = { | |
190 | .pixclock = 38000, | |
191 | .bpp = 16, | |
192 | .xres = 480, | |
193 | .yres = 640, | |
194 | .hsync_len = 8, | |
195 | .vsync_len = 2, | |
196 | .left_margin = 8, | |
197 | .upper_margin = 0, | |
198 | .right_margin = 24, | |
199 | .lower_margin = 4, | |
200 | .cmap_greyscale = 0, | |
201 | }, | |
202 | [1] = { | |
203 | .pixclock = 153800, | |
204 | .bpp = 16, | |
205 | .xres = 240, | |
206 | .yres = 320, | |
207 | .hsync_len = 8, | |
208 | .vsync_len = 2, | |
209 | .left_margin = 8, | |
210 | .upper_margin = 2, | |
211 | .right_margin = 88, | |
212 | .lower_margin = 2, | |
213 | .cmap_greyscale = 0, | |
214 | }, | |
215 | }; | |
216 | ||
217 | static struct pxafb_mach_info cm_x300_lcd = { | |
218 | .modes = cm_x300_lcd_modes, | |
219 | .num_modes = 2, | |
220 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, | |
221 | }; | |
222 | ||
223 | static void __init cm_x300_init_lcd(void) | |
224 | { | |
225 | set_pxa_fb_info(&cm_x300_lcd); | |
226 | } | |
227 | #else | |
228 | static inline void cm_x300_init_lcd(void) {} | |
229 | #endif | |
230 | ||
231 | #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE) | |
232 | static struct mtd_partition cm_x300_nand_partitions[] = { | |
233 | [0] = { | |
234 | .name = "OBM", | |
235 | .offset = 0, | |
236 | .size = SZ_256K, | |
237 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | |
238 | }, | |
239 | [1] = { | |
240 | .name = "U-Boot", | |
241 | .offset = MTDPART_OFS_APPEND, | |
242 | .size = SZ_256K, | |
243 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | |
244 | }, | |
245 | [2] = { | |
246 | .name = "Environment", | |
247 | .offset = MTDPART_OFS_APPEND, | |
248 | .size = SZ_256K, | |
249 | }, | |
250 | [3] = { | |
251 | .name = "reserved", | |
252 | .offset = MTDPART_OFS_APPEND, | |
253 | .size = SZ_256K + SZ_1M, | |
254 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | |
255 | }, | |
256 | [4] = { | |
257 | .name = "kernel", | |
258 | .offset = MTDPART_OFS_APPEND, | |
259 | .size = SZ_4M, | |
260 | }, | |
261 | [5] = { | |
262 | .name = "fs", | |
263 | .offset = MTDPART_OFS_APPEND, | |
264 | .size = MTDPART_SIZ_FULL, | |
265 | }, | |
266 | }; | |
267 | ||
268 | static struct pxa3xx_nand_platform_data cm_x300_nand_info = { | |
269 | .enable_arbiter = 1, | |
270 | .parts = cm_x300_nand_partitions, | |
271 | .nr_parts = ARRAY_SIZE(cm_x300_nand_partitions), | |
272 | }; | |
273 | ||
274 | static void __init cm_x300_init_nand(void) | |
275 | { | |
276 | pxa3xx_set_nand_info(&cm_x300_nand_info); | |
277 | } | |
278 | #else | |
279 | static inline void cm_x300_init_nand(void) {} | |
280 | #endif | |
281 | ||
282 | #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE) | |
283 | /* The first MMC slot of CM-X300 is hardwired to Libertas card and has | |
284 | no detection/ro pins */ | |
285 | static int cm_x300_mci_init(struct device *dev, | |
286 | irq_handler_t cm_x300_detect_int, | |
287 | void *data) | |
288 | { | |
289 | return 0; | |
290 | } | |
291 | ||
292 | static void cm_x300_mci_exit(struct device *dev, void *data) | |
293 | { | |
294 | } | |
295 | ||
296 | static struct pxamci_platform_data cm_x300_mci_platform_data = { | |
297 | .detect_delay = 20, | |
298 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, | |
299 | .init = cm_x300_mci_init, | |
300 | .exit = cm_x300_mci_exit, | |
301 | }; | |
302 | ||
303 | static int cm_x300_mci2_ro(struct device *dev) | |
304 | { | |
305 | return gpio_get_value(GPIO85_MMC2_WP); | |
306 | } | |
307 | ||
308 | static int cm_x300_mci2_init(struct device *dev, | |
309 | irq_handler_t cm_x300_detect_int, | |
310 | void *data) | |
311 | { | |
312 | int err; | |
313 | ||
314 | /* | |
315 | * setup GPIO for CM-X300 MMC controller | |
316 | */ | |
317 | err = gpio_request(GPIO82_MMC2_IRQ, "mmc card detect"); | |
318 | if (err) | |
319 | goto err_request_cd; | |
320 | gpio_direction_input(GPIO82_MMC2_IRQ); | |
321 | ||
322 | err = gpio_request(GPIO85_MMC2_WP, "mmc write protect"); | |
323 | if (err) | |
324 | goto err_request_wp; | |
325 | gpio_direction_input(GPIO85_MMC2_WP); | |
326 | ||
327 | err = request_irq(CM_X300_MMC2_IRQ, cm_x300_detect_int, | |
328 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | |
329 | "MMC card detect", data); | |
330 | if (err) { | |
331 | printk(KERN_ERR "%s: MMC/SD/SDIO: " | |
332 | "can't request card detect IRQ\n", __func__); | |
333 | goto err_request_irq; | |
334 | } | |
335 | ||
336 | return 0; | |
337 | ||
338 | err_request_irq: | |
339 | gpio_free(GPIO85_MMC2_WP); | |
340 | err_request_wp: | |
341 | gpio_free(GPIO82_MMC2_IRQ); | |
342 | err_request_cd: | |
343 | return err; | |
344 | } | |
345 | ||
346 | static void cm_x300_mci2_exit(struct device *dev, void *data) | |
347 | { | |
348 | free_irq(CM_X300_MMC2_IRQ, data); | |
349 | gpio_free(GPIO82_MMC2_IRQ); | |
350 | gpio_free(GPIO85_MMC2_WP); | |
351 | } | |
352 | ||
353 | static struct pxamci_platform_data cm_x300_mci2_platform_data = { | |
354 | .detect_delay = 20, | |
355 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, | |
356 | .init = cm_x300_mci2_init, | |
357 | .exit = cm_x300_mci2_exit, | |
358 | .get_ro = cm_x300_mci2_ro, | |
359 | }; | |
360 | ||
361 | static void __init cm_x300_init_mmc(void) | |
362 | { | |
363 | pxa_set_mci_info(&cm_x300_mci_platform_data); | |
364 | pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data); | |
365 | } | |
366 | #else | |
367 | static inline void cm_x300_init_mmc(void) {} | |
368 | #endif | |
369 | ||
370 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) | |
cf75d8d2 MR |
371 | static struct pxaohci_platform_data cm_x300_ohci_platform_data = { |
372 | .port_mode = PMM_PERPORT_MODE, | |
097b5334 | 373 | .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW, |
cf75d8d2 | 374 | }; |
097b5334 | 375 | |
cf75d8d2 MR |
376 | static void __init cm_x300_init_ohci(void) |
377 | { | |
378 | pxa_set_ohci_info(&cm_x300_ohci_platform_data); | |
379 | } | |
380 | #else | |
381 | static inline void cm_x300_init_ohci(void) {} | |
382 | #endif | |
383 | ||
384 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) | |
385 | static struct gpio_led cm_x300_leds[] = { | |
386 | [0] = { | |
387 | .name = "cm-x300:green", | |
388 | .default_trigger = "heartbeat", | |
389 | .gpio = 79, | |
390 | .active_low = 1, | |
391 | }, | |
392 | }; | |
393 | ||
394 | static struct gpio_led_platform_data cm_x300_gpio_led_pdata = { | |
395 | .num_leds = ARRAY_SIZE(cm_x300_leds), | |
396 | .leds = cm_x300_leds, | |
397 | }; | |
398 | ||
399 | static struct platform_device cm_x300_led_device = { | |
400 | .name = "leds-gpio", | |
401 | .id = -1, | |
402 | .dev = { | |
403 | .platform_data = &cm_x300_gpio_led_pdata, | |
404 | }, | |
405 | }; | |
406 | ||
407 | static void __init cm_x300_init_leds(void) | |
408 | { | |
409 | platform_device_register(&cm_x300_led_device); | |
410 | } | |
411 | #else | |
412 | static inline void cm_x300_init_leds(void) {} | |
413 | #endif | |
414 | ||
415 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | |
416 | /* PCA9555 */ | |
417 | static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = { | |
418 | .gpio_base = 128, | |
419 | }; | |
420 | ||
421 | static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = { | |
422 | .gpio_base = 144, | |
423 | }; | |
424 | ||
425 | static struct i2c_board_info cm_x300_gpio_ext_info[] = { | |
426 | [0] = { | |
427 | I2C_BOARD_INFO("pca9555", 0x24), | |
428 | .platform_data = &cm_x300_gpio_ext_pdata_0, | |
429 | }, | |
430 | [1] = { | |
431 | I2C_BOARD_INFO("pca9555", 0x25), | |
432 | .platform_data = &cm_x300_gpio_ext_pdata_1, | |
433 | }, | |
434 | }; | |
435 | ||
436 | static void __init cm_x300_init_i2c(void) | |
437 | { | |
438 | pxa_set_i2c_info(NULL); | |
439 | i2c_register_board_info(0, cm_x300_gpio_ext_info, | |
440 | ARRAY_SIZE(cm_x300_gpio_ext_info)); | |
441 | } | |
442 | #else | |
443 | static inline void cm_x300_init_i2c(void) {} | |
444 | #endif | |
445 | ||
446 | static void __init cm_x300_init(void) | |
447 | { | |
448 | /* board-processor specific GPIO initialization */ | |
449 | pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x300_mfp_cfg)); | |
450 | ||
451 | cm_x300_init_dm9000(); | |
452 | cm_x300_init_lcd(); | |
453 | cm_x300_init_ohci(); | |
454 | cm_x300_init_mmc(); | |
455 | cm_x300_init_nand(); | |
456 | cm_x300_init_leds(); | |
457 | cm_x300_init_i2c(); | |
458 | } | |
459 | ||
460 | MACHINE_START(CM_X300, "CM-X300 module") | |
461 | .phys_io = 0x40000000, | |
462 | .boot_params = 0xa0000100, | |
463 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
464 | .map_io = pxa_map_io, | |
465 | .init_irq = pxa3xx_init_irq, | |
466 | .timer = &pxa_timer, | |
467 | .init_machine = cm_x300_init, | |
468 | MACHINE_END |