From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 11/16] usb: dwc2_udc_otg: Read MAX_HW_ENDPOINT from HWCFG4 register
Date: Mon, 8 Apr 2019 23:55:48 +0200 [thread overview]
Message-ID: <20190408235548.1c4346cf@jawa> (raw)
In-Reply-To: <1553870544-15734-12-git-send-email-patrick.delaunay@st.com>
On Fri, 29 Mar 2019 15:42:19 +0100
Patrick Delaunay <patrick.delaunay@st.com> wrote:
> Some DWC2 ip variant doesn't use 16 hardware endpoint as hardcoded
> in the driver. Bits INEps [29:26] of HWCFG4 register allows to get
> this information.
>
> 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 | 11 ++++++++---
> drivers/usb/gadget/dwc2_udc_otg_priv.h | 1 -
> drivers/usb/gadget/dwc2_udc_otg_regs.h | 17 ++++++++++++-----
> 3 files changed, 20 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c
> b/drivers/usb/gadget/dwc2_udc_otg.c index b1efad1..5c7d131 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> @@ -456,6 +456,7 @@ static void reconfig_usbd(struct dwc2_udc *dev)
> unsigned int uTemp = writel(CORE_SOFT_RESET, ®->grstctl);
> uint32_t dflt_gusbcfg;
> uint32_t rx_fifo_sz, tx_fifo_sz, np_tx_fifo_sz;
> + u32 max_hw_ep;
>
> debug("Reseting OTG controller\n");
>
> @@ -538,9 +539,13 @@ static void reconfig_usbd(struct dwc2_udc *dev)
> writel((np_tx_fifo_sz << 16) | rx_fifo_sz,
> ®->gnptxfsiz);
>
> - for (i = 1; i < DWC2_MAX_HW_ENDPOINTS; i++)
> - writel((rx_fifo_sz + np_tx_fifo_sz +
> tx_fifo_sz*(i-1)) |
> - tx_fifo_sz << 16, ®->dieptxf[i-1]);
> + /* retrieve the number of IN Endpoints (excluding ep0) */
> + max_hw_ep = (readl(®->ghwcfg4) & GHWCFG4_NUM_IN_EPS_MASK)
> >>
> + GHWCFG4_NUM_IN_EPS_SHIFT;
> +
> + for (i = 0; i < max_hw_ep; i++)
> + writel((rx_fifo_sz + np_tx_fifo_sz + (tx_fifo_sz *
> i)) |
> + tx_fifo_sz << 16, ®->dieptxf[i]);
>
> /* Flush the RX FIFO */
> writel(RX_FIFO_FLUSH, ®->grstctl);
> diff --git a/drivers/usb/gadget/dwc2_udc_otg_priv.h
> b/drivers/usb/gadget/dwc2_udc_otg_priv.h index aaa9018..e72b22a 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg_priv.h
> +++ b/drivers/usb/gadget/dwc2_udc_otg_priv.h
> @@ -23,7 +23,6 @@
> #define EP_FIFO_SIZE2 1024
> /* ep0-control, ep1in-bulk, ep2out-bulk, ep3in-int */
> #define DWC2_MAX_ENDPOINTS 4
> -#define DWC2_MAX_HW_ENDPOINTS 16
>
> #define WAIT_FOR_SETUP 0
> #define DATA_STATE_XMIT 1
> diff --git a/drivers/usb/gadget/dwc2_udc_otg_regs.h
> b/drivers/usb/gadget/dwc2_udc_otg_regs.h index 0aee4ee..a389923 100644
> --- a/drivers/usb/gadget/dwc2_udc_otg_regs.h
> +++ b/drivers/usb/gadget/dwc2_udc_otg_regs.h
> @@ -60,22 +60,25 @@ struct dwc2_usbotg_reg {
> u32 grxstsp; /* Receive Status Debug Pop/Status Pop */
> u32 grxfsiz; /* Receive FIFO Size */
> u32 gnptxfsiz; /* Non-Periodic Transmit FIFO Size */
> - u8 res1[216];
> +
> + u8 res1[36];
> + u32 ghwcfg4; /* User HW Config4 */
> + u8 res2[176];
> u32 dieptxf[15]; /* Device Periodic Transmit FIFO size
> register */
> - u8 res2[1728];
> + u8 res3[1728];
> /* Device Configuration */
> u32 dcfg; /* Device Configuration Register */
> u32 dctl; /* Device Control */
> u32 dsts; /* Device Status */
> - u8 res3[4];
> + u8 res4[4];
> u32 diepmsk; /* Device IN Endpoint Common Interrupt Mask */
> u32 doepmsk; /* Device OUT Endpoint Common Interrupt Mask */
> u32 daint; /* Device All Endpoints Interrupt */
> u32 daintmsk; /* Device All Endpoints Interrupt Mask */
> - u8 res4[224];
> + u8 res5[224];
> struct dwc2_dev_in_endp in_endp[16];
> struct dwc2_dev_out_endp out_endp[16];
> - u8 res5[768];
> + u8 res6[768];
> struct ep_fifo ep[16];
> };
>
> @@ -273,4 +276,8 @@ struct dwc2_usbotg_reg {
> /* Device ALL Endpoints Interrupt Register (DAINT) */
> #define DAINT_IN_EP_INT(x) (x << 0)
> #define DAINT_OUT_EP_INT(x) (x << 16)
> +
> +/* User HW Config4 */
> +#define GHWCFG4_NUM_IN_EPS_MASK (0xf << 26)
> +#define GHWCFG4_NUM_IN_EPS_SHIFT 26
> #endif
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/dfb54d83/attachment.sig>
next prev parent 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 [this message]
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
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=20190408235548.1c4346cf@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