1
2
3
4
5
6
7
8
9
10
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>
21#include <linux/pwm_backlight.h>
22
23#include <asm/mach-types.h>
24#include <asm/mach/arch.h>
25
26#include <mach/pxa930.h>
27#include <linux/platform_data/video-pxafb.h>
28#include <linux/platform_data/keypad-pxa27x.h>
29
30#include "devices.h"
31#include "generic.h"
32
33
34static mfp_cfg_t tavorevb_mfp_cfg[] __initdata = {
35
36 DF_nCS1_nCS3,
37 GPIO47_GPIO,
38
39
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
56 GPIO43_PWM3,
57 GPIO32_PWM0,
58
59
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,
77};
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 = PXA_GPIO_TO_IRQ(mfp_to_gpio(MFP_PIN_GPIO47)),
89 .end = PXA_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
108#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
109static const unsigned int tavorevb_matrix_key_map[] = {
110
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),
137
138 KEY(4, 4, KEY_ENTER),
139 KEY(6, 2, KEY_ENTER),
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),
147 KEY(3, 3, KEY_F23),
148};
149
150static 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
155static struct pxa27x_keypad_platform_data tavorevb_keypad_info = {
156 .matrix_key_rows = 7,
157 .matrix_key_cols = 7,
158 .matrix_keymap_data = &tavorevb_matrix_keymap_data,
159 .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
169
170#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
171static struct platform_pwm_backlight_data tavorevb_backlight_data[] = {
172 [0] = {
173
174 .pwm_id = 2,
175 .max_brightness = 100,
176 .dft_brightness = 100,
177 .pwm_period_ns = 100000,
178 .enable_gpio = -1,
179 },
180 [1] = {
181
182 .pwm_id = 0,
183 .max_brightness = 100,
184 .dft_brightness = 100,
185 .pwm_period_ns = 100000,
186 .enable_gpio = -1,
187 },
188};
189
190static struct platform_device tavorevb_backlight_devices[] = {
191 [0] = {
192 .name = "pwm-backlight",
193 .id = 0,
194 .dev = {
195 .platform_data = &tavorevb_backlight_data[0],
196 },
197 },
198 [1] = {
199 .name = "pwm-backlight",
200 .id = 1,
201 .dev = {
202 .platform_data = &tavorevb_backlight_data[1],
203 },
204 },
205};
206
207static uint16_t panel_init[] = {
208
209 SMART_CMD(0x00),
210 SMART_CMD_NOOP,
211 SMART_DELAY(1),
212
213 SMART_CMD(0x00),
214 SMART_CMD_NOOP,
215 SMART_DELAY(1),
216
217 SMART_CMD(0x00),
218 SMART_CMD_NOOP,
219 SMART_DELAY(1),
220
221
222 SMART_CMD(0x00),
223 SMART_CMD(0x1D),
224 SMART_DAT(0x00),
225 SMART_DAT(0x05),
226 SMART_DELAY(1),
227
228
229 SMART_CMD(0x00),
230 SMART_CMD(0x00),
231 SMART_DAT(0x00),
232 SMART_DAT(0x01),
233 SMART_CMD(0x00),
234 SMART_CMD(0x01),
235 SMART_DAT(0x01),
236 SMART_DAT(0x27),
237 SMART_CMD(0x00),
238 SMART_CMD(0x02),
239 SMART_DAT(0x02),
240 SMART_DAT(0x00),
241 SMART_CMD(0x00),
242 SMART_CMD(0x03),
243 SMART_DAT(0x01),
244 SMART_DAT(0x30),
245 SMART_CMD(0x07),
246 SMART_CMD(0x00),
247 SMART_DAT(0x00),
248 SMART_DAT(0x03),
249 SMART_CMD(0x00),
250
251
252 SMART_CMD(0x07),
253 SMART_DAT(0x40),
254 SMART_DAT(0x00),
255 SMART_CMD(0x00),
256 SMART_CMD(0x08),
257 SMART_DAT(0x03),
258 SMART_DAT(0x02),
259 SMART_CMD(0x00),
260 SMART_CMD(0x0C),
261 SMART_DAT(0x00),
262 SMART_DAT(0x00),
263 SMART_CMD(0x00),
264 SMART_CMD(0x0D),
265 SMART_DAT(0x00),
266 SMART_DAT(0x10),
267 SMART_CMD(0x00),
268 SMART_CMD(0x12),
269 SMART_DAT(0x03),
270 SMART_DAT(0x02),
271 SMART_CMD(0x00),
272 SMART_CMD(0x13),
273 SMART_DAT(0x01),
274 SMART_DAT(0x02),
275 SMART_CMD(0x00),
276 SMART_CMD(0x14),
277 SMART_DAT(0x00),
278 SMART_DAT(0x00),
279 SMART_CMD(0x00),
280 SMART_CMD(0x15),
281 SMART_DAT(0x20),
282 SMART_DAT(0x00),
283 SMART_CMD(0x00),
284 SMART_CMD(0x1C),
285 SMART_DAT(0x00),
286 SMART_DAT(0x00),
287 SMART_CMD(0x03),
288 SMART_CMD(0x00),
289 SMART_DAT(0x04),
290 SMART_DAT(0x03),
291 SMART_CMD(0x03),
292 SMART_CMD(0x01),
293 SMART_DAT(0x03),
294 SMART_DAT(0x04),
295 SMART_CMD(0x03),
296 SMART_CMD(0x02),
297 SMART_DAT(0x04),
298 SMART_DAT(0x03),
299 SMART_CMD(0x03),
300 SMART_CMD(0x03),
301 SMART_DAT(0x03),
302 SMART_DAT(0x03),
303 SMART_CMD(0x03),
304 SMART_CMD(0x04),
305 SMART_DAT(0x01),
306 SMART_DAT(0x01),
307 SMART_CMD(0x03),
308 SMART_CMD(0x05),
309 SMART_DAT(0x00),
310 SMART_DAT(0x00),
311 SMART_CMD(0x04),
312 SMART_CMD(0x02),
313 SMART_DAT(0x00),
314 SMART_DAT(0x00),
315 SMART_CMD(0x04),
316 SMART_CMD(0x03),
317 SMART_DAT(0x01),
318 SMART_DAT(0x3F),
319 SMART_DELAY(0),
320
321
322 SMART_CMD(0x04),
323 SMART_CMD(0x06),
324 SMART_DAT(0x00),
325 SMART_DAT(0x00),
326 SMART_CMD(0x04),
327 SMART_CMD(0x07),
328 SMART_DAT(0x00),
329 SMART_DAT(0xEF),
330 SMART_CMD(0x04),
331 SMART_CMD(0x08),
332 SMART_DAT(0x00),
333 SMART_DAT(0x00),
334 SMART_CMD(0x04),
335 SMART_CMD(0x09),
336 SMART_DAT(0x01),
337 SMART_DAT(0x3F),
338 SMART_CMD(0x02),
339 SMART_CMD(0x00),
340 SMART_DAT(0x00),
341 SMART_DAT(0x00),
342 SMART_CMD(0x02),
343 SMART_CMD(0x01),
344 SMART_DAT(0x00),
345 SMART_DAT(0x00),
346};
347
348static uint16_t panel_on[] = {
349
350 SMART_CMD(0x01),
351 SMART_CMD(0x02),
352 SMART_DAT(0x07),
353 SMART_DAT(0x7D),
354 SMART_CMD(0x01),
355 SMART_CMD(0x03),
356 SMART_DAT(0x00),
357 SMART_DAT(0x05),
358 SMART_CMD(0x01),
359 SMART_CMD(0x04),
360 SMART_DAT(0x00),
361 SMART_DAT(0x00),
362 SMART_CMD(0x01),
363 SMART_CMD(0x05),
364 SMART_DAT(0x00),
365 SMART_DAT(0x15),
366 SMART_CMD(0x01),
367 SMART_CMD(0x00),
368 SMART_DAT(0xC0),
369 SMART_DAT(0x10),
370 SMART_DELAY(30),
371
372
373 SMART_CMD(0x01),
374 SMART_CMD(0x01),
375 SMART_DAT(0x00),
376 SMART_DAT(0x01),
377 SMART_CMD(0x01),
378 SMART_CMD(0x00),
379 SMART_DAT(0xFF),
380 SMART_DAT(0xFE),
381 SMART_DELAY(150),
382};
383
384static uint16_t panel_off[] = {
385 SMART_CMD(0x00),
386 SMART_CMD(0x1E),
387 SMART_DAT(0x00),
388 SMART_DAT(0x0A),
389 SMART_CMD(0x01),
390 SMART_CMD(0x00),
391 SMART_DAT(0xFF),
392 SMART_DAT(0xEE),
393 SMART_CMD(0x01),
394 SMART_CMD(0x00),
395 SMART_DAT(0xF8),
396 SMART_DAT(0x12),
397 SMART_CMD(0x01),
398 SMART_CMD(0x00),
399 SMART_DAT(0xE8),
400 SMART_DAT(0x11),
401 SMART_CMD(0x01),
402 SMART_CMD(0x00),
403 SMART_DAT(0xC0),
404 SMART_DAT(0x11),
405 SMART_CMD(0x01),
406 SMART_CMD(0x00),
407 SMART_DAT(0x40),
408 SMART_DAT(0x11),
409 SMART_CMD(0x01),
410 SMART_CMD(0x00),
411 SMART_DAT(0x00),
412 SMART_DAT(0x10),
413};
414
415static uint16_t update_framedata[] = {
416
417 SMART_CMD(0x02),
418 SMART_CMD(0x02),
419
420
421 SMART_CMD_WRITE_FRAME,
422};
423
424static void ltm020d550_lcd_power(int on, struct fb_var_screeninfo *var)
425{
426 struct fb_info *info = container_of(var, struct fb_info, var);
427
428 if (on) {
429 pxafb_smart_queue(info, ARRAY_AND_SIZE(panel_init));
430 pxafb_smart_queue(info, ARRAY_AND_SIZE(panel_on));
431 } else {
432 pxafb_smart_queue(info, ARRAY_AND_SIZE(panel_off));
433 }
434
435 if (pxafb_smart_flush(info))
436 pr_err("%s: timed out\n", __func__);
437}
438
439static void ltm020d550_update(struct fb_info *info)
440{
441 pxafb_smart_queue(info, ARRAY_AND_SIZE(update_framedata));
442 pxafb_smart_flush(info);
443}
444
445static struct pxafb_mode_info toshiba_ltm020d550_modes[] = {
446 [0] = {
447 .xres = 240,
448 .yres = 320,
449 .bpp = 16,
450 .a0csrd_set_hld = 30,
451 .a0cswr_set_hld = 30,
452 .wr_pulse_width = 30,
453 .rd_pulse_width = 170,
454 .op_hold_time = 30,
455 .cmd_inh_time = 60,
456
457
458 .sync = FB_SYNC_HOR_HIGH_ACT |
459 FB_SYNC_VERT_HIGH_ACT,
460 },
461};
462
463static struct pxafb_mach_info tavorevb_lcd_info = {
464 .modes = toshiba_ltm020d550_modes,
465 .num_modes = 1,
466 .lcd_conn = LCD_SMART_PANEL_8BPP | LCD_PCLK_EDGE_FALL,
467 .pxafb_lcd_power = ltm020d550_lcd_power,
468 .smart_update = ltm020d550_update,
469};
470
471static void __init tavorevb_init_lcd(void)
472{
473 platform_device_register(&tavorevb_backlight_devices[0]);
474 platform_device_register(&tavorevb_backlight_devices[1]);
475 pxa_set_fb_info(NULL, &tavorevb_lcd_info);
476}
477#else
478static inline void tavorevb_init_lcd(void) {}
479#endif
480
481static void __init tavorevb_init(void)
482{
483
484 pxa3xx_mfp_config(ARRAY_AND_SIZE(tavorevb_mfp_cfg));
485
486 pxa_set_ffuart_info(NULL);
487 pxa_set_btuart_info(NULL);
488 pxa_set_stuart_info(NULL);
489
490 platform_device_register(&smc91x_device);
491
492 tavorevb_init_lcd();
493 tavorevb_init_keypad();
494}
495
496MACHINE_START(TAVOREVB, "PXA930 Evaluation Board (aka TavorEVB)")
497
498 .atag_offset = 0x100,
499 .map_io = pxa3xx_map_io,
500 .nr_irqs = PXA_NR_IRQS,
501 .init_irq = pxa3xx_init_irq,
502 .handle_irq = pxa3xx_handle_irq,
503 .init_time = pxa_timer_init,
504 .init_machine = tavorevb_init,
505 .restart = pxa_restart,
506MACHINE_END
507