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