From c65a34942e292e1f74af798c6ccbef17a072e238 Mon Sep 17 00:00:00 2001 From: Meng Dongyang Date: Thu, 8 Jun 2017 15:34:20 +0800 Subject: usb: dwc2: force to host mode if not support HNP/SRP In current code, after running the command of "usb start", the controller will keep in otg mode and can't switch to host mode if not support SNP/SRP capability. So add the property of "hnp-srp-disable" in the DTS to config the contrller work in force mode of host. Signed-off-by: Meng Dongyang diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index bbaefd2..841e596 100644 --- a/drivers/usb/host/dwc2.c +++ b/drivers/usb/host/dwc2.c @@ -43,6 +43,7 @@ struct dwc2_priv { struct dwc2_core_regs *regs; int root_hub_devnum; bool ext_vbus; + bool hnp_srp_disable; bool oc_disable; }; @@ -394,6 +395,9 @@ static void dwc_otg_core_init(struct dwc2_priv *priv) usbcfg |= DWC2_GUSBCFG_ULPI_CLK_SUS_M; } #endif + if (priv->hnp_srp_disable) + usbcfg |= DWC2_GUSBCFG_FORCEHOSTMODE; + writel(usbcfg, ®s->gusbcfg); /* Program the GAHBCFG Register. */ @@ -422,12 +426,16 @@ static void dwc_otg_core_init(struct dwc2_priv *priv) writel(ahbcfg, ®s->gahbcfg); - /* Program the GUSBCFG register for HNP/SRP. */ - setbits_le32(®s->gusbcfg, DWC2_GUSBCFG_HNPCAP | DWC2_GUSBCFG_SRPCAP); + /* Program the capabilities in GUSBCFG Register */ + usbcfg = 0; + if (!priv->hnp_srp_disable) + usbcfg |= DWC2_GUSBCFG_HNPCAP | DWC2_GUSBCFG_SRPCAP; #ifdef CONFIG_DWC2_IC_USB_CAP - setbits_le32(®s->gusbcfg, DWC2_GUSBCFG_IC_USB_CAP); + usbcfg |= DWC2_GUSBCFG_IC_USB_CAP; #endif + + setbits_le32(®s->gusbcfg, usbcfg); } /* @@ -1244,6 +1252,11 @@ static int dwc2_usb_ofdata_to_platdata(struct udevice *dev) if (prop) priv->oc_disable = true; + prop = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), + "hnp-srp-disable", NULL); + if (prop) + priv->hnp_srp_disable = true; + return 0; } -- cgit v0.10.2 From 9000eddbae0d292331ef403b0a1ff7ec7a983a79 Mon Sep 17 00:00:00 2001 From: Alexey Brodkin Date: Mon, 5 Jun 2017 22:31:51 +0300 Subject: drivers/usb/ehci: Use platform-specific accessors Current implementation doesn't allow utilization of platform-specific reads and writes. But some arches or platforms may want to use their accessors that do some extra work like adding barriers for data serialization etc. Interesting enough OHCI accessors already do that so just aligning EHCI to it now. This is a resend of http://patchwork.ozlabs.org/patch/726714/ Back in the day this patch broke some PPC and Sandbox boards as they we missing inclusion of "asm/io.h". Those missing items were fixed with: 1) http://patchwork.ozlabs.org/patch/751397/ 2) http://patchwork.ozlabs.org/patch/771099/ So now it should be safe to apply this patch. FWIW TravisCI builds everything with all 3 patches in place, see https://travis-ci.org/abrodkin/u-boot/builds/239563813 Signed-off-by: Alexey Brodkin Cc: Simon Glass Cc: Mateusz Kulikowski Acked-by: Marek Vasut diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 734d7f0..2ab830d 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -102,13 +102,11 @@ struct usb_linux_config_descriptor { } __attribute__ ((packed)); #if defined CONFIG_EHCI_DESC_BIG_ENDIAN -#define ehci_readl(x) cpu_to_be32((*((volatile u32 *)(x)))) -#define ehci_writel(a, b) (*((volatile u32 *)(a)) = \ - cpu_to_be32(((volatile u32)b))) +#define ehci_readl(x) cpu_to_be32(readl(x)) +#define ehci_writel(a, b) writel(cpu_to_be32(b), a) #else -#define ehci_readl(x) cpu_to_le32((*((volatile u32 *)(x)))) -#define ehci_writel(a, b) (*((volatile u32 *)(a)) = \ - cpu_to_le32(((volatile u32)b))) +#define ehci_readl(x) cpu_to_le32(readl(x)) +#define ehci_writel(a, b) writel(cpu_to_le32(b), a) #endif #if defined CONFIG_EHCI_MMIO_BIG_ENDIAN -- cgit v0.10.2 From 61887521874e888cda4bdd8d78f698a2938b467e Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 18 Apr 2017 22:23:51 -0400 Subject: at91_udc.c: Fix unused variable warning With gcc-6 and later we see warnings that at91sam9263_udc_caps and at91rm9200_udc_caps are unused. Fixes: 620197670a69 ("usb: gadget: at91_udc: add at91_udc into U-Boot") Cc: Lukasz Majewski Cc: Marek Vasut Signed-off-by: Tom Rini Acked-by: Heiko Schocher diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index f5bc277..01a5907 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -1386,11 +1386,6 @@ static void at91rm9200_udc_pullup(struct at91_udc *udc, int is_on) gpio_set_value(udc->board.pullup_pin, !active); } -static const struct at91_udc_caps at91rm9200_udc_caps = { - .init = at91rm9200_udc_init, - .pullup = at91rm9200_udc_pullup, -}; - static int at91sam9260_udc_init(struct at91_udc *udc) { struct at91_ep *ep; @@ -1503,11 +1498,6 @@ static int at91sam9263_udc_init(struct at91_udc *udc) return 0; } -static const struct at91_udc_caps at91sam9263_udc_caps = { - .init = at91sam9263_udc_init, - .pullup = at91sam9260_udc_pullup, -}; - int usb_gadget_handle_interrupts(int index) { struct at91_udc *udc = controller; -- cgit v0.10.2 From d419026a0275bf0a17367d414ca2e891f3c3386b Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Fri, 27 May 2016 22:37:10 -0300 Subject: cmd: usb_mass_storage: Use NULL for pointer Use NULL for pointer to fix the following sparse warning: cmd/usb_mass_storage.c:47:15: warning: Using plain integer as NULL pointer Signed-off-by: Fabio Estevam diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c index 86398fc..cb5260b 100644 --- a/cmd/usb_mass_storage.c +++ b/cmd/usb_mass_storage.c @@ -44,7 +44,7 @@ static void ums_fini(void) for (i = 0; i < ums_count; i++) free((void *)ums[i].name); free(ums); - ums = 0; + ums = NULL; ums_count = 0; } -- cgit v0.10.2 From b9203429a04402bd03c48fa87670686ef7e7891d Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Fri, 27 May 2016 22:37:11 -0300 Subject: cmd: usb_mass_storage: Staticize do_usb_mass_storage() Make do_usb_mass_storage() static to fix the following sparse warning: cmd/usb_mass_storage.c:136:5: warning: symbol 'do_usb_mass_storage' was not declared. Should it be static? Signed-off-by: Fabio Estevam diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c index cb5260b..3353f95 100644 --- a/cmd/usb_mass_storage.c +++ b/cmd/usb_mass_storage.c @@ -133,7 +133,7 @@ cleanup: return ret; } -int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, +static int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { const char *usb_controller; -- cgit v0.10.2