• Home
  • Raw
  • Download

Lines Matching +full:phy +full:- +full:mode

2  * Meson GXL and GXM USB2 PHY driver
21 #include <linux/phy/phy.h>
24 /* bits [31:27] are read-only */
72 /* bits [31:14] are read-only */
100 enum phy_mode mode; member
113 static int phy_meson_gxl_usb2_init(struct phy *phy) in phy_meson_gxl_usb2_init() argument
115 struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy); in phy_meson_gxl_usb2_init()
118 ret = reset_control_reset(priv->reset); in phy_meson_gxl_usb2_init()
122 ret = clk_prepare_enable(priv->clk); in phy_meson_gxl_usb2_init()
129 static int phy_meson_gxl_usb2_exit(struct phy *phy) in phy_meson_gxl_usb2_exit() argument
131 struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy); in phy_meson_gxl_usb2_exit()
133 clk_disable_unprepare(priv->clk); in phy_meson_gxl_usb2_exit()
138 static int phy_meson_gxl_usb2_reset(struct phy *phy) in phy_meson_gxl_usb2_reset() argument
140 struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy); in phy_meson_gxl_usb2_reset()
142 if (priv->is_enabled) { in phy_meson_gxl_usb2_reset()
143 /* reset the PHY and wait until settings are stabilized */ in phy_meson_gxl_usb2_reset()
144 regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_POWER_ON_RESET, in phy_meson_gxl_usb2_reset()
147 regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_POWER_ON_RESET, in phy_meson_gxl_usb2_reset()
155 static int phy_meson_gxl_usb2_set_mode(struct phy *phy, enum phy_mode mode) in phy_meson_gxl_usb2_set_mode() argument
157 struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy); in phy_meson_gxl_usb2_set_mode()
159 switch (mode) { in phy_meson_gxl_usb2_set_mode()
162 regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_DM_PULLDOWN, in phy_meson_gxl_usb2_set_mode()
164 regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_DP_PULLDOWN, in phy_meson_gxl_usb2_set_mode()
166 regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_ID_PULLUP, 0); in phy_meson_gxl_usb2_set_mode()
170 regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_DM_PULLDOWN, in phy_meson_gxl_usb2_set_mode()
172 regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_DP_PULLDOWN, in phy_meson_gxl_usb2_set_mode()
174 regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_ID_PULLUP, in phy_meson_gxl_usb2_set_mode()
179 return -EINVAL; in phy_meson_gxl_usb2_set_mode()
182 phy_meson_gxl_usb2_reset(phy); in phy_meson_gxl_usb2_set_mode()
184 priv->mode = mode; in phy_meson_gxl_usb2_set_mode()
189 static int phy_meson_gxl_usb2_power_off(struct phy *phy) in phy_meson_gxl_usb2_power_off() argument
191 struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy); in phy_meson_gxl_usb2_power_off()
193 priv->is_enabled = 0; in phy_meson_gxl_usb2_power_off()
195 /* power off the PHY by putting it into reset mode */ in phy_meson_gxl_usb2_power_off()
196 regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_POWER_ON_RESET, in phy_meson_gxl_usb2_power_off()
202 static int phy_meson_gxl_usb2_power_on(struct phy *phy) in phy_meson_gxl_usb2_power_on() argument
204 struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy); in phy_meson_gxl_usb2_power_on()
207 priv->is_enabled = 1; in phy_meson_gxl_usb2_power_on()
209 /* power on the PHY by taking it out of reset mode */ in phy_meson_gxl_usb2_power_on()
210 regmap_update_bits(priv->regmap, U2P_R0, U2P_R0_POWER_ON_RESET, 0); in phy_meson_gxl_usb2_power_on()
212 ret = phy_meson_gxl_usb2_set_mode(phy, priv->mode); in phy_meson_gxl_usb2_power_on()
214 phy_meson_gxl_usb2_power_off(phy); in phy_meson_gxl_usb2_power_on()
216 dev_err(&phy->dev, "Failed to initialize PHY with mode %d\n", in phy_meson_gxl_usb2_power_on()
217 priv->mode); in phy_meson_gxl_usb2_power_on()
236 struct device *dev = &pdev->dev; in phy_meson_gxl_usb2_probe()
240 struct phy *phy; in phy_meson_gxl_usb2_probe() local
246 return -ENOMEM; in phy_meson_gxl_usb2_probe()
255 /* start in host mode */ in phy_meson_gxl_usb2_probe()
256 priv->mode = PHY_MODE_USB_HOST; in phy_meson_gxl_usb2_probe()
258 priv->regmap = devm_regmap_init_mmio(dev, base, in phy_meson_gxl_usb2_probe()
260 if (IS_ERR(priv->regmap)) in phy_meson_gxl_usb2_probe()
261 return PTR_ERR(priv->regmap); in phy_meson_gxl_usb2_probe()
263 priv->clk = devm_clk_get(dev, "phy"); in phy_meson_gxl_usb2_probe()
264 if (IS_ERR(priv->clk)) { in phy_meson_gxl_usb2_probe()
265 ret = PTR_ERR(priv->clk); in phy_meson_gxl_usb2_probe()
266 if (ret == -ENOENT) in phy_meson_gxl_usb2_probe()
267 priv->clk = NULL; in phy_meson_gxl_usb2_probe()
272 priv->reset = devm_reset_control_get_optional_shared(dev, "phy"); in phy_meson_gxl_usb2_probe()
273 if (IS_ERR(priv->reset)) in phy_meson_gxl_usb2_probe()
274 return PTR_ERR(priv->reset); in phy_meson_gxl_usb2_probe()
276 phy = devm_phy_create(dev, NULL, &phy_meson_gxl_usb2_ops); in phy_meson_gxl_usb2_probe()
277 if (IS_ERR(phy)) { in phy_meson_gxl_usb2_probe()
278 ret = PTR_ERR(phy); in phy_meson_gxl_usb2_probe()
279 if (ret != -EPROBE_DEFER) in phy_meson_gxl_usb2_probe()
280 dev_err(dev, "failed to create PHY\n"); in phy_meson_gxl_usb2_probe()
285 phy_set_drvdata(phy, priv); in phy_meson_gxl_usb2_probe()
293 { .compatible = "amlogic,meson-gxl-usb2-phy", },
301 .name = "phy-meson-gxl-usb2",
308 MODULE_DESCRIPTION("Meson GXL and GXM USB2 PHY driver");