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