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@xxxxxxxxxxx> --- 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(-) diff --git a/drivers/usb/cdns3/Kconfig b/drivers/usb/cdns3/Kconfig index 84716d216ae5..58154c0a73ac 100644 --- a/drivers/usb/cdns3/Kconfig +++ b/drivers/usb/cdns3/Kconfig @@ -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. diff --git a/drivers/usb/cdns3/Makefile b/drivers/usb/cdns3/Makefile index a1fe9612053a..16df87abf3cf 100644 --- a/drivers/usb/cdns3/Makefile +++ b/drivers/usb/cdns3/Makefile @@ -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 diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 079bd2abf65d..2c79fd5dbacb 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -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@xxxxxxx>"); +MODULE_AUTHOR("Pawel Laszczak <pawell@xxxxxxxxxxx>"); +MODULE_AUTHOR("Roger Quadros <rogerq@xxxxxx>"); +MODULE_DESCRIPTION("Cadence USBSS and USBSSP DRD Driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/cdns3/core.h b/drivers/usb/cdns3/core.h index 284707c19620..f868c415d4e7 100644 --- a/drivers/usb/cdns3/core.h +++ b/drivers/usb/cdns3/core.h @@ -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 */ diff --git a/drivers/usb/cdns3/drd.c b/drivers/usb/cdns3/drd.c index 2d78ad7e3e78..ee6c6ddb6a6f 100644 --- a/drivers/usb/cdns3/drd.c +++ b/drivers/usb/cdns3/drd.c @@ -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 diff --git a/drivers/usb/cdns3/drd.h b/drivers/usb/cdns3/drd.h index b8379c36194b..b4e4c5330f06 100644 --- a/drivers/usb/cdns3/drd.h +++ b/drivers/usb/cdns3/drd.h @@ -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 */ diff --git a/drivers/usb/cdns3/gadget-export.h b/drivers/usb/cdns3/gadget-export.h index 577469eee961..03a78593a04a 100644 --- a/drivers/usb/cdns3/gadget-export.h +++ b/drivers/usb/cdns3/gadget-export.h @@ -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 diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 02a69e20014b..132c7ed945d2 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -3227,3 +3227,4 @@ int cdns3_gadget_init(struct cdns3 *cdns) return 0; } +EXPORT_SYMBOL_GPL(cdns3_gadget_init); diff --git a/drivers/usb/cdns3/host.c b/drivers/usb/cdns3/host.c index 36c63d9ecd37..d4b911e7fa49 100644 --- a/drivers/usb/cdns3/host.c +++ b/drivers/usb/cdns3/host.c @@ -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); -- 2.17.1