blob: 8aedc60aaa654d56c8051b37686183bb10a6ac7c [file] [log] [blame]
Mike Rapoportcf75d8d2008-08-26 14:03:44 +01001/*
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>
Igor Grinbergb3d01da2009-10-14 09:20:21 +020019#include <linux/delay.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010020#include <linux/platform_device.h>
21
22#include <linux/gpio.h>
23#include <linux/dm9000.h>
24#include <linux/leds.h>
Mike Rapoport1858ced2009-06-04 10:44:52 +030025#include <linux/rtc-v3020.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010026
27#include <linux/i2c.h>
28#include <linux/i2c/pca953x.h>
29
Igor Grinberg9c017ca2009-10-14 09:20:24 +020030#include <linux/mfd/da903x.h>
31
Igor Grinberg83e560e2009-10-14 09:20:19 +020032#include <linux/spi/spi.h>
33#include <linux/spi/spi_gpio.h>
34#include <linux/spi/tdo24m.h>
35
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010036#include <asm/mach-types.h>
37#include <asm/mach/arch.h>
Mike Rapoportb5a5c472009-06-04 10:44:54 +030038#include <asm/setup.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010039
Eric Miao51c62982009-01-02 23:17:22 +080040#include <mach/pxa300.h>
Igor Grinbergedaa64c2009-10-14 09:20:23 +020041#include <mach/pxa27x-udc.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010042#include <mach/pxafb.h>
43#include <mach/mmc.h>
44#include <mach/ohci.h>
Eric Miaof0a83702009-04-13 15:03:11 +080045#include <plat/i2c.h>
Haojian Zhuang82b95ec2009-09-10 13:55:23 +080046#include <plat/pxa3xx_nand.h>
Igor Grinberg74e74de2009-10-14 09:20:20 +020047#include <mach/audio.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010048
49#include <asm/mach/map.h>
50
51#include "generic.h"
52
53#define CM_X300_ETH_PHYS 0x08000010
54
Mike Rapoport0bff2fc2009-10-15 10:11:09 +020055#define GPIO82_MMC_IRQ (82)
56#define GPIO85_MMC_WP (85)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010057
Mike Rapoport0bff2fc2009-10-15 10:11:09 +020058#define CM_X300_MMC_IRQ IRQ_GPIO(GPIO82_MMC_IRQ)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010059
Mike Rapoport1858ced2009-06-04 10:44:52 +030060#define GPIO95_RTC_CS (95)
61#define GPIO96_RTC_WR (96)
62#define GPIO97_RTC_RD (97)
63#define GPIO98_RTC_IO (98)
64
Igor Grinbergdef82522009-10-14 09:20:22 +020065static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010066 /* LCD */
67 GPIO54_LCD_LDD_0,
68 GPIO55_LCD_LDD_1,
69 GPIO56_LCD_LDD_2,
70 GPIO57_LCD_LDD_3,
71 GPIO58_LCD_LDD_4,
72 GPIO59_LCD_LDD_5,
73 GPIO60_LCD_LDD_6,
74 GPIO61_LCD_LDD_7,
75 GPIO62_LCD_LDD_8,
76 GPIO63_LCD_LDD_9,
77 GPIO64_LCD_LDD_10,
78 GPIO65_LCD_LDD_11,
79 GPIO66_LCD_LDD_12,
80 GPIO67_LCD_LDD_13,
81 GPIO68_LCD_LDD_14,
82 GPIO69_LCD_LDD_15,
83 GPIO72_LCD_FCLK,
84 GPIO73_LCD_LCLK,
85 GPIO74_LCD_PCLK,
86 GPIO75_LCD_BIAS,
87
88 /* BTUART */
89 GPIO111_UART2_RTS,
90 GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
91 GPIO113_UART2_TXD,
92 GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
93
94 /* STUART */
95 GPIO109_UART3_TXD,
96 GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
97
98 /* AC97 */
99 GPIO23_AC97_nACRESET,
100 GPIO24_AC97_SYSCLK,
101 GPIO29_AC97_BITCLK,
102 GPIO25_AC97_SDATA_IN_0,
103 GPIO27_AC97_SDATA_OUT,
104 GPIO28_AC97_SYNC,
105
106 /* Keypad */
107 GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
108 GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
109 GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
110 GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
111 GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
112 GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
113 GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
114 GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
115 GPIO121_KP_MKOUT_0,
116 GPIO122_KP_MKOUT_1,
117 GPIO123_KP_MKOUT_2,
118 GPIO124_KP_MKOUT_3,
119 GPIO125_KP_MKOUT_4,
120 GPIO4_2_KP_MKOUT_5,
121
122 /* MMC1 */
123 GPIO3_MMC1_DAT0,
124 GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
125 GPIO5_MMC1_DAT2,
126 GPIO6_MMC1_DAT3,
127 GPIO7_MMC1_CLK,
128 GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
129
130 /* MMC2 */
131 GPIO9_MMC2_DAT0,
132 GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
133 GPIO11_MMC2_DAT2,
134 GPIO12_MMC2_DAT3,
135 GPIO13_MMC2_CLK,
136 GPIO14_MMC2_CMD,
137
138 /* FFUART */
139 GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
140 GPIO31_UART1_TXD,
141 GPIO32_UART1_CTS,
142 GPIO37_UART1_RTS,
143 GPIO33_UART1_DCD,
144 GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
145 GPIO35_UART1_RI,
146 GPIO36_UART1_DTR,
147
148 /* GPIOs */
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100149 GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */
150 GPIO85_GPIO, /* MMC WP */
151 GPIO99_GPIO, /* Ethernet IRQ */
Eric Miao6f584cf2008-11-28 16:00:24 +0800152
Mike Rapoport1858ced2009-06-04 10:44:52 +0300153 /* RTC GPIOs */
154 GPIO95_GPIO, /* RTC CS */
155 GPIO96_GPIO, /* RTC WR */
156 GPIO97_GPIO, /* RTC RD */
157 GPIO98_GPIO, /* RTC IO */
158
Eric Miao6f584cf2008-11-28 16:00:24 +0800159 /* Standard I2C */
160 GPIO21_I2C_SCL,
161 GPIO22_I2C_SDA,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100162};
163
Igor Grinbergdef82522009-10-14 09:20:22 +0200164static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = {
Igor Grinberg55052ea2009-10-14 09:20:18 +0200165 /* GPIOs */
166 GPIO79_GPIO, /* LED */
167 GPIO77_GPIO, /* WiFi reset */
168 GPIO78_GPIO, /* BT reset */
169};
170
Igor Grinbergdef82522009-10-14 09:20:22 +0200171static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = {
Igor Grinberg55052ea2009-10-14 09:20:18 +0200172 /* GPIOs */
173 GPIO76_GPIO, /* LED */
174 GPIO71_GPIO, /* WiFi reset */
175 GPIO70_GPIO, /* BT reset */
176};
177
Igor Grinbergdef82522009-10-14 09:20:22 +0200178static mfp_cfg_t cm_x310_mfp_cfg[] __initdata = {
179 /* USB PORT 2 */
180 ULPI_STP,
181 ULPI_NXT,
182 ULPI_DIR,
183 GPIO30_ULPI_DATA_OUT_0,
184 GPIO31_ULPI_DATA_OUT_1,
185 GPIO32_ULPI_DATA_OUT_2,
186 GPIO33_ULPI_DATA_OUT_3,
187 GPIO34_ULPI_DATA_OUT_4,
188 GPIO35_ULPI_DATA_OUT_5,
189 GPIO36_ULPI_DATA_OUT_6,
190 GPIO37_ULPI_DATA_OUT_7,
191 GPIO38_ULPI_CLK,
192 /* external PHY reset pin */
193 GPIO127_GPIO,
194
195 /* USB PORT 3 */
196 GPIO77_USB_P3_1,
197 GPIO78_USB_P3_2,
198 GPIO79_USB_P3_3,
199 GPIO80_USB_P3_4,
200 GPIO81_USB_P3_5,
201 GPIO82_USB_P3_6,
202 GPIO0_2_USBH_PEN,
203};
204
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100205#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
206static struct resource dm9000_resources[] = {
207 [0] = {
208 .start = CM_X300_ETH_PHYS,
209 .end = CM_X300_ETH_PHYS + 0x3,
210 .flags = IORESOURCE_MEM,
211 },
212 [1] = {
213 .start = CM_X300_ETH_PHYS + 0x4,
214 .end = CM_X300_ETH_PHYS + 0x4 + 500,
215 .flags = IORESOURCE_MEM,
216 },
217 [2] = {
218 .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
219 .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
220 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
221 }
222};
223
224static struct dm9000_plat_data cm_x300_dm9000_platdata = {
Mike Rapoportbff22c92009-02-23 18:01:12 +0200225 .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100226};
227
228static struct platform_device dm9000_device = {
229 .name = "dm9000",
230 .id = 0,
231 .num_resources = ARRAY_SIZE(dm9000_resources),
232 .resource = dm9000_resources,
233 .dev = {
234 .platform_data = &cm_x300_dm9000_platdata,
235 }
236
237};
238
239static void __init cm_x300_init_dm9000(void)
240{
241 platform_device_register(&dm9000_device);
242}
243#else
244static inline void cm_x300_init_dm9000(void) {}
245#endif
246
Igor Grinberg83e560e2009-10-14 09:20:19 +0200247/* LCD */
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100248#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
249static struct pxafb_mode_info cm_x300_lcd_modes[] = {
250 [0] = {
Igor Grinberg83e560e2009-10-14 09:20:19 +0200251 .pixclock = 38250,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100252 .bpp = 16,
253 .xres = 480,
254 .yres = 640,
255 .hsync_len = 8,
256 .vsync_len = 2,
257 .left_margin = 8,
Igor Grinberg83e560e2009-10-14 09:20:19 +0200258 .upper_margin = 2,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100259 .right_margin = 24,
260 .lower_margin = 4,
261 .cmap_greyscale = 0,
262 },
263 [1] = {
264 .pixclock = 153800,
265 .bpp = 16,
266 .xres = 240,
267 .yres = 320,
268 .hsync_len = 8,
269 .vsync_len = 2,
270 .left_margin = 8,
271 .upper_margin = 2,
272 .right_margin = 88,
273 .lower_margin = 2,
274 .cmap_greyscale = 0,
275 },
276};
277
278static struct pxafb_mach_info cm_x300_lcd = {
279 .modes = cm_x300_lcd_modes,
Igor Grinberg83e560e2009-10-14 09:20:19 +0200280 .num_modes = ARRAY_SIZE(cm_x300_lcd_modes),
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100281 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
282};
283
284static void __init cm_x300_init_lcd(void)
285{
286 set_pxa_fb_info(&cm_x300_lcd);
287}
288#else
289static inline void cm_x300_init_lcd(void) {}
290#endif
291
Igor Grinberg83e560e2009-10-14 09:20:19 +0200292#if defined(CONFIG_SPI_GPIO) || defined(CONFIG_SPI_GPIO_MODULE)
293#define GPIO_LCD_BASE (144)
294#define GPIO_LCD_DIN (GPIO_LCD_BASE + 8) /* aux_gpio3_0 */
295#define GPIO_LCD_DOUT (GPIO_LCD_BASE + 9) /* aux_gpio3_1 */
296#define GPIO_LCD_SCL (GPIO_LCD_BASE + 10) /* aux_gpio3_2 */
297#define GPIO_LCD_CS (GPIO_LCD_BASE + 11) /* aux_gpio3_3 */
298#define LCD_SPI_BUS_NUM (1)
299
300static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata = {
301 .sck = GPIO_LCD_SCL,
302 .mosi = GPIO_LCD_DIN,
303 .miso = GPIO_LCD_DOUT,
304 .num_chipselect = 1,
305};
306
307static struct platform_device cm_x300_spi_gpio = {
308 .name = "spi_gpio",
309 .id = LCD_SPI_BUS_NUM,
310 .dev = {
311 .platform_data = &cm_x300_spi_gpio_pdata,
312 },
313};
314
315static struct tdo24m_platform_data cm_x300_tdo24m_pdata = {
316 .model = TDO35S,
317};
318
319static struct spi_board_info cm_x300_spi_devices[] __initdata = {
320 {
321 .modalias = "tdo24m",
322 .max_speed_hz = 1000000,
323 .bus_num = LCD_SPI_BUS_NUM,
324 .chip_select = 0,
325 .controller_data = (void *) GPIO_LCD_CS,
326 .platform_data = &cm_x300_tdo24m_pdata,
327 },
328};
329
330static void __init cm_x300_init_spi(void)
331{
332 spi_register_board_info(cm_x300_spi_devices,
333 ARRAY_SIZE(cm_x300_spi_devices));
334 platform_device_register(&cm_x300_spi_gpio);
335}
336#else
337static inline void cm_x300_init_spi(void) {}
338#endif
339
Igor Grinberg74e74de2009-10-14 09:20:20 +0200340#if defined(CONFIG_SND_PXA2XX_LIB_AC97)
341static void __init cm_x300_init_ac97(void)
342{
343 pxa_set_ac97_info(NULL);
344}
345#else
346static inline void cm_x300_init_ac97(void) {}
347#endif
348
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100349#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
350static struct mtd_partition cm_x300_nand_partitions[] = {
351 [0] = {
352 .name = "OBM",
353 .offset = 0,
354 .size = SZ_256K,
355 .mask_flags = MTD_WRITEABLE, /* force read-only */
356 },
357 [1] = {
358 .name = "U-Boot",
359 .offset = MTDPART_OFS_APPEND,
360 .size = SZ_256K,
361 .mask_flags = MTD_WRITEABLE, /* force read-only */
362 },
363 [2] = {
364 .name = "Environment",
365 .offset = MTDPART_OFS_APPEND,
366 .size = SZ_256K,
367 },
368 [3] = {
369 .name = "reserved",
370 .offset = MTDPART_OFS_APPEND,
371 .size = SZ_256K + SZ_1M,
372 .mask_flags = MTD_WRITEABLE, /* force read-only */
373 },
374 [4] = {
375 .name = "kernel",
376 .offset = MTDPART_OFS_APPEND,
377 .size = SZ_4M,
378 },
379 [5] = {
380 .name = "fs",
381 .offset = MTDPART_OFS_APPEND,
382 .size = MTDPART_SIZ_FULL,
383 },
384};
385
386static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
387 .enable_arbiter = 1,
Mike Rapoportb3992b62009-06-04 10:44:51 +0300388 .keep_config = 1,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100389 .parts = cm_x300_nand_partitions,
390 .nr_parts = ARRAY_SIZE(cm_x300_nand_partitions),
391};
392
393static void __init cm_x300_init_nand(void)
394{
395 pxa3xx_set_nand_info(&cm_x300_nand_info);
396}
397#else
398static inline void cm_x300_init_nand(void) {}
399#endif
400
401#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200402static struct pxamci_platform_data cm_x300_mci_platform_data = {
403 .detect_delay = 20,
404 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
405 .gpio_card_detect = GPIO82_MMC_IRQ,
406 .gpio_card_ro = GPIO85_MMC_WP,
407 .gpio_power = -1,
408};
409
410/* The second MMC slot of CM-X300 is hardwired to Libertas card and has
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100411 no detection/ro pins */
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200412static int cm_x300_mci2_init(struct device *dev,
413 irq_handler_t cm_x300_detect_int,
414 void *data)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100415{
416 return 0;
417}
418
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200419static void cm_x300_mci2_exit(struct device *dev, void *data)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100420{
421}
422
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100423static struct pxamci_platform_data cm_x300_mci2_platform_data = {
Robert Jarzmik7a648252009-07-06 22:16:42 +0200424 .detect_delay = 20,
425 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200426 .init = cm_x300_mci2_init,
427 .exit = cm_x300_mci2_exit,
428 .gpio_card_detect = -1,
429 .gpio_card_ro = -1,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200430 .gpio_power = -1,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100431};
432
433static void __init cm_x300_init_mmc(void)
434{
435 pxa_set_mci_info(&cm_x300_mci_platform_data);
436 pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
437}
438#else
439static inline void cm_x300_init_mmc(void) {}
440#endif
441
442#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
Igor Grinbergedaa64c2009-10-14 09:20:23 +0200443static int cm_x300_ohci_init(struct device *dev)
444{
445 if (cpu_is_pxa300())
446 UP2OCR = UP2OCR_HXS
447 | UP2OCR_HXOE | UP2OCR_DMPDE | UP2OCR_DPPDE;
448
449 return 0;
450}
451
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100452static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
453 .port_mode = PMM_PERPORT_MODE,
Igor Grinbergedaa64c2009-10-14 09:20:23 +0200454 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW,
455 .init = cm_x300_ohci_init,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100456};
Eric Miao097b5332008-09-27 15:49:57 +0800457
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100458static void __init cm_x300_init_ohci(void)
459{
460 pxa_set_ohci_info(&cm_x300_ohci_platform_data);
461}
462#else
463static inline void cm_x300_init_ohci(void) {}
464#endif
465
466#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
467static struct gpio_led cm_x300_leds[] = {
468 [0] = {
469 .name = "cm-x300:green",
470 .default_trigger = "heartbeat",
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100471 .active_low = 1,
472 },
473};
474
475static struct gpio_led_platform_data cm_x300_gpio_led_pdata = {
476 .num_leds = ARRAY_SIZE(cm_x300_leds),
477 .leds = cm_x300_leds,
478};
479
480static struct platform_device cm_x300_led_device = {
481 .name = "leds-gpio",
482 .id = -1,
483 .dev = {
484 .platform_data = &cm_x300_gpio_led_pdata,
485 },
486};
487
488static void __init cm_x300_init_leds(void)
489{
Igor Grinberg55052ea2009-10-14 09:20:18 +0200490 if (system_rev < 130)
491 cm_x300_leds[0].gpio = 79;
492 else
493 cm_x300_leds[0].gpio = 76;
494
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100495 platform_device_register(&cm_x300_led_device);
496}
497#else
498static inline void cm_x300_init_leds(void) {}
499#endif
500
501#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
502/* PCA9555 */
503static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = {
504 .gpio_base = 128,
505};
506
507static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = {
508 .gpio_base = 144,
509};
510
511static struct i2c_board_info cm_x300_gpio_ext_info[] = {
512 [0] = {
513 I2C_BOARD_INFO("pca9555", 0x24),
514 .platform_data = &cm_x300_gpio_ext_pdata_0,
515 },
516 [1] = {
517 I2C_BOARD_INFO("pca9555", 0x25),
518 .platform_data = &cm_x300_gpio_ext_pdata_1,
519 },
520};
521
522static void __init cm_x300_init_i2c(void)
523{
524 pxa_set_i2c_info(NULL);
525 i2c_register_board_info(0, cm_x300_gpio_ext_info,
526 ARRAY_SIZE(cm_x300_gpio_ext_info));
527}
528#else
529static inline void cm_x300_init_i2c(void) {}
530#endif
531
Mike Rapoport1858ced2009-06-04 10:44:52 +0300532#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
533struct v3020_platform_data cm_x300_v3020_pdata = {
534 .use_gpio = 1,
535 .gpio_cs = GPIO95_RTC_CS,
536 .gpio_wr = GPIO96_RTC_WR,
537 .gpio_rd = GPIO97_RTC_RD,
538 .gpio_io = GPIO98_RTC_IO,
539};
540
541static struct platform_device cm_x300_rtc_device = {
542 .name = "v3020",
543 .id = -1,
544 .dev = {
545 .platform_data = &cm_x300_v3020_pdata,
546 }
547};
548
549static void __init cm_x300_init_rtc(void)
550{
551 platform_device_register(&cm_x300_rtc_device);
552}
553#else
554static inline void cm_x300_init_rtc(void) {}
555#endif
556
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200557/* DA9030 */
558struct da903x_subdev_info cm_x300_da9030_subdevs[] = {
559 {
560 .name = "da903x-backlight",
561 .id = DA9030_ID_WLED,
562 }
563};
564
565static struct da903x_platform_data cm_x300_da9030_info = {
566 .num_subdevs = ARRAY_SIZE(cm_x300_da9030_subdevs),
567 .subdevs = cm_x300_da9030_subdevs,
568};
569
570static struct i2c_board_info cm_x300_pmic_info = {
571 I2C_BOARD_INFO("da9030", 0x49),
572 .irq = IRQ_GPIO(0),
573 .platform_data = &cm_x300_da9030_info,
574};
575
576static struct i2c_pxa_platform_data cm_x300_pwr_i2c_info = {
577 .use_pio = 1,
578};
579
580static void __init cm_x300_init_da9030(void)
581{
582 pxa3xx_set_i2c_power_info(&cm_x300_pwr_i2c_info);
583 i2c_register_board_info(1, &cm_x300_pmic_info, 1);
584}
585
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200586static void __init cm_x300_init_wi2wi(void)
587{
588 int bt_reset, wlan_en;
589 int err;
590
591 if (system_rev < 130) {
592 wlan_en = 77;
593 bt_reset = 78;
594 } else {
595 wlan_en = 71;
596 bt_reset = 70;
597 }
598
599 /* Libertas and CSR reset */
600 err = gpio_request(wlan_en, "wlan en");
601 if (err) {
602 pr_err("CM-X300: failed to request wlan en gpio: %d\n", err);
603 } else {
604 gpio_direction_output(wlan_en, 1);
605 gpio_free(wlan_en);
606 }
607
608 err = gpio_request(bt_reset, "bt reset");
609 if (err) {
610 pr_err("CM-X300: failed to request bt reset gpio: %d\n", err);
611 } else {
612 gpio_direction_output(bt_reset, 1);
613 udelay(10);
614 gpio_set_value(bt_reset, 0);
615 udelay(10);
616 gpio_set_value(bt_reset, 1);
617 gpio_free(bt_reset);
618 }
619}
620
621/* MFP */
Igor Grinberg55052ea2009-10-14 09:20:18 +0200622static void __init cm_x300_init_mfp(void)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100623{
624 /* board-processor specific GPIO initialization */
Igor Grinbergdef82522009-10-14 09:20:22 +0200625 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg));
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100626
Igor Grinberg55052ea2009-10-14 09:20:18 +0200627 if (system_rev < 130)
Igor Grinbergdef82522009-10-14 09:20:22 +0200628 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg));
Igor Grinberg55052ea2009-10-14 09:20:18 +0200629 else
Igor Grinbergdef82522009-10-14 09:20:22 +0200630 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_ge130_mfp_cfg));
631
632 if (cpu_is_pxa310())
633 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x310_mfp_cfg));
Igor Grinberg55052ea2009-10-14 09:20:18 +0200634}
635
636static void __init cm_x300_init(void)
637{
638 cm_x300_init_mfp();
639
Russell Kingcc155c62009-11-09 13:34:08 +0800640 pxa_set_ffuart_info(NULL);
641 pxa_set_btuart_info(NULL);
642 pxa_set_stuart_info(NULL);
643
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200644 cm_x300_init_da9030();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100645 cm_x300_init_dm9000();
646 cm_x300_init_lcd();
647 cm_x300_init_ohci();
648 cm_x300_init_mmc();
649 cm_x300_init_nand();
650 cm_x300_init_leds();
651 cm_x300_init_i2c();
Igor Grinberg83e560e2009-10-14 09:20:19 +0200652 cm_x300_init_spi();
Mike Rapoport1858ced2009-06-04 10:44:52 +0300653 cm_x300_init_rtc();
Igor Grinberg74e74de2009-10-14 09:20:20 +0200654 cm_x300_init_ac97();
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200655 cm_x300_init_wi2wi();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100656}
657
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300658static void __init cm_x300_fixup(struct machine_desc *mdesc, struct tag *tags,
659 char **cmdline, struct meminfo *mi)
660{
661 mi->nr_banks = 2;
662 mi->bank[0].start = 0xa0000000;
663 mi->bank[0].node = 0;
664 mi->bank[0].size = (64*1024*1024);
665 mi->bank[1].start = 0xc0000000;
666 mi->bank[1].node = 0;
667 mi->bank[1].size = (64*1024*1024);
668}
669
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100670MACHINE_START(CM_X300, "CM-X300 module")
671 .phys_io = 0x40000000,
672 .boot_params = 0xa0000100,
673 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
674 .map_io = pxa_map_io,
675 .init_irq = pxa3xx_init_irq,
676 .timer = &pxa_timer,
677 .init_machine = cm_x300_init,
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300678 .fixup = cm_x300_fixup,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100679MACHINE_END