dsi_phy_hw_v4_0.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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. bool less_than_1500_mhz = false;
  153. u32 vreg_ctrl_0 = 0;
  154. u32 glbl_str_swi_cal_sel_ctrl = 0;
  155. u32 glbl_hstx_str_ctrl_0 = 0;
  156. if (dsi_phy_hw_v4_0_is_pll_on(phy))
  157. pr_warn("PLL turned on before configuring PHY\n");
  158. /* wait for REFGEN READY */
  159. rc = readl_poll_timeout_atomic(phy->base + DSIPHY_CMN_PHY_STATUS,
  160. status, (status & BIT(0)), delay_us, timeout_us);
  161. if (rc) {
  162. pr_err("Ref gen not ready. Aborting\n");
  163. return;
  164. }
  165. if (phy->version == DSI_PHY_VERSION_4_1) {
  166. vreg_ctrl_0 = 0x58;
  167. glbl_str_swi_cal_sel_ctrl = 0x00;
  168. glbl_hstx_str_ctrl_0 = 0x88;
  169. } else {
  170. /* Alter PHY configurations if data rate less than 1.5GHZ*/
  171. if (cfg->bit_clk_rate_hz < 1500000000)
  172. less_than_1500_mhz = true;
  173. vreg_ctrl_0 = less_than_1500_mhz ? 0x5B : 0x59;
  174. glbl_str_swi_cal_sel_ctrl = less_than_1500_mhz ? 0x03 : 0x00;
  175. glbl_hstx_str_ctrl_0 = less_than_1500_mhz ? 0x66 : 0x88;
  176. }
  177. /* de-assert digital and pll power down */
  178. data = BIT(6) | BIT(5);
  179. DSI_W32(phy, DSIPHY_CMN_CTRL_0, data);
  180. /* Assert PLL core reset */
  181. DSI_W32(phy, DSIPHY_CMN_PLL_CNTRL, 0x00);
  182. /* turn off resync FIFO */
  183. DSI_W32(phy, DSIPHY_CMN_RBUF_CTRL, 0x00);
  184. /* Configure PHY lane swap */
  185. dsi_phy_hw_v4_0_lane_swap_config(phy, &cfg->lane_map);
  186. /* Enable LDO */
  187. DSI_W32(phy, DSIPHY_CMN_VREG_CTRL_0, vreg_ctrl_0);
  188. DSI_W32(phy, DSIPHY_CMN_VREG_CTRL_1, 0x5c);
  189. DSI_W32(phy, DSIPHY_CMN_CTRL_3, 0x00);
  190. DSI_W32(phy, DSIPHY_CMN_GLBL_STR_SWI_CAL_SEL_CTRL,
  191. glbl_str_swi_cal_sel_ctrl);
  192. DSI_W32(phy, DSIPHY_CMN_GLBL_HSTX_STR_CTRL_0, glbl_hstx_str_ctrl_0);
  193. DSI_W32(phy, DSIPHY_CMN_GLBL_PEMPH_CTRL_0, 0x00);
  194. DSI_W32(phy, DSIPHY_CMN_GLBL_RESCODE_OFFSET_TOP_CTRL, 0x03);
  195. DSI_W32(phy, DSIPHY_CMN_GLBL_RESCODE_OFFSET_BOT_CTRL, 0x3c);
  196. DSI_W32(phy, DSIPHY_CMN_GLBL_LPTX_STR_CTRL, 0x55);
  197. /* Remove power down from all blocks */
  198. DSI_W32(phy, DSIPHY_CMN_CTRL_0, 0x7f);
  199. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL0, 0x1F);
  200. /* Select full-rate mode */
  201. DSI_W32(phy, DSIPHY_CMN_CTRL_2, 0x40);
  202. switch (cfg->pll_source) {
  203. case DSI_PLL_SOURCE_STANDALONE:
  204. case DSI_PLL_SOURCE_NATIVE:
  205. data = 0x0; /* internal PLL */
  206. break;
  207. case DSI_PLL_SOURCE_NON_NATIVE:
  208. data = 0x1; /* external PLL */
  209. break;
  210. default:
  211. break;
  212. }
  213. DSI_W32(phy, DSIPHY_CMN_CLK_CFG1, (data << 2)); /* set PLL src */
  214. /* DSI PHY timings */
  215. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_0, timing->lane_v4[0]);
  216. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_1, timing->lane_v4[1]);
  217. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_2, timing->lane_v4[2]);
  218. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_3, timing->lane_v4[3]);
  219. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_4, timing->lane_v4[4]);
  220. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_5, timing->lane_v4[5]);
  221. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_6, timing->lane_v4[6]);
  222. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_7, timing->lane_v4[7]);
  223. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_8, timing->lane_v4[8]);
  224. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_9, timing->lane_v4[9]);
  225. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_10, timing->lane_v4[10]);
  226. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_11, timing->lane_v4[11]);
  227. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_12, timing->lane_v4[12]);
  228. DSI_W32(phy, DSIPHY_CMN_TIMING_CTRL_13, timing->lane_v4[13]);
  229. /* DSI lane settings */
  230. dsi_phy_hw_v4_0_lane_settings(phy, cfg);
  231. pr_debug("[DSI_%d]Phy enabled\n", phy->index);
  232. }
  233. /**
  234. * disable() - Disable PHY hardware
  235. * @phy: Pointer to DSI PHY hardware object.
  236. */
  237. void dsi_phy_hw_v4_0_disable(struct dsi_phy_hw *phy,
  238. struct dsi_phy_cfg *cfg)
  239. {
  240. u32 data = 0;
  241. if (dsi_phy_hw_v4_0_is_pll_on(phy))
  242. pr_warn("Turning OFF PHY while PLL is on\n");
  243. dsi_phy_hw_v4_0_config_lpcdrx(phy, cfg, false);
  244. data = DSI_R32(phy, DSIPHY_CMN_CTRL_0);
  245. /* disable all lanes */
  246. data &= ~0x1F;
  247. DSI_W32(phy, DSIPHY_CMN_CTRL_0, data);
  248. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL0, 0);
  249. /* Turn off all PHY blocks */
  250. DSI_W32(phy, DSIPHY_CMN_CTRL_0, 0x00);
  251. /* make sure phy is turned off */
  252. wmb();
  253. pr_debug("[DSI_%d]Phy disabled\n", phy->index);
  254. }
  255. void dsi_phy_hw_v4_0_toggle_resync_fifo(struct dsi_phy_hw *phy)
  256. {
  257. DSI_W32(phy, DSIPHY_CMN_RBUF_CTRL, 0x00);
  258. /* ensure that the FIFO is off */
  259. wmb();
  260. DSI_W32(phy, DSIPHY_CMN_RBUF_CTRL, 0x1);
  261. /* ensure that the FIFO is toggled back on */
  262. wmb();
  263. }
  264. void dsi_phy_hw_v4_0_reset_clk_en_sel(struct dsi_phy_hw *phy)
  265. {
  266. u32 data = 0;
  267. /*Turning off CLK_EN_SEL after retime buffer sync */
  268. data = DSI_R32(phy, DSIPHY_CMN_CLK_CFG1);
  269. data &= ~BIT(4);
  270. DSI_W32(phy, DSIPHY_CMN_CLK_CFG1, data);
  271. /* ensure that clk_en_sel bit is turned off */
  272. wmb();
  273. }
  274. int dsi_phy_hw_v4_0_wait_for_lane_idle(
  275. struct dsi_phy_hw *phy, u32 lanes)
  276. {
  277. int rc = 0, val = 0;
  278. u32 stop_state_mask = 0;
  279. u32 const sleep_us = 10;
  280. u32 const timeout_us = 100;
  281. stop_state_mask = BIT(4); /* clock lane */
  282. if (lanes & DSI_DATA_LANE_0)
  283. stop_state_mask |= BIT(0);
  284. if (lanes & DSI_DATA_LANE_1)
  285. stop_state_mask |= BIT(1);
  286. if (lanes & DSI_DATA_LANE_2)
  287. stop_state_mask |= BIT(2);
  288. if (lanes & DSI_DATA_LANE_3)
  289. stop_state_mask |= BIT(3);
  290. pr_debug("%s: polling for lanes to be in stop state, mask=0x%08x\n",
  291. __func__, stop_state_mask);
  292. rc = readl_poll_timeout(phy->base + DSIPHY_CMN_LANE_STATUS1, val,
  293. ((val & stop_state_mask) == stop_state_mask),
  294. sleep_us, timeout_us);
  295. if (rc) {
  296. pr_err("%s: lanes not in stop state, LANE_STATUS=0x%08x\n",
  297. __func__, val);
  298. return rc;
  299. }
  300. return 0;
  301. }
  302. void dsi_phy_hw_v4_0_ulps_request(struct dsi_phy_hw *phy,
  303. struct dsi_phy_cfg *cfg, u32 lanes)
  304. {
  305. u32 reg = 0;
  306. if (lanes & DSI_CLOCK_LANE)
  307. reg = BIT(4);
  308. if (lanes & DSI_DATA_LANE_0)
  309. reg |= BIT(0);
  310. if (lanes & DSI_DATA_LANE_1)
  311. reg |= BIT(1);
  312. if (lanes & DSI_DATA_LANE_2)
  313. reg |= BIT(2);
  314. if (lanes & DSI_DATA_LANE_3)
  315. reg |= BIT(3);
  316. if (cfg->force_clk_lane_hs)
  317. reg |= BIT(5) | BIT(6);
  318. /*
  319. * ULPS entry request. Wait for short time to make sure
  320. * that the lanes enter ULPS. Recommended as per HPG.
  321. */
  322. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL1, reg);
  323. usleep_range(100, 110);
  324. /* disable LPRX and CDRX */
  325. dsi_phy_hw_v4_0_config_lpcdrx(phy, cfg, false);
  326. pr_debug("[DSI_PHY%d] ULPS requested for lanes 0x%x\n", phy->index,
  327. lanes);
  328. }
  329. int dsi_phy_hw_v4_0_lane_reset(struct dsi_phy_hw *phy)
  330. {
  331. int ret = 0, loop = 10, u_dly = 200;
  332. u32 ln_status = 0;
  333. while ((ln_status != 0x1f) && loop) {
  334. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL3, 0x1f);
  335. wmb(); /* ensure register is committed */
  336. loop--;
  337. udelay(u_dly);
  338. ln_status = DSI_R32(phy, DSIPHY_CMN_LANE_STATUS1);
  339. pr_debug("trial no: %d\n", loop);
  340. }
  341. if (!loop)
  342. pr_debug("could not reset phy lanes\n");
  343. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL3, 0x0);
  344. wmb(); /* ensure register is committed */
  345. return ret;
  346. }
  347. void dsi_phy_hw_v4_0_ulps_exit(struct dsi_phy_hw *phy,
  348. struct dsi_phy_cfg *cfg, u32 lanes)
  349. {
  350. u32 reg = 0;
  351. if (lanes & DSI_CLOCK_LANE)
  352. reg = BIT(4);
  353. if (lanes & DSI_DATA_LANE_0)
  354. reg |= BIT(0);
  355. if (lanes & DSI_DATA_LANE_1)
  356. reg |= BIT(1);
  357. if (lanes & DSI_DATA_LANE_2)
  358. reg |= BIT(2);
  359. if (lanes & DSI_DATA_LANE_3)
  360. reg |= BIT(3);
  361. /* enable LPRX and CDRX */
  362. dsi_phy_hw_v4_0_config_lpcdrx(phy, cfg, true);
  363. /* ULPS exit request */
  364. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL2, reg);
  365. usleep_range(1000, 1010);
  366. /* Clear ULPS request flags on all lanes */
  367. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL1, 0);
  368. /* Clear ULPS exit flags on all lanes */
  369. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL2, 0);
  370. /*
  371. * Sometimes when exiting ULPS, it is possible that some DSI
  372. * lanes are not in the stop state which could lead to DSI
  373. * commands not going through. To avoid this, force the lanes
  374. * to be in stop state.
  375. */
  376. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL3, reg);
  377. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL3, 0);
  378. usleep_range(100, 110);
  379. if (cfg->force_clk_lane_hs) {
  380. reg = BIT(5) | BIT(6);
  381. DSI_W32(phy, DSIPHY_CMN_LANE_CTRL1, reg);
  382. }
  383. }
  384. u32 dsi_phy_hw_v4_0_get_lanes_in_ulps(struct dsi_phy_hw *phy)
  385. {
  386. u32 lanes = 0;
  387. lanes = DSI_R32(phy, DSIPHY_CMN_LANE_STATUS0);
  388. pr_debug("[DSI_PHY%d] lanes in ulps = 0x%x\n", phy->index, lanes);
  389. return lanes;
  390. }
  391. bool dsi_phy_hw_v4_0_is_lanes_in_ulps(u32 lanes, u32 ulps_lanes)
  392. {
  393. if (lanes & ulps_lanes)
  394. return false;
  395. return true;
  396. }
  397. int dsi_phy_hw_timing_val_v4_0(struct dsi_phy_per_lane_cfgs *timing_cfg,
  398. u32 *timing_val, u32 size)
  399. {
  400. int i = 0;
  401. if (size != DSI_PHY_TIMING_V4_SIZE) {
  402. pr_err("Unexpected timing array size %d\n", size);
  403. return -EINVAL;
  404. }
  405. for (i = 0; i < size; i++)
  406. timing_cfg->lane_v4[i] = timing_val[i];
  407. return 0;
  408. }