mdss_dsi.c 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672
  1. /* Copyright (c) 2012-2014, 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/module.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/spinlock.h>
  16. #include <linux/delay.h>
  17. #include <linux/io.h>
  18. #include <linux/of_device.h>
  19. #include <linux/of_gpio.h>
  20. #include <linux/gpio.h>
  21. #include <linux/err.h>
  22. #include <linux/regulator/consumer.h>
  23. #include <linux/clk.h>
  24. #include "mdss.h"
  25. #include "mdss_fb.h"
  26. #include "mdss_panel.h"
  27. #include "mdss_dsi.h"
  28. #include "mdss_debug.h"
  29. int contsplash_lkstat = 0;
  30. unsigned int gv_manufacture_id;
  31. extern unsigned int system_rev;
  32. int get_lcd_attached(void);
  33. #if defined (CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQHD_PT_PANEL) || \
  34. defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_FULL_HD_PT_PANEL) || \
  35. defined(CONFIG_FB_MSM_MIPI_SAMSUNG_TFT_VIDEO_WQXGA_PT_PANEL) || \
  36. defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6TNMR7_PT_PANEL) || \
  37. defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6E3HA1_PT_PANEL) || \
  38. defined (CONFIG_GET_LCD_ATTACHED)
  39. int get_samsung_lcd_attached(void);
  40. int get_lcd_ldi_info(void);
  41. #elif defined (CONFIG_FB_MSM8x26_MDSS_CHECK_LCD_CONNECTION)
  42. int get_samsung_lcd_attached(void);
  43. #endif
  44. #if (defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  45. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_LDI_EA8061))\
  46. || defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  47. int get_oled_id(void);
  48. #endif
  49. #if defined(CONFIG_GET_LCD_PCD_DETECTED)
  50. int get_lcd_pcd_detected(void);
  51. #endif
  52. #if defined (CONFIG_FB_MSM_MDSS_DSI_DBG)
  53. void xlog(const char *name, u32 data0, u32 data1, u32 data2, u32 data3, u32 data4, u32 data5);
  54. #endif
  55. #if !defined(CONFIG_FB_MSM_MIPI_JDI_TFT_VIDEO_FULL_HD_PT_PANEL)
  56. extern int mdss_panel_get_dst_fmt(u32 bpp, char mipi_mode, u32 pixel_packing,char *dst_format);
  57. #endif
  58. static int mdss_dsi_regulator_init(struct platform_device *pdev)
  59. {
  60. int ret = 0;
  61. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  62. struct dsi_drv_cm_data *dsi_drv = NULL;
  63. if (!pdev) {
  64. pr_err("%s: invalid input\n", __func__);
  65. return -EINVAL;
  66. }
  67. ctrl_pdata = platform_get_drvdata(pdev);
  68. if (!ctrl_pdata) {
  69. pr_err("%s: invalid driver data\n", __func__);
  70. return -EINVAL;
  71. }
  72. #if defined(CONFIG_GET_LCD_PCD_DETECTED)
  73. if (get_lcd_pcd_detected()) {
  74. pr_err("%s : pcd detected!!\n", __func__);
  75. return ret;
  76. }
  77. #endif
  78. dsi_drv = &(ctrl_pdata->shared_pdata);
  79. pr_info("%s: vregn(%d)\n", __func__,
  80. ctrl_pdata->power_data.num_vreg);
  81. if (ctrl_pdata->power_data.num_vreg > 0) { // ctrl->pdata = 0
  82. /* vdd, vddio, vdda */
  83. ret = msm_dss_config_vreg(&pdev->dev,
  84. ctrl_pdata->power_data.vreg_config,
  85. ctrl_pdata->power_data.num_vreg, 1);
  86. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQHD_PT_PANEL) || defined (CONFIG_FB_MSM_MIPI_MAGNA_OCTA_CMD_HD_PT_PANEL)
  87. dsi_drv->iovdd_vreg = devm_regulator_get(&pdev->dev, "iovdd");
  88. if (IS_ERR(dsi_drv->iovdd_vreg)) {
  89. pr_err("%s: could not get iovddreg, rc=%ld\n",
  90. __func__, PTR_ERR(dsi_drv->iovdd_vreg));
  91. return PTR_ERR(dsi_drv->iovdd_vreg);
  92. } else {
  93. pr_info("%s: vdd3 - VREG_LVS4 (i/o) init.. \n", __func__);
  94. }
  95. #elif defined(CONFIG_FB_MSM_MDSS_TC_DSI2LVDS_WXGA_PANEL)
  96. ctrl_pdata->iovdd_vreg = devm_regulator_get(&pdev->dev, "vddio");
  97. if (IS_ERR(ctrl_pdata->iovdd_vreg)) {
  98. pr_err("%s: could not get VDD L5, rc=%ld\n",
  99. __func__, PTR_ERR(ctrl_pdata->iovdd_vreg));
  100. return PTR_ERR(ctrl_pdata->iovdd_vreg);
  101. } else {
  102. pr_info("%s: VDD L5 - VREG_15 (i/o) init.. \n", __func__);
  103. }
  104. regulator_set_voltage(ctrl_pdata->iovdd_vreg, 1200000, 1200000);
  105. #elif defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_WXGA_PT_DUAL_PANEL)
  106. ctrl_pdata->lcd_3p0_vreg = devm_regulator_get(&pdev->dev, "max77826_ldo13");
  107. if (IS_ERR(ctrl_pdata->lcd_3p0_vreg)) {
  108. pr_err("%s: could not get ldo13(lcd_3p0), rc=%ld\n",
  109. __func__, PTR_ERR(ctrl_pdata->lcd_3p0_vreg));
  110. return PTR_ERR(ctrl_pdata->lcd_3p0_vreg);
  111. } else {
  112. pr_info("%s: ldo13(lcd_3p0) init.. \n", __func__);
  113. }
  114. regulator_set_voltage(ctrl_pdata->lcd_3p0_vreg, 3000000, 3000000);
  115. usleep_range(5000, 5000);
  116. if ( system_rev >= 4)
  117. ctrl_pdata->lcd_1p8_vreg = devm_regulator_get(&pdev->dev, "max77826_ldo6");
  118. else
  119. ctrl_pdata->lcd_1p8_vreg = devm_regulator_get(&pdev->dev, "max77826_ldo14");
  120. if (IS_ERR(ctrl_pdata->lcd_1p8_vreg)) {
  121. pr_err("%s: could not get (lcd_1p8), rc=%ld\n",
  122. __func__, PTR_ERR(ctrl_pdata->lcd_1p8_vreg));
  123. return PTR_ERR(ctrl_pdata->lcd_1p8_vreg);
  124. } else {
  125. pr_info("%s: (lcd_1p8) init.. \n", __func__);
  126. }
  127. regulator_set_voltage(ctrl_pdata->lcd_1p8_vreg, 1800000, 1800000);
  128. usleep_range(10000, 10000);
  129. #endif
  130. }
  131. return ret;
  132. }
  133. static int mdss_dsi_panel_power_on(struct mdss_panel_data *pdata, int enable)
  134. {
  135. int ret = 0;
  136. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  137. struct mdss_panel_info *pinfo = &pdata->panel_info;
  138. if (pdata == NULL) {
  139. pr_err("%s: Invalid input data\n", __func__);
  140. return -EINVAL;
  141. }
  142. #if defined(CONFIG_GET_LCD_PCD_DETECTED)
  143. if (get_lcd_pcd_detected()) {
  144. pr_err("%s : pcd detected!!\n", __func__);
  145. return ret;
  146. }
  147. #endif
  148. if (pinfo->alpm_event) {
  149. if (enable && pinfo->alpm_event(CHECK_PREVIOUS_STATUS))
  150. return 0;
  151. else if (!enable && pinfo->alpm_event(CHECK_CURRENT_STATUS))
  152. return 0;
  153. pr_debug("[ALPM_DEBUG]%s, LDO control, enable : %d\n",
  154. __func__, enable);
  155. }
  156. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  157. panel_data);
  158. pr_info("%s: enable=%d vregn(%d)\n", __func__,
  159. enable, ctrl_pdata->power_data.num_vreg);
  160. if (pdata->panel_info.dynamic_switch_pending)
  161. return 0;
  162. if (enable) {
  163. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_FULL_HD_PT_PANEL) \
  164. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_YOUM_CMD_FULL_HD_PT_PANEL) \
  165. || defined(CONFIG_MIPI_LCD_S6E3FA0_FORCE_VIDEO_MODE) \
  166. || defined(CONFIG_MACH_JS01LTEDCM) || defined(CONFIG_MACH_JS01LTESBM) \
  167. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_TFT_VIDEO_WQXGA_PT_PANEL) \
  168. || defined(CONFIG_FB_MSM_MDSS_S6E8AA0A_HD_PANEL) \
  169. || defined(CONFIG_FB_MSM_MDSS_HX8369B_TFT_VIDEO_WVGA_PT_PANEL)\
  170. || defined(CONFIG_FB_MSM_MIPI_S6E88A0_QHD_VIDEO_PT_PANEL)
  171. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  172. pr_info("%s : Set High LCD Enable GPIO \n", __func__);
  173. gpio_set_value((ctrl_pdata->disp_en_gpio), 1);
  174. }
  175. #elif defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  176. || defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  177. || defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  178. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  179. pr_info("%s : Set High LCD Enable GPIO \n", __func__);
  180. gpio_set_value((ctrl_pdata->disp_en_gpio), 1);
  181. }
  182. if (gpio_is_valid(ctrl_pdata->disp_en_gpio2)) {
  183. pr_info("%s : Set High LCD Enable GPIO2 \n", __func__);
  184. gpio_set_value((ctrl_pdata->disp_en_gpio2), 1);
  185. }
  186. #elif defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6TNMR7_PT_PANEL)
  187. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  188. pr_info("%s : Set High LCD Enable GPIO (3.3V) \n", __func__);
  189. gpio_set_value((ctrl_pdata->disp_en_gpio), 1);
  190. }
  191. usleep_range(15000, 15000);
  192. if (gpio_is_valid(ctrl_pdata->disp_en_gpio2)) {
  193. pr_info("%s : Set High TCON Enable GPIO (1.8V) \n", __func__);
  194. gpio_set_value((ctrl_pdata->disp_en_gpio2), 1);
  195. }
  196. #elif defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)\
  197. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  198. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  199. pr_info("%s : Set High LCD Enable GPIO \n", __func__);
  200. gpio_set_value((ctrl_pdata->disp_en_gpio), 1);
  201. }
  202. #elif defined(CONFIG_FB_MSM_MDSS_SDC_WXGA_PANEL)
  203. if ((gpio_is_valid(ctrl_pdata->disp_en_gpio)) && (get_lcd_attached() != 0)) {
  204. pr_info("%s : Set High LCD Enable GPIO SDC \n", __func__);
  205. gpio_set_value((ctrl_pdata->disp_en_gpio), 1);
  206. }
  207. #elif defined(CONFIG_FB_MSM_MDSS_TC_DSI2LVDS_WXGA_PANEL)
  208. regulator_set_optimum_mode(ctrl_pdata->iovdd_vreg, 100000);
  209. regulator_enable(ctrl_pdata->iovdd_vreg);
  210. mdelay(1);
  211. if ((gpio_is_valid(ctrl_pdata->disp_en_gpio)) && (get_lcd_attached() != 0)) {
  212. gpio_tlmm_config(GPIO_CFG(ctrl_pdata->disp_en_gpio, 0,
  213. GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  214. GPIO_CFG_ENABLE);
  215. pr_info("%s : Set High LCD Enable GPIO SDC \n", __func__);
  216. gpio_set_value((ctrl_pdata->disp_en_gpio), 1);
  217. }
  218. mdelay(1);
  219. #elif defined(CONFIG_FB_MSM_MDSS_HX8394C_TFT_VIDEO_720P_PANEL)
  220. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  221. pr_info("%s : Set High LCD Enable GPIO \n", __func__);
  222. gpio_set_value((ctrl_pdata->disp_en_gpio), 1);
  223. }
  224. mdelay(2);
  225. if (gpio_is_valid(ctrl_pdata->disp_en_vsp_gpio)) {
  226. pr_info("%s : Set High LCD Enable VSP GPIO \n", __func__);
  227. gpio_set_value((ctrl_pdata->disp_en_vsp_gpio), 1);
  228. }
  229. mdelay(2);
  230. if (gpio_is_valid(ctrl_pdata->disp_en_vsn_gpio)) {
  231. pr_info("%s : Set High LCD Enable VSN GPIO \n", __func__);
  232. gpio_set_value((ctrl_pdata->disp_en_vsn_gpio), 1);
  233. }
  234. mdelay(1);
  235. #elif defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_WXGA_PT_DUAL_PANEL)
  236. ret = regulator_set_optimum_mode(ctrl_pdata->lcd_1p8_vreg, 100000);
  237. if (ret < 0) {
  238. pr_err("set_optimum_mode lcd_1p8_vreg failed, rc=%d\n", ret);
  239. return -EINVAL;
  240. }
  241. usleep_range(3000, 3000);
  242. ret = regulator_enable(ctrl_pdata->lcd_1p8_vreg);
  243. if (ret) {
  244. pr_err("enable lcd_1p8_vreg failed, rc=%d\n", ret);
  245. return -ENODEV;
  246. }
  247. pr_info("%s : lcd_1p8 regulator enable!!\n", __func__);
  248. ret = regulator_set_optimum_mode(ctrl_pdata->lcd_3p0_vreg, 100000);
  249. if (ret < 0) {
  250. pr_err("set_optimum_mode lcd_3p0_vreg failed, rc=%d\n", ret);
  251. return -EINVAL;
  252. }
  253. usleep_range(3000, 3000);
  254. ret = regulator_enable(ctrl_pdata->lcd_3p0_vreg);
  255. if (ret) {
  256. pr_err("enable lcd_3p0_vreg failed, rc=%d\n", ret);
  257. return -ENODEV;
  258. }
  259. pr_info("%s : lcd_3p0 regulator enable!!\n", __func__);
  260. usleep_range(5000, 5000);
  261. #endif
  262. if (ctrl_pdata->power_data.num_vreg > 0) {
  263. ret = msm_dss_enable_vreg(
  264. ctrl_pdata->power_data.vreg_config,
  265. ctrl_pdata->power_data.num_vreg, 1);
  266. if (ret) {
  267. pr_err("%s:Failed to enable vregs.rc=%d\n",
  268. __func__, ret);
  269. return ret;
  270. }
  271. if (ctrl_pdata->panel_extra_power){
  272. ret = ctrl_pdata->panel_extra_power(pdata,1);
  273. if (ret) {
  274. pr_err("%s: Failed to enable extra power.rc=%d\n",
  275. __func__, ret);
  276. return ret;
  277. }
  278. }
  279. }
  280. #if defined(CONFIG_FB_MSM_MIPI_JDI_TFT_VIDEO_FULL_HD_PT_PANEL)
  281. mdelay(20);
  282. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  283. pr_info("%s : Set High LCD Enable GPIO \n", __func__);
  284. gpio_tlmm_config(GPIO_CFG(ctrl_pdata->disp_en_gpio, 0,
  285. GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL,GPIO_CFG_2MA),
  286. GPIO_CFG_ENABLE);
  287. gpio_set_value((ctrl_pdata->disp_en_gpio), 1);
  288. }
  289. if (gpio_is_valid(ctrl_pdata->bl_on_gpio)) {
  290. pr_info("%s : Set High Backlight Enable GPIO \n", __func__);
  291. gpio_set_value((ctrl_pdata->bl_on_gpio), 1);
  292. }
  293. #endif
  294. if (ctrl_pdata->ctrl_state & CTRL_STATE_PANEL_INIT) {
  295. pr_debug("%s: Panel Not properly turned OFF\n",
  296. __func__);
  297. ctrl_pdata->ctrl_state &= ~CTRL_STATE_PANEL_INIT;
  298. pr_debug("%s: Reset panel done\n", __func__);
  299. }
  300. /*panel reset function moved on lp11 state */
  301. } else {
  302. ctrl_pdata->panel_reset(pdata, 0);
  303. if (ctrl_pdata->power_data.num_vreg > 0) {
  304. if (ctrl_pdata->panel_extra_power){
  305. ret = ctrl_pdata->panel_extra_power(pdata,0);
  306. if (ret) {
  307. pr_err("%s: Failed to disable extra power.rc=%d\n",
  308. __func__, ret);
  309. return ret;
  310. }
  311. }
  312. #if defined(CONFIG_FB_MSM_MDSS_TC_DSI2LVDS_WXGA_PANEL)
  313. regulator_set_optimum_mode(ctrl_pdata->iovdd_vreg, 100);
  314. regulator_disable(ctrl_pdata->iovdd_vreg);
  315. mdelay(1);
  316. #elif defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_WXGA_PT_DUAL_PANEL)
  317. if (regulator_is_enabled(ctrl_pdata->lcd_3p0_vreg)) {
  318. ret = regulator_disable(ctrl_pdata->lcd_3p0_vreg);
  319. if (ret) {
  320. pr_err("disable lcd_3p0_vreg failed, rc=%d\n", ret);
  321. return -ENODEV;
  322. } else
  323. pr_info("%s : lcd_3p0 regulator disable!!\n", __func__);
  324. }
  325. if (regulator_is_enabled(ctrl_pdata->lcd_1p8_vreg)) {
  326. ret = regulator_disable(ctrl_pdata->lcd_1p8_vreg);
  327. if (ret) {
  328. pr_err("disable lcd_1p8_vreg failed, rc=%d\n", ret);
  329. return -ENODEV;
  330. } else
  331. pr_info("%s : lcd_1p8 regulator disable!!\n", __func__);
  332. }
  333. #endif
  334. ret = msm_dss_enable_vreg(
  335. ctrl_pdata->power_data.vreg_config,
  336. ctrl_pdata->power_data.num_vreg, 0);
  337. if (ret) {
  338. pr_err("%s: Failed to disable vregs.rc=%d\n",
  339. __func__, ret);
  340. return ret;
  341. }
  342. }
  343. }
  344. pr_debug("%s: --\n", __func__);
  345. return ret;
  346. }
  347. static void mdss_dsi_put_dt_vreg_data(struct device *dev,
  348. struct dss_module_power *module_power)
  349. {
  350. if (!module_power) {
  351. pr_err("%s: invalid input\n", __func__);
  352. return;
  353. }
  354. if (module_power->vreg_config) {
  355. devm_kfree(dev, module_power->vreg_config);
  356. module_power->vreg_config = NULL;
  357. }
  358. module_power->num_vreg = 0;
  359. }
  360. static int mdss_dsi_get_dt_vreg_data(struct device *dev,
  361. struct dss_module_power *mp)
  362. {
  363. int i = 0, rc = 0;
  364. u32 tmp = 0;
  365. struct device_node *of_node = NULL, *supply_node = NULL;
  366. if (!dev || !mp) {
  367. pr_err("%s: invalid input\n", __func__);
  368. rc = -EINVAL;
  369. return rc;
  370. }
  371. of_node = dev->of_node;
  372. mp->num_vreg = 0;
  373. for_each_child_of_node(of_node, supply_node) {
  374. if (!strncmp(supply_node->name, "qcom,platform-supply-entry",
  375. 26)) {
  376. #ifdef CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_WXGA_PT_DUAL_PANEL
  377. if(!strncmp(supply_node->name, "qcom,platform-supply-entry1", 28)) {
  378. pr_err("%s : VDD(l22) register skip!! (%s) \n", __func__, supply_node->name);
  379. continue;
  380. }
  381. #endif
  382. ++mp->num_vreg;
  383. }
  384. }
  385. if (mp->num_vreg == 0) {
  386. pr_debug("%s: no vreg\n", __func__);
  387. goto novreg;
  388. } else {
  389. pr_debug("%s: vreg found. count=%d\n", __func__, mp->num_vreg);
  390. }
  391. mp->vreg_config = devm_kzalloc(dev, sizeof(struct dss_vreg) *
  392. mp->num_vreg, GFP_KERNEL);
  393. if (!mp->vreg_config) {
  394. pr_err("%s: can't alloc vreg mem\n", __func__);
  395. rc = -ENOMEM;
  396. goto error;
  397. }
  398. for_each_child_of_node(of_node, supply_node) {
  399. if (!strncmp(supply_node->name, "qcom,platform-supply-entry",
  400. 26)) {
  401. const char *st = NULL;
  402. /* vreg-name */
  403. rc = of_property_read_string(supply_node,
  404. "qcom,supply-name", &st);
  405. if (rc) {
  406. pr_err("%s: error reading name. rc=%d\n",
  407. __func__, rc);
  408. goto error;
  409. }
  410. snprintf(mp->vreg_config[i].vreg_name,
  411. ARRAY_SIZE((mp->vreg_config[i].vreg_name)),
  412. "%s", st);
  413. #ifdef CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_WXGA_PT_DUAL_PANEL
  414. if(!strncmp(mp->vreg_config[i].vreg_name, "vdd", 4)) {
  415. pr_err("%s : VDD(l22) setting skip!!\n", __func__);
  416. continue;
  417. }
  418. #endif
  419. /* vreg-min-voltage */
  420. rc = of_property_read_u32(supply_node,
  421. "qcom,supply-min-voltage", &tmp);
  422. if (rc) {
  423. pr_err("%s: error reading min volt. rc=%d\n",
  424. __func__, rc);
  425. goto error;
  426. }
  427. mp->vreg_config[i].min_voltage = tmp;
  428. /* vreg-max-voltage */
  429. rc = of_property_read_u32(supply_node,
  430. "qcom,supply-max-voltage", &tmp);
  431. if (rc) {
  432. pr_err("%s: error reading max volt. rc=%d\n",
  433. __func__, rc);
  434. goto error;
  435. }
  436. mp->vreg_config[i].max_voltage = tmp;
  437. /* enable-load */
  438. rc = of_property_read_u32(supply_node,
  439. "qcom,supply-enable-load", &tmp);
  440. if (rc) {
  441. pr_err("%s: error reading enable load. rc=%d\n",
  442. __func__, rc);
  443. goto error;
  444. }
  445. mp->vreg_config[i].enable_load = tmp;
  446. /* disable-load */
  447. rc = of_property_read_u32(supply_node,
  448. "qcom,supply-disable-load", &tmp);
  449. if (rc) {
  450. pr_err("%s: error reading disable load. rc=%d\n",
  451. __func__, rc);
  452. goto error;
  453. }
  454. mp->vreg_config[i].disable_load = tmp;
  455. /* pre-sleep */
  456. rc = of_property_read_u32(supply_node,
  457. "qcom,supply-pre-on-sleep", &tmp);
  458. if (rc) {
  459. pr_debug("%s: error reading supply pre sleep value. rc=%d\n",
  460. __func__, rc);
  461. }
  462. mp->vreg_config[i].pre_on_sleep = (!rc ? tmp : 0);
  463. rc = of_property_read_u32(supply_node,
  464. "qcom,supply-pre-off-sleep", &tmp);
  465. if (rc) {
  466. pr_debug("%s: error reading supply pre sleep value. rc=%d\n",
  467. __func__, rc);
  468. }
  469. mp->vreg_config[i].pre_off_sleep = (!rc ? tmp : 0);
  470. /* post-sleep */
  471. rc = of_property_read_u32(supply_node,
  472. "qcom,supply-post-on-sleep", &tmp);
  473. if (rc) {
  474. pr_debug("%s: error reading supply post sleep value. rc=%d\n",
  475. __func__, rc);
  476. }
  477. mp->vreg_config[i].post_on_sleep = (!rc ? tmp : 0);
  478. rc = of_property_read_u32(supply_node,
  479. "qcom,supply-post-off-sleep", &tmp);
  480. if (rc) {
  481. pr_debug("%s: error reading supply post sleep value. rc=%d\n",
  482. __func__, rc);
  483. }
  484. mp->vreg_config[i].post_off_sleep = (!rc ? tmp : 0);
  485. pr_debug("%s: %s min=%d, max=%d, enable=%d, disable=%d, preonsleep=%d, postonsleep=%d, preoffsleep=%d, postoffsleep=%d\n",
  486. __func__,
  487. mp->vreg_config[i].vreg_name,
  488. mp->vreg_config[i].min_voltage,
  489. mp->vreg_config[i].max_voltage,
  490. mp->vreg_config[i].enable_load,
  491. mp->vreg_config[i].disable_load,
  492. mp->vreg_config[i].pre_on_sleep,
  493. mp->vreg_config[i].post_on_sleep,
  494. mp->vreg_config[i].pre_off_sleep,
  495. mp->vreg_config[i].post_off_sleep
  496. );
  497. ++i;
  498. }
  499. }
  500. return rc;
  501. error:
  502. if(mp){
  503. if (mp->vreg_config && dev) {
  504. devm_kfree(dev, mp->vreg_config);
  505. mp->vreg_config = NULL;
  506. }
  507. }
  508. novreg:
  509. if(mp){
  510. mp->num_vreg = 0;
  511. }
  512. return rc;
  513. }
  514. #define ULPS_REQUEST_BITS 0x001f
  515. #define ULPS_EXIT_BITS 0x1f00
  516. #define ULPS_LANE_STATUS_BITS 0x1f00
  517. #define CTRL_OFFSET 0xAC
  518. #define STATUS_OFFSET 0xA8
  519. static int mipi_ulps_mode(struct mdss_dsi_ctrl_pdata *ctrl_pdata,int enter)
  520. {
  521. uint32_t dsi0LaneCtrlReg = MIPI_INP(ctrl_pdata->ctrl_base + CTRL_OFFSET);
  522. uint32_t dsi0LaneStatusReg = MIPI_INP(ctrl_pdata->ctrl_base + STATUS_OFFSET);
  523. pr_debug("[ALPM_DEBUG] mipi_ulps_mode++: dsi0LaneStatusReg 0x%x\n", dsi0LaneStatusReg);
  524. if(enter) //enter into the mode
  525. {
  526. MIPI_OUTP(ctrl_pdata->ctrl_base + CTRL_OFFSET, dsi0LaneCtrlReg | ULPS_REQUEST_BITS);
  527. usleep(1000);
  528. pr_debug("[ALPM_DEBUG] entering into the ulps mode\n");
  529. }
  530. else //exit from the mode
  531. {
  532. MIPI_OUTP(ctrl_pdata->ctrl_base + CTRL_OFFSET, dsi0LaneCtrlReg | ULPS_EXIT_BITS);
  533. pr_debug("[ALPM_DEBUG] exiting from the ulps mode\n");
  534. usleep(2000);
  535. //Exit/ request bits clear (requirement)
  536. dsi0LaneCtrlReg = MIPI_INP(ctrl_pdata->ctrl_base + CTRL_OFFSET);
  537. dsi0LaneCtrlReg &= ~ULPS_REQUEST_BITS;
  538. MIPI_OUTP(ctrl_pdata->ctrl_base + CTRL_OFFSET, dsi0LaneCtrlReg);
  539. dsi0LaneCtrlReg &= ~ULPS_EXIT_BITS;
  540. MIPI_OUTP(ctrl_pdata->ctrl_base + CTRL_OFFSET, dsi0LaneCtrlReg);
  541. }
  542. return true;
  543. }
  544. static int mdss_dsi_get_panel_cfg(char *panel_cfg)
  545. {
  546. int rc;
  547. struct mdss_panel_cfg *pan_cfg = NULL;
  548. if (!panel_cfg)
  549. return MDSS_PANEL_INTF_INVALID;
  550. pan_cfg = mdss_panel_intf_type(MDSS_PANEL_INTF_DSI);
  551. if (IS_ERR(pan_cfg)) {
  552. return PTR_ERR(pan_cfg);
  553. } else if (!pan_cfg) {
  554. panel_cfg[0] = 0;
  555. return 0;
  556. }
  557. pr_info("%s:%d: cfg:[%s]\n", __func__, __LINE__,
  558. pan_cfg->arg_cfg);
  559. rc = strlcpy(panel_cfg, pan_cfg->arg_cfg,
  560. sizeof(pan_cfg->arg_cfg));
  561. return rc;
  562. }
  563. static int mdss_dsi_off(struct mdss_panel_data *pdata)
  564. {
  565. int ret = 0;
  566. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  567. struct mdss_panel_info *panel_info = NULL;
  568. struct mdss_panel_info *pinfo = &pdata->panel_info;
  569. if (pdata == NULL) {
  570. pr_err("%s: Invalid input data\n", __func__);
  571. return -EINVAL;
  572. }
  573. if (!pdata->panel_info.panel_power_on) {
  574. pr_warn("%s:%d Panel already off.\n", __func__, __LINE__);
  575. return 0;
  576. }
  577. #if defined (CONFIG_FB_MSM_MDSS_DSI_DBG)
  578. xlog(__func__,pdata->panel_info.panel_power_on,0,0, 0,0,0);
  579. #endif
  580. pdata->panel_info.panel_power_on = 0;
  581. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  582. panel_data);
  583. mutex_lock(&ctrl_pdata->mutex);
  584. panel_info = &ctrl_pdata->panel_data.panel_info;
  585. pr_info("%s+: ctrl=%pK ndx=%d\n", __func__,
  586. ctrl_pdata, ctrl_pdata->ndx);
  587. if (pinfo->alpm_event && pinfo->alpm_event(CHECK_CURRENT_STATUS))
  588. mipi_ulps_mode(ctrl_pdata, 1);
  589. if((pdata->panel_info.type == MIPI_CMD_PANEL) && (ctrl_pdata->ndx == DSI_CTRL_0)
  590. && (!ctrl_pdata->shared_pdata.broadcast_enable)) {
  591. ret = gpio_tlmm_config(GPIO_CFG(
  592. ctrl_pdata->disp_te_gpio, 0,
  593. GPIO_CFG_INPUT,
  594. GPIO_CFG_PULL_DOWN,
  595. GPIO_CFG_2MA),
  596. GPIO_CFG_ENABLE);
  597. if (ret) {
  598. pr_err("%s: unable to config tlmm = %d\n",
  599. __func__, ctrl_pdata->disp_te_gpio);
  600. gpio_free(ctrl_pdata->disp_te_gpio);
  601. mutex_unlock(&ctrl_pdata->mutex);
  602. return -ENODEV;
  603. }
  604. }
  605. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6TNMR7_PT_PANEL)
  606. if (pdata->panel_info.type == MIPI_CMD_PANEL)
  607. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_ALL_CLKS, 1);
  608. #endif
  609. /* disable DSI controller */
  610. mdss_dsi_controller_cfg(0, pdata);
  611. /* disable DSI phy */
  612. mdss_dsi_phy_disable(ctrl_pdata);
  613. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_ALL_CLKS, 0);
  614. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6TNMR7_PT_PANEL) || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6E3HA1_PT_PANEL)
  615. if (ctrl_pdata->ndx == DSI_CTRL_1) {
  616. #else
  617. {
  618. #endif
  619. ret = mdss_dsi_panel_power_on(pdata, 0);
  620. if (ret) {
  621. mutex_unlock(&ctrl_pdata->mutex);
  622. pr_err("%s: Panel power off failed\n", __func__);
  623. return ret;
  624. }
  625. }
  626. if (panel_info->dynamic_fps
  627. && (panel_info->dfps_update == DFPS_SUSPEND_RESUME_MODE)
  628. && (panel_info->new_fps != panel_info->mipi.frame_rate))
  629. panel_info->mipi.frame_rate = panel_info->new_fps;
  630. mutex_unlock(&ctrl_pdata->mutex);
  631. pr_info("%s-:\n", __func__);
  632. return ret;
  633. }
  634. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_WXGA_PT_DUAL_PANEL)
  635. extern int flip;
  636. #endif
  637. static void __mdss_dsi_ctrl_setup(struct mdss_panel_data *pdata)
  638. {
  639. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  640. struct mdss_panel_info *pinfo;
  641. struct mipi_panel_info *mipi;
  642. u32 clk_rate;
  643. u32 hbp, hfp, vbp, vfp, hspw, vspw, width, height;
  644. u32 ystride, bpp, data, dst_bpp;
  645. u32 dummy_xres, dummy_yres;
  646. u32 hsync_period, vsync_period;
  647. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  648. panel_data);
  649. pinfo = &pdata->panel_info;
  650. clk_rate = pdata->panel_info.clk_rate;
  651. clk_rate = min(clk_rate, pdata->panel_info.clk_max);
  652. dst_bpp = pdata->panel_info.fbc.enabled ?
  653. (pdata->panel_info.fbc.target_bpp) : (pinfo->bpp);
  654. hbp = mult_frac(pdata->panel_info.lcdc.h_back_porch, dst_bpp,
  655. pdata->panel_info.bpp);
  656. hfp = mult_frac(pdata->panel_info.lcdc.h_front_porch, dst_bpp,
  657. pdata->panel_info.bpp);
  658. vbp = mult_frac(pdata->panel_info.lcdc.v_back_porch, dst_bpp,
  659. pdata->panel_info.bpp);
  660. vfp = mult_frac(pdata->panel_info.lcdc.v_front_porch, dst_bpp,
  661. pdata->panel_info.bpp);
  662. hspw = mult_frac(pdata->panel_info.lcdc.h_pulse_width, dst_bpp,
  663. pdata->panel_info.bpp);
  664. vspw = pdata->panel_info.lcdc.v_pulse_width;
  665. width = mult_frac(pdata->panel_info.xres, dst_bpp,
  666. pdata->panel_info.bpp);
  667. height = pdata->panel_info.yres;
  668. if (pdata->panel_info.type == MIPI_VIDEO_PANEL) {
  669. dummy_xres = pdata->panel_info.lcdc.xres_pad;
  670. dummy_yres = pdata->panel_info.lcdc.yres_pad;
  671. }
  672. vsync_period = vspw + vbp + height + dummy_yres + vfp;
  673. hsync_period = hspw + hbp + width + dummy_xres + hfp;
  674. mipi = &pdata->panel_info.mipi;
  675. if (pdata->panel_info.type == MIPI_VIDEO_PANEL) {
  676. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x24,
  677. ((hspw + hbp + width + dummy_xres) << 16 |
  678. (hspw + hbp)));
  679. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x28,
  680. ((vspw + vbp + height + dummy_yres) << 16 |
  681. (vspw + vbp)));
  682. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x2C,
  683. ((vsync_period - 1) << 16)
  684. | (hsync_period - 1));
  685. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x30, (hspw << 16));
  686. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x34, 0);
  687. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x38, (vspw << 16));
  688. } else { /* command mode */
  689. if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB888)
  690. bpp = 3;
  691. else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB666)
  692. bpp = 3;
  693. else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB565)
  694. bpp = 2;
  695. else
  696. bpp = 3; /* Default format set to RGB888 */
  697. ystride = width * bpp + 1;
  698. /* DSI_COMMAND_MODE_MDP_STREAM_CTRL */
  699. data = (ystride << 16) | (mipi->vc << 8) | DTYPE_DCS_LWRITE;
  700. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x60, data);
  701. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x58, data);
  702. /* DSI_COMMAND_MODE_MDP_STREAM_TOTAL */
  703. data = height << 16 | width;
  704. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x64, data);
  705. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x5C, data);
  706. }
  707. }
  708. static inline bool __mdss_dsi_ulps_feature_enabled(
  709. struct mdss_panel_data *pdata)
  710. {
  711. return pdata->panel_info.ulps_feature_enabled;
  712. }
  713. static int mdss_dsi_ulps_config_sub(struct mdss_dsi_ctrl_pdata *ctrl_pdata,
  714. int enable)
  715. {
  716. int ret = 0;
  717. struct mdss_panel_data *pdata = NULL;
  718. struct mipi_panel_info *pinfo = NULL;
  719. u32 lane_status = 0;
  720. u32 active_lanes = 0;
  721. if (!ctrl_pdata) {
  722. pr_err("%s: invalid input\n", __func__);
  723. return -EINVAL;
  724. }
  725. pdata = &ctrl_pdata->panel_data;
  726. if (!pdata) {
  727. pr_err("%s: Invalid panel data\n", __func__);
  728. return -EINVAL;
  729. }
  730. pinfo = &pdata->panel_info.mipi;
  731. if (!__mdss_dsi_ulps_feature_enabled(pdata)) {
  732. pr_debug("%s: ULPS feature not supported. enable=%d\n",
  733. __func__, enable);
  734. return -ENOTSUPP;
  735. }
  736. if (enable && !ctrl_pdata->ulps) {
  737. /* No need to configure ULPS mode when entering suspend state */
  738. if (!pdata->panel_info.panel_power_on) {
  739. pr_err("%s: panel off. returning\n", __func__);
  740. goto error;
  741. }
  742. if (__mdss_dsi_clk_enabled(ctrl_pdata, DSI_LINK_CLKS)) {
  743. pr_err("%s: cannot enter ulps mode if dsi clocks are on\n",
  744. __func__);
  745. ret = -EPERM;
  746. goto error;
  747. }
  748. ret = mdss_dsi_clk_ctrl(ctrl_pdata, DSI_ALL_CLKS, 1);
  749. if (ret) {
  750. pr_err("%s: Failed to enable clocks. rc=%d\n",
  751. __func__, ret);
  752. goto error;
  753. }
  754. /*
  755. * ULPS Entry Request.
  756. * Wait for a short duration to ensure that the lanes
  757. * enter ULP state.
  758. */
  759. MIPI_OUTP(ctrl_pdata->ctrl_base + 0x0AC, 0x01F);
  760. usleep(100);
  761. /* Check to make sure that all active data lanes are in ULPS */
  762. if (pinfo->data_lane3)
  763. active_lanes |= BIT(11);
  764. if (pinfo->data_lane2)
  765. active_lanes |= BIT(10);
  766. if (pinfo->data_lane1)
  767. active_lanes |= BIT(9);
  768. if (pinfo->data_lane0)
  769. active_lanes |= BIT(8);
  770. active_lanes |= BIT(12); /* clock lane */
  771. lane_status = MIPI_INP(ctrl_pdata->ctrl_base + 0xA8);
  772. if (lane_status & active_lanes) {
  773. pr_err("%s: ULPS entry req failed. Lane status=0x%08x\n",
  774. __func__, lane_status);
  775. ret = -EINVAL;
  776. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_ALL_CLKS, 0);
  777. goto error;
  778. }
  779. /* Enable MMSS DSI Clamps */
  780. MIPI_OUTP(ctrl_pdata->mmss_misc_io.base + 0x14, 0x3FF);
  781. MIPI_OUTP(ctrl_pdata->mmss_misc_io.base + 0x14, 0x83FF);
  782. wmb();
  783. MIPI_OUTP(ctrl_pdata->mmss_misc_io.base + 0x108, 0x1);
  784. /* disable DSI controller */
  785. mdss_dsi_controller_cfg(0, pdata);
  786. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_ALL_CLKS, 0);
  787. ctrl_pdata->ulps = true;
  788. } else if (ctrl_pdata->ulps) {
  789. ret = mdss_dsi_clk_ctrl(ctrl_pdata, DSI_BUS_CLKS, 1);
  790. if (ret) {
  791. pr_err("%s: Failed to enable bus clocks. rc=%d\n",
  792. __func__, ret);
  793. goto error;
  794. }
  795. MIPI_OUTP(ctrl_pdata->mmss_misc_io.base + 0x108, 0x0);
  796. mdss_dsi_phy_init(pdata);
  797. __mdss_dsi_ctrl_setup(pdata);
  798. mdss_dsi_sw_reset(pdata);
  799. mdss_dsi_host_init(pdata);
  800. mdss_dsi_op_mode_config(pdata->panel_info.mipi.mode,
  801. pdata);
  802. /*
  803. * ULPS Entry Request. This is needed because, after power
  804. * collapse and reset, the DSI controller resets back to
  805. * idle state and not ULPS.
  806. * Wait for a short duration to ensure that the lanes
  807. * enter ULP state.
  808. */
  809. MIPI_OUTP(ctrl_pdata->ctrl_base + 0x0AC, 0x01F);
  810. usleep(100);
  811. /* Disable MMSS DSI Clamps */
  812. MIPI_OUTP(ctrl_pdata->mmss_misc_io.base + 0x14, 0x3FF);
  813. MIPI_OUTP(ctrl_pdata->mmss_misc_io.base + 0x14, 0x0);
  814. ret = mdss_dsi_clk_ctrl(ctrl_pdata, DSI_LINK_CLKS, 1);
  815. if (ret) {
  816. pr_err("%s: Failed to enable link clocks. rc=%d\n",
  817. __func__, ret);
  818. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_BUS_CLKS, 0);
  819. goto error;
  820. }
  821. /*
  822. * ULPS Exit Request
  823. * Hardware requirement is to wait for at least 1ms
  824. */
  825. MIPI_OUTP(ctrl_pdata->ctrl_base + 0x0AC, 0x1F00);
  826. usleep(1000);
  827. MIPI_OUTP(ctrl_pdata->ctrl_base + 0x0AC, 0x0);
  828. /*
  829. * Wait for a short duration before enabling
  830. * data transmission
  831. */
  832. usleep(100);
  833. lane_status = MIPI_INP(ctrl_pdata->ctrl_base + 0xA8);
  834. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_LINK_CLKS, 0);
  835. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_BUS_CLKS, 0);
  836. ctrl_pdata->ulps = false;
  837. }
  838. pr_debug("%s: DSI lane status = 0x%08x. Ulps %s\n", __func__,
  839. lane_status, enable ? "enabled" : "disabled");
  840. error:
  841. return ret;
  842. }
  843. #if !defined(CONFIG_FB_MSM_MIPI_JDI_TFT_VIDEO_FULL_HD_PT_PANEL)
  844. static int mdss_dsi_update_panel_config(struct mdss_dsi_ctrl_pdata *ctrl_pdata,
  845. int mode)
  846. {
  847. int ret = 0;
  848. struct mdss_panel_info *pinfo = &(ctrl_pdata->panel_data.panel_info);
  849. if (mode == DSI_CMD_MODE) {
  850. pinfo->mipi.mode = DSI_CMD_MODE;
  851. pinfo->type = MIPI_CMD_PANEL;
  852. pinfo->mipi.vsync_enable = 1;
  853. pinfo->mipi.hw_vsync_mode = 1;
  854. } else { /*video mode*/
  855. pinfo->mipi.mode = DSI_VIDEO_MODE;
  856. pinfo->type = MIPI_VIDEO_PANEL;
  857. pinfo->mipi.vsync_enable = 0;
  858. pinfo->mipi.hw_vsync_mode = 0;
  859. }
  860. ctrl_pdata->panel_mode = pinfo->mipi.mode;
  861. mdss_panel_dt_get_dst_fmt(pinfo->bpp, pinfo->mipi.mode,
  862. pinfo->mipi.pixel_packing, &(pinfo->mipi.dst_format));
  863. pinfo->cont_splash_enabled = 0;
  864. return ret;
  865. }
  866. #endif
  867. static int mdss_dsi_ulps_config(struct mdss_dsi_ctrl_pdata *ctrl,
  868. int enable)
  869. {
  870. int rc;
  871. struct mdss_dsi_ctrl_pdata *mctrl = NULL;
  872. if (&ctrl->mmss_misc_io == NULL) {
  873. pr_err("%s: mmss_misc_io is NULL. ULPS not valid\n", __func__);
  874. return -EINVAL;
  875. }
  876. if (mdss_dsi_is_slave_ctrl(ctrl)) {
  877. mctrl = mdss_dsi_get_master_ctrl();
  878. if (!mctrl) {
  879. pr_err("%s: Unable to get master control\n", __func__);
  880. return -EINVAL;
  881. }
  882. }
  883. if (mctrl) {
  884. pr_debug("%s: configuring ulps (%s) for master ctrl%d\n",
  885. __func__, (enable ? "on" : "off"), ctrl->ndx);
  886. rc = mdss_dsi_ulps_config_sub(mctrl, enable);
  887. if (rc)
  888. return rc;
  889. }
  890. pr_debug("%s: configuring ulps (%s) for ctrl%d\n",
  891. __func__, (enable ? "on" : "off"), ctrl->ndx);
  892. return mdss_dsi_ulps_config_sub(ctrl, enable);
  893. }
  894. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_WXGA_PT_DUAL_PANEL)
  895. extern int flip;
  896. #endif
  897. int mdss_dsi_on(struct mdss_panel_data *pdata)
  898. {
  899. int ret = 0;
  900. struct mdss_panel_info *pinfo;
  901. struct mipi_panel_info *mipi;
  902. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  903. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6TNMR7_PT_PANEL)
  904. u32 tmp;
  905. #endif
  906. if (pdata == NULL) {
  907. pr_err("%s: Invalid input data\n", __func__);
  908. return -EINVAL;
  909. }
  910. if (pdata->panel_info.panel_power_on) {
  911. pr_warn("%s:%d Panel already on.\n", __func__, __LINE__);
  912. return 0;
  913. }
  914. #if defined (CONFIG_FB_MSM_MDSS_DSI_DBG)
  915. xlog(__func__,pdata->panel_info.panel_power_on,0,0, 0,0,0);
  916. #endif
  917. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  918. panel_data);
  919. pr_info("%s+: ctrl=%pK ndx=%d\n",
  920. __func__, ctrl_pdata, ctrl_pdata->ndx);
  921. pinfo = &pdata->panel_info;
  922. mipi = &pdata->panel_info.mipi;
  923. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_WXGA_PT_DUAL_PANEL)
  924. gpio_set_value(ctrl_pdata->lcd_sel_gpio, flip);
  925. usleep_range(2000, 2000);
  926. pr_info("%s : flip [%s]\n", __func__, flip ? "CLOSE" : "OPEN");
  927. #endif
  928. if (pinfo->alpm_event && pinfo->alpm_event(CHECK_PREVIOUS_STATUS))
  929. mipi_ulps_mode(ctrl_pdata, 0);
  930. if((pdata->panel_info.type == MIPI_CMD_PANEL) && (ctrl_pdata->ndx == DSI_CTRL_0)) {
  931. ret = gpio_tlmm_config(GPIO_CFG(
  932. ctrl_pdata->disp_te_gpio, 1,
  933. GPIO_CFG_INPUT,
  934. GPIO_CFG_PULL_DOWN,
  935. GPIO_CFG_2MA),
  936. GPIO_CFG_ENABLE);
  937. if (ret) {
  938. pr_err("%s: unable to config tlmm = %d\n",
  939. __func__, ctrl_pdata->disp_te_gpio);
  940. gpio_free(ctrl_pdata->disp_te_gpio);
  941. return -ENODEV;
  942. } else {
  943. pr_info("%s: success [disp_te_gpio] gpio_ltmm_config..\n",__func__);
  944. }
  945. }
  946. if(ctrl_pdata->ndx == DSI_CTRL_0) {
  947. ret = mdss_dsi_panel_power_on(pdata, 1);
  948. if (ret) {
  949. pr_err("%s:Panel power on failed. rc=%d\n", __func__, ret);
  950. return ret;
  951. }
  952. }
  953. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_TFT_VIDEO_WQXGA_PT_PANEL) && \
  954. !defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_WXGA_PT_DUAL_PANEL)
  955. if (get_lcd_attached() == 0) {
  956. pr_err("%s : lcd is not attached..\n",__func__);
  957. mdss_dsi_panel_power_on(pdata, 0);
  958. pdata->panel_info.panel_power_on = 0;
  959. return 0;
  960. }
  961. #endif
  962. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_BUS_CLKS, 1);
  963. pdata->panel_info.panel_power_on = 1;
  964. mdss_dsi_phy_sw_reset((ctrl_pdata->ctrl_base));
  965. mdss_dsi_phy_init(pdata);
  966. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_BUS_CLKS, 0);
  967. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_ALL_CLKS, 1);
  968. __mdss_dsi_ctrl_setup(pdata);
  969. mdss_dsi_sw_reset(pdata);
  970. mdss_dsi_host_init(pdata);
  971. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6TNMR7_PT_PANEL)
  972. /* LP11 */
  973. tmp = MIPI_INP((ctrl_pdata->ctrl_base) + 0xac);
  974. #if defined(CONFIG_FB_MSM_MDSS_SHARP_HD_PANEL)
  975. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0xac, tmp & -(1<< 28));
  976. #else
  977. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0xac, 0x1F << 16);
  978. #endif
  979. wmb();
  980. #if defined(CONFIG_FB_MSM_MDSS_TC_DSI2LVDS_WXGA_PANEL) || \
  981. defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL) || \
  982. defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  983. mdelay(1);
  984. #else
  985. msleep(20);
  986. #endif
  987. /* LP11 */
  988. ctrl_pdata->panel_reset(pdata, 1);
  989. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0xac, tmp);
  990. if (mipi->force_clk_lane_hs) {
  991. u32 tmp;
  992. tmp = MIPI_INP((ctrl_pdata->ctrl_base) + 0xac);
  993. tmp |= (1<<28);
  994. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0xac, tmp);
  995. wmb();
  996. }
  997. if (pdata->panel_info.type == MIPI_CMD_PANEL)
  998. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_ALL_CLKS, 0);
  999. #else
  1000. ctrl_pdata->panel_reset(pdata, 1);
  1001. #endif
  1002. pr_info("%s-:\n", __func__);
  1003. return 0;
  1004. }
  1005. #if defined(CONFIG_FB_MSM_MDSS_S6E8AA0A_HD_PANEL)
  1006. static int mdss_MTP_read(struct mdss_panel_data *pdata)
  1007. {
  1008. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  1009. int ret=0;
  1010. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  1011. panel_data);
  1012. ctrl_pdata->mtp(pdata);
  1013. return ret;
  1014. }
  1015. #endif
  1016. static int mdss_dsi_unblank(struct mdss_panel_data *pdata)
  1017. {
  1018. int ret = 0;
  1019. struct mipi_panel_info *mipi;
  1020. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  1021. pr_debug("%s+:\n", __func__);
  1022. if (pdata == NULL) {
  1023. pr_err("%s: Invalid input data\n", __func__);
  1024. return -EINVAL;
  1025. }
  1026. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  1027. panel_data);
  1028. mipi = &pdata->panel_info.mipi;
  1029. if (!(ctrl_pdata->ctrl_state & CTRL_STATE_PANEL_INIT)) {
  1030. if (!pdata->panel_info.dynamic_switch_pending) {
  1031. ret = ctrl_pdata->on(pdata);
  1032. if (ret) {
  1033. pr_err("%s: unable to initialize the panel\n",
  1034. __func__);
  1035. return ret;
  1036. }
  1037. }
  1038. ctrl_pdata->ctrl_state |= CTRL_STATE_PANEL_INIT;
  1039. }
  1040. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQHD_PT_PANEL) && \
  1041. !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6TNMR7_PT_PANEL) && \
  1042. !defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_CMD_HD_PT_PANEL)
  1043. if (pdata->panel_info.type == MIPI_CMD_PANEL) {
  1044. if (mipi->vsync_enable && mipi->hw_vsync_mode
  1045. && gpio_is_valid(ctrl_pdata->disp_te_gpio)) {
  1046. mdss_dsi_set_tear_on(ctrl_pdata);
  1047. }
  1048. }
  1049. #endif
  1050. pr_debug("%s-:\n", __func__);
  1051. return ret;
  1052. }
  1053. static int mdss_dsi_blank(struct mdss_panel_data *pdata)
  1054. {
  1055. int ret = 0;
  1056. struct mipi_panel_info *mipi;
  1057. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  1058. pr_debug("%s+:\n", __func__);
  1059. if (pdata == NULL) {
  1060. pr_err("%s: Invalid input data\n", __func__);
  1061. return -EINVAL;
  1062. }
  1063. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  1064. panel_data);
  1065. mipi = &pdata->panel_info.mipi;
  1066. if (__mdss_dsi_ulps_feature_enabled(pdata) &&
  1067. (ctrl_pdata->ulps)) {
  1068. /* Disable ULPS mode before blanking the panel */
  1069. ret = mdss_dsi_ulps_config(ctrl_pdata, 0);
  1070. if (ret) {
  1071. pr_err("%s: failed to exit ULPS mode. rc=%d\n",
  1072. __func__, ret);
  1073. return ret;
  1074. }
  1075. }
  1076. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL) && \
  1077. ! defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  1078. if (pdata->panel_info.type == MIPI_VIDEO_PANEL &&
  1079. ctrl_pdata->off_cmds.link_state == DSI_LP_MODE) {
  1080. mdss_dsi_sw_reset(pdata);
  1081. mdss_dsi_host_init(pdata);
  1082. }
  1083. #endif
  1084. mdss_dsi_op_mode_config(DSI_CMD_MODE, pdata);
  1085. if (pdata->panel_info.dynamic_switch_pending) {
  1086. pr_info("%s: switching to %s mode\n", __func__,
  1087. (pdata->panel_info.mipi.mode ? "video" : "command"));
  1088. if (pdata->panel_info.type == MIPI_CMD_PANEL) {
  1089. ctrl_pdata->switch_mode(pdata, DSI_VIDEO_MODE);
  1090. } else if (pdata->panel_info.type == MIPI_VIDEO_PANEL) {
  1091. ctrl_pdata->switch_mode(pdata, DSI_CMD_MODE);
  1092. mdss_dsi_set_tear_off(ctrl_pdata);
  1093. }
  1094. }
  1095. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQHD_PT_PANEL) && \
  1096. !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6TNMR7_PT_PANEL) && \
  1097. !defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_CMD_HD_PT_PANEL)
  1098. if (pdata->panel_info.type == MIPI_CMD_PANEL) {
  1099. if (mipi->vsync_enable && mipi->hw_vsync_mode
  1100. && gpio_is_valid(ctrl_pdata->disp_te_gpio)) {
  1101. mdss_dsi_set_tear_off(ctrl_pdata);
  1102. }
  1103. }
  1104. #endif
  1105. if (ctrl_pdata->ctrl_state & CTRL_STATE_PANEL_INIT) {
  1106. if (!pdata->panel_info.dynamic_switch_pending) {
  1107. ret = ctrl_pdata->off(pdata);
  1108. if (ret) {
  1109. pr_err("%s: Panel OFF failed\n", __func__);
  1110. return ret;
  1111. }
  1112. }
  1113. ctrl_pdata->ctrl_state &= ~CTRL_STATE_PANEL_INIT;
  1114. }
  1115. pr_debug("%s-:End\n", __func__);
  1116. return ret;
  1117. }
  1118. int mdss_dsi_cont_splash_on(struct mdss_panel_data *pdata)
  1119. {
  1120. int ret = 0;
  1121. struct mipi_panel_info *mipi;
  1122. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  1123. pr_info("%s:%d DSI on for continuous splash.\n", __func__, __LINE__);
  1124. if (pdata == NULL) {
  1125. pr_err("%s: Invalid input data\n", __func__);
  1126. return -EINVAL;
  1127. }
  1128. mipi = &pdata->panel_info.mipi;
  1129. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  1130. panel_data);
  1131. pr_debug("%s+: ctrl=%pK ndx=%d\n", __func__,
  1132. ctrl_pdata, ctrl_pdata->ndx);
  1133. WARN((ctrl_pdata->ctrl_state & CTRL_STATE_PANEL_INIT),
  1134. "Incorrect Ctrl state=0x%x\n", ctrl_pdata->ctrl_state);
  1135. mdss_dsi_sw_reset(pdata);
  1136. mdss_dsi_host_init(pdata);
  1137. mdss_dsi_op_mode_config(mipi->mode, pdata);
  1138. pr_debug("%s-:End\n", __func__);
  1139. return ret;
  1140. }
  1141. static int mdss_dsi_dfps_config(struct mdss_panel_data *pdata, int new_fps)
  1142. {
  1143. int rc = 0;
  1144. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  1145. u32 dsi_ctrl;
  1146. pr_debug("%s+:\n", __func__);
  1147. if (pdata == NULL) {
  1148. pr_err("%s: Invalid input data\n", __func__);
  1149. return -EINVAL;
  1150. }
  1151. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  1152. panel_data);
  1153. if (!ctrl_pdata->panel_data.panel_info.dynamic_fps) {
  1154. pr_err("%s: Dynamic fps not enabled for this panel\n",
  1155. __func__);
  1156. return -EINVAL;
  1157. }
  1158. if (new_fps !=
  1159. ctrl_pdata->panel_data.panel_info.mipi.frame_rate) {
  1160. if (pdata->panel_info.dfps_update
  1161. == DFPS_IMMEDIATE_PORCH_UPDATE_MODE) {
  1162. u32 hsync_period, vsync_period;
  1163. u32 new_dsi_v_total, current_dsi_v_total;
  1164. vsync_period =
  1165. mdss_panel_get_vtotal(&pdata->panel_info);
  1166. hsync_period =
  1167. mdss_panel_get_htotal(&pdata->panel_info);
  1168. current_dsi_v_total =
  1169. MIPI_INP((ctrl_pdata->ctrl_base) + 0x2C);
  1170. new_dsi_v_total =
  1171. ((vsync_period - 1) << 16) | (hsync_period - 1);
  1172. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x2C,
  1173. (current_dsi_v_total | 0x8000000));
  1174. if (new_dsi_v_total & 0x8000000) {
  1175. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x2C,
  1176. new_dsi_v_total);
  1177. } else {
  1178. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x2C,
  1179. (new_dsi_v_total | 0x8000000));
  1180. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x2C,
  1181. (new_dsi_v_total & 0x7ffffff));
  1182. }
  1183. pdata->panel_info.mipi.frame_rate = new_fps;
  1184. } else {
  1185. rc = mdss_dsi_clk_div_config
  1186. (&ctrl_pdata->panel_data.panel_info, new_fps);
  1187. if (rc) {
  1188. pr_err("%s: unable to initialize the clk dividers\n",
  1189. __func__);
  1190. return rc;
  1191. }
  1192. ctrl_pdata->pclk_rate =
  1193. pdata->panel_info.mipi.dsi_pclk_rate;
  1194. ctrl_pdata->byte_clk_rate =
  1195. pdata->panel_info.clk_rate / 8;
  1196. if (pdata->panel_info.dfps_update
  1197. == DFPS_IMMEDIATE_CLK_UPDATE_MODE) {
  1198. dsi_ctrl = MIPI_INP((ctrl_pdata->ctrl_base) +
  1199. 0x0004);
  1200. pdata->panel_info.mipi.frame_rate = new_fps;
  1201. dsi_ctrl &= ~0x2;
  1202. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x0004,
  1203. dsi_ctrl);
  1204. mdss_dsi_controller_cfg(true, pdata);
  1205. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_ALL_CLKS, 0);
  1206. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_ALL_CLKS, 1);
  1207. dsi_ctrl |= 0x2;
  1208. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x0004,
  1209. dsi_ctrl);
  1210. }
  1211. }
  1212. } else {
  1213. pr_debug("%s: Panel is already at this FPS\n", __func__);
  1214. }
  1215. return rc;
  1216. }
  1217. static int mdss_dsi_ctl_partial_update(struct mdss_panel_data *pdata)
  1218. {
  1219. int rc = -EINVAL;
  1220. u32 data;
  1221. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  1222. if (pdata == NULL) {
  1223. pr_err("%s: Invalid input data\n", __func__);
  1224. return -EINVAL;
  1225. }
  1226. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  1227. panel_data);
  1228. /* DSI_COMMAND_MODE_MDP_STREAM_CTRL */
  1229. data = (((pdata->panel_info.roi_w * 3) + 1) << 16) |
  1230. (pdata->panel_info.mipi.vc << 8) | DTYPE_DCS_LWRITE;
  1231. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x60, data);
  1232. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x58, data);
  1233. /* DSI_COMMAND_MODE_MDP_STREAM_TOTAL */
  1234. data = pdata->panel_info.roi_h << 16 | pdata->panel_info.roi_w;
  1235. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x64, data);
  1236. MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x5C, data);
  1237. if (ctrl_pdata->partial_update_fnc)
  1238. rc = ctrl_pdata->partial_update_fnc(pdata);
  1239. if (rc) {
  1240. pr_err("%s: unable to initialize the panel\n",
  1241. __func__);
  1242. return rc;
  1243. }
  1244. return rc;
  1245. }
  1246. int mdss_dsi_register_recovery_handler(struct mdss_dsi_ctrl_pdata *ctrl,
  1247. struct mdss_panel_recovery *recovery)
  1248. {
  1249. mutex_lock(&ctrl->mutex);
  1250. ctrl->recovery = recovery;
  1251. mutex_unlock(&ctrl->mutex);
  1252. return 0;
  1253. }
  1254. static int mdss_dsi_event_handler(struct mdss_panel_data *pdata,
  1255. int event, void *arg)
  1256. {
  1257. int rc = 0;
  1258. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  1259. if (pdata == NULL) {
  1260. pr_err("%s: Invalid input data\n", __func__);
  1261. return -EINVAL;
  1262. }
  1263. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
  1264. panel_data);
  1265. pr_debug("%s+:event=%d\n", __func__, event);
  1266. MDSS_XLOG(event, arg, ctrl_pdata->ndx, 0x3333);
  1267. #if defined (CONFIG_FB_MSM_MDSS_DSI_DBG)
  1268. xlog(__func__, event, (int)arg, ctrl_pdata->ndx, 0, 0, 0x3333);
  1269. #endif
  1270. switch (event) {
  1271. case MDSS_EVENT_UNBLANK:
  1272. rc = mdss_dsi_on(pdata);
  1273. mdss_dsi_op_mode_config(pdata->panel_info.mipi.mode,
  1274. pdata);
  1275. if (ctrl_pdata->on_cmds.link_state == DSI_LP_MODE)
  1276. rc = mdss_dsi_unblank(pdata);
  1277. break;
  1278. case MDSS_EVENT_PANEL_ON:
  1279. ctrl_pdata->ctrl_state |= CTRL_STATE_MDP_ACTIVE;
  1280. ctrl_pdata->mdp_tg_on = 1;
  1281. if (ctrl_pdata->on_cmds.link_state == DSI_HS_MODE)
  1282. rc = mdss_dsi_unblank(pdata);
  1283. break;
  1284. case MDSS_EVENT_BLANK:
  1285. if (ctrl_pdata->off_cmds.link_state == DSI_HS_MODE)
  1286. rc = mdss_dsi_blank(pdata);
  1287. break;
  1288. case MDSS_EVENT_PANEL_OFF:
  1289. ctrl_pdata->ctrl_state &= ~CTRL_STATE_MDP_ACTIVE;
  1290. if (ctrl_pdata->off_cmds.link_state == DSI_LP_MODE)
  1291. rc = mdss_dsi_blank(pdata);
  1292. rc = mdss_dsi_off(pdata);
  1293. break;
  1294. #if defined(CONFIG_FB_MSM_MDSS_S6E8AA0A_HD_PANEL)
  1295. case MTP_READ:
  1296. rc = mdss_MTP_read(pdata);
  1297. break;
  1298. #endif
  1299. case MDSS_EVENT_FB_REGISTERED:
  1300. if (ctrl_pdata->registered) {
  1301. pr_debug("%s:event=%d, calling panel registered callback \n",
  1302. __func__, event);
  1303. rc = ctrl_pdata->registered(pdata);
  1304. /*
  1305. * Okay, since framebuffer is registered, display the kernel logo if needed
  1306. */
  1307. #if 0
  1308. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_FULL_HD_PT_PANEL)
  1309. if ((!ctrl_pdata->panel_data.panel_info.cont_splash_enabled)
  1310. && (ctrl_pdata->panel_data.panel_info.early_lcd_on))
  1311. load_samsung_boot_logo();
  1312. #endif
  1313. #endif
  1314. }
  1315. break;
  1316. case MDSS_EVENT_CONT_SPLASH_FINISH:
  1317. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_CMD_HD_PT_PANEL)
  1318. if (ctrl_pdata->off_cmds.link_state == DSI_HS_MODE){
  1319. ctrl_pdata->ctrl_state |= CTRL_STATE_PANEL_INIT;
  1320. rc = mdss_dsi_blank(pdata);
  1321. }
  1322. #else
  1323. if (ctrl_pdata->off_cmds.link_state == DSI_LP_MODE)
  1324. rc = mdss_dsi_blank(pdata);
  1325. #endif
  1326. ctrl_pdata->ctrl_state &= ~CTRL_STATE_MDP_ACTIVE;
  1327. rc = mdss_dsi_cont_splash_on(pdata);
  1328. break;
  1329. case MDSS_EVENT_PANEL_CLK_CTRL:
  1330. #ifdef DSI_CLK_DEBUG
  1331. pr_err("[QCT_TEST] %s : ndx(%d) arg(%d) ++\n",
  1332. __func__, ctrl_pdata->ndx, (int)arg);
  1333. #endif
  1334. mdss_dsi_clk_req(ctrl_pdata, (int)arg);
  1335. #ifdef DSI_CLK_DEBUG
  1336. pr_err("[QCT_TEST] %s : ndx(%d) arg(%d) --\n",
  1337. __func__, ctrl_pdata->ndx, (int)arg);
  1338. #endif
  1339. break;
  1340. case MDSS_EVENT_DSI_CMDLIST_KOFF:
  1341. mdss_dsi_cmdlist_commit(ctrl_pdata, 1);
  1342. break;
  1343. case MDSS_EVENT_PANEL_UPDATE_FPS:
  1344. if (arg != NULL) {
  1345. rc = mdss_dsi_dfps_config(pdata, (int)arg);
  1346. pr_debug("%s:update fps to = %d\n",
  1347. __func__, (int)arg);
  1348. }
  1349. break;
  1350. case MDSS_EVENT_CONT_SPLASH_BEGIN:
  1351. if (ctrl_pdata->off_cmds.link_state == DSI_HS_MODE) {
  1352. /* Panel is Enabled in Bootloader */
  1353. rc = mdss_dsi_blank(pdata);
  1354. }
  1355. break;
  1356. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL)
  1357. case MDSS_EVENT_FIRST_FRAME_UPDATE:
  1358. pr_info("MDSS_FIRST_FRAME_UPDATE\n");
  1359. #if !defined(CONFIG_FB_MSM_MDSS_SDC_WXGA_PANEL)\
  1360. && !defined(CONFIG_FB_MSM_MDSS_TC_DSI2LVDS_WXGA_PANEL)\
  1361. && !defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  1362. && !defined(CONFIG_FB_MSM_MDSS_CPT_QHD_PANEL)\
  1363. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  1364. && !defined(CONFIG_FB_MSM_MDSS_S6E8AA0A_HD_PANEL)\
  1365. && !defined(CONFIG_FB_MSM_MDSS_HX8369B_TFT_VIDEO_WVGA_PT_PANEL)\
  1366. && !defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_WXGA_PT_DUAL_PANEL)\
  1367. && !defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)\
  1368. && !defined(CONFIG_FB_MSM_MIPI_S6E88A0_QHD_VIDEO_PT_PANEL)\
  1369. && !defined(CONFIG_FB_MSM_MIPI_JDI_TFT_VIDEO_FULL_HD_PT_PANEL)\
  1370. && !defined(CONFIG_FB_MSM_MDSS_HX8394C_TFT_VIDEO_720P_PANEL)\
  1371. && !defined(CONFIG_FB_MSM_MDSS_SHARP_HD_PANEL)\
  1372. && !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)\
  1373. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  1374. ctrl_pdata->mdp_tg_on = 1;
  1375. /*Event is send only if cont_splash feature is enabled */
  1376. if (ctrl_pdata->off_cmds.link_state == DSI_HS_MODE) {
  1377. /* Panel is Enabled in Bootloader */
  1378. ctrl_pdata->ctrl_state |= CTRL_STATE_PANEL_INIT;
  1379. rc = mdss_dsi_blank(pdata);
  1380. }
  1381. #endif
  1382. break;
  1383. #endif
  1384. case MDSS_EVENT_ENABLE_PARTIAL_UPDATE:
  1385. rc = mdss_dsi_ctl_partial_update(pdata);
  1386. break;
  1387. case MDSS_EVENT_DSI_ULPS_CTRL:
  1388. rc = mdss_dsi_ulps_config(ctrl_pdata, (int)arg);
  1389. break;
  1390. case MDSS_EVENT_REGISTER_RECOVERY_HANDLER:
  1391. rc = mdss_dsi_register_recovery_handler(ctrl_pdata,
  1392. (struct mdss_panel_recovery *)arg);
  1393. break;
  1394. #if !defined(CONFIG_FB_MSM_MIPI_JDI_TFT_VIDEO_FULL_HD_PT_PANEL)
  1395. case MDSS_EVENT_DSI_DYNAMIC_SWITCH:
  1396. rc = mdss_dsi_update_panel_config(ctrl_pdata,
  1397. (int)(unsigned long) arg);
  1398. break;
  1399. #endif
  1400. default:
  1401. if(ctrl_pdata->event_handler)
  1402. rc = ctrl_pdata->event_handler(event);
  1403. else
  1404. pr_err("%s: unhandled event=%d\n", __func__, event);
  1405. break;
  1406. }
  1407. pr_debug("%s-:event=%d, rc=%d\n", __func__, event, rc);
  1408. return rc;
  1409. }
  1410. static struct device_node *mdss_dsi_pref_prim_panel(
  1411. struct platform_device *pdev)
  1412. {
  1413. struct device_node *dsi_pan_node = NULL;
  1414. pr_debug("%s:%d: Select primary panel from dt\n",
  1415. __func__, __LINE__);
  1416. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQHD_PT_PANEL)
  1417. if ( !get_lcd_ldi_info()){/* MAGNA_PANEL */
  1418. dsi_pan_node = of_parse_phandle(pdev->dev.of_node,
  1419. "qcom,dsi-pref-prim-pan-magna", 0);
  1420. } else /* SLSI_PANEL */
  1421. #elif (defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  1422. && !defined(CONFIG_FB_MSM_MDSS_MAGNA_LDI_EA8061))\
  1423. || defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  1424. if (get_oled_id() == 0x0){ /*magna*/
  1425. dsi_pan_node = of_parse_phandle(pdev->dev.of_node,
  1426. "qcom,dsi-pref-prim-pan2", 0);
  1427. } else
  1428. #endif
  1429. {
  1430. dsi_pan_node = of_parse_phandle(pdev->dev.of_node,
  1431. "qcom,dsi-pref-prim-pan", 0);
  1432. }
  1433. if (!dsi_pan_node)
  1434. pr_err("%s:can't find panel phandle\n", __func__);
  1435. return dsi_pan_node;
  1436. }
  1437. /**
  1438. * mdss_dsi_find_panel_of_node(): find device node of dsi panel
  1439. * @pdev: platform_device of the dsi ctrl node
  1440. * @panel_cfg: string containing intf specific config data
  1441. *
  1442. * Function finds the panel device node using the interface
  1443. * specific configuration data. This configuration data is
  1444. * could be derived from the result of bootloader's GCDB
  1445. * panel detection mechanism. If such config data doesn't
  1446. * exist then this panel returns the default panel configured
  1447. * in the device tree.
  1448. *
  1449. * returns pointer to panel node on success, NULL on error.
  1450. */
  1451. static struct device_node *mdss_dsi_find_panel_of_node(
  1452. struct platform_device *pdev, char *panel_cfg)
  1453. {
  1454. struct device_node *dsi_pan_node = NULL;
  1455. dsi_pan_node = mdss_dsi_pref_prim_panel(pdev);
  1456. return dsi_pan_node;
  1457. }
  1458. struct mutex dual_clk_lock;
  1459. static int __devinit mdss_dsi_ctrl_probe(struct platform_device *pdev)
  1460. {
  1461. int rc = 0;
  1462. u32 index;
  1463. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  1464. struct device_node *dsi_pan_node = NULL;
  1465. char panel_cfg[MDSS_MAX_PANEL_LEN];
  1466. const char *ctrl_name;
  1467. bool cmd_cfg_cont_splash = true;
  1468. if (!mdss_is_ready()) {
  1469. pr_err("%s: MDP not probed yet!\n", __func__);
  1470. return -EPROBE_DEFER;
  1471. }
  1472. if (!pdev->dev.of_node) {
  1473. pr_err("DSI driver only supports device tree probe\n");
  1474. return -ENOTSUPP;
  1475. }
  1476. #if !defined(CONFIG_FB_MSM8x26_MDSS_CHECK_LCD_CONNECTION) && \
  1477. !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_TFT_VIDEO_WQXGA_PT_PANEL) && \
  1478. !defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_WXGA_PT_DUAL_PANEL) && \
  1479. !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQHD_PT_PANEL)
  1480. if (get_lcd_attached() == 0) {
  1481. pr_err("%s : lcd is not attached..\n",__func__);
  1482. return -ENODEV;
  1483. }
  1484. #endif
  1485. ctrl_pdata = platform_get_drvdata(pdev);
  1486. if (!ctrl_pdata) {
  1487. ctrl_pdata = devm_kzalloc(&pdev->dev,
  1488. sizeof(struct mdss_dsi_ctrl_pdata),
  1489. GFP_KERNEL);
  1490. if (!ctrl_pdata) {
  1491. pr_err("%s: FAILED: cannot alloc dsi ctrl\n",
  1492. __func__);
  1493. rc = -ENOMEM;
  1494. goto error_no_mem;
  1495. }
  1496. platform_set_drvdata(pdev, ctrl_pdata);
  1497. }
  1498. ctrl_pdata->mdss_util = mdss_get_util_intf();
  1499. if (ctrl_pdata->mdss_util == NULL) {
  1500. pr_err("Failed to get mdss utility functions\n");
  1501. rc = -ENODEV;
  1502. goto error_no_mem;
  1503. }
  1504. ctrl_name = of_get_property(pdev->dev.of_node, "label", NULL);
  1505. if (!ctrl_name)
  1506. pr_info("%s:%d, DSI Ctrl name not specified\n",
  1507. __func__, __LINE__);
  1508. else
  1509. pr_info("%s: DSI Ctrl name = %s\n",
  1510. __func__, ctrl_name);
  1511. rc = of_property_read_u32(pdev->dev.of_node,
  1512. "cell-index", &index);
  1513. if (rc) {
  1514. dev_err(&pdev->dev,
  1515. "%s: Cell-index not specified, rc=%d\n",
  1516. __func__, rc);
  1517. goto error_no_mem;
  1518. }
  1519. if (index == 0)
  1520. pdev->id = 1;
  1521. else
  1522. pdev->id = 2;
  1523. if (index == 0)
  1524. mutex_init(&dual_clk_lock);
  1525. rc = of_platform_populate(pdev->dev.of_node,
  1526. NULL, NULL, &pdev->dev);
  1527. if (rc) {
  1528. dev_err(&pdev->dev,
  1529. "%s: failed to add child nodes, rc=%d\n",
  1530. __func__, rc);
  1531. goto error_no_mem;
  1532. }
  1533. /* Parse the regulator information */
  1534. rc = mdss_dsi_get_dt_vreg_data(&pdev->dev,
  1535. &ctrl_pdata->power_data);
  1536. if (rc) {
  1537. pr_err("%s: failed to get vreg data from dt. rc=%d\n",
  1538. __func__, rc);
  1539. goto error_vreg;
  1540. }
  1541. /* DSI panels can be different between controllers */
  1542. rc = mdss_dsi_get_panel_cfg(panel_cfg);
  1543. if (!rc)
  1544. /* dsi panel cfg not present */
  1545. pr_warn("%s:%d:dsi specific cfg not present\n",
  1546. __func__, __LINE__);
  1547. /* find panel device node */
  1548. dsi_pan_node = mdss_dsi_find_panel_of_node(pdev, panel_cfg);
  1549. if (!dsi_pan_node) {
  1550. pr_err("%s: can't find panel node %s\n", __func__, panel_cfg);
  1551. goto error_pan_node;
  1552. }
  1553. cmd_cfg_cont_splash = mdss_panel_get_boot_cfg() ? true : false;
  1554. rc = mdss_dsi_panel_init(dsi_pan_node, ctrl_pdata, cmd_cfg_cont_splash);
  1555. if (rc) {
  1556. pr_err("%s: dsi panel init failed\n", __func__);
  1557. goto error_pan_node;
  1558. }
  1559. rc = dsi_panel_device_register(dsi_pan_node, ctrl_pdata);
  1560. if (rc) {
  1561. pr_err("%s: dsi panel dev reg failed\n", __func__);
  1562. goto error_pan_node;
  1563. }
  1564. pr_info("%s: Dsi Ctrl->%d initialized\n", __func__, index);
  1565. return 0;
  1566. error_pan_node:
  1567. of_node_put(dsi_pan_node);
  1568. error_vreg:
  1569. mdss_dsi_put_dt_vreg_data(&pdev->dev, &ctrl_pdata->power_data);
  1570. error_no_mem:
  1571. devm_kfree(&pdev->dev, ctrl_pdata);
  1572. return rc;
  1573. }
  1574. static int __devexit mdss_dsi_ctrl_remove(struct platform_device *pdev)
  1575. {
  1576. struct msm_fb_data_type *mfd;
  1577. struct mdss_dsi_ctrl_pdata *ctrl_pdata = platform_get_drvdata(pdev);
  1578. if (!ctrl_pdata) {
  1579. pr_err("%s: no driver data\n", __func__);
  1580. return -ENODEV;
  1581. }
  1582. if (msm_dss_config_vreg(&pdev->dev,
  1583. ctrl_pdata->power_data.vreg_config,
  1584. ctrl_pdata->power_data.num_vreg, 1) < 0)
  1585. pr_err("%s: failed to de-init vregs\n", __func__);
  1586. mdss_dsi_put_dt_vreg_data(&pdev->dev, &ctrl_pdata->power_data);
  1587. mfd = platform_get_drvdata(pdev);
  1588. msm_dss_iounmap(&ctrl_pdata->mmss_misc_io);
  1589. msm_dss_iounmap(&ctrl_pdata->phy_io);
  1590. msm_dss_iounmap(&ctrl_pdata->ctrl_io);
  1591. return 0;
  1592. }
  1593. struct device dsi_dev;
  1594. int mdss_dsi_retrieve_ctrl_resources(struct platform_device *pdev, int mode,
  1595. struct mdss_dsi_ctrl_pdata *ctrl)
  1596. {
  1597. int rc = 0;
  1598. u32 index;
  1599. rc = of_property_read_u32(pdev->dev.of_node, "cell-index", &index);
  1600. if (rc) {
  1601. dev_err(&pdev->dev,
  1602. "%s: Cell-index not specified, rc=%d\n",
  1603. __func__, rc);
  1604. return rc;
  1605. }
  1606. if (index == 0) {
  1607. if (mode != DISPLAY_1) {
  1608. pr_err("%s:%d Panel->Ctrl mapping is wrong",
  1609. __func__, __LINE__);
  1610. return -EPERM;
  1611. }
  1612. } else if (index == 1) {
  1613. if (mode != DISPLAY_2) {
  1614. pr_err("%s:%d Panel->Ctrl mapping is wrong",
  1615. __func__, __LINE__);
  1616. return -EPERM;
  1617. }
  1618. } else {
  1619. pr_err("%s:%d Unknown Ctrl mapped to panel",
  1620. __func__, __LINE__);
  1621. return -EPERM;
  1622. }
  1623. rc = msm_dss_ioremap_byname(pdev, &ctrl->ctrl_io, "dsi_ctrl");
  1624. if (rc) {
  1625. pr_err("%s:%d unable to remap dsi ctrl resources",
  1626. __func__, __LINE__);
  1627. return rc;
  1628. }
  1629. ctrl->ctrl_base = ctrl->ctrl_io.base;
  1630. ctrl->reg_size = ctrl->ctrl_io.len;
  1631. rc = msm_dss_ioremap_byname(pdev, &ctrl->phy_io, "dsi_phy");
  1632. if (rc) {
  1633. pr_err("%s:%d unable to remap dsi phy resources",
  1634. __func__, __LINE__);
  1635. return rc;
  1636. }
  1637. pr_info("%s: ctrl_base=%pK ctrl_size=%x phy_base=%pK phy_size=%x\n",
  1638. __func__, ctrl->ctrl_base, ctrl->reg_size, ctrl->phy_io.base,
  1639. ctrl->phy_io.len);
  1640. rc = msm_dss_ioremap_byname(pdev, &ctrl->mmss_misc_io,
  1641. "mmss_misc_phys");
  1642. if (rc) {
  1643. pr_debug("%s:%d mmss_misc IO remap failed\n",
  1644. __func__, __LINE__);
  1645. }
  1646. return 0;
  1647. }
  1648. #ifdef DEBUG_LDI_STATUS
  1649. int read_ldi_status(void);
  1650. #endif
  1651. void mdss_dsi_dump_power_clk(struct mdss_panel_data *pdata, int flag) {
  1652. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL) \
  1653. && !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL) \
  1654. && !defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  1655. u8 rc, te_count = 0;
  1656. u8 te_max = 250;
  1657. #endif
  1658. struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
  1659. return;
  1660. ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata, panel_data);
  1661. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL) \
  1662. && !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL) \
  1663. && !defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  1664. if (pdata->panel_info.type == MIPI_CMD_PANEL) {
  1665. pr_info(" ============ waiting for TE ============\n");
  1666. for (te_count = 0 ; te_count < te_max ; te_count++)
  1667. {
  1668. rc = gpio_get_value(ctrl_pdata->disp_te_gpio);
  1669. if(rc != 0)
  1670. {
  1671. pr_info("%s: gpio_get_value(ctrl_pdata->disp_te_gpio) =%d\n",
  1672. __func__, rc);
  1673. break;
  1674. }
  1675. udelay(80);
  1676. }
  1677. }
  1678. #endif
  1679. pr_info(" ============ dump power & clk start ============\n");
  1680. if ((ctrl_pdata->shared_pdata).vdd_vreg)
  1681. pr_info("vdd_vreg : %d\n", regulator_is_enabled((ctrl_pdata->shared_pdata).vdd_vreg));
  1682. if ((ctrl_pdata->shared_pdata).vdd_io_vreg)
  1683. pr_info("vdd_io_vreg : %d\n", regulator_is_enabled((ctrl_pdata->shared_pdata).vdd_io_vreg));
  1684. if ((ctrl_pdata->shared_pdata).vdda_vreg)
  1685. pr_info("vdda_vreg : %d\n", regulator_is_enabled((ctrl_pdata->shared_pdata).vdda_vreg));
  1686. #if 0
  1687. clock_debug_print_clock2(ctrl_pdata->pixel_clk);
  1688. clock_debug_print_clock2(ctrl_pdata->byte_clk);
  1689. clock_debug_print_clock2(ctrl_pdata->esc_clk);
  1690. #endif
  1691. pr_info("%s: ctrl ndx=%d clk_cnt=%d\n",
  1692. __func__, ctrl_pdata->ndx, ctrl_pdata->clk_cnt);
  1693. pr_info(" ============ dump power & clk end ============\n");
  1694. pr_info(" === check manufacture ID cf) EVT0 0xXXXX0X / EVT1 0xXXXX2X ===\n");
  1695. pr_info(" Current LDI manufacture ID = 0x%x \n", gv_manufacture_id);
  1696. #if !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL) \
  1697. && !defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_WVGA_S6E88A0_PT_PANEL) \
  1698. && !defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  1699. if (pdata->panel_info.type == MIPI_CMD_PANEL) {
  1700. if(te_count == te_max)
  1701. {
  1702. pr_info("LDI doesn't generate TE/ manufacture ID = 0x%x", gv_manufacture_id);
  1703. #ifdef DEBUG_LDI_STATUS
  1704. if(flag)
  1705. {
  1706. if(read_ldi_status())
  1707. pr_err("%s : Can not read LDI status\n",__func__);
  1708. }
  1709. #endif
  1710. panic("LDI doesn't generate TE/ manufacture ID = 0x%x", gv_manufacture_id);
  1711. }
  1712. }
  1713. #endif
  1714. }
  1715. enum of_gpio_flags test_flags;
  1716. int dsi_panel_device_register(struct device_node *pan_node,
  1717. struct mdss_dsi_ctrl_pdata *ctrl_pdata)
  1718. {
  1719. struct mipi_panel_info *mipi;
  1720. int rc, broard_cast;
  1721. int i, len;
  1722. struct device_node *dsi_ctrl_np = NULL;
  1723. struct platform_device *ctrl_pdev = NULL;
  1724. const char *data;
  1725. struct mdss_panel_info *pinfo = &(ctrl_pdata->panel_data.panel_info);
  1726. pr_info("%s : ++ \n",__func__);
  1727. mipi = &(pinfo->mipi);
  1728. pinfo->type =
  1729. ((mipi->mode == DSI_VIDEO_MODE)
  1730. ? MIPI_VIDEO_PANEL : MIPI_CMD_PANEL);
  1731. rc = mdss_dsi_clk_div_config(pinfo, mipi->frame_rate);
  1732. if (rc) {
  1733. pr_err("%s: unable to initialize the clk dividers\n", __func__);
  1734. return rc;
  1735. }
  1736. dsi_ctrl_np = of_parse_phandle(pan_node,
  1737. "qcom,mdss-dsi-panel-controller", 0);
  1738. if (!dsi_ctrl_np) {
  1739. pr_err("%s: Dsi controller node not initialized\n", __func__);
  1740. return -EPROBE_DEFER;
  1741. }
  1742. ctrl_pdev = of_find_device_by_node(dsi_ctrl_np);
  1743. ctrl_pdata = platform_get_drvdata(ctrl_pdev);
  1744. if (!ctrl_pdata) {
  1745. pr_err("%s: no dsi ctrl driver data\n", __func__);
  1746. return -EINVAL;
  1747. }
  1748. rc = mdss_dsi_regulator_init(ctrl_pdev);
  1749. if (rc) {
  1750. pr_err("%s: failed to init regulator, rc=%d\n",
  1751. __func__, rc);
  1752. return rc;
  1753. }
  1754. #if defined(CONFIG_FB_MSM_MDSS_S6E8AA0A_HD_PANEL) || defined(CONFIG_FB_MSM_MDSS_SHARP_HD_PANEL)
  1755. data = of_get_property(ctrl_pdev->dev.of_node,
  1756. "qcom,platform-strength-ctrl", &len);
  1757. if ((!data) || (len != 2)) {
  1758. pr_err("%s:%d, Unable to read Phy Strength ctrl settings",
  1759. __func__, __LINE__);
  1760. return -EINVAL;
  1761. }
  1762. pinfo->mipi.dsi_phy_db.strength[0] = data[0];
  1763. pinfo->mipi.dsi_phy_db.strength[1] = data[1];
  1764. data = of_get_property(ctrl_pdev->dev.of_node,
  1765. "qcom,platform-regulator-settings", &len);
  1766. if ((!data) || (len != 7)) {
  1767. pr_err("%s:%d, Unable to read Phy regulator settings",
  1768. __func__, __LINE__);
  1769. return -EINVAL;
  1770. }
  1771. for (i = 0; i < len; i++) {
  1772. pinfo->mipi.dsi_phy_db.regulator[i]
  1773. = data[i];
  1774. }
  1775. #endif
  1776. rc = of_property_read_u32(pan_node,
  1777. "qcom,mdss-pan-broadcast-mode",&broard_cast);
  1778. ctrl_pdata->shared_pdata.broadcast_enable = (!rc ? broard_cast : 0);
  1779. pr_info("%s:%d, broadcast (%d)",__func__, __LINE__,
  1780. ctrl_pdata->shared_pdata.broadcast_enable);
  1781. if (pinfo->pdest == DISPLAY_1) {
  1782. data = of_get_property(ctrl_pdev->dev.of_node,
  1783. "qcom,platform-bist-ctrl", &len);
  1784. if ((!data) || (len != 6)) {
  1785. pr_err("%s:%d, Unable to read Phy Bist Ctrl settings",
  1786. __func__, __LINE__);
  1787. return -EINVAL;
  1788. }
  1789. for (i = 0; i < len; i++) {
  1790. pinfo->mipi.dsi_phy_db.bistctrl[i]
  1791. = data[i];
  1792. }
  1793. data = of_get_property(ctrl_pdev->dev.of_node,
  1794. "qcom,platform-lane-config", &len);
  1795. if ((!data) || (len != 45)) {
  1796. pr_err("%s:%d, Unable to read Phy lane configure settings",
  1797. __func__, __LINE__);
  1798. return -EINVAL;
  1799. }
  1800. for (i = 0; i < len; i++) {
  1801. pinfo->mipi.dsi_phy_db.lanecfg[i] =
  1802. data[i];
  1803. }
  1804. }
  1805. /*
  1806. ctrl_pdata->shared_pdata.broadcast_enable = of_property_read_bool(
  1807. pan_node, "qcom,mdss-dsi-panel-broadcast-mode");
  1808. */
  1809. pinfo->panel_max_fps = mdss_panel_get_framerate(pinfo);
  1810. pinfo->panel_max_vtotal = mdss_panel_get_vtotal(pinfo);
  1811. #if 1
  1812. ctrl_pdata->disp_en_gpio = of_get_named_gpio(pan_node,
  1813. "qcom,enable-gpio", 0);
  1814. #else
  1815. ctrl_pdata->disp_en_gpio = of_get_named_gpio(ctrl_pdev->dev.of_node,
  1816. "qcom,platform-enable-gpio", 0);
  1817. #endif
  1818. pr_err("%s:%d, Disp_en_gpio (%d)",__func__, __LINE__,ctrl_pdata->disp_en_gpio );
  1819. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_TFT_VIDEO_WQXGA_PT_PANEL)
  1820. if (get_lcd_attached() == 0) {
  1821. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  1822. pr_info("%s : Set Low LCD Enable GPIO \n", __func__);
  1823. gpio_set_value((ctrl_pdata->disp_en_gpio), 0);
  1824. }
  1825. }
  1826. #endif
  1827. if (!gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  1828. pr_err("%s:%d, Disp_en gpio not specified\n",
  1829. __func__, __LINE__);
  1830. } else {
  1831. if (ctrl_pdata->panel_data.panel_info.pdest == DISPLAY_1) {
  1832. rc = gpio_request(ctrl_pdata->disp_en_gpio, "disp_enable");
  1833. if (rc) {
  1834. pr_err("request disp_en gpio failed, rc=%d\n",
  1835. rc);
  1836. gpio_free(ctrl_pdata->disp_en_gpio);
  1837. return -ENODEV;
  1838. }
  1839. #if defined(CONFIG_FB_MSM_MDSS_S6E8AA0A_HD_PANEL) \
  1840. || defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL) \
  1841. || defined(CONFIG_FB_MSM_MIPI_JDI_TFT_VIDEO_FULL_HD_PT_PANEL) \
  1842. || defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_HD_PANEL)
  1843. else {
  1844. rc = gpio_tlmm_config(GPIO_CFG(ctrl_pdata->disp_en_gpio, 0,
  1845. GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL,GPIO_CFG_8MA),
  1846. GPIO_CFG_ENABLE);
  1847. if (rc)
  1848. pr_err("request disp_en_gpio failed, rc=%d\n",rc);
  1849. }
  1850. #endif
  1851. }
  1852. }
  1853. #if defined (CONFIG_FB_MSM8x26_MDSS_CHECK_LCD_CONNECTION)
  1854. if (get_lcd_attached() == 0) {
  1855. if (gpio_is_valid(ctrl_pdata->disp_en_gpio)) {
  1856. pr_info("%s : Set Low LCD Enable GPIO \n", __func__);
  1857. gpio_set_value((ctrl_pdata->disp_en_gpio), 0);
  1858. }
  1859. }
  1860. #endif
  1861. #if defined(CONFIG_FB_MSM_MDSS_HX8369B_TFT_VIDEO_WVGA_PT_PANEL) || defined(CONFIG_FB_MSM_MIPI_JDI_TFT_VIDEO_FULL_HD_PT_PANEL)
  1862. ctrl_pdata->bl_on_gpio = of_get_named_gpio(pan_node,
  1863. "qcom,bl-ctrl-gpio", 0);
  1864. if (!gpio_is_valid(ctrl_pdata->bl_on_gpio)) {
  1865. pr_err("%s:%dbl_on_gpio gpio not specified\n",
  1866. __func__, __LINE__);
  1867. } else {
  1868. rc = gpio_request(ctrl_pdata->bl_on_gpio, "backlight_enable");
  1869. if (rc) {
  1870. pr_err("request bl_on_gpio failed, rc=%d\n",rc);
  1871. gpio_free(ctrl_pdata->bl_on_gpio);
  1872. }else {
  1873. rc = gpio_tlmm_config(GPIO_CFG(ctrl_pdata->bl_on_gpio, 0,
  1874. GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL,GPIO_CFG_8MA),
  1875. GPIO_CFG_ENABLE);
  1876. if (rc)
  1877. pr_err("request BL ON gpio failed, rc=%d\n",rc);
  1878. }
  1879. }
  1880. #endif
  1881. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  1882. || defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  1883. || defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)\
  1884. || defined(CONFIG_FB_MSM_MIPI_JDI_TFT_VIDEO_FULL_HD_PT_PANEL)
  1885. ctrl_pdata->disp_en_gpio2 = of_get_named_gpio(pan_node,
  1886. "qcom,enable-gpio2", 0);
  1887. pr_err("%s:%d, Disp_en_gpio2 (%d)",__func__, __LINE__,ctrl_pdata->disp_en_gpio2 );
  1888. if (!gpio_is_valid(ctrl_pdata->disp_en_gpio2)) {
  1889. pr_err("%s:%d, Disp_en gpio2 not specified\n",
  1890. __func__, __LINE__);
  1891. } else {
  1892. if (ctrl_pdata->panel_data.panel_info.pdest == DISPLAY_1) {
  1893. rc = gpio_request(ctrl_pdata->disp_en_gpio2, "disp_enable2");
  1894. if (rc) {
  1895. pr_err("request disp_en gpio2 failed, rc=%d\n",
  1896. rc);
  1897. gpio_free(ctrl_pdata->disp_en_gpio2);
  1898. }
  1899. }
  1900. }
  1901. #endif
  1902. #if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6TNMR7_PT_PANEL)
  1903. ctrl_pdata->disp_en_gpio2 = of_get_named_gpio(pan_node,
  1904. "qcom,enable-gpio2", 0);
  1905. pr_err("%s:%d, Disp_en_gpio2 (%d)",__func__, __LINE__,ctrl_pdata->disp_en_gpio2 );
  1906. ctrl_pdata->tcon_ready_gpio = of_get_named_gpio(pan_node,
  1907. "qcom,tcon-ready-gpio", 0);
  1908. pr_err("%s:%d, tcon_ready gpio (%d)",__func__, __LINE__,ctrl_pdata->tcon_ready_gpio );
  1909. if (!gpio_is_valid(ctrl_pdata->disp_en_gpio2)) {
  1910. pr_err("%s:%d, Disp_en gpio2 not specified\n",
  1911. __func__, __LINE__);
  1912. } else {
  1913. if (ctrl_pdata->panel_data.panel_info.pdest == DISPLAY_1) {
  1914. rc = gpio_request(ctrl_pdata->disp_en_gpio2, "disp_enable2");
  1915. if (rc) {
  1916. pr_err("request disp_en gpio2 failed, rc=%d\n",
  1917. rc);
  1918. gpio_free(ctrl_pdata->disp_en_gpio2);
  1919. }
  1920. }
  1921. }
  1922. if (!gpio_is_valid(ctrl_pdata->tcon_ready_gpio)) {
  1923. pr_err("%s:%d, tcon_ready gpio not specified\n",
  1924. __func__, __LINE__);
  1925. } else {
  1926. if (ctrl_pdata->panel_data.panel_info.pdest == DISPLAY_2) {
  1927. rc = gpio_request(ctrl_pdata->tcon_ready_gpio, "tcon_ready");
  1928. if (rc) {
  1929. pr_err("request tcon_ready gpio failed, rc=%d\n",
  1930. rc);
  1931. gpio_free(ctrl_pdata->tcon_ready_gpio);
  1932. }
  1933. }
  1934. }
  1935. #endif
  1936. #if defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL)
  1937. ctrl_pdata->lcd_crack_det= of_get_named_gpio(pan_node,"qcom,lcd-crack-det-gpio", 0);
  1938. if (gpio_is_valid(ctrl_pdata->lcd_crack_det)) {
  1939. rc = gpio_request(ctrl_pdata->lcd_crack_det, "lcd_crack_det");
  1940. if (rc) {
  1941. pr_err("request lcd_crack_det gpio failed, rc=%d\n",rc);
  1942. gpio_free(ctrl_pdata->lcd_crack_det);
  1943. return -ENODEV;
  1944. }
  1945. rc = gpio_tlmm_config(GPIO_CFG(
  1946. ctrl_pdata->lcd_crack_det, 1,
  1947. GPIO_CFG_INPUT,
  1948. GPIO_CFG_NO_PULL,
  1949. GPIO_CFG_2MA),
  1950. GPIO_CFG_ENABLE);
  1951. if (rc) {
  1952. pr_err("%s: unable to config tlmm = %d\n",__func__, ctrl_pdata->lcd_crack_det);
  1953. gpio_free(ctrl_pdata->lcd_crack_det);
  1954. return -ENODEV;
  1955. }
  1956. rc = gpio_direction_input(ctrl_pdata->lcd_crack_det);
  1957. if (rc) {
  1958. pr_err("set_direction for disp_en gpio failed, rc=%d\n",rc);
  1959. gpio_free(ctrl_pdata->lcd_crack_det);
  1960. return -ENODEV;
  1961. }
  1962. pr_debug("%s: lcd_crack_det=%d\n", __func__, ctrl_pdata->lcd_crack_det);
  1963. } else {
  1964. pr_err("%s:%d, lcd_crack_det gpio not specified\n",__func__, __LINE__);
  1965. }
  1966. ctrl_pdata->expander_enble_gpio= of_get_named_gpio(pan_node,"qcom,expander-enable-gpio", 0);
  1967. if (gpio_is_valid(ctrl_pdata->expander_enble_gpio))
  1968. pr_err("%s:%d, expander_enble_gpio gpio not specified\n",__func__, __LINE__);
  1969. #endif
  1970. #if defined(CONFIG_FB_MSM_MDSS_SHARP_HD_PANEL)
  1971. ctrl_pdata->bl_on_gpio = of_get_named_gpio(ctrl_pdev->dev.of_node,
  1972. "qcom,bl-on-gpio", 0);
  1973. if (!gpio_is_valid(ctrl_pdata->bl_on_gpio)) {
  1974. pr_err("%s:%dbl_on_gpio gpio not specified\n",
  1975. __func__, __LINE__);
  1976. } else {
  1977. rc = gpio_request(ctrl_pdata->bl_on_gpio, "backlight_enable");
  1978. if (rc) {
  1979. pr_err("request bl_on_gpio failed, rc=%d\n",
  1980. rc);
  1981. gpio_free(ctrl_pdata->bl_on_gpio);
  1982. }else {
  1983. rc = gpio_tlmm_config(GPIO_CFG(ctrl_pdata->bl_on_gpio, 0,
  1984. GPIO_CFG_OUTPUT,GPIO_CFG_PULL_UP,GPIO_CFG_8MA),
  1985. GPIO_CFG_ENABLE);
  1986. if (rc)
  1987. pr_err("request BL ON gpio failed, rc=%d\n",rc);
  1988. }
  1989. }
  1990. ctrl_pdata->disp_en_gpio_p = of_get_named_gpio(ctrl_pdev->dev.of_node,
  1991. "qcom,disp-on-gpio-p", 0);
  1992. rc = gpio_request(ctrl_pdata->disp_en_gpio_p, "disp_en_gpio_p");
  1993. if (rc) {
  1994. pr_err("request disp_en_gpio_p gpio failed, rc=%d\n",
  1995. rc);
  1996. gpio_free(ctrl_pdata->disp_en_gpio_p);
  1997. }else{
  1998. rc = gpio_tlmm_config(GPIO_CFG(ctrl_pdata->disp_en_gpio_p, 0,
  1999. GPIO_CFG_OUTPUT,GPIO_CFG_PULL_UP,GPIO_CFG_8MA),
  2000. GPIO_CFG_ENABLE);
  2001. if (rc)
  2002. pr_err("request disp_en_gpio_p failed, rc=%d\n",rc);
  2003. }
  2004. ctrl_pdata->disp_en_gpio_n = of_get_named_gpio(ctrl_pdev->dev.of_node,
  2005. "qcom,disp-on-gpio-n", 0);
  2006. rc = gpio_request(ctrl_pdata->disp_en_gpio_n, "disp_en_gpio_n");
  2007. if (rc) {
  2008. pr_err("request disp_en_gpio_n gpio failed, rc=%d\n",
  2009. rc);
  2010. gpio_free(ctrl_pdata->disp_en_gpio_n);
  2011. }else{
  2012. rc = gpio_tlmm_config(GPIO_CFG(ctrl_pdata->disp_en_gpio_n, 0,
  2013. GPIO_CFG_OUTPUT,GPIO_CFG_PULL_UP,GPIO_CFG_8MA),
  2014. GPIO_CFG_ENABLE);
  2015. if (rc)
  2016. pr_err("request disp_en_gpio_n failed, rc=%d\n",rc);
  2017. }
  2018. #endif
  2019. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_WXGA_PT_DUAL_PANEL)
  2020. ctrl_pdata->lcd_sel_gpio = of_get_named_gpio(pan_node, "qcom,lcd-sel-gpio", 0);
  2021. if (!gpio_is_valid(ctrl_pdata->lcd_sel_gpio)) {
  2022. pr_err("%s:%d, lcd_sel_gpio not specified\n", __func__, __LINE__);
  2023. } else {
  2024. rc = gpio_request(ctrl_pdata->lcd_sel_gpio, "lcd_sel");
  2025. if (rc) {
  2026. pr_err("request lcd_sel gpio failed, rc=%d\n", rc);
  2027. gpio_free(ctrl_pdata->lcd_sel_gpio);
  2028. return -ENODEV;
  2029. }
  2030. pr_info("%s: lcd_sel_gpio = %d\n", __func__, ctrl_pdata->lcd_sel_gpio);
  2031. rc = gpio_tlmm_config(GPIO_CFG(ctrl_pdata->lcd_sel_gpio, 0,
  2032. GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL,GPIO_CFG_8MA),
  2033. GPIO_CFG_ENABLE);
  2034. if (rc) {
  2035. pr_err("%s: unable to lcd_sel config tlmm = %d\n",
  2036. __func__, ctrl_pdata->lcd_sel_gpio);
  2037. gpio_free(ctrl_pdata->lcd_sel_gpio);
  2038. return -ENODEV;
  2039. }
  2040. /*
  2041. rc = gpio_direction_output(ctrl_pdata->lcd_sel_gpio, 1);
  2042. if (rc) {
  2043. pr_err("set_direction for lcd_sel gpio failed, rc=%d\n",
  2044. rc);
  2045. gpio_free(ctrl_pdata->lcd_sel_gpio);
  2046. return -ENODEV;
  2047. }
  2048. */
  2049. }
  2050. #endif
  2051. #if defined(CONFIG_FB_MSM_MDSS_HX8394C_TFT_VIDEO_720P_PANEL)
  2052. ctrl_pdata->disp_en_vsp_gpio = of_get_named_gpio(pan_node, "qcom,enable-vsp-gpio", 0);
  2053. ctrl_pdata->disp_en_vsn_gpio = of_get_named_gpio(pan_node, "qcom,enable-vsn-gpio", 0);
  2054. pr_err("%s:%d, Disp_en_vsp_gpio (%d)",__func__, __LINE__,ctrl_pdata->disp_en_vsp_gpio );
  2055. pr_err("%s:%d, Disp_en_vsn_gpio (%d)",__func__, __LINE__,ctrl_pdata->disp_en_vsn_gpio );
  2056. if (!gpio_is_valid(ctrl_pdata->disp_en_vsp_gpio)) {
  2057. pr_err("%s:%d, Disp_en vsp gpio not specified\n",
  2058. __func__, __LINE__);
  2059. } else {
  2060. if (ctrl_pdata->panel_data.panel_info.pdest == DISPLAY_1) {
  2061. rc = gpio_request(ctrl_pdata->disp_en_vsp_gpio, "disp_vsp_enable");
  2062. if (rc) {
  2063. pr_err("request disp_vsp_en gpio failed, rc=%d\n",
  2064. rc);
  2065. gpio_free(ctrl_pdata->disp_en_vsp_gpio);
  2066. }
  2067. }
  2068. }
  2069. if (!gpio_is_valid(ctrl_pdata->disp_en_vsn_gpio)) {
  2070. pr_err("%s:%d, Disp_en vsn gpio not specified\n",
  2071. __func__, __LINE__);
  2072. } else {
  2073. if (ctrl_pdata->panel_data.panel_info.pdest == DISPLAY_1) {
  2074. rc = gpio_request(ctrl_pdata->disp_en_vsn_gpio, "disp_vsn_enable");
  2075. if (rc) {
  2076. pr_err("request disp_vsn_en gpio failed, rc=%d\n",
  2077. rc);
  2078. gpio_free(ctrl_pdata->disp_en_vsn_gpio);
  2079. }
  2080. }
  2081. }
  2082. #endif
  2083. if (pinfo->type == MIPI_CMD_PANEL) {
  2084. ctrl_pdata->disp_te_gpio = of_get_named_gpio(pan_node,
  2085. "qcom,te-gpio", 0);
  2086. pr_err("%s:%d, Disp_te_gpio (%d)",__func__, __LINE__,ctrl_pdata->disp_te_gpio );
  2087. if (gpio_is_valid(ctrl_pdata->disp_te_gpio) &&
  2088. pinfo->type == MIPI_CMD_PANEL &&
  2089. pinfo->pdest == DISPLAY_1) {
  2090. rc = gpio_request(ctrl_pdata->disp_te_gpio, "disp_te");
  2091. if (rc) {
  2092. pr_err("request TE gpio failed, rc=%d\n",
  2093. rc);
  2094. gpio_free(ctrl_pdata->disp_te_gpio);
  2095. return -ENODEV;
  2096. }
  2097. rc = gpio_tlmm_config(GPIO_CFG(
  2098. ctrl_pdata->disp_te_gpio, 1,
  2099. GPIO_CFG_INPUT,
  2100. GPIO_CFG_PULL_DOWN,
  2101. GPIO_CFG_2MA),
  2102. GPIO_CFG_ENABLE);
  2103. if (rc) {
  2104. pr_err("%s: unable to config tlmm = %d\n",
  2105. __func__, ctrl_pdata->disp_te_gpio);
  2106. gpio_free(ctrl_pdata->disp_te_gpio);
  2107. return -ENODEV;
  2108. }
  2109. rc = gpio_direction_input(ctrl_pdata->disp_te_gpio);
  2110. if (rc) {
  2111. pr_err("set_direction for disp_en gpio failed, rc=%d\n",
  2112. rc);
  2113. gpio_free(ctrl_pdata->disp_te_gpio);
  2114. return -ENODEV;
  2115. }
  2116. pr_debug("%s: te_gpio=%d\n", __func__,
  2117. ctrl_pdata->disp_te_gpio);
  2118. } else {
  2119. pr_err("%s:%d, Disp_te gpio not specified\n",
  2120. __func__, __LINE__);
  2121. }
  2122. }
  2123. #if defined(CONFIG_FB_MSM_MDSS_SHARP_HD_PANEL)
  2124. ctrl_pdata->rst_gpio = of_get_named_gpio(ctrl_pdev->dev.of_node,
  2125. "qcom,platform-reset-gpio", 0);
  2126. #else
  2127. ctrl_pdata->rst_gpio = of_get_named_gpio(pan_node,
  2128. "qcom,rst-gpio", 0);
  2129. #endif
  2130. pr_err("%s:%d, Disp_rst_gpio (%d)",__func__, __LINE__,ctrl_pdata->rst_gpio );
  2131. if (!gpio_is_valid(ctrl_pdata->rst_gpio)) {
  2132. pr_err("%s:%d, Disp_reset gpio not specified\n",
  2133. __func__, __LINE__);
  2134. } else {
  2135. if (ctrl_pdata->panel_data.panel_info.pdest == DISPLAY_1) {
  2136. rc = gpio_request(ctrl_pdata->rst_gpio, "disp_rst_n");
  2137. if (rc) {
  2138. pr_err("request reset gpio failed, rc=%d\n",
  2139. rc);
  2140. gpio_free(ctrl_pdata->rst_gpio);
  2141. if (gpio_is_valid(ctrl_pdata->disp_en_gpio))
  2142. gpio_free(ctrl_pdata->disp_en_gpio);
  2143. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  2144. || defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  2145. || defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  2146. if (gpio_is_valid(ctrl_pdata->disp_en_gpio2))
  2147. gpio_free(ctrl_pdata->disp_en_gpio2);
  2148. #elif defined(CONFIG_FB_MSM_MDSS_HX8394C_TFT_VIDEO_720P_PANEL)
  2149. if (gpio_is_valid(ctrl_pdata->disp_en_vsp_gpio))
  2150. gpio_free(ctrl_pdata->disp_en_vsp_gpio);
  2151. if (gpio_is_valid(ctrl_pdata->disp_en_vsn_gpio))
  2152. gpio_free(ctrl_pdata->disp_en_vsn_gpio);
  2153. #endif
  2154. #if defined(CONFIG_FB_MSM_MIPI_JDI_TFT_VIDEO_FULL_HD_PT_PANEL)
  2155. if (gpio_is_valid(ctrl_pdata->bl_on_gpio))
  2156. gpio_free(ctrl_pdata->bl_on_gpio);
  2157. #endif
  2158. return -ENODEV;
  2159. }
  2160. }
  2161. }
  2162. if (pinfo->mode_gpio_state != MODE_GPIO_NOT_VALID) {
  2163. ctrl_pdata->mode_gpio = of_get_named_gpio(
  2164. ctrl_pdev->dev.of_node,
  2165. "qcom,platform-mode-gpio", 0);
  2166. if (!gpio_is_valid(ctrl_pdata->mode_gpio)) {
  2167. pr_info("%s:%d, mode gpio not specified\n",
  2168. __func__, __LINE__);
  2169. } else {
  2170. rc = gpio_request(ctrl_pdata->mode_gpio, "panel_mode");
  2171. if (rc) {
  2172. pr_err("request panel mode gpio failed,rc=%d\n",
  2173. rc);
  2174. gpio_free(ctrl_pdata->mode_gpio);
  2175. if (gpio_is_valid(ctrl_pdata->disp_en_gpio))
  2176. gpio_free(ctrl_pdata->disp_en_gpio);
  2177. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  2178. || defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  2179. || defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  2180. if (gpio_is_valid(ctrl_pdata->disp_en_gpio2))
  2181. gpio_free(ctrl_pdata->disp_en_gpio2);
  2182. #elif defined(CONFIG_FB_MSM_MDSS_HX8394C_TFT_VIDEO_720P_PANEL)
  2183. if (gpio_is_valid(ctrl_pdata->disp_en_vsp_gpio))
  2184. gpio_free(ctrl_pdata->disp_en_vsp_gpio);
  2185. if (gpio_is_valid(ctrl_pdata->disp_en_vsn_gpio))
  2186. gpio_free(ctrl_pdata->disp_en_vsn_gpio);
  2187. #endif
  2188. #if defined(CONFIG_FB_MSM_MIPI_JDI_TFT_VIDEO_FULL_HD_PT_PANEL)
  2189. if (gpio_is_valid(ctrl_pdata->bl_on_gpio))
  2190. gpio_free(ctrl_pdata->bl_on_gpio);
  2191. #endif
  2192. if (gpio_is_valid(ctrl_pdata->rst_gpio))
  2193. gpio_free(ctrl_pdata->rst_gpio);
  2194. if (gpio_is_valid(ctrl_pdata->disp_te_gpio))
  2195. gpio_free(ctrl_pdata->disp_te_gpio);
  2196. return -ENODEV;
  2197. }
  2198. }
  2199. }
  2200. if (mdss_dsi_clk_init(ctrl_pdev, ctrl_pdata)) {
  2201. pr_err("%s: unable to initialize Dsi ctrl clks\n", __func__);
  2202. return -EPERM;
  2203. }
  2204. if (mdss_dsi_retrieve_ctrl_resources(ctrl_pdev,
  2205. pinfo->pdest,
  2206. ctrl_pdata)) {
  2207. pr_err("%s: unable to get Dsi controller res\n", __func__);
  2208. return -EPERM;
  2209. }
  2210. ctrl_pdata->panel_data.event_handler = mdss_dsi_event_handler;
  2211. if (ctrl_pdata->status_mode == ESD_REG)
  2212. ctrl_pdata->check_status = mdss_dsi_reg_status_check;
  2213. else if (ctrl_pdata->status_mode == ESD_BTA)
  2214. ctrl_pdata->check_status = mdss_dsi_bta_status_check;
  2215. if (ctrl_pdata->status_mode == ESD_MAX) {
  2216. pr_err("%s: Using default BTA for ESD check\n", __func__);
  2217. ctrl_pdata->check_status = mdss_dsi_bta_status_check;
  2218. }
  2219. #if !(defined(CONFIG_FB_MSM_MDSS_TC_DSI2LVDS_WXGA_PANEL) || defined(CONFIG_BACKLIGHT_IC_KTD2801))
  2220. if (ctrl_pdata->bklt_ctrl == BL_PWM)
  2221. mdss_dsi_panel_pwm_cfg(ctrl_pdata);
  2222. #endif
  2223. mdss_dsi_ctrl_init(ctrl_pdata);
  2224. /*
  2225. * register in mdp driver
  2226. */
  2227. ctrl_pdata->pclk_rate = mipi->dsi_pclk_rate;
  2228. ctrl_pdata->byte_clk_rate = pinfo->clk_rate / 8;
  2229. pr_debug("%s: pclk=%d, bclk=%d\n", __func__,
  2230. ctrl_pdata->pclk_rate, ctrl_pdata->byte_clk_rate);
  2231. ctrl_pdata->ctrl_state = CTRL_STATE_UNKNOWN;
  2232. if (pinfo->cont_splash_enabled) {
  2233. pr_info("%s : splash enabled..panel_power_on (1)\n", __func__);
  2234. pinfo->panel_power_on = 1;
  2235. if(ctrl_pdata->ndx == DSI_CTRL_0) {
  2236. rc = mdss_dsi_panel_power_on(&(ctrl_pdata->panel_data), 1);
  2237. if (rc) {
  2238. pr_err("%s: Panel power on failed\n", __func__);
  2239. return rc;
  2240. }
  2241. }
  2242. mdss_dsi_clk_ctrl(ctrl_pdata, DSI_ALL_CLKS, 1);
  2243. #if (defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_VIDEO_FULL_HD_PT_PANEL) || \
  2244. defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PANEL))
  2245. ctrl_pdata->ctrl_state |= (CTRL_STATE_PANEL_INIT | CTRL_STATE_MDP_ACTIVE);
  2246. #else
  2247. ctrl_pdata->ctrl_state |= CTRL_STATE_MDP_ACTIVE;
  2248. #endif
  2249. ctrl_pdata->mdp_tg_on = 1;
  2250. } else {
  2251. pr_info("%s : splash disabled..panel_power_on (0)\n", __func__);
  2252. pinfo->panel_power_on = 0;
  2253. }
  2254. rc = mdss_register_panel(ctrl_pdev, &(ctrl_pdata->panel_data));
  2255. if (rc) {
  2256. pr_err("%s: unable to register MIPI DSI panel\n", __func__);
  2257. if (ctrl_pdata->rst_gpio)
  2258. gpio_free(ctrl_pdata->rst_gpio);
  2259. if (gpio_is_valid(ctrl_pdata->disp_en_gpio))
  2260. gpio_free(ctrl_pdata->disp_en_gpio);
  2261. #if defined(CONFIG_FB_MSM_MIPI_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  2262. || defined(CONFIG_FB_MSM_MDSS_MAGNA_OCTA_VIDEO_720P_PT_PANEL)\
  2263. || defined(CONFIG_FB_MSM_MDSS_SAMSUNG_OCTA_VIDEO_720P_PT_PANEL)
  2264. if (gpio_is_valid(ctrl_pdata->disp_en_gpio2))
  2265. gpio_free(ctrl_pdata->disp_en_gpio2);
  2266. #elif defined(CONFIG_FB_MSM_MDSS_HX8394C_TFT_VIDEO_720P_PANEL)
  2267. if (gpio_is_valid(ctrl_pdata->disp_en_vsp_gpio))
  2268. gpio_free(ctrl_pdata->disp_en_vsp_gpio);
  2269. if (gpio_is_valid(ctrl_pdata->disp_en_vsn_gpio))
  2270. gpio_free(ctrl_pdata->disp_en_vsn_gpio);
  2271. #endif
  2272. #if defined(CONFIG_FB_MSM_MIPI_JDI_TFT_VIDEO_FULL_HD_PT_PANEL)
  2273. if (gpio_is_valid(ctrl_pdata->bl_on_gpio))
  2274. gpio_free(ctrl_pdata->bl_on_gpio);
  2275. #endif
  2276. return rc;
  2277. }
  2278. if (pinfo->pdest == DISPLAY_1) {
  2279. mdss_debug_register_base("dsi0",
  2280. ctrl_pdata->ctrl_base, ctrl_pdata->reg_size);
  2281. ctrl_pdata->ndx = 0;
  2282. } else {
  2283. mdss_debug_register_base("dsi1",
  2284. ctrl_pdata->ctrl_base, ctrl_pdata->reg_size);
  2285. ctrl_pdata->ndx = 1;
  2286. }
  2287. pr_info("%s: Panel data initialized\n", __func__);
  2288. return 0;
  2289. }
  2290. static const struct of_device_id mdss_dsi_ctrl_dt_match[] = {
  2291. {.compatible = "qcom,mdss-dsi-ctrl"},
  2292. {}
  2293. };
  2294. MODULE_DEVICE_TABLE(of, mdss_dsi_ctrl_dt_match);
  2295. static struct platform_driver mdss_dsi_ctrl_driver = {
  2296. .probe = mdss_dsi_ctrl_probe,
  2297. .remove = __devexit_p(mdss_dsi_ctrl_remove),
  2298. .shutdown = NULL,
  2299. .driver = {
  2300. .name = "mdss_dsi_ctrl",
  2301. .of_match_table = mdss_dsi_ctrl_dt_match,
  2302. },
  2303. };
  2304. static int mdss_dsi_register_driver(void)
  2305. {
  2306. return platform_driver_register(&mdss_dsi_ctrl_driver);
  2307. }
  2308. static int __init mdss_dsi_driver_init(void)
  2309. {
  2310. int ret;
  2311. pr_info("%s ++ \n",__func__);
  2312. ret = mdss_dsi_register_driver();
  2313. if (ret) {
  2314. pr_err("mdss_dsi_register_driver() failed!\n");
  2315. return ret;
  2316. }
  2317. pr_info("%s -- \n",__func__);
  2318. return ret;
  2319. }
  2320. module_init(mdss_dsi_driver_init);
  2321. static void __exit mdss_dsi_driver_cleanup(void)
  2322. {
  2323. platform_driver_unregister(&mdss_dsi_ctrl_driver);
  2324. }
  2325. module_exit(mdss_dsi_driver_cleanup);
  2326. int get_lcd_attached(void)
  2327. {
  2328. #if defined (CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQHD_PT_PANEL) || \
  2329. defined (CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_FULL_HD_PT_PANEL) || \
  2330. defined (CONFIG_FB_MSM_MIPI_SAMSUNG_TFT_VIDEO_WQXGA_PT_PANEL) || \
  2331. defined (CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6TNMR7_PT_PANEL) || \
  2332. defined (CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6E3HA1_PT_PANEL) || \
  2333. defined (CONFIG_FB_MSM8x26_MDSS_CHECK_LCD_CONNECTION) || \
  2334. defined (CONFIG_GET_LCD_ATTACHED)
  2335. return get_samsung_lcd_attached();
  2336. #else
  2337. return 1;
  2338. #endif
  2339. }
  2340. EXPORT_SYMBOL(get_lcd_attached);
  2341. MODULE_LICENSE("GPL v2");
  2342. MODULE_DESCRIPTION("DSI controller driver");
  2343. MODULE_AUTHOR("Chandan Uddaraju <chandanu@codeaurora.org>");