blob: 024c1fbcc55aee5816526b5574528e6c9532a3aa [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>
Linus Walleij9b00bc72018-02-12 13:45:30 +010026#include <linux/gpio/machine.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010027#include <linux/dm9000.h>
28#include <linux/leds.h>
Alexandre Bellonicd9b5182016-06-27 00:03:03 +020029#include <linux/platform_data/rtc-v3020.h>
Thierry Reding783bc782015-10-05 10:49:41 +020030#include <linux/pwm.h>
Igor Grinbergdb205462009-11-10 14:18:41 +020031#include <linux/pwm_backlight.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010032
33#include <linux/i2c.h>
Vivien Didelot58774572013-08-29 15:24:14 -040034#include <linux/platform_data/pca953x.h>
Wolfram Sangf15fc9b2017-11-13 18:27:39 +010035#include <linux/platform_data/i2c-pxa.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010036
Igor Grinberg9c017ca2009-10-14 09:20:24 +020037#include <linux/mfd/da903x.h>
Igor Grinbergd176d642010-03-09 11:43:51 +020038#include <linux/regulator/machine.h>
Igor Grinberg03ba7e02010-03-09 11:43:48 +020039#include <linux/power_supply.h>
40#include <linux/apm-emulation.h>
Igor Grinberg9c017ca2009-10-14 09:20:24 +020041
Igor Grinberg83e560e2009-10-14 09:20:19 +020042#include <linux/spi/spi.h>
43#include <linux/spi/spi_gpio.h>
44#include <linux/spi/tdo24m.h>
45
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010046#include <asm/mach-types.h>
47#include <asm/mach/arch.h>
Mike Rapoportb5a5c472009-06-04 10:44:54 +030048#include <asm/setup.h>
David Howells9f97da72012-03-28 18:30:01 +010049#include <asm/system_info.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010050
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010051#include "pxa300.h"
52#include "pxa27x-udc.h"
Arnd Bergmann293b2da2012-08-24 15:16:48 +020053#include <linux/platform_data/video-pxafb.h>
54#include <linux/platform_data/mmc-pxamci.h>
55#include <linux/platform_data/usb-ohci-pxa27x.h>
56#include <linux/platform_data/mtd-nand-pxa3xx.h>
Igor Grinberg74e74de2009-10-14 09:20:20 +020057#include <mach/audio.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020058#include <linux/platform_data/usb-pxa3xx-ulpi.h>
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010059
60#include <asm/mach/map.h>
61
62#include "generic.h"
Igor Grinbergdb205462009-11-10 14:18:41 +020063#include "devices.h"
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010064
65#define CM_X300_ETH_PHYS 0x08000010
66
Mike Rapoport0bff2fc2009-10-15 10:11:09 +020067#define GPIO82_MMC_IRQ (82)
68#define GPIO85_MMC_WP (85)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010069
Haojian Zhuang6384fda2011-10-10 14:21:08 +080070#define CM_X300_MMC_IRQ PXA_GPIO_TO_IRQ(GPIO82_MMC_IRQ)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010071
Mike Rapoport1858ced2009-06-04 10:44:52 +030072#define GPIO95_RTC_CS (95)
73#define GPIO96_RTC_WR (96)
74#define GPIO97_RTC_RD (97)
75#define GPIO98_RTC_IO (98)
76
Igor Grinberg1b43d8e2010-07-27 15:07:00 +030077#define GPIO_ULPI_PHY_RST (127)
78
Igor Grinbergdef82522009-10-14 09:20:22 +020079static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
Mike Rapoportcf75d8d2008-08-26 14:03:44 +010080 /* LCD */
81 GPIO54_LCD_LDD_0,
82 GPIO55_LCD_LDD_1,
83 GPIO56_LCD_LDD_2,
84 GPIO57_LCD_LDD_3,
85 GPIO58_LCD_LDD_4,
86 GPIO59_LCD_LDD_5,
87 GPIO60_LCD_LDD_6,
88 GPIO61_LCD_LDD_7,
89 GPIO62_LCD_LDD_8,
90 GPIO63_LCD_LDD_9,
91 GPIO64_LCD_LDD_10,
92 GPIO65_LCD_LDD_11,
93 GPIO66_LCD_LDD_12,
94 GPIO67_LCD_LDD_13,
95 GPIO68_LCD_LDD_14,
96 GPIO69_LCD_LDD_15,
97 GPIO72_LCD_FCLK,
98 GPIO73_LCD_LCLK,
99 GPIO74_LCD_PCLK,
100 GPIO75_LCD_BIAS,
101
102 /* BTUART */
103 GPIO111_UART2_RTS,
104 GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL,
105 GPIO113_UART2_TXD,
106 GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH,
107
108 /* STUART */
109 GPIO109_UART3_TXD,
110 GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL,
111
112 /* AC97 */
113 GPIO23_AC97_nACRESET,
114 GPIO24_AC97_SYSCLK,
115 GPIO29_AC97_BITCLK,
116 GPIO25_AC97_SDATA_IN_0,
117 GPIO27_AC97_SDATA_OUT,
118 GPIO28_AC97_SYNC,
119
120 /* Keypad */
121 GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
122 GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
123 GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
124 GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
125 GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
126 GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
127 GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
128 GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
129 GPIO121_KP_MKOUT_0,
130 GPIO122_KP_MKOUT_1,
131 GPIO123_KP_MKOUT_2,
132 GPIO124_KP_MKOUT_3,
133 GPIO125_KP_MKOUT_4,
134 GPIO4_2_KP_MKOUT_5,
135
136 /* MMC1 */
137 GPIO3_MMC1_DAT0,
138 GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
139 GPIO5_MMC1_DAT2,
140 GPIO6_MMC1_DAT3,
141 GPIO7_MMC1_CLK,
142 GPIO8_MMC1_CMD, /* CMD0 for slot 0 */
143
144 /* MMC2 */
145 GPIO9_MMC2_DAT0,
146 GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
147 GPIO11_MMC2_DAT2,
148 GPIO12_MMC2_DAT3,
149 GPIO13_MMC2_CLK,
150 GPIO14_MMC2_CMD,
151
152 /* FFUART */
153 GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL,
154 GPIO31_UART1_TXD,
155 GPIO32_UART1_CTS,
156 GPIO37_UART1_RTS,
157 GPIO33_UART1_DCD,
158 GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL,
159 GPIO35_UART1_RI,
160 GPIO36_UART1_DTR,
161
162 /* GPIOs */
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100163 GPIO82_GPIO | MFP_PULL_HIGH, /* MMC CD */
164 GPIO85_GPIO, /* MMC WP */
165 GPIO99_GPIO, /* Ethernet IRQ */
Eric Miao6f584cf2008-11-28 16:00:24 +0800166
Mike Rapoport1858ced2009-06-04 10:44:52 +0300167 /* RTC GPIOs */
Igor Grinberg6c7b3ea2011-05-09 14:41:46 +0300168 GPIO95_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC CS */
169 GPIO96_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC WR */
170 GPIO97_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC RD */
171 GPIO98_GPIO, /* RTC IO */
Mike Rapoport1858ced2009-06-04 10:44:52 +0300172
Eric Miao6f584cf2008-11-28 16:00:24 +0800173 /* Standard I2C */
174 GPIO21_I2C_SCL,
175 GPIO22_I2C_SDA,
Igor Grinbergdb205462009-11-10 14:18:41 +0200176
177 /* PWM Backlight */
178 GPIO19_PWM2_OUT,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100179};
180
Igor Grinbergdef82522009-10-14 09:20:22 +0200181static mfp_cfg_t cm_x3xx_rev_lt130_mfp_cfg[] __initdata = {
Igor Grinberg55052ea2009-10-14 09:20:18 +0200182 /* GPIOs */
183 GPIO79_GPIO, /* LED */
184 GPIO77_GPIO, /* WiFi reset */
185 GPIO78_GPIO, /* BT reset */
186};
187
Igor Grinbergdef82522009-10-14 09:20:22 +0200188static mfp_cfg_t cm_x3xx_rev_ge130_mfp_cfg[] __initdata = {
Igor Grinberg55052ea2009-10-14 09:20:18 +0200189 /* GPIOs */
190 GPIO76_GPIO, /* LED */
191 GPIO71_GPIO, /* WiFi reset */
192 GPIO70_GPIO, /* BT reset */
193};
194
Igor Grinbergdef82522009-10-14 09:20:22 +0200195static mfp_cfg_t cm_x310_mfp_cfg[] __initdata = {
196 /* USB PORT 2 */
197 ULPI_STP,
198 ULPI_NXT,
199 ULPI_DIR,
200 GPIO30_ULPI_DATA_OUT_0,
201 GPIO31_ULPI_DATA_OUT_1,
202 GPIO32_ULPI_DATA_OUT_2,
203 GPIO33_ULPI_DATA_OUT_3,
204 GPIO34_ULPI_DATA_OUT_4,
205 GPIO35_ULPI_DATA_OUT_5,
206 GPIO36_ULPI_DATA_OUT_6,
207 GPIO37_ULPI_DATA_OUT_7,
208 GPIO38_ULPI_CLK,
209 /* external PHY reset pin */
210 GPIO127_GPIO,
211
212 /* USB PORT 3 */
213 GPIO77_USB_P3_1,
214 GPIO78_USB_P3_2,
215 GPIO79_USB_P3_3,
216 GPIO80_USB_P3_4,
217 GPIO81_USB_P3_5,
218 GPIO82_USB_P3_6,
219 GPIO0_2_USBH_PEN,
220};
221
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100222#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
223static struct resource dm9000_resources[] = {
224 [0] = {
225 .start = CM_X300_ETH_PHYS,
226 .end = CM_X300_ETH_PHYS + 0x3,
227 .flags = IORESOURCE_MEM,
228 },
229 [1] = {
230 .start = CM_X300_ETH_PHYS + 0x4,
231 .end = CM_X300_ETH_PHYS + 0x4 + 500,
232 .flags = IORESOURCE_MEM,
233 },
234 [2] = {
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800235 .start = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO99)),
236 .end = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO99)),
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100237 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
238 }
239};
240
241static struct dm9000_plat_data cm_x300_dm9000_platdata = {
Mike Rapoportbff22c92009-02-23 18:01:12 +0200242 .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100243};
244
245static struct platform_device dm9000_device = {
246 .name = "dm9000",
247 .id = 0,
248 .num_resources = ARRAY_SIZE(dm9000_resources),
249 .resource = dm9000_resources,
250 .dev = {
251 .platform_data = &cm_x300_dm9000_platdata,
252 }
253
254};
255
256static void __init cm_x300_init_dm9000(void)
257{
258 platform_device_register(&dm9000_device);
259}
260#else
261static inline void cm_x300_init_dm9000(void) {}
262#endif
263
Igor Grinberg83e560e2009-10-14 09:20:19 +0200264/* LCD */
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100265#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
266static struct pxafb_mode_info cm_x300_lcd_modes[] = {
267 [0] = {
Igor Grinberg83e560e2009-10-14 09:20:19 +0200268 .pixclock = 38250,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100269 .bpp = 16,
270 .xres = 480,
271 .yres = 640,
272 .hsync_len = 8,
273 .vsync_len = 2,
274 .left_margin = 8,
Igor Grinberg83e560e2009-10-14 09:20:19 +0200275 .upper_margin = 2,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100276 .right_margin = 24,
277 .lower_margin = 4,
278 .cmap_greyscale = 0,
279 },
280 [1] = {
281 .pixclock = 153800,
282 .bpp = 16,
283 .xres = 240,
284 .yres = 320,
285 .hsync_len = 8,
286 .vsync_len = 2,
287 .left_margin = 8,
288 .upper_margin = 2,
289 .right_margin = 88,
290 .lower_margin = 2,
291 .cmap_greyscale = 0,
292 },
293};
294
295static struct pxafb_mach_info cm_x300_lcd = {
296 .modes = cm_x300_lcd_modes,
Igor Grinberg83e560e2009-10-14 09:20:19 +0200297 .num_modes = ARRAY_SIZE(cm_x300_lcd_modes),
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100298 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
299};
300
301static void __init cm_x300_init_lcd(void)
302{
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800303 pxa_set_fb_info(NULL, &cm_x300_lcd);
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100304}
305#else
306static inline void cm_x300_init_lcd(void) {}
307#endif
308
Igor Grinbergdb205462009-11-10 14:18:41 +0200309#if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
Thierry Reding783bc782015-10-05 10:49:41 +0200310static struct pwm_lookup cm_x300_pwm_lookup[] = {
311 PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.0", NULL, 10000,
312 PWM_POLARITY_NORMAL),
313};
314
Igor Grinbergdb205462009-11-10 14:18:41 +0200315static struct platform_pwm_backlight_data cm_x300_backlight_data = {
Igor Grinbergdb205462009-11-10 14:18:41 +0200316 .max_brightness = 100,
317 .dft_brightness = 100,
Thierry Redingdb011202013-08-30 12:15:24 +0200318 .enable_gpio = -1,
Igor Grinbergdb205462009-11-10 14:18:41 +0200319};
320
321static struct platform_device cm_x300_backlight_device = {
322 .name = "pwm-backlight",
323 .dev = {
324 .parent = &pxa27x_device_pwm0.dev,
325 .platform_data = &cm_x300_backlight_data,
326 },
327};
328
329static void cm_x300_init_bl(void)
330{
Thierry Reding783bc782015-10-05 10:49:41 +0200331 pwm_add_table(cm_x300_pwm_lookup, ARRAY_SIZE(cm_x300_pwm_lookup));
Igor Grinbergdb205462009-11-10 14:18:41 +0200332 platform_device_register(&cm_x300_backlight_device);
333}
334#else
335static inline void cm_x300_init_bl(void) {}
336#endif
337
Igor Grinberg83e560e2009-10-14 09:20:19 +0200338#if defined(CONFIG_SPI_GPIO) || defined(CONFIG_SPI_GPIO_MODULE)
339#define GPIO_LCD_BASE (144)
340#define GPIO_LCD_DIN (GPIO_LCD_BASE + 8) /* aux_gpio3_0 */
341#define GPIO_LCD_DOUT (GPIO_LCD_BASE + 9) /* aux_gpio3_1 */
342#define GPIO_LCD_SCL (GPIO_LCD_BASE + 10) /* aux_gpio3_2 */
343#define GPIO_LCD_CS (GPIO_LCD_BASE + 11) /* aux_gpio3_3 */
344#define LCD_SPI_BUS_NUM (1)
345
346static struct spi_gpio_platform_data cm_x300_spi_gpio_pdata = {
Igor Grinberg83e560e2009-10-14 09:20:19 +0200347 .num_chipselect = 1,
348};
349
350static struct platform_device cm_x300_spi_gpio = {
351 .name = "spi_gpio",
352 .id = LCD_SPI_BUS_NUM,
353 .dev = {
354 .platform_data = &cm_x300_spi_gpio_pdata,
355 },
356};
357
Linus Walleij9b00bc72018-02-12 13:45:30 +0100358static struct gpiod_lookup_table cm_x300_spi_gpiod_table = {
359 .dev_id = "spi_gpio",
360 .table = {
361 GPIO_LOOKUP("gpio-pxa", GPIO_LCD_SCL,
362 "sck", GPIO_ACTIVE_HIGH),
363 GPIO_LOOKUP("gpio-pxa", GPIO_LCD_DIN,
364 "mosi", GPIO_ACTIVE_HIGH),
365 GPIO_LOOKUP("gpio-pxa", GPIO_LCD_DOUT,
366 "miso", GPIO_ACTIVE_HIGH),
367 GPIO_LOOKUP("gpio-pxa", GPIO_LCD_CS,
368 "cs", GPIO_ACTIVE_HIGH),
369 { },
370 },
371};
372
Igor Grinberg83e560e2009-10-14 09:20:19 +0200373static struct tdo24m_platform_data cm_x300_tdo24m_pdata = {
374 .model = TDO35S,
375};
376
377static struct spi_board_info cm_x300_spi_devices[] __initdata = {
378 {
379 .modalias = "tdo24m",
380 .max_speed_hz = 1000000,
381 .bus_num = LCD_SPI_BUS_NUM,
382 .chip_select = 0,
Igor Grinberg83e560e2009-10-14 09:20:19 +0200383 .platform_data = &cm_x300_tdo24m_pdata,
384 },
385};
386
387static void __init cm_x300_init_spi(void)
388{
389 spi_register_board_info(cm_x300_spi_devices,
390 ARRAY_SIZE(cm_x300_spi_devices));
Linus Walleij9b00bc72018-02-12 13:45:30 +0100391 gpiod_add_lookup_table(&cm_x300_spi_gpiod_table);
Igor Grinberg83e560e2009-10-14 09:20:19 +0200392 platform_device_register(&cm_x300_spi_gpio);
393}
394#else
395static inline void cm_x300_init_spi(void) {}
396#endif
397
Igor Grinberg74e74de2009-10-14 09:20:20 +0200398#if defined(CONFIG_SND_PXA2XX_LIB_AC97)
399static void __init cm_x300_init_ac97(void)
400{
401 pxa_set_ac97_info(NULL);
402}
403#else
404static inline void cm_x300_init_ac97(void) {}
405#endif
406
Miquel Raynal349dfe62018-02-19 23:35:52 +0100407#if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100408static struct mtd_partition cm_x300_nand_partitions[] = {
409 [0] = {
410 .name = "OBM",
411 .offset = 0,
412 .size = SZ_256K,
413 .mask_flags = MTD_WRITEABLE, /* force read-only */
414 },
415 [1] = {
416 .name = "U-Boot",
417 .offset = MTDPART_OFS_APPEND,
418 .size = SZ_256K,
419 .mask_flags = MTD_WRITEABLE, /* force read-only */
420 },
421 [2] = {
422 .name = "Environment",
423 .offset = MTDPART_OFS_APPEND,
424 .size = SZ_256K,
425 },
426 [3] = {
427 .name = "reserved",
428 .offset = MTDPART_OFS_APPEND,
429 .size = SZ_256K + SZ_1M,
430 .mask_flags = MTD_WRITEABLE, /* force read-only */
431 },
432 [4] = {
433 .name = "kernel",
434 .offset = MTDPART_OFS_APPEND,
435 .size = SZ_4M,
436 },
437 [5] = {
438 .name = "fs",
439 .offset = MTDPART_OFS_APPEND,
440 .size = MTDPART_SIZ_FULL,
441 },
442};
443
444static struct pxa3xx_nand_platform_data cm_x300_nand_info = {
Mike Rapoportb3992b62009-06-04 10:44:51 +0300445 .keep_config = 1,
Miquel Raynal75765942018-02-19 23:35:54 +0100446 .parts = cm_x300_nand_partitions,
447 .nr_parts = ARRAY_SIZE(cm_x300_nand_partitions),
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100448};
449
450static void __init cm_x300_init_nand(void)
451{
452 pxa3xx_set_nand_info(&cm_x300_nand_info);
453}
454#else
455static inline void cm_x300_init_nand(void) {}
456#endif
457
458#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200459static struct pxamci_platform_data cm_x300_mci_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800460 .detect_delay_ms = 200,
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200461 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
462 .gpio_card_detect = GPIO82_MMC_IRQ,
463 .gpio_card_ro = GPIO85_MMC_WP,
464 .gpio_power = -1,
465};
466
467/* The second MMC slot of CM-X300 is hardwired to Libertas card and has
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100468 no detection/ro pins */
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200469static int cm_x300_mci2_init(struct device *dev,
470 irq_handler_t cm_x300_detect_int,
471 void *data)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100472{
473 return 0;
474}
475
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200476static void cm_x300_mci2_exit(struct device *dev, void *data)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100477{
478}
479
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100480static struct pxamci_platform_data cm_x300_mci2_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800481 .detect_delay_ms = 200,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200482 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
Mike Rapoport0bff2fc2009-10-15 10:11:09 +0200483 .init = cm_x300_mci2_init,
484 .exit = cm_x300_mci2_exit,
485 .gpio_card_detect = -1,
486 .gpio_card_ro = -1,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200487 .gpio_power = -1,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100488};
489
490static void __init cm_x300_init_mmc(void)
491{
492 pxa_set_mci_info(&cm_x300_mci_platform_data);
493 pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data);
494}
495#else
496static inline void cm_x300_init_mmc(void) {}
497#endif
498
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300499#if defined(CONFIG_PXA310_ULPI)
500static struct clk *pout_clk;
501
502static int cm_x300_ulpi_phy_reset(void)
503{
504 int err;
505
506 /* reset the PHY */
Igor Grinberg5a009df2011-05-09 14:41:47 +0300507 err = gpio_request_one(GPIO_ULPI_PHY_RST, GPIOF_OUT_INIT_LOW,
508 "ulpi reset");
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300509 if (err) {
Igor Grinberg32de50e2011-05-09 14:41:48 +0300510 pr_err("failed to request ULPI reset GPIO: %d\n", err);
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300511 return err;
512 }
513
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300514 msleep(10);
515 gpio_set_value(GPIO_ULPI_PHY_RST, 1);
516 msleep(10);
517
518 gpio_free(GPIO_ULPI_PHY_RST);
519
520 return 0;
521}
522
Igor Grinberg69a90f42017-12-26 14:45:36 +0200523static int cm_x300_u2d_init(struct device *dev)
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300524{
525 int err = 0;
526
527 if (cpu_is_pxa310()) {
528 /* CLK_POUT is connected to the ULPI PHY */
529 pout_clk = clk_get(NULL, "CLK_POUT");
530 if (IS_ERR(pout_clk)) {
531 err = PTR_ERR(pout_clk);
Igor Grinberg32de50e2011-05-09 14:41:48 +0300532 pr_err("failed to get CLK_POUT: %d\n", err);
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300533 return err;
534 }
Igor Grinberg7a5d9a92017-12-26 15:32:53 +0200535 clk_prepare_enable(pout_clk);
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300536
537 err = cm_x300_ulpi_phy_reset();
538 if (err) {
539 clk_disable(pout_clk);
540 clk_put(pout_clk);
541 }
542 }
543
544 return err;
545}
546
547static void cm_x300_u2d_exit(struct device *dev)
548{
549 if (cpu_is_pxa310()) {
Igor Grinberg7a5d9a92017-12-26 15:32:53 +0200550 clk_disable_unprepare(pout_clk);
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300551 clk_put(pout_clk);
552 }
553}
554
555static struct pxa3xx_u2d_platform_data cm_x300_u2d_platform_data = {
556 .ulpi_mode = ULPI_SER_6PIN,
557 .init = cm_x300_u2d_init,
558 .exit = cm_x300_u2d_exit,
559};
560
Arnd Bergmann8b4116f2018-12-10 22:58:39 +0100561static void __init cm_x300_init_u2d(void)
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300562{
563 pxa3xx_set_u2d_info(&cm_x300_u2d_platform_data);
564}
565#else
566static inline void cm_x300_init_u2d(void) {}
567#endif
568
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100569#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
Igor Grinbergedaa64c2009-10-14 09:20:23 +0200570static int cm_x300_ohci_init(struct device *dev)
571{
572 if (cpu_is_pxa300())
573 UP2OCR = UP2OCR_HXS
574 | UP2OCR_HXOE | UP2OCR_DMPDE | UP2OCR_DPPDE;
575
576 return 0;
577}
578
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100579static struct pxaohci_platform_data cm_x300_ohci_platform_data = {
580 .port_mode = PMM_PERPORT_MODE,
Igor Grinbergedaa64c2009-10-14 09:20:23 +0200581 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW,
582 .init = cm_x300_ohci_init,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100583};
Eric Miao097b5332008-09-27 15:49:57 +0800584
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100585static void __init cm_x300_init_ohci(void)
586{
587 pxa_set_ohci_info(&cm_x300_ohci_platform_data);
588}
589#else
590static inline void cm_x300_init_ohci(void) {}
591#endif
592
593#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
594static struct gpio_led cm_x300_leds[] = {
595 [0] = {
596 .name = "cm-x300:green",
597 .default_trigger = "heartbeat",
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100598 .active_low = 1,
599 },
600};
601
602static struct gpio_led_platform_data cm_x300_gpio_led_pdata = {
603 .num_leds = ARRAY_SIZE(cm_x300_leds),
604 .leds = cm_x300_leds,
605};
606
607static struct platform_device cm_x300_led_device = {
608 .name = "leds-gpio",
609 .id = -1,
610 .dev = {
611 .platform_data = &cm_x300_gpio_led_pdata,
612 },
613};
614
615static void __init cm_x300_init_leds(void)
616{
Igor Grinberg55052ea2009-10-14 09:20:18 +0200617 if (system_rev < 130)
618 cm_x300_leds[0].gpio = 79;
619 else
620 cm_x300_leds[0].gpio = 76;
621
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100622 platform_device_register(&cm_x300_led_device);
623}
624#else
625static inline void cm_x300_init_leds(void) {}
626#endif
627
628#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
629/* PCA9555 */
630static struct pca953x_platform_data cm_x300_gpio_ext_pdata_0 = {
631 .gpio_base = 128,
632};
633
634static struct pca953x_platform_data cm_x300_gpio_ext_pdata_1 = {
635 .gpio_base = 144,
636};
637
638static struct i2c_board_info cm_x300_gpio_ext_info[] = {
639 [0] = {
640 I2C_BOARD_INFO("pca9555", 0x24),
641 .platform_data = &cm_x300_gpio_ext_pdata_0,
642 },
643 [1] = {
644 I2C_BOARD_INFO("pca9555", 0x25),
645 .platform_data = &cm_x300_gpio_ext_pdata_1,
646 },
647};
648
649static void __init cm_x300_init_i2c(void)
650{
651 pxa_set_i2c_info(NULL);
652 i2c_register_board_info(0, cm_x300_gpio_ext_info,
653 ARRAY_SIZE(cm_x300_gpio_ext_info));
654}
655#else
656static inline void cm_x300_init_i2c(void) {}
657#endif
658
Mike Rapoport1858ced2009-06-04 10:44:52 +0300659#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
660struct v3020_platform_data cm_x300_v3020_pdata = {
661 .use_gpio = 1,
662 .gpio_cs = GPIO95_RTC_CS,
663 .gpio_wr = GPIO96_RTC_WR,
664 .gpio_rd = GPIO97_RTC_RD,
665 .gpio_io = GPIO98_RTC_IO,
666};
667
668static struct platform_device cm_x300_rtc_device = {
669 .name = "v3020",
670 .id = -1,
671 .dev = {
672 .platform_data = &cm_x300_v3020_pdata,
673 }
674};
675
676static void __init cm_x300_init_rtc(void)
677{
678 platform_device_register(&cm_x300_rtc_device);
679}
680#else
681static inline void cm_x300_init_rtc(void) {}
682#endif
683
Igor Grinberg03ba7e02010-03-09 11:43:48 +0200684/* Battery */
685struct power_supply_info cm_x300_psy_info = {
686 .name = "battery",
687 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
688 .voltage_max_design = 4200000,
689 .voltage_min_design = 3000000,
690 .use_for_apm = 1,
691};
692
693static void cm_x300_battery_low(void)
694{
695#if defined(CONFIG_APM_EMULATION)
696 apm_queue_event(APM_LOW_BATTERY);
697#endif
698}
699
700static void cm_x300_battery_critical(void)
701{
702#if defined(CONFIG_APM_EMULATION)
703 apm_queue_event(APM_CRITICAL_SUSPEND);
704#endif
705}
706
707struct da9030_battery_info cm_x300_battery_info = {
708 .battery_info = &cm_x300_psy_info,
709
710 .charge_milliamp = 1000,
711 .charge_millivolt = 4200,
712
713 .vbat_low = 3600,
714 .vbat_crit = 3400,
715 .vbat_charge_start = 4100,
716 .vbat_charge_stop = 4200,
717 .vbat_charge_restart = 4000,
718
719 .vcharge_min = 3200,
720 .vcharge_max = 5500,
721
722 .tbat_low = 197,
723 .tbat_high = 78,
724 .tbat_restart = 100,
725
726 .batmon_interval = 0,
727
728 .battery_low = cm_x300_battery_low,
729 .battery_critical = cm_x300_battery_critical,
730};
731
Igor Grinbergd176d642010-03-09 11:43:51 +0200732static struct regulator_consumer_supply buck2_consumers[] = {
Axel Lin0bf189a2012-05-08 16:25:10 +0800733 REGULATOR_SUPPLY("vcc_core", NULL),
Igor Grinbergd176d642010-03-09 11:43:51 +0200734};
735
736static struct regulator_init_data buck2_data = {
737 .constraints = {
738 .min_uV = 1375000,
739 .max_uV = 1375000,
740 .state_mem = {
741 .enabled = 0,
742 },
743 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
744 .apply_uV = 1,
745 },
746 .num_consumer_supplies = ARRAY_SIZE(buck2_consumers),
747 .consumer_supplies = buck2_consumers,
748};
749
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200750/* DA9030 */
751struct da903x_subdev_info cm_x300_da9030_subdevs[] = {
752 {
Igor Grinberg03ba7e02010-03-09 11:43:48 +0200753 .name = "da903x-battery",
754 .id = DA9030_ID_BAT,
755 .platform_data = &cm_x300_battery_info,
756 },
Igor Grinbergd176d642010-03-09 11:43:51 +0200757 {
758 .name = "da903x-regulator",
759 .id = DA9030_ID_BUCK2,
760 .platform_data = &buck2_data,
761 },
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200762};
763
764static struct da903x_platform_data cm_x300_da9030_info = {
765 .num_subdevs = ARRAY_SIZE(cm_x300_da9030_subdevs),
766 .subdevs = cm_x300_da9030_subdevs,
767};
768
769static struct i2c_board_info cm_x300_pmic_info = {
770 I2C_BOARD_INFO("da9030", 0x49),
Igor Grinberge4e30972010-03-09 11:43:50 +0200771 .irq = IRQ_WAKEUP0,
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200772 .platform_data = &cm_x300_da9030_info,
773};
774
775static struct i2c_pxa_platform_data cm_x300_pwr_i2c_info = {
776 .use_pio = 1,
777};
778
779static void __init cm_x300_init_da9030(void)
780{
781 pxa3xx_set_i2c_power_info(&cm_x300_pwr_i2c_info);
782 i2c_register_board_info(1, &cm_x300_pmic_info, 1);
Thomas Gleixner6845664a2011-03-24 13:25:22 +0100783 irq_set_irq_wake(IRQ_WAKEUP0, 1);
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200784}
785
Igor Grinberg5a009df2011-05-09 14:41:47 +0300786/* wi2wi gpio setting for system_rev >= 130 */
787static struct gpio cm_x300_wi2wi_gpios[] __initdata = {
788 { 71, GPIOF_OUT_INIT_HIGH, "wlan en" },
789 { 70, GPIOF_OUT_INIT_HIGH, "bt reset" },
790};
791
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200792static void __init cm_x300_init_wi2wi(void)
793{
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200794 int err;
795
796 if (system_rev < 130) {
Igor Grinberg5a009df2011-05-09 14:41:47 +0300797 cm_x300_wi2wi_gpios[0].gpio = 77; /* wlan en */
798 cm_x300_wi2wi_gpios[1].gpio = 78; /* bt reset */
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200799 }
800
801 /* Libertas and CSR reset */
Igor Grinberg5a009df2011-05-09 14:41:47 +0300802 err = gpio_request_array(ARRAY_AND_SIZE(cm_x300_wi2wi_gpios));
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200803 if (err) {
Igor Grinberg32de50e2011-05-09 14:41:48 +0300804 pr_err("failed to request wifi/bt gpios: %d\n", err);
Igor Grinberg5a009df2011-05-09 14:41:47 +0300805 return;
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200806 }
807
Igor Grinberg5a009df2011-05-09 14:41:47 +0300808 udelay(10);
Axel Lin1a642002011-09-17 22:15:34 +0800809 gpio_set_value(cm_x300_wi2wi_gpios[1].gpio, 0);
Igor Grinberg5a009df2011-05-09 14:41:47 +0300810 udelay(10);
Axel Lin1a642002011-09-17 22:15:34 +0800811 gpio_set_value(cm_x300_wi2wi_gpios[1].gpio, 1);
Igor Grinberg5a009df2011-05-09 14:41:47 +0300812
Axel Lin1a642002011-09-17 22:15:34 +0800813 gpio_free_array(ARRAY_AND_SIZE(cm_x300_wi2wi_gpios));
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200814}
815
816/* MFP */
Igor Grinberg55052ea2009-10-14 09:20:18 +0200817static void __init cm_x300_init_mfp(void)
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100818{
819 /* board-processor specific GPIO initialization */
Igor Grinbergdef82522009-10-14 09:20:22 +0200820 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_mfp_cfg));
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100821
Igor Grinberg55052ea2009-10-14 09:20:18 +0200822 if (system_rev < 130)
Igor Grinbergdef82522009-10-14 09:20:22 +0200823 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_lt130_mfp_cfg));
Igor Grinberg55052ea2009-10-14 09:20:18 +0200824 else
Igor Grinbergdef82522009-10-14 09:20:22 +0200825 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x3xx_rev_ge130_mfp_cfg));
826
827 if (cpu_is_pxa310())
828 pxa3xx_mfp_config(ARRAY_AND_SIZE(cm_x310_mfp_cfg));
Igor Grinberg55052ea2009-10-14 09:20:18 +0200829}
830
831static void __init cm_x300_init(void)
832{
833 cm_x300_init_mfp();
834
Russell Kingcc155c62009-11-09 13:34:08 +0800835 pxa_set_btuart_info(NULL);
836 pxa_set_stuart_info(NULL);
Igor Grinberga6cd7eb2010-07-20 10:58:52 +0300837 if (cpu_is_pxa300())
838 pxa_set_ffuart_info(NULL);
Russell Kingcc155c62009-11-09 13:34:08 +0800839
Igor Grinberg9c017ca2009-10-14 09:20:24 +0200840 cm_x300_init_da9030();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100841 cm_x300_init_dm9000();
842 cm_x300_init_lcd();
Igor Grinberg1b43d8e2010-07-27 15:07:00 +0300843 cm_x300_init_u2d();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100844 cm_x300_init_ohci();
845 cm_x300_init_mmc();
846 cm_x300_init_nand();
847 cm_x300_init_leds();
848 cm_x300_init_i2c();
Igor Grinberg83e560e2009-10-14 09:20:19 +0200849 cm_x300_init_spi();
Mike Rapoport1858ced2009-06-04 10:44:52 +0300850 cm_x300_init_rtc();
Igor Grinberg74e74de2009-10-14 09:20:20 +0200851 cm_x300_init_ac97();
Igor Grinbergb3d01da2009-10-14 09:20:21 +0200852 cm_x300_init_wi2wi();
Igor Grinbergdb205462009-11-10 14:18:41 +0200853 cm_x300_init_bl();
Robert Jarzmika927ef82015-07-11 21:33:06 +0200854
855 regulator_has_full_constraints();
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100856}
857
Laura Abbott1c2f87c2014-04-13 22:54:58 +0100858static void __init cm_x300_fixup(struct tag *tags, char **cmdline)
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300859{
Igor Grinberg81880972010-03-09 11:43:52 +0200860 /* Make sure that mi->bank[0].start = PHYS_ADDR */
861 for (; tags->hdr.size; tags = tag_next(tags))
862 if (tags->hdr.tag == ATAG_MEM &&
863 tags->u.mem.start == 0x80000000) {
864 tags->u.mem.start = 0xa0000000;
865 break;
866 }
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300867}
868
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100869MACHINE_START(CM_X300, "CM-X300 module")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400870 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +0200871 .map_io = pxa3xx_map_io,
Rob Herring4e611092012-01-03 16:53:48 -0600872 .nr_irqs = PXA_NR_IRQS,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100873 .init_irq = pxa3xx_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800874 .handle_irq = pxa3xx_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700875 .init_time = pxa_timer_init,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100876 .init_machine = cm_x300_init,
Mike Rapoportb5a5c472009-06-04 10:44:54 +0300877 .fixup = cm_x300_fixup,
Russell King271a74f2011-11-04 14:15:53 +0000878 .restart = pxa_restart,
Mike Rapoportcf75d8d2008-08-26 14:03:44 +0100879MACHINE_END