usb: zynqmp: Add XHCI driver support
Subsystems (3)
PATCH v5 1/2 usb: zynqmp: Add XHCI driver support
From: Siva Durga Prasad Paladugu <[email protected]>
Added USB XHCI driver support for zynqmp.
---
Changes for v5:
- Removed __board_usb_init() as per
review comment
Changes for v4:
- Added sanity check for index as per
review comment
Changes for v3:
- Decreased the phy reset delay to 10 micro secs
- Defined base addresses in board config file as
per review comment.
Changes for v2:
- Moved all from xhci-zynqmp.h to .c file as
per review comment
- Removed ad-hoc function zynqmp_xhci_core_exit()
as per review comment
--- drivers/usb/host/Makefile | 1 + drivers/usb/host/xhci-zynqmp.c | 143 ++++++++++++++++++++++++++++++++++++ include/configs/xilinx_zynqmp_ep.h | 2 + 3 files changed, 146 insertions(+), 0 deletions(-) create mode 100644 drivers/usb/host/xhci-zynqmp.c
drivers/usb/host/Makefile +1 -0
@@ -54,6 +54,7 @@ obj-$(CONFIG_USB_EHCI_ZYNQ) += ehci-zynq.o # xhci obj-$(CONFIG_USB_XHCI) += xhci.o xhci-mem.o xhci-ring.o obj-$(CONFIG_USB_XHCI_DWC3) += xhci-dwc3.o +obj-$(CONFIG_USB_XHCI_ZYNQMP) += xhci-zynqmp.o obj-$(CONFIG_USB_XHCI_KEYSTONE) += xhci-keystone.o obj-$(CONFIG_USB_XHCI_EXYNOS) += xhci-exynos5.o obj-$(CONFIG_USB_XHCI_FSL) += xhci-fsl.o
drivers/usb/host/xhci-zynqmp.c new file +143 -0
143 lines not on this page · raw message
include/configs/xilinx_zynqmp_ep.h +2 -0
@@ -23,6 +23,8 @@#define CONFIG_SYS_I2C_ZYNQ #define CONFIG_ZYNQ_EEPROM #define CONFIG_AHCI +#define CONFIG_ZYNQMP_XHCI_LIST {ZYNQMP_USB0_XHCI_BASEADDR, \ + ZYNQMP_USB1_XHCI_BASEADDR}#include <configs/xilinx_zynqmp.h>
Signature · 1 line
1.7.1
PATCH v5 2/2 usb: zynqmp: Enable USB XHCI support
From: Siva Durga Prasad Paladugu <[email protected]>
Enable USB XHCI support for ZynqMP
---
Changes for v5:
- None
Changes for v4:
- None
Changes for v3:
- Removed extra space between # and define
as per review comment
Changes for v2:
- None
--- include/configs/xilinx_zynqmp.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
include/configs/xilinx_zynqmp.h +8 -0
@@ -114,6 +114,14 @@#define CONFIG_SYS_LOAD_ADDR 0x8000000#if defined(CONFIG_ZYNQMP_USB ) +#define CONFIG_USB_XHCI_DWC3 +#define CONFIG_USB_XHCI +#define CONFIG_USB_MAX_CONTROLLER_COUNT 1 +#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2 +#define CONFIG_CMD_USB +#define CONFIG_USB_STORAGE +#define CONFIG_USB_XHCI_ZYNQMP +#define CONFIG_USB_DWC3 #define CONFIG_USB_DWC3_GADGET
Signature · 1 line
1.7.1
PATCH v5 1/2 usb: zynqmp: Add XHCI driver support
In reply to Siva Durga Prasad PaladuguQuoted 5 lines · Siva Durga Prasad Paladugu
From: Siva Durga Prasad Paladugu <[email protected]>
Added USB XHCI driver support for zynqmp.
Signed-off-by Siva Durga Prasad Paladugu <[email protected]>
Hi!
[...]
drivers/usb/host/xhci-zynqmp.c line 66
Quoted 3 lines
drivers/usb/host/xhci-zynqmp.c new file +3
-0+static struct zynqmp_xhci zynqmp_xhci; + +unsigned long ctr_addr[] =CONFIG_ZYNQMP_XHCI_LIST ;
Still no DM/DT support on Xilinx parts, huh ? :)
[...]
drivers/usb/host/xhci-zynqmp.c line 110
Quoted 10 lines
+int
xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor)+{drivers/usb/host/xhci-zynqmp.c new file +8
-0+struct zynqmp_xhci *ctx = &zynqmp_xhci; +int ret =0 ; + +if (index <0 || index >=ARRAY_SIZE (ctr_addr)) +return -EINVAL ; + + ctx->hcd = (struct xhci_hccr *)ctr_addr[index]; + ctx->dwc3_reg = (struct dwc3 *)((char *)(ctx->hcd) +DWC3_REG_OFFSET );
Should be void *, not char * I think. Also, the parenthesis around ctx->hcd are not needed.
Quoted 5 lines
drivers/usb/host/xhci-zynqmp.c new file +5
-0+ ret =board_usb_init (index,USB_INIT_HOST ); +if (ret !=0 ) { +puts ("Failed to initialize board for USB\n" ); +return ret; + }
drivers/usb/host/xhci-zynqmp.c line 126
Quoted 10 lines
drivers/usb/host/xhci-zynqmp.c new file +10
-0+ + ret =zynqmp_xhci_core_init (ctx); +if (ret <0 ) { +puts ("Failed to initialize xhci\n" ); +return ret; + } + + *hccr = (struct xhci_hccr *)ctx->hcd; + *hcor = (struct xhci_hcor *)((uint32_t ) *hccr + +HC_LENGTH (xhci_readl (&(*hccr)->cr_capbase)));
You want to use uintptr_t for the same of 64bit parts.
drivers/usb/host/xhci-zynqmp.c line 130
Quoted 3 lines
drivers/usb/host/xhci-zynqmp.c new file +3
-0+debug ("zynqmp-xhci: init hccr %x and hcor %x hc_length %d\n" , + (uint32_t )*hccr, (uint32_t )*hcor, + (uint32_t )HC_LENGTH (xhci_readl (&(*hccr)->cr_capbase)));
We have %p for printing pointers, so drop the casts.
Also, since you're using HC_LENGTH() here twice, you might as well put it's value into temporary variable and use it in both places, it might make the code slightly more readable.
Quoted 24 lines
drivers/usb/host/xhci-zynqmp.c new file +12
-0+return ret; +} + +void xhci_hcd_stop (int index) +{ +/* +* Currently zynqmp socs do not support PHY shutdown from +* sw. But this support may be added in future socs. +*/ + +return 0 ; +}(quoted diff) +0
-0
b/include/configs/xilinx_zynqmp_ep.hindex ed6023a..1845622 100644include/configs/xilinx_zynqmp_ep.h +2
-0@@ -23,6 +23,8 @@#define CONFIG_SYS_I2C_ZYNQ #define CONFIG_ZYNQ_EEPROM #define CONFIG_AHCI +#define CONFIG_ZYNQMP_XHCI_LIST {ZYNQMP_USB0_XHCI_BASEADDR, \ + ZYNQMP_USB1_XHCI_BASEADDR}#include <configs/xilinx_zynqmp.h>
PATCH v5 1/2 usb: zynqmp: Add XHCI driver support
Hi Marek,
Quoted 17 lines
-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: Monday, November 16, 2015 11:39 AM
To: Siva Durga Prasad Paladugu
Cc: u-boot at lists.denx.de; Siva Durga Prasad Paladugu
Subject: Re: [PATCH v5 1/2] usb: zynqmp: Add XHCI driver supportQuoted 5 lines · Siva Durga Prasad Paladugu
From: Siva Durga Prasad Paladugu <[email protected]>
Added USB XHCI driver support for zynqmp.
Signed-off-by Siva Durga Prasad Paladugu <[email protected]>Hi!
Quoted 7 lines
[...]
drivers/usb/host/xhci-zynqmp.c line 66
Quoted 3 lines
drivers/usb/host/xhci-zynqmp.c new file +3
-0+static struct zynqmp_xhci zynqmp_xhci; + +unsigned long ctr_addr[] =CONFIG_ZYNQMP_XHCI_LIST ;Still no DM/DT support on Xilinx parts, huh ? :)
We have this support for Zynq but not for ZynqMP yet as this is new and this patch is related to ZynqMP.
Quoted 18 lines
[...]
drivers/usb/host/xhci-zynqmp.c
Quoted 12 lines
(quoted diff) +2
-0+int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct +xhci_hcor**hcor) +{
drivers/usb/host/xhci-zynqmp.c new file +9
-0+struct zynqmp_xhci *ctx = &zynqmp_xhci; +int ret =0 ; + +if (index <0 || index >=ARRAY_SIZE (ctr_addr)) +return -EINVAL ; + + ctx->hcd = (struct xhci_hccr *)ctr_addr[index]; + ctx->dwc3_reg = (struct dwc3 *)((char *)(ctx->hcd) + +DWC3_REG_OFFSET );Should be void *, not char * I think. Also, the parenthesis around
ctx->hcdare not needed.
I think keeping char* would be good for easy understanding and readability.
Quoted 11 lines
Quoted 11 lines
drivers/usb/host/xhci-zynqmp.c new file +10
-0+ ret =board_usb_init (index,USB_INIT_HOST ); +if (ret !=0 ) { +puts ("Failed to initialize board for USB\n" ); +return ret; + } + + ret =zynqmp_xhci_core_init (ctx); +if (ret <0 ) { +puts ("Failed to initialize xhci\n" ); +return ret;
Quoted 8 lines
Quoted 6 lines
drivers/usb/host/xhci-zynqmp.c new file +5
-0+ } + + *hccr = (struct xhci_hccr *)ctx->hcd; + *hcor = (struct xhci_hcor *)((uint32_t ) *hccr + + HC_LENGTH(xhci_readl(&(*hccr)-
cr_capbase)));You want to use
uintptr_tfor the same of 64bit parts.
Ok
Quoted 10 lines
drivers/usb/host/xhci-zynqmp.c line 130
Quoted 4 lines
drivers/usb/host/xhci-zynqmp.c new file +3
-0+debug ("zynqmp-xhci: init hccr %x and hcor %x hc_length %d\n" , + (uint32_t )*hccr, (uint32_t )*hcor, + (uint32_t )HC_LENGTH (xhci_readl (&(*hccr)->cr_capbase)));We have %p for printing pointers, so drop the casts.
Also, since you're using
HC_LENGTH()here twice, you might as well put it's value into temporary variable and use it in both places, it might make the code slightly more readable.
Ok, will take care in next version
Regards,
Siva
Quoted 26 lines
Quoted 18 lines
drivers/usb/host/xhci-zynqmp.c new file +12
-0+return ret; +} + +void xhci_hcd_stop (int index) +{ +/* +* Currently zynqmp socs do not support PHY shutdown from +* sw. But this support may be added in future socs. +*/ + +return 0 ; +}(quoted diff) +0
-0
b/include/configs/xilinx_zynqmp_ep.hindex ed6023a..1845622 100644include/configs/xilinx_zynqmp_ep.h line 26
Quoted 4 lines
include/configs/xilinx_zynqmp_ep.h +1
-0@@ -23,6 +23,8 @@#define CONFIG_SYS_I2C_ZYNQ #define CONFIG_ZYNQ_EEPROM #define CONFIG_AHCI +#define CONFIG_ZYNQMP_XHCI_LIST {ZYNQMP_USB0_XHCI_BASEADDR,\
Quoted 3 lines
include/configs/xilinx_zynqmp_ep.h +1
-0+ ZYNQMP_USB1_XHCI_BASEADDR}#include <configs/xilinx_zynqmp.h>
PATCH v5 1/2 usb: zynqmp: Add XHCI driver support
Quoted 1 line · Siva Durga Prasad Paladugu
Hi Marek,
Hi,
[...]
Quoted 8 lines
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ ctx->hcd = (struct xhci_hccr *)ctr_addr[index]; + ctx->dwc3_reg = (struct dwc3 *)((char *)(ctx->hcd) + +DWC3_REG_OFFSET);Should be void *, not char * I think. Also, the parenthesis around
ctx->hcdare not needed.I think keeping char* would be good for easy understanding and readability.
Using bogus casts is never good for anything.
Quoted 28 lines
Quoted 16 lines
Quoted 16 lines
drivers/usb/host/xhci-zynqmp.c new file +15
-0+ ret =board_usb_init (index,USB_INIT_HOST ); +if (ret !=0 ) { +puts ("Failed to initialize board for USB\n" ); +return ret; + } + + ret =zynqmp_xhci_core_init (ctx); +if (ret <0 ) { +puts ("Failed to initialize xhci\n" ); +return ret; + } + + *hccr = (struct xhci_hccr *)ctx->hcd; + *hcor = (struct xhci_hcor *)((uint32_t ) *hccr + + HC_LENGTH(xhci_readl(&(*hccr)-Quoted 3 lines
Quoted 1 line
cr_capbase)));You want to use
uintptr_tfor the same of 64bit parts.Ok
Quoted 6 lines
drivers/usb/host/xhci-zynqmp.c line 130
Quoted 3 lines
drivers/usb/host/xhci-zynqmp.c new file +3
-0+debug ("zynqmp-xhci: init hccr %x and hcor %x hc_length %d\n" , + (uint32_t )*hccr, (uint32_t )*hcor, + (uint32_t )HC_LENGTH (xhci_readl (&(*hccr)->cr_capbase)));We have %p for printing pointers, so drop the casts.
Quoted 5 lines
Quoted 3 lines
Also, since you're using
HC_LENGTH()here twice, you might as well put it's value into temporary variable and use it in both places, it might make the code slightly more readable.Ok, will take care in next version
Thanks!
Best regards,
Marek Vasut