Lines Matching +full:phy +full:- +full:grf
1 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
11 * chromeos-4.4 branch.
14 * Jacob Chen <jacob2.chen@rock-chips.com>
15 * Shunqian Zheng <zhengsq@rock-chips.com>
25 #include <linux/phy/phy.h>
26 #include <linux/phy/phy-mipi-dphy.h>
65 "dphy-ref",
66 "dphy-cfg",
67 "grf",
111 { .offset = _offset, .mask = BIT(_width) - 1, .shift = _shift, }
151 struct regmap *grf; member
163 const struct dphy_reg *reg = &priv->drv_data->regs[index]; in rk_dphy_write_grf()
165 unsigned int val = (value << reg->shift) | in rk_dphy_write_grf()
166 (reg->mask << (reg->shift + 16)); in rk_dphy_write_grf()
168 if (WARN_ON(!reg->offset)) in rk_dphy_write_grf()
170 regmap_write(priv->grf, reg->offset, val); in rk_dphy_write_grf()
199 GENMASK(priv->config.lanes - 1, 0)); in rk_dphy_enable()
212 rk_dphy_write(priv, LANE0_HS_RX_CONTROL, priv->hsfreq << 1); in rk_dphy_enable()
214 rk_dphy_write(priv, LANE1_HS_RX_CONTROL, priv->hsfreq << 1); in rk_dphy_enable()
216 rk_dphy_write(priv, LANE2_HS_RX_CONTROL, priv->hsfreq << 1); in rk_dphy_enable()
218 rk_dphy_write(priv, LANE3_HS_RX_CONTROL, priv->hsfreq << 1); in rk_dphy_enable()
227 static int rk_dphy_configure(struct phy *phy, union phy_configure_opts *opts) in rk_dphy_configure() argument
229 struct rk_dphy *priv = phy_get_drvdata(phy); in rk_dphy_configure()
230 const struct rk_dphy_drv_data *drv_data = priv->drv_data; in rk_dphy_configure()
231 struct phy_configure_opts_mipi_dphy *config = &opts->mipi_dphy; in rk_dphy_configure()
242 data_rate_mbps = div_u64(config->hs_clk_rate, 1000 * 1000); in rk_dphy_configure()
244 dev_dbg(priv->dev, "lanes %d - data_rate_mbps %llu\n", in rk_dphy_configure()
245 config->lanes, data_rate_mbps); in rk_dphy_configure()
246 for (i = 0; i < drv_data->num_hsfreq_ranges; i++) { in rk_dphy_configure()
247 if (drv_data->hsfreq_ranges[i].range_h >= data_rate_mbps) { in rk_dphy_configure()
248 hsfreq = drv_data->hsfreq_ranges[i].cfg_bit; in rk_dphy_configure()
253 return -EINVAL; in rk_dphy_configure()
255 priv->hsfreq = hsfreq; in rk_dphy_configure()
256 priv->config = *config; in rk_dphy_configure()
260 static int rk_dphy_power_on(struct phy *phy) in rk_dphy_power_on() argument
262 struct rk_dphy *priv = phy_get_drvdata(phy); in rk_dphy_power_on()
265 ret = clk_bulk_enable(priv->drv_data->num_clks, priv->clks); in rk_dphy_power_on()
274 static int rk_dphy_power_off(struct phy *phy) in rk_dphy_power_off() argument
276 struct rk_dphy *priv = phy_get_drvdata(phy); in rk_dphy_power_off()
279 clk_bulk_disable(priv->drv_data->num_clks, priv->clks); in rk_dphy_power_off()
283 static int rk_dphy_init(struct phy *phy) in rk_dphy_init() argument
285 struct rk_dphy *priv = phy_get_drvdata(phy); in rk_dphy_init()
287 return clk_bulk_prepare(priv->drv_data->num_clks, priv->clks); in rk_dphy_init()
290 static int rk_dphy_exit(struct phy *phy) in rk_dphy_exit() argument
292 struct rk_dphy *priv = phy_get_drvdata(phy); in rk_dphy_exit()
294 clk_bulk_unprepare(priv->drv_data->num_clks, priv->clks); in rk_dphy_exit()
317 .compatible = "rockchip,rk3399-mipi-dphy-rx0",
326 struct device *dev = &pdev->dev; in rk_dphy_probe()
327 struct device_node *np = dev->of_node; in rk_dphy_probe()
331 struct phy *phy; in rk_dphy_probe() local
335 if (!dev->parent || !dev->parent->of_node) in rk_dphy_probe()
336 return -ENODEV; in rk_dphy_probe()
340 return -ENOMEM; in rk_dphy_probe()
341 priv->dev = dev; in rk_dphy_probe()
343 priv->grf = syscon_node_to_regmap(dev->parent->of_node); in rk_dphy_probe()
344 if (IS_ERR(priv->grf)) { in rk_dphy_probe()
345 dev_err(dev, "Can't find GRF syscon\n"); in rk_dphy_probe()
346 return -ENODEV; in rk_dphy_probe()
350 priv->drv_data = drv_data; in rk_dphy_probe()
351 priv->clks = devm_kcalloc(&pdev->dev, drv_data->num_clks, in rk_dphy_probe()
352 sizeof(*priv->clks), GFP_KERNEL); in rk_dphy_probe()
353 if (!priv->clks) in rk_dphy_probe()
354 return -ENOMEM; in rk_dphy_probe()
355 for (i = 0; i < drv_data->num_clks; i++) in rk_dphy_probe()
356 priv->clks[i].id = drv_data->clks[i]; in rk_dphy_probe()
357 ret = devm_clk_bulk_get(&pdev->dev, drv_data->num_clks, priv->clks); in rk_dphy_probe()
361 phy = devm_phy_create(dev, np, &rk_dphy_ops); in rk_dphy_probe()
362 if (IS_ERR(phy)) { in rk_dphy_probe()
363 dev_err(dev, "failed to create phy\n"); in rk_dphy_probe()
364 return PTR_ERR(phy); in rk_dphy_probe()
366 phy_set_drvdata(phy, priv); in rk_dphy_probe()
376 .name = "rockchip-mipi-dphy-rx0",