Advertisement
Guest User

Untitled

a guest
Apr 24th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.48 KB | None | 0 0
  1. /* linux/arch/arm/mach-msm/board-htcwhitestone-panel.c
  2. * Based on board-htctopaz-panel.c.
  3. */
  4.  
  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 <linux/microp-klt.h>
  13.  
  14. #include <asm/io.h>
  15. #include <asm/gpio.h>
  16. #include <asm/mach-types.h>
  17.  
  18. #include <mach/msm_fb.h>
  19. #include <mach/vreg.h>
  20. #include <linux/microp-klt.h>
  21.  
  22. #include "board-htcwhitestone.h"
  23. #include "proc_comm_wince.h"
  24. #include "devices.h"
  25.  
  26. #define REG_WAIT (0xffff)
  27.  
  28. static struct nov_regs {
  29. unsigned reg;
  30. unsigned val;
  31. } eid_es3_init_seq[] = {
  32. {0x5100, 0x00},
  33. {0x1100, 0x01},
  34. {REG_WAIT, 100},
  35.  
  36. {0x4e00, 0},
  37. {0x180, 2},
  38. {0x880, 0},
  39. {0x2080, 0x33},
  40. {0x2680, 0x78},
  41. {0x2880, 0x3e},
  42. {0x2980,4},
  43. {0x2C80, 0x22},
  44. {0x2e80, 0},
  45. {0xde80, 2},
  46. {0x3a00, 0x55},
  47. {0x3500, 0},
  48. {0x4400, 0},
  49. {0x4401, 0},
  50. {0x5e00, 0},
  51. {0x6a01, 0},
  52. {0x6a02, 1},
  53. {0x5301, 0x10},
  54. {0x5500, 2},
  55. {0x6a17, 1},
  56. {0x6a18, 0xff},
  57. {0x2900, 1},
  58. {0x5300, 0x2d},
  59. {0x5e03, 0x1},
  60.  
  61. // {0x1100, 0x00}, // EXIT_SLEEP_MODE ("Sleep Out")
  62. {REG_WAIT, 120}, // REG_WAIT (must wait 120ms after "Sleep Out")
  63. };
  64.  
  65. static struct nov_regs nov_deinit_seq[] = {
  66. {0x5300, 0x00}, // WRCTRLD
  67. {0x2800, 0x00}, // SET_DISPLAY_OFF
  68. {0x1000, 0x00}, // ENTER_SLEEP_MODE ("Sleep In")
  69. };
  70.  
  71. //static struct clk *gp_clk;
  72. static struct vreg *vreg_lcd_1; /* LCD1 */
  73. static struct vreg *vreg_lcd_2; /* LCD2 */
  74.  
  75.  
  76. static int htcwhitestone_mddi_client_init(
  77. struct msm_mddi_bridge_platform_data *bridge_data,
  78. struct msm_mddi_client_data *client_data)
  79. {
  80. int i;
  81. unsigned reg, val;
  82.  
  83. printk(KERN_DEBUG "%s\n", __func__);
  84.  
  85. client_data->auto_hibernate(client_data, 0);
  86.  
  87. for (i = 0; i < ARRAY_SIZE(nov_init_seq); i++) {
  88. reg = cpu_to_le32(nov_init_seq[i].reg);
  89. val = cpu_to_le32(nov_init_seq[i].val);
  90. if (reg == REG_WAIT)
  91. msleep(val);
  92. else
  93. client_data->remote_write(client_data, val, reg);
  94. }
  95.  
  96. client_data->auto_hibernate(client_data, 1);
  97.  
  98. return 0;
  99. }
  100.  
  101. static int htcwhitestone_mddi_client_uninit(
  102. struct msm_mddi_bridge_platform_data *bridge_data,
  103. struct msm_mddi_client_data *client_data)
  104. {
  105. int i;
  106. unsigned reg, val;
  107.  
  108. printk(KERN_DEBUG "%s\n", __func__);
  109.  
  110. for (i = 0; i < ARRAY_SIZE(nov_deinit_seq); i++) {
  111. reg = cpu_to_le32(nov_deinit_seq[i].reg);
  112. val = cpu_to_le32(nov_deinit_seq[i].val);
  113. if (reg == REG_WAIT)
  114. msleep(val);
  115. else
  116. client_data->remote_write(client_data, val, reg);
  117. }
  118.  
  119. return 0;
  120. }
  121.  
  122. static int htcwhitestone_mddi_panel_blank(
  123. struct msm_mddi_bridge_platform_data *bridge_data,
  124. struct msm_mddi_client_data *client_data)
  125. {
  126. printk(KERN_DEBUG "%s\n", __func__);
  127.  
  128. //~ micropklt_panel_suspend();
  129.  
  130. return 0;
  131. }
  132.  
  133. static int htcwhitestone_mddi_panel_unblank(
  134. struct msm_mddi_bridge_platform_data *bridge_data,
  135. struct msm_mddi_client_data *client_data)
  136. {
  137. printk(KERN_DEBUG "%s\n", __func__);
  138.  
  139. // SET_DISPLAY_ON
  140. client_data->remote_write(client_data, 0x00, 0x2900);
  141. // WRCTRLD
  142. client_data->remote_write(client_data, 0x2c, 0x5300);
  143.  
  144. //~ micropklt_panel_resume();
  145.  
  146. return 0;
  147. }
  148.  
  149. static void htcwhitestone_mddi_power_client(
  150. struct msm_mddi_client_data *client_data,
  151. int on)
  152. {
  153. struct msm_dex_command dex;
  154.  
  155. printk(KERN_DEBUG "%s(%s)\n", __func__, on ? "on" : "off");
  156.  
  157. if (on) {
  158. vreg_enable(vreg_lcd_1);
  159. vreg_enable(vreg_lcd_2);
  160. mdelay(50);
  161.  
  162. gpio_set_value(57, 0);
  163. gpio_set_value(58, 0);
  164. msleep(5);
  165.  
  166. dex.cmd=PCOM_PMIC_REG_ON;
  167. dex.has_data=1;
  168. dex.data=0x80;
  169. msm_proc_comm_wince(&dex,0);
  170. msleep(5);
  171.  
  172. dex.data=0x2000;
  173. msm_proc_comm_wince(&dex,0);
  174. msleep(5);
  175.  
  176. gpio_set_value(87, 1);
  177. msleep(10);
  178. } else {
  179. gpio_set_value(87, 0);
  180. msleep(10);
  181.  
  182. dex.cmd=PCOM_PMIC_REG_OFF;
  183. dex.has_data=1;
  184. dex.data=0x2000;
  185. msm_proc_comm_wince(&dex,0);
  186. msleep(5);
  187.  
  188. dex.data=0x80;
  189. msm_proc_comm_wince(&dex,0);
  190. msleep(5);
  191.  
  192. gpio_set_value(57, 1);
  193. gpio_set_value(58, 1);
  194. msleep(5);
  195.  
  196. vreg_disable(vreg_lcd_1);
  197. vreg_disable(vreg_lcd_2);
  198. mdelay(50);
  199. }
  200. }
  201.  
  202. extern struct resource resources_msm_fb[];
  203.  
  204. static struct msm_mddi_bridge_platform_data novatec_client_data = {
  205. .init = htcwhitestone_mddi_client_init,
  206. .uninit = htcwhitestone_mddi_client_uninit,
  207. .blank = htcwhitestone_mddi_panel_blank,
  208. .unblank = htcwhitestone_mddi_panel_unblank,
  209. .fb_data = {
  210. .xres = 480,
  211. .yres = 800,
  212. .output_format = 0,
  213. },
  214. #if 0
  215. .panel_conf = {
  216. .caps = MSMFB_CAP_CABC,
  217. },
  218. #endif
  219. };
  220.  
  221. static struct msm_mddi_platform_data mddi_pdata = {
  222. .vsync_irq = MSM_GPIO_TO_INT(WHIT100_LCD_VSYNC),
  223. .power_client = htcwhitestone_mddi_power_client,
  224. .fb_resource = resources_msm_fb,
  225. .num_clients = 2,
  226. .client_platform_data = {
  227. {
  228. // unconfirmed
  229. .product_id = (0xb9f6 << 16 | 0x5580),
  230. .name = "mddi_c_b9f6_5582",
  231. .id = 0,
  232. .client_data = &novatec_client_data,
  233. .clk_rate = 0,
  234. },
  235. {
  236. // unconfirmed
  237. .product_id = (0xb9f6 << 16 | 0x5582),
  238. .name = "mddi_c_b9f6_5582",
  239. .id = 0,
  240. .client_data = &novatec_client_data,
  241. .clk_rate = 0,
  242. }
  243. },
  244. };
  245.  
  246. int __init htcwhitestone_init_panel(void)
  247. {
  248. int rc, panel_id;
  249.  
  250. if(!machine_is_htcwhitestone()) {
  251. printk(KERN_INFO "%s: panel does not apply to this device, aborted\n", __func__);
  252. return -1;
  253. }
  254.  
  255. panel_id = readl(MSM_SPL_BASE+0x81034);
  256. printk("Panel type detected: %x\n",panel_id);
  257.  
  258. printk(KERN_INFO "%s: Initializing panel\n", __func__);
  259.  
  260. #if 0
  261. gp_clk = clk_get(NULL, "gp_clk");
  262. if (IS_ERR(gp_clk)) {
  263. printk(KERN_ERR "%s: could not get gp clock\n", __func__);
  264. gp_clk = NULL;
  265. }
  266. rc = clk_set_rate(gp_clk, 19200000);
  267. if (rc)
  268. {
  269. printk(KERN_ERR "%s: set clock rate failed\n", __func__);
  270. }
  271. #endif
  272. gpio_request(57, "panel 1");
  273. gpio_request(58, "panel 2");
  274. gpio_request(87, "panel 3");
  275.  
  276. gpio_direction_output(57, 1);
  277. gpio_direction_output(58, 1);
  278. gpio_direction_output(87, 1);
  279.  
  280. vreg_lcd_1 = vreg_get(0, "gp2");
  281. if (IS_ERR(vreg_lcd_1))
  282. return PTR_ERR(vreg_lcd_1);
  283.  
  284. vreg_lcd_2 = vreg_get(0, "gp4");
  285. if (IS_ERR(vreg_lcd_2))
  286. return PTR_ERR(vreg_lcd_2);
  287.  
  288. rc = gpio_request(WHIT100_LCD_VSYNC, "vsync");
  289. if (rc)
  290. return rc;
  291. rc = gpio_direction_input(WHIT100_LCD_VSYNC);
  292. if (rc)
  293. return rc;
  294.  
  295. rc = platform_device_register(&msm_device_mdp);
  296. if (rc)
  297. return rc;
  298. msm_device_mddi0.dev.platform_data = &mddi_pdata;
  299. return platform_device_register(&msm_device_mddi0);
  300. }
  301.  
  302. device_initcall(htcwhitestone_init_panel);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement