public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: John.Youn@synopsys.com (John Youn)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 RFC 2/6] usb: dwc2: Add DT properties to specify fifo size in host/otg mode
Date: Thu, 18 Aug 2016 11:12:42 -0700	[thread overview]
Message-ID: <4db23ecb-e35c-e70a-e6ed-f3bbb5f7f1a2@synopsys.com> (raw)
In-Reply-To: <1469559213-16160-3-git-send-email-stefan.wahren@i2se.com>

On 7/26/2016 11:54 AM, Stefan Wahren wrote:
> Currently the fifo sizes for host/otg mode are defined per platform
> and doesn't take the mode into account. So we will get errors
> like this:
> 
> dwc2 20980000.usb: 256 invalid for host_nperio_tx_fifo_size.
> dwc2 20980000.usb: Setting host_nperio_tx_fifo_size to 32
> 
> So add DT properties for these mode specific fifo sizes in order
> to define them in the devicetree and avoid these errors.
> 
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
>  Documentation/devicetree/bindings/usb/dwc2.txt |    3 +++
>  drivers/usb/dwc2/core.c                        |   25 ++++++++++++++++++------
>  2 files changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt b/Documentation/devicetree/bindings/usb/dwc2.txt
> index 20a68bf..298bac1 100644
> --- a/Documentation/devicetree/bindings/usb/dwc2.txt
> +++ b/Documentation/devicetree/bindings/usb/dwc2.txt
> @@ -27,6 +27,9 @@ Refer to phy/phy-bindings.txt for generic phy consumer properties
>  - g-rx-fifo-size: size of rx fifo size in gadget mode.
>  - g-np-tx-fifo-size: size of non-periodic tx fifo size in gadget mode.
>  - g-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0) in gadget mode.
> +- h-rx-fifo-size: size of rx fifo size in host / otg mode.
> +- h-np-tx-fifo-size: size of non-periodic tx fifo size in host / otg mode.
> +- h-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0) in host / otg mode.
>  
>  Example:
>  
> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
> index 5645528..5dffc6e 100644
> --- a/drivers/usb/dwc2/core.c
> +++ b/drivers/usb/dwc2/core.c
> @@ -47,6 +47,7 @@
>  #include <linux/dma-mapping.h>
>  #include <linux/delay.h>
>  #include <linux/io.h>
> +#include <linux/of.h>
>  #include <linux/slab.h>
>  #include <linux/usb.h>
>  
> @@ -1289,6 +1290,9 @@ static void dwc2_set_param_hibernation(struct dwc2_hsotg *hsotg,
>  void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
>  			 const struct dwc2_core_params *params)
>  {
> +	struct device_node *np = hsotg->dev->of_node;
> +	u32 val = 0;
> +
>  	dev_dbg(hsotg->dev, "%s()\n", __func__);
>  
>  	dwc2_set_param_otg_cap(hsotg, params->otg_cap);
> @@ -1299,12 +1303,6 @@ void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
>  			params->host_support_fs_ls_low_power);
>  	dwc2_set_param_enable_dynamic_fifo(hsotg,
>  			params->enable_dynamic_fifo);
> -	dwc2_set_param_host_rx_fifo_size(hsotg,
> -			params->host_rx_fifo_size);
> -	dwc2_set_param_host_nperio_tx_fifo_size(hsotg,
> -			params->host_nperio_tx_fifo_size);
> -	dwc2_set_param_host_perio_tx_fifo_size(hsotg,
> -			params->host_perio_tx_fifo_size);
>  	dwc2_set_param_max_transfer_size(hsotg,
>  			params->max_transfer_size);
>  	dwc2_set_param_max_packet_count(hsotg,
> @@ -1329,6 +1327,21 @@ void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
>  	dwc2_set_param_uframe_sched(hsotg, params->uframe_sched);
>  	dwc2_set_param_external_id_pin_ctl(hsotg, params->external_id_pin_ctl);
>  	dwc2_set_param_hibernation(hsotg, params->hibernation);
> +
> +	if (!IS_ENABLED(CONFIG_OF) ||
> +	    of_property_read_u32(np, "h-rx-fifo-size", &val))
> +		val = params->host_rx_fifo_size;
> +	dwc2_set_param_host_rx_fifo_size(hsotg, val);
> +
> +	if (!IS_ENABLED(CONFIG_OF) ||
> +	    of_property_read_u32(np, "h-np-tx-fifo-size", &val))
> +		val = params->host_nperio_tx_fifo_size;
> +	dwc2_set_param_host_nperio_tx_fifo_size(hsotg, val);
> +
> +	if (!IS_ENABLED(CONFIG_OF) ||
> +	    of_property_read_u32(np, "h-tx-fifo-size", &val))
> +		val = params->host_perio_tx_fifo_size;
> +	dwc2_set_param_host_perio_tx_fifo_size(hsotg, val);
>  }
>  
>  /*
> 

You should be able to use "device_property_read" as in the dwc3
driver. I know gadget.c currently uses of_property_read but we have
already made this change internally. This will allow us to set these
for PCI based devices, and also you won't need the CONFIG_OF check.

Regards,
John

  parent reply	other threads:[~2016-08-18 18:12 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-26 18:53 [PATCH V2 RFC 0/6] ARM: dts: bcm2835: Add Raspberry Pi Zero Stefan Wahren
2016-07-26 18:53 ` [PATCH V2 RFC 1/6] usb: dwc2: core: Avoid nonsense error in gadget mode Stefan Wahren
2016-08-16  1:30   ` John Youn
2016-08-16 16:22     ` Eric Anholt
2016-08-16 16:44     ` Stefan Wahren
2016-08-16 19:20       ` John Youn
2016-08-16 20:09         ` Stefan Wahren
2016-07-26 18:53 ` [PATCH V2 RFC 2/6] usb: dwc2: Add DT properties to specify fifo size in host/otg mode Stefan Wahren
2016-07-29 21:12   ` Rob Herring
2016-08-18 18:12   ` John Youn [this message]
2016-07-26 18:53 ` [PATCH V2 RFC 3/6] ARM: dts: bcm283x: Add missing usb clock Stefan Wahren
2016-07-26 18:53 ` [PATCH V2 RFC 4/6] ARM: dts: bcm283x: Add generic USB PHY Stefan Wahren
2016-07-26 18:53 ` [PATCH V2 RFC 5/6] DT: bindings: bcm: Add Raspberry Pi Zero Stefan Wahren
2016-07-29 21:13   ` Rob Herring
2016-07-26 18:53 ` [PATCH V2 RFC 6/6] ARM: dts: bcm2835: " Stefan Wahren
2016-08-02 17:19   ` Stephen Warren
2016-08-02 19:29     ` Stefan Wahren
2016-08-02 20:56       ` Stephen Warren
2016-08-16 19:30   ` John Youn
2016-08-16 19:58     ` Stefan Wahren
2016-08-16 22:07       ` John Youn
2016-08-17 19:11         ` Stefan Wahren
2016-08-17 21:21           ` John Youn
2016-08-17 22:17             ` Stefan Wahren
2016-08-18 18:03               ` John Youn
2016-08-18 19:04                 ` Stefan Wahren
2016-08-18 19:34                   ` John Youn
2016-08-18 18:14 ` [PATCH V2 RFC 0/6] " Eric Anholt
2016-08-18 18:57   ` Stefan Wahren
2016-08-19  0:37     ` Eric Anholt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4db23ecb-e35c-e70a-e6ed-f3bbb5f7f1a2@synopsys.com \
    --to=john.youn@synopsys.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox