board-msm7627a-display.c 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454
  1. /* Copyright (c) 2012, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #include <linux/init.h>
  14. #include <linux/ioport.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/bootmem.h>
  17. #include <linux/regulator/consumer.h>
  18. #include <linux/gpio.h>
  19. #include <asm/mach-types.h>
  20. #include <asm/io.h>
  21. #include <mach/msm_bus_board.h>
  22. #include <mach/msm_memtypes.h>
  23. #include <mach/board.h>
  24. #include <mach/gpiomux.h>
  25. #include <mach/socinfo.h>
  26. #include <mach/rpc_pmapp.h>
  27. #include "devices.h"
  28. #include "board-msm7627a.h"
  29. #ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
  30. #define MSM_FB_SIZE 0x4BF000
  31. #define MSM7x25A_MSM_FB_SIZE 0x1C2000
  32. #define MSM8x25_MSM_FB_SIZE 0x5FA000
  33. #else
  34. #define MSM_FB_SIZE 0x32A000
  35. #define MSM7x25A_MSM_FB_SIZE 0x12C000
  36. #define MSM8x25_MSM_FB_SIZE 0x3FC000
  37. #endif
  38. /*
  39. * Reserve enough v4l2 space for a double buffered full screen
  40. * res image (864x480x1.5x2)
  41. */
  42. #define MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE 1244160
  43. static unsigned fb_size = MSM_FB_SIZE;
  44. static int __init fb_size_setup(char *p)
  45. {
  46. fb_size = memparse(p, NULL);
  47. return 0;
  48. }
  49. early_param("fb_size", fb_size_setup);
  50. static uint32_t lcdc_truly_gpio_initialized;
  51. static struct regulator_bulk_data regs_truly_lcdc[] = {
  52. { .supply = "rfrx1", .min_uV = 1800000, .max_uV = 1800000 },
  53. };
  54. #define SKU3_LCDC_GPIO_DISPLAY_RESET 90
  55. #define SKU3_LCDC_GPIO_SPI_MOSI 19
  56. #define SKU3_LCDC_GPIO_SPI_CLK 20
  57. #define SKU3_LCDC_GPIO_SPI_CS0_N 21
  58. #define SKU3_LCDC_LCD_CAMERA_LDO_2V8 35 /*LCD_CAMERA_LDO_2V8*/
  59. #define SKU3_LCDC_LCD_CAMERA_LDO_1V8 34 /*LCD_CAMERA_LDO_1V8*/
  60. #define SKU3_1_LCDC_LCD_CAMERA_LDO_1V8 58 /*LCD_CAMERA_LDO_1V8*/
  61. static struct regulator *gpio_reg_2p85v_sku3, *gpio_reg_1p8v_sku3;
  62. static uint32_t lcdc_truly_gpio_table[] = {
  63. 19,
  64. 20,
  65. 21,
  66. 89,
  67. 90,
  68. };
  69. static char *lcdc_gpio_name_table[5] = {
  70. "spi_mosi",
  71. "spi_clk",
  72. "spi_cs",
  73. "gpio_bkl_en",
  74. "gpio_disp_reset",
  75. };
  76. static char lcdc_splash_is_enabled(void);
  77. static int lcdc_truly_gpio_init(void)
  78. {
  79. int i;
  80. int rc = 0;
  81. if (!lcdc_truly_gpio_initialized) {
  82. for (i = 0; i < ARRAY_SIZE(lcdc_truly_gpio_table); i++) {
  83. rc = gpio_request(lcdc_truly_gpio_table[i],
  84. lcdc_gpio_name_table[i]);
  85. if (rc < 0) {
  86. pr_err("Error request gpio %s\n",
  87. lcdc_gpio_name_table[i]);
  88. goto truly_gpio_fail;
  89. }
  90. rc = gpio_tlmm_config(GPIO_CFG(lcdc_truly_gpio_table[i],
  91. 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
  92. GPIO_CFG_2MA), GPIO_CFG_ENABLE);
  93. if (rc < 0) {
  94. pr_err("Error config lcdc gpio:%d\n",
  95. lcdc_truly_gpio_table[i]);
  96. goto truly_gpio_fail;
  97. }
  98. if (lcdc_splash_is_enabled())
  99. rc = gpio_direction_output(
  100. lcdc_truly_gpio_table[i], 1);
  101. else
  102. rc = gpio_direction_output(
  103. lcdc_truly_gpio_table[i], 0);
  104. if (rc < 0) {
  105. pr_err("Error direct lcdc gpio:%d\n",
  106. lcdc_truly_gpio_table[i]);
  107. goto truly_gpio_fail;
  108. }
  109. }
  110. lcdc_truly_gpio_initialized = 1;
  111. }
  112. return rc;
  113. truly_gpio_fail:
  114. for (; i >= 0; i--) {
  115. pr_err("Freeing GPIO: %d", lcdc_truly_gpio_table[i]);
  116. gpio_free(lcdc_truly_gpio_table[i]);
  117. }
  118. lcdc_truly_gpio_initialized = 0;
  119. return rc;
  120. }
  121. void sku3_lcdc_power_init(void)
  122. {
  123. int rc = 0;
  124. u32 socinfo = socinfo_get_platform_type();
  125. /* LDO_EXT2V8 */
  126. if (gpio_request(SKU3_LCDC_LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
  127. pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
  128. return;
  129. }
  130. rc = gpio_tlmm_config(GPIO_CFG(SKU3_LCDC_LCD_CAMERA_LDO_2V8, 0,
  131. GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
  132. GPIO_CFG_ENABLE);
  133. if (rc < 0) {
  134. pr_err("%s:unable to enable lcd_camera_ldo_2v8!\n", __func__);
  135. goto fail_gpio2;
  136. }
  137. /* LDO_EVT1V8 */
  138. if (socinfo == 0x0B) {
  139. if (gpio_request(SKU3_LCDC_LCD_CAMERA_LDO_1V8,
  140. "lcd_camera_ldo_1v8")) {
  141. pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
  142. goto fail_gpio1;
  143. }
  144. rc = gpio_tlmm_config(GPIO_CFG(SKU3_LCDC_LCD_CAMERA_LDO_1V8, 0,
  145. GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
  146. GPIO_CFG_ENABLE);
  147. if (rc < 0) {
  148. pr_err("%s: unable to enable lcdc_camera_ldo_1v8!\n",
  149. __func__);
  150. goto fail_gpio1;
  151. }
  152. } else if (socinfo == 0x0F || machine_is_msm8625_qrd7()) {
  153. if (gpio_request(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
  154. "lcd_camera_ldo_1v8")) {
  155. pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
  156. goto fail_gpio1;
  157. }
  158. rc = gpio_tlmm_config(GPIO_CFG(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
  159. 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
  160. GPIO_CFG_ENABLE);
  161. if (rc < 0) {
  162. pr_err("%s: unable to enable lcdc_camera_ldo_1v8!\n",
  163. __func__);
  164. goto fail_gpio1;
  165. }
  166. }
  167. if (socinfo == 0x0B)
  168. gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_1V8);
  169. else if (socinfo == 0x0F || machine_is_msm8625_qrd7())
  170. gpio_free(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8);
  171. gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_2V8);
  172. gpio_reg_2p85v_sku3 = regulator_get(&msm_lcdc_device.dev,
  173. "lcd_vdd_sku3");
  174. if (IS_ERR(gpio_reg_2p85v_sku3)) {
  175. pr_err("%s:ext_2p85v regulator get failed", __func__);
  176. regulator_put(gpio_reg_2p85v_sku3);
  177. return;
  178. }
  179. gpio_reg_1p8v_sku3 = regulator_get(&msm_lcdc_device.dev,
  180. "lcd_vddi_sku3");
  181. if (IS_ERR(gpio_reg_1p8v_sku3)) {
  182. pr_err("%s:ext_1p8v regulator get failed", __func__);
  183. regulator_put(gpio_reg_1p8v_sku3);
  184. return;
  185. }
  186. rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_truly_lcdc),
  187. regs_truly_lcdc);
  188. if (rc)
  189. pr_err("%s: could not get regulators: %d\n", __func__, rc);
  190. rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_truly_lcdc),
  191. regs_truly_lcdc);
  192. if (rc)
  193. pr_err("%s: could not set voltages: %d\n", __func__, rc);
  194. return;
  195. fail_gpio1:
  196. if (socinfo == 0x0B)
  197. gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_1V8);
  198. else if (socinfo == 0x0F || machine_is_msm8625_qrd7())
  199. gpio_free(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8);
  200. fail_gpio2:
  201. gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_2V8);
  202. return;
  203. }
  204. int sku3_lcdc_power_onoff(int on)
  205. {
  206. int rc = 0;
  207. if (on) {
  208. rc = regulator_enable(gpio_reg_2p85v_sku3);
  209. if (rc < 0) {
  210. pr_err("%s: reg enable failed\n", __func__);
  211. return -EINVAL;
  212. }
  213. rc = regulator_enable(gpio_reg_1p8v_sku3);
  214. if (rc < 0) {
  215. pr_err("%s: reg enable failed\n", __func__);
  216. return -EINVAL;
  217. }
  218. rc = regulator_bulk_enable(ARRAY_SIZE(regs_truly_lcdc),
  219. regs_truly_lcdc);
  220. if (rc) {
  221. pr_err("%s: could not enable regulators: %d\n",
  222. __func__, rc);
  223. return -EINVAL;
  224. }
  225. } else {
  226. rc = regulator_disable(gpio_reg_2p85v_sku3);
  227. if (rc < 0) {
  228. pr_err("%s: reg disable failed\n", __func__);
  229. return -EINVAL;
  230. }
  231. rc = regulator_disable(gpio_reg_1p8v_sku3);
  232. if (rc < 0) {
  233. pr_err("%s: reg disable failed\n", __func__);
  234. return -EINVAL;
  235. }
  236. rc = regulator_bulk_disable(ARRAY_SIZE(regs_truly_lcdc),
  237. regs_truly_lcdc);
  238. if (rc) {
  239. pr_err("%s: could not disable regulators: %d\n",
  240. __func__, rc);
  241. return -EINVAL;
  242. }
  243. }
  244. return rc;
  245. }
  246. static int sku3_lcdc_power_save(int on)
  247. {
  248. int rc = 0;
  249. static int cont_splash_done;
  250. if (on) {
  251. sku3_lcdc_power_onoff(1);
  252. rc = lcdc_truly_gpio_init();
  253. if (rc < 0) {
  254. pr_err("%s(): Truly GPIO initializations failed",
  255. __func__);
  256. return rc;
  257. }
  258. if (lcdc_splash_is_enabled() && !cont_splash_done) {
  259. cont_splash_done = 1;
  260. return rc;
  261. }
  262. if (lcdc_truly_gpio_initialized) {
  263. /*LCD reset*/
  264. gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 1);
  265. msleep(20);
  266. gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 0);
  267. msleep(20);
  268. gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 1);
  269. msleep(20);
  270. }
  271. } else {
  272. /* pull down LCD IO to avoid current leakage */
  273. gpio_set_value(SKU3_LCDC_GPIO_SPI_MOSI, 0);
  274. gpio_set_value(SKU3_LCDC_GPIO_SPI_CLK, 0);
  275. gpio_set_value(SKU3_LCDC_GPIO_SPI_CS0_N, 0);
  276. gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 0);
  277. sku3_lcdc_power_onoff(0);
  278. }
  279. return rc;
  280. }
  281. static struct msm_panel_common_pdata lcdc_truly_panel_data = {
  282. .panel_config_gpio = NULL,
  283. .gpio_num = lcdc_truly_gpio_table,
  284. };
  285. static struct platform_device lcdc_truly_panel_device = {
  286. .name = "lcdc_truly_hvga_ips3p2335_pt",
  287. .id = 0,
  288. .dev = {
  289. .platform_data = &lcdc_truly_panel_data,
  290. }
  291. };
  292. static struct regulator_bulk_data regs_lcdc[] = {
  293. { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
  294. { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
  295. };
  296. static uint32_t lcdc_gpio_initialized;
  297. static void lcdc_toshiba_gpio_init(void)
  298. {
  299. int rc = 0;
  300. if (!lcdc_gpio_initialized) {
  301. if (gpio_request(GPIO_SPI_CLK, "spi_clk")) {
  302. pr_err("failed to request gpio spi_clk\n");
  303. return;
  304. }
  305. if (gpio_request(GPIO_SPI_CS0_N, "spi_cs")) {
  306. pr_err("failed to request gpio spi_cs0_N\n");
  307. goto fail_gpio6;
  308. }
  309. if (gpio_request(GPIO_SPI_MOSI, "spi_mosi")) {
  310. pr_err("failed to request gpio spi_mosi\n");
  311. goto fail_gpio5;
  312. }
  313. if (gpio_request(GPIO_SPI_MISO, "spi_miso")) {
  314. pr_err("failed to request gpio spi_miso\n");
  315. goto fail_gpio4;
  316. }
  317. if (gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr")) {
  318. pr_err("failed to request gpio_disp_pwr\n");
  319. goto fail_gpio3;
  320. }
  321. if (gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en")) {
  322. pr_err("failed to request gpio_bkl_en\n");
  323. goto fail_gpio2;
  324. }
  325. pmapp_disp_backlight_init();
  326. rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_lcdc),
  327. regs_lcdc);
  328. if (rc) {
  329. pr_err("%s: could not get regulators: %d\n",
  330. __func__, rc);
  331. goto fail_gpio1;
  332. }
  333. rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_lcdc),
  334. regs_lcdc);
  335. if (rc) {
  336. pr_err("%s: could not set voltages: %d\n",
  337. __func__, rc);
  338. goto fail_vreg;
  339. }
  340. lcdc_gpio_initialized = 1;
  341. }
  342. return;
  343. fail_vreg:
  344. regulator_bulk_free(ARRAY_SIZE(regs_lcdc), regs_lcdc);
  345. fail_gpio1:
  346. gpio_free(GPIO_BACKLIGHT_EN);
  347. fail_gpio2:
  348. gpio_free(GPIO_DISPLAY_PWR_EN);
  349. fail_gpio3:
  350. gpio_free(GPIO_SPI_MISO);
  351. fail_gpio4:
  352. gpio_free(GPIO_SPI_MOSI);
  353. fail_gpio5:
  354. gpio_free(GPIO_SPI_CS0_N);
  355. fail_gpio6:
  356. gpio_free(GPIO_SPI_CLK);
  357. lcdc_gpio_initialized = 0;
  358. }
  359. static uint32_t lcdc_gpio_table[] = {
  360. GPIO_SPI_CLK,
  361. GPIO_SPI_CS0_N,
  362. GPIO_SPI_MOSI,
  363. GPIO_DISPLAY_PWR_EN,
  364. GPIO_BACKLIGHT_EN,
  365. GPIO_SPI_MISO,
  366. };
  367. static void config_lcdc_gpio_table(uint32_t *table, int len, unsigned enable)
  368. {
  369. int n;
  370. if (lcdc_gpio_initialized) {
  371. /* All are IO Expander GPIOs */
  372. for (n = 0; n < (len - 1); n++)
  373. gpio_direction_output(table[n], 1);
  374. }
  375. }
  376. static void lcdc_toshiba_config_gpios(int enable)
  377. {
  378. config_lcdc_gpio_table(lcdc_gpio_table,
  379. ARRAY_SIZE(lcdc_gpio_table), enable);
  380. }
  381. static int msm_fb_lcdc_power_save(int on)
  382. {
  383. int rc = 0;
  384. /* Doing the init of the LCDC GPIOs very late as they are from
  385. an I2C-controlled IO Expander */
  386. lcdc_toshiba_gpio_init();
  387. if (lcdc_gpio_initialized) {
  388. gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on);
  389. gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on);
  390. rc = on ? regulator_bulk_enable(
  391. ARRAY_SIZE(regs_lcdc), regs_lcdc) :
  392. regulator_bulk_disable(
  393. ARRAY_SIZE(regs_lcdc), regs_lcdc);
  394. if (rc)
  395. pr_err("%s: could not %sable regulators: %d\n",
  396. __func__, on ? "en" : "dis", rc);
  397. }
  398. return rc;
  399. }
  400. static int lcdc_toshiba_set_bl(int level)
  401. {
  402. int ret;
  403. ret = pmapp_disp_backlight_set_brightness(level);
  404. if (ret)
  405. pr_err("%s: can't set lcd backlight!\n", __func__);
  406. return ret;
  407. }
  408. static int msm_lcdc_power_save(int on)
  409. {
  410. int rc = 0;
  411. if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7())
  412. rc = sku3_lcdc_power_save(on);
  413. else
  414. rc = msm_fb_lcdc_power_save(on);
  415. return rc;
  416. }
  417. static struct lcdc_platform_data lcdc_pdata = {
  418. .lcdc_gpio_config = NULL,
  419. .lcdc_power_save = msm_lcdc_power_save,
  420. };
  421. static int lcd_panel_spi_gpio_num[] = {
  422. GPIO_SPI_MOSI, /* spi_sdi */
  423. GPIO_SPI_MISO, /* spi_sdoi */
  424. GPIO_SPI_CLK, /* spi_clk */
  425. GPIO_SPI_CS0_N, /* spi_cs */
  426. };
  427. static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
  428. .panel_config_gpio = lcdc_toshiba_config_gpios,
  429. .pmic_backlight = lcdc_toshiba_set_bl,
  430. .gpio_num = lcd_panel_spi_gpio_num,
  431. };
  432. static struct platform_device lcdc_toshiba_panel_device = {
  433. .name = "lcdc_toshiba_fwvga_pt",
  434. .id = 0,
  435. .dev = {
  436. .platform_data = &lcdc_toshiba_panel_data,
  437. }
  438. };
  439. static struct resource msm_fb_resources[] = {
  440. {
  441. .flags = IORESOURCE_DMA,
  442. }
  443. };
  444. #ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
  445. static struct resource msm_v4l2_video_overlay_resources[] = {
  446. {
  447. .flags = IORESOURCE_DMA,
  448. }
  449. };
  450. #endif
  451. #define LCDC_TOSHIBA_FWVGA_PANEL_NAME "lcdc_toshiba_fwvga_pt"
  452. #define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga"
  453. static int msm_fb_detect_panel(const char *name)
  454. {
  455. int ret = -ENODEV;
  456. if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() ||
  457. machine_is_msm8625_surf()) {
  458. if (!strncmp(name, "lcdc_toshiba_fwvga_pt", 21) ||
  459. !strncmp(name, "mipi_cmd_renesas_fwvga", 22))
  460. ret = 0;
  461. } else if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
  462. || machine_is_msm8625_ffa()) {
  463. if (!strncmp(name, "mipi_cmd_renesas_fwvga", 22))
  464. ret = 0;
  465. } else if (machine_is_msm7627a_qrd1()) {
  466. if (!strncmp(name, "mipi_video_truly_wvga", 21))
  467. ret = 0;
  468. } else if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) {
  469. if (!strncmp(name, "lcdc_truly_hvga_ips3p2335_pt", 28))
  470. ret = 0;
  471. } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb() ||
  472. machine_is_msm8625_evt() ||
  473. machine_is_qrd_skud_prime()) {
  474. if (!strncmp(name, "mipi_cmd_nt35510_wvga", 21))
  475. ret = 0;
  476. }
  477. #if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
  478. !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
  479. !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
  480. if (machine_is_msm7x27a_surf() ||
  481. machine_is_msm7625a_surf() ||
  482. machine_is_msm8625_surf()) {
  483. if (!strncmp(name, LCDC_TOSHIBA_FWVGA_PANEL_NAME,
  484. strnlen(LCDC_TOSHIBA_FWVGA_PANEL_NAME,
  485. PANEL_NAME_MAX_LEN)))
  486. return 0;
  487. }
  488. #endif
  489. return ret;
  490. }
  491. static int mipi_truly_set_bl(int on)
  492. {
  493. gpio_set_value_cansleep(QRD_GPIO_BACKLIGHT_EN, !!on);
  494. return 1;
  495. }
  496. static struct msm_fb_platform_data msm_fb_pdata = {
  497. .detect_client = msm_fb_detect_panel,
  498. };
  499. static struct platform_device msm_fb_device = {
  500. .name = "msm_fb",
  501. .id = 0,
  502. .num_resources = ARRAY_SIZE(msm_fb_resources),
  503. .resource = msm_fb_resources,
  504. .dev = {
  505. .platform_data = &msm_fb_pdata,
  506. }
  507. };
  508. #ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
  509. static struct platform_device msm_v4l2_video_overlay_device = {
  510. .name = "msm_v4l2_overlay_pd",
  511. .id = 0,
  512. .num_resources = ARRAY_SIZE(msm_v4l2_video_overlay_resources),
  513. .resource = msm_v4l2_video_overlay_resources,
  514. };
  515. #endif
  516. #ifdef CONFIG_FB_MSM_MIPI_DSI
  517. static int mipi_renesas_set_bl(int level)
  518. {
  519. int ret;
  520. ret = pmapp_disp_backlight_set_brightness(level);
  521. if (ret)
  522. pr_err("%s: can't set lcd backlight!\n", __func__);
  523. return ret;
  524. }
  525. static struct msm_panel_common_pdata mipi_renesas_pdata = {
  526. .pmic_backlight = mipi_renesas_set_bl,
  527. };
  528. static struct platform_device mipi_dsi_renesas_panel_device = {
  529. .name = "mipi_renesas",
  530. .id = 0,
  531. .dev = {
  532. .platform_data = &mipi_renesas_pdata,
  533. }
  534. };
  535. #endif
  536. static int evb_backlight_control(int level, int mode)
  537. {
  538. int i = 0;
  539. int remainder, ret = 0;
  540. /* device address byte = 0x72 */
  541. if (!mode) {
  542. gpio_set_value(96, 0);
  543. udelay(67);
  544. gpio_set_value(96, 1);
  545. udelay(33);
  546. gpio_set_value(96, 0);
  547. udelay(33);
  548. gpio_set_value(96, 1);
  549. udelay(67);
  550. gpio_set_value(96, 0);
  551. udelay(33);
  552. gpio_set_value(96, 1);
  553. udelay(67);
  554. gpio_set_value(96, 0);
  555. udelay(33);
  556. gpio_set_value(96, 1);
  557. udelay(67);
  558. gpio_set_value(96, 0);
  559. udelay(67);
  560. gpio_set_value(96, 1);
  561. udelay(33);
  562. gpio_set_value(96, 0);
  563. udelay(67);
  564. gpio_set_value(96, 1);
  565. udelay(33);
  566. gpio_set_value(96, 0);
  567. udelay(33);
  568. gpio_set_value(96, 1);
  569. udelay(67);
  570. gpio_set_value(96, 0);
  571. udelay(67);
  572. gpio_set_value(96, 1);
  573. udelay(33);
  574. /* t-EOS and t-start */
  575. gpio_set_value(96, 0);
  576. ndelay(4200);
  577. gpio_set_value(96, 1);
  578. ndelay(9000);
  579. /* data byte */
  580. /* RFA = 0 */
  581. gpio_set_value(96, 0);
  582. udelay(67);
  583. gpio_set_value(96, 1);
  584. udelay(33);
  585. /* Address bits */
  586. gpio_set_value(96, 0);
  587. udelay(67);
  588. gpio_set_value(96, 1);
  589. udelay(33);
  590. gpio_set_value(96, 0);
  591. udelay(67);
  592. gpio_set_value(96, 1);
  593. udelay(33);
  594. /* Data bits */
  595. for (i = 0; i < 5; i++) {
  596. remainder = (level) & (16);
  597. if (remainder) {
  598. gpio_set_value(96, 0);
  599. udelay(33);
  600. gpio_set_value(96, 1);
  601. udelay(67);
  602. } else {
  603. gpio_set_value(96, 0);
  604. udelay(67);
  605. gpio_set_value(96, 1);
  606. udelay(33);
  607. }
  608. level = level << 1;
  609. }
  610. /* t-EOS */
  611. gpio_set_value(96, 0);
  612. ndelay(12000);
  613. gpio_set_value(96, 1);
  614. } else {
  615. ret = pmapp_disp_backlight_set_brightness(level);
  616. if (ret)
  617. pr_err("%s: can't set lcd backlight!\n", __func__);
  618. }
  619. return ret;
  620. }
  621. static int mipi_NT35510_rotate_panel(void)
  622. {
  623. int rotate = 0;
  624. if (machine_is_msm8625_evt())
  625. rotate = 1;
  626. return rotate;
  627. }
  628. static struct msm_panel_common_pdata mipi_truly_pdata = {
  629. .pmic_backlight = mipi_truly_set_bl,
  630. };
  631. static struct platform_device mipi_dsi_truly_panel_device = {
  632. .name = "mipi_truly",
  633. .id = 0,
  634. .dev = {
  635. .platform_data = &mipi_truly_pdata,
  636. }
  637. };
  638. static struct msm_panel_common_pdata mipi_NT35510_pdata = {
  639. .backlight = evb_backlight_control,
  640. .rotate_panel = mipi_NT35510_rotate_panel,
  641. };
  642. static struct platform_device mipi_dsi_NT35510_panel_device = {
  643. .name = "mipi_NT35510",
  644. .id = 0,
  645. .dev = {
  646. .platform_data = &mipi_NT35510_pdata,
  647. }
  648. };
  649. static struct msm_panel_common_pdata mipi_NT35516_pdata = {
  650. .backlight = evb_backlight_control,
  651. };
  652. static struct platform_device mipi_dsi_NT35516_panel_device = {
  653. .name = "mipi_truly_tft540960_1_e",
  654. .id = 0,
  655. .dev = {
  656. .platform_data = &mipi_NT35516_pdata,
  657. }
  658. };
  659. static struct platform_device *msm_fb_devices[] __initdata = {
  660. &msm_fb_device,
  661. &lcdc_toshiba_panel_device,
  662. #ifdef CONFIG_FB_MSM_MIPI_DSI
  663. &mipi_dsi_renesas_panel_device,
  664. #endif
  665. #ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
  666. &msm_v4l2_video_overlay_device,
  667. #endif
  668. };
  669. static struct platform_device *qrd_fb_devices[] __initdata = {
  670. &msm_fb_device,
  671. &mipi_dsi_truly_panel_device,
  672. };
  673. static struct platform_device *qrd3_fb_devices[] __initdata = {
  674. &msm_fb_device,
  675. &lcdc_truly_panel_device,
  676. };
  677. static struct platform_device *evb_fb_devices[] __initdata = {
  678. &msm_fb_device,
  679. &mipi_dsi_NT35510_panel_device,
  680. &mipi_dsi_NT35516_panel_device,
  681. };
  682. void __init msm_msm7627a_allocate_memory_regions(void)
  683. {
  684. void *addr;
  685. unsigned long fb_size;
  686. if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa())
  687. fb_size = MSM7x25A_MSM_FB_SIZE;
  688. else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
  689. || machine_is_msm8625_evt()
  690. || machine_is_qrd_skud_prime())
  691. fb_size = MSM8x25_MSM_FB_SIZE;
  692. else
  693. fb_size = MSM_FB_SIZE;
  694. addr = alloc_bootmem_align(fb_size, 0x1000);
  695. msm_fb_resources[0].start = __pa(addr);
  696. msm_fb_resources[0].end = msm_fb_resources[0].start + fb_size - 1;
  697. pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", fb_size,
  698. addr, __pa(addr));
  699. #ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
  700. fb_size = MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE;
  701. addr = alloc_bootmem_align(fb_size, 0x1000);
  702. msm_v4l2_video_overlay_resources[0].start = __pa(addr);
  703. msm_v4l2_video_overlay_resources[0].end =
  704. msm_v4l2_video_overlay_resources[0].start + fb_size - 1;
  705. pr_debug("allocating %lu bytes at %p (%lx physical) for v4l2\n",
  706. fb_size, addr, __pa(addr));
  707. #endif
  708. }
  709. static struct msm_panel_common_pdata mdp_pdata = {
  710. .gpio = 97,
  711. .mdp_rev = MDP_REV_303,
  712. .cont_splash_enabled = 0x1,
  713. };
  714. static char lcdc_splash_is_enabled()
  715. {
  716. return mdp_pdata.cont_splash_enabled;
  717. }
  718. #define GPIO_LCDC_BRDG_PD 128
  719. #define GPIO_LCDC_BRDG_RESET_N 129
  720. #define GPIO_LCD_DSI_SEL 125
  721. #define LCDC_RESET_PHYS 0x90008014
  722. static void __iomem *lcdc_reset_ptr;
  723. static unsigned mipi_dsi_gpio[] = {
  724. GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT,
  725. GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */
  726. GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT,
  727. GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_PD */
  728. };
  729. static unsigned lcd_dsi_sel_gpio[] = {
  730. GPIO_CFG(GPIO_LCD_DSI_SEL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
  731. GPIO_CFG_2MA),
  732. };
  733. enum {
  734. DSI_SINGLE_LANE = 1,
  735. DSI_TWO_LANES,
  736. };
  737. static int msm_fb_get_lane_config(void)
  738. {
  739. /* For MSM7627A SURF/FFA and QRD */
  740. int rc = DSI_TWO_LANES;
  741. if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
  742. rc = DSI_SINGLE_LANE;
  743. pr_info("DSI_SINGLE_LANES\n");
  744. } else {
  745. pr_info("DSI_TWO_LANES\n");
  746. }
  747. return rc;
  748. }
  749. static int msm_fb_dsi_client_msm_reset(void)
  750. {
  751. int rc = 0;
  752. rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n");
  753. if (rc < 0) {
  754. pr_err("failed to request lcd brdg reset_n\n");
  755. return rc;
  756. }
  757. rc = gpio_request(GPIO_LCDC_BRDG_PD, "lcdc_brdg_pd");
  758. if (rc < 0) {
  759. pr_err("failed to request lcd brdg pd\n");
  760. return rc;
  761. }
  762. rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
  763. if (rc) {
  764. pr_err("Failed to enable LCDC Bridge reset enable\n");
  765. goto gpio_error;
  766. }
  767. rc = gpio_tlmm_config(mipi_dsi_gpio[1], GPIO_CFG_ENABLE);
  768. if (rc) {
  769. pr_err("Failed to enable LCDC Bridge pd enable\n");
  770. goto gpio_error2;
  771. }
  772. rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1);
  773. rc |= gpio_direction_output(GPIO_LCDC_BRDG_PD, 1);
  774. gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0);
  775. if (!rc) {
  776. if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()
  777. || machine_is_msm8625_surf()) {
  778. lcdc_reset_ptr = ioremap_nocache(LCDC_RESET_PHYS,
  779. sizeof(uint32_t));
  780. if (!lcdc_reset_ptr)
  781. return 0;
  782. }
  783. return rc;
  784. } else {
  785. goto gpio_error;
  786. }
  787. gpio_error2:
  788. pr_err("Failed GPIO bridge pd\n");
  789. gpio_free(GPIO_LCDC_BRDG_PD);
  790. gpio_error:
  791. pr_err("Failed GPIO bridge reset\n");
  792. gpio_free(GPIO_LCDC_BRDG_RESET_N);
  793. return rc;
  794. }
  795. static int mipi_truly_sel_mode(int video_mode)
  796. {
  797. int rc = 0;
  798. rc = gpio_request(GPIO_LCD_DSI_SEL, "lcd_dsi_sel");
  799. if (rc < 0)
  800. goto gpio_error;
  801. rc = gpio_tlmm_config(lcd_dsi_sel_gpio[0], GPIO_CFG_ENABLE);
  802. if (rc)
  803. goto gpio_error;
  804. rc = gpio_direction_output(GPIO_LCD_DSI_SEL, 1);
  805. if (!rc) {
  806. gpio_set_value_cansleep(GPIO_LCD_DSI_SEL, video_mode);
  807. return rc;
  808. } else {
  809. goto gpio_error;
  810. }
  811. gpio_error:
  812. pr_err("mipi_truly_sel_mode failed\n");
  813. gpio_free(GPIO_LCD_DSI_SEL);
  814. return rc;
  815. }
  816. static int msm_fb_dsi_client_qrd1_reset(void)
  817. {
  818. int rc = 0;
  819. rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n");
  820. if (rc < 0) {
  821. pr_err("failed to request lcd brdg reset_n\n");
  822. return rc;
  823. }
  824. rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
  825. if (rc < 0) {
  826. pr_err("Failed to enable LCDC Bridge reset enable\n");
  827. return rc;
  828. }
  829. rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1);
  830. if (rc < 0) {
  831. pr_err("Failed GPIO bridge pd\n");
  832. gpio_free(GPIO_LCDC_BRDG_RESET_N);
  833. return rc;
  834. }
  835. mipi_truly_sel_mode(1);
  836. return rc;
  837. }
  838. #define GPIO_QRD3_LCD_BRDG_RESET_N 85
  839. #define GPIO_QRD3_LCD_BACKLIGHT_EN 96
  840. #define GPIO_QRD3_LCD_EXT_2V85_EN 35
  841. #define GPIO_QRD3_LCD_EXT_1V8_EN 40
  842. static unsigned qrd3_mipi_dsi_gpio[] = {
  843. GPIO_CFG(GPIO_QRD3_LCD_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT,
  844. GPIO_CFG_NO_PULL,
  845. GPIO_CFG_2MA), /* GPIO_QRD3_LCD_BRDG_RESET_N */
  846. GPIO_CFG(GPIO_QRD3_LCD_BACKLIGHT_EN, 0, GPIO_CFG_OUTPUT,
  847. GPIO_CFG_NO_PULL,
  848. GPIO_CFG_2MA), /* GPIO_QRD3_LCD_BACKLIGHT_EN */
  849. GPIO_CFG(GPIO_QRD3_LCD_EXT_2V85_EN, 0, GPIO_CFG_OUTPUT,
  850. GPIO_CFG_NO_PULL,
  851. GPIO_CFG_2MA), /* GPIO_QRD3_LCD_EXT_2V85_EN */
  852. GPIO_CFG(GPIO_QRD3_LCD_EXT_1V8_EN, 0, GPIO_CFG_OUTPUT,
  853. GPIO_CFG_NO_PULL,
  854. GPIO_CFG_2MA), /* GPIO_QRD3_LCD_EXT_1V8_EN */
  855. };
  856. static int msm_fb_dsi_client_qrd3_reset(void)
  857. {
  858. int rc = 0;
  859. rc = gpio_request(GPIO_QRD3_LCD_BRDG_RESET_N, "qrd3_lcd_brdg_reset_n");
  860. if (rc < 0) {
  861. pr_err("failed to request qrd3 lcd brdg reset_n\n");
  862. return rc;
  863. }
  864. return rc;
  865. }
  866. static int msm_fb_dsi_client_reset(void)
  867. {
  868. int rc = 0;
  869. if (machine_is_msm7627a_qrd1())
  870. rc = msm_fb_dsi_client_qrd1_reset();
  871. else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
  872. || machine_is_msm8625_evt()
  873. || machine_is_qrd_skud_prime())
  874. rc = msm_fb_dsi_client_qrd3_reset();
  875. else
  876. rc = msm_fb_dsi_client_msm_reset();
  877. return rc;
  878. }
  879. static struct regulator_bulk_data regs_dsi[] = {
  880. { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
  881. { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
  882. };
  883. static int dsi_gpio_initialized;
  884. static int mipi_dsi_panel_msm_power(int on)
  885. {
  886. int rc = 0;
  887. uint32_t lcdc_reset_cfg;
  888. /* I2C-controlled GPIO Expander -init of the GPIOs very late */
  889. if (unlikely(!dsi_gpio_initialized)) {
  890. pmapp_disp_backlight_init();
  891. rc = gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr");
  892. if (rc < 0) {
  893. pr_err("failed to request gpio_disp_pwr\n");
  894. return rc;
  895. }
  896. if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()
  897. || machine_is_msm8625_surf()) {
  898. rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, 1);
  899. if (rc < 0) {
  900. pr_err("failed to enable display pwr\n");
  901. goto fail_gpio1;
  902. }
  903. rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en");
  904. if (rc < 0) {
  905. pr_err("failed to request gpio_bkl_en\n");
  906. goto fail_gpio1;
  907. }
  908. rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1);
  909. if (rc < 0) {
  910. pr_err("failed to enable backlight\n");
  911. goto fail_gpio2;
  912. }
  913. }
  914. rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_dsi), regs_dsi);
  915. if (rc) {
  916. pr_err("%s: could not get regulators: %d\n",
  917. __func__, rc);
  918. goto fail_gpio2;
  919. }
  920. rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_dsi),
  921. regs_dsi);
  922. if (rc) {
  923. pr_err("%s: could not set voltages: %d\n",
  924. __func__, rc);
  925. goto fail_vreg;
  926. }
  927. if (pmapp_disp_backlight_set_brightness(100))
  928. pr_err("backlight set brightness failed\n");
  929. dsi_gpio_initialized = 1;
  930. }
  931. if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() ||
  932. machine_is_msm8625_surf()) {
  933. gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on);
  934. gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on);
  935. } else if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
  936. || machine_is_msm8625_ffa()) {
  937. if (on) {
  938. /* This line drives an active low pin on FFA */
  939. rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, !on);
  940. if (rc < 0)
  941. pr_err("failed to set direction for "
  942. "display pwr\n");
  943. } else {
  944. gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, !on);
  945. rc = gpio_direction_input(GPIO_DISPLAY_PWR_EN);
  946. if (rc < 0)
  947. pr_err("failed to set direction for "
  948. "display pwr\n");
  949. }
  950. }
  951. if (on) {
  952. gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0);
  953. if (machine_is_msm7x27a_surf() ||
  954. machine_is_msm7625a_surf() ||
  955. machine_is_msm8625_surf()) {
  956. lcdc_reset_cfg = readl_relaxed(lcdc_reset_ptr);
  957. rmb();
  958. lcdc_reset_cfg &= ~1;
  959. writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr);
  960. msleep(20);
  961. wmb();
  962. lcdc_reset_cfg |= 1;
  963. writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr);
  964. msleep(20);
  965. } else {
  966. gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0);
  967. msleep(20);
  968. gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
  969. msleep(20);
  970. }
  971. } else {
  972. gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 1);
  973. }
  974. rc = on ? regulator_bulk_enable(ARRAY_SIZE(regs_dsi), regs_dsi) :
  975. regulator_bulk_disable(ARRAY_SIZE(regs_dsi), regs_dsi);
  976. if (rc)
  977. pr_err("%s: could not %sable regulators: %d\n",
  978. __func__, on ? "en" : "dis", rc);
  979. return rc;
  980. fail_vreg:
  981. regulator_bulk_free(ARRAY_SIZE(regs_dsi), regs_dsi);
  982. fail_gpio2:
  983. gpio_free(GPIO_BACKLIGHT_EN);
  984. fail_gpio1:
  985. gpio_free(GPIO_DISPLAY_PWR_EN);
  986. dsi_gpio_initialized = 0;
  987. return rc;
  988. }
  989. static int mipi_dsi_panel_qrd1_power(int on)
  990. {
  991. int rc = 0;
  992. if (!dsi_gpio_initialized) {
  993. rc = gpio_request(QRD_GPIO_BACKLIGHT_EN, "gpio_bkl_en");
  994. if (rc < 0)
  995. return rc;
  996. rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_BACKLIGHT_EN, 0,
  997. GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
  998. GPIO_CFG_ENABLE);
  999. if (rc < 0) {
  1000. pr_err("failed GPIO_BACKLIGHT_EN tlmm config\n");
  1001. return rc;
  1002. }
  1003. rc = gpio_direction_output(QRD_GPIO_BACKLIGHT_EN, 1);
  1004. if (rc < 0) {
  1005. pr_err("failed to enable backlight\n");
  1006. gpio_free(QRD_GPIO_BACKLIGHT_EN);
  1007. return rc;
  1008. }
  1009. dsi_gpio_initialized = 1;
  1010. }
  1011. gpio_set_value_cansleep(QRD_GPIO_BACKLIGHT_EN, !!on);
  1012. if (on) {
  1013. gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
  1014. msleep(20);
  1015. gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0);
  1016. msleep(20);
  1017. gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
  1018. }
  1019. return rc;
  1020. }
  1021. static int qrd3_dsi_gpio_initialized;
  1022. static struct regulator *gpio_reg_2p85v, *gpio_reg_1p8v;
  1023. static int mipi_dsi_panel_qrd3_power(int on)
  1024. {
  1025. int rc = 0;
  1026. if (!qrd3_dsi_gpio_initialized) {
  1027. pmapp_disp_backlight_init();
  1028. rc = gpio_request(GPIO_QRD3_LCD_BACKLIGHT_EN,
  1029. "qrd3_gpio_bkl_en");
  1030. if (rc < 0)
  1031. return rc;
  1032. qrd3_dsi_gpio_initialized = 1;
  1033. if (mdp_pdata.cont_splash_enabled) {
  1034. rc = gpio_tlmm_config(GPIO_CFG(
  1035. GPIO_QRD3_LCD_BACKLIGHT_EN, 0, GPIO_CFG_OUTPUT,
  1036. GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
  1037. if (rc < 0) {
  1038. pr_err("failed QRD3 GPIO_BACKLIGHT_EN tlmm config\n");
  1039. return rc;
  1040. }
  1041. rc = gpio_direction_output(GPIO_QRD3_LCD_BACKLIGHT_EN,
  1042. 1);
  1043. if (rc < 0) {
  1044. pr_err("failed to enable backlight\n");
  1045. gpio_free(GPIO_QRD3_LCD_BACKLIGHT_EN);
  1046. return rc;
  1047. }
  1048. /*Configure LCD Bridge reset*/
  1049. rc = gpio_tlmm_config(qrd3_mipi_dsi_gpio[0],
  1050. GPIO_CFG_ENABLE);
  1051. if (rc < 0) {
  1052. pr_err("Failed to enable LCD Bridge reset enable\n");
  1053. return rc;
  1054. }
  1055. rc = gpio_direction_output(GPIO_QRD3_LCD_BRDG_RESET_N,
  1056. 1);
  1057. if (rc < 0) {
  1058. pr_err("Failed GPIO bridge Reset\n");
  1059. gpio_free(GPIO_QRD3_LCD_BRDG_RESET_N);
  1060. return rc;
  1061. }
  1062. return 0;
  1063. }
  1064. }
  1065. if (on) {
  1066. rc = gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BACKLIGHT_EN, 0,
  1067. GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),
  1068. GPIO_CFG_ENABLE);
  1069. if (rc < 0) {
  1070. pr_err("failed QRD3 GPIO_BACKLIGHT_EN tlmm config\n");
  1071. return rc;
  1072. }
  1073. rc = gpio_direction_output(GPIO_QRD3_LCD_BACKLIGHT_EN, 1);
  1074. if (rc < 0) {
  1075. pr_err("failed to enable backlight\n");
  1076. gpio_free(GPIO_QRD3_LCD_BACKLIGHT_EN);
  1077. return rc;
  1078. }
  1079. /*Toggle Backlight GPIO*/
  1080. gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 1);
  1081. udelay(100);
  1082. gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 0);
  1083. udelay(430);
  1084. gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 1);
  1085. /* 1 wire mode starts from this low to high transition */
  1086. udelay(50);
  1087. /*Enable EXT_2.85 and 1.8 regulators*/
  1088. rc = regulator_enable(gpio_reg_2p85v);
  1089. if (rc < 0)
  1090. pr_err("%s: reg enable failed\n", __func__);
  1091. rc = regulator_enable(gpio_reg_1p8v);
  1092. if (rc < 0)
  1093. pr_err("%s: reg enable failed\n", __func__);
  1094. /*Configure LCD Bridge reset*/
  1095. rc = gpio_tlmm_config(qrd3_mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
  1096. if (rc < 0) {
  1097. pr_err("Failed to enable LCD Bridge reset enable\n");
  1098. return rc;
  1099. }
  1100. rc = gpio_direction_output(GPIO_QRD3_LCD_BRDG_RESET_N, 1);
  1101. if (rc < 0) {
  1102. pr_err("Failed GPIO bridge Reset\n");
  1103. gpio_free(GPIO_QRD3_LCD_BRDG_RESET_N);
  1104. return rc;
  1105. }
  1106. /*Toggle Bridge Reset GPIO*/
  1107. msleep(20);
  1108. gpio_set_value_cansleep(GPIO_QRD3_LCD_BRDG_RESET_N, 0);
  1109. msleep(20);
  1110. gpio_set_value_cansleep(GPIO_QRD3_LCD_BRDG_RESET_N, 1);
  1111. msleep(20);
  1112. } else {
  1113. gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BACKLIGHT_EN, 0,
  1114. GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
  1115. GPIO_CFG_DISABLE);
  1116. gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BRDG_RESET_N, 0,
  1117. GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
  1118. GPIO_CFG_DISABLE);
  1119. rc = regulator_disable(gpio_reg_2p85v);
  1120. if (rc < 0)
  1121. pr_err("%s: reg disable failed\n", __func__);
  1122. rc = regulator_disable(gpio_reg_1p8v);
  1123. if (rc < 0)
  1124. pr_err("%s: reg disable failed\n", __func__);
  1125. }
  1126. return rc;
  1127. }
  1128. static char mipi_dsi_splash_is_enabled(void);
  1129. static int mipi_dsi_panel_power(int on)
  1130. {
  1131. int rc = 0;
  1132. if (machine_is_msm7627a_qrd1())
  1133. rc = mipi_dsi_panel_qrd1_power(on);
  1134. else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
  1135. || machine_is_msm8625_evt()
  1136. || machine_is_qrd_skud_prime())
  1137. rc = mipi_dsi_panel_qrd3_power(on);
  1138. else
  1139. rc = mipi_dsi_panel_msm_power(on);
  1140. return rc;
  1141. }
  1142. #define MDP_303_VSYNC_GPIO 97
  1143. #ifdef CONFIG_FB_MSM_MIPI_DSI
  1144. static struct mipi_dsi_platform_data mipi_dsi_pdata = {
  1145. .vsync_gpio = MDP_303_VSYNC_GPIO,
  1146. .dsi_power_save = mipi_dsi_panel_power,
  1147. .dsi_client_reset = msm_fb_dsi_client_reset,
  1148. .get_lane_config = msm_fb_get_lane_config,
  1149. .splash_is_enabled = mipi_dsi_splash_is_enabled,
  1150. };
  1151. #endif
  1152. static char mipi_dsi_splash_is_enabled(void)
  1153. {
  1154. return mdp_pdata.cont_splash_enabled;
  1155. }
  1156. static char prim_panel_name[PANEL_NAME_MAX_LEN];
  1157. static int __init prim_display_setup(char *param)
  1158. {
  1159. if (strnlen(param, PANEL_NAME_MAX_LEN))
  1160. strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
  1161. return 0;
  1162. }
  1163. early_param("prim_display", prim_display_setup);
  1164. static int disable_splash;
  1165. void msm7x27a_set_display_params(char *prim_panel)
  1166. {
  1167. if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
  1168. strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
  1169. PANEL_NAME_MAX_LEN);
  1170. pr_debug("msm_fb_pdata.prim_panel_name %s\n",
  1171. msm_fb_pdata.prim_panel_name);
  1172. }
  1173. if (strnlen(msm_fb_pdata.prim_panel_name, PANEL_NAME_MAX_LEN)) {
  1174. if (strncmp((char *)msm_fb_pdata.prim_panel_name,
  1175. "mipi_cmd_nt35510_wvga",
  1176. strnlen("mipi_cmd_nt35510_wvga",
  1177. PANEL_NAME_MAX_LEN)) &&
  1178. strncmp((char *)msm_fb_pdata.prim_panel_name,
  1179. "mipi_video_nt35510_wvga",
  1180. strnlen("mipi_video_nt35510_wvga",
  1181. PANEL_NAME_MAX_LEN)))
  1182. disable_splash = 1;
  1183. }
  1184. }
  1185. void __init msm_fb_add_devices(void)
  1186. {
  1187. int rc = 0;
  1188. msm7x27a_set_display_params(prim_panel_name);
  1189. if (machine_is_msm7627a_qrd1()) {
  1190. platform_add_devices(qrd_fb_devices,
  1191. ARRAY_SIZE(qrd_fb_devices));
  1192. } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
  1193. || machine_is_msm8625_evt()
  1194. || machine_is_qrd_skud_prime()) {
  1195. mipi_NT35510_pdata.bl_lock = 1;
  1196. mipi_NT35516_pdata.bl_lock = 1;
  1197. if (disable_splash)
  1198. mdp_pdata.cont_splash_enabled = 0x0;
  1199. platform_add_devices(evb_fb_devices,
  1200. ARRAY_SIZE(evb_fb_devices));
  1201. } else if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) {
  1202. if (machine_is_msm7627a_qrd3())
  1203. mdp_pdata.cont_splash_enabled = 0x0;
  1204. else
  1205. mdp_pdata.cont_splash_enabled = 0x1;
  1206. platform_add_devices(qrd3_fb_devices,
  1207. ARRAY_SIZE(qrd3_fb_devices));
  1208. } else {
  1209. mdp_pdata.cont_splash_enabled = 0x0;
  1210. platform_add_devices(msm_fb_devices,
  1211. ARRAY_SIZE(msm_fb_devices));
  1212. }
  1213. msm_fb_register_device("mdp", &mdp_pdata);
  1214. if (machine_is_msm7625a_surf() || machine_is_msm7x27a_surf() ||
  1215. machine_is_msm8625_surf() || machine_is_msm7627a_qrd3()
  1216. || machine_is_msm8625_qrd7())
  1217. msm_fb_register_device("lcdc", &lcdc_pdata);
  1218. if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7())
  1219. sku3_lcdc_power_init();
  1220. #ifdef CONFIG_FB_MSM_MIPI_DSI
  1221. msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
  1222. #endif
  1223. if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
  1224. || machine_is_msm8625_evt()
  1225. || machine_is_qrd_skud_prime()) {
  1226. gpio_reg_2p85v = regulator_get(&mipi_dsi_device.dev,
  1227. "lcd_vdd");
  1228. if (IS_ERR(gpio_reg_2p85v))
  1229. pr_err("%s:ext_2p85v regulator get failed", __func__);
  1230. gpio_reg_1p8v = regulator_get(&mipi_dsi_device.dev,
  1231. "lcd_vddi");
  1232. if (IS_ERR(gpio_reg_1p8v))
  1233. pr_err("%s:ext_1p8v regulator get failed", __func__);
  1234. if (mdp_pdata.cont_splash_enabled) {
  1235. /*Enable EXT_2.85 and 1.8 regulators*/
  1236. rc = regulator_enable(gpio_reg_2p85v);
  1237. if (rc < 0)
  1238. pr_err("%s: reg enable failed\n", __func__);
  1239. rc = regulator_enable(gpio_reg_1p8v);
  1240. if (rc < 0)
  1241. pr_err("%s: reg enable failed\n", __func__);
  1242. }
  1243. }
  1244. }