2015-05-07 12:36:03

by Ramneek Mehresh

[permalink] [raw]
Subject: [PATCH 01/10] usb:fsl:otg: Add controller version based ULPI and UTMI phy

Add controller version based ULPI and UTMI phy initialization for
otg driver

Signed-off-by: Shengzhou Liu <[email protected]>
Signed-off-by: Ramneek Mehresh <[email protected]>
Reviewed-by: Fleming Andrew-AFLEMING <[email protected]>
Tested-by: Fleming Andrew-AFLEMING <[email protected]>
---
drivers/usb/phy/phy-fsl-usb.c | 20 ++++++++++++++++++++
drivers/usb/phy/phy-fsl-usb.h | 7 +++++++
2 files changed, 27 insertions(+)

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index 94eb292..f90093a 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -923,12 +923,32 @@ int usb_otg_start(struct platform_device *pdev)
temp &= ~(PORTSC_PHY_TYPE_SEL | PORTSC_PTW);
switch (pdata->phy_mode) {
case FSL_USB2_PHY_ULPI:
+ if (pdata->controller_ver) {
+ /* controller version 1.6 or above */
+ setbits32(&p_otg->dr_mem_map->control,
+ USB_CTRL_ULPI_PHY_CLK_SEL);
+ /*
+ * Due to controller issue of PHY_CLK_VALID in ULPI
+ * mode, we set USB_CTRL_USB_EN before checking
+ * PHY_CLK_VALID, otherwise PHY_CLK_VALID doesn't work.
+ */
+ clrsetbits_be32(&p_otg->dr_mem_map->control,
+ USB_CTRL_UTMI_PHY_EN, USB_CTRL_IOENB);
+ }
temp |= PORTSC_PTS_ULPI;
break;
case FSL_USB2_PHY_UTMI_WIDE:
temp |= PORTSC_PTW_16BIT;
/* fall through */
case FSL_USB2_PHY_UTMI:
+ if (pdata->controller_ver) {
+ /* controller version 1.6 or above */
+ setbits32(&p_otg->dr_mem_map->control,
+ USB_CTRL_UTMI_PHY_EN);
+ /* Delay for UTMI PHY CLK to become stable - 10ms */
+ mdelay(FSL_UTMI_PHY_DLY);
+ }
+ setbits32(&p_otg->dr_mem_map->control, USB_CTRL_UTMI_PHY_EN);
temp |= PORTSC_PTS_UTMI;
/* fall through */
default:
diff --git a/drivers/usb/phy/phy-fsl-usb.h b/drivers/usb/phy/phy-fsl-usb.h
index 2314995..4a78fb3 100644
--- a/drivers/usb/phy/phy-fsl-usb.h
+++ b/drivers/usb/phy/phy-fsl-usb.h
@@ -199,6 +199,13 @@
/* control Register Bit Masks */
#define USB_CTRL_IOENB (0x1<<2)
#define USB_CTRL_ULPI_INT0EN (0x1<<0)
+#define USB_CTRL_WU_INT_EN (0x1<<1)
+#define USB_CTRL_LINE_STATE_FILTER__EN (0x1<<3)
+#define USB_CTRL_KEEP_OTG_ON (0x1<<4)
+#define USB_CTRL_OTG_PORT (0x1<<5)
+#define USB_CTRL_PLL_RESET (0x1<<8)
+#define USB_CTRL_UTMI_PHY_EN (0x1<<9)
+#define USB_CTRL_ULPI_PHY_CLK_SEL (0x1<<10)

/* BCSR5 */
#define BCSR5_INT_USB (0x02)
--
1.8.3.1


2015-05-07 12:36:07

by Ramneek Mehresh

[permalink] [raw]
Subject: [PATCH 02/10] drivers:host:fsl: Use ehci_overrides structure for EHCI drv

Make use of ehci_driver_overrides structure for ehci-fsl
driver

Signed-off-by: Ramneek Mehresh <[email protected]>
---
drivers/usb/host/ehci-fsl.c | 55 +++++++++------------------------------------
1 file changed, 11 insertions(+), 44 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index ab4eee3..1fe8ce7 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -636,60 +636,27 @@ static int ehci_start_port_reset(struct usb_hcd *hcd, unsigned port)
#define ehci_start_port_reset NULL
#endif /* CONFIG_USB_OTG */

+static struct hc_driver __read_mostly ehci_fsl_hc_driver;

-static const struct hc_driver ehci_fsl_hc_driver = {
- .description = hcd_name,
- .product_desc = "Freescale On-Chip EHCI Host Controller",
- .hcd_priv_size = sizeof(struct ehci_fsl),
-
- /*
- * generic hardware linkage
- */
- .irq = ehci_irq,
- .flags = HCD_USB2 | HCD_MEMORY | HCD_BH,
-
- /*
- * basic lifecycle operations
- */
+static struct ehci_driver_overrides ehci_fsl_overrides __initdata = {
+ .extra_priv_size = sizeof(struct ehci_fsl),
.reset = ehci_fsl_setup,
- .start = ehci_run,
- .stop = ehci_stop,
- .shutdown = ehci_shutdown,
-
- /*
- * managing i/o requests and associated device resources
- */
- .urb_enqueue = ehci_urb_enqueue,
- .urb_dequeue = ehci_urb_dequeue,
- .endpoint_disable = ehci_endpoint_disable,
- .endpoint_reset = ehci_endpoint_reset,
-
- /*
- * scheduling support
- */
- .get_frame_number = ehci_get_frame,
-
- /*
- * root hub support
- */
- .hub_status_data = ehci_hub_status_data,
- .hub_control = ehci_hub_control,
- .bus_suspend = ehci_bus_suspend,
- .bus_resume = ehci_bus_resume,
- .start_port_reset = ehci_start_port_reset,
- .relinquish_port = ehci_relinquish_port,
- .port_handed_over = ehci_port_handed_over,
-
- .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
};

static int ehci_fsl_drv_probe(struct platform_device *pdev)
{
+ struct hc_driver *driver = &ehci_fsl_hc_driver;
+
if (usb_disabled())
return -ENODEV;

+ ehci_init_driver(driver, &ehci_fsl_overrides);
+ driver->product_desc = "Freescale On-Chip EHCI Host Controller";
+ driver->start = ehci_run;
+ driver->start_port_reset = ehci_start_port_reset;
+
/* FIXME we only want one one probe() not two */
- return usb_hcd_fsl_probe(&ehci_fsl_hc_driver, pdev);
+ return usb_hcd_fsl_probe(driver, pdev);
}

static int ehci_fsl_drv_remove(struct platform_device *pdev)
--
1.8.3.1

2015-05-07 12:36:11

by Ramneek Mehresh

[permalink] [raw]
Subject: [PATCH 03/10] usb:fsl:otg: Add support to add/remove usb host driver

Add workqueue to add/remove host driver (outside interrupt context)
upon each id change

Signed-off-by: Li Yang <[email protected]>
Signed-off-by: Ramneek Mehresh <[email protected]>
---
drivers/usb/host/ehci-fsl.c | 81 ++++++++++++++++++++++++++++++++++-----------
drivers/usb/host/ehci-fsl.h | 19 +++++++++++
2 files changed, 81 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 1fe8ce7..ff39ac6 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -33,6 +33,33 @@

#include "ehci-fsl.h"

+#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
+static struct ehci_fsl *hcd_to_ehci_fsl(struct usb_hcd *hcd)
+{
+ return (struct ehci_fsl *)hcd_to_ehci(hcd)->priv;
+}
+
+static void do_change_hcd(struct work_struct *work)
+{
+ struct ehci_fsl *ehci_fsl = container_of(work, struct ehci_fsl,
+ change_hcd_work);
+ struct usb_hcd *hcd = ehci_fsl->hcd;
+ void __iomem *non_ehci = hcd->regs;
+ int retval;
+
+ if (ehci_fsl->hcd_add && !ehci_fsl->have_hcd) {
+ writel(USBMODE_CM_HOST, non_ehci + FSL_SOC_USB_USBMODE);
+ /* host, gadget and otg share same int line */
+ retval = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
+ if (retval == 0)
+ ehci_fsl->have_hcd = 1;
+ } else if (!ehci_fsl->hcd_add && ehci_fsl->have_hcd) {
+ usb_remove_hcd(hcd);
+ ehci_fsl->have_hcd = 0;
+ }
+}
+#endif
+
/* configure so an HC device and id are always provided */
/* always called with process context; sleeping is OK */

@@ -126,11 +153,16 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
goto err2;
device_wakeup_enable(hcd->self.controller);

-#ifdef CONFIG_USB_OTG
+#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
if (pdata->operating_mode == FSL_USB2_DR_OTG) {
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+ struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);

+ ehci_fsl->hcd = hcd;
hcd->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2);
+
+ INIT_WORK(&ehci_fsl->change_hcd_work, do_change_hcd);
+
dev_dbg(&pdev->dev, "hcd=0x%p ehci=0x%p, phy=0x%p\n",
hcd, ehci, hcd->usb_phy);

@@ -376,15 +408,6 @@ static int ehci_fsl_setup(struct usb_hcd *hcd)
return retval;
}

-struct ehci_fsl {
- struct ehci_hcd ehci;
-
-#ifdef CONFIG_PM
- /* Saved USB PHY settings, need to restore after deep sleep. */
- u32 usb_ctrl;
-#endif
-};
-
#ifdef CONFIG_PM

#ifdef CONFIG_PPC_MPC512x
@@ -532,24 +555,30 @@ static inline int ehci_fsl_mpc512x_drv_resume(struct device *dev)
}
#endif /* CONFIG_PPC_MPC512x */

-static struct ehci_fsl *hcd_to_ehci_fsl(struct usb_hcd *hcd)
-{
- struct ehci_hcd *ehci = hcd_to_ehci(hcd);
-
- return container_of(ehci, struct ehci_fsl, ehci);
-}
-
static int ehci_fsl_drv_suspend(struct device *dev)
{
struct usb_hcd *hcd = dev_get_drvdata(dev);
- struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
void __iomem *non_ehci = hcd->regs;
+#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
+ struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
+ struct usb_bus host = hcd->self;
+#endif

if (of_device_is_compatible(dev->parent->of_node,
"fsl,mpc5121-usb2-dr")) {
return ehci_fsl_mpc512x_drv_suspend(dev);
}

+#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
+ if (host.is_otg) {
+ /* remove hcd */
+ ehci_fsl->hcd_add = 0;
+ schedule_work(&ehci_fsl->change_hcd_work);
+ host.is_otg = 0;
+ return 0;
+ }
+#endif
+
ehci_prepare_ports_for_controller_suspend(hcd_to_ehci(hcd),
device_may_wakeup(dev));
if (!fsl_deep_sleep())
@@ -562,15 +591,29 @@ static int ehci_fsl_drv_suspend(struct device *dev)
static int ehci_fsl_drv_resume(struct device *dev)
{
struct usb_hcd *hcd = dev_get_drvdata(dev);
- struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
void __iomem *non_ehci = hcd->regs;
+#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
+ struct ehci_fsl *ehci_fsl = hcd_to_ehci_fsl(hcd);
+ struct usb_bus host = hcd->self;
+#endif

if (of_device_is_compatible(dev->parent->of_node,
"fsl,mpc5121-usb2-dr")) {
return ehci_fsl_mpc512x_drv_resume(dev);
}

+#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
+ if (host.is_otg) {
+ /* add hcd */
+ ehci_fsl->hcd_add = 1;
+ schedule_work(&ehci_fsl->change_hcd_work);
+ usb_hcd_resume_root_hub(hcd);
+ host.is_otg = 0;
+ return 0;
+ }
+#endif
+
ehci_prepare_ports_for_controller_resume(ehci);
if (!fsl_deep_sleep())
return 0;
diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h
index dbd292e..523714c 100644
--- a/drivers/usb/host/ehci-fsl.h
+++ b/drivers/usb/host/ehci-fsl.h
@@ -62,4 +62,23 @@
#define UTMI_PHY_EN (1<<9)
#define ULPI_PHY_CLK_SEL (1<<10)
#define PHY_CLK_VALID (1<<17)
+
+struct ehci_fsl {
+#ifdef CONFIG_PM
+ /* Saved USB PHY settings, need to restore after deep sleep. */
+ u32 usb_ctrl;
+#endif
+ struct usb_hcd *hcd;
+#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
+ struct work_struct change_hcd_work;
+#endif
+ /* store current hcd state for otg;
+ * have_hcd is true when host drv al already part of otg framework,
+ * otherwise false;
+ * hcd_add is true when otg framework wants to add host
+ * drv as part of otg;flase when it wants to remove it
+ */
+ unsigned have_hcd:1;
+ unsigned hcd_add:1;
+};
#endif /* _EHCI_FSL_H */
--
1.8.3.1

2015-05-07 12:38:36

by Ramneek Mehresh

[permalink] [raw]
Subject: [PATCH 04/10] usb:fsl:otg: Signal host drv when host is otg

Set is_otg boolean flag to signal host driver when
host is running in context of otg host suspend/resume

Signed-off-by: Ramneek Mehresh <[email protected]>
---
drivers/usb/phy/phy-fsl-usb.c | 7 ++++++-
include/linux/usb.h | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index f90093a..26168da 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -463,6 +463,7 @@ void otg_reset_controller(void)
int fsl_otg_start_host(struct otg_fsm *fsm, int on)
{
struct usb_otg *otg = fsm->otg;
+ struct usb_bus *host = otg->host;
struct device *dev;
struct fsl_otg *otg_dev =
container_of(otg->usb_phy, struct fsl_otg, phy);
@@ -485,6 +486,7 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on)
else {
otg_reset_controller();
VDBG("host on......\n");
+ host->is_otg = 1;
if (dev->driver->pm && dev->driver->pm->resume) {
retval = dev->driver->pm->resume(dev);
if (fsm->id) {
@@ -510,8 +512,11 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on)
else {
VDBG("host off......\n");
if (dev && dev->driver) {
- if (dev->driver->pm && dev->driver->pm->suspend)
+ if (dev->driver->pm &&
+ dev->driver->pm->suspend) {
+ host->is_otg = 1;
retval = dev->driver->pm->suspend(dev);
+ }
if (fsm->id)
/* default-b */
fsl_otg_drv_vbus(fsm, 0);
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 7ee1b5c..c3a6702 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -329,6 +329,7 @@ struct usb_bus {
* for control transfers?
*/
u8 otg_port; /* 0, or number of OTG/HNP port */
+ unsigned is_otg:1; /* true when host is also otg */
unsigned is_b_host:1; /* true during some HNP roleswitches */
unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */
unsigned no_stop_on_short:1; /*
--
1.8.3.1

2015-05-07 12:38:17

by Ramneek Mehresh

[permalink] [raw]
Subject: [PATCH 05/10] usb:fsl:otg: Modify otg_event to start host drv

Add mechanism to start host driver from inside fsl_otg_even
upon each id change interrupt

Signed-off-by: Ramneek Mehresh <[email protected]>
Reviewed-by: Fleming Andrew-AFLEMING <[email protected]>
Tested-by: Fleming Andrew-AFLEMING <[email protected]>
---
drivers/usb/phy/phy-fsl-usb.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index 26168da..2eb54ef 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -677,6 +677,10 @@ static void fsl_otg_event(struct work_struct *work)
fsl_otg_start_host(fsm, 0);
otg_drv_vbus(fsm, 0);
fsl_otg_start_gadget(fsm, 1);
+ } else {
+ fsl_otg_start_gadget(fsm, 0);
+ otg_drv_vbus(fsm, 1);
+ fsl_otg_start_host(fsm, 1);
}
}

--
1.8.3.1

2015-05-07 12:36:19

by Ramneek Mehresh

[permalink] [raw]
Subject: [PATCH 06/10] usb:fsl:otg: Combine host/gadget start/resume for ID change

Make call to fsl_otg_event for each id change even

Signed-off-by: Ramneek Mehresh <[email protected]>
Reviewed-by: Fleming Andrew-AFLEMING <[email protected]>
Tested-by: Fleming Andrew-AFLEMING <[email protected]>
---
drivers/usb/phy/phy-fsl-usb.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index 2eb54ef..ce40d5c 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -733,6 +733,7 @@ irqreturn_t fsl_otg_isr(int irq, void *dev_id)
{
struct otg_fsm *fsm = &((struct fsl_otg *)dev_id)->fsm;
struct usb_otg *otg = ((struct fsl_otg *)dev_id)->phy.otg;
+ struct fsl_otg *otg_dev = dev_id;
u32 otg_int_src, otg_sc;

otg_sc = fsl_readl(&usb_dr_regs->otgsc);
@@ -762,18 +763,8 @@ irqreturn_t fsl_otg_isr(int irq, void *dev_id)
otg->gadget->is_a_peripheral = !fsm->id;
VDBG("ID int (ID is %d)\n", fsm->id);

- if (fsm->id) { /* switch to gadget */
- schedule_delayed_work(
- &((struct fsl_otg *)dev_id)->otg_event,
- 100);
- } else { /* switch to host */
- cancel_delayed_work(&
- ((struct fsl_otg *)dev_id)->
- otg_event);
- fsl_otg_start_gadget(fsm, 0);
- otg_drv_vbus(fsm, 1);
- fsl_otg_start_host(fsm, 1);
- }
+ schedule_delayed_work(&otg_dev->otg_event, 100);
+
return IRQ_HANDLED;
}
}
--
1.8.3.1

2015-05-07 12:37:18

by Ramneek Mehresh

[permalink] [raw]
Subject: [PATCH 07/10] usb:fsl:otg: Remove host drv upon otg bring-up

Change have_hcd variable to remove/suspend host driver on
completion of otg initialization for otg auto detect

Signed-off-by: Ramneek Mehresh <[email protected]>
Reviewed-by: Li Yang-R58472 <[email protected]>
Reviewed-by: Fleming Andrew-AFLEMING <[email protected]>
Tested-by: Fleming Andrew-AFLEMING <[email protected]>
---
drivers/usb/host/ehci-fsl.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index ff39ac6..4bd4b0c 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -178,6 +178,11 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
retval = -ENODEV;
goto err2;
}
+
+ ehci_fsl->have_hcd = 1;
+ } else {
+ dev_err(&pdev->dev, "wrong operating mode\n");
+ return -ENODEV;
}
#endif
return retval;
--
1.8.3.1

2015-05-07 12:37:12

by Ramneek Mehresh

[permalink] [raw]
Subject: [PATCH 08/10] usb:fsl:otg: Add host-gadget drv sync delay

Resolve synchronization issue between host and gadget drivers
upon role-reversal

Signed-off-by: Ramneek Mehresh <[email protected]>
Reviewed-by: Li Yang-R58472 <[email protected]>
Reviewed-by: Fleming Andrew-AFLEMING <[email protected]>
Tested-by: Fleming Andrew-AFLEMING <[email protected]>
---
drivers/usb/phy/phy-fsl-usb.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index ce40d5c..a3a578d 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -544,8 +544,17 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on)
dev = otg->gadget->dev.parent;

if (on) {
- if (dev->driver->resume)
+ /* Delay gadget resume to synchronize between host and gadget
+ * drivers. Upon role-reversal host drv is shutdown by kernel
+ * worker thread. By the time host drv shuts down, controller
+ * gets programmed for gadget role. Shutting host drv after
+ * this results in controller getting reset, and it stops
+ * responding to otg events
+ */
+ if (dev->driver->resume) {
+ msleep(1000);
dev->driver->resume(dev);
+ }
} else {
if (dev->driver->suspend)
dev->driver->suspend(dev, otg_suspend_state);
--
1.8.3.1

2015-05-07 12:36:24

by Ramneek Mehresh

[permalink] [raw]
Subject: [PATCH 09/10] usb:fsl:otg: Resolve OTG crash issue with another host

Resolves kernel crash issue when a USB flash drive is inserted
into USB1 port with USB2 port configured as otg. Removing
"else" block so that the controller coming up in "non-otg" mode
doesn't return -ENODEV. Returning "ENODEV" results in platform
framework unbinding platform-drv from controller resulting in
kernel crash later in hub driver

Signed-off-by: Ramneek Mehresh <[email protected]>
---
drivers/usb/host/ehci-fsl.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 4bd4b0c..8d55f2b 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -180,9 +180,6 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
}

ehci_fsl->have_hcd = 1;
- } else {
- dev_err(&pdev->dev, "wrong operating mode\n");
- return -ENODEV;
}
#endif
return retval;
--
1.8.3.1

2015-05-07 12:36:30

by Ramneek Mehresh

[permalink] [raw]
Subject: [PATCH 10/10] usb:fsl:otg: Make fsl otg driver as tristate

Provide option to load fsl otg driver as loadable
module

Signed-off-by: Ramneek Mehresh <[email protected]>
---
drivers/usb/phy/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 2175678..4927905 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -19,7 +19,7 @@ config AB8500_USB
in host mode, low speed.

config FSL_USB2_OTG
- bool "Freescale USB OTG Transceiver Driver"
+ tristate "Freescale USB OTG Transceiver Driver"
depends on USB_EHCI_FSL && USB_FSL_USB2 && USB_OTG_FSM && PM
select USB_OTG
select USB_PHY
--
1.8.3.1

2015-05-07 13:01:37

by Sergei Shtylyov

[permalink] [raw]
Subject: Re: [PATCH 09/10] usb:fsl:otg: Resolve OTG crash issue with another host

Hello.

On 5/7/2015 3:47 PM, Ramneek Mehresh wrote:

> Resolves kernel crash issue when a USB flash drive is inserted
> into USB1 port with USB2 port configured as otg. Removing
> "else" block so that the controller coming up in "non-otg" mode
> doesn't return -ENODEV. Returning "ENODEV" results in platform
> framework unbinding platform-drv from controller resulting in
> kernel crash later in hub driver

> Signed-off-by: Ramneek Mehresh <[email protected]>
> ---
> drivers/usb/host/ehci-fsl.c | 3 ---
> 1 file changed, 3 deletions(-)

> diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> index 4bd4b0c..8d55f2b 100644
> --- a/drivers/usb/host/ehci-fsl.c
> +++ b/drivers/usb/host/ehci-fsl.c
> @@ -180,9 +180,6 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
> }
>
> ehci_fsl->have_hcd = 1;
> - } else {
> - dev_err(&pdev->dev, "wrong operating mode\n");
> - return -ENODEV;

Isn't it easier to just not add this code in the patch #7?

WBR, Sergei

2015-05-07 14:45:44

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH 03/10] usb:fsl:otg: Add support to add/remove usb host driver

On Thu, 7 May 2015, Ramneek Mehresh wrote:

> Add workqueue to add/remove host driver (outside interrupt context)
> upon each id change
>
> Signed-off-by: Li Yang <[email protected]>
> Signed-off-by: Ramneek Mehresh <[email protected]>

> +#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)

We have IS_ENABLED() for things like this.

Alan Stern

2015-05-07 14:46:10

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH 02/10] drivers:host:fsl: Use ehci_overrides structure for EHCI drv

On Thu, 7 May 2015, Ramneek Mehresh wrote:

> Make use of ehci_driver_overrides structure for ehci-fsl
> driver
>
> Signed-off-by: Ramneek Mehresh <[email protected]>

You need to change a lot more than this. See commit a76dd463c58e (USB:
EHCI: make ehci-orion a separate driver) as an example of what is
needed. In the end, ehci-fsl.ko should be a new driver module, not
compiled into ehci-hcd.ko.

> + ehci_init_driver(driver, &ehci_fsl_overrides);
> + driver->product_desc = "Freescale On-Chip EHCI Host Controller";
> + driver->start = ehci_run;
> + driver->start_port_reset = ehci_start_port_reset;

Why do you want to override driver->start? The default value
for this field is already set to ehci_run.

Alan Stern

2015-05-08 05:03:59

by Ramneek Mehresh

[permalink] [raw]
Subject: RE: [PATCH 02/10] drivers:host:fsl: Use ehci_overrides structure for EHCI drv



> -----Original Message-----
> From: Alan Stern [mailto:[email protected]]
> Sent: Thursday, May 07, 2015 8:16 PM
> To: Mehresh Ramneek-B31383
> Cc: [email protected]; [email protected]; [email protected];
> [email protected]
> Subject: Re: [PATCH 02/10] drivers:host:fsl: Use ehci_overrides structure for
> EHCI drv
>
> On Thu, 7 May 2015, Ramneek Mehresh wrote:
>
> > Make use of ehci_driver_overrides structure for ehci-fsl driver
> >
> > Signed-off-by: Ramneek Mehresh <[email protected]>
>
> You need to change a lot more than this. See commit a76dd463c58e (USB:
> EHCI: make ehci-orion a separate driver) as an example of what is needed. In
> the end, ehci-fsl.ko should be a new driver module, not compiled into ehci-
> hcd.ko.
>
I can definitely make this change, but this patch set is about OTG functionality
fix for all FSL QorIQ socs. Changes you are asking are for FSL Host driver. For that
I can float separate patch/patch set. Hence, I would request you to please accept the
Patch series in conext of OTG functionality fix
> > + ehci_init_driver(driver, &ehci_fsl_overrides);
> > + driver->product_desc = "Freescale On-Chip EHCI Host Controller";
> > + driver->start = ehci_run;
> > + driver->start_port_reset = ehci_start_port_reset;
>
> Why do you want to override driver->start? The default value for this field is
> already set to ehci_run.
>
Will correct this
> Alan Stern

2015-05-08 05:28:52

by Ramneek Mehresh

[permalink] [raw]
Subject: RE: [PATCH 09/10] usb:fsl:otg: Resolve OTG crash issue with another host



> -----Original Message-----
> From: Sergei Shtylyov [mailto:[email protected]]
> Sent: Thursday, May 07, 2015 6:32 PM
> To: Mehresh Ramneek-B31383; [email protected]
> Cc: [email protected]; [email protected]; [email protected];
> [email protected]
> Subject: Re: [PATCH 09/10] usb:fsl:otg: Resolve OTG crash issue with another
> host
>
> Hello.
>
> On 5/7/2015 3:47 PM, Ramneek Mehresh wrote:
>
> > Resolves kernel crash issue when a USB flash drive is inserted into
> > USB1 port with USB2 port configured as otg. Removing "else" block so
> > that the controller coming up in "non-otg" mode doesn't return
> > -ENODEV. Returning "ENODEV" results in platform framework unbinding
> > platform-drv from controller resulting in kernel crash later in hub
> > driver
>
> > Signed-off-by: Ramneek Mehresh <[email protected]>
> > ---
> > drivers/usb/host/ehci-fsl.c | 3 ---
> > 1 file changed, 3 deletions(-)
>
> > diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> > index 4bd4b0c..8d55f2b 100644
> > --- a/drivers/usb/host/ehci-fsl.c
> > +++ b/drivers/usb/host/ehci-fsl.c
> > @@ -180,9 +180,6 @@ static int usb_hcd_fsl_probe(const struct hc_driver
> *driver,
> > }
> >
> > ehci_fsl->have_hcd = 1;
> > - } else {
> > - dev_err(&pdev->dev, "wrong operating mode\n");
> > - return -ENODEV;
>
> Isn't it easier to just not add this code in the patch #7?
>
Will do, thanks
> WBR, Sergei

2015-05-08 08:35:48

by Paul Bolle

[permalink] [raw]
Subject: Re: [PATCH 10/10] usb:fsl:otg: Make fsl otg driver as tristate

On Thu, 2015-05-07 at 18:17 +0530, Ramneek Mehresh wrote:
> Provide option to load fsl otg driver as loadable
> module

(Full stop at the end of that sentence, please.)

In case anyone is wondering: this is all that's needed to allow the
build of a phy-fsl-usb.ko module because the code already contains the
required module specific boilerplate. Actually, that boilerplate has
always been there since this driver was added in v3.0, as a built-in
only driver, through commit 0807c500a1a6 ("USB: add Freescale USB OTG
Transceiver driver").

(Of course, this assumes building modular and loading the module
actually works, none of which I have tried myself.)

> Signed-off-by: Ramneek Mehresh <[email protected]>
> ---
> drivers/usb/phy/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> index 2175678..4927905 100644
> --- a/drivers/usb/phy/Kconfig
> +++ b/drivers/usb/phy/Kconfig
> @@ -19,7 +19,7 @@ config AB8500_USB
> in host mode, low speed.
>
> config FSL_USB2_OTG
> - bool "Freescale USB OTG Transceiver Driver"
> + tristate "Freescale USB OTG Transceiver Driver"
> depends on USB_EHCI_FSL && USB_FSL_USB2 && USB_OTG_FSM && PM
> select USB_OTG
> select USB_PHY


Paul Bolle

2015-05-08 14:26:12

by Alan Stern

[permalink] [raw]
Subject: RE: [PATCH 02/10] drivers:host:fsl: Use ehci_overrides structure for EHCI drv

On Fri, 8 May 2015, Ramneek Mehresh wrote:

> > On Thu, 7 May 2015, Ramneek Mehresh wrote:
> >
> > > Make use of ehci_driver_overrides structure for ehci-fsl driver
> > >
> > > Signed-off-by: Ramneek Mehresh <[email protected]>
> >
> > You need to change a lot more than this. See commit a76dd463c58e (USB:
> > EHCI: make ehci-orion a separate driver) as an example of what is needed. In
> > the end, ehci-fsl.ko should be a new driver module, not compiled into ehci-
> > hcd.ko.
> >
> I can definitely make this change, but this patch set is about OTG functionality
> fix for all FSL QorIQ socs. Changes you are asking are for FSL Host driver. For that
> I can float separate patch/patch set. Hence, I would request you to please accept the
> Patch series in conext of OTG functionality fix

Accept which patch series? You have posted several different versions
(and you failed to put the version numbers in the email Subject:
lines, so I can't tell which patches belong to which version!).

I am not going to accept something that does a partial job of
converting ehci-fsl into a separate module. Either do the entire
conversion first, as a separate patch that is prerequisite to the OTG
fix, or else fix the OTG stuff in a way that doesn't require ehci-fsl
to be a separate module.

Alan Stern

2015-05-11 05:18:15

by Ramneek Mehresh

[permalink] [raw]
Subject: RE: [PATCH 02/10] drivers:host:fsl: Use ehci_overrides structure for EHCI drv



> -----Original Message-----
> From: Alan Stern [mailto:[email protected]]
> Sent: Friday, May 08, 2015 7:56 PM
> To: Mehresh Ramneek-B31383
> Cc: [email protected]; [email protected]; [email protected];
> [email protected]
> Subject: RE: [PATCH 02/10] drivers:host:fsl: Use ehci_overrides structure for
> EHCI drv
>
> On Fri, 8 May 2015, Ramneek Mehresh wrote:
>
> > > On Thu, 7 May 2015, Ramneek Mehresh wrote:
> > >
> > > > Make use of ehci_driver_overrides structure for ehci-fsl driver
> > > >
> > > > Signed-off-by: Ramneek Mehresh
> <[email protected]>
> > >
> > > You need to change a lot more than this. See commit a76dd463c58e
> (USB:
> > > EHCI: make ehci-orion a separate driver) as an example of what is
> > > needed. In the end, ehci-fsl.ko should be a new driver module, not
> > > compiled into ehci- hcd.ko.
> > >
> > I can definitely make this change, but this patch set is about OTG
> > functionality fix for all FSL QorIQ socs. Changes you are asking are
> > for FSL Host driver. For that I can float separate patch/patch set.
> > Hence, I would request you to please accept the Patch series in conext
> > of OTG functionality fix
>
> Accept which patch series? You have posted several different versions (and
> you failed to put the version numbers in the email Subject:
> lines, so I can't tell which patches belong to which version!).
>
> I am not going to accept something that does a partial job of converting ehci-
> fsl into a separate module. Either do the entire conversion first, as a
> separate patch that is prerequisite to the OTG fix, or else fix the OTG stuff in
> a way that doesn't require ehci-fsl to be a separate module.
>
Ok, then let me first fix USB host driver as per expectation...
I'll then re-send OTG patch set over that...I don't want to intermingle these two
separate functionalities. Thanks.

> Alan Stern