Message ID | 1521203280-20149-1-git-send-email-patrice.chotard@st.com |
---|---|
State | Not Applicable |
Delegated to: | Marek Vasut |
Headers | show |
Series | [U-Boot] usb: dwc2_udc_otg: Add gotgctl customization | expand |
On 03/16/2018 01:27 PM, Patrice Chotard wrote: > Allow passing in a custom configuration of the gotgctl > register via platform data. > This allows for example to override the A/B session valid signals > by setting AvalidOvEn / AvalidOvVal and BvalidOvEn / BvalidOvVal > bits in GOTGCTL reg. If you need to override those, doesn't it mean the device is broken? btw can we start moving this to DT instead ? > Signed-off-by: Patrice Chotard <patrice.chotard@st.com> > --- > > drivers/usb/gadget/dwc2_udc_otg.c | 3 +++ > include/usb/dwc2_udc.h | 1 + > 2 files changed, 4 insertions(+) > > diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c > index 088811c19136..c6c2edf7affa 100644 > --- a/drivers/usb/gadget/dwc2_udc_otg.c > +++ b/drivers/usb/gadget/dwc2_udc_otg.c > @@ -426,6 +426,9 @@ static void reconfig_usbd(struct dwc2_udc *dev) > > writel(dflt_gusbcfg, ®->gusbcfg); > > + if (dev->pdata->usb_gotgctl) > + writel(dev->pdata->usb_gotgctl, ®->gotgctl); > + > /* 3. Put the OTG device core in the disconnected state.*/ > uTemp = readl(®->dctl); > uTemp |= SOFT_DISCONNECT; > diff --git a/include/usb/dwc2_udc.h b/include/usb/dwc2_udc.h > index 1a370e0e86b5..36ab78dfb7e8 100644 > --- a/include/usb/dwc2_udc.h > +++ b/include/usb/dwc2_udc.h > @@ -20,6 +20,7 @@ struct dwc2_plat_otg_data { > unsigned int usb_phy_ctrl; > unsigned int usb_flags; > unsigned int usb_gusbcfg; > + unsigned int usb_gotgctl; > unsigned int rx_fifo_sz; > unsigned int np_tx_fifo_sz; > unsigned int tx_fifo_sz; >
Hi Marek On 03/16/2018 05:28 PM, Marek Vasut wrote: > On 03/16/2018 01:27 PM, Patrice Chotard wrote: >> Allow passing in a custom configuration of the gotgctl >> register via platform data. >> This allows for example to override the A/B session valid signals >> by setting AvalidOvEn / AvalidOvVal and BvalidOvEn / BvalidOvVal >> bits in GOTGCTL reg. > > If you need to override those, doesn't it mean the device is broken? We have a board with a specific wiring. Forcing A/B session valid signals is the solution to make device mode working on this setup. > > btw can we start moving this to DT instead ? Yes for sure, i will send a v2 Thanks Patrice > >> Signed-off-by: Patrice Chotard <patrice.chotard@st.com> >> --- >> >> drivers/usb/gadget/dwc2_udc_otg.c | 3 +++ >> include/usb/dwc2_udc.h | 1 + >> 2 files changed, 4 insertions(+) >> >> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c >> index 088811c19136..c6c2edf7affa 100644 >> --- a/drivers/usb/gadget/dwc2_udc_otg.c >> +++ b/drivers/usb/gadget/dwc2_udc_otg.c >> @@ -426,6 +426,9 @@ static void reconfig_usbd(struct dwc2_udc *dev) >> >> writel(dflt_gusbcfg, ®->gusbcfg); >> >> + if (dev->pdata->usb_gotgctl) >> + writel(dev->pdata->usb_gotgctl, ®->gotgctl); >> + >> /* 3. Put the OTG device core in the disconnected state.*/ >> uTemp = readl(®->dctl); >> uTemp |= SOFT_DISCONNECT; >> diff --git a/include/usb/dwc2_udc.h b/include/usb/dwc2_udc.h >> index 1a370e0e86b5..36ab78dfb7e8 100644 >> --- a/include/usb/dwc2_udc.h >> +++ b/include/usb/dwc2_udc.h >> @@ -20,6 +20,7 @@ struct dwc2_plat_otg_data { >> unsigned int usb_phy_ctrl; >> unsigned int usb_flags; >> unsigned int usb_gusbcfg; >> + unsigned int usb_gotgctl; >> unsigned int rx_fifo_sz; >> unsigned int np_tx_fifo_sz; >> unsigned int tx_fifo_sz; >> > >
On 03/19/2018 09:05 AM, Patrice CHOTARD wrote: > Hi Marek Hi, > On 03/16/2018 05:28 PM, Marek Vasut wrote: >> On 03/16/2018 01:27 PM, Patrice Chotard wrote: >>> Allow passing in a custom configuration of the gotgctl >>> register via platform data. >>> This allows for example to override the A/B session valid signals >>> by setting AvalidOvEn / AvalidOvVal and BvalidOvEn / BvalidOvVal >>> bits in GOTGCTL reg. >> >> If you need to override those, doesn't it mean the device is broken? > > We have a board with a specific wiring. Forcing A/B session valid > signals is the solution to make device mode working on this setup. Meaning your OTG ID detection is broken, right ? >> btw can we start moving this to DT instead ? > > Yes for sure, i will send a v2 Thanks
Hi Marek On 03/19/2018 10:52 AM, Marek Vasut wrote: > On 03/19/2018 09:05 AM, Patrice CHOTARD wrote: >> Hi Marek > > Hi, > >> On 03/16/2018 05:28 PM, Marek Vasut wrote: >>> On 03/16/2018 01:27 PM, Patrice Chotard wrote: >>>> Allow passing in a custom configuration of the gotgctl >>>> register via platform data. >>>> This allows for example to override the A/B session valid signals >>>> by setting AvalidOvEn / AvalidOvVal and BvalidOvEn / BvalidOvVal >>>> bits in GOTGCTL reg. >>> >>> If you need to override those, doesn't it mean the device is broken? >> >> We have a board with a specific wiring. Forcing A/B session valid >> signals is the solution to make device mode working on this setup. > > Meaning your OTG ID detection is broken, right ? Right > >>> btw can we start moving this to DT instead ? >> >> Yes for sure, i will send a v2 I got a look at this point, but unfortunately dwc2_udc_otg.c is not converted to DM/DT. I will try to propose a DM/DT transition patch for this driver by keeping compatibility with current usage by all platforms. Patrice > Thanks >
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c index 088811c19136..c6c2edf7affa 100644 --- a/drivers/usb/gadget/dwc2_udc_otg.c +++ b/drivers/usb/gadget/dwc2_udc_otg.c @@ -426,6 +426,9 @@ static void reconfig_usbd(struct dwc2_udc *dev) writel(dflt_gusbcfg, ®->gusbcfg); + if (dev->pdata->usb_gotgctl) + writel(dev->pdata->usb_gotgctl, ®->gotgctl); + /* 3. Put the OTG device core in the disconnected state.*/ uTemp = readl(®->dctl); uTemp |= SOFT_DISCONNECT; diff --git a/include/usb/dwc2_udc.h b/include/usb/dwc2_udc.h index 1a370e0e86b5..36ab78dfb7e8 100644 --- a/include/usb/dwc2_udc.h +++ b/include/usb/dwc2_udc.h @@ -20,6 +20,7 @@ struct dwc2_plat_otg_data { unsigned int usb_phy_ctrl; unsigned int usb_flags; unsigned int usb_gusbcfg; + unsigned int usb_gotgctl; unsigned int rx_fifo_sz; unsigned int np_tx_fifo_sz; unsigned int tx_fifo_sz;
Allow passing in a custom configuration of the gotgctl register via platform data. This allows for example to override the A/B session valid signals by setting AvalidOvEn / AvalidOvVal and BvalidOvEn / BvalidOvVal bits in GOTGCTL reg. Signed-off-by: Patrice Chotard <patrice.chotard@st.com> --- drivers/usb/gadget/dwc2_udc_otg.c | 3 +++ include/usb/dwc2_udc.h | 1 + 2 files changed, 4 insertions(+)