Commit bcb8fd3a authored by Bin Liu's avatar Bin Liu Committed by Greg Kroah-Hartman

usb: musb: break the huge isr musb_stage0_irq() into small functions

musb_stage0_irq() is 400+ lines long. Break its interrupt events
handling into each individual functions to make it easy to read.
Signed-off-by: default avatarBin Liu <b-liu@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2bc2e05f
...@@ -523,31 +523,8 @@ void musb_hnp_stop(struct musb *musb) ...@@ -523,31 +523,8 @@ void musb_hnp_stop(struct musb *musb)
static void musb_recover_from_babble(struct musb *musb); static void musb_recover_from_babble(struct musb *musb);
/* static void musb_handle_intr_resume(struct musb *musb, u8 devctl)
* Interrupt Service Routine to record USB "global" interrupts.
* Since these do not happen often and signify things of
* paramount importance, it seems OK to check them individually;
* the order of the tests is specified in the manual
*
* @param musb instance pointer
* @param int_usb register contents
* @param devctl
* @param power
*/
static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
u8 devctl)
{ {
irqreturn_t handled = IRQ_NONE;
musb_dbg(musb, "<== DevCtl=%02x, int_usb=0x%x", devctl, int_usb);
/* in host mode, the peripheral may issue remote wakeup.
* in peripheral mode, the host may resume the link.
* spurious RESUME irqs happen too, paired with SUSPEND.
*/
if (int_usb & MUSB_INTR_RESUME) {
handled = IRQ_HANDLED;
musb_dbg(musb, "RESUME (%s)", musb_dbg(musb, "RESUME (%s)",
usb_otg_state_string(musb->xceiv->otg->state)); usb_otg_state_string(musb->xceiv->otg->state));
...@@ -606,10 +583,11 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, ...@@ -606,10 +583,11 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
usb_otg_state_string(musb->xceiv->otg->state)); usb_otg_state_string(musb->xceiv->otg->state));
} }
} }
} }
/* see manual for the order of the tests */ /* return IRQ_HANDLED to tell the caller to return immediately */
if (int_usb & MUSB_INTR_SESSREQ) { static irqreturn_t musb_handle_intr_sessreq(struct musb *musb, u8 devctl)
{
void __iomem *mbase = musb->mregs; void __iomem *mbase = musb->mregs;
if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS
...@@ -634,10 +612,11 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, ...@@ -634,10 +612,11 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
musb_platform_set_vbus(musb, 1); musb_platform_set_vbus(musb, 1);
handled = IRQ_HANDLED; return IRQ_NONE;
} }
if (int_usb & MUSB_INTR_VBUSERROR) { static void musb_handle_intr_vbuserr(struct musb *musb, u8 devctl)
{
int ignore = 0; int ignore = 0;
/* During connection as an A-Device, we may see a short /* During connection as an A-Device, we may see a short
...@@ -705,13 +684,12 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, ...@@ -705,13 +684,12 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
/* go through A_WAIT_VFALL then start a new session */ /* go through A_WAIT_VFALL then start a new session */
if (!ignore) if (!ignore)
musb_platform_set_vbus(musb, 0); musb_platform_set_vbus(musb, 0);
handled = IRQ_HANDLED; }
}
if (int_usb & MUSB_INTR_SUSPEND) { static void musb_handle_intr_suspend(struct musb *musb, u8 devctl)
{
musb_dbg(musb, "SUSPEND (%s) devctl %02x", musb_dbg(musb, "SUSPEND (%s) devctl %02x",
usb_otg_state_string(musb->xceiv->otg->state), devctl); usb_otg_state_string(musb->xceiv->otg->state), devctl);
handled = IRQ_HANDLED;
switch (musb->xceiv->otg->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_PERIPHERAL: case OTG_STATE_A_PERIPHERAL:
...@@ -763,14 +741,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, ...@@ -763,14 +741,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
musb->is_active = 0; musb->is_active = 0;
break; break;
} }
} }
if (int_usb & MUSB_INTR_CONNECT) { static void musb_handle_intr_connect(struct musb *musb, u8 devctl, u8 int_usb)
{
struct usb_hcd *hcd = musb->hcd; struct usb_hcd *hcd = musb->hcd;
handled = IRQ_HANDLED;
musb->is_active = 1; musb->is_active = 1;
musb->ep0_stage = MUSB_EP0_START; musb->ep0_stage = MUSB_EP0_START;
musb->intrtxe = musb->epmask; musb->intrtxe = musb->epmask;
...@@ -821,13 +798,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, ...@@ -821,13 +798,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
musb_dbg(musb, "CONNECT (%s) devctl %02x", musb_dbg(musb, "CONNECT (%s) devctl %02x",
usb_otg_state_string(musb->xceiv->otg->state), devctl); usb_otg_state_string(musb->xceiv->otg->state), devctl);
} }
if (int_usb & MUSB_INTR_DISCONNECT) { static void musb_handle_intr_disconnect(struct musb *musb, u8 devctl)
{
musb_dbg(musb, "DISCONNECT (%s) as %s, devctl %02x", musb_dbg(musb, "DISCONNECT (%s) as %s, devctl %02x",
usb_otg_state_string(musb->xceiv->otg->state), usb_otg_state_string(musb->xceiv->otg->state),
MUSB_MODE(musb), devctl); MUSB_MODE(musb), devctl);
handled = IRQ_HANDLED;
switch (musb->xceiv->otg->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
...@@ -866,13 +843,14 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, ...@@ -866,13 +843,14 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
usb_otg_state_string(musb->xceiv->otg->state)); usb_otg_state_string(musb->xceiv->otg->state));
break; break;
} }
} }
/* mentor saves a bit: bus reset and babble share the same irq. /*
* mentor saves a bit: bus reset and babble share the same irq.
* only host sees babble; only peripheral sees bus reset. * only host sees babble; only peripheral sees bus reset.
*/ */
if (int_usb & MUSB_INTR_RESET) { static void musb_handle_intr_reset(struct musb *musb)
handled = IRQ_HANDLED; {
if (is_host_active(musb)) { if (is_host_active(musb)) {
/* /*
* When BABBLE happens what we can depends on which * When BABBLE happens what we can depends on which
...@@ -920,6 +898,66 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, ...@@ -920,6 +898,66 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
usb_otg_state_string(musb->xceiv->otg->state)); usb_otg_state_string(musb->xceiv->otg->state));
} }
} }
}
/*
* Interrupt Service Routine to record USB "global" interrupts.
* Since these do not happen often and signify things of
* paramount importance, it seems OK to check them individually;
* the order of the tests is specified in the manual
*
* @param musb instance pointer
* @param int_usb register contents
* @param devctl
* @param power
*/
static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
u8 devctl)
{
irqreturn_t handled = IRQ_NONE;
musb_dbg(musb, "<== DevCtl=%02x, int_usb=0x%x", devctl, int_usb);
/* in host mode, the peripheral may issue remote wakeup.
* in peripheral mode, the host may resume the link.
* spurious RESUME irqs happen too, paired with SUSPEND.
*/
if (int_usb & MUSB_INTR_RESUME) {
musb_handle_intr_resume(musb, devctl);
handled = IRQ_HANDLED;
}
/* see manual for the order of the tests */
if (int_usb & MUSB_INTR_SESSREQ) {
if (musb_handle_intr_sessreq(musb, devctl))
return IRQ_HANDLED;
handled = IRQ_HANDLED;
}
if (int_usb & MUSB_INTR_VBUSERROR) {
musb_handle_intr_vbuserr(musb, devctl);
handled = IRQ_HANDLED;
}
if (int_usb & MUSB_INTR_SUSPEND) {
musb_handle_intr_suspend(musb, devctl);
handled = IRQ_HANDLED;
}
if (int_usb & MUSB_INTR_CONNECT) {
musb_handle_intr_connect(musb, devctl, int_usb);
handled = IRQ_HANDLED;
}
if (int_usb & MUSB_INTR_DISCONNECT) {
musb_handle_intr_disconnect(musb, devctl);
handled = IRQ_HANDLED;
}
if (int_usb & MUSB_INTR_RESET) {
musb_handle_intr_reset(musb);
handled = IRQ_HANDLED;
} }
#if 0 #if 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment