All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/3] usb: dwc2_udc_otg: add bcm2835 SoC (Raspberry Pi4) support
Date: Mon, 16 Sep 2019 23:40:08 +0200	[thread overview]
Message-ID: <20190916234008.097184b5@jawa> (raw)
In-Reply-To: <20190916122417.27520-3-m.szyprowski@samsung.com>

Hi Marek,

> Broadcom 2835 SoC requires special conversion of physical memory
> addresses for DMA purpose, so add needed wrappers to dwc2_udc_otg
> driver. Also extend the list of compatible devices with
> 'brcm,bcm2835-usb' entry. This allows to use USB gadget drivers (i.e.
> DFU) on Raspberry Pi4 boards.
> 
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>  drivers/usb/gadget/dwc2_udc_otg.c          |  2 ++
>  drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c | 12 ++++++------
>  2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/gadget/dwc2_udc_otg.c
> b/drivers/usb/gadget/dwc2_udc_otg.c index 35f4147840e..49f342eb211
> 100644 --- a/drivers/usb/gadget/dwc2_udc_otg.c
> +++ b/drivers/usb/gadget/dwc2_udc_otg.c
> @@ -31,6 +31,7 @@
>  #include <linux/usb/otg.h>
>  #include <linux/usb/gadget.h>
>  
> +#include <phys2bus.h>
>  #include <asm/byteorder.h>
>  #include <asm/unaligned.h>
>  #include <asm/io.h>
> @@ -1213,6 +1214,7 @@ static int dwc2_udc_otg_remove(struct udevice
> *dev) 
>  static const struct udevice_id dwc2_udc_otg_ids[] = {
>  	{ .compatible = "snps,dwc2" },
> +	{ .compatible = "brcm,bcm2835-usb" },
>  	{ .compatible = "st,stm32mp1-hsotg",
>  	  .data = (ulong)dwc2_set_stm32mp1_hsotg_params },
>  	{},
> diff --git a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c
> b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c index
> 7eb632d3b14..5e695b4ff2a 100644 ---
> a/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c +++
> b/drivers/usb/gadget/dwc2_udc_otg_xfer_dma.c @@ -28,7 +28,7 @@ static
> inline void dwc2_udc_ep0_zlp(struct dwc2_udc *dev) {
>  	u32 ep_ctrl;
>  
> -	writel(usb_ctrl_dma_addr, &reg->in_endp[EP0_CON].diepdma);
> +	writel(phys_to_bus((unsigned long)usb_ctrl_dma_addr),
> &reg->in_endp[EP0_CON].diepdma); writel(DIEPT_SIZ_PKT_CNT(1),
> &reg->in_endp[EP0_CON].dieptsiz); 
>  	ep_ctrl = readl(&reg->in_endp[EP0_CON].diepctl);
> @@ -49,7 +49,7 @@ static void dwc2_udc_pre_setup(void)
>  
>  	writel(DOEPT_SIZ_PKT_CNT(1) | sizeof(struct usb_ctrlrequest),
>  	       &reg->out_endp[EP0_CON].doeptsiz);
> -	writel(usb_ctrl_dma_addr, &reg->out_endp[EP0_CON].doepdma);
> +	writel(phys_to_bus((unsigned long)usb_ctrl_dma_addr),
> &reg->out_endp[EP0_CON].doepdma); 
>  	ep_ctrl = readl(&reg->out_endp[EP0_CON].doepctl);
>  	writel(ep_ctrl|DEPCTL_EPENA,
> &reg->out_endp[EP0_CON].doepctl); @@ -75,7 +75,7 @@ static inline
> void dwc2_ep0_complete_out(void) 
>  	writel(DOEPT_SIZ_PKT_CNT(1) | sizeof(struct usb_ctrlrequest),
>  	       &reg->out_endp[EP0_CON].doeptsiz);
> -	writel(usb_ctrl_dma_addr, &reg->out_endp[EP0_CON].doepdma);
> +	writel(phys_to_bus((unsigned long)usb_ctrl_dma_addr),
> &reg->out_endp[EP0_CON].doepdma); 
>  	ep_ctrl = readl(&reg->out_endp[EP0_CON].doepctl);
>  	writel(ep_ctrl|DEPCTL_EPENA|DEPCTL_CNAK,
> @@ -113,7 +113,7 @@ static int setdma_rx(struct dwc2_ep *ep, struct
> dwc2_request *req) (unsigned long) ep->dma_buf +
>  				ROUND(ep->len,
> CONFIG_SYS_CACHELINE_SIZE)); 
> -	writel((unsigned long) ep->dma_buf,
> &reg->out_endp[ep_num].doepdma);
> +	writel(phys_to_bus((unsigned long)ep->dma_buf),
> &reg->out_endp[ep_num].doepdma); writel(DOEPT_SIZ_PKT_CNT(pktcnt) |
> DOEPT_SIZ_XFER_SIZE(length), &reg->out_endp[ep_num].doeptsiz);
>  	writel(DEPCTL_EPENA|DEPCTL_CNAK|ctrl,
> &reg->out_endp[ep_num].doepctl); @@ -161,7 +161,7 @@ static int
> setdma_tx(struct dwc2_ep *ep, struct dwc2_request *req) while
> (readl(&reg->grstctl) & TX_FIFO_FLUSH) ;
>  
> -	writel((unsigned long) ep->dma_buf,
> &reg->in_endp[ep_num].diepdma);
> +	writel(phys_to_bus((unsigned long)ep->dma_buf),
> &reg->in_endp[ep_num].diepdma); writel(DIEPT_SIZ_PKT_CNT(pktcnt) |
> DIEPT_SIZ_XFER_SIZE(length), &reg->in_endp[ep_num].dieptsiz);
>  
> @@ -921,7 +921,7 @@ static int dwc2_udc_get_status(struct dwc2_udc
> *dev, (unsigned long) usb_ctrl +
>  			   ROUND(sizeof(g_status),
> CONFIG_SYS_CACHELINE_SIZE)); 
> -	writel(usb_ctrl_dma_addr, &reg->in_endp[EP0_CON].diepdma);
> +	writel(phys_to_bus(usb_ctrl_dma_addr),
> &reg->in_endp[EP0_CON].diepdma); writel(DIEPT_SIZ_PKT_CNT(1) |
> DIEPT_SIZ_XFER_SIZE(2), &reg->in_endp[EP0_CON].dieptsiz);
>  

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/20190916/1a9e3a65/attachment.sig>

  reply	other threads:[~2019-09-16 21:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190916122430eucas1p164f3467e5ad5981c01bde6376ec51a27@eucas1p1.samsung.com>
2019-09-16 12:24 ` [U-Boot] [PATCH 0/3] Raspberry Pi4: add support for DFU over USB Marek Szyprowski
2019-09-16 12:24   ` [U-Boot] [PATCH 1/3] fat: write: fix broken write to fragmented files Marek Szyprowski
2019-09-16 13:18     ` Oleksandr Suvorov
2019-09-16 21:38     ` Lukasz Majewski
2019-09-16 12:24   ` [U-Boot] [PATCH 2/3] usb: dwc2_udc_otg: add bcm2835 SoC (Raspberry Pi4) support Marek Szyprowski
2019-09-16 21:40     ` Lukasz Majewski [this message]
2019-09-16 12:24   ` [U-Boot] [PATCH 3/3] config: enable DFU over USB on Raspberry Pi4 boards Marek Szyprowski
2019-09-16 12:45     ` Matthias Brugger
2019-09-16 12:53       ` Marek Szyprowski
2019-09-16 16:18         ` Jonathan Gray
2019-09-17  5:41           ` Marek Szyprowski
2019-09-16 21:41     ` Lukasz Majewski

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=20190916234008.097184b5@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.