Lines Matching refs:mxs_phy
92 #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
161 struct mxs_phy { struct
169 static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy) in is_imx6q_phy() argument
171 return mxs_phy->data == &imx6q_phy_data; in is_imx6q_phy()
174 static inline bool is_imx6sl_phy(struct mxs_phy *mxs_phy) in is_imx6sl_phy() argument
176 return mxs_phy->data == &imx6sl_phy_data; in is_imx6sl_phy()
188 static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) in mxs_phy_hw_init() argument
191 void __iomem *base = mxs_phy->phy.io_priv; in mxs_phy_hw_init()
214 if (mxs_phy->data->flags & MXS_PHY_NEED_IP_FIX) in mxs_phy_hw_init()
221 static bool mxs_phy_get_vbus_status(struct mxs_phy *mxs_phy) in mxs_phy_get_vbus_status() argument
225 if (!mxs_phy->regmap_anatop) in mxs_phy_get_vbus_status()
228 if (mxs_phy->port_id == 0) in mxs_phy_get_vbus_status()
229 regmap_read(mxs_phy->regmap_anatop, in mxs_phy_get_vbus_status()
232 else if (mxs_phy->port_id == 1) in mxs_phy_get_vbus_status()
233 regmap_read(mxs_phy->regmap_anatop, in mxs_phy_get_vbus_status()
243 static void __mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool disconnect) in __mxs_phy_disconnect_line() argument
245 void __iomem *base = mxs_phy->phy.io_priv; in __mxs_phy_disconnect_line()
252 if (mxs_phy->port_id == 0) { in __mxs_phy_disconnect_line()
255 regmap_write(mxs_phy->regmap_anatop, reg, in __mxs_phy_disconnect_line()
258 } else if (mxs_phy->port_id == 1) { in __mxs_phy_disconnect_line()
261 regmap_write(mxs_phy->regmap_anatop, reg, in __mxs_phy_disconnect_line()
275 static bool mxs_phy_is_otg_host(struct mxs_phy *mxs_phy) in mxs_phy_is_otg_host() argument
277 void __iomem *base = mxs_phy->phy.io_priv; in mxs_phy_is_otg_host()
287 static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on) in mxs_phy_disconnect_line() argument
292 if (!(mxs_phy->data->flags & MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS)) in mxs_phy_disconnect_line()
296 if (!mxs_phy->regmap_anatop) in mxs_phy_disconnect_line()
299 vbus_is_on = mxs_phy_get_vbus_status(mxs_phy); in mxs_phy_disconnect_line()
301 if (on && !vbus_is_on && !mxs_phy_is_otg_host(mxs_phy)) in mxs_phy_disconnect_line()
302 __mxs_phy_disconnect_line(mxs_phy, true); in mxs_phy_disconnect_line()
304 __mxs_phy_disconnect_line(mxs_phy, false); in mxs_phy_disconnect_line()
311 struct mxs_phy *mxs_phy = to_mxs_phy(phy); in mxs_phy_init() local
314 ret = clk_prepare_enable(mxs_phy->clk); in mxs_phy_init()
318 return mxs_phy_hw_init(mxs_phy); in mxs_phy_init()
323 struct mxs_phy *mxs_phy = to_mxs_phy(phy); in mxs_phy_shutdown() local
339 clk_disable_unprepare(mxs_phy->clk); in mxs_phy_shutdown()
342 static bool mxs_phy_is_low_speed_connection(struct mxs_phy *mxs_phy) in mxs_phy_is_low_speed_connection() argument
351 if (!mxs_phy->regmap_anatop) in mxs_phy_is_low_speed_connection()
354 if (mxs_phy->port_id == 0) in mxs_phy_is_low_speed_connection()
356 else if (mxs_phy->port_id == 1) in mxs_phy_is_low_speed_connection()
359 regmap_read(mxs_phy->regmap_anatop, reg, &line_state); in mxs_phy_is_low_speed_connection()
370 struct mxs_phy *mxs_phy = to_mxs_phy(x); in mxs_phy_suspend() local
373 low_speed_connection = mxs_phy_is_low_speed_connection(mxs_phy); in mxs_phy_suspend()
374 vbus_is_on = mxs_phy_get_vbus_status(mxs_phy); in mxs_phy_suspend()
394 clk_disable_unprepare(mxs_phy->clk); in mxs_phy_suspend()
397 ret = clk_prepare_enable(mxs_phy->clk); in mxs_phy_suspend()
410 struct mxs_phy *mxs_phy = to_mxs_phy(x); in mxs_phy_set_wakeup() local
415 mxs_phy_disconnect_line(mxs_phy, true); in mxs_phy_set_wakeup()
419 mxs_phy_disconnect_line(mxs_phy, false); in mxs_phy_set_wakeup()
458 struct mxs_phy *mxs_phy; in mxs_phy_probe() local
479 mxs_phy = devm_kzalloc(&pdev->dev, sizeof(*mxs_phy), GFP_KERNEL); in mxs_phy_probe()
480 if (!mxs_phy) in mxs_phy_probe()
485 mxs_phy->regmap_anatop = syscon_regmap_lookup_by_phandle in mxs_phy_probe()
487 if (IS_ERR(mxs_phy->regmap_anatop)) { in mxs_phy_probe()
490 return PTR_ERR(mxs_phy->regmap_anatop); in mxs_phy_probe()
497 mxs_phy->port_id = ret; in mxs_phy_probe()
499 mxs_phy->phy.io_priv = base; in mxs_phy_probe()
500 mxs_phy->phy.dev = &pdev->dev; in mxs_phy_probe()
501 mxs_phy->phy.label = DRIVER_NAME; in mxs_phy_probe()
502 mxs_phy->phy.init = mxs_phy_init; in mxs_phy_probe()
503 mxs_phy->phy.shutdown = mxs_phy_shutdown; in mxs_phy_probe()
504 mxs_phy->phy.set_suspend = mxs_phy_suspend; in mxs_phy_probe()
505 mxs_phy->phy.notify_connect = mxs_phy_on_connect; in mxs_phy_probe()
506 mxs_phy->phy.notify_disconnect = mxs_phy_on_disconnect; in mxs_phy_probe()
507 mxs_phy->phy.type = USB_PHY_TYPE_USB2; in mxs_phy_probe()
508 mxs_phy->phy.set_wakeup = mxs_phy_set_wakeup; in mxs_phy_probe()
510 mxs_phy->clk = clk; in mxs_phy_probe()
511 mxs_phy->data = of_id->data; in mxs_phy_probe()
513 platform_set_drvdata(pdev, mxs_phy); in mxs_phy_probe()
517 return usb_add_phy_dev(&mxs_phy->phy); in mxs_phy_probe()
522 struct mxs_phy *mxs_phy = platform_get_drvdata(pdev); in mxs_phy_remove() local
524 usb_remove_phy(&mxs_phy->phy); in mxs_phy_remove()
530 static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on) in mxs_phy_enable_ldo_in_suspend() argument
535 if (!mxs_phy->regmap_anatop) in mxs_phy_enable_ldo_in_suspend()
538 if (is_imx6q_phy(mxs_phy)) in mxs_phy_enable_ldo_in_suspend()
539 regmap_write(mxs_phy->regmap_anatop, reg, in mxs_phy_enable_ldo_in_suspend()
541 else if (is_imx6sl_phy(mxs_phy)) in mxs_phy_enable_ldo_in_suspend()
542 regmap_write(mxs_phy->regmap_anatop, in mxs_phy_enable_ldo_in_suspend()
548 struct mxs_phy *mxs_phy = dev_get_drvdata(dev); in mxs_phy_system_suspend() local
551 mxs_phy_enable_ldo_in_suspend(mxs_phy, true); in mxs_phy_system_suspend()
558 struct mxs_phy *mxs_phy = dev_get_drvdata(dev); in mxs_phy_system_resume() local
561 mxs_phy_enable_ldo_in_suspend(mxs_phy, false); in mxs_phy_system_resume()