public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: musb: dsps: implement vbus_status method
@ 2015-10-07 14:40 Roman Alyautdin
  2015-10-08 13:50 ` Sergei Shtylyov
  0 siblings, 1 reply; 5+ messages in thread
From: Roman Alyautdin @ 2015-10-07 14:40 UTC (permalink / raw)
  To: balbi; +Cc: linux-usb, linux-kernel, sergei.shtylyov, Roman Alyautdin

Implement vbus_status  method of musb_platform_ops that allows
musb_core to properly represent the VBUS status of musb_dsps devices in
corresponding sysfs entry

Signed-off-by: Roman Alyautdin <ralyautdin@dev.rtsoft.ru>
---
 drivers/usb/musb/musb_dsps.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 84512d1..9c00edf 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -632,6 +632,18 @@ static void dsps_read_fifo32(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
 	}
 }
 
+static int dsps_musb_vbus_status(struct musb *musb)
+{
+	void __iomem *mregs = musb->mregs;
+	u8 devctl;
+
+	devctl = dsps_readb(mregs, MUSB_DEVCTL);
+	if ((devctl & MUSB_DEVCTL_VBUS) == (3 << MUSB_DEVCTL_VBUS_SHIFT))
+		return 1;
+	else
+		return 0;
+}
+
 static struct musb_platform_ops dsps_ops = {
 	.quirks		= MUSB_DMA_CPPI41 | MUSB_INDEXED_EP,
 	.init		= dsps_musb_init,
@@ -647,6 +659,7 @@ static struct musb_platform_ops dsps_ops = {
 	.try_idle	= dsps_musb_try_idle,
 	.set_mode	= dsps_musb_set_mode,
 	.recover	= dsps_musb_recover,
+	.vbus_status	= dsps_musb_vbus_status,
 };
 
 static u64 musb_dmamask = DMA_BIT_MASK(32);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: musb: dsps: implement vbus_status method
  2015-10-07 14:40 [PATCH] usb: musb: dsps: implement vbus_status method Roman Alyautdin
@ 2015-10-08 13:50 ` Sergei Shtylyov
  2015-10-08 14:07   ` Sergei Shtylyov
  0 siblings, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2015-10-08 13:50 UTC (permalink / raw)
  To: Roman Alyautdin, balbi; +Cc: linux-usb, linux-kernel

Hello.

On 10/7/2015 5:40 PM, Roman Alyautdin wrote:

> Implement vbus_status  method of musb_platform_ops that allows
> musb_core to properly represent the VBUS status of musb_dsps devices in
> corresponding sysfs entry
>
> Signed-off-by: Roman Alyautdin <ralyautdin@dev.rtsoft.ru>
> ---
>   drivers/usb/musb/musb_dsps.c |   13 +++++++++++++
>   1 file changed, 13 insertions(+)
>
> diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
> index 84512d1..9c00edf 100644
> --- a/drivers/usb/musb/musb_dsps.c
> +++ b/drivers/usb/musb/musb_dsps.c
> @@ -632,6 +632,18 @@ static void dsps_read_fifo32(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
>   	}
>   }
>
> +static int dsps_musb_vbus_status(struct musb *musb)
> +{
> +	void __iomem *mregs = musb->mregs;
> +	u8 devctl;
> +
> +	devctl = dsps_readb(mregs, MUSB_DEVCTL);
> +	if ((devctl & MUSB_DEVCTL_VBUS) == (3 << MUSB_DEVCTL_VBUS_SHIFT))

    I don't see why this has to be is implemented in the DSPS glue layer. The 
DevCtl register is a standard MUSB one.

[...]

MBR, Sergei


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: musb: dsps: implement vbus_status method
  2015-10-08 13:50 ` Sergei Shtylyov
@ 2015-10-08 14:07   ` Sergei Shtylyov
  2015-10-08 14:27     ` Roman Alyautdin
  0 siblings, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2015-10-08 14:07 UTC (permalink / raw)
  To: Roman Alyautdin, balbi; +Cc: linux-usb, linux-kernel

On 10/8/2015 4:50 PM, Sergei Shtylyov wrote:

>> Implement vbus_status  method of musb_platform_ops that allows
>> musb_core to properly represent the VBUS status of musb_dsps devices in
>> corresponding sysfs entry
>>
>> Signed-off-by: Roman Alyautdin <ralyautdin@dev.rtsoft.ru>
>> ---
>>   drivers/usb/musb/musb_dsps.c |   13 +++++++++++++
>>   1 file changed, 13 insertions(+)
>>
>> diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
>> index 84512d1..9c00edf 100644
>> --- a/drivers/usb/musb/musb_dsps.c
>> +++ b/drivers/usb/musb/musb_dsps.c
>> @@ -632,6 +632,18 @@ static void dsps_read_fifo32(struct musb_hw_ep *hw_ep,
>> u16 len, u8 *dst)
>>       }
>>   }
>>
>> +static int dsps_musb_vbus_status(struct musb *musb)
>> +{
>> +    void __iomem *mregs = musb->mregs;
>> +    u8 devctl;
>> +
>> +    devctl = dsps_readb(mregs, MUSB_DEVCTL);
>> +    if ((devctl & MUSB_DEVCTL_VBUS) == (3 << MUSB_DEVCTL_VBUS_SHIFT))
>
>     I don't see why this has to be is implemented in the DSPS glue layer. The
> DevCtl register is a standard MUSB one.

    Looking at the musb_platform_get_vbus_status(), it's unclear why it 
returns 0 if the vbus_status() method id undefined. I think we should read the 
DevCtl registre here, removing the FIXME at the call site.

MBR, Sergei


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: musb: dsps: implement vbus_status method
  2015-10-08 14:07   ` Sergei Shtylyov
@ 2015-10-08 14:27     ` Roman Alyautdin
  2015-10-09 21:19       ` Felipe Balbi
  0 siblings, 1 reply; 5+ messages in thread
From: Roman Alyautdin @ 2015-10-08 14:27 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: balbi, linux-usb, linux-kernel

On 08/10/15 17:07, Sergei Shtylyov wrote:
> On 10/8/2015 4:50 PM, Sergei Shtylyov wrote:
>
>>> Implement vbus_status  method of musb_platform_ops that allows
>>> musb_core to properly represent the VBUS status of musb_dsps devices in
>>> corresponding sysfs entry
>>>
>>> Signed-off-by: Roman Alyautdin <ralyautdin@dev.rtsoft.ru>
>>> ---
>>>   drivers/usb/musb/musb_dsps.c |   13 +++++++++++++
>>>   1 file changed, 13 insertions(+)
>>>
>>> diff --git a/drivers/usb/musb/musb_dsps.c 
>>> b/drivers/usb/musb/musb_dsps.c
>>> index 84512d1..9c00edf 100644
>>> --- a/drivers/usb/musb/musb_dsps.c
>>> +++ b/drivers/usb/musb/musb_dsps.c
>>> @@ -632,6 +632,18 @@ static void dsps_read_fifo32(struct musb_hw_ep 
>>> *hw_ep,
>>> u16 len, u8 *dst)
>>>       }
>>>   }
>>>
>>> +static int dsps_musb_vbus_status(struct musb *musb)
>>> +{
>>> +    void __iomem *mregs = musb->mregs;
>>> +    u8 devctl;
>>> +
>>> +    devctl = dsps_readb(mregs, MUSB_DEVCTL);
>>> +    if ((devctl & MUSB_DEVCTL_VBUS) == (3 << MUSB_DEVCTL_VBUS_SHIFT))
>>
>>     I don't see why this has to be is implemented in the DSPS glue 
>> layer. The
>> DevCtl register is a standard MUSB one.
>
>    Looking at the musb_platform_get_vbus_status(), it's unclear why it 
> returns 0 if the vbus_status() method id undefined. I think we should 
> read the DevCtl registre here, removing the FIXME at the call site.

Maybe it is worth to return -EINVAL from musb_platform_get_vbus_status 
in case of method is undefined and keep current logic of interface 
implementation in platform-specific driver.

Hence print "Vbus unknown" in musb_vbus_show() in case of -EINVAL from 
musb_platform_get_vbus_status

Regards,
Roman


>
> MBR, Sergei
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: musb: dsps: implement vbus_status method
  2015-10-08 14:27     ` Roman Alyautdin
@ 2015-10-09 21:19       ` Felipe Balbi
  0 siblings, 0 replies; 5+ messages in thread
From: Felipe Balbi @ 2015-10-09 21:19 UTC (permalink / raw)
  To: Roman Alyautdin, Sergei Shtylyov; +Cc: linux-usb, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1984 bytes --]


Hi,

Roman Alyautdin <ralyautdin@dev.rtsoft.ru> writes:
> On 08/10/15 17:07, Sergei Shtylyov wrote:
>> On 10/8/2015 4:50 PM, Sergei Shtylyov wrote:
>>
>>>> Implement vbus_status  method of musb_platform_ops that allows
>>>> musb_core to properly represent the VBUS status of musb_dsps devices in
>>>> corresponding sysfs entry
>>>>
>>>> Signed-off-by: Roman Alyautdin <ralyautdin@dev.rtsoft.ru>
>>>> ---
>>>>   drivers/usb/musb/musb_dsps.c |   13 +++++++++++++
>>>>   1 file changed, 13 insertions(+)
>>>>
>>>> diff --git a/drivers/usb/musb/musb_dsps.c 
>>>> b/drivers/usb/musb/musb_dsps.c
>>>> index 84512d1..9c00edf 100644
>>>> --- a/drivers/usb/musb/musb_dsps.c
>>>> +++ b/drivers/usb/musb/musb_dsps.c
>>>> @@ -632,6 +632,18 @@ static void dsps_read_fifo32(struct musb_hw_ep 
>>>> *hw_ep,
>>>> u16 len, u8 *dst)
>>>>       }
>>>>   }
>>>>
>>>> +static int dsps_musb_vbus_status(struct musb *musb)
>>>> +{
>>>> +    void __iomem *mregs = musb->mregs;
>>>> +    u8 devctl;
>>>> +
>>>> +    devctl = dsps_readb(mregs, MUSB_DEVCTL);
>>>> +    if ((devctl & MUSB_DEVCTL_VBUS) == (3 << MUSB_DEVCTL_VBUS_SHIFT))
>>>
>>>     I don't see why this has to be is implemented in the DSPS glue 
>>> layer. The
>>> DevCtl register is a standard MUSB one.
>>
>>    Looking at the musb_platform_get_vbus_status(), it's unclear why it 
>> returns 0 if the vbus_status() method id undefined. I think we should 
>> read the DevCtl registre here, removing the FIXME at the call site.
>
> Maybe it is worth to return -EINVAL from musb_platform_get_vbus_status 
> in case of method is undefined and keep current logic of interface 
> implementation in platform-specific driver.
>
> Hence print "Vbus unknown" in musb_vbus_show() in case of -EINVAL from 
> musb_platform_get_vbus_status

I actually like the idea of reading DevCtl. That's a nice, safe default
afaict. That's one of the information DevCtl is supposed to tell MUSB anyway.

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-09 21:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-07 14:40 [PATCH] usb: musb: dsps: implement vbus_status method Roman Alyautdin
2015-10-08 13:50 ` Sergei Shtylyov
2015-10-08 14:07   ` Sergei Shtylyov
2015-10-08 14:27     ` Roman Alyautdin
2015-10-09 21:19       ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox