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 return mxs_phy->phy.last_event == USB_EVENT_ID; in mxs_phy_is_otg_host()
394 static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on) in mxs_phy_disconnect_line() argument
397 enum usb_phy_events last_event = mxs_phy->phy.last_event; in mxs_phy_disconnect_line()
400 if (!(mxs_phy->data->flags & MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS)) in mxs_phy_disconnect_line()
404 if (!mxs_phy->regmap_anatop) in mxs_phy_disconnect_line()
407 vbus_is_on = mxs_phy_get_vbus_status(mxs_phy); in mxs_phy_disconnect_line()
409 if (on && ((!vbus_is_on && !mxs_phy_is_otg_host(mxs_phy)) in mxs_phy_disconnect_line()
411 __mxs_phy_disconnect_line(mxs_phy, true); in mxs_phy_disconnect_line()
413 __mxs_phy_disconnect_line(mxs_phy, false); in mxs_phy_disconnect_line()
420 struct mxs_phy *mxs_phy = to_mxs_phy(phy); in mxs_phy_init() local
423 ret = clk_prepare_enable(mxs_phy->clk); in mxs_phy_init()
427 return mxs_phy_hw_init(mxs_phy); in mxs_phy_init()
432 struct mxs_phy *mxs_phy = to_mxs_phy(phy); in mxs_phy_shutdown() local
448 if (is_imx7ulp_phy(mxs_phy)) in mxs_phy_shutdown()
451 clk_disable_unprepare(mxs_phy->clk); in mxs_phy_shutdown()
454 static bool mxs_phy_is_low_speed_connection(struct mxs_phy *mxs_phy) in mxs_phy_is_low_speed_connection() argument
463 if (!mxs_phy->regmap_anatop) in mxs_phy_is_low_speed_connection()
466 if (mxs_phy->port_id == 0) in mxs_phy_is_low_speed_connection()
468 else if (mxs_phy->port_id == 1) in mxs_phy_is_low_speed_connection()
471 regmap_read(mxs_phy->regmap_anatop, reg, &line_state); in mxs_phy_is_low_speed_connection()
482 struct mxs_phy *mxs_phy = to_mxs_phy(x); in mxs_phy_suspend() local
485 low_speed_connection = mxs_phy_is_low_speed_connection(mxs_phy); in mxs_phy_suspend()
486 vbus_is_on = mxs_phy_get_vbus_status(mxs_phy); in mxs_phy_suspend()
506 clk_disable_unprepare(mxs_phy->clk); in mxs_phy_suspend()
509 ret = clk_prepare_enable(mxs_phy->clk); in mxs_phy_suspend()
522 struct mxs_phy *mxs_phy = to_mxs_phy(x); in mxs_phy_set_wakeup() local
527 mxs_phy_disconnect_line(mxs_phy, true); in mxs_phy_set_wakeup()
531 mxs_phy_disconnect_line(mxs_phy, false); in mxs_phy_set_wakeup()
566 static int mxs_charger_data_contact_detect(struct mxs_phy *x) in mxs_charger_data_contact_detect()
619 static enum usb_charger_type mxs_charger_primary_detection(struct mxs_phy *x) in mxs_charger_primary_detection()
655 static enum usb_charger_type mxs_charger_secondary_detection(struct mxs_phy *x) in mxs_charger_secondary_detection()
674 struct mxs_phy *mxs_phy = to_mxs_phy(phy); in mxs_phy_charger_detect() local
675 struct regmap *regmap = mxs_phy->regmap_anatop; in mxs_phy_charger_detect()
682 if (mxs_charger_data_contact_detect(mxs_phy)) in mxs_phy_charger_detect()
685 chgr_type = mxs_charger_primary_detection(mxs_phy); in mxs_phy_charger_detect()
694 chgr_type = mxs_charger_secondary_detection(mxs_phy); in mxs_phy_charger_detect()
710 struct mxs_phy *mxs_phy; in mxs_phy_probe() local
726 mxs_phy = devm_kzalloc(&pdev->dev, sizeof(*mxs_phy), GFP_KERNEL); in mxs_phy_probe()
727 if (!mxs_phy) in mxs_phy_probe()
732 mxs_phy->regmap_anatop = syscon_regmap_lookup_by_phandle in mxs_phy_probe()
734 if (IS_ERR(mxs_phy->regmap_anatop)) { in mxs_phy_probe()
737 return PTR_ERR(mxs_phy->regmap_anatop); in mxs_phy_probe()
747 mxs_phy->tx_reg_mask |= GM_USBPHY_TX_TXCAL45DN(~0); in mxs_phy_probe()
748 mxs_phy->tx_reg_set |= GM_USBPHY_TX_TXCAL45DN(val); in mxs_phy_probe()
756 mxs_phy->tx_reg_mask |= GM_USBPHY_TX_TXCAL45DP(~0); in mxs_phy_probe()
757 mxs_phy->tx_reg_set |= GM_USBPHY_TX_TXCAL45DP(val); in mxs_phy_probe()
768 mxs_phy->tx_reg_mask |= GM_USBPHY_TX_D_CAL(~0); in mxs_phy_probe()
769 mxs_phy->tx_reg_set |= GM_USBPHY_TX_D_CAL(val); in mxs_phy_probe()
775 mxs_phy->port_id = ret; in mxs_phy_probe()
777 mxs_phy->phy.io_priv = base; in mxs_phy_probe()
778 mxs_phy->phy.dev = &pdev->dev; in mxs_phy_probe()
779 mxs_phy->phy.label = DRIVER_NAME; in mxs_phy_probe()
780 mxs_phy->phy.init = mxs_phy_init; in mxs_phy_probe()
781 mxs_phy->phy.shutdown = mxs_phy_shutdown; in mxs_phy_probe()
782 mxs_phy->phy.set_suspend = mxs_phy_suspend; in mxs_phy_probe()
783 mxs_phy->phy.notify_connect = mxs_phy_on_connect; in mxs_phy_probe()
784 mxs_phy->phy.notify_disconnect = mxs_phy_on_disconnect; in mxs_phy_probe()
785 mxs_phy->phy.type = USB_PHY_TYPE_USB2; in mxs_phy_probe()
786 mxs_phy->phy.set_wakeup = mxs_phy_set_wakeup; in mxs_phy_probe()
787 mxs_phy->phy.charger_detect = mxs_phy_charger_detect; in mxs_phy_probe()
789 mxs_phy->clk = clk; in mxs_phy_probe()
790 mxs_phy->data = of_device_get_match_data(&pdev->dev); in mxs_phy_probe()
792 platform_set_drvdata(pdev, mxs_phy); in mxs_phy_probe()
796 return usb_add_phy_dev(&mxs_phy->phy); in mxs_phy_probe()
801 struct mxs_phy *mxs_phy = platform_get_drvdata(pdev); in mxs_phy_remove() local
803 usb_remove_phy(&mxs_phy->phy); in mxs_phy_remove()
807 static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on) in mxs_phy_enable_ldo_in_suspend() argument
812 if (!mxs_phy->regmap_anatop) in mxs_phy_enable_ldo_in_suspend()
815 if (is_imx6q_phy(mxs_phy)) in mxs_phy_enable_ldo_in_suspend()
816 regmap_write(mxs_phy->regmap_anatop, reg, in mxs_phy_enable_ldo_in_suspend()
818 else if (is_imx6sl_phy(mxs_phy)) in mxs_phy_enable_ldo_in_suspend()
819 regmap_write(mxs_phy->regmap_anatop, in mxs_phy_enable_ldo_in_suspend()
825 struct mxs_phy *mxs_phy = dev_get_drvdata(dev); in mxs_phy_system_suspend() local
828 mxs_phy_enable_ldo_in_suspend(mxs_phy, true); in mxs_phy_system_suspend()
835 struct mxs_phy *mxs_phy = dev_get_drvdata(dev); in mxs_phy_system_resume() local
838 mxs_phy_enable_ldo_in_suspend(mxs_phy, false); in mxs_phy_system_resume()