summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorPeter Chen <peter.chen@freescale.com>2011-01-13 13:22:22 +0800
committerPeter Chen <peter.chen@freescale.com>2011-01-13 15:02:24 +0800
commitadf6f75e6a65597bf3d143d669983fff5a819cc1 (patch)
tree5ed544d5db242395a6885a0c548741003af82692 /arch
parent544e9b55d3e5f0c4fc57142832341db9da5d6db4 (diff)
ENGR00137927-2 mx5x_msl_usb: re-organize the platform data for device and host
To fix the compile error for device only function for OTG port. Add macro to differetiate the host and device function. Signed-off-by: Peter Chen <peter.chen@freescale.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-mx5/usb_dr.c177
-rw-r--r--arch/arm/mach-mx5/usb_h1.c6
-rw-r--r--arch/arm/mach-mx5/usb_h2.c5
3 files changed, 110 insertions, 78 deletions
diff --git a/arch/arm/mach-mx5/usb_dr.c b/arch/arm/mach-mx5/usb_dr.c
index 9864059ab3cc..d0dba3a3bf38 100644
--- a/arch/arm/mach-mx5/usb_dr.c
+++ b/arch/arm/mach-mx5/usb_dr.c
@@ -29,7 +29,9 @@ static struct clk *usb_oh3_clk;
static struct clk *usb_ahb_clk;
static void usbotg_wakeup_event_clear(void);
extern int clk_get_usecount(struct clk *clk);
-extern void fsl_usb_recover_hcd(struct platform_device *pdev);
+
+/* Beginning of Common operation for DR port */
+
/*
* platform data structs
* - Which one to use is determined by CONFIG options in usb.h
@@ -46,6 +48,8 @@ static struct fsl_usb2_platform_data dr_utmi_config = {
.usb_clock_for_pm = usbotg_clock_gate,
.transceiver = "utmi",
};
+
+/* Platform data for wakeup operation */
static struct fsl_usb2_wakeup_platform_data dr_wakeup_config = {
.name = "DR wakeup",
.usb_clock_for_pm = usbotg_clock_gate,
@@ -113,39 +117,6 @@ static void __wakeup_irq_enable(bool on, int source)
}
}
-static void _host_wakeup_enable(struct fsl_usb2_platform_data *pdata, bool enable)
-{
- __wakeup_irq_enable(enable, ENABLED_BY_HOST);
- /* host only care the ID change wakeup event */
- if (enable) {
- pr_debug("host wakeup enable\n");
- USBCTRL_HOST2 |= UCTRL_H2OIDWK_EN;
- } else {
- pr_debug("host wakeup disable\n");
- USBCTRL_HOST2 &= ~UCTRL_H2OIDWK_EN;
- /* The interrupt must be disabled for at least 3 clock
- * cycles of the standby clock(32k Hz) , that is 0.094 ms*/
- udelay(100);
- }
-}
-
-static void _device_wakeup_enable(struct fsl_usb2_platform_data *pdata, bool enable)
-{
- __wakeup_irq_enable(enable, ENABLED_BY_DEVICE);
- /* if udc is not used by any gadget, we can not enable the vbus wakeup */
- if (!pdata->port_enables) {
- USBCTRL_HOST2 &= ~UCTRL_H2OVBWK_EN;
- return;
- }
- if (enable) {
- pr_debug("device wakeup enable\n");
- USBCTRL_HOST2 |= UCTRL_H2OVBWK_EN;
- } else {
- pr_debug("device wakeup disable\n");
- USBCTRL_HOST2 &= ~UCTRL_H2OVBWK_EN;
- }
-}
-
static u32 low_power_enable_src; /* only useful at otg mode */
static void __phy_lowpower_suspend(bool enable, int source)
{
@@ -166,14 +137,68 @@ static void __phy_lowpower_suspend(bool enable, int source)
}
}
-static void _host_phy_lowpower_suspend(struct fsl_usb2_platform_data *pdata, bool enable)
+static void usbotg_clock_gate(bool on)
{
- __phy_lowpower_suspend(enable, ENABLED_BY_HOST);
+ pr_debug("%s: on is %d\n", __func__, on);
+ if (on) {
+ clk_enable(usb_ahb_clk);
+ clk_enable(usb_oh3_clk);
+ clk_enable(usb_phy1_clk);
+ } else {
+ clk_disable(usb_phy1_clk);
+ clk_disable(usb_oh3_clk);
+ clk_disable(usb_ahb_clk);
+ }
+ pr_debug("usb_ahb_ref_count:%d, usb_phy_clk1_ref_count:%d\n", clk_get_usecount(usb_ahb_clk), clk_get_usecount(usb_phy1_clk));
}
-static void _device_phy_lowpower_suspend(struct fsl_usb2_platform_data *pdata, bool enable)
+void mx5_set_otghost_vbus_func(driver_vbus_func driver_vbus)
{
- __phy_lowpower_suspend(enable, ENABLED_BY_DEVICE);
+ dr_utmi_config.platform_driver_vbus = driver_vbus;
+}
+
+/* The wakeup operation for DR port, it will clear the wakeup irq status
+ * and re-enable the wakeup
+ */
+static void usbotg_wakeup_event_clear(void)
+{
+ int wakeup_req = USBCTRL & UCTRL_OWIR;
+
+ if (wakeup_req != 0) {
+ printk(KERN_INFO "Unknown wakeup.(OTGSC 0x%x)\n", UOG_OTGSC);
+ /* Disable OWIE to clear OWIR, wait 3 clock
+ * cycles of standly clock(32KHz)
+ */
+ USBCTRL &= ~UCTRL_OWIE;
+ udelay(100);
+ USBCTRL |= UCTRL_OWIE;
+ }
+}
+/* End of Common operation for DR port */
+
+
+#ifdef CONFIG_USB_EHCI_ARC_OTG
+extern void fsl_usb_recover_hcd(struct platform_device *pdev);
+/* Beginning of host related operation for DR port */
+static void _host_wakeup_enable(struct fsl_usb2_platform_data *pdata, bool enable)
+{
+ __wakeup_irq_enable(enable, ENABLED_BY_HOST);
+ /* host only care the ID change wakeup event */
+ if (enable) {
+ pr_debug("host wakeup enable\n");
+ USBCTRL_HOST2 |= UCTRL_H2OIDWK_EN;
+ } else {
+ pr_debug("host wakeup disable\n");
+ USBCTRL_HOST2 &= ~UCTRL_H2OIDWK_EN;
+ /* The interrupt must be disabled for at least 3 clock
+ * cycles of the standby clock(32k Hz) , that is 0.094 ms*/
+ udelay(100);
+ }
+}
+
+static void _host_phy_lowpower_suspend(struct fsl_usb2_platform_data *pdata, bool enable)
+{
+ __phy_lowpower_suspend(enable, ENABLED_BY_HOST);
}
static enum usb_wakeup_event _is_host_wakeup(struct fsl_usb2_platform_data *pdata)
@@ -196,66 +221,62 @@ static enum usb_wakeup_event _is_host_wakeup(struct fsl_usb2_platform_data *pdat
return WAKEUP_EVENT_INVALID;
}
-static enum usb_wakeup_event _is_device_wakeup(struct fsl_usb2_platform_data *pdata)
-{
- int wakeup_req = USBCTRL & UCTRL_OWIR;
-
- if (wakeup_req && (UOG_OTGSC & OTGSC_STS_USB_ID) && (UOG_OTGSC & OTGSC_IS_B_SESSION_VALID)) {
- printk(KERN_INFO "otg udc wakeup\n");
- return WAKEUP_EVENT_VBUS;
- }
- return WAKEUP_EVENT_INVALID;
-
-}
-
static void host_wakeup_handler(struct fsl_usb2_platform_data *pdata)
{
_host_wakeup_enable(pdata, false);
_host_phy_lowpower_suspend(pdata, false);
fsl_usb_recover_hcd(&mxc_usbdr_host_device);
}
+/* End of host related operation for DR port */
+#endif /* CONFIG_USB_EHCI_ARC_OTG */
-static void device_wakeup_handler(struct fsl_usb2_platform_data *pdata)
+
+#ifdef CONFIG_USB_GADGET_ARC
+/* Beginning of device related operation for DR port */
+static void _device_wakeup_enable(struct fsl_usb2_platform_data *pdata, bool enable)
{
- _device_wakeup_enable(pdata, false);
- _device_phy_lowpower_suspend(pdata, false);
+ __wakeup_irq_enable(enable, ENABLED_BY_DEVICE);
+ /* if udc is not used by any gadget, we can not enable the vbus wakeup */
+ if (!pdata->port_enables) {
+ USBCTRL_HOST2 &= ~UCTRL_H2OVBWK_EN;
+ return;
+ }
+ if (enable) {
+ pr_debug("device wakeup enable\n");
+ USBCTRL_HOST2 |= UCTRL_H2OVBWK_EN;
+ } else {
+ pr_debug("device wakeup disable\n");
+ USBCTRL_HOST2 &= ~UCTRL_H2OVBWK_EN;
+ }
}
-static void usbotg_wakeup_event_clear(void)
+static void _device_phy_lowpower_suspend(struct fsl_usb2_platform_data *pdata, bool enable)
{
- int wakeup_req = USBCTRL & UCTRL_OWIR;
-
- if (wakeup_req != 0) {
- printk(KERN_INFO "Unknown wakeup.(OTGSC 0x%x)\n", UOG_OTGSC);
- /* Disable OWIE to clear OWIR, wait 3 clock
- * cycles of standly clock(32KHz)
- */
- USBCTRL &= ~UCTRL_OWIE;
- udelay(100);
- USBCTRL |= UCTRL_OWIE;
- }
+ __phy_lowpower_suspend(enable, ENABLED_BY_DEVICE);
}
-static void usbotg_clock_gate(bool on)
+static enum usb_wakeup_event _is_device_wakeup(struct fsl_usb2_platform_data *pdata)
{
- pr_debug("%s: on is %d\n", __func__, on);
- if (on) {
- clk_enable(usb_ahb_clk);
- clk_enable(usb_oh3_clk);
- clk_enable(usb_phy1_clk);
- } else {
- clk_disable(usb_phy1_clk);
- clk_disable(usb_oh3_clk);
- clk_disable(usb_ahb_clk);
+ int wakeup_req = USBCTRL & UCTRL_OWIR;
+
+ if (wakeup_req && (UOG_OTGSC & OTGSC_STS_USB_ID) && (UOG_OTGSC & OTGSC_IS_B_SESSION_VALID)) {
+ printk(KERN_INFO "otg udc wakeup\n");
+ return WAKEUP_EVENT_VBUS;
}
- pr_debug("usb_ahb_ref_count:%d, usb_phy_clk1_ref_count:%d\n", clk_get_usecount(usb_ahb_clk), clk_get_usecount(usb_phy1_clk));
+ return WAKEUP_EVENT_INVALID;
+
}
-void mx5_set_otghost_vbus_func(driver_vbus_func driver_vbus)
+static void device_wakeup_handler(struct fsl_usb2_platform_data *pdata)
{
- dr_utmi_config.platform_driver_vbus = driver_vbus;
+ _device_wakeup_enable(pdata, false);
+ _device_phy_lowpower_suspend(pdata, false);
}
+/* end of device related operation for DR port */
+#endif /* CONFIG_USB_GADGET_ARC */
+
+
void __init mx5_usb_dr_init(void)
{
#ifdef CONFIG_USB_OTG
diff --git a/arch/arm/mach-mx5/usb_h1.c b/arch/arm/mach-mx5/usb_h1.c
index b2d230e8a8bd..197947cfcb3c 100644
--- a/arch/arm/mach-mx5/usb_h1.c
+++ b/arch/arm/mach-mx5/usb_h1.c
@@ -28,7 +28,13 @@ static struct clk *usb_phy2_clk;
static struct clk *usb_oh3_clk;
static struct clk *usb_ahb_clk;
extern int clk_get_usecount(struct clk *clk);
+
+#ifdef CONFIG_USB_EHCI_ARC
extern void fsl_usb_recover_hcd(struct platform_device *pdev);
+#else
+static void fsl_usb_recover_hcd(struct platform_device *pdev)
+{; }
+#endif
/*
* USB Host1 HS port
*/
diff --git a/arch/arm/mach-mx5/usb_h2.c b/arch/arm/mach-mx5/usb_h2.c
index bdc2dded7613..516c62dea814 100644
--- a/arch/arm/mach-mx5/usb_h2.c
+++ b/arch/arm/mach-mx5/usb_h2.c
@@ -22,7 +22,12 @@
#include "iomux.h"
#include "mx51_pins.h"
+#ifdef CONFIG_USB_EHCI_ARC
extern void fsl_usb_recover_hcd(struct platform_device *pdev);
+#else
+static void fsl_usb_recover_hcd(struct platform_device *pdev)
+{; }
+#endif
/*
* USB Host2 HS port
*/