Lines Matching refs:rk_phy
88 struct rockchip_pcie_phy *rk_phy = dev_get_drvdata(dev); in rockchip_pcie_phy_of_xlate() local
91 return rk_phy->phys[0].phy; in rockchip_pcie_phy_of_xlate()
96 return rk_phy->phys[args->args[0]].phy; in rockchip_pcie_phy_of_xlate()
100 static inline void phy_wr_cfg(struct rockchip_pcie_phy *rk_phy, in phy_wr_cfg() argument
103 regmap_write(rk_phy->reg_base, rk_phy->phy_data->pcie_conf, in phy_wr_cfg()
111 regmap_write(rk_phy->reg_base, rk_phy->phy_data->pcie_conf, in phy_wr_cfg()
116 regmap_write(rk_phy->reg_base, rk_phy->phy_data->pcie_conf, in phy_wr_cfg()
122 static inline u32 phy_rd_cfg(struct rockchip_pcie_phy *rk_phy, in phy_rd_cfg() argument
127 regmap_write(rk_phy->reg_base, rk_phy->phy_data->pcie_conf, in phy_rd_cfg()
131 regmap_read(rk_phy->reg_base, in phy_rd_cfg()
132 rk_phy->phy_data->pcie_status, in phy_rd_cfg()
140 struct rockchip_pcie_phy *rk_phy = to_pcie_phy(inst); in rockchip_pcie_phy_power_off() local
143 mutex_lock(&rk_phy->pcie_mutex); in rockchip_pcie_phy_power_off()
145 regmap_write(rk_phy->reg_base, in rockchip_pcie_phy_power_off()
146 rk_phy->phy_data->pcie_laneoff, in rockchip_pcie_phy_power_off()
151 if (--rk_phy->pwr_cnt) in rockchip_pcie_phy_power_off()
154 err = reset_control_assert(rk_phy->phy_rst); in rockchip_pcie_phy_power_off()
161 mutex_unlock(&rk_phy->pcie_mutex); in rockchip_pcie_phy_power_off()
165 rk_phy->pwr_cnt++; in rockchip_pcie_phy_power_off()
166 regmap_write(rk_phy->reg_base, in rockchip_pcie_phy_power_off()
167 rk_phy->phy_data->pcie_laneoff, in rockchip_pcie_phy_power_off()
171 mutex_unlock(&rk_phy->pcie_mutex); in rockchip_pcie_phy_power_off()
178 struct rockchip_pcie_phy *rk_phy = to_pcie_phy(inst); in rockchip_pcie_phy_power_on() local
183 mutex_lock(&rk_phy->pcie_mutex); in rockchip_pcie_phy_power_on()
185 if (rk_phy->pwr_cnt++) in rockchip_pcie_phy_power_on()
188 err = reset_control_deassert(rk_phy->phy_rst); in rockchip_pcie_phy_power_on()
194 regmap_write(rk_phy->reg_base, rk_phy->phy_data->pcie_conf, in rockchip_pcie_phy_power_on()
199 regmap_write(rk_phy->reg_base, in rockchip_pcie_phy_power_on()
200 rk_phy->phy_data->pcie_laneoff, in rockchip_pcie_phy_power_on()
214 regmap_read(rk_phy->reg_base, in rockchip_pcie_phy_power_on()
215 rk_phy->phy_data->pcie_status, in rockchip_pcie_phy_power_on()
230 phy_wr_cfg(rk_phy, PHY_CFG_CLK_TEST, PHY_CFG_SEPE_RATE); in rockchip_pcie_phy_power_on()
231 phy_wr_cfg(rk_phy, PHY_CFG_CLK_SCC, PHY_CFG_PLL_100M); in rockchip_pcie_phy_power_on()
235 regmap_read(rk_phy->reg_base, in rockchip_pcie_phy_power_on()
236 rk_phy->phy_data->pcie_status, in rockchip_pcie_phy_power_on()
251 regmap_write(rk_phy->reg_base, rk_phy->phy_data->pcie_conf, in rockchip_pcie_phy_power_on()
257 regmap_read(rk_phy->reg_base, in rockchip_pcie_phy_power_on()
258 rk_phy->phy_data->pcie_status, in rockchip_pcie_phy_power_on()
274 mutex_unlock(&rk_phy->pcie_mutex); in rockchip_pcie_phy_power_on()
278 reset_control_assert(rk_phy->phy_rst); in rockchip_pcie_phy_power_on()
280 rk_phy->pwr_cnt--; in rockchip_pcie_phy_power_on()
281 mutex_unlock(&rk_phy->pcie_mutex); in rockchip_pcie_phy_power_on()
288 struct rockchip_pcie_phy *rk_phy = to_pcie_phy(inst); in rockchip_pcie_phy_init() local
291 mutex_lock(&rk_phy->pcie_mutex); in rockchip_pcie_phy_init()
293 if (rk_phy->init_cnt++) in rockchip_pcie_phy_init()
296 err = clk_prepare_enable(rk_phy->clk_pciephy_ref); in rockchip_pcie_phy_init()
302 err = reset_control_assert(rk_phy->phy_rst); in rockchip_pcie_phy_init()
309 mutex_unlock(&rk_phy->pcie_mutex); in rockchip_pcie_phy_init()
314 clk_disable_unprepare(rk_phy->clk_pciephy_ref); in rockchip_pcie_phy_init()
316 rk_phy->init_cnt--; in rockchip_pcie_phy_init()
317 mutex_unlock(&rk_phy->pcie_mutex); in rockchip_pcie_phy_init()
324 struct rockchip_pcie_phy *rk_phy = to_pcie_phy(inst); in rockchip_pcie_phy_exit() local
326 mutex_lock(&rk_phy->pcie_mutex); in rockchip_pcie_phy_exit()
328 if (--rk_phy->init_cnt) in rockchip_pcie_phy_exit()
331 clk_disable_unprepare(rk_phy->clk_pciephy_ref); in rockchip_pcie_phy_exit()
334 mutex_unlock(&rk_phy->pcie_mutex); in rockchip_pcie_phy_exit()
365 struct rockchip_pcie_phy *rk_phy; in rockchip_pcie_phy_probe() local
378 rk_phy = devm_kzalloc(dev, sizeof(*rk_phy), GFP_KERNEL); in rockchip_pcie_phy_probe()
379 if (!rk_phy) in rockchip_pcie_phy_probe()
386 rk_phy->phy_data = (struct rockchip_pcie_data *)of_id->data; in rockchip_pcie_phy_probe()
387 rk_phy->reg_base = grf; in rockchip_pcie_phy_probe()
389 mutex_init(&rk_phy->pcie_mutex); in rockchip_pcie_phy_probe()
391 rk_phy->phy_rst = devm_reset_control_get(dev, "phy"); in rockchip_pcie_phy_probe()
392 if (IS_ERR(rk_phy->phy_rst)) { in rockchip_pcie_phy_probe()
393 if (PTR_ERR(rk_phy->phy_rst) != -EPROBE_DEFER) in rockchip_pcie_phy_probe()
396 return PTR_ERR(rk_phy->phy_rst); in rockchip_pcie_phy_probe()
399 rk_phy->clk_pciephy_ref = devm_clk_get(dev, "refclk"); in rockchip_pcie_phy_probe()
400 if (IS_ERR(rk_phy->clk_pciephy_ref)) { in rockchip_pcie_phy_probe()
402 return PTR_ERR(rk_phy->clk_pciephy_ref); in rockchip_pcie_phy_probe()
413 rk_phy->phys[i].phy = devm_phy_create(dev, dev->of_node, &ops); in rockchip_pcie_phy_probe()
414 if (IS_ERR(rk_phy->phys[i].phy)) { in rockchip_pcie_phy_probe()
416 return PTR_ERR(rk_phy->phys[i].phy); in rockchip_pcie_phy_probe()
418 rk_phy->phys[i].index = i; in rockchip_pcie_phy_probe()
419 phy_set_drvdata(rk_phy->phys[i].phy, &rk_phy->phys[i]); in rockchip_pcie_phy_probe()
422 platform_set_drvdata(pdev, rk_phy); in rockchip_pcie_phy_probe()