blob: 4d3588d26c2a18854b6fc81430dafe371a6af747 [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>
Igor Grinbergdb205462009-11-10 14:18:41 +020029#include <linux/pwm_backlight.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010030
31#include <linux/i2c.h>
Vivien Didelot58774572013-08-29 15:24:14 -040032#include <linux/platform_data/pca953x.h>
Sebastian Andrzej Siewiorb4593962011-02-23 12:38:16 +010033#include <linux/i2c/pxa-i2c.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010034
Igor Grinberg9c017ca2009-10-14 09:20:24 +020035#include <linux/mfd/da903x.h>
Igor Grinbergd176d642010-03-09 11:43:51 +020036#include <linux/regulator/machine.h>
Igor Grinberg03ba7e02010-03-09 11:43:48 +020037#include <linux/power_supply.h>
38#include <linux/apm-emulation.h>
Igor Grinberg9c017ca2009-10-14 09:20:24 +020039
Igor Grinberg83e560e2009-10-14 09:20:19 +020040#include <linux/spi/spi.h>
41#include <linux/spi/spi_gpio.h>
42#include <linux/spi/tdo24m.h>
43
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010044#include <asm/mach-types.h>
45#include <asm/mach/arch.h>
Mike Rapoportb5a5c472009-06-04 10:44:54 +030046#include <asm/setup.h>
David Howells9f97da72012-03-28 18:30:01 +010047#include <asm/system_info.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010048
Eric Miao51c62982009-01-02 23:17:22 +080049#include <mach/pxa300.h>
Igor Grinbergedaa64c2009-10-14 09:20:23 +020050#include <mach/pxa27x-udc.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020051#include <linux/platform_data/video-pxafb.h>
52#include <linux/platform_data/mmc-pxamci.h>
53#include <linux/platform_data/usb-ohci-pxa27x.h>
54#include <linux/platform_data/mtd-nand-pxa3xx.h>
Igor Grinberg74e74de2009-10-14 09:20:20 +020055#include <mach/audio.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020056#include <linux/platform_data/usb-pxa3xx-ulpi.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010057
58#include <asm/mach/map.h>
59
60#include "generic.h"
Igor Grinbergdb205462009-11-10 14:18:41 +020061#include "devices.h"
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010062
63#define CM_X300_ETH_PHYS 0x08000010
64
Mike Rapoport0bff2fc2009-10-15 10:11:09 +020065#define GPIO82_MMC_IRQ (82)
66#define GPIO85_MMC_WP (85)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010067
Haojian Zhuang6384fda2011-10-10 14:21:08 +080068#define CM_X300_MMC_IRQ PXA_GPIO_TO_IRQ(GPIO82_MMC_IRQ)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010069
Mike Rapoport1858ced2009-06-04 10:44:52 +030070#define GPIO95_RTC_CS (95)
71#define GPIO96_RTC_WR (96)
72#define GPIO97_RTC_RD (97)
73#define GPIO98_RTC_IO (98)
74
Igor Grinberg1b43d8e2010-07-27 15:07:00 +030075#define GPIO_ULPI_PHY_RST (127)
76
Igor Grinbergdef82522009-10-14 09:20:22 +020077static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010078 /* LCD */
79 GPIO54_LCD_LDD_0,
80 GPIO55_LCD_LDD_1,
81 GPIO56_LCD_LDD_2,
82 GPIO57_LCD_LDD_3,
83 GPIO58_LCD_LDD_4,
84 GPIO59_LCD_LDD_5,
85 GPIO60_LCD_LDD_6,
86 GPIO61_LCD_LDD_7,
87 GPIO62_LCD_LDD_8,
88 GPIO63_LCD_LDD_9,
89 GPIO64_LCD_LDD_10,
90 GPIO65_LCD_LDD_11,
91 GPIO66_LCD_LDD_12,
92 GPIO67_LCD_LDD_13,
93 GPIO68_LCD_LDD_14,
94 GPIO69_LCD_LDD_15,
95 GPIO72_LCD_FCLK,
96 GPIO73_LCD_LCLK,
97 GPIO74_LCD_PCLK,
98 GPIO75_LCD_BIAS,
99
100 /* BTUART */
101 GPIO111_UART2_RTS,
102 GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
103 GPIO113_UART2_TXD,
104 GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
105
106 /* STUART */
107 GPIO109_UART3_TXD,
108 GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
109
110 /* AC97 */
111 GPIO23_AC97_nACRESET,
112 GPIO24_AC97_SYSCLK,
113 GPIO29_AC97_BITCLK,
114 GPIO25_AC97_SDATA_IN_0,
115 GPIO27_AC97_SDATA_OUT,
116 GPIO28_AC97_SYNC,
117
118 /* Keypad */
119 GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
120 GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
121 GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
122 GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
123 GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
124 GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
125 GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
126 GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
127 GPIO121_KP_MKOUT_0,
128 GPIO122_KP_MKOUT_1,
129 GPIO123_KP_MKOUT_2,
130 GPIO124_KP_MKOUT_3,
131 GPIO125_KP_MKOUT_4,
132 GPIO4_2_KP_MKOUT_5,
133
134 /* MMC1 */
135 GPIO3_MMC1_DAT0,
136 GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
137 GPIO5_MMC1_DAT2,
138 GPIO6_MMC1_DAT3,
139 GPIO7_MMC1_CLK,
140 GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
141
142 /* MMC2 */
143 GPIO9_MMC2_DAT0,
144 GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
145 GPIO11_MMC2_DAT2,
146 GPIO12_MMC2_DAT3,
147 GPIO13_MMC2_CLK,
148 GPIO14_MMC2_CMD,
149
150 /* FFUART */
151 GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
152 GPIO31_UART1_TXD,
153 GPIO32_UART1_CTS,
154 GPIO37_UART1_RTS,
155 GPIO33_UART1_DCD,
156 GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
157 GPIO35_UART1_RI,
158 GPIO36_UART1_DTR,
159
160 /* GPIOs */
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100161 GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */
162 GPIO85_GPIO, /* MMC WP */
163 GPIO99_GPIO, /* Ethernet IRQ */
Eric Miao6f584cf2008-11-28 16:00:24 +0800164
Mike Rapoport1858ced2009-06-04 10:44:52 +0300165 /* RTC GPIOs */
Igor Grinberg6c7b3ea2011-05-09 14:41:46 +0300166 GPIO95_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC CS */
167 GPIO96_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC WR */
168 GPIO97_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC RD */
169 GPIO98_GPIO, /* RTC IO */
Mike Rapoport1858ced2009-06-04 10:44:52 +0300170
Eric Miao6f584cf2008-11-28 16:00:24 +0800171 /* Standard I2C */
172 GPIO21_I2C_SCL,
173 GPIO22_I2C_SDA,
Igor Grinbergdb205462009-11-10 14:18:41 +0200174
175 /* PWM Backlight */
176 GPIO19_PWM2_OUT,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100177};
178
Igor Grinbergdef82522009-10-14 09:20:22 +0200179static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = {
Igor Grinberg55052ea2009-10-14 09:20:18 +0200180 /* GPIOs */
181 GPIO79_GPIO, /* LED */
182 GPIO77_GPIO, /* WiFi reset */
183 GPIO78_GPIO, /* BT reset */
184};
185
Igor Grinbergdef82522009-10-14 09:20:22 +0200186static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = {
Igor Grinberg55052ea2009-10-14 09:20:18 +0200187 /* GPIOs */
188 GPIO76_GPIO, /* LED */
189 GPIO71_GPIO, /* WiFi reset */
190 GPIO70_GPIO, /* BT reset */
191};
192
Igor Grinbergdef82522009-10-14 09:20:22 +0200193static mfp_cfg_t cm_x310_mfp_cfg[] __initdata = {
194 /* USB PORT 2 */
195 ULPI_STP,
196 ULPI_NXT,
197 ULPI_DIR,
198 GPIO30_ULPI_DATA_OUT_0,
199 GPIO31_ULPI_DATA_OUT_1,
200 GPIO32_ULPI_DATA_OUT_2,
201 GPIO33_ULPI_DATA_OUT_3,
202 GPIO34_ULPI_DATA_OUT_4,
203 GPIO35_ULPI_DATA_OUT_5,
204 GPIO36_ULPI_DATA_OUT_6,
205 GPIO37_ULPI_DATA_OUT_7,
206 GPIO38_ULPI_CLK,
207 /* external PHY reset pin */
208 GPIO127_GPIO,
209
210 /* USB PORT 3 */
211 GPIO77_USB_P3_1,
212 GPIO78_USB_P3_2,
213 GPIO79_USB_P3_3,
214 GPIO80_USB_P3_4,
215 GPIO81_USB_P3_5,
216 GPIO82_USB_P3_6,
217 GPIO0_2_USBH_PEN,
218};
219
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100220#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
221static struct resource dm9000_resources[] = {
222 [0] = {
223 .start = CM_X300_ETH_PHYS,
224 .end = CM_X300_ETH_PHYS + 0x3,
225 .flags = IORESOURCE_MEM,
226 },
227 [1] = {
228 .start = CM_X300_ETH_PHYS + 0x4,
229 .end = CM_X300_ETH_PHYS + 0x4 + 500,
230 .flags = IORESOURCE_MEM,
231 },
232 [2] = {
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800233 .start = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO99)),
234 .end = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO99)),
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100235 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
236 }
237};
238
239static struct dm9000_plat_data cm_x300_dm9000_platdata = {
Mike Rapoportbff22c92009-02-23 18:01:12 +0200240 .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100241};
242
243static struct platform_device dm9000_device = {
244 .name = "dm9000",
245 .id = 0,
246 .num_resources = ARRAY_SIZE(dm9000_resources),
247 .resource = dm9000_resources,
248 .dev = {
249 .platform_data = &cm_x300_dm9000_platdata,
250 }
251
252};
253
254static void __init cm_x300_init_dm9000(void)
255{
256 platform_device_register(&dm9000_device);
257}
258#else
259static inline void cm_x300_init_dm9000(void) {}
260#endif
261
Igor Grinberg83e560e2009-10-14 09:20:19 +0200262/* LCD */
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100263#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
264static struct pxafb_mode_info cm_x300_lcd_modes[] = {
265 [0] = {
Igor Grinberg83e560e2009-10-14 09:20:19 +0200266 .pixclock = 38250,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100267 .bpp = 16,
268 .xres = 480,
269 .yres = 640,
270 .hsync_len = 8,
271 .vsync_len = 2,
272 .left_margin = 8,
Igor Grinberg83e560e2009-10-14 09:20:19 +0200273 .upper_margin = 2,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100274 .right_margin = 24,
275 .lower_margin = 4,
276 .cmap_greyscale = 0,
277 },
278 [1] = {
279 .pixclock = 153800,
280 .bpp = 16,
281 .xres = 240,
282 .yres = 320,
283 .hsync_len = 8,
284 .vsync_len = 2,
285 .left_margin = 8,
286 .upper_margin = 2,
287 .right_margin = 88,
288 .lower_margin = 2,
289 .cmap_greyscale = 0,
290 },
291};
292
293static struct pxafb_mach_info cm_x300_lcd = {
294 .modes = cm_x300_lcd_modes,
Igor Grinberg83e560e2009-10-14 09:20:19 +0200295 .num_modes = ARRAY_SIZE(cm_x300_lcd_modes),
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100296 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
297};
298
299static void __init cm_x300_init_lcd(void)
300{
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800301 pxa_set_fb_info(NULL, &cm_x300_lcd);
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100302}
303#else
304static inline void cm_x300_init_lcd(void) {}
305#endif
306
Igor Grinbergdb205462009-11-10 14:18:41 +0200307#if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
308static struct platform_pwm_backlight_data cm_x300_backlight_data = {
309 .pwm_id = 2,
310 .max_brightness = 100,
311 .dft_brightness = 100,
312 .pwm_period_ns = 10000,
Thierry Redingdb011202013-08-30 12:15:24 +0200313 .enable_gpio = -1,
Igor Grinbergdb205462009-11-10 14:18:41 +0200314};
315
316static struct platform_device cm_x300_backlight_device = {
317 .name = "pwm-backlight",
318 .dev = {
319 .parent = &pxa27x_device_pwm0.dev,
320 .platform_data = &cm_x300_backlight_data,
321 },
322};
323
324static void cm_x300_init_bl(void)
325{
326 platform_device_register(&cm_x300_backlight_device);
327}
328#else
329static inline void cm_x300_init_bl(void) {}
330#endif
331
Igor Grinberg83e560e2009-10-14 09:20:19 +0200332#if defined(CONFIG_SPI_GPIO) || defined(CONFIG_SPI_GPIO_MODULE)
333#define GPIO_LCD_BASE (144)
334#define GPIO_LCD_DIN (GPIO_LCD_BASE + 8) /* aux_gpio3_0 */
335#define GPIO_LCD_DOUT (GPIO_LCD_BASE + 9) /* aux_gpio3_1 */
336#define GPIO_LCD_SCL (GPIO_LCD_BASE + 10) /* aux_gpio3_2 */
337#define GPIO_LCD_CS (GPIO_LCD_BASE + 11) /* aux_gpio3_3 */
338#define LCD_SPI_BUS_NUM (1)
339
340static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata = {
341 .sck = GPIO_LCD_SCL,
342 .mosi = GPIO_LCD_DIN,
343 .miso = GPIO_LCD_DOUT,
344 .num_chipselect = 1,
345};
346
347static struct platform_device cm_x300_spi_gpio = {
348 .name = "spi_gpio",
349 .id = LCD_SPI_BUS_NUM,
350 .dev = {
351 .platform_data = &cm_x300_spi_gpio_pdata,
352 },
353};
354
355static struct tdo24m_platform_data cm_x300_tdo24m_pdata = {
356 .model = TDO35S,
357};
358
359static struct spi_board_info cm_x300_spi_devices[] __initdata = {
360 {
361 .modalias = "tdo24m",
362 .max_speed_hz = 1000000,
363 .bus_num = LCD_SPI_BUS_NUM,
364 .chip_select = 0,
365 .controller_data = (void *) GPIO_LCD_CS,
366 .platform_data = &cm_x300_tdo24m_pdata,
367 },
368};
369
370static void __init cm_x300_init_spi(void)
371{
372 spi_register_board_info(cm_x300_spi_devices,
373 ARRAY_SIZE(cm_x300_spi_devices));
374 platform_device_register(&cm_x300_spi_gpio);
375}
376#else
377static inline void cm_x300_init_spi(void) {}
378#endif
379
Igor Grinberg74e74de2009-10-14 09:20:20 +0200380#if defined(CONFIG_SND_PXA2XX_LIB_AC97)
381static void __init cm_x300_init_ac97(void)
382{
383 pxa_set_ac97_info(NULL);
384}
385#else
386static inline void cm_x300_init_ac97(void) {}
387#endif
388
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100389#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
390static struct mtd_partition cm_x300_nand_partitions[] = {
391 [0] = {
392 .name = "OBM",
393 .offset = 0,
394 .size = SZ_256K,
395 .mask_flags = MTD_WRITEABLE, /* force read-only */
396 },
397 [1] = {
398 .name = "U-Boot",
399 .offset = MTDPART_OFS_APPEND,
400 .size = SZ_256K,
401 .mask_flags = MTD_WRITEABLE, /* force read-only */
402 },
403 [2] = {
404 .name = "Environment",
405 .offset = MTDPART_OFS_APPEND,
406 .size = SZ_256K,
407 },
408 [3] = {
409 .name = "reserved",
410 .offset = MTDPART_OFS_APPEND,
411 .size = SZ_256K + SZ_1M,
412 .mask_flags = MTD_WRITEABLE, /* force read-only */
413 },
414 [4] = {
415 .name = "kernel",
416 .offset = MTDPART_OFS_APPEND,
417 .size = SZ_4M,
418 },
419 [5] = {
420 .name = "fs",
421 .offset = MTDPART_OFS_APPEND,
422 .size = MTDPART_SIZ_FULL,
423 },
424};
425
426static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
427 .enable_arbiter = 1,
Mike Rapoportb3992b62009-06-04 10:44:51 +0300428 .keep_config = 1,
Lei Wenf3c8cfc2011-07-14 20:44:33 -0700429 .num_cs = 1,
430 .parts[0] = cm_x300_nand_partitions,
431 .nr_parts[0] = ARRAY_SIZE(cm_x300_nand_partitions),
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100432};
433
434static void __init cm_x300_init_nand(void)
435{
436 pxa3xx_set_nand_info(&cm_x300_nand_info);
437}
438#else
439static inline void cm_x300_init_nand(void) {}
440#endif
441
442#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200443static struct pxamci_platform_data cm_x300_mci_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800444 .detect_delay_ms = 200,
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200445 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
446 .gpio_card_detect = GPIO82_MMC_IRQ,
447 .gpio_card_ro = GPIO85_MMC_WP,
448 .gpio_power = -1,
449};
450
451/* The second MMC slot of CM-X300 is hardwired to Libertas card and has
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100452 no detection/ro pins */
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200453static int cm_x300_mci2_init(struct device *dev,
454 irq_handler_t cm_x300_detect_int,
455 void *data)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100456{
457 return 0;
458}
459
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200460static void cm_x300_mci2_exit(struct device *dev, void *data)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100461{
462}
463
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100464static struct pxamci_platform_data cm_x300_mci2_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800465 .detect_delay_ms = 200,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200466 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200467 .init = cm_x300_mci2_init,
468 .exit = cm_x300_mci2_exit,
469 .gpio_card_detect = -1,
470 .gpio_card_ro = -1,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200471 .gpio_power = -1,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100472};
473
474static void __init cm_x300_init_mmc(void)
475{
476 pxa_set_mci_info(&cm_x300_mci_platform_data);
477 pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
478}
479#else
480static inline void cm_x300_init_mmc(void) {}
481#endif
482
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300483#if defined(CONFIG_PXA310_ULPI)
484static struct clk *pout_clk;
485
486static int cm_x300_ulpi_phy_reset(void)
487{
488 int err;
489
490 /* reset the PHY */
Igor Grinberg5a009df2011-05-09 14:41:47 +0300491 err = gpio_request_one(GPIO_ULPI_PHY_RST, GPIOF_OUT_INIT_LOW,
492 "ulpi reset");
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300493 if (err) {
Igor Grinberg32de50e2011-05-09 14:41:48 +0300494 pr_err("failed to request ULPI reset GPIO: %d\n", err);
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300495 return err;
496 }
497
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300498 msleep(10);
499 gpio_set_value(GPIO_ULPI_PHY_RST, 1);
500 msleep(10);
501
502 gpio_free(GPIO_ULPI_PHY_RST);
503
504 return 0;
505}
506
507static inline int cm_x300_u2d_init(struct device *dev)
508{
509 int err = 0;
510
511 if (cpu_is_pxa310()) {
512 /* CLK_POUT is connected to the ULPI PHY */
513 pout_clk = clk_get(NULL, "CLK_POUT");
514 if (IS_ERR(pout_clk)) {
515 err = PTR_ERR(pout_clk);
Igor Grinberg32de50e2011-05-09 14:41:48 +0300516 pr_err("failed to get CLK_POUT: %d\n", err);
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300517 return err;
518 }
519 clk_enable(pout_clk);
520
521 err = cm_x300_ulpi_phy_reset();
522 if (err) {
523 clk_disable(pout_clk);
524 clk_put(pout_clk);
525 }
526 }
527
528 return err;
529}
530
531static void cm_x300_u2d_exit(struct device *dev)
532{
533 if (cpu_is_pxa310()) {
534 clk_disable(pout_clk);
535 clk_put(pout_clk);
536 }
537}
538
539static struct pxa3xx_u2d_platform_data cm_x300_u2d_platform_data = {
540 .ulpi_mode = ULPI_SER_6PIN,
541 .init = cm_x300_u2d_init,
542 .exit = cm_x300_u2d_exit,
543};
544
545static void cm_x300_init_u2d(void)
546{
547 pxa3xx_set_u2d_info(&cm_x300_u2d_platform_data);
548}
549#else
550static inline void cm_x300_init_u2d(void) {}
551#endif
552
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100553#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
Igor Grinbergedaa64c2009-10-14 09:20:23 +0200554static int cm_x300_ohci_init(struct device *dev)
555{
556 if (cpu_is_pxa300())
557 UP2OCR = UP2OCR_HXS
558 | UP2OCR_HXOE | UP2OCR_DMPDE | UP2OCR_DPPDE;
559
560 return 0;
561}
562
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100563static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
564 .port_mode = PMM_PERPORT_MODE,
Igor Grinbergedaa64c2009-10-14 09:20:23 +0200565 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW,
566 .init = cm_x300_ohci_init,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100567};
Eric Miao097b5332008-09-27 15:49:57 +0800568
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100569static void __init cm_x300_init_ohci(void)
570{
571 pxa_set_ohci_info(&cm_x300_ohci_platform_data);
572}
573#else
574static inline void cm_x300_init_ohci(void) {}
575#endif
576
577#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
578static struct gpio_led cm_x300_leds[] = {
579 [0] = {
580 .name = "cm-x300:green",
581 .default_trigger = "heartbeat",
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100582 .active_low = 1,
583 },
584};
585
586static struct gpio_led_platform_data cm_x300_gpio_led_pdata = {
587 .num_leds = ARRAY_SIZE(cm_x300_leds),
588 .leds = cm_x300_leds,
589};
590
591static struct platform_device cm_x300_led_device = {
592 .name = "leds-gpio",
593 .id = -1,
594 .dev = {
595 .platform_data = &cm_x300_gpio_led_pdata,
596 },
597};
598
599static void __init cm_x300_init_leds(void)
600{
Igor Grinberg55052ea2009-10-14 09:20:18 +0200601 if (system_rev < 130)
602 cm_x300_leds[0].gpio = 79;
603 else
604 cm_x300_leds[0].gpio = 76;
605
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100606 platform_device_register(&cm_x300_led_device);
607}
608#else
609static inline void cm_x300_init_leds(void) {}
610#endif
611
612#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
613/* PCA9555 */
614static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = {
615 .gpio_base = 128,
616};
617
618static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = {
619 .gpio_base = 144,
620};
621
622static struct i2c_board_info cm_x300_gpio_ext_info[] = {
623 [0] = {
624 I2C_BOARD_INFO("pca9555", 0x24),
625 .platform_data = &cm_x300_gpio_ext_pdata_0,
626 },
627 [1] = {
628 I2C_BOARD_INFO("pca9555", 0x25),
629 .platform_data = &cm_x300_gpio_ext_pdata_1,
630 },
631};
632
633static void __init cm_x300_init_i2c(void)
634{
635 pxa_set_i2c_info(NULL);
636 i2c_register_board_info(0, cm_x300_gpio_ext_info,
637 ARRAY_SIZE(cm_x300_gpio_ext_info));
638}
639#else
640static inline void cm_x300_init_i2c(void) {}
641#endif
642
Mike Rapoport1858ced2009-06-04 10:44:52 +0300643#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
644struct v3020_platform_data cm_x300_v3020_pdata = {
645 .use_gpio = 1,
646 .gpio_cs = GPIO95_RTC_CS,
647 .gpio_wr = GPIO96_RTC_WR,
648 .gpio_rd = GPIO97_RTC_RD,
649 .gpio_io = GPIO98_RTC_IO,
650};
651
652static struct platform_device cm_x300_rtc_device = {
653 .name = "v3020",
654 .id = -1,
655 .dev = {
656 .platform_data = &cm_x300_v3020_pdata,
657 }
658};
659
660static void __init cm_x300_init_rtc(void)
661{
662 platform_device_register(&cm_x300_rtc_device);
663}
664#else
665static inline void cm_x300_init_rtc(void) {}
666#endif
667
Igor Grinberg03ba7e02010-03-09 11:43:48 +0200668/* Battery */
669struct power_supply_info cm_x300_psy_info = {
670 .name = "battery",
671 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
672 .voltage_max_design = 4200000,
673 .voltage_min_design = 3000000,
674 .use_for_apm = 1,
675};
676
677static void cm_x300_battery_low(void)
678{
679#if defined(CONFIG_APM_EMULATION)
680 apm_queue_event(APM_LOW_BATTERY);
681#endif
682}
683
684static void cm_x300_battery_critical(void)
685{
686#if defined(CONFIG_APM_EMULATION)
687 apm_queue_event(APM_CRITICAL_SUSPEND);
688#endif
689}
690
691struct da9030_battery_info cm_x300_battery_info = {
692 .battery_info = &cm_x300_psy_info,
693
694 .charge_milliamp = 1000,
695 .charge_millivolt = 4200,
696
697 .vbat_low = 3600,
698 .vbat_crit = 3400,
699 .vbat_charge_start = 4100,
700 .vbat_charge_stop = 4200,
701 .vbat_charge_restart = 4000,
702
703 .vcharge_min = 3200,
704 .vcharge_max = 5500,
705
706 .tbat_low = 197,
707 .tbat_high = 78,
708 .tbat_restart = 100,
709
710 .batmon_interval = 0,
711
712 .battery_low = cm_x300_battery_low,
713 .battery_critical = cm_x300_battery_critical,
714};
715
Igor Grinbergd176d642010-03-09 11:43:51 +0200716static struct regulator_consumer_supply buck2_consumers[] = {
Axel Lin0bf189a2012-05-08 16:25:10 +0800717 REGULATOR_SUPPLY("vcc_core", NULL),
Igor Grinbergd176d642010-03-09 11:43:51 +0200718};
719
720static struct regulator_init_data buck2_data = {
721 .constraints = {
722 .min_uV = 1375000,
723 .max_uV = 1375000,
724 .state_mem = {
725 .enabled = 0,
726 },
727 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
728 .apply_uV = 1,
729 },
730 .num_consumer_supplies = ARRAY_SIZE(buck2_consumers),
731 .consumer_supplies = buck2_consumers,
732};
733
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200734/* DA9030 */
735struct da903x_subdev_info cm_x300_da9030_subdevs[] = {
736 {
Igor Grinberg03ba7e02010-03-09 11:43:48 +0200737 .name = "da903x-battery",
738 .id = DA9030_ID_BAT,
739 .platform_data = &cm_x300_battery_info,
740 },
Igor Grinbergd176d642010-03-09 11:43:51 +0200741 {
742 .name = "da903x-regulator",
743 .id = DA9030_ID_BUCK2,
744 .platform_data = &buck2_data,
745 },
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200746};
747
748static struct da903x_platform_data cm_x300_da9030_info = {
749 .num_subdevs = ARRAY_SIZE(cm_x300_da9030_subdevs),
750 .subdevs = cm_x300_da9030_subdevs,
751};
752
753static struct i2c_board_info cm_x300_pmic_info = {
754 I2C_BOARD_INFO("da9030", 0x49),
Igor Grinberge4e30972010-03-09 11:43:50 +0200755 .irq = IRQ_WAKEUP0,
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200756 .platform_data = &cm_x300_da9030_info,
757};
758
759static struct i2c_pxa_platform_data cm_x300_pwr_i2c_info = {
760 .use_pio = 1,
761};
762
763static void __init cm_x300_init_da9030(void)
764{
765 pxa3xx_set_i2c_power_info(&cm_x300_pwr_i2c_info);
766 i2c_register_board_info(1, &cm_x300_pmic_info, 1);
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100767 irq_set_irq_wake(IRQ_WAKEUP0, 1);
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200768}
769
Igor Grinberg5a009df2011-05-09 14:41:47 +0300770/* wi2wi gpio setting for system_rev >= 130 */
771static struct gpio cm_x300_wi2wi_gpios[] __initdata = {
772 { 71, GPIOF_OUT_INIT_HIGH, "wlan en" },
773 { 70, GPIOF_OUT_INIT_HIGH, "bt reset" },
774};
775
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200776static void __init cm_x300_init_wi2wi(void)
777{
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200778 int err;
779
780 if (system_rev < 130) {
Igor Grinberg5a009df2011-05-09 14:41:47 +0300781 cm_x300_wi2wi_gpios[0].gpio = 77; /* wlan en */
782 cm_x300_wi2wi_gpios[1].gpio = 78; /* bt reset */
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200783 }
784
785 /* Libertas and CSR reset */
Igor Grinberg5a009df2011-05-09 14:41:47 +0300786 err = gpio_request_array(ARRAY_AND_SIZE(cm_x300_wi2wi_gpios));
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200787 if (err) {
Igor Grinberg32de50e2011-05-09 14:41:48 +0300788 pr_err("failed to request wifi/bt gpios: %d\n", err);
Igor Grinberg5a009df2011-05-09 14:41:47 +0300789 return;
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200790 }
791
Igor Grinberg5a009df2011-05-09 14:41:47 +0300792 udelay(10);
Axel Lin1a642002011-09-17 22:15:34 +0800793 gpio_set_value(cm_x300_wi2wi_gpios[1].gpio, 0);
Igor Grinberg5a009df2011-05-09 14:41:47 +0300794 udelay(10);
Axel Lin1a642002011-09-17 22:15:34 +0800795 gpio_set_value(cm_x300_wi2wi_gpios[1].gpio, 1);
Igor Grinberg5a009df2011-05-09 14:41:47 +0300796
Axel Lin1a642002011-09-17 22:15:34 +0800797 gpio_free_array(ARRAY_AND_SIZE(cm_x300_wi2wi_gpios));
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200798}
799
800/* MFP */
Igor Grinberg55052ea2009-10-14 09:20:18 +0200801static void __init cm_x300_init_mfp(void)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100802{
803 /* board-processor specific GPIO initialization */
Igor Grinbergdef82522009-10-14 09:20:22 +0200804 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg));
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100805
Igor Grinberg55052ea2009-10-14 09:20:18 +0200806 if (system_rev < 130)
Igor Grinbergdef82522009-10-14 09:20:22 +0200807 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg));
Igor Grinberg55052ea2009-10-14 09:20:18 +0200808 else
Igor Grinbergdef82522009-10-14 09:20:22 +0200809 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_ge130_mfp_cfg));
810
811 if (cpu_is_pxa310())
812 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x310_mfp_cfg));
Igor Grinberg55052ea2009-10-14 09:20:18 +0200813}
814
815static void __init cm_x300_init(void)
816{
817 cm_x300_init_mfp();
818
Russell Kingcc155c62009-11-09 13:34:08 +0800819 pxa_set_btuart_info(NULL);
820 pxa_set_stuart_info(NULL);
Igor Grinberga6cd7eb2010-07-20 10:58:52 +0300821 if (cpu_is_pxa300())
822 pxa_set_ffuart_info(NULL);
Russell Kingcc155c62009-11-09 13:34:08 +0800823
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200824 cm_x300_init_da9030();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100825 cm_x300_init_dm9000();
826 cm_x300_init_lcd();
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300827 cm_x300_init_u2d();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100828 cm_x300_init_ohci();
829 cm_x300_init_mmc();
830 cm_x300_init_nand();
831 cm_x300_init_leds();
832 cm_x300_init_i2c();
Igor Grinberg83e560e2009-10-14 09:20:19 +0200833 cm_x300_init_spi();
Mike Rapoport1858ced2009-06-04 10:44:52 +0300834 cm_x300_init_rtc();
Igor Grinberg74e74de2009-10-14 09:20:20 +0200835 cm_x300_init_ac97();
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200836 cm_x300_init_wi2wi();
Igor Grinbergdb205462009-11-10 14:18:41 +0200837 cm_x300_init_bl();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100838}
839
Laura Abbott1c2f87c2014-04-13 22:54:58 +0100840static void __init cm_x300_fixup(struct tag *tags, char **cmdline)
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300841{
Igor Grinberg81880972010-03-09 11:43:52 +0200842 /* Make sure that mi->bank[0].start = PHYS_ADDR */
843 for (; tags->hdr.size; tags = tag_next(tags))
844 if (tags->hdr.tag == ATAG_MEM &&
845 tags->u.mem.start == 0x80000000) {
846 tags->u.mem.start = 0xa0000000;
847 break;
848 }
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300849}
850
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100851MACHINE_START(CM_X300, "CM-X300 module")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400852 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +0200853 .map_io = pxa3xx_map_io,
Rob Herring4e611092012-01-03 16:53:48 -0600854 .nr_irqs = PXA_NR_IRQS,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100855 .init_irq = pxa3xx_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800856 .handle_irq = pxa3xx_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700857 .init_time = pxa_timer_init,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100858 .init_machine = cm_x300_init,
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300859 .fixup = cm_x300_fixup,
Russell King271a74f2011-11-04 14:15:53 +0000860 .restart = pxa_restart,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100861MACHINE_END