diff mbox series

[U-Boot,v2,1/3] usb: dwc2: correctly handle binding for g-tx-fifo-size

Message ID 1560869838-22025-1-git-send-email-patrick.delaunay@st.com
State Accepted
Commit 7350a75b517b6162c8f832a9ead09b9e26e8068f
Delegated to: Patrice Chotard
Headers show
Series [U-Boot,v2,1/3] usb: dwc2: correctly handle binding for g-tx-fifo-size | expand

Commit Message

Patrick DELAUNAY June 18, 2019, 2:57 p.m. UTC
Manage g-tx-fifo-size as a array as specify in the binding.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v2:
- move dt update in a separate patch
- remove unecessary temporary variable

 drivers/usb/gadget/dwc2_udc_otg.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Marek Vasut June 18, 2019, 4:46 p.m. UTC | #1
On 6/18/19 4:57 PM, Patrick Delaunay wrote:
> Manage g-tx-fifo-size as a array as specify in the binding.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>

Reviewed-by: Marek Vasut <marex@denx.de>

I'm missing 2/3 , although I think it might be better if you take this
whole series through u-boot-stm .

> ---
> 
> Changes in v2:
> - move dt update in a separate patch
> - remove unecessary temporary variable
> 
>  drivers/usb/gadget/dwc2_udc_otg.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
> index 494ab53..023439c 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> @@ -1039,6 +1039,7 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
>  	int node = dev_of_offset(dev);
>  	ulong drvdata;
>  	void (*set_params)(struct dwc2_plat_otg_data *data);
> +	int ret;
>  
>  	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL) {
>  		dev_dbg(dev, "Invalid mode\n");
> @@ -1050,7 +1051,18 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
>  	platdata->rx_fifo_sz = dev_read_u32_default(dev, "g-rx-fifo-size", 0);
>  	platdata->np_tx_fifo_sz = dev_read_u32_default(dev,
>  						       "g-np-tx-fifo-size", 0);
> -	platdata->tx_fifo_sz = dev_read_u32_default(dev, "g-tx-fifo-size", 0);
> +
> +	platdata->tx_fifo_sz_nb =
> +		dev_read_size(dev, "g-tx-fifo-size") / sizeof(u32);
> +	if (platdata->tx_fifo_sz_nb > DWC2_MAX_HW_ENDPOINTS)
> +		platdata->tx_fifo_sz_nb = DWC2_MAX_HW_ENDPOINTS;
> +	if (platdata->tx_fifo_sz_nb) {
> +		ret = dev_read_u32_array(dev, "g-tx-fifo-size",
> +					 platdata->tx_fifo_sz_array,
> +					 platdata->tx_fifo_sz_nb);
> +		if (ret)
> +			return ret;
> +	}
>  
>  	platdata->force_b_session_valid =
>  		dev_read_bool(dev, "u-boot,force-b-session-valid");
>
Patrick DELAUNAY June 19, 2019, 2:50 p.m. UTC | #2
Hi Marek,

> From: Marek Vasut <marex@denx.de>
> Sent: mardi 18 juin 2019 18:46
> 
> On 6/18/19 4:57 PM, Patrick Delaunay wrote:
> > Manage g-tx-fifo-size as a array as specify in the binding.
> >
> > Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> 
> Reviewed-by: Marek Vasut <marex@denx.de>
> 
> I'm missing 2/3 , although I think it might be better if you take this whole series
> through u-boot-stm .

Ok thanks,

We (Patrice or me) we will take the serie on u-boot-stm.

> > ---
> >
> > Changes in v2:
> > - move dt update in a separate patch
> > - remove unecessary temporary variable
> >
> >  drivers/usb/gadget/dwc2_udc_otg.c | 14 +++++++++++++-
> >  1 file changed, 13 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/gadget/dwc2_udc_otg.c
> > b/drivers/usb/gadget/dwc2_udc_otg.c
> > index 494ab53..023439c 100644
> > --- a/drivers/usb/gadget/dwc2_udc_otg.c
> > +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> > @@ -1039,6 +1039,7 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct
> udevice *dev)
> >  	int node = dev_of_offset(dev);
> >  	ulong drvdata;
> >  	void (*set_params)(struct dwc2_plat_otg_data *data);
> > +	int ret;
> >
> >  	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL) {
> >  		dev_dbg(dev, "Invalid mode\n");
> > @@ -1050,7 +1051,18 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct
> udevice *dev)
> >  	platdata->rx_fifo_sz = dev_read_u32_default(dev, "g-rx-fifo-size", 0);
> >  	platdata->np_tx_fifo_sz = dev_read_u32_default(dev,
> >  						       "g-np-tx-fifo-size", 0);
> > -	platdata->tx_fifo_sz = dev_read_u32_default(dev, "g-tx-fifo-size", 0);
> > +
> > +	platdata->tx_fifo_sz_nb =
> > +		dev_read_size(dev, "g-tx-fifo-size") / sizeof(u32);
> > +	if (platdata->tx_fifo_sz_nb > DWC2_MAX_HW_ENDPOINTS)
> > +		platdata->tx_fifo_sz_nb = DWC2_MAX_HW_ENDPOINTS;
> > +	if (platdata->tx_fifo_sz_nb) {
> > +		ret = dev_read_u32_array(dev, "g-tx-fifo-size",
> > +					 platdata->tx_fifo_sz_array,
> > +					 platdata->tx_fifo_sz_nb);
> > +		if (ret)
> > +			return ret;
> > +	}
> >
> >  	platdata->force_b_session_valid =
> >  		dev_read_bool(dev, "u-boot,force-b-session-valid");
> >
> 
> 
> --
> Best regards,
> Marek Vasut
Patrice CHOTARD June 19, 2019, 3:01 p.m. UTC | #3
Hi Patrick

On 6/18/19 6:46 PM, Marek Vasut wrote:
> On 6/18/19 4:57 PM, Patrick Delaunay wrote:
>> Manage g-tx-fifo-size as a array as specify in the binding.
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> Reviewed-by: Marek Vasut <marex@denx.de>
>
> I'm missing 2/3 , although I think it might be better if you take this
> whole series through u-boot-stm .

Applied to uboot-stm

Thanks


>> ---
>>
>> Changes in v2:
>> - move dt update in a separate patch
>> - remove unecessary temporary variable
>>
>>  drivers/usb/gadget/dwc2_udc_otg.c | 14 +++++++++++++-
>>  1 file changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
>> index 494ab53..023439c 100644
>> --- a/drivers/usb/gadget/dwc2_udc_otg.c
>> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
>> @@ -1039,6 +1039,7 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
>>  	int node = dev_of_offset(dev);
>>  	ulong drvdata;
>>  	void (*set_params)(struct dwc2_plat_otg_data *data);
>> +	int ret;
>>  
>>  	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL) {
>>  		dev_dbg(dev, "Invalid mode\n");
>> @@ -1050,7 +1051,18 @@ static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
>>  	platdata->rx_fifo_sz = dev_read_u32_default(dev, "g-rx-fifo-size", 0);
>>  	platdata->np_tx_fifo_sz = dev_read_u32_default(dev,
>>  						       "g-np-tx-fifo-size", 0);
>> -	platdata->tx_fifo_sz = dev_read_u32_default(dev, "g-tx-fifo-size", 0);
>> +
>> +	platdata->tx_fifo_sz_nb =
>> +		dev_read_size(dev, "g-tx-fifo-size") / sizeof(u32);
>> +	if (platdata->tx_fifo_sz_nb > DWC2_MAX_HW_ENDPOINTS)
>> +		platdata->tx_fifo_sz_nb = DWC2_MAX_HW_ENDPOINTS;
>> +	if (platdata->tx_fifo_sz_nb) {
>> +		ret = dev_read_u32_array(dev, "g-tx-fifo-size",
>> +					 platdata->tx_fifo_sz_array,
>> +					 platdata->tx_fifo_sz_nb);
>> +		if (ret)
>> +			return ret;
>> +	}
>>  
>>  	platdata->force_b_session_valid =
>>  		dev_read_bool(dev, "u-boot,force-b-session-valid");
>>
>
diff mbox series

Patch

diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index 494ab53..023439c 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -1039,6 +1039,7 @@  static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 	int node = dev_of_offset(dev);
 	ulong drvdata;
 	void (*set_params)(struct dwc2_plat_otg_data *data);
+	int ret;
 
 	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL) {
 		dev_dbg(dev, "Invalid mode\n");
@@ -1050,7 +1051,18 @@  static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 	platdata->rx_fifo_sz = dev_read_u32_default(dev, "g-rx-fifo-size", 0);
 	platdata->np_tx_fifo_sz = dev_read_u32_default(dev,
 						       "g-np-tx-fifo-size", 0);
-	platdata->tx_fifo_sz = dev_read_u32_default(dev, "g-tx-fifo-size", 0);
+
+	platdata->tx_fifo_sz_nb =
+		dev_read_size(dev, "g-tx-fifo-size") / sizeof(u32);
+	if (platdata->tx_fifo_sz_nb > DWC2_MAX_HW_ENDPOINTS)
+		platdata->tx_fifo_sz_nb = DWC2_MAX_HW_ENDPOINTS;
+	if (platdata->tx_fifo_sz_nb) {
+		ret = dev_read_u32_array(dev, "g-tx-fifo-size",
+					 platdata->tx_fifo_sz_array,
+					 platdata->tx_fifo_sz_nb);
+		if (ret)
+			return ret;
+	}
 
 	platdata->force_b_session_valid =
 		dev_read_bool(dev, "u-boot,force-b-session-valid");