Advertisement
Guest User

Untitled

a guest
Apr 29th, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.51 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, 0x2c},
  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 eid_es3_deinit_seq[] = {
  66. {0x2800, 0x01},
  67. {0x5300, 0x28},
  68. {0x5500, 0},
  69. {0x5300, 0x8},
  70. {0x5e03, 0},
  71. {0x5300, 0},
  72. {0x1000, 1},
  73. };
  74.  
  75. //static struct clk *gp_clk;
  76. static struct vreg *vreg_lcd_1; /* LCD1 */
  77. static struct vreg *vreg_lcd_2; /* LCD2 */
  78.  
  79.  
  80. static int htcwhitestone_mddi_client_init(
  81. struct msm_mddi_bridge_platform_data *bridge_data,
  82. struct msm_mddi_client_data *client_data)
  83. {
  84. int i;
  85. unsigned reg, val;
  86.  
  87. printk(KERN_DEBUG "%s\n", __func__);
  88.  
  89. client_data->auto_hibernate(client_data, 0);
  90.  
  91. for (i = 0; i < ARRAY_SIZE(eid_es3_init_seq); i++) {
  92. reg = cpu_to_le32(eid_es3_init_seq[i].reg);
  93. val = cpu_to_le32(eid_es3_init_seq[i].val);
  94. if (reg == REG_WAIT)
  95. msleep(val);
  96. else
  97. client_data->remote_write(client_data, val, reg);
  98. }
  99.  
  100. client_data->auto_hibernate(client_data, 1);
  101.  
  102. return 0;
  103. }
  104.  
  105. static int htcwhitestone_mddi_client_uninit(
  106. struct msm_mddi_bridge_platform_data *bridge_data,
  107. struct msm_mddi_client_data *client_data)
  108. {
  109. int i;
  110. unsigned reg, val;
  111.  
  112. printk(KERN_DEBUG "%s\n", __func__);
  113.  
  114. for (i = 0; i < ARRAY_SIZE(eid_es3_deinit_seq); i++) {
  115. reg = cpu_to_le32(eid_es3_deinit_seq[i].reg);
  116. val = cpu_to_le32(eid_es3_deinit_seq[i].val);
  117. if (reg == REG_WAIT)
  118. msleep(val);
  119. else
  120. client_data->remote_write(client_data, val, reg);
  121. }
  122.  
  123. return 0;
  124. }
  125.  
  126. static int htcwhitestone_mddi_panel_blank(
  127. struct msm_mddi_bridge_platform_data *bridge_data,
  128. struct msm_mddi_client_data *client_data)
  129. {
  130. printk(KERN_DEBUG "%s\n", __func__);
  131.  
  132. //~ micropklt_panel_suspend();
  133.  
  134. return 0;
  135. }
  136.  
  137. static int htcwhitestone_mddi_panel_unblank(
  138. struct msm_mddi_bridge_platform_data *bridge_data,
  139. struct msm_mddi_client_data *client_data)
  140. {
  141. printk(KERN_DEBUG "%s\n", __func__);
  142.  
  143. // SET_DISPLAY_ON
  144. // client_data->remote_write(client_data, 0x00, 0x2900);
  145. // WRCTRLD
  146. // client_data->remote_write(client_data, 0x2c, 0x5300);
  147.  
  148. //~ micropklt_panel_resume();
  149.  
  150. return 0;
  151. }
  152.  
  153. static void htcwhitestone_mddi_power_client(
  154. struct msm_mddi_client_data *client_data,
  155. int on)
  156. {
  157. struct msm_dex_command dex;
  158.  
  159. printk(KERN_DEBUG "%s(%s)\n", __func__, on ? "on" : "off");
  160.  
  161. if (on) {
  162. vreg_enable(vreg_lcd_1);
  163. vreg_enable(vreg_lcd_2);
  164. mdelay(50);
  165.  
  166. gpio_set_value(57, 0);
  167. gpio_set_value(58, 0);
  168. msleep(5);
  169.  
  170. dex.cmd=PCOM_PMIC_REG_ON;
  171. dex.has_data=1;
  172. dex.data=0x80;
  173. msm_proc_comm_wince(&dex,0);
  174. msleep(5);
  175.  
  176. dex.da ta=0x2000;
  177. msm_proc_comm_wince(&dex,0);
  178. msleep(5);
  179.  
  180. gpio_set_value(87, 1);
  181. msleep(10);
  182. } else {
  183. gpio_set_value(87, 0);
  184. msleep(10);
  185.  
  186. dex.cmd=PCOM_PMIC_REG_OFF;
  187. dex.has_data=1;
  188. dex.data=0x2000;
  189. msm_proc_comm_wince(&dex,0);
  190. msleep(5);
  191.  
  192. dex.data=0x80;
  193. msm_proc_comm_wince(&dex,0);
  194. msleep(5);
  195.  
  196. gpio_set_value(57, 1);
  197. gpio_set_value(58, 1);
  198. msleep(5);
  199.  
  200. vreg_disable(vreg_lcd_1);
  201. vreg_disable(vreg_lcd_2);
  202. mdelay(50);
  203. }
  204. }
  205.  
  206. extern struct resource resources_msm_fb[];
  207.  
  208. static struct msm_mddi_bridge_platform_data novatec_client_data = {
  209. .init = htcwhitestone_mddi_client_init,
  210. .uninit = htcwhitestone_mddi_client_uninit,
  211. .blank = htcwhitestone_mddi_panel_blank,
  212. .unblank = htcwhitestone_mddi_panel_unblank,
  213. .fb_data = {
  214. .xres = 480,
  215. .yres = 800,
  216. .output_format = 0,
  217. },
  218. #if 0
  219. .panel_conf = {
  220. .caps = MSMFB_CAP_CABC,
  221. },
  222. #endif
  223. };
  224.  
  225. static struct msm_mddi_platform_data mddi_pdata = {
  226. .vsync_irq = MSM_GPIO_TO_INT(WHIT100_LCD_VSYNC),
  227. .power_client = htcwhitestone_mddi_power_client,
  228. .fb_resource = resources_msm_fb,
  229. .num_clients = 2,
  230. .client_platform_data = {
  231. {
  232. // unconfirmed
  233. .product_id = (0xb9f6 << 16 | 0x5580),
  234. .name = "mddi_c_b9f6_5582",
  235. .id = 0,
  236. .client_data = &novatec_client_data,
  237. .clk_rate = 0,
  238. },
  239. {
  240. // unconfirmed
  241. .product_id = (0xb9f6 << 16 | 0x5582),
  242. .name = "mddi_c_b9f6_5582",
  243. .id = 0,
  244. .client_data = &novatec_client_data,
  245. .clk_rate = 0,
  246. }
  247. },
  248. };
  249.  
  250. int __init htcwhitestone_init_panel(void)
  251. {
  252. int rc, panel_id;
  253.  
  254. if(!machine_is_htcwhitestone()) {
  255. printk(KERN_INFO "%s: panel does not apply to this device, aborted\n", __func__);
  256. return -1;
  257. }
  258.  
  259. panel_id = readl(MSM_SPL_BASE+0x81034);
  260. printk("Panel type detected: %x\n",panel_id);
  261.  
  262. printk(KERN_INFO "%s: Initializing panel\n", __func__);
  263.  
  264. #if 0
  265. gp_clk = clk_get(NULL, "gp_clk");
  266. if (IS_ERR(gp_clk)) {
  267. printk(KERN_ERR "%s: could not get gp clock\n", __func__);
  268. gp_clk = NULL;
  269. }
  270. rc = clk_set_rate(gp_clk, 19200000);
  271. if (rc)
  272. {
  273. printk(KERN_ERR "%s: set clock rate failed\n", __func__);
  274. }
  275. #endif
  276. gpio_request(57, "panel 1");
  277. gpio_request(58, "panel 2");
  278. gpio_request(87, "panel 3");
  279.  
  280. gpio_direction_output(57, 1);
  281. gpio_direction_output(58, 1);
  282. gpio_direction_output(87, 1);
  283.  
  284. vreg_lcd_1 = vreg_get(0, "gp2");
  285. if (IS_ERR(vreg_lcd_1))
  286. return PTR_ERR(vreg_lcd_1);
  287.  
  288. vreg_lcd_2 = vreg_get(0, "gp4");
  289. if (IS_ERR(vreg_lcd_2))
  290. return PTR_ERR(vreg_lcd_2);
  291.  
  292. rc = gpio_request(WHIT100_LCD_VSYNC, "vsync");
  293. if (rc)
  294. return rc;
  295. rc = gpio_direction_input(WHIT100_LCD_VSYNC);
  296. if (rc)
  297. return rc;
  298.  
  299. rc = platform_device_register(&msm_device_mdp);
  300. if (rc)
  301. return rc;
  302. msm_device_mddi0.dev.platform_data = &mddi_pdata;
  303. return platform_device_register(&msm_device_mddi0);
  304. }
  305.  
  306. device_initcall(htcwhitestone_init_panel);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement