* [PATCH 0/12] musb_hdrc: Host and OTG updates
@ 2007-10-11 17:05 Tony Lindgren
2007-10-11 17:05 ` [PATCH 1/12] musb_hdrc: Allow tusb3.0 and greater to use multichannel DMA Tony Lindgren
2007-10-12 20:32 ` [PATCH 0/12] musb_hdrc: Host and OTG updates Tony Lindgren
0 siblings, 2 replies; 18+ messages in thread
From: Tony Lindgren @ 2007-10-11 17:05 UTC (permalink / raw)
To: linux-omap-open-source
Hi all,
Attached patch series updates musb code for host PM (mostly
on tusb6010), and otg HNP stuff. Please comment and test.
Tested on tusb, compile tested on 2430sdp.
Regards,
Tony
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1/12] musb_hdrc: Allow tusb3.0 and greater to use multichannel DMA
2007-10-11 17:05 [PATCH 0/12] musb_hdrc: Host and OTG updates Tony Lindgren
@ 2007-10-11 17:05 ` Tony Lindgren
2007-10-11 17:05 ` [PATCH 2/12] musb_hdrc: Add more sysfs notify events Tony Lindgren
2007-10-12 20:32 ` [PATCH 0/12] musb_hdrc: Host and OTG updates Tony Lindgren
1 sibling, 1 reply; 18+ messages in thread
From: Tony Lindgren @ 2007-10-11 17:05 UTC (permalink / raw)
To: linux-omap-open-source
Allow tusb3.0 and greater to use multichannel DMA
Signed-off-by: Tony Lindgren <tony@atomide.com>
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index fbb402c..5026f2b 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -34,7 +34,7 @@ static void tusb_source_power(struct musb *musb, int is_on);
* Checks the revision. We need to use the DMA register as 3.0 does not
* have correct versions for TUSB_PRCM_REV or TUSB_INT_CTRL_REV.
*/
-static u8 tusb_get_revision(struct musb *musb)
+u8 tusb_get_revision(struct musb *musb)
{
void __iomem *tbase = musb->ctrl_base;
u32 die_id;
diff --git a/drivers/usb/musb/tusb6010.h b/drivers/usb/musb/tusb6010.h
index 16a311a..7ef6abf 100644
--- a/drivers/usb/musb/tusb6010.h
+++ b/drivers/usb/musb/tusb6010.h
@@ -13,6 +13,8 @@
#ifndef __TUSB6010_H__
#define __TUSB6010_H__
+extern u8 tusb_get_revision(struct musb *musb);
+
#ifdef CONFIG_USB_TUSB6010
#define musb_in_tusb() 1
#else
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index 42c6a6b..09a6a3c 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -20,18 +20,6 @@
#include "musb_core.h"
-/*
- * REVISIT: With TUSB2.0 only one dmareq line can be used at a time.
- * This should get fixed in hardware at some point.
- */
-#define BROKEN_DMAREQ
-
-#ifdef BROKEN_DMAREQ
-#define dmareq_works() 0
-#else
-#define dmareq_works() 1
-#endif
-
#define to_chdat(c) (struct tusb_omap_dma_ch *)(c)->private_data
#define MAX_DMAREQ 5 /* REVISIT: Really 6, but req5 not OK */
@@ -67,6 +55,7 @@ struct tusb_omap_dma {
int ch;
s8 dmareq;
s8 sync_dev;
+ unsigned multichannel:1;
};
static int tusb_omap_dma_start(struct dma_controller *c)
@@ -91,8 +80,6 @@ static int tusb_omap_dma_stop(struct dma_controller *c)
return 0;
}
-#ifdef BROKEN_DMAREQ
-
/*
* Allocate dmareq0 to the current channel unless it's already taken
*/
@@ -128,11 +115,6 @@ static inline void tusb_omap_free_shared_dmareq(struct tusb_omap_dma_ch *chdat)
musb_writel(chdat->tbase, TUSB_DMA_EP_MAP, 0);
}
-#else
-#define tusb_omap_use_shared_dmareq(x, y) do {} while (0)
-#define tusb_omap_free_shared_dmareq(x, y) do {} while (0)
-#endif
-
/*
* See also musb_dma_completion in plat_uds.c and musb_g_[tx|rx]() in
* musb_gadget.c.
@@ -151,7 +133,7 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
spin_lock_irqsave(&musb->lock, flags);
- if (dmareq_works())
+ if (tusb_dma->multichannel)
ch = chdat->ch;
else
ch = tusb_dma->ch;
@@ -201,7 +183,7 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
channel->actual_len += pio;
}
- if (!dmareq_works())
+ if (!tusb_dma->multichannel)
tusb_omap_free_shared_dmareq(chdat);
channel->status = MUSB_DMA_STATUS_FREE;
@@ -283,7 +265,6 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
return false;
}
-
chdat->transfer_len = len & ~0x1f;
if (len < packet_sz)
@@ -291,7 +272,7 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
else
chdat->transfer_packet_sz = packet_sz;
- if (dmareq_works()) {
+ if (tusb_dma->multichannel) {
ch = chdat->ch;
dmareq = chdat->dmareq;
sync_dev = chdat->sync_dev;
@@ -441,7 +422,7 @@ static int tusb_omap_dma_abort(struct dma_channel *channel)
struct tusb_omap_dma_ch *chdat = to_chdat(channel);
struct tusb_omap_dma *tusb_dma = chdat->tusb_dma;
- if (!dmareq_works()) {
+ if (!tusb_dma->multichannel) {
if (tusb_dma->ch >= 0) {
omap_stop_dma(tusb_dma->ch);
omap_free_dma(tusb_dma->ch);
@@ -574,7 +555,7 @@ tusb_omap_dma_allocate(struct dma_controller *c,
channel->desired_mode = 0;
channel->actual_len = 0;
- if (dmareq_works()) {
+ if (tusb_dma->multichannel) {
ret = tusb_omap_dma_allocate_dmareq(chdat);
if (ret != 0)
goto free_dmareq;
@@ -668,7 +649,7 @@ void dma_controller_destroy(struct dma_controller *c)
}
}
- if (!dmareq_works() && tusb_dma && tusb_dma->ch >= 0)
+ if (!tusb_dma->multichannel && tusb_dma && tusb_dma->ch >= 0)
omap_free_dma(tusb_dma->ch);
kfree(tusb_dma);
@@ -710,6 +691,9 @@ dma_controller_create(struct musb *musb, void __iomem *base)
tusb_dma->controller.channel_abort = tusb_omap_dma_abort;
tusb_dma->controller.private_data = tusb_dma;
+ if (tusb_get_revision(musb) >= TUSB_REV_30)
+ tusb_dma->multichannel = 1;
+
for (i = 0; i < MAX_DMAREQ; i++) {
struct dma_channel *ch;
struct tusb_omap_dma_ch *chdat;
--
1.5.2.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 2/12] musb_hdrc: Add more sysfs notify events
2007-10-11 17:05 ` [PATCH 1/12] musb_hdrc: Allow tusb3.0 and greater to use multichannel DMA Tony Lindgren
@ 2007-10-11 17:05 ` Tony Lindgren
2007-10-11 17:05 ` [PATCH 3/12] musb_hdrc: Remove old sysfs entry cable, use mode instead Tony Lindgren
0 siblings, 1 reply; 18+ messages in thread
From: Tony Lindgren @ 2007-10-11 17:05 UTC (permalink / raw)
To: linux-omap-open-source
Notify on all musb_stage0_irq events. For musb_stage2_irq events,
add notify on suspend. Do not notify on SOF.
Signed-off-by: Tony Lindgren <tony@atomide.com>
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 3093bda..f7dc22c 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -652,11 +652,11 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
DBG(1, "Unhandled BUS RESET as %s\n",
otg_state_string(musb));
}
- schedule_work(&musb->irq_work);
}
handled = IRQ_HANDLED;
}
+ schedule_work(&musb->irq_work);
return handled;
}
@@ -811,6 +811,7 @@ static irqreturn_t musb_stage2_irq(struct musb * musb, u8 int_usb,
musb->is_active = 0;
break;
}
+ schedule_work(&musb->irq_work);
}
--
1.5.2.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 3/12] musb_hdrc: Remove old sysfs entry cable, use mode instead
2007-10-11 17:05 ` [PATCH 2/12] musb_hdrc: Add more sysfs notify events Tony Lindgren
@ 2007-10-11 17:05 ` Tony Lindgren
2007-10-11 17:05 ` [PATCH 4/12] musb_hdrc: Remove non-debug otg_state_string Tony Lindgren
2007-10-12 0:56 ` [PATCH 3/12] musb_hdrc: Remove old sysfs entry cable, use mode instead David Brownell
0 siblings, 2 replies; 18+ messages in thread
From: Tony Lindgren @ 2007-10-11 17:05 UTC (permalink / raw)
To: linux-omap-open-source
Cable was used earlier before OTG support for peripherals, however
it does not really work for OTG. Sysfs entry mode shows the right
OTG mode and should be used instead.
Signed-off-by: Tony Lindgren <tony@atomide.com>
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index f7dc22c..82bf57a 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1660,52 +1660,6 @@ musb_mode_store(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR(mode, 0644, musb_mode_show, musb_mode_store);
static ssize_t
-musb_cable_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
- struct musb *musb = dev_to_musb(dev);
- char *v1= "", *v2 = "?";
- unsigned long flags;
- int vbus;
-
- spin_lock_irqsave(&musb->lock, flags);
-#if defined(CONFIG_USB_TUSB6010) && !defined(CONFIG_USB_MUSB_OTG)
- /* REVISIT: connect-A != connect-B ... */
- vbus = musb_platform_get_vbus_status(musb);
- if (vbus)
- v2 = "connected";
- else
- v2 = "disconnected";
-#else
- /* NOTE: board-specific issues, like too-big capacitors keeping
- * VBUS high for a long time after power has been removed, can
- * cause temporary false indications of a connection.
- */
- vbus = musb_readb(musb->mregs, MUSB_DEVCTL);
- if (vbus & 0x10) {
- /* REVISIT retest on real OTG hardware */
- switch (musb->board_mode) {
- case MUSB_HOST:
- v2 = "A";
- break;
- case MUSB_PERIPHERAL:
- v2 = "B";
- break;
- case MUSB_OTG:
- v1 = "Mini-";
- v2 = (vbus & MUSB_DEVCTL_BDEVICE) ? "B" : "A";
- break;
- }
- } else /* VBUS level below A-Valid */
- v2 = "disconnected";
-#endif
- musb_platform_try_idle(musb, 0);
- spin_unlock_irqrestore(&musb->lock, flags);
-
- return sprintf(buf, "%s%s\n", v1, v2);
-}
-static DEVICE_ATTR(cable, S_IRUGO, musb_cable_show, NULL);
-
-static ssize_t
musb_vbus_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t n)
{
@@ -1780,7 +1734,6 @@ static void musb_irq_work(struct work_struct *data)
if (musb->xceiv.state != old_state) {
old_state = musb->xceiv.state;
- sysfs_notify(&musb->controller->kobj, NULL, "cable");
sysfs_notify(&musb->controller->kobj, NULL, "mode");
}
}
@@ -1846,7 +1799,6 @@ static void musb_free(struct musb *musb)
#ifdef CONFIG_SYSFS
device_remove_file(musb->controller, &dev_attr_mode);
- device_remove_file(musb->controller, &dev_attr_cable);
device_remove_file(musb->controller, &dev_attr_vbus);
#ifdef CONFIG_USB_MUSB_OTG
device_remove_file(musb->controller, &dev_attr_srp);
@@ -2082,7 +2034,6 @@ fail:
#ifdef CONFIG_SYSFS
status = device_create_file(dev, &dev_attr_mode);
- status = device_create_file(dev, &dev_attr_cable);
status = device_create_file(dev, &dev_attr_vbus);
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
status = device_create_file(dev, &dev_attr_srp);
--
1.5.2.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 4/12] musb_hdrc: Remove non-debug otg_state_string
2007-10-11 17:05 ` [PATCH 3/12] musb_hdrc: Remove old sysfs entry cable, use mode instead Tony Lindgren
@ 2007-10-11 17:05 ` Tony Lindgren
2007-10-11 17:05 ` [PATCH 5/12] musb_hdrc: Fix host suspend handling, remove earlier hacks Tony Lindgren
2007-10-12 0:56 ` [PATCH 3/12] musb_hdrc: Remove old sysfs entry cable, use mode instead David Brownell
1 sibling, 1 reply; 18+ messages in thread
From: Tony Lindgren @ 2007-10-11 17:05 UTC (permalink / raw)
To: linux-omap-open-source
The right state information via sys is good to know, don't try to optimize
it away.
Signed-off-by: Tony Lindgren <tony@atomide.com>
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 82bf57a..b438036 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -121,15 +121,6 @@ module_param(debug, uint, 0);
MODULE_PARM_DESC(debug, "initial debug message level");
#define MUSB_VERSION_SUFFIX "/dbg"
-#else
-
-const char *otg_state_string(struct musb *musb)
-{
- static char buf[8];
-
- snprintf(buf, sizeof buf, "otg-%d", musb->xceiv.state);
- return buf;
-}
#endif
#define DRIVER_AUTHOR "Mentor Graphics, Texas Instruments, Nokia"
@@ -281,6 +272,26 @@ void musb_load_testpacket(struct musb *musb)
/*-------------------------------------------------------------------------*/
+const char *otg_state_string(struct musb *musb)
+{
+ switch (musb->xceiv.state) {
+ case OTG_STATE_A_IDLE: return "a_idle";
+ case OTG_STATE_A_WAIT_VRISE: return "a_wait_vrise";
+ case OTG_STATE_A_WAIT_BCON: return "a_wait_bcon";
+ case OTG_STATE_A_HOST: return "a_host";
+ case OTG_STATE_A_SUSPEND: return "a_suspend";
+ case OTG_STATE_A_PERIPHERAL: return "a_peripheral";
+ case OTG_STATE_A_WAIT_VFALL: return "a_wait_vfall";
+ case OTG_STATE_A_VBUS_ERR: return "a_vbus_err";
+ case OTG_STATE_B_IDLE: return "b_idle";
+ case OTG_STATE_B_SRP_INIT: return "b_srp_init";
+ case OTG_STATE_B_PERIPHERAL: return "b_peripheral";
+ case OTG_STATE_B_WAIT_ACON: return "b_wait_acon";
+ case OTG_STATE_B_HOST: return "b_host";
+ default: return "UNDEFINED";
+ }
+}
+
#ifdef CONFIG_USB_MUSB_OTG
/*
diff --git a/drivers/usb/musb/musb_procfs.c b/drivers/usb/musb/musb_procfs.c
index ca53d13..bd282da 100644
--- a/drivers/usb/musb/musb_procfs.c
+++ b/drivers/usb/musb/musb_procfs.c
@@ -42,27 +42,6 @@
#include "davinci.h"
-
-const char *otg_state_string(struct musb *musb)
-{
- switch (musb->xceiv.state) {
- case OTG_STATE_A_IDLE: return "a_idle";
- case OTG_STATE_A_WAIT_VRISE: return "a_wait_vrise";
- case OTG_STATE_A_WAIT_BCON: return "a_wait_bcon";
- case OTG_STATE_A_HOST: return "a_host";
- case OTG_STATE_A_SUSPEND: return "a_suspend";
- case OTG_STATE_A_PERIPHERAL: return "a_peripheral";
- case OTG_STATE_A_WAIT_VFALL: return "a_wait_vfall";
- case OTG_STATE_A_VBUS_ERR: return "a_vbus_err";
- case OTG_STATE_B_IDLE: return "b_idle";
- case OTG_STATE_B_SRP_INIT: return "b_srp_init";
- case OTG_STATE_B_PERIPHERAL: return "b_peripheral";
- case OTG_STATE_B_WAIT_ACON: return "b_wait_acon";
- case OTG_STATE_B_HOST: return "b_host";
- default: return "UNDEFINED";
- }
-}
-
#ifdef CONFIG_USB_MUSB_HDRC_HCD
static int dump_qh(struct musb_qh *qh, char *buf, unsigned max)
--
1.5.2.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 5/12] musb_hdrc: Fix host suspend handling, remove earlier hacks
2007-10-11 17:05 ` [PATCH 4/12] musb_hdrc: Remove non-debug otg_state_string Tony Lindgren
@ 2007-10-11 17:05 ` Tony Lindgren
2007-10-11 17:05 ` [PATCH 6/12] musb_hdrc: Improve tusb host state handling for a_idle Tony Lindgren
0 siblings, 1 reply; 18+ messages in thread
From: Tony Lindgren @ 2007-10-11 17:05 UTC (permalink / raw)
To: linux-omap-open-source
If A-cable was connected and a gadget module was reloaded, root hub
suspend would fail.
This the problem by managing musb inactive state better. The patch also adds
more debug info for cases where suspend is attempted in active state.
Signed-off-by: Tony Lindgren <tony@atomide.com>
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 79518ae..091ae8f 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2128,9 +2128,11 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
{
struct musb *musb = hcd_to_musb(hcd);
- if (is_host_active(musb) && musb->is_active)
+ if (is_host_active(musb) && musb->is_active) {
+ WARN("trying to suspend as %s is_active=%i\n",
+ otg_state_string(musb), musb->is_active);
return -EBUSY;
- else
+ } else
return 0;
}
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index b123d8e..22b1d5e 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -190,6 +190,7 @@ void musb_root_disconnect(struct musb *musb)
case OTG_STATE_A_HOST:
case OTG_STATE_A_SUSPEND:
musb->xceiv.state = OTG_STATE_A_WAIT_BCON;
+ musb->is_active = 0;
break;
case OTG_STATE_A_WAIT_VFALL:
musb->xceiv.state = OTG_STATE_B_IDLE;
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 5026f2b..b3e745d 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -430,7 +430,7 @@ static void musb_do_idle(unsigned long _musb)
DBG(4, "Nothing connected %s, turning off VBUS\n",
otg_state_string(musb));
tusb_source_power(musb, 0);
- musb->xceiv.state = OTG_STATE_A_IDLE;
+ musb->xceiv.state = OTG_STATE_A_WAIT_VFALL;
musb->is_active = 0;
}
break;
@@ -551,16 +551,14 @@ static void tusb_source_power(struct musb *musb, int is_on)
if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) {
switch (musb->xceiv.state) {
case OTG_STATE_A_WAIT_VFALL:
- musb->is_active = 1;
break;
case OTG_STATE_A_WAIT_VRISE:
- musb->is_active = 1;
musb->xceiv.state = OTG_STATE_A_WAIT_VFALL;
break;
default:
- musb->is_active = 0;
musb->xceiv.state = OTG_STATE_A_IDLE;
}
+ musb->is_active = 0;
musb->xceiv.default_a = 1;
MUSB_HST_MODE(musb);
} else {
@@ -778,11 +776,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
break;
}
musb->xceiv.state = OTG_STATE_A_WAIT_BCON;
- /* CONNECT can wake if a_wait_bcon is set */
- if (musb->a_wait_bcon != 0)
- musb->is_active = 0;
- else
- musb->is_active = 1;
+ musb->is_active = 0;
idle_timeout = jiffies
+ msecs_to_jiffies(musb->a_wait_bcon);
} else {
--
1.5.2.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 6/12] musb_hdrc: Improve tusb host state handling for a_idle
2007-10-11 17:05 ` [PATCH 5/12] musb_hdrc: Fix host suspend handling, remove earlier hacks Tony Lindgren
@ 2007-10-11 17:05 ` Tony Lindgren
2007-10-11 17:05 ` [PATCH 7/12] musb_hdrc: Don't idle as host if VBUS timeout is 0 Tony Lindgren
0 siblings, 1 reply; 18+ messages in thread
From: Tony Lindgren @ 2007-10-11 17:05 UTC (permalink / raw)
To: linux-omap-open-source
This patch makes the changes happen based on vbus change.
This also seems to make enumeration work better.
Signed-off-by: Tony Lindgren <tony@atomide.com>
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index b3e745d..16eaa48 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -422,18 +422,15 @@ static void musb_do_idle(unsigned long _musb)
switch (musb->xceiv.state) {
case OTG_STATE_A_WAIT_BCON:
- case OTG_STATE_A_WAIT_VRISE:
- case OTG_STATE_A_IDLE:
if ((musb->a_wait_bcon != 0)
&& (musb->idle_timeout == 0
|| time_after(jiffies, musb->idle_timeout))) {
DBG(4, "Nothing connected %s, turning off VBUS\n",
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:
break;
}
@@ -533,7 +530,6 @@ static void tusb_source_power(struct musb *musb, int is_on)
if (is_on) {
if (musb->set_clock)
musb->set_clock(musb->clock, 1);
- musb->is_active = 1;
timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);
musb->xceiv.default_a = 1;
musb->xceiv.state = OTG_STATE_A_WAIT_VRISE;
@@ -550,11 +546,13 @@ static void tusb_source_power(struct musb *musb, int is_on)
otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) {
switch (musb->xceiv.state) {
- case OTG_STATE_A_WAIT_VFALL:
- break;
case OTG_STATE_A_WAIT_VRISE:
+ case OTG_STATE_A_WAIT_BCON:
musb->xceiv.state = OTG_STATE_A_WAIT_VFALL;
break;
+ case OTG_STATE_A_WAIT_VFALL:
+ musb->xceiv.state = OTG_STATE_A_IDLE;
+ break;
default:
musb->xceiv.state = OTG_STATE_A_IDLE;
}
@@ -798,6 +796,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
break;
}
}
+ schedule_work(&musb->irq_work);
return idle_timeout;
}
--
1.5.2.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 7/12] musb_hdrc: Don't idle as host if VBUS timeout is 0
2007-10-11 17:05 ` [PATCH 6/12] musb_hdrc: Improve tusb host state handling for a_idle Tony Lindgren
@ 2007-10-11 17:05 ` Tony Lindgren
2007-10-11 17:05 ` [PATCH 8/12] musb_hdrc: Add timer for returning to host mode from HNP Tony Lindgren
0 siblings, 1 reply; 18+ messages in thread
From: Tony Lindgren @ 2007-10-11 17:05 UTC (permalink / raw)
To: linux-omap-open-source
VBUS must be on all the time in this case.
Signed-off-by: Tony Lindgren <tony@atomide.com>
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index 16eaa48..3008b6d 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -482,7 +482,9 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
if (timeout == 0)
timeout = default_timeout;
- if (musb->is_active) {
+ /* Never idle if active, or when VBUS timeout is not set as host */
+ if (musb->is_active || ((musb->a_wait_bcon == 0)
+ && (musb->xceiv.state == OTG_STATE_A_WAIT_BCON))) {
DBG(4, "%s active, deleting timer\n", otg_state_string(musb));
del_timer(&musb_idle_timer);
last_timer = jiffies;
--
1.5.2.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 8/12] musb_hdrc: Add timer for returning to host mode from HNP
2007-10-11 17:05 ` [PATCH 7/12] musb_hdrc: Don't idle as host if VBUS timeout is 0 Tony Lindgren
@ 2007-10-11 17:05 ` Tony Lindgren
2007-10-11 17:05 ` [PATCH 9/12] musb_hdrc: Make HNP more reliable Tony Lindgren
0 siblings, 1 reply; 18+ messages in thread
From: Tony Lindgren @ 2007-10-11 17:05 UTC (permalink / raw)
To: linux-omap-open-source
This seems like the only way to deal with interrupted HNP if waiting
as a_wait_bcon.
Signed-off-by: Tony Lindgren <tony@atomide.com>
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index b438036..efaa4fb 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -309,11 +309,17 @@ void musb_otg_timer_func(unsigned long data)
unsigned long flags;
spin_lock_irqsave(&musb->lock, flags);
- if (musb->xceiv.state == OTG_STATE_B_WAIT_ACON) {
- DBG(1, "HNP: B_WAIT_ACON timeout; back to B_PERIPHERAL\n");
+ switch (musb->xceiv.state) {
+ case OTG_STATE_B_WAIT_ACON:
+ DBG(1, "HNP: b_wait_acon timeout; back to b_peripheral\n");
musb_g_disconnect(musb);
musb->xceiv.state = OTG_STATE_B_PERIPHERAL;
musb->is_active = 0;
+ break;
+ case OTG_STATE_A_WAIT_BCON:
+ DBG(1, "HNP: a_wait_bcon timeout; back to a_host\n");
+ musb_hnp_stop(musb);
+ break;
}
spin_unlock_irqrestore(&musb->lock, flags);
}
@@ -649,10 +655,17 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
} else if (is_peripheral_capable()) {
DBG(1, "BUS RESET as %s\n", otg_state_string(musb));
switch (musb->xceiv.state) {
- case OTG_STATE_A_PERIPHERAL:
+#ifdef CONFIG_USB_OTG
case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */
+ DBG(1, "HNP: Setting timer as a_wait_bcon\n");
+ musb_otg_timer.data = (unsigned long)musb;
+ mod_timer(&musb_otg_timer, jiffies
+ + msecs_to_jiffies(100));
+ break;
+ case OTG_STATE_A_PERIPHERAL:
musb_hnp_stop(musb);
break;
+#endif
case OTG_STATE_B_IDLE:
musb->xceiv.state = OTG_STATE_B_PERIPHERAL;
/* FALLTHROUGH */
--
1.5.2.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 9/12] musb_hdrc: Make HNP more reliable
2007-10-11 17:05 ` [PATCH 8/12] musb_hdrc: Add timer for returning to host mode from HNP Tony Lindgren
@ 2007-10-11 17:05 ` Tony Lindgren
2007-10-11 17:05 ` [PATCH 10/12] musb_hdrc: Make vbus sysfs entry report current Vbus status Tony Lindgren
0 siblings, 1 reply; 18+ messages in thread
From: Tony Lindgren @ 2007-10-11 17:05 UTC (permalink / raw)
To: linux-omap-open-source
Sometimes we get both SUSPEND and DISCONNECT the same time.
In that case DISCONNECT must be ignored or else the HNP connection
will break right away.
Signed-off-by: Tony Lindgren <tony@atomide.com>
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index efaa4fb..3d35a4e 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -321,6 +321,7 @@ void musb_otg_timer_func(unsigned long data)
musb_hnp_stop(musb);
break;
}
+ musb->ignore_disconnect = 0;
spin_unlock_irqrestore(&musb->lock, flags);
}
@@ -656,8 +657,13 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
DBG(1, "BUS RESET as %s\n", otg_state_string(musb));
switch (musb->xceiv.state) {
#ifdef CONFIG_USB_OTG
+ case OTG_STATE_A_SUSPEND:
+ musb->ignore_disconnect = 1;
+ musb_g_reset(musb);
+ /* FALLTHROUGH */
case OTG_STATE_A_WAIT_BCON: /* OPT TD.4.7-900ms */
- DBG(1, "HNP: Setting timer as a_wait_bcon\n");
+ DBG(1, "HNP: Setting timer as %s\n",
+ otg_state_string(musb));
musb_otg_timer.data = (unsigned long)musb;
mod_timer(&musb_otg_timer, jiffies
+ msecs_to_jiffies(100));
--
1.5.2.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 10/12] musb_hdrc: Make vbus sysfs entry report current Vbus status
2007-10-11 17:05 ` [PATCH 9/12] musb_hdrc: Make HNP more reliable Tony Lindgren
@ 2007-10-11 17:05 ` Tony Lindgren
2007-10-11 17:05 ` [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended Tony Lindgren
0 siblings, 1 reply; 18+ messages in thread
From: Tony Lindgren @ 2007-10-11 17:05 UTC (permalink / raw)
To: linux-omap-open-source
From: Felipe Balbi <felipe.lima@indt.org.br>
Getting the current status of Vbus is useful when running
USB Compliance Tests.
Signed-off-by: Felipe Balbi <felipe.lima@indt.org.br>
Signed-off-by: Tony Lindgren <tony@atomide.com>
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 3d35a4e..dc934dc 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1718,12 +1718,15 @@ musb_vbus_show(struct device *dev, struct device_attribute *attr, char *buf)
struct musb *musb = dev_to_musb(dev);
unsigned long flags;
unsigned long val;
+ int vbus;
spin_lock_irqsave(&musb->lock, flags);
val = musb->a_wait_bcon;
+ vbus = musb_platform_get_vbus_status(musb);
spin_unlock_irqrestore(&musb->lock, flags);
- return sprintf(buf, "%lu\n", val);
+ return sprintf(buf, "Vbus %s, timeout %lu\n",
+ vbus ? "on" : "off", val);
}
static DEVICE_ATTR(vbus, 0644, musb_vbus_show, musb_vbus_store);
--
1.5.2.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended
2007-10-11 17:05 ` [PATCH 10/12] musb_hdrc: Make vbus sysfs entry report current Vbus status Tony Lindgren
@ 2007-10-11 17:05 ` Tony Lindgren
2007-10-11 17:05 ` musb_hdrc: Fix compile if CONFIG_ARCH_OMAP_OTG is not set Tony Lindgren
2007-10-11 20:07 ` [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended Felipe Balbi
0 siblings, 2 replies; 18+ messages in thread
From: Tony Lindgren @ 2007-10-11 17:05 UTC (permalink / raw)
To: linux-omap-open-source
Allow suspend if host is already suspended
Signed-off-by: Tony Lindgren <tony@atomide.com>
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 091ae8f..4eeff91 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2128,6 +2128,9 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
{
struct musb *musb = hcd_to_musb(hcd);
+ if (musb->xceiv.state == OTG_STATE_A_SUSPEND)
+ return 0;
+
if (is_host_active(musb) && musb->is_active) {
WARN("trying to suspend as %s is_active=%i\n",
otg_state_string(musb), musb->is_active);
--
1.5.2.5
^ permalink raw reply related [flat|nested] 18+ messages in thread
* musb_hdrc: Fix compile if CONFIG_ARCH_OMAP_OTG is not set
2007-10-11 17:05 ` [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended Tony Lindgren
@ 2007-10-11 17:05 ` Tony Lindgren
2007-10-11 20:07 ` [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended Felipe Balbi
1 sibling, 0 replies; 18+ messages in thread
From: Tony Lindgren @ 2007-10-11 17:05 UTC (permalink / raw)
To: linux-omap-open-source
Fix compile if CONFIG_ARCH_OMAP_OTG is not set
Signed-off-by: Tony Lindgren <tony@atomide.com>
--- a/arch/arm/plat-omap/usb.c
+++ b/arch/arm/plat-omap/usb.c
@@ -76,7 +76,7 @@
/*-------------------------------------------------------------------------*/
-#ifdef CONFIG_ARCH_OMAP_OTG
+#if defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_USB_MUSB_OTG)
static struct otg_transceiver *xceiv;
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended
2007-10-11 17:05 ` [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended Tony Lindgren
2007-10-11 17:05 ` musb_hdrc: Fix compile if CONFIG_ARCH_OMAP_OTG is not set Tony Lindgren
@ 2007-10-11 20:07 ` Felipe Balbi
2007-10-11 20:21 ` David Brownell
1 sibling, 1 reply; 18+ messages in thread
From: Felipe Balbi @ 2007-10-11 20:07 UTC (permalink / raw)
To: Tony Lindgren; +Cc: linux-omap-open-source
Hi,
On 10/11/07, Tony Lindgren <tony@atomide.com> wrote:
> Allow suspend if host is already suspended
>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
>
> diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
> index 091ae8f..4eeff91 100644
> --- a/drivers/usb/musb/musb_host.c
> +++ b/drivers/usb/musb/musb_host.c
> @@ -2128,6 +2128,9 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
> {
> struct musb *musb = hcd_to_musb(hcd);
>
> + if (musb->xceiv.state == OTG_STATE_A_SUSPEND)
> + return 0;
> +
Should we allow this ? If it's already suspended it doesn't make sense
suspending again. And in OTG state machine there's no way to suspend a
suspended device i.e. no loop going back to [ab]_suspend state.
In any case, if it works... ;-)
> if (is_host_active(musb) && musb->is_active) {
> WARN("trying to suspend as %s is_active=%i\n",
> otg_state_string(musb), musb->is_active);
> --
> 1.5.2.5
>
> _______________________________________________
> Linux-omap-open-source mailing list
> Linux-omap-open-source@linux.omap.com
> http://linux.omap.com/mailman/listinfo/linux-omap-open-source
>
--
Best Regards,
Felipe Balbi
felipebalbi@users.sourceforge.net
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended
2007-10-11 20:07 ` [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended Felipe Balbi
@ 2007-10-11 20:21 ` David Brownell
2007-10-11 20:38 ` Felipe Balbi
0 siblings, 1 reply; 18+ messages in thread
From: David Brownell @ 2007-10-11 20:21 UTC (permalink / raw)
To: tony, felipebalbi; +Cc: linux-omap-open-source
> > @@ -2128,6 +2128,9 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
> > {
> > struct musb *musb = hcd_to_musb(hcd);
> >
> > + if (musb->xceiv.state == OTG_STATE_A_SUSPEND)
> > + return 0;
> > +
>
> Should we allow this ? If it's already suspended it doesn't make sense
> suspending again.
Allow it. The invariant is that when the call returns,
the bus has been suspended.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended
2007-10-11 20:21 ` David Brownell
@ 2007-10-11 20:38 ` Felipe Balbi
0 siblings, 0 replies; 18+ messages in thread
From: Felipe Balbi @ 2007-10-11 20:38 UTC (permalink / raw)
To: David Brownell; +Cc: linux-omap-open-source
On 10/11/07, David Brownell <david-b@pacbell.net> wrote:
<snip>
> > Should we allow this ? If it's already suspended it doesn't make sense
> > suspending again.
>
> Allow it. The invariant is that when the call returns,
> the bus has been suspended.
K... thanks for clarification. ;-)
--
Best Regards,
Felipe Balbi
felipebalbi@users.sourceforge.net
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/12] musb_hdrc: Remove old sysfs entry cable, use mode instead
2007-10-11 17:05 ` [PATCH 3/12] musb_hdrc: Remove old sysfs entry cable, use mode instead Tony Lindgren
2007-10-11 17:05 ` [PATCH 4/12] musb_hdrc: Remove non-debug otg_state_string Tony Lindgren
@ 2007-10-12 0:56 ` David Brownell
1 sibling, 0 replies; 18+ messages in thread
From: David Brownell @ 2007-10-12 0:56 UTC (permalink / raw)
To: linux-omap-open-source
Glad to see this go. :)
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/12] musb_hdrc: Host and OTG updates
2007-10-11 17:05 [PATCH 0/12] musb_hdrc: Host and OTG updates Tony Lindgren
2007-10-11 17:05 ` [PATCH 1/12] musb_hdrc: Allow tusb3.0 and greater to use multichannel DMA Tony Lindgren
@ 2007-10-12 20:32 ` Tony Lindgren
1 sibling, 0 replies; 18+ messages in thread
From: Tony Lindgren @ 2007-10-12 20:32 UTC (permalink / raw)
To: linux-omap-open-source
* Tony Lindgren <tony@atomide.com> [071011 10:05]:
> Hi all,
>
> Attached patch series updates musb code for host PM (mostly
> on tusb6010), and otg HNP stuff. Please comment and test.
>
> Tested on tusb, compile tested on 2430sdp.
Pushing this series today.
Tony
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2007-10-12 20:32 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-11 17:05 [PATCH 0/12] musb_hdrc: Host and OTG updates Tony Lindgren
2007-10-11 17:05 ` [PATCH 1/12] musb_hdrc: Allow tusb3.0 and greater to use multichannel DMA Tony Lindgren
2007-10-11 17:05 ` [PATCH 2/12] musb_hdrc: Add more sysfs notify events Tony Lindgren
2007-10-11 17:05 ` [PATCH 3/12] musb_hdrc: Remove old sysfs entry cable, use mode instead Tony Lindgren
2007-10-11 17:05 ` [PATCH 4/12] musb_hdrc: Remove non-debug otg_state_string Tony Lindgren
2007-10-11 17:05 ` [PATCH 5/12] musb_hdrc: Fix host suspend handling, remove earlier hacks Tony Lindgren
2007-10-11 17:05 ` [PATCH 6/12] musb_hdrc: Improve tusb host state handling for a_idle Tony Lindgren
2007-10-11 17:05 ` [PATCH 7/12] musb_hdrc: Don't idle as host if VBUS timeout is 0 Tony Lindgren
2007-10-11 17:05 ` [PATCH 8/12] musb_hdrc: Add timer for returning to host mode from HNP Tony Lindgren
2007-10-11 17:05 ` [PATCH 9/12] musb_hdrc: Make HNP more reliable Tony Lindgren
2007-10-11 17:05 ` [PATCH 10/12] musb_hdrc: Make vbus sysfs entry report current Vbus status Tony Lindgren
2007-10-11 17:05 ` [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended Tony Lindgren
2007-10-11 17:05 ` musb_hdrc: Fix compile if CONFIG_ARCH_OMAP_OTG is not set Tony Lindgren
2007-10-11 20:07 ` [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended Felipe Balbi
2007-10-11 20:21 ` David Brownell
2007-10-11 20:38 ` Felipe Balbi
2007-10-12 0:56 ` [PATCH 3/12] musb_hdrc: Remove old sysfs entry cable, use mode instead David Brownell
2007-10-12 20:32 ` [PATCH 0/12] musb_hdrc: Host and OTG updates Tony Lindgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox