@@ -1,8 +1,15 @@
+config CDNS_USB_COMMON
+ tristate
+
+config CDNS_USB_HOST
+ bool
+
config USB_CDNS3
tristate "Cadence USB3 Dual-Role Controller"
depends on USB_SUPPORT && (USB || USB_GADGET) && HAS_DMA
select USB_XHCI_PLATFORM if USB_XHCI_HCD
select USB_ROLE_SWITCH
+ select CDNS_USB_COMMON
help
Say Y here if your system has a Cadence USB3 dual-role controller.
It supports: dual-role switch, Host-only, and Peripheral-only.
@@ -25,6 +32,7 @@ config USB_CDNS3_GADGET
config USB_CDNS3_HOST
bool "Cadence USB3 host controller"
depends on USB=y || USB=USB_CDNS3
+ select CDNS_USB_HOST
help
Say Y here to enable host controller functionality of the
Cadence driver.
@@ -2,17 +2,19 @@
# define_trace.h needs to know how to find our header
CFLAGS_trace.o := -I$(src)
-cdns3-y := cdns3-plat.o core.o drd.o
+cdns-usb-common-y := core.o drd.o
+cdns3-y := cdns3-plat.o
obj-$(CONFIG_USB_CDNS3) += cdns3.o
+obj-$(CONFIG_CDNS_USB_COMMON) += cdns-usb-common.o
+
+cdns-usb-common-$(CONFIG_CDNS_USB_HOST) += host.o
cdns3-$(CONFIG_USB_CDNS3_GADGET) += gadget.o ep0.o
ifneq ($(CONFIG_USB_CDNS3_GADGET),)
cdns3-$(CONFIG_TRACING) += trace.o
endif
-cdns3-$(CONFIG_USB_CDNS3_HOST) += host.o
-
obj-$(CONFIG_USB_CDNS3_PCI_WRAP) += cdns3-pci-wrap.o
obj-$(CONFIG_USB_CDNS3_TI) += cdns3-ti.o
obj-$(CONFIG_USB_CDNS3_IMX) += cdns3-imx.o
@@ -431,6 +431,7 @@ int cdns3_init(struct cdns3 *cdns)
return ret;
}
+EXPORT_SYMBOL_GPL(cdns3_init);
/**
* cdns3_remove - unbind drd driver and clean up
@@ -445,6 +446,7 @@ int cdns3_remove(struct cdns3 *cdns)
return 0;
}
+EXPORT_SYMBOL_GPL(cdns3_remove);
#ifdef CONFIG_PM_SLEEP
@@ -463,6 +465,7 @@ int cdns3_suspend(struct cdns3 *cdns)
return 0;
}
+EXPORT_SYMBOL_GPL(cdns3_suspend);
int cdns3_resume(struct cdns3 *cdns)
{
@@ -480,4 +483,11 @@ int cdns3_resume(struct cdns3 *cdns)
return 0;
}
+EXPORT_SYMBOL_GPL(cdns3_resume);
#endif
+
+MODULE_AUTHOR("Peter Chen <peter.chen@nxp.com>");
+MODULE_AUTHOR("Pawel Laszczak <pawell@cadence.com>");
+MODULE_AUTHOR("Roger Quadros <rogerq@ti.com>");
+MODULE_DESCRIPTION("Cadence USBSS and USBSSP DRD Driver");
+MODULE_LICENSE("GPL");
@@ -97,11 +97,11 @@ struct cdns3 {
};
int cdns3_hw_role_switch(struct cdns3 *cdns);
-int cdns3_init(struct cdns3 *cdns);
-int cdns3_remove(struct cdns3 *cdns);
+extern int cdns3_init(struct cdns3 *cdns);
+extern int cdns3_remove(struct cdns3 *cdns);
#ifdef CONFIG_PM_SLEEP
-int cdns3_resume(struct cdns3 *cdns);
-int cdns3_suspend(struct cdns3 *cdns);
+extern int cdns3_resume(struct cdns3 *cdns);
+extern int cdns3_suspend(struct cdns3 *cdns);
#endif /* CONFIG_PM_SLEEP */
#endif /* __LINUX_CDNS3_CORE_H */
@@ -159,6 +159,7 @@ int cdns3_drd_host_on(struct cdns3 *cdns)
return ret;
}
+EXPORT_SYMBOL_GPL(cdns3_drd_host_on);
/**
* cdns3_drd_host_off - stop host.
@@ -177,6 +178,7 @@ void cdns3_drd_host_off(struct cdns3 *cdns)
!(val & OTGSTATE_HOST_STATE_MASK),
1, 2000000);
}
+EXPORT_SYMBOL_GPL(cdns3_drd_host_off);
/**
* cdns3_drd_gadget_on - start gadget.
@@ -209,6 +211,7 @@ int cdns3_drd_gadget_on(struct cdns3 *cdns)
return 0;
}
+EXPORT_SYMBOL_GPL(cdns3_drd_gadget_on);
/**
* cdns3_drd_gadget_off - stop gadget.
@@ -231,6 +234,7 @@ void cdns3_drd_gadget_off(struct cdns3 *cdns)
!(val & OTGSTATE_DEV_STATE_MASK),
1, 2000000);
}
+EXPORT_SYMBOL_GPL(cdns3_drd_gadget_off);
/**
* cdns3_init_otg_mode - initialize drd controller
@@ -207,9 +207,9 @@ int cdns3_get_vbus(struct cdns3 *cdns);
int cdns3_drd_init(struct cdns3 *cdns);
int cdns3_drd_exit(struct cdns3 *cdns);
int cdns3_drd_update_mode(struct cdns3 *cdns);
-int cdns3_drd_gadget_on(struct cdns3 *cdns);
-void cdns3_drd_gadget_off(struct cdns3 *cdns);
-int cdns3_drd_host_on(struct cdns3 *cdns);
-void cdns3_drd_host_off(struct cdns3 *cdns);
+extern int cdns3_drd_gadget_on(struct cdns3 *cdns);
+extern void cdns3_drd_gadget_off(struct cdns3 *cdns);
+extern int cdns3_drd_host_on(struct cdns3 *cdns);
+extern void cdns3_drd_host_off(struct cdns3 *cdns);
#endif /* __LINUX_CDNS3_DRD */
@@ -12,7 +12,7 @@
#ifdef CONFIG_USB_CDNS3_GADGET
-int cdns3_gadget_init(struct cdns3 *cdns);
+extern int cdns3_gadget_init(struct cdns3 *cdns);
void cdns3_gadget_exit(struct cdns3 *cdns);
#else
@@ -3227,3 +3227,4 @@ int cdns3_gadget_init(struct cdns3 *cdns)
return 0;
}
+EXPORT_SYMBOL_GPL(cdns3_gadget_init);
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/*
- * Cadence USBSS DRD Driver - host side
+ * Cadence USBSS and USBSSP DRD Driver - host side
*
* Copyright (C) 2018-2019 Cadence Design Systems.
* Copyright (C) 2017-2018 NXP
@@ -73,3 +73,4 @@ int cdns3_host_init(struct cdns3 *cdns)
return 0;
}
+EXPORT_SYMBOL_GPL(cdns_host_init);
Patch moves common reusable code used by cdns3 and cdnsp driver to cdns-usb-common library. This library include core.c, drd.c and host.c files. Signed-off-by: Pawel Laszczak <pawell@cadence.com> --- drivers/usb/cdns3/Kconfig | 8 ++++++++ drivers/usb/cdns3/Makefile | 8 +++++--- drivers/usb/cdns3/core.c | 10 ++++++++++ drivers/usb/cdns3/core.h | 8 ++++---- drivers/usb/cdns3/drd.c | 4 ++++ drivers/usb/cdns3/drd.h | 8 ++++---- drivers/usb/cdns3/gadget-export.h | 2 +- drivers/usb/cdns3/gadget.c | 1 + drivers/usb/cdns3/host.c | 3 ++- 9 files changed, 39 insertions(+), 13 deletions(-)