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