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