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