dsi_phy_hw_v4_0.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #define pr_fmt(fmt) "dsi-phy-hw-v4: %s:" fmt, __func__
  6. #include <linux/math64.h>
  7. #include <linux/delay.h>
  8. #include <linux/iopoll.h>
  9. #include "dsi_hw.h"
  10. #include "dsi_phy_hw.h"
  11. #include "dsi_catalog.h"
  12. #define DSIPHY_CMN_REVISION_ID0 0x000
  13. #define DSIPHY_CMN_REVISION_ID1 0x004
  14. #define DSIPHY_CMN_REVISION_ID2 0x008
  15. #define DSIPHY_CMN_REVISION_ID3 0x00C
  16. #define DSIPHY_CMN_CLK_CFG0 0x010
  17. #define DSIPHY_CMN_CLK_CFG1 0x014
  18. #define DSIPHY_CMN_GLBL_CTRL 0x018
  19. #define DSIPHY_CMN_RBUF_CTRL 0x01C
  20. #define DSIPHY_CMN_VREG_CTRL_0 0x020
  21. #define DSIPHY_CMN_CTRL_0 0x024
  22. #define DSIPHY_CMN_CTRL_1 0x028
  23. #define DSIPHY_CMN_CTRL_2 0x02C
  24. #define DSIPHY_CMN_CTRL_3 0x030
  25. #define DSIPHY_CMN_LANE_CFG0 0x034
  26. #define DSIPHY_CMN_LANE_CFG1 0x038
  27. #define DSIPHY_CMN_PLL_CNTRL 0x03C
  28. #define DSIPHY_CMN_DPHY_SOT 0x040
  29. #define DSIPHY_CMN_LANE_CTRL0 0x0A0
  30. #define DSIPHY_CMN_LANE_CTRL1 0x0A4
  31. #define DSIPHY_CMN_LANE_CTRL2 0x0A8
  32. #define DSIPHY_CMN_LANE_CTRL3 0x0AC
  33. #define DSIPHY_CMN_LANE_CTRL4 0x0B0
  34. #define DSIPHY_CMN_TIMING_CTRL_0 0x0B4
  35. #define DSIPHY_CMN_TIMING_CTRL_1 0x0B8
  36. #define DSIPHY_CMN_TIMING_CTRL_2 0x0Bc
  37. #define DSIPHY_CMN_TIMING_CTRL_3 0x0C0
  38. #define DSIPHY_CMN_TIMING_CTRL_4 0x0C4
  39. #define DSIPHY_CMN_TIMING_CTRL_5 0x0C8
  40. #define DSIPHY_CMN_TIMING_CTRL_6 0x0CC
  41. #define DSIPHY_CMN_TIMING_CTRL_7 0x0D0
  42. #define DSIPHY_CMN_TIMING_CTRL_8 0x0D4
  43. #define DSIPHY_CMN_TIMING_CTRL_9 0x0D8
  44. #define DSIPHY_CMN_TIMING_CTRL_10 0x0DC
  45. #define DSIPHY_CMN_TIMING_CTRL_11 0x0E0
  46. #define DSIPHY_CMN_TIMING_CTRL_12 0x0E4
  47. #define DSIPHY_CMN_TIMING_CTRL_13 0x0E8
  48. #define DSIPHY_CMN_GLBL_HSTX_STR_CTRL_0 0x0EC
  49. #define DSIPHY_CMN_GLBL_HSTX_STR_CTRL_1 0x0F0
  50. #define DSIPHY_CMN_GLBL_RESCODE_OFFSET_TOP_CTRL 0x0F4
  51. #define DSIPHY_CMN_GLBL_RESCODE_OFFSET_BOT_CTRL 0x0F8
  52. #define DSIPHY_CMN_GLBL_RESCODE_OFFSET_MID_CTRL 0x0FC
  53. #define DSIPHY_CMN_GLBL_LPTX_STR_CTRL 0x100
  54. #define DSIPHY_CMN_GLBL_PEMPH_CTRL_0 0x104
  55. #define DSIPHY_CMN_GLBL_PEMPH_CTRL_1 0x108
  56. #define DSIPHY_CMN_GLBL_STR_SWI_CAL_SEL_CTRL 0x10C
  57. #define DSIPHY_CMN_VREG_CTRL_1 0x110
  58. #define DSIPHY_CMN_CTRL_4 0x114
  59. #define DSIPHY_CMN_PHY_STATUS 0x140
  60. #define DSIPHY_CMN_LANE_STATUS0 0x148
  61. #define DSIPHY_CMN_LANE_STATUS1 0x14C
  62. /* n = 0..3 for data lanes and n = 4 for clock lane */
  63. #define DSIPHY_LNX_CFG0(n) (0x200 + (0x80 * (n)))
  64. #define DSIPHY_LNX_CFG1(n) (0x204 + (0x80 * (n)))
  65. #define DSIPHY_LNX_CFG2(n) (0x208 + (0x80 * (n)))
  66. #define DSIPHY_LNX_TEST_DATAPATH(n) (0x20C + (0x80 * (n)))
  67. #define DSIPHY_LNX_PIN_SWAP(n) (0x210 + (0x80 * (n)))
  68. #define DSIPHY_LNX_LPRX_CTRL(n) (0x214 + (0x80 * (n)))
  69. #define DSIPHY_LNX_TX_DCTRL(n) (0x218 + (0x80 * (n)))
  70. static int dsi_phy_hw_v4_0_is_pll_on(struct dsi_phy_hw *phy)
  71. {
  72. u32 data = 0;
  73. data = DSI_R32(phy, DSIPHY_CMN_PLL_CNTRL);
  74. mb(); /*make sure read happened */
  75. return (data & BIT(0));
  76. }
  77. static void dsi_phy_hw_v4_0_config_lpcdrx(struct dsi_phy_hw *phy,
  78. struct dsi_phy_cfg *cfg, bool enable)
  79. {
  80. int phy_lane_0 = dsi_phy_conv_logical_to_phy_lane(&cfg->lane_map,
  81. DSI_LOGICAL_LANE_0);
  82. /*
  83. * LPRX and CDRX need to enabled only for physical data lane
  84. * corresponding to the logical data lane 0
  85. */
  86. if (enable)
  87. DSI_W32(phy, DSIPHY_LNX_LPRX_CTRL(phy_lane_0),
  88. cfg->strength.lane[phy_lane_0][1]);
  89. else
  90. DSI_W32(phy, DSIPHY_LNX_LPRX_CTRL(phy_lane_0), 0);
  91. }
  92. static void dsi_phy_hw_v4_0_lane_swap_config(struct dsi_phy_hw *phy,
  93. struct dsi_lane_map *lane_map)
  94. {
  95. DSI_W32(phy, DSIPHY_CMN_LANE_CFG0,
  96. (lane_map->lane_map_v2[DSI_LOGICAL_LANE_0] |
  97. (lane_map->lane_map_v2[DSI_LOGICAL_LANE_1] << 4)));
  98. DSI_W32(phy, DSIPHY_CMN_LANE_CFG1,
  99. (lane_map->lane_map_v2[DSI_LOGICAL_LANE_2] |
  100. (lane_map->lane_map_v2[DSI_LOGICAL_LANE_3] << 4)));
  101. }
  102. static void dsi_phy_hw_v4_0_lane_settings(struct dsi_phy_hw *phy,
  103. struct dsi_phy_cfg *cfg)
  104. {
  105. int i;
  106. u8 tx_dctrl_v4[] = {0x00, 0x00, 0x00, 0x04, 0x01};
  107. u8 tx_dctrl_v4_1[] = {0x40, 0x40, 0x40, 0x46, 0x41};
  108. u8 *tx_dctrl;
  109. if (phy->version == DSI_PHY_VERSION_4_1)
  110. tx_dctrl = &tx_dctrl_v4_1[0];
  111. else
  112. tx_dctrl = &tx_dctrl_v4[0];
  113. /* Strength ctrl settings */
  114. for (i = DSI_LOGICAL_LANE_0; i < DSI_LANE_MAX; i++) {
  115. /*
  116. * Disable LPRX and CDRX for all lanes. And later on, it will
  117. * be only enabled for the physical data lane corresponding
  118. * to the logical data lane 0
  119. */
  120. DSI_W32(phy, DSIPHY_LNX_LPRX_CTRL(i), 0);
  121. DSI_W32(phy, DSIPHY_LNX_PIN_SWAP(i), 0x0);
  122. }
  123. dsi_phy_hw_v4_0_config_lpcdrx(phy, cfg, true);
  124. /* other settings */
  125. for (i = DSI_LOGICAL_LANE_0; i < DSI_LANE_MAX; i++) {
  126. DSI_W32(phy, DSIPHY_LNX_CFG0(i), cfg->lanecfg.lane[i][0]);
  127. DSI_W32(phy, DSIPHY_LNX_CFG1(i), cfg->lanecfg.lane[i][1]);
  128. DSI_W32(phy, DSIPHY_LNX_CFG2(i), cfg->lanecfg.lane[i][2]);
  129. DSI_W32(phy, DSIPHY_LNX_TX_DCTRL(i), tx_dctrl[i]);
  130. }
  131. if (cfg->force_clk_lane_hs) {
  132. u32 reg = DSI_R32(phy, DSIPHY_CMN_LANE_CTRL1);
  133. reg |= BIT(5) | BIT(6);
  134. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL1, reg);
  135. }
  136. }
  137. /**
  138. * enable() - Enable PHY hardware
  139. * @phy: Pointer to DSI PHY hardware object.
  140. * @cfg: Per lane configurations for timing, strength and lane
  141. * configurations.
  142. */
  143. void dsi_phy_hw_v4_0_enable(struct dsi_phy_hw *phy,
  144. struct dsi_phy_cfg *cfg)
  145. {
  146. int rc = 0;
  147. u32 status;
  148. u32 const delay_us = 5;
  149. u32 const timeout_us = 1000;
  150. struct dsi_phy_per_lane_cfgs *timing = &cfg->timing;
  151. u32 data;
  152. u32 minor_ver = 0;
  153. bool less_than_1500_mhz = false;
  154. u32 vreg_ctrl_0 = 0;
  155. u32 glbl_str_swi_cal_sel_ctrl = 0;
  156. u32 glbl_hstx_str_ctrl_0 = 0;
  157. if (dsi_phy_hw_v4_0_is_pll_on(phy))
  158. pr_warn("PLL turned on before configuring PHY\n");
  159. /* wait for REFGEN READY */
  160. rc = readl_poll_timeout_atomic(phy->base + DSIPHY_CMN_PHY_STATUS,
  161. status, (status & BIT(0)), delay_us, timeout_us);
  162. if (rc) {
  163. pr_err("Ref gen not ready. Aborting\n");
  164. return;
  165. }
  166. if (phy->version == DSI_PHY_VERSION_4_1) {
  167. vreg_ctrl_0 = 0x58;
  168. glbl_str_swi_cal_sel_ctrl = 0x00;
  169. glbl_hstx_str_ctrl_0 = 0x88;
  170. } else {
  171. /* Alter PHY configurations if data rate less than 1.5GHZ*/
  172. if (cfg->bit_clk_rate_hz < 1500000000)
  173. less_than_1500_mhz = true;
  174. vreg_ctrl_0 = less_than_1500_mhz ? 0x5B : 0x59;
  175. glbl_str_swi_cal_sel_ctrl = less_than_1500_mhz ? 0x03 : 0x00;
  176. glbl_hstx_str_ctrl_0 = less_than_1500_mhz ? 0x66 : 0x88;
  177. }
  178. /* de-assert digital and pll power down */
  179. data = BIT(6) | BIT(5);
  180. DSI_W32(phy, DSIPHY_CMN_CTRL_0, data);
  181. /* Assert PLL core reset */
  182. DSI_W32(phy, DSIPHY_CMN_PLL_CNTRL, 0x00);
  183. /* turn off resync FIFO */
  184. DSI_W32(phy, DSIPHY_CMN_RBUF_CTRL, 0x00);
  185. /* program CMN_CTRL_4 for minor_ver 2 chipsets*/
  186. minor_ver = DSI_R32(phy, DSIPHY_CMN_REVISION_ID0);
  187. minor_ver = minor_ver & (0xf0);
  188. if (minor_ver == 0x20)
  189. DSI_W32(phy, DSIPHY_CMN_CTRL_4, 0x04);
  190. /* Configure PHY lane swap */
  191. dsi_phy_hw_v4_0_lane_swap_config(phy, &cfg->lane_map);
  192. /* Enable LDO */
  193. DSI_W32(phy, DSIPHY_CMN_VREG_CTRL_0, vreg_ctrl_0);
  194. DSI_W32(phy, DSIPHY_CMN_VREG_CTRL_1, 0x5c);
  195. DSI_W32(phy, DSIPHY_CMN_CTRL_3, 0x00);
  196. DSI_W32(phy, DSIPHY_CMN_GLBL_STR_SWI_CAL_SEL_CTRL,
  197. glbl_str_swi_cal_sel_ctrl);
  198. DSI_W32(phy, DSIPHY_CMN_GLBL_HSTX_STR_CTRL_0, glbl_hstx_str_ctrl_0);
  199. DSI_W32(phy, DSIPHY_CMN_GLBL_PEMPH_CTRL_0, 0x00);
  200. DSI_W32(phy, DSIPHY_CMN_GLBL_RESCODE_OFFSET_TOP_CTRL, 0x03);
  201. DSI_W32(phy, DSIPHY_CMN_GLBL_RESCODE_OFFSET_BOT_CTRL, 0x3c);
  202. DSI_W32(phy, DSIPHY_CMN_GLBL_LPTX_STR_CTRL, 0x55);
  203. /* Remove power down from all blocks */
  204. DSI_W32(phy, DSIPHY_CMN_CTRL_0, 0x7f);
  205. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL0, 0x1F);
  206. /* Select full-rate mode */
  207. DSI_W32(phy, DSIPHY_CMN_CTRL_2, 0x40);
  208. switch (cfg->pll_source) {
  209. case DSI_PLL_SOURCE_STANDALONE:
  210. case DSI_PLL_SOURCE_NATIVE:
  211. data = 0x0; /* internal PLL */
  212. break;
  213. case DSI_PLL_SOURCE_NON_NATIVE:
  214. data = 0x1; /* external PLL */
  215. break;
  216. default:
  217. break;
  218. }
  219. DSI_W32(phy, DSIPHY_CMN_CLK_CFG1, (data << 2)); /* set PLL src */
  220. /* DSI PHY timings */
  221. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_0, timing->lane_v4[0]);
  222. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_1, timing->lane_v4[1]);
  223. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_2, timing->lane_v4[2]);
  224. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_3, timing->lane_v4[3]);
  225. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_4, timing->lane_v4[4]);
  226. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_5, timing->lane_v4[5]);
  227. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_6, timing->lane_v4[6]);
  228. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_7, timing->lane_v4[7]);
  229. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_8, timing->lane_v4[8]);
  230. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_9, timing->lane_v4[9]);
  231. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_10, timing->lane_v4[10]);
  232. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_11, timing->lane_v4[11]);
  233. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_12, timing->lane_v4[12]);
  234. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_13, timing->lane_v4[13]);
  235. /* DSI lane settings */
  236. dsi_phy_hw_v4_0_lane_settings(phy, cfg);
  237. pr_debug("[DSI_%d]Phy enabled\n", phy->index);
  238. }
  239. /**
  240. * disable() - Disable PHY hardware
  241. * @phy: Pointer to DSI PHY hardware object.
  242. */
  243. void dsi_phy_hw_v4_0_disable(struct dsi_phy_hw *phy,
  244. struct dsi_phy_cfg *cfg)
  245. {
  246. u32 data = 0;
  247. if (dsi_phy_hw_v4_0_is_pll_on(phy))
  248. pr_warn("Turning OFF PHY while PLL is on\n");
  249. dsi_phy_hw_v4_0_config_lpcdrx(phy, cfg, false);
  250. data = DSI_R32(phy, DSIPHY_CMN_CTRL_0);
  251. /* disable all lanes */
  252. data &= ~0x1F;
  253. DSI_W32(phy, DSIPHY_CMN_CTRL_0, data);
  254. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL0, 0);
  255. /* Turn off all PHY blocks */
  256. DSI_W32(phy, DSIPHY_CMN_CTRL_0, 0x00);
  257. /* make sure phy is turned off */
  258. wmb();
  259. pr_debug("[DSI_%d]Phy disabled\n", phy->index);
  260. }
  261. void dsi_phy_hw_v4_0_toggle_resync_fifo(struct dsi_phy_hw *phy)
  262. {
  263. DSI_W32(phy, DSIPHY_CMN_RBUF_CTRL, 0x00);
  264. /* ensure that the FIFO is off */
  265. wmb();
  266. DSI_W32(phy, DSIPHY_CMN_RBUF_CTRL, 0x1);
  267. /* ensure that the FIFO is toggled back on */
  268. wmb();
  269. }
  270. void dsi_phy_hw_v4_0_reset_clk_en_sel(struct dsi_phy_hw *phy)
  271. {
  272. u32 data = 0;
  273. /*Turning off CLK_EN_SEL after retime buffer sync */
  274. data = DSI_R32(phy, DSIPHY_CMN_CLK_CFG1);
  275. data &= ~BIT(4);
  276. DSI_W32(phy, DSIPHY_CMN_CLK_CFG1, data);
  277. /* ensure that clk_en_sel bit is turned off */
  278. wmb();
  279. }
  280. int dsi_phy_hw_v4_0_wait_for_lane_idle(
  281. struct dsi_phy_hw *phy, u32 lanes)
  282. {
  283. int rc = 0, val = 0;
  284. u32 stop_state_mask = 0;
  285. u32 const sleep_us = 10;
  286. u32 const timeout_us = 100;
  287. stop_state_mask = BIT(4); /* clock lane */
  288. if (lanes & DSI_DATA_LANE_0)
  289. stop_state_mask |= BIT(0);
  290. if (lanes & DSI_DATA_LANE_1)
  291. stop_state_mask |= BIT(1);
  292. if (lanes & DSI_DATA_LANE_2)
  293. stop_state_mask |= BIT(2);
  294. if (lanes & DSI_DATA_LANE_3)
  295. stop_state_mask |= BIT(3);
  296. pr_debug("%s: polling for lanes to be in stop state, mask=0x%08x\n",
  297. __func__, stop_state_mask);
  298. rc = readl_poll_timeout(phy->base + DSIPHY_CMN_LANE_STATUS1, val,
  299. ((val & stop_state_mask) == stop_state_mask),
  300. sleep_us, timeout_us);
  301. if (rc) {
  302. pr_err("%s: lanes not in stop state, LANE_STATUS=0x%08x\n",
  303. __func__, val);
  304. return rc;
  305. }
  306. return 0;
  307. }
  308. void dsi_phy_hw_v4_0_ulps_request(struct dsi_phy_hw *phy,
  309. struct dsi_phy_cfg *cfg, u32 lanes)
  310. {
  311. u32 reg = 0;
  312. if (lanes & DSI_CLOCK_LANE)
  313. reg = BIT(4);
  314. if (lanes & DSI_DATA_LANE_0)
  315. reg |= BIT(0);
  316. if (lanes & DSI_DATA_LANE_1)
  317. reg |= BIT(1);
  318. if (lanes & DSI_DATA_LANE_2)
  319. reg |= BIT(2);
  320. if (lanes & DSI_DATA_LANE_3)
  321. reg |= BIT(3);
  322. if (cfg->force_clk_lane_hs)
  323. reg |= BIT(5) | BIT(6);
  324. /*
  325. * ULPS entry request. Wait for short time to make sure
  326. * that the lanes enter ULPS. Recommended as per HPG.
  327. */
  328. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL1, reg);
  329. usleep_range(100, 110);
  330. /* disable LPRX and CDRX */
  331. dsi_phy_hw_v4_0_config_lpcdrx(phy, cfg, false);
  332. pr_debug("[DSI_PHY%d] ULPS requested for lanes 0x%x\n", phy->index,
  333. lanes);
  334. }
  335. int dsi_phy_hw_v4_0_lane_reset(struct dsi_phy_hw *phy)
  336. {
  337. int ret = 0, loop = 10, u_dly = 200;
  338. u32 ln_status = 0;
  339. while ((ln_status != 0x1f) && loop) {
  340. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL3, 0x1f);
  341. wmb(); /* ensure register is committed */
  342. loop--;
  343. udelay(u_dly);
  344. ln_status = DSI_R32(phy, DSIPHY_CMN_LANE_STATUS1);
  345. pr_debug("trial no: %d\n", loop);
  346. }
  347. if (!loop)
  348. pr_debug("could not reset phy lanes\n");
  349. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL3, 0x0);
  350. wmb(); /* ensure register is committed */
  351. return ret;
  352. }
  353. void dsi_phy_hw_v4_0_ulps_exit(struct dsi_phy_hw *phy,
  354. struct dsi_phy_cfg *cfg, u32 lanes)
  355. {
  356. u32 reg = 0;
  357. if (lanes & DSI_CLOCK_LANE)
  358. reg = BIT(4);
  359. if (lanes & DSI_DATA_LANE_0)
  360. reg |= BIT(0);
  361. if (lanes & DSI_DATA_LANE_1)
  362. reg |= BIT(1);
  363. if (lanes & DSI_DATA_LANE_2)
  364. reg |= BIT(2);
  365. if (lanes & DSI_DATA_LANE_3)
  366. reg |= BIT(3);
  367. /* enable LPRX and CDRX */
  368. dsi_phy_hw_v4_0_config_lpcdrx(phy, cfg, true);
  369. /* ULPS exit request */
  370. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL2, reg);
  371. usleep_range(1000, 1010);
  372. /* Clear ULPS request flags on all lanes */
  373. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL1, 0);
  374. /* Clear ULPS exit flags on all lanes */
  375. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL2, 0);
  376. /*
  377. * Sometimes when exiting ULPS, it is possible that some DSI
  378. * lanes are not in the stop state which could lead to DSI
  379. * commands not going through. To avoid this, force the lanes
  380. * to be in stop state.
  381. */
  382. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL3, reg);
  383. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL3, 0);
  384. usleep_range(100, 110);
  385. if (cfg->force_clk_lane_hs) {
  386. reg = BIT(5) | BIT(6);
  387. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL1, reg);
  388. }
  389. }
  390. u32 dsi_phy_hw_v4_0_get_lanes_in_ulps(struct dsi_phy_hw *phy)
  391. {
  392. u32 lanes = 0;
  393. lanes = DSI_R32(phy, DSIPHY_CMN_LANE_STATUS0);
  394. pr_debug("[DSI_PHY%d] lanes in ulps = 0x%x\n", phy->index, lanes);
  395. return lanes;
  396. }
  397. bool dsi_phy_hw_v4_0_is_lanes_in_ulps(u32 lanes, u32 ulps_lanes)
  398. {
  399. if (lanes & ulps_lanes)
  400. return false;
  401. return true;
  402. }
  403. int dsi_phy_hw_timing_val_v4_0(struct dsi_phy_per_lane_cfgs *timing_cfg,
  404. u32 *timing_val, u32 size)
  405. {
  406. int i = 0;
  407. if (size != DSI_PHY_TIMING_V4_SIZE) {
  408. pr_err("Unexpected timing array size %d\n", size);
  409. return -EINVAL;
  410. }
  411. for (i = 0; i < size; i++)
  412. timing_cfg->lane_v4[i] = timing_val[i];
  413. return 0;
  414. }