blob: d69de312d8d91a432d5652428cdfc3808ff760e6 [file] [log] [blame]
eric miao2c8086a2007-09-11 19:13:17 -07001/*
2 * linux/arch/arm/mach-pxa/zylonite.c
3 *
4 * Support for the PXA3xx Development Platform (aka Zylonite)
5 *
6 * Copyright (C) 2006 Marvell International Ltd.
7 *
eric miaoe9bba8e2007-10-30 08:01:38 +01008 * 2007-09-04: eric miao <eric.miao@marvell.com>
eric miao2c8086a2007-09-11 19:13:17 -07009 * rewrite to align with latest kernel
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/interrupt.h>
Ulf Hansson40d727a2017-01-13 14:14:02 +010019#include <linux/leds.h>
eric miao2c8086a2007-09-11 19:13:17 -070020#include <linux/init.h>
21#include <linux/platform_device.h>
Eric Miao80796f22008-11-25 11:03:03 +080022#include <linux/gpio.h>
Thierry Reding6f26f6f2015-10-05 10:49:57 +020023#include <linux/pwm.h>
eric miao5cca9142008-04-13 21:46:34 +010024#include <linux/pwm_backlight.h>
Eric Miao88c36eb2008-06-24 16:47:37 +080025#include <linux/smc91x.h>
eric miao2c8086a2007-09-11 19:13:17 -070026
27#include <asm/mach-types.h>
28#include <asm/mach/arch.h>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010029#include "pxa3xx.h"
Russell Kinga09e64f2008-08-05 16:14:15 +010030#include <mach/audio.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020031#include <linux/platform_data/video-pxafb.h>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010032#include "zylonite.h"
Arnd Bergmann293b2da2012-08-24 15:16:48 +020033#include <linux/platform_data/mmc-pxamci.h>
34#include <linux/platform_data/usb-ohci-pxa27x.h>
35#include <linux/platform_data/keypad-pxa27x.h>
36#include <linux/platform_data/mtd-nand-pxa3xx.h>
eric miao2c8086a2007-09-11 19:13:17 -070037
eric miao5cca9142008-04-13 21:46:34 +010038#include "devices.h"
eric miao2c8086a2007-09-11 19:13:17 -070039#include "generic.h"
40
eric miao2c8086a2007-09-11 19:13:17 -070041int gpio_eth_irq;
Eric Miao5c9f50e2008-06-17 19:03:54 +080042int gpio_debug_led1;
43int gpio_debug_led2;
eric miao2c8086a2007-09-11 19:13:17 -070044
Mark Brown768dec42008-04-15 15:50:49 +010045int wm9713_irq;
46
eric miao2c8086a2007-09-11 19:13:17 -070047int lcd_id;
48int lcd_orientation;
49
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000050struct platform_device pxa_device_wm9713_audio = {
51 .name = "wm9713-codec",
52 .id = -1,
53};
54
55static void __init zylonite_init_wm9713_audio(void)
56{
57 platform_device_register(&pxa_device_wm9713_audio);
58}
59
eric miao2c8086a2007-09-11 19:13:17 -070060static struct resource smc91x_resources[] = {
61 [0] = {
62 .start = ZYLONITE_ETH_PHYS + 0x300,
63 .end = ZYLONITE_ETH_PHYS + 0xfffff,
64 .flags = IORESOURCE_MEM,
65 },
66 [1] = {
67 .start = -1, /* for run-time assignment */
68 .end = -1,
Russell Kinge7b3dc72008-01-14 22:30:10 +000069 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
eric miao2c8086a2007-09-11 19:13:17 -070070 }
71};
72
Eric Miao88c36eb2008-06-24 16:47:37 +080073static struct smc91x_platdata zylonite_smc91x_info = {
74 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT |
75 SMC91X_NOWAIT | SMC91X_USE_DMA,
76};
77
eric miao2c8086a2007-09-11 19:13:17 -070078static struct platform_device smc91x_device = {
79 .name = "smc91x",
80 .id = 0,
81 .num_resources = ARRAY_SIZE(smc91x_resources),
82 .resource = smc91x_resources,
Eric Miao88c36eb2008-06-24 16:47:37 +080083 .dev = {
84 .platform_data = &zylonite_smc91x_info,
85 },
eric miao2c8086a2007-09-11 19:13:17 -070086};
87
Eric Miao5c9f50e2008-06-17 19:03:54 +080088#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
89static struct gpio_led zylonite_debug_leds[] = {
90 [0] = {
91 .name = "zylonite:yellow:1",
92 .default_trigger = "heartbeat",
93 },
94 [1] = {
95 .name = "zylonite:yellow:2",
96 .default_trigger = "default-on",
97 },
98};
99
100static struct gpio_led_platform_data zylonite_debug_leds_info = {
101 .leds = zylonite_debug_leds,
102 .num_leds = ARRAY_SIZE(zylonite_debug_leds),
103};
104
105static struct platform_device zylonite_device_leds = {
106 .name = "leds-gpio",
107 .id = -1,
108 .dev = {
109 .platform_data = &zylonite_debug_leds_info,
110 }
111};
112
113static void __init zylonite_init_leds(void)
114{
115 zylonite_debug_leds[0].gpio = gpio_debug_led1;
116 zylonite_debug_leds[1].gpio = gpio_debug_led2;
117
118 platform_device_register(&zylonite_device_leds);
119}
120#else
121static inline void zylonite_init_leds(void) {}
122#endif
123
eric miao7a987e82008-02-27 02:00:26 +0100124#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
Thierry Reding6f26f6f2015-10-05 10:49:57 +0200125static struct pwm_lookup zylonite_pwm_lookup[] = {
126 PWM_LOOKUP("pxa27x-pwm.1", 1, "pwm-backlight.0", NULL, 10000,
127 PWM_POLARITY_NORMAL),
128};
129
eric miao5cca9142008-04-13 21:46:34 +0100130static struct platform_pwm_backlight_data zylonite_backlight_data = {
eric miao5cca9142008-04-13 21:46:34 +0100131 .max_brightness = 100,
132 .dft_brightness = 100,
Thierry Redingdb011202013-08-30 12:15:24 +0200133 .enable_gpio = -1,
eric miao5cca9142008-04-13 21:46:34 +0100134};
135
136static struct platform_device zylonite_backlight_device = {
137 .name = "pwm-backlight",
138 .dev = {
139 .parent = &pxa27x_device_pwm1.dev,
140 .platform_data = &zylonite_backlight_data,
141 },
142};
eric miao2c8086a2007-09-11 19:13:17 -0700143
144static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
145 .pixclock = 110000,
146 .xres = 240,
147 .yres = 320,
148 .bpp = 16,
149 .hsync_len = 4,
150 .left_margin = 6,
151 .right_margin = 4,
152 .vsync_len = 2,
153 .upper_margin = 2,
154 .lower_margin = 3,
155 .sync = FB_SYNC_VERT_HIGH_ACT,
156};
157
158static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
159 .pixclock = 50000,
160 .xres = 640,
161 .yres = 480,
162 .bpp = 16,
163 .hsync_len = 1,
164 .left_margin = 0x9f,
165 .right_margin = 1,
166 .vsync_len = 44,
167 .upper_margin = 0,
168 .lower_margin = 0,
169 .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
170};
171
172static struct pxafb_mach_info zylonite_toshiba_lcd_info = {
173 .num_modes = 1,
eric miao0454bd02008-04-30 00:52:23 -0700174 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
eric miao2c8086a2007-09-11 19:13:17 -0700175};
176
177static struct pxafb_mode_info sharp_ls037_modes[] = {
178 [0] = {
179 .pixclock = 158000,
180 .xres = 240,
181 .yres = 320,
182 .bpp = 16,
183 .hsync_len = 4,
184 .left_margin = 39,
185 .right_margin = 39,
186 .vsync_len = 1,
187 .upper_margin = 2,
188 .lower_margin = 3,
189 .sync = 0,
190 },
191 [1] = {
192 .pixclock = 39700,
193 .xres = 480,
194 .yres = 640,
195 .bpp = 16,
196 .hsync_len = 8,
197 .left_margin = 81,
198 .right_margin = 81,
199 .vsync_len = 1,
200 .upper_margin = 2,
201 .lower_margin = 7,
202 .sync = 0,
203 },
204};
205
206static struct pxafb_mach_info zylonite_sharp_lcd_info = {
207 .modes = sharp_ls037_modes,
208 .num_modes = 2,
eric miao0454bd02008-04-30 00:52:23 -0700209 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
eric miao2c8086a2007-09-11 19:13:17 -0700210};
211
212static void __init zylonite_init_lcd(void)
213{
Thierry Reding6f26f6f2015-10-05 10:49:57 +0200214 pwm_add_table(zylonite_pwm_lookup, ARRAY_SIZE(zylonite_pwm_lookup));
eric miao5cca9142008-04-13 21:46:34 +0100215 platform_device_register(&zylonite_backlight_device);
eric miao2c8086a2007-09-11 19:13:17 -0700216
217 if (lcd_id & 0x20) {
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800218 pxa_set_fb_info(NULL, &zylonite_sharp_lcd_info);
eric miao2c8086a2007-09-11 19:13:17 -0700219 return;
220 }
221
222 /* legacy LCD panels, it would be handy here if LCD panel type can
223 * be decided at run-time
224 */
225 if (1)
226 zylonite_toshiba_lcd_info.modes = &toshiba_ltm035a776c_mode;
227 else
228 zylonite_toshiba_lcd_info.modes = &toshiba_ltm04c380k_mode;
229
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800230 pxa_set_fb_info(NULL, &zylonite_toshiba_lcd_info);
eric miao2c8086a2007-09-11 19:13:17 -0700231}
232#else
233static inline void zylonite_init_lcd(void) {}
234#endif
235
Bridge Wufafc9d32007-12-21 19:00:13 +0800236#if defined(CONFIG_MMC)
Bridge Wufafc9d32007-12-21 19:00:13 +0800237static struct pxamci_platform_data zylonite_mci_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800238 .detect_delay_ms= 200,
Bridge Wufafc9d32007-12-21 19:00:13 +0800239 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
Haojian Zhuangf91e4902009-12-22 07:29:40 -0500240 .gpio_card_detect = EXT_GPIO(0),
241 .gpio_card_ro = EXT_GPIO(2),
Robert Jarzmik7a648252009-07-06 22:16:42 +0200242 .gpio_power = -1,
Bridge Wufafc9d32007-12-21 19:00:13 +0800243};
244
Bridge Wu8d33b052007-12-21 19:15:36 +0800245static struct pxamci_platform_data zylonite_mci2_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800246 .detect_delay_ms= 200,
Bridge Wu8d33b052007-12-21 19:15:36 +0800247 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
Haojian Zhuangf91e4902009-12-22 07:29:40 -0500248 .gpio_card_detect = EXT_GPIO(1),
249 .gpio_card_ro = EXT_GPIO(3),
250 .gpio_power = -1,
251};
252
253static struct pxamci_platform_data zylonite_mci3_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800254 .detect_delay_ms= 200,
Haojian Zhuangf91e4902009-12-22 07:29:40 -0500255 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
256 .gpio_card_detect = EXT_GPIO(30),
257 .gpio_card_ro = EXT_GPIO(31),
258 .gpio_power = -1,
Bridge Wu8d33b052007-12-21 19:15:36 +0800259};
260
Bridge Wufafc9d32007-12-21 19:00:13 +0800261static void __init zylonite_init_mmc(void)
262{
263 pxa_set_mci_info(&zylonite_mci_platform_data);
Bridge Wu8d33b052007-12-21 19:15:36 +0800264 pxa3xx_set_mci2_info(&zylonite_mci2_platform_data);
Bridge Wu5a1f21b2007-12-21 19:27:08 +0800265 if (cpu_is_pxa310())
Haojian Zhuangf91e4902009-12-22 07:29:40 -0500266 pxa3xx_set_mci3_info(&zylonite_mci3_platform_data);
Bridge Wufafc9d32007-12-21 19:00:13 +0800267}
268#else
269static inline void zylonite_init_mmc(void) {}
270#endif
271
Eric Miao36caeb42008-06-02 13:32:42 +0800272#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
Chao Xie0a085a92013-05-05 20:24:58 -0700273static const unsigned int zylonite_matrix_key_map[] = {
eric miao468e0862008-01-23 14:25:50 +0800274 /* KEY(row, col, key_code) */
275 KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_C), KEY(0, 5, KEY_D),
276 KEY(1, 0, KEY_E), KEY(1, 1, KEY_F), KEY(1, 2, KEY_G), KEY(1, 5, KEY_H),
277 KEY(2, 0, KEY_I), KEY(2, 1, KEY_J), KEY(2, 2, KEY_K), KEY(2, 5, KEY_L),
278 KEY(3, 0, KEY_M), KEY(3, 1, KEY_N), KEY(3, 2, KEY_O), KEY(3, 5, KEY_P),
279 KEY(5, 0, KEY_Q), KEY(5, 1, KEY_R), KEY(5, 2, KEY_S), KEY(5, 5, KEY_T),
280 KEY(6, 0, KEY_U), KEY(6, 1, KEY_V), KEY(6, 2, KEY_W), KEY(6, 5, KEY_X),
281 KEY(7, 1, KEY_Y), KEY(7, 2, KEY_Z),
282
283 KEY(4, 4, KEY_0), KEY(1, 3, KEY_1), KEY(4, 1, KEY_2), KEY(1, 4, KEY_3),
284 KEY(2, 3, KEY_4), KEY(4, 2, KEY_5), KEY(2, 4, KEY_6), KEY(3, 3, KEY_7),
285 KEY(4, 3, KEY_8), KEY(3, 4, KEY_9),
286
287 KEY(4, 5, KEY_SPACE),
288 KEY(5, 3, KEY_KPASTERISK), /* * */
289 KEY(5, 4, KEY_KPDOT), /* #" */
290
291 KEY(0, 7, KEY_UP),
292 KEY(1, 7, KEY_DOWN),
293 KEY(2, 7, KEY_LEFT),
294 KEY(3, 7, KEY_RIGHT),
295 KEY(2, 6, KEY_HOME),
296 KEY(3, 6, KEY_END),
297 KEY(6, 4, KEY_DELETE),
298 KEY(6, 6, KEY_BACK),
299 KEY(6, 3, KEY_CAPSLOCK), /* KEY_LEFTSHIFT), */
300
301 KEY(4, 6, KEY_ENTER), /* scroll push */
302 KEY(5, 7, KEY_ENTER), /* keypad action */
303
304 KEY(0, 4, KEY_EMAIL),
305 KEY(5, 6, KEY_SEND),
306 KEY(4, 0, KEY_CALENDAR),
307 KEY(7, 6, KEY_RECORD),
308 KEY(6, 7, KEY_VOLUMEUP),
309 KEY(7, 7, KEY_VOLUMEDOWN),
310
311 KEY(0, 6, KEY_F22), /* soft1 */
312 KEY(1, 6, KEY_F23), /* soft2 */
313 KEY(0, 3, KEY_AUX), /* contact */
314};
315
Chao Xie0a085a92013-05-05 20:24:58 -0700316static struct matrix_keymap_data zylonite_matrix_keymap_data = {
317 .keymap = zylonite_matrix_key_map,
318 .keymap_size = ARRAY_SIZE(zylonite_matrix_key_map),
319};
320
eric miao468e0862008-01-23 14:25:50 +0800321static struct pxa27x_keypad_platform_data zylonite_keypad_info = {
322 .matrix_key_rows = 8,
323 .matrix_key_cols = 8,
Chao Xie0a085a92013-05-05 20:24:58 -0700324 .matrix_keymap_data = &zylonite_matrix_keymap_data,
eric miao468e0862008-01-23 14:25:50 +0800325
326 .enable_rotary0 = 1,
327 .rotary0_up_key = KEY_UP,
328 .rotary0_down_key = KEY_DOWN,
329
330 .debounce_interval = 30,
331};
332
333static void __init zylonite_init_keypad(void)
334{
335 pxa_set_keypad_info(&zylonite_keypad_info);
336}
337#else
338static inline void zylonite_init_keypad(void) {}
339#endif
340
Miquel Raynal349dfe62018-02-19 23:35:52 +0100341#if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
Eric Miao481b5522008-06-02 15:37:20 +0800342static struct mtd_partition zylonite_nand_partitions[] = {
343 [0] = {
344 .name = "Bootloader",
345 .offset = 0,
346 .size = 0x060000,
347 .mask_flags = MTD_WRITEABLE, /* force read-only */
348 },
349 [1] = {
350 .name = "Kernel",
351 .offset = 0x060000,
352 .size = 0x200000,
353 .mask_flags = MTD_WRITEABLE, /* force read-only */
354 },
355 [2] = {
356 .name = "Filesystem",
357 .offset = 0x0260000,
358 .size = 0x3000000, /* 48M - rootfs */
359 },
360 [3] = {
361 .name = "MassStorage",
362 .offset = 0x3260000,
363 .size = 0x3d40000,
364 },
365 [4] = {
366 .name = "BBT",
367 .offset = 0x6FA0000,
368 .size = 0x80000,
369 .mask_flags = MTD_WRITEABLE, /* force read-only */
370 },
371 /* NOTE: we reserve some blocks at the end of the NAND flash for
372 * bad block management, and the max number of relocation blocks
373 * differs on different platforms. Please take care with it when
374 * defining the partition table.
375 */
376};
377
378static struct pxa3xx_nand_platform_data zylonite_nand_info = {
Miquel Raynal75765942018-02-19 23:35:54 +0100379 .parts = zylonite_nand_partitions,
380 .nr_parts = ARRAY_SIZE(zylonite_nand_partitions),
Eric Miao481b5522008-06-02 15:37:20 +0800381};
382
383static void __init zylonite_init_nand(void)
384{
385 pxa3xx_set_nand_info(&zylonite_nand_info);
386}
387#else
388static inline void zylonite_init_nand(void) {}
Miquel Raynal349dfe62018-02-19 23:35:52 +0100389#endif /* IS_ENABLED(CONFIG_MTD_NAND_MARVELL) */
Eric Miao481b5522008-06-02 15:37:20 +0800390
Eric Miao7ff43532008-09-27 18:05:49 +0800391#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
392static struct pxaohci_platform_data zylonite_ohci_info = {
393 .port_mode = PMM_PERPORT_MODE,
394 .flags = ENABLE_PORT1 | ENABLE_PORT2 |
395 POWER_CONTROL_LOW | POWER_SENSE_LOW,
396};
397
398static void __init zylonite_init_ohci(void)
399{
400 pxa_set_ohci_info(&zylonite_ohci_info);
401}
402#else
403static inline void zylonite_init_ohci(void) {}
404#endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */
405
eric miao2c8086a2007-09-11 19:13:17 -0700406static void __init zylonite_init(void)
407{
Russell Kingcc155c62009-11-09 13:34:08 +0800408 pxa_set_ffuart_info(NULL);
409 pxa_set_btuart_info(NULL);
410 pxa_set_stuart_info(NULL);
411
eric miao2c8086a2007-09-11 19:13:17 -0700412 /* board-processor specific initialization */
413 zylonite_pxa300_init();
414 zylonite_pxa320_init();
415
416 /*
417 * Note: We depend that the bootloader set
418 * the correct value to MSC register for SMC91x.
419 */
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800420 smc91x_resources[1].start = PXA_GPIO_TO_IRQ(gpio_eth_irq);
421 smc91x_resources[1].end = PXA_GPIO_TO_IRQ(gpio_eth_irq);
eric miao2c8086a2007-09-11 19:13:17 -0700422 platform_device_register(&smc91x_device);
423
Mark Browncabb3522008-06-10 10:48:25 +0100424 pxa_set_ac97_info(NULL);
eric miao2c8086a2007-09-11 19:13:17 -0700425 zylonite_init_lcd();
Bridge Wufafc9d32007-12-21 19:00:13 +0800426 zylonite_init_mmc();
eric miao468e0862008-01-23 14:25:50 +0800427 zylonite_init_keypad();
Eric Miao481b5522008-06-02 15:37:20 +0800428 zylonite_init_nand();
Eric Miao5c9f50e2008-06-17 19:03:54 +0800429 zylonite_init_leds();
Eric Miao7ff43532008-09-27 18:05:49 +0800430 zylonite_init_ohci();
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000431 zylonite_init_wm9713_audio();
eric miao2c8086a2007-09-11 19:13:17 -0700432}
433
434MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400435 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +0200436 .map_io = pxa3xx_map_io,
Haojian Zhuang6ac6b812010-08-20 15:23:59 +0800437 .nr_irqs = ZYLONITE_NR_IRQS,
eric miao2c8086a2007-09-11 19:13:17 -0700438 .init_irq = pxa3xx_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800439 .handle_irq = pxa3xx_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700440 .init_time = pxa_timer_init,
eric miao2c8086a2007-09-11 19:13:17 -0700441 .init_machine = zylonite_init,
Russell King271a74f2011-11-04 14:15:53 +0000442 .restart = pxa_restart,
eric miao2c8086a2007-09-11 19:13:17 -0700443MACHINE_END