public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 12/16] usb: dwc2_udc_otg: Add tx_fifo_sz array support
Date: Mon, 8 Apr 2019 23:55:56 +0200	[thread overview]
Message-ID: <20190408235556.38fda453@jawa> (raw)
In-Reply-To: <1553870544-15734-13-git-send-email-patrick.delaunay@st.com>

On Fri, 29 Mar 2019 15:42:20 +0100
Patrick Delaunay <patrick.delaunay@st.com> wrote:

> From: Patrice Chotard <patrice.chotard@st.com>
> 
> All TX fifo size can be different, add tx_fifo_sz_array[]
> into dwc2_plat_otg_data to be able to set them.
> 
> tx_fifo_sz_array[] is 17 Bytes long and can contains max 16
> tx fifo size (synopsys IP supports max 16 IN endpoints).
> First entry of tx_fifo_sz_array[] is the number of valid
> fifo size the array contains.
> 
> In case of tx_fifo_sz_array[] doesn't contains the same
> number of element than max hardware endpoint, display
> a warning message.
> 
> Compatibility with board which doesn't use tx_fifo_sz_array[]
> (Rockchip rk322x/rk3128/rv1108/rk3288/rk3036) is kept.
> 
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
> 
>  drivers/usb/gadget/dwc2_udc_otg.c | 14 ++++++++++++--
>  include/usb/dwc2_udc.h            |  3 +++
>  2 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c
> b/drivers/usb/gadget/dwc2_udc_otg.c index 5c7d131..106dec5 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> @@ -457,6 +457,7 @@ static void reconfig_usbd(struct dwc2_udc *dev)
>  	uint32_t dflt_gusbcfg;
>  	uint32_t rx_fifo_sz, tx_fifo_sz, np_tx_fifo_sz;
>  	u32 max_hw_ep;
> +	int pdata_hw_ep;
>  
>  	debug("Reseting OTG controller\n");
>  
> @@ -542,11 +543,20 @@ static void reconfig_usbd(struct dwc2_udc *dev)
>  	/* retrieve the number of IN Endpoints (excluding ep0) */
>  	max_hw_ep = (readl(&reg->ghwcfg4) & GHWCFG4_NUM_IN_EPS_MASK)
> >> GHWCFG4_NUM_IN_EPS_SHIFT;
> +	pdata_hw_ep = dev->pdata->tx_fifo_sz_nb;
> +
> +	/* tx_fifo_sz_nb should equal to number of IN Endpoint */
> +	if (pdata_hw_ep && max_hw_ep != pdata_hw_ep)
> +		pr_warn("Got %d hw endpoint but %d tx-fifo-size in
> array !!\n",
> +			max_hw_ep, pdata_hw_ep);
> +
> +	for (i = 0; i < max_hw_ep; i++) {
> +		if (pdata_hw_ep)
> +			tx_fifo_sz = dev->pdata->tx_fifo_sz_array[i];
>  
> -	for (i = 0; i < max_hw_ep; i++)
>  		writel((rx_fifo_sz + np_tx_fifo_sz + (tx_fifo_sz *
> i)) | tx_fifo_sz << 16, &reg->dieptxf[i]);
> -
> +	}
>  	/* Flush the RX FIFO */
>  	writel(RX_FIFO_FLUSH, &reg->grstctl);
>  	while (readl(&reg->grstctl) & RX_FIFO_FLUSH)
> diff --git a/include/usb/dwc2_udc.h b/include/usb/dwc2_udc.h
> index 8a426b6..369f6fb 100644
> --- a/include/usb/dwc2_udc.h
> +++ b/include/usb/dwc2_udc.h
> @@ -9,6 +9,7 @@
>  #define __DWC2_USB_GADGET
>  
>  #define PHY0_SLEEP              (1 << 5)
> +#define DWC2_MAX_HW_ENDPOINTS	16
>  
>  struct dwc2_plat_otg_data {
>  	void		*priv;
> @@ -22,6 +23,8 @@ struct dwc2_plat_otg_data {
>  	unsigned int	rx_fifo_sz;
>  	unsigned int	np_tx_fifo_sz;
>  	unsigned int	tx_fifo_sz;
> +	unsigned int	tx_fifo_sz_array[DWC2_MAX_HW_ENDPOINTS];
> +	unsigned char   tx_fifo_sz_nb;
>  	bool		force_b_session_valid;
>  };
>  

Reviewed-by: Lukasz Majewski <lukma@denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190408/5e44c485/attachment.sig>

  reply	other threads:[~2019-04-08 21:55 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-29 14:42 [U-Boot] [PATCH 00/16] usb: convert dwc2 gadget to driver model, used in stm32mp1 Patrick Delaunay
2019-03-29 14:42 ` [U-Boot] [PATCH 01/16] phy: usbphyc: remove unused variable index Patrick Delaunay
2019-03-29 14:42 ` [U-Boot] [PATCH 02/16] phy: usbphyc: update xlate with DT binding Patrick Delaunay
2019-03-29 14:42 ` [U-Boot] [PATCH 03/16] phy: usbphyc: Binding update of vdda supply Patrick Delaunay
2019-03-29 14:42 ` [U-Boot] [PATCH 04/16] phy: usbphyc: move vdda1v1 and vdda1v8 in phy_init Patrick Delaunay
2019-03-29 14:42 ` [U-Boot] [PATCH 05/16] phy: usbphyc: increase PLL wait timeout Patrick Delaunay
2019-03-29 14:42 ` [U-Boot] [PATCH 06/16] usb: dwc2: remove unused variable regs_otg Patrick Delaunay
2019-04-08 21:54   ` Lukasz Majewski
2019-03-29 14:42 ` [U-Boot] [PATCH 07/16] usb: dwc2: convert driver to DM_USB_GADGET Patrick Delaunay
2019-04-08 21:55   ` Lukasz Majewski
2019-03-29 14:42 ` [U-Boot] [PATCH 08/16] usb: dwc2: force reset assert before to probe the driver Patrick Delaunay
2019-04-08 21:55   ` Lukasz Majewski
2019-03-29 14:42 ` [U-Boot] [PATCH 09/16] usb: dwc2: Add force-b-session-valid support Patrick Delaunay
2019-04-08 21:55   ` Lukasz Majewski
2019-03-29 14:42 ` [U-Boot] [PATCH 10/16] usb: dwc2: Add function for session B check Patrick Delaunay
2019-04-08 21:55   ` Lukasz Majewski
2019-03-29 14:42 ` [U-Boot] [PATCH 11/16] usb: dwc2_udc_otg: Read MAX_HW_ENDPOINT from HWCFG4 register Patrick Delaunay
2019-04-08 21:55   ` Lukasz Majewski
2019-03-29 14:42 ` [U-Boot] [PATCH 12/16] usb: dwc2_udc_otg: Add tx_fifo_sz array support Patrick Delaunay
2019-04-08 21:55   ` Lukasz Majewski [this message]
2019-03-29 14:42 ` [U-Boot] [PATCH 13/16] usb: dwc2: add support for STM32MP1 Patrick Delaunay
2019-04-08 21:56   ` Lukasz Majewski
2019-03-29 14:42 ` [U-Boot] [PATCH 14/16] stm32mp1: remove CONFIG_USB_DWC2, HOST support for USBO Patrick Delaunay
2019-03-29 14:42 ` [U-Boot] [PATCH 15/16] stm32mp1: migrate USBOTG device to driver model Patrick Delaunay
2019-03-29 14:42 ` [U-Boot] [PATCH 16/16] stm32mp1: add stusb1600 support for DK1 and DK2 board Patrick Delaunay
2019-04-08 22:04   ` Lukasz Majewski
2019-03-30 11:42 ` [U-Boot] [PATCH 00/16] usb: convert dwc2 gadget to driver model, used in stm32mp1 Jack Mitchell
2019-04-01  9:49   ` Patrick DELAUNAY
2019-04-01 10:38     ` Jack Mitchell
2019-04-01 12:29       ` Patrick DELAUNAY

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=20190408235556.38fda453@jawa \
    --to=lukma@denx.de \
    --cc=u-boot@lists.denx.de \
    /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