* [PATCH v15 01/13] usb: chipidea: move vbus regulator operation to core
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
@ 2013-08-12 1:22 ` Peter Chen
2013-08-12 1:22 ` [PATCH v15 02/13] usb: chipidea: host: add vbus regulator control Peter Chen
` (13 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-12 1:22 UTC (permalink / raw)
To: linux-arm-kernel
The vbus regulator is a common element for USB vbus operation,
So, move it from glue layer to core.
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/ci_hdrc_imx.c | 26 ++------------------------
drivers/usb/chipidea/core.c | 23 +++++++++++++++++++++++
include/linux/usb/chipidea.h | 1 +
3 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 35008e3..bd1fe25 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -19,7 +19,6 @@
#include <linux/dma-mapping.h>
#include <linux/usb/chipidea.h>
#include <linux/clk.h>
-#include <linux/regulator/consumer.h>
#include "ci.h"
#include "ci_hdrc_imx.h"
@@ -31,7 +30,6 @@ struct ci_hdrc_imx_data {
struct usb_phy *phy;
struct platform_device *ci_pdev;
struct clk *clk;
- struct regulator *reg_vbus;
};
static const struct usbmisc_ops *usbmisc_ops;
@@ -134,20 +132,6 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
goto err_clk;
}
- /* we only support host now, so enable vbus here */
- data->reg_vbus = devm_regulator_get(&pdev->dev, "vbus");
- if (!IS_ERR(data->reg_vbus)) {
- ret = regulator_enable(data->reg_vbus);
- if (ret) {
- dev_err(&pdev->dev,
- "Failed to enable vbus regulator, err=%d\n",
- ret);
- goto err_clk;
- }
- } else {
- data->reg_vbus = NULL;
- }
-
pdata.phy = data->phy;
if (!pdev->dev.dma_mask)
@@ -160,7 +144,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
if (ret) {
dev_err(&pdev->dev,
"usbmisc init failed, ret=%d\n", ret);
- goto err;
+ goto err_clk;
}
}
@@ -172,7 +156,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
dev_err(&pdev->dev,
"Can't register ci_hdrc platform device, err=%d\n",
ret);
- goto err;
+ goto err_clk;
}
if (usbmisc_ops && usbmisc_ops->post) {
@@ -193,9 +177,6 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
disable_device:
ci_hdrc_remove_device(data->ci_pdev);
-err:
- if (data->reg_vbus)
- regulator_disable(data->reg_vbus);
err_clk:
clk_disable_unprepare(data->clk);
return ret;
@@ -208,9 +189,6 @@ static int ci_hdrc_imx_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
ci_hdrc_remove_device(data->ci_pdev);
- if (data->reg_vbus)
- regulator_disable(data->reg_vbus);
-
if (data->phy)
usb_phy_shutdown(data->phy);
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 3126c03..26f6599 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -65,6 +65,7 @@
#include <linux/usb/chipidea.h>
#include <linux/usb/of.h>
#include <linux/phy.h>
+#include <linux/regulator/consumer.h>
#include "ci.h"
#include "udc.h"
@@ -342,6 +343,24 @@ static irqreturn_t ci_irq(int irq, void *data)
return ret;
}
+static int ci_get_platdata(struct device *dev,
+ struct ci_hdrc_platform_data *platdata)
+{
+ /* Get the vbus regulator */
+ platdata->reg_vbus = devm_regulator_get(dev, "vbus");
+ if (PTR_ERR(platdata->reg_vbus) == -EPROBE_DEFER) {
+ return -EPROBE_DEFER;
+ } else if (PTR_ERR(platdata->reg_vbus) == -ENODEV) {
+ platdata->reg_vbus = NULL; /* no vbus regualator is needed */
+ } else if (IS_ERR(platdata->reg_vbus)) {
+ dev_err(dev, "Getting regulator error: %ld\n",
+ PTR_ERR(platdata->reg_vbus));
+ return PTR_ERR(platdata->reg_vbus);
+ }
+
+ return 0;
+}
+
static DEFINE_IDA(ci_ida);
struct platform_device *ci_hdrc_add_device(struct device *dev,
@@ -351,6 +370,10 @@ struct platform_device *ci_hdrc_add_device(struct device *dev,
struct platform_device *pdev;
int id, ret;
+ ret = ci_get_platdata(dev, platdata);
+ if (ret)
+ return ERR_PTR(ret);
+
id = ida_simple_get(&ci_ida, 0, 0, GFP_KERNEL);
if (id < 0)
return ERR_PTR(id);
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index 2562994..ce4e1aa 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -24,6 +24,7 @@ struct ci_hdrc_platform_data {
#define CI_HDRC_CONTROLLER_RESET_EVENT 0
#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
void (*notify_event) (struct ci_hdrc *ci, unsigned event);
+ struct regulator *reg_vbus;
};
/* Default offset of capability registers */
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v15 02/13] usb: chipidea: host: add vbus regulator control
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
2013-08-12 1:22 ` [PATCH v15 01/13] usb: chipidea: move vbus regulator operation to core Peter Chen
@ 2013-08-12 1:22 ` Peter Chen
2013-08-12 1:22 ` [PATCH v15 03/13] usb: chipidea: udc: otg_set_peripheral is useless for some chipidea users Peter Chen
` (12 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-12 1:22 UTC (permalink / raw)
To: linux-arm-kernel
For boards which have board level vbus control (eg, through gpio), we
need to vbus operation according to below rules:
- For host, we need open vbus before start hcd, and close it
after remove hcd.
- For otg, the vbus needs to be on/off when usb role switches.
When the host roles begins, it opens vbus; when the host role
finishes, it closes vbus.
We put vbus operation to host as host is the only vbus user,
When we are at host mode, the vbus is on, when we are not at
host mode, vbus should be off.
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/host.c | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 40d0fda..e94e52b 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -24,6 +24,7 @@
#include <linux/usb.h>
#include <linux/usb/hcd.h>
#include <linux/usb/chipidea.h>
+#include <linux/regulator/consumer.h>
#include "../host/ehci.h"
@@ -64,9 +65,19 @@ static int host_start(struct ci_hdrc *ci)
ehci->caps = ci->hw_bank.cap;
ehci->has_hostpc = ci->hw_bank.lpm;
+ if (ci->platdata->reg_vbus) {
+ ret = regulator_enable(ci->platdata->reg_vbus);
+ if (ret) {
+ dev_err(ci->dev,
+ "Failed to enable vbus regulator, ret=%d\n",
+ ret);
+ goto put_hcd;
+ }
+ }
+
ret = usb_add_hcd(hcd, 0, 0);
if (ret)
- usb_put_hcd(hcd);
+ goto disable_reg;
else
ci->hcd = hcd;
@@ -74,6 +85,14 @@ static int host_start(struct ci_hdrc *ci)
hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
return ret;
+
+disable_reg:
+ regulator_disable(ci->platdata->reg_vbus);
+
+put_hcd:
+ usb_put_hcd(hcd);
+
+ return ret;
}
static void host_stop(struct ci_hdrc *ci)
@@ -82,6 +101,8 @@ static void host_stop(struct ci_hdrc *ci)
usb_remove_hcd(hcd);
usb_put_hcd(hcd);
+ if (ci->platdata->reg_vbus)
+ regulator_disable(ci->platdata->reg_vbus);
}
int ci_hdrc_host_init(struct ci_hdrc *ci)
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v15 03/13] usb: chipidea: udc: otg_set_peripheral is useless for some chipidea users
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
2013-08-12 1:22 ` [PATCH v15 01/13] usb: chipidea: move vbus regulator operation to core Peter Chen
2013-08-12 1:22 ` [PATCH v15 02/13] usb: chipidea: host: add vbus regulator control Peter Chen
@ 2013-08-12 1:22 ` Peter Chen
2013-08-12 1:22 ` [PATCH v15 04/13] usb: chipidea: otg: Add otg file used to access otgsc Peter Chen
` (11 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-12 1:22 UTC (permalink / raw)
To: linux-arm-kernel
It is useless at below cases:
- If we implement both usb host and device at chipidea driver.
- If we don't need phy->otg.
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/udc.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index e475fcd..116c762 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1805,7 +1805,12 @@ static int udc_start(struct ci_hdrc *ci)
if (ci->transceiver) {
retval = otg_set_peripheral(ci->transceiver->otg,
&ci->gadget);
- if (retval)
+ /*
+ * If we implement all USB functions using chipidea drivers,
+ * it doesn't need to call above API, meanwhile, if we only
+ * use gadget function, calling above API is useless.
+ */
+ if (retval && retval != -ENOTSUPP)
goto put_transceiver;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v15 04/13] usb: chipidea: otg: Add otg file used to access otgsc
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
` (2 preceding siblings ...)
2013-08-12 1:22 ` [PATCH v15 03/13] usb: chipidea: udc: otg_set_peripheral is useless for some chipidea users Peter Chen
@ 2013-08-12 1:22 ` Peter Chen
2013-08-12 1:22 ` [PATCH v15 05/13] usb: chipidea: Add role init and destroy APIs Peter Chen
` (10 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-12 1:22 UTC (permalink / raw)
To: linux-arm-kernel
This file is mainly used to access otgsc currently, it may
add otg related things in the future.
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/Makefile | 2 +-
drivers/usb/chipidea/bits.h | 10 ++++++++++
drivers/usb/chipidea/core.c | 3 ++-
drivers/usb/chipidea/otg.c | 35 +++++++++++++++++++++++++++++++++++
drivers/usb/chipidea/otg.h | 32 ++++++++++++++++++++++++++++++++
5 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 6cf5f68..a99d980 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -2,7 +2,7 @@ ccflags-$(CONFIG_USB_CHIPIDEA_DEBUG) := -DDEBUG
obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o
-ci_hdrc-y := core.o
+ci_hdrc-y := core.o otg.o
ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o
ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST) += host.o
ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG) += debug.o
diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index aefa026..dd0cf9e 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -79,11 +79,21 @@
#define OTGSC_ASVIS BIT(18)
#define OTGSC_BSVIS BIT(19)
#define OTGSC_BSEIS BIT(20)
+#define OTGSC_1MSIS BIT(21)
+#define OTGSC_DPIS BIT(22)
#define OTGSC_IDIE BIT(24)
#define OTGSC_AVVIE BIT(25)
#define OTGSC_ASVIE BIT(26)
#define OTGSC_BSVIE BIT(27)
#define OTGSC_BSEIE BIT(28)
+#define OTGSC_1MSIE BIT(29)
+#define OTGSC_DPIE BIT(30)
+#define OTGSC_INT_EN_BITS (OTGSC_IDIE | OTGSC_AVVIE | OTGSC_ASVIE \
+ | OTGSC_BSVIE | OTGSC_BSEIE | OTGSC_1MSIE \
+ | OTGSC_DPIE)
+#define OTGSC_INT_STATUS_BITS (OTGSC_IDIS | OTGSC_AVVIS | OTGSC_ASVIS \
+ | OTGSC_BSVIS | OTGSC_BSEIS | OTGSC_1MSIS \
+ | OTGSC_DPIS)
/* USBMODE */
#define USBMODE_CM (0x03UL << 0)
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 26f6599..a4be8a5 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -72,6 +72,7 @@
#include "bits.h"
#include "host.h"
#include "debug.h"
+#include "otg.h"
/* Controller register map */
static uintptr_t ci_regs_nolpm[] = {
@@ -530,7 +531,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
goto stop;
if (ci->is_otg)
- hw_write(ci, OP_OTGSC, OTGSC_IDIE, OTGSC_IDIE);
+ ci_hdrc_otg_init(ci);
ret = dbg_create_files(ci);
if (!ret)
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
new file mode 100644
index 0000000..999a085
--- /dev/null
+++ b/drivers/usb/chipidea/otg.c
@@ -0,0 +1,35 @@
+/*
+ * otg.c - ChipIdea USB IP core OTG driver
+ *
+ * Copyright (C) 2013 Freescale Semiconductor, Inc.
+ *
+ * Author: Peter Chen
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * This file mainly handles otgsc register, it may include OTG operation
+ * in the future.
+ */
+
+#include <linux/usb/otg.h>
+#include <linux/usb/gadget.h>
+#include <linux/usb/chipidea.h>
+
+#include "ci.h"
+#include "bits.h"
+#include "otg.h"
+
+/**
+ * ci_hdrc_otg_init - initialize otgsc bits
+ * ci: the controller
+ */
+int ci_hdrc_otg_init(struct ci_hdrc *ci)
+{
+ ci_enable_otg_interrupt(ci, OTGSC_IDIE);
+
+ return 0;
+}
diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h
new file mode 100644
index 0000000..376eaee
--- /dev/null
+++ b/drivers/usb/chipidea/otg.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2013 Freescale Semiconductor, Inc.
+ *
+ * Author: Peter Chen
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __DRIVERS_USB_CHIPIDEA_OTG_H
+#define __DRIVERS_USB_CHIPIDEA_OTG_H
+
+static inline void ci_clear_otg_interrupt(struct ci_hdrc *ci, u32 bits)
+{
+ /* Only clear request bits */
+ hw_write(ci, OP_OTGSC, OTGSC_INT_STATUS_BITS, bits);
+}
+
+static inline void ci_enable_otg_interrupt(struct ci_hdrc *ci, u32 bits)
+{
+ hw_write(ci, OP_OTGSC, bits, bits);
+}
+
+static inline void ci_disable_otg_interrupt(struct ci_hdrc *ci, u32 bits)
+{
+ hw_write(ci, OP_OTGSC, bits, 0);
+}
+
+int ci_hdrc_otg_init(struct ci_hdrc *ci);
+
+#endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v15 05/13] usb: chipidea: Add role init and destroy APIs
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
` (3 preceding siblings ...)
2013-08-12 1:22 ` [PATCH v15 04/13] usb: chipidea: otg: Add otg file used to access otgsc Peter Chen
@ 2013-08-12 1:22 ` Peter Chen
2013-08-12 1:22 ` [PATCH v15 06/13] usb: chipidea: add flag CI_HDRC_DUAL_ROLE_NOT_OTG Peter Chen
` (9 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-12 1:22 UTC (permalink / raw)
To: linux-arm-kernel
- The role's init will be called at probe procedure.
- The role's destroy will be called at fail patch
at probe and driver's removal.
- The role's start/stop will be called when specific
role has started.
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/core.c | 10 ++++++++--
drivers/usb/chipidea/host.c | 7 +++++++
drivers/usb/chipidea/host.h | 6 ++++++
drivers/usb/chipidea/udc.c | 36 +++++++++++++++++++++++++++---------
drivers/usb/chipidea/udc.h | 6 ++++++
5 files changed, 54 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index a4be8a5..bfc9aef 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -420,6 +420,12 @@ void ci_hdrc_remove_device(struct platform_device *pdev)
}
EXPORT_SYMBOL_GPL(ci_hdrc_remove_device);
+static inline void ci_role_destroy(struct ci_hdrc *ci)
+{
+ ci_hdrc_gadget_destroy(ci);
+ ci_hdrc_host_destroy(ci);
+}
+
static int ci_hdrc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -539,7 +545,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
free_irq(ci->irq, ci);
stop:
- ci_role_stop(ci);
+ ci_role_destroy(ci);
rm_wq:
flush_workqueue(ci->wq);
destroy_workqueue(ci->wq);
@@ -555,7 +561,7 @@ static int ci_hdrc_remove(struct platform_device *pdev)
flush_workqueue(ci->wq);
destroy_workqueue(ci->wq);
free_irq(ci->irq, ci);
- ci_role_stop(ci);
+ ci_role_destroy(ci);
return 0;
}
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index e94e52b..382be5b 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -105,6 +105,13 @@ static void host_stop(struct ci_hdrc *ci)
regulator_disable(ci->platdata->reg_vbus);
}
+
+void ci_hdrc_host_destroy(struct ci_hdrc *ci)
+{
+ if (ci->role == CI_ROLE_HOST)
+ host_stop(ci);
+}
+
int ci_hdrc_host_init(struct ci_hdrc *ci)
{
struct ci_role_driver *rdrv;
diff --git a/drivers/usb/chipidea/host.h b/drivers/usb/chipidea/host.h
index 058875c..5707bf3 100644
--- a/drivers/usb/chipidea/host.h
+++ b/drivers/usb/chipidea/host.h
@@ -4,6 +4,7 @@
#ifdef CONFIG_USB_CHIPIDEA_HOST
int ci_hdrc_host_init(struct ci_hdrc *ci);
+void ci_hdrc_host_destroy(struct ci_hdrc *ci);
#else
@@ -12,6 +13,11 @@ static inline int ci_hdrc_host_init(struct ci_hdrc *ci)
return -ENXIO;
}
+static inline void ci_hdrc_host_destroy(struct ci_hdrc *ci)
+{
+
+}
+
#endif
#endif /* __DRIVERS_USB_CHIPIDEA_HOST_H */
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 116c762..24a100d 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -27,6 +27,7 @@
#include "udc.h"
#include "bits.h"
#include "debug.h"
+#include "otg.h"
/* control endpoint description */
static const struct usb_endpoint_descriptor
@@ -1844,13 +1845,13 @@ free_qh_pool:
}
/**
- * udc_remove: parent remove must call this to remove UDC
+ * ci_hdrc_gadget_destroy: parent remove must call this to remove UDC
*
* No interrupts active, the IRQ has been released
*/
-static void udc_stop(struct ci_hdrc *ci)
+void ci_hdrc_gadget_destroy(struct ci_hdrc *ci)
{
- if (ci == NULL)
+ if (!ci->roles[CI_ROLE_GADGET])
return;
usb_del_gadget_udc(&ci->gadget);
@@ -1865,15 +1866,32 @@ static void udc_stop(struct ci_hdrc *ci)
if (ci->global_phy)
usb_put_phy(ci->transceiver);
}
- /* my kobject is dynamic, I swear! */
- memset(&ci->gadget, 0, sizeof(ci->gadget));
+}
+
+static int udc_id_switch_for_device(struct ci_hdrc *ci)
+{
+ if (ci->is_otg) {
+ ci_clear_otg_interrupt(ci, OTGSC_BSVIS);
+ ci_enable_otg_interrupt(ci, OTGSC_BSVIE);
+ }
+
+ return 0;
+}
+
+static void udc_id_switch_for_host(struct ci_hdrc *ci)
+{
+ if (ci->is_otg) {
+ /* host doesn't care B_SESSION_VALID event */
+ ci_clear_otg_interrupt(ci, OTGSC_BSVIS);
+ ci_disable_otg_interrupt(ci, OTGSC_BSVIE);
+ }
}
/**
* ci_hdrc_gadget_init - initialize device related bits
* ci: the controller
*
- * This function enables the gadget role, if the device is "device capable".
+ * This function initializes the gadget, if the device is "device capable".
*/
int ci_hdrc_gadget_init(struct ci_hdrc *ci)
{
@@ -1886,11 +1904,11 @@ int ci_hdrc_gadget_init(struct ci_hdrc *ci)
if (!rdrv)
return -ENOMEM;
- rdrv->start = udc_start;
- rdrv->stop = udc_stop;
+ rdrv->start = udc_id_switch_for_device;
+ rdrv->stop = udc_id_switch_for_host;
rdrv->irq = udc_irq;
rdrv->name = "gadget";
ci->roles[CI_ROLE_GADGET] = rdrv;
- return 0;
+ return udc_start(ci);
}
diff --git a/drivers/usb/chipidea/udc.h b/drivers/usb/chipidea/udc.h
index 455ac21..e66df00 100644
--- a/drivers/usb/chipidea/udc.h
+++ b/drivers/usb/chipidea/udc.h
@@ -84,6 +84,7 @@ struct ci_hw_req {
#ifdef CONFIG_USB_CHIPIDEA_UDC
int ci_hdrc_gadget_init(struct ci_hdrc *ci);
+void ci_hdrc_gadget_destroy(struct ci_hdrc *ci);
#else
@@ -92,6 +93,11 @@ static inline int ci_hdrc_gadget_init(struct ci_hdrc *ci)
return -ENXIO;
}
+static inline void ci_hdrc_gadget_destroy(struct ci_hdrc *ci)
+{
+
+}
+
#endif
#endif /* __DRIVERS_USB_CHIPIDEA_UDC_H */
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v15 06/13] usb: chipidea: add flag CI_HDRC_DUAL_ROLE_NOT_OTG
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
` (4 preceding siblings ...)
2013-08-12 1:22 ` [PATCH v15 05/13] usb: chipidea: Add role init and destroy APIs Peter Chen
@ 2013-08-12 1:22 ` Peter Chen
2013-08-12 1:22 ` [PATCH v15 07/13] usb: chipidea: disable all interrupts and clear all interrupts status Peter Chen
` (8 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-12 1:22 UTC (permalink / raw)
To: linux-arm-kernel
Since we need otgsc to know vbus's status at some chipidea
controllers even it is peripheral-only mode. Besides, some
SoCs (eg, AR9331 SoC) don't have otgsc register even
the DCCPARAMS_DC and DCCPARAMS_HC are both 1 at CAP_DCCPARAMS.
We inroduce flag CI_HDRC_DUAL_ROLE_NOT_OTG to indicate if the
controller is dual role, but not supports OTG. If this flag is
not set, we follow the rule that if DCCPARAMS_DC and DCCPARAMS_HC
are both 1 at CAP_DCCPARAMS, then this controller is otg capable.
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/core.c | 37 ++++++++++++++++++++++++++++++-------
include/linux/usb/chipidea.h | 5 +++++
2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index bfc9aef..56294e0 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -426,6 +426,18 @@ static inline void ci_role_destroy(struct ci_hdrc *ci)
ci_hdrc_host_destroy(ci);
}
+static void ci_get_otg_capable(struct ci_hdrc *ci)
+{
+ if (ci->platdata->flags & CI_HDRC_DUAL_ROLE_NOT_OTG)
+ ci->is_otg = false;
+ else
+ ci->is_otg = (hw_read(ci, CAP_DCCPARAMS,
+ DCCPARAMS_DC | DCCPARAMS_HC)
+ == (DCCPARAMS_DC | DCCPARAMS_HC));
+ if (ci->is_otg)
+ dev_dbg(ci->dev, "It is OTG capable controller\n");
+}
+
static int ci_hdrc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -482,6 +494,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}
+ ci_get_otg_capable(ci);
+
if (!ci->platdata->phy_mode)
ci->platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
@@ -514,10 +528,22 @@ static int ci_hdrc_probe(struct platform_device *pdev)
}
if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) {
- ci->is_otg = true;
- /* ID pin needs 1ms debouce time, we delay 2ms for safe */
- mdelay(2);
- ci->role = ci_otg_role(ci);
+ if (ci->is_otg) {
+ /*
+ * ID pin needs 1ms debouce time,
+ * we delay 2ms for safe.
+ */
+ mdelay(2);
+ ci->role = ci_otg_role(ci);
+ ci_hdrc_otg_init(ci);
+ } else {
+ /*
+ * If the controller is not OTG capable, but support
+ * role switch, the defalt role is gadget, and the
+ * user can switch it through debugfs.
+ */
+ ci->role = CI_ROLE_GADGET;
+ }
} else {
ci->role = ci->roles[CI_ROLE_HOST]
? CI_ROLE_HOST
@@ -536,9 +562,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
if (ret)
goto stop;
- if (ci->is_otg)
- ci_hdrc_otg_init(ci);
-
ret = dbg_create_files(ci);
if (!ret)
return 0;
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index ce4e1aa..10a607c 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -20,6 +20,11 @@ struct ci_hdrc_platform_data {
#define CI_HDRC_REQUIRE_TRANSCEIVER BIT(1)
#define CI_HDRC_PULLUP_ON_VBUS BIT(2)
#define CI_HDRC_DISABLE_STREAMING BIT(3)
+ /*
+ * Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1,
+ * but otg is not supported (no register otgsc).
+ */
+#define CI_HDRC_DUAL_ROLE_NOT_OTG BIT(4)
enum usb_dr_mode dr_mode;
#define CI_HDRC_CONTROLLER_RESET_EVENT 0
#define CI_HDRC_CONTROLLER_STOPPED_EVENT 1
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v15 07/13] usb: chipidea: disable all interrupts and clear all interrupts status
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
` (5 preceding siblings ...)
2013-08-12 1:22 ` [PATCH v15 06/13] usb: chipidea: add flag CI_HDRC_DUAL_ROLE_NOT_OTG Peter Chen
@ 2013-08-12 1:22 ` Peter Chen
2013-08-12 1:22 ` [PATCH v15 08/13] usb: chipidea: move otg related things to otg file Peter Chen
` (7 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-12 1:22 UTC (permalink / raw)
To: linux-arm-kernel
During the initialization, it needs to disable all interrupts
enable bit as well as clear all interrupts status bits to avoid
exceptional interrupt.
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/core.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 56294e0..8ce0c45 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -199,6 +199,12 @@ static int hw_device_init(struct ci_hdrc *ci, void __iomem *base)
if (ci->hw_ep_max > ENDPT_MAX)
return -ENODEV;
+ /* Disable all interrupts bits */
+ hw_write(ci, OP_USBINTR, 0xffffffff, 0);
+
+ /* Clear all interrupts status bits*/
+ hw_write(ci, OP_USBSTS, 0xffffffff, 0xffffffff);
+
dev_dbg(ci->dev, "ChipIdea HDRC found, lpm: %d; cap: %p op: %p\n",
ci->hw_bank.lpm, ci->hw_bank.cap, ci->hw_bank.op);
@@ -434,8 +440,11 @@ static void ci_get_otg_capable(struct ci_hdrc *ci)
ci->is_otg = (hw_read(ci, CAP_DCCPARAMS,
DCCPARAMS_DC | DCCPARAMS_HC)
== (DCCPARAMS_DC | DCCPARAMS_HC));
- if (ci->is_otg)
+ if (ci->is_otg) {
dev_dbg(ci->dev, "It is OTG capable controller\n");
+ ci_disable_otg_interrupt(ci, OTGSC_INT_EN_BITS);
+ ci_clear_otg_interrupt(ci, OTGSC_INT_STATUS_BITS);
+ }
}
static int ci_hdrc_probe(struct platform_device *pdev)
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v15 08/13] usb: chipidea: move otg related things to otg file
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
` (6 preceding siblings ...)
2013-08-12 1:22 ` [PATCH v15 07/13] usb: chipidea: disable all interrupts and clear all interrupts status Peter Chen
@ 2013-08-12 1:22 ` Peter Chen
2013-08-12 1:22 ` [PATCH v15 09/13] usb: chipidea: add vbus interrupt handler Peter Chen
` (6 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-12 1:22 UTC (permalink / raw)
To: linux-arm-kernel
Move otg related things to otg file.
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/core.c | 63 +++++++++----------------------------------
drivers/usb/chipidea/otg.c | 57 +++++++++++++++++++++++++++++++++++++-
drivers/usb/chipidea/otg.h | 2 +
3 files changed, 70 insertions(+), 52 deletions(-)
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 8ce0c45..e869269 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -294,40 +294,6 @@ int hw_device_reset(struct ci_hdrc *ci, u32 mode)
return 0;
}
-/**
- * ci_otg_role - pick role based on ID pin state
- * @ci: the controller
- */
-static enum ci_role ci_otg_role(struct ci_hdrc *ci)
-{
- u32 sts = hw_read(ci, OP_OTGSC, ~0);
- enum ci_role role = sts & OTGSC_ID
- ? CI_ROLE_GADGET
- : CI_ROLE_HOST;
-
- return role;
-}
-
-/**
- * ci_role_work - perform role changing based on ID pin
- * @work: work struct
- */
-static void ci_role_work(struct work_struct *work)
-{
- struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work);
- enum ci_role role = ci_otg_role(ci);
-
- if (role != ci->role) {
- dev_dbg(ci->dev, "switching from %s to %s\n",
- ci_role(ci)->name, ci->roles[role]->name);
-
- ci_role_stop(ci);
- ci_role_start(ci, role);
- }
-
- enable_irq(ci->irq);
-}
-
static irqreturn_t ci_irq(int irq, void *data)
{
struct ci_hdrc *ci = data;
@@ -430,6 +396,8 @@ static inline void ci_role_destroy(struct ci_hdrc *ci)
{
ci_hdrc_gadget_destroy(ci);
ci_hdrc_host_destroy(ci);
+ if (ci->is_otg)
+ ci_hdrc_otg_destroy(ci);
}
static void ci_get_otg_capable(struct ci_hdrc *ci)
@@ -496,13 +464,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}
- INIT_WORK(&ci->work, ci_role_work);
- ci->wq = create_singlethread_workqueue("ci_otg");
- if (!ci->wq) {
- dev_err(dev, "can't create workqueue\n");
- return -ENODEV;
- }
-
ci_get_otg_capable(ci);
if (!ci->platdata->phy_mode)
@@ -532,8 +493,15 @@ static int ci_hdrc_probe(struct platform_device *pdev)
if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) {
dev_err(dev, "no supported roles\n");
- ret = -ENODEV;
- goto rm_wq;
+ return -ENODEV;
+ }
+
+ if (ci->is_otg) {
+ ret = ci_hdrc_otg_init(ci);
+ if (ret) {
+ dev_err(dev, "init otg fails, ret = %d\n", ret);
+ goto stop;
+ }
}
if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) {
@@ -544,7 +512,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
*/
mdelay(2);
ci->role = ci_otg_role(ci);
- ci_hdrc_otg_init(ci);
+ ci_enable_otg_interrupt(ci, OTGSC_IDIE);
} else {
/*
* If the controller is not OTG capable, but support
@@ -562,7 +530,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
ret = ci_role_start(ci, ci->role);
if (ret) {
dev_err(dev, "can't start %s role\n", ci_role(ci)->name);
- goto rm_wq;
+ goto stop;
}
platform_set_drvdata(pdev, ci);
@@ -578,9 +546,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
free_irq(ci->irq, ci);
stop:
ci_role_destroy(ci);
-rm_wq:
- flush_workqueue(ci->wq);
- destroy_workqueue(ci->wq);
return ret;
}
@@ -590,8 +555,6 @@ static int ci_hdrc_remove(struct platform_device *pdev)
struct ci_hdrc *ci = platform_get_drvdata(pdev);
dbg_remove_files(ci);
- flush_workqueue(ci->wq);
- destroy_workqueue(ci->wq);
free_irq(ci->irq, ci);
ci_role_destroy(ci);
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 999a085..3b66cbe 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -24,12 +24,65 @@
#include "otg.h"
/**
- * ci_hdrc_otg_init - initialize otgsc bits
+ * ci_otg_role - pick role based on ID pin state
+ * @ci: the controller
+ */
+enum ci_role ci_otg_role(struct ci_hdrc *ci)
+{
+ u32 sts = hw_read(ci, OP_OTGSC, ~0);
+ enum ci_role role = sts & OTGSC_ID
+ ? CI_ROLE_GADGET
+ : CI_ROLE_HOST;
+
+ return role;
+}
+
+/**
+ * ci_role_work - perform role changing based on ID pin
+ * @work: work struct
+ */
+static void ci_role_work(struct work_struct *work)
+{
+ struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work);
+ enum ci_role role = ci_otg_role(ci);
+
+ if (role != ci->role) {
+ dev_dbg(ci->dev, "switching from %s to %s\n",
+ ci_role(ci)->name, ci->roles[role]->name);
+
+ ci_role_stop(ci);
+ ci_role_start(ci, role);
+ }
+
+ enable_irq(ci->irq);
+}
+
+/**
+ * ci_hdrc_otg_init - initialize otg struct
* ci: the controller
*/
int ci_hdrc_otg_init(struct ci_hdrc *ci)
{
- ci_enable_otg_interrupt(ci, OTGSC_IDIE);
+ INIT_WORK(&ci->work, ci_role_work);
+ ci->wq = create_singlethread_workqueue("ci_otg");
+ if (!ci->wq) {
+ dev_err(ci->dev, "can't create workqueue\n");
+ return -ENODEV;
+ }
return 0;
}
+
+/**
+ * ci_hdrc_otg_destroy - destroy otg struct
+ * ci: the controller
+ */
+void ci_hdrc_otg_destroy(struct ci_hdrc *ci)
+{
+ if (ci->wq) {
+ flush_workqueue(ci->wq);
+ destroy_workqueue(ci->wq);
+ }
+ ci_disable_otg_interrupt(ci, OTGSC_INT_EN_BITS);
+ ci_clear_otg_interrupt(ci, OTGSC_INT_STATUS_BITS);
+}
diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h
index 376eaee..8acf3df 100644
--- a/drivers/usb/chipidea/otg.h
+++ b/drivers/usb/chipidea/otg.h
@@ -28,5 +28,7 @@ static inline void ci_disable_otg_interrupt(struct ci_hdrc *ci, u32 bits)
}
int ci_hdrc_otg_init(struct ci_hdrc *ci);
+void ci_hdrc_otg_destroy(struct ci_hdrc *ci);
+enum ci_role ci_otg_role(struct ci_hdrc *ci);
#endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v15 09/13] usb: chipidea: add vbus interrupt handler
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
` (7 preceding siblings ...)
2013-08-12 1:22 ` [PATCH v15 08/13] usb: chipidea: move otg related things to otg file Peter Chen
@ 2013-08-12 1:22 ` Peter Chen
2013-08-12 1:22 ` [PATCH v15 10/13] usb: chipidea: add wait vbus lower than OTGSC_BSV before role starts Peter Chen
` (5 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-12 1:22 UTC (permalink / raw)
To: linux-arm-kernel
We add vbus interrupt handler at ci_otg_work, it uses OTGSC_BSV(at otgsc)
to know it is connect or disconnet event.
Meanwhile, we introduce two flags id_event and b_sess_valid_event to
indicate it is an id interrupt or a vbus interrupt.
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/ci.h | 5 +++++
drivers/usb/chipidea/core.c | 28 +++++++++++++++++++++++-----
drivers/usb/chipidea/otg.c | 42 +++++++++++++++++++++++++++++++++++-------
drivers/usb/chipidea/otg.h | 1 +
drivers/usb/chipidea/udc.c | 7 +++++++
5 files changed, 71 insertions(+), 12 deletions(-)
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 33cb29f..3160363 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -132,6 +132,9 @@ struct hw_bank {
* @transceiver: pointer to USB PHY, if any
* @hcd: pointer to usb_hcd for ehci host driver
* @debugfs: root dentry for this controller in debugfs
+ * @id_event: indicates there is an id event, and handled at ci_otg_work
+ * @b_sess_valid_event: indicates there is a vbus event, and handled
+ * at ci_otg_work
*/
struct ci_hdrc {
struct device *dev;
@@ -168,6 +171,8 @@ struct ci_hdrc {
struct usb_phy *transceiver;
struct usb_hcd *hcd;
struct dentry *debugfs;
+ bool id_event;
+ bool b_sess_valid_event;
};
static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index e869269..ec0bb11 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -303,16 +303,34 @@ static irqreturn_t ci_irq(int irq, void *data)
if (ci->is_otg)
otgsc = hw_read(ci, OP_OTGSC, ~0);
- if (ci->role != CI_ROLE_END)
- ret = ci_role(ci)->irq(ci);
+ /*
+ * Handle id change interrupt, it indicates device/host function
+ * switch.
+ */
+ if (ci->is_otg && (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS)) {
+ ci->id_event = true;
+ ci_clear_otg_interrupt(ci, OTGSC_IDIS);
+ disable_irq_nosync(ci->irq);
+ queue_work(ci->wq, &ci->work);
+ return IRQ_HANDLED;
+ }
- if (ci->is_otg && (otgsc & OTGSC_IDIS)) {
- hw_write(ci, OP_OTGSC, OTGSC_IDIS, OTGSC_IDIS);
+ /*
+ * Handle vbus change interrupt, it indicates device connection
+ * and disconnection events.
+ */
+ if (ci->is_otg && (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS)) {
+ ci->b_sess_valid_event = true;
+ ci_clear_otg_interrupt(ci, OTGSC_BSVIS);
disable_irq_nosync(ci->irq);
queue_work(ci->wq, &ci->work);
- ret = IRQ_HANDLED;
+ return IRQ_HANDLED;
}
+ /* Handle device/host interrupt */
+ if (ci->role != CI_ROLE_END)
+ ret = ci_role(ci)->irq(ci);
+
return ret;
}
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 3b66cbe..7f37484 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -37,13 +37,23 @@ enum ci_role ci_otg_role(struct ci_hdrc *ci)
return role;
}
-/**
- * ci_role_work - perform role changing based on ID pin
- * @work: work struct
- */
-static void ci_role_work(struct work_struct *work)
+void ci_handle_vbus_change(struct ci_hdrc *ci)
+{
+ u32 otgsc;
+
+ if (!ci->is_otg)
+ return;
+
+ otgsc = hw_read(ci, OP_OTGSC, ~0);
+
+ if (otgsc & OTGSC_BSV)
+ usb_gadget_vbus_connect(&ci->gadget);
+ else
+ usb_gadget_vbus_disconnect(&ci->gadget);
+}
+
+static void ci_handle_id_switch(struct ci_hdrc *ci)
{
- struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work);
enum ci_role role = ci_otg_role(ci);
if (role != ci->role) {
@@ -53,17 +63,35 @@ static void ci_role_work(struct work_struct *work)
ci_role_stop(ci);
ci_role_start(ci, role);
}
+}
+/**
+ * ci_otg_work - perform otg (vbus/id) event handle
+ * @work: work struct
+ */
+static void ci_otg_work(struct work_struct *work)
+{
+ struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work);
+
+ if (ci->id_event) {
+ ci->id_event = false;
+ ci_handle_id_switch(ci);
+ } else if (ci->b_sess_valid_event) {
+ ci->b_sess_valid_event = false;
+ ci_handle_vbus_change(ci);
+ } else
+ dev_err(ci->dev, "unexpected event occurs at %s\n", __func__);
enable_irq(ci->irq);
}
+
/**
* ci_hdrc_otg_init - initialize otg struct
* ci: the controller
*/
int ci_hdrc_otg_init(struct ci_hdrc *ci)
{
- INIT_WORK(&ci->work, ci_role_work);
+ INIT_WORK(&ci->work, ci_otg_work);
ci->wq = create_singlethread_workqueue("ci_otg");
if (!ci->wq) {
dev_err(ci->dev, "can't create workqueue\n");
diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h
index 8acf3df..2d9f090 100644
--- a/drivers/usb/chipidea/otg.h
+++ b/drivers/usb/chipidea/otg.h
@@ -30,5 +30,6 @@ static inline void ci_disable_otg_interrupt(struct ci_hdrc *ci, u32 bits)
int ci_hdrc_otg_init(struct ci_hdrc *ci);
void ci_hdrc_otg_destroy(struct ci_hdrc *ci);
enum ci_role ci_otg_role(struct ci_hdrc *ci);
+void ci_handle_vbus_change(struct ci_hdrc *ci);
#endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 24a100d..c70ce38 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -85,8 +85,10 @@ static int hw_device_state(struct ci_hdrc *ci, u32 dma)
/* interrupt, error, port change, reset, sleep/suspend */
hw_write(ci, OP_USBINTR, ~0,
USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI);
+ hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
} else {
hw_write(ci, OP_USBINTR, ~0, 0);
+ hw_write(ci, OP_USBCMD, USBCMD_RS, 0);
}
return 0;
}
@@ -1460,6 +1462,7 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
pm_runtime_get_sync(&_gadget->dev);
hw_device_reset(ci, USBMODE_CM_DC);
hw_device_state(ci, ci->ep0out->qh.dma);
+ dev_dbg(ci->dev, "Connected to host\n");
} else {
hw_device_state(ci, 0);
if (ci->platdata->notify_event)
@@ -1467,6 +1470,7 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
CI_HDRC_CONTROLLER_STOPPED_EVENT);
_gadget_stop_activity(&ci->gadget);
pm_runtime_put_sync(&_gadget->dev);
+ dev_dbg(ci->dev, "Disconnected from host\n");
}
}
@@ -1822,6 +1826,9 @@ static int udc_start(struct ci_hdrc *ci)
pm_runtime_no_callbacks(&ci->gadget.dev);
pm_runtime_enable(&ci->gadget.dev);
+ /* Update ci->vbus_active */
+ ci_handle_vbus_change(ci);
+
return retval;
remove_trans:
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v15 10/13] usb: chipidea: add wait vbus lower than OTGSC_BSV before role starts
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
` (8 preceding siblings ...)
2013-08-12 1:22 ` [PATCH v15 09/13] usb: chipidea: add vbus interrupt handler Peter Chen
@ 2013-08-12 1:22 ` Peter Chen
2013-08-12 1:22 ` [PATCH v15 11/13] usb: chipidea: udc: misuse flag CI_HDRC_REGS_SHARED and CI_HDRC_PULLUP_ON_VBUS Peter Chen
` (4 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-12 1:22 UTC (permalink / raw)
To: linux-arm-kernel
When the gadget role starts, we need to make sure the vbus is lower
than OTGSC_BSV, or there will be an vbus interrupt since we use
B_SESSION_VALID as vbus interrupt to indicate connect and disconnect.
When the host role starts, it may not be useful to wait vbus to lower
than OTGSC_BSV, but it can indicate some hardware problems like the
vbus is still higher than OTGSC_BSV after we disconnect to host some
time later (5000 milliseconds currently), which is obvious not correct.
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/ci.h | 3 +++
drivers/usb/chipidea/core.c | 32 ++++++++++++++++++++++++++++++++
drivers/usb/chipidea/otg.c | 4 ++++
3 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 3160363..1c94fc5 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -308,4 +308,7 @@ int hw_port_test_set(struct ci_hdrc *ci, u8 mode);
u8 hw_port_test_get(struct ci_hdrc *ci);
+int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask,
+ u32 value, unsigned int timeout_ms);
+
#endif /* __DRIVERS_USB_CHIPIDEA_CI_H */
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index ec0bb11..cfeae3c 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -294,6 +294,38 @@ int hw_device_reset(struct ci_hdrc *ci, u32 mode)
return 0;
}
+/**
+ * hw_wait_reg: wait the register value
+ *
+ * Sometimes, it needs to wait register value before going on.
+ * Eg, when switch to device mode, the vbus value should be lower
+ * than OTGSC_BSV before connects to host.
+ *
+ * @ci: the controller
+ * @reg: register index
+ * @mask: mast bit
+ * @value: the bit value to wait
+ * @timeout_ms: timeout in millisecond
+ *
+ * This function returns an error code if timeout
+ */
+int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask,
+ u32 value, unsigned int timeout_ms)
+{
+ unsigned long elapse = jiffies + msecs_to_jiffies(timeout_ms);
+
+ while (hw_read(ci, reg, mask) != value) {
+ if (time_after(jiffies, elapse)) {
+ dev_err(ci->dev, "timeout waiting for %08x in %d\n",
+ mask, reg);
+ return -ETIMEDOUT;
+ }
+ msleep(20);
+ }
+
+ return 0;
+}
+
static irqreturn_t ci_irq(int irq, void *data)
{
struct ci_hdrc *ci = data;
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 7f37484..39bd7ec 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -52,6 +52,7 @@ void ci_handle_vbus_change(struct ci_hdrc *ci)
usb_gadget_vbus_disconnect(&ci->gadget);
}
+#define CI_VBUS_STABLE_TIMEOUT_MS 5000
static void ci_handle_id_switch(struct ci_hdrc *ci)
{
enum ci_role role = ci_otg_role(ci);
@@ -61,6 +62,9 @@ static void ci_handle_id_switch(struct ci_hdrc *ci)
ci_role(ci)->name, ci->roles[role]->name);
ci_role_stop(ci);
+ /* wait vbus lower than OTGSC_BSV */
+ hw_wait_reg(ci, OP_OTGSC, OTGSC_BSV, 0,
+ CI_VBUS_STABLE_TIMEOUT_MS);
ci_role_start(ci, role);
}
}
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v15 11/13] usb: chipidea: udc: misuse flag CI_HDRC_REGS_SHARED and CI_HDRC_PULLUP_ON_VBUS
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
` (9 preceding siblings ...)
2013-08-12 1:22 ` [PATCH v15 10/13] usb: chipidea: add wait vbus lower than OTGSC_BSV before role starts Peter Chen
@ 2013-08-12 1:22 ` Peter Chen
2013-08-12 1:22 ` [PATCH v15 12/13] usb: chipidea: retire flag CI_HDRC_PULLUP_ON_VBUS Peter Chen
` (3 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-12 1:22 UTC (permalink / raw)
To: linux-arm-kernel
CI_HDRC_REGS_SHARED stands for the controller registers is shared
with other USB drivers, if all USB drivers are at chipidea/, it doesn't
needed to set.
CI_HDRC_PULLUP_ON_VBUS stands for pullup dp when the vbus is on. This
flag doesn't need to set if the vbus is always on for gadget
since dp has always pulled up after the gadget has initialized.
So, the current code seems to misuse this two flags.
- When the gadget initializes, the controller doesn't need to run if
it depends on vbus (CI_HDRC_PULLUP_ON_VBUS), it does not
relate to shared register.
- When the gadget starts (load one gadget module), the controller
can run if vbus is on (CI_HDRC_PULLUP_ON_VBUS), it also does not
relate to shared register.
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/udc.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index c70ce38..45abf4d 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1637,8 +1637,7 @@ static int ci_udc_start(struct usb_gadget *gadget,
pm_runtime_get_sync(&ci->gadget.dev);
if (ci->platdata->flags & CI_HDRC_PULLUP_ON_VBUS) {
if (ci->vbus_active) {
- if (ci->platdata->flags & CI_HDRC_REGS_SHARED)
- hw_device_reset(ci, USBMODE_CM_DC);
+ hw_device_reset(ci, USBMODE_CM_DC);
} else {
pm_runtime_put_sync(&ci->gadget.dev);
goto done;
@@ -1801,7 +1800,7 @@ static int udc_start(struct ci_hdrc *ci)
}
}
- if (!(ci->platdata->flags & CI_HDRC_REGS_SHARED)) {
+ if (!(ci->platdata->flags & CI_HDRC_PULLUP_ON_VBUS)) {
retval = hw_device_reset(ci, USBMODE_CM_DC);
if (retval)
goto put_transceiver;
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v15 12/13] usb: chipidea: retire flag CI_HDRC_PULLUP_ON_VBUS
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
` (10 preceding siblings ...)
2013-08-12 1:22 ` [PATCH v15 11/13] usb: chipidea: udc: misuse flag CI_HDRC_REGS_SHARED and CI_HDRC_PULLUP_ON_VBUS Peter Chen
@ 2013-08-12 1:22 ` Peter Chen
2013-08-12 1:22 ` [PATCH v15 13/13] usb: chipidea: udc: .pullup is valid only when vbus is there Peter Chen
` (2 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-12 1:22 UTC (permalink / raw)
To: linux-arm-kernel
Currently, the controller only runs when the ci->vbus_active is true.
So the flag CI_HDRC_PULLUP_ON_VBUS is useless no longer.
If the user doesn't have otgsc, he/she needs to change ci_handle_vbus_change
to update ci->vbus_active.
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/ci_hdrc_imx.c | 1 -
drivers/usb/chipidea/ci_hdrc_msm.c | 1 -
drivers/usb/chipidea/udc.c | 24 ++++++------------------
include/linux/usb/chipidea.h | 1 -
4 files changed, 6 insertions(+), 21 deletions(-)
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index bd1fe25..ab3e74a 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -91,7 +91,6 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
.name = "ci_hdrc_imx",
.capoffset = DEF_CAPOFFSET,
.flags = CI_HDRC_REQUIRE_TRANSCEIVER |
- CI_HDRC_PULLUP_ON_VBUS |
CI_HDRC_DISABLE_STREAMING,
};
int ret;
diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c
index fb657ef..2d51d85 100644
--- a/drivers/usb/chipidea/ci_hdrc_msm.c
+++ b/drivers/usb/chipidea/ci_hdrc_msm.c
@@ -49,7 +49,6 @@ static struct ci_hdrc_platform_data ci_hdrc_msm_platdata = {
.name = "ci_hdrc_msm",
.flags = CI_HDRC_REGS_SHARED |
CI_HDRC_REQUIRE_TRANSCEIVER |
- CI_HDRC_PULLUP_ON_VBUS |
CI_HDRC_DISABLE_STREAMING,
.notify_event = ci_hdrc_msm_notify_event,
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 45abf4d..90c3572 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1448,9 +1448,6 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
unsigned long flags;
int gadget_ready = 0;
- if (!(ci->platdata->flags & CI_HDRC_PULLUP_ON_VBUS))
- return -EOPNOTSUPP;
-
spin_lock_irqsave(&ci->lock, flags);
ci->vbus_active = is_active;
if (ci->driver)
@@ -1635,13 +1632,11 @@ static int ci_udc_start(struct usb_gadget *gadget,
ci->driver = driver;
pm_runtime_get_sync(&ci->gadget.dev);
- if (ci->platdata->flags & CI_HDRC_PULLUP_ON_VBUS) {
- if (ci->vbus_active) {
- hw_device_reset(ci, USBMODE_CM_DC);
- } else {
- pm_runtime_put_sync(&ci->gadget.dev);
- goto done;
- }
+ if (ci->vbus_active) {
+ hw_device_reset(ci, USBMODE_CM_DC);
+ } else {
+ pm_runtime_put_sync(&ci->gadget.dev);
+ goto done;
}
retval = hw_device_state(ci, ci->ep0out->qh.dma);
@@ -1664,8 +1659,7 @@ static int ci_udc_stop(struct usb_gadget *gadget,
spin_lock_irqsave(&ci->lock, flags);
- if (!(ci->platdata->flags & CI_HDRC_PULLUP_ON_VBUS) ||
- ci->vbus_active) {
+ if (ci->vbus_active) {
hw_device_state(ci, 0);
if (ci->platdata->notify_event)
ci->platdata->notify_event(ci,
@@ -1800,12 +1794,6 @@ static int udc_start(struct ci_hdrc *ci)
}
}
- if (!(ci->platdata->flags & CI_HDRC_PULLUP_ON_VBUS)) {
- retval = hw_device_reset(ci, USBMODE_CM_DC);
- if (retval)
- goto put_transceiver;
- }
-
if (ci->transceiver) {
retval = otg_set_peripheral(ci->transceiver->otg,
&ci->gadget);
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index 10a607c..7d39967 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -18,7 +18,6 @@ struct ci_hdrc_platform_data {
unsigned long flags;
#define CI_HDRC_REGS_SHARED BIT(0)
#define CI_HDRC_REQUIRE_TRANSCEIVER BIT(1)
-#define CI_HDRC_PULLUP_ON_VBUS BIT(2)
#define CI_HDRC_DISABLE_STREAMING BIT(3)
/*
* Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1,
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v15 13/13] usb: chipidea: udc: .pullup is valid only when vbus is there
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
` (11 preceding siblings ...)
2013-08-12 1:22 ` [PATCH v15 12/13] usb: chipidea: retire flag CI_HDRC_PULLUP_ON_VBUS Peter Chen
@ 2013-08-12 1:22 ` Peter Chen
2013-08-13 23:43 ` [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
2013-08-26 16:24 ` Hector Palacios
14 siblings, 0 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-12 1:22 UTC (permalink / raw)
To: linux-arm-kernel
For chipidea, the IP must know vbus before the controller
begins to run. So the .pullup should only be called when
the vbus is there.
Tested-by: Marek Vasut <marex@denx.de>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/udc.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 90c3572..6b4c2f2 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1511,6 +1511,9 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on)
{
struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
+ if (!ci->vbus_active)
+ return -EOPNOTSUPP;
+
if (is_on)
hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
else
--
1.7.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
` (12 preceding siblings ...)
2013-08-12 1:22 ` [PATCH v15 13/13] usb: chipidea: udc: .pullup is valid only when vbus is there Peter Chen
@ 2013-08-13 23:43 ` Peter Chen
2013-08-14 9:48 ` Alexander Shishkin
2013-08-26 16:06 ` Hector Palacios
2013-08-26 16:24 ` Hector Palacios
14 siblings, 2 replies; 23+ messages in thread
From: Peter Chen @ 2013-08-13 23:43 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Aug 12, 2013 at 09:22:46AM +0800, Peter Chen wrote:
> This patchset adds tested otg id switch function and vbus connect
> and disconnect detection for chipidea driver. And fix kinds of
> bugs found at chipidea drivers after enabling id and vbus detection.
>
> This patch are fully tested at imx6 sabresd and imx28evk platform by me.
> Besides, marek tested it on two STMP3780-based boards (not yet mainline)
> and two MX28-based boards.
>
> My chipidea repo: https://github.com/hzpeterchen/linux-usb.git
Hi Alex,
I see Felipe has already sent his pull request for 3.12 merge
windows. Would you please speed up review my chipidea patches?
At least, I hope this serial can be queued at 3.12. Thanks.
>
> Changes for v15:
> - Mark otgsc API as static line, and move them to otg.h [4/13]
> - Remove some redundant comments [6/13]
> - Fix some typos [8/13]
> - Retire flag CI_HDRC_PULLUP_ON_VBUS [12/13] [13/13]
>
> Changes for v14:
> - This patchset is based on below recent chipidea patches and newest
> usb-next, it can decrease rebase effort.
>
> Fabio Estevam (3):
> chipidea: ci_hdrc_imx: Remove unused variable 'res'
> chipidea: core: Move hw_phymode_configure() into probe
> chipidea: Remove previous MODULE_ALIAS
>
> Lothar Wabmann (3):
> usb: chipidea: improve kconfig 2.0
> usb: chipidea: don't clobber return value of ci_role_start()
> usb: chipidea: ci_hdrc_imx: remove an unsolicited module_put() call
> from ci_hdrc_imx_remove()
>
> Peter Chen (1):
> usb: chipidea: fix the build error with randconfig
>
> - [Michael comments]: move vbus operation to core, and squash two vbus
> patches. [1/12], [2/12]
> - [Michael comments]: move out non vbus and non id related patches. [14/14 at v13]
>
> Chagnes for v13:
> - Add Tested-by: Marek Vasut <marex@denx.de>
> - [Sascha's comments]: Add return value check for devm_regulator_get. [3/14]
> - [Marc's comments]: Change timeout usage at hw_wait_reg. [11/14]
> - [Alex's comments]: Using platdata flag to indicate dual role but not
> OTG controller. [7/14]
>
> Changes for v12:
> - Rebased greg's usb-next tree (3.10.0-rc7+)
> - Split more small patches for single function and fix.
>
> Peter Chen (12):
> usb: chipidea: move vbus regulator operation to core
> usb: chipidea: host: add vbus regulator control
> usb: chipidea: udc: otg_set_peripheral is useless for some chipidea
> users
> usb: chipidea: otg: Add otg file used to access otgsc
> usb: chipidea: Add role init and destory APIs
> usb: chipidea: add flag CI_HDRC_DUAL_ROLE_NOT_OTG
> usb: chipidea: disable all interrupts and clear all interrupts status
> usb: chipidea: move otg relate things to otg file
> usb: chipidea: add vbus interrupt handler
> usb: chipidea: add wait vbus lower than OTGSC_BSV before role starts
> usb: chipidea: udc: misuse flag CI_HDRC_REGS_SHARED and
> CI_HDRC_PULLUP_ON_VBUS
> usb: chipidea: udc: .pullup is valid when vbus is on at
> CI_HDRC_PULLUP_ON_VBUS
>
> Peter Chen (13):
> usb: chipidea: move vbus regulator operation to core
> usb: chipidea: host: add vbus regulator control
> usb: chipidea: udc: otg_set_peripheral is useless for some chipidea
> users
> usb: chipidea: otg: Add otg file used to access otgsc
> usb: chipidea: Add role init and destroy APIs
> usb: chipidea: add flag CI_HDRC_DUAL_ROLE_NOT_OTG
> usb: chipidea: disable all interrupts and clear all interrupts status
> usb: chipidea: move otg related things to otg file
> usb: chipidea: add vbus interrupt handler
> usb: chipidea: add wait vbus lower than OTGSC_BSV before role starts
> usb: chipidea: udc: misuse flag CI_HDRC_REGS_SHARED and
> CI_HDRC_PULLUP_ON_VBUS
> usb: chipidea: retire flag CI_HDRC_PULLUP_ON_VBUS
> usb: chipidea: udc: .pullup is valid only when vbus is there
>
> drivers/usb/chipidea/Makefile | 2 +-
> drivers/usb/chipidea/bits.h | 10 ++
> drivers/usb/chipidea/ci.h | 8 ++
> drivers/usb/chipidea/ci_hdrc_imx.c | 27 +-----
> drivers/usb/chipidea/ci_hdrc_msm.c | 1 -
> drivers/usb/chipidea/core.c | 183 +++++++++++++++++++++++++-----------
> drivers/usb/chipidea/host.c | 30 ++++++-
> drivers/usb/chipidea/host.h | 6 +
> drivers/usb/chipidea/otg.c | 120 +++++++++++++++++++++++
> drivers/usb/chipidea/otg.h | 35 +++++++
> drivers/usb/chipidea/udc.c | 78 ++++++++++------
> drivers/usb/chipidea/udc.h | 6 +
> include/linux/usb/chipidea.h | 7 +-
> 13 files changed, 401 insertions(+), 112 deletions(-)
> create mode 100644 drivers/usb/chipidea/otg.c
> create mode 100644 drivers/usb/chipidea/otg.h
>
--
Best Regards,
Peter Chen
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea
2013-08-13 23:43 ` [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
@ 2013-08-14 9:48 ` Alexander Shishkin
2013-08-26 16:06 ` Hector Palacios
1 sibling, 0 replies; 23+ messages in thread
From: Alexander Shishkin @ 2013-08-14 9:48 UTC (permalink / raw)
To: linux-arm-kernel
Peter Chen <peter.chen@freescale.com> writes:
> On Mon, Aug 12, 2013 at 09:22:46AM +0800, Peter Chen wrote:
>> This patchset adds tested otg id switch function and vbus connect
>> and disconnect detection for chipidea driver. And fix kinds of
>> bugs found at chipidea drivers after enabling id and vbus detection.
>>
>> This patch are fully tested at imx6 sabresd and imx28evk platform by me.
>> Besides, marek tested it on two STMP3780-based boards (not yet mainline)
>> and two MX28-based boards.
>>
>> My chipidea repo: https://github.com/hzpeterchen/linux-usb.git
>
> Hi Alex,
>
> I see Felipe has already sent his pull request for 3.12 merge
> windows. Would you please speed up review my chipidea patches?
> At least, I hope this serial can be queued at 3.12. Thanks.
Yes, it is about time.
Thanks,
--
Alex
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea
2013-08-13 23:43 ` [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
2013-08-14 9:48 ` Alexander Shishkin
@ 2013-08-26 16:06 ` Hector Palacios
1 sibling, 0 replies; 23+ messages in thread
From: Hector Palacios @ 2013-08-26 16:06 UTC (permalink / raw)
To: linux-arm-kernel
Dear Peter,
On 08/14/2013 01:43 AM, Peter Chen wrote:
> On Mon, Aug 12, 2013 at 09:22:46AM +0800, Peter Chen wrote:
>> This patchset adds tested otg id switch function and vbus connect
>> and disconnect detection for chipidea driver. And fix kinds of
>> bugs found at chipidea drivers after enabling id and vbus detection.
>>
>> This patch are fully tested at imx6 sabresd and imx28evk platform by me.
>> Besides, marek tested it on two STMP3780-based boards (not yet mainline)
>> and two MX28-based boards.
>>
>> My chipidea repo: https://github.com/hzpeterchen/linux-usb.git
>
> Hi Alex,
>
> I see Felipe has already sent his pull request for 3.12 merge
> windows. Would you please speed up review my chipidea patches?
> At least, I hope this serial can be queued at 3.12. Thanks.
>
>>
>> Changes for v15:
>> - Mark otgsc API as static line, and move them to otg.h [4/13]
>> - Remove some redundant comments [6/13]
>> - Fix some typos [8/13]
>> - Retire flag CI_HDRC_PULLUP_ON_VBUS [12/13] [13/13]
Patches 6 and 12 in this series seem to be incomplete or malformed. Please check.
Best regards
--
H?ctor Palacios
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea
2013-08-12 1:22 [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
` (13 preceding siblings ...)
2013-08-13 23:43 ` [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea Peter Chen
@ 2013-08-26 16:24 ` Hector Palacios
2013-08-27 2:51 ` Peter Chen
14 siblings, 1 reply; 23+ messages in thread
From: Hector Palacios @ 2013-08-26 16:24 UTC (permalink / raw)
To: linux-arm-kernel
Dear Peter,
On 08/12/2013 03:22 AM, Peter Chen wrote:
> This patchset adds tested otg id switch function and vbus connect
> and disconnect detection for chipidea driver. And fix kinds of
> bugs found at chipidea drivers after enabling id and vbus detection.
>
> This patch are fully tested at imx6 sabresd and imx28evk platform by me.
> Besides, marek tested it on two STMP3780-based boards (not yet mainline)
> and two MX28-based boards.
>
> My chipidea repo: https://github.com/hzpeterchen/linux-usb.git
>
> Changes for v15:
> - Mark otgsc API as static line, and move them to otg.h [4/13]
> - Remove some redundant comments [6/13]
> - Fix some typos [8/13]
> - Retire flag CI_HDRC_PULLUP_ON_VBUS [12/13] [13/13]
Patches 6 and 12 in this series seem to be incomplete or malformed. Please check.
Best regards,
--
Hector Palacios
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea
2013-08-26 16:24 ` Hector Palacios
@ 2013-08-27 2:51 ` Peter Chen
2013-08-27 7:06 ` Hector Palacios
0 siblings, 1 reply; 23+ messages in thread
From: Peter Chen @ 2013-08-27 2:51 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Aug 26, 2013 at 06:24:48PM +0200, Hector Palacios wrote:
> Dear Peter,
>
> On 08/12/2013 03:22 AM, Peter Chen wrote:
> >This patchset adds tested otg id switch function and vbus connect
> >and disconnect detection for chipidea driver. And fix kinds of
> >bugs found at chipidea drivers after enabling id and vbus detection.
> >
> >This patch are fully tested at imx6 sabresd and imx28evk platform by me.
> >Besides, marek tested it on two STMP3780-based boards (not yet mainline)
> >and two MX28-based boards.
> >
> >My chipidea repo: https://github.com/hzpeterchen/linux-usb.git
> >
> >Changes for v15:
> >- Mark otgsc API as static line, and move them to otg.h [4/13]
> >- Remove some redundant comments [6/13]
> >- Fix some typos [8/13]
> >- Retire flag CI_HDRC_PULLUP_ON_VBUS [12/13] [13/13]
>
> Patches 6 and 12 in this series seem to be incomplete or malformed. Please check.
>
Would you post what's the problem for them or what's problem
at your system after using them?
--
Best Regards,
Peter Chen
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea
2013-08-27 2:51 ` Peter Chen
@ 2013-08-27 7:06 ` Hector Palacios
2013-08-27 8:09 ` Alexander Shishkin
0 siblings, 1 reply; 23+ messages in thread
From: Hector Palacios @ 2013-08-27 7:06 UTC (permalink / raw)
To: linux-arm-kernel
Dear Peter,
On 08/27/2013 04:51 AM, Peter Chen wrote:
> On Mon, Aug 26, 2013 at 06:24:48PM +0200, Hector Palacios wrote:
>> Dear Peter,
>>
>> On 08/12/2013 03:22 AM, Peter Chen wrote:
>>> This patchset adds tested otg id switch function and vbus connect
>>> and disconnect detection for chipidea driver. And fix kinds of
>>> bugs found at chipidea drivers after enabling id and vbus detection.
>>>
>>> This patch are fully tested at imx6 sabresd and imx28evk platform by me.
>>> Besides, marek tested it on two STMP3780-based boards (not yet mainline)
>>> and two MX28-based boards.
>>>
>>> My chipidea repo: https://github.com/hzpeterchen/linux-usb.git
>>>
>>> Changes for v15:
>>> - Mark otgsc API as static line, and move them to otg.h [4/13]
>>> - Remove some redundant comments [6/13]
>>> - Fix some typos [8/13]
>>> - Retire flag CI_HDRC_PULLUP_ON_VBUS [12/13] [13/13]
>>
>> Patches 6 and 12 in this series seem to be incomplete or malformed. Please check.
>>
>
> Would you post what's the problem for them or what's problem
> at your system after using them?
I'm sorry, I thought it was evident. Patches 6 and 12 were posted incomplete. See how
they end:
http://permalink.gmane.org/gmane.linux.usb.general/92231
http://permalink.gmane.org/gmane.linux.usb.general/92237
In patch 12 the modified file include/linux/usb/chipidea.h does not even appear.
Something happened during the generation or posting of these patches.
Best regards,
--
Hector Palacios
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea
2013-08-27 7:06 ` Hector Palacios
@ 2013-08-27 8:09 ` Alexander Shishkin
2013-08-27 8:12 ` Hector Palacios
0 siblings, 1 reply; 23+ messages in thread
From: Alexander Shishkin @ 2013-08-27 8:09 UTC (permalink / raw)
To: linux-arm-kernel
Hector Palacios <hector.palacios@digi.com> writes:
> Dear Peter,
>
> On 08/27/2013 04:51 AM, Peter Chen wrote:
>> On Mon, Aug 26, 2013 at 06:24:48PM +0200, Hector Palacios wrote:
>>> Dear Peter,
>>>
>>> On 08/12/2013 03:22 AM, Peter Chen wrote:
>>>> This patchset adds tested otg id switch function and vbus connect
>>>> and disconnect detection for chipidea driver. And fix kinds of
>>>> bugs found at chipidea drivers after enabling id and vbus detection.
>>>>
>>>> This patch are fully tested at imx6 sabresd and imx28evk platform by me.
>>>> Besides, marek tested it on two STMP3780-based boards (not yet mainline)
>>>> and two MX28-based boards.
>>>>
>>>> My chipidea repo: https://github.com/hzpeterchen/linux-usb.git
>>>>
>>>> Changes for v15:
>>>> - Mark otgsc API as static line, and move them to otg.h [4/13]
>>>> - Remove some redundant comments [6/13]
>>>> - Fix some typos [8/13]
>>>> - Retire flag CI_HDRC_PULLUP_ON_VBUS [12/13] [13/13]
>>>
>>> Patches 6 and 12 in this series seem to be incomplete or malformed. Please check.
>>>
>>
>> Would you post what's the problem for them or what's problem
>> at your system after using them?
>
> I'm sorry, I thought it was evident. Patches 6 and 12 were posted incomplete. See how
> they end:
> http://permalink.gmane.org/gmane.linux.usb.general/92231
> http://permalink.gmane.org/gmane.linux.usb.general/92237
>
> In patch 12 the modified file include/linux/usb/chipidea.h does not even appear.
> Something happened during the generation or posting of these patches.
Or something's wrong with gmane.
http://www.spinics.net/lists/linux-usb/msg91695.html
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea
2013-08-27 8:09 ` Alexander Shishkin
@ 2013-08-27 8:12 ` Hector Palacios
2013-08-27 10:20 ` Hector Palacios
0 siblings, 1 reply; 23+ messages in thread
From: Hector Palacios @ 2013-08-27 8:12 UTC (permalink / raw)
To: linux-arm-kernel
On 08/27/2013 10:09 AM, Alexander Shishkin wrote:
> Hector Palacios <hector.palacios@digi.com> writes:
>
>> Dear Peter,
>>
>> On 08/27/2013 04:51 AM, Peter Chen wrote:
>>> On Mon, Aug 26, 2013 at 06:24:48PM +0200, Hector Palacios wrote:
>>>> Dear Peter,
>>>>
>>>> On 08/12/2013 03:22 AM, Peter Chen wrote:
>>>>> This patchset adds tested otg id switch function and vbus connect
>>>>> and disconnect detection for chipidea driver. And fix kinds of
>>>>> bugs found at chipidea drivers after enabling id and vbus detection.
>>>>>
>>>>> This patch are fully tested at imx6 sabresd and imx28evk platform by me.
>>>>> Besides, marek tested it on two STMP3780-based boards (not yet mainline)
>>>>> and two MX28-based boards.
>>>>>
>>>>> My chipidea repo: https://github.com/hzpeterchen/linux-usb.git
>>>>>
>>>>> Changes for v15:
>>>>> - Mark otgsc API as static line, and move them to otg.h [4/13]
>>>>> - Remove some redundant comments [6/13]
>>>>> - Fix some typos [8/13]
>>>>> - Retire flag CI_HDRC_PULLUP_ON_VBUS [12/13] [13/13]
>>>>
>>>> Patches 6 and 12 in this series seem to be incomplete or malformed. Please check.
>>>>
>>>
>>> Would you post what's the problem for them or what's problem
>>> at your system after using them?
>>
>> I'm sorry, I thought it was evident. Patches 6 and 12 were posted incomplete. See how
>> they end:
>> http://permalink.gmane.org/gmane.linux.usb.general/92231
>> http://permalink.gmane.org/gmane.linux.usb.general/92237
>>
>> In patch 12 the modified file include/linux/usb/chipidea.h does not even appear.
>> Something happened during the generation or posting of these patches.
>
> Or something's wrong with gmane.
>
> http://www.spinics.net/lists/linux-usb/msg91695.html
Oops. My fault, then. Sorry about that.
Best regards,
--
Hector Palacios
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v15 00/13] Add tested id switch and vbus connect detect support for Chipidea
2013-08-27 8:12 ` Hector Palacios
@ 2013-08-27 10:20 ` Hector Palacios
0 siblings, 0 replies; 23+ messages in thread
From: Hector Palacios @ 2013-08-27 10:20 UTC (permalink / raw)
To: linux-arm-kernel
On 08/27/2013 10:12 AM, Hector Palacios wrote:
> On 08/27/2013 10:09 AM, Alexander Shishkin wrote:
>> Hector Palacios <hector.palacios@digi.com> writes:
>>
>>> Dear Peter,
>>>
>>> On 08/27/2013 04:51 AM, Peter Chen wrote:
>>>> On Mon, Aug 26, 2013 at 06:24:48PM +0200, Hector Palacios wrote:
>>>>> Dear Peter,
>>>>>
>>>>> On 08/12/2013 03:22 AM, Peter Chen wrote:
>>>>>> This patchset adds tested otg id switch function and vbus connect
>>>>>> and disconnect detection for chipidea driver. And fix kinds of
>>>>>> bugs found at chipidea drivers after enabling id and vbus detection.
>>>>>>
>>>>>> This patch are fully tested at imx6 sabresd and imx28evk platform by me.
>>>>>> Besides, marek tested it on two STMP3780-based boards (not yet mainline)
>>>>>> and two MX28-based boards.
>>>>>>
>>>>>> My chipidea repo: https://github.com/hzpeterchen/linux-usb.git
>>>>>>
>>>>>> Changes for v15:
>>>>>> - Mark otgsc API as static line, and move them to otg.h [4/13]
>>>>>> - Remove some redundant comments [6/13]
>>>>>> - Fix some typos [8/13]
>>>>>> - Retire flag CI_HDRC_PULLUP_ON_VBUS [12/13] [13/13]
>>>>>
>>>>> Patches 6 and 12 in this series seem to be incomplete or malformed. Please check.
>>>>>
>>>>
>>>> Would you post what's the problem for them or what's problem
>>>> at your system after using them?
>>>
>>> I'm sorry, I thought it was evident. Patches 6 and 12 were posted incomplete. See how
>>> they end:
>>> http://permalink.gmane.org/gmane.linux.usb.general/92231
>>> http://permalink.gmane.org/gmane.linux.usb.general/92237
>>>
>>> In patch 12 the modified file include/linux/usb/chipidea.h does not even appear.
>>> Something happened during the generation or posting of these patches.
>>
>> Or something's wrong with gmane.
>>
>> http://www.spinics.net/lists/linux-usb/msg91695.html
>
> Oops. My fault, then. Sorry about that.
For what is worth, I successfully tested these series with serial, ethernet and mass
storage gadget drivers on a custom board (not upstream) based on i.MX28.
Tested-by: Hector Palacios <hector.palacios@digi.com>
Best regards,
--
Hector Palacios
^ permalink raw reply [flat|nested] 23+ messages in thread