]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/arm/mach-pxa/zylonite.c
[ARM] pxa/zylonite: simplify reduntant gpio settings on mmc slot
[net-next-2.6.git] / arch / arm / mach-pxa / zylonite.c
CommitLineData
2c8086a5 1/*
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 *
e9bba8ee 8 * 2007-09-04: eric miao <eric.miao@marvell.com>
2c8086a5 9 * 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>
80796f2a 21#include <linux/gpio.h>
5cca9147 22#include <linux/pwm_backlight.h>
88c36eb7 23#include <linux/smc91x.h>
2c8086a5 24
25#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
a09e64fb
RK
27#include <mach/hardware.h>
28#include <mach/audio.h>
a09e64fb
RK
29#include <mach/pxafb.h>
30#include <mach/zylonite.h>
31#include <mach/mmc.h>
7ff43535 32#include <mach/ohci.h>
a09e64fb 33#include <mach/pxa27x_keypad.h>
82b95ecb 34#include <plat/pxa3xx_nand.h>
2c8086a5 35
5cca9147 36#include "devices.h"
2c8086a5 37#include "generic.h"
38
2c8086a5 39int gpio_eth_irq;
5c9f50e9
EM
40int gpio_debug_led1;
41int gpio_debug_led2;
2c8086a5 42
768dec4c
MB
43int wm9713_irq;
44
2c8086a5 45int lcd_id;
46int lcd_orientation;
47
48static struct resource smc91x_resources[] = {
49 [0] = {
50 .start = ZYLONITE_ETH_PHYS + 0x300,
51 .end = ZYLONITE_ETH_PHYS + 0xfffff,
52 .flags = IORESOURCE_MEM,
53 },
54 [1] = {
55 .start = -1, /* for run-time assignment */
56 .end = -1,
e7b3dc7e 57 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
2c8086a5 58 }
59};
60
88c36eb7
EM
61static struct smc91x_platdata zylonite_smc91x_info = {
62 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT |
63 SMC91X_NOWAIT | SMC91X_USE_DMA,
64};
65
2c8086a5 66static struct platform_device smc91x_device = {
67 .name = "smc91x",
68 .id = 0,
69 .num_resources = ARRAY_SIZE(smc91x_resources),
70 .resource = smc91x_resources,
88c36eb7
EM
71 .dev = {
72 .platform_data = &zylonite_smc91x_info,
73 },
2c8086a5 74};
75
5c9f50e9
EM
76#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
77static struct gpio_led zylonite_debug_leds[] = {
78 [0] = {
79 .name = "zylonite:yellow:1",
80 .default_trigger = "heartbeat",
81 },
82 [1] = {
83 .name = "zylonite:yellow:2",
84 .default_trigger = "default-on",
85 },
86};
87
88static struct gpio_led_platform_data zylonite_debug_leds_info = {
89 .leds = zylonite_debug_leds,
90 .num_leds = ARRAY_SIZE(zylonite_debug_leds),
91};
92
93static struct platform_device zylonite_device_leds = {
94 .name = "leds-gpio",
95 .id = -1,
96 .dev = {
97 .platform_data = &zylonite_debug_leds_info,
98 }
99};
100
101static void __init zylonite_init_leds(void)
102{
103 zylonite_debug_leds[0].gpio = gpio_debug_led1;
104 zylonite_debug_leds[1].gpio = gpio_debug_led2;
105
106 platform_device_register(&zylonite_device_leds);
107}
108#else
109static inline void zylonite_init_leds(void) {}
110#endif
111
7a987e82 112#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
5cca9147 113static struct platform_pwm_backlight_data zylonite_backlight_data = {
114 .pwm_id = 3,
115 .max_brightness = 100,
116 .dft_brightness = 100,
117 .pwm_period_ns = 10000,
118};
119
120static struct platform_device zylonite_backlight_device = {
121 .name = "pwm-backlight",
122 .dev = {
123 .parent = &pxa27x_device_pwm1.dev,
124 .platform_data = &zylonite_backlight_data,
125 },
126};
2c8086a5 127
128static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
129 .pixclock = 110000,
130 .xres = 240,
131 .yres = 320,
132 .bpp = 16,
133 .hsync_len = 4,
134 .left_margin = 6,
135 .right_margin = 4,
136 .vsync_len = 2,
137 .upper_margin = 2,
138 .lower_margin = 3,
139 .sync = FB_SYNC_VERT_HIGH_ACT,
140};
141
142static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
143 .pixclock = 50000,
144 .xres = 640,
145 .yres = 480,
146 .bpp = 16,
147 .hsync_len = 1,
148 .left_margin = 0x9f,
149 .right_margin = 1,
150 .vsync_len = 44,
151 .upper_margin = 0,
152 .lower_margin = 0,
153 .sync = FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT,
154};
155
156static struct pxafb_mach_info zylonite_toshiba_lcd_info = {
157 .num_modes = 1,
0454bd09 158 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
2c8086a5 159};
160
161static struct pxafb_mode_info sharp_ls037_modes[] = {
162 [0] = {
163 .pixclock = 158000,
164 .xres = 240,
165 .yres = 320,
166 .bpp = 16,
167 .hsync_len = 4,
168 .left_margin = 39,
169 .right_margin = 39,
170 .vsync_len = 1,
171 .upper_margin = 2,
172 .lower_margin = 3,
173 .sync = 0,
174 },
175 [1] = {
176 .pixclock = 39700,
177 .xres = 480,
178 .yres = 640,
179 .bpp = 16,
180 .hsync_len = 8,
181 .left_margin = 81,
182 .right_margin = 81,
183 .vsync_len = 1,
184 .upper_margin = 2,
185 .lower_margin = 7,
186 .sync = 0,
187 },
188};
189
190static struct pxafb_mach_info zylonite_sharp_lcd_info = {
191 .modes = sharp_ls037_modes,
192 .num_modes = 2,
0454bd09 193 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
2c8086a5 194};
195
196static void __init zylonite_init_lcd(void)
197{
5cca9147 198 platform_device_register(&zylonite_backlight_device);
2c8086a5 199
200 if (lcd_id & 0x20) {
201 set_pxa_fb_info(&zylonite_sharp_lcd_info);
202 return;
203 }
204
205 /* legacy LCD panels, it would be handy here if LCD panel type can
206 * be decided at run-time
207 */
208 if (1)
209 zylonite_toshiba_lcd_info.modes = &toshiba_ltm035a776c_mode;
210 else
211 zylonite_toshiba_lcd_info.modes = &toshiba_ltm04c380k_mode;
212
213 set_pxa_fb_info(&zylonite_toshiba_lcd_info);
214}
215#else
216static inline void zylonite_init_lcd(void) {}
217#endif
218
fafc9d3f 219#if defined(CONFIG_MMC)
fafc9d3f
BW
220static struct pxamci_platform_data zylonite_mci_platform_data = {
221 .detect_delay = 20,
222 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
f91e4906
HZ
223 .gpio_card_detect = EXT_GPIO(0),
224 .gpio_card_ro = EXT_GPIO(2),
7a648256 225 .gpio_power = -1,
fafc9d3f
BW
226};
227
8d33b055
BW
228static struct pxamci_platform_data zylonite_mci2_platform_data = {
229 .detect_delay = 20,
230 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
f91e4906
HZ
231 .gpio_card_detect = EXT_GPIO(1),
232 .gpio_card_ro = EXT_GPIO(3),
233 .gpio_power = -1,
234};
235
236static struct pxamci_platform_data zylonite_mci3_platform_data = {
237 .detect_delay = 20,
238 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
239 .gpio_card_detect = EXT_GPIO(30),
240 .gpio_card_ro = EXT_GPIO(31),
241 .gpio_power = -1,
8d33b055
BW
242};
243
fafc9d3f
BW
244static void __init zylonite_init_mmc(void)
245{
246 pxa_set_mci_info(&zylonite_mci_platform_data);
8d33b055 247 pxa3xx_set_mci2_info(&zylonite_mci2_platform_data);
5a1f21b1 248 if (cpu_is_pxa310())
f91e4906 249 pxa3xx_set_mci3_info(&zylonite_mci3_platform_data);
fafc9d3f
BW
250}
251#else
252static inline void zylonite_init_mmc(void) {}
253#endif
254
36caeb4e 255#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
468e086f 256static unsigned int zylonite_matrix_key_map[] = {
257 /* KEY(row, col, key_code) */
258 KEY(0, 0, KEY_A), KEY(0, 1, KEY_B), KEY(0, 2, KEY_C), KEY(0, 5, KEY_D),
259 KEY(1, 0, KEY_E), KEY(1, 1, KEY_F), KEY(1, 2, KEY_G), KEY(1, 5, KEY_H),
260 KEY(2, 0, KEY_I), KEY(2, 1, KEY_J), KEY(2, 2, KEY_K), KEY(2, 5, KEY_L),
261 KEY(3, 0, KEY_M), KEY(3, 1, KEY_N), KEY(3, 2, KEY_O), KEY(3, 5, KEY_P),
262 KEY(5, 0, KEY_Q), KEY(5, 1, KEY_R), KEY(5, 2, KEY_S), KEY(5, 5, KEY_T),
263 KEY(6, 0, KEY_U), KEY(6, 1, KEY_V), KEY(6, 2, KEY_W), KEY(6, 5, KEY_X),
264 KEY(7, 1, KEY_Y), KEY(7, 2, KEY_Z),
265
266 KEY(4, 4, KEY_0), KEY(1, 3, KEY_1), KEY(4, 1, KEY_2), KEY(1, 4, KEY_3),
267 KEY(2, 3, KEY_4), KEY(4, 2, KEY_5), KEY(2, 4, KEY_6), KEY(3, 3, KEY_7),
268 KEY(4, 3, KEY_8), KEY(3, 4, KEY_9),
269
270 KEY(4, 5, KEY_SPACE),
271 KEY(5, 3, KEY_KPASTERISK), /* * */
272 KEY(5, 4, KEY_KPDOT), /* #" */
273
274 KEY(0, 7, KEY_UP),
275 KEY(1, 7, KEY_DOWN),
276 KEY(2, 7, KEY_LEFT),
277 KEY(3, 7, KEY_RIGHT),
278 KEY(2, 6, KEY_HOME),
279 KEY(3, 6, KEY_END),
280 KEY(6, 4, KEY_DELETE),
281 KEY(6, 6, KEY_BACK),
282 KEY(6, 3, KEY_CAPSLOCK), /* KEY_LEFTSHIFT), */
283
284 KEY(4, 6, KEY_ENTER), /* scroll push */
285 KEY(5, 7, KEY_ENTER), /* keypad action */
286
287 KEY(0, 4, KEY_EMAIL),
288 KEY(5, 6, KEY_SEND),
289 KEY(4, 0, KEY_CALENDAR),
290 KEY(7, 6, KEY_RECORD),
291 KEY(6, 7, KEY_VOLUMEUP),
292 KEY(7, 7, KEY_VOLUMEDOWN),
293
294 KEY(0, 6, KEY_F22), /* soft1 */
295 KEY(1, 6, KEY_F23), /* soft2 */
296 KEY(0, 3, KEY_AUX), /* contact */
297};
298
299static struct pxa27x_keypad_platform_data zylonite_keypad_info = {
300 .matrix_key_rows = 8,
301 .matrix_key_cols = 8,
302 .matrix_key_map = zylonite_matrix_key_map,
303 .matrix_key_map_size = ARRAY_SIZE(zylonite_matrix_key_map),
304
305 .enable_rotary0 = 1,
306 .rotary0_up_key = KEY_UP,
307 .rotary0_down_key = KEY_DOWN,
308
309 .debounce_interval = 30,
310};
311
312static void __init zylonite_init_keypad(void)
313{
314 pxa_set_keypad_info(&zylonite_keypad_info);
315}
316#else
317static inline void zylonite_init_keypad(void) {}
318#endif
319
481b5526
EM
320#if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
321static struct mtd_partition zylonite_nand_partitions[] = {
322 [0] = {
323 .name = "Bootloader",
324 .offset = 0,
325 .size = 0x060000,
326 .mask_flags = MTD_WRITEABLE, /* force read-only */
327 },
328 [1] = {
329 .name = "Kernel",
330 .offset = 0x060000,
331 .size = 0x200000,
332 .mask_flags = MTD_WRITEABLE, /* force read-only */
333 },
334 [2] = {
335 .name = "Filesystem",
336 .offset = 0x0260000,
337 .size = 0x3000000, /* 48M - rootfs */
338 },
339 [3] = {
340 .name = "MassStorage",
341 .offset = 0x3260000,
342 .size = 0x3d40000,
343 },
344 [4] = {
345 .name = "BBT",
346 .offset = 0x6FA0000,
347 .size = 0x80000,
348 .mask_flags = MTD_WRITEABLE, /* force read-only */
349 },
350 /* NOTE: we reserve some blocks at the end of the NAND flash for
351 * bad block management, and the max number of relocation blocks
352 * differs on different platforms. Please take care with it when
353 * defining the partition table.
354 */
355};
356
357static struct pxa3xx_nand_platform_data zylonite_nand_info = {
358 .enable_arbiter = 1,
359 .parts = zylonite_nand_partitions,
360 .nr_parts = ARRAY_SIZE(zylonite_nand_partitions),
361};
362
363static void __init zylonite_init_nand(void)
364{
365 pxa3xx_set_nand_info(&zylonite_nand_info);
366}
367#else
368static inline void zylonite_init_nand(void) {}
369#endif /* CONFIG_MTD_NAND_PXA3xx || CONFIG_MTD_NAND_PXA3xx_MODULE */
370
7ff43535
EM
371#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
372static struct pxaohci_platform_data zylonite_ohci_info = {
373 .port_mode = PMM_PERPORT_MODE,
374 .flags = ENABLE_PORT1 | ENABLE_PORT2 |
375 POWER_CONTROL_LOW | POWER_SENSE_LOW,
376};
377
378static void __init zylonite_init_ohci(void)
379{
380 pxa_set_ohci_info(&zylonite_ohci_info);
381}
382#else
383static inline void zylonite_init_ohci(void) {}
384#endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */
385
2c8086a5 386static void __init zylonite_init(void)
387{
cc155c6f
RK
388 pxa_set_ffuart_info(NULL);
389 pxa_set_btuart_info(NULL);
390 pxa_set_stuart_info(NULL);
391
2c8086a5 392 /* board-processor specific initialization */
393 zylonite_pxa300_init();
394 zylonite_pxa320_init();
395
396 /*
397 * Note: We depend that the bootloader set
398 * the correct value to MSC register for SMC91x.
399 */
400 smc91x_resources[1].start = gpio_to_irq(gpio_eth_irq);
401 smc91x_resources[1].end = gpio_to_irq(gpio_eth_irq);
402 platform_device_register(&smc91x_device);
403
cabb352a 404 pxa_set_ac97_info(NULL);
2c8086a5 405 zylonite_init_lcd();
fafc9d3f 406 zylonite_init_mmc();
468e086f 407 zylonite_init_keypad();
481b5526 408 zylonite_init_nand();
5c9f50e9 409 zylonite_init_leds();
7ff43535 410 zylonite_init_ohci();
2c8086a5 411}
412
413MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
414 .phys_io = 0x40000000,
415 .boot_params = 0xa0000100,
416 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
417 .map_io = pxa_map_io,
418 .init_irq = pxa3xx_init_irq,
419 .timer = &pxa_timer,
420 .init_machine = zylonite_init,
421MACHINE_END