Lines Matching refs:phy

70 		struct phy *phy;  member
79 #define to_sun4i_usb_phy_data(phy) \ argument
80 container_of((phy), struct sun4i_usb_phy_data, phys[(phy)->index])
82 static void sun4i_usb_phy_write(struct sun4i_usb_phy *phy, u32 addr, u32 data, in sun4i_usb_phy_write() argument
85 struct sun4i_usb_phy_data *phy_data = to_sun4i_usb_phy_data(phy); in sun4i_usb_phy_write()
86 u32 temp, usbc_bit = BIT(phy->index * 2); in sun4i_usb_phy_write()
124 static void sun4i_usb_phy_passby(struct sun4i_usb_phy *phy, int enable) in sun4i_usb_phy_passby() argument
128 if (!phy->pmu) in sun4i_usb_phy_passby()
134 reg_value = readl(phy->pmu); in sun4i_usb_phy_passby()
141 writel(reg_value, phy->pmu); in sun4i_usb_phy_passby()
144 static int sun4i_usb_phy_init(struct phy *_phy) in sun4i_usb_phy_init()
146 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy); in sun4i_usb_phy_init() local
147 struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy); in sun4i_usb_phy_init()
150 ret = clk_prepare_enable(phy->clk); in sun4i_usb_phy_init()
154 ret = reset_control_deassert(phy->reset); in sun4i_usb_phy_init()
156 clk_disable_unprepare(phy->clk); in sun4i_usb_phy_init()
161 if (phy->index == 0) in sun4i_usb_phy_init()
162 sun4i_usb_phy_write(phy, PHY_RES45_CAL_EN, 0x01, 1); in sun4i_usb_phy_init()
165 sun4i_usb_phy_write(phy, PHY_TX_AMPLITUDE_TUNE, 0x14, 5); in sun4i_usb_phy_init()
168 sun4i_usb_phy_write(phy, PHY_DISCON_TH_SEL, data->disc_thresh, 2); in sun4i_usb_phy_init()
170 sun4i_usb_phy_passby(phy, 1); in sun4i_usb_phy_init()
175 static int sun4i_usb_phy_exit(struct phy *_phy) in sun4i_usb_phy_exit()
177 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy); in sun4i_usb_phy_exit() local
179 sun4i_usb_phy_passby(phy, 0); in sun4i_usb_phy_exit()
180 reset_control_assert(phy->reset); in sun4i_usb_phy_exit()
181 clk_disable_unprepare(phy->clk); in sun4i_usb_phy_exit()
186 static int sun4i_usb_phy_power_on(struct phy *_phy) in sun4i_usb_phy_power_on()
188 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy); in sun4i_usb_phy_power_on() local
191 if (phy->vbus) in sun4i_usb_phy_power_on()
192 ret = regulator_enable(phy->vbus); in sun4i_usb_phy_power_on()
197 static int sun4i_usb_phy_power_off(struct phy *_phy) in sun4i_usb_phy_power_off()
199 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy); in sun4i_usb_phy_power_off() local
201 if (phy->vbus) in sun4i_usb_phy_power_off()
202 regulator_disable(phy->vbus); in sun4i_usb_phy_power_off()
215 static struct phy *sun4i_usb_phy_xlate(struct device *dev, in sun4i_usb_phy_xlate()
223 return data->phys[args->args[0]].phy; in sun4i_usb_phy_xlate()
264 struct sun4i_usb_phy *phy = data->phys + i; in sun4i_usb_phy_probe() local
268 phy->vbus = devm_regulator_get_optional(dev, name); in sun4i_usb_phy_probe()
269 if (IS_ERR(phy->vbus)) { in sun4i_usb_phy_probe()
270 if (PTR_ERR(phy->vbus) == -EPROBE_DEFER) in sun4i_usb_phy_probe()
272 phy->vbus = NULL; in sun4i_usb_phy_probe()
280 phy->clk = devm_clk_get(dev, name); in sun4i_usb_phy_probe()
281 if (IS_ERR(phy->clk)) { in sun4i_usb_phy_probe()
283 return PTR_ERR(phy->clk); in sun4i_usb_phy_probe()
287 phy->reset = devm_reset_control_get(dev, name); in sun4i_usb_phy_probe()
288 if (IS_ERR(phy->reset)) { in sun4i_usb_phy_probe()
290 return PTR_ERR(phy->reset); in sun4i_usb_phy_probe()
297 phy->pmu = devm_ioremap_resource(dev, res); in sun4i_usb_phy_probe()
298 if (IS_ERR(phy->pmu)) in sun4i_usb_phy_probe()
299 return PTR_ERR(phy->pmu); in sun4i_usb_phy_probe()
302 phy->phy = devm_phy_create(dev, NULL, &sun4i_usb_phy_ops); in sun4i_usb_phy_probe()
303 if (IS_ERR(phy->phy)) { in sun4i_usb_phy_probe()
305 return PTR_ERR(phy->phy); in sun4i_usb_phy_probe()
308 phy->index = i; in sun4i_usb_phy_probe()
309 phy_set_drvdata(phy->phy, &data->phys[i]); in sun4i_usb_phy_probe()