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