2021-08-23 18:47:08

by Shah, Nehal-bakulchandra

[permalink] [raw]
Subject: [PATCH 2/2] usb: dwc3: pci add property to allow user space role switch

For AMD platform there is a requirement to enable user space role
switch from host to device and device to host by means of running
following commands.

HOST: echo host > /sys/class/usb_role/dwc3.0.auto-role-switch/role
DEVICE: echo device > /sys/class/usb_role/dwc3.0.auto-role-switch/role
Signed-off-by: Nehal Bakulchandra Shah <[email protected]>
---
drivers/usb/dwc3/drd.c | 2 ++
drivers/usb/dwc3/dwc3-pci.c | 1 +
2 files changed, 3 insertions(+)

diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
index 8fcbac10510c..6d579780ffcc 100644
--- a/drivers/usb/dwc3/drd.c
+++ b/drivers/usb/dwc3/drd.c
@@ -555,6 +555,8 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc)
mode = DWC3_GCTL_PRTCAP_DEVICE;
}

+ if (device_property_read_bool(dwc->dev, "allow-userspace-role-switch"))
+ dwc3_role_switch.allow_userspace_control = true;
dwc3_role_switch.fwnode = dev_fwnode(dwc->dev);
dwc3_role_switch.set = dwc3_usb_role_switch_set;
dwc3_role_switch.get = dwc3_usb_role_switch_get;
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 7ff8fc8f79a9..c1412a6e85b6 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -153,6 +153,7 @@ static const struct property_entry dwc3_pci_mr_properties[] = {
PROPERTY_ENTRY_STRING("dr_mode", "otg"),
PROPERTY_ENTRY_BOOL("usb-role-switch"),
PROPERTY_ENTRY_STRING("role-switch-default-mode", "host"),
+ PROPERTY_ENTRY_BOOL("allow-userspace-role-switch"),
PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
{}
};
--
2.25.1


2021-08-24 08:23:32

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: dwc3: pci add property to allow user space role switch


Nehal Bakulchandra Shah <[email protected]> writes:

> For AMD platform there is a requirement to enable user space role
> switch from host to device and device to host by means of running
> following commands.
>
> HOST: echo host > /sys/class/usb_role/dwc3.0.auto-role-switch/role
> DEVICE: echo device > /sys/class/usb_role/dwc3.0.auto-role-switch/role

A more important question that needs to be answered: why?

--
balbi

2021-08-24 16:04:14

by Shah, Nehal-bakulchandra

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: dwc3: pci add property to allow user space role switch

Hi
On 8/24/2021 1:49 PM, Felipe Balbi wrote:
>
> Nehal Bakulchandra Shah <[email protected]> writes:
>
>> For AMD platform there is a requirement to enable user space role
>> switch from host to device and device to host by means of running
>> following commands.
>>
>> HOST: echo host > /sys/class/usb_role/dwc3.0.auto-role-switch/role
>> DEVICE: echo device > /sys/class/usb_role/dwc3.0.auto-role-switch/role
>
> A more important question that needs to be answered: why?
>
Our customer platform is not completely capable of OTG i.e with type C
controller it does not have PD to support role switching. Hence, they
have script which triggers the role switch based on ACPI/EC interrupt.

Regards
Nehal Shah

2021-08-24 16:19:06

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: dwc3: pci add property to allow user space role switch


"Shah, Nehal-bakulchandra" <[email protected]> writes:

> Hi
> On 8/24/2021 1:49 PM, Felipe Balbi wrote:
>> Nehal Bakulchandra Shah <[email protected]> writes:
>>
>>> For AMD platform there is a requirement to enable user space role
>>> switch from host to device and device to host by means of running
>>> following commands.
>>>
>>> HOST: echo host > /sys/class/usb_role/dwc3.0.auto-role-switch/role
>>> DEVICE: echo device > /sys/class/usb_role/dwc3.0.auto-role-switch/role
>> A more important question that needs to be answered: why?
>>
> Our customer platform is not completely capable of OTG i.e with type C
> controller it does not have PD to support role switching. Hence, they
> have script which triggers the role switch based on ACPI/EC interrupt.

sounds like some generalized version of this text should be added to
commit log.

--
balbi

2021-08-24 16:30:15

by Shah, Nehal-bakulchandra

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: dwc3: pci add property to allow user space role switch

On 8/24/2021 9:47 PM, Felipe Balbi wrote:
>
> "Shah, Nehal-bakulchandra" <[email protected]> writes:
>
>> Hi
>> On 8/24/2021 1:49 PM, Felipe Balbi wrote:
>>> Nehal Bakulchandra Shah <[email protected]> writes:
>>>
>>>> For AMD platform there is a requirement to enable user space role
>>>> switch from host to device and device to host by means of running
>>>> following commands.
>>>>
>>>> HOST: echo host > /sys/class/usb_role/dwc3.0.auto-role-switch/role
>>>> DEVICE: echo device > /sys/class/usb_role/dwc3.0.auto-role-switch/role
>>> A more important question that needs to be answered: why?
>>>
>> Our customer platform is not completely capable of OTG i.e with type C
>> controller it does not have PD to support role switching. Hence, they
>> have script which triggers the role switch based on ACPI/EC interrupt.
>
> sounds like some generalized version of this text should be added to
> commit log.
>
Sure i will resubmit this patch with this description should be ok?

Nehal

2021-08-24 16:57:17

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: dwc3: pci add property to allow user space role switch


Hi,

"Shah, Nehal-bakulchandra" <[email protected]> writes:
> On 8/24/2021 9:47 PM, Felipe Balbi wrote:
>> "Shah, Nehal-bakulchandra" <[email protected]> writes:
>>
>>> Hi
>>> On 8/24/2021 1:49 PM, Felipe Balbi wrote:
>>>> Nehal Bakulchandra Shah <[email protected]> writes:
>>>>
>>>>> For AMD platform there is a requirement to enable user space role
>>>>> switch from host to device and device to host by means of running
>>>>> following commands.
>>>>>
>>>>> HOST: echo host > /sys/class/usb_role/dwc3.0.auto-role-switch/role
>>>>> DEVICE: echo device > /sys/class/usb_role/dwc3.0.auto-role-switch/role
>>>> A more important question that needs to be answered: why?
>>>>
>>> Our customer platform is not completely capable of OTG i.e with type C
>>> controller it does not have PD to support role switching. Hence, they
>>> have script which triggers the role switch based on ACPI/EC interrupt.
>> sounds like some generalized version of this text should be added to
>> commit log.
>>
> Sure i will resubmit this patch with this description should be ok?

yup, sounds good. Thank you


--
balbi