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 | * | |
14fd9e00 | 6 | * Copyright (C) 2008,2009 CompuLab Ltd. |
cf75d8d2 MR |
7 | * |
8 | * Mike Rapoport <mike@compulab.co.il> | |
14fd9e00 | 9 | * Igor Grinberg <grinberg@compulab.co.il> |
cf75d8d2 MR |
10 | * |
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. | |
14 | */ | |
15 | ||
16 | #include <linux/module.h> | |
17 | #include <linux/kernel.h> | |
18 | #include <linux/interrupt.h> | |
19 | #include <linux/init.h> | |
b3d01da6 | 20 | #include <linux/delay.h> |
cf75d8d2 MR |
21 | #include <linux/platform_device.h> |
22 | ||
23 | #include <linux/gpio.h> | |
24 | #include <linux/dm9000.h> | |
25 | #include <linux/leds.h> | |
1858ced3 | 26 | #include <linux/rtc-v3020.h> |
db205463 | 27 | #include <linux/pwm_backlight.h> |
cf75d8d2 MR |
28 | |
29 | #include <linux/i2c.h> | |
30 | #include <linux/i2c/pca953x.h> | |
31 | ||
9c017ca1 | 32 | #include <linux/mfd/da903x.h> |
03ba7e07 IG |
33 | #include <linux/power_supply.h> |
34 | #include <linux/apm-emulation.h> | |
9c017ca1 | 35 | |
83e560ee IG |
36 | #include <linux/spi/spi.h> |
37 | #include <linux/spi/spi_gpio.h> | |
38 | #include <linux/spi/tdo24m.h> | |
39 | ||
cf75d8d2 MR |
40 | #include <asm/mach-types.h> |
41 | #include <asm/mach/arch.h> | |
b5a5c474 | 42 | #include <asm/setup.h> |
cf75d8d2 | 43 | |
51c62982 | 44 | #include <mach/pxa300.h> |
edaa64c9 | 45 | #include <mach/pxa27x-udc.h> |
cf75d8d2 MR |
46 | #include <mach/pxafb.h> |
47 | #include <mach/mmc.h> | |
48 | #include <mach/ohci.h> | |
f0a83701 | 49 | #include <plat/i2c.h> |
82b95ecb | 50 | #include <plat/pxa3xx_nand.h> |
74e74def | 51 | #include <mach/audio.h> |
cf75d8d2 MR |
52 | |
53 | #include <asm/mach/map.h> | |
54 | ||
55 | #include "generic.h" | |
db205463 | 56 | #include "devices.h" |
cf75d8d2 MR |
57 | |
58 | #define CM_X300_ETH_PHYS 0x08000010 | |
59 | ||
0bff2fc3 MR |
60 | #define GPIO82_MMC_IRQ (82) |
61 | #define GPIO85_MMC_WP (85) | |
cf75d8d2 | 62 | |
0bff2fc3 | 63 | #define CM_X300_MMC_IRQ IRQ_GPIO(GPIO82_MMC_IRQ) |
cf75d8d2 | 64 | |
1858ced3 MR |
65 | #define GPIO95_RTC_CS (95) |
66 | #define GPIO96_RTC_WR (96) | |
67 | #define GPIO97_RTC_RD (97) | |
68 | #define GPIO98_RTC_IO (98) | |
69 | ||
def8252d | 70 | static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = { |
cf75d8d2 MR |
71 | /* LCD */ |
72 | GPIO54_LCD_LDD_0, | |
73 | GPIO55_LCD_LDD_1, | |
74 | GPIO56_LCD_LDD_2, | |
75 | GPIO57_LCD_LDD_3, | |
76 | GPIO58_LCD_LDD_4, | |
77 | GPIO59_LCD_LDD_5, | |
78 | GPIO60_LCD_LDD_6, | |
79 | GPIO61_LCD_LDD_7, | |
80 | GPIO62_LCD_LDD_8, | |
81 | GPIO63_LCD_LDD_9, | |
82 | GPIO64_LCD_LDD_10, | |
83 | GPIO65_LCD_LDD_11, | |
84 | GPIO66_LCD_LDD_12, | |
85 | GPIO67_LCD_LDD_13, | |
86 | GPIO68_LCD_LDD_14, | |
87 | GPIO69_LCD_LDD_15, | |
88 | GPIO72_LCD_FCLK, | |
89 | GPIO73_LCD_LCLK, | |
90 | GPIO74_LCD_PCLK, | |
91 | GPIO75_LCD_BIAS, | |
92 | ||
93 | /* BTUART */ | |
94 | GPIO111_UART2_RTS, | |
95 | GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL, | |
96 | GPIO113_UART2_TXD, | |
97 | GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH, | |
98 | ||
99 | /* STUART */ | |
100 | GPIO109_UART3_TXD, | |
101 | GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL, | |
102 | ||
103 | /* AC97 */ | |
104 | GPIO23_AC97_nACRESET, | |
105 | GPIO24_AC97_SYSCLK, | |
106 | GPIO29_AC97_BITCLK, | |
107 | GPIO25_AC97_SDATA_IN_0, | |
108 | GPIO27_AC97_SDATA_OUT, | |
109 | GPIO28_AC97_SYNC, | |
110 | ||
111 | /* Keypad */ | |
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, | |
120 | GPIO121_KP_MKOUT_0, | |
121 | GPIO122_KP_MKOUT_1, | |
122 | GPIO123_KP_MKOUT_2, | |
123 | GPIO124_KP_MKOUT_3, | |
124 | GPIO125_KP_MKOUT_4, | |
125 | GPIO4_2_KP_MKOUT_5, | |
126 | ||
127 | /* MMC1 */ | |
128 | GPIO3_MMC1_DAT0, | |
129 | GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH, | |
130 | GPIO5_MMC1_DAT2, | |
131 | GPIO6_MMC1_DAT3, | |
132 | GPIO7_MMC1_CLK, | |
133 | GPIO8_MMC1_CMD, /* CMD0 for slot 0 */ | |
134 | ||
135 | /* MMC2 */ | |
136 | GPIO9_MMC2_DAT0, | |
137 | GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH, | |
138 | GPIO11_MMC2_DAT2, | |
139 | GPIO12_MMC2_DAT3, | |
140 | GPIO13_MMC2_CLK, | |
141 | GPIO14_MMC2_CMD, | |
142 | ||
143 | /* FFUART */ | |
144 | GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL, | |
145 | GPIO31_UART1_TXD, | |
146 | GPIO32_UART1_CTS, | |
147 | GPIO37_UART1_RTS, | |
148 | GPIO33_UART1_DCD, | |
149 | GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL, | |
150 | GPIO35_UART1_RI, | |
151 | GPIO36_UART1_DTR, | |
152 | ||
153 | /* GPIOs */ | |
cf75d8d2 MR |
154 | GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */ |
155 | GPIO85_GPIO, /* MMC WP */ | |
156 | GPIO99_GPIO, /* Ethernet IRQ */ | |
6f584cfa | 157 | |
1858ced3 MR |
158 | /* RTC GPIOs */ |
159 | GPIO95_GPIO, /* RTC CS */ | |
160 | GPIO96_GPIO, /* RTC WR */ | |
161 | GPIO97_GPIO, /* RTC RD */ | |
162 | GPIO98_GPIO, /* RTC IO */ | |
163 | ||
6f584cfa EM |
164 | /* Standard I2C */ |
165 | GPIO21_I2C_SCL, | |
166 | GPIO22_I2C_SDA, | |
db205463 IG |
167 | |
168 | /* PWM Backlight */ | |
169 | GPIO19_PWM2_OUT, | |
cf75d8d2 MR |
170 | }; |
171 | ||
def8252d | 172 | static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = { |
55052ea2 IG |
173 | /* GPIOs */ |
174 | GPIO79_GPIO, /* LED */ | |
175 | GPIO77_GPIO, /* WiFi reset */ | |
176 | GPIO78_GPIO, /* BT reset */ | |
177 | }; | |
178 | ||
def8252d | 179 | static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = { |
55052ea2 IG |
180 | /* GPIOs */ |
181 | GPIO76_GPIO, /* LED */ | |
182 | GPIO71_GPIO, /* WiFi reset */ | |
183 | GPIO70_GPIO, /* BT reset */ | |
184 | }; | |
185 | ||
def8252d IG |
186 | static mfp_cfg_t cm_x310_mfp_cfg[] __initdata = { |
187 | /* USB PORT 2 */ | |
188 | ULPI_STP, | |
189 | ULPI_NXT, | |
190 | ULPI_DIR, | |
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, | |
199 | GPIO38_ULPI_CLK, | |
200 | /* external PHY reset pin */ | |
201 | GPIO127_GPIO, | |
202 | ||
203 | /* USB PORT 3 */ | |
204 | GPIO77_USB_P3_1, | |
205 | GPIO78_USB_P3_2, | |
206 | GPIO79_USB_P3_3, | |
207 | GPIO80_USB_P3_4, | |
208 | GPIO81_USB_P3_5, | |
209 | GPIO82_USB_P3_6, | |
210 | GPIO0_2_USBH_PEN, | |
211 | }; | |
212 | ||
cf75d8d2 MR |
213 | #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) |
214 | static struct resource dm9000_resources[] = { | |
215 | [0] = { | |
216 | .start = CM_X300_ETH_PHYS, | |
217 | .end = CM_X300_ETH_PHYS + 0x3, | |
218 | .flags = IORESOURCE_MEM, | |
219 | }, | |
220 | [1] = { | |
221 | .start = CM_X300_ETH_PHYS + 0x4, | |
222 | .end = CM_X300_ETH_PHYS + 0x4 + 500, | |
223 | .flags = IORESOURCE_MEM, | |
224 | }, | |
225 | [2] = { | |
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, | |
229 | } | |
230 | }; | |
231 | ||
232 | static struct dm9000_plat_data cm_x300_dm9000_platdata = { | |
bff22c9b | 233 | .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM, |
cf75d8d2 MR |
234 | }; |
235 | ||
236 | static struct platform_device dm9000_device = { | |
237 | .name = "dm9000", | |
238 | .id = 0, | |
239 | .num_resources = ARRAY_SIZE(dm9000_resources), | |
240 | .resource = dm9000_resources, | |
241 | .dev = { | |
242 | .platform_data = &cm_x300_dm9000_platdata, | |
243 | } | |
244 | ||
245 | }; | |
246 | ||
247 | static void __init cm_x300_init_dm9000(void) | |
248 | { | |
249 | platform_device_register(&dm9000_device); | |
250 | } | |
251 | #else | |
252 | static inline void cm_x300_init_dm9000(void) {} | |
253 | #endif | |
254 | ||
83e560ee | 255 | /* LCD */ |
cf75d8d2 MR |
256 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
257 | static struct pxafb_mode_info cm_x300_lcd_modes[] = { | |
258 | [0] = { | |
83e560ee | 259 | .pixclock = 38250, |
cf75d8d2 MR |
260 | .bpp = 16, |
261 | .xres = 480, | |
262 | .yres = 640, | |
263 | .hsync_len = 8, | |
264 | .vsync_len = 2, | |
265 | .left_margin = 8, | |
83e560ee | 266 | .upper_margin = 2, |
cf75d8d2 MR |
267 | .right_margin = 24, |
268 | .lower_margin = 4, | |
269 | .cmap_greyscale = 0, | |
270 | }, | |
271 | [1] = { | |
272 | .pixclock = 153800, | |
273 | .bpp = 16, | |
274 | .xres = 240, | |
275 | .yres = 320, | |
276 | .hsync_len = 8, | |
277 | .vsync_len = 2, | |
278 | .left_margin = 8, | |
279 | .upper_margin = 2, | |
280 | .right_margin = 88, | |
281 | .lower_margin = 2, | |
282 | .cmap_greyscale = 0, | |
283 | }, | |
284 | }; | |
285 | ||
286 | static struct pxafb_mach_info cm_x300_lcd = { | |
287 | .modes = cm_x300_lcd_modes, | |
83e560ee | 288 | .num_modes = ARRAY_SIZE(cm_x300_lcd_modes), |
cf75d8d2 MR |
289 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL, |
290 | }; | |
291 | ||
292 | static void __init cm_x300_init_lcd(void) | |
293 | { | |
294 | set_pxa_fb_info(&cm_x300_lcd); | |
295 | } | |
296 | #else | |
297 | static inline void cm_x300_init_lcd(void) {} | |
298 | #endif | |
299 | ||
db205463 IG |
300 | #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE) |
301 | static struct platform_pwm_backlight_data cm_x300_backlight_data = { | |
302 | .pwm_id = 2, | |
303 | .max_brightness = 100, | |
304 | .dft_brightness = 100, | |
305 | .pwm_period_ns = 10000, | |
306 | }; | |
307 | ||
308 | static struct platform_device cm_x300_backlight_device = { | |
309 | .name = "pwm-backlight", | |
310 | .dev = { | |
311 | .parent = &pxa27x_device_pwm0.dev, | |
312 | .platform_data = &cm_x300_backlight_data, | |
313 | }, | |
314 | }; | |
315 | ||
316 | static void cm_x300_init_bl(void) | |
317 | { | |
318 | platform_device_register(&cm_x300_backlight_device); | |
319 | } | |
320 | #else | |
321 | static inline void cm_x300_init_bl(void) {} | |
322 | #endif | |
323 | ||
83e560ee IG |
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) | |
331 | ||
332 | static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata = { | |
333 | .sck = GPIO_LCD_SCL, | |
334 | .mosi = GPIO_LCD_DIN, | |
335 | .miso = GPIO_LCD_DOUT, | |
336 | .num_chipselect = 1, | |
337 | }; | |
338 | ||
339 | static struct platform_device cm_x300_spi_gpio = { | |
340 | .name = "spi_gpio", | |
341 | .id = LCD_SPI_BUS_NUM, | |
342 | .dev = { | |
343 | .platform_data = &cm_x300_spi_gpio_pdata, | |
344 | }, | |
345 | }; | |
346 | ||
347 | static struct tdo24m_platform_data cm_x300_tdo24m_pdata = { | |
348 | .model = TDO35S, | |
349 | }; | |
350 | ||
351 | static struct spi_board_info cm_x300_spi_devices[] __initdata = { | |
352 | { | |
353 | .modalias = "tdo24m", | |
354 | .max_speed_hz = 1000000, | |
355 | .bus_num = LCD_SPI_BUS_NUM, | |
356 | .chip_select = 0, | |
357 | .controller_data = (void *) GPIO_LCD_CS, | |
358 | .platform_data = &cm_x300_tdo24m_pdata, | |
359 | }, | |
360 | }; | |
361 | ||
362 | static void __init cm_x300_init_spi(void) | |
363 | { | |
364 | spi_register_board_info(cm_x300_spi_devices, | |
365 | ARRAY_SIZE(cm_x300_spi_devices)); | |
366 | platform_device_register(&cm_x300_spi_gpio); | |
367 | } | |
368 | #else | |
369 | static inline void cm_x300_init_spi(void) {} | |
370 | #endif | |
371 | ||
74e74def IG |
372 | #if defined(CONFIG_SND_PXA2XX_LIB_AC97) |
373 | static void __init cm_x300_init_ac97(void) | |
374 | { | |
375 | pxa_set_ac97_info(NULL); | |
376 | } | |
377 | #else | |
378 | static inline void cm_x300_init_ac97(void) {} | |
379 | #endif | |
380 | ||
cf75d8d2 MR |
381 | #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE) |
382 | static struct mtd_partition cm_x300_nand_partitions[] = { | |
383 | [0] = { | |
384 | .name = "OBM", | |
385 | .offset = 0, | |
386 | .size = SZ_256K, | |
387 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | |
388 | }, | |
389 | [1] = { | |
390 | .name = "U-Boot", | |
391 | .offset = MTDPART_OFS_APPEND, | |
392 | .size = SZ_256K, | |
393 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | |
394 | }, | |
395 | [2] = { | |
396 | .name = "Environment", | |
397 | .offset = MTDPART_OFS_APPEND, | |
398 | .size = SZ_256K, | |
399 | }, | |
400 | [3] = { | |
401 | .name = "reserved", | |
402 | .offset = MTDPART_OFS_APPEND, | |
403 | .size = SZ_256K + SZ_1M, | |
404 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | |
405 | }, | |
406 | [4] = { | |
407 | .name = "kernel", | |
408 | .offset = MTDPART_OFS_APPEND, | |
409 | .size = SZ_4M, | |
410 | }, | |
411 | [5] = { | |
412 | .name = "fs", | |
413 | .offset = MTDPART_OFS_APPEND, | |
414 | .size = MTDPART_SIZ_FULL, | |
415 | }, | |
416 | }; | |
417 | ||
418 | static struct pxa3xx_nand_platform_data cm_x300_nand_info = { | |
419 | .enable_arbiter = 1, | |
b3992b66 | 420 | .keep_config = 1, |
cf75d8d2 MR |
421 | .parts = cm_x300_nand_partitions, |
422 | .nr_parts = ARRAY_SIZE(cm_x300_nand_partitions), | |
423 | }; | |
424 | ||
425 | static void __init cm_x300_init_nand(void) | |
426 | { | |
427 | pxa3xx_set_nand_info(&cm_x300_nand_info); | |
428 | } | |
429 | #else | |
430 | static inline void cm_x300_init_nand(void) {} | |
431 | #endif | |
432 | ||
433 | #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE) | |
0bff2fc3 MR |
434 | static struct pxamci_platform_data cm_x300_mci_platform_data = { |
435 | .detect_delay = 20, | |
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, | |
439 | .gpio_power = -1, | |
440 | }; | |
441 | ||
442 | /* The second MMC slot of CM-X300 is hardwired to Libertas card and has | |
cf75d8d2 | 443 | no detection/ro pins */ |
0bff2fc3 MR |
444 | static int cm_x300_mci2_init(struct device *dev, |
445 | irq_handler_t cm_x300_detect_int, | |
446 | void *data) | |
cf75d8d2 MR |
447 | { |
448 | return 0; | |
449 | } | |
450 | ||
0bff2fc3 | 451 | static void cm_x300_mci2_exit(struct device *dev, void *data) |
cf75d8d2 MR |
452 | { |
453 | } | |
454 | ||
0bff2fc3 | 455 | static struct pxamci_platform_data cm_x300_mci2_platform_data = { |
7a648256 RJ |
456 | .detect_delay = 20, |
457 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, | |
0bff2fc3 MR |
458 | .init = cm_x300_mci2_init, |
459 | .exit = cm_x300_mci2_exit, | |
7a648256 RJ |
460 | .gpio_card_detect = -1, |
461 | .gpio_card_ro = -1, | |
462 | .gpio_power = -1, | |
cf75d8d2 MR |
463 | }; |
464 | ||
cf75d8d2 MR |
465 | static void __init cm_x300_init_mmc(void) |
466 | { | |
467 | pxa_set_mci_info(&cm_x300_mci_platform_data); | |
468 | pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data); | |
469 | } | |
470 | #else | |
471 | static inline void cm_x300_init_mmc(void) {} | |
472 | #endif | |
473 | ||
474 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) | |
edaa64c9 IG |
475 | static int cm_x300_ohci_init(struct device *dev) |
476 | { | |
477 | if (cpu_is_pxa300()) | |
478 | UP2OCR = UP2OCR_HXS | |
479 | | UP2OCR_HXOE | UP2OCR_DMPDE | UP2OCR_DPPDE; | |
480 | ||
481 | return 0; | |
482 | } | |
483 | ||
cf75d8d2 MR |
484 | static struct pxaohci_platform_data cm_x300_ohci_platform_data = { |
485 | .port_mode = PMM_PERPORT_MODE, | |
edaa64c9 IG |
486 | .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW, |
487 | .init = cm_x300_ohci_init, | |
cf75d8d2 | 488 | }; |
097b5334 | 489 | |
cf75d8d2 MR |
490 | static void __init cm_x300_init_ohci(void) |
491 | { | |
492 | pxa_set_ohci_info(&cm_x300_ohci_platform_data); | |
493 | } | |
494 | #else | |
495 | static inline void cm_x300_init_ohci(void) {} | |
496 | #endif | |
497 | ||
498 | #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) | |
499 | static struct gpio_led cm_x300_leds[] = { | |
500 | [0] = { | |
501 | .name = "cm-x300:green", | |
502 | .default_trigger = "heartbeat", | |
cf75d8d2 MR |
503 | .active_low = 1, |
504 | }, | |
505 | }; | |
506 | ||
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, | |
510 | }; | |
511 | ||
512 | static struct platform_device cm_x300_led_device = { | |
513 | .name = "leds-gpio", | |
514 | .id = -1, | |
515 | .dev = { | |
516 | .platform_data = &cm_x300_gpio_led_pdata, | |
517 | }, | |
518 | }; | |
519 | ||
520 | static void __init cm_x300_init_leds(void) | |
521 | { | |
55052ea2 IG |
522 | if (system_rev < 130) |
523 | cm_x300_leds[0].gpio = 79; | |
524 | else | |
525 | cm_x300_leds[0].gpio = 76; | |
526 | ||
cf75d8d2 MR |
527 | platform_device_register(&cm_x300_led_device); |
528 | } | |
529 | #else | |
530 | static inline void cm_x300_init_leds(void) {} | |
531 | #endif | |
532 | ||
533 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | |
534 | /* PCA9555 */ | |
535 | static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = { | |
536 | .gpio_base = 128, | |
537 | }; | |
538 | ||
539 | static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = { | |
540 | .gpio_base = 144, | |
541 | }; | |
542 | ||
543 | static struct i2c_board_info cm_x300_gpio_ext_info[] = { | |
544 | [0] = { | |
545 | I2C_BOARD_INFO("pca9555", 0x24), | |
546 | .platform_data = &cm_x300_gpio_ext_pdata_0, | |
547 | }, | |
548 | [1] = { | |
549 | I2C_BOARD_INFO("pca9555", 0x25), | |
550 | .platform_data = &cm_x300_gpio_ext_pdata_1, | |
551 | }, | |
552 | }; | |
553 | ||
554 | static void __init cm_x300_init_i2c(void) | |
555 | { | |
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)); | |
559 | } | |
560 | #else | |
561 | static inline void cm_x300_init_i2c(void) {} | |
562 | #endif | |
563 | ||
1858ced3 MR |
564 | #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE) |
565 | struct v3020_platform_data cm_x300_v3020_pdata = { | |
566 | .use_gpio = 1, | |
567 | .gpio_cs = GPIO95_RTC_CS, | |
568 | .gpio_wr = GPIO96_RTC_WR, | |
569 | .gpio_rd = GPIO97_RTC_RD, | |
570 | .gpio_io = GPIO98_RTC_IO, | |
571 | }; | |
572 | ||
573 | static struct platform_device cm_x300_rtc_device = { | |
574 | .name = "v3020", | |
575 | .id = -1, | |
576 | .dev = { | |
577 | .platform_data = &cm_x300_v3020_pdata, | |
578 | } | |
579 | }; | |
580 | ||
581 | static void __init cm_x300_init_rtc(void) | |
582 | { | |
583 | platform_device_register(&cm_x300_rtc_device); | |
584 | } | |
585 | #else | |
586 | static inline void cm_x300_init_rtc(void) {} | |
587 | #endif | |
588 | ||
03ba7e07 IG |
589 | /* Battery */ |
590 | struct power_supply_info cm_x300_psy_info = { | |
591 | .name = "battery", | |
592 | .technology = POWER_SUPPLY_TECHNOLOGY_LIPO, | |
593 | .voltage_max_design = 4200000, | |
594 | .voltage_min_design = 3000000, | |
595 | .use_for_apm = 1, | |
596 | }; | |
597 | ||
598 | static void cm_x300_battery_low(void) | |
599 | { | |
600 | #if defined(CONFIG_APM_EMULATION) | |
601 | apm_queue_event(APM_LOW_BATTERY); | |
602 | #endif | |
603 | } | |
604 | ||
605 | static void cm_x300_battery_critical(void) | |
606 | { | |
607 | #if defined(CONFIG_APM_EMULATION) | |
608 | apm_queue_event(APM_CRITICAL_SUSPEND); | |
609 | #endif | |
610 | } | |
611 | ||
612 | struct da9030_battery_info cm_x300_battery_info = { | |
613 | .battery_info = &cm_x300_psy_info, | |
614 | ||
615 | .charge_milliamp = 1000, | |
616 | .charge_millivolt = 4200, | |
617 | ||
618 | .vbat_low = 3600, | |
619 | .vbat_crit = 3400, | |
620 | .vbat_charge_start = 4100, | |
621 | .vbat_charge_stop = 4200, | |
622 | .vbat_charge_restart = 4000, | |
623 | ||
624 | .vcharge_min = 3200, | |
625 | .vcharge_max = 5500, | |
626 | ||
627 | .tbat_low = 197, | |
628 | .tbat_high = 78, | |
629 | .tbat_restart = 100, | |
630 | ||
631 | .batmon_interval = 0, | |
632 | ||
633 | .battery_low = cm_x300_battery_low, | |
634 | .battery_critical = cm_x300_battery_critical, | |
635 | }; | |
636 | ||
9c017ca1 IG |
637 | /* DA9030 */ |
638 | struct da903x_subdev_info cm_x300_da9030_subdevs[] = { | |
03ba7e07 IG |
639 | { |
640 | .name = "da903x-battery", | |
641 | .id = DA9030_ID_BAT, | |
642 | .platform_data = &cm_x300_battery_info, | |
643 | }, | |
9c017ca1 IG |
644 | }; |
645 | ||
646 | static struct da903x_platform_data cm_x300_da9030_info = { | |
647 | .num_subdevs = ARRAY_SIZE(cm_x300_da9030_subdevs), | |
648 | .subdevs = cm_x300_da9030_subdevs, | |
649 | }; | |
650 | ||
651 | static struct i2c_board_info cm_x300_pmic_info = { | |
652 | I2C_BOARD_INFO("da9030", 0x49), | |
653 | .irq = IRQ_GPIO(0), | |
654 | .platform_data = &cm_x300_da9030_info, | |
655 | }; | |
656 | ||
657 | static struct i2c_pxa_platform_data cm_x300_pwr_i2c_info = { | |
658 | .use_pio = 1, | |
659 | }; | |
660 | ||
661 | static void __init cm_x300_init_da9030(void) | |
662 | { | |
663 | pxa3xx_set_i2c_power_info(&cm_x300_pwr_i2c_info); | |
664 | i2c_register_board_info(1, &cm_x300_pmic_info, 1); | |
665 | } | |
666 | ||
b3d01da6 IG |
667 | static void __init cm_x300_init_wi2wi(void) |
668 | { | |
669 | int bt_reset, wlan_en; | |
670 | int err; | |
671 | ||
672 | if (system_rev < 130) { | |
673 | wlan_en = 77; | |
674 | bt_reset = 78; | |
675 | } else { | |
676 | wlan_en = 71; | |
677 | bt_reset = 70; | |
678 | } | |
679 | ||
680 | /* Libertas and CSR reset */ | |
681 | err = gpio_request(wlan_en, "wlan en"); | |
682 | if (err) { | |
683 | pr_err("CM-X300: failed to request wlan en gpio: %d\n", err); | |
684 | } else { | |
685 | gpio_direction_output(wlan_en, 1); | |
686 | gpio_free(wlan_en); | |
687 | } | |
688 | ||
689 | err = gpio_request(bt_reset, "bt reset"); | |
690 | if (err) { | |
691 | pr_err("CM-X300: failed to request bt reset gpio: %d\n", err); | |
692 | } else { | |
693 | gpio_direction_output(bt_reset, 1); | |
694 | udelay(10); | |
695 | gpio_set_value(bt_reset, 0); | |
696 | udelay(10); | |
697 | gpio_set_value(bt_reset, 1); | |
698 | gpio_free(bt_reset); | |
699 | } | |
700 | } | |
701 | ||
702 | /* MFP */ | |
55052ea2 | 703 | static void __init cm_x300_init_mfp(void) |
cf75d8d2 MR |
704 | { |
705 | /* board-processor specific GPIO initialization */ | |
def8252d | 706 | pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg)); |
cf75d8d2 | 707 | |
55052ea2 | 708 | if (system_rev < 130) |
def8252d | 709 | pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg)); |
55052ea2 | 710 | else |
def8252d IG |
711 | pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_ge130_mfp_cfg)); |
712 | ||
713 | if (cpu_is_pxa310()) | |
714 | pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x310_mfp_cfg)); | |
55052ea2 IG |
715 | } |
716 | ||
717 | static void __init cm_x300_init(void) | |
718 | { | |
719 | cm_x300_init_mfp(); | |
720 | ||
cc155c6f RK |
721 | pxa_set_ffuart_info(NULL); |
722 | pxa_set_btuart_info(NULL); | |
723 | pxa_set_stuart_info(NULL); | |
724 | ||
9c017ca1 | 725 | cm_x300_init_da9030(); |
cf75d8d2 MR |
726 | cm_x300_init_dm9000(); |
727 | cm_x300_init_lcd(); | |
728 | cm_x300_init_ohci(); | |
729 | cm_x300_init_mmc(); | |
730 | cm_x300_init_nand(); | |
731 | cm_x300_init_leds(); | |
732 | cm_x300_init_i2c(); | |
83e560ee | 733 | cm_x300_init_spi(); |
1858ced3 | 734 | cm_x300_init_rtc(); |
74e74def | 735 | cm_x300_init_ac97(); |
b3d01da6 | 736 | cm_x300_init_wi2wi(); |
db205463 | 737 | cm_x300_init_bl(); |
cf75d8d2 MR |
738 | } |
739 | ||
b5a5c474 MR |
740 | static void __init cm_x300_fixup(struct machine_desc *mdesc, struct tag *tags, |
741 | char **cmdline, struct meminfo *mi) | |
742 | { | |
743 | mi->nr_banks = 2; | |
744 | mi->bank[0].start = 0xa0000000; | |
745 | mi->bank[0].node = 0; | |
746 | mi->bank[0].size = (64*1024*1024); | |
747 | mi->bank[1].start = 0xc0000000; | |
748 | mi->bank[1].node = 0; | |
749 | mi->bank[1].size = (64*1024*1024); | |
750 | } | |
751 | ||
cf75d8d2 MR |
752 | MACHINE_START(CM_X300, "CM-X300 module") |
753 | .phys_io = 0x40000000, | |
754 | .boot_params = 0xa0000100, | |
755 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
756 | .map_io = pxa_map_io, | |
757 | .init_irq = pxa3xx_init_irq, | |
758 | .timer = &pxa_timer, | |
759 | .init_machine = cm_x300_init, | |
b5a5c474 | 760 | .fixup = cm_x300_fixup, |
cf75d8d2 | 761 | MACHINE_END |