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