tavorevb.c 11 KB

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