blob: b2248e76ec8b713b9bf1f8a01ca84aca2e845d9c [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>
Igor Grinberg1b43d8e2010-07-27 15:07:00 +030022#include <linux/clk.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010023
24#include <linux/gpio.h>
25#include <linux/dm9000.h>
26#include <linux/leds.h>
Mike Rapoport1858ced2009-06-04 10:44:52 +030027#include <linux/rtc-v3020.h>
Igor Grinbergdb205462009-11-10 14:18:41 +020028#include <linux/pwm_backlight.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010029
30#include <linux/i2c.h>
31#include <linux/i2c/pca953x.h>
Sebastian Andrzej Siewiorb4593962011-02-23 12:38:16 +010032#include <linux/i2c/pxa-i2c.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010033
Igor Grinberg9c017ca2009-10-14 09:20:24 +020034#include <linux/mfd/da903x.h>
Igor Grinbergd176d642010-03-09 11:43:51 +020035#include <linux/regulator/machine.h>
Igor Grinberg03ba7e02010-03-09 11:43:48 +020036#include <linux/power_supply.h>
37#include <linux/apm-emulation.h>
Igor Grinberg9c017ca2009-10-14 09:20:24 +020038
Igor Grinberg83e560e2009-10-14 09:20:19 +020039#include <linux/spi/spi.h>
40#include <linux/spi/spi_gpio.h>
41#include <linux/spi/tdo24m.h>
42
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010043#include <asm/mach-types.h>
44#include <asm/mach/arch.h>
Mike Rapoportb5a5c472009-06-04 10:44:54 +030045#include <asm/setup.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010046
Eric Miao51c62982009-01-02 23:17:22 +080047#include <mach/pxa300.h>
Igor Grinbergedaa64c2009-10-14 09:20:23 +020048#include <mach/pxa27x-udc.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010049#include <mach/pxafb.h>
50#include <mach/mmc.h>
51#include <mach/ohci.h>
Haojian Zhuang82b95ec2009-09-10 13:55:23 +080052#include <plat/pxa3xx_nand.h>
Igor Grinberg74e74de2009-10-14 09:20:20 +020053#include <mach/audio.h>
Igor Grinberg1b43d8e2010-07-27 15:07:00 +030054#include <mach/pxa3xx-u2d.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010055
56#include <asm/mach/map.h>
57
58#include "generic.h"
Igor Grinbergdb205462009-11-10 14:18:41 +020059#include "devices.h"
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010060
61#define CM_X300_ETH_PHYS 0x08000010
62
Mike Rapoport0bff2fc2009-10-15 10:11:09 +020063#define GPIO82_MMC_IRQ (82)
64#define GPIO85_MMC_WP (85)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010065
Mike Rapoport0bff2fc2009-10-15 10:11:09 +020066#define CM_X300_MMC_IRQ IRQ_GPIO(GPIO82_MMC_IRQ)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010067
Mike Rapoport1858ced2009-06-04 10:44:52 +030068#define GPIO95_RTC_CS (95)
69#define GPIO96_RTC_WR (96)
70#define GPIO97_RTC_RD (97)
71#define GPIO98_RTC_IO (98)
72
Igor Grinberg1b43d8e2010-07-27 15:07:00 +030073#define GPIO_ULPI_PHY_RST (127)
74
Igor Grinbergdef82522009-10-14 09:20:22 +020075static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010076 /* LCD */
77 GPIO54_LCD_LDD_0,
78 GPIO55_LCD_LDD_1,
79 GPIO56_LCD_LDD_2,
80 GPIO57_LCD_LDD_3,
81 GPIO58_LCD_LDD_4,
82 GPIO59_LCD_LDD_5,
83 GPIO60_LCD_LDD_6,
84 GPIO61_LCD_LDD_7,
85 GPIO62_LCD_LDD_8,
86 GPIO63_LCD_LDD_9,
87 GPIO64_LCD_LDD_10,
88 GPIO65_LCD_LDD_11,
89 GPIO66_LCD_LDD_12,
90 GPIO67_LCD_LDD_13,
91 GPIO68_LCD_LDD_14,
92 GPIO69_LCD_LDD_15,
93 GPIO72_LCD_FCLK,
94 GPIO73_LCD_LCLK,
95 GPIO74_LCD_PCLK,
96 GPIO75_LCD_BIAS,
97
98 /* BTUART */
99 GPIO111_UART2_RTS,
100 GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
101 GPIO113_UART2_TXD,
102 GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
103
104 /* STUART */
105 GPIO109_UART3_TXD,
106 GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
107
108 /* AC97 */
109 GPIO23_AC97_nACRESET,
110 GPIO24_AC97_SYSCLK,
111 GPIO29_AC97_BITCLK,
112 GPIO25_AC97_SDATA_IN_0,
113 GPIO27_AC97_SDATA_OUT,
114 GPIO28_AC97_SYNC,
115
116 /* Keypad */
117 GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
118 GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
119 GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
120 GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
121 GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
122 GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
123 GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
124 GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
125 GPIO121_KP_MKOUT_0,
126 GPIO122_KP_MKOUT_1,
127 GPIO123_KP_MKOUT_2,
128 GPIO124_KP_MKOUT_3,
129 GPIO125_KP_MKOUT_4,
130 GPIO4_2_KP_MKOUT_5,
131
132 /* MMC1 */
133 GPIO3_MMC1_DAT0,
134 GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
135 GPIO5_MMC1_DAT2,
136 GPIO6_MMC1_DAT3,
137 GPIO7_MMC1_CLK,
138 GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
139
140 /* MMC2 */
141 GPIO9_MMC2_DAT0,
142 GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
143 GPIO11_MMC2_DAT2,
144 GPIO12_MMC2_DAT3,
145 GPIO13_MMC2_CLK,
146 GPIO14_MMC2_CMD,
147
148 /* FFUART */
149 GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
150 GPIO31_UART1_TXD,
151 GPIO32_UART1_CTS,
152 GPIO37_UART1_RTS,
153 GPIO33_UART1_DCD,
154 GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
155 GPIO35_UART1_RI,
156 GPIO36_UART1_DTR,
157
158 /* GPIOs */
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100159 GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */
160 GPIO85_GPIO, /* MMC WP */
161 GPIO99_GPIO, /* Ethernet IRQ */
Eric Miao6f584cf2008-11-28 16:00:24 +0800162
Mike Rapoport1858ced2009-06-04 10:44:52 +0300163 /* RTC GPIOs */
164 GPIO95_GPIO, /* RTC CS */
165 GPIO96_GPIO, /* RTC WR */
166 GPIO97_GPIO, /* RTC RD */
167 GPIO98_GPIO, /* RTC IO */
168
Eric Miao6f584cf2008-11-28 16:00:24 +0800169 /* Standard I2C */
170 GPIO21_I2C_SCL,
171 GPIO22_I2C_SDA,
Igor Grinbergdb205462009-11-10 14:18:41 +0200172
173 /* PWM Backlight */
174 GPIO19_PWM2_OUT,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100175};
176
Igor Grinbergdef82522009-10-14 09:20:22 +0200177static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = {
Igor Grinberg55052ea2009-10-14 09:20:18 +0200178 /* GPIOs */
179 GPIO79_GPIO, /* LED */
180 GPIO77_GPIO, /* WiFi reset */
181 GPIO78_GPIO, /* BT reset */
182};
183
Igor Grinbergdef82522009-10-14 09:20:22 +0200184static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = {
Igor Grinberg55052ea2009-10-14 09:20:18 +0200185 /* GPIOs */
186 GPIO76_GPIO, /* LED */
187 GPIO71_GPIO, /* WiFi reset */
188 GPIO70_GPIO, /* BT reset */
189};
190
Igor Grinbergdef82522009-10-14 09:20:22 +0200191static mfp_cfg_t cm_x310_mfp_cfg[] __initdata = {
192 /* USB PORT 2 */
193 ULPI_STP,
194 ULPI_NXT,
195 ULPI_DIR,
196 GPIO30_ULPI_DATA_OUT_0,
197 GPIO31_ULPI_DATA_OUT_1,
198 GPIO32_ULPI_DATA_OUT_2,
199 GPIO33_ULPI_DATA_OUT_3,
200 GPIO34_ULPI_DATA_OUT_4,
201 GPIO35_ULPI_DATA_OUT_5,
202 GPIO36_ULPI_DATA_OUT_6,
203 GPIO37_ULPI_DATA_OUT_7,
204 GPIO38_ULPI_CLK,
205 /* external PHY reset pin */
206 GPIO127_GPIO,
207
208 /* USB PORT 3 */
209 GPIO77_USB_P3_1,
210 GPIO78_USB_P3_2,
211 GPIO79_USB_P3_3,
212 GPIO80_USB_P3_4,
213 GPIO81_USB_P3_5,
214 GPIO82_USB_P3_6,
215 GPIO0_2_USBH_PEN,
216};
217
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100218#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
219static struct resource dm9000_resources[] = {
220 [0] = {
221 .start = CM_X300_ETH_PHYS,
222 .end = CM_X300_ETH_PHYS + 0x3,
223 .flags = IORESOURCE_MEM,
224 },
225 [1] = {
226 .start = CM_X300_ETH_PHYS + 0x4,
227 .end = CM_X300_ETH_PHYS + 0x4 + 500,
228 .flags = IORESOURCE_MEM,
229 },
230 [2] = {
231 .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
232 .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO99)),
233 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
234 }
235};
236
237static struct dm9000_plat_data cm_x300_dm9000_platdata = {
Mike Rapoportbff22c92009-02-23 18:01:12 +0200238 .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100239};
240
241static struct platform_device dm9000_device = {
242 .name = "dm9000",
243 .id = 0,
244 .num_resources = ARRAY_SIZE(dm9000_resources),
245 .resource = dm9000_resources,
246 .dev = {
247 .platform_data = &cm_x300_dm9000_platdata,
248 }
249
250};
251
252static void __init cm_x300_init_dm9000(void)
253{
254 platform_device_register(&dm9000_device);
255}
256#else
257static inline void cm_x300_init_dm9000(void) {}
258#endif
259
Igor Grinberg83e560e2009-10-14 09:20:19 +0200260/* LCD */
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100261#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
262static struct pxafb_mode_info cm_x300_lcd_modes[] = {
263 [0] = {
Igor Grinberg83e560e2009-10-14 09:20:19 +0200264 .pixclock = 38250,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100265 .bpp = 16,
266 .xres = 480,
267 .yres = 640,
268 .hsync_len = 8,
269 .vsync_len = 2,
270 .left_margin = 8,
Igor Grinberg83e560e2009-10-14 09:20:19 +0200271 .upper_margin = 2,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100272 .right_margin = 24,
273 .lower_margin = 4,
274 .cmap_greyscale = 0,
275 },
276 [1] = {
277 .pixclock = 153800,
278 .bpp = 16,
279 .xres = 240,
280 .yres = 320,
281 .hsync_len = 8,
282 .vsync_len = 2,
283 .left_margin = 8,
284 .upper_margin = 2,
285 .right_margin = 88,
286 .lower_margin = 2,
287 .cmap_greyscale = 0,
288 },
289};
290
291static struct pxafb_mach_info cm_x300_lcd = {
292 .modes = cm_x300_lcd_modes,
Igor Grinberg83e560e2009-10-14 09:20:19 +0200293 .num_modes = ARRAY_SIZE(cm_x300_lcd_modes),
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100294 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
295};
296
297static void __init cm_x300_init_lcd(void)
298{
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800299 pxa_set_fb_info(NULL, &cm_x300_lcd);
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100300}
301#else
302static inline void cm_x300_init_lcd(void) {}
303#endif
304
Igor Grinbergdb205462009-11-10 14:18:41 +0200305#if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
306static struct platform_pwm_backlight_data cm_x300_backlight_data = {
307 .pwm_id = 2,
308 .max_brightness = 100,
309 .dft_brightness = 100,
310 .pwm_period_ns = 10000,
311};
312
313static struct platform_device cm_x300_backlight_device = {
314 .name = "pwm-backlight",
315 .dev = {
316 .parent = &pxa27x_device_pwm0.dev,
317 .platform_data = &cm_x300_backlight_data,
318 },
319};
320
321static void cm_x300_init_bl(void)
322{
323 platform_device_register(&cm_x300_backlight_device);
324}
325#else
326static inline void cm_x300_init_bl(void) {}
327#endif
328
Igor Grinberg83e560e2009-10-14 09:20:19 +0200329#if defined(CONFIG_SPI_GPIO) || defined(CONFIG_SPI_GPIO_MODULE)
330#define GPIO_LCD_BASE (144)
331#define GPIO_LCD_DIN (GPIO_LCD_BASE + 8) /* aux_gpio3_0 */
332#define GPIO_LCD_DOUT (GPIO_LCD_BASE + 9) /* aux_gpio3_1 */
333#define GPIO_LCD_SCL (GPIO_LCD_BASE + 10) /* aux_gpio3_2 */
334#define GPIO_LCD_CS (GPIO_LCD_BASE + 11) /* aux_gpio3_3 */
335#define LCD_SPI_BUS_NUM (1)
336
337static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata = {
338 .sck = GPIO_LCD_SCL,
339 .mosi = GPIO_LCD_DIN,
340 .miso = GPIO_LCD_DOUT,
341 .num_chipselect = 1,
342};
343
344static struct platform_device cm_x300_spi_gpio = {
345 .name = "spi_gpio",
346 .id = LCD_SPI_BUS_NUM,
347 .dev = {
348 .platform_data = &cm_x300_spi_gpio_pdata,
349 },
350};
351
352static struct tdo24m_platform_data cm_x300_tdo24m_pdata = {
353 .model = TDO35S,
354};
355
356static struct spi_board_info cm_x300_spi_devices[] __initdata = {
357 {
358 .modalias = "tdo24m",
359 .max_speed_hz = 1000000,
360 .bus_num = LCD_SPI_BUS_NUM,
361 .chip_select = 0,
362 .controller_data = (void *) GPIO_LCD_CS,
363 .platform_data = &cm_x300_tdo24m_pdata,
364 },
365};
366
367static void __init cm_x300_init_spi(void)
368{
369 spi_register_board_info(cm_x300_spi_devices,
370 ARRAY_SIZE(cm_x300_spi_devices));
371 platform_device_register(&cm_x300_spi_gpio);
372}
373#else
374static inline void cm_x300_init_spi(void) {}
375#endif
376
Igor Grinberg74e74de2009-10-14 09:20:20 +0200377#if defined(CONFIG_SND_PXA2XX_LIB_AC97)
378static void __init cm_x300_init_ac97(void)
379{
380 pxa_set_ac97_info(NULL);
381}
382#else
383static inline void cm_x300_init_ac97(void) {}
384#endif
385
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100386#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
387static struct mtd_partition cm_x300_nand_partitions[] = {
388 [0] = {
389 .name = "OBM",
390 .offset = 0,
391 .size = SZ_256K,
392 .mask_flags = MTD_WRITEABLE, /* force read-only */
393 },
394 [1] = {
395 .name = "U-Boot",
396 .offset = MTDPART_OFS_APPEND,
397 .size = SZ_256K,
398 .mask_flags = MTD_WRITEABLE, /* force read-only */
399 },
400 [2] = {
401 .name = "Environment",
402 .offset = MTDPART_OFS_APPEND,
403 .size = SZ_256K,
404 },
405 [3] = {
406 .name = "reserved",
407 .offset = MTDPART_OFS_APPEND,
408 .size = SZ_256K + SZ_1M,
409 .mask_flags = MTD_WRITEABLE, /* force read-only */
410 },
411 [4] = {
412 .name = "kernel",
413 .offset = MTDPART_OFS_APPEND,
414 .size = SZ_4M,
415 },
416 [5] = {
417 .name = "fs",
418 .offset = MTDPART_OFS_APPEND,
419 .size = MTDPART_SIZ_FULL,
420 },
421};
422
423static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
424 .enable_arbiter = 1,
Mike Rapoportb3992b62009-06-04 10:44:51 +0300425 .keep_config = 1,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100426 .parts = cm_x300_nand_partitions,
427 .nr_parts = ARRAY_SIZE(cm_x300_nand_partitions),
428};
429
430static void __init cm_x300_init_nand(void)
431{
432 pxa3xx_set_nand_info(&cm_x300_nand_info);
433}
434#else
435static inline void cm_x300_init_nand(void) {}
436#endif
437
438#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200439static struct pxamci_platform_data cm_x300_mci_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800440 .detect_delay_ms = 200,
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200441 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
442 .gpio_card_detect = GPIO82_MMC_IRQ,
443 .gpio_card_ro = GPIO85_MMC_WP,
444 .gpio_power = -1,
445};
446
447/* The second MMC slot of CM-X300 is hardwired to Libertas card and has
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100448 no detection/ro pins */
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200449static int cm_x300_mci2_init(struct device *dev,
450 irq_handler_t cm_x300_detect_int,
451 void *data)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100452{
453 return 0;
454}
455
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200456static void cm_x300_mci2_exit(struct device *dev, void *data)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100457{
458}
459
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100460static struct pxamci_platform_data cm_x300_mci2_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800461 .detect_delay_ms = 200,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200462 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200463 .init = cm_x300_mci2_init,
464 .exit = cm_x300_mci2_exit,
465 .gpio_card_detect = -1,
466 .gpio_card_ro = -1,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200467 .gpio_power = -1,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100468};
469
470static void __init cm_x300_init_mmc(void)
471{
472 pxa_set_mci_info(&cm_x300_mci_platform_data);
473 pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
474}
475#else
476static inline void cm_x300_init_mmc(void) {}
477#endif
478
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300479#if defined(CONFIG_PXA310_ULPI)
480static struct clk *pout_clk;
481
482static int cm_x300_ulpi_phy_reset(void)
483{
484 int err;
485
486 /* reset the PHY */
487 err = gpio_request(GPIO_ULPI_PHY_RST, "ulpi reset");
488 if (err) {
489 pr_err("%s: failed to request ULPI reset GPIO: %d\n",
490 __func__, err);
491 return err;
492 }
493
494 gpio_direction_output(GPIO_ULPI_PHY_RST, 0);
495 msleep(10);
496 gpio_set_value(GPIO_ULPI_PHY_RST, 1);
497 msleep(10);
498
499 gpio_free(GPIO_ULPI_PHY_RST);
500
501 return 0;
502}
503
504static inline int cm_x300_u2d_init(struct device *dev)
505{
506 int err = 0;
507
508 if (cpu_is_pxa310()) {
509 /* CLK_POUT is connected to the ULPI PHY */
510 pout_clk = clk_get(NULL, "CLK_POUT");
511 if (IS_ERR(pout_clk)) {
512 err = PTR_ERR(pout_clk);
513 pr_err("%s: failed to get CLK_POUT: %d\n",
514 __func__, err);
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
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100551#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
Igor Grinbergedaa64c2009-10-14 09:20:23 +0200552static 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
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100561static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
562 .port_mode = PMM_PERPORT_MODE,
Igor Grinbergedaa64c2009-10-14 09:20:23 +0200563 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW,
564 .init = cm_x300_ohci_init,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100565};
Eric Miao097b5332008-09-27 15:49:57 +0800566
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100567static 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",
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100580 .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{
Igor Grinberg55052ea2009-10-14 09:20:18 +0200599 if (system_rev < 130)
600 cm_x300_leds[0].gpio = 79;
601 else
602 cm_x300_leds[0].gpio = 76;
603
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100604 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
Mike Rapoport1858ced2009-06-04 10:44:52 +0300641#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
Igor Grinberg03ba7e02010-03-09 11:43:48 +0200666/* 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
Igor Grinbergd176d642010-03-09 11:43:51 +0200714static 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
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200735/* DA9030 */
736struct da903x_subdev_info cm_x300_da9030_subdevs[] = {
737 {
Igor Grinberg03ba7e02010-03-09 11:43:48 +0200738 .name = "da903x-battery",
739 .id = DA9030_ID_BAT,
740 .platform_data = &cm_x300_battery_info,
741 },
Igor Grinbergd176d642010-03-09 11:43:51 +0200742 {
743 .name = "da903x-regulator",
744 .id = DA9030_ID_BUCK2,
745 .platform_data = &buck2_data,
746 },
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200747};
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),
Igor Grinberge4e30972010-03-09 11:43:50 +0200756 .irq = IRQ_WAKEUP0,
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200757 .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);
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100768 irq_set_irq_wake(IRQ_WAKEUP0, 1);
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200769}
770
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200771static void __init cm_x300_init_wi2wi(void)
772{
773 int bt_reset, wlan_en;
774 int err;
775
776 if (system_rev < 130) {
777 wlan_en = 77;
778 bt_reset = 78;
779 } else {
780 wlan_en = 71;
781 bt_reset = 70;
782 }
783
784 /* Libertas and CSR reset */
785 err = gpio_request(wlan_en, "wlan en");
786 if (err) {
787 pr_err("CM-X300: failed to request wlan en gpio: %d\n", err);
788 } else {
789 gpio_direction_output(wlan_en, 1);
790 gpio_free(wlan_en);
791 }
792
793 err = gpio_request(bt_reset, "bt reset");
794 if (err) {
795 pr_err("CM-X300: failed to request bt reset gpio: %d\n", err);
796 } else {
797 gpio_direction_output(bt_reset, 1);
798 udelay(10);
799 gpio_set_value(bt_reset, 0);
800 udelay(10);
801 gpio_set_value(bt_reset, 1);
802 gpio_free(bt_reset);
803 }
804}
805
806/* MFP */
Igor Grinberg55052ea2009-10-14 09:20:18 +0200807static void __init cm_x300_init_mfp(void)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100808{
809 /* board-processor specific GPIO initialization */
Igor Grinbergdef82522009-10-14 09:20:22 +0200810 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg));
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100811
Igor Grinberg55052ea2009-10-14 09:20:18 +0200812 if (system_rev < 130)
Igor Grinbergdef82522009-10-14 09:20:22 +0200813 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg));
Igor Grinberg55052ea2009-10-14 09:20:18 +0200814 else
Igor Grinbergdef82522009-10-14 09:20:22 +0200815 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_ge130_mfp_cfg));
816
817 if (cpu_is_pxa310())
818 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x310_mfp_cfg));
Igor Grinberg55052ea2009-10-14 09:20:18 +0200819}
820
821static void __init cm_x300_init(void)
822{
823 cm_x300_init_mfp();
824
Russell Kingcc155c62009-11-09 13:34:08 +0800825 pxa_set_btuart_info(NULL);
826 pxa_set_stuart_info(NULL);
Igor Grinberga6cd7eb2010-07-20 10:58:52 +0300827 if (cpu_is_pxa300())
828 pxa_set_ffuart_info(NULL);
Russell Kingcc155c62009-11-09 13:34:08 +0800829
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200830 cm_x300_init_da9030();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100831 cm_x300_init_dm9000();
832 cm_x300_init_lcd();
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300833 cm_x300_init_u2d();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100834 cm_x300_init_ohci();
835 cm_x300_init_mmc();
836 cm_x300_init_nand();
837 cm_x300_init_leds();
838 cm_x300_init_i2c();
Igor Grinberg83e560e2009-10-14 09:20:19 +0200839 cm_x300_init_spi();
Mike Rapoport1858ced2009-06-04 10:44:52 +0300840 cm_x300_init_rtc();
Igor Grinberg74e74de2009-10-14 09:20:20 +0200841 cm_x300_init_ac97();
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200842 cm_x300_init_wi2wi();
Igor Grinbergdb205462009-11-10 14:18:41 +0200843 cm_x300_init_bl();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100844}
845
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300846static void __init cm_x300_fixup(struct machine_desc *mdesc, struct tag *tags,
847 char **cmdline, struct meminfo *mi)
848{
Igor Grinberg81880972010-03-09 11:43:52 +0200849 /* Make sure that mi->bank[0].start = PHYS_ADDR */
850 for (; tags->hdr.size; tags = tag_next(tags))
851 if (tags->hdr.tag == ATAG_MEM &&
852 tags->u.mem.start == 0x80000000) {
853 tags->u.mem.start = 0xa0000000;
854 break;
855 }
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300856}
857
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100858MACHINE_START(CM_X300, "CM-X300 module")
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100859 .boot_params = 0xa0000100,
Marek Vasut851982c2010-10-11 02:20:19 +0200860 .map_io = pxa3xx_map_io,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100861 .init_irq = pxa3xx_init_irq,
862 .timer = &pxa_timer,
863 .init_machine = cm_x300_init,
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300864 .fixup = cm_x300_fixup,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100865MACHINE_END