2020-07-28 07:47:42

by Amelie Delaunay

[permalink] [raw]
Subject: [PATCH v5 0/3] Add USB role switch support to DWC2

When using usb-c connector (but it can also be the case with a micro-b
connector), iddig, avalid, bvalid, vbusvalid input signals may not be
connected to the DWC2 OTG controller.
DWC2 OTG controller features an overriding control of the PHY voltage valid
and ID input signals.
So, missing signals can be forced using usb role from usb role switch and
this override feature.

This series adds support for usb role switch to dwc2, by using overriding
control of the PHY voltage valid and ID input signals.

It has been tested on stm32mp157c-dk2 [1], which has a Type-C connector
managed by a Type-C port controller, and connected to USB OTG controller.

[1] https://www.st.com/en/evaluation-tools/stm32mp157c-dk2.html

Amelie Delaunay (3):
dt-bindings: usb: dwc2: add optional usb-role-switch property
usb: dwc2: override PHY input signals with usb role switch support
usb: dwc2: don't use ID/Vbus detection if usb-role-switch on STM32MP15
SoCs
---
Changes in v5:
- Use device_property_read_bool instead of of_read_property_bool in params.c
Changes in v4:
- Simplify call to dwc2_force_mode in drd.c
- Add error_drd label in probe error path in platform.c
Changes in v3:
- Fix build issue reported by kernel test robot in drd.c
Changes in v2:
- Previous DT patch already in stm32-next branch so removed from v2 patchset
"ARM: dts: stm32: enable usb-role-switch on USB OTG on stm32mp15xx-dkx"
- DWC2 DT bindings update added
- Build issue reported by kernel test robot fixed
- Martin's comments taken into account
---
.../devicetree/bindings/usb/dwc2.yaml | 4 +
drivers/usb/dwc2/Kconfig | 1 +
drivers/usb/dwc2/Makefile | 2 +-
drivers/usb/dwc2/core.h | 9 +
drivers/usb/dwc2/drd.c | 180 ++++++++++++++++++
drivers/usb/dwc2/gadget.c | 2 +-
drivers/usb/dwc2/params.c | 2 +-
drivers/usb/dwc2/platform.c | 20 +-
8 files changed, 215 insertions(+), 5 deletions(-)
create mode 100644 drivers/usb/dwc2/drd.c

--
2.17.1


2020-07-28 07:49:17

by Amelie Delaunay

[permalink] [raw]
Subject: [PATCH v5 3/3] usb: dwc2: don't use ID/Vbus detection if usb-role-switch on STM32MP15 SoCs

If usb-role-switch is present in the device tree, it means that ID and Vbus
signals are not connected to the OTG controller but to an external
component (GPIOs, Type-C controller). In this configuration, usb role
switch is used to force valid sessions on STM32MP15 SoCs.

Signed-off-by: Amelie Delaunay <[email protected]>
---
Changes in v5:
- Use device_property_read_bool instead of of_read_property_bool
---
drivers/usb/dwc2/params.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index a3611cdd1dea..50df72f32b4c 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -185,7 +185,7 @@ static void dwc2_set_stm32mp15_hsotg_params(struct dwc2_hsotg *hsotg)
struct dwc2_core_params *p = &hsotg->params;

p->otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE;
- p->activate_stm_id_vb_detection = true;
+ p->activate_stm_id_vb_detection = !device_property_read_bool(hsotg->dev, "usb-role-switch");
p->host_rx_fifo_size = 440;
p->host_nperio_tx_fifo_size = 256;
p->host_perio_tx_fifo_size = 256;
--
2.17.1

2020-07-28 20:03:27

by Martin Blumenstingl

[permalink] [raw]
Subject: Re: [PATCH v5 3/3] usb: dwc2: don't use ID/Vbus detection if usb-role-switch on STM32MP15 SoCs

Hi Amelie,

On Tue, Jul 28, 2020 at 9:46 AM Amelie Delaunay <[email protected]> wrote:
>
> If usb-role-switch is present in the device tree, it means that ID and Vbus
> signals are not connected to the OTG controller but to an external
> component (GPIOs, Type-C controller). In this configuration, usb role
> switch is used to force valid sessions on STM32MP15 SoCs.
>
> Signed-off-by: Amelie Delaunay <[email protected]>
thank you for updating this patch - please add my:
Acked-by: Martin Blumenstingl <[email protected]>


Martin