Lines Matching full:dphy

16 #include <linux/phy/phy-mipi-dphy.h>
21 /* DPHY registers */
76 int (*probe)(struct cdns_dphy *dphy);
77 void (*remove)(struct cdns_dphy *dphy);
78 void (*set_psm_div)(struct cdns_dphy *dphy, u8 div);
79 void (*set_clk_lane_cfg)(struct cdns_dphy *dphy,
81 void (*set_pll_cfg)(struct cdns_dphy *dphy,
83 unsigned long (*get_wakeup_time_ns)(struct cdns_dphy *dphy);
95 static int cdns_dsi_get_dphy_pll_cfg(struct cdns_dphy *dphy, in cdns_dsi_get_dphy_pll_cfg() argument
100 unsigned long pll_ref_hz = clk_get_rate(dphy->pll_ref_clk); in cdns_dsi_get_dphy_pll_cfg()
136 static int cdns_dphy_setup_psm(struct cdns_dphy *dphy) in cdns_dphy_setup_psm() argument
138 unsigned long psm_clk_hz = clk_get_rate(dphy->psm_clk); in cdns_dphy_setup_psm()
145 if (dphy->ops->set_psm_div) in cdns_dphy_setup_psm()
146 dphy->ops->set_psm_div(dphy, psm_div); in cdns_dphy_setup_psm()
151 static void cdns_dphy_set_clk_lane_cfg(struct cdns_dphy *dphy, in cdns_dphy_set_clk_lane_cfg() argument
154 if (dphy->ops->set_clk_lane_cfg) in cdns_dphy_set_clk_lane_cfg()
155 dphy->ops->set_clk_lane_cfg(dphy, cfg); in cdns_dphy_set_clk_lane_cfg()
158 static void cdns_dphy_set_pll_cfg(struct cdns_dphy *dphy, in cdns_dphy_set_pll_cfg() argument
161 if (dphy->ops->set_pll_cfg) in cdns_dphy_set_pll_cfg()
162 dphy->ops->set_pll_cfg(dphy, cfg); in cdns_dphy_set_pll_cfg()
165 static unsigned long cdns_dphy_get_wakeup_time_ns(struct cdns_dphy *dphy) in cdns_dphy_get_wakeup_time_ns() argument
167 return dphy->ops->get_wakeup_time_ns(dphy); in cdns_dphy_get_wakeup_time_ns()
170 static unsigned long cdns_dphy_ref_get_wakeup_time_ns(struct cdns_dphy *dphy) in cdns_dphy_ref_get_wakeup_time_ns() argument
176 static void cdns_dphy_ref_set_pll_cfg(struct cdns_dphy *dphy, in cdns_dphy_ref_set_pll_cfg() argument
187 dphy->regs + DPHY_CMN_OPIPDIV); in cdns_dphy_ref_set_pll_cfg()
190 dphy->regs + DPHY_CMN_FBDIV); in cdns_dphy_ref_set_pll_cfg()
193 dphy->regs + DPHY_CMN_PWM); in cdns_dphy_ref_set_pll_cfg()
196 static void cdns_dphy_ref_set_psm_div(struct cdns_dphy *dphy, u8 div) in cdns_dphy_ref_set_psm_div() argument
199 dphy->regs + DPHY_PSM_CFG); in cdns_dphy_ref_set_psm_div()
203 * This is the reference implementation of DPHY hooks. Specific integration of
217 struct cdns_dphy *dphy = phy_get_drvdata(phy); in cdns_dphy_config_from_opts() local
225 ret = cdns_dsi_get_dphy_pll_cfg(dphy, cfg, in cdns_dphy_config_from_opts()
230 opts->wakeup = cdns_dphy_get_wakeup_time_ns(dphy) / 1000; in cdns_dphy_config_from_opts()
248 struct cdns_dphy *dphy = phy_get_drvdata(phy); in cdns_dphy_configure() local
257 * Configure the internal PSM clk divider so that the DPHY has a in cdns_dphy_configure()
260 ret = cdns_dphy_setup_psm(dphy); in cdns_dphy_configure()
265 * Configure attach clk lanes to data lanes: the DPHY has 2 clk lanes in cdns_dphy_configure()
271 cdns_dphy_set_clk_lane_cfg(dphy, DPHY_CLK_CFG_LEFT_DRIVES_LEFT); in cdns_dphy_configure()
274 * Configure the DPHY PLL that will be used to generate the TX byte in cdns_dphy_configure()
277 cdns_dphy_set_pll_cfg(dphy, &cfg); in cdns_dphy_configure()
284 struct cdns_dphy *dphy = phy_get_drvdata(phy); in cdns_dphy_power_on() local
286 clk_prepare_enable(dphy->psm_clk); in cdns_dphy_power_on()
287 clk_prepare_enable(dphy->pll_ref_clk); in cdns_dphy_power_on()
291 dphy->regs + DPHY_CMN_SSM); in cdns_dphy_power_on()
298 struct cdns_dphy *dphy = phy_get_drvdata(phy); in cdns_dphy_power_off() local
300 clk_disable_unprepare(dphy->pll_ref_clk); in cdns_dphy_power_off()
301 clk_disable_unprepare(dphy->psm_clk); in cdns_dphy_power_off()
316 struct cdns_dphy *dphy; in cdns_dphy_probe() local
320 dphy = devm_kzalloc(&pdev->dev, sizeof(*dphy), GFP_KERNEL); in cdns_dphy_probe()
321 if (!dphy) in cdns_dphy_probe()
323 dev_set_drvdata(&pdev->dev, dphy); in cdns_dphy_probe()
325 dphy->ops = of_device_get_match_data(&pdev->dev); in cdns_dphy_probe()
326 if (!dphy->ops) in cdns_dphy_probe()
330 dphy->regs = devm_ioremap_resource(&pdev->dev, res); in cdns_dphy_probe()
331 if (IS_ERR(dphy->regs)) in cdns_dphy_probe()
332 return PTR_ERR(dphy->regs); in cdns_dphy_probe()
334 dphy->psm_clk = devm_clk_get(&pdev->dev, "psm"); in cdns_dphy_probe()
335 if (IS_ERR(dphy->psm_clk)) in cdns_dphy_probe()
336 return PTR_ERR(dphy->psm_clk); in cdns_dphy_probe()
338 dphy->pll_ref_clk = devm_clk_get(&pdev->dev, "pll_ref"); in cdns_dphy_probe()
339 if (IS_ERR(dphy->pll_ref_clk)) in cdns_dphy_probe()
340 return PTR_ERR(dphy->pll_ref_clk); in cdns_dphy_probe()
342 if (dphy->ops->probe) { in cdns_dphy_probe()
343 ret = dphy->ops->probe(dphy); in cdns_dphy_probe()
348 dphy->phy = devm_phy_create(&pdev->dev, NULL, &cdns_dphy_ops); in cdns_dphy_probe()
349 if (IS_ERR(dphy->phy)) { in cdns_dphy_probe()
351 if (dphy->ops->remove) in cdns_dphy_probe()
352 dphy->ops->remove(dphy); in cdns_dphy_probe()
353 return PTR_ERR(dphy->phy); in cdns_dphy_probe()
356 phy_set_drvdata(dphy->phy, dphy); in cdns_dphy_probe()
365 struct cdns_dphy *dphy = dev_get_drvdata(&pdev->dev); in cdns_dphy_remove() local
367 if (dphy->ops->remove) in cdns_dphy_remove()
368 dphy->ops->remove(dphy); in cdns_dphy_remove()
374 { .compatible = "cdns,dphy", .data = &ref_dphy_ops },
383 .name = "cdns-mipi-dphy",