[ARM] pxa/cm-x300.c: add battery charger support
[pandora-kernel.git] / arch / arm / mach-pxa / cm-x300.c
1 /*
2  * linux/arch/arm/mach-pxa/cm-x300.c
3  *
4  * Support for the CompuLab CM-X300 modules
5  *
6  * Copyright (C) 2008,2009 CompuLab Ltd.
7  *
8  * Mike Rapoport <mike@compulab.co.il>
9  * Igor Grinberg <grinberg@compulab.co.il>
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>
20 #include <linux/delay.h>
21 #include <linux/platform_device.h>
22
23 #include <linux/gpio.h>
24 #include <linux/dm9000.h>
25 #include <linux/leds.h>
26 #include <linux/rtc-v3020.h>
27 #include <linux/pwm_backlight.h>
28
29 #include <linux/i2c.h>
30 #include <linux/i2c/pca953x.h>
31
32 #include <linux/mfd/da903x.h>
33 #include <linux/power_supply.h>
34 #include <linux/apm-emulation.h>
35
36 #include <linux/spi/spi.h>
37 #include <linux/spi/spi_gpio.h>
38 #include <linux/spi/tdo24m.h>
39
40 #include <asm/mach-types.h>
41 #include <asm/mach/arch.h>
42 #include <asm/setup.h>
43
44 #include <mach/pxa300.h>
45 #include <mach/pxa27x-udc.h>
46 #include <mach/pxafb.h>
47 #include <mach/mmc.h>
48 #include <mach/ohci.h>
49 #include <plat/i2c.h>
50 #include <plat/pxa3xx_nand.h>
51 #include <mach/audio.h>
52
53 #include <asm/mach/map.h>
54
55 #include "generic.h"
56 #include "devices.h"
57
58 #define CM_X300_ETH_PHYS        0x08000010
59
60 #define GPIO82_MMC_IRQ          (82)
61 #define GPIO85_MMC_WP           (85)
62
63 #define CM_X300_MMC_IRQ         IRQ_GPIO(GPIO82_MMC_IRQ)
64
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
70 static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
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 */
154         GPIO82_GPIO | MFP_PULL_HIGH,    /* MMC CD */
155         GPIO85_GPIO,                    /* MMC WP */
156         GPIO99_GPIO,                    /* Ethernet IRQ */
157
158         /* RTC GPIOs */
159         GPIO95_GPIO,                    /* RTC CS */
160         GPIO96_GPIO,                    /* RTC WR */
161         GPIO97_GPIO,                    /* RTC RD */
162         GPIO98_GPIO,                    /* RTC IO */
163
164         /* Standard I2C */
165         GPIO21_I2C_SCL,
166         GPIO22_I2C_SDA,
167
168         /* PWM Backlight */
169         GPIO19_PWM2_OUT,
170 };
171
172 static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = {
173         /* GPIOs */
174         GPIO79_GPIO,                    /* LED */
175         GPIO77_GPIO,                    /* WiFi reset */
176         GPIO78_GPIO,                    /* BT reset */
177 };
178
179 static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = {
180         /* GPIOs */
181         GPIO76_GPIO,                    /* LED */
182         GPIO71_GPIO,                    /* WiFi reset */
183         GPIO70_GPIO,                    /* BT reset */
184 };
185
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
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 = {
233         .flags          = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
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
255 /* LCD */
256 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
257 static struct pxafb_mode_info cm_x300_lcd_modes[] = {
258         [0] = {
259                 .pixclock       = 38250,
260                 .bpp            = 16,
261                 .xres           = 480,
262                 .yres           = 640,
263                 .hsync_len      = 8,
264                 .vsync_len      = 2,
265                 .left_margin    = 8,
266                 .upper_margin   = 2,
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,
288         .num_modes              = ARRAY_SIZE(cm_x300_lcd_modes),
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
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
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
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
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,
420         .keep_config    = 1,
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)
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
443    no detection/ro pins */
444 static int cm_x300_mci2_init(struct device *dev,
445                              irq_handler_t cm_x300_detect_int,
446         void *data)
447 {
448         return 0;
449 }
450
451 static void cm_x300_mci2_exit(struct device *dev, void *data)
452 {
453 }
454
455 static struct pxamci_platform_data cm_x300_mci2_platform_data = {
456         .detect_delay           = 20,
457         .ocr_mask               = MMC_VDD_32_33|MMC_VDD_33_34,
458         .init                   = cm_x300_mci2_init,
459         .exit                   = cm_x300_mci2_exit,
460         .gpio_card_detect       = -1,
461         .gpio_card_ro           = -1,
462         .gpio_power             = -1,
463 };
464
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)
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
484 static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
485         .port_mode      = PMM_PERPORT_MODE,
486         .flags          = ENABLE_PORT_ALL | POWER_CONTROL_LOW,
487         .init           = cm_x300_ohci_init,
488 };
489
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",
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 {
522         if (system_rev < 130)
523                 cm_x300_leds[0].gpio = 79;
524         else
525                 cm_x300_leds[0].gpio = 76;
526
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
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
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
637 /* DA9030 */
638 struct da903x_subdev_info cm_x300_da9030_subdevs[] = {
639         {
640                 .name = "da903x-backlight",
641                 .id = DA9030_ID_WLED,
642         },
643         {
644                 .name = "da903x-battery",
645                 .id = DA9030_ID_BAT,
646                 .platform_data = &cm_x300_battery_info,
647         },
648 };
649
650 static struct da903x_platform_data cm_x300_da9030_info = {
651         .num_subdevs = ARRAY_SIZE(cm_x300_da9030_subdevs),
652         .subdevs = cm_x300_da9030_subdevs,
653 };
654
655 static struct i2c_board_info cm_x300_pmic_info = {
656         I2C_BOARD_INFO("da9030", 0x49),
657         .irq = IRQ_GPIO(0),
658         .platform_data = &cm_x300_da9030_info,
659 };
660
661 static struct i2c_pxa_platform_data cm_x300_pwr_i2c_info = {
662         .use_pio = 1,
663 };
664
665 static void __init cm_x300_init_da9030(void)
666 {
667         pxa3xx_set_i2c_power_info(&cm_x300_pwr_i2c_info);
668         i2c_register_board_info(1, &cm_x300_pmic_info, 1);
669 }
670
671 static void __init cm_x300_init_wi2wi(void)
672 {
673         int bt_reset, wlan_en;
674         int err;
675
676         if (system_rev < 130) {
677                 wlan_en = 77;
678                 bt_reset = 78;
679         } else {
680                 wlan_en = 71;
681                 bt_reset = 70;
682         }
683
684         /* Libertas and CSR reset */
685         err = gpio_request(wlan_en, "wlan en");
686         if (err) {
687                 pr_err("CM-X300: failed to request wlan en gpio: %d\n", err);
688         } else {
689                 gpio_direction_output(wlan_en, 1);
690                 gpio_free(wlan_en);
691         }
692
693         err = gpio_request(bt_reset, "bt reset");
694         if (err) {
695                 pr_err("CM-X300: failed to request bt reset gpio: %d\n", err);
696         } else {
697                 gpio_direction_output(bt_reset, 1);
698                 udelay(10);
699                 gpio_set_value(bt_reset, 0);
700                 udelay(10);
701                 gpio_set_value(bt_reset, 1);
702                 gpio_free(bt_reset);
703         }
704 }
705
706 /* MFP */
707 static void __init cm_x300_init_mfp(void)
708 {
709         /* board-processor specific GPIO initialization */
710         pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg));
711
712         if (system_rev < 130)
713                 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg));
714         else
715                 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_ge130_mfp_cfg));
716
717         if (cpu_is_pxa310())
718                 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x310_mfp_cfg));
719 }
720
721 static void __init cm_x300_init(void)
722 {
723         cm_x300_init_mfp();
724
725         pxa_set_ffuart_info(NULL);
726         pxa_set_btuart_info(NULL);
727         pxa_set_stuart_info(NULL);
728
729         cm_x300_init_da9030();
730         cm_x300_init_dm9000();
731         cm_x300_init_lcd();
732         cm_x300_init_ohci();
733         cm_x300_init_mmc();
734         cm_x300_init_nand();
735         cm_x300_init_leds();
736         cm_x300_init_i2c();
737         cm_x300_init_spi();
738         cm_x300_init_rtc();
739         cm_x300_init_ac97();
740         cm_x300_init_wi2wi();
741         cm_x300_init_bl();
742 }
743
744 static void __init cm_x300_fixup(struct machine_desc *mdesc, struct tag *tags,
745                                  char **cmdline, struct meminfo *mi)
746 {
747         mi->nr_banks = 2;
748         mi->bank[0].start = 0xa0000000;
749         mi->bank[0].node = 0;
750         mi->bank[0].size = (64*1024*1024);
751         mi->bank[1].start = 0xc0000000;
752         mi->bank[1].node = 0;
753         mi->bank[1].size = (64*1024*1024);
754 }
755
756 MACHINE_START(CM_X300, "CM-X300 module")
757         .phys_io        = 0x40000000,
758         .boot_params    = 0xa0000100,
759         .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
760         .map_io         = pxa_map_io,
761         .init_irq       = pxa3xx_init_irq,
762         .timer          = &pxa_timer,
763         .init_machine   = cm_x300_init,
764         .fixup          = cm_x300_fixup,
765 MACHINE_END