usb: cdns3: Moves reusable code to separate module
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> Tested-by: Aswath Govindraju <a-govindraju@ti.com> Signed-off-by: Peter Chen <peter.chen@nxp.com>
This commit is contained in:
Родитель
f738957277
Коммит
394c3a144d
|
@ -1,8 +1,15 @@
|
||||||
|
config CDNS_USB_COMMON
|
||||||
|
tristate
|
||||||
|
|
||||||
|
config CDNS_USB_HOST
|
||||||
|
bool
|
||||||
|
|
||||||
config USB_CDNS3
|
config USB_CDNS3
|
||||||
tristate "Cadence USB3 Dual-Role Controller"
|
tristate "Cadence USB3 Dual-Role Controller"
|
||||||
depends on USB_SUPPORT && (USB || USB_GADGET) && HAS_DMA
|
depends on USB_SUPPORT && (USB || USB_GADGET) && HAS_DMA
|
||||||
select USB_XHCI_PLATFORM if USB_XHCI_HCD
|
select USB_XHCI_PLATFORM if USB_XHCI_HCD
|
||||||
select USB_ROLE_SWITCH
|
select USB_ROLE_SWITCH
|
||||||
|
select CDNS_USB_COMMON
|
||||||
help
|
help
|
||||||
Say Y here if your system has a Cadence USB3 dual-role controller.
|
Say Y here if your system has a Cadence USB3 dual-role controller.
|
||||||
It supports: dual-role switch, Host-only, and Peripheral-only.
|
It supports: dual-role switch, Host-only, and Peripheral-only.
|
||||||
|
@ -25,6 +32,7 @@ config USB_CDNS3_GADGET
|
||||||
config USB_CDNS3_HOST
|
config USB_CDNS3_HOST
|
||||||
bool "Cadence USB3 host controller"
|
bool "Cadence USB3 host controller"
|
||||||
depends on USB=y || USB=USB_CDNS3
|
depends on USB=y || USB=USB_CDNS3
|
||||||
|
select CDNS_USB_HOST
|
||||||
help
|
help
|
||||||
Say Y here to enable host controller functionality of the
|
Say Y here to enable host controller functionality of the
|
||||||
Cadence driver.
|
Cadence driver.
|
||||||
|
|
|
@ -2,17 +2,19 @@
|
||||||
# define_trace.h needs to know how to find our header
|
# define_trace.h needs to know how to find our header
|
||||||
CFLAGS_trace.o := -I$(src)
|
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_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
|
cdns3-$(CONFIG_USB_CDNS3_GADGET) += gadget.o ep0.o
|
||||||
|
|
||||||
ifneq ($(CONFIG_USB_CDNS3_GADGET),)
|
ifneq ($(CONFIG_USB_CDNS3_GADGET),)
|
||||||
cdns3-$(CONFIG_TRACING) += trace.o
|
cdns3-$(CONFIG_TRACING) += trace.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
cdns3-$(CONFIG_USB_CDNS3_HOST) += host.o
|
|
||||||
|
|
||||||
obj-$(CONFIG_USB_CDNS3_PCI_WRAP) += cdns3-pci-wrap.o
|
obj-$(CONFIG_USB_CDNS3_PCI_WRAP) += cdns3-pci-wrap.o
|
||||||
obj-$(CONFIG_USB_CDNS3_TI) += cdns3-ti.o
|
obj-$(CONFIG_USB_CDNS3_TI) += cdns3-ti.o
|
||||||
obj-$(CONFIG_USB_CDNS3_IMX) += cdns3-imx.o
|
obj-$(CONFIG_USB_CDNS3_IMX) += cdns3-imx.o
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <linux/pm_runtime.h>
|
#include <linux/pm_runtime.h>
|
||||||
|
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
#include "gadget-export.h"
|
||||||
|
|
||||||
static int set_phy_power_on(struct cdns3 *cdns)
|
static int set_phy_power_on(struct cdns3 *cdns)
|
||||||
{
|
{
|
||||||
|
@ -134,6 +135,7 @@ static int cdns3_plat_probe(struct platform_device *pdev)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_phy_power_on;
|
goto err_phy_power_on;
|
||||||
|
|
||||||
|
cdns->gadget_init = cdns3_gadget_init;
|
||||||
ret = cdns3_init(cdns);
|
ret = cdns3_init(cdns);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_cdns_init;
|
goto err_cdns_init;
|
||||||
|
|
|
@ -19,10 +19,8 @@
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/pm_runtime.h>
|
#include <linux/pm_runtime.h>
|
||||||
|
|
||||||
#include "gadget.h"
|
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "host-export.h"
|
#include "host-export.h"
|
||||||
#include "gadget-export.h"
|
|
||||||
#include "drd.h"
|
#include "drd.h"
|
||||||
|
|
||||||
static int cdns3_idle_init(struct cdns3 *cdns);
|
static int cdns3_idle_init(struct cdns3 *cdns);
|
||||||
|
@ -147,7 +145,11 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
|
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
|
||||||
ret = cdns3_gadget_init(cdns);
|
if (cdns->gadget_init)
|
||||||
|
ret = cdns->gadget_init(cdns);
|
||||||
|
else
|
||||||
|
ret = -ENXIO;
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "Device initialization failed with %d\n",
|
dev_err(dev, "Device initialization failed with %d\n",
|
||||||
ret);
|
ret);
|
||||||
|
@ -477,6 +479,7 @@ role_switch_unregister:
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(cdns3_init);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cdns3_remove - unbind drd driver and clean up
|
* cdns3_remove - unbind drd driver and clean up
|
||||||
|
@ -491,6 +494,7 @@ int cdns3_remove(struct cdns3 *cdns)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(cdns3_remove);
|
||||||
|
|
||||||
#ifdef CONFIG_PM_SLEEP
|
#ifdef CONFIG_PM_SLEEP
|
||||||
int cdns3_suspend(struct cdns3 *cdns)
|
int cdns3_suspend(struct cdns3 *cdns)
|
||||||
|
@ -509,6 +513,7 @@ int cdns3_suspend(struct cdns3 *cdns)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(cdns3_suspend);
|
||||||
|
|
||||||
int cdns3_resume(struct cdns3 *cdns, u8 set_active)
|
int cdns3_resume(struct cdns3 *cdns, u8 set_active)
|
||||||
{
|
{
|
||||||
|
@ -525,4 +530,11 @@ int cdns3_resume(struct cdns3 *cdns, u8 set_active)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(cdns3_resume);
|
||||||
#endif /* CONFIG_PM_SLEEP */
|
#endif /* CONFIG_PM_SLEEP */
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
|
@ -78,6 +78,7 @@ struct cdns3_platform_data {
|
||||||
* @pdata: platform data from glue layer
|
* @pdata: platform data from glue layer
|
||||||
* @lock: spinlock structure
|
* @lock: spinlock structure
|
||||||
* @xhci_plat_data: xhci private data structure pointer
|
* @xhci_plat_data: xhci private data structure pointer
|
||||||
|
* @gadget_init: pointer to gadget initialization function
|
||||||
*/
|
*/
|
||||||
struct cdns3 {
|
struct cdns3 {
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
@ -115,6 +116,8 @@ struct cdns3 {
|
||||||
struct cdns3_platform_data *pdata;
|
struct cdns3_platform_data *pdata;
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
struct xhci_plat_priv *xhci_plat_data;
|
struct xhci_plat_priv *xhci_plat_data;
|
||||||
|
|
||||||
|
int (*gadget_init)(struct cdns3 *cdns);
|
||||||
};
|
};
|
||||||
|
|
||||||
int cdns3_hw_role_switch(struct cdns3 *cdns);
|
int cdns3_hw_role_switch(struct cdns3 *cdns);
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include <linux/iopoll.h>
|
#include <linux/iopoll.h>
|
||||||
#include <linux/usb/otg.h>
|
#include <linux/usb/otg.h>
|
||||||
|
|
||||||
#include "gadget.h"
|
|
||||||
#include "drd.h"
|
#include "drd.h"
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
|
||||||
|
@ -226,6 +225,7 @@ int cdns3_drd_gadget_on(struct cdns3 *cdns)
|
||||||
phy_set_mode(cdns->usb3_phy, PHY_MODE_USB_DEVICE);
|
phy_set_mode(cdns->usb3_phy, PHY_MODE_USB_DEVICE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(cdns3_drd_gadget_on);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cdns3_drd_gadget_off - stop gadget.
|
* cdns3_drd_gadget_off - stop gadget.
|
||||||
|
@ -249,6 +249,7 @@ void cdns3_drd_gadget_off(struct cdns3 *cdns)
|
||||||
1, 2000000);
|
1, 2000000);
|
||||||
phy_set_mode(cdns->usb3_phy, PHY_MODE_INVALID);
|
phy_set_mode(cdns->usb3_phy, PHY_MODE_INVALID);
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(cdns3_drd_gadget_off);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cdns3_init_otg_mode - initialize drd controller
|
* cdns3_init_otg_mode - initialize drd controller
|
||||||
|
|
Загрузка…
Ссылка в новой задаче