blob: 09784d3954e42c0254d94a05b8af466931b1faf1 [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>
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/hardware.h>
28#include <mach/audio.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/pxafb.h>
30#include <mach/zylonite.h>
31#include <mach/mmc.h>
Eric Miao7ff43532008-09-27 18:05:49 +080032#include <mach/ohci.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010033#include <mach/pxa27x_keypad.h>
34#include <mach/pxa3xx_nand.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
Bridge Wu5a1f21b2007-12-21 19:27:08 +080039#define MAX_SLOTS 3
Bridge Wufafc9d32007-12-21 19:00:13 +080040struct platform_mmc_slot zylonite_mmc_slot[MAX_SLOTS];
41
eric miao2c8086a2007-09-11 19:13:17 -070042int gpio_eth_irq;
Eric Miao5c9f50e2008-06-17 19:03:54 +080043int gpio_debug_led1;
44int gpio_debug_led2;
eric miao2c8086a2007-09-11 19:13:17 -070045
Mark Brown768dec42008-04-15 15:50:49 +010046int wm9713_irq;
47
eric miao2c8086a2007-09-11 19:13:17 -070048int lcd_id;
49int lcd_orientation;
50
51static struct resource smc91x_resources[] = {
52 [0] = {
53 .start = ZYLONITE_ETH_PHYS + 0x300,
54 .end = ZYLONITE_ETH_PHYS + 0xfffff,
55 .flags = IORESOURCE_MEM,
56 },
57 [1] = {
58 .start = -1, /* for run-time assignment */
59 .end = -1,
Russell Kinge7b3dc72008-01-14 22:30:10 +000060 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
eric miao2c8086a2007-09-11 19:13:17 -070061 }
62};
63
Eric Miao88c36eb2008-06-24 16:47:37 +080064static struct smc91x_platdata zylonite_smc91x_info = {
65 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT |
66 SMC91X_NOWAIT | SMC91X_USE_DMA,
67};
68
eric miao2c8086a2007-09-11 19:13:17 -070069static struct platform_device smc91x_device = {
70 .name = "smc91x",
71 .id = 0,
72 .num_resources = ARRAY_SIZE(smc91x_resources),
73 .resource = smc91x_resources,
Eric Miao88c36eb2008-06-24 16:47:37 +080074 .dev = {
75 .platform_data = &zylonite_smc91x_info,
76 },
eric miao2c8086a2007-09-11 19:13:17 -070077};
78
Eric Miao5c9f50e2008-06-17 19:03:54 +080079#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
80static struct gpio_led zylonite_debug_leds[] = {
81 [0] = {
82 .name = "zylonite:yellow:1",
83 .default_trigger = "heartbeat",
84 },
85 [1] = {
86 .name = "zylonite:yellow:2",
87 .default_trigger = "default-on",
88 },
89};
90
91static struct gpio_led_platform_data zylonite_debug_leds_info = {
92 .leds = zylonite_debug_leds,
93 .num_leds = ARRAY_SIZE(zylonite_debug_leds),
94};
95
96static struct platform_device zylonite_device_leds = {
97 .name = "leds-gpio",
98 .id = -1,
99 .dev = {
100 .platform_data = &zylonite_debug_leds_info,
101 }
102};
103
104static void __init zylonite_init_leds(void)
105{
106 zylonite_debug_leds[0].gpio = gpio_debug_led1;
107 zylonite_debug_leds[1].gpio = gpio_debug_led2;
108
109 platform_device_register(&zylonite_device_leds);
110}
111#else
112static inline void zylonite_init_leds(void) {}
113#endif
114
eric miao7a987e82008-02-27 02:00:26 +0100115#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
eric miao5cca9142008-04-13 21:46:34 +0100116static struct platform_pwm_backlight_data zylonite_backlight_data = {
117 .pwm_id = 3,
118 .max_brightness = 100,
119 .dft_brightness = 100,
120 .pwm_period_ns = 10000,
121};
122
123static struct platform_device zylonite_backlight_device = {
124 .name = "pwm-backlight",
125 .dev = {
126 .parent = &pxa27x_device_pwm1.dev,
127 .platform_data = &zylonite_backlight_data,
128 },
129};
eric miao2c8086a2007-09-11 19:13:17 -0700130
131static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
132 .pixclock = 110000,
133 .xres = 240,
134 .yres = 320,
135 .bpp = 16,
136 .hsync_len = 4,
137 .left_margin = 6,
138 .right_margin = 4,
139 .vsync_len = 2,
140 .upper_margin = 2,
141 .lower_margin = 3,
142 .sync = FB_SYNC_VERT_HIGH_ACT,
143};
144
145static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
146 .pixclock = 50000,
147 .xres = 640,
148 .yres = 480,
149 .bpp = 16,
150 .hsync_len = 1,
151 .left_margin = 0x9f,
152 .right_margin = 1,
153 .vsync_len = 44,
154 .upper_margin = 0,
155 .lower_margin = 0,
156 .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
157};
158
159static struct pxafb_mach_info zylonite_toshiba_lcd_info = {
160 .num_modes = 1,
eric miao0454bd02008-04-30 00:52:23 -0700161 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
eric miao2c8086a2007-09-11 19:13:17 -0700162};
163
164static struct pxafb_mode_info sharp_ls037_modes[] = {
165 [0] = {
166 .pixclock = 158000,
167 .xres = 240,
168 .yres = 320,
169 .bpp = 16,
170 .hsync_len = 4,
171 .left_margin = 39,
172 .right_margin = 39,
173 .vsync_len = 1,
174 .upper_margin = 2,
175 .lower_margin = 3,
176 .sync = 0,
177 },
178 [1] = {
179 .pixclock = 39700,
180 .xres = 480,
181 .yres = 640,
182 .bpp = 16,
183 .hsync_len = 8,
184 .left_margin = 81,
185 .right_margin = 81,
186 .vsync_len = 1,
187 .upper_margin = 2,
188 .lower_margin = 7,
189 .sync = 0,
190 },
191};
192
193static struct pxafb_mach_info zylonite_sharp_lcd_info = {
194 .modes = sharp_ls037_modes,
195 .num_modes = 2,
eric miao0454bd02008-04-30 00:52:23 -0700196 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
eric miao2c8086a2007-09-11 19:13:17 -0700197};
198
199static void __init zylonite_init_lcd(void)
200{
eric miao5cca9142008-04-13 21:46:34 +0100201 platform_device_register(&zylonite_backlight_device);
eric miao2c8086a2007-09-11 19:13:17 -0700202
203 if (lcd_id & 0x20) {
204 set_pxa_fb_info(&zylonite_sharp_lcd_info);
205 return;
206 }
207
208 /* legacy LCD panels, it would be handy here if LCD panel type can
209 * be decided at run-time
210 */
211 if (1)
212 zylonite_toshiba_lcd_info.modes = &toshiba_ltm035a776c_mode;
213 else
214 zylonite_toshiba_lcd_info.modes = &toshiba_ltm04c380k_mode;
215
216 set_pxa_fb_info(&zylonite_toshiba_lcd_info);
217}
218#else
219static inline void zylonite_init_lcd(void) {}
220#endif
221
Bridge Wufafc9d32007-12-21 19:00:13 +0800222#if defined(CONFIG_MMC)
223static int zylonite_mci_ro(struct device *dev)
224{
225 struct platform_device *pdev = to_platform_device(dev);
226
227 return gpio_get_value(zylonite_mmc_slot[pdev->id].gpio_wp);
228}
229
230static int zylonite_mci_init(struct device *dev,
231 irq_handler_t zylonite_detect_int,
232 void *data)
233{
234 struct platform_device *pdev = to_platform_device(dev);
235 int err, cd_irq, gpio_cd, gpio_wp;
236
237 cd_irq = gpio_to_irq(zylonite_mmc_slot[pdev->id].gpio_cd);
238 gpio_cd = zylonite_mmc_slot[pdev->id].gpio_cd;
239 gpio_wp = zylonite_mmc_slot[pdev->id].gpio_wp;
240
241 /*
242 * setup GPIO for Zylonite MMC controller
243 */
244 err = gpio_request(gpio_cd, "mmc card detect");
245 if (err)
246 goto err_request_cd;
247 gpio_direction_input(gpio_cd);
248
249 err = gpio_request(gpio_wp, "mmc write protect");
250 if (err)
251 goto err_request_wp;
252 gpio_direction_input(gpio_wp);
253
254 err = request_irq(cd_irq, zylonite_detect_int,
255 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
256 "MMC card detect", data);
257 if (err) {
258 printk(KERN_ERR "%s: MMC/SD/SDIO: "
259 "can't request card detect IRQ\n", __func__);
260 goto err_request_irq;
261 }
262
263 return 0;
264
265err_request_irq:
266 gpio_free(gpio_wp);
267err_request_wp:
268 gpio_free(gpio_cd);
269err_request_cd:
270 return err;
271}
272
273static void zylonite_mci_exit(struct device *dev, void *data)
274{
275 struct platform_device *pdev = to_platform_device(dev);
276 int cd_irq, gpio_cd, gpio_wp;
277
278 cd_irq = gpio_to_irq(zylonite_mmc_slot[pdev->id].gpio_cd);
279 gpio_cd = zylonite_mmc_slot[pdev->id].gpio_cd;
280 gpio_wp = zylonite_mmc_slot[pdev->id].gpio_wp;
281
282 free_irq(cd_irq, data);
283 gpio_free(gpio_cd);
284 gpio_free(gpio_wp);
285}
286
287static struct pxamci_platform_data zylonite_mci_platform_data = {
288 .detect_delay = 20,
289 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
290 .init = zylonite_mci_init,
291 .exit = zylonite_mci_exit,
292 .get_ro = zylonite_mci_ro,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200293 .gpio_card_detect = -1,
294 .gpio_card_ro = -1,
295 .gpio_power = -1,
Bridge Wufafc9d32007-12-21 19:00:13 +0800296};
297
Bridge Wu8d33b052007-12-21 19:15:36 +0800298static struct pxamci_platform_data zylonite_mci2_platform_data = {
299 .detect_delay = 20,
300 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
301};
302
Bridge Wufafc9d32007-12-21 19:00:13 +0800303static void __init zylonite_init_mmc(void)
304{
305 pxa_set_mci_info(&zylonite_mci_platform_data);
Bridge Wu8d33b052007-12-21 19:15:36 +0800306 pxa3xx_set_mci2_info(&zylonite_mci2_platform_data);
Bridge Wu5a1f21b2007-12-21 19:27:08 +0800307 if (cpu_is_pxa310())
308 pxa3xx_set_mci3_info(&zylonite_mci_platform_data);
Bridge Wufafc9d32007-12-21 19:00:13 +0800309}
310#else
311static inline void zylonite_init_mmc(void) {}
312#endif
313
Eric Miao36caeb42008-06-02 13:32:42 +0800314#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
eric miao468e0862008-01-23 14:25:50 +0800315static unsigned int zylonite_matrix_key_map[] = {
316 /* KEY(row, col, key_code) */
317 KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_C), KEY(0, 5, KEY_D),
318 KEY(1, 0, KEY_E), KEY(1, 1, KEY_F), KEY(1, 2, KEY_G), KEY(1, 5, KEY_H),
319 KEY(2, 0, KEY_I), KEY(2, 1, KEY_J), KEY(2, 2, KEY_K), KEY(2, 5, KEY_L),
320 KEY(3, 0, KEY_M), KEY(3, 1, KEY_N), KEY(3, 2, KEY_O), KEY(3, 5, KEY_P),
321 KEY(5, 0, KEY_Q), KEY(5, 1, KEY_R), KEY(5, 2, KEY_S), KEY(5, 5, KEY_T),
322 KEY(6, 0, KEY_U), KEY(6, 1, KEY_V), KEY(6, 2, KEY_W), KEY(6, 5, KEY_X),
323 KEY(7, 1, KEY_Y), KEY(7, 2, KEY_Z),
324
325 KEY(4, 4, KEY_0), KEY(1, 3, KEY_1), KEY(4, 1, KEY_2), KEY(1, 4, KEY_3),
326 KEY(2, 3, KEY_4), KEY(4, 2, KEY_5), KEY(2, 4, KEY_6), KEY(3, 3, KEY_7),
327 KEY(4, 3, KEY_8), KEY(3, 4, KEY_9),
328
329 KEY(4, 5, KEY_SPACE),
330 KEY(5, 3, KEY_KPASTERISK), /* * */
331 KEY(5, 4, KEY_KPDOT), /* #" */
332
333 KEY(0, 7, KEY_UP),
334 KEY(1, 7, KEY_DOWN),
335 KEY(2, 7, KEY_LEFT),
336 KEY(3, 7, KEY_RIGHT),
337 KEY(2, 6, KEY_HOME),
338 KEY(3, 6, KEY_END),
339 KEY(6, 4, KEY_DELETE),
340 KEY(6, 6, KEY_BACK),
341 KEY(6, 3, KEY_CAPSLOCK), /* KEY_LEFTSHIFT), */
342
343 KEY(4, 6, KEY_ENTER), /* scroll push */
344 KEY(5, 7, KEY_ENTER), /* keypad action */
345
346 KEY(0, 4, KEY_EMAIL),
347 KEY(5, 6, KEY_SEND),
348 KEY(4, 0, KEY_CALENDAR),
349 KEY(7, 6, KEY_RECORD),
350 KEY(6, 7, KEY_VOLUMEUP),
351 KEY(7, 7, KEY_VOLUMEDOWN),
352
353 KEY(0, 6, KEY_F22), /* soft1 */
354 KEY(1, 6, KEY_F23), /* soft2 */
355 KEY(0, 3, KEY_AUX), /* contact */
356};
357
358static struct pxa27x_keypad_platform_data zylonite_keypad_info = {
359 .matrix_key_rows = 8,
360 .matrix_key_cols = 8,
361 .matrix_key_map = zylonite_matrix_key_map,
362 .matrix_key_map_size = ARRAY_SIZE(zylonite_matrix_key_map),
363
364 .enable_rotary0 = 1,
365 .rotary0_up_key = KEY_UP,
366 .rotary0_down_key = KEY_DOWN,
367
368 .debounce_interval = 30,
369};
370
371static void __init zylonite_init_keypad(void)
372{
373 pxa_set_keypad_info(&zylonite_keypad_info);
374}
375#else
376static inline void zylonite_init_keypad(void) {}
377#endif
378
Eric Miao481b5522008-06-02 15:37:20 +0800379#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
380static struct mtd_partition zylonite_nand_partitions[] = {
381 [0] = {
382 .name = "Bootloader",
383 .offset = 0,
384 .size = 0x060000,
385 .mask_flags = MTD_WRITEABLE, /* force read-only */
386 },
387 [1] = {
388 .name = "Kernel",
389 .offset = 0x060000,
390 .size = 0x200000,
391 .mask_flags = MTD_WRITEABLE, /* force read-only */
392 },
393 [2] = {
394 .name = "Filesystem",
395 .offset = 0x0260000,
396 .size = 0x3000000, /* 48M - rootfs */
397 },
398 [3] = {
399 .name = "MassStorage",
400 .offset = 0x3260000,
401 .size = 0x3d40000,
402 },
403 [4] = {
404 .name = "BBT",
405 .offset = 0x6FA0000,
406 .size = 0x80000,
407 .mask_flags = MTD_WRITEABLE, /* force read-only */
408 },
409 /* NOTE: we reserve some blocks at the end of the NAND flash for
410 * bad block management, and the max number of relocation blocks
411 * differs on different platforms. Please take care with it when
412 * defining the partition table.
413 */
414};
415
416static struct pxa3xx_nand_platform_data zylonite_nand_info = {
417 .enable_arbiter = 1,
418 .parts = zylonite_nand_partitions,
419 .nr_parts = ARRAY_SIZE(zylonite_nand_partitions),
420};
421
422static void __init zylonite_init_nand(void)
423{
424 pxa3xx_set_nand_info(&zylonite_nand_info);
425}
426#else
427static inline void zylonite_init_nand(void) {}
428#endif /* CONFIG_MTD_NAND_PXA3xx || CONFIG_MTD_NAND_PXA3xx_MODULE */
429
Eric Miao7ff43532008-09-27 18:05:49 +0800430#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
431static struct pxaohci_platform_data zylonite_ohci_info = {
432 .port_mode = PMM_PERPORT_MODE,
433 .flags = ENABLE_PORT1 | ENABLE_PORT2 |
434 POWER_CONTROL_LOW | POWER_SENSE_LOW,
435};
436
437static void __init zylonite_init_ohci(void)
438{
439 pxa_set_ohci_info(&zylonite_ohci_info);
440}
441#else
442static inline void zylonite_init_ohci(void) {}
443#endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */
444
eric miao2c8086a2007-09-11 19:13:17 -0700445static void __init zylonite_init(void)
446{
447 /* board-processor specific initialization */
448 zylonite_pxa300_init();
449 zylonite_pxa320_init();
450
451 /*
452 * Note: We depend that the bootloader set
453 * the correct value to MSC register for SMC91x.
454 */
455 smc91x_resources[1].start = gpio_to_irq(gpio_eth_irq);
456 smc91x_resources[1].end = gpio_to_irq(gpio_eth_irq);
457 platform_device_register(&smc91x_device);
458
Mark Browncabb3522008-06-10 10:48:25 +0100459 pxa_set_ac97_info(NULL);
eric miao2c8086a2007-09-11 19:13:17 -0700460 zylonite_init_lcd();
Bridge Wufafc9d32007-12-21 19:00:13 +0800461 zylonite_init_mmc();
eric miao468e0862008-01-23 14:25:50 +0800462 zylonite_init_keypad();
Eric Miao481b5522008-06-02 15:37:20 +0800463 zylonite_init_nand();
Eric Miao5c9f50e2008-06-17 19:03:54 +0800464 zylonite_init_leds();
Eric Miao7ff43532008-09-27 18:05:49 +0800465 zylonite_init_ohci();
eric miao2c8086a2007-09-11 19:13:17 -0700466}
467
468MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
469 .phys_io = 0x40000000,
470 .boot_params = 0xa0000100,
471 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
472 .map_io = pxa_map_io,
473 .init_irq = pxa3xx_init_irq,
474 .timer = &pxa_timer,
475 .init_machine = zylonite_init,
476MACHINE_END