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