dwc3 role-switch handling for HiKey960
Subsystems (3)
cover dwc3 role-switch handling for HiKey960
I'm just trying to pick up parts of a patch previously by Yu Chen to get HiKey960 dev-board's USB functionality working.
The current full patchset can be found here:
https://git.linaro.org/people/john.stultz/android-dev.git/log/?id=12289c95c89e0e3173f8da1ebd3a29e52fd50a44
I don't have any real knowledge of the hardware other then the code, and what I can intuit from testing, but I tried to document the previously undocumented bindings as best I could and fixed up a few minor checkpatch issues.
I'd greatly appreciate feedback or thoughts!
thanks
-john
John Stultz (1):
dt-bindings: usb: generic: Add role-switch-default-host binding
Yu Chen (2):
usb: roles: Add usb role switch notifier.
usb: dwc3: Registering a role switch in the DRD code.
.../devicetree/bindings/usb/generic.txt | 5 ++ drivers/usb/dwc3/Kconfig | 1 + drivers/usb/dwc3/core.h | 6 ++ drivers/usb/dwc3/drd.c | 78 ++++++++++++++++++- drivers/usb/roles/class.c | 35 ++++++++- include/linux/usb/role.h | 16 ++++ 6 files changed, 139 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
RFC PATCH 1/3 dt-bindings: usb: generic: Add role-switch-default-host binding
Add binding to configure the default role the controller assumes is host mode when the usb role is USB_ROLE_NONE.
--- Documentation/devicetree/bindings/usb/generic.txt | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/usb/generic.txt +5 -0
@@ -34,6 +34,11 @@ Optional properties: the USB data role (USB host or USB device) for a given USB connector, such as Type-C, Type-B(micro). see connector/usb-connector.txt. + - role-switch-default-host: boolean, indicating if usb-role-switch is enabled + the device default operation mode of controller while + usb role is USB_ROLE_NONE is host mode. If this is not + set or false, it will be assumed the default is device + mode. This is an attribute to a USB controller such as:
Signature · 1 line
2.17.1
RFC PATCH 2/3 usb: roles: Add usb role switch notifier.
In reply to John StultzFrom: Yu Chen <[email protected]>
This patch adds notifier for drivers want to be informed of the usb role switch.
--- drivers/usb/roles/class.c | 35 ++++++++++++++++++++++++++++++++++- include/linux/usb/role.h | 16 ++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-)
drivers/usb/roles/class.c +34 -1
@@ -20,6 +20,7 @@ struct usb_role_switch {struct device dev;struct mutex lock;/* device lock*/ enum usb_role role; +struct blocking_notifier_head nh;/* From descriptor */ struct device *usb2_port;
@@ -49,8 +50,10 @@ int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role)mutex_lock (&sw->lock); ret = sw->set (sw->dev.parent, role); -if (!ret) +if (!ret) { sw->role = role; +blocking_notifier_call_chain (&sw->nh, role,NULL ); + }mutex_unlock (&sw->lock);
@@ -58,6 +61,35 @@ int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role) }EXPORT_SYMBOL_GPL (usb_role_switch_set_role); +int usb_role_switch_register_notifier (struct usb_role_switch *sw, +struct notifier_block *nb) +{ +int ret =blocking_notifier_chain_register (&sw->nh, nb); +enum usb_role role; + +if (ret) +return ret; + +/* Initialize the notifier that was just registered */ +mutex_lock (&sw->lock); +if (sw->get) + role = sw->get (sw->dev.parent); +else + role = sw->role; +blocking_notifier_call_chain (&sw->nh, role,NULL ); +mutex_unlock (&sw->lock); + +return 0 ; +} +EXPORT_SYMBOL_GPL (usb_role_switch_register_notifier); + +int usb_role_switch_unregister_notifier (struct usb_role_switch *sw, +struct notifier_block *nb) +{ +return blocking_notifier_chain_unregister (&sw->nh, nb); +} +EXPORT_SYMBOL_GPL (usb_role_switch_unregister_notifier); +/** * usb_role_switch_get_role - Get the USB role for a switch * @sw: USB role switch
@@ -296,6 +328,7 @@ usb_role_switch_register(struct device *parent,return ERR_PTR (-ENOMEM );mutex_init (&sw->lock); +BLOCKING_INIT_NOTIFIER_HEAD (&sw->nh); sw->allow_userspace_control = desc->allow_userspace_control; sw->usb2_port = desc->usb2_port;
include/linux/usb/role.h +16 -0
@@ -54,6 +54,10 @@ struct usb_role_switch * usb_role_switch_register(struct device *parent, const struct usb_role_switch_desc *desc);void usb_role_switch_unregister (struct usb_role_switch *sw); +int usb_role_switch_register_notifier (struct usb_role_switch *sw, +struct notifier_block *nb); +int usb_role_switch_unregister_notifier (struct usb_role_switch *sw, +struct notifier_block *nb);#else static inline int usb_role_switch_set_role (struct usb_role_switch *sw,enum usb_role role)
@@ -87,6 +91,18 @@ usb_role_switch_register(struct device *parent, }static inline void usb_role_switch_unregister (struct usb_role_switch *sw) { } + +static int usb_role_switch_register_notifier (struct usb_role_switch *sw, +struct notifier_block *nb) +{ +return -ENODEV ; +} + +static int usb_role_switch_unregister_notifier (struct usb_role_switch *sw, +struct notifier_block *nb) +{ +return -ENODEV ; +}#endif #endif /* __LINUX_USB_ROLE_H */
Signature · 1 line
2.17.1
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Hi John,
Quoted 4 lines · John Stultz
From: Yu Chen <[email protected]>
This patch adds notifier for drivers want to be informed of the usb role switch.
I do not see any patches in this series actually using this new notifier.
Maybe it is best to drop this patch until we actually have in-kernel users of this new API show up ?
Regards,
Hans
Quoted 126 lines
Cc Greg Kroah-Hartman <[email protected]>Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Heikki Krogerus <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Chunfeng Yun <[email protected]>Cc Yu Chen <[email protected]>Cc Felipe Balbi <[email protected]>Cc Hans de Goede <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Jun Li <[email protected]>Cc Valentin Schneider <[email protected]>Suggested-by Heikki Krogerus <[email protected]>Signed-off-by Yu Chen <[email protected]>Signed-off-by John Stultz <[email protected]>--- drivers/usb/roles/class.c | 35 ++++++++++++++++++++++++++++++++++- include/linux/usb/role.h | 16 ++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-)drivers/usb/roles/class.c +34
-1@@ -20,6 +20,7 @@ struct usb_role_switch {struct device dev;struct mutex lock;/* device lock*/ enum usb_role role; +struct blocking_notifier_head nh;/* From descriptor */ struct device *usb2_port;@@ -49,8 +50,10 @@ int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role)mutex_lock (&sw->lock); ret = sw->set (sw->dev.parent, role); -if (!ret) +if (!ret) { sw->role = role; +blocking_notifier_call_chain (&sw->nh, role,NULL ); + }mutex_unlock (&sw->lock);@@ -58,6 +61,35 @@ int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role) }EXPORT_SYMBOL_GPL (usb_role_switch_set_role); +int usb_role_switch_register_notifier (struct usb_role_switch *sw, +struct notifier_block *nb) +{ +int ret =blocking_notifier_chain_register (&sw->nh, nb); +enum usb_role role; + +if (ret) +return ret; + +/* Initialize the notifier that was just registered */ +mutex_lock (&sw->lock); +if (sw->get) + role = sw->get (sw->dev.parent); +else + role = sw->role; +blocking_notifier_call_chain (&sw->nh, role,NULL ); +mutex_unlock (&sw->lock); + +return 0 ; +} +EXPORT_SYMBOL_GPL (usb_role_switch_register_notifier); + +int usb_role_switch_unregister_notifier (struct usb_role_switch *sw, +struct notifier_block *nb) +{ +return blocking_notifier_chain_unregister (&sw->nh, nb); +} +EXPORT_SYMBOL_GPL (usb_role_switch_unregister_notifier); +/** * usb_role_switch_get_role - Get the USB role for a switch * @sw: USB role switch @@ -296,6 +328,7 @@ usb_role_switch_register(struct device *parent,return ERR_PTR (-ENOMEM );mutex_init (&sw->lock); +BLOCKING_INIT_NOTIFIER_HEAD (&sw->nh); sw->allow_userspace_control = desc->allow_userspace_control; sw->usb2_port = desc->usb2_port;include/linux/usb/role.h +16
-0@@ -54,6 +54,10 @@ struct usb_role_switch * usb_role_switch_register(struct device *parent, const struct usb_role_switch_desc *desc);void usb_role_switch_unregister (struct usb_role_switch *sw); +int usb_role_switch_register_notifier (struct usb_role_switch *sw, +struct notifier_block *nb); +int usb_role_switch_unregister_notifier (struct usb_role_switch *sw, +struct notifier_block *nb);#else static inline int usb_role_switch_set_role (struct usb_role_switch *sw,enum usb_role role)@@ -87,6 +91,18 @@ usb_role_switch_register(struct device *parent, }static inline void usb_role_switch_unregister (struct usb_role_switch *sw) { } + +static int usb_role_switch_register_notifier (struct usb_role_switch *sw, +struct notifier_block *nb) +{ +return -ENODEV ; +} + +static int usb_role_switch_unregister_notifier (struct usb_role_switch *sw, +struct notifier_block *nb) +{ +return -ENODEV ; +}#endif #endif /* __LINUX_USB_ROLE_H */
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Quoted 11 lines · Hans de Goede
Quoted 4 lines · John Stultz
From: Yu Chen <[email protected]>
This patch adds notifier for drivers want to be informed of the usb role switch.
I do not see any patches in this series actually using this new notifier.
Maybe it is best to drop this patch until we actually have in-kernel users of this new API show up ?
Fair point. I'm sort of taking a larger patchset and trying to break it up into more easily reviewable chunks, but I guess here I mis-cut.
The user is the hikey960 gpio hub driver here:
https://git.linaro.org/people/john.stultz/android-dev.git/commit/?id=b06158a2d3eb00c914f12c76c93695e92d9af00f
I'll resubmit again later with that patch included.
thanks
-john
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Hi,
Quoted 10 lines · John Stultz
Quoted 9 lines · Hans de Goede
Quoted 4 lines · John Stultz
From: Yu Chen <[email protected]>
This patch adds notifier for drivers want to be informed of the usb role switch.
I do not see any patches in this series actually using this new notifier.
Quoted 8 lines
Quoted 2 lines
Maybe it is best to drop this patch until we actually have in-kernel users of this new API show up ?
Fair point. I'm sort of taking a larger patchset and trying to break it up into more easily reviewable chunks, but I guess here I mis-cut.
The user is the hikey960 gpio hub driver here:
https://git.linaro.org/people/john.stultz/android-dev.git/commit/?id=b06158a2d3eb00c914f12c76c93695e92d9af00f
Hmm, that seems to tie the TypeC data-role to the power-role, which is not going to work with role swapping.
What is controlling the usb-role-switch, and thus ultimately causing the notifier you are suggesting to get called ?
Things like TYPEC_VBUS_POWER_OFF and TYPEC_VBUS_POWER_ON really beg to be modeled as a regulator and then the Type-C controller (using e.g. the drivers/usb/typec/tcpm/tcpm.c framework) can use that regulator to control things. in case of the tcpm.c framework it can then use that regulator to implement the set_vbus callback.
You really do not want to tie this do the usb_switch, both because doing so ties the data and power-roles together which is not supposed to happen and because role-swapping requires careful timing of the VBUS on / off at different moments then the moments when you actually set the mux/switch for connecting the Dp/Dn lines to the host or gadget controller.
The usb role switch abstraction is really only intended for the data-lines switch and should not be tied together with other stuff.
Regards,
Hans
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Quoted 43 lines · Hans de Goede
Hi,
Quoted 10 lines · John Stultz
Quoted 9 lines · Hans de Goede
Quoted 4 lines · John Stultz
From: Yu Chen <[email protected]>
This patch adds notifier for drivers want to be informed of the usb role switch.
I do not see any patches in this series actually using this new notifier.
Quoted 8 lines
Quoted 2 lines
Maybe it is best to drop this patch until we actually have in-kernel users of this new API show up ?
Fair point. I'm sort of taking a larger patchset and trying to break it up into more easily reviewable chunks, but I guess here I mis-cut.
The user is the hikey960 gpio hub driver here:
https://git.linaro.org/people/john.stultz/android-dev.git/commit/?id=b06158a2d3eb00c914f12c76c93695e92d9af00fHmm, that seems to tie the TypeC data-role to the power-role, which is not going to work with role swapping.
What is controlling the usb-role-switch, and thus ultimately causing the notifier you are suggesting to get called ?
Things like
TYPEC_VBUS_POWER_OFFandTYPEC_VBUS_POWER_ONreally beg to be modeled as a regulator and then the Type-C controller (using e.g. thedrivers/usb/typec/tcpm/tcpm.cframework) can use that regulator to control things. in case of thetcpm.cframework it can then use that regulator to implement theset_vbuscallback.You really do not want to tie this do the
usb_switch, both because doing so ties the data and power-roles together which is not supposed to happen and because role-swapping requires careful timing of the VBUS on / off at different moments then the moments when you actually set the mux/switch for connecting the Dp/Dn lines to the host or gadget controller.
Quoted 3 lines
The usb role switch abstraction is really only intended for the data-lines switch and should not be tied together with other stuff.
Hear, hear.
Signature · 1 line
heikki
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
In reply to Hans de GoedeQuoted 9 lines · Hans de Goede
Quoted 5 lines · John Stultz
Fair point. I'm sort of taking a larger patchset and trying to break it up into more easily reviewable chunks, but I guess here I mis-cut.
The user is the hikey960 gpio hub driver here:
https://git.linaro.org/people/john.stultz/android-dev.git/commit/?id=b06158a2d3eb00c914f12c76c93695e92d9af00fHmm, that seems to tie the TypeC data-role to the power-role, which is not going to work with role swapping.
Thanks again for the feedback here. Sorry for the slow response. Been reworking some of the easier changes but am starting to look at how to address your feedback here.
Quoted 2 lines
What is controlling the usb-role-switch, and thus ultimately causing the notifier you are suggesting to get called ?
The tcpm_mux_set() call via tcpm_state_machine_work()
Quoted 6 lines
Things like
TYPEC_VBUS_POWER_OFFandTYPEC_VBUS_POWER_ONreally beg to be modeled as a regulator and then the Type-C controller (using e.g. thedrivers/usb/typec/tcpm/tcpm.cframework) can use that regulator to control things. in case of thetcpm.cframework it can then use that regulator to implement theset_vbuscallback.
So I'm looking at the bindings and I'm not sure exactly how to tie a regulator style driver into the tcpm for this?
Looking at the driver I just see this commented out bit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/typec/tcpm/tcpm.c#n3075
Do you happen to have a pointer to something closer to what you are describing?
thanks
-john
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Hi,
Quoted 27 lines · John Stultz
Quoted 9 lines · Hans de Goede
Quoted 5 lines · John Stultz
Fair point. I'm sort of taking a larger patchset and trying to break it up into more easily reviewable chunks, but I guess here I mis-cut.
The user is the hikey960 gpio hub driver here:
https://git.linaro.org/people/john.stultz/android-dev.git/commit/?id=b06158a2d3eb00c914f12c76c93695e92d9af00fHmm, that seems to tie the TypeC data-role to the power-role, which is not going to work with role swapping.
Thanks again for the feedback here. Sorry for the slow response. Been reworking some of the easier changes but am starting to look at how to address your feedback here.
Quoted 2 lines
What is controlling the usb-role-switch, and thus ultimately causing the notifier you are suggesting to get called ?
The
tcpm_mux_set()call viatcpm_state_machine_work()Quoted 6 lines
Things like
TYPEC_VBUS_POWER_OFFandTYPEC_VBUS_POWER_ONreally beg to be modeled as a regulator and then the Type-C controller (using e.g. thedrivers/usb/typec/tcpm/tcpm.cframework) can use that regulator to control things. in case of thetcpm.cframework it can then use that regulator to implement theset_vbuscallback.
Quoted 6 lines
So I'm looking at the bindings and I'm not sure exactly how to tie a regulator style driver into the tcpm for this?
Looking at the driver I just see this commented out bit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/typec/tcpm/tcpm.c#n3075Do you happen to have a pointer to something closer to what you are describing?
Look at the tcpm_set_vbus implementation in drivers/usb/typec/tcpm/fusb302.c you need to do something similar in your Type-C controller driver and export the GPIO as as a gpio-controlled regulator and tie the regulator to the connector.
Regards,
Hans
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Quoted 33 lines · Hans de Goede
Quoted 32 lines · John Stultz
Quoted 9 lines · Hans de Goede
Quoted 5 lines · John Stultz
Fair point. I'm sort of taking a larger patchset and trying to break it up into more easily reviewable chunks, but I guess here I mis-cut.
The user is the hikey960 gpio hub driver here:
https://git.linaro.org/people/john.stultz/android-dev.git/commit/?id=b06158a2d3eb00c914f12c76c93695e92d9af00fHmm, that seems to tie the TypeC data-role to the power-role, which is not going to work with role swapping.
Thanks again for the feedback here. Sorry for the slow response. Been reworking some of the easier changes but am starting to look at how to address your feedback here.
Quoted 2 lines
What is controlling the usb-role-switch, and thus ultimately causing the notifier you are suggesting to get called ?
The
tcpm_mux_set()call viatcpm_state_machine_work()Quoted 6 lines
Things like
TYPEC_VBUS_POWER_OFFandTYPEC_VBUS_POWER_ONreally beg to be modeled as a regulator and then the Type-C controller (using e.g. thedrivers/usb/typec/tcpm/tcpm.cframework) can use that regulator to control things. in case of thetcpm.cframework it can then use that regulator to implement theset_vbuscallback.So I'm looking at the bindings and I'm not sure exactly how to tie a regulator style driver into the tcpm for this?
Looking at the driver I just see this commented out bit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/typec/tcpm/tcpm.c#n3075
Quoted 6 lines
Quoted 1 line
Do you happen to have a pointer to something closer to what you are describing?
Look at the
tcpm_set_vbusimplementation indrivers/usb/typec/tcpm/fusb302.cyou need to do something similar in your Type-C controller driver and export the GPIO as as a gpio-controlled regulator and tie the regulator to the connector.
Thanks for the suggestion, I really appreciate it! One more question though, since I'm using the tcpci_rt1711h driver, which re-uses the somewhat sparse tcpci.c implementation, would you recommend trying to add generic regulator support to the tcpci code or trying to extend the implementation somehow allow the tcpci_rt1711h driver replace just the set_vbus function?
thanks
-john
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Hi,
Quoted 41 lines · John Stultz
Quoted 33 lines · Hans de Goede
Quoted 32 lines · John Stultz
Quoted 9 lines · Hans de Goede
Quoted 5 lines · John Stultz
Fair point. I'm sort of taking a larger patchset and trying to break it up into more easily reviewable chunks, but I guess here I mis-cut.
The user is the hikey960 gpio hub driver here:
https://git.linaro.org/people/john.stultz/android-dev.git/commit/?id=b06158a2d3eb00c914f12c76c93695e92d9af00fHmm, that seems to tie the TypeC data-role to the power-role, which is not going to work with role swapping.
Thanks again for the feedback here. Sorry for the slow response. Been reworking some of the easier changes but am starting to look at how to address your feedback here.
Quoted 2 lines
What is controlling the usb-role-switch, and thus ultimately causing the notifier you are suggesting to get called ?
The
tcpm_mux_set()call viatcpm_state_machine_work()Quoted 6 lines
Things like
TYPEC_VBUS_POWER_OFFandTYPEC_VBUS_POWER_ONreally beg to be modeled as a regulator and then the Type-C controller (using e.g. thedrivers/usb/typec/tcpm/tcpm.cframework) can use that regulator to control things. in case of thetcpm.cframework it can then use that regulator to implement theset_vbuscallback.So I'm looking at the bindings and I'm not sure exactly how to tie a regulator style driver into the tcpm for this?
Looking at the driver I just see this commented out bit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/typec/tcpm/tcpm.c#n3075Quoted 6 lines
Quoted 1 line
Do you happen to have a pointer to something closer to what you are describing?
Look at the
tcpm_set_vbusimplementation indrivers/usb/typec/tcpm/fusb302.cyou need to do something similar in your Type-C controller driver and export the GPIO as as a gpio-controlled regulator and tie the regulator to the connector.
Quoted 6 lines
Thanks for the suggestion, I really appreciate it! One more question though, since I'm using the
tcpci_rt1711hdriver, which re-uses the somewhat sparsetcpci.cimplementation, would you recommend trying to add generic regulator support to the tcpci code or trying to extend the implementation somehow allow thetcpci_rt1711hdriver replace just theset_vbusfunction?
I have the feeling that this is more of a question for Heikki.
My first instinct is: if you are using tcpci can't you put all the hacks you need for the usb connection shared between hub and type-c in your firmware ?
Regards,
Hans
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Quoted 14 lines · Hans de Goede
Quoted 6 lines · John Stultz
Quoted 4 lines · Hans de Goede
Look at the
tcpm_set_vbusimplementation indrivers/usb/typec/tcpm/fusb302.cyou need to do something similar in your Type-C controller driver and export the GPIO as as a gpio-controlled regulator and tie the regulator to the connector.Quoted 6 lines
Thanks for the suggestion, I really appreciate it! One more question though, since I'm using the
tcpci_rt1711hdriver, which re-uses the somewhat sparsetcpci.cimplementation, would you recommend trying to add generic regulator support to the tcpci code or trying to extend the implementation somehow allow thetcpci_rt1711hdriver replace just theset_vbusfunction?
Quoted 5 lines
I have the feeling that this is more of a question for Heikki.
My first instinct is: if you are using tcpci can't you put all the hacks you need for the usb connection shared between hub and type-c in your firmware ?
I appreciate the suggestion, but I'm not aware of any USB firmware for the board, nor do I think I have any such source. :(
thanks
-john
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Hi,
Quoted 15 lines · John Stultz
Quoted 14 lines · Hans de Goede
Quoted 12 lines · John Stultz
Quoted 4 lines · Hans de Goede
Look at the
tcpm_set_vbusimplementation indrivers/usb/typec/tcpm/fusb302.cyou need to do something similar in your Type-C controller driver and export the GPIO as as a gpio-controlled regulator and tie the regulator to the connector.Thanks for the suggestion, I really appreciate it! One more question though, since I'm using the
tcpci_rt1711hdriver, which re-uses the somewhat sparsetcpci.cimplementation, would you recommend trying to add generic regulator support to the tcpci code or trying to extend the implementation somehow allow thetcpci_rt1711hdriver replace just theset_vbusfunction?
Quoted 8 lines
Quoted 5 lines
I have the feeling that this is more of a question for Heikki.
My first instinct is: if you are using tcpci can't you put all the hacks you need for the usb connection shared between hub and type-c in your firmware ?
I appreciate the suggestion, but I'm not aware of any USB firmware for the board, nor do I think I have any such source. :(
My bad, I was under the impression that tcpci was a firmware interface, but it is not (I was confusing it with ucsi).
Looking at drivers/usb/typec/tcpm/tcpci.c: tcpci_set_vconn I see that there is a data struct with vendor specific callbacks and that the drivers/usb/typec/tcpm/tcpci_rt1711h.c implements that.
So you may want something similar here. But things are tricky here, because when nothing is connected you want to provide Vbus for the USB-A ports, which means that if someone then connects a USB-A to C cable to connect the board to a PC (switching the port to device mode) there will be a time when both sides are supplying 5V if I remember the schedule correctly.
I think that the original hack might not be that bad, the whole hw design seems so, erm, broken, that you probably cannot do proper roleswapping anyways. So just tying Vbus to host mode might be fine, the question then becomes again how can some other piece of code listen to the role-switch events...
Regards,
Hans
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Quoted 10 lines · Hans de Goede
Looking at
drivers/usb/typec/tcpm/tcpci.c:tcpci_set_vconnI see that there is a data struct with vendor specific callbacks and that thedrivers/usb/typec/tcpm/tcpci_rt1711h.cimplements that.So you may want something similar here. But things are tricky here, because when nothing is connected you want to provide Vbus for the USB-A ports, which means that if someone then connects a USB-A to C cable to connect the board to a PC (switching the port to device mode) there will be a time when both sides are supplying 5V if I remember the schedule correctly.
Ok. Thanks for the pointer, I'll take a look at that to see if I can get it to work.
Quoted 5 lines
I think that the original hack might not be that bad, the whole hw design seems so, erm, broken, that you probably cannot do proper roleswapping anyways. So just tying Vbus to host mode might be fine, the question then becomes again how can some other piece of code listen to the role-switch events...
So, at least in the current approach (see the v3 series), I've basically set the hub driver as an role-switch intermediary, sitting between the calls from the tcpm to the dwc3 driver. It actually works better then the earlier notifier method (which had some issues with reliably establishing the initial state on boot). Does that approach work for you?
thanks
-john
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Hi,
Quoted 21 lines · John Stultz
Quoted 10 lines · Hans de Goede
Looking at
drivers/usb/typec/tcpm/tcpci.c:tcpci_set_vconnI see that there is a data struct with vendor specific callbacks and that thedrivers/usb/typec/tcpm/tcpci_rt1711h.cimplements that.So you may want something similar here. But things are tricky here, because when nothing is connected you want to provide Vbus for the USB-A ports, which means that if someone then connects a USB-A to C cable to connect the board to a PC (switching the port to device mode) there will be a time when both sides are supplying 5V if I remember the schedule correctly.
Ok. Thanks for the pointer, I'll take a look at that to see if I can get it to work.
Quoted 5 lines
I think that the original hack might not be that bad, the whole hw design seems so, erm, broken, that you probably cannot do proper roleswapping anyways. So just tying Vbus to host mode might be fine, the question then becomes again how can some other piece of code listen to the role-switch events...
Quoted 6 lines
So, at least in the current approach (see the v3 series), I've basically set the hub driver as an role-switch intermediary, sitting between the calls from the tcpm to the dwc3 driver. It actually works better then the earlier notifier method (which had some issues with reliably establishing the initial state on boot). Does that approach work for you?
That sounds like it might be a nice solution. But I have not seen the code, I think I was not Cc-ed on v3. Do you have a patchwork or lore.kernel.org link for me?
Regards,
Hans
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Quoted 29 lines · Hans de Goede
Quoted 21 lines · John Stultz
Quoted 10 lines · Hans de Goede
Looking at
drivers/usb/typec/tcpm/tcpci.c:tcpci_set_vconnI see that there is a data struct with vendor specific callbacks and that thedrivers/usb/typec/tcpm/tcpci_rt1711h.cimplements that.So you may want something similar here. But things are tricky here, because when nothing is connected you want to provide Vbus for the USB-A ports, which means that if someone then connects a USB-A to C cable to connect the board to a PC (switching the port to device mode) there will be a time when both sides are supplying 5V if I remember the schedule correctly.
Ok. Thanks for the pointer, I'll take a look at that to see if I can get it to work.
Quoted 5 lines
I think that the original hack might not be that bad, the whole hw design seems so, erm, broken, that you probably cannot do proper roleswapping anyways. So just tying Vbus to host mode might be fine, the question then becomes again how can some other piece of code listen to the role-switch events...
Quoted 6 lines
So, at least in the current approach (see the v3 series), I've basically set the hub driver as an role-switch intermediary, sitting between the calls from the tcpm to the dwc3 driver. It actually works better then the earlier notifier method (which had some issues with reliably establishing the initial state on boot). Does that approach work for you?
Quoted 3 lines
That sounds like it might be a nice solution. But I have not seen the code, I think I was not Cc-ed on v3. Do you have a patchwork or lore.kernel.org link for me?
Oh! I think I had you on CC, maybe it got caught in your spam folder? My apologies either way! The thread is here:
https://lore.kernel.org/lkml/[email protected]/
And the hub/role-switch-intermediary driver is here:
https://lore.kernel.org/lkml/[email protected]/
thanks
-john
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Hi,
Quoted 30 lines · John Stultz
Quoted 29 lines · Hans de Goede
Quoted 27 lines · John Stultz
Quoted 10 lines · Hans de Goede
Looking at
drivers/usb/typec/tcpm/tcpci.c:tcpci_set_vconnI see that there is a data struct with vendor specific callbacks and that thedrivers/usb/typec/tcpm/tcpci_rt1711h.cimplements that.So you may want something similar here. But things are tricky here, because when nothing is connected you want to provide Vbus for the USB-A ports, which means that if someone then connects a USB-A to C cable to connect the board to a PC (switching the port to device mode) there will be a time when both sides are supplying 5V if I remember the schedule correctly.
Ok. Thanks for the pointer, I'll take a look at that to see if I can get it to work.
Quoted 5 lines
I think that the original hack might not be that bad, the whole hw design seems so, erm, broken, that you probably cannot do proper roleswapping anyways. So just tying Vbus to host mode might be fine, the question then becomes again how can some other piece of code listen to the role-switch events...
So, at least in the current approach (see the v3 series), I've basically set the hub driver as an role-switch intermediary, sitting between the calls from the tcpm to the dwc3 driver. It actually works better then the earlier notifier method (which had some issues with reliably establishing the initial state on boot). Does that approach work for you?
Quoted 5 lines
Quoted 3 lines
That sounds like it might be a nice solution. But I have not seen the code, I think I was not Cc-ed on v3. Do you have a patchwork or lore.kernel.org link for me?
Oh! I think I had you on CC, maybe it got caught in your spam folder?
More likely I just deleted mail to aggressively, sorry.
Quoted 5 lines
My apologies either way! The thread is here:
https://lore.kernel.org/lkml/[email protected]/And the hub/role-switch-intermediary driver is here:
https://lore.kernel.org/lkml/[email protected]/
Hm, this looks very nice actually, much much better then the notifier stuff!
As for your:
"NOTE: It was noted that controlling the TYPEC_VBUS_POWER_OFF and TYPEC_VBUS_POWER_ON values here is not reccomended. I'm looking for a way to remove that bit from the logic here, but wanted to still get feedback on this approach."
Comment in the commit message, normally a type-c port would turn external Vbus off until a sink is connected, IIRC the same Vbus is also used for the TupeA ports on the hub, so that would mean those are unusable when nothing is connected to the TypeC port, which is not what you want.
So I think that given the special case / hack-ish hw you have, that just setting Vbus based on the role is ok(ish).
Regards,
Hans
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Quoted 54 lines · Hans de Goede
Quoted 30 lines · John Stultz
Quoted 29 lines · Hans de Goede
Quoted 27 lines · John Stultz
Quoted 10 lines · Hans de Goede
Looking at
drivers/usb/typec/tcpm/tcpci.c:tcpci_set_vconnI see that there is a data struct with vendor specific callbacks and that thedrivers/usb/typec/tcpm/tcpci_rt1711h.cimplements that.So you may want something similar here. But things are tricky here, because when nothing is connected you want to provide Vbus for the USB-A ports, which means that if someone then connects a USB-A to C cable to connect the board to a PC (switching the port to device mode) there will be a time when both sides are supplying 5V if I remember the schedule correctly.
Ok. Thanks for the pointer, I'll take a look at that to see if I can get it to work.
Quoted 5 lines
I think that the original hack might not be that bad, the whole hw design seems so, erm, broken, that you probably cannot do proper roleswapping anyways. So just tying Vbus to host mode might be fine, the question then becomes again how can some other piece of code listen to the role-switch events...
So, at least in the current approach (see the v3 series), I've basically set the hub driver as an role-switch intermediary, sitting between the calls from the tcpm to the dwc3 driver. It actually works better then the earlier notifier method (which had some issues with reliably establishing the initial state on boot). Does that approach work for you?
Quoted 5 lines
Quoted 3 lines
That sounds like it might be a nice solution. But I have not seen the code, I think I was not Cc-ed on v3. Do you have a patchwork or lore.kernel.org link for me?
Oh! I think I had you on CC, maybe it got caught in your spam folder?
More likely I just deleted mail to aggressively, sorry.
Quoted 5 lines
My apologies either way! The thread is here:
https://lore.kernel.org/lkml/[email protected]/And the hub/role-switch-intermediary driver is here:
https://lore.kernel.org/lkml/[email protected]/Hm, this looks very nice actually, much much better then the notifier stuff!
As for your:
"NOTE: It was noted that controlling the
TYPEC_VBUS_POWER_OFFandTYPEC_VBUS_POWER_ONvalues here is not reccomended. I'm looking for a way to remove that bit from the logic here, but wanted to still get feedback on this approach."
Quoted 4 lines
Comment in the commit message, normally a type-c port would turn external Vbus off until a sink is connected, IIRC the same Vbus is also used for the TupeA ports on the hub, so that would mean those are unusable when nothing is connected to the TypeC port, which is not what you want.
Uh, so I think for the HiKey960, the type-A ports on the hub are separately powered via the hub_power_ctrl(hisi_hikey_usb, HUB_VBUS_POWER_OFF/ON) call.
At least, with the current driver, the functionality is working as
expected: remove the USB-C cable, and devices connected to the hub power on, plug something into the USB-C port and devices plugged into the hub shutdown.
But maybe I'm missing what you mean?
Quoted 2 lines
So I think that given the special case / hack-ish hw you have, that just setting Vbus based on the role is ok(ish).
Ok. I'm happy to stick with what works here, since it is at least the oddness is isolated to the device specific hub driver.
thanks
-john
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Hi,
Quoted 64 lines · John Stultz
Quoted 54 lines · Hans de Goede
Quoted 30 lines · John Stultz
Quoted 29 lines · Hans de Goede
Quoted 27 lines · John Stultz
Quoted 10 lines · Hans de Goede
Looking at
drivers/usb/typec/tcpm/tcpci.c:tcpci_set_vconnI see that there is a data struct with vendor specific callbacks and that thedrivers/usb/typec/tcpm/tcpci_rt1711h.cimplements that.So you may want something similar here. But things are tricky here, because when nothing is connected you want to provide Vbus for the USB-A ports, which means that if someone then connects a USB-A to C cable to connect the board to a PC (switching the port to device mode) there will be a time when both sides are supplying 5V if I remember the schedule correctly.
Ok. Thanks for the pointer, I'll take a look at that to see if I can get it to work.
Quoted 5 lines
I think that the original hack might not be that bad, the whole hw design seems so, erm, broken, that you probably cannot do proper roleswapping anyways. So just tying Vbus to host mode might be fine, the question then becomes again how can some other piece of code listen to the role-switch events...
So, at least in the current approach (see the v3 series), I've basically set the hub driver as an role-switch intermediary, sitting between the calls from the tcpm to the dwc3 driver. It actually works better then the earlier notifier method (which had some issues with reliably establishing the initial state on boot). Does that approach work for you?
Quoted 5 lines
Quoted 3 lines
That sounds like it might be a nice solution. But I have not seen the code, I think I was not Cc-ed on v3. Do you have a patchwork or lore.kernel.org link for me?
Oh! I think I had you on CC, maybe it got caught in your spam folder?
More likely I just deleted mail to aggressively, sorry.
Quoted 5 lines
My apologies either way! The thread is here:
https://lore.kernel.org/lkml/[email protected]/And the hub/role-switch-intermediary driver is here:
https://lore.kernel.org/lkml/[email protected]/Hm, this looks very nice actually, much much better then the notifier stuff!
As for your:
"NOTE: It was noted that controlling the
TYPEC_VBUS_POWER_OFFandTYPEC_VBUS_POWER_ONvalues here is not reccomended. I'm looking for a way to remove that bit from the logic here, but wanted to still get feedback on this approach."Quoted 4 lines
Comment in the commit message, normally a type-c port would turn external Vbus off until a sink is connected, IIRC the same Vbus is also used for the TupeA ports on the hub, so that would mean those are unusable when nothing is connected to the TypeC port, which is not what you want.
Uh, so I think for the HiKey960, the type-A ports on the hub are separately powered via the
hub_power_ctrl(hisi_hikey_usb, HUB_VBUS_POWER_OFF/ON)call.
Quoted 6 lines
At least, with the current driver, the functionality is working as
expected: remove the USB-C cable, and devices connected to the hub power on, plug something into the USB-C port and devices plugged into the hub shutdown.But maybe I'm missing what you mean?
Ok, so double checking the schematic I do see separate Vbus-es for the TypeC port and the TypeA ports, with the TypeC port one being controlled by GPIO_202_VBUS_TYPEC. So ideally that gpio would be controlled to enable/disable vbus by the tcpm framework.
Quoted 5 lines
Quoted 2 lines
So I think that given the special case / hack-ish hw you have, that just setting Vbus based on the role is ok(ish).
Ok. I'm happy to stick with what works here, since it is at least the oddness is isolated to the device specific hub driver.
Right, so for the Type-A ports Vbus controlled by PRT_CTL1 enabling it depending on host vs devices mode makes sense. But the Type-C one really should be controlled by the tcpm framework.
Regards,
Hans
p.s.
Sorry for the confusion I was under the impression that there was only 1 Vbus enable for both Type-A and Type-C ports.
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Quoted 6 lines · Hans de Goede
Quoted 5 lines · John Stultz
At least, with the current driver, the functionality is working as
expected: remove the USB-C cable, and devices connected to the hub power on, plug something into the USB-C port and devices plugged into the hub shutdown.
Quoted 6 lines
Quoted 1 line
But maybe I'm missing what you mean?
Ok, so double checking the schematic I do see separate Vbus-es for the TypeC port and the TypeA ports, with the TypeC port one being controlled by
GPIO_202_VBUS_TYPEC. So ideally that gpio would be controlled to enable/disable vbus by the tcpm framework.
So I've given this a shot, adding a gpio regulator for the type-c vbus, and added a set_vbus hook to the tcpci_rt1711 with logic to enable and disable the regulator depending on the source state. I've also added some debug logic to check the regulator disabling/enabling is working properly. However, doing the type-c vbus control via the tcpm logic doesn't seem to be working properly.
The issue seems to be when the USB-C cable is unplugged the device goes into ROLE_NONE, we switch to the on-board hub. Then when we connect a USB-C hub to the type-c port, we switch to ROLE_HOST, and power on the regulator, and that starts to power on the USB-C hub devices. However, since this disconnects/powers down the on-board hub, we see the on-board hub device disconnect. I'm guessing the hub disconnection causes some confusion in the state machine, as then I see the state change from state change SRC_ATTACHED -> SRC_UNATTACHED, and set_vbus is immediately called with source=0 and the regulator is disabled, and we switch back to ROLE_NONE (which powers on the onboard hub). The system then seems to quickly oscillate between the ROLE_HOST and ROLE_NONE switching the regulator on and off fairly quickly (see log below for more details) and never really settling for one state or the other.
Any off-hand thoughts on what might be going wrong here? I'm fine to continue digging and working on this approach, but I also don't want to have to pollute the core code too much for this oddball hardware (esp since doing the vbus control in the role-switch intermediary does work ok - or at least better then this approach so far).
thanks
-john
Starts in ROLE_NONE with nothing connected to type-c port, with the on-board hub powered on, then we connect a type-c usb hub.
[ 57.828323] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 58.031325] JDB: state change SRC_ATTACH_WAIT -> SNK_TRY [delayed 200 ms] [ 58.031525] JDB: tcpm_state_machine_work state chage: SNK_TRY->SNK_TRY [ 58.135273] JDB: state change SNK_TRY -> SNK_TRY_WAIT [delayed 100 ms] [ 58.135296] JDB: tcpm_state_machine_work state chage: SNK_TRY_WAIT->SRC_TRYWAIT [ 58.149344] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT->SRC_TRYWAIT [ 58.251273] JDB: state change SRC_TRYWAIT -> SRC_TRYWAIT_UNATTACHED [delayed 100 ms] [ 58.251297] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT_UNATTACHED->SNK_UNATTACHED [ 58.269076] JDB: tcpm_state_machine_work state chage: SNK_UNATTACHED->TOGGLING [ 58.276789] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 58.323506] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 58.527310] JDB: state change SRC_ATTACH_WAIT -> SRC_ATTACHED [delayed 200 ms] [ 58.527788] JDB: hub_usb_role_switch_set switching to ROLE_HOST! [ 58.541555] usb usb1-port1: disabled by hub (EMI?), re-enabling... [ 58.548654] usb 1-1: USB disconnect, device number 2 [ 58.554077] usb 1-1.5: USB disconnect, device number 3 [ 58.560133] JDB: rt1711h_set_vbus source: 1 sink: 0 [ 58.565377] JDB: rt1711h_set_vbus enabling regulator! [ 58.570495] type-c-vbus-current-regulator: being enabled! JDB! [ 58.586202] type-c-vbus-current-regulator: enabled successfully?! JDB! [ 58.602350] rt1711h_set_vbus: vbus := On [ 58.602354] rt1711h_set_vbus: charge is already Off [ 58.747321] usb 2-1: USB disconnect, device number 2 [ 58.819706] JDB: tcpm_state_machine_work state chage: SRC_ATTACHED->SRC_ATTACHED [ 58.871270] usb 1-1: new high-speed USB device number 4 using xhci-hcd [ 59.030402] usb 1-1: New USB device found, idVendor=2109, idProduct=2813, bcdDevice=90.11 [ 59.038677] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 59.045881] usb 1-1: Product: USB2.0 Hub [ 59.049838] usb 1-1: Manufacturer: VIA Labs, Inc. [ 59.104926] hub 1-1:1.0: USB hub found [ 59.109112] hub 1-1:1.0: 4 ports detected [ 59.327259] JDB: state change SRC_ATTACHED -> SRC_UNATTACHED [delayed 480 ms] [ 59.327710] JDB: rt1711h_set_vbus source: 0 sink: 0 [ 59.340022] JDB: rt1711h_set_vbus disabling regulator! [ 59.345296] type-c-vbus-current-regulator: disabled successfully?! JDB! (ret=0) [ 59.353458] rt1711h_set_vbus: vbus := Off [ 59.353465] rt1711h_set_vbus: charge is already Off [ 59.483278] usb 1-1.1: new low-speed USB device number 5 using xhci-hcd [ 59.571494] JDB: hub_usb_role_switch_set switching to ROLE_NONE! [ 59.577810] usb 1-1: USB disconnect, device number 4 [ 59.586675] JDB: tcpm_state_machine_work state chage: SRC_UNATTACHED->TOGGLING [ 59.593896] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 59.600757] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 59.627362] usb 1-1.1: Device not responding to setup address. [ 59.661413] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 59.839438] usb 1-1.1: Device not responding to setup address. [ 59.863252] JDB: state change SRC_ATTACH_WAIT -> SNK_TRY [delayed 200 ms] [ 59.863428] JDB: tcpm_state_machine_work state chage: SNK_TRY->SNK_TRY [ 59.967359] JDB: state change SNK_TRY -> SNK_TRY_WAIT [delayed 100 ms] [ 59.967383] JDB: tcpm_state_machine_work state chage: SNK_TRY_WAIT->SRC_TRYWAIT [ 59.981452] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT->SRC_TRYWAIT [ 60.051272] usb 1-1.1: device not accepting address 5, error -71 [ 60.083337] JDB: state change SRC_TRYWAIT -> SRC_TRYWAIT_UNATTACHED [delayed 100 ms] [ 60.083365] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT_UNATTACHED->SNK_UNATTACHED [ 60.101151] JDB: tcpm_state_machine_work state chage: SNK_UNATTACHED->TOGGLING [ 60.108462] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 60.155642] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 60.183338] usb 2-1: new SuperSpeed Gen 1 USB device number 3 using xhci-hcd [ 60.207782] usb 1-1-port1: attempt power cycle [ 60.212603] usb 2-1: New USB device found, idVendor=0424, idProduct=5734, bcdDevice= 2.02 [ 60.220923] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=0 [ 60.228147] usb 2-1: Product: USB5734 [ 60.231883] usb 2-1: Manufacturer: Microchip Tech [ 60.256450] hub 2-1:1.0: USB hub found [ 60.260360] hub 2-1:1.0: 5 ports detected [ 60.359385] JDB: state change SRC_ATTACH_WAIT -> SRC_ATTACHED [delayed 200 ms] [ 60.359853] JDB: hub_usb_role_switch_set switching to ROLE_HOST! [ 60.374310] JDB: rt1711h_set_vbus source: 1 sink: 0 [ 60.379386] JDB: rt1711h_set_vbus enabling regulator! [ 60.384485] type-c-vbus-current-regulator: being enabled! JDB! [ 60.390552] hub 2-1:1.0: hub_ext_port_status failed (err = -71) [ 60.396544] type-c-vbus-current-regulator: enabled successfully?! JDB! [ 60.403538] usb 2-1: Failed to suspend device, error -71 [ 60.403694] usb 2-1: USB disconnect, device number 3 [ 60.413841] rt1711h_set_vbus: vbus := On [ 60.413844] rt1711h_set_vbus: charge is already Off [ 60.631357] JDB: tcpm_state_machine_work state chage: SRC_ATTACHED->SRC_ATTACHED [ 60.815285] usb 1-1: new high-speed USB device number 9 using xhci-hcd [ 60.969662] usb 1-1: New USB device found, idVendor=2109, idProduct=2813, bcdDevice=90.11 [ 60.977964] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 60.985156] usb 1-1: Product: USB2.0 Hub [ 60.989419] usb 1-1: Manufacturer: VIA Labs, Inc. [ 61.056894] hub 1-1:1.0: USB hub found [ 61.061194] hub 1-1:1.0: 4 ports detected [ 61.119310] JDB: state change SRC_ATTACHED -> SRC_UNATTACHED [delayed 480 ms] [ 61.119759] JDB: rt1711h_set_vbus source: 0 sink: 0 [ 61.131951] JDB: rt1711h_set_vbus disabling regulator! [ 61.137141] type-c-vbus-current-regulator: disabled successfully?! JDB! (ret=0) [ 61.145007] rt1711h_set_vbus: vbus := Off [ 61.145010] rt1711h_set_vbus: charge is already Off [ 61.362956] JDB: hub_usb_role_switch_set switching to ROLE_NONE! [ 61.374082] usb 1-1: USB disconnect, device number 9 [ 61.380600] JDB: tcpm_state_machine_work state chage: SRC_UNATTACHED->TOGGLING [ 61.390394] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 61.397257] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 61.419292] usb 1-1.1: new low-speed USB device number 10 using xhci-hcd [ 61.427378] usb 1-1-port1: attempt power cycle [ 61.452874] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 61.655250] JDB: state change SRC_ATTACH_WAIT -> SNK_TRY [delayed 200 ms] [ 61.655398] JDB: tcpm_state_machine_work state chage: SNK_TRY->SNK_TRY [ 61.723383] usb 2-1: new SuperSpeed Gen 1 USB device number 4 using xhci-hcd [ 61.748163] usb 2-1: New USB device found, idVendor=0424, idProduct=5734, bcdDevice= 2.02 [ 61.757846] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=0 [ 61.763291] JDB: state change SNK_TRY -> SNK_TRY_WAIT [delayed 100 ms] [ 61.763317] JDB: tcpm_state_machine_work state chage: SNK_TRY_WAIT->SRC_TRYWAIT [ 61.766781] usb 2-1: Product: USB5734 [ 61.782560] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT->SRC_TRYWAIT [ 61.790221] usb 2-1: Manufacturer: Microchip Tech [ 61.824476] hub 2-1:1.0: USB hub found [ 61.828701] hub 2-1:1.0: 5 ports detected [ 61.883350] JDB: state change SRC_TRYWAIT -> SRC_TRYWAIT_UNATTACHED [delayed 100 ms] [ 61.883378] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT_UNATTACHED->SNK_UNATTACHED [ 61.901040] JDB: tcpm_state_machine_work state chage: SNK_UNATTACHED->TOGGLING [ 61.909513] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 61.955483] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 62.035296] usb 1-1: new high-speed USB device number 14 using xhci-hcd [ 62.159263] JDB: state change SRC_ATTACH_WAIT -> SRC_ATTACHED [delayed 200 ms] [ 62.159750] JDB: hub_usb_role_switch_set switching to ROLE_HOST! [ 62.174502] JDB: rt1711h_set_vbus source: 1 sink: 0 [ 62.179534] JDB: rt1711h_set_vbus enabling regulator! [ 62.185067] type-c-vbus-current-regulator: being enabled! JDB! [ 62.191039] type-c-vbus-current-regulator: enabled successfully?! JDB! [ 62.198180] usb 1-1: device descriptor read/all, error -71 [ 62.203769] rt1711h_set_vbus: vbus := On [ 62.203775] rt1711h_set_vbus: charge is already Off [ 62.351356] usb 2-1: USB disconnect, device number 4 [ 62.421558] JDB: tcpm_state_machine_work state chage: SRC_ATTACHED->SRC_ATTACHED [ 62.543282] usb 1-1: new high-speed USB device number 15 using xhci-hcd [ 62.696916] usb 1-1: New USB device found, idVendor=2109, idProduct=2813, bcdDevice=90.11 [ 62.705142] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 62.712616] usb 1-1: Product: USB2.0 Hub [ 62.716595] usb 1-1: Manufacturer: VIA Labs, Inc. [ 62.784743] hub 1-1:1.0: USB hub found [ 62.788841] hub 1-1:1.0: 4 ports detected [ 62.911249] JDB: state change SRC_ATTACHED -> SRC_UNATTACHED [delayed 480 ms] [ 62.911598] JDB: rt1711h_set_vbus source: 0 sink: 0 [ 62.923769] JDB: rt1711h_set_vbus disabling regulator! [ 62.928940] type-c-vbus-current-regulator: disabled successfully?! JDB! (ret=0) [ 62.936711] rt1711h_set_vbus: vbus := Off [ 62.936714] rt1711h_set_vbus: charge is already Off [ 63.143272] usb 1-1.1: new low-speed USB device number 16 using xhci-hcd [ 63.154684] JDB: hub_usb_role_switch_set switching to ROLE_NONE! [ 63.160941] usb 1-1-port1: cannot reset (err = -71) [ 63.161185] usb 1-1: USB disconnect, device number 15 [ 63.171398] JDB: tcpm_state_machine_work state chage: SRC_UNATTACHED->TOGGLING [ 63.175823] usb 1-1-port1: attempt power cycle [ 63.181995] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 63.182155] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 63.244450] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 63.447246] JDB: state change SRC_ATTACH_WAIT -> SNK_TRY [delayed 200 ms] [ 63.447391] JDB: tcpm_state_machine_work state chage: SNK_TRY->SNK_TRY [ 63.507335] usb 2-1: new SuperSpeed Gen 1 USB device number 5 using xhci-hcd [ 63.532130] usb 2-1: New USB device found, idVendor=0424, idProduct=5734, bcdDevice= 2.02 [ 63.542169] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=0 [ 63.549402] usb 2-1: Product: USB5734 [ 63.551286] JDB: state change SNK_TRY -> SNK_TRY_WAIT [delayed 100 ms] [ 63.551313] JDB: tcpm_state_machine_work state chage: SNK_TRY_WAIT->SRC_TRYWAIT [ 63.554868] usb 2-1: Manufacturer: Microchip Tech [ 63.571708] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT->SRC_TRYWAIT [ 63.600310] hub 2-1:1.0: USB hub found [ 63.604194] hub 2-1:1.0: 5 ports detected [ 63.675303] JDB: state change SRC_TRYWAIT -> SRC_TRYWAIT_UNATTACHED [delayed 100 ms] [ 63.675331] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT_UNATTACHED->SNK_UNATTACHED [ 63.693027] JDB: tcpm_state_machine_work state chage: SNK_UNATTACHED->TOGGLING [ 63.701676] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 63.747517] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 63.827281] usb 1-1: new high-speed USB device number 20 using xhci-hcd [ 63.941498] JDB: tcpm_state_machine_work state chage: SRC_UNATTACHED->TOGGLING [ 63.948872] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 63.979728] usb 1-1: New USB device found, idVendor=0424, idProduct=2734, bcdDevice= 2.02 [ 63.988033] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 63.995636] usb 1-1: Product: USB2734 [ 63.999540] usb 1-1: Manufacturer: Microchip Tech [ 64.064532] hub 1-1:1.0: USB hub found [ 64.068557] hub 1-1:1.0: 5 ports detected [ 64.415290] usb 1-1.5: new high-speed USB device number 21 using xhci-hcd [ 64.520307] usb 1-1.5: New USB device found, idVendor=0424, idProduct=2740, bcdDevice= 2.00 [ 64.528969] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 64.536345] usb 1-1.5: Product: Hub Controller [ 64.540828] usb 1-1.5: Manufacturer: Microchip Tech
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Hi John,
Sorry for being a bit slow to respond.
Quoted 36 lines · John Stultz
Quoted 6 lines · Hans de Goede
Quoted 5 lines · John Stultz
At least, with the current driver, the functionality is working as
expected: remove the USB-C cable, and devices connected to the hub power on, plug something into the USB-C port and devices plugged into the hub shutdown.Quoted 6 lines
Quoted 1 line
But maybe I'm missing what you mean?
Ok, so double checking the schematic I do see separate Vbus-es for the TypeC port and the TypeA ports, with the TypeC port one being controlled by
GPIO_202_VBUS_TYPEC. So ideally that gpio would be controlled to enable/disable vbus by the tcpm framework.So I've given this a shot, adding a gpio regulator for the type-c vbus, and added a
set_vbushook to thetcpci_rt1711with logic to enable and disable the regulator depending on the source state. I've also added some debug logic to check the regulator disabling/enabling is working properly. However, doing the type-c vbus control via the tcpm logic doesn't seem to be working properly.The issue seems to be when the USB-C cable is unplugged the device goes into
ROLE_NONE, we switch to the on-board hub. Then when we connect a USB-C hub to the type-c port, we switch toROLE_HOST, and power on the regulator, and that starts to power on the USB-C hub devices. However, since this disconnects/powers down the on-board hub, we see the on-board hub device disconnect. I'm guessing the hub disconnection causes some confusion in the state machine, as then I see the state change from state changeSRC_ATTACHED->SRC_UNATTACHED, andset_vbusis immediately called with source=0 and the regulator is disabled, and we switch back toROLE_NONE(which powers on the onboard hub). The system then seems to quickly oscillate between theROLE_HOSTandROLE_NONEswitching the regulator on and off fairly quickly (see log below for more details) and never really settling for one state or the other.
Quoted 1 line
Any off-hand thoughts on what might be going wrong here?
Sorry no clue.
Quoted 5 lines
I'm fine to
continue digging and working on this approach, but I also don't want to have to pollute the core code too much for this oddball hardware (esp since doing the vbus control in the role-switch intermediary does work ok - or at least better then this approach so far).
Given the special nature of the hardware I'm fine with the OTG intermediary approach here. IMHO it is fine to just stick with that and to not spend too much time on this.
Regards,
Hans
Quoted 242 lines
thanks
-johnStarts in
ROLE_NONEwith nothing connected to type-c port, with the on-board hub powered on, then we connect a type-c usb hub.[ 57.828323] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 58.031325] JDB: state change SRC_ATTACH_WAIT -> SNK_TRY [delayed 200 ms] [ 58.031525] JDB: tcpm_state_machine_work state chage: SNK_TRY->SNK_TRY [ 58.135273] JDB: state change SNK_TRY -> SNK_TRY_WAIT [delayed 100 ms] [ 58.135296] JDB: tcpm_state_machine_work state chage: SNK_TRY_WAIT->SRC_TRYWAIT [ 58.149344] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT->SRC_TRYWAIT [ 58.251273] JDB: state change SRC_TRYWAIT -> SRC_TRYWAIT_UNATTACHED [delayed 100 ms] [ 58.251297] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT_UNATTACHED->SNK_UNATTACHED [ 58.269076] JDB: tcpm_state_machine_work state chage: SNK_UNATTACHED->TOGGLING [ 58.276789] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 58.323506] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 58.527310] JDB: state change SRC_ATTACH_WAIT -> SRC_ATTACHED [delayed 200 ms] [ 58.527788] JDB: hub_usb_role_switch_set switching to ROLE_HOST! [ 58.541555] usb usb1-port1: disabled by hub (EMI?), re-enabling... [ 58.548654] usb 1-1: USB disconnect, device number 2 [ 58.554077] usb 1-1.5: USB disconnect, device number 3 [ 58.560133] JDB: rt1711h_set_vbus source: 1 sink: 0 [ 58.565377] JDB: rt1711h_set_vbus enabling regulator! [ 58.570495] type-c-vbus-current-regulator: being enabled! JDB! [ 58.586202] type-c-vbus-current-regulator: enabled successfully?! JDB! [ 58.602350] rt1711h_set_vbus: vbus := On [ 58.602354] rt1711h_set_vbus: charge is already Off [ 58.747321] usb 2-1: USB disconnect, device number 2 [ 58.819706] JDB: tcpm_state_machine_work state chage: SRC_ATTACHED->SRC_ATTACHED [ 58.871270] usb 1-1: new high-speed USB device number 4 using xhci-hcd [ 59.030402] usb 1-1: New USB device found, idVendor=2109, idProduct=2813, bcdDevice=90.11 [ 59.038677] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 59.045881] usb 1-1: Product: USB2.0 Hub [ 59.049838] usb 1-1: Manufacturer: VIA Labs, Inc. [ 59.104926] hub 1-1:1.0: USB hub found [ 59.109112] hub 1-1:1.0: 4 ports detected [ 59.327259] JDB: state change SRC_ATTACHED -> SRC_UNATTACHED [delayed 480 ms] [ 59.327710] JDB: rt1711h_set_vbus source: 0 sink: 0 [ 59.340022] JDB: rt1711h_set_vbus disabling regulator! [ 59.345296] type-c-vbus-current-regulator: disabled successfully?! JDB! (ret=0) [ 59.353458] rt1711h_set_vbus: vbus := Off [ 59.353465] rt1711h_set_vbus: charge is already Off [ 59.483278] usb 1-1.1: new low-speed USB device number 5 using xhci-hcd [ 59.571494] JDB: hub_usb_role_switch_set switching to ROLE_NONE! [ 59.577810] usb 1-1: USB disconnect, device number 4 [ 59.586675] JDB: tcpm_state_machine_work state chage: SRC_UNATTACHED->TOGGLING [ 59.593896] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 59.600757] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 59.627362] usb 1-1.1: Device not responding to setup address. [ 59.661413] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 59.839438] usb 1-1.1: Device not responding to setup address. [ 59.863252] JDB: state change SRC_ATTACH_WAIT -> SNK_TRY [delayed 200 ms] [ 59.863428] JDB: tcpm_state_machine_work state chage: SNK_TRY->SNK_TRY [ 59.967359] JDB: state change SNK_TRY -> SNK_TRY_WAIT [delayed 100 ms] [ 59.967383] JDB: tcpm_state_machine_work state chage: SNK_TRY_WAIT->SRC_TRYWAIT [ 59.981452] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT->SRC_TRYWAIT [ 60.051272] usb 1-1.1: device not accepting address 5, error -71 [ 60.083337] JDB: state change SRC_TRYWAIT -> SRC_TRYWAIT_UNATTACHED [delayed 100 ms] [ 60.083365] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT_UNATTACHED->SNK_UNATTACHED [ 60.101151] JDB: tcpm_state_machine_work state chage: SNK_UNATTACHED->TOGGLING [ 60.108462] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 60.155642] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 60.183338] usb 2-1: new SuperSpeed Gen 1 USB device number 3 using xhci-hcd [ 60.207782] usb 1-1-port1: attempt power cycle [ 60.212603] usb 2-1: New USB device found, idVendor=0424, idProduct=5734, bcdDevice= 2.02 [ 60.220923] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=0 [ 60.228147] usb 2-1: Product: USB5734 [ 60.231883] usb 2-1: Manufacturer: Microchip Tech [ 60.256450] hub 2-1:1.0: USB hub found [ 60.260360] hub 2-1:1.0: 5 ports detected [ 60.359385] JDB: state change SRC_ATTACH_WAIT -> SRC_ATTACHED [delayed 200 ms] [ 60.359853] JDB: hub_usb_role_switch_set switching to ROLE_HOST! [ 60.374310] JDB: rt1711h_set_vbus source: 1 sink: 0 [ 60.379386] JDB: rt1711h_set_vbus enabling regulator! [ 60.384485] type-c-vbus-current-regulator: being enabled! JDB! [ 60.390552] hub 2-1:1.0: hub_ext_port_status failed (err = -71) [ 60.396544] type-c-vbus-current-regulator: enabled successfully?! JDB! [ 60.403538] usb 2-1: Failed to suspend device, error -71 [ 60.403694] usb 2-1: USB disconnect, device number 3 [ 60.413841] rt1711h_set_vbus: vbus := On [ 60.413844] rt1711h_set_vbus: charge is already Off [ 60.631357] JDB: tcpm_state_machine_work state chage: SRC_ATTACHED->SRC_ATTACHED [ 60.815285] usb 1-1: new high-speed USB device number 9 using xhci-hcd [ 60.969662] usb 1-1: New USB device found, idVendor=2109, idProduct=2813, bcdDevice=90.11 [ 60.977964] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 60.985156] usb 1-1: Product: USB2.0 Hub [ 60.989419] usb 1-1: Manufacturer: VIA Labs, Inc. [ 61.056894] hub 1-1:1.0: USB hub found [ 61.061194] hub 1-1:1.0: 4 ports detected [ 61.119310] JDB: state change SRC_ATTACHED -> SRC_UNATTACHED [delayed 480 ms] [ 61.119759] JDB: rt1711h_set_vbus source: 0 sink: 0 [ 61.131951] JDB: rt1711h_set_vbus disabling regulator! [ 61.137141] type-c-vbus-current-regulator: disabled successfully?! JDB! (ret=0) [ 61.145007] rt1711h_set_vbus: vbus := Off [ 61.145010] rt1711h_set_vbus: charge is already Off [ 61.362956] JDB: hub_usb_role_switch_set switching to ROLE_NONE! [ 61.374082] usb 1-1: USB disconnect, device number 9 [ 61.380600] JDB: tcpm_state_machine_work state chage: SRC_UNATTACHED->TOGGLING [ 61.390394] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 61.397257] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 61.419292] usb 1-1.1: new low-speed USB device number 10 using xhci-hcd [ 61.427378] usb 1-1-port1: attempt power cycle [ 61.452874] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 61.655250] JDB: state change SRC_ATTACH_WAIT -> SNK_TRY [delayed 200 ms] [ 61.655398] JDB: tcpm_state_machine_work state chage: SNK_TRY->SNK_TRY [ 61.723383] usb 2-1: new SuperSpeed Gen 1 USB device number 4 using xhci-hcd [ 61.748163] usb 2-1: New USB device found, idVendor=0424, idProduct=5734, bcdDevice= 2.02 [ 61.757846] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=0 [ 61.763291] JDB: state change SNK_TRY -> SNK_TRY_WAIT [delayed 100 ms] [ 61.763317] JDB: tcpm_state_machine_work state chage: SNK_TRY_WAIT->SRC_TRYWAIT [ 61.766781] usb 2-1: Product: USB5734 [ 61.782560] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT->SRC_TRYWAIT [ 61.790221] usb 2-1: Manufacturer: Microchip Tech [ 61.824476] hub 2-1:1.0: USB hub found [ 61.828701] hub 2-1:1.0: 5 ports detected [ 61.883350] JDB: state change SRC_TRYWAIT -> SRC_TRYWAIT_UNATTACHED [delayed 100 ms] [ 61.883378] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT_UNATTACHED->SNK_UNATTACHED [ 61.901040] JDB: tcpm_state_machine_work state chage: SNK_UNATTACHED->TOGGLING [ 61.909513] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 61.955483] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 62.035296] usb 1-1: new high-speed USB device number 14 using xhci-hcd [ 62.159263] JDB: state change SRC_ATTACH_WAIT -> SRC_ATTACHED [delayed 200 ms] [ 62.159750] JDB: hub_usb_role_switch_set switching to ROLE_HOST! [ 62.174502] JDB: rt1711h_set_vbus source: 1 sink: 0 [ 62.179534] JDB: rt1711h_set_vbus enabling regulator! [ 62.185067] type-c-vbus-current-regulator: being enabled! JDB! [ 62.191039] type-c-vbus-current-regulator: enabled successfully?! JDB! [ 62.198180] usb 1-1: device descriptor read/all, error -71 [ 62.203769] rt1711h_set_vbus: vbus := On [ 62.203775] rt1711h_set_vbus: charge is already Off [ 62.351356] usb 2-1: USB disconnect, device number 4 [ 62.421558] JDB: tcpm_state_machine_work state chage: SRC_ATTACHED->SRC_ATTACHED [ 62.543282] usb 1-1: new high-speed USB device number 15 using xhci-hcd [ 62.696916] usb 1-1: New USB device found, idVendor=2109, idProduct=2813, bcdDevice=90.11 [ 62.705142] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 62.712616] usb 1-1: Product: USB2.0 Hub [ 62.716595] usb 1-1: Manufacturer: VIA Labs, Inc. [ 62.784743] hub 1-1:1.0: USB hub found [ 62.788841] hub 1-1:1.0: 4 ports detected [ 62.911249] JDB: state change SRC_ATTACHED -> SRC_UNATTACHED [delayed 480 ms] [ 62.911598] JDB: rt1711h_set_vbus source: 0 sink: 0 [ 62.923769] JDB: rt1711h_set_vbus disabling regulator! [ 62.928940] type-c-vbus-current-regulator: disabled successfully?! JDB! (ret=0) [ 62.936711] rt1711h_set_vbus: vbus := Off [ 62.936714] rt1711h_set_vbus: charge is already Off [ 63.143272] usb 1-1.1: new low-speed USB device number 16 using xhci-hcd [ 63.154684] JDB: hub_usb_role_switch_set switching to ROLE_NONE! [ 63.160941] usb 1-1-port1: cannot reset (err = -71) [ 63.161185] usb 1-1: USB disconnect, device number 15 [ 63.171398] JDB: tcpm_state_machine_work state chage: SRC_UNATTACHED->TOGGLING [ 63.175823] usb 1-1-port1: attempt power cycle [ 63.181995] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 63.182155] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 63.244450] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 63.447246] JDB: state change SRC_ATTACH_WAIT -> SNK_TRY [delayed 200 ms] [ 63.447391] JDB: tcpm_state_machine_work state chage: SNK_TRY->SNK_TRY [ 63.507335] usb 2-1: new SuperSpeed Gen 1 USB device number 5 using xhci-hcd [ 63.532130] usb 2-1: New USB device found, idVendor=0424, idProduct=5734, bcdDevice= 2.02 [ 63.542169] usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=0 [ 63.549402] usb 2-1: Product: USB5734 [ 63.551286] JDB: state change SNK_TRY -> SNK_TRY_WAIT [delayed 100 ms] [ 63.551313] JDB: tcpm_state_machine_work state chage: SNK_TRY_WAIT->SRC_TRYWAIT [ 63.554868] usb 2-1: Manufacturer: Microchip Tech [ 63.571708] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT->SRC_TRYWAIT [ 63.600310] hub 2-1:1.0: USB hub found [ 63.604194] hub 2-1:1.0: 5 ports detected [ 63.675303] JDB: state change SRC_TRYWAIT -> SRC_TRYWAIT_UNATTACHED [delayed 100 ms] [ 63.675331] JDB: tcpm_state_machine_work state chage: SRC_TRYWAIT_UNATTACHED->SNK_UNATTACHED [ 63.693027] JDB: tcpm_state_machine_work state chage: SNK_UNATTACHED->TOGGLING [ 63.701676] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 63.747517] JDB: tcpm_state_machine_work state chage: SRC_ATTACH_WAIT->SRC_ATTACH_WAIT [ 63.827281] usb 1-1: new high-speed USB device number 20 using xhci-hcd [ 63.941498] JDB: tcpm_state_machine_work state chage: SRC_UNATTACHED->TOGGLING [ 63.948872] JDB: tcpm_state_machine_work state chage: TOGGLING->TOGGLING [ 63.979728] usb 1-1: New USB device found, idVendor=0424, idProduct=2734, bcdDevice= 2.02 [ 63.988033] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 63.995636] usb 1-1: Product: USB2734 [ 63.999540] usb 1-1: Manufacturer: Microchip Tech [ 64.064532] hub 1-1:1.0: USB hub found [ 64.068557] hub 1-1:1.0: 5 ports detected [ 64.415290] usb 1-1.5: new high-speed USB device number 21 using xhci-hcd [ 64.520307] usb 1-1.5: New USB device found, idVendor=0424, idProduct=2740, bcdDevice= 2.00 [ 64.528969] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 64.536345] usb 1-1.5: Product: Hub Controller [ 64.540828] usb 1-1.5: Manufacturer: Microchip Tech
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Quoted 10 lines · Hans de Goede
Quoted 5 lines · John Stultz
I'm fine to
continue digging and working on this approach, but I also don't want to have to pollute the core code too much for this oddball hardware (esp since doing the vbus control in the role-switch intermediary does work ok - or at least better then this approach so far).Given the special nature of the hardware I'm fine with the OTG intermediary approach here. IMHO it is fine to just stick with that and to not spend too much time on this.
Ok. That was what I was leaning towards as well.
Thanks again for all the review and feedback here! I really appreciate it! -john
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
In reply to John StultzHi,
Quoted 27 lines · John Stultz
Quoted 9 lines · Hans de Goede
Quoted 5 lines · John Stultz
Fair point. I'm sort of taking a larger patchset and trying to break it up into more easily reviewable chunks, but I guess here I mis-cut.
The user is the hikey960 gpio hub driver here:
https://git.linaro.org/people/john.stultz/android-dev.git/commit/?id=b06158a2d3eb00c914f12c76c93695e92d9af00fHmm, that seems to tie the TypeC data-role to the power-role, which is not going to work with role swapping.
Thanks again for the feedback here. Sorry for the slow response. Been reworking some of the easier changes but am starting to look at how to address your feedback here.
Quoted 2 lines
What is controlling the usb-role-switch, and thus ultimately causing the notifier you are suggesting to get called ?
The
tcpm_mux_set()call viatcpm_state_machine_work()Quoted 6 lines
Things like
TYPEC_VBUS_POWER_OFFandTYPEC_VBUS_POWER_ONreally beg to be modeled as a regulator and then the Type-C controller (using e.g. thedrivers/usb/typec/tcpm/tcpm.cframework) can use that regulator to control things. in case of thetcpm.cframework it can then use that regulator to implement theset_vbuscallback.
Quoted 6 lines
So I'm looking at the bindings and I'm not sure exactly how to tie a regulator style driver into the tcpm for this?
Looking at the driver I just see this commented out bit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/typec/tcpm/tcpm.c#n3075Do you happen to have a pointer to something closer to what you are describing?
Look at the tcpm_set_vbus implementation in drivers/usb/typec/tcpm/fusb302.c you need to do something similar in your Type-C controller driver and export the GPIO as as a gpio-controlled regulator and tie the regulator to the connector.
Regards,
Han
Greg Kroah-Hartman
maintainerRe: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
In reply to John StultzQuoted 4 lines · John Stultz
From: Yu Chen <[email protected]>
This patch adds notifier for drivers want to be informed of the usb role switch.
Ick, I hate notifiers, they always come back to cause problems.
What's just wrong with a "real" call to who ever needs to know this? And who does need to know this anyway? Like Hans said, if we don't have a user for it, we should not add it.
thanks,
greg k-h
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Quoted 4 lines · Greg Kroah-Hartman
Quoted 2 lines · John Stultz
From: Yu Chen <[email protected]>
Quoted 8 lines
Quoted 2 lines
This patch adds notifier for drivers want to be informed of the usb role switch.
Ick, I hate notifiers, they always come back to cause problems.
What's just wrong with a "real" call to who ever needs to know this? And who does need to know this anyway? Like Hans said, if we don't have a user for it, we should not add it.
So in this case, its used for interactions between the dwc3 driver and the hikey960 integrated USB hub, which is controlled via gpio (which I didn't submit here as I was trying to keep things short and reviewable, but likely misjudged).
The HiKey960 has only one USB controller, but in order to support both USB-C gadget/OTG and USB-A (host only) ports. When the USB-C connection is attached, it powers down and disconnects the hub. When the USB-C connection is detached, it powers the hub on and connects the controller to the hub.
This is pretty HiKey960 specific, so I think the notifier is useful to let the gpio hub logic tie into the role switching events.
Suggestions for alternative approaches?
thanks
-john
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Hi,
Quoted 20 lines · John Stultz
Quoted 4 lines · Greg Kroah-Hartman
Quoted 2 lines · John Stultz
From: Yu Chen <[email protected]>
Quoted 8 lines
Quoted 2 lines
This patch adds notifier for drivers want to be informed of the usb role switch.
Ick, I hate notifiers, they always come back to cause problems.
What's just wrong with a "real" call to who ever needs to know this? And who does need to know this anyway? Like Hans said, if we don't have a user for it, we should not add it.
So in this case, its used for interactions between the dwc3 driver and the hikey960 integrated USB hub, which is controlled via gpio (which I didn't submit here as I was trying to keep things short and reviewable, but likely misjudged).
Quoted 5 lines
The HiKey960 has only one USB controller, but in order to support both USB-C gadget/OTG and USB-A (host only) ports. When the USB-C connection is attached, it powers down and disconnects the hub. When the USB-C connection is detached, it powers the hub on and connects the controller to the hub.
When you say one controller, do you mean 1 host and 1 gadget controller, or is this one of these lovely devices where a gadget controller gets abused as / confused with a proper host controller?
And since you are doing a usb-role-switch driver, I guess that the role-switch is integrated inside the SoC, so you only get one pair of USB datalines to the outside ?
This does seem rather special, it might help if you can provide a diagram with both the relevant bits inside the SoC as well as what lives outside the Soc. even if it is in ASCII art...
Regards,
Hans
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Quoted 10 lines · Hans de Goede
Quoted 5 lines · John Stultz
The HiKey960 has only one USB controller, but in order to support both USB-C gadget/OTG and USB-A (host only) ports. When the USB-C connection is attached, it powers down and disconnects the hub. When the USB-C connection is detached, it powers the hub on and connects the controller to the hub.
When you say one controller, do you mean 1 host and 1 gadget controller, or is this one of these lovely devices where a gadget controller gets abused as / confused with a proper host controller?
I'm not totally sure myself, but I believe it's the latter, as the host ports have to be disabled in order for the gadet/otg port to function.
There was a similar situation w/ the original HiKey board (dwc2 controller) as well, though the switching was done fully in hardware and we only needed some minor tweaks to the driver to keep the state transitions straight.
Quoted 3 lines
And since you are doing a usb-role-switch driver, I guess that the role-switch is integrated inside the SoC, so you only get one pair of USB datalines to the outside ?
I believe so, but again, I don't have a ton of knowledge about the SoC details, Chen Yu would probably be the right person to answer, but I don't know if he's doing upstreaming anymore.
Quoted 3 lines
This does seem rather special, it might help if you can provide a diagram with both the relevant bits inside the SoC as well as what lives outside the Soc. even if it is in ASCII art...
There is a schematic pdf here:
https://github.com/96boards/documentation/raw/master/consumer/hikey/hikey960/hardware-docs/HiKey960_Schematics.pdf
The larger block diagram on page 3 might be helpful, but you can find more details on the usb hub bits on page 17 and 18.
thanks
-john
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Hi,
Quoted 33 lines · John Stultz
Quoted 10 lines · Hans de Goede
Quoted 5 lines · John Stultz
The HiKey960 has only one USB controller, but in order to support both USB-C gadget/OTG and USB-A (host only) ports. When the USB-C connection is attached, it powers down and disconnects the hub. When the USB-C connection is detached, it powers the hub on and connects the controller to the hub.
When you say one controller, do you mean 1 host and 1 gadget controller, or is this one of these lovely devices where a gadget controller gets abused as / confused with a proper host controller?
I'm not totally sure myself, but I believe it's the latter, as the host ports have to be disabled in order for the gadet/otg port to function.
There was a similar situation w/ the original HiKey board (dwc2 controller) as well, though the switching was done fully in hardware and we only needed some minor tweaks to the driver to keep the state transitions straight.
Quoted 3 lines
And since you are doing a usb-role-switch driver, I guess that the role-switch is integrated inside the SoC, so you only get one pair of USB datalines to the outside ?
I believe so, but again, I don't have a ton of knowledge about the SoC details, Chen Yu would probably be the right person to answer, but I don't know if he's doing upstreaming anymore.
Quoted 3 lines
This does seem rather special, it might help if you can provide a diagram with both the relevant bits inside the SoC as well as what lives outside the Soc. even if it is in ASCII art...
Quoted 5 lines
There is a schematic pdf here:
https://github.com/96boards/documentation/raw/master/consumer/hikey/hikey960/hardware-docs/HiKey960_Schematics.pdfThe larger block diagram on page 3 might be helpful, but you can find more details on the usb hub bits on page 17 and 18.
Ok, so I took a quick look at the schematic and it is really funky.
The USB3 superspeed data pairs are only going to the USB-3 hub and only the USB-2 lines are muxed between the TypeC and the HUB, so in theory superspeed devices could keep working while the TypeC is in device mode, since their data lines will still be connected, but I guess the controller in the SoC is switched to device mode then so this does not work. Likewise Vbus is an all or nothing thing, either both the TypeC connector + the 2 Type-A reeptacles get Vusb or none of them get Vusb. Also it is seems to use the TypeC connector in host-mode together with the A receptacles. I must say this is a weird design...
Anyways back the code to add a usb role switch notifier. I do not think that this is a good idea, this is making "core" changes to deal with a special case. If you are going to use a notfier for this then IMHO the notifier should be part of the hikey960 usb role swtich driver and not be in the usb-role-switch class code, since this is very much a device specific hack.
Regards,
Hans
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
Quoted 7 lines · Hans de Goede
Anyways back the code to add a usb role switch notifier. I do not think that this is a good idea, this is making "core" changes to deal with a special case. If you are going to use a notfier for this then IMHO the notifier should be part of the hikey960 usb role swtich driver and not be in the usb-role-switch class code, since this is very much a device specific hack.
Ok, that sounds fair. I still need to find some way to hook into the role-switch path between the tcpm and the dwc3 in order to switch to the hub, but I guess I can try to add a hook somewhere in the dwc3 code itself. I'll dig on this a bit.
thanks
-john
Re: [RFC][PATCH 2/3] usb: roles: Add usb role switch notifier.
In reply to Hans de GoedeQuoted 29 lines · Hans de Goede
Hi,
Quoted 20 lines · John Stultz
Quoted 4 lines · Greg Kroah-Hartman
Quoted 2 lines · John Stultz
From: Yu Chen <[email protected]>
Quoted 8 lines
Quoted 2 lines
This patch adds notifier for drivers want to be informed of the usb role switch.
Ick, I hate notifiers, they always come back to cause problems.
What's just wrong with a "real" call to who ever needs to know this? And who does need to know this anyway? Like Hans said, if we don't have a user for it, we should not add it.
So in this case, its used for interactions between the dwc3 driver and the hikey960 integrated USB hub, which is controlled via gpio (which I didn't submit here as I was trying to keep things short and reviewable, but likely misjudged).
Quoted 5 lines
The HiKey960 has only one USB controller, but in order to support both USB-C gadget/OTG and USB-A (host only) ports. When the USB-C connection is attached, it powers down and disconnects the hub. When the USB-C connection is detached, it powers the hub on and connects the controller to the hub.
Quoted 7 lines
When you say one controller, do you mean 1 host and 1 gadget controller, or is this one of these lovely devices where a gadget controller gets abused as / confused with a proper host controller?
And since you are doing a usb-role-switch driver, I guess that the role-switch is integrated inside the SoC, so you only get one pair of USB datalines to the outside ?
Unless I'm mistaken, the dwc3 driver in this case is the usb-role-switch. The DWC3 IP includes both USB dost and device blocks, i.e. it's a dual role controller. Drivers like tcpm.c that negotiate the actual role need to tell the outcome of the negotiation to the dwc3 driver. So I think this part is OK.
The platform has also some kind of discrete switch for routing the signals to either Standard-A (the hub) or Type-C connector, so it does not represent the usb-role-switch. It should however affect the USB role, as if that switch routes the data signals to the Standard-A port (to the hub) instead of USB Type-C, the USB role needs to be fixed to host mode.
I guess this series does not include the driver for that discrete switch/mux. I don't remember/know how that switch was planned to be handled.
Quoted 3 lines
This does seem rather special, it might help if you can provide a diagram with both the relevant bits inside the SoC as well as what lives outside the Soc. even if it is in ASCII art...
thanks,
Signature · 1 line
heikki
RFC PATCH 3/3 usb: dwc3: Registering a role switch in the DRD code.
In reply to John StultzFrom: Yu Chen <[email protected]>
The Type-C drivers use USB role switch API to inform the system about the negotiated data role, so registering a role switch in the DRD code in order to support platforms with USB Type-C connectors.
--- drivers/usb/dwc3/Kconfig | 1 + drivers/usb/dwc3/core.h | 6 ++++ drivers/usb/dwc3/drd.c | 78 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 84 insertions(+), 1 deletion(-)
drivers/usb/dwc3/Kconfig +1 -0
@@ -44,6 +44,7 @@ config USB_DWC3_DUAL_ROLE bool "Dual Role mode" depends on ((USB=y || USB=USB_DWC3) && (USB_GADGET=y || USB_GADGET=USB_DWC3)) depends on (EXTCON=y || EXTCON=USB_DWC3) + select USB_ROLE_SWITCH help This is the default mode of working of DWC3 controller where both host and gadget features are enabled.
drivers/usb/dwc3/core.h +6 -0
@@ -25,6 +25,7 @@#include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb/otg.h> +#include <linux/usb/role.h> #include <linux/ulpi/interface.h> #include <linux/phy/phy.h>
@@ -951,6 +952,9 @@ struct dwc3_scratchpad_array {* @hsphy_mode: UTMI phy mode, one of following: * - USBPHY_INTERFACE_MODE_UTMI * - USBPHY_INTERFACE_MODE_UTMIW +* role_sw: usb_role_switch handle +* role_switch_default_mode: default operation mode of controller while +* usb role is USB_ROLE_NONE. * @usb2_phy: pointer to USB2 PHY * @usb3_phy: pointer to USB3 PHY * @usb2_generic_phy: pointer to USB2 PHY
@@ -1085,6 +1089,8 @@ struct dwc3 {struct extcon_dev *edev;struct notifier_block edev_nb;enum usb_phy_interface hsphy_mode; +struct usb_role_switch *role_sw; +enum usb_dr_mode role_switch_default_mode;u32 fladj;u32 irq_gadget;
drivers/usb/dwc3/drd.c +77 -1
96 lines not on this page · raw message
Signature · 1 line
2.17.1
kbuild test robot
build botRe: [RFC][PATCH 3/3] usb: dwc3: Registering a role switch in the DRD code.
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please…
Hi John,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on usb/usb-testing]
[cannot apply to v5.4-rc1 next-20191002]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/John-Stultz/dwc3-role-switch-handling-for-HiKey960/20191003-072715 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing reproduce: make htmldocs
If you fix the issue, kindly add following tag
All warnings (new ones prefixed by >>):
Warning: The Sphinx 'sphinx_rtd_theme' HTML theme was not found. Make sure you have the theme installed to produce pretty HTML output. Falling back to the default theme.
WARNING: dot(1) not found, for better output quality install graphviz from http://www.graphviz.org
WARNING: convert(1) not found, for SVG to PDF conversion install ImageMagick (https://www.imagemagick.org)
include/linux/regulator/machine.h:196: warning: Function parameter or member 'max_uV_step' not described in 'regulation_constraints' include/linux/regulator/driver.h:223: warning: Function parameter or member 'resume' not described in 'regulator_ops'
Error: Cannot open file drivers/dma-buf/reservation.c
Error: Cannot open file drivers/dma-buf/reservation.c
Error: Cannot open file drivers/dma-buf/reservation.c
Error: Cannot open file include/linux/reservation.h
Error: Cannot open file include/linux/reservation.h
include/linux/spi/spi.h:190: warning: Function parameter or member 'driver_override' not described in 'spi_device'
>> drivers/usb/dwc3/core.h:1230: warning: Function parameter or member 'role_sw' not described in 'dwc3' >> drivers/usb/dwc3/core.h:1230: warning: Function parameter or member 'role_switch_default_mode' not described in 'dwc3'
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c:335: warning: Excess function parameter 'dev' description in 'amdgpu_gem_prime_export' drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c:336: warning: Excess function parameter 'dev' description in 'amdgpu_gem_prime_export' drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c:142: warning: Function parameter or member 'blockable' not described in 'amdgpu_mn_read_lock' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:347: warning: cannot understand function prototype: 'struct amdgpu_vm_pt_cursor '
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:348: warning: cannot understand function prototype: 'struct amdgpu_vm_pt_cursor '
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:494: warning: Function parameter or member 'start' not described in 'amdgpu_vm_pt_first_dfs' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:546: warning: Function parameter or member 'adev' not described in 'for_each_amdgpu_vm_pt_dfs_safe' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:546: warning: Function parameter or member 'vm' not described in 'for_each_amdgpu_vm_pt_dfs_safe' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:546: warning: Function parameter or member 'start' not described in 'for_each_amdgpu_vm_pt_dfs_safe' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:546: warning: Function parameter or member 'cursor' not described in 'for_each_amdgpu_vm_pt_dfs_safe' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:546: warning: Function parameter or member 'entry' not described in 'for_each_amdgpu_vm_pt_dfs_safe' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:823: warning: Function parameter or member 'level' not described in 'amdgpu_vm_bo_param' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1285: warning: Function parameter or member 'params' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1285: warning: Function parameter or member 'bo' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1285: warning: Function parameter or member 'level' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1285: warning: Function parameter or member 'pe' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1285: warning: Function parameter or member 'addr' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1285: warning: Function parameter or member 'count' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1285: warning: Function parameter or member 'incr' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:1285: warning: Function parameter or member 'flags' not described in 'amdgpu_vm_update_flags' drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:2823: warning: Function parameter or member 'pasid' not described in 'amdgpu_vm_make_compute' drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c:378: warning: Excess function parameter 'entry' description in 'amdgpu_irq_dispatch' drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c:379: warning: Function parameter or member 'ih' not described in 'amdgpu_irq_dispatch' drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c:379: warning: Excess function parameter 'entry' description in 'amdgpu_irq_dispatch'
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c:1: warning: no structured comments found
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:1: warning: no structured comments found
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c:1: warning: 'pp_dpm_sclk pp_dpm_mclk pp_dpm_pcie' not found
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:132: warning: Incorrect use of kernel-doc format: Documentation Makefile include scripts source @atomic_obj drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:238: warning: Incorrect use of kernel-doc format: Documentation Makefile include scripts source gpu_info FW provided soc bounding box struct or 0 if not drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'atomic_obj' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'backlight_link' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'backlight_caps' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'freesync_module' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'fw_dmcu' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'dmcu_fw_version' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'soc_bounding_box' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:1: warning: 'dm_pflip_high_irq' not found
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:1: warning: 'register_hpd_handlers' not found
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:1: warning: 'dm_crtc_high_irq' not found
drivers/gpio/gpiolib-of.c:92: warning: Excess function parameter 'dev' description in 'of_gpio_need_valid_mask'
include/linux/i2c.h:337: warning: Function parameter or member 'init_irq' not described in 'i2c_client'
fs/fs-writeback.c:913: warning: Excess function parameter 'nr_pages' description in 'cgroup_writeback_by_id'
fs/direct-io.c:258: warning: Excess function parameter 'offset' description in 'dio_complete'
fs/libfs.c:496: warning: Excess function parameter 'available' description in 'simple_write_end'
fs/posix_acl.c:647: warning: Function parameter or member 'inode' not described in 'posix_acl_update_mode'
fs/posix_acl.c:647: warning: Function parameter or member 'mode_p' not described in 'posix_acl_update_mode'
fs/posix_acl.c:647: warning: Function parameter or member 'acl' not described in 'posix_acl_update_mode'
mm/util.c:1: warning: 'get_user_pages_fast' not found
mm/slab.c:4215: warning: Function parameter or member 'objp' not described in '__ksize'
drivers/usb/typec/bus.c:1: warning: 'typec_altmode_register_driver' not found
drivers/usb/typec/bus.c:1: warning: 'typec_altmode_unregister_driver' not found
drivers/usb/typec/class.c:1: warning: 'typec_altmode_unregister_notifier' not found
drivers/usb/typec/class.c:1: warning: 'typec_altmode_register_notifier' not found
include/linux/w1.h:277: warning: Function parameter or member 'of_match_table' not described in 'w1_family'
kernel/dma/coherent.c:1: warning: no structured comments found
include/linux/input/sparse-keymap.h:43: warning: Function parameter or member 'sw' not described in 'key_entry'
lib/genalloc.c:1: warning: 'gen_pool_add_virt' not found
lib/genalloc.c:1: warning: 'gen_pool_alloc' not found
lib/genalloc.c:1: warning: 'gen_pool_free' not found
lib/genalloc.c:1: warning: 'gen_pool_alloc_algo' not found
include/linux/bitmap.h:341: warning: Function parameter or member 'nbits' not described in 'bitmap_or_equal'
include/linux/rculist.h:374: warning: Excess function parameter 'cond' description in 'list_for_each_entry_rcu'
include/linux/rculist.h:651: warning: Excess function parameter 'cond' description in 'hlist_for_each_entry_rcu'
include/net/mac80211.h:4056: warning: Function parameter or member 'sta_set_txpwr' not described in 'ieee80211_ops'
include/net/mac80211.h:2018: warning: Function parameter or member 'txpwr' not described in 'ieee80211_sta'
include/net/cfg80211.h:1185: warning: Function parameter or member 'txpwr' not described in 'station_parameters'
include/linux/skbuff.h:888: warning: Function parameter or member 'dev_scratch' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'list' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'ip_defrag_offset' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'skb_mstamp_ns' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member '__cloned_offset' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'head_frag' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member '__pkt_type_offset' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'encapsulation' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'encap_hdr_csum' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'csum_valid' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member '__pkt_vlan_present_offset' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'vlan_present' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'csum_complete_sw' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'csum_level' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'inner_protocol_type' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'remcsum_offload' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'sender_cpu' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'reserved_tailroom' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'inner_ipproto' not described in 'sk_buff'
include/net/sock.h:233: warning: Function parameter or member 'skc_addrpair' not described in 'sock_common'
include/net/sock.h:233: warning: Function parameter or member 'skc_portpair' not described in 'sock_common'
include/net/sock.h:233: warning: Function parameter or member 'skc_ipv6only' not described in 'sock_common'
include/net/sock.h:233: warning: Function parameter or member 'skc_net_refcnt' not described in 'sock_common'
include/net/sock.h:233: warning: Function parameter or member 'skc_v6_daddr' not described in 'sock_common'
include/net/sock.h:233: warning: Function parameter or member 'skc_v6_rcv_saddr' not described in 'sock_common'
include/net/sock.h:233: warning: Function parameter or member 'skc_cookie' not described in 'sock_common'
include/net/sock.h:233: warning: Function parameter or member 'skc_listener' not described in 'sock_common'
include/net/sock.h:233: warning: Function parameter or member 'skc_tw_dr' not described in 'sock_common'
include/net/sock.h:233: warning: Function parameter or member 'skc_rcv_wnd' not described in 'sock_common'
include/net/sock.h:233: warning: Function parameter or member 'skc_tw_rcv_nxt' not described in 'sock_common'
include/net/sock.h:515: warning: Function parameter or member 'sk_rx_skb_cache' not described in 'sock'
include/net/sock.h:515: warning: Function parameter or member 'sk_wq_raw' not described in 'sock'
include/net/sock.h:515: warning: Function parameter or member 'tcp_rtx_queue' not described in 'sock'
include/net/sock.h:515: warning: Function parameter or member 'sk_tx_skb_cache' not described in 'sock'
vim +1230 drivers/usb/dwc3/core.h
72246da40f3719 Felipe Balbi 2011-08-19 @1230
:::::: The code at line 1230 was first introduced by commit
:::::: 72246da40f3719af3bfd104a2365b32537c27d83 usb: Introduce DesignWare USB3 DRD Driver
:::::: TO: Felipe Balbi <[email protected]>
:::::: CC: Greg Kroah-Hartman <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [RFC][PATCH 3/3] usb: dwc3: Registering a role switch in the DRD code.
Quoted 2 lines · kbuild test robot
Quoted 2 lines
Quoted 2 lines
drivers/usb/dwc3/core.h:1230: warning: Function parameter or member 'role_sw' not described in 'dwc3'drivers/usb/dwc3/core.h:1230: warning: Function parameter or member 'role_switch_default_mode' not described in 'dwc3'
Ah. The descriptions are missing the @ prefix. Thanks for the heads up! -john
kbuild test robot
build botRe: [RFC][PATCH 3/3] usb: dwc3: Registering a role switch in the DRD code.
In reply to John Stultz[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please…
Hi John,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on usb/usb-testing]
[cannot apply to v5.4-rc2 next-20191011]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/John-Stultz/dwc3-role-switch-handling-for-HiKey960/20191003-072715 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing reproduce: # apt-get install sparse # sparse version: v0.6.1-rc1-43-g0ccb3b4-dirty make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
sparse warnings: (new ones prefixed by >>)
>> drivers/usb/dwc3/drd.c:543:65: sparse: sparse: Using plain integer as NULL pointer
vim +543 drivers/usb/dwc3/drd.c
533
534 int dwc3_drd_init(struct dwc3 *dwc)
535 {
536 int ret, irq;
537
538 dwc->edev = dwc3_get_extcon(dwc);
539 if (IS_ERR(dwc->edev))
540 return PTR_ERR(dwc->edev);
541
542 if (device_property_read_bool(dwc->dev, "usb-role-switch")) {
> 543 struct usb_role_switch_desc dwc3_role_switch = {0}; 544 u32 mode;
545
546 if (device_property_read_bool(dwc->dev,
547 "role-switch-default-host")) {
548 dwc->role_switch_default_mode = USB_DR_MODE_HOST;
549 mode = DWC3_GCTL_PRTCAP_HOST;
550 } else {
551 dwc->role_switch_default_mode = USB_DR_MODE_PERIPHERAL;
552 mode = DWC3_GCTL_PRTCAP_DEVICE;
553 }
554 dwc3_role_switch.fwnode = dev_fwnode(dwc->dev);
555 dwc3_role_switch.set = dwc3_usb_role_switch_set;
556 dwc3_role_switch.get = dwc3_usb_role_switch_get;
557 dwc->role_sw = usb_role_switch_register(dwc->dev,
558 &dwc3_role_switch);
559 if (IS_ERR(dwc->role_sw))
560 return PTR_ERR(dwc->role_sw);
561
562 dwc3_set_mode(dwc, mode);
563 } else if (dwc->edev) {
564 dwc->edev_nb.notifier_call = dwc3_drd_notifier;
565 ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST,
566 &dwc->edev_nb);
567 if (ret < 0) {
568 dev_err(dwc->dev, "couldn't register cable notifier\n");
569 return ret;
570 }
571
572 dwc3_drd_update(dwc);
573 } else {
574 dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_OTG);
575 dwc->current_dr_role = DWC3_GCTL_PRTCAP_OTG;
576
577 /* use OTG block to get ID event */
578 irq = dwc3_otg_get_irq(dwc);
579 if (irq < 0)
580 return irq;
581
582 dwc->otg_irq = irq;
583
584 /* disable all OTG IRQs */
585 dwc3_otg_disable_events(dwc, DWC3_OTG_ALL_EVENTS);
586 /* clear all events */
587 dwc3_otg_clear_events(dwc);
588
589 ret = request_threaded_irq(dwc->otg_irq, dwc3_otg_irq,
590 dwc3_otg_thread_irq,
591 IRQF_SHARED, "dwc3-otg", dwc);
592 if (ret) {
593 dev_err(dwc->dev, "failed to request irq #%d --> %d\n",
594 dwc->otg_irq, ret);
595 ret = -ENODEV;
596 return ret;
597 }
598
599 dwc3_otg_init(dwc);
600 dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
601 }
602
603 return 0;
604 }
605
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [RFC][PATCH 3/3] usb: dwc3: Registering a role switch in the DRD code.
In reply to John StultzHi,
Quoted 137 lines · John Stultz
From: Yu Chen <[email protected]>
The Type-C drivers use USB role switch API to inform the system about the negotiated data role, so registering a role switch in the DRD code in order to support platforms with USB Type-C connectors.
Cc Greg Kroah-Hartman <[email protected]>Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Heikki Krogerus <[email protected]>Cc Suzuki K Poulose <[email protected]>Cc Chunfeng Yun <[email protected]>Cc Yu Chen <[email protected]>Cc Felipe Balbi <[email protected]>Cc Hans de Goede <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Jun Li <[email protected]>Cc Valentin Schneider <[email protected]>Suggested-by Heikki Krogerus <[email protected]>Signed-off-by Yu Chen <[email protected]>Signed-off-by John Stultz <[email protected]>--- drivers/usb/dwc3/Kconfig | 1 + drivers/usb/dwc3/core.h | 6 ++++ drivers/usb/dwc3/drd.c | 78 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 84 insertions(+), 1 deletion(-)drivers/usb/dwc3/Kconfig +1
-0@@ -44,6 +44,7 @@ config USB_DWC3_DUAL_ROLE bool "Dual Role mode" depends on ((USB=y || USB=USB_DWC3) && (USB_GADGET=y || USB_GADGET=USB_DWC3)) depends on (EXTCON=y || EXTCON=USB_DWC3) + select USB_ROLE_SWITCH help This is the default mode of working of DWC3 controller where both host and gadget features are enabled.drivers/usb/dwc3/core.h +6
-0@@ -25,6 +25,7 @@#include <linux/usb/ch9.h> #include <linux/usb/gadget.h> #include <linux/usb/otg.h> +#include <linux/usb/role.h> #include <linux/ulpi/interface.h> #include <linux/phy/phy.h> @@ -951,6 +952,9 @@ struct dwc3_scratchpad_array {* @hsphy_mode: UTMI phy mode, one of following: * - USBPHY_INTERFACE_MODE_UTMI * - USBPHY_INTERFACE_MODE_UTMIW +* role_sw: usb_role_switch handle +* role_switch_default_mode: default operation mode of controller while +* usb role is USB_ROLE_NONE. * @usb2_phy: pointer to USB2 PHY * @usb3_phy: pointer to USB3 PHY * @usb2_generic_phy: pointer to USB2 PHY @@ -1085,6 +1089,8 @@ struct dwc3 {struct extcon_dev *edev;struct notifier_block edev_nb;enum usb_phy_interface hsphy_mode; +struct usb_role_switch *role_sw; +enum usb_dr_mode role_switch_default_mode;u32 fladj;u32 irq_gadget;drivers/usb/dwc3/drd.c +52
-0@@ -479,6 +479,58 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)return edev; } +static int dwc3_usb_role_switch_set (struct device *dev,enum usb_role role) +{ +struct dwc3 *dwc =dev_get_drvdata (dev); +u32 mode; + +switch (role) { +case USB_ROLE_HOST : + mode =DWC3_GCTL_PRTCAP_HOST ; +break ; +case USB_ROLE_DEVICE : + mode =DWC3_GCTL_PRTCAP_DEVICE ; +break ; +default : +if (dwc->role_switch_default_mode ==USB_DR_MODE_HOST ) + mode =DWC3_GCTL_PRTCAP_HOST ; +else + mode =DWC3_GCTL_PRTCAP_DEVICE ; +break ; + } + +dwc3_set_mode (dwc, mode); +return 0 ; +} + +static enum usb_role dwc3_usb_role_switch_get (struct device *dev) +{ +struct dwc3 *dwc =dev_get_drvdata (dev); +unsigned long flags; +enum usb_role role; + +spin_lock_irqsave (&dwc->lock, flags); +switch (dwc->current_dr_role) { +case DWC3_GCTL_PRTCAP_HOST : + role =USB_ROLE_HOST ; +break ; +case DWC3_GCTL_PRTCAP_DEVICE : + role =USB_ROLE_DEVICE ; +break ; +case DWC3_GCTL_PRTCAP_OTG : + role = dwc->current_otg_role; +break ; +default : +if (dwc->role_switch_default_mode ==USB_DR_MODE_HOST ) + role =USB_ROLE_HOST ; +else + role =USB_ROLE_DEVICE ; +break ; + } +spin_unlock_irqrestore (&dwc->lock, flags); +return role; +} +int dwc3_drd_init (struct dwc3 *dwc) {int ret, irq;
drivers/usb/dwc3/drd.c int dwc3_drd_init(struct dwc3 *dwc) · line 542
Quoted 5 lines
drivers/usb/dwc3/drd.c +1
-1@@ -487,7 +539,28 @@ int dwc3_drd_init(struct dwc3 *dwc)if (IS_ERR (dwc->edev))return PTR_ERR (dwc->edev); -if (dwc->edev) { +if (device_property_read_bool (dwc->dev,"usb-role-switch" )) {
I think we should use role switch unconditionally and get rid of the debugfs role status/change mechanism.
Quoted 11 lines
drivers/usb/dwc3/drd.c +11
-0+struct usb_role_switch_desc dwc3_role_switch = {0 }; +u32 mode; + +if (device_property_read_bool (dwc->dev, +"role-switch-default-host" )) { + dwc->role_switch_default_mode =USB_DR_MODE_HOST ; + mode =DWC3_GCTL_PRTCAP_HOST ; + }else { + dwc->role_switch_default_mode =USB_DR_MODE_PERIPHERAL ; + mode =DWC3_GCTL_PRTCAP_DEVICE ; + }
drivers/usb/dwc3/drd.c int dwc3_drd_init(struct dwc3 *dwc) · line 563
Quoted 10 lines
drivers/usb/dwc3/drd.c +10
-0+ 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; + dwc->role_sw =usb_role_switch_register (dwc->dev, + &dwc3_role_switch); +if (IS_ERR (dwc->role_sw)) +return PTR_ERR (dwc->role_sw); + +dwc3_set_mode (dwc, mode); + }else if (dwc->edev) {
Role switch should exist regardless if dwc->edev is present or not.
Quoted 14 lines
drivers/usb/dwc3/drd.c +3
-0dwc->edev_nb.notifier_call = dwc3_drd_notifier; ret =extcon_register_notifier (dwc->edev,EXTCON_USB_HOST , &dwc->edev_nb);@@ -534,6 +607,9 @@ void dwc3_drd_exit(struct dwc3 *dwc) {unsigned long flags; +if (dwc->role_sw) +usb_role_switch_unregister (dwc->role_sw); +if (dwc->edev)extcon_unregister_notifier (dwc->edev,EXTCON_USB_HOST , &dwc->edev_nb);
Signature · 5 lines
cheers, -roger Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Re: [RFC][PATCH 3/3] usb: dwc3: Registering a role switch in the DRD code.
Quoted 26 lines · Roger Quadros
drivers/usb/dwc3/drd.c int dwc3_drd_init(struct dwc3 *dwc) · line 542
Quoted 6 lines · John Stultz
drivers/usb/dwc3/drd.c +1
-1@@ -487,7 +539,28 @@ int dwc3_drd_init(struct dwc3 *dwc)if (IS_ERR (dwc->edev))return PTR_ERR (dwc->edev); -if (dwc->edev) { +if (device_property_read_bool (dwc->dev,"usb-role-switch" )) {I think we should use role switch unconditionally and get rid of the debugfs role status/change mechanism.
Quoted 15 lines
drivers/usb/dwc3/drd.c +15
-0+struct usb_role_switch_desc dwc3_role_switch = {0 }; +u32 mode; + +if (device_property_read_bool (dwc->dev, +"role-switch-default-host" )) { + dwc->role_switch_default_mode =USB_DR_MODE_HOST ; + mode =DWC3_GCTL_PRTCAP_HOST ; + }else { + dwc->role_switch_default_mode =USB_DR_MODE_PERIPHERAL ; + mode =DWC3_GCTL_PRTCAP_DEVICE ; + } + 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; + dwc->role_sw = usb_role_switch_register(dwc->dev,
Quoted 8 lines
drivers/usb/dwc3/drd.c int dwc3_drd_init(struct dwc3 *dwc) · line 563
Quoted 6 lines
drivers/usb/dwc3/drd.c +6
-0+ &dwc3_role_switch); +if (IS_ERR (dwc->role_sw)) +return PTR_ERR (dwc->role_sw); + +dwc3_set_mode (dwc, mode); + }else if (dwc->edev) {Role switch should exist regardless if
dwc->edevis present or not.
Does that risk duplicative mode sets when things change (via the dwc3_drd_notifier and dwc3_usb_role_switch_set calls?).
thanks
-john
Re: [RFC][PATCH 3/3] usb: dwc3: Registering a role switch in the DRD code.
Quoted 36 lines · John Stultz
Quoted 26 lines · Roger Quadros
drivers/usb/dwc3/drd.c int dwc3_drd_init(struct dwc3 *dwc) · line 542
Quoted 6 lines · John Stultz
drivers/usb/dwc3/drd.c +1
-1@@ -487,7 +539,28 @@ int dwc3_drd_init(struct dwc3 *dwc)if (IS_ERR (dwc->edev))return PTR_ERR (dwc->edev); -if (dwc->edev) { +if (device_property_read_bool (dwc->dev,"usb-role-switch" )) {I think we should use role switch unconditionally and get rid of the debugfs role status/change mechanism.
Quoted 15 lines
drivers/usb/dwc3/drd.c +15
-0+struct usb_role_switch_desc dwc3_role_switch = {0 }; +u32 mode; + +if (device_property_read_bool (dwc->dev, +"role-switch-default-host" )) { + dwc->role_switch_default_mode =USB_DR_MODE_HOST ; + mode =DWC3_GCTL_PRTCAP_HOST ; + }else { + dwc->role_switch_default_mode =USB_DR_MODE_PERIPHERAL ; + mode =DWC3_GCTL_PRTCAP_DEVICE ; + } + 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; + dwc->role_sw = usb_role_switch_register(dwc->dev,Quoted 8 lines
drivers/usb/dwc3/drd.c int dwc3_drd_init(struct dwc3 *dwc) · line 563
Quoted 6 lines
drivers/usb/dwc3/drd.c +6
-0+ &dwc3_role_switch); +if (IS_ERR (dwc->role_sw)) +return PTR_ERR (dwc->role_sw); + +dwc3_set_mode (dwc, mode); + }else if (dwc->edev) {Role switch should exist regardless if
dwc->edevis present or not.
Quoted 2 lines
Does that risk duplicative mode sets when things change (via the
dwc3_drd_notifieranddwc3_usb_role_switch_setcalls?).
Yes, we need to deal with it in the driver. e.g. in current case when debugfs overrides a role from "otg" to "host" or "device", we ignore the notifier.
Something similar could be done with role switch I think.
Felipe, what do you think?
Signature · 4 lines
cheers, -roger Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki