Lines Matching refs:phy
98 struct phy *phy; member
122 #define to_sun4i_usb_phy_data(phy) \ argument
123 container_of((phy), struct sun4i_usb_phy_data, phys[(phy)->index])
125 static void sun4i_usb_phy0_update_iscr(struct phy *_phy, u32 clr, u32 set) in sun4i_usb_phy0_update_iscr()
127 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy); in sun4i_usb_phy0_update_iscr() local
128 struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy); in sun4i_usb_phy0_update_iscr()
137 static void sun4i_usb_phy0_set_id_detect(struct phy *phy, u32 val) in sun4i_usb_phy0_set_id_detect() argument
144 sun4i_usb_phy0_update_iscr(phy, ISCR_FORCE_ID_MASK, val); in sun4i_usb_phy0_set_id_detect()
147 static void sun4i_usb_phy0_set_vbus_detect(struct phy *phy, u32 val) in sun4i_usb_phy0_set_vbus_detect() argument
154 sun4i_usb_phy0_update_iscr(phy, ISCR_FORCE_VBUS_MASK, val); in sun4i_usb_phy0_set_vbus_detect()
157 static void sun4i_usb_phy_write(struct sun4i_usb_phy *phy, u32 addr, u32 data, in sun4i_usb_phy_write() argument
160 struct sun4i_usb_phy_data *phy_data = to_sun4i_usb_phy_data(phy); in sun4i_usb_phy_write()
161 u32 temp, usbc_bit = BIT(phy->index * 2); in sun4i_usb_phy_write()
208 static void sun4i_usb_phy_passby(struct sun4i_usb_phy *phy, int enable) in sun4i_usb_phy_passby() argument
212 if (!phy->pmu) in sun4i_usb_phy_passby()
218 reg_value = readl(phy->pmu); in sun4i_usb_phy_passby()
225 writel(reg_value, phy->pmu); in sun4i_usb_phy_passby()
228 static int sun4i_usb_phy_init(struct phy *_phy) in sun4i_usb_phy_init()
230 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy); in sun4i_usb_phy_init() local
231 struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy); in sun4i_usb_phy_init()
234 ret = clk_prepare_enable(phy->clk); in sun4i_usb_phy_init()
238 ret = reset_control_deassert(phy->reset); in sun4i_usb_phy_init()
240 clk_disable_unprepare(phy->clk); in sun4i_usb_phy_init()
245 if (phy->index == 0) in sun4i_usb_phy_init()
246 sun4i_usb_phy_write(phy, PHY_RES45_CAL_EN, 0x01, 1); in sun4i_usb_phy_init()
249 sun4i_usb_phy_write(phy, PHY_TX_AMPLITUDE_TUNE, 0x14, 5); in sun4i_usb_phy_init()
252 sun4i_usb_phy_write(phy, PHY_DISCON_TH_SEL, data->disc_thresh, 2); in sun4i_usb_phy_init()
254 sun4i_usb_phy_passby(phy, 1); in sun4i_usb_phy_init()
256 if (phy->index == 0) { in sun4i_usb_phy_init()
278 static int sun4i_usb_phy_exit(struct phy *_phy) in sun4i_usb_phy_exit()
280 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy); in sun4i_usb_phy_exit() local
281 struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy); in sun4i_usb_phy_exit()
283 if (phy->index == 0) { in sun4i_usb_phy_exit()
290 sun4i_usb_phy_passby(phy, 0); in sun4i_usb_phy_exit()
291 reset_control_assert(phy->reset); in sun4i_usb_phy_exit()
292 clk_disable_unprepare(phy->clk); in sun4i_usb_phy_exit()
321 static int sun4i_usb_phy_power_on(struct phy *_phy) in sun4i_usb_phy_power_on()
323 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy); in sun4i_usb_phy_power_on() local
324 struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy); in sun4i_usb_phy_power_on()
327 if (!phy->vbus || phy->regulator_on) in sun4i_usb_phy_power_on()
331 if (phy->index == 0 && sun4i_usb_phy0_have_vbus_det(data) && in sun4i_usb_phy_power_on()
335 ret = regulator_enable(phy->vbus); in sun4i_usb_phy_power_on()
339 phy->regulator_on = true; in sun4i_usb_phy_power_on()
342 if (phy->index == 0 && data->vbus_det_gpio && data->phy0_poll) in sun4i_usb_phy_power_on()
348 static int sun4i_usb_phy_power_off(struct phy *_phy) in sun4i_usb_phy_power_off()
350 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy); in sun4i_usb_phy_power_off() local
351 struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy); in sun4i_usb_phy_power_off()
353 if (!phy->vbus || !phy->regulator_on) in sun4i_usb_phy_power_off()
356 regulator_disable(phy->vbus); in sun4i_usb_phy_power_off()
357 phy->regulator_on = false; in sun4i_usb_phy_power_off()
363 if (phy->index == 0 && data->vbus_det_gpio && !data->phy0_poll) in sun4i_usb_phy_power_off()
369 void sun4i_usb_phy_set_squelch_detect(struct phy *_phy, bool enabled) in sun4i_usb_phy_set_squelch_detect()
371 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy); in sun4i_usb_phy_set_squelch_detect() local
373 sun4i_usb_phy_write(phy, PHY_SQUELCH_DETECT, enabled ? 0 : 2, 2); in sun4i_usb_phy_set_squelch_detect()
389 struct phy *phy0 = data->phys[0].phy; in sun4i_usb_phy0_id_vbus_det_scan()
474 static struct phy *sun4i_usb_phy_xlate(struct device *dev, in sun4i_usb_phy_xlate()
482 return data->phys[args->args[0]].phy; in sun4i_usb_phy_xlate()
594 struct sun4i_usb_phy *phy = data->phys + i; in sun4i_usb_phy_probe() local
598 phy->vbus = devm_regulator_get_optional(dev, name); in sun4i_usb_phy_probe()
599 if (IS_ERR(phy->vbus)) { in sun4i_usb_phy_probe()
600 if (PTR_ERR(phy->vbus) == -EPROBE_DEFER) in sun4i_usb_phy_probe()
602 phy->vbus = NULL; in sun4i_usb_phy_probe()
610 phy->clk = devm_clk_get(dev, name); in sun4i_usb_phy_probe()
611 if (IS_ERR(phy->clk)) { in sun4i_usb_phy_probe()
613 return PTR_ERR(phy->clk); in sun4i_usb_phy_probe()
617 phy->reset = devm_reset_control_get(dev, name); in sun4i_usb_phy_probe()
618 if (IS_ERR(phy->reset)) { in sun4i_usb_phy_probe()
620 return PTR_ERR(phy->reset); in sun4i_usb_phy_probe()
627 phy->pmu = devm_ioremap_resource(dev, res); in sun4i_usb_phy_probe()
628 if (IS_ERR(phy->pmu)) in sun4i_usb_phy_probe()
629 return PTR_ERR(phy->pmu); in sun4i_usb_phy_probe()
632 phy->phy = devm_phy_create(dev, NULL, &sun4i_usb_phy_ops); in sun4i_usb_phy_probe()
633 if (IS_ERR(phy->phy)) { in sun4i_usb_phy_probe()
635 return PTR_ERR(phy->phy); in sun4i_usb_phy_probe()
638 phy->index = i; in sun4i_usb_phy_probe()
639 phy_set_drvdata(phy->phy, &data->phys[i]); in sun4i_usb_phy_probe()