Lines Matching refs:mxs_phy
120 #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
199 struct mxs_phy { struct
209 static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy) in is_imx6q_phy() argument
211 return mxs_phy->data == &imx6q_phy_data; in is_imx6q_phy()
214 static inline bool is_imx6sl_phy(struct mxs_phy *mxs_phy) in is_imx6sl_phy() argument
216 return mxs_phy->data == &imx6sl_phy_data; in is_imx6sl_phy()
219 static inline bool is_imx7ulp_phy(struct mxs_phy *mxs_phy) in is_imx7ulp_phy() argument
221 return mxs_phy->data == &imx7ulp_phy_data; in is_imx7ulp_phy()
233 static void mxs_phy_tx_init(struct mxs_phy *mxs_phy) in mxs_phy_tx_init() argument
235 void __iomem *base = mxs_phy->phy.io_priv; in mxs_phy_tx_init()
239 if (mxs_phy->tx_reg_mask) { in mxs_phy_tx_init()
241 phytx &= ~mxs_phy->tx_reg_mask; in mxs_phy_tx_init()
242 phytx |= mxs_phy->tx_reg_set; in mxs_phy_tx_init()
276 static int mxs_phy_hw_init(struct mxs_phy *mxs_phy) in mxs_phy_hw_init() argument
279 void __iomem *base = mxs_phy->phy.io_priv; in mxs_phy_hw_init()
281 if (is_imx7ulp_phy(mxs_phy)) { in mxs_phy_hw_init()
308 if (mxs_phy->data->flags & MXS_PHY_NEED_IP_FIX) in mxs_phy_hw_init()
311 if (mxs_phy->regmap_anatop) { in mxs_phy_hw_init()
312 unsigned int reg = mxs_phy->port_id ? in mxs_phy_hw_init()
319 regmap_write(mxs_phy->regmap_anatop, reg, in mxs_phy_hw_init()
324 mxs_phy_tx_init(mxs_phy); in mxs_phy_hw_init()
329 if (is_imx7ulp_phy(mxs_phy)) in mxs_phy_hw_init()
335 static bool mxs_phy_get_vbus_status(struct mxs_phy *mxs_phy) in mxs_phy_get_vbus_status() argument
339 if (!mxs_phy->regmap_anatop) in mxs_phy_get_vbus_status()
342 if (mxs_phy->port_id == 0) in mxs_phy_get_vbus_status()
343 regmap_read(mxs_phy->regmap_anatop, in mxs_phy_get_vbus_status()
346 else if (mxs_phy->port_id == 1) in mxs_phy_get_vbus_status()
347 regmap_read(mxs_phy->regmap_anatop, in mxs_phy_get_vbus_status()
357 static void __mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool disconnect) in __mxs_phy_disconnect_line() argument
359 void __iomem *base = mxs_phy->phy.io_priv; in __mxs_phy_disconnect_line()
366 if (mxs_phy->port_id == 0) { in __mxs_phy_disconnect_line()
369 regmap_write(mxs_phy->regmap_anatop, reg, in __mxs_phy_disconnect_line()
372 } else if (mxs_phy->port_id == 1) { in __mxs_phy_disconnect_line()
375 regmap_write(mxs_phy->regmap_anatop, reg, in __mxs_phy_disconnect_line()
389 static bool mxs_phy_is_otg_host(struct mxs_phy *mxs_phy) in mxs_phy_is_otg_host() argument
391 void __iomem *base = mxs_phy->phy.io_priv; in mxs_phy_is_otg_host()
401 static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on) in mxs_phy_disconnect_line() argument
406 if (!(mxs_phy->data->flags & MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS)) in mxs_phy_disconnect_line()
410 if (!mxs_phy->regmap_anatop) in mxs_phy_disconnect_line()
413 vbus_is_on = mxs_phy_get_vbus_status(mxs_phy); in mxs_phy_disconnect_line()
415 if (on && !vbus_is_on && !mxs_phy_is_otg_host(mxs_phy)) in mxs_phy_disconnect_line()
416 __mxs_phy_disconnect_line(mxs_phy, true); in mxs_phy_disconnect_line()
418 __mxs_phy_disconnect_line(mxs_phy, false); in mxs_phy_disconnect_line()
425 struct mxs_phy *mxs_phy = to_mxs_phy(phy); in mxs_phy_init() local
428 ret = clk_prepare_enable(mxs_phy->clk); in mxs_phy_init()
432 return mxs_phy_hw_init(mxs_phy); in mxs_phy_init()
437 struct mxs_phy *mxs_phy = to_mxs_phy(phy); in mxs_phy_shutdown() local
453 if (is_imx7ulp_phy(mxs_phy)) in mxs_phy_shutdown()
456 clk_disable_unprepare(mxs_phy->clk); in mxs_phy_shutdown()
459 static bool mxs_phy_is_low_speed_connection(struct mxs_phy *mxs_phy) in mxs_phy_is_low_speed_connection() argument
468 if (!mxs_phy->regmap_anatop) in mxs_phy_is_low_speed_connection()
471 if (mxs_phy->port_id == 0) in mxs_phy_is_low_speed_connection()
473 else if (mxs_phy->port_id == 1) in mxs_phy_is_low_speed_connection()
476 regmap_read(mxs_phy->regmap_anatop, reg, &line_state); in mxs_phy_is_low_speed_connection()
487 struct mxs_phy *mxs_phy = to_mxs_phy(x); in mxs_phy_suspend() local
490 low_speed_connection = mxs_phy_is_low_speed_connection(mxs_phy); in mxs_phy_suspend()
491 vbus_is_on = mxs_phy_get_vbus_status(mxs_phy); in mxs_phy_suspend()
511 clk_disable_unprepare(mxs_phy->clk); in mxs_phy_suspend()
514 ret = clk_prepare_enable(mxs_phy->clk); in mxs_phy_suspend()
527 struct mxs_phy *mxs_phy = to_mxs_phy(x); in mxs_phy_set_wakeup() local
532 mxs_phy_disconnect_line(mxs_phy, true); in mxs_phy_set_wakeup()
536 mxs_phy_disconnect_line(mxs_phy, false); in mxs_phy_set_wakeup()
571 static int mxs_charger_data_contact_detect(struct mxs_phy *x) in mxs_charger_data_contact_detect()
624 static enum usb_charger_type mxs_charger_primary_detection(struct mxs_phy *x) in mxs_charger_primary_detection()
660 static enum usb_charger_type mxs_charger_secondary_detection(struct mxs_phy *x) in mxs_charger_secondary_detection()
679 struct mxs_phy *mxs_phy = to_mxs_phy(phy); in mxs_phy_charger_detect() local
680 struct regmap *regmap = mxs_phy->regmap_anatop; in mxs_phy_charger_detect()
687 if (mxs_charger_data_contact_detect(mxs_phy)) in mxs_phy_charger_detect()
690 chgr_type = mxs_charger_primary_detection(mxs_phy); in mxs_phy_charger_detect()
699 chgr_type = mxs_charger_secondary_detection(mxs_phy); in mxs_phy_charger_detect()
715 struct mxs_phy *mxs_phy; in mxs_phy_probe() local
736 mxs_phy = devm_kzalloc(&pdev->dev, sizeof(*mxs_phy), GFP_KERNEL); in mxs_phy_probe()
737 if (!mxs_phy) in mxs_phy_probe()
742 mxs_phy->regmap_anatop = syscon_regmap_lookup_by_phandle in mxs_phy_probe()
744 if (IS_ERR(mxs_phy->regmap_anatop)) { in mxs_phy_probe()
747 return PTR_ERR(mxs_phy->regmap_anatop); in mxs_phy_probe()
757 mxs_phy->tx_reg_mask |= GM_USBPHY_TX_TXCAL45DN(~0); in mxs_phy_probe()
758 mxs_phy->tx_reg_set |= GM_USBPHY_TX_TXCAL45DN(val); in mxs_phy_probe()
766 mxs_phy->tx_reg_mask |= GM_USBPHY_TX_TXCAL45DP(~0); in mxs_phy_probe()
767 mxs_phy->tx_reg_set |= GM_USBPHY_TX_TXCAL45DP(val); in mxs_phy_probe()
778 mxs_phy->tx_reg_mask |= GM_USBPHY_TX_D_CAL(~0); in mxs_phy_probe()
779 mxs_phy->tx_reg_set |= GM_USBPHY_TX_D_CAL(val); in mxs_phy_probe()
785 mxs_phy->port_id = ret; in mxs_phy_probe()
787 mxs_phy->phy.io_priv = base; in mxs_phy_probe()
788 mxs_phy->phy.dev = &pdev->dev; in mxs_phy_probe()
789 mxs_phy->phy.label = DRIVER_NAME; in mxs_phy_probe()
790 mxs_phy->phy.init = mxs_phy_init; in mxs_phy_probe()
791 mxs_phy->phy.shutdown = mxs_phy_shutdown; in mxs_phy_probe()
792 mxs_phy->phy.set_suspend = mxs_phy_suspend; in mxs_phy_probe()
793 mxs_phy->phy.notify_connect = mxs_phy_on_connect; in mxs_phy_probe()
794 mxs_phy->phy.notify_disconnect = mxs_phy_on_disconnect; in mxs_phy_probe()
795 mxs_phy->phy.type = USB_PHY_TYPE_USB2; in mxs_phy_probe()
796 mxs_phy->phy.set_wakeup = mxs_phy_set_wakeup; in mxs_phy_probe()
797 mxs_phy->phy.charger_detect = mxs_phy_charger_detect; in mxs_phy_probe()
799 mxs_phy->clk = clk; in mxs_phy_probe()
800 mxs_phy->data = of_id->data; in mxs_phy_probe()
802 platform_set_drvdata(pdev, mxs_phy); in mxs_phy_probe()
806 return usb_add_phy_dev(&mxs_phy->phy); in mxs_phy_probe()
811 struct mxs_phy *mxs_phy = platform_get_drvdata(pdev); in mxs_phy_remove() local
813 usb_remove_phy(&mxs_phy->phy); in mxs_phy_remove()
819 static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on) in mxs_phy_enable_ldo_in_suspend() argument
824 if (!mxs_phy->regmap_anatop) in mxs_phy_enable_ldo_in_suspend()
827 if (is_imx6q_phy(mxs_phy)) in mxs_phy_enable_ldo_in_suspend()
828 regmap_write(mxs_phy->regmap_anatop, reg, in mxs_phy_enable_ldo_in_suspend()
830 else if (is_imx6sl_phy(mxs_phy)) in mxs_phy_enable_ldo_in_suspend()
831 regmap_write(mxs_phy->regmap_anatop, in mxs_phy_enable_ldo_in_suspend()
837 struct mxs_phy *mxs_phy = dev_get_drvdata(dev); in mxs_phy_system_suspend() local
840 mxs_phy_enable_ldo_in_suspend(mxs_phy, true); in mxs_phy_system_suspend()
847 struct mxs_phy *mxs_phy = dev_get_drvdata(dev); in mxs_phy_system_resume() local
850 mxs_phy_enable_ldo_in_suspend(mxs_phy, false); in mxs_phy_system_resume()