blob: 4680efe553459bd6c98e3d4c771d7633c3a840a1 [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>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020027#include <linux/platform_data/video-pxafb.h>
28#include <linux/platform_data/keypad-pxa27x.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] = {
Haojian Zhuang4929f5a2011-10-10 16:03:51 +080088 .start = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO47)),
89 .end = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO47)),
Eric Miaobae03312008-07-11 12:59:38 +080090 .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)
Chao Xie0a085a92013-05-05 20:24:58 -0700109static const unsigned int tavorevb_matrix_key_map[] = {
Eric Miao9f1442b2008-12-28 00:40:29 +0800110 /* 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
Chao Xie0a085a92013-05-05 20:24:58 -0700150static struct matrix_keymap_data tavorevb_matrix_keymap_data = {
151 .keymap = tavorevb_matrix_key_map,
152 .keymap_size = ARRAY_SIZE(tavorevb_matrix_key_map),
153};
154
Eric Miao9f1442b2008-12-28 00:40:29 +0800155static struct pxa27x_keypad_platform_data tavorevb_keypad_info = {
156 .matrix_key_rows = 7,
157 .matrix_key_cols = 7,
Chao Xie0a085a92013-05-05 20:24:58 -0700158 .matrix_keymap_data = &tavorevb_matrix_keymap_data,
Eric Miao9f1442b2008-12-28 00:40:29 +0800159 .debounce_interval = 30,
160};
161
162static void __init tavorevb_init_keypad(void)
163{
164 pxa_set_keypad_info(&tavorevb_keypad_info);
165}
166#else
167static inline void tavorevb_init_keypad(void) {}
168#endif /* CONFIG_KEYBOARD_PXA27x || CONFIG_KEYBOARD_PXA27x_MODULE */
169
170#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
171static struct platform_pwm_backlight_data tavorevb_backlight_data[] = {
172 [0] = {
173 /* primary backlight */
174 .pwm_id = 2,
175 .max_brightness = 100,
176 .dft_brightness = 100,
177 .pwm_period_ns = 100000,
178 },
179 [1] = {
180 /* secondary backlight */
181 .pwm_id = 0,
182 .max_brightness = 100,
183 .dft_brightness = 100,
184 .pwm_period_ns = 100000,
185 },
186};
187
188static struct platform_device tavorevb_backlight_devices[] = {
189 [0] = {
190 .name = "pwm-backlight",
191 .id = 0,
192 .dev = {
193 .platform_data = &tavorevb_backlight_data[0],
194 },
195 },
196 [1] = {
197 .name = "pwm-backlight",
198 .id = 1,
199 .dev = {
200 .platform_data = &tavorevb_backlight_data[1],
201 },
202 },
203};
204
205static uint16_t panel_init[] = {
206 /* DSTB OUT */
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 SMART_CMD(0x00),
216 SMART_CMD_NOOP,
217 SMART_DELAY(1),
218
219 /* STB OUT */
220 SMART_CMD(0x00),
221 SMART_CMD(0x1D),
222 SMART_DAT(0x00),
223 SMART_DAT(0x05),
224 SMART_DELAY(1),
225
226 /* P-ON Init sequence */
227 SMART_CMD(0x00), /* OSC ON */
228 SMART_CMD(0x00),
229 SMART_DAT(0x00),
230 SMART_DAT(0x01),
231 SMART_CMD(0x00),
232 SMART_CMD(0x01), /* SOURCE DRIVER SHIFT DIRECTION and display RAM setting */
233 SMART_DAT(0x01),
234 SMART_DAT(0x27),
235 SMART_CMD(0x00),
236 SMART_CMD(0x02), /* LINE INV */
237 SMART_DAT(0x02),
238 SMART_DAT(0x00),
239 SMART_CMD(0x00),
240 SMART_CMD(0x03), /* IF mode(1) */
241 SMART_DAT(0x01), /* 8bit smart mode(8-8),high speed write mode */
242 SMART_DAT(0x30),
243 SMART_CMD(0x07),
244 SMART_CMD(0x00), /* RAM Write Mode */
245 SMART_DAT(0x00),
246 SMART_DAT(0x03),
247 SMART_CMD(0x00),
248
249 /* DISPLAY Setting, 262K, fixed(NO scroll), no split screen */
250 SMART_CMD(0x07),
251 SMART_DAT(0x40), /* 16/18/19 BPP */
252 SMART_DAT(0x00),
253 SMART_CMD(0x00),
254 SMART_CMD(0x08), /* BP, FP Seting, BP=2H, FP=3H */
255 SMART_DAT(0x03),
256 SMART_DAT(0x02),
257 SMART_CMD(0x00),
258 SMART_CMD(0x0C), /* IF mode(2), using internal clock & MPU */
259 SMART_DAT(0x00),
260 SMART_DAT(0x00),
261 SMART_CMD(0x00),
262 SMART_CMD(0x0D), /* Frame setting, 1Min. Frequence, 16CLK */
263 SMART_DAT(0x00),
264 SMART_DAT(0x10),
265 SMART_CMD(0x00),
266 SMART_CMD(0x12), /* Timing(1),ASW W=4CLK, ASW ST=1CLK */
267 SMART_DAT(0x03),
268 SMART_DAT(0x02),
269 SMART_CMD(0x00),
270 SMART_CMD(0x13), /* Timing(2),OEV ST=0.5CLK, OEV ED=1CLK */
271 SMART_DAT(0x01),
272 SMART_DAT(0x02),
273 SMART_CMD(0x00),
274 SMART_CMD(0x14), /* Timing(3), ASW HOLD=0.5CLK */
275 SMART_DAT(0x00),
276 SMART_DAT(0x00),
277 SMART_CMD(0x00),
278 SMART_CMD(0x15), /* Timing(4), CKV ST=0CLK, CKV ED=1CLK */
279 SMART_DAT(0x20),
280 SMART_DAT(0x00),
281 SMART_CMD(0x00),
282 SMART_CMD(0x1C),
283 SMART_DAT(0x00),
284 SMART_DAT(0x00),
285 SMART_CMD(0x03),
286 SMART_CMD(0x00),
287 SMART_DAT(0x04),
288 SMART_DAT(0x03),
289 SMART_CMD(0x03),
290 SMART_CMD(0x01),
291 SMART_DAT(0x03),
292 SMART_DAT(0x04),
293 SMART_CMD(0x03),
294 SMART_CMD(0x02),
295 SMART_DAT(0x04),
296 SMART_DAT(0x03),
297 SMART_CMD(0x03),
298 SMART_CMD(0x03),
299 SMART_DAT(0x03),
300 SMART_DAT(0x03),
301 SMART_CMD(0x03),
302 SMART_CMD(0x04),
303 SMART_DAT(0x01),
304 SMART_DAT(0x01),
305 SMART_CMD(0x03),
306 SMART_CMD(0x05),
307 SMART_DAT(0x00),
308 SMART_DAT(0x00),
309 SMART_CMD(0x04),
310 SMART_CMD(0x02),
311 SMART_DAT(0x00),
312 SMART_DAT(0x00),
313 SMART_CMD(0x04),
314 SMART_CMD(0x03),
315 SMART_DAT(0x01),
316 SMART_DAT(0x3F),
317 SMART_DELAY(0),
318
319 /* DISP RAM setting: 240*320 */
320 SMART_CMD(0x04), /* HADDR, START 0 */
321 SMART_CMD(0x06),
322 SMART_DAT(0x00),
323 SMART_DAT(0x00), /* x1,3 */
324 SMART_CMD(0x04), /* HADDR, END 4 */
325 SMART_CMD(0x07),
326 SMART_DAT(0x00),
327 SMART_DAT(0xEF), /* x2, 7 */
328 SMART_CMD(0x04), /* VADDR, START 8 */
329 SMART_CMD(0x08),
330 SMART_DAT(0x00), /* y1, 10 */
331 SMART_DAT(0x00), /* y1, 11 */
332 SMART_CMD(0x04), /* VADDR, END 12 */
333 SMART_CMD(0x09),
334 SMART_DAT(0x01), /* y2, 14 */
335 SMART_DAT(0x3F), /* y2, 15 */
336 SMART_CMD(0x02), /* RAM ADDR SETTING 16 */
337 SMART_CMD(0x00),
338 SMART_DAT(0x00),
339 SMART_DAT(0x00), /* x1, 19 */
340 SMART_CMD(0x02), /* RAM ADDR SETTING 20 */
341 SMART_CMD(0x01),
342 SMART_DAT(0x00), /* y1, 22 */
343 SMART_DAT(0x00), /* y1, 23 */
344};
345
346static uint16_t panel_on[] = {
347 /* Power-IC ON */
348 SMART_CMD(0x01),
349 SMART_CMD(0x02),
350 SMART_DAT(0x07),
351 SMART_DAT(0x7D),
352 SMART_CMD(0x01),
353 SMART_CMD(0x03),
354 SMART_DAT(0x00),
355 SMART_DAT(0x05),
356 SMART_CMD(0x01),
357 SMART_CMD(0x04),
358 SMART_DAT(0x00),
359 SMART_DAT(0x00),
360 SMART_CMD(0x01),
361 SMART_CMD(0x05),
362 SMART_DAT(0x00),
363 SMART_DAT(0x15),
364 SMART_CMD(0x01),
365 SMART_CMD(0x00),
366 SMART_DAT(0xC0),
367 SMART_DAT(0x10),
368 SMART_DELAY(30),
369
370 /* DISP ON */
371 SMART_CMD(0x01),
372 SMART_CMD(0x01),
373 SMART_DAT(0x00),
374 SMART_DAT(0x01),
375 SMART_CMD(0x01),
376 SMART_CMD(0x00),
377 SMART_DAT(0xFF),
378 SMART_DAT(0xFE),
379 SMART_DELAY(150),
380};
381
382static uint16_t panel_off[] = {
383 SMART_CMD(0x00),
384 SMART_CMD(0x1E),
385 SMART_DAT(0x00),
386 SMART_DAT(0x0A),
387 SMART_CMD(0x01),
388 SMART_CMD(0x00),
389 SMART_DAT(0xFF),
390 SMART_DAT(0xEE),
391 SMART_CMD(0x01),
392 SMART_CMD(0x00),
393 SMART_DAT(0xF8),
394 SMART_DAT(0x12),
395 SMART_CMD(0x01),
396 SMART_CMD(0x00),
397 SMART_DAT(0xE8),
398 SMART_DAT(0x11),
399 SMART_CMD(0x01),
400 SMART_CMD(0x00),
401 SMART_DAT(0xC0),
402 SMART_DAT(0x11),
403 SMART_CMD(0x01),
404 SMART_CMD(0x00),
405 SMART_DAT(0x40),
406 SMART_DAT(0x11),
407 SMART_CMD(0x01),
408 SMART_CMD(0x00),
409 SMART_DAT(0x00),
410 SMART_DAT(0x10),
411};
412
413static uint16_t update_framedata[] = {
414 /* write ram */
415 SMART_CMD(0x02),
416 SMART_CMD(0x02),
417
418 /* write frame data */
419 SMART_CMD_WRITE_FRAME,
420};
421
422static void ltm020d550_lcd_power(int on, struct fb_var_screeninfo *var)
423{
424 struct fb_info *info = container_of(var, struct fb_info, var);
425
426 if (on) {
427 pxafb_smart_queue(info, ARRAY_AND_SIZE(panel_init));
428 pxafb_smart_queue(info, ARRAY_AND_SIZE(panel_on));
429 } else {
430 pxafb_smart_queue(info, ARRAY_AND_SIZE(panel_off));
431 }
432
433 if (pxafb_smart_flush(info))
434 pr_err("%s: timed out\n", __func__);
435}
436
437static void ltm020d550_update(struct fb_info *info)
438{
439 pxafb_smart_queue(info, ARRAY_AND_SIZE(update_framedata));
440 pxafb_smart_flush(info);
441}
442
443static struct pxafb_mode_info toshiba_ltm020d550_modes[] = {
444 [0] = {
445 .xres = 240,
446 .yres = 320,
447 .bpp = 16,
448 .a0csrd_set_hld = 30,
449 .a0cswr_set_hld = 30,
450 .wr_pulse_width = 30,
451 .rd_pulse_width = 170,
452 .op_hold_time = 30,
453 .cmd_inh_time = 60,
454
455 /* L_LCLK_A0 and L_LCLK_RD active low */
456 .sync = FB_SYNC_HOR_HIGH_ACT |
457 FB_SYNC_VERT_HIGH_ACT,
458 },
459};
460
461static struct pxafb_mach_info tavorevb_lcd_info = {
462 .modes = toshiba_ltm020d550_modes,
463 .num_modes = 1,
464 .lcd_conn = LCD_SMART_PANEL_8BPP | LCD_PCLK_EDGE_FALL,
465 .pxafb_lcd_power = ltm020d550_lcd_power,
466 .smart_update = ltm020d550_update,
467};
468
469static void __init tavorevb_init_lcd(void)
470{
471 platform_device_register(&tavorevb_backlight_devices[0]);
472 platform_device_register(&tavorevb_backlight_devices[1]);
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800473 pxa_set_fb_info(NULL, &tavorevb_lcd_info);
Eric Miao9f1442b2008-12-28 00:40:29 +0800474}
475#else
476static inline void tavorevb_init_lcd(void) {}
477#endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */
478
Eric Miaobae03312008-07-11 12:59:38 +0800479static void __init tavorevb_init(void)
480{
481 /* initialize MFP configurations */
482 pxa3xx_mfp_config(ARRAY_AND_SIZE(tavorevb_mfp_cfg));
483
Russell Kingcc155c62009-11-09 13:34:08 +0800484 pxa_set_ffuart_info(NULL);
485 pxa_set_btuart_info(NULL);
486 pxa_set_stuart_info(NULL);
487
Eric Miaobae03312008-07-11 12:59:38 +0800488 platform_device_register(&smc91x_device);
Eric Miao9f1442b2008-12-28 00:40:29 +0800489
490 tavorevb_init_lcd();
491 tavorevb_init_keypad();
Eric Miaobae03312008-07-11 12:59:38 +0800492}
493
494MACHINE_START(TAVOREVB, "PXA930 Evaluation Board (aka TavorEVB)")
495 /* Maintainer: Eric Miao <eric.miao@marvell.com> */
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400496 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +0200497 .map_io = pxa3xx_map_io,
Rob Herring4e611092012-01-03 16:53:48 -0600498 .nr_irqs = PXA_NR_IRQS,
Eric Miaobae03312008-07-11 12:59:38 +0800499 .init_irq = pxa3xx_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800500 .handle_irq = pxa3xx_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700501 .init_time = pxa_timer_init,
Eric Miaobae03312008-07-11 12:59:38 +0800502 .init_machine = tavorevb_init,
Russell King271a74f2011-11-04 14:15:53 +0000503 .restart = pxa_restart,
Eric Miaobae03312008-07-11 12:59:38 +0800504MACHINE_END