blob: 77daea478e88709aa20568d30073ae3c625efa73 [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>
19#include <linux/init.h>
20#include <linux/platform_device.h>
Eric Miao80796f22008-11-25 11:03:03 +080021#include <linux/gpio.h>
eric miao5cca9142008-04-13 21:46:34 +010022#include <linux/pwm_backlight.h>
Eric Miao88c36eb2008-06-24 16:47:37 +080023#include <linux/smc91x.h>
eric miao2c8086a2007-09-11 19:13:17 -070024
25#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
Eric Miaoca0e6872011-05-18 21:19:04 +080027#include <mach/pxa3xx.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010028#include <mach/audio.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020029#include <linux/platform_data/video-pxafb.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010030#include <mach/zylonite.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020031#include <linux/platform_data/mmc-pxamci.h>
32#include <linux/platform_data/usb-ohci-pxa27x.h>
33#include <linux/platform_data/keypad-pxa27x.h>
34#include <linux/platform_data/mtd-nand-pxa3xx.h>
eric miao2c8086a2007-09-11 19:13:17 -070035
eric miao5cca9142008-04-13 21:46:34 +010036#include "devices.h"
eric miao2c8086a2007-09-11 19:13:17 -070037#include "generic.h"
38
eric miao2c8086a2007-09-11 19:13:17 -070039int gpio_eth_irq;
Eric Miao5c9f50e2008-06-17 19:03:54 +080040int gpio_debug_led1;
41int gpio_debug_led2;
eric miao2c8086a2007-09-11 19:13:17 -070042
Mark Brown768dec42008-04-15 15:50:49 +010043int wm9713_irq;
44
eric miao2c8086a2007-09-11 19:13:17 -070045int lcd_id;
46int lcd_orientation;
47
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000048struct platform_device pxa_device_wm9713_audio = {
49 .name = "wm9713-codec",
50 .id = -1,
51};
52
53static void __init zylonite_init_wm9713_audio(void)
54{
55 platform_device_register(&pxa_device_wm9713_audio);
56}
57
eric miao2c8086a2007-09-11 19:13:17 -070058static struct resource smc91x_resources[] = {
59 [0] = {
60 .start = ZYLONITE_ETH_PHYS + 0x300,
61 .end = ZYLONITE_ETH_PHYS + 0xfffff,
62 .flags = IORESOURCE_MEM,
63 },
64 [1] = {
65 .start = -1, /* for run-time assignment */
66 .end = -1,
Russell Kinge7b3dc72008-01-14 22:30:10 +000067 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
eric miao2c8086a2007-09-11 19:13:17 -070068 }
69};
70
Eric Miao88c36eb2008-06-24 16:47:37 +080071static struct smc91x_platdata zylonite_smc91x_info = {
72 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT |
73 SMC91X_NOWAIT | SMC91X_USE_DMA,
74};
75
eric miao2c8086a2007-09-11 19:13:17 -070076static struct platform_device smc91x_device = {
77 .name = "smc91x",
78 .id = 0,
79 .num_resources = ARRAY_SIZE(smc91x_resources),
80 .resource = smc91x_resources,
Eric Miao88c36eb2008-06-24 16:47:37 +080081 .dev = {
82 .platform_data = &zylonite_smc91x_info,
83 },
eric miao2c8086a2007-09-11 19:13:17 -070084};
85
Eric Miao5c9f50e2008-06-17 19:03:54 +080086#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
87static struct gpio_led zylonite_debug_leds[] = {
88 [0] = {
89 .name = "zylonite:yellow:1",
90 .default_trigger = "heartbeat",
91 },
92 [1] = {
93 .name = "zylonite:yellow:2",
94 .default_trigger = "default-on",
95 },
96};
97
98static struct gpio_led_platform_data zylonite_debug_leds_info = {
99 .leds = zylonite_debug_leds,
100 .num_leds = ARRAY_SIZE(zylonite_debug_leds),
101};
102
103static struct platform_device zylonite_device_leds = {
104 .name = "leds-gpio",
105 .id = -1,
106 .dev = {
107 .platform_data = &zylonite_debug_leds_info,
108 }
109};
110
111static void __init zylonite_init_leds(void)
112{
113 zylonite_debug_leds[0].gpio = gpio_debug_led1;
114 zylonite_debug_leds[1].gpio = gpio_debug_led2;
115
116 platform_device_register(&zylonite_device_leds);
117}
118#else
119static inline void zylonite_init_leds(void) {}
120#endif
121
eric miao7a987e82008-02-27 02:00:26 +0100122#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
eric miao5cca9142008-04-13 21:46:34 +0100123static struct platform_pwm_backlight_data zylonite_backlight_data = {
124 .pwm_id = 3,
125 .max_brightness = 100,
126 .dft_brightness = 100,
127 .pwm_period_ns = 10000,
Thierry Redingdb011202013-08-30 12:15:24 +0200128 .enable_gpio = -1,
eric miao5cca9142008-04-13 21:46:34 +0100129};
130
131static struct platform_device zylonite_backlight_device = {
132 .name = "pwm-backlight",
133 .dev = {
134 .parent = &pxa27x_device_pwm1.dev,
135 .platform_data = &zylonite_backlight_data,
136 },
137};
eric miao2c8086a2007-09-11 19:13:17 -0700138
139static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
140 .pixclock = 110000,
141 .xres = 240,
142 .yres = 320,
143 .bpp = 16,
144 .hsync_len = 4,
145 .left_margin = 6,
146 .right_margin = 4,
147 .vsync_len = 2,
148 .upper_margin = 2,
149 .lower_margin = 3,
150 .sync = FB_SYNC_VERT_HIGH_ACT,
151};
152
153static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
154 .pixclock = 50000,
155 .xres = 640,
156 .yres = 480,
157 .bpp = 16,
158 .hsync_len = 1,
159 .left_margin = 0x9f,
160 .right_margin = 1,
161 .vsync_len = 44,
162 .upper_margin = 0,
163 .lower_margin = 0,
164 .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
165};
166
167static struct pxafb_mach_info zylonite_toshiba_lcd_info = {
168 .num_modes = 1,
eric miao0454bd02008-04-30 00:52:23 -0700169 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
eric miao2c8086a2007-09-11 19:13:17 -0700170};
171
172static struct pxafb_mode_info sharp_ls037_modes[] = {
173 [0] = {
174 .pixclock = 158000,
175 .xres = 240,
176 .yres = 320,
177 .bpp = 16,
178 .hsync_len = 4,
179 .left_margin = 39,
180 .right_margin = 39,
181 .vsync_len = 1,
182 .upper_margin = 2,
183 .lower_margin = 3,
184 .sync = 0,
185 },
186 [1] = {
187 .pixclock = 39700,
188 .xres = 480,
189 .yres = 640,
190 .bpp = 16,
191 .hsync_len = 8,
192 .left_margin = 81,
193 .right_margin = 81,
194 .vsync_len = 1,
195 .upper_margin = 2,
196 .lower_margin = 7,
197 .sync = 0,
198 },
199};
200
201static struct pxafb_mach_info zylonite_sharp_lcd_info = {
202 .modes = sharp_ls037_modes,
203 .num_modes = 2,
eric miao0454bd02008-04-30 00:52:23 -0700204 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
eric miao2c8086a2007-09-11 19:13:17 -0700205};
206
207static void __init zylonite_init_lcd(void)
208{
eric miao5cca9142008-04-13 21:46:34 +0100209 platform_device_register(&zylonite_backlight_device);
eric miao2c8086a2007-09-11 19:13:17 -0700210
211 if (lcd_id & 0x20) {
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800212 pxa_set_fb_info(NULL, &zylonite_sharp_lcd_info);
eric miao2c8086a2007-09-11 19:13:17 -0700213 return;
214 }
215
216 /* legacy LCD panels, it would be handy here if LCD panel type can
217 * be decided at run-time
218 */
219 if (1)
220 zylonite_toshiba_lcd_info.modes = &toshiba_ltm035a776c_mode;
221 else
222 zylonite_toshiba_lcd_info.modes = &toshiba_ltm04c380k_mode;
223
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800224 pxa_set_fb_info(NULL, &zylonite_toshiba_lcd_info);
eric miao2c8086a2007-09-11 19:13:17 -0700225}
226#else
227static inline void zylonite_init_lcd(void) {}
228#endif
229
Bridge Wufafc9d32007-12-21 19:00:13 +0800230#if defined(CONFIG_MMC)
Bridge Wufafc9d32007-12-21 19:00:13 +0800231static struct pxamci_platform_data zylonite_mci_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800232 .detect_delay_ms= 200,
Bridge Wufafc9d32007-12-21 19:00:13 +0800233 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
Haojian Zhuangf91e4902009-12-22 07:29:40 -0500234 .gpio_card_detect = EXT_GPIO(0),
235 .gpio_card_ro = EXT_GPIO(2),
Robert Jarzmik7a648252009-07-06 22:16:42 +0200236 .gpio_power = -1,
Bridge Wufafc9d32007-12-21 19:00:13 +0800237};
238
Bridge Wu8d33b052007-12-21 19:15:36 +0800239static struct pxamci_platform_data zylonite_mci2_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800240 .detect_delay_ms= 200,
Bridge Wu8d33b052007-12-21 19:15:36 +0800241 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
Haojian Zhuangf91e4902009-12-22 07:29:40 -0500242 .gpio_card_detect = EXT_GPIO(1),
243 .gpio_card_ro = EXT_GPIO(3),
244 .gpio_power = -1,
245};
246
247static struct pxamci_platform_data zylonite_mci3_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800248 .detect_delay_ms= 200,
Haojian Zhuangf91e4902009-12-22 07:29:40 -0500249 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
250 .gpio_card_detect = EXT_GPIO(30),
251 .gpio_card_ro = EXT_GPIO(31),
252 .gpio_power = -1,
Bridge Wu8d33b052007-12-21 19:15:36 +0800253};
254
Bridge Wufafc9d32007-12-21 19:00:13 +0800255static void __init zylonite_init_mmc(void)
256{
257 pxa_set_mci_info(&zylonite_mci_platform_data);
Bridge Wu8d33b052007-12-21 19:15:36 +0800258 pxa3xx_set_mci2_info(&zylonite_mci2_platform_data);
Bridge Wu5a1f21b2007-12-21 19:27:08 +0800259 if (cpu_is_pxa310())
Haojian Zhuangf91e4902009-12-22 07:29:40 -0500260 pxa3xx_set_mci3_info(&zylonite_mci3_platform_data);
Bridge Wufafc9d32007-12-21 19:00:13 +0800261}
262#else
263static inline void zylonite_init_mmc(void) {}
264#endif
265
Eric Miao36caeb42008-06-02 13:32:42 +0800266#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
Chao Xie0a085a92013-05-05 20:24:58 -0700267static const unsigned int zylonite_matrix_key_map[] = {
eric miao468e0862008-01-23 14:25:50 +0800268 /* KEY(row, col, key_code) */
269 KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_C), KEY(0, 5, KEY_D),
270 KEY(1, 0, KEY_E), KEY(1, 1, KEY_F), KEY(1, 2, KEY_G), KEY(1, 5, KEY_H),
271 KEY(2, 0, KEY_I), KEY(2, 1, KEY_J), KEY(2, 2, KEY_K), KEY(2, 5, KEY_L),
272 KEY(3, 0, KEY_M), KEY(3, 1, KEY_N), KEY(3, 2, KEY_O), KEY(3, 5, KEY_P),
273 KEY(5, 0, KEY_Q), KEY(5, 1, KEY_R), KEY(5, 2, KEY_S), KEY(5, 5, KEY_T),
274 KEY(6, 0, KEY_U), KEY(6, 1, KEY_V), KEY(6, 2, KEY_W), KEY(6, 5, KEY_X),
275 KEY(7, 1, KEY_Y), KEY(7, 2, KEY_Z),
276
277 KEY(4, 4, KEY_0), KEY(1, 3, KEY_1), KEY(4, 1, KEY_2), KEY(1, 4, KEY_3),
278 KEY(2, 3, KEY_4), KEY(4, 2, KEY_5), KEY(2, 4, KEY_6), KEY(3, 3, KEY_7),
279 KEY(4, 3, KEY_8), KEY(3, 4, KEY_9),
280
281 KEY(4, 5, KEY_SPACE),
282 KEY(5, 3, KEY_KPASTERISK), /* * */
283 KEY(5, 4, KEY_KPDOT), /* #" */
284
285 KEY(0, 7, KEY_UP),
286 KEY(1, 7, KEY_DOWN),
287 KEY(2, 7, KEY_LEFT),
288 KEY(3, 7, KEY_RIGHT),
289 KEY(2, 6, KEY_HOME),
290 KEY(3, 6, KEY_END),
291 KEY(6, 4, KEY_DELETE),
292 KEY(6, 6, KEY_BACK),
293 KEY(6, 3, KEY_CAPSLOCK), /* KEY_LEFTSHIFT), */
294
295 KEY(4, 6, KEY_ENTER), /* scroll push */
296 KEY(5, 7, KEY_ENTER), /* keypad action */
297
298 KEY(0, 4, KEY_EMAIL),
299 KEY(5, 6, KEY_SEND),
300 KEY(4, 0, KEY_CALENDAR),
301 KEY(7, 6, KEY_RECORD),
302 KEY(6, 7, KEY_VOLUMEUP),
303 KEY(7, 7, KEY_VOLUMEDOWN),
304
305 KEY(0, 6, KEY_F22), /* soft1 */
306 KEY(1, 6, KEY_F23), /* soft2 */
307 KEY(0, 3, KEY_AUX), /* contact */
308};
309
Chao Xie0a085a92013-05-05 20:24:58 -0700310static struct matrix_keymap_data zylonite_matrix_keymap_data = {
311 .keymap = zylonite_matrix_key_map,
312 .keymap_size = ARRAY_SIZE(zylonite_matrix_key_map),
313};
314
eric miao468e0862008-01-23 14:25:50 +0800315static struct pxa27x_keypad_platform_data zylonite_keypad_info = {
316 .matrix_key_rows = 8,
317 .matrix_key_cols = 8,
Chao Xie0a085a92013-05-05 20:24:58 -0700318 .matrix_keymap_data = &zylonite_matrix_keymap_data,
eric miao468e0862008-01-23 14:25:50 +0800319
320 .enable_rotary0 = 1,
321 .rotary0_up_key = KEY_UP,
322 .rotary0_down_key = KEY_DOWN,
323
324 .debounce_interval = 30,
325};
326
327static void __init zylonite_init_keypad(void)
328{
329 pxa_set_keypad_info(&zylonite_keypad_info);
330}
331#else
332static inline void zylonite_init_keypad(void) {}
333#endif
334
Eric Miao481b5522008-06-02 15:37:20 +0800335#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
336static struct mtd_partition zylonite_nand_partitions[] = {
337 [0] = {
338 .name = "Bootloader",
339 .offset = 0,
340 .size = 0x060000,
341 .mask_flags = MTD_WRITEABLE, /* force read-only */
342 },
343 [1] = {
344 .name = "Kernel",
345 .offset = 0x060000,
346 .size = 0x200000,
347 .mask_flags = MTD_WRITEABLE, /* force read-only */
348 },
349 [2] = {
350 .name = "Filesystem",
351 .offset = 0x0260000,
352 .size = 0x3000000, /* 48M - rootfs */
353 },
354 [3] = {
355 .name = "MassStorage",
356 .offset = 0x3260000,
357 .size = 0x3d40000,
358 },
359 [4] = {
360 .name = "BBT",
361 .offset = 0x6FA0000,
362 .size = 0x80000,
363 .mask_flags = MTD_WRITEABLE, /* force read-only */
364 },
365 /* NOTE: we reserve some blocks at the end of the NAND flash for
366 * bad block management, and the max number of relocation blocks
367 * differs on different platforms. Please take care with it when
368 * defining the partition table.
369 */
370};
371
372static struct pxa3xx_nand_platform_data zylonite_nand_info = {
373 .enable_arbiter = 1,
Lei Wenf3c8cfc2011-07-14 20:44:33 -0700374 .num_cs = 1,
375 .parts[0] = zylonite_nand_partitions,
376 .nr_parts[0] = ARRAY_SIZE(zylonite_nand_partitions),
Eric Miao481b5522008-06-02 15:37:20 +0800377};
378
379static void __init zylonite_init_nand(void)
380{
381 pxa3xx_set_nand_info(&zylonite_nand_info);
382}
383#else
384static inline void zylonite_init_nand(void) {}
385#endif /* CONFIG_MTD_NAND_PXA3xx || CONFIG_MTD_NAND_PXA3xx_MODULE */
386
Eric Miao7ff43532008-09-27 18:05:49 +0800387#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
388static struct pxaohci_platform_data zylonite_ohci_info = {
389 .port_mode = PMM_PERPORT_MODE,
390 .flags = ENABLE_PORT1 | ENABLE_PORT2 |
391 POWER_CONTROL_LOW | POWER_SENSE_LOW,
392};
393
394static void __init zylonite_init_ohci(void)
395{
396 pxa_set_ohci_info(&zylonite_ohci_info);
397}
398#else
399static inline void zylonite_init_ohci(void) {}
400#endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */
401
eric miao2c8086a2007-09-11 19:13:17 -0700402static void __init zylonite_init(void)
403{
Russell Kingcc155c62009-11-09 13:34:08 +0800404 pxa_set_ffuart_info(NULL);
405 pxa_set_btuart_info(NULL);
406 pxa_set_stuart_info(NULL);
407
eric miao2c8086a2007-09-11 19:13:17 -0700408 /* board-processor specific initialization */
409 zylonite_pxa300_init();
410 zylonite_pxa320_init();
411
412 /*
413 * Note: We depend that the bootloader set
414 * the correct value to MSC register for SMC91x.
415 */
Haojian Zhuang4929f5a2011-10-10 16:03:51 +0800416 smc91x_resources[1].start = PXA_GPIO_TO_IRQ(gpio_eth_irq);
417 smc91x_resources[1].end = PXA_GPIO_TO_IRQ(gpio_eth_irq);
eric miao2c8086a2007-09-11 19:13:17 -0700418 platform_device_register(&smc91x_device);
419
Mark Browncabb3522008-06-10 10:48:25 +0100420 pxa_set_ac97_info(NULL);
eric miao2c8086a2007-09-11 19:13:17 -0700421 zylonite_init_lcd();
Bridge Wufafc9d32007-12-21 19:00:13 +0800422 zylonite_init_mmc();
eric miao468e0862008-01-23 14:25:50 +0800423 zylonite_init_keypad();
Eric Miao481b5522008-06-02 15:37:20 +0800424 zylonite_init_nand();
Eric Miao5c9f50e2008-06-17 19:03:54 +0800425 zylonite_init_leds();
Eric Miao7ff43532008-09-27 18:05:49 +0800426 zylonite_init_ohci();
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000427 zylonite_init_wm9713_audio();
eric miao2c8086a2007-09-11 19:13:17 -0700428}
429
430MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400431 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +0200432 .map_io = pxa3xx_map_io,
Haojian Zhuang6ac6b812010-08-20 15:23:59 +0800433 .nr_irqs = ZYLONITE_NR_IRQS,
eric miao2c8086a2007-09-11 19:13:17 -0700434 .init_irq = pxa3xx_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800435 .handle_irq = pxa3xx_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700436 .init_time = pxa_timer_init,
eric miao2c8086a2007-09-11 19:13:17 -0700437 .init_machine = zylonite_init,
Russell King271a74f2011-11-04 14:15:53 +0000438 .restart = pxa_restart,
eric miao2c8086a2007-09-11 19:13:17 -0700439MACHINE_END