littleton.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. /*
  2. * linux/arch/arm/mach-pxa/littleton.c
  3. *
  4. * Support for the Marvell Littleton Development Platform.
  5. *
  6. * Author: Jason Chagas (largely modified code)
  7. * Created: Nov 20, 2006
  8. * Copyright: (C) Copyright 2006 Marvell International Ltd.
  9. *
  10. * 2007-11-22 modified to align with latest kernel
  11. * eric miao <eric.miao@marvell.com>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License version 2 as
  15. * publishhed by the Free Software Foundation.
  16. */
  17. #include <linux/init.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/delay.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/clk.h>
  22. #include <linux/smc91x.h>
  23. #include <asm/types.h>
  24. #include <asm/setup.h>
  25. #include <asm/memory.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/hardware.h>
  28. #include <asm/irq.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/map.h>
  31. #include <asm/mach/irq.h>
  32. #include <asm/arch/pxa-regs.h>
  33. #include <asm/arch/mfp-pxa300.h>
  34. #include <asm/arch/gpio.h>
  35. #include <asm/arch/pxafb.h>
  36. #include <asm/arch/ssp.h>
  37. #include <asm/arch/pxa27x_keypad.h>
  38. #include <asm/arch/pxa3xx_nand.h>
  39. #include <asm/arch/littleton.h>
  40. #include "generic.h"
  41. /* Littleton MFP configurations */
  42. static mfp_cfg_t littleton_mfp_cfg[] __initdata = {
  43. /* LCD */
  44. GPIO54_LCD_LDD_0,
  45. GPIO55_LCD_LDD_1,
  46. GPIO56_LCD_LDD_2,
  47. GPIO57_LCD_LDD_3,
  48. GPIO58_LCD_LDD_4,
  49. GPIO59_LCD_LDD_5,
  50. GPIO60_LCD_LDD_6,
  51. GPIO61_LCD_LDD_7,
  52. GPIO62_LCD_LDD_8,
  53. GPIO63_LCD_LDD_9,
  54. GPIO64_LCD_LDD_10,
  55. GPIO65_LCD_LDD_11,
  56. GPIO66_LCD_LDD_12,
  57. GPIO67_LCD_LDD_13,
  58. GPIO68_LCD_LDD_14,
  59. GPIO69_LCD_LDD_15,
  60. GPIO70_LCD_LDD_16,
  61. GPIO71_LCD_LDD_17,
  62. GPIO72_LCD_FCLK,
  63. GPIO73_LCD_LCLK,
  64. GPIO74_LCD_PCLK,
  65. GPIO75_LCD_BIAS,
  66. /* SSP2 */
  67. GPIO25_SSP2_SCLK,
  68. GPIO17_SSP2_FRM,
  69. GPIO27_SSP2_TXD,
  70. /* Debug Ethernet */
  71. GPIO90_GPIO,
  72. /* Keypad */
  73. GPIO107_KP_DKIN_0,
  74. GPIO108_KP_DKIN_1,
  75. GPIO115_KP_MKIN_0,
  76. GPIO116_KP_MKIN_1,
  77. GPIO117_KP_MKIN_2,
  78. GPIO118_KP_MKIN_3,
  79. GPIO119_KP_MKIN_4,
  80. GPIO120_KP_MKIN_5,
  81. GPIO121_KP_MKOUT_0,
  82. GPIO122_KP_MKOUT_1,
  83. GPIO123_KP_MKOUT_2,
  84. GPIO124_KP_MKOUT_3,
  85. GPIO125_KP_MKOUT_4,
  86. };
  87. static struct resource smc91x_resources[] = {
  88. [0] = {
  89. .start = (LITTLETON_ETH_PHYS + 0x300),
  90. .end = (LITTLETON_ETH_PHYS + 0xfffff),
  91. .flags = IORESOURCE_MEM,
  92. },
  93. [1] = {
  94. .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)),
  95. .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)),
  96. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  97. }
  98. };
  99. static struct smc91x_platdata littleton_smc91x_info = {
  100. .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT |
  101. SMC91X_NOWAIT | SMC91X_USE_DMA,
  102. };
  103. static struct platform_device smc91x_device = {
  104. .name = "smc91x",
  105. .id = 0,
  106. .num_resources = ARRAY_SIZE(smc91x_resources),
  107. .resource = smc91x_resources,
  108. .dev = {
  109. .platform_data = &littleton_smc91x_info,
  110. },
  111. };
  112. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  113. /* use bit 30, 31 as the indicator of command parameter number */
  114. #define CMD0(x) ((0x00000000) | ((x) << 9))
  115. #define CMD1(x, x1) ((0x40000000) | ((x) << 9) | 0x100 | (x1))
  116. #define CMD2(x, x1, x2) ((0x80000000) | ((x) << 18) | 0x20000 |\
  117. ((x1) << 9) | 0x100 | (x2))
  118. static uint32_t lcd_panel_reset[] = {
  119. CMD0(0x1), /* reset */
  120. CMD0(0x0), /* nop */
  121. CMD0(0x0), /* nop */
  122. CMD0(0x0), /* nop */
  123. };
  124. static uint32_t lcd_panel_on[] = {
  125. CMD0(0x29), /* Display ON */
  126. CMD2(0xB8, 0xFF, 0xF9), /* Output Control */
  127. CMD0(0x11), /* Sleep out */
  128. CMD1(0xB0, 0x16), /* Wake */
  129. };
  130. static uint32_t lcd_panel_off[] = {
  131. CMD0(0x28), /* Display OFF */
  132. CMD2(0xB8, 0x80, 0x02), /* Output Control */
  133. CMD0(0x10), /* Sleep in */
  134. CMD1(0xB0, 0x00), /* Deep stand by in */
  135. };
  136. static uint32_t lcd_vga_pass_through[] = {
  137. CMD1(0xB0, 0x16),
  138. CMD1(0xBC, 0x80),
  139. CMD1(0xE1, 0x00),
  140. CMD1(0x36, 0x50),
  141. CMD1(0x3B, 0x00),
  142. };
  143. static uint32_t lcd_qvga_pass_through[] = {
  144. CMD1(0xB0, 0x16),
  145. CMD1(0xBC, 0x81),
  146. CMD1(0xE1, 0x00),
  147. CMD1(0x36, 0x50),
  148. CMD1(0x3B, 0x22),
  149. };
  150. static uint32_t lcd_vga_transfer[] = {
  151. CMD1(0xcf, 0x02), /* Blanking period control (1) */
  152. CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
  153. CMD1(0xd1, 0x01), /* CKV timing control on/off */
  154. CMD2(0xd2, 0x14, 0x00), /* CKV 1,2 timing control */
  155. CMD2(0xd3, 0x1a, 0x0f), /* OEV timing control */
  156. CMD2(0xd4, 0x1f, 0xaf), /* ASW timing control (1) */
  157. CMD1(0xd5, 0x14), /* ASW timing control (2) */
  158. CMD0(0x21), /* Invert for normally black display */
  159. CMD0(0x29), /* Display on */
  160. };
  161. static uint32_t lcd_qvga_transfer[] = {
  162. CMD1(0xd6, 0x02), /* Blanking period control (1) */
  163. CMD2(0xd7, 0x08, 0x04), /* Blanking period control (2) */
  164. CMD1(0xd8, 0x01), /* CKV timing control on/off */
  165. CMD2(0xd9, 0x00, 0x08), /* CKV 1,2 timing control */
  166. CMD2(0xde, 0x05, 0x0a), /* OEV timing control */
  167. CMD2(0xdf, 0x0a, 0x19), /* ASW timing control (1) */
  168. CMD1(0xe0, 0x0a), /* ASW timing control (2) */
  169. CMD0(0x21), /* Invert for normally black display */
  170. CMD0(0x29), /* Display on */
  171. };
  172. static uint32_t lcd_panel_config[] = {
  173. CMD2(0xb8, 0xff, 0xf9), /* Output control */
  174. CMD0(0x11), /* sleep out */
  175. CMD1(0xba, 0x01), /* Display mode (1) */
  176. CMD1(0xbb, 0x00), /* Display mode (2) */
  177. CMD1(0x3a, 0x60), /* Display mode 18-bit RGB */
  178. CMD1(0xbf, 0x10), /* Drive system change control */
  179. CMD1(0xb1, 0x56), /* Booster operation setup */
  180. CMD1(0xb2, 0x33), /* Booster mode setup */
  181. CMD1(0xb3, 0x11), /* Booster frequency setup */
  182. CMD1(0xb4, 0x02), /* Op amp/system clock */
  183. CMD1(0xb5, 0x35), /* VCS voltage */
  184. CMD1(0xb6, 0x40), /* VCOM voltage */
  185. CMD1(0xb7, 0x03), /* External display signal */
  186. CMD1(0xbd, 0x00), /* ASW slew rate */
  187. CMD1(0xbe, 0x00), /* Dummy data for QuadData operation */
  188. CMD1(0xc0, 0x11), /* Sleep out FR count (A) */
  189. CMD1(0xc1, 0x11), /* Sleep out FR count (B) */
  190. CMD1(0xc2, 0x11), /* Sleep out FR count (C) */
  191. CMD2(0xc3, 0x20, 0x40), /* Sleep out FR count (D) */
  192. CMD2(0xc4, 0x60, 0xc0), /* Sleep out FR count (E) */
  193. CMD2(0xc5, 0x10, 0x20), /* Sleep out FR count (F) */
  194. CMD1(0xc6, 0xc0), /* Sleep out FR count (G) */
  195. CMD2(0xc7, 0x33, 0x43), /* Gamma 1 fine tuning (1) */
  196. CMD1(0xc8, 0x44), /* Gamma 1 fine tuning (2) */
  197. CMD1(0xc9, 0x33), /* Gamma 1 inclination adjustment */
  198. CMD1(0xca, 0x00), /* Gamma 1 blue offset adjustment */
  199. CMD2(0xec, 0x01, 0xf0), /* Horizontal clock cycles */
  200. };
  201. static void ssp_reconfig(struct ssp_dev *dev, int nparam)
  202. {
  203. static int last_nparam = -1;
  204. /* check if it is necessary to re-config SSP */
  205. if (nparam == last_nparam)
  206. return;
  207. ssp_disable(dev);
  208. ssp_config(dev, (nparam == 2) ? 0x0010058a : 0x00100581, 0x18, 0, 0);
  209. last_nparam = nparam;
  210. }
  211. static void ssp_send_cmd(uint32_t *cmd, int num)
  212. {
  213. static int ssp_initialized;
  214. static struct ssp_dev ssp2;
  215. int i;
  216. if (!ssp_initialized) {
  217. ssp_init(&ssp2, 2, SSP_NO_IRQ);
  218. ssp_initialized = 1;
  219. }
  220. clk_enable(ssp2.ssp->clk);
  221. for (i = 0; i < num; i++, cmd++) {
  222. ssp_reconfig(&ssp2, (*cmd >> 30) & 0x3);
  223. ssp_write_word(&ssp2, *cmd & 0x3fffffff);
  224. /* FIXME: ssp_flush() is mandatory here to work */
  225. ssp_flush(&ssp2);
  226. }
  227. clk_disable(ssp2.ssp->clk);
  228. }
  229. static void littleton_lcd_power(int on, struct fb_var_screeninfo *var)
  230. {
  231. if (on) {
  232. ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_on));
  233. ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_reset));
  234. if (var->xres > 240) {
  235. /* VGA */
  236. ssp_send_cmd(ARRAY_AND_SIZE(lcd_vga_pass_through));
  237. ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_config));
  238. ssp_send_cmd(ARRAY_AND_SIZE(lcd_vga_transfer));
  239. } else {
  240. /* QVGA */
  241. ssp_send_cmd(ARRAY_AND_SIZE(lcd_qvga_pass_through));
  242. ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_config));
  243. ssp_send_cmd(ARRAY_AND_SIZE(lcd_qvga_transfer));
  244. }
  245. } else
  246. ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_off));
  247. }
  248. static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = {
  249. [0] = {
  250. /* VGA */
  251. .pixclock = 38250,
  252. .xres = 480,
  253. .yres = 640,
  254. .bpp = 16,
  255. .hsync_len = 8,
  256. .left_margin = 8,
  257. .right_margin = 24,
  258. .vsync_len = 2,
  259. .upper_margin = 2,
  260. .lower_margin = 4,
  261. .sync = 0,
  262. },
  263. [1] = {
  264. /* QVGA */
  265. .pixclock = 153000,
  266. .xres = 240,
  267. .yres = 320,
  268. .bpp = 16,
  269. .hsync_len = 8,
  270. .left_margin = 8,
  271. .right_margin = 88,
  272. .vsync_len = 2,
  273. .upper_margin = 2,
  274. .lower_margin = 2,
  275. .sync = 0,
  276. },
  277. };
  278. static struct pxafb_mach_info littleton_lcd_info = {
  279. .modes = tpo_tdo24mtea1_modes,
  280. .num_modes = 2,
  281. .lcd_conn = LCD_COLOR_TFT_16BPP,
  282. .pxafb_lcd_power = littleton_lcd_power,
  283. };
  284. static void littleton_init_lcd(void)
  285. {
  286. set_pxa_fb_info(&littleton_lcd_info);
  287. }
  288. #else
  289. static inline void littleton_init_lcd(void) {};
  290. #endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULE */
  291. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  292. static unsigned int littleton_matrix_key_map[] = {
  293. /* KEY(row, col, key_code) */
  294. KEY(1, 3, KEY_0), KEY(0, 0, KEY_1), KEY(1, 0, KEY_2), KEY(2, 0, KEY_3),
  295. KEY(0, 1, KEY_4), KEY(1, 1, KEY_5), KEY(2, 1, KEY_6), KEY(0, 2, KEY_7),
  296. KEY(1, 2, KEY_8), KEY(2, 2, KEY_9),
  297. KEY(0, 3, KEY_KPASTERISK), /* * */
  298. KEY(2, 3, KEY_KPDOT), /* # */
  299. KEY(5, 4, KEY_ENTER),
  300. KEY(5, 0, KEY_UP),
  301. KEY(5, 1, KEY_DOWN),
  302. KEY(5, 2, KEY_LEFT),
  303. KEY(5, 3, KEY_RIGHT),
  304. KEY(3, 2, KEY_HOME),
  305. KEY(4, 1, KEY_END),
  306. KEY(3, 3, KEY_BACK),
  307. KEY(4, 0, KEY_SEND),
  308. KEY(4, 2, KEY_VOLUMEUP),
  309. KEY(4, 3, KEY_VOLUMEDOWN),
  310. KEY(3, 0, KEY_F22), /* soft1 */
  311. KEY(3, 1, KEY_F23), /* soft2 */
  312. };
  313. static struct pxa27x_keypad_platform_data littleton_keypad_info = {
  314. .matrix_key_rows = 6,
  315. .matrix_key_cols = 5,
  316. .matrix_key_map = littleton_matrix_key_map,
  317. .matrix_key_map_size = ARRAY_SIZE(littleton_matrix_key_map),
  318. .enable_rotary0 = 1,
  319. .rotary0_up_key = KEY_UP,
  320. .rotary0_down_key = KEY_DOWN,
  321. .debounce_interval = 30,
  322. };
  323. static void __init littleton_init_keypad(void)
  324. {
  325. pxa_set_keypad_info(&littleton_keypad_info);
  326. }
  327. #else
  328. static inline void littleton_init_keypad(void) {}
  329. #endif
  330. #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
  331. static struct mtd_partition littleton_nand_partitions[] = {
  332. [0] = {
  333. .name = "Bootloader",
  334. .offset = 0,
  335. .size = 0x060000,
  336. .mask_flags = MTD_WRITEABLE, /* force read-only */
  337. },
  338. [1] = {
  339. .name = "Kernel",
  340. .offset = 0x060000,
  341. .size = 0x200000,
  342. .mask_flags = MTD_WRITEABLE, /* force read-only */
  343. },
  344. [2] = {
  345. .name = "Filesystem",
  346. .offset = 0x0260000,
  347. .size = 0x3000000, /* 48M - rootfs */
  348. },
  349. [3] = {
  350. .name = "MassStorage",
  351. .offset = 0x3260000,
  352. .size = 0x3d40000,
  353. },
  354. [4] = {
  355. .name = "BBT",
  356. .offset = 0x6FA0000,
  357. .size = 0x80000,
  358. .mask_flags = MTD_WRITEABLE, /* force read-only */
  359. },
  360. /* NOTE: we reserve some blocks at the end of the NAND flash for
  361. * bad block management, and the max number of relocation blocks
  362. * differs on different platforms. Please take care with it when
  363. * defining the partition table.
  364. */
  365. };
  366. static struct pxa3xx_nand_platform_data littleton_nand_info = {
  367. .enable_arbiter = 1,
  368. .parts = littleton_nand_partitions,
  369. .nr_parts = ARRAY_SIZE(littleton_nand_partitions),
  370. };
  371. static void __init littleton_init_nand(void)
  372. {
  373. pxa3xx_set_nand_info(&littleton_nand_info);
  374. }
  375. #else
  376. static inline void littleton_init_nand(void) {}
  377. #endif /* CONFIG_MTD_NAND_PXA3xx || CONFIG_MTD_NAND_PXA3xx_MODULE */
  378. static void __init littleton_init(void)
  379. {
  380. /* initialize MFP configurations */
  381. pxa3xx_mfp_config(ARRAY_AND_SIZE(littleton_mfp_cfg));
  382. /*
  383. * Note: we depend bootloader set the correct
  384. * value to MSC register for SMC91x.
  385. */
  386. platform_device_register(&smc91x_device);
  387. littleton_init_lcd();
  388. littleton_init_keypad();
  389. littleton_init_nand();
  390. }
  391. MACHINE_START(LITTLETON, "Marvell Form Factor Development Platform (aka Littleton)")
  392. .phys_io = 0x40000000,
  393. .boot_params = 0xa0000100,
  394. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  395. .map_io = pxa_map_io,
  396. .init_irq = pxa3xx_init_irq,
  397. .timer = &pxa_timer,
  398. .init_machine = littleton_init,
  399. MACHINE_END