tavorevb.c 12 KB

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