Commit fc7ac4a0 authored by Tony Lindgren's avatar Tony Lindgren

musb_hdrc: Improve tusb host state handling for a_idle

This patch makes the changes happen based on vbus change.
This also seems to make enumeration work better.
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 3b33d3a9
...@@ -422,18 +422,15 @@ static void musb_do_idle(unsigned long _musb) ...@@ -422,18 +422,15 @@ static void musb_do_idle(unsigned long _musb)
switch (musb->xceiv.state) { switch (musb->xceiv.state) {
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
case OTG_STATE_A_WAIT_VRISE:
case OTG_STATE_A_IDLE:
if ((musb->a_wait_bcon != 0) if ((musb->a_wait_bcon != 0)
&& (musb->idle_timeout == 0 && (musb->idle_timeout == 0
|| time_after(jiffies, musb->idle_timeout))) { || time_after(jiffies, musb->idle_timeout))) {
DBG(4, "Nothing connected %s, turning off VBUS\n", DBG(4, "Nothing connected %s, turning off VBUS\n",
otg_state_string(musb)); otg_state_string(musb));
tusb_source_power(musb, 0);
musb->xceiv.state = OTG_STATE_A_WAIT_VFALL;
musb->is_active = 0;
} }
break; /* FALLTHROUGH */
case OTG_STATE_A_IDLE:
tusb_source_power(musb, 0);
default: default:
break; break;
} }
...@@ -533,7 +530,6 @@ static void tusb_source_power(struct musb *musb, int is_on) ...@@ -533,7 +530,6 @@ static void tusb_source_power(struct musb *musb, int is_on)
if (is_on) { if (is_on) {
if (musb->set_clock) if (musb->set_clock)
musb->set_clock(musb->clock, 1); musb->set_clock(musb->clock, 1);
musb->is_active = 1;
timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE); timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);
musb->xceiv.default_a = 1; musb->xceiv.default_a = 1;
musb->xceiv.state = OTG_STATE_A_WAIT_VRISE; musb->xceiv.state = OTG_STATE_A_WAIT_VRISE;
...@@ -550,11 +546,13 @@ static void tusb_source_power(struct musb *musb, int is_on) ...@@ -550,11 +546,13 @@ static void tusb_source_power(struct musb *musb, int is_on)
otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT); otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) { if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) {
switch (musb->xceiv.state) { switch (musb->xceiv.state) {
case OTG_STATE_A_WAIT_VFALL:
break;
case OTG_STATE_A_WAIT_VRISE: case OTG_STATE_A_WAIT_VRISE:
case OTG_STATE_A_WAIT_BCON:
musb->xceiv.state = OTG_STATE_A_WAIT_VFALL; musb->xceiv.state = OTG_STATE_A_WAIT_VFALL;
break; break;
case OTG_STATE_A_WAIT_VFALL:
musb->xceiv.state = OTG_STATE_A_IDLE;
break;
default: default:
musb->xceiv.state = OTG_STATE_A_IDLE; musb->xceiv.state = OTG_STATE_A_IDLE;
} }
...@@ -798,6 +796,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) ...@@ -798,6 +796,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
break; break;
} }
} }
schedule_work(&musb->irq_work);
return idle_timeout; return idle_timeout;
} }
......
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