Lines Matching refs:mxs_phy
92 #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
156 struct mxs_phy { struct
164 static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy) in is_imx6q_phy() argument
166 return mxs_phy->data == &imx6q_phy_data; in is_imx6q_phy()
169 static inline bool is_imx6sl_phy(struct mxs_phy *mxs_phy) in is_imx6sl_phy() argument
171 return mxs_phy->data == &imx6sl_phy_data; in is_imx6sl_phy()
183 static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) in mxs_phy_hw_init() argument
186 void __iomem *base = mxs_phy->phy.io_priv; in mxs_phy_hw_init()
209 if (mxs_phy->data->flags & MXS_PHY_NEED_IP_FIX) in mxs_phy_hw_init()
216 static bool mxs_phy_get_vbus_status(struct mxs_phy *mxs_phy) in mxs_phy_get_vbus_status() argument
220 if (!mxs_phy->regmap_anatop) in mxs_phy_get_vbus_status()
223 if (mxs_phy->port_id == 0) in mxs_phy_get_vbus_status()
224 regmap_read(mxs_phy->regmap_anatop, in mxs_phy_get_vbus_status()
227 else if (mxs_phy->port_id == 1) in mxs_phy_get_vbus_status()
228 regmap_read(mxs_phy->regmap_anatop, in mxs_phy_get_vbus_status()
238 static void __mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool disconnect) in __mxs_phy_disconnect_line() argument
240 void __iomem *base = mxs_phy->phy.io_priv; in __mxs_phy_disconnect_line()
247 if (mxs_phy->port_id == 0) { in __mxs_phy_disconnect_line()
250 regmap_write(mxs_phy->regmap_anatop, reg, in __mxs_phy_disconnect_line()
253 } else if (mxs_phy->port_id == 1) { in __mxs_phy_disconnect_line()
256 regmap_write(mxs_phy->regmap_anatop, reg, in __mxs_phy_disconnect_line()
270 static bool mxs_phy_is_otg_host(struct mxs_phy *mxs_phy) in mxs_phy_is_otg_host() argument
272 void __iomem *base = mxs_phy->phy.io_priv; in mxs_phy_is_otg_host()
282 static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on) in mxs_phy_disconnect_line() argument
287 if (!(mxs_phy->data->flags & MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS)) in mxs_phy_disconnect_line()
291 if (!mxs_phy->regmap_anatop) in mxs_phy_disconnect_line()
294 vbus_is_on = mxs_phy_get_vbus_status(mxs_phy); in mxs_phy_disconnect_line()
296 if (on && !vbus_is_on && !mxs_phy_is_otg_host(mxs_phy)) in mxs_phy_disconnect_line()
297 __mxs_phy_disconnect_line(mxs_phy, true); in mxs_phy_disconnect_line()
299 __mxs_phy_disconnect_line(mxs_phy, false); in mxs_phy_disconnect_line()
306 struct mxs_phy *mxs_phy = to_mxs_phy(phy); in mxs_phy_init() local
309 ret = clk_prepare_enable(mxs_phy->clk); in mxs_phy_init()
313 return mxs_phy_hw_init(mxs_phy); in mxs_phy_init()
318 struct mxs_phy *mxs_phy = to_mxs_phy(phy); in mxs_phy_shutdown() local
334 clk_disable_unprepare(mxs_phy->clk); in mxs_phy_shutdown()
337 static bool mxs_phy_is_low_speed_connection(struct mxs_phy *mxs_phy) in mxs_phy_is_low_speed_connection() argument
346 if (!mxs_phy->regmap_anatop) in mxs_phy_is_low_speed_connection()
349 if (mxs_phy->port_id == 0) in mxs_phy_is_low_speed_connection()
351 else if (mxs_phy->port_id == 1) in mxs_phy_is_low_speed_connection()
354 regmap_read(mxs_phy->regmap_anatop, reg, &line_state); in mxs_phy_is_low_speed_connection()
365 struct mxs_phy *mxs_phy = to_mxs_phy(x); in mxs_phy_suspend() local
368 low_speed_connection = mxs_phy_is_low_speed_connection(mxs_phy); in mxs_phy_suspend()
369 vbus_is_on = mxs_phy_get_vbus_status(mxs_phy); in mxs_phy_suspend()
389 clk_disable_unprepare(mxs_phy->clk); in mxs_phy_suspend()
392 ret = clk_prepare_enable(mxs_phy->clk); in mxs_phy_suspend()
405 struct mxs_phy *mxs_phy = to_mxs_phy(x); in mxs_phy_set_wakeup() local
410 mxs_phy_disconnect_line(mxs_phy, true); in mxs_phy_set_wakeup()
414 mxs_phy_disconnect_line(mxs_phy, false); in mxs_phy_set_wakeup()
453 struct mxs_phy *mxs_phy; in mxs_phy_probe() local
471 mxs_phy = devm_kzalloc(&pdev->dev, sizeof(*mxs_phy), GFP_KERNEL); in mxs_phy_probe()
472 if (!mxs_phy) in mxs_phy_probe()
477 mxs_phy->regmap_anatop = syscon_regmap_lookup_by_phandle in mxs_phy_probe()
479 if (IS_ERR(mxs_phy->regmap_anatop)) { in mxs_phy_probe()
482 return PTR_ERR(mxs_phy->regmap_anatop); in mxs_phy_probe()
489 mxs_phy->port_id = ret; in mxs_phy_probe()
491 mxs_phy->phy.io_priv = base; in mxs_phy_probe()
492 mxs_phy->phy.dev = &pdev->dev; in mxs_phy_probe()
493 mxs_phy->phy.label = DRIVER_NAME; in mxs_phy_probe()
494 mxs_phy->phy.init = mxs_phy_init; in mxs_phy_probe()
495 mxs_phy->phy.shutdown = mxs_phy_shutdown; in mxs_phy_probe()
496 mxs_phy->phy.set_suspend = mxs_phy_suspend; in mxs_phy_probe()
497 mxs_phy->phy.notify_connect = mxs_phy_on_connect; in mxs_phy_probe()
498 mxs_phy->phy.notify_disconnect = mxs_phy_on_disconnect; in mxs_phy_probe()
499 mxs_phy->phy.type = USB_PHY_TYPE_USB2; in mxs_phy_probe()
500 mxs_phy->phy.set_wakeup = mxs_phy_set_wakeup; in mxs_phy_probe()
502 mxs_phy->clk = clk; in mxs_phy_probe()
503 mxs_phy->data = of_id->data; in mxs_phy_probe()
505 platform_set_drvdata(pdev, mxs_phy); in mxs_phy_probe()
509 ret = usb_add_phy_dev(&mxs_phy->phy); in mxs_phy_probe()
518 struct mxs_phy *mxs_phy = platform_get_drvdata(pdev); in mxs_phy_remove() local
520 usb_remove_phy(&mxs_phy->phy); in mxs_phy_remove()
526 static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on) in mxs_phy_enable_ldo_in_suspend() argument
531 if (!mxs_phy->regmap_anatop) in mxs_phy_enable_ldo_in_suspend()
534 if (is_imx6q_phy(mxs_phy)) in mxs_phy_enable_ldo_in_suspend()
535 regmap_write(mxs_phy->regmap_anatop, reg, in mxs_phy_enable_ldo_in_suspend()
537 else if (is_imx6sl_phy(mxs_phy)) in mxs_phy_enable_ldo_in_suspend()
538 regmap_write(mxs_phy->regmap_anatop, in mxs_phy_enable_ldo_in_suspend()
544 struct mxs_phy *mxs_phy = dev_get_drvdata(dev); in mxs_phy_system_suspend() local
547 mxs_phy_enable_ldo_in_suspend(mxs_phy, true); in mxs_phy_system_suspend()
554 struct mxs_phy *mxs_phy = dev_get_drvdata(dev); in mxs_phy_system_resume() local
557 mxs_phy_enable_ldo_in_suspend(mxs_phy, false); in mxs_phy_system_resume()