blob: 58ef08a5224b566b18331da22d8a04a0d0923973 [file] [log] [blame]
Eric Miaobae03312008-07-11 12:59:38 +08001/*
2 * linux/arch/arm/mach-pxa/tavorevb.c
3 *
4 * Support for the Marvell PXA930 Evaluation Board
5 *
6 * Copyright (C) 2007-2008 Marvell International Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * publishhed by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/interrupt.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/clk.h>
19#include <linux/gpio.h>
20#include <linux/smc91x.h>
Eric Miao9f1442b2008-12-28 00:40:29 +080021#include <linux/pwm_backlight.h>
Eric Miaobae03312008-07-11 12:59:38 +080022
23#include <asm/mach-types.h>
24#include <asm/mach/arch.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010025#include <mach/hardware.h>
26#include <mach/pxa3xx-regs.h>
27#include <mach/mfp-pxa930.h>
Eric Miao9f1442b2008-12-28 00:40:29 +080028#include <mach/pxafb.h>
29#include <mach/pxa27x_keypad.h>
Eric Miaobae03312008-07-11 12:59:38 +080030
31#include "devices.h"
32#include "generic.h"
33
34/* Tavor EVB MFP configurations */
35static mfp_cfg_t tavorevb_mfp_cfg[] __initdata = {
36 /* Ethernet */
37 DF_nCS1_nCS3,
38 GPIO47_GPIO,
Eric Miao9f1442b2008-12-28 00:40:29 +080039
40 /* LCD */
41 GPIO23_LCD_DD0,
42 GPIO24_LCD_DD1,
43 GPIO25_LCD_DD2,
44 GPIO26_LCD_DD3,
45 GPIO27_LCD_DD4,
46 GPIO28_LCD_DD5,
47 GPIO29_LCD_DD6,
48 GPIO44_LCD_DD7,
49 GPIO21_LCD_CS,
50 GPIO22_LCD_CS2,
51
52 GPIO17_LCD_FCLK_RD,
53 GPIO18_LCD_LCLK_A0,
54 GPIO19_LCD_PCLK_WR,
55
56 /* LCD Backlight */
57 GPIO43_PWM3, /* primary backlight */
58 GPIO32_PWM0, /* secondary backlight */
59
60 /* Keypad */
61 GPIO0_KP_MKIN_0,
62 GPIO2_KP_MKIN_1,
63 GPIO4_KP_MKIN_2,
64 GPIO6_KP_MKIN_3,
65 GPIO8_KP_MKIN_4,
66 GPIO10_KP_MKIN_5,
67 GPIO12_KP_MKIN_6,
68 GPIO1_KP_MKOUT_0,
69 GPIO3_KP_MKOUT_1,
70 GPIO5_KP_MKOUT_2,
71 GPIO7_KP_MKOUT_3,
72 GPIO9_KP_MKOUT_4,
73 GPIO11_KP_MKOUT_5,
74 GPIO13_KP_MKOUT_6,
75
76 GPIO14_KP_DKIN_2,
77 GPIO15_KP_DKIN_3,
Eric Miaobae03312008-07-11 12:59:38 +080078};
79
80#define TAVOREVB_ETH_PHYS (0x14000000)
81
82static struct resource smc91x_resources[] = {
83 [0] = {
84 .start = (TAVOREVB_ETH_PHYS + 0x300),
85 .end = (TAVOREVB_ETH_PHYS + 0xfffff),
86 .flags = IORESOURCE_MEM,
87 },
88 [1] = {
89 .start = gpio_to_irq(mfp_to_gpio(MFP_PIN_GPIO47)),
90 .end = gpio_to_irq(mfp_to_gpio(MFP_PIN_GPIO47)),
91 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
92 }
93};
94
95static struct smc91x_platdata tavorevb_smc91x_info = {
96 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT | SMC91X_USE_DMA,
97};
98
99static struct platform_device smc91x_device = {
100 .name = "smc91x",
101 .id = 0,
102 .num_resources = ARRAY_SIZE(smc91x_resources),
103 .resource = smc91x_resources,
104 .dev = {
105 .platform_data = &tavorevb_smc91x_info,
106 },
107};
108
Eric Miao9f1442b2008-12-28 00:40:29 +0800109#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
110static unsigned int tavorevb_matrix_key_map[] = {
111 /* KEY(row, col, key_code) */
112 KEY(0, 4, KEY_A), KEY(0, 5, KEY_B), KEY(0, 6, KEY_C),
113 KEY(1, 4, KEY_E), KEY(1, 5, KEY_F), KEY(1, 6, KEY_G),
114 KEY(2, 4, KEY_I), KEY(2, 5, KEY_J), KEY(2, 6, KEY_K),
115 KEY(3, 4, KEY_M), KEY(3, 5, KEY_N), KEY(3, 6, KEY_O),
116 KEY(4, 5, KEY_R), KEY(4, 6, KEY_S),
117 KEY(5, 4, KEY_U), KEY(5, 4, KEY_V), KEY(5, 6, KEY_W),
118
119 KEY(6, 4, KEY_Y), KEY(6, 5, KEY_Z),
120
121 KEY(0, 3, KEY_0), KEY(2, 0, KEY_1), KEY(2, 1, KEY_2), KEY(2, 2, KEY_3),
122 KEY(2, 3, KEY_4), KEY(1, 0, KEY_5), KEY(1, 1, KEY_6), KEY(1, 2, KEY_7),
123 KEY(1, 3, KEY_8), KEY(0, 2, KEY_9),
124
125 KEY(6, 6, KEY_SPACE),
126 KEY(0, 0, KEY_KPASTERISK), /* * */
127 KEY(0, 1, KEY_KPDOT), /* # */
128
129 KEY(4, 1, KEY_UP),
130 KEY(4, 3, KEY_DOWN),
131 KEY(4, 0, KEY_LEFT),
132 KEY(4, 2, KEY_RIGHT),
133 KEY(6, 0, KEY_HOME),
134 KEY(3, 2, KEY_END),
135 KEY(6, 1, KEY_DELETE),
136 KEY(5, 2, KEY_BACK),
137 KEY(6, 3, KEY_CAPSLOCK), /* KEY_LEFTSHIFT), */
138
139 KEY(4, 4, KEY_ENTER), /* scroll push */
140 KEY(6, 2, KEY_ENTER), /* keypad action */
141
142 KEY(3, 1, KEY_SEND),
143 KEY(5, 3, KEY_RECORD),
144 KEY(5, 0, KEY_VOLUMEUP),
145 KEY(5, 1, KEY_VOLUMEDOWN),
146
147 KEY(3, 0, KEY_F22), /* soft1 */
148 KEY(3, 3, KEY_F23), /* soft2 */
149};
150
151static struct pxa27x_keypad_platform_data tavorevb_keypad_info = {
152 .matrix_key_rows = 7,
153 .matrix_key_cols = 7,
154 .matrix_key_map = tavorevb_matrix_key_map,
155 .matrix_key_map_size = ARRAY_SIZE(tavorevb_matrix_key_map),
156 .debounce_interval = 30,
157};
158
159static void __init tavorevb_init_keypad(void)
160{
161 pxa_set_keypad_info(&tavorevb_keypad_info);
162}
163#else
164static inline void tavorevb_init_keypad(void) {}
165#endif /* CONFIG_KEYBOARD_PXA27x || CONFIG_KEYBOARD_PXA27x_MODULE */
166
167#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
168static struct platform_pwm_backlight_data tavorevb_backlight_data[] = {
169 [0] = {
170 /* primary backlight */
171 .pwm_id = 2,
172 .max_brightness = 100,
173 .dft_brightness = 100,
174 .pwm_period_ns = 100000,
175 },
176 [1] = {
177 /* secondary backlight */
178 .pwm_id = 0,
179 .max_brightness = 100,
180 .dft_brightness = 100,
181 .pwm_period_ns = 100000,
182 },
183};
184
185static struct platform_device tavorevb_backlight_devices[] = {
186 [0] = {
187 .name = "pwm-backlight",
188 .id = 0,
189 .dev = {
190 .platform_data = &tavorevb_backlight_data[0],
191 },
192 },
193 [1] = {
194 .name = "pwm-backlight",
195 .id = 1,
196 .dev = {
197 .platform_data = &tavorevb_backlight_data[1],
198 },
199 },
200};
201
202static uint16_t panel_init[] = {
203 /* DSTB OUT */
204 SMART_CMD(0x00),
205 SMART_CMD_NOOP,
206 SMART_DELAY(1),
207
208 SMART_CMD(0x00),
209 SMART_CMD_NOOP,
210 SMART_DELAY(1),
211
212 SMART_CMD(0x00),
213 SMART_CMD_NOOP,
214 SMART_DELAY(1),
215
216 /* STB OUT */
217 SMART_CMD(0x00),
218 SMART_CMD(0x1D),
219 SMART_DAT(0x00),
220 SMART_DAT(0x05),
221 SMART_DELAY(1),
222
223 /* P-ON Init sequence */
224 SMART_CMD(0x00), /* OSC ON */
225 SMART_CMD(0x00),
226 SMART_DAT(0x00),
227 SMART_DAT(0x01),
228 SMART_CMD(0x00),
229 SMART_CMD(0x01), /* SOURCE DRIVER SHIFT DIRECTION and display RAM setting */
230 SMART_DAT(0x01),
231 SMART_DAT(0x27),
232 SMART_CMD(0x00),
233 SMART_CMD(0x02), /* LINE INV */
234 SMART_DAT(0x02),
235 SMART_DAT(0x00),
236 SMART_CMD(0x00),
237 SMART_CMD(0x03), /* IF mode(1) */
238 SMART_DAT(0x01), /* 8bit smart mode(8-8),high speed write mode */
239 SMART_DAT(0x30),
240 SMART_CMD(0x07),
241 SMART_CMD(0x00), /* RAM Write Mode */
242 SMART_DAT(0x00),
243 SMART_DAT(0x03),
244 SMART_CMD(0x00),
245
246 /* DISPLAY Setting, 262K, fixed(NO scroll), no split screen */
247 SMART_CMD(0x07),
248 SMART_DAT(0x40), /* 16/18/19 BPP */
249 SMART_DAT(0x00),
250 SMART_CMD(0x00),
251 SMART_CMD(0x08), /* BP, FP Seting, BP=2H, FP=3H */
252 SMART_DAT(0x03),
253 SMART_DAT(0x02),
254 SMART_CMD(0x00),
255 SMART_CMD(0x0C), /* IF mode(2), using internal clock & MPU */
256 SMART_DAT(0x00),
257 SMART_DAT(0x00),
258 SMART_CMD(0x00),
259 SMART_CMD(0x0D), /* Frame setting, 1Min. Frequence, 16CLK */
260 SMART_DAT(0x00),
261 SMART_DAT(0x10),
262 SMART_CMD(0x00),
263 SMART_CMD(0x12), /* Timing(1),ASW W=4CLK, ASW ST=1CLK */
264 SMART_DAT(0x03),
265 SMART_DAT(0x02),
266 SMART_CMD(0x00),
267 SMART_CMD(0x13), /* Timing(2),OEV ST=0.5CLK, OEV ED=1CLK */
268 SMART_DAT(0x01),
269 SMART_DAT(0x02),
270 SMART_CMD(0x00),
271 SMART_CMD(0x14), /* Timing(3), ASW HOLD=0.5CLK */
272 SMART_DAT(0x00),
273 SMART_DAT(0x00),
274 SMART_CMD(0x00),
275 SMART_CMD(0x15), /* Timing(4), CKV ST=0CLK, CKV ED=1CLK */
276 SMART_DAT(0x20),
277 SMART_DAT(0x00),
278 SMART_CMD(0x00),
279 SMART_CMD(0x1C),
280 SMART_DAT(0x00),
281 SMART_DAT(0x00),
282 SMART_CMD(0x03),
283 SMART_CMD(0x00),
284 SMART_DAT(0x04),
285 SMART_DAT(0x03),
286 SMART_CMD(0x03),
287 SMART_CMD(0x01),
288 SMART_DAT(0x03),
289 SMART_DAT(0x04),
290 SMART_CMD(0x03),
291 SMART_CMD(0x02),
292 SMART_DAT(0x04),
293 SMART_DAT(0x03),
294 SMART_CMD(0x03),
295 SMART_CMD(0x03),
296 SMART_DAT(0x03),
297 SMART_DAT(0x03),
298 SMART_CMD(0x03),
299 SMART_CMD(0x04),
300 SMART_DAT(0x01),
301 SMART_DAT(0x01),
302 SMART_CMD(0x03),
303 SMART_CMD(0x05),
304 SMART_DAT(0x00),
305 SMART_DAT(0x00),
306 SMART_CMD(0x04),
307 SMART_CMD(0x02),
308 SMART_DAT(0x00),
309 SMART_DAT(0x00),
310 SMART_CMD(0x04),
311 SMART_CMD(0x03),
312 SMART_DAT(0x01),
313 SMART_DAT(0x3F),
314 SMART_DELAY(0),
315
316 /* DISP RAM setting: 240*320 */
317 SMART_CMD(0x04), /* HADDR, START 0 */
318 SMART_CMD(0x06),
319 SMART_DAT(0x00),
320 SMART_DAT(0x00), /* x1,3 */
321 SMART_CMD(0x04), /* HADDR, END 4 */
322 SMART_CMD(0x07),
323 SMART_DAT(0x00),
324 SMART_DAT(0xEF), /* x2, 7 */
325 SMART_CMD(0x04), /* VADDR, START 8 */
326 SMART_CMD(0x08),
327 SMART_DAT(0x00), /* y1, 10 */
328 SMART_DAT(0x00), /* y1, 11 */
329 SMART_CMD(0x04), /* VADDR, END 12 */
330 SMART_CMD(0x09),
331 SMART_DAT(0x01), /* y2, 14 */
332 SMART_DAT(0x3F), /* y2, 15 */
333 SMART_CMD(0x02), /* RAM ADDR SETTING 16 */
334 SMART_CMD(0x00),
335 SMART_DAT(0x00),
336 SMART_DAT(0x00), /* x1, 19 */
337 SMART_CMD(0x02), /* RAM ADDR SETTING 20 */
338 SMART_CMD(0x01),
339 SMART_DAT(0x00), /* y1, 22 */
340 SMART_DAT(0x00), /* y1, 23 */
341};
342
343static uint16_t panel_on[] = {
344 /* Power-IC ON */
345 SMART_CMD(0x01),
346 SMART_CMD(0x02),
347 SMART_DAT(0x07),
348 SMART_DAT(0x7D),
349 SMART_CMD(0x01),
350 SMART_CMD(0x03),
351 SMART_DAT(0x00),
352 SMART_DAT(0x05),
353 SMART_CMD(0x01),
354 SMART_CMD(0x04),
355 SMART_DAT(0x00),
356 SMART_DAT(0x00),
357 SMART_CMD(0x01),
358 SMART_CMD(0x05),
359 SMART_DAT(0x00),
360 SMART_DAT(0x15),
361 SMART_CMD(0x01),
362 SMART_CMD(0x00),
363 SMART_DAT(0xC0),
364 SMART_DAT(0x10),
365 SMART_DELAY(30),
366
367 /* DISP ON */
368 SMART_CMD(0x01),
369 SMART_CMD(0x01),
370 SMART_DAT(0x00),
371 SMART_DAT(0x01),
372 SMART_CMD(0x01),
373 SMART_CMD(0x00),
374 SMART_DAT(0xFF),
375 SMART_DAT(0xFE),
376 SMART_DELAY(150),
377};
378
379static uint16_t panel_off[] = {
380 SMART_CMD(0x00),
381 SMART_CMD(0x1E),
382 SMART_DAT(0x00),
383 SMART_DAT(0x0A),
384 SMART_CMD(0x01),
385 SMART_CMD(0x00),
386 SMART_DAT(0xFF),
387 SMART_DAT(0xEE),
388 SMART_CMD(0x01),
389 SMART_CMD(0x00),
390 SMART_DAT(0xF8),
391 SMART_DAT(0x12),
392 SMART_CMD(0x01),
393 SMART_CMD(0x00),
394 SMART_DAT(0xE8),
395 SMART_DAT(0x11),
396 SMART_CMD(0x01),
397 SMART_CMD(0x00),
398 SMART_DAT(0xC0),
399 SMART_DAT(0x11),
400 SMART_CMD(0x01),
401 SMART_CMD(0x00),
402 SMART_DAT(0x40),
403 SMART_DAT(0x11),
404 SMART_CMD(0x01),
405 SMART_CMD(0x00),
406 SMART_DAT(0x00),
407 SMART_DAT(0x10),
408};
409
410static uint16_t update_framedata[] = {
411 /* write ram */
412 SMART_CMD(0x02),
413 SMART_CMD(0x02),
414
415 /* write frame data */
416 SMART_CMD_WRITE_FRAME,
417};
418
419static void ltm020d550_lcd_power(int on, struct fb_var_screeninfo *var)
420{
421 struct fb_info *info = container_of(var, struct fb_info, var);
422
423 if (on) {
424 pxafb_smart_queue(info, ARRAY_AND_SIZE(panel_init));
425 pxafb_smart_queue(info, ARRAY_AND_SIZE(panel_on));
426 } else {
427 pxafb_smart_queue(info, ARRAY_AND_SIZE(panel_off));
428 }
429
430 if (pxafb_smart_flush(info))
431 pr_err("%s: timed out\n", __func__);
432}
433
434static void ltm020d550_update(struct fb_info *info)
435{
436 pxafb_smart_queue(info, ARRAY_AND_SIZE(update_framedata));
437 pxafb_smart_flush(info);
438}
439
440static struct pxafb_mode_info toshiba_ltm020d550_modes[] = {
441 [0] = {
442 .xres = 240,
443 .yres = 320,
444 .bpp = 16,
445 .a0csrd_set_hld = 30,
446 .a0cswr_set_hld = 30,
447 .wr_pulse_width = 30,
448 .rd_pulse_width = 170,
449 .op_hold_time = 30,
450 .cmd_inh_time = 60,
451
452 /* L_LCLK_A0 and L_LCLK_RD active low */
453 .sync = FB_SYNC_HOR_HIGH_ACT |
454 FB_SYNC_VERT_HIGH_ACT,
455 },
456};
457
458static struct pxafb_mach_info tavorevb_lcd_info = {
459 .modes = toshiba_ltm020d550_modes,
460 .num_modes = 1,
461 .lcd_conn = LCD_SMART_PANEL_8BPP | LCD_PCLK_EDGE_FALL,
462 .pxafb_lcd_power = ltm020d550_lcd_power,
463 .smart_update = ltm020d550_update,
464};
465
466static void __init tavorevb_init_lcd(void)
467{
468 platform_device_register(&tavorevb_backlight_devices[0]);
469 platform_device_register(&tavorevb_backlight_devices[1]);
470 set_pxa_fb_info(&tavorevb_lcd_info);
471}
472#else
473static inline void tavorevb_init_lcd(void) {}
474#endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */
475
Eric Miaobae03312008-07-11 12:59:38 +0800476static void __init tavorevb_init(void)
477{
478 /* initialize MFP configurations */
479 pxa3xx_mfp_config(ARRAY_AND_SIZE(tavorevb_mfp_cfg));
480
481 platform_device_register(&smc91x_device);
Eric Miao9f1442b2008-12-28 00:40:29 +0800482
483 tavorevb_init_lcd();
484 tavorevb_init_keypad();
Eric Miaobae03312008-07-11 12:59:38 +0800485}
486
487MACHINE_START(TAVOREVB, "PXA930 Evaluation Board (aka TavorEVB)")
488 /* Maintainer: Eric Miao <eric.miao@marvell.com> */
489 .phys_io = 0x40000000,
490 .boot_params = 0xa0000100,
491 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
492 .map_io = pxa_map_io,
493 .init_irq = pxa3xx_init_irq,
494 .timer = &pxa_timer,
495 .init_machine = tavorevb_init,
496MACHINE_END