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