blob: a7dae60810e8717c09eda1058e934d546dd66ddc [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 */
Igor Grinberg32de50e2011-05-09 14:41:48 +030015#define pr_fmt(fmt) "%s: " fmt, __func__
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010016
17#include <linux/module.h>
18#include <linux/kernel.h>
19#include <linux/interrupt.h>
20#include <linux/init.h>
Igor Grinbergb3d01da2009-10-14 09:20:21 +020021#include <linux/delay.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010022#include <linux/platform_device.h>
Igor Grinberg1b43d8e2010-07-27 15:07:00 +030023#include <linux/clk.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010024
25#include <linux/gpio.h>
26#include <linux/dm9000.h>
27#include <linux/leds.h>
Mike Rapoport1858ced2009-06-04 10:44:52 +030028#include <linux/rtc-v3020.h>
Thierry Reding783bc782015-10-05 10:49:41 +020029#include <linux/pwm.h>
Igor Grinbergdb205462009-11-10 14:18:41 +020030#include <linux/pwm_backlight.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010031
32#include <linux/i2c.h>
Vivien Didelot58774572013-08-29 15:24:14 -040033#include <linux/platform_data/pca953x.h>
Sebastian Andrzej Siewiorb4593962011-02-23 12:38:16 +010034#include <linux/i2c/pxa-i2c.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010035
Igor Grinberg9c017ca2009-10-14 09:20:24 +020036#include <linux/mfd/da903x.h>
Igor Grinbergd176d642010-03-09 11:43:51 +020037#include <linux/regulator/machine.h>
Igor Grinberg03ba7e02010-03-09 11:43:48 +020038#include <linux/power_supply.h>
39#include <linux/apm-emulation.h>
Igor Grinberg9c017ca2009-10-14 09:20:24 +020040
Igor Grinberg83e560e2009-10-14 09:20:19 +020041#include <linux/spi/spi.h>
42#include <linux/spi/spi_gpio.h>
43#include <linux/spi/tdo24m.h>
44
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010045#include <asm/mach-types.h>
46#include <asm/mach/arch.h>
Mike Rapoportb5a5c472009-06-04 10:44:54 +030047#include <asm/setup.h>
David Howells9f97da72012-03-28 18:30:01 +010048#include <asm/system_info.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010049
Eric Miao51c62982009-01-02 23:17:22 +080050#include <mach/pxa300.h>
Igor Grinbergedaa64c2009-10-14 09:20:23 +020051#include <mach/pxa27x-udc.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020052#include <linux/platform_data/video-pxafb.h>
53#include <linux/platform_data/mmc-pxamci.h>
54#include <linux/platform_data/usb-ohci-pxa27x.h>
55#include <linux/platform_data/mtd-nand-pxa3xx.h>
Igor Grinberg74e74de2009-10-14 09:20:20 +020056#include <mach/audio.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020057#include <linux/platform_data/usb-pxa3xx-ulpi.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010058
59#include <asm/mach/map.h>
60
61#include "generic.h"
Igor Grinbergdb205462009-11-10 14:18:41 +020062#include "devices.h"
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010063
64#define CM_X300_ETH_PHYS 0x08000010
65
Mike Rapoport0bff2fc2009-10-15 10:11:09 +020066#define GPIO82_MMC_IRQ (82)
67#define GPIO85_MMC_WP (85)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010068
Haojian Zhuang6384fda2011-10-10 14:21:08 +080069#define CM_X300_MMC_IRQ PXA_GPIO_TO_IRQ(GPIO82_MMC_IRQ)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010070
Mike Rapoport1858ced2009-06-04 10:44:52 +030071#define GPIO95_RTC_CS (95)
72#define GPIO96_RTC_WR (96)
73#define GPIO97_RTC_RD (97)
74#define GPIO98_RTC_IO (98)
75
Igor Grinberg1b43d8e2010-07-27 15:07:00 +030076#define GPIO_ULPI_PHY_RST (127)
77
Igor Grinbergdef82522009-10-14 09:20:22 +020078static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010079 /* LCD */
80 GPIO54_LCD_LDD_0,
81 GPIO55_LCD_LDD_1,
82 GPIO56_LCD_LDD_2,
83 GPIO57_LCD_LDD_3,
84 GPIO58_LCD_LDD_4,
85 GPIO59_LCD_LDD_5,
86 GPIO60_LCD_LDD_6,
87 GPIO61_LCD_LDD_7,
88 GPIO62_LCD_LDD_8,
89 GPIO63_LCD_LDD_9,
90 GPIO64_LCD_LDD_10,
91 GPIO65_LCD_LDD_11,
92 GPIO66_LCD_LDD_12,
93 GPIO67_LCD_LDD_13,
94 GPIO68_LCD_LDD_14,
95 GPIO69_LCD_LDD_15,
96 GPIO72_LCD_FCLK,
97 GPIO73_LCD_LCLK,
98 GPIO74_LCD_PCLK,
99 GPIO75_LCD_BIAS,
100
101 /* BTUART */
102 GPIO111_UART2_RTS,
103 GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
104 GPIO113_UART2_TXD,
105 GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
106
107 /* STUART */
108 GPIO109_UART3_TXD,
109 GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
110
111 /* AC97 */
112 GPIO23_AC97_nACRESET,
113 GPIO24_AC97_SYSCLK,
114 GPIO29_AC97_BITCLK,
115 GPIO25_AC97_SDATA_IN_0,
116 GPIO27_AC97_SDATA_OUT,
117 GPIO28_AC97_SYNC,
118
119 /* Keypad */
120 GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
121 GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
122 GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
123 GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
124 GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
125 GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
126 GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
127 GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
128 GPIO121_KP_MKOUT_0,
129 GPIO122_KP_MKOUT_1,
130 GPIO123_KP_MKOUT_2,
131 GPIO124_KP_MKOUT_3,
132 GPIO125_KP_MKOUT_4,
133 GPIO4_2_KP_MKOUT_5,
134
135 /* MMC1 */
136 GPIO3_MMC1_DAT0,
137 GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
138 GPIO5_MMC1_DAT2,
139 GPIO6_MMC1_DAT3,
140 GPIO7_MMC1_CLK,
141 GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
142
143 /* MMC2 */
144 GPIO9_MMC2_DAT0,
145 GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
146 GPIO11_MMC2_DAT2,
147 GPIO12_MMC2_DAT3,
148 GPIO13_MMC2_CLK,
149 GPIO14_MMC2_CMD,
150
151 /* FFUART */
152 GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
153 GPIO31_UART1_TXD,
154 GPIO32_UART1_CTS,
155 GPIO37_UART1_RTS,
156 GPIO33_UART1_DCD,
157 GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
158 GPIO35_UART1_RI,
159 GPIO36_UART1_DTR,
160
161 /* GPIOs */
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100162 GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */
163 GPIO85_GPIO, /* MMC WP */
164 GPIO99_GPIO, /* Ethernet IRQ */
Eric Miao6f584cf2008-11-28 16:00:24 +0800165
Mike Rapoport1858ced2009-06-04 10:44:52 +0300166 /* RTC GPIOs */
Igor Grinberg6c7b3ea2011-05-09 14:41:46 +0300167 GPIO95_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC CS */
168 GPIO96_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC WR */
169 GPIO97_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC RD */
170 GPIO98_GPIO, /* RTC IO */
Mike Rapoport1858ced2009-06-04 10:44:52 +0300171
Eric Miao6f584cf2008-11-28 16:00:24 +0800172 /* Standard I2C */
173 GPIO21_I2C_SCL,
174 GPIO22_I2C_SDA,
Igor Grinbergdb205462009-11-10 14:18:41 +0200175
176 /* PWM Backlight */
177 GPIO19_PWM2_OUT,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100178};
179
Igor Grinbergdef82522009-10-14 09:20:22 +0200180static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = {
Igor Grinberg55052ea2009-10-14 09:20:18 +0200181 /* GPIOs */
182 GPIO79_GPIO, /* LED */
183 GPIO77_GPIO, /* WiFi reset */
184 GPIO78_GPIO, /* BT reset */
185};
186
Igor Grinbergdef82522009-10-14 09:20:22 +0200187static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = {
Igor Grinberg55052ea2009-10-14 09:20:18 +0200188 /* GPIOs */
189 GPIO76_GPIO, /* LED */
190 GPIO71_GPIO, /* WiFi reset */
191 GPIO70_GPIO, /* BT reset */
192};
193
Igor Grinbergdef82522009-10-14 09:20:22 +0200194static mfp_cfg_t cm_x310_mfp_cfg[] __initdata = {
195 /* USB PORT 2 */
196 ULPI_STP,
197 ULPI_NXT,
198 ULPI_DIR,
199 GPIO30_ULPI_DATA_OUT_0,
200 GPIO31_ULPI_DATA_OUT_1,
201 GPIO32_ULPI_DATA_OUT_2,
202 GPIO33_ULPI_DATA_OUT_3,
203 GPIO34_ULPI_DATA_OUT_4,
204 GPIO35_ULPI_DATA_OUT_5,
205 GPIO36_ULPI_DATA_OUT_6,
206 GPIO37_ULPI_DATA_OUT_7,
207 GPIO38_ULPI_CLK,
208 /* external PHY reset pin */
209 GPIO127_GPIO,
210
211 /* USB PORT 3 */
212 GPIO77_USB_P3_1,
213 GPIO78_USB_P3_2,
214 GPIO79_USB_P3_3,
215 GPIO80_USB_P3_4,
216 GPIO81_USB_P3_5,
217 GPIO82_USB_P3_6,
218 GPIO0_2_USBH_PEN,
219};
220
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100221#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
222static struct resource dm9000_resources[] = {
223 [0] = {
224 .start = CM_X300_ETH_PHYS,
225 .end = CM_X300_ETH_PHYS + 0x3,
226 .flags = IORESOURCE_MEM,
227 },
228 [1] = {
229 .start = CM_X300_ETH_PHYS + 0x4,
230 .end = CM_X300_ETH_PHYS + 0x4 + 500,
231 .flags = IORESOURCE_MEM,
232 },
233 [2] = {
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800234 .start = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO99)),
235 .end = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO99)),
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100236 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
237 }
238};
239
240static struct dm9000_plat_data cm_x300_dm9000_platdata = {
Mike Rapoportbff22c92009-02-23 18:01:12 +0200241 .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100242};
243
244static struct platform_device dm9000_device = {
245 .name = "dm9000",
246 .id = 0,
247 .num_resources = ARRAY_SIZE(dm9000_resources),
248 .resource = dm9000_resources,
249 .dev = {
250 .platform_data = &cm_x300_dm9000_platdata,
251 }
252
253};
254
255static void __init cm_x300_init_dm9000(void)
256{
257 platform_device_register(&dm9000_device);
258}
259#else
260static inline void cm_x300_init_dm9000(void) {}
261#endif
262
Igor Grinberg83e560e2009-10-14 09:20:19 +0200263/* LCD */
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100264#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
265static struct pxafb_mode_info cm_x300_lcd_modes[] = {
266 [0] = {
Igor Grinberg83e560e2009-10-14 09:20:19 +0200267 .pixclock = 38250,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100268 .bpp = 16,
269 .xres = 480,
270 .yres = 640,
271 .hsync_len = 8,
272 .vsync_len = 2,
273 .left_margin = 8,
Igor Grinberg83e560e2009-10-14 09:20:19 +0200274 .upper_margin = 2,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100275 .right_margin = 24,
276 .lower_margin = 4,
277 .cmap_greyscale = 0,
278 },
279 [1] = {
280 .pixclock = 153800,
281 .bpp = 16,
282 .xres = 240,
283 .yres = 320,
284 .hsync_len = 8,
285 .vsync_len = 2,
286 .left_margin = 8,
287 .upper_margin = 2,
288 .right_margin = 88,
289 .lower_margin = 2,
290 .cmap_greyscale = 0,
291 },
292};
293
294static struct pxafb_mach_info cm_x300_lcd = {
295 .modes = cm_x300_lcd_modes,
Igor Grinberg83e560e2009-10-14 09:20:19 +0200296 .num_modes = ARRAY_SIZE(cm_x300_lcd_modes),
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100297 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
298};
299
300static void __init cm_x300_init_lcd(void)
301{
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800302 pxa_set_fb_info(NULL, &cm_x300_lcd);
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100303}
304#else
305static inline void cm_x300_init_lcd(void) {}
306#endif
307
Igor Grinbergdb205462009-11-10 14:18:41 +0200308#if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
Thierry Reding783bc782015-10-05 10:49:41 +0200309static struct pwm_lookup cm_x300_pwm_lookup[] = {
310 PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.0", NULL, 10000,
311 PWM_POLARITY_NORMAL),
312};
313
Igor Grinbergdb205462009-11-10 14:18:41 +0200314static struct platform_pwm_backlight_data cm_x300_backlight_data = {
Igor Grinbergdb205462009-11-10 14:18:41 +0200315 .max_brightness = 100,
316 .dft_brightness = 100,
Thierry Redingdb011202013-08-30 12:15:24 +0200317 .enable_gpio = -1,
Igor Grinbergdb205462009-11-10 14:18:41 +0200318};
319
320static struct platform_device cm_x300_backlight_device = {
321 .name = "pwm-backlight",
322 .dev = {
323 .parent = &pxa27x_device_pwm0.dev,
324 .platform_data = &cm_x300_backlight_data,
325 },
326};
327
328static void cm_x300_init_bl(void)
329{
Thierry Reding783bc782015-10-05 10:49:41 +0200330 pwm_add_table(cm_x300_pwm_lookup, ARRAY_SIZE(cm_x300_pwm_lookup));
Igor Grinbergdb205462009-11-10 14:18:41 +0200331 platform_device_register(&cm_x300_backlight_device);
332}
333#else
334static inline void cm_x300_init_bl(void) {}
335#endif
336
Igor Grinberg83e560e2009-10-14 09:20:19 +0200337#if defined(CONFIG_SPI_GPIO) || defined(CONFIG_SPI_GPIO_MODULE)
338#define GPIO_LCD_BASE (144)
339#define GPIO_LCD_DIN (GPIO_LCD_BASE + 8) /* aux_gpio3_0 */
340#define GPIO_LCD_DOUT (GPIO_LCD_BASE + 9) /* aux_gpio3_1 */
341#define GPIO_LCD_SCL (GPIO_LCD_BASE + 10) /* aux_gpio3_2 */
342#define GPIO_LCD_CS (GPIO_LCD_BASE + 11) /* aux_gpio3_3 */
343#define LCD_SPI_BUS_NUM (1)
344
345static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata = {
346 .sck = GPIO_LCD_SCL,
347 .mosi = GPIO_LCD_DIN,
348 .miso = GPIO_LCD_DOUT,
349 .num_chipselect = 1,
350};
351
352static struct platform_device cm_x300_spi_gpio = {
353 .name = "spi_gpio",
354 .id = LCD_SPI_BUS_NUM,
355 .dev = {
356 .platform_data = &cm_x300_spi_gpio_pdata,
357 },
358};
359
360static struct tdo24m_platform_data cm_x300_tdo24m_pdata = {
361 .model = TDO35S,
362};
363
364static struct spi_board_info cm_x300_spi_devices[] __initdata = {
365 {
366 .modalias = "tdo24m",
367 .max_speed_hz = 1000000,
368 .bus_num = LCD_SPI_BUS_NUM,
369 .chip_select = 0,
370 .controller_data = (void *) GPIO_LCD_CS,
371 .platform_data = &cm_x300_tdo24m_pdata,
372 },
373};
374
375static void __init cm_x300_init_spi(void)
376{
377 spi_register_board_info(cm_x300_spi_devices,
378 ARRAY_SIZE(cm_x300_spi_devices));
379 platform_device_register(&cm_x300_spi_gpio);
380}
381#else
382static inline void cm_x300_init_spi(void) {}
383#endif
384
Igor Grinberg74e74de2009-10-14 09:20:20 +0200385#if defined(CONFIG_SND_PXA2XX_LIB_AC97)
386static void __init cm_x300_init_ac97(void)
387{
388 pxa_set_ac97_info(NULL);
389}
390#else
391static inline void cm_x300_init_ac97(void) {}
392#endif
393
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100394#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
395static struct mtd_partition cm_x300_nand_partitions[] = {
396 [0] = {
397 .name = "OBM",
398 .offset = 0,
399 .size = SZ_256K,
400 .mask_flags = MTD_WRITEABLE, /* force read-only */
401 },
402 [1] = {
403 .name = "U-Boot",
404 .offset = MTDPART_OFS_APPEND,
405 .size = SZ_256K,
406 .mask_flags = MTD_WRITEABLE, /* force read-only */
407 },
408 [2] = {
409 .name = "Environment",
410 .offset = MTDPART_OFS_APPEND,
411 .size = SZ_256K,
412 },
413 [3] = {
414 .name = "reserved",
415 .offset = MTDPART_OFS_APPEND,
416 .size = SZ_256K + SZ_1M,
417 .mask_flags = MTD_WRITEABLE, /* force read-only */
418 },
419 [4] = {
420 .name = "kernel",
421 .offset = MTDPART_OFS_APPEND,
422 .size = SZ_4M,
423 },
424 [5] = {
425 .name = "fs",
426 .offset = MTDPART_OFS_APPEND,
427 .size = MTDPART_SIZ_FULL,
428 },
429};
430
431static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
432 .enable_arbiter = 1,
Mike Rapoportb3992b62009-06-04 10:44:51 +0300433 .keep_config = 1,
Lei Wenf3c8cfc2011-07-14 20:44:33 -0700434 .num_cs = 1,
435 .parts[0] = cm_x300_nand_partitions,
436 .nr_parts[0] = ARRAY_SIZE(cm_x300_nand_partitions),
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100437};
438
439static void __init cm_x300_init_nand(void)
440{
441 pxa3xx_set_nand_info(&cm_x300_nand_info);
442}
443#else
444static inline void cm_x300_init_nand(void) {}
445#endif
446
447#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200448static struct pxamci_platform_data cm_x300_mci_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800449 .detect_delay_ms = 200,
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200450 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
451 .gpio_card_detect = GPIO82_MMC_IRQ,
452 .gpio_card_ro = GPIO85_MMC_WP,
453 .gpio_power = -1,
454};
455
456/* The second MMC slot of CM-X300 is hardwired to Libertas card and has
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100457 no detection/ro pins */
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200458static int cm_x300_mci2_init(struct device *dev,
459 irq_handler_t cm_x300_detect_int,
460 void *data)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100461{
462 return 0;
463}
464
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200465static void cm_x300_mci2_exit(struct device *dev, void *data)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100466{
467}
468
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100469static struct pxamci_platform_data cm_x300_mci2_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800470 .detect_delay_ms = 200,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200471 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200472 .init = cm_x300_mci2_init,
473 .exit = cm_x300_mci2_exit,
474 .gpio_card_detect = -1,
475 .gpio_card_ro = -1,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200476 .gpio_power = -1,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100477};
478
479static void __init cm_x300_init_mmc(void)
480{
481 pxa_set_mci_info(&cm_x300_mci_platform_data);
482 pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
483}
484#else
485static inline void cm_x300_init_mmc(void) {}
486#endif
487
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300488#if defined(CONFIG_PXA310_ULPI)
489static struct clk *pout_clk;
490
491static int cm_x300_ulpi_phy_reset(void)
492{
493 int err;
494
495 /* reset the PHY */
Igor Grinberg5a009df2011-05-09 14:41:47 +0300496 err = gpio_request_one(GPIO_ULPI_PHY_RST, GPIOF_OUT_INIT_LOW,
497 "ulpi reset");
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300498 if (err) {
Igor Grinberg32de50e2011-05-09 14:41:48 +0300499 pr_err("failed to request ULPI reset GPIO: %d\n", err);
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300500 return err;
501 }
502
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300503 msleep(10);
504 gpio_set_value(GPIO_ULPI_PHY_RST, 1);
505 msleep(10);
506
507 gpio_free(GPIO_ULPI_PHY_RST);
508
509 return 0;
510}
511
512static inline int cm_x300_u2d_init(struct device *dev)
513{
514 int err = 0;
515
516 if (cpu_is_pxa310()) {
517 /* CLK_POUT is connected to the ULPI PHY */
518 pout_clk = clk_get(NULL, "CLK_POUT");
519 if (IS_ERR(pout_clk)) {
520 err = PTR_ERR(pout_clk);
Igor Grinberg32de50e2011-05-09 14:41:48 +0300521 pr_err("failed to get CLK_POUT: %d\n", err);
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300522 return err;
523 }
524 clk_enable(pout_clk);
525
526 err = cm_x300_ulpi_phy_reset();
527 if (err) {
528 clk_disable(pout_clk);
529 clk_put(pout_clk);
530 }
531 }
532
533 return err;
534}
535
536static void cm_x300_u2d_exit(struct device *dev)
537{
538 if (cpu_is_pxa310()) {
539 clk_disable(pout_clk);
540 clk_put(pout_clk);
541 }
542}
543
544static struct pxa3xx_u2d_platform_data cm_x300_u2d_platform_data = {
545 .ulpi_mode = ULPI_SER_6PIN,
546 .init = cm_x300_u2d_init,
547 .exit = cm_x300_u2d_exit,
548};
549
550static void cm_x300_init_u2d(void)
551{
552 pxa3xx_set_u2d_info(&cm_x300_u2d_platform_data);
553}
554#else
555static inline void cm_x300_init_u2d(void) {}
556#endif
557
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100558#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
Igor Grinbergedaa64c2009-10-14 09:20:23 +0200559static int cm_x300_ohci_init(struct device *dev)
560{
561 if (cpu_is_pxa300())
562 UP2OCR = UP2OCR_HXS
563 | UP2OCR_HXOE | UP2OCR_DMPDE | UP2OCR_DPPDE;
564
565 return 0;
566}
567
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100568static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
569 .port_mode = PMM_PERPORT_MODE,
Igor Grinbergedaa64c2009-10-14 09:20:23 +0200570 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW,
571 .init = cm_x300_ohci_init,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100572};
Eric Miao097b5332008-09-27 15:49:57 +0800573
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100574static void __init cm_x300_init_ohci(void)
575{
576 pxa_set_ohci_info(&cm_x300_ohci_platform_data);
577}
578#else
579static inline void cm_x300_init_ohci(void) {}
580#endif
581
582#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
583static struct gpio_led cm_x300_leds[] = {
584 [0] = {
585 .name = "cm-x300:green",
586 .default_trigger = "heartbeat",
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100587 .active_low = 1,
588 },
589};
590
591static struct gpio_led_platform_data cm_x300_gpio_led_pdata = {
592 .num_leds = ARRAY_SIZE(cm_x300_leds),
593 .leds = cm_x300_leds,
594};
595
596static struct platform_device cm_x300_led_device = {
597 .name = "leds-gpio",
598 .id = -1,
599 .dev = {
600 .platform_data = &cm_x300_gpio_led_pdata,
601 },
602};
603
604static void __init cm_x300_init_leds(void)
605{
Igor Grinberg55052ea2009-10-14 09:20:18 +0200606 if (system_rev < 130)
607 cm_x300_leds[0].gpio = 79;
608 else
609 cm_x300_leds[0].gpio = 76;
610
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100611 platform_device_register(&cm_x300_led_device);
612}
613#else
614static inline void cm_x300_init_leds(void) {}
615#endif
616
617#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
618/* PCA9555 */
619static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = {
620 .gpio_base = 128,
621};
622
623static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = {
624 .gpio_base = 144,
625};
626
627static struct i2c_board_info cm_x300_gpio_ext_info[] = {
628 [0] = {
629 I2C_BOARD_INFO("pca9555", 0x24),
630 .platform_data = &cm_x300_gpio_ext_pdata_0,
631 },
632 [1] = {
633 I2C_BOARD_INFO("pca9555", 0x25),
634 .platform_data = &cm_x300_gpio_ext_pdata_1,
635 },
636};
637
638static void __init cm_x300_init_i2c(void)
639{
640 pxa_set_i2c_info(NULL);
641 i2c_register_board_info(0, cm_x300_gpio_ext_info,
642 ARRAY_SIZE(cm_x300_gpio_ext_info));
643}
644#else
645static inline void cm_x300_init_i2c(void) {}
646#endif
647
Mike Rapoport1858ced2009-06-04 10:44:52 +0300648#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
649struct v3020_platform_data cm_x300_v3020_pdata = {
650 .use_gpio = 1,
651 .gpio_cs = GPIO95_RTC_CS,
652 .gpio_wr = GPIO96_RTC_WR,
653 .gpio_rd = GPIO97_RTC_RD,
654 .gpio_io = GPIO98_RTC_IO,
655};
656
657static struct platform_device cm_x300_rtc_device = {
658 .name = "v3020",
659 .id = -1,
660 .dev = {
661 .platform_data = &cm_x300_v3020_pdata,
662 }
663};
664
665static void __init cm_x300_init_rtc(void)
666{
667 platform_device_register(&cm_x300_rtc_device);
668}
669#else
670static inline void cm_x300_init_rtc(void) {}
671#endif
672
Igor Grinberg03ba7e02010-03-09 11:43:48 +0200673/* Battery */
674struct power_supply_info cm_x300_psy_info = {
675 .name = "battery",
676 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
677 .voltage_max_design = 4200000,
678 .voltage_min_design = 3000000,
679 .use_for_apm = 1,
680};
681
682static void cm_x300_battery_low(void)
683{
684#if defined(CONFIG_APM_EMULATION)
685 apm_queue_event(APM_LOW_BATTERY);
686#endif
687}
688
689static void cm_x300_battery_critical(void)
690{
691#if defined(CONFIG_APM_EMULATION)
692 apm_queue_event(APM_CRITICAL_SUSPEND);
693#endif
694}
695
696struct da9030_battery_info cm_x300_battery_info = {
697 .battery_info = &cm_x300_psy_info,
698
699 .charge_milliamp = 1000,
700 .charge_millivolt = 4200,
701
702 .vbat_low = 3600,
703 .vbat_crit = 3400,
704 .vbat_charge_start = 4100,
705 .vbat_charge_stop = 4200,
706 .vbat_charge_restart = 4000,
707
708 .vcharge_min = 3200,
709 .vcharge_max = 5500,
710
711 .tbat_low = 197,
712 .tbat_high = 78,
713 .tbat_restart = 100,
714
715 .batmon_interval = 0,
716
717 .battery_low = cm_x300_battery_low,
718 .battery_critical = cm_x300_battery_critical,
719};
720
Igor Grinbergd176d642010-03-09 11:43:51 +0200721static struct regulator_consumer_supply buck2_consumers[] = {
Axel Lin0bf189a2012-05-08 16:25:10 +0800722 REGULATOR_SUPPLY("vcc_core", NULL),
Igor Grinbergd176d642010-03-09 11:43:51 +0200723};
724
725static struct regulator_init_data buck2_data = {
726 .constraints = {
727 .min_uV = 1375000,
728 .max_uV = 1375000,
729 .state_mem = {
730 .enabled = 0,
731 },
732 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
733 .apply_uV = 1,
734 },
735 .num_consumer_supplies = ARRAY_SIZE(buck2_consumers),
736 .consumer_supplies = buck2_consumers,
737};
738
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200739/* DA9030 */
740struct da903x_subdev_info cm_x300_da9030_subdevs[] = {
741 {
Igor Grinberg03ba7e02010-03-09 11:43:48 +0200742 .name = "da903x-battery",
743 .id = DA9030_ID_BAT,
744 .platform_data = &cm_x300_battery_info,
745 },
Igor Grinbergd176d642010-03-09 11:43:51 +0200746 {
747 .name = "da903x-regulator",
748 .id = DA9030_ID_BUCK2,
749 .platform_data = &buck2_data,
750 },
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200751};
752
753static struct da903x_platform_data cm_x300_da9030_info = {
754 .num_subdevs = ARRAY_SIZE(cm_x300_da9030_subdevs),
755 .subdevs = cm_x300_da9030_subdevs,
756};
757
758static struct i2c_board_info cm_x300_pmic_info = {
759 I2C_BOARD_INFO("da9030", 0x49),
Igor Grinberge4e30972010-03-09 11:43:50 +0200760 .irq = IRQ_WAKEUP0,
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200761 .platform_data = &cm_x300_da9030_info,
762};
763
764static struct i2c_pxa_platform_data cm_x300_pwr_i2c_info = {
765 .use_pio = 1,
766};
767
768static void __init cm_x300_init_da9030(void)
769{
770 pxa3xx_set_i2c_power_info(&cm_x300_pwr_i2c_info);
771 i2c_register_board_info(1, &cm_x300_pmic_info, 1);
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100772 irq_set_irq_wake(IRQ_WAKEUP0, 1);
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200773}
774
Igor Grinberg5a009df2011-05-09 14:41:47 +0300775/* wi2wi gpio setting for system_rev >= 130 */
776static struct gpio cm_x300_wi2wi_gpios[] __initdata = {
777 { 71, GPIOF_OUT_INIT_HIGH, "wlan en" },
778 { 70, GPIOF_OUT_INIT_HIGH, "bt reset" },
779};
780
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200781static void __init cm_x300_init_wi2wi(void)
782{
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200783 int err;
784
785 if (system_rev < 130) {
Igor Grinberg5a009df2011-05-09 14:41:47 +0300786 cm_x300_wi2wi_gpios[0].gpio = 77; /* wlan en */
787 cm_x300_wi2wi_gpios[1].gpio = 78; /* bt reset */
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200788 }
789
790 /* Libertas and CSR reset */
Igor Grinberg5a009df2011-05-09 14:41:47 +0300791 err = gpio_request_array(ARRAY_AND_SIZE(cm_x300_wi2wi_gpios));
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200792 if (err) {
Igor Grinberg32de50e2011-05-09 14:41:48 +0300793 pr_err("failed to request wifi/bt gpios: %d\n", err);
Igor Grinberg5a009df2011-05-09 14:41:47 +0300794 return;
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200795 }
796
Igor Grinberg5a009df2011-05-09 14:41:47 +0300797 udelay(10);
Axel Lin1a642002011-09-17 22:15:34 +0800798 gpio_set_value(cm_x300_wi2wi_gpios[1].gpio, 0);
Igor Grinberg5a009df2011-05-09 14:41:47 +0300799 udelay(10);
Axel Lin1a642002011-09-17 22:15:34 +0800800 gpio_set_value(cm_x300_wi2wi_gpios[1].gpio, 1);
Igor Grinberg5a009df2011-05-09 14:41:47 +0300801
Axel Lin1a642002011-09-17 22:15:34 +0800802 gpio_free_array(ARRAY_AND_SIZE(cm_x300_wi2wi_gpios));
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200803}
804
805/* MFP */
Igor Grinberg55052ea2009-10-14 09:20:18 +0200806static void __init cm_x300_init_mfp(void)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100807{
808 /* board-processor specific GPIO initialization */
Igor Grinbergdef82522009-10-14 09:20:22 +0200809 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg));
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100810
Igor Grinberg55052ea2009-10-14 09:20:18 +0200811 if (system_rev < 130)
Igor Grinbergdef82522009-10-14 09:20:22 +0200812 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg));
Igor Grinberg55052ea2009-10-14 09:20:18 +0200813 else
Igor Grinbergdef82522009-10-14 09:20:22 +0200814 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_ge130_mfp_cfg));
815
816 if (cpu_is_pxa310())
817 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x310_mfp_cfg));
Igor Grinberg55052ea2009-10-14 09:20:18 +0200818}
819
820static void __init cm_x300_init(void)
821{
822 cm_x300_init_mfp();
823
Russell Kingcc155c62009-11-09 13:34:08 +0800824 pxa_set_btuart_info(NULL);
825 pxa_set_stuart_info(NULL);
Igor Grinberga6cd7eb2010-07-20 10:58:52 +0300826 if (cpu_is_pxa300())
827 pxa_set_ffuart_info(NULL);
Russell Kingcc155c62009-11-09 13:34:08 +0800828
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200829 cm_x300_init_da9030();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100830 cm_x300_init_dm9000();
831 cm_x300_init_lcd();
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300832 cm_x300_init_u2d();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100833 cm_x300_init_ohci();
834 cm_x300_init_mmc();
835 cm_x300_init_nand();
836 cm_x300_init_leds();
837 cm_x300_init_i2c();
Igor Grinberg83e560e2009-10-14 09:20:19 +0200838 cm_x300_init_spi();
Mike Rapoport1858ced2009-06-04 10:44:52 +0300839 cm_x300_init_rtc();
Igor Grinberg74e74de2009-10-14 09:20:20 +0200840 cm_x300_init_ac97();
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200841 cm_x300_init_wi2wi();
Igor Grinbergdb205462009-11-10 14:18:41 +0200842 cm_x300_init_bl();
Robert Jarzmika927ef82015-07-11 21:33:06 +0200843
844 regulator_has_full_constraints();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100845}
846
Laura Abbott1c2f87c2014-04-13 22:54:58 +0100847static void __init cm_x300_fixup(struct tag *tags, char **cmdline)
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300848{
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")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400859 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +0200860 .map_io = pxa3xx_map_io,
Rob Herring4e611092012-01-03 16:53:48 -0600861 .nr_irqs = PXA_NR_IRQS,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100862 .init_irq = pxa3xx_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800863 .handle_irq = pxa3xx_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700864 .init_time = pxa_timer_init,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100865 .init_machine = cm_x300_init,
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300866 .fixup = cm_x300_fixup,
Russell King271a74f2011-11-04 14:15:53 +0000867 .restart = pxa_restart,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100868MACHINE_END