From cea6c8ce2327cfb41a13a8b8655e74dd18c2e6b7 Mon Sep 17 00:00:00 2001 From: Alban Bedel Date: Sat, 10 Sep 2016 03:54:09 +0200 Subject: net: asix: Fix ASIX 88772B with driver model Commit 147271209a9d ("net: asix: fix operation without eeprom") added a special handling for ASIX 88772B that enable another type of header. This break the driver in DM mode as the extra handling needed in the receive path is missing. However this new header mode is not required and only seems to increase the code complexity, so this patch revert this part of commit 147271209a9d. This also reverts commit 41d1258aceb45b45f9e68f67a9c40f0afbc09dc9 ("net: asix: Fix AX88772B when used with DriverModel") of late. Fixes: 147271209a9d ("net: asix: fix operation without eeprom") Signed-off-by: Alban Bedel Signed-off-by: Marcel Ziswiler --- drivers/usb/eth/asix.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/eth/asix.c b/drivers/usb/eth/asix.c index a610ae447b..1c6e967db1 100644 --- a/drivers/usb/eth/asix.c +++ b/drivers/usb/eth/asix.c @@ -67,11 +67,8 @@ AX_MEDIUM_AC | AX_MEDIUM_RE) /* AX88772 & AX88178 RX_CTL values */ -#define AX_RX_CTL_RH2M 0x0200 /* 32-bit aligned RX IP header */ -#define AX_RX_CTL_RH1M 0x0100 /* Enable RX header format type 1 */ -#define AX_RX_CTL_SO 0x0080 -#define AX_RX_CTL_AB 0x0008 -#define AX_RX_HEADER_DEFAULT (AX_RX_CTL_RH1M | AX_RX_CTL_RH2M) +#define AX_RX_CTL_SO 0x0080 +#define AX_RX_CTL_AB 0x0008 #define AX_DEFAULT_RX_CTL \ (AX_RX_CTL_SO | AX_RX_CTL_AB) @@ -98,8 +95,6 @@ #define FLAG_TYPE_AX88772B (1U << 2) #define FLAG_EEPROM_MAC (1U << 3) /* initial mac address in eeprom */ -#define ASIX_USB_VENDOR_ID 0x0b95 -#define AX88772B_USB_PRODUCT_ID 0x772b /* driver private */ struct asix_private { @@ -431,15 +426,10 @@ static int asix_init_common(struct ueth_data *dev, uint8_t *enetaddr) int timeout = 0; #define TIMEOUT_RESOLUTION 50 /* ms */ int link_detected; - u32 ctl = AX_DEFAULT_RX_CTL; debug("** %s()\n", __func__); - if ((dev->pusb_dev->descriptor.idVendor == ASIX_USB_VENDOR_ID) && - (dev->pusb_dev->descriptor.idProduct == AX88772B_USB_PRODUCT_ID)) - ctl |= AX_RX_HEADER_DEFAULT; - - if (asix_write_rx_ctl(dev, ctl) < 0) + if (asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL) < 0) goto out_err; if (asix_write_hwaddr_common(dev, enetaddr) < 0) @@ -572,12 +562,6 @@ static int asix_recv(struct eth_device *eth) return -1; } - if ((dev->pusb_dev->descriptor.idVendor == - ASIX_USB_VENDOR_ID) && - (dev->pusb_dev->descriptor.idProduct == - AX88772B_USB_PRODUCT_ID)) - buf_ptr += 2; - /* Notify net stack */ net_process_received_packet(buf_ptr + sizeof(packet_len), packet_len); @@ -819,11 +803,6 @@ int asix_eth_recv(struct udevice *dev, int flags, uchar **packetp) } *packetp = ptr + sizeof(packet_len); - - if ((ueth->pusb_dev->descriptor.idVendor == ASIX_USB_VENDOR_ID) && - (ueth->pusb_dev->descriptor.idProduct == AX88772B_USB_PRODUCT_ID)) - *packetp += 2; - return packet_len; err: -- cgit From e915716a5cdb40939204b3503f9356085e39fbd2 Mon Sep 17 00:00:00 2001 From: Sriram Dash Date: Mon, 22 Aug 2016 17:55:15 +0530 Subject: drivers: usb: xhci-fsl: Change burst beat and outstanding pipelined transfers requests This is required for better performance, and performs below tuning: 1. Enable burst length set, and define it as 4/8/16. 2. Set burst request limit to 16 requests. Signed-off-by: Rajesh Bhagat Signed-off-by: Sriram Dash --- drivers/usb/host/xhci-fsl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/host/xhci-fsl.c b/drivers/usb/host/xhci-fsl.c index bda5b5f913..2529d0eb13 100644 --- a/drivers/usb/host/xhci-fsl.c +++ b/drivers/usb/host/xhci-fsl.c @@ -58,6 +58,13 @@ static void fsl_apply_xhci_errata(void) } } +static void fsl_xhci_set_beat_burst_length(struct dwc3 *dwc3_reg) +{ + clrsetbits_le32(&dwc3_reg->g_sbuscfg0, USB3_ENABLE_BEAT_BURST_MASK, + USB3_ENABLE_BEAT_BURST); + setbits_le32(&dwc3_reg->g_sbuscfg1, USB3_SET_BEAT_BURST_LIMIT); +} + static int fsl_xhci_core_init(struct fsl_xhci *fsl_xhci) { int ret = 0; @@ -74,6 +81,9 @@ static int fsl_xhci_core_init(struct fsl_xhci *fsl_xhci) /* Set GFLADJ_30MHZ as 20h as per XHCI spec default value */ dwc3_set_fladj(fsl_xhci->dwc3_reg, GFLADJ_30MHZ_DEFAULT); + /* Change beat burst and outstanding pipelined transfers requests */ + fsl_xhci_set_beat_burst_length(fsl_xhci->dwc3_reg); + return ret; } -- cgit From 0885cdb9d154ac0f63bb681d4f280a39de354f8c Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Tue, 9 Aug 2016 23:44:59 +0530 Subject: usb: host: ehci-vf: Migrate Vybrid USB to driver model Add driver model support for Vybrid USB driver. Signed-off-by: Sanchayan Maity --- drivers/usb/host/ehci-vf.c | 208 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 201 insertions(+), 7 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c index 61789dddc3..f6f9efb6cd 100644 --- a/drivers/usb/host/ehci-vf.c +++ b/drivers/usb/host/ehci-vf.c @@ -8,16 +8,20 @@ */ #include +#include #include #include #include #include +#include #include #include #include #include #include #include +#include +#include #include "ehci.h" @@ -32,6 +36,8 @@ #define UCMD_RUN_STOP (1 << 0) /* controller run/stop */ #define UCMD_RESET (1 << 1) /* controller reset */ +DECLARE_GLOBAL_DATA_PTR; + static const unsigned phy_bases[] = { USB_PHY0_BASE_ADDR, USB_PHY1_BASE_ADDR, @@ -131,24 +137,39 @@ int __weak board_ehci_hcd_init(int port) return 0; } +int ehci_vf_common_init(struct usb_ehci *ehci, int index) +{ + int ret; + + /* Do board specific initialisation */ + ret = board_ehci_hcd_init(index); + if (ret) + return ret; + + usb_power_config(index); + usb_oc_config(index); + usb_internal_phy_clock_gate(index); + usb_phy_enable(index, ehci); + + return 0; +} + +#ifndef CONFIG_DM_USB int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { struct usb_ehci *ehci; enum usb_init_type type; + int ret; if (index >= ARRAY_SIZE(nc_reg_bases)) return -EINVAL; ehci = (struct usb_ehci *)nc_reg_bases[index]; - /* Do board specific initialisation */ - board_ehci_hcd_init(index); - - usb_power_config(index); - usb_oc_config(index); - usb_internal_phy_clock_gate(index); - usb_phy_enable(index, ehci); + ret = ehci_vf_common_init(index); + if (ret) + return ret; *hccr = (struct ehci_hccr *)((uint32_t)&ehci->caplength); *hcor = (struct ehci_hcor *)((uint32_t)*hccr + @@ -175,3 +196,176 @@ int ehci_hcd_stop(int index) { return 0; } +#else +/* Possible port types (dual role mode) */ +enum dr_mode { + DR_MODE_NONE = 0, + DR_MODE_HOST, /* supports host operation */ + DR_MODE_DEVICE, /* supports device operation */ + DR_MODE_OTG, /* supports both */ +}; + +struct ehci_vf_priv_data { + struct ehci_ctrl ctrl; + struct usb_ehci *ehci; + struct gpio_desc cdet_gpio; + enum usb_init_type init_type; + enum dr_mode dr_mode; + u32 portnr; +}; + +static int vf_usb_ofdata_to_platdata(struct udevice *dev) +{ + struct ehci_vf_priv_data *priv = dev_get_priv(dev); + const void *dt_blob = gd->fdt_blob; + int node = dev->of_offset; + const char *mode; + + priv->portnr = dev->seq; + + priv->ehci = (struct usb_ehci *)dev_get_addr(dev); + mode = fdt_getprop(dt_blob, node, "dr_mode", NULL); + if (mode) { + if (0 == strcmp(mode, "host")) { + priv->dr_mode = DR_MODE_HOST; + priv->init_type = USB_INIT_HOST; + } else if (0 == strcmp(mode, "peripheral")) { + priv->dr_mode = DR_MODE_DEVICE; + priv->init_type = USB_INIT_DEVICE; + } else if (0 == strcmp(mode, "otg")) { + priv->dr_mode = DR_MODE_OTG; + /* + * We set init_type to device by default when OTG + * mode is requested. If a valid gpio is provided + * we will switch the init_type based on the state + * of the gpio pin. + */ + priv->init_type = USB_INIT_DEVICE; + } else { + debug("%s: Cannot decode dr_mode '%s'\n", + __func__, mode); + return -EINVAL; + } + } else { + priv->dr_mode = DR_MODE_HOST; + priv->init_type = USB_INIT_HOST; + } + + if (priv->dr_mode == DR_MODE_OTG) { + gpio_request_by_name_nodev(dt_blob, node, "fsl,cdet-gpio", 0, + &priv->cdet_gpio, GPIOD_IS_IN); + if (dm_gpio_is_valid(&priv->cdet_gpio)) { + if (dm_gpio_get_value(&priv->cdet_gpio)) + priv->init_type = USB_INIT_DEVICE; + else + priv->init_type = USB_INIT_HOST; + } + } + + return 0; +} + +static int vf_init_after_reset(struct ehci_ctrl *dev) +{ + struct ehci_vf_priv_data *priv = dev->priv; + enum usb_init_type type = priv->init_type; + struct usb_ehci *ehci = priv->ehci; + int ret; + + ret = ehci_vf_common_init(priv->ehci, priv->portnr); + if (ret) + return ret; + + if (type == USB_INIT_DEVICE) + return 0; + + setbits_le32(&ehci->usbmode, CM_HOST); + writel((PORT_PTS_UTMI | PORT_PTS_PTW), &ehci->portsc); + setbits_le32(&ehci->portsc, USB_EN); + + mdelay(10); + + return 0; +} + +static const struct ehci_ops vf_ehci_ops = { + .init_after_reset = vf_init_after_reset +}; + +static int vf_usb_bind(struct udevice *dev) +{ + static int num_controllers; + + /* + * Without this hack, if we return ENODEV for USB Controller 0, on + * probe for the next controller, USB Controller 1 will be given a + * sequence number of 0. This conflicts with our requirement of + * sequence numbers while initialising the peripherals. + */ + dev->req_seq = num_controllers; + num_controllers++; + + return 0; +} + +static int ehci_usb_probe(struct udevice *dev) +{ + struct usb_platdata *plat = dev_get_platdata(dev); + struct ehci_vf_priv_data *priv = dev_get_priv(dev); + struct usb_ehci *ehci = priv->ehci; + struct ehci_hccr *hccr; + struct ehci_hcor *hcor; + int ret; + + ret = ehci_vf_common_init(ehci, priv->portnr); + if (ret) + return ret; + + if (priv->init_type != plat->init_type) + return -ENODEV; + + if (priv->init_type == USB_INIT_HOST) { + setbits_le32(&ehci->usbmode, CM_HOST); + writel((PORT_PTS_UTMI | PORT_PTS_PTW), &ehci->portsc); + setbits_le32(&ehci->portsc, USB_EN); + } + + mdelay(10); + + hccr = (struct ehci_hccr *)((uint32_t)&ehci->caplength); + hcor = (struct ehci_hcor *)((uint32_t)hccr + + HC_LENGTH(ehci_readl(&hccr->cr_capbase))); + + return ehci_register(dev, hccr, hcor, &vf_ehci_ops, 0, priv->init_type); +} + +static int ehci_usb_remove(struct udevice *dev) +{ + int ret; + + ret = ehci_deregister(dev); + if (ret) + return ret; + + return 0; +} + +static const struct udevice_id vf_usb_ids[] = { + { .compatible = "fsl,vf610-usb" }, + { } +}; + +U_BOOT_DRIVER(usb_ehci) = { + .name = "ehci_vf", + .id = UCLASS_USB, + .of_match = vf_usb_ids, + .bind = vf_usb_bind, + .probe = ehci_usb_probe, + .remove = ehci_usb_remove, + .ops = &ehci_usb_ops, + .ofdata_to_platdata = vf_usb_ofdata_to_platdata, + .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .priv_auto_alloc_size = sizeof(struct ehci_vf_priv_data), + .flags = DM_FLAG_ALLOC_PRIV_DMA, +}; +#endif -- cgit From a5c289b9bca3805fa35e42f389dc8225c6b916be Mon Sep 17 00:00:00 2001 From: Sriram Dash Date: Fri, 16 Sep 2016 17:12:15 +0530 Subject: usb: fsl: Rename fdt_fixup_dr_usb The function fdt_fixup_dr_usb is specific to fsl/nxp. So, make the function name explicit and rename fdt_fixup_dr_usb into fsl_fdt_fixup_dr_usb. Signed-off-by: Sriram Dash --- drivers/usb/common/fsl-dt-fixup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/common/fsl-dt-fixup.c b/drivers/usb/common/fsl-dt-fixup.c index 9c48852ea0..906f9df5d8 100644 --- a/drivers/usb/common/fsl-dt-fixup.c +++ b/drivers/usb/common/fsl-dt-fixup.c @@ -131,7 +131,7 @@ static int fdt_fixup_erratum(int *usb_erratum_off, void *blob, return 0; } -void fdt_fixup_dr_usb(void *blob, bd_t *bd) +void fsl_fdt_fixup_dr_usb(void *blob, bd_t *bd) { static const char * const modes[] = { "host", "peripheral", "otg" }; static const char * const phys[] = { "ulpi", "utmi", "utmi_dual" }; -- cgit From c609775e6fe6ce70d8ad3e244440b42fbf66bc13 Mon Sep 17 00:00:00 2001 From: Sriram Dash Date: Fri, 16 Sep 2016 17:12:16 +0530 Subject: usb: fsl: Renaming fdt_fixup_erratum and fdt_fixup_usb_erratum The functions fdt_fixup_erratum and fdt_fixup_usb_erratum are fsl/nxp specific. So, make them explicit by renaming them fsl_fdt_fixup_erratum and fsl_fdt_fixup_usb_erratum Signed-off-by: Sriram Dash --- drivers/usb/common/fsl-dt-fixup.c | 45 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/common/fsl-dt-fixup.c b/drivers/usb/common/fsl-dt-fixup.c index 906f9df5d8..63a24f74ad 100644 --- a/drivers/usb/common/fsl-dt-fixup.c +++ b/drivers/usb/common/fsl-dt-fixup.c @@ -86,8 +86,9 @@ static int fdt_fixup_usb_mode_phy_type(void *blob, const char *mode, return node_offset; } -static int fdt_fixup_usb_erratum(void *blob, const char *prop_erratum, - const char *controller_type, int start_offset) +static int fsl_fdt_fixup_usb_erratum(void *blob, const char *prop_erratum, + const char *controller_type, + int start_offset) { int node_offset, err; const char *node_type = NULL; @@ -114,17 +115,17 @@ 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)) +static int fsl_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); + *usb_erratum_off = fsl_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); @@ -198,29 +199,29 @@ void fsl_fdt_fixup_dr_usb(void *blob, bd_t *bd) if (usb_phy_off < 0) return; - ret = fdt_fixup_erratum(&usb_erratum_a006261_off, blob, - CHIPIDEA_USB2, "a006261", - has_erratum_a006261); + ret = fsl_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); + ret = fsl_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); + ret = fsl_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); + ret = fsl_fdt_fixup_erratum(&usb_erratum_a005697_off, blob, + CHIPIDEA_USB2, "a005697", + has_erratum_a005697); if (ret == -ENOSPC) return; - ret = fdt_fixup_erratum(&usb_erratum_a008751_off, blob, - SNPS_DWC3, "a008751", - has_erratum_a008751); + ret = fsl_fdt_fixup_erratum(&usb_erratum_a008751_off, blob, + SNPS_DWC3, "a008751", + has_erratum_a008751); if (ret == -ENOSPC) return; -- cgit From 4c043712e9910ef1d612aedbd8304a1f7348ef5f Mon Sep 17 00:00:00 2001 From: Sriram Dash Date: Fri, 23 Sep 2016 12:57:52 +0530 Subject: drivers: usb: xhci-fsl: Implement Erratum A-010151 for FSL USB3 controller Currently the controller by default enables the Receive Detect feature in P3 mode in USB 3.0 PHY. However, USB 3.0 PHY does not reliably support receive detection in P3 mode. Enabling the USB3 controller to configure USB in P2 mode whenever the Receive Detect feature is required. Signed-off-by: Sriram Dash Signed-off-by: Rajesh Bhagat --- drivers/usb/common/fsl-errata.c | 26 ++++++++++++++++++++++++++ drivers/usb/host/xhci-fsl.c | 13 +++++++++++++ 2 files changed, 39 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/common/fsl-errata.c b/drivers/usb/common/fsl-errata.c index 183bf2ba42..f2bffba35e 100644 --- a/drivers/usb/common/fsl-errata.c +++ b/drivers/usb/common/fsl-errata.c @@ -190,4 +190,30 @@ bool has_erratum_a008751(void) return false; } +bool has_erratum_a010151(void) +{ + u32 svr = get_svr(); + u32 soc = SVR_SOC_VER(svr); + + switch (soc) { +#ifdef CONFIG_ARM64 + case SVR_LS2080A: + case SVR_LS2085A: + case SVR_LS1046A: + case SVR_LS1012A: + return IS_SVR_REV(svr, 1, 0); + case SVR_LS1043A: + return IS_SVR_REV(svr, 1, 0) || IS_SVR_REV(svr, 1, 1); +#endif +#ifdef CONFIG_LS102XA + case SOC_VER_LS1020: + case SOC_VER_LS1021: + case SOC_VER_LS1022: + case SOC_VER_SLS1020: + return IS_SVR_REV(svr, 2, 0); +#endif + } + return false; +} + #endif diff --git a/drivers/usb/host/xhci-fsl.c b/drivers/usb/host/xhci-fsl.c index 2529d0eb13..798c358fd9 100644 --- a/drivers/usb/host/xhci-fsl.c +++ b/drivers/usb/host/xhci-fsl.c @@ -84,6 +84,19 @@ static int fsl_xhci_core_init(struct fsl_xhci *fsl_xhci) /* Change beat burst and outstanding pipelined transfers requests */ fsl_xhci_set_beat_burst_length(fsl_xhci->dwc3_reg); + /* + * A-010151: The dwc3 phy TSMC 28-nm HPM 0.9/1.8 V does not + * reliably support Rx Detect in P3 mode(P3 is the default + * setting). Therefore, some USB3.0 devices may not be detected + * reliably in Super Speed mode. So, USB controller to configure + * USB in P2 mode whenever the Receive Detect feature is required. + * whenever the Receive Detect feature is required. + */ + if (has_erratum_a010151()) + clrsetbits_le32(&fsl_xhci->dwc3_reg->g_usb3pipectl[0], + DWC3_GUSB3PIPECTL_DISRXDETP3, + DWC3_GUSB3PIPECTL_DISRXDETP3); + return ret; } -- cgit