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