[1/9] usb: dwc2/gadget: report disconnect event from 'end session' irq

Message ID 1413464285-24172-2-git-send-email-m.szyprowski@samsung.com
State New
Headers show

Commit Message

Marek Szyprowski Oct. 16, 2014, 12:57 p.m.
This patch adds a call to s3c_hsotg_disconnect() from 'end session'
interrupt to correctly notify gadget subsystem about unplugged usb
cable.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 drivers/usb/dwc2/gadget.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Felipe Balbi Oct. 16, 2014, 1:33 p.m. | #1
On Thu, Oct 16, 2014 at 02:57:57PM +0200, Marek Szyprowski wrote:
> This patch adds a call to s3c_hsotg_disconnect() from 'end session'
> interrupt to correctly notify gadget subsystem about unplugged usb
> cable.
> 
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>  drivers/usb/dwc2/gadget.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 7b5856fadd93..119c8a3effc2 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -2279,6 +2279,12 @@ irq_retry:
>  		dev_info(hsotg->dev, "OTGInt: %08x\n", otgint);
>  
>  		writel(otgint, hsotg->regs + GOTGINT);
> +
> +		if (otgint & GOTGINT_SES_END_DET) {

looks like this should be done for GINTSTS_DISCONNINT.
Marek Szyprowski Oct. 17, 2014, 10:35 a.m. | #2
Hello,

On 2014-10-16 15:33, Felipe Balbi wrote:
> On Thu, Oct 16, 2014 at 02:57:57PM +0200, Marek Szyprowski wrote:
>> This patch adds a call to s3c_hsotg_disconnect() from 'end session'
>> interrupt to correctly notify gadget subsystem about unplugged usb
>> cable.
>>
>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
>> ---
>>   drivers/usb/dwc2/gadget.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
>> index 7b5856fadd93..119c8a3effc2 100644
>> --- a/drivers/usb/dwc2/gadget.c
>> +++ b/drivers/usb/dwc2/gadget.c
>> @@ -2279,6 +2279,12 @@ irq_retry:
>>   		dev_info(hsotg->dev, "OTGInt: %08x\n", otgint);
>>   
>>   		writel(otgint, hsotg->regs + GOTGINT);
>> +
>> +		if (otgint & GOTGINT_SES_END_DET) {
> looks like this should be done for GINTSTS_DISCONNINT.

I also would like to report it from that interrupt, but according to 
DWC2 databook
(version 2.81a) and my observations on Samsung Exynos SoCs, DISCONNINT 
interrupt
is asserted only in host mode, so in device mode we need to use 
something else.

Best regards
Felipe Balbi Oct. 17, 2014, 7:20 p.m. | #3
On Fri, Oct 17, 2014 at 12:35:39PM +0200, Marek Szyprowski wrote:
> Hello,
> 
> On 2014-10-16 15:33, Felipe Balbi wrote:
> >On Thu, Oct 16, 2014 at 02:57:57PM +0200, Marek Szyprowski wrote:
> >>This patch adds a call to s3c_hsotg_disconnect() from 'end session'
> >>interrupt to correctly notify gadget subsystem about unplugged usb
> >>cable.
> >>
> >>Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> >>---
> >>  drivers/usb/dwc2/gadget.c | 6 ++++++
> >>  1 file changed, 6 insertions(+)
> >>
> >>diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> >>index 7b5856fadd93..119c8a3effc2 100644
> >>--- a/drivers/usb/dwc2/gadget.c
> >>+++ b/drivers/usb/dwc2/gadget.c
> >>@@ -2279,6 +2279,12 @@ irq_retry:
> >>  		dev_info(hsotg->dev, "OTGInt: %08x\n", otgint);
> >>  		writel(otgint, hsotg->regs + GOTGINT);
> >>+
> >>+		if (otgint & GOTGINT_SES_END_DET) {
> >looks like this should be done for GINTSTS_DISCONNINT.
> 
> I also would like to report it from that interrupt, but according to
> DWC2 databook (version 2.81a) and my observations on Samsung Exynos
> SoCs, DISCONNINT interrupt is asserted only in host mode, so in device
> mode we need to use something else.

If that's the case, then I withdraw my comments. I don't have access to
HW or docs about this IP, it just looked suspicious :-)

Patch

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 7b5856fadd93..119c8a3effc2 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2279,6 +2279,12 @@  irq_retry:
 		dev_info(hsotg->dev, "OTGInt: %08x\n", otgint);
 
 		writel(otgint, hsotg->regs + GOTGINT);
+
+		if (otgint & GOTGINT_SES_END_DET) {
+			if (hsotg->gadget.speed != USB_SPEED_UNKNOWN)
+				s3c_hsotg_disconnect(hsotg);
+			hsotg->gadget.speed = USB_SPEED_UNKNOWN;
+		}
 	}
 
 	if (gintsts & GINTSTS_SESSREQINT) {