diff mbox

[2/4] usb: musb: Prepare dsps glue layer for PM runtime support

Message ID 1471560410-6428-3-git-send-email-tony@atomide.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tony Lindgren Aug. 18, 2016, 10:46 p.m. UTC
We want to be polling the state when nothing is connected.
Let's change the polling logic in preparation for PM runtime
support.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/usb/musb/musb_dsps.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

Comments

Bin Liu Sept. 2, 2016, 2:05 p.m. UTC | #1
On Thu, Aug 18, 2016 at 03:46:48PM -0700, Tony Lindgren wrote:
> We want to be polling the state when nothing is connected.
> Let's change the polling logic in preparation for PM runtime
> support.
> 
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/usb/musb/musb_dsps.c | 24 +++++++++++++++++++-----
>  1 file changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
> index 2537179..ec0369b 100644
> --- a/drivers/usb/musb/musb_dsps.c
> +++ b/drivers/usb/musb/musb_dsps.c
> @@ -247,6 +247,10 @@ static void otg_timer(unsigned long _musb)
>  
>  	spin_lock_irqsave(&musb->lock, flags);
>  	switch (musb->xceiv->otg->state) {
> +	case OTG_STATE_A_WAIT_VRISE:
> +		mod_timer(&glue->timer, jiffies +
> +				msecs_to_jiffies(wrp->poll_timeout));
> +		break;
>  	case OTG_STATE_A_WAIT_BCON:
>  		musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
>  		skip_session = 1;
> @@ -338,7 +342,8 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
>  			MUSB_HST_MODE(musb);
>  			musb->xceiv->otg->default_a = 1;
>  			musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
> -			del_timer(&glue->timer);
> +			mod_timer(&glue->timer, jiffies +
> +				  msecs_to_jiffies(wrp->poll_timeout));
>  		} else {
>  			musb->is_active = 0;
>  			MUSB_DEV_MODE(musb);
> @@ -358,11 +363,17 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
>  	if (musb->int_tx || musb->int_rx || musb->int_usb)
>  		ret |= musb_interrupt(musb);
>  
> -	/* Poll for ID change in OTG port mode */
> -	if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
> -			musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
> +	/* Poll for ID change and connect */
> +	switch (musb->xceiv->otg->state) {
> +	case OTG_STATE_B_IDLE:
> +	case OTG_STATE_A_WAIT_BCON:
>  		mod_timer(&glue->timer, jiffies +
> -				msecs_to_jiffies(wrp->poll_timeout));
> +			  msecs_to_jiffies(wrp->poll_timeout));

Unintentional change? I undo'ed it in my tree.

> +		break;
> +	default:
> +		break;
> +	}
> +
>  out:
>  	spin_unlock_irqrestore(&musb->lock, flags);
>  
> @@ -461,6 +472,9 @@ static int dsps_musb_init(struct musb *musb)
>  		musb_writeb(musb->mregs, MUSB_BABBLE_CTL, val);
>  	}
>  
> +	mod_timer(&glue->timer, jiffies +
> +		  msecs_to_jiffies(glue->wrp->poll_timeout));
> +
>  	return dsps_musb_dbg_init(musb, glue);
>  }
>  
> -- 
> 2.8.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tony Lindgren Sept. 2, 2016, 2:59 p.m. UTC | #2
* Bin Liu <b-liu@ti.com> [160902 07:05]:
> On Thu, Aug 18, 2016 at 03:46:48PM -0700, Tony Lindgren wrote:
> > +	case OTG_STATE_A_WAIT_BCON:
> >  		mod_timer(&glue->timer, jiffies +
> > -				msecs_to_jiffies(wrp->poll_timeout));
> > +			  msecs_to_jiffies(wrp->poll_timeout));
> 
> Unintentional change? I undo'ed it in my tree.

Yes that's not needed thanks.

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 2537179..ec0369b 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -247,6 +247,10 @@  static void otg_timer(unsigned long _musb)
 
 	spin_lock_irqsave(&musb->lock, flags);
 	switch (musb->xceiv->otg->state) {
+	case OTG_STATE_A_WAIT_VRISE:
+		mod_timer(&glue->timer, jiffies +
+				msecs_to_jiffies(wrp->poll_timeout));
+		break;
 	case OTG_STATE_A_WAIT_BCON:
 		musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
 		skip_session = 1;
@@ -338,7 +342,8 @@  static irqreturn_t dsps_interrupt(int irq, void *hci)
 			MUSB_HST_MODE(musb);
 			musb->xceiv->otg->default_a = 1;
 			musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
-			del_timer(&glue->timer);
+			mod_timer(&glue->timer, jiffies +
+				  msecs_to_jiffies(wrp->poll_timeout));
 		} else {
 			musb->is_active = 0;
 			MUSB_DEV_MODE(musb);
@@ -358,11 +363,17 @@  static irqreturn_t dsps_interrupt(int irq, void *hci)
 	if (musb->int_tx || musb->int_rx || musb->int_usb)
 		ret |= musb_interrupt(musb);
 
-	/* Poll for ID change in OTG port mode */
-	if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
-			musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
+	/* Poll for ID change and connect */
+	switch (musb->xceiv->otg->state) {
+	case OTG_STATE_B_IDLE:
+	case OTG_STATE_A_WAIT_BCON:
 		mod_timer(&glue->timer, jiffies +
-				msecs_to_jiffies(wrp->poll_timeout));
+			  msecs_to_jiffies(wrp->poll_timeout));
+		break;
+	default:
+		break;
+	}
+
 out:
 	spin_unlock_irqrestore(&musb->lock, flags);
 
@@ -461,6 +472,9 @@  static int dsps_musb_init(struct musb *musb)
 		musb_writeb(musb->mregs, MUSB_BABBLE_CTL, val);
 	}
 
+	mod_timer(&glue->timer, jiffies +
+		  msecs_to_jiffies(glue->wrp->poll_timeout));
+
 	return dsps_musb_dbg_init(musb, glue);
 }