* [PATCH] usb: dwc2: add "u-boot,force-vbus-detection" for stm32
@ 2020-10-15 12:49 Patrick Delaunay
2020-10-15 13:07 ` Marek Vasut
2020-10-21 11:46 ` Patrice CHOTARD
0 siblings, 2 replies; 9+ messages in thread
From: Patrick Delaunay @ 2020-10-15 12:49 UTC (permalink / raw)
To: u-boot
On some board, the ID pin is not connected so the B session must be
overridden with "u-boot,force_b_session_valid" but the VBus sensing
must continue to be handle.
To managed it, this patch adds a new DT field
"u-boot,force-vbus-detection" to use with "u-boot,force_b_session_valid"
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
drivers/usb/gadget/dwc2_udc_otg.c | 59 +++++++++++++++++---------
drivers/usb/gadget/dwc2_udc_otg_regs.h | 2 +
include/usb/dwc2_udc.h | 1 +
3 files changed, 41 insertions(+), 21 deletions(-)
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index eaa5dcb9b1..d20ce6147e 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -1014,6 +1014,9 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
platdata->force_b_session_valid =
dev_read_bool(dev, "u-boot,force-b-session-valid");
+ platdata->force_vbus_detection =
+ dev_read_bool(dev, "u-boot,force-vbus-detection");
+
/* force platdata according compatible */
drvdata = dev_get_driver_data(dev);
if (drvdata) {
@@ -1106,31 +1109,45 @@ static int dwc2_udc_otg_probe(struct udevice *dev)
if (ret)
return ret;
- if (CONFIG_IS_ENABLED(DM_REGULATOR) &&
- platdata->activate_stm_id_vb_detection &&
- !platdata->force_b_session_valid) {
- ret = device_get_supply_regulator(dev, "usb33d-supply",
- &priv->usb33d_supply);
- if (ret) {
- dev_err(dev, "can't get voltage level detector supply\n");
- return ret;
+ if (platdata->activate_stm_id_vb_detection) {
+ if (CONFIG_IS_ENABLED(DM_REGULATOR) &&
+ (!platdata->force_b_session_valid ||
+ platdata->force_vbus_detection)) {
+ ret = device_get_supply_regulator(dev, "usb33d-supply",
+ &priv->usb33d_supply);
+ if (ret) {
+ dev_err(dev, "can't get voltage level detector supply\n");
+ return ret;
+ }
+ ret = regulator_set_enable(priv->usb33d_supply, true);
+ if (ret) {
+ dev_err(dev, "can't enable voltage level detector supply\n");
+ return ret;
+ }
}
- ret = regulator_set_enable(priv->usb33d_supply, true);
- if (ret) {
- dev_err(dev, "can't enable voltage level detector supply\n");
- return ret;
+
+ if (platdata->force_b_session_valid &&
+ !platdata->force_vbus_detection) {
+ /* Override VBUS detection: enable then value*/
+ setbits_le32(&usbotg_reg->gotgctl, VB_VALOEN);
+ setbits_le32(&usbotg_reg->gotgctl, VB_VALOVAL);
+ } else {
+ /* Enable VBUS sensing */
+ setbits_le32(&usbotg_reg->ggpio,
+ GGPIO_STM32_OTG_GCCFG_VBDEN);
+ }
+ if (platdata->force_b_session_valid) {
+ /* Override B session bits: enable then value */
+ setbits_le32(&usbotg_reg->gotgctl, A_VALOEN | B_VALOEN);
+ setbits_le32(&usbotg_reg->gotgctl,
+ A_VALOVAL | B_VALOVAL);
+ } else {
+ /* Enable ID detection */
+ setbits_le32(&usbotg_reg->ggpio,
+ GGPIO_STM32_OTG_GCCFG_IDEN);
}
- /* Enable vbus sensing */
- setbits_le32(&usbotg_reg->ggpio,
- GGPIO_STM32_OTG_GCCFG_VBDEN |
- GGPIO_STM32_OTG_GCCFG_IDEN);
}
- if (platdata->force_b_session_valid)
- /* Override B session bits : value and enable */
- setbits_le32(&usbotg_reg->gotgctl,
- A_VALOEN | A_VALOVAL | B_VALOEN | B_VALOVAL);
-
ret = dwc2_udc_probe(platdata);
if (ret)
return ret;
diff --git a/drivers/usb/gadget/dwc2_udc_otg_regs.h b/drivers/usb/gadget/dwc2_udc_otg_regs.h
index 2eda5c3720..9ca6f42375 100644
--- a/drivers/usb/gadget/dwc2_udc_otg_regs.h
+++ b/drivers/usb/gadget/dwc2_udc_otg_regs.h
@@ -94,6 +94,8 @@ struct dwc2_usbotg_reg {
#define B_VALOEN BIT(6)
#define A_VALOVAL BIT(5)
#define A_VALOEN BIT(4)
+#define VB_VALOVAL BIT(3)
+#define VB_VALOEN BIT(2)
/* DWC2_UDC_OTG_GOTINT */
#define GOTGINT_SES_END_DET (1<<2)
diff --git a/include/usb/dwc2_udc.h b/include/usb/dwc2_udc.h
index a2af381a66..aa37e957b4 100644
--- a/include/usb/dwc2_udc.h
+++ b/include/usb/dwc2_udc.h
@@ -28,6 +28,7 @@ struct dwc2_plat_otg_data {
unsigned int tx_fifo_sz_array[DWC2_MAX_HW_ENDPOINTS];
unsigned char tx_fifo_sz_nb;
bool force_b_session_valid;
+ bool force_vbus_detection;
bool activate_stm_id_vb_detection;
};
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH] usb: dwc2: add "u-boot,force-vbus-detection" for stm32
2020-10-15 12:49 [PATCH] usb: dwc2: add "u-boot,force-vbus-detection" for stm32 Patrick Delaunay
@ 2020-10-15 13:07 ` Marek Vasut
2020-10-15 16:52 ` Patrick DELAUNAY
2020-10-21 11:46 ` Patrice CHOTARD
1 sibling, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2020-10-15 13:07 UTC (permalink / raw)
To: u-boot
On 10/15/20 2:49 PM, Patrick Delaunay wrote:
> On some board, the ID pin is not connected so the B session must be
> overridden with "u-boot,force_b_session_valid" but the VBus sensing
> must continue to be handle.
>
> To managed it, this patch adds a new DT field
> "u-boot,force-vbus-detection" to use with "u-boot,force_b_session_valid"
How is this solved in Linux ?
btw can you do something about that huge change in indent ? Is it
necessary ?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] usb: dwc2: add "u-boot,force-vbus-detection" for stm32
2020-10-15 13:07 ` Marek Vasut
@ 2020-10-15 16:52 ` Patrick DELAUNAY
2020-10-15 17:38 ` Marek Vasut
0 siblings, 1 reply; 9+ messages in thread
From: Patrick DELAUNAY @ 2020-10-15 16:52 UTC (permalink / raw)
To: u-boot
Hi Marek,
> From: Marek Vasut <marex@denx.de>
> Sent: jeudi 15 octobre 2020 15:08
>
> On 10/15/20 2:49 PM, Patrick Delaunay wrote:
> > On some board, the ID pin is not connected so the B session must be
> > overridden with "u-boot,force_b_session_valid" but the VBus sensing
> > must continue to be handle.
> >
> > To managed it, this patch adds a new DT field
> > "u-boot,force-vbus-detection" to use with "u-boot,force_b_session_valid"
>
> How is this solved in Linux ?
It is managed by Linux DWC2 driver: it is a real OTG driver, with dual mode
support and by usb framework
Throught the properties
&usbotg_hs {
usb-role-switch;
};
a glue treat the session and the sensing management
see linux/drivers/usb/dwc2/drd.c in linux-next
PS: activate_stm_id_vb_detection is also used in driver = hsotg->params.
As ID pin / vbus is completly managed by the USB TYPE driver C
(STUSB1600 for STMicroelectronics board) and DWC2 driver with dual role
stack (host/gadget).
I don't found a better solution than device tree property for this task in U-Boot as DWC2
driver don't support dual role and U-Boot don't have framework for USB type C controller.
>
> btw can you do something about that huge change in indent ? Is it necessary ?
I move all this code under activate_stm_id_vb_detection (linked to compatible "st,stm32mp1-hsotg")
to avoid impact on other platform as this "sensing" properties are only support for STM32MP15X
(it is linked to USB block detection integrated in SOC)
And after I need to check the
1/ The usb33d-supply is required of vbus or IDPIN sensing
2/ manage Vbus sensing or override (according dt)
3/ manage IDPIN or override (according dt)
I add a new property to be backward compatible (even it the combinaison is less clear)
I protect regulator function call to avoid compilation issue for other platform.
PS: after reading the refmanual, I also split VALOEN and VALOVAL bit update as it is required.
So yes I think it is needed but I can split the patch to simplify the review.
Patrick
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] usb: dwc2: add "u-boot,force-vbus-detection" for stm32
2020-10-15 16:52 ` Patrick DELAUNAY
@ 2020-10-15 17:38 ` Marek Vasut
2020-10-16 16:32 ` Patrick DELAUNAY
0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2020-10-15 17:38 UTC (permalink / raw)
To: u-boot
On 10/15/20 6:52 PM, Patrick DELAUNAY wrote:
Hi,
[...]
>> On 10/15/20 2:49 PM, Patrick Delaunay wrote:
>>> On some board, the ID pin is not connected so the B session must be
>>> overridden with "u-boot,force_b_session_valid" but the VBus sensing
>>> must continue to be handle.
>>>
>>> To managed it, this patch adds a new DT field
>>> "u-boot,force-vbus-detection" to use with "u-boot,force_b_session_valid"
>>
>> How is this solved in Linux ?
>
> It is managed by Linux DWC2 driver: it is a real OTG driver, with dual mode
> support and by usb framework
>
> Throught the properties
> &usbotg_hs {
> usb-role-switch;
> };
>
> a glue treat the session and the sensing management
> see linux/drivers/usb/dwc2/drd.c in linux-next
>
> PS: activate_stm_id_vb_detection is also used in driver = hsotg->params.
>
> As ID pin / vbus is completly managed by the USB TYPE driver C
> (STUSB1600 for STMicroelectronics board) and DWC2 driver with dual role
> stack (host/gadget).
>
> I don't found a better solution than device tree property for this task in U-Boot as DWC2
> driver don't support dual role and U-Boot don't have framework for USB type C controller.
>
>>
>> btw can you do something about that huge change in indent ? Is it necessary ?
>
> I move all this code under activate_stm_id_vb_detection (linked to compatible "st,stm32mp1-hsotg")
> to avoid impact on other platform as this "sensing" properties are only support for STM32MP15X
> (it is linked to USB block detection integrated in SOC)
>
> And after I need to check the
> 1/ The usb33d-supply is required of vbus or IDPIN sensing
> 2/ manage Vbus sensing or override (according dt)
> 3/ manage IDPIN or override (according dt)
>
> I add a new property to be backward compatible (even it the combinaison is less clear)
> I protect regulator function call to avoid compilation issue for other platform.
>
> PS: after reading the refmanual, I also split VALOEN and VALOVAL bit update as it is required.
>
> So yes I think it is needed but I can split the patch to simplify the review.
I presume you don't feel like implementing proper OTG support, right ?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] usb: dwc2: add "u-boot,force-vbus-detection" for stm32
2020-10-15 17:38 ` Marek Vasut
@ 2020-10-16 16:32 ` Patrick DELAUNAY
2020-10-20 10:21 ` Marek Vasut
0 siblings, 1 reply; 9+ messages in thread
From: Patrick DELAUNAY @ 2020-10-16 16:32 UTC (permalink / raw)
To: u-boot
Hi Marek,
> From: Marek Vasut <marex@denx.de>
> Sent: jeudi 15 octobre 2020 19:39
>
> On 10/15/20 6:52 PM, Patrick DELAUNAY wrote:
>
> Hi,
>
> [...]
>
> >> On 10/15/20 2:49 PM, Patrick Delaunay wrote:
> >>> On some board, the ID pin is not connected so the B session must be
> >>> overridden with "u-boot,force_b_session_valid" but the VBus sensing
> >>> must continue to be handle.
> >>>
> >>> To managed it, this patch adds a new DT field
> >>> "u-boot,force-vbus-detection" to use with "u-boot,force_b_session_valid"
> >>
> >> How is this solved in Linux ?
> >
> > It is managed by Linux DWC2 driver: it is a real OTG driver, with dual
> > mode support and by usb framework
> >
> > Throught the properties
> > &usbotg_hs {
> > usb-role-switch;
> > };
> >
> > a glue treat the session and the sensing management see
> > linux/drivers/usb/dwc2/drd.c in linux-next
> >
> > PS: activate_stm_id_vb_detection is also used in driver = hsotg->params.
> >
> > As ID pin / vbus is completly managed by the USB TYPE driver C
> > (STUSB1600 for STMicroelectronics board) and DWC2 driver with dual
> > role stack (host/gadget).
> >
> > I don't found a better solution than device tree property for this
> > task in U-Boot as DWC2 driver don't support dual role and U-Boot don't have
> framework for USB type C controller.
> >
> >>
> >> btw can you do something about that huge change in indent ? Is it necessary ?
> >
> > I move all this code under activate_stm_id_vb_detection (linked to
> > compatible "st,stm32mp1-hsotg") to avoid impact on other platform as
> > this "sensing" properties are only support for STM32MP15X (it is
> > linked to USB block detection integrated in SOC)
> >
> > And after I need to check the
> > 1/ The usb33d-supply is required of vbus or IDPIN sensing 2/ manage
> > Vbus sensing or override (according dt) 3/ manage IDPIN or override
> > (according dt)
> >
> > I add a new property to be backward compatible (even it the
> > combinaison is less clear) I protect regulator function call to avoid compilation
> issue for other platform.
> >
> > PS: after reading the refmanual, I also split VALOEN and VALOVAL bit update
> as it is required.
> >
> > So yes I think it is needed but I can split the patch to simplify the review.
>
> I presume you don't feel like implementing proper OTG support, right ?
Yes, I am afraid of this task.
Patrick
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] usb: dwc2: add "u-boot,force-vbus-detection" for stm32
2020-10-16 16:32 ` Patrick DELAUNAY
@ 2020-10-20 10:21 ` Marek Vasut
[not found] ` <6b18d5817aa84b92852d70132c0b7b8c@SFHDAG2NODE3.st.com>
0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2020-10-20 10:21 UTC (permalink / raw)
To: u-boot
On 10/16/20 6:32 PM, Patrick DELAUNAY wrote:
> Hi Marek,
Hi,
[...]
>>>> On 10/15/20 2:49 PM, Patrick Delaunay wrote:
>>>>> On some board, the ID pin is not connected so the B session must be
>>>>> overridden with "u-boot,force_b_session_valid" but the VBus sensing
>>>>> must continue to be handle.
>>>>>
>>>>> To managed it, this patch adds a new DT field
>>>>> "u-boot,force-vbus-detection" to use with "u-boot,force_b_session_valid"
>>>>
>>>> How is this solved in Linux ?
>>>
>>> It is managed by Linux DWC2 driver: it is a real OTG driver, with dual
>>> mode support and by usb framework
>>>
>>> Throught the properties
>>> &usbotg_hs {
>>> usb-role-switch;
>>> };
>>>
>>> a glue treat the session and the sensing management see
>>> linux/drivers/usb/dwc2/drd.c in linux-next
>>>
>>> PS: activate_stm_id_vb_detection is also used in driver = hsotg->params.
>>>
>>> As ID pin / vbus is completly managed by the USB TYPE driver C
>>> (STUSB1600 for STMicroelectronics board) and DWC2 driver with dual
>>> role stack (host/gadget).
>>>
>>> I don't found a better solution than device tree property for this
>>> task in U-Boot as DWC2 driver don't support dual role and U-Boot don't have
>> framework for USB type C controller.
>>>
>>>>
>>>> btw can you do something about that huge change in indent ? Is it necessary ?
>>>
>>> I move all this code under activate_stm_id_vb_detection (linked to
>>> compatible "st,stm32mp1-hsotg") to avoid impact on other platform as
>>> this "sensing" properties are only support for STM32MP15X (it is
>>> linked to USB block detection integrated in SOC)
>>>
>>> And after I need to check the
>>> 1/ The usb33d-supply is required of vbus or IDPIN sensing 2/ manage
>>> Vbus sensing or override (according dt) 3/ manage IDPIN or override
>>> (according dt)
>>>
>>> I add a new property to be backward compatible (even it the
>>> combinaison is less clear) I protect regulator function call to avoid compilation
>> issue for other platform.
>>>
>>> PS: after reading the refmanual, I also split VALOEN and VALOVAL bit update
>> as it is required.
>>>
>>> So yes I think it is needed but I can split the patch to simplify the review.
>>
>> I presume you don't feel like implementing proper OTG support, right ?
>
> Yes, I am afraid of this task.
Can you take a look ?
I will pick this patch into next for now.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] usb: dwc2: add "u-boot,force-vbus-detection" for stm32
2020-10-15 12:49 [PATCH] usb: dwc2: add "u-boot,force-vbus-detection" for stm32 Patrick Delaunay
2020-10-15 13:07 ` Marek Vasut
@ 2020-10-21 11:46 ` Patrice CHOTARD
1 sibling, 0 replies; 9+ messages in thread
From: Patrice CHOTARD @ 2020-10-21 11:46 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 10/15/20 2:49 PM, Patrick Delaunay wrote:
> On some board, the ID pin is not connected so the B session must be
> overridden with "u-boot,force_b_session_valid" but the VBus sensing
> must continue to be handle.
>
> To managed it, this patch adds a new DT field
> "u-boot,force-vbus-detection" to use with "u-boot,force_b_session_valid"
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> drivers/usb/gadget/dwc2_udc_otg.c | 59 +++++++++++++++++---------
> drivers/usb/gadget/dwc2_udc_otg_regs.h | 2 +
> include/usb/dwc2_udc.h | 1 +
> 3 files changed, 41 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
> index eaa5dcb9b1..d20ce6147e 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> @@ -1014,6 +1014,9 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
> platdata->force_b_session_valid =
> dev_read_bool(dev, "u-boot,force-b-session-valid");
>
> + platdata->force_vbus_detection =
> + dev_read_bool(dev, "u-boot,force-vbus-detection");
> +
> /* force platdata according compatible */
> drvdata = dev_get_driver_data(dev);
> if (drvdata) {
> @@ -1106,31 +1109,45 @@ static int dwc2_udc_otg_probe(struct udevice *dev)
> if (ret)
> return ret;
>
> - if (CONFIG_IS_ENABLED(DM_REGULATOR) &&
> - platdata->activate_stm_id_vb_detection &&
> - !platdata->force_b_session_valid) {
> - ret = device_get_supply_regulator(dev, "usb33d-supply",
> - &priv->usb33d_supply);
> - if (ret) {
> - dev_err(dev, "can't get voltage level detector supply\n");
> - return ret;
> + if (platdata->activate_stm_id_vb_detection) {
> + if (CONFIG_IS_ENABLED(DM_REGULATOR) &&
> + (!platdata->force_b_session_valid ||
> + platdata->force_vbus_detection)) {
> + ret = device_get_supply_regulator(dev, "usb33d-supply",
> + &priv->usb33d_supply);
> + if (ret) {
> + dev_err(dev, "can't get voltage level detector supply\n");
> + return ret;
> + }
> + ret = regulator_set_enable(priv->usb33d_supply, true);
> + if (ret) {
> + dev_err(dev, "can't enable voltage level detector supply\n");
> + return ret;
> + }
> }
> - ret = regulator_set_enable(priv->usb33d_supply, true);
> - if (ret) {
> - dev_err(dev, "can't enable voltage level detector supply\n");
> - return ret;
> +
> + if (platdata->force_b_session_valid &&
> + !platdata->force_vbus_detection) {
> + /* Override VBUS detection: enable then value*/
> + setbits_le32(&usbotg_reg->gotgctl, VB_VALOEN);
> + setbits_le32(&usbotg_reg->gotgctl, VB_VALOVAL);
> + } else {
> + /* Enable VBUS sensing */
> + setbits_le32(&usbotg_reg->ggpio,
> + GGPIO_STM32_OTG_GCCFG_VBDEN);
> + }
> + if (platdata->force_b_session_valid) {
> + /* Override B session bits: enable then value */
> + setbits_le32(&usbotg_reg->gotgctl, A_VALOEN | B_VALOEN);
> + setbits_le32(&usbotg_reg->gotgctl,
> + A_VALOVAL | B_VALOVAL);
> + } else {
> + /* Enable ID detection */
> + setbits_le32(&usbotg_reg->ggpio,
> + GGPIO_STM32_OTG_GCCFG_IDEN);
> }
> - /* Enable vbus sensing */
> - setbits_le32(&usbotg_reg->ggpio,
> - GGPIO_STM32_OTG_GCCFG_VBDEN |
> - GGPIO_STM32_OTG_GCCFG_IDEN);
> }
>
> - if (platdata->force_b_session_valid)
> - /* Override B session bits : value and enable */
> - setbits_le32(&usbotg_reg->gotgctl,
> - A_VALOEN | A_VALOVAL | B_VALOEN | B_VALOVAL);
> -
> ret = dwc2_udc_probe(platdata);
> if (ret)
> return ret;
> diff --git a/drivers/usb/gadget/dwc2_udc_otg_regs.h b/drivers/usb/gadget/dwc2_udc_otg_regs.h
> index 2eda5c3720..9ca6f42375 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg_regs.h
> +++ b/drivers/usb/gadget/dwc2_udc_otg_regs.h
> @@ -94,6 +94,8 @@ struct dwc2_usbotg_reg {
> #define B_VALOEN BIT(6)
> #define A_VALOVAL BIT(5)
> #define A_VALOEN BIT(4)
> +#define VB_VALOVAL BIT(3)
> +#define VB_VALOEN BIT(2)
>
> /* DWC2_UDC_OTG_GOTINT */
> #define GOTGINT_SES_END_DET (1<<2)
> diff --git a/include/usb/dwc2_udc.h b/include/usb/dwc2_udc.h
> index a2af381a66..aa37e957b4 100644
> --- a/include/usb/dwc2_udc.h
> +++ b/include/usb/dwc2_udc.h
> @@ -28,6 +28,7 @@ struct dwc2_plat_otg_data {
> unsigned int tx_fifo_sz_array[DWC2_MAX_HW_ENDPOINTS];
> unsigned char tx_fifo_sz_nb;
> bool force_b_session_valid;
> + bool force_vbus_detection;
> bool activate_stm_id_vb_detection;
> };
>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] usb: dwc2: add "u-boot,force-vbus-detection" for stm32
[not found] ` <6b18d5817aa84b92852d70132c0b7b8c@SFHDAG2NODE3.st.com>
@ 2020-12-09 17:04 ` Patrick DELAUNAY
2020-12-09 17:22 ` Marek Vasut
0 siblings, 1 reply; 9+ messages in thread
From: Patrick DELAUNAY @ 2020-12-09 17:04 UTC (permalink / raw)
To: u-boot
Hi Marek,
On 12/9/20 5:22 PM, Patrick DELAUNAY wrote:
> -----Original Message-----
> From: Marek Vasut <marex@denx.de>
> Sent: mardi 20 octobre 2020 12:21
>
> On 10/16/20 6:32 PM, Patrick DELAUNAY wrote:
>> Hi Marek,
> Hi,
>
> [...]
>
>>>>> On 10/15/20 2:49 PM, Patrick Delaunay wrote:
>>>>>> On some board, the ID pin is not connected so the B session must
>>>>>> be overridden with "u-boot,force_b_session_valid" but the VBus
>>>>>> sensing must continue to be handle.
>>>>>>
>>>>>> To managed it, this patch adds a new DT field
>>>>>> "u-boot,force-vbus-detection" to use with "u-boot,force_b_session_valid"
>>>>> How is this solved in Linux ?
>>>> It is managed by Linux DWC2 driver: it is a real OTG driver, with
>>>> dual mode support and by usb framework
>>>>
>>>> Throught the properties
>>>> &usbotg_hs {
>>>> usb-role-switch;
>>>> };
>>>>
>>>> a glue treat the session and the sensing management see
>>>> linux/drivers/usb/dwc2/drd.c in linux-next
>>>>
>>>> PS: activate_stm_id_vb_detection is also used in driver = hsotg->params.
>>>>
>>>> As ID pin / vbus is completly managed by the USB TYPE driver C
>>>> (STUSB1600 for STMicroelectronics board) and DWC2 driver with dual
>>>> role stack (host/gadget).
>>>>
>>>> I don't found a better solution than device tree property for this
>>>> task in U-Boot as DWC2 driver don't support dual role and U-Boot
>>>> don't have
>>> framework for USB type C controller.
>>>>> btw can you do something about that huge change in indent ? Is it necessary ?
>>>> I move all this code under activate_stm_id_vb_detection (linked to
>>>> compatible "st,stm32mp1-hsotg") to avoid impact on other platform as
>>>> this "sensing" properties are only support for STM32MP15X (it is
>>>> linked to USB block detection integrated in SOC)
>>>>
>>>> And after I need to check the
>>>> 1/ The usb33d-supply is required of vbus or IDPIN sensing 2/ manage
>>>> Vbus sensing or override (according dt) 3/ manage IDPIN or override
>>>> (according dt)
>>>>
>>>> I add a new property to be backward compatible (even it the
>>>> combinaison is less clear) I protect regulator function call to
>>>> avoid compilation
>>> issue for other platform.
>>>> PS: after reading the refmanual, I also split VALOEN and VALOVAL bit
>>>> update
>>> as it is required.
>>>> So yes I think it is needed but I can split the patch to simplify the review.
>>> I presume you don't feel like implementing proper OTG support, right ?
>> Yes, I am afraid of this task.
> Can you take a look ?
>
> I will pick this patch into next for now.
I check this topic, I think I don't need to support OTG in dwc2
but I need to support USB port and connector as it is done in linux kernel.
and I think that I can propose a plan (6 month-1 year)
- Add a new u-class for USB connector based on
linux/drivers/usb/typec/class.c
??? => Allow to detect cable connection and USB mode (device / host)
- Add a new driver for USB type C connector (compatible "usb-c-connector")
- Migrate stusb1600 driver to use this new driver
- Update driver (dwc2 or usbphyc or directly in uclass ?) to use
connector when present in device tree
(devicetree/bindings/connector/usb-connector.yaml)
With these modifcations, I hope to have the same hooks than Linux.
And for future
- Add a USB typeC connector driver based on UCSI
(linux/drivers/usb/typec/ucsi)
https://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/usb-type-c-ucsi-spec.pdf
- Adapt other driver to use USB connector..... (as DWC3 for example to
manage dual role with type-c)
Patrick
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] usb: dwc2: add "u-boot,force-vbus-detection" for stm32
2020-12-09 17:04 ` Patrick DELAUNAY
@ 2020-12-09 17:22 ` Marek Vasut
0 siblings, 0 replies; 9+ messages in thread
From: Marek Vasut @ 2020-12-09 17:22 UTC (permalink / raw)
To: u-boot
On 12/9/20 6:04 PM, Patrick DELAUNAY wrote:
Hi,
[...]
>>>>> I add a new property to be backward compatible (even it the
>>>>> combinaison is less clear) I protect regulator function call to
>>>>> avoid compilation
>>>> issue for other platform.
>>>>> PS: after reading the refmanual, I also split VALOEN and VALOVAL bit
>>>>> update
>>>> as it is required.
>>>>> So yes I think it is needed but I can split the patch to simplify
>>>>> the review.
>>>> I presume you don't feel like implementing proper OTG support, right ?
>>> Yes, I am afraid of this task.
>> Can you take a look ?
>>
>> I will pick this patch into next for now.
>
> I check this topic, I think I don't need to support OTG in dwc2
>
> but I need to support USB port and connector as it is done in linux kernel.
>
> and I think that I can propose a plan (6 month-1 year)
>
> - Add a new u-class for USB connector based on
> linux/drivers/usb/typec/class.c
>
> ??? => Allow to detect cable connection and USB mode (device / host)
>
> - Add a new driver for USB type C connector (compatible "usb-c-connector")
>
> - Migrate stusb1600 driver to use this new driver
>
> - Update driver (dwc2 or usbphyc or directly in uclass ?) to use
> connector when present in device tree
> (devicetree/bindings/connector/usb-connector.yaml)
>
> With these modifcations, I hope to have the same hooks than Linux.
>
>
> And for future
>
> - Add a USB typeC connector driver based on UCSI
> (linux/drivers/usb/typec/ucsi)
>
> https://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/usb-type-c-ucsi-spec.pdf
>
>
> - Adapt other driver to use USB connector..... (as DWC3 for example to
> manage dual role with type-c)
Sounds good, thanks :)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-12-09 17:22 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-15 12:49 [PATCH] usb: dwc2: add "u-boot,force-vbus-detection" for stm32 Patrick Delaunay
2020-10-15 13:07 ` Marek Vasut
2020-10-15 16:52 ` Patrick DELAUNAY
2020-10-15 17:38 ` Marek Vasut
2020-10-16 16:32 ` Patrick DELAUNAY
2020-10-20 10:21 ` Marek Vasut
[not found] ` <6b18d5817aa84b92852d70132c0b7b8c@SFHDAG2NODE3.st.com>
2020-12-09 17:04 ` Patrick DELAUNAY
2020-12-09 17:22 ` Marek Vasut
2020-10-21 11:46 ` Patrice CHOTARD
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.