linux-mips
[Top] [All Lists]

[PATCH 3/5] usb: chipidea: Don't access OTG related registers

To: Ralf Baechle <ralf@linux-mips.org>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Gabor Juhos <juhosg@openwrt.org>, John Crispin <blogic@openwrt.org>, Alan Stern <stern@rowland.harvard.edu>, "Luis R. Rodriguez" <mcgrof@qca.qualcomm.com>
Subject: [PATCH 3/5] usb: chipidea: Don't access OTG related registers
From: Svetoslav Neykov <svetoslav@neykov.name>
Date: Wed, 13 Feb 2013 23:38:56 +0200
Cc: linux-mips@linux-mips.org, linux-usb@vger.kernel.org, Svetoslav Neykov <svetoslav@neykov.name>
In-reply-to: <1360791538-6332-1-git-send-email-svetoslav@neykov.name>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
References: <1360791538-6332-1-git-send-email-svetoslav@neykov.name>
Sender: linux-mips-bounce@linux-mips.org
According to the datasheet the chipidea controller in AR933x doesn't expose OTG 
and TEST registers.
If no OTG support is detected don't call functions which access those registers.

Signed-off-by: Svetoslav Neykov <svetoslav@neykov.name>
---
 drivers/usb/chipidea/udc.c |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 78ac5e5..9fda4d8 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1395,7 +1395,10 @@ static int ci13xxx_vbus_session(struct usb_gadget 
*_gadget, int is_active)
                if (is_active) {
                        pm_runtime_get_sync(&_gadget->dev);
                        hw_device_reset(ci, USBMODE_CM_DC);
-                       hw_enable_vbus_intr(ci);
+
+                       if (ci->is_otg)
+                               hw_enable_vbus_intr(ci);
+
                        hw_device_state(ci, ci->ep0out->qh.dma);
                } else {
                        hw_device_state(ci, 0);
@@ -1572,7 +1575,8 @@ static int ci13xxx_start(struct usb_gadget *gadget,
                if (ci->vbus_active) {
                        if (ci->platdata->flags & CI13XXX_REGS_SHARED) {
                                hw_device_reset(ci, USBMODE_CM_DC);
-                               hw_enable_vbus_intr(ci);
+                               if (ci->is_otg)
+                                       hw_enable_vbus_intr(ci);
                        }
                } else {
                        pm_runtime_put_sync(&ci->gadget.dev);
@@ -1680,11 +1684,13 @@ static irqreturn_t udc_irq(struct ci13xxx *ci)
                retval = IRQ_NONE;
        }
 
-       intr = hw_read(ci, OP_OTGSC, ~0);
-       hw_write(ci, OP_OTGSC, ~0, intr);
+       if (ci->is_otg) {
+               intr = hw_read(ci, OP_OTGSC, ~0);
+               hw_write(ci, OP_OTGSC, ~0, intr);
 
-       if (intr & (OTGSC_AVVIE & OTGSC_AVVIS))
-               queue_work(ci->wq, &ci->vbus_work);
+               if (intr & (OTGSC_AVVIE & OTGSC_AVVIS))
+                       queue_work(ci->wq, &ci->vbus_work);
+       }
 
        spin_unlock(&ci->lock);
 
@@ -1761,7 +1767,8 @@ static int udc_start(struct ci13xxx *ci)
                retval = hw_device_reset(ci, USBMODE_CM_DC);
                if (retval)
                        goto put_transceiver;
-               hw_enable_vbus_intr(ci);
+               if (ci->is_otg)
+                       hw_enable_vbus_intr(ci);
        }
 
        retval = device_register(&ci->gadget.dev);
@@ -1824,7 +1831,8 @@ static void udc_stop(struct ci13xxx *ci)
        if (ci == NULL)
                return;
 
-       hw_disable_vbus_intr(ci);
+       if (ci->is_otg)
+               hw_disable_vbus_intr(ci);
        cancel_work_sync(&ci->vbus_work);
 
        usb_del_gadget_udc(&ci->gadget);
-- 
1.7.9.5


<Prev in Thread] Current Thread [Next in Thread>