board-trout-panel.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /* linux/arch/arm/mach-msm/board-trout-mddi.c
  2. ** Author: Brian Swetland <swetland@google.com>
  3. */
  4. #include <linux/kernel.h>
  5. #include <linux/init.h>
  6. #include <linux/platform_device.h>
  7. #include <linux/delay.h>
  8. #include <linux/leds.h>
  9. #include <linux/clk.h>
  10. #include <linux/err.h>
  11. #include <asm/io.h>
  12. #include <asm/gpio.h>
  13. #include <asm/mach-types.h>
  14. #include <mach/msm_fb.h>
  15. #include <mach/vreg.h>
  16. #include "board-trout.h"
  17. #include "proc_comm.h"
  18. #include "devices.h"
  19. #define TROUT_DEFAULT_BACKLIGHT_BRIGHTNESS 255
  20. #define MDDI_CLIENT_CORE_BASE 0x108000
  21. #define LCD_CONTROL_BLOCK_BASE 0x110000
  22. #define SPI_BLOCK_BASE 0x120000
  23. #define I2C_BLOCK_BASE 0x130000
  24. #define PWM_BLOCK_BASE 0x140000
  25. #define GPIO_BLOCK_BASE 0x150000
  26. #define SYSTEM_BLOCK1_BASE 0x160000
  27. #define SYSTEM_BLOCK2_BASE 0x170000
  28. #define DPSUS (MDDI_CLIENT_CORE_BASE|0x24)
  29. #define SYSCLKENA (MDDI_CLIENT_CORE_BASE|0x2C)
  30. #define PWM0OFF (PWM_BLOCK_BASE|0x1C)
  31. #define V_VDDE2E_VDD2_GPIO 0
  32. #define MDDI_RST_N 82
  33. #define MDDICAP0 (MDDI_CLIENT_CORE_BASE|0x00)
  34. #define MDDICAP1 (MDDI_CLIENT_CORE_BASE|0x04)
  35. #define MDDICAP2 (MDDI_CLIENT_CORE_BASE|0x08)
  36. #define MDDICAP3 (MDDI_CLIENT_CORE_BASE|0x0C)
  37. #define MDCAPCHG (MDDI_CLIENT_CORE_BASE|0x10)
  38. #define MDCRCERC (MDDI_CLIENT_CORE_BASE|0x14)
  39. #define TTBUSSEL (MDDI_CLIENT_CORE_BASE|0x18)
  40. #define DPSET0 (MDDI_CLIENT_CORE_BASE|0x1C)
  41. #define DPSET1 (MDDI_CLIENT_CORE_BASE|0x20)
  42. #define DPSUS (MDDI_CLIENT_CORE_BASE|0x24)
  43. #define DPRUN (MDDI_CLIENT_CORE_BASE|0x28)
  44. #define SYSCKENA (MDDI_CLIENT_CORE_BASE|0x2C)
  45. #define TESTMODE (MDDI_CLIENT_CORE_BASE|0x30)
  46. #define FIFOMONI (MDDI_CLIENT_CORE_BASE|0x34)
  47. #define INTMONI (MDDI_CLIENT_CORE_BASE|0x38)
  48. #define MDIOBIST (MDDI_CLIENT_CORE_BASE|0x3C)
  49. #define MDIOPSET (MDDI_CLIENT_CORE_BASE|0x40)
  50. #define BITMAP0 (MDDI_CLIENT_CORE_BASE|0x44)
  51. #define BITMAP1 (MDDI_CLIENT_CORE_BASE|0x48)
  52. #define BITMAP2 (MDDI_CLIENT_CORE_BASE|0x4C)
  53. #define BITMAP3 (MDDI_CLIENT_CORE_BASE|0x50)
  54. #define BITMAP4 (MDDI_CLIENT_CORE_BASE|0x54)
  55. #define SRST (LCD_CONTROL_BLOCK_BASE|0x00)
  56. #define PORT_ENB (LCD_CONTROL_BLOCK_BASE|0x04)
  57. #define START (LCD_CONTROL_BLOCK_BASE|0x08)
  58. #define PORT (LCD_CONTROL_BLOCK_BASE|0x0C)
  59. #define CMN (LCD_CONTROL_BLOCK_BASE|0x10)
  60. #define GAMMA (LCD_CONTROL_BLOCK_BASE|0x14)
  61. #define INTFLG (LCD_CONTROL_BLOCK_BASE|0x18)
  62. #define INTMSK (LCD_CONTROL_BLOCK_BASE|0x1C)
  63. #define MPLFBUF (LCD_CONTROL_BLOCK_BASE|0x20)
  64. #define HDE_LEFT (LCD_CONTROL_BLOCK_BASE|0x24)
  65. #define VDE_TOP (LCD_CONTROL_BLOCK_BASE|0x28)
  66. #define PXL (LCD_CONTROL_BLOCK_BASE|0x30)
  67. #define HCYCLE (LCD_CONTROL_BLOCK_BASE|0x34)
  68. #define HSW (LCD_CONTROL_BLOCK_BASE|0x38)
  69. #define HDE_START (LCD_CONTROL_BLOCK_BASE|0x3C)
  70. #define HDE_SIZE (LCD_CONTROL_BLOCK_BASE|0x40)
  71. #define VCYCLE (LCD_CONTROL_BLOCK_BASE|0x44)
  72. #define VSW (LCD_CONTROL_BLOCK_BASE|0x48)
  73. #define VDE_START (LCD_CONTROL_BLOCK_BASE|0x4C)
  74. #define VDE_SIZE (LCD_CONTROL_BLOCK_BASE|0x50)
  75. #define WAKEUP (LCD_CONTROL_BLOCK_BASE|0x54)
  76. #define WSYN_DLY (LCD_CONTROL_BLOCK_BASE|0x58)
  77. #define REGENB (LCD_CONTROL_BLOCK_BASE|0x5C)
  78. #define VSYNIF (LCD_CONTROL_BLOCK_BASE|0x60)
  79. #define WRSTB (LCD_CONTROL_BLOCK_BASE|0x64)
  80. #define RDSTB (LCD_CONTROL_BLOCK_BASE|0x68)
  81. #define ASY_DATA (LCD_CONTROL_BLOCK_BASE|0x6C)
  82. #define ASY_DATB (LCD_CONTROL_BLOCK_BASE|0x70)
  83. #define ASY_DATC (LCD_CONTROL_BLOCK_BASE|0x74)
  84. #define ASY_DATD (LCD_CONTROL_BLOCK_BASE|0x78)
  85. #define ASY_DATE (LCD_CONTROL_BLOCK_BASE|0x7C)
  86. #define ASY_DATF (LCD_CONTROL_BLOCK_BASE|0x80)
  87. #define ASY_DATG (LCD_CONTROL_BLOCK_BASE|0x84)
  88. #define ASY_DATH (LCD_CONTROL_BLOCK_BASE|0x88)
  89. #define ASY_CMDSET (LCD_CONTROL_BLOCK_BASE|0x8C)
  90. #define SSICTL (SPI_BLOCK_BASE|0x00)
  91. #define SSITIME (SPI_BLOCK_BASE|0x04)
  92. #define SSITX (SPI_BLOCK_BASE|0x08)
  93. #define SSIRX (SPI_BLOCK_BASE|0x0C)
  94. #define SSIINTC (SPI_BLOCK_BASE|0x10)
  95. #define SSIINTS (SPI_BLOCK_BASE|0x14)
  96. #define SSIDBG1 (SPI_BLOCK_BASE|0x18)
  97. #define SSIDBG2 (SPI_BLOCK_BASE|0x1C)
  98. #define SSIID (SPI_BLOCK_BASE|0x20)
  99. #define WKREQ (SYSTEM_BLOCK1_BASE|0x00)
  100. #define CLKENB (SYSTEM_BLOCK1_BASE|0x04)
  101. #define DRAMPWR (SYSTEM_BLOCK1_BASE|0x08)
  102. #define INTMASK (SYSTEM_BLOCK1_BASE|0x0C)
  103. #define GPIOSEL (SYSTEM_BLOCK2_BASE|0x00)
  104. #define GPIODATA (GPIO_BLOCK_BASE|0x00)
  105. #define GPIODIR (GPIO_BLOCK_BASE|0x04)
  106. #define GPIOIS (GPIO_BLOCK_BASE|0x08)
  107. #define GPIOIBE (GPIO_BLOCK_BASE|0x0C)
  108. #define GPIOIEV (GPIO_BLOCK_BASE|0x10)
  109. #define GPIOIE (GPIO_BLOCK_BASE|0x14)
  110. #define GPIORIS (GPIO_BLOCK_BASE|0x18)
  111. #define GPIOMIS (GPIO_BLOCK_BASE|0x1C)
  112. #define GPIOIC (GPIO_BLOCK_BASE|0x20)
  113. #define GPIOOMS (GPIO_BLOCK_BASE|0x24)
  114. #define GPIOPC (GPIO_BLOCK_BASE|0x28)
  115. #define GPIOID (GPIO_BLOCK_BASE|0x30)
  116. #define SPI_WRITE(reg, val) \
  117. { SSITX, 0x00010000 | (((reg) & 0xff) << 8) | ((val) & 0xff) }, \
  118. { 0, 5 },
  119. #define SPI_WRITE1(reg) \
  120. { SSITX, (reg) & 0xff }, \
  121. { 0, 5 },
  122. struct mddi_table {
  123. uint32_t reg;
  124. uint32_t value;
  125. };
  126. static struct mddi_table mddi_toshiba_init_table[] = {
  127. { DPSET0, 0x09e90046 },
  128. { DPSET1, 0x00000118 },
  129. { DPSUS, 0x00000000 },
  130. { DPRUN, 0x00000001 },
  131. { 1, 14 }, /* msleep 14 */
  132. { SYSCKENA, 0x00000001 },
  133. { CLKENB, 0x0000A1EF }, /* # SYS.CLKENB # Enable clocks for each module (without DCLK , i2cCLK) */
  134. { GPIODATA, 0x02000200 }, /* # GPI .GPIODATA # GPIO2(RESET_LCD_N) set to 0 , GPIO3(eDRAM_Power) set to 0 */
  135. { GPIODIR, 0x000030D }, /* 24D # GPI .GPIODIR # Select direction of GPIO port (0,2,3,6,9 output) */
  136. { GPIOSEL, 0/*0x00000173*/}, /* # SYS.GPIOSEL # GPIO port multiplexing control */
  137. { GPIOPC, 0x03C300C0 }, /* # GPI .GPIOPC # GPIO2,3 PD cut */
  138. { WKREQ, 0x00000000 }, /* # SYS.WKREQ # Wake-up request event is VSYNC alignment */
  139. { GPIOIBE, 0x000003FF },
  140. { GPIOIS, 0x00000000 },
  141. { GPIOIC, 0x000003FF },
  142. { GPIOIE, 0x00000000 },
  143. { GPIODATA, 0x00040004 }, /* # GPI .GPIODATA # eDRAM VD supply */
  144. { 1, 1 }, /* msleep 1 */
  145. { GPIODATA, 0x02040004 }, /* # GPI .GPIODATA # eDRAM VD supply */
  146. { DRAMPWR, 0x00000001 }, /* eDRAM power */
  147. };
  148. #define GPIOSEL_VWAKEINT (1U << 0)
  149. #define INTMASK_VWAKEOUT (1U << 0)
  150. static struct clk *gp_clk;
  151. static int trout_new_backlight = 1;
  152. static struct vreg *vreg_mddi_1v5;
  153. static struct vreg *vreg_lcm_2v85;
  154. static void trout_process_mddi_table(struct msm_mddi_client_data *client_data,
  155. struct mddi_table *table, size_t count)
  156. {
  157. int i;
  158. for (i = 0; i < count; i++) {
  159. uint32_t reg = table[i].reg;
  160. uint32_t value = table[i].value;
  161. if (reg == 0)
  162. udelay(value);
  163. else if (reg == 1)
  164. msleep(value);
  165. else
  166. client_data->remote_write(client_data, value, reg);
  167. }
  168. }
  169. static int trout_mddi_toshiba_client_init(
  170. struct msm_mddi_bridge_platform_data *bridge_data,
  171. struct msm_mddi_client_data *client_data)
  172. {
  173. int panel_id;
  174. client_data->auto_hibernate(client_data, 0);
  175. trout_process_mddi_table(client_data, mddi_toshiba_init_table,
  176. ARRAY_SIZE(mddi_toshiba_init_table));
  177. client_data->auto_hibernate(client_data, 1);
  178. panel_id = (client_data->remote_read(client_data, GPIODATA) >> 4) & 3;
  179. if (panel_id > 1) {
  180. printk(KERN_WARNING "unknown panel id at mddi_enable\n");
  181. return -1;
  182. }
  183. return 0;
  184. }
  185. static int trout_mddi_toshiba_client_uninit(
  186. struct msm_mddi_bridge_platform_data *bridge_data,
  187. struct msm_mddi_client_data *client_data)
  188. {
  189. return 0;
  190. }
  191. static struct resource resources_msm_fb[] = {
  192. {
  193. .start = MSM_FB_BASE,
  194. .end = MSM_FB_BASE + MSM_FB_SIZE,
  195. .flags = IORESOURCE_MEM,
  196. },
  197. };
  198. struct msm_mddi_bridge_platform_data toshiba_client_data = {
  199. .init = trout_mddi_toshiba_client_init,
  200. .uninit = trout_mddi_toshiba_client_uninit,
  201. .fb_data = {
  202. .xres = 320,
  203. .yres = 480,
  204. .width = 45,
  205. .height = 67,
  206. .output_format = 0,
  207. },
  208. };
  209. static struct msm_mddi_platform_data mddi_pdata = {
  210. .clk_rate = 122880000,
  211. .fb_resource = resources_msm_fb,
  212. .num_clients = 1,
  213. .client_platform_data = {
  214. {
  215. .product_id = (0xd263 << 16 | 0),
  216. .name = "mddi_c_d263_0000",
  217. .id = 0,
  218. .client_data = &toshiba_client_data,
  219. .clk_rate = 0,
  220. },
  221. },
  222. };
  223. int __init trout_init_panel(void)
  224. {
  225. int rc;
  226. if (!machine_is_trout())
  227. return 0;
  228. vreg_mddi_1v5 = vreg_get(0, "gp2");
  229. if (IS_ERR(vreg_mddi_1v5))
  230. return PTR_ERR(vreg_mddi_1v5);
  231. vreg_lcm_2v85 = vreg_get(0, "gp4");
  232. if (IS_ERR(vreg_lcm_2v85))
  233. return PTR_ERR(vreg_lcm_2v85);
  234. trout_new_backlight = system_rev >= 5;
  235. if (trout_new_backlight) {
  236. uint32_t config = PCOM_GPIO_CFG(27, 0, GPIO_OUTPUT,
  237. GPIO_NO_PULL, GPIO_8MA);
  238. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &config, 0);
  239. } else {
  240. uint32_t config = PCOM_GPIO_CFG(27, 1, GPIO_OUTPUT,
  241. GPIO_NO_PULL, GPIO_8MA);
  242. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &config, 0);
  243. gp_clk = clk_get(NULL, "gp_clk");
  244. if (IS_ERR(gp_clk)) {
  245. printk(KERN_ERR "trout_init_panel: could not get gp"
  246. "clock\n");
  247. gp_clk = NULL;
  248. }
  249. rc = clk_set_rate(gp_clk, 19200000);
  250. if (rc)
  251. printk(KERN_ERR "trout_init_panel: set clock rate "
  252. "failed\n");
  253. }
  254. rc = platform_device_register(&msm_device_mdp);
  255. if (rc)
  256. return rc;
  257. msm_device_mddi0.dev.platform_data = &mddi_pdata;
  258. return platform_device_register(&msm_device_mddi0);
  259. }
  260. device_initcall(trout_init_panel);