2021-09-15 08:00:46

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH 0/3] usb: dwc2: fill in gadget caps, configure it for stm32mp15

This patchset fills in 'otg_caps' of the usb_gadget structure, and configures it
on stm32mp15.

When dwc2 is configured as dual role (OTG), the USB gadget descriptors (device mode)
are configured via configfs. This lead in calling usb_otg_descriptor_init().
In usb_otg_descriptor_init() (drivers/usb/gadget/config.c):
- If otg caps structure is provided -> use it
- If otg caps structure isn't provided -> HNP and SRP are enabled by default

This could lead to a configuration mismatch beetween:
- OTG controller: HNP and SRP aren't enabled
- gadget descriptors: HNP and SRP are advertised

Fabrice Gasnier (3):
usb: dwc2: add otg_rev and otg_caps information for gadget driver
usb: dwc2: stm32mp15: set otg_rev
ARM: dts: stm32: set otg-rev on stm32mp151

arch/arm/boot/dts/stm32mp151.dtsi | 1 +
drivers/usb/dwc2/core.h | 7 +++++++
drivers/usb/dwc2/gadget.c | 1 +
drivers/usb/dwc2/params.c | 16 ++++++++++++++++
4 files changed, 25 insertions(+)

--
2.7.4


2021-09-15 08:00:53

by Fabrice Gasnier

[permalink] [raw]
Subject: [PATCH 2/3] usb: dwc2: stm32mp15: set otg_rev

STM32MP15 complies with the OTG 2.0. Set OTG revision accordingly. It is
useful for the of_usb_update_otg_caps() routine to check and update
otg_rev to the lower value between DT and provided params.

Signed-off-by: Fabrice Gasnier <[email protected]>
---
drivers/usb/dwc2/params.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index f8ab211..fe2e88f 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -170,6 +170,7 @@ static void dwc2_set_stm32mp15_fsotg_params(struct dwc2_hsotg *hsotg)
struct dwc2_core_params *p = &hsotg->params;

p->otg_cap = DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE;
+ p->otg_rev = 0x200;
p->speed = DWC2_SPEED_PARAM_FULL;
p->host_rx_fifo_size = 128;
p->host_nperio_tx_fifo_size = 96;
@@ -190,6 +191,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->otg_rev = 0x200;
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;
--
2.7.4

2021-10-01 11:25:16

by Minas Harutyunyan

[permalink] [raw]
Subject: Re: [PATCH 2/3] usb: dwc2: stm32mp15: set otg_rev

On 9/15/2021 11:54 AM, Fabrice Gasnier wrote:
> STM32MP15 complies with the OTG 2.0. Set OTG revision accordingly. It is
> useful for the of_usb_update_otg_caps() routine to check and update
> otg_rev to the lower value between DT and provided params.
>
> Signed-off-by: Fabrice Gasnier <[email protected]>

Acked-by: Minas Harutyunyan <[email protected]>