Lines Matching full:dphy
18 #include <linux/phy/phy-mipi-dphy.h>
24 /* DPHY registers */
95 int (*probe)(struct cdns_dphy *dphy);
96 void (*remove)(struct cdns_dphy *dphy);
97 void (*set_psm_div)(struct cdns_dphy *dphy, u8 div);
98 void (*set_clk_lane_cfg)(struct cdns_dphy *dphy,
100 void (*set_pll_cfg)(struct cdns_dphy *dphy,
102 unsigned long (*get_wakeup_time_ns)(struct cdns_dphy *dphy);
120 static int cdns_dsi_get_dphy_pll_cfg(struct cdns_dphy *dphy, in cdns_dsi_get_dphy_pll_cfg() argument
125 unsigned long pll_ref_hz = clk_get_rate(dphy->pll_ref_clk); in cdns_dsi_get_dphy_pll_cfg()
161 static int cdns_dphy_setup_psm(struct cdns_dphy *dphy) in cdns_dphy_setup_psm() argument
163 unsigned long psm_clk_hz = clk_get_rate(dphy->psm_clk); in cdns_dphy_setup_psm()
170 if (dphy->ops->set_psm_div) in cdns_dphy_setup_psm()
171 dphy->ops->set_psm_div(dphy, psm_div); in cdns_dphy_setup_psm()
176 static void cdns_dphy_set_clk_lane_cfg(struct cdns_dphy *dphy, in cdns_dphy_set_clk_lane_cfg() argument
179 if (dphy->ops->set_clk_lane_cfg) in cdns_dphy_set_clk_lane_cfg()
180 dphy->ops->set_clk_lane_cfg(dphy, cfg); in cdns_dphy_set_clk_lane_cfg()
183 static void cdns_dphy_set_pll_cfg(struct cdns_dphy *dphy, in cdns_dphy_set_pll_cfg() argument
186 if (dphy->ops->set_pll_cfg) in cdns_dphy_set_pll_cfg()
187 dphy->ops->set_pll_cfg(dphy, cfg); in cdns_dphy_set_pll_cfg()
190 static unsigned long cdns_dphy_get_wakeup_time_ns(struct cdns_dphy *dphy) in cdns_dphy_get_wakeup_time_ns() argument
192 return dphy->ops->get_wakeup_time_ns(dphy); in cdns_dphy_get_wakeup_time_ns()
195 static unsigned long cdns_dphy_ref_get_wakeup_time_ns(struct cdns_dphy *dphy) in cdns_dphy_ref_get_wakeup_time_ns() argument
201 static void cdns_dphy_ref_set_pll_cfg(struct cdns_dphy *dphy, in cdns_dphy_ref_set_pll_cfg() argument
212 dphy->regs + DPHY_CMN_OPIPDIV); in cdns_dphy_ref_set_pll_cfg()
215 dphy->regs + DPHY_CMN_FBDIV); in cdns_dphy_ref_set_pll_cfg()
218 dphy->regs + DPHY_CMN_PWM); in cdns_dphy_ref_set_pll_cfg()
221 static void cdns_dphy_ref_set_psm_div(struct cdns_dphy *dphy, u8 div) in cdns_dphy_ref_set_psm_div() argument
224 dphy->regs + DPHY_PSM_CFG); in cdns_dphy_ref_set_psm_div()
227 static unsigned long cdns_dphy_j721e_get_wakeup_time_ns(struct cdns_dphy *dphy) in cdns_dphy_j721e_get_wakeup_time_ns() argument
233 static void cdns_dphy_j721e_set_pll_cfg(struct cdns_dphy *dphy, in cdns_dphy_j721e_set_pll_cfg() argument
244 dphy->regs + DPHY_CMN_PWM); in cdns_dphy_j721e_set_pll_cfg()
249 dphy->regs + DPHY_TX_J721E_WIZ_PLL_CTRL); in cdns_dphy_j721e_set_pll_cfg()
252 dphy->regs + DPHY_TX_J721E_WIZ_RST_CTRL); in cdns_dphy_j721e_set_pll_cfg()
254 readl_poll_timeout(dphy->regs + DPHY_TX_J721E_WIZ_PLL_CTRL, status, in cdns_dphy_j721e_set_pll_cfg()
257 readl_poll_timeout(dphy->regs + DPHY_TX_J721E_WIZ_STATUS, status, in cdns_dphy_j721e_set_pll_cfg()
262 static void cdns_dphy_j721e_set_psm_div(struct cdns_dphy *dphy, u8 div) in cdns_dphy_j721e_set_psm_div() argument
264 writel(div, dphy->regs + DPHY_TX_J721E_WIZ_PSM_FREQ); in cdns_dphy_j721e_set_psm_div()
268 * This is the reference implementation of DPHY hooks. Specific integration of
288 struct cdns_dphy *dphy = phy_get_drvdata(phy); in cdns_dphy_config_from_opts() local
296 ret = cdns_dsi_get_dphy_pll_cfg(dphy, cfg, in cdns_dphy_config_from_opts()
301 opts->wakeup = cdns_dphy_get_wakeup_time_ns(dphy) / 1000; in cdns_dphy_config_from_opts()
337 struct cdns_dphy *dphy = phy_get_drvdata(phy); in cdns_dphy_configure() local
347 * Configure the internal PSM clk divider so that the DPHY has a in cdns_dphy_configure()
350 ret = cdns_dphy_setup_psm(dphy); in cdns_dphy_configure()
355 * Configure attach clk lanes to data lanes: the DPHY has 2 clk lanes in cdns_dphy_configure()
361 cdns_dphy_set_clk_lane_cfg(dphy, DPHY_CLK_CFG_LEFT_DRIVES_LEFT); in cdns_dphy_configure()
364 * Configure the DPHY PLL that will be used to generate the TX byte in cdns_dphy_configure()
367 cdns_dphy_set_pll_cfg(dphy, &cfg); in cdns_dphy_configure()
375 writel(reg, dphy->regs + DPHY_BAND_CFG); in cdns_dphy_configure()
382 struct cdns_dphy *dphy = phy_get_drvdata(phy); in cdns_dphy_power_on() local
384 clk_prepare_enable(dphy->psm_clk); in cdns_dphy_power_on()
385 clk_prepare_enable(dphy->pll_ref_clk); in cdns_dphy_power_on()
389 dphy->regs + DPHY_CMN_SSM); in cdns_dphy_power_on()
396 struct cdns_dphy *dphy = phy_get_drvdata(phy); in cdns_dphy_power_off() local
398 clk_disable_unprepare(dphy->pll_ref_clk); in cdns_dphy_power_off()
399 clk_disable_unprepare(dphy->psm_clk); in cdns_dphy_power_off()
414 struct cdns_dphy *dphy; in cdns_dphy_probe() local
417 dphy = devm_kzalloc(&pdev->dev, sizeof(*dphy), GFP_KERNEL); in cdns_dphy_probe()
418 if (!dphy) in cdns_dphy_probe()
420 dev_set_drvdata(&pdev->dev, dphy); in cdns_dphy_probe()
422 dphy->ops = of_device_get_match_data(&pdev->dev); in cdns_dphy_probe()
423 if (!dphy->ops) in cdns_dphy_probe()
426 dphy->regs = devm_platform_ioremap_resource(pdev, 0); in cdns_dphy_probe()
427 if (IS_ERR(dphy->regs)) in cdns_dphy_probe()
428 return PTR_ERR(dphy->regs); in cdns_dphy_probe()
430 dphy->psm_clk = devm_clk_get(&pdev->dev, "psm"); in cdns_dphy_probe()
431 if (IS_ERR(dphy->psm_clk)) in cdns_dphy_probe()
432 return PTR_ERR(dphy->psm_clk); in cdns_dphy_probe()
434 dphy->pll_ref_clk = devm_clk_get(&pdev->dev, "pll_ref"); in cdns_dphy_probe()
435 if (IS_ERR(dphy->pll_ref_clk)) in cdns_dphy_probe()
436 return PTR_ERR(dphy->pll_ref_clk); in cdns_dphy_probe()
438 if (dphy->ops->probe) { in cdns_dphy_probe()
439 ret = dphy->ops->probe(dphy); in cdns_dphy_probe()
444 dphy->phy = devm_phy_create(&pdev->dev, NULL, &cdns_dphy_ops); in cdns_dphy_probe()
445 if (IS_ERR(dphy->phy)) { in cdns_dphy_probe()
447 if (dphy->ops->remove) in cdns_dphy_probe()
448 dphy->ops->remove(dphy); in cdns_dphy_probe()
449 return PTR_ERR(dphy->phy); in cdns_dphy_probe()
452 phy_set_drvdata(dphy->phy, dphy); in cdns_dphy_probe()
461 struct cdns_dphy *dphy = dev_get_drvdata(&pdev->dev); in cdns_dphy_remove() local
463 if (dphy->ops->remove) in cdns_dphy_remove()
464 dphy->ops->remove(dphy); in cdns_dphy_remove()
470 { .compatible = "cdns,dphy", .data = &ref_dphy_ops },
471 { .compatible = "ti,j721e-dphy", .data = &j721e_dphy_ops },
480 .name = "cdns-mipi-dphy",