* [PATCH 1/2] USB: musb: add two states to handle vbus error
@ 2010-03-15 10:23 Wang Hui
[not found] ` <1268648622-28529-1-git-send-email-Hui.Wang-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
2010-03-16 10:49 ` [PATCH 1/2] USB: musb: add two states to handle vbus error wanghui
0 siblings, 2 replies; 10+ messages in thread
From: Wang Hui @ 2010-03-15 10:23 UTC (permalink / raw)
To: tony, felipe.balbi; +Cc: linux-arm-kernel, linux-usb, linux-omap
When the MUSB is configured as host mode or OTG mode, the xceiv->state
will be set to OTG_STATE_A_IDLE or OTG_STATE_B_IDLE unconditionally
during init process. These init states can change to other
states When the MUSB module detects id pin change, devices connect or
disconnect.
But on some platforms(omap2, omap3), the id pin change
can't raise IRQ request to the MUSB module, so on these platforms,
the init xceiv->state will be A_IDLE or B_IDLE. Under this condition,
when we want the MUSB to act as a host and hotplug a usb device in
mini-B side of the cable, the MUSB will have a possibility to suffer
power underrun under A_IDLE or B_IDLE state, So here adding these
two states under which we can handle VBUSERROR IRQ.
Signed-off-by: Wang Hui <Hui.Wang@windriver.com>
---
drivers/usb/musb/musb_core.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index b4bbf8f..655413c 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -516,6 +516,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
* another reset is due (at least for high speed,
* to redo the chirp etc), it might work OK...
*/
+ case OTG_STATE_A_IDLE:
+ case OTG_STATE_B_IDLE:
case OTG_STATE_A_WAIT_BCON:
case OTG_STATE_A_WAIT_VRISE:
if (musb->vbuserr_retry) {
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread[parent not found: <1268648622-28529-1-git-send-email-Hui.Wang-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>]
* [PATCH 2/2] USB: musb: omap2430: add mode change from A to B
[not found] ` <1268648622-28529-1-git-send-email-Hui.Wang-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
@ 2010-03-15 10:23 ` Wang Hui
[not found] ` <1268648622-28529-2-git-send-email-Hui.Wang-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
2010-07-22 15:16 ` Kan-Ru Chen
0 siblings, 2 replies; 10+ messages in thread
From: Wang Hui @ 2010-03-15 10:23 UTC (permalink / raw)
To: tony-4v6yS6AI5VpBDgjK7y7TUQ, felipe.balbi-xNZwKgViW5gAvxtiuMwx3w
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-omap-u79uwXL29TY76Z2rM5mHXA
On omap2/3 series platforms, the musb can't raise id pin change
detection interrupt, so we must change otg mode through sysfs
interface manually. Currently when the musb is in B mode, if we
want musb to be changed to A mode, we should plug a mini-A cable
and then execute echo host > /sys/devices/platform/musb_hdrc/mode.
But if the musb is in A mode, we can't change it to B mode through
this method.
To solve this problem, add a process for sending end session request.
This process works like this, if the musb is in A mode, it will send
an end session request first, then it will follow original routine:
start a new session, during this session, it will identify whether
A or B is plugging in the socket, then it will init controller to A
or B mode according to its identification.
Usage: change cable as you desired,
change musb mode by #>echo host[peripheral] > /sys/devices/\
platform/musb_hdrc/mode,
then you will get required musb mode.
Signed-off-by: Wang Hui <Hui.Wang-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
---
drivers/usb/musb/omap2430.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 3fe1686..b02897e 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -194,6 +194,11 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
{
u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
+ if ((devctl & MUSB_DEVCTL_BDEVICE) == 0x0) {
+ devctl &= ~MUSB_DEVCTL_SESSION;
+ musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
+ }
+
devctl |= MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
--
1.5.6.5
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 10+ messages in thread[parent not found: <1268648622-28529-2-git-send-email-Hui.Wang-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>]
* Re: [PATCH 2/2] USB: musb: omap2430: add mode change from A to B
[not found] ` <1268648622-28529-2-git-send-email-Hui.Wang-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
@ 2010-03-15 11:22 ` Sergei Shtylyov
[not found] ` <4B9E187E.6090802-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
0 siblings, 1 reply; 10+ messages in thread
From: Sergei Shtylyov @ 2010-03-15 11:22 UTC (permalink / raw)
To: Wang Hui
Cc: tony-4v6yS6AI5VpBDgjK7y7TUQ, felipe.balbi-xNZwKgViW5gAvxtiuMwx3w,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-omap-u79uwXL29TY76Z2rM5mHXA
Hello.
Wang Hui wrote:
> On omap2/3 series platforms, the musb can't raise id pin change
> detection interrupt, so we must change otg mode through sysfs
> interface manually. Currently when the musb is in B mode, if we
> want musb to be changed to A mode, we should plug a mini-A cable
> and then execute echo host > /sys/devices/platform/musb_hdrc/mode.
> But if the musb is in A mode, we can't change it to B mode through
> this method.
> To solve this problem, add a process for sending end session request.
> This process works like this, if the musb is in A mode, it will send
> an end session request first, then it will follow original routine:
> start a new session, during this session, it will identify whether
> A or B is plugging in the socket, then it will init controller to A
> or B mode according to its identification.
>
> Usage: change cable as you desired,
> change musb mode by #>echo host[peripheral] > /sys/devices/\
> platform/musb_hdrc/mode,
> then you will get required musb mode.
>
> Signed-off-by: Wang Hui <Hui.Wang-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
> ---
> drivers/usb/musb/omap2430.c | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
> index 3fe1686..b02897e 100644
> --- a/drivers/usb/musb/omap2430.c
> +++ b/drivers/usb/musb/omap2430.c
> @@ -194,6 +194,11 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
> {
> u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
>
> + if ((devctl & MUSB_DEVCTL_BDEVICE) == 0x0) {
> + devctl &= ~MUSB_DEVCTL_SESSION;
> + musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
> + }
> +
> devctl |= MUSB_DEVCTL_SESSION;
> musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
>
The whole musb_platform_set_mode() seems to be implemented
incorrectly on OMAPs -- it shouldn't touch the DevCtl.Session bit. This
function should control the ID pin override instead -- if the controller
supports it. SRP must be initiated thru other means, i.e. 'srp' file in
sysfs.
WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] USB: musb: omap2430: add mode change from A to B
2010-03-15 10:23 ` [PATCH 2/2] USB: musb: omap2430: add mode change from A to B Wang Hui
[not found] ` <1268648622-28529-2-git-send-email-Hui.Wang-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
@ 2010-07-22 15:16 ` Kan-Ru Chen
[not found] ` <877hknwnrb.fsf-ONHucydYG54+Yz5RL6G0bA@public.gmane.org>
1 sibling, 1 reply; 10+ messages in thread
From: Kan-Ru Chen @ 2010-07-22 15:16 UTC (permalink / raw)
To: Wang Hui, tony, felipe.balbi; +Cc: linux-omap, linux-usb, linux-arm-kernel
--text follows this line--
Hi,
On Mon, 15 Mar 2010 18:23:42 +0800, Wang Hui <Hui.Wang@windriver.com> wrote:
> On omap2/3 series platforms, the musb can't raise id pin change
> detection interrupt, so we must change otg mode through sysfs
> interface manually. Currently when the musb is in B mode, if we
> want musb to be changed to A mode, we should plug a mini-A cable
> and then execute echo host > /sys/devices/platform/musb_hdrc/mode.
> But if the musb is in A mode, we can't change it to B mode through
> this method.
> To solve this problem, add a process for sending end session request.
> This process works like this, if the musb is in A mode, it will send
> an end session request first, then it will follow original routine:
> start a new session, during this session, it will identify whether
> A or B is plugging in the socket, then it will init controller to A
> or B mode according to its identification.
Just curious about how to do this in a more automatic way.
I think setup a daemon to monitor the musb_hdrc mode and try to alter
it's state via sysfs interface will work, but it may be error prone and
not always desirable solution.
Can we query the id pin state periodically in the kernel and change to
corresponding role?
Regards,
Kanru
>
> Usage: change cable as you desired,
> change musb mode by #>echo host[peripheral] > /sys/devices/\
> platform/musb_hdrc/mode,
> then you will get required musb mode.
>
> Signed-off-by: Wang Hui <Hui.Wang@windriver.com>
> ---
> drivers/usb/musb/omap2430.c | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
> index 3fe1686..b02897e 100644
> --- a/drivers/usb/musb/omap2430.c
> +++ b/drivers/usb/musb/omap2430.c
> @@ -194,6 +194,11 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
> {
> u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
>
> + if ((devctl & MUSB_DEVCTL_BDEVICE) == 0x0) {
> + devctl &= ~MUSB_DEVCTL_SESSION;
> + musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
> + }
> +
> devctl |= MUSB_DEVCTL_SESSION;
> musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
>
> --
> 1.5.6.5
>
> --
> 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] USB: musb: add two states to handle vbus error
2010-03-15 10:23 [PATCH 1/2] USB: musb: add two states to handle vbus error Wang Hui
[not found] ` <1268648622-28529-1-git-send-email-Hui.Wang-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
@ 2010-03-16 10:49 ` wanghui
1 sibling, 0 replies; 10+ messages in thread
From: wanghui @ 2010-03-16 10:49 UTC (permalink / raw)
To: Wang Hui; +Cc: tony, felipe.balbi, linux-omap, linux-usb, linux-arm-kernel
On omap platforms, when configuring the kernel, if we choose the musb
work as host or OTG mode and we plug
a mini-A cable into the socket, after the kernel boot up in host mode or
insmod gadget driver in OTG mode,
the state of musb's xceiv is A_IDLE or B_IDLE correspondingly because id
change can't trigger ISR. Under this
condition, if we hotplug a usb device(without self-powered) at the other
side of the cable, the musb will suffer a vbus error,
This patch can handle this vbus error.
Wang Hui wrote:
> When the MUSB is configured as host mode or OTG mode, the xceiv->state
> will be set to OTG_STATE_A_IDLE or OTG_STATE_B_IDLE unconditionally
> during init process. These init states can change to other
> states When the MUSB module detects id pin change, devices connect or
> disconnect.
> But on some platforms(omap2, omap3), the id pin change
> can't raise IRQ request to the MUSB module, so on these platforms,
> the init xceiv->state will be A_IDLE or B_IDLE. Under this condition,
> when we want the MUSB to act as a host and hotplug a usb device in
> mini-B side of the cable, the MUSB will have a possibility to suffer
> power underrun under A_IDLE or B_IDLE state, So here adding these
> two states under which we can handle VBUSERROR IRQ.
>
> Signed-off-by: Wang Hui <Hui.Wang@windriver.com>
> ---
> drivers/usb/musb/musb_core.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index b4bbf8f..655413c 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -516,6 +516,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
> * another reset is due (at least for high speed,
> * to redo the chirp etc), it might work OK...
> */
> + case OTG_STATE_A_IDLE:
> + case OTG_STATE_B_IDLE:
> case OTG_STATE_A_WAIT_BCON:
> case OTG_STATE_A_WAIT_VRISE:
> if (musb->vbuserr_retry) {
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2010-07-23 4:39 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-15 10:23 [PATCH 1/2] USB: musb: add two states to handle vbus error Wang Hui
[not found] ` <1268648622-28529-1-git-send-email-Hui.Wang-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
2010-03-15 10:23 ` [PATCH 2/2] USB: musb: omap2430: add mode change from A to B Wang Hui
[not found] ` <1268648622-28529-2-git-send-email-Hui.Wang-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
2010-03-15 11:22 ` Sergei Shtylyov
[not found] ` <4B9E187E.6090802-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
2010-03-15 16:10 ` Felipe Balbi
2010-03-16 10:13 ` wanghui
[not found] ` <4B9F59DE.4070807-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
2010-03-16 14:46 ` Felipe Balbi
2010-07-22 15:16 ` Kan-Ru Chen
[not found] ` <877hknwnrb.fsf-ONHucydYG54+Yz5RL6G0bA@public.gmane.org>
2010-07-22 16:40 ` Felipe Balbi
2010-07-23 4:38 ` Kan-Ru Chen
2010-03-16 10:49 ` [PATCH 1/2] USB: musb: add two states to handle vbus error wanghui
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).