Lines Matching full:dphy

17 #include <linux/phy/phy-mipi-dphy.h>
23 /* DPHY registers */
94 int (*probe)(struct cdns_dphy *dphy);
95 void (*remove)(struct cdns_dphy *dphy);
96 void (*set_psm_div)(struct cdns_dphy *dphy, u8 div);
97 void (*set_clk_lane_cfg)(struct cdns_dphy *dphy,
99 void (*set_pll_cfg)(struct cdns_dphy *dphy,
101 unsigned long (*get_wakeup_time_ns)(struct cdns_dphy *dphy);
119 static int cdns_dsi_get_dphy_pll_cfg(struct cdns_dphy *dphy, in cdns_dsi_get_dphy_pll_cfg() argument
124 unsigned long pll_ref_hz = clk_get_rate(dphy->pll_ref_clk); in cdns_dsi_get_dphy_pll_cfg()
160 static int cdns_dphy_setup_psm(struct cdns_dphy *dphy) in cdns_dphy_setup_psm() argument
162 unsigned long psm_clk_hz = clk_get_rate(dphy->psm_clk); in cdns_dphy_setup_psm()
169 if (dphy->ops->set_psm_div) in cdns_dphy_setup_psm()
170 dphy->ops->set_psm_div(dphy, psm_div); in cdns_dphy_setup_psm()
175 static void cdns_dphy_set_clk_lane_cfg(struct cdns_dphy *dphy, in cdns_dphy_set_clk_lane_cfg() argument
178 if (dphy->ops->set_clk_lane_cfg) in cdns_dphy_set_clk_lane_cfg()
179 dphy->ops->set_clk_lane_cfg(dphy, cfg); in cdns_dphy_set_clk_lane_cfg()
182 static void cdns_dphy_set_pll_cfg(struct cdns_dphy *dphy, in cdns_dphy_set_pll_cfg() argument
185 if (dphy->ops->set_pll_cfg) in cdns_dphy_set_pll_cfg()
186 dphy->ops->set_pll_cfg(dphy, cfg); in cdns_dphy_set_pll_cfg()
189 static unsigned long cdns_dphy_get_wakeup_time_ns(struct cdns_dphy *dphy) in cdns_dphy_get_wakeup_time_ns() argument
191 return dphy->ops->get_wakeup_time_ns(dphy); in cdns_dphy_get_wakeup_time_ns()
194 static unsigned long cdns_dphy_ref_get_wakeup_time_ns(struct cdns_dphy *dphy) in cdns_dphy_ref_get_wakeup_time_ns() argument
200 static void cdns_dphy_ref_set_pll_cfg(struct cdns_dphy *dphy, in cdns_dphy_ref_set_pll_cfg() argument
211 dphy->regs + DPHY_CMN_OPIPDIV); in cdns_dphy_ref_set_pll_cfg()
214 dphy->regs + DPHY_CMN_FBDIV); in cdns_dphy_ref_set_pll_cfg()
217 dphy->regs + DPHY_CMN_PWM); in cdns_dphy_ref_set_pll_cfg()
220 static void cdns_dphy_ref_set_psm_div(struct cdns_dphy *dphy, u8 div) in cdns_dphy_ref_set_psm_div() argument
223 dphy->regs + DPHY_PSM_CFG); in cdns_dphy_ref_set_psm_div()
226 static unsigned long cdns_dphy_j721e_get_wakeup_time_ns(struct cdns_dphy *dphy) in cdns_dphy_j721e_get_wakeup_time_ns() argument
232 static void cdns_dphy_j721e_set_pll_cfg(struct cdns_dphy *dphy, in cdns_dphy_j721e_set_pll_cfg() argument
243 dphy->regs + DPHY_CMN_PWM); in cdns_dphy_j721e_set_pll_cfg()
248 dphy->regs + DPHY_TX_J721E_WIZ_PLL_CTRL); in cdns_dphy_j721e_set_pll_cfg()
251 dphy->regs + DPHY_TX_J721E_WIZ_RST_CTRL); in cdns_dphy_j721e_set_pll_cfg()
253 readl_poll_timeout(dphy->regs + DPHY_TX_J721E_WIZ_PLL_CTRL, status, in cdns_dphy_j721e_set_pll_cfg()
256 readl_poll_timeout(dphy->regs + DPHY_TX_J721E_WIZ_STATUS, status, in cdns_dphy_j721e_set_pll_cfg()
261 static void cdns_dphy_j721e_set_psm_div(struct cdns_dphy *dphy, u8 div) in cdns_dphy_j721e_set_psm_div() argument
263 writel(div, dphy->regs + DPHY_TX_J721E_WIZ_PSM_FREQ); in cdns_dphy_j721e_set_psm_div()
267 * This is the reference implementation of DPHY hooks. Specific integration of
287 struct cdns_dphy *dphy = phy_get_drvdata(phy); in cdns_dphy_config_from_opts() local
295 ret = cdns_dsi_get_dphy_pll_cfg(dphy, cfg, in cdns_dphy_config_from_opts()
300 opts->wakeup = cdns_dphy_get_wakeup_time_ns(dphy) / 1000; in cdns_dphy_config_from_opts()
336 struct cdns_dphy *dphy = phy_get_drvdata(phy); in cdns_dphy_configure() local
346 * Configure the internal PSM clk divider so that the DPHY has a in cdns_dphy_configure()
349 ret = cdns_dphy_setup_psm(dphy); in cdns_dphy_configure()
354 * Configure attach clk lanes to data lanes: the DPHY has 2 clk lanes in cdns_dphy_configure()
360 cdns_dphy_set_clk_lane_cfg(dphy, DPHY_CLK_CFG_LEFT_DRIVES_LEFT); in cdns_dphy_configure()
363 * Configure the DPHY PLL that will be used to generate the TX byte in cdns_dphy_configure()
366 cdns_dphy_set_pll_cfg(dphy, &cfg); in cdns_dphy_configure()
374 writel(reg, dphy->regs + DPHY_BAND_CFG); in cdns_dphy_configure()
381 struct cdns_dphy *dphy = phy_get_drvdata(phy); in cdns_dphy_power_on() local
383 clk_prepare_enable(dphy->psm_clk); in cdns_dphy_power_on()
384 clk_prepare_enable(dphy->pll_ref_clk); in cdns_dphy_power_on()
388 dphy->regs + DPHY_CMN_SSM); in cdns_dphy_power_on()
395 struct cdns_dphy *dphy = phy_get_drvdata(phy); in cdns_dphy_power_off() local
397 clk_disable_unprepare(dphy->pll_ref_clk); in cdns_dphy_power_off()
398 clk_disable_unprepare(dphy->psm_clk); in cdns_dphy_power_off()
413 struct cdns_dphy *dphy; in cdns_dphy_probe() local
416 dphy = devm_kzalloc(&pdev->dev, sizeof(*dphy), GFP_KERNEL); in cdns_dphy_probe()
417 if (!dphy) in cdns_dphy_probe()
419 dev_set_drvdata(&pdev->dev, dphy); in cdns_dphy_probe()
421 dphy->ops = of_device_get_match_data(&pdev->dev); in cdns_dphy_probe()
422 if (!dphy->ops) in cdns_dphy_probe()
425 dphy->regs = devm_platform_ioremap_resource(pdev, 0); in cdns_dphy_probe()
426 if (IS_ERR(dphy->regs)) in cdns_dphy_probe()
427 return PTR_ERR(dphy->regs); in cdns_dphy_probe()
429 dphy->psm_clk = devm_clk_get(&pdev->dev, "psm"); in cdns_dphy_probe()
430 if (IS_ERR(dphy->psm_clk)) in cdns_dphy_probe()
431 return PTR_ERR(dphy->psm_clk); in cdns_dphy_probe()
433 dphy->pll_ref_clk = devm_clk_get(&pdev->dev, "pll_ref"); in cdns_dphy_probe()
434 if (IS_ERR(dphy->pll_ref_clk)) in cdns_dphy_probe()
435 return PTR_ERR(dphy->pll_ref_clk); in cdns_dphy_probe()
437 if (dphy->ops->probe) { in cdns_dphy_probe()
438 ret = dphy->ops->probe(dphy); in cdns_dphy_probe()
443 dphy->phy = devm_phy_create(&pdev->dev, NULL, &cdns_dphy_ops); in cdns_dphy_probe()
444 if (IS_ERR(dphy->phy)) { in cdns_dphy_probe()
446 if (dphy->ops->remove) in cdns_dphy_probe()
447 dphy->ops->remove(dphy); in cdns_dphy_probe()
448 return PTR_ERR(dphy->phy); in cdns_dphy_probe()
451 phy_set_drvdata(dphy->phy, dphy); in cdns_dphy_probe()
460 struct cdns_dphy *dphy = dev_get_drvdata(&pdev->dev); in cdns_dphy_remove() local
462 if (dphy->ops->remove) in cdns_dphy_remove()
463 dphy->ops->remove(dphy); in cdns_dphy_remove()
467 { .compatible = "cdns,dphy", .data = &ref_dphy_ops },
468 { .compatible = "ti,j721e-dphy", .data = &j721e_dphy_ops },
477 .name = "cdns-mipi-dphy",