Merge remote-tracking branch 'usb-chipidea-next/ci-for-usb-next'
authorStephen Rothwell <sfr@canb.auug.org.au>
Tue, 13 Sep 2016 02:45:57 +0000 (12:45 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 13 Sep 2016 02:45:57 +0000 (12:45 +1000)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
Documentation/devicetree/bindings/usb/usbmisc-imx.txt
drivers/usb/chipidea/ci_hdrc_imx.c
drivers/usb/chipidea/ci_hdrc_imx.h
drivers/usb/chipidea/host.c
drivers/usb/chipidea/udc.c
drivers/usb/chipidea/usbmisc_imx.c

index 341dc67f3472c746a92e38340848a509f8140831..0e03344e2e8bb3b9567f00dd5bfae3b2f1021bb3 100644 (file)
@@ -81,6 +81,8 @@ i.mx specific properties
 - fsl,usbmisc: phandler of non-core register device, with one
   argument that indicate usb controller index
 - disable-over-current: disable over current detect
+- over-current-active-high: over current signal polarity is high active,
+  typically over current signal polarity is low active.
 - external-vbus-divider: enables off-chip resistor divider for Vbus
 
 Example:
index 3539d4e7d23e1a1e0b5a4625f285f138d5d39071..f1e27faf528e7e5abdec2a79cac85cf794c7e768 100644 (file)
@@ -6,6 +6,7 @@ Required properties:
        "fsl,imx6q-usbmisc" for imx6q
        "fsl,vf610-usbmisc" for Vybrid vf610
        "fsl,imx6sx-usbmisc" for imx6sx
+       "fsl,imx7d-usbmisc" for imx7d
 - reg: Should contain registers location and length
 
 Examples:
index dedc33e589f41e752730f495fb082db8d4b771ae..099179457f60c0247af8c49c4084b7f77d30e98f 100644 (file)
@@ -140,6 +140,9 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
        if (of_find_property(np, "disable-over-current", NULL))
                data->disable_oc = 1;
 
+       if (of_find_property(np, "over-current-active-high", NULL))
+               data->oc_polarity = 1;
+
        if (of_find_property(np, "external-vbus-divider", NULL))
                data->evdo = 1;
 
index 635717e9354aa0f7a30c1797c0718f058adb045b..409aa5ca8dda1405aaf9c94ca16d363be386c810 100644 (file)
@@ -17,6 +17,7 @@ struct imx_usbmisc_data {
        int index;
 
        unsigned int disable_oc:1; /* over current detect disabled */
+       unsigned int oc_polarity:1; /* over current polarity if oc enabled */
        unsigned int evdo:1; /* set external vbus divider option */
 };
 
index 053bac9d983cbd7b3e4d24ee9f227ec0ba909368..96ae69502c86fac5b1b2f7306f049d7f7bb5085f 100644 (file)
@@ -81,12 +81,15 @@ static int ehci_ci_reset(struct usb_hcd *hcd)
 {
        struct device *dev = hcd->self.controller;
        struct ci_hdrc *ci = dev_get_drvdata(dev);
+       struct ehci_hcd *ehci = hcd_to_ehci(hcd);
        int ret;
 
        ret = ehci_setup(hcd);
        if (ret)
                return ret;
 
+       ehci->need_io_watchdog = 0;
+
        ci_platform_configure(ci);
 
        return ret;
index b93356834bb5660bb451f712c7ef6f13018bc5d3..c1eea62ab998c607aa05ccd0fcc3825f7a93f01b 100644 (file)
@@ -59,7 +59,7 @@ ctrl_endpt_in_desc = {
  */
 static inline int hw_ep_bit(int num, int dir)
 {
-       return num + (dir ? 16 : 0);
+       return num + ((dir == TX) ? 16 : 0);
 }
 
 static inline int ep_to_bit(struct ci_hdrc *ci, int n)
@@ -121,9 +121,8 @@ static int hw_ep_flush(struct ci_hdrc *ci, int num, int dir)
  */
 static int hw_ep_disable(struct ci_hdrc *ci, int num, int dir)
 {
-       hw_ep_flush(ci, num, dir);
        hw_write(ci, OP_ENDPTCTRL + num,
-                dir ? ENDPTCTRL_TXE : ENDPTCTRL_RXE, 0);
+                (dir == TX) ? ENDPTCTRL_TXE : ENDPTCTRL_RXE, 0);
        return 0;
 }
 
@@ -139,7 +138,7 @@ static int hw_ep_enable(struct ci_hdrc *ci, int num, int dir, int type)
 {
        u32 mask, data;
 
-       if (dir) {
+       if (dir == TX) {
                mask  = ENDPTCTRL_TXT;  /* type    */
                data  = type << __ffs(mask);
 
@@ -171,7 +170,7 @@ static int hw_ep_enable(struct ci_hdrc *ci, int num, int dir, int type)
  */
 static int hw_ep_get_halt(struct ci_hdrc *ci, int num, int dir)
 {
-       u32 mask = dir ? ENDPTCTRL_TXS : ENDPTCTRL_RXS;
+       u32 mask = (dir == TX) ? ENDPTCTRL_TXS : ENDPTCTRL_RXS;
 
        return hw_read(ci, OP_ENDPTCTRL + num, mask) ? 1 : 0;
 }
@@ -188,6 +187,9 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl)
 {
        int n = hw_ep_bit(num, dir);
 
+       /* Synchronize before ep prime */
+       wmb();
+
        if (is_ctrl && dir == RX && hw_read(ci, OP_ENDPTSETUPSTAT, BIT(num)))
                return -EAGAIN;
 
@@ -218,8 +220,8 @@ static int hw_ep_set_halt(struct ci_hdrc *ci, int num, int dir, int value)
 
        do {
                enum ci_hw_regs reg = OP_ENDPTCTRL + num;
-               u32 mask_xs = dir ? ENDPTCTRL_TXS : ENDPTCTRL_RXS;
-               u32 mask_xr = dir ? ENDPTCTRL_TXR : ENDPTCTRL_RXR;
+               u32 mask_xs = (dir == TX) ? ENDPTCTRL_TXS : ENDPTCTRL_RXS;
+               u32 mask_xr = (dir == TX) ? ENDPTCTRL_TXR : ENDPTCTRL_RXR;
 
                /* data toggle - reserved for EP0 but it's in ESS */
                hw_write(ci, reg, mask_xs|mask_xr,
@@ -506,8 +508,6 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
                hwep->qh.ptr->cap |= mul << __ffs(QH_MULT);
        }
 
-       wmb();   /* synchronize before ep prime */
-
        ret = hw_ep_prime(ci, hwep->num, hwep->dir,
                           hwep->type == USB_ENDPOINT_XFER_CONTROL);
 done:
@@ -534,9 +534,6 @@ static int reprime_dtd(struct ci_hdrc *ci, struct ci_hw_ep *hwep,
        hwep->qh.ptr->td.token &=
                cpu_to_le32(~(TD_STATUS_HALTED | TD_STATUS_ACTIVE));
 
-       /* Synchronize before ep prime */
-       wmb();
-
        return hw_ep_prime(ci, hwep->num, hwep->dir,
                                hwep->type == USB_ENDPOINT_XFER_CONTROL);
 }
@@ -590,7 +587,7 @@ static int _hardware_dequeue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
                }
 
                if (remaining_length) {
-                       if (hwep->dir) {
+                       if (hwep->dir == TX) {
                                hwreq->req.status = -EPROTO;
                                break;
                        }
@@ -1051,9 +1048,9 @@ __acquires(ci->lock)
                        if (req.wLength != 0)
                                break;
                        num  = le16_to_cpu(req.wIndex);
-                       dir = num & USB_ENDPOINT_DIR_MASK;
+                       dir = (num & USB_ENDPOINT_DIR_MASK) ? TX : RX;
                        num &= USB_ENDPOINT_NUMBER_MASK;
-                       if (dir) /* TX */
+                       if (dir == TX)
                                num += ci->hw_ep_max / 2;
                        if (!ci->ci_hw_ep[num].wedge) {
                                spin_unlock(&ci->lock);
@@ -1103,9 +1100,9 @@ __acquires(ci->lock)
                        if (req.wLength != 0)
                                break;
                        num  = le16_to_cpu(req.wIndex);
-                       dir = num & USB_ENDPOINT_DIR_MASK;
+                       dir = (num & USB_ENDPOINT_DIR_MASK) ? TX : RX;
                        num &= USB_ENDPOINT_NUMBER_MASK;
-                       if (dir) /* TX */
+                       if (dir == TX)
                                num += ci->hw_ep_max / 2;
 
                        spin_unlock(&ci->lock);
index ab8b027e8cc870615d399abb631849875db72427..20d02a5e418d936231fcb091e183c6f939d16701 100644 (file)
@@ -56,6 +56,7 @@
 
 #define MX6_BM_NON_BURST_SETTING       BIT(1)
 #define MX6_BM_OVER_CUR_DIS            BIT(7)
+#define MX6_BM_OVER_CUR_POLARITY       BIT(8)
 #define MX6_BM_WAKEUP_ENABLE           BIT(10)
 #define MX6_BM_ID_WAKEUP               BIT(16)
 #define MX6_BM_VBUS_WAKEUP             BIT(17)
@@ -266,11 +267,14 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)
 
        spin_lock_irqsave(&usbmisc->lock, flags);
 
+       reg = readl(usbmisc->base + data->index * 4);
        if (data->disable_oc) {
-               reg = readl(usbmisc->base + data->index * 4);
-               writel(reg | MX6_BM_OVER_CUR_DIS,
-                       usbmisc->base + data->index * 4);
+               reg |= MX6_BM_OVER_CUR_DIS;
+       } else if (data->oc_polarity == 1) {
+               /* High active */
+               reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY);
        }
+       writel(reg, usbmisc->base + data->index * 4);
 
        /* SoC non-burst setting */
        reg = readl(usbmisc->base + data->index * 4);
@@ -365,10 +369,14 @@ static int usbmisc_imx7d_init(struct imx_usbmisc_data *data)
                return -EINVAL;
 
        spin_lock_irqsave(&usbmisc->lock, flags);
+       reg = readl(usbmisc->base);
        if (data->disable_oc) {
-               reg = readl(usbmisc->base);
-               writel(reg | MX6_BM_OVER_CUR_DIS, usbmisc->base);
+               reg |= MX6_BM_OVER_CUR_DIS;
+       } else if (data->oc_polarity == 1) {
+               /* High active */
+               reg &= ~(MX6_BM_OVER_CUR_DIS | MX6_BM_OVER_CUR_POLARITY);
        }
+       writel(reg, usbmisc->base);
 
        reg = readl(usbmisc->base + MX7D_USBNC_USB_CTRL2);
        reg &= ~MX7D_USB_VBUS_WAKEUP_SOURCE_MASK;
@@ -492,6 +500,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = {
                .compatible = "fsl,imx6ul-usbmisc",
                .data = &imx6sx_usbmisc_ops,
        },
+       {
+               .compatible = "fsl,imx7d-usbmisc",
+               .data = &imx7d_usbmisc_ops,
+       },
        { /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, usbmisc_imx_dt_ids);
This page took 0.032623 seconds and 5 git commands to generate.