dsi_phy.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/of_device.h>
  6. #include <linux/err.h>
  7. #include <linux/regulator/consumer.h>
  8. #include <linux/clk.h>
  9. #include <linux/msm-bus.h>
  10. #include <linux/list.h>
  11. #include "msm_drv.h"
  12. #include "msm_kms.h"
  13. #include "dsi_phy.h"
  14. #include "dsi_phy_hw.h"
  15. #include "dsi_clk.h"
  16. #include "dsi_pwr.h"
  17. #include "dsi_catalog.h"
  18. #include "sde_dbg.h"
  19. #define DSI_PHY_DEFAULT_LABEL "MDSS PHY CTRL"
  20. #define BITS_PER_BYTE 8
  21. struct dsi_phy_list_item {
  22. struct msm_dsi_phy *phy;
  23. struct list_head list;
  24. };
  25. static LIST_HEAD(dsi_phy_list);
  26. static DEFINE_MUTEX(dsi_phy_list_lock);
  27. static const struct dsi_ver_spec_info dsi_phy_v0_0_hpm = {
  28. .version = DSI_PHY_VERSION_0_0_HPM,
  29. .lane_cfg_count = 4,
  30. .strength_cfg_count = 2,
  31. .regulator_cfg_count = 1,
  32. .timing_cfg_count = 8,
  33. };
  34. static const struct dsi_ver_spec_info dsi_phy_v0_0_lpm = {
  35. .version = DSI_PHY_VERSION_0_0_LPM,
  36. .lane_cfg_count = 4,
  37. .strength_cfg_count = 2,
  38. .regulator_cfg_count = 1,
  39. .timing_cfg_count = 8,
  40. };
  41. static const struct dsi_ver_spec_info dsi_phy_v1_0 = {
  42. .version = DSI_PHY_VERSION_1_0,
  43. .lane_cfg_count = 4,
  44. .strength_cfg_count = 2,
  45. .regulator_cfg_count = 1,
  46. .timing_cfg_count = 8,
  47. };
  48. static const struct dsi_ver_spec_info dsi_phy_v2_0 = {
  49. .version = DSI_PHY_VERSION_2_0,
  50. .lane_cfg_count = 4,
  51. .strength_cfg_count = 2,
  52. .regulator_cfg_count = 1,
  53. .timing_cfg_count = 8,
  54. };
  55. static const struct dsi_ver_spec_info dsi_phy_v3_0 = {
  56. .version = DSI_PHY_VERSION_3_0,
  57. .lane_cfg_count = 4,
  58. .strength_cfg_count = 2,
  59. .regulator_cfg_count = 0,
  60. .timing_cfg_count = 12,
  61. };
  62. static const struct dsi_ver_spec_info dsi_phy_v4_0 = {
  63. .version = DSI_PHY_VERSION_4_0,
  64. .lane_cfg_count = 4,
  65. .strength_cfg_count = 2,
  66. .regulator_cfg_count = 0,
  67. .timing_cfg_count = 14,
  68. };
  69. static const struct dsi_ver_spec_info dsi_phy_v4_1 = {
  70. .version = DSI_PHY_VERSION_4_1,
  71. .lane_cfg_count = 4,
  72. .strength_cfg_count = 2,
  73. .regulator_cfg_count = 0,
  74. .timing_cfg_count = 14,
  75. };
  76. static const struct of_device_id msm_dsi_phy_of_match[] = {
  77. { .compatible = "qcom,dsi-phy-v0.0-hpm",
  78. .data = &dsi_phy_v0_0_hpm,},
  79. { .compatible = "qcom,dsi-phy-v0.0-lpm",
  80. .data = &dsi_phy_v0_0_lpm,},
  81. { .compatible = "qcom,dsi-phy-v1.0",
  82. .data = &dsi_phy_v1_0,},
  83. { .compatible = "qcom,dsi-phy-v2.0",
  84. .data = &dsi_phy_v2_0,},
  85. { .compatible = "qcom,dsi-phy-v3.0",
  86. .data = &dsi_phy_v3_0,},
  87. { .compatible = "qcom,dsi-phy-v4.0",
  88. .data = &dsi_phy_v4_0,},
  89. { .compatible = "qcom,dsi-phy-v4.1",
  90. .data = &dsi_phy_v4_1,},
  91. {}
  92. };
  93. static int dsi_phy_regmap_init(struct platform_device *pdev,
  94. struct msm_dsi_phy *phy)
  95. {
  96. int rc = 0;
  97. void __iomem *ptr;
  98. ptr = msm_ioremap(pdev, "dsi_phy", phy->name);
  99. if (IS_ERR(ptr)) {
  100. rc = PTR_ERR(ptr);
  101. return rc;
  102. }
  103. phy->hw.base = ptr;
  104. ptr = msm_ioremap(pdev, "dyn_refresh_base", phy->name);
  105. phy->hw.dyn_pll_base = ptr;
  106. DSI_PHY_DBG(phy, "map dsi_phy registers to %pK\n", phy->hw.base);
  107. switch (phy->ver_info->version) {
  108. case DSI_PHY_VERSION_2_0:
  109. ptr = msm_ioremap(pdev, "phy_clamp_base", phy->name);
  110. if (IS_ERR(ptr))
  111. phy->hw.phy_clamp_base = NULL;
  112. else
  113. phy->hw.phy_clamp_base = ptr;
  114. break;
  115. default:
  116. break;
  117. }
  118. return rc;
  119. }
  120. static int dsi_phy_regmap_deinit(struct msm_dsi_phy *phy)
  121. {
  122. DSI_PHY_DBG(phy, "unmap registers\n");
  123. return 0;
  124. }
  125. static int dsi_phy_supplies_init(struct platform_device *pdev,
  126. struct msm_dsi_phy *phy)
  127. {
  128. int rc = 0;
  129. int i = 0;
  130. struct dsi_regulator_info *regs;
  131. struct regulator *vreg = NULL;
  132. regs = &phy->pwr_info.digital;
  133. regs->vregs = devm_kzalloc(&pdev->dev, sizeof(struct dsi_vreg),
  134. GFP_KERNEL);
  135. if (!regs->vregs)
  136. goto error;
  137. regs->count = 1;
  138. snprintf(regs->vregs->vreg_name,
  139. ARRAY_SIZE(regs->vregs[i].vreg_name),
  140. "%s", "gdsc");
  141. rc = dsi_pwr_get_dt_vreg_data(&pdev->dev,
  142. &phy->pwr_info.phy_pwr,
  143. "qcom,phy-supply-entries");
  144. if (rc) {
  145. DSI_PHY_ERR(phy, "failed to get host power supplies, rc = %d\n",
  146. rc);
  147. goto error_digital;
  148. }
  149. regs = &phy->pwr_info.digital;
  150. for (i = 0; i < regs->count; i++) {
  151. vreg = devm_regulator_get(&pdev->dev, regs->vregs[i].vreg_name);
  152. rc = PTR_RET(vreg);
  153. if (rc) {
  154. DSI_PHY_ERR(phy, "failed to get %s regulator\n",
  155. regs->vregs[i].vreg_name);
  156. goto error_host_pwr;
  157. }
  158. regs->vregs[i].vreg = vreg;
  159. }
  160. regs = &phy->pwr_info.phy_pwr;
  161. for (i = 0; i < regs->count; i++) {
  162. vreg = devm_regulator_get(&pdev->dev, regs->vregs[i].vreg_name);
  163. rc = PTR_RET(vreg);
  164. if (rc) {
  165. DSI_PHY_ERR(phy, "failed to get %s regulator\n",
  166. regs->vregs[i].vreg_name);
  167. for (--i; i >= 0; i--)
  168. devm_regulator_put(regs->vregs[i].vreg);
  169. goto error_digital_put;
  170. }
  171. regs->vregs[i].vreg = vreg;
  172. }
  173. return rc;
  174. error_digital_put:
  175. regs = &phy->pwr_info.digital;
  176. for (i = 0; i < regs->count; i++)
  177. devm_regulator_put(regs->vregs[i].vreg);
  178. error_host_pwr:
  179. devm_kfree(&pdev->dev, phy->pwr_info.phy_pwr.vregs);
  180. phy->pwr_info.phy_pwr.vregs = NULL;
  181. phy->pwr_info.phy_pwr.count = 0;
  182. error_digital:
  183. devm_kfree(&pdev->dev, phy->pwr_info.digital.vregs);
  184. phy->pwr_info.digital.vregs = NULL;
  185. phy->pwr_info.digital.count = 0;
  186. error:
  187. return rc;
  188. }
  189. static int dsi_phy_supplies_deinit(struct msm_dsi_phy *phy)
  190. {
  191. int i = 0;
  192. int rc = 0;
  193. struct dsi_regulator_info *regs;
  194. regs = &phy->pwr_info.digital;
  195. for (i = 0; i < regs->count; i++) {
  196. if (!regs->vregs[i].vreg)
  197. DSI_PHY_ERR(phy, "vreg is NULL, should not reach here\n");
  198. else
  199. devm_regulator_put(regs->vregs[i].vreg);
  200. }
  201. regs = &phy->pwr_info.phy_pwr;
  202. for (i = 0; i < regs->count; i++) {
  203. if (!regs->vregs[i].vreg)
  204. DSI_PHY_ERR(phy, "vreg is NULL, should not reach here\n");
  205. else
  206. devm_regulator_put(regs->vregs[i].vreg);
  207. }
  208. if (phy->pwr_info.phy_pwr.vregs) {
  209. devm_kfree(&phy->pdev->dev, phy->pwr_info.phy_pwr.vregs);
  210. phy->pwr_info.phy_pwr.vregs = NULL;
  211. phy->pwr_info.phy_pwr.count = 0;
  212. }
  213. if (phy->pwr_info.digital.vregs) {
  214. devm_kfree(&phy->pdev->dev, phy->pwr_info.digital.vregs);
  215. phy->pwr_info.digital.vregs = NULL;
  216. phy->pwr_info.digital.count = 0;
  217. }
  218. return rc;
  219. }
  220. static int dsi_phy_parse_dt_per_lane_cfgs(struct platform_device *pdev,
  221. struct dsi_phy_per_lane_cfgs *cfg,
  222. char *property)
  223. {
  224. int rc = 0, i = 0, j = 0;
  225. const u8 *data;
  226. u32 len = 0;
  227. data = of_get_property(pdev->dev.of_node, property, &len);
  228. if (!data) {
  229. DSI_ERR("Unable to read Phy %s settings\n", property);
  230. return -EINVAL;
  231. }
  232. if (len != DSI_LANE_MAX * cfg->count_per_lane) {
  233. DSI_ERR("incorrect phy %s settings, exp=%d, act=%d\n",
  234. property, (DSI_LANE_MAX * cfg->count_per_lane), len);
  235. return -EINVAL;
  236. }
  237. for (i = DSI_LOGICAL_LANE_0; i < DSI_LANE_MAX; i++) {
  238. for (j = 0; j < cfg->count_per_lane; j++) {
  239. cfg->lane[i][j] = *data;
  240. data++;
  241. }
  242. }
  243. return rc;
  244. }
  245. static int dsi_phy_settings_init(struct platform_device *pdev,
  246. struct msm_dsi_phy *phy)
  247. {
  248. int rc = 0;
  249. struct dsi_phy_per_lane_cfgs *lane = &phy->cfg.lanecfg;
  250. struct dsi_phy_per_lane_cfgs *strength = &phy->cfg.strength;
  251. struct dsi_phy_per_lane_cfgs *timing = &phy->cfg.timing;
  252. struct dsi_phy_per_lane_cfgs *regs = &phy->cfg.regulators;
  253. lane->count_per_lane = phy->ver_info->lane_cfg_count;
  254. rc = dsi_phy_parse_dt_per_lane_cfgs(pdev, lane,
  255. "qcom,platform-lane-config");
  256. if (rc) {
  257. DSI_PHY_ERR(phy, "failed to parse lane cfgs, rc=%d\n", rc);
  258. goto err;
  259. }
  260. strength->count_per_lane = phy->ver_info->strength_cfg_count;
  261. rc = dsi_phy_parse_dt_per_lane_cfgs(pdev, strength,
  262. "qcom,platform-strength-ctrl");
  263. if (rc) {
  264. DSI_PHY_ERR(phy, "failed to parse lane cfgs, rc=%d\n", rc);
  265. goto err;
  266. }
  267. regs->count_per_lane = phy->ver_info->regulator_cfg_count;
  268. if (regs->count_per_lane > 0) {
  269. rc = dsi_phy_parse_dt_per_lane_cfgs(pdev, regs,
  270. "qcom,platform-regulator-settings");
  271. if (rc) {
  272. DSI_PHY_ERR(phy, "failed to parse lane cfgs, rc=%d\n",
  273. rc);
  274. goto err;
  275. }
  276. }
  277. /* Actual timing values are dependent on panel */
  278. timing->count_per_lane = phy->ver_info->timing_cfg_count;
  279. phy->allow_phy_power_off = of_property_read_bool(pdev->dev.of_node,
  280. "qcom,panel-allow-phy-poweroff");
  281. of_property_read_u32(pdev->dev.of_node,
  282. "qcom,dsi-phy-regulator-min-datarate-bps",
  283. &phy->regulator_min_datarate_bps);
  284. phy->cfg.force_clk_lane_hs = of_property_read_bool(pdev->dev.of_node,
  285. "qcom,panel-force-clock-lane-hs");
  286. return 0;
  287. err:
  288. lane->count_per_lane = 0;
  289. strength->count_per_lane = 0;
  290. regs->count_per_lane = 0;
  291. timing->count_per_lane = 0;
  292. return rc;
  293. }
  294. static int dsi_phy_settings_deinit(struct msm_dsi_phy *phy)
  295. {
  296. memset(&phy->cfg.lanecfg, 0x0, sizeof(phy->cfg.lanecfg));
  297. memset(&phy->cfg.strength, 0x0, sizeof(phy->cfg.strength));
  298. memset(&phy->cfg.timing, 0x0, sizeof(phy->cfg.timing));
  299. memset(&phy->cfg.regulators, 0x0, sizeof(phy->cfg.regulators));
  300. return 0;
  301. }
  302. static int dsi_phy_driver_probe(struct platform_device *pdev)
  303. {
  304. struct msm_dsi_phy *dsi_phy;
  305. struct dsi_phy_list_item *item;
  306. const struct of_device_id *id;
  307. const struct dsi_ver_spec_info *ver_info;
  308. int rc = 0;
  309. u32 index = 0;
  310. if (!pdev || !pdev->dev.of_node) {
  311. DSI_ERR("pdev not found\n");
  312. return -ENODEV;
  313. }
  314. id = of_match_node(msm_dsi_phy_of_match, pdev->dev.of_node);
  315. if (!id)
  316. return -ENODEV;
  317. ver_info = id->data;
  318. item = devm_kzalloc(&pdev->dev, sizeof(*item), GFP_KERNEL);
  319. if (!item)
  320. return -ENOMEM;
  321. dsi_phy = devm_kzalloc(&pdev->dev, sizeof(*dsi_phy), GFP_KERNEL);
  322. if (!dsi_phy) {
  323. devm_kfree(&pdev->dev, item);
  324. return -ENOMEM;
  325. }
  326. rc = of_property_read_u32(pdev->dev.of_node, "cell-index", &index);
  327. if (rc) {
  328. DSI_PHY_DBG(dsi_phy, "cell index not set, default to 0\n");
  329. index = 0;
  330. }
  331. dsi_phy->index = index;
  332. dsi_phy->name = of_get_property(pdev->dev.of_node, "label", NULL);
  333. if (!dsi_phy->name)
  334. dsi_phy->name = DSI_PHY_DEFAULT_LABEL;
  335. DSI_PHY_DBG(dsi_phy, "Probing device\n");
  336. dsi_phy->ver_info = ver_info;
  337. rc = dsi_phy_regmap_init(pdev, dsi_phy);
  338. if (rc) {
  339. DSI_PHY_ERR(dsi_phy, "Failed to parse register information, rc=%d\n",
  340. rc);
  341. goto fail;
  342. }
  343. rc = dsi_phy_supplies_init(pdev, dsi_phy);
  344. if (rc) {
  345. DSI_PHY_ERR(dsi_phy, "failed to parse voltage supplies, rc = %d\n",
  346. rc);
  347. goto fail_regmap;
  348. }
  349. rc = dsi_catalog_phy_setup(&dsi_phy->hw, ver_info->version,
  350. dsi_phy->index);
  351. if (rc) {
  352. DSI_PHY_ERR(dsi_phy, "Catalog does not support version (%d)\n",
  353. ver_info->version);
  354. goto fail_supplies;
  355. }
  356. rc = dsi_phy_settings_init(pdev, dsi_phy);
  357. if (rc) {
  358. DSI_PHY_ERR(dsi_phy, "Failed to parse phy setting, rc=%d\n",
  359. rc);
  360. goto fail_supplies;
  361. }
  362. item->phy = dsi_phy;
  363. mutex_lock(&dsi_phy_list_lock);
  364. list_add(&item->list, &dsi_phy_list);
  365. mutex_unlock(&dsi_phy_list_lock);
  366. mutex_init(&dsi_phy->phy_lock);
  367. /** TODO: initialize debugfs */
  368. dsi_phy->pdev = pdev;
  369. platform_set_drvdata(pdev, dsi_phy);
  370. DSI_PHY_INFO(dsi_phy, "Probe successful\n");
  371. return 0;
  372. fail_supplies:
  373. (void)dsi_phy_supplies_deinit(dsi_phy);
  374. fail_regmap:
  375. (void)dsi_phy_regmap_deinit(dsi_phy);
  376. fail:
  377. devm_kfree(&pdev->dev, dsi_phy);
  378. devm_kfree(&pdev->dev, item);
  379. return rc;
  380. }
  381. static int dsi_phy_driver_remove(struct platform_device *pdev)
  382. {
  383. int rc = 0;
  384. struct msm_dsi_phy *phy = platform_get_drvdata(pdev);
  385. struct list_head *pos, *tmp;
  386. if (!pdev || !phy) {
  387. DSI_PHY_ERR(phy, "Invalid device\n");
  388. return -EINVAL;
  389. }
  390. mutex_lock(&dsi_phy_list_lock);
  391. list_for_each_safe(pos, tmp, &dsi_phy_list) {
  392. struct dsi_phy_list_item *n;
  393. n = list_entry(pos, struct dsi_phy_list_item, list);
  394. if (n->phy == phy) {
  395. list_del(&n->list);
  396. devm_kfree(&pdev->dev, n);
  397. break;
  398. }
  399. }
  400. mutex_unlock(&dsi_phy_list_lock);
  401. mutex_lock(&phy->phy_lock);
  402. rc = dsi_phy_settings_deinit(phy);
  403. if (rc)
  404. DSI_PHY_ERR(phy, "failed to deinitialize phy settings, rc=%d\n",
  405. rc);
  406. rc = dsi_phy_supplies_deinit(phy);
  407. if (rc)
  408. DSI_PHY_ERR(phy, "failed to deinitialize voltage supplies, rc=%d\n",
  409. rc);
  410. rc = dsi_phy_regmap_deinit(phy);
  411. if (rc)
  412. DSI_PHY_ERR(phy, "failed to deinitialize regmap, rc=%d\n", rc);
  413. mutex_unlock(&phy->phy_lock);
  414. mutex_destroy(&phy->phy_lock);
  415. devm_kfree(&pdev->dev, phy);
  416. platform_set_drvdata(pdev, NULL);
  417. return 0;
  418. }
  419. static struct platform_driver dsi_phy_platform_driver = {
  420. .probe = dsi_phy_driver_probe,
  421. .remove = dsi_phy_driver_remove,
  422. .driver = {
  423. .name = "dsi_phy",
  424. .of_match_table = msm_dsi_phy_of_match,
  425. },
  426. };
  427. static void dsi_phy_enable_hw(struct msm_dsi_phy *phy)
  428. {
  429. if (phy->hw.ops.regulator_enable)
  430. phy->hw.ops.regulator_enable(&phy->hw, &phy->cfg.regulators);
  431. if (phy->hw.ops.enable)
  432. phy->hw.ops.enable(&phy->hw, &phy->cfg);
  433. }
  434. static void dsi_phy_disable_hw(struct msm_dsi_phy *phy)
  435. {
  436. if (phy->hw.ops.disable)
  437. phy->hw.ops.disable(&phy->hw, &phy->cfg);
  438. if (phy->hw.ops.regulator_disable)
  439. phy->hw.ops.regulator_disable(&phy->hw);
  440. }
  441. /**
  442. * dsi_phy_get() - get a dsi phy handle from device node
  443. * @of_node: device node for dsi phy controller
  444. *
  445. * Gets the DSI PHY handle for the corresponding of_node. The ref count is
  446. * incremented to one all subsequents get will fail until the original client
  447. * calls a put.
  448. *
  449. * Return: DSI PHY handle or an error code.
  450. */
  451. struct msm_dsi_phy *dsi_phy_get(struct device_node *of_node)
  452. {
  453. struct list_head *pos, *tmp;
  454. struct msm_dsi_phy *phy = NULL;
  455. mutex_lock(&dsi_phy_list_lock);
  456. list_for_each_safe(pos, tmp, &dsi_phy_list) {
  457. struct dsi_phy_list_item *n;
  458. n = list_entry(pos, struct dsi_phy_list_item, list);
  459. if (n->phy->pdev->dev.of_node == of_node) {
  460. phy = n->phy;
  461. break;
  462. }
  463. }
  464. mutex_unlock(&dsi_phy_list_lock);
  465. if (!phy) {
  466. DSI_PHY_ERR(phy, "Device with of node not found\n");
  467. phy = ERR_PTR(-EPROBE_DEFER);
  468. return phy;
  469. }
  470. mutex_lock(&phy->phy_lock);
  471. if (phy->refcount > 0) {
  472. DSI_PHY_ERR(phy, "Device under use\n");
  473. phy = ERR_PTR(-EINVAL);
  474. } else {
  475. phy->refcount++;
  476. }
  477. mutex_unlock(&phy->phy_lock);
  478. return phy;
  479. }
  480. /**
  481. * dsi_phy_put() - release dsi phy handle
  482. * @dsi_phy: DSI PHY handle.
  483. *
  484. * Release the DSI PHY hardware. Driver will clean up all resources and puts
  485. * back the DSI PHY into reset state.
  486. */
  487. void dsi_phy_put(struct msm_dsi_phy *dsi_phy)
  488. {
  489. mutex_lock(&dsi_phy->phy_lock);
  490. if (dsi_phy->refcount == 0)
  491. DSI_PHY_ERR(dsi_phy, "Unbalanced %s call\n", __func__);
  492. else
  493. dsi_phy->refcount--;
  494. mutex_unlock(&dsi_phy->phy_lock);
  495. }
  496. /**
  497. * dsi_phy_drv_init() - initialize dsi phy driver
  498. * @dsi_phy: DSI PHY handle.
  499. *
  500. * Initializes DSI PHY driver. Should be called after dsi_phy_get().
  501. *
  502. * Return: error code.
  503. */
  504. int dsi_phy_drv_init(struct msm_dsi_phy *dsi_phy)
  505. {
  506. char dbg_name[DSI_DEBUG_NAME_LEN];
  507. snprintf(dbg_name, DSI_DEBUG_NAME_LEN, "dsi%d_phy", dsi_phy->index);
  508. sde_dbg_reg_register_base(dbg_name, dsi_phy->hw.base,
  509. msm_iomap_size(dsi_phy->pdev, "dsi_phy"));
  510. return 0;
  511. }
  512. /**
  513. * dsi_phy_drv_deinit() - de-initialize dsi phy driver
  514. * @dsi_phy: DSI PHY handle.
  515. *
  516. * Release all resources acquired by dsi_phy_drv_init().
  517. *
  518. * Return: error code.
  519. */
  520. int dsi_phy_drv_deinit(struct msm_dsi_phy *dsi_phy)
  521. {
  522. return 0;
  523. }
  524. int dsi_phy_clk_cb_register(struct msm_dsi_phy *dsi_phy,
  525. struct clk_ctrl_cb *clk_cb)
  526. {
  527. if (!dsi_phy || !clk_cb) {
  528. DSI_PHY_ERR(dsi_phy, "Invalid params\n");
  529. return -EINVAL;
  530. }
  531. dsi_phy->clk_cb.priv = clk_cb->priv;
  532. dsi_phy->clk_cb.dsi_clk_cb = clk_cb->dsi_clk_cb;
  533. return 0;
  534. }
  535. /**
  536. * dsi_phy_validate_mode() - validate a display mode
  537. * @dsi_phy: DSI PHY handle.
  538. * @mode: Mode information.
  539. *
  540. * Validation will fail if the mode cannot be supported by the PHY driver or
  541. * hardware.
  542. *
  543. * Return: error code.
  544. */
  545. int dsi_phy_validate_mode(struct msm_dsi_phy *dsi_phy,
  546. struct dsi_mode_info *mode)
  547. {
  548. int rc = 0;
  549. if (!dsi_phy || !mode) {
  550. DSI_PHY_ERR(dsi_phy, "Invalid params\n");
  551. return -EINVAL;
  552. }
  553. DSI_PHY_DBG(dsi_phy, "Skipping validation\n");
  554. return rc;
  555. }
  556. /**
  557. * dsi_phy_set_power_state() - enable/disable dsi phy power supplies
  558. * @dsi_phy: DSI PHY handle.
  559. * @enable: Boolean flag to enable/disable.
  560. *
  561. * Return: error code.
  562. */
  563. int dsi_phy_set_power_state(struct msm_dsi_phy *dsi_phy, bool enable)
  564. {
  565. int rc = 0;
  566. if (!dsi_phy) {
  567. DSI_PHY_ERR(dsi_phy, "Invalid params\n");
  568. return -EINVAL;
  569. }
  570. mutex_lock(&dsi_phy->phy_lock);
  571. if (enable == dsi_phy->power_state) {
  572. DSI_PHY_ERR(dsi_phy, "No state change\n");
  573. goto error;
  574. }
  575. if (enable) {
  576. rc = dsi_pwr_enable_regulator(&dsi_phy->pwr_info.digital, true);
  577. if (rc) {
  578. DSI_PHY_ERR(dsi_phy, "failed to enable digital regulator\n");
  579. goto error;
  580. }
  581. if (dsi_phy->dsi_phy_state == DSI_PHY_ENGINE_OFF &&
  582. dsi_phy->regulator_required) {
  583. rc = dsi_pwr_enable_regulator(
  584. &dsi_phy->pwr_info.phy_pwr, true);
  585. if (rc) {
  586. DSI_PHY_ERR(dsi_phy, "failed to enable phy power\n");
  587. (void)dsi_pwr_enable_regulator(
  588. &dsi_phy->pwr_info.digital, false);
  589. goto error;
  590. }
  591. }
  592. } else {
  593. if (dsi_phy->dsi_phy_state == DSI_PHY_ENGINE_OFF &&
  594. dsi_phy->regulator_required) {
  595. rc = dsi_pwr_enable_regulator(
  596. &dsi_phy->pwr_info.phy_pwr, false);
  597. if (rc) {
  598. DSI_PHY_ERR(dsi_phy, "failed to enable digital regulator\n");
  599. goto error;
  600. }
  601. }
  602. rc = dsi_pwr_enable_regulator(&dsi_phy->pwr_info.digital,
  603. false);
  604. if (rc) {
  605. DSI_PHY_ERR(dsi_phy, "failed to enable phy power\n");
  606. goto error;
  607. }
  608. }
  609. dsi_phy->power_state = enable;
  610. error:
  611. mutex_unlock(&dsi_phy->phy_lock);
  612. return rc;
  613. }
  614. static int dsi_phy_enable_ulps(struct msm_dsi_phy *phy,
  615. struct dsi_host_config *config, bool clamp_enabled)
  616. {
  617. int rc = 0;
  618. u32 lanes = 0;
  619. u32 ulps_lanes;
  620. lanes = config->common_config.data_lanes;
  621. lanes |= DSI_CLOCK_LANE;
  622. /*
  623. * If DSI clamps are enabled, it means that the DSI lanes are
  624. * already in idle state. Checking for lanes to be in idle state
  625. * should be skipped during ULPS entry programming while coming
  626. * out of idle screen.
  627. */
  628. if (!clamp_enabled) {
  629. rc = phy->hw.ops.ulps_ops.wait_for_lane_idle(&phy->hw, lanes);
  630. if (rc) {
  631. DSI_PHY_ERR(phy, "lanes not entering idle, skip ULPS\n");
  632. return rc;
  633. }
  634. }
  635. phy->hw.ops.ulps_ops.ulps_request(&phy->hw, &phy->cfg, lanes);
  636. ulps_lanes = phy->hw.ops.ulps_ops.get_lanes_in_ulps(&phy->hw);
  637. if (!phy->hw.ops.ulps_ops.is_lanes_in_ulps(lanes, ulps_lanes)) {
  638. DSI_PHY_ERR(phy, "Failed to enter ULPS, request=0x%x, actual=0x%x\n",
  639. lanes, ulps_lanes);
  640. rc = -EIO;
  641. }
  642. return rc;
  643. }
  644. static int dsi_phy_disable_ulps(struct msm_dsi_phy *phy,
  645. struct dsi_host_config *config)
  646. {
  647. u32 ulps_lanes, lanes = 0;
  648. lanes = config->common_config.data_lanes;
  649. lanes |= DSI_CLOCK_LANE;
  650. ulps_lanes = phy->hw.ops.ulps_ops.get_lanes_in_ulps(&phy->hw);
  651. if (!phy->hw.ops.ulps_ops.is_lanes_in_ulps(lanes, ulps_lanes)) {
  652. DSI_PHY_ERR(phy, "Mismatch in ULPS: lanes:%d, ulps_lanes:%d\n",
  653. lanes, ulps_lanes);
  654. return -EIO;
  655. }
  656. phy->hw.ops.ulps_ops.ulps_exit(&phy->hw, &phy->cfg, lanes);
  657. ulps_lanes = phy->hw.ops.ulps_ops.get_lanes_in_ulps(&phy->hw);
  658. if (phy->hw.ops.ulps_ops.is_lanes_in_ulps(lanes, ulps_lanes)) {
  659. DSI_PHY_ERR(phy, "Lanes (0x%x) stuck in ULPS\n", ulps_lanes);
  660. return -EIO;
  661. }
  662. return 0;
  663. }
  664. void dsi_phy_toggle_resync_fifo(struct msm_dsi_phy *phy)
  665. {
  666. if (!phy)
  667. return;
  668. if (!phy->hw.ops.toggle_resync_fifo)
  669. return;
  670. phy->hw.ops.toggle_resync_fifo(&phy->hw);
  671. }
  672. void dsi_phy_reset_clk_en_sel(struct msm_dsi_phy *phy)
  673. {
  674. if (!phy)
  675. return;
  676. if (!phy->hw.ops.reset_clk_en_sel)
  677. return;
  678. phy->hw.ops.reset_clk_en_sel(&phy->hw);
  679. }
  680. int dsi_phy_set_ulps(struct msm_dsi_phy *phy, struct dsi_host_config *config,
  681. bool enable, bool clamp_enabled)
  682. {
  683. int rc = 0;
  684. if (!phy) {
  685. DSI_PHY_ERR(phy, "Invalid params\n");
  686. return DSI_PHY_ULPS_ERROR;
  687. }
  688. if (!phy->hw.ops.ulps_ops.ulps_request ||
  689. !phy->hw.ops.ulps_ops.ulps_exit ||
  690. !phy->hw.ops.ulps_ops.get_lanes_in_ulps ||
  691. !phy->hw.ops.ulps_ops.is_lanes_in_ulps ||
  692. !phy->hw.ops.ulps_ops.wait_for_lane_idle) {
  693. DSI_PHY_DBG(phy, "DSI PHY ULPS ops not present\n");
  694. return DSI_PHY_ULPS_NOT_HANDLED;
  695. }
  696. mutex_lock(&phy->phy_lock);
  697. if (enable)
  698. rc = dsi_phy_enable_ulps(phy, config, clamp_enabled);
  699. else
  700. rc = dsi_phy_disable_ulps(phy, config);
  701. if (rc) {
  702. DSI_PHY_ERR(phy, "Ulps state change(%d) failed, rc=%d\n",
  703. enable, rc);
  704. rc = DSI_PHY_ULPS_ERROR;
  705. goto error;
  706. }
  707. DSI_PHY_DBG(phy, "ULPS state = %d\n", enable);
  708. error:
  709. mutex_unlock(&phy->phy_lock);
  710. return rc;
  711. }
  712. /**
  713. * dsi_phy_enable() - enable DSI PHY hardware
  714. * @dsi_phy: DSI PHY handle.
  715. * @config: DSI host configuration.
  716. * @pll_source: Source PLL for PHY clock.
  717. * @skip_validation: Validation will not be performed on parameters.
  718. * @is_cont_splash_enabled: check whether continuous splash enabled.
  719. *
  720. * Validates and enables DSI PHY.
  721. *
  722. * Return: error code.
  723. */
  724. int dsi_phy_enable(struct msm_dsi_phy *phy,
  725. struct dsi_host_config *config,
  726. enum dsi_phy_pll_source pll_source,
  727. bool skip_validation,
  728. bool is_cont_splash_enabled)
  729. {
  730. int rc = 0;
  731. if (!phy || !config) {
  732. DSI_PHY_ERR(phy, "Invalid params\n");
  733. return -EINVAL;
  734. }
  735. mutex_lock(&phy->phy_lock);
  736. if (!skip_validation)
  737. DSI_PHY_DBG(phy, "TODO: perform validation\n");
  738. memcpy(&phy->mode, &config->video_timing, sizeof(phy->mode));
  739. memcpy(&phy->cfg.lane_map, &config->lane_map, sizeof(config->lane_map));
  740. phy->data_lanes = config->common_config.data_lanes;
  741. phy->dst_format = config->common_config.dst_format;
  742. phy->cfg.pll_source = pll_source;
  743. phy->cfg.bit_clk_rate_hz = config->bit_clk_rate_hz;
  744. /**
  745. * If PHY timing parameters are not present in panel dtsi file,
  746. * then calculate them in the driver
  747. */
  748. if (!phy->cfg.is_phy_timing_present)
  749. rc = phy->hw.ops.calculate_timing_params(&phy->hw,
  750. &phy->mode,
  751. &config->common_config,
  752. &phy->cfg.timing, false);
  753. if (rc) {
  754. DSI_PHY_ERR(phy, "failed to set timing, rc=%d\n", rc);
  755. goto error;
  756. }
  757. if (!is_cont_splash_enabled) {
  758. dsi_phy_enable_hw(phy);
  759. DSI_PHY_DBG(phy, "cont splash not enabled, phy enable required\n");
  760. }
  761. phy->dsi_phy_state = DSI_PHY_ENGINE_ON;
  762. error:
  763. mutex_unlock(&phy->phy_lock);
  764. return rc;
  765. }
  766. /* update dsi phy timings for dynamic clk switch use case */
  767. int dsi_phy_update_phy_timings(struct msm_dsi_phy *phy,
  768. struct dsi_host_config *config)
  769. {
  770. int rc = 0;
  771. if (!phy || !config) {
  772. DSI_PHY_ERR(phy, "invalid argument\n");
  773. return -EINVAL;
  774. }
  775. memcpy(&phy->mode, &config->video_timing, sizeof(phy->mode));
  776. rc = phy->hw.ops.calculate_timing_params(&phy->hw, &phy->mode,
  777. &config->common_config,
  778. &phy->cfg.timing, true);
  779. if (rc)
  780. DSI_PHY_ERR(phy, "failed to calculate phy timings %d\n", rc);
  781. return rc;
  782. }
  783. int dsi_phy_lane_reset(struct msm_dsi_phy *phy)
  784. {
  785. int ret = 0;
  786. if (!phy)
  787. return ret;
  788. mutex_lock(&phy->phy_lock);
  789. if (phy->hw.ops.phy_lane_reset)
  790. ret = phy->hw.ops.phy_lane_reset(&phy->hw);
  791. mutex_unlock(&phy->phy_lock);
  792. return ret;
  793. }
  794. /**
  795. * dsi_phy_disable() - disable DSI PHY hardware.
  796. * @phy: DSI PHY handle.
  797. *
  798. * Return: error code.
  799. */
  800. int dsi_phy_disable(struct msm_dsi_phy *phy)
  801. {
  802. int rc = 0;
  803. if (!phy) {
  804. DSI_PHY_ERR(phy, "Invalid params\n");
  805. return -EINVAL;
  806. }
  807. mutex_lock(&phy->phy_lock);
  808. dsi_phy_disable_hw(phy);
  809. phy->dsi_phy_state = DSI_PHY_ENGINE_OFF;
  810. mutex_unlock(&phy->phy_lock);
  811. return rc;
  812. }
  813. /**
  814. * dsi_phy_set_clamp_state() - configure clamps for DSI lanes
  815. * @phy: DSI PHY handle.
  816. * @enable: boolean to specify clamp enable/disable.
  817. *
  818. * Return: error code.
  819. */
  820. int dsi_phy_set_clamp_state(struct msm_dsi_phy *phy, bool enable)
  821. {
  822. if (!phy)
  823. return -EINVAL;
  824. DSI_PHY_DBG(phy, "enable=%d\n", enable);
  825. if (phy->hw.ops.clamp_ctrl)
  826. phy->hw.ops.clamp_ctrl(&phy->hw, enable);
  827. return 0;
  828. }
  829. /**
  830. * dsi_phy_idle_ctrl() - enable/disable DSI PHY during idle screen
  831. * @phy: DSI PHY handle
  832. * @enable: boolean to specify PHY enable/disable.
  833. *
  834. * Return: error code.
  835. */
  836. int dsi_phy_idle_ctrl(struct msm_dsi_phy *phy, bool enable)
  837. {
  838. if (!phy) {
  839. DSI_PHY_ERR(phy, "Invalid params\n");
  840. return -EINVAL;
  841. }
  842. DSI_PHY_DBG(phy, "enable=%d\n", enable);
  843. mutex_lock(&phy->phy_lock);
  844. if (enable) {
  845. if (phy->hw.ops.phy_idle_on)
  846. phy->hw.ops.phy_idle_on(&phy->hw, &phy->cfg);
  847. if (phy->hw.ops.regulator_enable)
  848. phy->hw.ops.regulator_enable(&phy->hw,
  849. &phy->cfg.regulators);
  850. if (phy->hw.ops.enable)
  851. phy->hw.ops.enable(&phy->hw, &phy->cfg);
  852. phy->dsi_phy_state = DSI_PHY_ENGINE_ON;
  853. } else {
  854. phy->dsi_phy_state = DSI_PHY_ENGINE_OFF;
  855. if (phy->hw.ops.disable)
  856. phy->hw.ops.disable(&phy->hw, &phy->cfg);
  857. if (phy->hw.ops.phy_idle_off)
  858. phy->hw.ops.phy_idle_off(&phy->hw);
  859. }
  860. mutex_unlock(&phy->phy_lock);
  861. return 0;
  862. }
  863. /**
  864. * dsi_phy_set_clk_freq() - set DSI PHY clock frequency setting
  865. * @phy: DSI PHY handle
  866. * @clk_freq: link clock frequency
  867. *
  868. * Return: error code.
  869. */
  870. int dsi_phy_set_clk_freq(struct msm_dsi_phy *phy,
  871. struct link_clk_freq *clk_freq)
  872. {
  873. if (!phy || !clk_freq) {
  874. DSI_PHY_ERR(phy, "Invalid params\n");
  875. return -EINVAL;
  876. }
  877. phy->regulator_required = clk_freq->byte_clk_rate >
  878. (phy->regulator_min_datarate_bps / BITS_PER_BYTE);
  879. /*
  880. * DSI PLL needs 0p9 LDO1A for Powering DSI PLL block.
  881. * PLL driver can vote for this regulator in PLL driver file, but for
  882. * the usecase where we come out of idle(static screen), if PLL and
  883. * PHY vote for regulator ,there will be performance delays as both
  884. * votes go through RPM to enable regulators.
  885. */
  886. phy->regulator_required = true;
  887. DSI_PHY_DBG(phy, "lane_datarate=%u min_datarate=%u required=%d\n",
  888. clk_freq->byte_clk_rate * BITS_PER_BYTE,
  889. phy->regulator_min_datarate_bps,
  890. phy->regulator_required);
  891. return 0;
  892. }
  893. /**
  894. * dsi_phy_set_timing_params() - timing parameters for the panel
  895. * @phy: DSI PHY handle
  896. * @timing: array holding timing params.
  897. * @size: size of the array.
  898. * @commit: boolean to indicate if programming PHY HW registers is
  899. * required
  900. *
  901. * When PHY timing calculator is not implemented, this array will be used to
  902. * pass PHY timing information.
  903. *
  904. * Return: error code.
  905. */
  906. int dsi_phy_set_timing_params(struct msm_dsi_phy *phy,
  907. u32 *timing, u32 size, bool commit)
  908. {
  909. int rc = 0;
  910. if (!phy || !timing || !size) {
  911. DSI_PHY_ERR(phy, "Invalid params\n");
  912. return -EINVAL;
  913. }
  914. mutex_lock(&phy->phy_lock);
  915. if (phy->hw.ops.phy_timing_val)
  916. rc = phy->hw.ops.phy_timing_val(&phy->cfg.timing, timing, size);
  917. if (!rc)
  918. phy->cfg.is_phy_timing_present = true;
  919. if (phy->hw.ops.commit_phy_timing && commit)
  920. phy->hw.ops.commit_phy_timing(&phy->hw, &phy->cfg.timing);
  921. mutex_unlock(&phy->phy_lock);
  922. return rc;
  923. }
  924. /**
  925. * dsi_phy_conv_phy_to_logical_lane() - Convert physical to logical lane
  926. * @lane_map: logical lane
  927. * @phy_lane: physical lane
  928. *
  929. * Return: Error code on failure. Lane number on success.
  930. */
  931. int dsi_phy_conv_phy_to_logical_lane(
  932. struct dsi_lane_map *lane_map, enum dsi_phy_data_lanes phy_lane)
  933. {
  934. int i = 0;
  935. if (phy_lane > DSI_PHYSICAL_LANE_3)
  936. return -EINVAL;
  937. for (i = DSI_LOGICAL_LANE_0; i < (DSI_LANE_MAX - 1); i++) {
  938. if (lane_map->lane_map_v2[i] == phy_lane)
  939. break;
  940. }
  941. return i;
  942. }
  943. /**
  944. * dsi_phy_conv_logical_to_phy_lane() - Convert logical to physical lane
  945. * @lane_map: physical lane
  946. * @lane: logical lane
  947. *
  948. * Return: Error code on failure. Lane number on success.
  949. */
  950. int dsi_phy_conv_logical_to_phy_lane(
  951. struct dsi_lane_map *lane_map, enum dsi_logical_lane lane)
  952. {
  953. int i = 0;
  954. if (lane > (DSI_LANE_MAX - 1))
  955. return -EINVAL;
  956. for (i = DSI_LOGICAL_LANE_0; i < (DSI_LANE_MAX - 1); i++) {
  957. if (BIT(i) == lane_map->lane_map_v2[lane])
  958. break;
  959. }
  960. return i;
  961. }
  962. /**
  963. * dsi_phy_config_dynamic_refresh() - Configure dynamic refresh registers
  964. * @phy: DSI PHY handle
  965. * @delay: pipe delays for dynamic refresh
  966. * @is_master: Boolean to indicate if for master or slave.
  967. */
  968. void dsi_phy_config_dynamic_refresh(struct msm_dsi_phy *phy,
  969. struct dsi_dyn_clk_delay *delay,
  970. bool is_master)
  971. {
  972. struct dsi_phy_cfg *cfg;
  973. if (!phy)
  974. return;
  975. mutex_lock(&phy->phy_lock);
  976. cfg = &phy->cfg;
  977. if (phy->hw.ops.dyn_refresh_ops.dyn_refresh_config)
  978. phy->hw.ops.dyn_refresh_ops.dyn_refresh_config(&phy->hw, cfg,
  979. is_master);
  980. if (phy->hw.ops.dyn_refresh_ops.dyn_refresh_pipe_delay)
  981. phy->hw.ops.dyn_refresh_ops.dyn_refresh_pipe_delay(
  982. &phy->hw, delay);
  983. mutex_unlock(&phy->phy_lock);
  984. }
  985. /**
  986. * dsi_phy_dynamic_refresh_trigger() - trigger dynamic refresh
  987. * @phy: DSI PHY handle
  988. * @is_master: Boolean to indicate if for master or slave.
  989. */
  990. void dsi_phy_dynamic_refresh_trigger(struct msm_dsi_phy *phy, bool is_master)
  991. {
  992. u32 off;
  993. if (!phy)
  994. return;
  995. mutex_lock(&phy->phy_lock);
  996. /*
  997. * program PLL_SWI_INTF_SEL and SW_TRIGGER bit only for
  998. * master and program SYNC_MODE bit only for slave.
  999. */
  1000. if (is_master)
  1001. off = BIT(DYN_REFRESH_INTF_SEL) | BIT(DYN_REFRESH_SWI_CTRL) |
  1002. BIT(DYN_REFRESH_SW_TRIGGER);
  1003. else
  1004. off = BIT(DYN_REFRESH_SYNC_MODE) | BIT(DYN_REFRESH_SWI_CTRL);
  1005. if (phy->hw.ops.dyn_refresh_ops.dyn_refresh_helper)
  1006. phy->hw.ops.dyn_refresh_ops.dyn_refresh_helper(&phy->hw, off);
  1007. mutex_unlock(&phy->phy_lock);
  1008. }
  1009. /**
  1010. * dsi_phy_cache_phy_timings - cache the phy timings calculated as part of
  1011. * dynamic refresh.
  1012. * @phy: DSI PHY Handle.
  1013. * @dst: Pointer to cache location.
  1014. * @size: Number of phy lane settings.
  1015. */
  1016. int dsi_phy_dyn_refresh_cache_phy_timings(struct msm_dsi_phy *phy, u32 *dst,
  1017. u32 size)
  1018. {
  1019. int rc = 0;
  1020. if (!phy || !dst || !size)
  1021. return -EINVAL;
  1022. if (phy->hw.ops.dyn_refresh_ops.cache_phy_timings)
  1023. rc = phy->hw.ops.dyn_refresh_ops.cache_phy_timings(
  1024. &phy->cfg.timing, dst, size);
  1025. if (rc)
  1026. DSI_PHY_ERR(phy, "failed to cache phy timings %d\n", rc);
  1027. return rc;
  1028. }
  1029. /**
  1030. * dsi_phy_dynamic_refresh_clear() - clear dynamic refresh config
  1031. * @phy: DSI PHY handle
  1032. */
  1033. void dsi_phy_dynamic_refresh_clear(struct msm_dsi_phy *phy)
  1034. {
  1035. if (!phy)
  1036. return;
  1037. mutex_lock(&phy->phy_lock);
  1038. if (phy->hw.ops.dyn_refresh_ops.dyn_refresh_helper)
  1039. phy->hw.ops.dyn_refresh_ops.dyn_refresh_helper(&phy->hw, 0);
  1040. mutex_unlock(&phy->phy_lock);
  1041. }
  1042. /**
  1043. * dsi_phy_set_continuous_clk() - set/unset force clock lane HS request
  1044. * @phy: DSI PHY handle
  1045. * @enable: variable to control continuous clock
  1046. */
  1047. void dsi_phy_set_continuous_clk(struct msm_dsi_phy *phy, bool enable)
  1048. {
  1049. if (!phy)
  1050. return;
  1051. mutex_lock(&phy->phy_lock);
  1052. if (phy->hw.ops.set_continuous_clk)
  1053. phy->hw.ops.set_continuous_clk(&phy->hw, enable);
  1054. else
  1055. DSI_PHY_WARN(phy, "set_continuous_clk ops not present\n");
  1056. mutex_unlock(&phy->phy_lock);
  1057. }
  1058. void dsi_phy_drv_register(void)
  1059. {
  1060. platform_driver_register(&dsi_phy_platform_driver);
  1061. }
  1062. void dsi_phy_drv_unregister(void)
  1063. {
  1064. platform_driver_unregister(&dsi_phy_platform_driver);
  1065. }