Support the same property used by the Linux kernel, obsoleting the
CONFIG_MXC_USB_OTG_HACTIVE Kconfig symbol.

Signed-off-by: Nora Schiffer <[email protected]>
---
 drivers/usb/host/ehci-mx6.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 84e2328a767..eae18e22c57 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -264,7 +264,7 @@ int usb_phy_mode(int port)
 #endif
 
 /* Should be done in the a imx-usbmisc driver */
-static void usb_oc_config(struct usbnc_regs *usbnc, int index)
+static void usb_oc_config(struct usbnc_regs *usbnc, int index, bool 
active_high)
 {
        void __iomem *ctrl;
 
@@ -274,12 +274,10 @@ static void usb_oc_config(struct usbnc_regs *usbnc, int 
index)
        ctrl = (void __iomem *)(&usbnc->ctrl[index]);
        setbits_le32(ctrl, UCTRL_OVER_CUR_POL | UCTRL_OVER_CUR_DIS);
 
-       /* Set power polarity to high active */
-#ifdef CONFIG_MXC_USB_OTG_HACTIVE
-       setbits_le32(ctrl, UCTRL_PWR_POL);
-#else
-       clrbits_le32(ctrl, UCTRL_PWR_POL);
-#endif
+       if (IS_ENABLED(CONFIG_MXC_USB_OTG_HACTIVE) || active_high)
+               setbits_le32(ctrl, UCTRL_PWR_POL);
+       else
+               clrbits_le32(ctrl, UCTRL_PWR_POL);
 }
 
 #if !CONFIG_IS_ENABLED(DM_USB)
@@ -383,7 +381,7 @@ int ehci_hcd_init(int index, enum usb_init_type init,
        usb_power_config_mx7ulp(usbphy);
 #endif
 
-       usb_oc_config(usbnc, index);
+       usb_oc_config(usbnc, index, false);
 
 #if defined(CONFIG_MX6) || defined(CONFIG_MX7ULP) || defined(CONFIG_IMXRT)
        if (index < ARRAY_SIZE(phy_bases)) {
@@ -431,6 +429,7 @@ struct ehci_mx6_priv_data {
        enum usb_phy_interface phy_type;
        void __iomem *misc_addr;
        int portnr;
+       bool pwr_active_high;
 #if !defined(CONFIG_PHY)
        void __iomem *phy_addr;
        void __iomem *anatop_addr;
@@ -472,7 +471,7 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev)
 #endif
 
        usb_misc_config_mx7(priv->misc_addr);
-       usb_oc_config(priv->misc_addr, priv->portnr);
+       usb_oc_config(priv->misc_addr, priv->portnr, priv->pwr_active_high);
 
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
        if (priv->vbus_supply) {
@@ -690,6 +689,8 @@ static int ehci_usb_probe(struct udevice *dev)
                debug("%s: No vbus supply\n", dev->name);
 #endif
 
+       priv->pwr_active_high = dev_read_bool(dev, "power-active-high");
+
 #if !defined(CONFIG_PHY)
        usb_power_config_mx6(priv->anatop_addr, priv->portnr);
        usb_power_config_mx7ulp(priv->phy_addr);
@@ -705,7 +706,7 @@ static int ehci_usb_probe(struct udevice *dev)
 #endif
 
        usb_misc_config_mx7(priv->misc_addr);
-       usb_oc_config(priv->misc_addr, priv->portnr);
+       usb_oc_config(priv->misc_addr, priv->portnr, priv->pwr_active_high);
 
        if (priv->init_type == USB_INIT_HOST) {
                setbits_le32(&ehci->usbmode, CM_HOST);
-- 
2.55.0

Reply via email to