From f221db0ed5b4c6580abb4ab6fde5cbabaa348350 Mon Sep 17 00:00:00 2001 From: Steve Rae Date: Tue, 7 Jun 2016 15:35:21 -0700 Subject: usb: dwc2_udc_otg: support 8-bit interface Define CONFIG_USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8 to allow the physical interface to be 8-bit (rather than 16-bit). Signed-off-by: Steve Rae --- drivers/usb/gadget/Kconfig | 10 ++++++++++ drivers/usb/gadget/dwc2_udc_otg.c | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index a35a1c7760..ae624766c1 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -52,6 +52,16 @@ config USB_GADGET_DWC2_OTG driver to operate in Peripheral mode. This option requires USB_GADGET to be enabled. +if USB_GADGET_DWC2_OTG + +config USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8 + bool "DesignWare USB2.0 HS OTG controller 8-bit PHY bus width" + help + Set the Designware USB2.0 high-speed OTG controller + PHY interface width to 8 bits, rather than the default (16 bits). + +endif # USB_GADGET_DWC2_OTG + config CI_UDC bool "ChipIdea device controller" select USB_GADGET_DUALSPEED diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c index cb20b00a56..a23278d957 100644 --- a/drivers/usb/gadget/dwc2_udc_otg.c +++ b/drivers/usb/gadget/dwc2_udc_otg.c @@ -415,7 +415,11 @@ static void reconfig_usbd(struct dwc2_udc *dev) |0<<7 /* Ulpi DDR sel*/ |0<<6 /* 0: high speed utmi+, 1: full speed serial*/ |0<<4 /* 0: utmi+, 1:ulpi*/ +#ifdef CONFIG_USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8 + |0<<3 /* phy i/f 0:8bit, 1:16bit*/ +#else |1<<3 /* phy i/f 0:8bit, 1:16bit*/ +#endif |0x7<<0; /* HS/FS Timeout**/ if (dev->pdata->usb_gusbcfg) -- cgit v1.2.1 From 1653cd18eee1555e1fd4a8c2fd88048d53bdc619 Mon Sep 17 00:00:00 2001 From: Steve Rae Date: Tue, 7 Jun 2016 15:35:22 -0700 Subject: arm: bcm281xx: choose 8-bit phy bus width The Kona PHY supports an 8-bit wide UTMI interface, therefore, choose this Kconfig setting. Signed-off-by: Steve Rae --- configs/bcm11130_defconfig | 1 + configs/bcm11130_nand_defconfig | 1 + configs/bcm28155_ap_defconfig | 1 + configs/bcm28155_w1d_defconfig | 1 + 4 files changed, 4 insertions(+) diff --git a/configs/bcm11130_defconfig b/configs/bcm11130_defconfig index b8ec8acefc..2716868a31 100644 --- a/configs/bcm11130_defconfig +++ b/configs/bcm11130_defconfig @@ -18,6 +18,7 @@ CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8=y CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Broadcom Corporation" CONFIG_G_DNL_VENDOR_NUM=0x18d1 diff --git a/configs/bcm11130_nand_defconfig b/configs/bcm11130_nand_defconfig index 6021fd271a..8e01c521ee 100644 --- a/configs/bcm11130_nand_defconfig +++ b/configs/bcm11130_nand_defconfig @@ -18,6 +18,7 @@ CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8=y CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Broadcom Corporation" CONFIG_G_DNL_VENDOR_NUM=0x18d1 diff --git a/configs/bcm28155_ap_defconfig b/configs/bcm28155_ap_defconfig index 71a52a12ad..4c0f3b30ba 100644 --- a/configs/bcm28155_ap_defconfig +++ b/configs/bcm28155_ap_defconfig @@ -18,6 +18,7 @@ CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8=y CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Broadcom Corporation" CONFIG_G_DNL_VENDOR_NUM=0x18d1 diff --git a/configs/bcm28155_w1d_defconfig b/configs/bcm28155_w1d_defconfig index 97fe622f91..e9d13b9c86 100644 --- a/configs/bcm28155_w1d_defconfig +++ b/configs/bcm28155_w1d_defconfig @@ -19,6 +19,7 @@ CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_GADGET_DWC2_OTG_PHY_BUS_WIDTH_8=y CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Broadcom Corporation" CONFIG_G_DNL_VENDOR_NUM=0x18d1 -- cgit v1.2.1 From 6fb522dc774db981e1c8463e71898287e039c5f4 Mon Sep 17 00:00:00 2001 From: Sriram Dash Date: Mon, 13 Jun 2016 09:58:32 +0530 Subject: arm64: fsl-layerscape: add get_svr and IS_SVR_REV helper Adds get_svr and IS_SVR_REV helpers for ARMv8 platforms, similar to PPC and ARMv7. Signed-off-by: Sriram Dash Signed-off-by: Rajesh Bhagat --- arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 7 +++++++ arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h | 2 ++ arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h | 3 +++ arch/arm/include/asm/arch-fsl-layerscape/soc.h | 2 ++ 4 files changed, 14 insertions(+) diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c index 9a5a6b53f7..9c575c14d7 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c @@ -528,6 +528,13 @@ u32 fsl_qoriq_core_to_type(unsigned int core) return -1; /* cannot identify the cluster */ } +uint get_svr(void) +{ + struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); + + return gur_in32(&gur->svr); +} + #ifdef CONFIG_DISPLAY_CPUINFO int print_cpuinfo(void) { diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h index e98e055d9f..8b8a7c15bd 100644 --- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h +++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h @@ -596,4 +596,6 @@ struct ccsr_cci400 { #define SCR0_CLIENTPD_MASK 0x00000001 #define SCR0_USFCFG_MASK 0x00000400 +uint get_svr(void); + #endif /* __ARCH_FSL_LSCH2_IMMAP_H__*/ diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h index 65b3357009..e48bbaf7f4 100644 --- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h @@ -319,4 +319,7 @@ struct ccsr_reset { u32 ip_rev1; /* 0xbf8 */ u32 ip_rev2; /* 0xbfc */ }; + +uint get_svr(void); + #endif /* __ARCH_FSL_LSCH3_IMMAP_H_ */ diff --git a/arch/arm/include/asm/arch-fsl-layerscape/soc.h b/arch/arm/include/asm/arch-fsl-layerscape/soc.h index 02ecc6257e..2cb6c5430e 100644 --- a/arch/arm/include/asm/arch-fsl-layerscape/soc.h +++ b/arch/arm/include/asm/arch-fsl-layerscape/soc.h @@ -53,6 +53,8 @@ struct cpu_type { #define SVR_MIN(svr) (((svr) >> 0) & 0xf) #define SVR_SOC_VER(svr) (((svr) >> 8) & SVR_WO_E) #define IS_E_PROCESSOR(svr) (!((svr >> 8) & 0x1)) +#define IS_SVR_REV(svr, maj, min) \ + ((SVR_MAJ(svr) == (maj)) && (SVR_MIN(svr) == (min))) /* ahci port register default value */ #define AHCI_PORT_PHY_1_CFG 0xa003fffe -- cgit v1.2.1 From bf655775f5f97122605c96c0ecd41158c1147785 Mon Sep 17 00:00:00 2001 From: Sriram Dash Date: Mon, 13 Jun 2016 09:58:33 +0530 Subject: usb: xhci: fsl: code cleanup for device tree fixup for fsl usb controllers Performs code cleanup for device tree fixup for fsl usb controllers by making functions to handle these similar errata checking code. Signed-off-by: Rajesh Bhagat Signed-off-by: Sriram Dash --- drivers/usb/common/fsl-dt-fixup.c | 94 +++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 38 deletions(-) diff --git a/drivers/usb/common/fsl-dt-fixup.c b/drivers/usb/common/fsl-dt-fixup.c index 6f31932c37..1523f98cbc 100644 --- a/drivers/usb/common/fsl-dt-fixup.c +++ b/drivers/usb/common/fsl-dt-fixup.c @@ -19,10 +19,16 @@ #define CONFIG_USB_MAX_CONTROLLER_COUNT 1 #endif +/* USB Controllers */ +#define FSL_USB2_MPH "fsl-usb2-mph" +#define FSL_USB2_DR "fsl-usb2-dr" +#define CHIPIDEA_USB2 "chipidea,usb2" +#define SNPS_DWC3 "snps,dwc3" + static const char * const compat_usb_fsl[] = { - "fsl-usb2-mph", - "fsl-usb2-dr", - "snps,dwc3", + FSL_USB2_MPH, + FSL_USB2_DR, + SNPS_DWC3, NULL }; @@ -80,16 +86,24 @@ static int fdt_fixup_usb_mode_phy_type(void *blob, const char *mode, } static int fdt_fixup_usb_erratum(void *blob, const char *prop_erratum, - int start_offset) + const char *controller_type, int start_offset) { int node_offset, err; const char *node_type = NULL; + const char *node_name = NULL; err = fdt_usb_get_node_type(blob, start_offset, &node_offset, &node_type); if (err < 0) return err; + if (!strcmp(node_type, FSL_USB2_MPH) || !strcmp(node_type, FSL_USB2_DR)) + node_name = CHIPIDEA_USB2; + else + node_name = node_type; + if (strcmp(node_name, controller_type)) + return err; + err = fdt_setprop(blob, node_offset, prop_erratum, NULL, 0); if (err < 0) { printf("ERROR: could not set %s for %s: %s.\n", @@ -99,6 +113,23 @@ static int fdt_fixup_usb_erratum(void *blob, const char *prop_erratum, return node_offset; } +static int fdt_fixup_erratum(int *usb_erratum_off, void *blob, + const char *controller_type, char *str, + bool (*has_erratum)(void)) +{ + char buf[32] = {0}; + + snprintf(buf, sizeof(buf), "fsl,usb-erratum-%s", str); + if (!has_erratum()) + return -EINVAL; + *usb_erratum_off = fdt_fixup_usb_erratum(blob, buf, controller_type, + *usb_erratum_off); + if (*usb_erratum_off < 0) + return -ENOSPC; + debug("Adding USB erratum %s\n", str); + return 0; +} + void fdt_fixup_dr_usb(void *blob, bd_t *bd) { static const char * const modes[] = { "host", "peripheral", "otg" }; @@ -111,6 +142,7 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd) int usb_phy_off = -1; char str[5]; int i, j; + int ret; for (i = 1; i <= CONFIG_USB_MAX_CONTROLLER_COUNT; i++) { const char *dr_mode_type = NULL; @@ -164,39 +196,25 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd) if (usb_phy_off < 0) return; - if (has_erratum_a006261()) { - usb_erratum_a006261_off = fdt_fixup_usb_erratum - (blob, - "fsl,usb-erratum-a006261", - usb_erratum_a006261_off); - if (usb_erratum_a006261_off < 0) - return; - } - - if (has_erratum_a007075()) { - usb_erratum_a007075_off = fdt_fixup_usb_erratum - (blob, - "fsl,usb-erratum-a007075", - usb_erratum_a007075_off); - if (usb_erratum_a007075_off < 0) - return; - } - - if (has_erratum_a007792()) { - usb_erratum_a007792_off = fdt_fixup_usb_erratum - (blob, - "fsl,usb-erratum-a007792", - usb_erratum_a007792_off); - if (usb_erratum_a007792_off < 0) - return; - } - if (has_erratum_a005697()) { - usb_erratum_a005697_off = fdt_fixup_usb_erratum - (blob, - "fsl,usb-erratum-a005697", - usb_erratum_a005697_off); - if (usb_erratum_a005697_off < 0) - return; - } + ret = fdt_fixup_erratum(&usb_erratum_a006261_off, blob, + CHIPIDEA_USB2, "a006261", + has_erratum_a006261); + if (ret == -ENOSPC) + return; + ret = fdt_fixup_erratum(&usb_erratum_a007075_off, blob, + CHIPIDEA_USB2, "a007075", + has_erratum_a007075); + if (ret == -ENOSPC) + return; + ret = fdt_fixup_erratum(&usb_erratum_a007792_off, blob, + CHIPIDEA_USB2, "a007792", + has_erratum_a007792); + if (ret == -ENOSPC) + return; + ret = fdt_fixup_erratum(&usb_erratum_a005697_off, blob, + CHIPIDEA_USB2, "a005697", + has_erratum_a005697); + if (ret == -ENOSPC) + return; } } -- cgit v1.2.1 From 92623672f9d3f1b4ea12ae1e2bcc0ad9fde5d2cb Mon Sep 17 00:00:00 2001 From: Sriram Dash Date: Mon, 13 Jun 2016 09:58:34 +0530 Subject: fsl: usb: make errata function common for PPC and ARM This patch does the following things: 1. Makes the errata checking code common for PPC and ARM 2. Moves all these static inline functions into a dedicated C file Signed-off-by: Sriram Dash Signed-off-by: Rajesh Bhagat --- drivers/usb/common/Makefile | 4 +- drivers/usb/common/fsl-dt-fixup.c | 1 + drivers/usb/common/fsl-errata.c | 178 +++++++++++++++++++++++++++++++++++ include/fsl_usb.h | 191 ++------------------------------------ 4 files changed, 189 insertions(+), 185 deletions(-) create mode 100644 drivers/usb/common/fsl-errata.c diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile index 2f46d38d2b..aee7e32e59 100644 --- a/drivers/usb/common/Makefile +++ b/drivers/usb/common/Makefile @@ -4,5 +4,5 @@ # obj-$(CONFIG_DM_USB) += common.o -obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o -obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o +obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o fsl-errata.o +obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o fsl-errata.o diff --git a/drivers/usb/common/fsl-dt-fixup.c b/drivers/usb/common/fsl-dt-fixup.c index 1523f98cbc..930ca1d35e 100644 --- a/drivers/usb/common/fsl-dt-fixup.c +++ b/drivers/usb/common/fsl-dt-fixup.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/drivers/usb/common/fsl-errata.c b/drivers/usb/common/fsl-errata.c new file mode 100644 index 0000000000..95918fc890 --- /dev/null +++ b/drivers/usb/common/fsl-errata.c @@ -0,0 +1,178 @@ +/* + * Freescale USB Controller + * + * Copyright 2013 Freescale Semiconductor, Inc. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include + +/* USB Erratum Checking code */ +#if defined(CONFIG_PPC) || defined(CONFIG_ARM) +bool has_dual_phy(void) +{ + u32 svr = get_svr(); + u32 soc = SVR_SOC_VER(svr); + + switch (soc) { +#ifdef CONFIG_PPC + case SVR_T1023: + case SVR_T1024: + case SVR_T1013: + case SVR_T1014: + return IS_SVR_REV(svr, 1, 0); + case SVR_T1040: + case SVR_T1042: + case SVR_T1020: + case SVR_T1022: + case SVR_T2080: + case SVR_T2081: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1); + case SVR_T4240: + case SVR_T4160: + case SVR_T4080: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); +#endif + } + + return false; +} + +bool has_erratum_a006261(void) +{ + u32 svr = get_svr(); + u32 soc = SVR_SOC_VER(svr); + + switch (soc) { +#ifdef CONFIG_PPC + case SVR_P1010: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); + case SVR_P2041: + case SVR_P2040: + return IS_SVR_REV(svr, 1, 0) || + IS_SVR_REV(svr, 1, 1) || IS_SVR_REV(svr, 2, 1); + case SVR_P3041: + return IS_SVR_REV(svr, 1, 0) || + IS_SVR_REV(svr, 1, 1) || + IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 2, 1); + case SVR_P5010: + case SVR_P5020: + case SVR_P5021: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); + case SVR_T4240: + case SVR_T4160: + case SVR_T4080: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); + case SVR_T1040: + return IS_SVR_REV(svr, 1, 0); + case SVR_T2080: + case SVR_T2081: + return IS_SVR_REV(svr, 1, 0); + case SVR_P5040: + return IS_SVR_REV(svr, 1, 0); +#endif + } + + return false; +} + +bool has_erratum_a007075(void) +{ + u32 svr = get_svr(); + u32 soc = SVR_SOC_VER(svr); + + switch (soc) { +#ifdef CONFIG_PPC + case SVR_B4860: + case SVR_B4420: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); + case SVR_P1010: + return IS_SVR_REV(svr, 1, 0); + case SVR_P4080: + return IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 3, 0); +#endif + } + return false; +} + +bool has_erratum_a007798(void) +{ +#ifdef CONFIG_PPC + return SVR_SOC_VER(get_svr()) == SVR_T4240 && + IS_SVR_REV(get_svr(), 2, 0); +#endif + return false; +} + +bool has_erratum_a007792(void) +{ + u32 svr = get_svr(); + u32 soc = SVR_SOC_VER(svr); + + switch (soc) { +#ifdef CONFIG_PPC + case SVR_T4240: + case SVR_T4160: + case SVR_T4080: + return IS_SVR_REV(svr, 2, 0); + case SVR_T1024: + case SVR_T1023: + return IS_SVR_REV(svr, 1, 0); + case SVR_T1040: + case SVR_T1042: + case SVR_T1020: + case SVR_T1022: + case SVR_T2080: + case SVR_T2081: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1); +#endif + } + return false; +} + +bool has_erratum_a005697(void) +{ + u32 svr = get_svr(); + u32 soc = SVR_SOC_VER(svr); + + switch (soc) { +#ifdef CONFIG_PPC + case SVR_9131: + case SVR_9132: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1); +#endif + } + return false; +} + +bool has_erratum_a004477(void) +{ + u32 svr = get_svr(); + u32 soc = SVR_SOC_VER(svr); + + switch (soc) { +#ifdef CONFIG_PPC + case SVR_P1010: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); + case SVR_P1022: + case SVR_9131: + case SVR_9132: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1); + case SVR_P2020: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0) || + IS_SVR_REV(svr, 2, 1); + case SVR_B4860: + case SVR_B4420: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); + case SVR_P4080: + return IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 3, 0); +#endif + } + + return false; +} + +#endif diff --git a/include/fsl_usb.h b/include/fsl_usb.h index 187e384305..d18334965f 100644 --- a/include/fsl_usb.h +++ b/include/fsl_usb.h @@ -86,188 +86,13 @@ struct ccsr_usb_phy { #endif /* USB Erratum Checking code */ -#ifdef CONFIG_PPC -static inline bool has_dual_phy(void) -{ - u32 svr = get_svr(); - u32 soc = SVR_SOC_VER(svr); - - switch (soc) { - case SVR_T1023: - case SVR_T1024: - case SVR_T1013: - case SVR_T1014: - return IS_SVR_REV(svr, 1, 0); - case SVR_T1040: - case SVR_T1042: - case SVR_T1020: - case SVR_T1022: - case SVR_T2080: - case SVR_T2081: - return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1); - case SVR_T4240: - case SVR_T4160: - case SVR_T4080: - return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); - } - - return false; -} - -static inline bool has_erratum_a006261(void) -{ - u32 svr = get_svr(); - u32 soc = SVR_SOC_VER(svr); - - switch (soc) { - case SVR_P1010: - return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); - case SVR_P2041: - case SVR_P2040: - return IS_SVR_REV(svr, 1, 0) || - IS_SVR_REV(svr, 1, 1) || IS_SVR_REV(svr, 2, 1); - case SVR_P3041: - return IS_SVR_REV(svr, 1, 0) || - IS_SVR_REV(svr, 1, 1) || - IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 2, 1); - case SVR_P5010: - case SVR_P5020: - case SVR_P5021: - return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); - case SVR_T4240: - case SVR_T4160: - case SVR_T4080: - return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); - case SVR_T1040: - return IS_SVR_REV(svr, 1, 0); - case SVR_T2080: - case SVR_T2081: - return IS_SVR_REV(svr, 1, 0); - case SVR_P5040: - return IS_SVR_REV(svr, 1, 0); - } - - return false; -} - -static inline bool has_erratum_a007075(void) -{ - u32 svr = get_svr(); - u32 soc = SVR_SOC_VER(svr); - - switch (soc) { - case SVR_B4860: - case SVR_B4420: - return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); - case SVR_P1010: - return IS_SVR_REV(svr, 1, 0); - case SVR_P4080: - return IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 3, 0); - } - return false; -} - -static inline bool has_erratum_a007798(void) -{ - return SVR_SOC_VER(get_svr()) == SVR_T4240 && - IS_SVR_REV(get_svr(), 2, 0); -} - -static inline bool has_erratum_a007792(void) -{ - u32 svr = get_svr(); - u32 soc = SVR_SOC_VER(svr); - - switch (soc) { - case SVR_T4240: - case SVR_T4160: - case SVR_T4080: - return IS_SVR_REV(svr, 2, 0); - case SVR_T1024: - case SVR_T1023: - return IS_SVR_REV(svr, 1, 0); - case SVR_T1040: - case SVR_T1042: - case SVR_T1020: - case SVR_T1022: - case SVR_T2080: - case SVR_T2081: - return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1); - } - return false; -} - -static inline bool has_erratum_a005697(void) -{ - u32 svr = get_svr(); - u32 soc = SVR_SOC_VER(svr); - - switch (soc) { - case SVR_9131: - case SVR_9132: - return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1); - } - return false; -} - -static inline bool has_erratum_a004477(void) -{ - u32 svr = get_svr(); - u32 soc = SVR_SOC_VER(svr); - - switch (soc) { - case SVR_P1010: - return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); - case SVR_P1022: - case SVR_9131: - case SVR_9132: - return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1); - case SVR_P2020: - return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0) || - IS_SVR_REV(svr, 2, 1); - case SVR_B4860: - case SVR_B4420: - return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 2, 0); - case SVR_P4080: - return IS_SVR_REV(svr, 2, 0) || IS_SVR_REV(svr, 3, 0); - } - - return false; -} -#else -static inline bool has_dual_phy(void) -{ - return false; -} - -static inline bool has_erratum_a006261(void) -{ - return false; -} - -static inline bool has_erratum_a007075(void) -{ - return false; -} - -static inline bool has_erratum_a007798(void) -{ - return false; -} - -static inline bool has_erratum_a007792(void) -{ - return false; -} - -static inline bool has_erratum_a005697(void) -{ - return false; -} - -static inline bool has_erratum_a004477(void) -{ - return false; -} +#if defined(CONFIG_PPC) || defined(CONFIG_ARM) +bool has_dual_phy(void); +bool has_erratum_a006261(void); +bool has_erratum_a007075(void); +bool has_erratum_a007798(void); +bool has_erratum_a007792(void); +bool has_erratum_a005697(void); +bool has_erratum_a004477(void); #endif #endif /*_ASM_FSL_USB_H_ */ -- cgit v1.2.1 From 32fbd46f38ed183ae92aabc0a2abd7847bc3363e Mon Sep 17 00:00:00 2001 From: Sriram Dash Date: Mon, 13 Jun 2016 09:58:35 +0530 Subject: armv8/ls2080: Remove workaround for erratum A008751 This errata a008751 is applied on Soc specific file currently.This will be moved to a file where all the errata implementation will take place for usb for fsl. This patch removes the errata workaround from soc specific file for LS2080. Signed-off-by: Sriram Dash Signed-off-by: Rajesh Bhagat --- arch/arm/cpu/armv8/fsl-layerscape/soc.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c b/arch/arm/cpu/armv8/fsl-layerscape/soc.c index dd633f3690..d8ec426ce2 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c @@ -124,15 +124,6 @@ void erratum_a009635(void) } #endif /* CONFIG_SYS_FSL_ERRATUM_A009635 */ -static void erratum_a008751(void) -{ -#ifdef CONFIG_SYS_FSL_ERRATUM_A008751 - u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE; - - writel(0x27672b2a, scfg + SCFG_USB3PRM1CR / 4); -#endif -} - static void erratum_rcw_src(void) { #if defined(CONFIG_SPL) @@ -189,7 +180,6 @@ void bypass_smmu(void) } void fsl_lsch3_early_init_f(void) { - erratum_a008751(); erratum_rcw_src(); init_early_memctl_regs(); /* tighten IFC timing */ erratum_a009203(); -- cgit v1.2.1 From ef53b8c4ce2919d6685d2dc0c51a91a180433ff0 Mon Sep 17 00:00:00 2001 From: Sriram Dash Date: Mon, 13 Jun 2016 09:58:36 +0530 Subject: usb: xhci: fsl: Add workaround for USB erratum A008751 This patch is doing the following: 1. Implementing the errata for LS2080. 2. Adding fixup for fdt for LS2080. Signed-off-by: Sriram Dash Signed-off-by: Rajesh Bhagat --- .../include/asm/arch-fsl-layerscape/immap_lsch3.h | 1 + board/freescale/ls2080aqds/ls2080aqds.c | 2 ++ board/freescale/ls2080ardb/ls2080ardb.c | 2 ++ drivers/usb/common/fsl-dt-fixup.c | 7 +++++++ drivers/usb/common/fsl-errata.c | 15 ++++++++++++++ drivers/usb/host/xhci-fsl.c | 24 ++++++++++++++++++++++ include/fsl_usb.h | 1 + 7 files changed, 52 insertions(+) diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h index e48bbaf7f4..9b60bd310a 100644 --- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h @@ -139,6 +139,7 @@ /* Supplemental Configuration */ #define SCFG_BASE 0x01fc0000 #define SCFG_USB3PRM1CR 0x000 +#define SCFG_USB3PRM1CR_INIT 0x27672b2a #define TP_ITYP_AV 0x00000001 /* Initiator available */ #define TP_ITYP_TYPE(x) (((x) & 0x6) >> 1) /* Initiator Type */ diff --git a/board/freescale/ls2080aqds/ls2080aqds.c b/board/freescale/ls2080aqds/ls2080aqds.c index 897793d85b..479f68945b 100644 --- a/board/freescale/ls2080aqds/ls2080aqds.c +++ b/board/freescale/ls2080aqds/ls2080aqds.c @@ -298,6 +298,8 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_memory_banks(blob, base, size, 2); + fdt_fixup_dr_usb(blob, bd); + #ifdef CONFIG_FSL_MC_ENET fdt_fixup_board_enet(blob); err = fsl_mc_ldpaa_exit(bd); diff --git a/board/freescale/ls2080ardb/ls2080ardb.c b/board/freescale/ls2080ardb/ls2080ardb.c index 52e5e3f516..a65cd4ab80 100644 --- a/board/freescale/ls2080ardb/ls2080ardb.c +++ b/board/freescale/ls2080ardb/ls2080ardb.c @@ -281,6 +281,8 @@ int ft_board_setup(void *blob, bd_t *bd) fdt_fixup_memory_banks(blob, base, size, 2); + fdt_fixup_dr_usb(blob, bd); + #ifdef CONFIG_FSL_MC_ENET fdt_fixup_board_enet(blob); err = fsl_mc_ldpaa_exit(bd); diff --git a/drivers/usb/common/fsl-dt-fixup.c b/drivers/usb/common/fsl-dt-fixup.c index 930ca1d35e..9c48852ea0 100644 --- a/drivers/usb/common/fsl-dt-fixup.c +++ b/drivers/usb/common/fsl-dt-fixup.c @@ -139,6 +139,7 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd) int usb_erratum_a007075_off = -1; int usb_erratum_a007792_off = -1; int usb_erratum_a005697_off = -1; + int usb_erratum_a008751_off = -1; int usb_mode_off = -1; int usb_phy_off = -1; char str[5]; @@ -217,5 +218,11 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd) has_erratum_a005697); if (ret == -ENOSPC) return; + ret = fdt_fixup_erratum(&usb_erratum_a008751_off, blob, + SNPS_DWC3, "a008751", + has_erratum_a008751); + if (ret == -ENOSPC) + return; + } } diff --git a/drivers/usb/common/fsl-errata.c b/drivers/usb/common/fsl-errata.c index 95918fc890..ebe60a82f1 100644 --- a/drivers/usb/common/fsl-errata.c +++ b/drivers/usb/common/fsl-errata.c @@ -175,4 +175,19 @@ bool has_erratum_a004477(void) return false; } +bool has_erratum_a008751(void) +{ + u32 svr = get_svr(); + u32 soc = SVR_SOC_VER(svr); + + switch (soc) { +#ifdef CONFIG_ARM64 + case SVR_LS2080: + case SVR_LS2085: + return IS_SVR_REV(svr, 1, 0); +#endif + } + return false; +} + #endif diff --git a/drivers/usb/host/xhci-fsl.c b/drivers/usb/host/xhci-fsl.c index 05f09d7600..c12a189485 100644 --- a/drivers/usb/host/xhci-fsl.c +++ b/drivers/usb/host/xhci-fsl.c @@ -15,6 +15,8 @@ #include #include #include "xhci.h" +#include +#include /* Declare global data pointer */ DECLARE_GLOBAL_DATA_PTR; @@ -27,6 +29,26 @@ __weak int __board_usb_init(int index, enum usb_init_type init) return 0; } +static int erratum_a008751(void) +{ +#if defined(CONFIG_TARGET_LS2080AQDS) || defined(CONFIG_TARGET_LS2080ARDB) + u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE; + writel(SCFG_USB3PRM1CR_INIT, scfg + SCFG_USB3PRM1CR / 4); + return 0; +#endif + return 1; +} + +static void fsl_apply_xhci_errata(void) +{ + int ret; + if (has_erratum_a008751()) { + ret = erratum_a008751(); + if (ret != 0) + puts("Failed to apply erratum a008751\n"); + } +} + static int fsl_xhci_core_init(struct fsl_xhci *fsl_xhci) { int ret = 0; @@ -69,6 +91,8 @@ int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor) return ret; } + fsl_apply_xhci_errata(); + ret = fsl_xhci_core_init(ctx); if (ret < 0) { puts("Failed to initialize xhci\n"); diff --git a/include/fsl_usb.h b/include/fsl_usb.h index d18334965f..fc72fb9384 100644 --- a/include/fsl_usb.h +++ b/include/fsl_usb.h @@ -94,5 +94,6 @@ bool has_erratum_a007798(void); bool has_erratum_a007792(void); bool has_erratum_a005697(void); bool has_erratum_a004477(void); +bool has_erratum_a008751(void); #endif #endif /*_ASM_FSL_USB_H_ */ -- cgit v1.2.1 From 7839f5f8092762f048076c6c7b010c10f2ee8a0b Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Fri, 17 Jun 2016 14:18:11 +0800 Subject: cmd: usb: check if_type before using this device For legacy usb storage driver, USB_MAX_STOR_DEV is defined as 7. If we only have one usb disk on board, `usb dev 0` is ok. But if `usb dev 1`, still ok, then `usb read xxx` will trigger system fault and reboot. So check if_type before using this device. Signed-off-by: Peng Fan Cc: Simon Glass Cc: Hans de Goede Cc: Bin Meng Cc: Marek Vasut Cc: Stefan Roese Cc: Marcel Ziswiler Cc: Peng Fan Cc: Stephen Warren --- cmd/usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/usb.c b/cmd/usb.c index b83d3233b7..58d9db29d7 100644 --- a/cmd/usb.c +++ b/cmd/usb.c @@ -800,7 +800,8 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int dev = (int)simple_strtoul(argv[2], NULL, 10); printf("\nUSB device %d: ", dev); stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, dev); - if (stor_dev == NULL) { + if ((stor_dev == NULL) || + (stor_dev->if_type == IF_TYPE_UNKNOWN)) { printf("unknown device\n"); return 1; } -- cgit v1.2.1 From 1e6fb0e367564d427d7c57fa7b3b972ecb7147a3 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Wed, 15 Jun 2016 13:15:46 +0800 Subject: usb: ehci: only shutdown opened controller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the usb controller is not running, no need to shutdown it, otherwise `usb stop` complains about: "EHCI failed to shut down host controller". To i.MX7D SDB, there are two usb ports, one Host, one OTG. If we only plug one udisk to the Host port and then `usb start`, the OTG controller for OTG port does not run actually. Then, if `usb stop`, the OTG controller for OTG port will also be shutdown, but it is not running. This patch adds a check to only shutdown the running controller. Signed-off-by: Peng Fan Cc: Marek Vasut Cc: Simon Glass Cc: Mateusz Kulikowski Cc: Hans de Goede Cc: "Stefan BrĂ¼ns" Cc: Stephen Warren --- drivers/usb/host/ehci-hcd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index fa5d584b82..13aa70d606 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -210,6 +210,9 @@ static int ehci_shutdown(struct ehci_ctrl *ctrl) return -EINVAL; cmd = ehci_readl(&ctrl->hcor->or_usbcmd); + /* If not run, directly return */ + if (!(cmd & CMD_RUN)) + return 0; cmd &= ~(CMD_PSE | CMD_ASE); ehci_writel(&ctrl->hcor->or_usbcmd, cmd); ret = handshake(&ctrl->hcor->or_usbsts, STS_ASS | STS_PSS, 0, -- cgit v1.2.1