[U-Boot] [PATCH v4 02/10] usb: introduce a separate config option for DM USB device

Jean-Jacques Hiblot jjhiblot at ti.com
Thu Nov 29 09:52:42 UTC 2018


Using CONFIG_DM_USB for this purpose prevents using DM_USB for host and not
for device.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
Reviewed-by: Lukasz Majewski <lukma at denx.de>

---

Changes in v4:
- renamed DM_USB_DEV as DM_USB_GADGET

Changes in v3: None
Changes in v2:
- select DM_USB_DEV by default for zynqmp platforms

 arch/arm/Kconfig                |  2 ++
 drivers/usb/Kconfig             | 14 ++++++++++++++
 drivers/usb/dwc3/core.c         |  3 +--
 drivers/usb/dwc3/dwc3-generic.c |  4 ++--
 4 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f5d4d39..05b6ebf 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -917,6 +917,7 @@ config ARCH_ZYNQMP_R5
 	select DM_SERIAL
 	select OF_CONTROL
 	imply CMD_DM
+	imply DM_USB_GADGET
 
 config ARCH_ZYNQMP
 	bool "Xilinx ZynqMP based platform"
@@ -933,6 +934,7 @@ config ARCH_ZYNQMP
 	imply CMD_DM
 	imply FAT_WRITE
 	imply MP
+	imply DM_USB_GADGET
 
 config TEGRA
 	bool "NVIDIA Tegra"
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 03746dd..631fcce 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -52,6 +52,20 @@ config SPL_DM_USB
 	depends on DM_USB
 	default y
 
+config DM_USB_GADGET
+	bool "Enable driver model for USB Gadget"
+	depends on DM_USB
+	help
+	  Enable driver model for USB Gadget (Peripheral
+	  mode)
+
+config SPL_DM_USB_GADGET
+	bool "Enable driver model for USB Gadget in sPL"
+	depends on SPL_DM_USB
+	help
+	  Enable driver model for USB Gadget in SPL
+	  (Peripheral mode)
+
 source "drivers/usb/host/Kconfig"
 
 source "drivers/usb/dwc3/Kconfig"
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index f1ca619..f9d8465 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -789,8 +789,7 @@ MODULE_AUTHOR("Felipe Balbi <balbi at ti.com>");
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver");
 
-#if CONFIG_IS_ENABLED(DM_USB)
-
+#if CONFIG_IS_ENABLED(DM_USB_GADGET)
 int dwc3_init(struct dwc3 *dwc)
 {
 	int ret;
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 56c9fd6..ad3a116 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -21,8 +21,7 @@
 #include "gadget.h"
 #include "linux-compat.h"
 
-DECLARE_GLOBAL_DATA_PTR;
-
+#if CONFIG_IS_ENABLED(DM_USB_GADGET)
 int usb_gadget_handle_interrupts(int index)
 {
 	struct dwc3 *priv;
@@ -97,6 +96,7 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = {
 	.priv_auto_alloc_size = sizeof(struct dwc3),
 	.flags	= DM_FLAG_ALLOC_PRIV_DMA,
 };
+#endif
 
 static int dwc3_generic_bind(struct udevice *parent)
 {
-- 
2.7.4



More information about the U-Boot mailing list