blob: 6fba9a08f53e430c1d66ba094c849fce8a920702 [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 *
Igor Grinberg14fd9e02009-10-14 09:20:25 +02006 * Copyright (C) 2008,2009 CompuLab Ltd.
Mike Rapoportcf75d8d2008-08-26 14:03:44 +01007 *
8 * Mike Rapoport <mike@compulab.co.il>
Igor Grinberg14fd9e02009-10-14 09:20:25 +02009 * Igor Grinberg <grinberg@compulab.co.il>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010010 *
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>
Igor Grinbergb3d01da2009-10-14 09:20:21 +020020#include <linux/delay.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010021#include <linux/platform_device.h>
22
23#include <linux/gpio.h>
24#include <linux/dm9000.h>
25#include <linux/leds.h>
Mike Rapoport1858ced2009-06-04 10:44:52 +030026#include <linux/rtc-v3020.h>
Igor Grinbergdb205462009-11-10 14:18:41 +020027#include <linux/pwm_backlight.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010028
29#include <linux/i2c.h>
30#include <linux/i2c/pca953x.h>
31
Igor Grinberg9c017ca2009-10-14 09:20:24 +020032#include <linux/mfd/da903x.h>
Igor Grinberg03ba7e02010-03-09 11:43:48 +020033#include <linux/power_supply.h>
34#include <linux/apm-emulation.h>
Igor Grinberg9c017ca2009-10-14 09:20:24 +020035
Igor Grinberg83e560e2009-10-14 09:20:19 +020036#include <linux/spi/spi.h>
37#include <linux/spi/spi_gpio.h>
38#include <linux/spi/tdo24m.h>
39
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010040#include <asm/mach-types.h>
41#include <asm/mach/arch.h>
Mike Rapoportb5a5c472009-06-04 10:44:54 +030042#include <asm/setup.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010043
Eric Miao51c62982009-01-02 23:17:22 +080044#include <mach/pxa300.h>
Igor Grinbergedaa64c2009-10-14 09:20:23 +020045#include <mach/pxa27x-udc.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010046#include <mach/pxafb.h>
47#include <mach/mmc.h>
48#include <mach/ohci.h>
Eric Miaof0a83702009-04-13 15:03:11 +080049#include <plat/i2c.h>
Haojian Zhuang82b95ec2009-09-10 13:55:23 +080050#include <plat/pxa3xx_nand.h>
Igor Grinberg74e74de2009-10-14 09:20:20 +020051#include <mach/audio.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010052
53#include <asm/mach/map.h>
54
55#include "generic.h"
Igor Grinbergdb205462009-11-10 14:18:41 +020056#include "devices.h"
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010057
58#define CM_X300_ETH_PHYS 0x08000010
59
Mike Rapoport0bff2fc2009-10-15 10:11:09 +020060#define GPIO82_MMC_IRQ (82)
61#define GPIO85_MMC_WP (85)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010062
Mike Rapoport0bff2fc2009-10-15 10:11:09 +020063#define CM_X300_MMC_IRQ IRQ_GPIO(GPIO82_MMC_IRQ)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010064
Mike Rapoport1858ced2009-06-04 10:44:52 +030065#define GPIO95_RTC_CS (95)
66#define GPIO96_RTC_WR (96)
67#define GPIO97_RTC_RD (97)
68#define GPIO98_RTC_IO (98)
69
Igor Grinbergdef82522009-10-14 09:20:22 +020070static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010071 /* 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 */
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100154 GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */
155 GPIO85_GPIO, /* MMC WP */
156 GPIO99_GPIO, /* Ethernet IRQ */
Eric Miao6f584cf2008-11-28 16:00:24 +0800157
Mike Rapoport1858ced2009-06-04 10:44:52 +0300158 /* RTC GPIOs */
159 GPIO95_GPIO, /* RTC CS */
160 GPIO96_GPIO, /* RTC WR */
161 GPIO97_GPIO, /* RTC RD */
162 GPIO98_GPIO, /* RTC IO */
163
Eric Miao6f584cf2008-11-28 16:00:24 +0800164 /* Standard I2C */
165 GPIO21_I2C_SCL,
166 GPIO22_I2C_SDA,
Igor Grinbergdb205462009-11-10 14:18:41 +0200167
168 /* PWM Backlight */
169 GPIO19_PWM2_OUT,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100170};
171
Igor Grinbergdef82522009-10-14 09:20:22 +0200172static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = {
Igor Grinberg55052ea2009-10-14 09:20:18 +0200173 /* GPIOs */
174 GPIO79_GPIO, /* LED */
175 GPIO77_GPIO, /* WiFi reset */
176 GPIO78_GPIO, /* BT reset */
177};
178
Igor Grinbergdef82522009-10-14 09:20:22 +0200179static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = {
Igor Grinberg55052ea2009-10-14 09:20:18 +0200180 /* GPIOs */
181 GPIO76_GPIO, /* LED */
182 GPIO71_GPIO, /* WiFi reset */
183 GPIO70_GPIO, /* BT reset */
184};
185
Igor Grinbergdef82522009-10-14 09:20:22 +0200186static 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
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100213#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
214static 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
232static struct dm9000_plat_data cm_x300_dm9000_platdata = {
Mike Rapoportbff22c92009-02-23 18:01:12 +0200233 .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100234};
235
236static 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
247static void __init cm_x300_init_dm9000(void)
248{
249 platform_device_register(&dm9000_device);
250}
251#else
252static inline void cm_x300_init_dm9000(void) {}
253#endif
254
Igor Grinberg83e560e2009-10-14 09:20:19 +0200255/* LCD */
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100256#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
257static struct pxafb_mode_info cm_x300_lcd_modes[] = {
258 [0] = {
Igor Grinberg83e560e2009-10-14 09:20:19 +0200259 .pixclock = 38250,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100260 .bpp = 16,
261 .xres = 480,
262 .yres = 640,
263 .hsync_len = 8,
264 .vsync_len = 2,
265 .left_margin = 8,
Igor Grinberg83e560e2009-10-14 09:20:19 +0200266 .upper_margin = 2,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100267 .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
286static struct pxafb_mach_info cm_x300_lcd = {
287 .modes = cm_x300_lcd_modes,
Igor Grinberg83e560e2009-10-14 09:20:19 +0200288 .num_modes = ARRAY_SIZE(cm_x300_lcd_modes),
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100289 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
290};
291
292static void __init cm_x300_init_lcd(void)
293{
294 set_pxa_fb_info(&cm_x300_lcd);
295}
296#else
297static inline void cm_x300_init_lcd(void) {}
298#endif
299
Igor Grinbergdb205462009-11-10 14:18:41 +0200300#if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
301static 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
308static 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
316static void cm_x300_init_bl(void)
317{
318 platform_device_register(&cm_x300_backlight_device);
319}
320#else
321static inline void cm_x300_init_bl(void) {}
322#endif
323
Igor Grinberg83e560e2009-10-14 09:20:19 +0200324#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
332static 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
339static 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
347static struct tdo24m_platform_data cm_x300_tdo24m_pdata = {
348 .model = TDO35S,
349};
350
351static 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
362static 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
369static inline void cm_x300_init_spi(void) {}
370#endif
371
Igor Grinberg74e74de2009-10-14 09:20:20 +0200372#if defined(CONFIG_SND_PXA2XX_LIB_AC97)
373static void __init cm_x300_init_ac97(void)
374{
375 pxa_set_ac97_info(NULL);
376}
377#else
378static inline void cm_x300_init_ac97(void) {}
379#endif
380
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100381#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
382static 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
418static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
419 .enable_arbiter = 1,
Mike Rapoportb3992b62009-06-04 10:44:51 +0300420 .keep_config = 1,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100421 .parts = cm_x300_nand_partitions,
422 .nr_parts = ARRAY_SIZE(cm_x300_nand_partitions),
423};
424
425static void __init cm_x300_init_nand(void)
426{
427 pxa3xx_set_nand_info(&cm_x300_nand_info);
428}
429#else
430static inline void cm_x300_init_nand(void) {}
431#endif
432
433#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200434static 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
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100443 no detection/ro pins */
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200444static int cm_x300_mci2_init(struct device *dev,
445 irq_handler_t cm_x300_detect_int,
446 void *data)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100447{
448 return 0;
449}
450
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200451static void cm_x300_mci2_exit(struct device *dev, void *data)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100452{
453}
454
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100455static struct pxamci_platform_data cm_x300_mci2_platform_data = {
Robert Jarzmik7a648252009-07-06 22:16:42 +0200456 .detect_delay = 20,
457 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200458 .init = cm_x300_mci2_init,
459 .exit = cm_x300_mci2_exit,
460 .gpio_card_detect = -1,
461 .gpio_card_ro = -1,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200462 .gpio_power = -1,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100463};
464
465static 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
471static inline void cm_x300_init_mmc(void) {}
472#endif
473
474#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
Igor Grinbergedaa64c2009-10-14 09:20:23 +0200475static 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
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100484static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
485 .port_mode = PMM_PERPORT_MODE,
Igor Grinbergedaa64c2009-10-14 09:20:23 +0200486 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW,
487 .init = cm_x300_ohci_init,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100488};
Eric Miao097b5332008-09-27 15:49:57 +0800489
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100490static void __init cm_x300_init_ohci(void)
491{
492 pxa_set_ohci_info(&cm_x300_ohci_platform_data);
493}
494#else
495static inline void cm_x300_init_ohci(void) {}
496#endif
497
498#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
499static struct gpio_led cm_x300_leds[] = {
500 [0] = {
501 .name = "cm-x300:green",
502 .default_trigger = "heartbeat",
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100503 .active_low = 1,
504 },
505};
506
507static 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
512static 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
520static void __init cm_x300_init_leds(void)
521{
Igor Grinberg55052ea2009-10-14 09:20:18 +0200522 if (system_rev < 130)
523 cm_x300_leds[0].gpio = 79;
524 else
525 cm_x300_leds[0].gpio = 76;
526
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100527 platform_device_register(&cm_x300_led_device);
528}
529#else
530static inline void cm_x300_init_leds(void) {}
531#endif
532
533#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
534/* PCA9555 */
535static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = {
536 .gpio_base = 128,
537};
538
539static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = {
540 .gpio_base = 144,
541};
542
543static 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
554static 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
561static inline void cm_x300_init_i2c(void) {}
562#endif
563
Mike Rapoport1858ced2009-06-04 10:44:52 +0300564#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
565struct 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
573static 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
581static void __init cm_x300_init_rtc(void)
582{
583 platform_device_register(&cm_x300_rtc_device);
584}
585#else
586static inline void cm_x300_init_rtc(void) {}
587#endif
588
Igor Grinberg03ba7e02010-03-09 11:43:48 +0200589/* Battery */
590struct 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
598static void cm_x300_battery_low(void)
599{
600#if defined(CONFIG_APM_EMULATION)
601 apm_queue_event(APM_LOW_BATTERY);
602#endif
603}
604
605static void cm_x300_battery_critical(void)
606{
607#if defined(CONFIG_APM_EMULATION)
608 apm_queue_event(APM_CRITICAL_SUSPEND);
609#endif
610}
611
612struct 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
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200637/* DA9030 */
638struct da903x_subdev_info cm_x300_da9030_subdevs[] = {
639 {
Igor Grinberg03ba7e02010-03-09 11:43:48 +0200640 .name = "da903x-battery",
641 .id = DA9030_ID_BAT,
642 .platform_data = &cm_x300_battery_info,
643 },
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200644};
645
646static 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
651static struct i2c_board_info cm_x300_pmic_info = {
652 I2C_BOARD_INFO("da9030", 0x49),
Igor Grinberge4e30972010-03-09 11:43:50 +0200653 .irq = IRQ_WAKEUP0,
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200654 .platform_data = &cm_x300_da9030_info,
655};
656
657static struct i2c_pxa_platform_data cm_x300_pwr_i2c_info = {
658 .use_pio = 1,
659};
660
661static 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
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200667static 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 */
Igor Grinberg55052ea2009-10-14 09:20:18 +0200703static void __init cm_x300_init_mfp(void)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100704{
705 /* board-processor specific GPIO initialization */
Igor Grinbergdef82522009-10-14 09:20:22 +0200706 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg));
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100707
Igor Grinberg55052ea2009-10-14 09:20:18 +0200708 if (system_rev < 130)
Igor Grinbergdef82522009-10-14 09:20:22 +0200709 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg));
Igor Grinberg55052ea2009-10-14 09:20:18 +0200710 else
Igor Grinbergdef82522009-10-14 09:20:22 +0200711 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));
Igor Grinberg55052ea2009-10-14 09:20:18 +0200715}
716
717static void __init cm_x300_init(void)
718{
719 cm_x300_init_mfp();
720
Russell Kingcc155c62009-11-09 13:34:08 +0800721 pxa_set_ffuart_info(NULL);
722 pxa_set_btuart_info(NULL);
723 pxa_set_stuart_info(NULL);
724
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200725 cm_x300_init_da9030();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100726 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();
Igor Grinberg83e560e2009-10-14 09:20:19 +0200733 cm_x300_init_spi();
Mike Rapoport1858ced2009-06-04 10:44:52 +0300734 cm_x300_init_rtc();
Igor Grinberg74e74de2009-10-14 09:20:20 +0200735 cm_x300_init_ac97();
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200736 cm_x300_init_wi2wi();
Igor Grinbergdb205462009-11-10 14:18:41 +0200737 cm_x300_init_bl();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100738}
739
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300740static 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
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100752MACHINE_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,
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300760 .fixup = cm_x300_fixup,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100761MACHINE_END