usb: dwc2: disable erroneous overcurrent condition
authorDinh Nguyen <dinguyen@kernel.org>
Mon, 16 Oct 2017 13:57:18 +0000 (08:57 -0500)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 19 Oct 2017 07:38:14 +0000 (10:38 +0300)
For the case where an external VBUS is used, we should enable the external
VBUS comparator in the driver. This would prevent an unnecessary
overcurrent error which would then disable the host port.

This patch uses the standard 'disable-over-current' binding to allow of the
option of disabling the over-current condition.

Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc2/core.h
drivers/usb/dwc2/hcd.c
drivers/usb/dwc2/params.c

index 8367d4f985c1220773a7c6efc38df94d837c7f28..730d7eb449bb6f863baf3f3bcaed5c41c4c97a90 100644 (file)
@@ -395,6 +395,9 @@ enum dwc2_ep0_state {
  *                           (default when phy_type is UTMI+ or ULPI)
  *                       1 - 6 MHz
  *                           (default when phy_type is Full Speed)
+ * @oc_disable:                Flag to disable overcurrent condition.
+ *                     0 - Allow overcurrent condition to get detected
+ *                     1 - Disable overcurrent condtion to get detected
  * @ts_dline:           Enable Term Select Dline pulsing
  *                       0 - No (default)
  *                       1 - Yes
@@ -492,6 +495,7 @@ struct dwc2_core_params {
        bool dma_desc_fs_enable;
        bool host_support_fs_ls_low_power;
        bool host_ls_low_power_phy_clk;
+       bool oc_disable;
 
        u8 host_channels;
        u16 host_rx_fifo_size;
index c2631145f404943fc148b747c4620e0a5165153d..5e2033616acaf0bfefb633995387b20289f4347d 100644 (file)
@@ -213,6 +213,11 @@ static int dwc2_hs_phy_init(struct dwc2_hsotg *hsotg, bool select_phy)
                usbcfg &= ~(GUSBCFG_PHYIF16 | GUSBCFG_DDRSEL);
                if (hsotg->params.phy_ulpi_ddr)
                        usbcfg |= GUSBCFG_DDRSEL;
+
+               /* Set external VBUS indicator as needed. */
+               if (hsotg->params.oc_disable)
+                       usbcfg |= (GUSBCFG_ULPI_INT_VBUS_IND |
+                                  GUSBCFG_INDICATORPASSTHROUGH);
                break;
        case DWC2_PHY_TYPE_PARAM_UTMI:
                /* UTMI+ interface */
index 015d23ebcf5a5b4c6a1050b17960ecd66d017c1e..fe770a2834d25214d79d4ee0ad23cdb3a98e41ac 100644 (file)
@@ -346,6 +346,9 @@ static void dwc2_get_device_properties(struct dwc2_hsotg *hsotg)
                                                       num);
                }
        }
+
+       if (of_find_property(hsotg->dev->of_node, "disable-over-current", NULL))
+               p->oc_disable = true;
 }
 
 static void dwc2_check_param_otg_cap(struct dwc2_hsotg *hsotg)