Lines Matching refs:phy

2  * Allwinner sun4i USB phy driver
32 #include <linux/phy/phy.h>
70 struct phy *phy;
79 #define to_sun4i_usb_phy_data(phy) \
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,
85 struct sun4i_usb_phy_data *phy_data = to_sun4i_usb_phy_data(phy);
86 u32 temp, usbc_bit = BIT(phy->index * 2);
124 static void sun4i_usb_phy_passby(struct sun4i_usb_phy *phy, int enable)
128 if (!phy->pmu)
134 reg_value = readl(phy->pmu);
141 writel(reg_value, phy->pmu);
144 static int sun4i_usb_phy_init(struct phy *_phy)
146 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy);
147 struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy);
150 ret = clk_prepare_enable(phy->clk);
154 ret = reset_control_deassert(phy->reset);
156 clk_disable_unprepare(phy->clk);
161 sun4i_usb_phy_write(phy, PHY_TX_AMPLITUDE_TUNE, 0x14, 5);
164 sun4i_usb_phy_write(phy, PHY_DISCON_TH_SEL, data->disc_thresh, 2);
166 sun4i_usb_phy_passby(phy, 1);
171 static int sun4i_usb_phy_exit(struct phy *_phy)
173 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy);
175 sun4i_usb_phy_passby(phy, 0);
176 reset_control_assert(phy->reset);
177 clk_disable_unprepare(phy->clk);
182 static int sun4i_usb_phy_power_on(struct phy *_phy)
184 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy);
187 if (phy->vbus)
188 ret = regulator_enable(phy->vbus);
193 static int sun4i_usb_phy_power_off(struct phy *_phy)
195 struct sun4i_usb_phy *phy = phy_get_drvdata(_phy);
197 if (phy->vbus)
198 regulator_disable(phy->vbus);
211 static struct phy *sun4i_usb_phy_xlate(struct device *dev,
219 return data->phys[args->args[0]].phy;
238 if (of_device_is_compatible(np, "allwinner,sun5i-a13-usb-phy"))
243 if (of_device_is_compatible(np, "allwinner,sun4i-a10-usb-phy"))
248 if (of_device_is_compatible(np, "allwinner,sun6i-a31-usb-phy"))
258 /* Skip 0, 0 is the phy for otg which is not yet supported. */
260 struct sun4i_usb_phy *phy = data->phys + i;
264 phy->vbus = devm_regulator_get_optional(dev, name);
265 if (IS_ERR(phy->vbus)) {
266 if (PTR_ERR(phy->vbus) == -EPROBE_DEFER)
268 phy->vbus = NULL;
276 phy->clk = devm_clk_get(dev, name);
277 if (IS_ERR(phy->clk)) {
279 return PTR_ERR(phy->clk);
283 phy->reset = devm_reset_control_get(dev, name);
284 if (IS_ERR(phy->reset)) {
286 return PTR_ERR(phy->reset);
293 phy->pmu = devm_ioremap_resource(dev, res);
294 if (IS_ERR(phy->pmu))
295 return PTR_ERR(phy->pmu);
298 phy->phy = devm_phy_create(dev, NULL, &sun4i_usb_phy_ops, NULL);
299 if (IS_ERR(phy->phy)) {
301 return PTR_ERR(phy->phy);
304 phy->index = i;
305 phy_set_drvdata(phy->phy, &data->phys[i]);
315 { .compatible = "allwinner,sun4i-a10-usb-phy" },
316 { .compatible = "allwinner,sun5i-a13-usb-phy" },
317 { .compatible = "allwinner,sun6i-a31-usb-phy" },
318 { .compatible = "allwinner,sun7i-a20-usb-phy" },
327 .name = "sun4i-usb-phy",
332 MODULE_DESCRIPTION("Allwinner sun4i USB phy driver");