cdns-dphy.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright: 2017-2018 Cadence Design Systems, Inc.
  4. */
  5. #include <linux/bitfield.h>
  6. #include <linux/bitops.h>
  7. #include <linux/clk.h>
  8. #include <linux/io.h>
  9. #include <linux/iopoll.h>
  10. #include <linux/module.h>
  11. #include <linux/of.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/reset.h>
  14. #include <linux/phy/phy.h>
  15. #include <linux/phy/phy-mipi-dphy.h>
  16. #define REG_WAKEUP_TIME_NS 800
  17. #define DPHY_PLL_RATE_HZ 108000000
  18. #define POLL_TIMEOUT_US 1000
  19. /* DPHY registers */
  20. #define DPHY_PMA_CMN(reg) (reg)
  21. #define DPHY_PMA_LCLK(reg) (0x100 + (reg))
  22. #define DPHY_PMA_LDATA(lane, reg) (0x200 + ((lane) * 0x100) + (reg))
  23. #define DPHY_PMA_RCLK(reg) (0x600 + (reg))
  24. #define DPHY_PMA_RDATA(lane, reg) (0x700 + ((lane) * 0x100) + (reg))
  25. #define DPHY_PCS(reg) (0xb00 + (reg))
  26. #define DPHY_CMN_SSM DPHY_PMA_CMN(0x20)
  27. #define DPHY_CMN_SSM_EN BIT(0)
  28. #define DPHY_CMN_SSM_CAL_WAIT_TIME GENMASK(8, 1)
  29. #define DPHY_CMN_TX_MODE_EN BIT(9)
  30. #define DPHY_CMN_PWM DPHY_PMA_CMN(0x40)
  31. #define DPHY_CMN_PWM_DIV(x) ((x) << 20)
  32. #define DPHY_CMN_PWM_LOW(x) ((x) << 10)
  33. #define DPHY_CMN_PWM_HIGH(x) (x)
  34. #define DPHY_CMN_FBDIV DPHY_PMA_CMN(0x4c)
  35. #define DPHY_CMN_FBDIV_VAL(low, high) (((high) << 11) | ((low) << 22))
  36. #define DPHY_CMN_FBDIV_FROM_REG (BIT(10) | BIT(21))
  37. #define DPHY_CMN_OPIPDIV DPHY_PMA_CMN(0x50)
  38. #define DPHY_CMN_IPDIV_FROM_REG BIT(0)
  39. #define DPHY_CMN_IPDIV(x) ((x) << 1)
  40. #define DPHY_CMN_OPDIV_FROM_REG BIT(6)
  41. #define DPHY_CMN_OPDIV(x) ((x) << 7)
  42. #define DPHY_BAND_CFG DPHY_PCS(0x0)
  43. #define DPHY_BAND_CFG_LEFT_BAND GENMASK(4, 0)
  44. #define DPHY_BAND_CFG_RIGHT_BAND GENMASK(9, 5)
  45. #define DPHY_PSM_CFG DPHY_PCS(0x4)
  46. #define DPHY_PSM_CFG_FROM_REG BIT(0)
  47. #define DPHY_PSM_CLK_DIV(x) ((x) << 1)
  48. #define DSI_HBP_FRAME_OVERHEAD 12
  49. #define DSI_HSA_FRAME_OVERHEAD 14
  50. #define DSI_HFP_FRAME_OVERHEAD 6
  51. #define DSI_HSS_VSS_VSE_FRAME_OVERHEAD 4
  52. #define DSI_BLANKING_FRAME_OVERHEAD 6
  53. #define DSI_NULL_FRAME_OVERHEAD 6
  54. #define DSI_EOT_PKT_SIZE 4
  55. #define DPHY_TX_J721E_WIZ_PLL_CTRL 0xF04
  56. #define DPHY_TX_J721E_WIZ_STATUS 0xF08
  57. #define DPHY_TX_J721E_WIZ_RST_CTRL 0xF0C
  58. #define DPHY_TX_J721E_WIZ_PSM_FREQ 0xF10
  59. #define DPHY_TX_J721E_WIZ_IPDIV GENMASK(4, 0)
  60. #define DPHY_TX_J721E_WIZ_OPDIV GENMASK(13, 8)
  61. #define DPHY_TX_J721E_WIZ_FBDIV GENMASK(25, 16)
  62. #define DPHY_TX_J721E_WIZ_LANE_RSTB BIT(31)
  63. #define DPHY_TX_WIZ_PLL_LOCK BIT(31)
  64. #define DPHY_TX_WIZ_O_CMN_READY BIT(31)
  65. struct cdns_dphy_cfg {
  66. u8 pll_ipdiv;
  67. u8 pll_opdiv;
  68. u16 pll_fbdiv;
  69. u32 hs_clk_rate;
  70. unsigned int nlanes;
  71. };
  72. enum cdns_dphy_clk_lane_cfg {
  73. DPHY_CLK_CFG_LEFT_DRIVES_ALL = 0,
  74. DPHY_CLK_CFG_LEFT_DRIVES_RIGHT = 1,
  75. DPHY_CLK_CFG_LEFT_DRIVES_LEFT = 2,
  76. DPHY_CLK_CFG_RIGHT_DRIVES_ALL = 3,
  77. };
  78. struct cdns_dphy;
  79. struct cdns_dphy_ops {
  80. int (*probe)(struct cdns_dphy *dphy);
  81. void (*remove)(struct cdns_dphy *dphy);
  82. void (*set_psm_div)(struct cdns_dphy *dphy, u8 div);
  83. void (*set_clk_lane_cfg)(struct cdns_dphy *dphy,
  84. enum cdns_dphy_clk_lane_cfg cfg);
  85. void (*set_pll_cfg)(struct cdns_dphy *dphy,
  86. const struct cdns_dphy_cfg *cfg);
  87. unsigned long (*get_wakeup_time_ns)(struct cdns_dphy *dphy);
  88. int (*wait_for_pll_lock)(struct cdns_dphy *dphy);
  89. int (*wait_for_cmn_ready)(struct cdns_dphy *dphy);
  90. };
  91. struct cdns_dphy {
  92. struct cdns_dphy_cfg cfg;
  93. void __iomem *regs;
  94. struct clk *psm_clk;
  95. struct clk *pll_ref_clk;
  96. const struct cdns_dphy_ops *ops;
  97. struct phy *phy;
  98. bool is_configured;
  99. bool is_powered;
  100. };
  101. /* Order of bands is important since the index is the band number. */
  102. static const unsigned int tx_bands[] = {
  103. 80, 100, 120, 160, 200, 240, 320, 390, 450, 510, 560, 640, 690, 770,
  104. 870, 950, 1000, 1200, 1400, 1600, 1800, 2000, 2200, 2500
  105. };
  106. static int cdns_dsi_get_dphy_pll_cfg(struct cdns_dphy *dphy,
  107. struct cdns_dphy_cfg *cfg,
  108. struct phy_configure_opts_mipi_dphy *opts,
  109. unsigned int *dsi_hfp_ext)
  110. {
  111. unsigned long pll_ref_hz = clk_get_rate(dphy->pll_ref_clk);
  112. u64 dlane_bps;
  113. memset(cfg, 0, sizeof(*cfg));
  114. if (pll_ref_hz < 9600000 || pll_ref_hz >= 150000000)
  115. return -EINVAL;
  116. else if (pll_ref_hz < 19200000)
  117. cfg->pll_ipdiv = 1;
  118. else if (pll_ref_hz < 38400000)
  119. cfg->pll_ipdiv = 2;
  120. else if (pll_ref_hz < 76800000)
  121. cfg->pll_ipdiv = 4;
  122. else
  123. cfg->pll_ipdiv = 8;
  124. dlane_bps = opts->hs_clk_rate;
  125. if (dlane_bps > 2500000000UL || dlane_bps < 160000000UL)
  126. return -EINVAL;
  127. else if (dlane_bps >= 1250000000)
  128. cfg->pll_opdiv = 1;
  129. else if (dlane_bps >= 630000000)
  130. cfg->pll_opdiv = 2;
  131. else if (dlane_bps >= 320000000)
  132. cfg->pll_opdiv = 4;
  133. else if (dlane_bps >= 160000000)
  134. cfg->pll_opdiv = 8;
  135. cfg->pll_fbdiv = DIV_ROUND_UP_ULL(dlane_bps * 2 * cfg->pll_opdiv *
  136. cfg->pll_ipdiv,
  137. pll_ref_hz);
  138. cfg->hs_clk_rate = div_u64((u64)pll_ref_hz * cfg->pll_fbdiv,
  139. 2 * cfg->pll_opdiv * cfg->pll_ipdiv);
  140. return 0;
  141. }
  142. static int cdns_dphy_setup_psm(struct cdns_dphy *dphy)
  143. {
  144. unsigned long psm_clk_hz = clk_get_rate(dphy->psm_clk);
  145. unsigned long psm_div;
  146. if (!psm_clk_hz || psm_clk_hz > 100000000)
  147. return -EINVAL;
  148. psm_div = DIV_ROUND_CLOSEST(psm_clk_hz, 1000000);
  149. if (dphy->ops->set_psm_div)
  150. dphy->ops->set_psm_div(dphy, psm_div);
  151. return 0;
  152. }
  153. static void cdns_dphy_set_clk_lane_cfg(struct cdns_dphy *dphy,
  154. enum cdns_dphy_clk_lane_cfg cfg)
  155. {
  156. if (dphy->ops->set_clk_lane_cfg)
  157. dphy->ops->set_clk_lane_cfg(dphy, cfg);
  158. }
  159. static void cdns_dphy_set_pll_cfg(struct cdns_dphy *dphy,
  160. const struct cdns_dphy_cfg *cfg)
  161. {
  162. if (dphy->ops->set_pll_cfg)
  163. dphy->ops->set_pll_cfg(dphy, cfg);
  164. }
  165. static unsigned long cdns_dphy_get_wakeup_time_ns(struct cdns_dphy *dphy)
  166. {
  167. return dphy->ops->get_wakeup_time_ns(dphy);
  168. }
  169. static int cdns_dphy_wait_for_pll_lock(struct cdns_dphy *dphy)
  170. {
  171. return dphy->ops->wait_for_pll_lock ? dphy->ops->wait_for_pll_lock(dphy) : 0;
  172. }
  173. static int cdns_dphy_wait_for_cmn_ready(struct cdns_dphy *dphy)
  174. {
  175. return dphy->ops->wait_for_cmn_ready ? dphy->ops->wait_for_cmn_ready(dphy) : 0;
  176. }
  177. static unsigned long cdns_dphy_ref_get_wakeup_time_ns(struct cdns_dphy *dphy)
  178. {
  179. /* Default wakeup time is 800 ns (in a simulated environment). */
  180. return 800;
  181. }
  182. static void cdns_dphy_ref_set_pll_cfg(struct cdns_dphy *dphy,
  183. const struct cdns_dphy_cfg *cfg)
  184. {
  185. u32 fbdiv_low, fbdiv_high;
  186. fbdiv_low = (cfg->pll_fbdiv / 4) - 2;
  187. fbdiv_high = cfg->pll_fbdiv - fbdiv_low - 2;
  188. writel(DPHY_CMN_IPDIV_FROM_REG | DPHY_CMN_OPDIV_FROM_REG |
  189. DPHY_CMN_IPDIV(cfg->pll_ipdiv) |
  190. DPHY_CMN_OPDIV(cfg->pll_opdiv),
  191. dphy->regs + DPHY_CMN_OPIPDIV);
  192. writel(DPHY_CMN_FBDIV_FROM_REG |
  193. DPHY_CMN_FBDIV_VAL(fbdiv_low, fbdiv_high),
  194. dphy->regs + DPHY_CMN_FBDIV);
  195. writel(DPHY_CMN_PWM_HIGH(6) | DPHY_CMN_PWM_LOW(0x101) |
  196. DPHY_CMN_PWM_DIV(0x8),
  197. dphy->regs + DPHY_CMN_PWM);
  198. }
  199. static void cdns_dphy_ref_set_psm_div(struct cdns_dphy *dphy, u8 div)
  200. {
  201. writel(DPHY_PSM_CFG_FROM_REG | DPHY_PSM_CLK_DIV(div),
  202. dphy->regs + DPHY_PSM_CFG);
  203. }
  204. static unsigned long cdns_dphy_j721e_get_wakeup_time_ns(struct cdns_dphy *dphy)
  205. {
  206. /* Minimum wakeup time as per MIPI D-PHY spec v1.2 */
  207. return 1000000;
  208. }
  209. static void cdns_dphy_j721e_set_pll_cfg(struct cdns_dphy *dphy,
  210. const struct cdns_dphy_cfg *cfg)
  211. {
  212. /*
  213. * set the PWM and PLL Byteclk divider settings to recommended values
  214. * which is same as that of in ref ops
  215. */
  216. writel(DPHY_CMN_PWM_HIGH(6) | DPHY_CMN_PWM_LOW(0x101) |
  217. DPHY_CMN_PWM_DIV(0x8),
  218. dphy->regs + DPHY_CMN_PWM);
  219. writel((FIELD_PREP(DPHY_TX_J721E_WIZ_IPDIV, cfg->pll_ipdiv) |
  220. FIELD_PREP(DPHY_TX_J721E_WIZ_OPDIV, cfg->pll_opdiv) |
  221. FIELD_PREP(DPHY_TX_J721E_WIZ_FBDIV, cfg->pll_fbdiv)),
  222. dphy->regs + DPHY_TX_J721E_WIZ_PLL_CTRL);
  223. writel(DPHY_TX_J721E_WIZ_LANE_RSTB,
  224. dphy->regs + DPHY_TX_J721E_WIZ_RST_CTRL);
  225. }
  226. static void cdns_dphy_j721e_set_psm_div(struct cdns_dphy *dphy, u8 div)
  227. {
  228. writel(div, dphy->regs + DPHY_TX_J721E_WIZ_PSM_FREQ);
  229. }
  230. static int cdns_dphy_j721e_wait_for_pll_lock(struct cdns_dphy *dphy)
  231. {
  232. u32 status;
  233. return readl_poll_timeout(dphy->regs + DPHY_TX_J721E_WIZ_PLL_CTRL, status,
  234. status & DPHY_TX_WIZ_PLL_LOCK, 0, POLL_TIMEOUT_US);
  235. }
  236. static int cdns_dphy_j721e_wait_for_cmn_ready(struct cdns_dphy *dphy)
  237. {
  238. u32 status;
  239. return readl_poll_timeout(dphy->regs + DPHY_TX_J721E_WIZ_STATUS, status,
  240. status & DPHY_TX_WIZ_O_CMN_READY, 0,
  241. POLL_TIMEOUT_US);
  242. }
  243. /*
  244. * This is the reference implementation of DPHY hooks. Specific integration of
  245. * this IP may have to re-implement some of them depending on how they decided
  246. * to wire things in the SoC.
  247. */
  248. static const struct cdns_dphy_ops ref_dphy_ops = {
  249. .get_wakeup_time_ns = cdns_dphy_ref_get_wakeup_time_ns,
  250. .set_pll_cfg = cdns_dphy_ref_set_pll_cfg,
  251. .set_psm_div = cdns_dphy_ref_set_psm_div,
  252. };
  253. static const struct cdns_dphy_ops j721e_dphy_ops = {
  254. .get_wakeup_time_ns = cdns_dphy_j721e_get_wakeup_time_ns,
  255. .set_pll_cfg = cdns_dphy_j721e_set_pll_cfg,
  256. .set_psm_div = cdns_dphy_j721e_set_psm_div,
  257. .wait_for_pll_lock = cdns_dphy_j721e_wait_for_pll_lock,
  258. .wait_for_cmn_ready = cdns_dphy_j721e_wait_for_cmn_ready,
  259. };
  260. static int cdns_dphy_config_from_opts(struct phy *phy,
  261. struct phy_configure_opts_mipi_dphy *opts,
  262. struct cdns_dphy_cfg *cfg)
  263. {
  264. struct cdns_dphy *dphy = phy_get_drvdata(phy);
  265. unsigned int dsi_hfp_ext = 0;
  266. int ret;
  267. ret = phy_mipi_dphy_config_validate(opts);
  268. if (ret)
  269. return ret;
  270. ret = cdns_dsi_get_dphy_pll_cfg(dphy, cfg,
  271. opts, &dsi_hfp_ext);
  272. if (ret)
  273. return ret;
  274. opts->hs_clk_rate = cfg->hs_clk_rate;
  275. opts->wakeup = cdns_dphy_get_wakeup_time_ns(dphy) / 1000;
  276. return 0;
  277. }
  278. static int cdns_dphy_tx_get_band_ctrl(unsigned long hs_clk_rate)
  279. {
  280. unsigned int rate;
  281. int i;
  282. rate = hs_clk_rate / 1000000UL;
  283. if (rate < tx_bands[0])
  284. return -EOPNOTSUPP;
  285. for (i = 0; i < ARRAY_SIZE(tx_bands) - 1; i++) {
  286. if (rate >= tx_bands[i] && rate < tx_bands[i + 1])
  287. return i;
  288. }
  289. return -EOPNOTSUPP;
  290. }
  291. static int cdns_dphy_validate(struct phy *phy, enum phy_mode mode, int submode,
  292. union phy_configure_opts *opts)
  293. {
  294. struct cdns_dphy_cfg cfg = { 0 };
  295. if (mode != PHY_MODE_MIPI_DPHY)
  296. return -EINVAL;
  297. return cdns_dphy_config_from_opts(phy, &opts->mipi_dphy, &cfg);
  298. }
  299. static int cdns_dphy_configure(struct phy *phy, union phy_configure_opts *opts)
  300. {
  301. struct cdns_dphy *dphy = phy_get_drvdata(phy);
  302. int ret;
  303. ret = cdns_dphy_config_from_opts(phy, &opts->mipi_dphy, &dphy->cfg);
  304. if (!ret)
  305. dphy->is_configured = true;
  306. return ret;
  307. }
  308. static int cdns_dphy_power_on(struct phy *phy)
  309. {
  310. struct cdns_dphy *dphy = phy_get_drvdata(phy);
  311. int ret;
  312. u32 reg;
  313. if (!dphy->is_configured || dphy->is_powered)
  314. return -EINVAL;
  315. clk_prepare_enable(dphy->psm_clk);
  316. clk_prepare_enable(dphy->pll_ref_clk);
  317. /*
  318. * Configure the internal PSM clk divider so that the DPHY has a
  319. * 1MHz clk (or something close).
  320. */
  321. ret = cdns_dphy_setup_psm(dphy);
  322. if (ret) {
  323. dev_err(&dphy->phy->dev, "Failed to setup PSM with error %d\n", ret);
  324. goto err_power_on;
  325. }
  326. /*
  327. * Configure attach clk lanes to data lanes: the DPHY has 2 clk lanes
  328. * and 8 data lanes, each clk lane can be attache different set of
  329. * data lanes. The 2 groups are named 'left' and 'right', so here we
  330. * just say that we want the 'left' clk lane to drive the 'left' data
  331. * lanes.
  332. */
  333. cdns_dphy_set_clk_lane_cfg(dphy, DPHY_CLK_CFG_LEFT_DRIVES_LEFT);
  334. /*
  335. * Configure the DPHY PLL that will be used to generate the TX byte
  336. * clk.
  337. */
  338. cdns_dphy_set_pll_cfg(dphy, &dphy->cfg);
  339. ret = cdns_dphy_tx_get_band_ctrl(dphy->cfg.hs_clk_rate);
  340. if (ret < 0) {
  341. dev_err(&dphy->phy->dev, "Failed to get band control value with error %d\n", ret);
  342. goto err_power_on;
  343. }
  344. reg = FIELD_PREP(DPHY_BAND_CFG_LEFT_BAND, ret) |
  345. FIELD_PREP(DPHY_BAND_CFG_RIGHT_BAND, ret);
  346. writel(reg, dphy->regs + DPHY_BAND_CFG);
  347. /* Start TX state machine. */
  348. reg = readl(dphy->regs + DPHY_CMN_SSM);
  349. writel((reg & DPHY_CMN_SSM_CAL_WAIT_TIME) | DPHY_CMN_SSM_EN | DPHY_CMN_TX_MODE_EN,
  350. dphy->regs + DPHY_CMN_SSM);
  351. ret = cdns_dphy_wait_for_pll_lock(dphy);
  352. if (ret) {
  353. dev_err(&dphy->phy->dev, "Failed to lock PLL with error %d\n", ret);
  354. goto err_power_on;
  355. }
  356. ret = cdns_dphy_wait_for_cmn_ready(dphy);
  357. if (ret) {
  358. dev_err(&dphy->phy->dev, "O_CMN_READY signal failed to assert with error %d\n",
  359. ret);
  360. goto err_power_on;
  361. }
  362. dphy->is_powered = true;
  363. return 0;
  364. err_power_on:
  365. clk_disable_unprepare(dphy->pll_ref_clk);
  366. clk_disable_unprepare(dphy->psm_clk);
  367. return ret;
  368. }
  369. static int cdns_dphy_power_off(struct phy *phy)
  370. {
  371. struct cdns_dphy *dphy = phy_get_drvdata(phy);
  372. u32 reg;
  373. clk_disable_unprepare(dphy->pll_ref_clk);
  374. clk_disable_unprepare(dphy->psm_clk);
  375. /* Stop TX state machine. */
  376. reg = readl(dphy->regs + DPHY_CMN_SSM);
  377. writel(reg & ~DPHY_CMN_SSM_EN, dphy->regs + DPHY_CMN_SSM);
  378. dphy->is_powered = false;
  379. return 0;
  380. }
  381. static const struct phy_ops cdns_dphy_ops = {
  382. .configure = cdns_dphy_configure,
  383. .validate = cdns_dphy_validate,
  384. .power_on = cdns_dphy_power_on,
  385. .power_off = cdns_dphy_power_off,
  386. };
  387. static int cdns_dphy_probe(struct platform_device *pdev)
  388. {
  389. struct phy_provider *phy_provider;
  390. struct cdns_dphy *dphy;
  391. int ret;
  392. dphy = devm_kzalloc(&pdev->dev, sizeof(*dphy), GFP_KERNEL);
  393. if (!dphy)
  394. return -ENOMEM;
  395. dev_set_drvdata(&pdev->dev, dphy);
  396. dphy->ops = of_device_get_match_data(&pdev->dev);
  397. if (!dphy->ops)
  398. return -EINVAL;
  399. dphy->regs = devm_platform_ioremap_resource(pdev, 0);
  400. if (IS_ERR(dphy->regs))
  401. return PTR_ERR(dphy->regs);
  402. dphy->psm_clk = devm_clk_get(&pdev->dev, "psm");
  403. if (IS_ERR(dphy->psm_clk))
  404. return PTR_ERR(dphy->psm_clk);
  405. dphy->pll_ref_clk = devm_clk_get(&pdev->dev, "pll_ref");
  406. if (IS_ERR(dphy->pll_ref_clk))
  407. return PTR_ERR(dphy->pll_ref_clk);
  408. if (dphy->ops->probe) {
  409. ret = dphy->ops->probe(dphy);
  410. if (ret)
  411. return ret;
  412. }
  413. dphy->phy = devm_phy_create(&pdev->dev, NULL, &cdns_dphy_ops);
  414. if (IS_ERR(dphy->phy)) {
  415. dev_err(&pdev->dev, "failed to create PHY\n");
  416. if (dphy->ops->remove)
  417. dphy->ops->remove(dphy);
  418. return PTR_ERR(dphy->phy);
  419. }
  420. phy_set_drvdata(dphy->phy, dphy);
  421. phy_provider = devm_of_phy_provider_register(&pdev->dev,
  422. of_phy_simple_xlate);
  423. return PTR_ERR_OR_ZERO(phy_provider);
  424. }
  425. static void cdns_dphy_remove(struct platform_device *pdev)
  426. {
  427. struct cdns_dphy *dphy = dev_get_drvdata(&pdev->dev);
  428. if (dphy->ops->remove)
  429. dphy->ops->remove(dphy);
  430. }
  431. static const struct of_device_id cdns_dphy_of_match[] = {
  432. { .compatible = "cdns,dphy", .data = &ref_dphy_ops },
  433. { .compatible = "ti,j721e-dphy", .data = &j721e_dphy_ops },
  434. { /* sentinel */ },
  435. };
  436. MODULE_DEVICE_TABLE(of, cdns_dphy_of_match);
  437. static struct platform_driver cdns_dphy_platform_driver = {
  438. .probe = cdns_dphy_probe,
  439. .remove_new = cdns_dphy_remove,
  440. .driver = {
  441. .name = "cdns-mipi-dphy",
  442. .of_match_table = cdns_dphy_of_match,
  443. },
  444. };
  445. module_platform_driver(cdns_dphy_platform_driver);
  446. MODULE_AUTHOR("Maxime Ripard <maxime.ripard@bootlin.com>");
  447. MODULE_DESCRIPTION("Cadence MIPI D-PHY Driver");
  448. MODULE_LICENSE("GPL");