From: Ziyuan Xu <xzy.xu@rock-chips.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 2/4] usb: dwc2-otg: adjust fifo size via platform data
Date: Thu, 14 Jul 2016 14:52:33 +0800 [thread overview]
Message-ID: <1468479155-1796-3-git-send-email-xzy.xu@rock-chips.com> (raw)
In-Reply-To: <1468479155-1796-1-git-send-email-xzy.xu@rock-chips.com>
From: Xu Ziyuan <xzy.xu@rock-chips.com>
The total FIFO size of some SoCs may be different from the existen, this
patch supports fifo size setting from platform data.
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
---
Changes in v4:
- Rework fifo size getting and setting
- Update commit message
Changes in v3: None
Changes in v2:
- Update detailed commit message
- Modify the macro's values
drivers/usb/gadget/dwc2_udc_otg.c | 22 ++++++++++++++++------
drivers/usb/gadget/dwc2_udc_otg_regs.h | 6 +++---
include/usb/dwc2_udc.h | 3 +++
3 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index a23278d..029927f 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -403,6 +403,7 @@ static void reconfig_usbd(struct dwc2_udc *dev)
int i;
unsigned int uTemp = writel(CORE_SOFT_RESET, ®->grstctl);
uint32_t dflt_gusbcfg;
+ uint32_t rx_fifo_sz, tx_fifo_sz, np_tx_fifo_sz;
debug("Reseting OTG controller\n");
@@ -467,18 +468,27 @@ static void reconfig_usbd(struct dwc2_udc *dev)
/* 10. Unmask device IN EP common interrupts*/
writel(DIEPMSK_INIT, ®->diepmsk);
+ rx_fifo_sz = RX_FIFO_SIZE;
+ np_tx_fifo_sz = NPTX_FIFO_SIZE;
+ tx_fifo_sz = PTX_FIFO_SIZE;
+
+ if (dev->pdata->rx_fifo_sz)
+ rx_fifo_sz = dev->pdata->rx_fifo_sz;
+ if (dev->pdata->np_tx_fifo_sz)
+ np_tx_fifo_sz = dev->pdata->np_tx_fifo_sz;
+ if (dev->pdata->tx_fifo_sz)
+ tx_fifo_sz = dev->pdata->tx_fifo_sz;
+
/* 11. Set Rx FIFO Size (in 32-bit words) */
- writel(RX_FIFO_SIZE >> 2, ®->grxfsiz);
+ writel(rx_fifo_sz, ®->grxfsiz);
/* 12. Set Non Periodic Tx FIFO Size */
- writel((NPTX_FIFO_SIZE >> 2) << 16 | ((RX_FIFO_SIZE >> 2)) << 0,
+ writel((np_tx_fifo_sz << 16) | rx_fifo_sz,
®->gnptxfsiz);
for (i = 1; i < DWC2_MAX_HW_ENDPOINTS; i++)
- writel((PTX_FIFO_SIZE >> 2) << 16 |
- ((RX_FIFO_SIZE + NPTX_FIFO_SIZE +
- PTX_FIFO_SIZE*(i-1)) >> 2) << 0,
- ®->dieptxf[i-1]);
+ writel((rx_fifo_sz + np_tx_fifo_sz + tx_fifo_sz*(i-1)) |
+ tx_fifo_sz << 16, ®->dieptxf[i-1]);
/* Flush the RX FIFO */
writel(RX_FIFO_FLUSH, ®->grstctl);
diff --git a/drivers/usb/gadget/dwc2_udc_otg_regs.h b/drivers/usb/gadget/dwc2_udc_otg_regs.h
index 78ec90e..c94396a 100644
--- a/drivers/usb/gadget/dwc2_udc_otg_regs.h
+++ b/drivers/usb/gadget/dwc2_udc_otg_regs.h
@@ -130,9 +130,9 @@ struct dwc2_usbotg_reg {
#define HIGH_SPEED_CONTROL_PKT_SIZE 64
#define HIGH_SPEED_BULK_PKT_SIZE 512
-#define RX_FIFO_SIZE (1024*4)
-#define NPTX_FIFO_SIZE (1024*4)
-#define PTX_FIFO_SIZE (1536*1)
+#define RX_FIFO_SIZE (1024)
+#define NPTX_FIFO_SIZE (1024)
+#define PTX_FIFO_SIZE (384)
#define DEPCTL_TXFNUM_0 (0x0<<22)
#define DEPCTL_TXFNUM_1 (0x1<<22)
diff --git a/include/usb/dwc2_udc.h b/include/usb/dwc2_udc.h
index 3ce43f8..7324d8a 100644
--- a/include/usb/dwc2_udc.h
+++ b/include/usb/dwc2_udc.h
@@ -20,6 +20,9 @@ struct dwc2_plat_otg_data {
unsigned int usb_phy_ctrl;
unsigned int usb_flags;
unsigned int usb_gusbcfg;
+ unsigned int rx_fifo_sz;
+ unsigned int np_tx_fifo_sz;
+ unsigned int tx_fifo_sz;
};
int dwc2_udc_probe(struct dwc2_plat_otg_data *pdata);
--
1.9.1
next prev parent reply other threads:[~2016-07-14 6:52 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-14 6:52 [U-Boot] [PATCH v4 0/4] rockchip: rk3288: add fastboot support Ziyuan Xu
2016-07-14 6:52 ` [U-Boot] [PATCH v4 1/4] usb: rockchip-phy: implement USB2.0 phy control Ziyuan Xu
2016-07-15 3:20 ` Simon Glass
2016-07-15 3:56 ` Simon Glass
2016-07-14 6:52 ` Ziyuan Xu [this message]
2016-07-15 3:20 ` [U-Boot] [PATCH v4 2/4] usb: dwc2-otg: adjust fifo size via platform data Simon Glass
2016-07-15 3:56 ` Simon Glass
2016-07-16 5:43 ` Marek Vasut
2016-07-16 20:59 ` Simon Glass
2016-07-14 6:52 ` [U-Boot] [PATCH v4 3/4] rockchip: rk3288: add fastboot support Ziyuan Xu
2016-07-14 11:06 ` William.wu
2016-07-14 15:51 ` Ziyuan Xu
2016-07-14 16:26 ` [U-Boot] [PATCH v4.1 " Ziyuan Xu
2016-07-15 3:20 ` Simon Glass
2016-07-15 14:05 ` Ziyuan Xu
2016-07-15 14:38 ` Simon Glass
2016-07-16 22:31 ` Simon Glass
2016-07-14 6:52 ` [U-Boot] [PATCH v4 4/4] usb: dwc2 : invalidate dcache before starting DMA Ziyuan Xu
2016-07-15 3:20 ` Simon Glass
2016-07-15 3:56 ` Simon Glass
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=1468479155-1796-3-git-send-email-xzy.xu@rock-chips.com \
--to=xzy.xu@rock-chips.com \
--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.