]> err.no Git - linux-2.6/blob - arch/arm/mach-pxa/littleton.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6] / arch / arm / mach-pxa / littleton.c
1 /*
2  *  linux/arch/arm/mach-pxa/littleton.c
3  *
4  *  Support for the Marvell Littleton Development Platform.
5  *
6  *  Author:     Jason Chagas (largely modified code)
7  *  Created:    Nov 20, 2006
8  *  Copyright:  (C) Copyright 2006 Marvell International Ltd.
9  *
10  *  2007-11-22  modified to align with latest kernel
11  *              eric miao <eric.miao@marvell.com>
12  *
13  *  This program is free software; you can redistribute it and/or modify
14  *  it under the terms of the GNU General Public License version 2 as
15  *  publishhed by the Free Software Foundation.
16  */
17
18 #include <linux/init.h>
19 #include <linux/interrupt.h>
20 #include <linux/delay.h>
21 #include <linux/platform_device.h>
22 #include <linux/clk.h>
23
24 #include <asm/types.h>
25 #include <asm/setup.h>
26 #include <asm/memory.h>
27 #include <asm/mach-types.h>
28 #include <asm/hardware.h>
29 #include <asm/irq.h>
30
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <asm/mach/irq.h>
34
35 #include <asm/arch/pxa-regs.h>
36 #include <asm/arch/mfp-pxa300.h>
37 #include <asm/arch/gpio.h>
38 #include <asm/arch/pxafb.h>
39 #include <asm/arch/ssp.h>
40 #include <asm/arch/pxa27x_keypad.h>
41 #include <asm/arch/littleton.h>
42
43 #include "generic.h"
44
45 /* Littleton MFP configurations */
46 static mfp_cfg_t littleton_mfp_cfg[] __initdata = {
47         /* LCD */
48         GPIO54_LCD_LDD_0,
49         GPIO55_LCD_LDD_1,
50         GPIO56_LCD_LDD_2,
51         GPIO57_LCD_LDD_3,
52         GPIO58_LCD_LDD_4,
53         GPIO59_LCD_LDD_5,
54         GPIO60_LCD_LDD_6,
55         GPIO61_LCD_LDD_7,
56         GPIO62_LCD_LDD_8,
57         GPIO63_LCD_LDD_9,
58         GPIO64_LCD_LDD_10,
59         GPIO65_LCD_LDD_11,
60         GPIO66_LCD_LDD_12,
61         GPIO67_LCD_LDD_13,
62         GPIO68_LCD_LDD_14,
63         GPIO69_LCD_LDD_15,
64         GPIO70_LCD_LDD_16,
65         GPIO71_LCD_LDD_17,
66         GPIO72_LCD_FCLK,
67         GPIO73_LCD_LCLK,
68         GPIO74_LCD_PCLK,
69         GPIO75_LCD_BIAS,
70
71         /* SSP2 */
72         GPIO25_SSP2_SCLK,
73         GPIO17_SSP2_FRM,
74         GPIO27_SSP2_TXD,
75
76         /* Debug Ethernet */
77         GPIO90_GPIO,
78
79         /* Keypad */
80         GPIO107_KP_DKIN_0,
81         GPIO108_KP_DKIN_1,
82         GPIO115_KP_MKIN_0,
83         GPIO116_KP_MKIN_1,
84         GPIO117_KP_MKIN_2,
85         GPIO118_KP_MKIN_3,
86         GPIO119_KP_MKIN_4,
87         GPIO120_KP_MKIN_5,
88         GPIO121_KP_MKOUT_0,
89         GPIO122_KP_MKOUT_1,
90         GPIO123_KP_MKOUT_2,
91         GPIO124_KP_MKOUT_3,
92         GPIO125_KP_MKOUT_4,
93 };
94
95 static struct resource smc91x_resources[] = {
96         [0] = {
97                 .start  = (LITTLETON_ETH_PHYS + 0x300),
98                 .end    = (LITTLETON_ETH_PHYS + 0xfffff),
99                 .flags  = IORESOURCE_MEM,
100         },
101         [1] = {
102                 .start  = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)),
103                 .end    = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)),
104                 .flags  = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
105         }
106 };
107
108 static struct platform_device smc91x_device = {
109         .name           = "smc91x",
110         .id             = 0,
111         .num_resources  = ARRAY_SIZE(smc91x_resources),
112         .resource       = smc91x_resources,
113 };
114
115 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULES)
116 /* use bit 30, 31 as the indicator of command parameter number */
117 #define CMD0(x)         ((0x00000000) | ((x) << 9))
118 #define CMD1(x, x1)     ((0x40000000) | ((x) << 9) | 0x100 | (x1))
119 #define CMD2(x, x1, x2) ((0x80000000) | ((x) << 18) | 0x20000 |\
120                          ((x1) << 9) | 0x100 | (x2))
121
122 static uint32_t lcd_panel_reset[] = {
123         CMD0(0x1), /* reset */
124         CMD0(0x0), /* nop */
125         CMD0(0x0), /* nop */
126         CMD0(0x0), /* nop */
127 };
128
129 static uint32_t lcd_panel_on[] = {
130         CMD0(0x29),             /* Display ON */
131         CMD2(0xB8, 0xFF, 0xF9), /* Output Control */
132         CMD0(0x11),             /* Sleep out */
133         CMD1(0xB0, 0x16),       /* Wake */
134 };
135
136 static uint32_t lcd_panel_off[] = {
137         CMD0(0x28),             /* Display OFF */
138         CMD2(0xB8, 0x80, 0x02), /* Output Control */
139         CMD0(0x10),             /* Sleep in */
140         CMD1(0xB0, 0x00),       /* Deep stand by in */
141 };
142
143 static uint32_t lcd_vga_pass_through[] = {
144         CMD1(0xB0, 0x16),
145         CMD1(0xBC, 0x80),
146         CMD1(0xE1, 0x00),
147         CMD1(0x36, 0x50),
148         CMD1(0x3B, 0x00),
149 };
150
151 static uint32_t lcd_qvga_pass_through[] = {
152         CMD1(0xB0, 0x16),
153         CMD1(0xBC, 0x81),
154         CMD1(0xE1, 0x00),
155         CMD1(0x36, 0x50),
156         CMD1(0x3B, 0x22),
157 };
158
159 static uint32_t lcd_vga_transfer[] = {
160         CMD1(0xcf, 0x02),       /* Blanking period control (1) */
161         CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
162         CMD1(0xd1, 0x01),       /* CKV timing control on/off */
163         CMD2(0xd2, 0x14, 0x00), /* CKV 1,2 timing control */
164         CMD2(0xd3, 0x1a, 0x0f), /* OEV timing control */
165         CMD2(0xd4, 0x1f, 0xaf), /* ASW timing control (1) */
166         CMD1(0xd5, 0x14),       /* ASW timing control (2) */
167         CMD0(0x21),             /* Invert for normally black display */
168         CMD0(0x29),             /* Display on */
169 };
170
171 static uint32_t lcd_qvga_transfer[] = {
172         CMD1(0xd6, 0x02),       /* Blanking period control (1) */
173         CMD2(0xd7, 0x08, 0x04), /* Blanking period control (2) */
174         CMD1(0xd8, 0x01),       /* CKV timing control on/off */
175         CMD2(0xd9, 0x00, 0x08), /* CKV 1,2 timing control */
176         CMD2(0xde, 0x05, 0x0a), /* OEV timing control */
177         CMD2(0xdf, 0x0a, 0x19), /* ASW timing control (1) */
178         CMD1(0xe0, 0x0a),       /* ASW timing control (2) */
179         CMD0(0x21),             /* Invert for normally black display */
180         CMD0(0x29),             /* Display on */
181 };
182
183 static uint32_t lcd_panel_config[] = {
184         CMD2(0xb8, 0xff, 0xf9), /* Output control */
185         CMD0(0x11),             /* sleep out */
186         CMD1(0xba, 0x01),       /* Display mode (1) */
187         CMD1(0xbb, 0x00),       /* Display mode (2) */
188         CMD1(0x3a, 0x60),       /* Display mode 18-bit RGB */
189         CMD1(0xbf, 0x10),       /* Drive system change control */
190         CMD1(0xb1, 0x56),       /* Booster operation setup */
191         CMD1(0xb2, 0x33),       /* Booster mode setup */
192         CMD1(0xb3, 0x11),       /* Booster frequency setup */
193         CMD1(0xb4, 0x02),       /* Op amp/system clock */
194         CMD1(0xb5, 0x35),       /* VCS voltage */
195         CMD1(0xb6, 0x40),       /* VCOM voltage */
196         CMD1(0xb7, 0x03),       /* External display signal */
197         CMD1(0xbd, 0x00),       /* ASW slew rate */
198         CMD1(0xbe, 0x00),       /* Dummy data for QuadData operation */
199         CMD1(0xc0, 0x11),       /* Sleep out FR count (A) */
200         CMD1(0xc1, 0x11),       /* Sleep out FR count (B) */
201         CMD1(0xc2, 0x11),       /* Sleep out FR count (C) */
202         CMD2(0xc3, 0x20, 0x40), /* Sleep out FR count (D) */
203         CMD2(0xc4, 0x60, 0xc0), /* Sleep out FR count (E) */
204         CMD2(0xc5, 0x10, 0x20), /* Sleep out FR count (F) */
205         CMD1(0xc6, 0xc0),       /* Sleep out FR count (G) */
206         CMD2(0xc7, 0x33, 0x43), /* Gamma 1 fine tuning (1) */
207         CMD1(0xc8, 0x44),       /* Gamma 1 fine tuning (2) */
208         CMD1(0xc9, 0x33),       /* Gamma 1 inclination adjustment */
209         CMD1(0xca, 0x00),       /* Gamma 1 blue offset adjustment */
210         CMD2(0xec, 0x01, 0xf0), /* Horizontal clock cycles */
211 };
212
213 static void ssp_reconfig(struct ssp_dev *dev, int nparam)
214 {
215         static int last_nparam = -1;
216
217         /* check if it is necessary to re-config SSP */
218         if (nparam == last_nparam)
219                 return;
220
221         ssp_disable(dev);
222         ssp_config(dev, (nparam == 2) ? 0x0010058a : 0x00100581, 0x18, 0, 0);
223
224         last_nparam = nparam;
225 }
226
227 static void ssp_send_cmd(uint32_t *cmd, int num)
228 {
229         static int ssp_initialized;
230         static struct ssp_dev ssp2;
231
232         int i;
233
234         if (!ssp_initialized) {
235                 ssp_init(&ssp2, 2, SSP_NO_IRQ);
236                 ssp_initialized = 1;
237         }
238
239         clk_enable(ssp2.ssp->clk);
240         for (i = 0; i < num; i++, cmd++) {
241                 ssp_reconfig(&ssp2, (*cmd >> 30) & 0x3);
242                 ssp_write_word(&ssp2, *cmd & 0x3fffffff);
243
244                 /* FIXME: ssp_flush() is mandatory here to work */
245                 ssp_flush(&ssp2);
246         }
247         clk_disable(ssp2.ssp->clk);
248 }
249
250 static void littleton_lcd_power(int on, struct fb_var_screeninfo *var)
251 {
252         if (on) {
253                 ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_on));
254                 ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_reset));
255                 if (var->xres > 240) {
256                         /* VGA */
257                         ssp_send_cmd(ARRAY_AND_SIZE(lcd_vga_pass_through));
258                         ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_config));
259                         ssp_send_cmd(ARRAY_AND_SIZE(lcd_vga_transfer));
260                 } else {
261                         /* QVGA */
262                         ssp_send_cmd(ARRAY_AND_SIZE(lcd_qvga_pass_through));
263                         ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_config));
264                         ssp_send_cmd(ARRAY_AND_SIZE(lcd_qvga_transfer));
265                 }
266         } else
267                 ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_off));
268 }
269
270 static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = {
271         [0] = {
272                 /* VGA */
273                 .pixclock       = 38250,
274                 .xres           = 480,
275                 .yres           = 640,
276                 .bpp            = 16,
277                 .hsync_len      = 8,
278                 .left_margin    = 8,
279                 .right_margin   = 24,
280                 .vsync_len      = 2,
281                 .upper_margin   = 2,
282                 .lower_margin   = 4,
283                 .sync           = 0,
284         },
285         [1] = {
286                 /* QVGA */
287                 .pixclock       = 153000,
288                 .xres           = 240,
289                 .yres           = 320,
290                 .bpp            = 16,
291                 .hsync_len      = 8,
292                 .left_margin    = 8,
293                 .right_margin   = 88,
294                 .vsync_len      = 2,
295                 .upper_margin   = 2,
296                 .lower_margin   = 2,
297                 .sync           = 0,
298         },
299 };
300
301 static struct pxafb_mach_info littleton_lcd_info = {
302         .modes                  = tpo_tdo24mtea1_modes,
303         .num_modes              = 2,
304         .lcd_conn               = LCD_COLOR_TFT_16BPP,
305         .pxafb_lcd_power        = littleton_lcd_power,
306 };
307
308 static void littleton_init_lcd(void)
309 {
310         set_pxa_fb_info(&littleton_lcd_info);
311 }
312 #else
313 static inline void littleton_init_lcd(void) {};
314 #endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULES */
315
316 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULES)
317 static unsigned int littleton_matrix_key_map[] = {
318         /* KEY(row, col, key_code) */
319         KEY(1, 3, KEY_0), KEY(0, 0, KEY_1), KEY(1, 0, KEY_2), KEY(2, 0, KEY_3),
320         KEY(0, 1, KEY_4), KEY(1, 1, KEY_5), KEY(2, 1, KEY_6), KEY(0, 2, KEY_7),
321         KEY(1, 2, KEY_8), KEY(2, 2, KEY_9),
322
323         KEY(0, 3, KEY_KPASTERISK),      /* * */
324         KEY(2, 3, KEY_KPDOT),           /* # */
325
326         KEY(5, 4, KEY_ENTER),
327
328         KEY(5, 0, KEY_UP),
329         KEY(5, 1, KEY_DOWN),
330         KEY(5, 2, KEY_LEFT),
331         KEY(5, 3, KEY_RIGHT),
332         KEY(3, 2, KEY_HOME),
333         KEY(4, 1, KEY_END),
334         KEY(3, 3, KEY_BACK),
335
336         KEY(4, 0, KEY_SEND),
337         KEY(4, 2, KEY_VOLUMEUP),
338         KEY(4, 3, KEY_VOLUMEDOWN),
339
340         KEY(3, 0, KEY_F22),     /* soft1 */
341         KEY(3, 1, KEY_F23),     /* soft2 */
342 };
343
344 static struct pxa27x_keypad_platform_data littleton_keypad_info = {
345         .matrix_key_rows        = 6,
346         .matrix_key_cols        = 5,
347         .matrix_key_map         = littleton_matrix_key_map,
348         .matrix_key_map_size    = ARRAY_SIZE(littleton_matrix_key_map),
349
350         .enable_rotary0         = 1,
351         .rotary0_up_key         = KEY_UP,
352         .rotary0_down_key       = KEY_DOWN,
353
354         .debounce_interval      = 30,
355 };
356 static void __init littleton_init_keypad(void)
357 {
358         pxa_set_keypad_info(&littleton_keypad_info);
359 }
360 #else
361 static inline void littleton_init_keypad(void) {}
362 #endif
363
364 static void __init littleton_init(void)
365 {
366         /* initialize MFP configurations */
367         pxa3xx_mfp_config(ARRAY_AND_SIZE(littleton_mfp_cfg));
368
369         /*
370          * Note: we depend bootloader set the correct
371          * value to MSC register for SMC91x.
372          */
373         platform_device_register(&smc91x_device);
374
375         littleton_init_lcd();
376         littleton_init_keypad();
377 }
378
379 MACHINE_START(LITTLETON, "Marvell Form Factor Development Platform (aka Littleton)")
380         .phys_io        = 0x40000000,
381         .boot_params    = 0xa0000100,
382         .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
383         .map_io         = pxa_map_io,
384         .init_irq       = pxa3xx_init_irq,
385         .timer          = &pxa_timer,
386         .init_machine   = littleton_init,
387 MACHINE_END