From 5506ff149d4aa4b76f162a71c2cf68c2b00d38e9 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Wed, 6 Sep 2017 22:54:52 +0200 Subject: usb: gadget: Move USBNET_DEVADDR option out of g_dnl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The USBNET_DEVADDR has nothing to do with the USB download gadget, but rather with the USB Ethernet gadget. Move it out of the if statement. Acked-by: Łukasz Majewski Reviewed-by: Simon Glass Signed-off-by: Maxime Ripard --- drivers/usb/gadget/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 225b66bc95f..d5262690884 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -119,10 +119,10 @@ config G_DNL_VENDOR_NUM config G_DNL_PRODUCT_NUM hex "Product ID of USB device" +endif # USB_GADGET_DOWNLOAD + config USBNET_DEVADDR string "USB Gadget Ethernet device mac address" default "de:ad:be:ef:00:01" -endif # USB_GADGET_DOWNLOAD - endif # USB_GADGET -- cgit v1.2.3 From 74e7997c70d80e4b3de0622fbff3e75f72b8c1ce Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 12 Sep 2017 18:32:45 +0200 Subject: usb: gadget: Document USBNET_DEVADDR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add an help about the USBNET_DEVADDR Kconfig option to make it clearer what it's about. Acked-by: Łukasz Majewski Reviewed-by: Simon Glass Signed-off-by: Maxime Ripard --- drivers/usb/gadget/Kconfig | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index d5262690884..6dc9d177f5a 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -124,5 +124,8 @@ endif # USB_GADGET_DOWNLOAD config USBNET_DEVADDR string "USB Gadget Ethernet device mac address" default "de:ad:be:ef:00:01" + help + Ethernet MAC address of the device-side (ie. local board's) MAC + address of the usb_ether interface endif # USB_GADGET -- cgit v1.2.3 From c163668a4abaeef3eaab22b4a5ac13d2d74f1306 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Wed, 6 Sep 2017 22:53:43 +0200 Subject: usb: gadget: Move USBNET_HOST_ADDR to Kconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While the USB Ethernet device address is already defined in Kconfig, the host address isn't. Convert it. Reviewed-by: Łukasz Majewski Reviewed-by: Simon Glass Signed-off-by: Maxime Ripard --- drivers/usb/gadget/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 6dc9d177f5a..510efd67b9a 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -128,4 +128,11 @@ config USBNET_DEVADDR Ethernet MAC address of the device-side (ie. local board's) MAC address of the usb_ether interface +config USBNET_HOST_ADDR + string "USB Gadget Ethernet host mac address" + default "de:ad:be:ef:00:00" + help + Ethernet MAC address of the host-side (ie. remote device's) MAC + address of the usb_ether interface + endif # USB_GADGET -- cgit v1.2.3 From 3f33d3c8f4cc1b19a4a74e185bd3b6910f30e00f Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Wed, 6 Sep 2017 23:23:21 +0200 Subject: usb: gadget: Convert USB_ETHER to Kconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The USB Ethernet gadget option has not yet been moved to Kconfig, let's deal with that. Reviewed-by: Łukasz Majewski Reviewed-by: Simon Glass Signed-off-by: Maxime Ripard --- drivers/usb/gadget/Kconfig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 510efd67b9a..6558d2458b1 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -121,6 +121,18 @@ config G_DNL_PRODUCT_NUM endif # USB_GADGET_DOWNLOAD +config USB_ETHER + bool "USB Ethernet Gadget" + help + Creates an Ethernet network device through a USB peripheral + controller. This will create a network interface on both the device + (U-Boot) and the host (remote device) that can be used just like any + other nework interface. + It will bind on the peripheral USB controller, ignoring the USB hosts + controllers in the system. + +if USB_ETHER + config USBNET_DEVADDR string "USB Gadget Ethernet device mac address" default "de:ad:be:ef:00:01" @@ -135,4 +147,6 @@ config USBNET_HOST_ADDR Ethernet MAC address of the host-side (ie. remote device's) MAC address of the usb_ether interface +endif # USB_ETHER + endif # USB_GADGET -- cgit v1.2.3 From d2f0f4af4b655de9c63976be659288c88ae23953 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Thu, 7 Sep 2017 08:46:14 +0200 Subject: usb: gadget: usb_ether: Move the interfaces to Kconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to select an interface for the usb_ether gadget, and they haven't been converted to Kconfig yet. Add a choice to make sure we have an option selected, and convert all the users. Reviewed-by: Łukasz Majewski Reviewed-by: Simon Glass Signed-off-by: Maxime Ripard --- drivers/usb/gadget/Kconfig | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 6558d2458b1..7a1ee74a555 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -133,6 +133,34 @@ config USB_ETHER if USB_ETHER +choice + prompt "USB Ethernet Gadget Model" + default USB_ETH_RNDIS + help + There is several models (protocols) to implement Ethernet over USB + devices. The main ones are Microsoft's RNDIS and USB's CDC-Ethernet + (also called CDC-ECM). RNDIS is obviously compatible with Windows, + while CDC-ECM is not. Most other operating systems support both, so + if inter-operability is a concern, RNDIS is to be preferred. + +config USB_ETH_CDC + bool "CDC-ECM Protocol" + help + CDC (Communications Device Class) is the standard for Ethernet over + USB devices. While there's several alternatives, the most widely used + protocol is ECM (Ethernet Control Model). However, compatibility with + Windows is not that great. + +config USB_ETH_RNDIS + bool "RNDIS Protocol" + help + The RNDIS (Remote Network Driver Interface Specification) is a + Microsoft proprietary protocol to create an Ethernet device over USB. + Windows obviously supports it, as well as all the major operating + systems, so it's the best option for compatibility. + +endchoice + config USBNET_DEVADDR string "USB Gadget Ethernet device mac address" default "de:ad:be:ef:00:01" -- cgit v1.2.3 From a95aee6af70d8815547b81329125f2800c8ee37c Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Thu, 7 Sep 2017 08:58:08 +0200 Subject: usb: gadget: Make g_dnl USB settings common The g_dnl USB settings for the vendor ID, product ID and manufacturer are actually common settings that can and should be shared by all the gadgets. Make them common by renaming them, and convert all the users. Reviewed-by: Simon Glass Reviewed-by: Lukasz Majewski Signed-off-by: Maxime Ripard --- drivers/usb/gadget/Kconfig | 30 +++++++++++++++++++++--------- drivers/usb/gadget/g_dnl.c | 12 ++++++------ 2 files changed, 27 insertions(+), 15 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 7a1ee74a555..dfeeb5725af 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -36,6 +36,27 @@ menuconfig USB_GADGET if USB_GADGET +config USB_GADGET_MANUFACTURER + string "Vendor name of the USB device" + default "U-Boot" + help + Vendor name of the USB device emulated, reported to the host device. + This is usually either the manufacturer of the device or the SoC. + +config USB_GADGET_VENDOR_NUM + hex "Vendor ID of the USB device" + default 0x0 + help + Vendor ID of the USB device emulated, reported to the host device. + This is usually the board or SoC vendor's, unless you've registered + for one. + +config USB_GADGET_PRODUCT_NUM + hex "Product ID of the USB device" + default 0x0 + help + Product ID of the USB device emulated, reported to the host device. + config USB_GADGET_ATMEL_USBA bool "Atmel USBA" select USB_GADGET_DUALSPEED @@ -110,15 +131,6 @@ config USB_FUNCTION_SDP allows to download images into memory and execute (jump to) them using the same protocol as implemented by the i.MX family's boot ROM. -config G_DNL_MANUFACTURER - string "Vendor name of USB device" - -config G_DNL_VENDOR_NUM - hex "Vendor ID of USB device" - -config G_DNL_PRODUCT_NUM - hex "Product ID of USB device" - endif # USB_GADGET_DOWNLOAD config USB_ETHER diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c index 039331a5afd..99d500a6af4 100644 --- a/drivers/usb/gadget/g_dnl.c +++ b/drivers/usb/gadget/g_dnl.c @@ -26,9 +26,9 @@ /* * One needs to define the following: - * CONFIG_G_DNL_VENDOR_NUM - * CONFIG_G_DNL_PRODUCT_NUM - * CONFIG_G_DNL_MANUFACTURER + * CONFIG_USB_GADGET_VENDOR_NUM + * CONFIG_USB_GADGET_PRODUCT_NUM + * CONFIG_USB_GADGET_MANUFACTURER * at e.g. ./configs/_defconfig */ @@ -46,7 +46,7 @@ static const char product[] = "USB download gadget"; static char g_dnl_serial[MAX_STRING_SERIAL]; -static const char manufacturer[] = CONFIG_G_DNL_MANUFACTURER; +static const char manufacturer[] = CONFIG_USB_GADGET_MANUFACTURER; void g_dnl_set_serialnumber(char *s) { @@ -62,8 +62,8 @@ static struct usb_device_descriptor device_desc = { .bDeviceClass = USB_CLASS_PER_INTERFACE, .bDeviceSubClass = 0, /*0x02:CDC-modem , 0x00:CDC-serial*/ - .idVendor = __constant_cpu_to_le16(CONFIG_G_DNL_VENDOR_NUM), - .idProduct = __constant_cpu_to_le16(CONFIG_G_DNL_PRODUCT_NUM), + .idVendor = __constant_cpu_to_le16(CONFIG_USB_GADGET_VENDOR_NUM), + .idProduct = __constant_cpu_to_le16(CONFIG_USB_GADGET_PRODUCT_NUM), /* .iProduct = DYNAMIC */ /* .iSerialNumber = DYNAMIC */ .bNumConfigurations = 1, -- cgit v1.2.3 From 10ac57fda3ff46a20af7ded6cc03d78e88032495 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Thu, 7 Sep 2017 09:15:08 +0200 Subject: usb: gadget: usb_ether: Move settings to common The usb_ether gadget duplicates the USB settings for the manufacturer, product ID and vendor ID. Make sure we use the common option so that we can expect a single VID/PID couple for a single device. Reviewed-by: Simon Glass Reviewed-by: Lukasz Majewski Signed-off-by: Maxime Ripard --- drivers/usb/gadget/ether.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 2cf5c8d31e2..dbb578258f9 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -273,8 +273,8 @@ static inline int BITRATE(struct usb_gadget *g) * static ushort idProduct; */ -#if defined(CONFIG_USBNET_MANUFACTURER) -static char *iManufacturer = CONFIG_USBNET_MANUFACTURER; +#if defined(CONFIG_USB_GADGET_MANUFACTURER) +static char *iManufacturer = CONFIG_USB_GADGET_MANUFACTURER; #else static char *iManufacturer = "U-Boot"; #endif @@ -2073,11 +2073,11 @@ static int eth_bind(struct usb_gadget *gadget) * to choose the right configuration otherwise. */ if (rndis) { -#if defined(CONFIG_USB_RNDIS_VENDOR_ID) && defined(CONFIG_USB_RNDIS_PRODUCT_ID) +#if defined(CONFIG_USB_GADGET_VENDOR_NUM) && defined(CONFIG_USB_GADGET_PRODUCT_NUM) device_desc.idVendor = - __constant_cpu_to_le16(CONFIG_USB_RNDIS_VENDOR_ID); + __constant_cpu_to_le16(CONFIG_USB_GADGET_VENDOR_NUM); device_desc.idProduct = - __constant_cpu_to_le16(CONFIG_USB_RNDIS_PRODUCT_ID); + __constant_cpu_to_le16(CONFIG_USB_GADGET_PRODUCT_NUM); #else device_desc.idVendor = __constant_cpu_to_le16(RNDIS_VENDOR_NUM); @@ -2092,9 +2092,9 @@ static int eth_bind(struct usb_gadget *gadget) * supporting one submode of the "SAFE" variant of MDLM.) */ } else { -#if defined(CONFIG_USB_CDC_VENDOR_ID) && defined(CONFIG_USB_CDC_PRODUCT_ID) - device_desc.idVendor = cpu_to_le16(CONFIG_USB_CDC_VENDOR_ID); - device_desc.idProduct = cpu_to_le16(CONFIG_USB_CDC_PRODUCT_ID); +#if defined(CONFIG_USB_GADGET_VENDOR_NUM) && defined(CONFIG_USB_GADGET_PRODUCT_NUM) + device_desc.idVendor = cpu_to_le16(CONFIG_USB_GADGET_VENDOR_NUM); + device_desc.idProduct = cpu_to_le16(CONFIG_USB_GADGET_PRODUCT_NUM); #else if (!cdc) { device_desc.idVendor = -- cgit v1.2.3 From e02687bda96cc8ed942e14b558796d3043d24b23 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 12 Sep 2017 19:41:15 +0200 Subject: sunxi: provide default USB gadget setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All the Allwinner boards use the same manufacturer, VID and PID for the gadgets. Make them the defaults to remove some boilerplate from our defconfigs. Reviewed-by: Łukasz Majewski Reviewed-by: Simon Glass Signed-off-by: Maxime Ripard --- drivers/usb/gadget/Kconfig | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index dfeeb5725af..78faac74e99 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -38,6 +38,7 @@ if USB_GADGET config USB_GADGET_MANUFACTURER string "Vendor name of the USB device" + default "Allwinner Technology" if ARCH_SUNXI default "U-Boot" help Vendor name of the USB device emulated, reported to the host device. @@ -45,6 +46,7 @@ config USB_GADGET_MANUFACTURER config USB_GADGET_VENDOR_NUM hex "Vendor ID of the USB device" + default 0x1f3a if ARCH_SUNXI default 0x0 help Vendor ID of the USB device emulated, reported to the host device. @@ -53,6 +55,7 @@ config USB_GADGET_VENDOR_NUM config USB_GADGET_PRODUCT_NUM hex "Product ID of the USB device" + default 0x1010 if ARCH_SUNXI default 0x0 help Product ID of the USB device emulated, reported to the host device. -- cgit v1.2.3 From 3a61b080acee941a1b14b709b58ff9cde0b367bc Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 5 Sep 2017 22:10:35 +0200 Subject: musb: sunxi: switch to the device model MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The device model was implemented so far using a hook that needed to be called from the board support, without DT support and only for the host. Switch to probing both in peripheral and host mode through the DT. Reviewed-by: Łukasz Majewski Reviewed-by: Simon Glass Signed-off-by: Maxime Ripard --- drivers/usb/musb-new/sunxi.c | 56 +++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index 5c1a902e42d..7ee44ea9190 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -308,9 +308,6 @@ static struct musb_hdrc_platform_data musb_plat = { .platform_ops = &sunxi_musb_ops, }; -#ifdef CONFIG_USB_MUSB_HOST -static int musb_usb_remove(struct udevice *dev); - static int musb_usb_probe(struct udevice *dev) { struct musb_host_data *host = dev_get_priv(dev); @@ -319,16 +316,20 @@ static int musb_usb_probe(struct udevice *dev) priv->desc_before_addr = true; +#ifdef CONFIG_USB_MUSB_HOST host->host = musb_init_controller(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); if (!host->host) return -EIO; ret = musb_lowlevel_init(host); - if (ret == 0) - printf("MUSB OTG\n"); - else - musb_usb_remove(dev); + if (!ret) + printf("Allwinner mUSB OTG (Host)\n"); +#else + ret = musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); + if (!ret) + printf("Allwinner mUSB OTG (Peripheral)\n"); +#endif return ret; } @@ -352,30 +353,27 @@ static int musb_usb_remove(struct udevice *dev) return 0; } -U_BOOT_DRIVER(usb_musb) = { - .name = "sunxi-musb", - .id = UCLASS_USB, - .probe = musb_usb_probe, - .remove = musb_usb_remove, - .ops = &musb_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct musb_host_data), +static const struct udevice_id sunxi_musb_ids[] = { + { .compatible = "allwinner,sun4i-a10-musb" }, + { .compatible = "allwinner,sun6i-a31-musb" }, + { .compatible = "allwinner,sun8i-a33-musb" }, + { .compatible = "allwinner,sun8i-h3-musb" }, + { } }; -#endif -void sunxi_musb_board_init(void) -{ +U_BOOT_DRIVER(usb_musb) = { + .name = "sunxi-musb", #ifdef CONFIG_USB_MUSB_HOST - struct udevice *dev; - - /* - * Bind the driver directly for now as musb linux kernel support is - * still pending upstream so our dts files do not have the necessary - * nodes yet. TODO: Remove this as soon as the dts nodes are in place - * and bind by compatible instead. - */ - device_bind_driver(dm_root(), "sunxi-musb", "sunxi-musb", &dev); + .id = UCLASS_USB, #else - musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); + .id = UCLASS_USB_DEV_GENERIC, #endif -} + .of_match = sunxi_musb_ids, + .probe = musb_usb_probe, + .remove = musb_usb_remove, +#ifdef CONFIG_USB_MUSB_HOST + .ops = &musb_usb_ops, +#endif + .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .priv_auto_alloc_size = sizeof(struct musb_host_data), +}; -- cgit v1.2.3 From 3c989f3a19fc6db5866ed3172d7a620849d824c4 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Fri, 22 Sep 2017 09:51:37 +0200 Subject: sunxi: Fix USB_GADGET implication USB_GADGET will fail to compile if USB_MUSB_GADGET is not defined. Make sure we have that condition right. Fixes: e0ea88042d51 ("sunxi: Imply USB_ETHER") Suggested-by: Chen-Yu Tsai Signed-off-by: Maxime Ripard --- drivers/usb/gadget/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 78faac74e99..102a63b8eeb 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -138,6 +138,7 @@ endif # USB_GADGET_DOWNLOAD config USB_ETHER bool "USB Ethernet Gadget" + default y if ARCH_SUNXI && USB_MUSB_GADGET help Creates an Ethernet network device through a USB peripheral controller. This will create a network interface on both the device -- cgit v1.2.3