littleton.c 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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 <asm/types.h>
  23. #include <asm/setup.h>
  24. #include <asm/memory.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/hardware.h>
  27. #include <asm/irq.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <asm/mach/irq.h>
  31. #include <asm/arch/pxa-regs.h>
  32. #include <asm/arch/mfp-pxa300.h>
  33. #include <asm/arch/gpio.h>
  34. #include <asm/arch/pxafb.h>
  35. #include <asm/arch/ssp.h>
  36. #include <asm/arch/littleton.h>
  37. #include "generic.h"
  38. #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)
  39. /* Littleton MFP configurations */
  40. static mfp_cfg_t littleton_mfp_cfg[] __initdata = {
  41. /* LCD */
  42. GPIO54_LCD_LDD_0,
  43. GPIO55_LCD_LDD_1,
  44. GPIO56_LCD_LDD_2,
  45. GPIO57_LCD_LDD_3,
  46. GPIO58_LCD_LDD_4,
  47. GPIO59_LCD_LDD_5,
  48. GPIO60_LCD_LDD_6,
  49. GPIO61_LCD_LDD_7,
  50. GPIO62_LCD_LDD_8,
  51. GPIO63_LCD_LDD_9,
  52. GPIO64_LCD_LDD_10,
  53. GPIO65_LCD_LDD_11,
  54. GPIO66_LCD_LDD_12,
  55. GPIO67_LCD_LDD_13,
  56. GPIO68_LCD_LDD_14,
  57. GPIO69_LCD_LDD_15,
  58. GPIO70_LCD_LDD_16,
  59. GPIO71_LCD_LDD_17,
  60. GPIO72_LCD_FCLK,
  61. GPIO73_LCD_LCLK,
  62. GPIO74_LCD_PCLK,
  63. GPIO75_LCD_BIAS,
  64. /* SSP2 */
  65. GPIO25_SSP2_SCLK,
  66. GPIO17_SSP2_FRM,
  67. GPIO27_SSP2_TXD,
  68. /* Debug Ethernet */
  69. GPIO90_GPIO,
  70. };
  71. static struct resource smc91x_resources[] = {
  72. [0] = {
  73. .start = (LITTLETON_ETH_PHYS + 0x300),
  74. .end = (LITTLETON_ETH_PHYS + 0xfffff),
  75. .flags = IORESOURCE_MEM,
  76. },
  77. [1] = {
  78. .start = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)),
  79. .end = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO90)),
  80. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
  81. }
  82. };
  83. static struct platform_device smc91x_device = {
  84. .name = "smc91x",
  85. .id = 0,
  86. .num_resources = ARRAY_SIZE(smc91x_resources),
  87. .resource = smc91x_resources,
  88. };
  89. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULES)
  90. /* use bit 30, 31 as the indicator of command parameter number */
  91. #define CMD0(x) ((0x00000000) | ((x) << 9))
  92. #define CMD1(x, x1) ((0x40000000) | ((x) << 9) | 0x100 | (x1))
  93. #define CMD2(x, x1, x2) ((0x80000000) | ((x) << 18) | 0x20000 |\
  94. ((x1) << 9) | 0x100 | (x2))
  95. static uint32_t lcd_panel_reset[] = {
  96. CMD0(0x1), /* reset */
  97. CMD0(0x0), /* nop */
  98. CMD0(0x0), /* nop */
  99. CMD0(0x0), /* nop */
  100. };
  101. static uint32_t lcd_panel_on[] = {
  102. CMD0(0x29), /* Display ON */
  103. CMD2(0xB8, 0xFF, 0xF9), /* Output Control */
  104. CMD0(0x11), /* Sleep out */
  105. CMD1(0xB0, 0x16), /* Wake */
  106. };
  107. static uint32_t lcd_panel_off[] = {
  108. CMD0(0x28), /* Display OFF */
  109. CMD2(0xB8, 0x80, 0x02), /* Output Control */
  110. CMD0(0x10), /* Sleep in */
  111. CMD1(0xB0, 0x00), /* Deep stand by in */
  112. };
  113. static uint32_t lcd_vga_pass_through[] = {
  114. CMD1(0xB0, 0x16),
  115. CMD1(0xBC, 0x80),
  116. CMD1(0xE1, 0x00),
  117. CMD1(0x36, 0x50),
  118. CMD1(0x3B, 0x00),
  119. };
  120. static uint32_t lcd_qvga_pass_through[] = {
  121. CMD1(0xB0, 0x16),
  122. CMD1(0xBC, 0x81),
  123. CMD1(0xE1, 0x00),
  124. CMD1(0x36, 0x50),
  125. CMD1(0x3B, 0x22),
  126. };
  127. static uint32_t lcd_vga_transfer[] = {
  128. CMD1(0xcf, 0x02), /* Blanking period control (1) */
  129. CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
  130. CMD1(0xd1, 0x01), /* CKV timing control on/off */
  131. CMD2(0xd2, 0x14, 0x00), /* CKV 1,2 timing control */
  132. CMD2(0xd3, 0x1a, 0x0f), /* OEV timing control */
  133. CMD2(0xd4, 0x1f, 0xaf), /* ASW timing control (1) */
  134. CMD1(0xd5, 0x14), /* ASW timing control (2) */
  135. CMD0(0x21), /* Invert for normally black display */
  136. CMD0(0x29), /* Display on */
  137. };
  138. static uint32_t lcd_qvga_transfer[] = {
  139. CMD1(0xd6, 0x02), /* Blanking period control (1) */
  140. CMD2(0xd7, 0x08, 0x04), /* Blanking period control (2) */
  141. CMD1(0xd8, 0x01), /* CKV timing control on/off */
  142. CMD2(0xd9, 0x00, 0x08), /* CKV 1,2 timing control */
  143. CMD2(0xde, 0x05, 0x0a), /* OEV timing control */
  144. CMD2(0xdf, 0x0a, 0x19), /* ASW timing control (1) */
  145. CMD1(0xe0, 0x0a), /* ASW timing control (2) */
  146. CMD0(0x21), /* Invert for normally black display */
  147. CMD0(0x29), /* Display on */
  148. };
  149. static uint32_t lcd_panel_config[] = {
  150. CMD2(0xb8, 0xff, 0xf9), /* Output control */
  151. CMD0(0x11), /* sleep out */
  152. CMD1(0xba, 0x01), /* Display mode (1) */
  153. CMD1(0xbb, 0x00), /* Display mode (2) */
  154. CMD1(0x3a, 0x60), /* Display mode 18-bit RGB */
  155. CMD1(0xbf, 0x10), /* Drive system change control */
  156. CMD1(0xb1, 0x56), /* Booster operation setup */
  157. CMD1(0xb2, 0x33), /* Booster mode setup */
  158. CMD1(0xb3, 0x11), /* Booster frequency setup */
  159. CMD1(0xb4, 0x02), /* Op amp/system clock */
  160. CMD1(0xb5, 0x35), /* VCS voltage */
  161. CMD1(0xb6, 0x40), /* VCOM voltage */
  162. CMD1(0xb7, 0x03), /* External display signal */
  163. CMD1(0xbd, 0x00), /* ASW slew rate */
  164. CMD1(0xbe, 0x00), /* Dummy data for QuadData operation */
  165. CMD1(0xc0, 0x11), /* Sleep out FR count (A) */
  166. CMD1(0xc1, 0x11), /* Sleep out FR count (B) */
  167. CMD1(0xc2, 0x11), /* Sleep out FR count (C) */
  168. CMD2(0xc3, 0x20, 0x40), /* Sleep out FR count (D) */
  169. CMD2(0xc4, 0x60, 0xc0), /* Sleep out FR count (E) */
  170. CMD2(0xc5, 0x10, 0x20), /* Sleep out FR count (F) */
  171. CMD1(0xc6, 0xc0), /* Sleep out FR count (G) */
  172. CMD2(0xc7, 0x33, 0x43), /* Gamma 1 fine tuning (1) */
  173. CMD1(0xc8, 0x44), /* Gamma 1 fine tuning (2) */
  174. CMD1(0xc9, 0x33), /* Gamma 1 inclination adjustment */
  175. CMD1(0xca, 0x00), /* Gamma 1 blue offset adjustment */
  176. CMD2(0xec, 0x01, 0xf0), /* Horizontal clock cycles */
  177. };
  178. static void ssp_reconfig(struct ssp_dev *dev, int nparam)
  179. {
  180. static int last_nparam = -1;
  181. /* check if it is necessary to re-config SSP */
  182. if (nparam == last_nparam)
  183. return;
  184. ssp_disable(dev);
  185. ssp_config(dev, (nparam == 2) ? 0x0010058a : 0x00100581, 0x18, 0, 0);
  186. last_nparam = nparam;
  187. }
  188. static void ssp_send_cmd(uint32_t *cmd, int num)
  189. {
  190. static int ssp_initialized;
  191. static struct ssp_dev ssp2;
  192. int i;
  193. if (!ssp_initialized) {
  194. ssp_init(&ssp2, 2, SSP_NO_IRQ);
  195. ssp_initialized = 1;
  196. }
  197. clk_enable(ssp2.ssp->clk);
  198. for (i = 0; i < num; i++, cmd++) {
  199. ssp_reconfig(&ssp2, (*cmd >> 30) & 0x3);
  200. ssp_write_word(&ssp2, *cmd & 0x3fffffff);
  201. /* FIXME: ssp_flush() is mandatory here to work */
  202. ssp_flush(&ssp2);
  203. }
  204. clk_disable(ssp2.ssp->clk);
  205. }
  206. static void littleton_lcd_power(int on, struct fb_var_screeninfo *var)
  207. {
  208. if (on) {
  209. ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_on));
  210. ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_reset));
  211. if (var->xres > 240) {
  212. /* VGA */
  213. ssp_send_cmd(ARRAY_AND_SIZE(lcd_vga_pass_through));
  214. ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_config));
  215. ssp_send_cmd(ARRAY_AND_SIZE(lcd_vga_transfer));
  216. } else {
  217. /* QVGA */
  218. ssp_send_cmd(ARRAY_AND_SIZE(lcd_qvga_pass_through));
  219. ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_config));
  220. ssp_send_cmd(ARRAY_AND_SIZE(lcd_qvga_transfer));
  221. }
  222. } else
  223. ssp_send_cmd(ARRAY_AND_SIZE(lcd_panel_off));
  224. }
  225. static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = {
  226. [0] = {
  227. /* VGA */
  228. .pixclock = 38250,
  229. .xres = 480,
  230. .yres = 640,
  231. .bpp = 16,
  232. .hsync_len = 8,
  233. .left_margin = 8,
  234. .right_margin = 24,
  235. .vsync_len = 2,
  236. .upper_margin = 2,
  237. .lower_margin = 4,
  238. .sync = 0,
  239. },
  240. [1] = {
  241. /* QVGA */
  242. .pixclock = 153000,
  243. .xres = 240,
  244. .yres = 320,
  245. .bpp = 16,
  246. .hsync_len = 8,
  247. .left_margin = 8,
  248. .right_margin = 88,
  249. .vsync_len = 2,
  250. .upper_margin = 2,
  251. .lower_margin = 2,
  252. .sync = 0,
  253. },
  254. };
  255. static struct pxafb_mach_info littleton_lcd_info = {
  256. .modes = tpo_tdo24mtea1_modes,
  257. .num_modes = 2,
  258. .lccr0 = LCCR0_Act,
  259. .lccr3 = LCCR3_HSP | LCCR3_VSP,
  260. .pxafb_lcd_power = littleton_lcd_power,
  261. };
  262. static void littleton_init_lcd(void)
  263. {
  264. set_pxa_fb_info(&littleton_lcd_info);
  265. }
  266. #else
  267. static inline void littleton_init_lcd(void) {};
  268. #endif /* CONFIG_FB_PXA || CONFIG_FB_PXA_MODULES */
  269. static void __init littleton_init(void)
  270. {
  271. /* initialize MFP configurations */
  272. pxa3xx_mfp_config(ARRAY_AND_SIZE(littleton_mfp_cfg));
  273. /*
  274. * Note: we depend bootloader set the correct
  275. * value to MSC register for SMC91x.
  276. */
  277. platform_device_register(&smc91x_device);
  278. littleton_init_lcd();
  279. }
  280. MACHINE_START(LITTLETON, "Marvell Form Factor Development Platform (aka Littleton)")
  281. .phys_io = 0x40000000,
  282. .boot_params = 0xa0000100,
  283. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  284. .map_io = pxa_map_io,
  285. .init_irq = pxa3xx_init_irq,
  286. .timer = &pxa_timer,
  287. .init_machine = littleton_init,
  288. MACHINE_END