* [PATCH 00/14] Add vbus status to udc-core
@ 2013-03-14 5:50 Peter Chen
2013-03-14 5:50 ` [PATCH 01/14] usb: udc-core: introduce vbus_active for struct usb_gadget Peter Chen
` (13 more replies)
0 siblings, 14 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
Vbus event is a common event for gadget, this patchset
move vbus status from individual driver private data to
common struct usb_gadget, after that, the udc core
can know vbus status well.
The last patch uses this vbus_active to determine if
we can pullup dp when load gadget module.
CC: Alexander Shishkin <alexander.shishkin@linux.intel.com>
CC: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
CC: Li Yang <leoli@freescale.com>
CC: Roland Stigge <stigge@antcom.de>
CC: Yu Xu <yuxu@marvell.com>
CC: Chao Xie <chao.xie@marvell.com>
CC: Eric Miao <eric.y.miao@gmail.com>
CC: Ben Dooks <ben-linux@fluff.org>
CC: Felipe Balbi <balbi@ti.com>
Peter Chen (14):
usb: udc-core: introduce vbus_active for struct usb_gadget
usb: chipidea: using common vbus_active
usb: at91_udc: using common vbus_active
usb: fsl_udc_core: using common vbus_active
usb: lpc32xx_udc: using common vbus_active
usb: mv_u3d_core: using common vbus_active
usb: mv_udc: using common vbus_active
usb: omap_udc: using common vbus_active
usb: pch_udc: using common vbus_active
usb: pxa25x_udc: using common vbus_active
usb: pxa27x_udc: using common vbus_active
usb: s3c2410_udc: using common vbus_active
usb: udc-core: small cleanup for udc->gadget
usb: udc-core: add judgement logic for usb_gadget_connect
drivers/usb/chipidea/ci.h | 2 --
drivers/usb/chipidea/udc.c | 6 +++---
drivers/usb/gadget/at91_udc.c | 16 ++++++++--------
drivers/usb/gadget/at91_udc.h | 1 -
drivers/usb/gadget/fsl_udc_core.c | 4 ++--
drivers/usb/gadget/fsl_usb2_udc.h | 1 -
drivers/usb/gadget/lpc32xx_udc.c | 1 +
drivers/usb/gadget/mv_u3d.h | 1 -
drivers/usb/gadget/mv_u3d_core.c | 14 +++++++-------
drivers/usb/gadget/mv_udc.h | 1 -
drivers/usb/gadget/mv_udc_core.c | 14 +++++++-------
drivers/usb/gadget/omap_udc.c | 4 ++--
drivers/usb/gadget/omap_udc.h | 1 -
drivers/usb/gadget/pch_udc.c | 10 ++++------
drivers/usb/gadget/pxa25x_udc.c | 6 +++---
drivers/usb/gadget/pxa25x_udc.h | 1 -
drivers/usb/gadget/pxa27x_udc.c | 8 ++++----
drivers/usb/gadget/pxa27x_udc.h | 1 -
drivers/usb/gadget/s3c2410_udc.c | 6 +++---
drivers/usb/gadget/s3c2410_udc.h | 1 -
drivers/usb/gadget/udc-core.c | 24 ++++++++++++++++--------
include/linux/usb/gadget.h | 1 +
22 files changed, 61 insertions(+), 63 deletions(-)
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 01/14] usb: udc-core: introduce vbus_active for struct usb_gadget
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 5:50 ` [PATCH 02/14] usb: chipidea: using common vbus_active Peter Chen
` (12 subsequent siblings)
13 siblings, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
If there is an vbus session event for udc driver, let the
udc core know vbus's status.
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
include/linux/usb/gadget.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 2e297e8..7e373a2 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -531,6 +531,7 @@ struct usb_gadget {
unsigned b_hnp_enable:1;
unsigned a_hnp_support:1;
unsigned a_alt_hnp_support:1;
+ unsigned vbus_active:1;
const char *name;
struct device dev;
unsigned out_epnum;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 02/14] usb: chipidea: using common vbus_active
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
2013-03-14 5:50 ` [PATCH 01/14] usb: udc-core: introduce vbus_active for struct usb_gadget Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 5:50 ` [PATCH 03/14] usb: at91_udc: " Peter Chen
` (11 subsequent siblings)
13 siblings, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
Using common vbus_active to indicate vbus status
CC: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/chipidea/ci.h | 2 --
drivers/usb/chipidea/udc.c | 6 +++---
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index e25d126..e4c1f63 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -126,7 +126,6 @@ struct hw_bank {
* @suspended: suspended by host
* @test_mode: the selected test mode
* @platdata: platform specific information supplied by parent device
- * @vbus_active: is VBUS active
* @transceiver: pointer to USB PHY, if any
* @hcd: pointer to usb_hcd for ehci host driver
*/
@@ -160,7 +159,6 @@ struct ci13xxx {
u8 test_mode;
struct ci13xxx_platform_data *platdata;
- int vbus_active;
/* FIXME: some day, we'll not use global phy */
bool global_phy;
struct usb_phy *transceiver;
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 2f45bba..78e8bac 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1383,7 +1383,7 @@ static int ci13xxx_vbus_session(struct usb_gadget *_gadget, int is_active)
return -EOPNOTSUPP;
spin_lock_irqsave(&ci->lock, flags);
- ci->vbus_active = is_active;
+ _gadget->vbus_active = is_active;
if (ci->driver)
gadget_ready = 1;
spin_unlock_irqrestore(&ci->lock, flags);
@@ -1566,7 +1566,7 @@ static int ci13xxx_start(struct usb_gadget *gadget,
ci->driver = driver;
pm_runtime_get_sync(&ci->gadget.dev);
if (ci->platdata->flags & CI13XXX_PULLUP_ON_VBUS) {
- if (ci->vbus_active) {
+ if (gadget->vbus_active) {
if (ci->platdata->flags & CI13XXX_REGS_SHARED) {
hw_device_reset(ci, USBMODE_CM_DC);
hw_enable_vbus_intr(ci);
@@ -1598,7 +1598,7 @@ static int ci13xxx_stop(struct usb_gadget *gadget,
spin_lock_irqsave(&ci->lock, flags);
if (!(ci->platdata->flags & CI13XXX_PULLUP_ON_VBUS) ||
- ci->vbus_active) {
+ gadget->vbus_active) {
hw_device_state(ci, 0);
if (ci->platdata->notify_event)
ci->platdata->notify_event(ci,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 03/14] usb: at91_udc: using common vbus_active
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
2013-03-14 5:50 ` [PATCH 01/14] usb: udc-core: introduce vbus_active for struct usb_gadget Peter Chen
2013-03-14 5:50 ` [PATCH 02/14] usb: chipidea: using common vbus_active Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 5:50 ` [PATCH 04/14] usb: fsl_udc_core: " Peter Chen
` (10 subsequent siblings)
13 siblings, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
Using common vbus_active to indicate vbus status
CC: Felipe Balbi <balbi@ti.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/gadget/at91_udc.c | 16 ++++++++--------
drivers/usb/gadget/at91_udc.h | 1 -
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 45dd292..9508d40 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -173,9 +173,9 @@ static int proc_udc_show(struct seq_file *s, void *unused)
seq_printf(s, "%s: version %s\n", driver_name, DRIVER_VERSION);
seq_printf(s, "vbus %s, pullup %s, %s powered%s, gadget %s\n\n",
- udc->vbus ? "present" : "off",
+ udc->gadget.vbus_active ? "present" : "off",
udc->enabled
- ? (udc->vbus ? "active" : "enabled")
+ ? (udc->gadget.vbus_active ? "active" : "enabled")
: "disabled",
udc->selfpowered ? "self" : "VBUS",
udc->suspended ? ", suspended" : "",
@@ -209,7 +209,7 @@ static int proc_udc_show(struct seq_file *s, void *unused)
proc_irq_show(s, "imr ", at91_udp_read(udc, AT91_UDP_IMR));
proc_irq_show(s, "isr ", at91_udp_read(udc, AT91_UDP_ISR));
- if (udc->enabled && udc->vbus) {
+ if (udc->enabled && udc->gadget.vbus_active) {
proc_ep_show(s, &udc->ep[0]);
list_for_each_entry (ep, &udc->gadget.ep_list, ep.ep_list) {
if (ep->ep.desc)
@@ -892,7 +892,7 @@ static void pullup(struct at91_udc *udc, int is_on)
{
int active = !udc->board.pullup_active_low;
- if (!udc->enabled || !udc->vbus)
+ if (!udc->enabled || !udc->gadget.vbus_active)
is_on = 0;
DBG("%sactive\n", is_on ? "" : "in");
@@ -944,7 +944,7 @@ static int at91_vbus_session(struct usb_gadget *gadget, int is_active)
/* VDBG("vbus %s\n", is_active ? "on" : "off"); */
spin_lock_irqsave(&udc->lock, flags);
- udc->vbus = (is_active != 0);
+ gadget->vbus_active = (is_active != 0);
if (udc->driver)
pullup(udc, is_active);
else
@@ -1586,7 +1586,7 @@ static struct at91_udc controller = {
static void at91_vbus_update(struct at91_udc *udc, unsigned value)
{
value ^= udc->board.vbus_active_low;
- if (value != udc->vbus)
+ if (value != udc->gadget.vbus_active)
at91_vbus_session(&udc->gadget, value);
}
@@ -1817,7 +1817,7 @@ static int at91udc_probe(struct platform_device *pdev)
* Get the initial state of VBUS - we cannot expect
* a pending interrupt.
*/
- udc->vbus = gpio_get_value_cansleep(udc->board.vbus_pin) ^
+ udc->gadget.vbus_active = gpio_get_value_cansleep(udc->board.vbus_pin) ^
udc->board.vbus_active_low;
if (udc->board.vbus_polled) {
@@ -1837,7 +1837,7 @@ static int at91udc_probe(struct platform_device *pdev)
}
} else {
DBG("no VBUS detection, assuming always-on\n");
- udc->vbus = 1;
+ udc->gadget.vbus_active = 1;
}
retval = usb_add_gadget_udc(dev, &udc->gadget);
if (retval)
diff --git a/drivers/usb/gadget/at91_udc.h b/drivers/usb/gadget/at91_udc.h
index e647d1c..6f8c7a4 100644
--- a/drivers/usb/gadget/at91_udc.h
+++ b/drivers/usb/gadget/at91_udc.h
@@ -115,7 +115,6 @@ struct at91_udc {
struct usb_gadget gadget;
struct at91_ep ep[NUM_ENDPOINTS];
struct usb_gadget_driver *driver;
- unsigned vbus:1;
unsigned enabled:1;
unsigned clocked:1;
unsigned suspended:1;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 04/14] usb: fsl_udc_core: using common vbus_active
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
` (2 preceding siblings ...)
2013-03-14 5:50 ` [PATCH 03/14] usb: at91_udc: " Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 5:50 ` [PATCH 05/14] usb: lpc32xx_udc: " Peter Chen
` (9 subsequent siblings)
13 siblings, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
Using common vbus_active to indicate vbus status
CC: Li Yang <leoli@freescale.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/gadget/fsl_udc_core.c | 4 ++--
drivers/usb/gadget/fsl_usb2_udc.h | 1 -
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index 04d5fef..c343bbf 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -1195,7 +1195,7 @@ static int fsl_wakeup(struct usb_gadget *gadget)
static int can_pullup(struct fsl_udc *udc)
{
- return udc->driver && udc->softconnect && udc->vbus_active;
+ return udc->driver && udc->softconnect && udc->gadget.vbus_active;
}
/* Notify controller that VBUS is powered, Called by whatever
@@ -1208,7 +1208,7 @@ static int fsl_vbus_session(struct usb_gadget *gadget, int is_active)
udc = container_of(gadget, struct fsl_udc, gadget);
spin_lock_irqsave(&udc->lock, flags);
VDBG("VBUS %s", is_active ? "on" : "off");
- udc->vbus_active = (is_active != 0);
+ udc->gadget.vbus_active = (is_active != 0);
if (can_pullup(udc))
fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP),
&dr_regs->usbcmd);
diff --git a/drivers/usb/gadget/fsl_usb2_udc.h b/drivers/usb/gadget/fsl_usb2_udc.h
index c6703bb..f17ce58 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.h
+++ b/drivers/usb/gadget/fsl_usb2_udc.h
@@ -483,7 +483,6 @@ struct fsl_udc {
spinlock_t lock;
struct usb_phy *transceiver;
unsigned softconnect:1;
- unsigned vbus_active:1;
unsigned stopped:1;
unsigned remote_wakeup:1;
unsigned already_stopped:1;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 05/14] usb: lpc32xx_udc: using common vbus_active
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
` (3 preceding siblings ...)
2013-03-14 5:50 ` [PATCH 04/14] usb: fsl_udc_core: " Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 5:50 ` [PATCH 06/14] usb: mv_u3d_core: " Peter Chen
` (8 subsequent siblings)
13 siblings, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
Using common vbus_active to indicate vbus status
CC: Felipe Balbi <balbi@ti.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/gadget/lpc32xx_udc.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c
index aa04089..13270a9 100644
--- a/drivers/usb/gadget/lpc32xx_udc.c
+++ b/drivers/usb/gadget/lpc32xx_udc.c
@@ -2550,6 +2550,7 @@ static int lpc32xx_vbus_session(struct usb_gadget *gadget, int is_active)
spin_lock_irqsave(&udc->lock, flags);
+ gadget->vbus_active = is_active;
/* Doesn't need lock */
if (udc->driver) {
udc_clk_set(udc, 1);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 06/14] usb: mv_u3d_core: using common vbus_active
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
` (4 preceding siblings ...)
2013-03-14 5:50 ` [PATCH 05/14] usb: lpc32xx_udc: " Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 5:50 ` [PATCH 07/14] usb: mv_udc: " Peter Chen
` (7 subsequent siblings)
13 siblings, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
Using common vbus_active to indicate vbus status
CC: Yu Xu <yuxu@marvell.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/gadget/mv_u3d.h | 1 -
drivers/usb/gadget/mv_u3d_core.c | 14 +++++++-------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/gadget/mv_u3d.h b/drivers/usb/gadget/mv_u3d.h
index e32a787..16a6955 100644
--- a/drivers/usb/gadget/mv_u3d.h
+++ b/drivers/usb/gadget/mv_u3d.h
@@ -274,7 +274,6 @@ struct mv_u3d {
unsigned int errors;
unsigned softconnect:1;
- unsigned vbus_active:1; /* vbus is active or not */
unsigned remote_wakeup:1; /* support remote wakeup */
unsigned clock_gating:1; /* clock gating or not */
unsigned active:1; /* udc is active or not */
diff --git a/drivers/usb/gadget/mv_u3d_core.c b/drivers/usb/gadget/mv_u3d_core.c
index b5cea27..95236db 100644
--- a/drivers/usb/gadget/mv_u3d_core.c
+++ b/drivers/usb/gadget/mv_u3d_core.c
@@ -1159,15 +1159,15 @@ static int mv_u3d_vbus_session(struct usb_gadget *gadget, int is_active)
spin_lock_irqsave(&u3d->lock, flags);
- u3d->vbus_active = (is_active != 0);
+ u3d->gadget.vbus_active = (is_active != 0);
dev_dbg(u3d->dev, "%s: softconnect %d, vbus_active %d\n",
- __func__, u3d->softconnect, u3d->vbus_active);
+ __func__, u3d->softconnect, u3d->gadget.vbus_active);
/*
* 1. external VBUS detect: we can disable/enable clock on demand.
* 2. UDC VBUS detect: we have to enable clock all the time.
* 3. No VBUS detect: we have to enable clock all the time.
*/
- if (u3d->driver && u3d->softconnect && u3d->vbus_active) {
+ if (u3d->driver && u3d->softconnect && u3d->gadget.vbus_active) {
retval = mv_u3d_enable(u3d);
if (retval == 0) {
/*
@@ -1218,9 +1218,9 @@ static int mv_u3d_pullup(struct usb_gadget *gadget, int is_on)
spin_lock_irqsave(&u3d->lock, flags);
dev_dbg(u3d->dev, "%s: softconnect %d, vbus_active %d\n",
- __func__, u3d->softconnect, u3d->vbus_active);
+ __func__, u3d->softconnect, u3d->gadget.vbus_active);
u3d->softconnect = (is_on != 0);
- if (u3d->driver && u3d->softconnect && u3d->vbus_active) {
+ if (u3d->driver && u3d->softconnect && u3d->gadget.vbus_active) {
retval = mv_u3d_enable(u3d);
if (retval == 0) {
/*
@@ -1231,7 +1231,7 @@ static int mv_u3d_pullup(struct usb_gadget *gadget, int is_on)
mv_u3d_ep0_reset(u3d);
mv_u3d_controller_start(u3d);
}
- } else if (u3d->driver && u3d->vbus_active) {
+ } else if (u3d->driver && u3d->gadget.vbus_active) {
/* stop all the transfer in queue*/
mv_u3d_stop_activity(u3d, u3d->driver);
mv_u3d_controller_stop(u3d);
@@ -1976,7 +1976,7 @@ static int mv_u3d_probe(struct platform_device *dev)
}
if (!u3d->clock_gating)
- u3d->vbus_active = 1;
+ u3d->gadget.vbus_active = 1;
/* enable usb3 controller vbus detection */
u3d->vbus_valid_detect = 1;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 07/14] usb: mv_udc: using common vbus_active
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
` (5 preceding siblings ...)
2013-03-14 5:50 ` [PATCH 06/14] usb: mv_u3d_core: " Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 5:50 ` [PATCH 08/14] usb: omap_udc: " Peter Chen
` (6 subsequent siblings)
13 siblings, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
Using common vbus_active to indicate vbus status
CC: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/gadget/mv_udc.h | 1 -
drivers/usb/gadget/mv_udc_core.c | 14 +++++++-------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/gadget/mv_udc.h b/drivers/usb/gadget/mv_udc.h
index 9073436..6d848b4 100644
--- a/drivers/usb/gadget/mv_udc.h
+++ b/drivers/usb/gadget/mv_udc.h
@@ -206,7 +206,6 @@ struct mv_udc {
int errors;
unsigned softconnect:1,
- vbus_active:1,
remote_wakeup:1,
softconnected:1,
force_fs:1,
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c
index c8cf959..91a1b0d 100644
--- a/drivers/usb/gadget/mv_udc_core.c
+++ b/drivers/usb/gadget/mv_udc_core.c
@@ -1204,12 +1204,12 @@ static int mv_udc_vbus_session(struct usb_gadget *gadget, int is_active)
udc = container_of(gadget, struct mv_udc, gadget);
spin_lock_irqsave(&udc->lock, flags);
- udc->vbus_active = (is_active != 0);
+ gadget->vbus_active = (is_active != 0);
dev_dbg(&udc->dev->dev, "%s: softconnect %d, vbus_active %d\n",
- __func__, udc->softconnect, udc->vbus_active);
+ __func__, udc->softconnect, gadget->vbus_active);
- if (udc->driver && udc->softconnect && udc->vbus_active) {
+ if (udc->driver && udc->softconnect && gadget->vbus_active) {
retval = mv_udc_enable(udc);
if (retval == 0) {
/* Clock is disabled, need re-init registers */
@@ -1244,9 +1244,9 @@ static int mv_udc_pullup(struct usb_gadget *gadget, int is_on)
udc->softconnect = (is_on != 0);
dev_dbg(&udc->dev->dev, "%s: softconnect %d, vbus_active %d\n",
- __func__, udc->softconnect, udc->vbus_active);
+ __func__, udc->softconnect, gadget->vbus_active);
- if (udc->driver && udc->softconnect && udc->vbus_active) {
+ if (udc->driver && udc->softconnect && gadget->vbus_active) {
retval = mv_udc_enable(udc);
if (retval == 0) {
/* Clock is disabled, need re-init registers */
@@ -1254,7 +1254,7 @@ static int mv_udc_pullup(struct usb_gadget *gadget, int is_on)
ep0_reset(udc);
udc_start(udc);
}
- } else if (udc->driver && udc->vbus_active) {
+ } else if (udc->driver && gadget->vbus_active) {
/* stop all the transfer in queue*/
stop_activity(udc, udc->driver);
udc_stop(udc);
@@ -2356,7 +2356,7 @@ static int mv_udc_probe(struct platform_device *pdev)
if (udc->clock_gating)
mv_udc_disable_internal(udc);
else
- udc->vbus_active = 1;
+ udc->gadget.vbus_active = 1;
retval = usb_add_gadget_udc(&pdev->dev, &udc->gadget);
if (retval)
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 08/14] usb: omap_udc: using common vbus_active
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
` (6 preceding siblings ...)
2013-03-14 5:50 ` [PATCH 07/14] usb: mv_udc: " Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 5:50 ` [PATCH 09/14] usb: pch_udc: " Peter Chen
` (5 subsequent siblings)
13 siblings, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
Using common vbus_active to indicate vbus status
CC: Felipe Balbi <balbi@ti.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/gadget/omap_udc.c | 4 ++--
drivers/usb/gadget/omap_udc.h | 1 -
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 06be85c..2d0cf7f 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -1186,7 +1186,7 @@ omap_set_selfpowered(struct usb_gadget *gadget, int is_selfpowered)
static int can_pullup(struct omap_udc *udc)
{
- return udc->driver && udc->softconnect && udc->vbus_active;
+ return udc->driver && udc->softconnect && udc->gadget.vbus_active;
}
static void pullup_enable(struct omap_udc *udc)
@@ -1253,7 +1253,7 @@ static int omap_vbus_session(struct usb_gadget *gadget, int is_active)
udc = container_of(gadget, struct omap_udc, gadget);
spin_lock_irqsave(&udc->lock, flags);
VDBG("VBUS %s\n", is_active ? "on" : "off");
- udc->vbus_active = (is_active != 0);
+ gadget->vbus_active = (is_active != 0);
if (cpu_is_omap15xx()) {
/* "software" detect, ignored if !VBUS_MODE_1510 */
l = omap_readl(FUNC_MUX_CTRL_0);
diff --git a/drivers/usb/gadget/omap_udc.h b/drivers/usb/gadget/omap_udc.h
index cfadeb5..62cdb9d 100644
--- a/drivers/usb/gadget/omap_udc.h
+++ b/drivers/usb/gadget/omap_udc.h
@@ -166,7 +166,6 @@ struct omap_udc {
struct usb_phy *transceiver;
struct list_head iso;
unsigned softconnect:1;
- unsigned vbus_active:1;
unsigned ep0_pending:1;
unsigned ep0_in:1;
unsigned ep0_set_config:1;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 09/14] usb: pch_udc: using common vbus_active
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
` (7 preceding siblings ...)
2013-03-14 5:50 ` [PATCH 08/14] usb: omap_udc: " Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 5:50 ` [PATCH 10/14] usb: pxa25x_udc: " Peter Chen
` (4 subsequent siblings)
13 siblings, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
Using common vbus_active to indicate vbus status
CC: Felipe Balbi <balbi@ti.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/gadget/pch_udc.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/gadget/pch_udc.c b/drivers/usb/gadget/pch_udc.c
index a787a8e..f49d0d2 100644
--- a/drivers/usb/gadget/pch_udc.c
+++ b/drivers/usb/gadget/pch_udc.c
@@ -333,7 +333,6 @@ struct pch_vbus_gpio_data {
* @registered: driver regsitered with system
* @suspended: driver in suspended state
* @connected: gadget driver associated
- * @vbus_session: required vbus_session state
* @set_cfg_not_acked: pending acknowledgement 4 setup
* @waiting_zlp_ack: pending acknowledgement 4 ZLP
* @data_requests: DMA pool for data requests
@@ -361,7 +360,6 @@ struct pch_udc_dev {
registered:1,
suspended:1,
connected:1,
- vbus_session:1,
set_cfg_not_acked:1,
waiting_zlp_ack:1;
struct pci_pool *data_requests;
@@ -614,7 +612,7 @@ static inline void pch_udc_vbus_session(struct pch_udc_dev *dev,
{
if (is_active) {
pch_udc_reconnect(dev);
- dev->vbus_session = 1;
+ dev->gadget.vbus_active = 1;
} else {
if (dev->driver && dev->driver->disconnect) {
spin_unlock(&dev->lock);
@@ -622,7 +620,7 @@ static inline void pch_udc_vbus_session(struct pch_udc_dev *dev,
spin_lock(&dev->lock);
}
pch_udc_set_disconnect(dev);
- dev->vbus_session = 0;
+ dev->gadget.vbus_active = 0;
}
}
@@ -2745,7 +2743,7 @@ static void pch_udc_dev_isr(struct pch_udc_dev *dev, u32 dev_intr)
}
vbus = pch_vbus_gpio_get_value(dev);
- if ((dev->vbus_session == 0)
+ if ((dev->gadget.vbus_active == 0)
&& (vbus != 1)) {
if (dev->driver && dev->driver->disconnect) {
spin_unlock(&dev->lock);
@@ -2753,7 +2751,7 @@ static void pch_udc_dev_isr(struct pch_udc_dev *dev, u32 dev_intr)
spin_lock(&dev->lock);
}
pch_udc_reconnect(dev);
- } else if ((dev->vbus_session == 0)
+ } else if ((dev->gadget.vbus_active == 0)
&& (vbus == 1)
&& !dev->vbus_gpio.intr)
schedule_work(&dev->vbus_gpio.irq_work_fall);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 10/14] usb: pxa25x_udc: using common vbus_active
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
` (8 preceding siblings ...)
2013-03-14 5:50 ` [PATCH 09/14] usb: pch_udc: " Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 5:50 ` [PATCH 11/14] usb: pxa27x_udc: " Peter Chen
` (3 subsequent siblings)
13 siblings, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
Using common vbus_active to indicate vbus status
CC: Eric Miao <eric.y.miao@gmail.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/gadget/pxa25x_udc.c | 6 +++---
drivers/usb/gadget/pxa25x_udc.h | 1 -
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index 2bbcdce..1007546 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -926,7 +926,7 @@ static void udc_disable(struct pxa25x_udc *);
*/
static int pullup(struct pxa25x_udc *udc)
{
- int is_active = udc->vbus && udc->pullup && !udc->suspended;
+ int is_active = udc->gadget.vbus_active && udc->pullup && !udc->suspended;
DMSG("%s\n", is_active ? "active" : "inactive");
if (is_active) {
if (!udc->active) {
@@ -959,7 +959,7 @@ static int pxa25x_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
struct pxa25x_udc *udc;
udc = container_of(_gadget, struct pxa25x_udc, gadget);
- udc->vbus = is_active;
+ udc->gadget.vbus_active = is_active;
DMSG("vbus %s\n", is_active ? "supplied" : "inactive");
pullup(udc);
return 0;
@@ -2152,7 +2152,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev)
udc_disable(dev);
udc_reinit(dev);
- dev->vbus = 0;
+ dev->gadget.vbus_active = 0;
/* irq setup after old hardware state is cleaned up */
retval = request_irq(irq, pxa25x_udc_irq,
diff --git a/drivers/usb/gadget/pxa25x_udc.h b/drivers/usb/gadget/pxa25x_udc.h
index 3fe5931..3039992 100644
--- a/drivers/usb/gadget/pxa25x_udc.h
+++ b/drivers/usb/gadget/pxa25x_udc.h
@@ -103,7 +103,6 @@ struct pxa25x_udc {
enum ep0_state ep0state;
struct udc_stats stats;
unsigned got_irq : 1,
- vbus : 1,
pullup : 1,
has_cfr : 1,
req_pending : 1,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 11/14] usb: pxa27x_udc: using common vbus_active
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
` (9 preceding siblings ...)
2013-03-14 5:50 ` [PATCH 10/14] usb: pxa25x_udc: " Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 5:50 ` [PATCH 12/14] usb: s3c2410_udc: " Peter Chen
` (2 subsequent siblings)
13 siblings, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
Using common vbus_active to indicate vbus status
CC: Eric Miao <eric.y.miao@gmail.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/gadget/pxa27x_udc.c | 8 ++++----
drivers/usb/gadget/pxa27x_udc.h | 1 -
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index f7d2579..de997c5 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -1574,7 +1574,7 @@ static int should_enable_udc(struct pxa_udc *udc)
int put_on;
put_on = ((udc->pullup_on) && (udc->driver));
- put_on &= ((udc->vbus_sensed) || (IS_ERR_OR_NULL(udc->transceiver)));
+ put_on &= ((udc->gadget.vbus_active) || (IS_ERR_OR_NULL(udc->transceiver)));
return put_on;
}
@@ -1595,7 +1595,7 @@ static int should_disable_udc(struct pxa_udc *udc)
int put_off;
put_off = ((!udc->pullup_on) || (!udc->driver));
- put_off |= ((!udc->vbus_sensed) && (!IS_ERR_OR_NULL(udc->transceiver)));
+ put_off |= ((!udc->gadget.vbus_active) && (!IS_ERR_OR_NULL(udc->transceiver)));
return put_off;
}
@@ -1640,7 +1640,7 @@ static int pxa_udc_vbus_session(struct usb_gadget *_gadget, int is_active)
{
struct pxa_udc *udc = to_gadget_udc(_gadget);
- udc->vbus_sensed = is_active;
+ _gadget->vbus_active = is_active;
if (should_enable_udc(udc))
udc_enable(udc);
if (should_disable_udc(udc))
@@ -2465,7 +2465,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev)
device_initialize(&udc->gadget.dev);
udc->gadget.dev.parent = &pdev->dev;
udc->gadget.dev.dma_mask = NULL;
- udc->vbus_sensed = 0;
+ udc->gadget.vbus_active = 0;
the_controller = udc;
platform_set_drvdata(pdev, udc);
diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h
index 28f2b53..184bf45 100644
--- a/drivers/usb/gadget/pxa27x_udc.h
+++ b/drivers/usb/gadget/pxa27x_udc.h
@@ -458,7 +458,6 @@ struct pxa_udc {
unsigned enabled:1;
unsigned pullup_on:1;
unsigned pullup_resume:1;
- unsigned vbus_sensed:1;
unsigned config:2;
unsigned last_interface:3;
unsigned last_alternate:3;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 12/14] usb: s3c2410_udc: using common vbus_active
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
` (10 preceding siblings ...)
2013-03-14 5:50 ` [PATCH 11/14] usb: pxa27x_udc: " Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 5:50 ` [PATCH 13/14] usb: udc-core: small cleanup for udc->gadget Peter Chen
2013-03-14 5:50 ` [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect Peter Chen
13 siblings, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
Using common vbus_active to indicate vbus status
CC: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/gadget/s3c2410_udc.c | 6 +++---
drivers/usb/gadget/s3c2410_udc.h | 1 -
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c
index fc07b43..ae7a7e3 100644
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -1494,7 +1494,7 @@ static int s3c2410_udc_vbus_session(struct usb_gadget *gadget, int is_active)
dprintk(DEBUG_NORMAL, "%s()\n", __func__);
- udc->vbus = (is_active != 0);
+ gadget->vbus_active = (is_active != 0);
s3c2410_udc_set_pullup(udc, is_active);
return 0;
}
@@ -1520,7 +1520,7 @@ static irqreturn_t s3c2410_udc_vbus_irq(int irq, void *_dev)
if (udc_info->vbus_pin_inverted)
value = !value;
- if (value != dev->vbus)
+ if (value != &dev->gadget.vbus)
s3c2410_udc_vbus_session(&dev->gadget, value);
return IRQ_HANDLED;
@@ -1887,7 +1887,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
dev_dbg(dev, "got irq %i\n", irq);
} else {
- udc->vbus = 1;
+ udc->gadget.vbus = 1;
}
if (udc_info && !udc_info->udc_command &&
diff --git a/drivers/usb/gadget/s3c2410_udc.h b/drivers/usb/gadget/s3c2410_udc.h
index 93bf225..ca5ad98 100644
--- a/drivers/usb/gadget/s3c2410_udc.h
+++ b/drivers/usb/gadget/s3c2410_udc.h
@@ -92,7 +92,6 @@ struct s3c2410_udc {
unsigned req_std : 1;
unsigned req_config : 1;
unsigned req_pending : 1;
- u8 vbus;
struct dentry *regs_info;
};
#define to_s3c2410(g) (container_of((g), struct s3c2410_udc, gadget))
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 13/14] usb: udc-core: small cleanup for udc->gadget
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
` (11 preceding siblings ...)
2013-03-14 5:50 ` [PATCH 12/14] usb: s3c2410_udc: " Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 5:50 ` [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect Peter Chen
13 siblings, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
:s/udc->gadget/gadget
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/gadget/udc-core.c | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index 2a9cd36..4d90bdf 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -262,6 +262,7 @@ EXPORT_SYMBOL_GPL(usb_del_gadget_udc);
static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *driver)
{
int ret;
+ struct usb_gadget *gadget = udc->gadget;
dev_dbg(&udc->dev, "registering UDC driver [%s]\n",
driver->function);
@@ -269,15 +270,15 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri
udc->driver = driver;
udc->dev.driver = &driver->driver;
- ret = driver->bind(udc->gadget, driver);
+ ret = driver->bind(gadget, driver);
if (ret)
goto err1;
- ret = usb_gadget_udc_start(udc->gadget, driver);
+ ret = usb_gadget_udc_start(gadget, driver);
if (ret) {
- driver->unbind(udc->gadget);
+ driver->unbind(gadget);
goto err1;
}
- usb_gadget_connect(udc->gadget);
+ usb_gadget_connect(gadget);
kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
return 0;
@@ -379,13 +380,14 @@ static ssize_t usb_udc_softconn_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t n)
{
struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
+ struct usb_gadget *gadget = udc->gadget;
if (sysfs_streq(buf, "connect")) {
- usb_gadget_udc_start(udc->gadget, udc->driver);
- usb_gadget_connect(udc->gadget);
+ usb_gadget_udc_start(gadget, udc->driver);
+ usb_gadget_connect(gadget);
} else if (sysfs_streq(buf, "disconnect")) {
- usb_gadget_disconnect(udc->gadget);
- usb_gadget_udc_stop(udc->gadget, udc->driver);
+ usb_gadget_disconnect(gadget);
+ usb_gadget_udc_stop(gadget, udc->driver);
} else {
dev_err(dev, "unsupported command '%s'\n", buf);
return -EINVAL;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
` (12 preceding siblings ...)
2013-03-14 5:50 ` [PATCH 13/14] usb: udc-core: small cleanup for udc->gadget Peter Chen
@ 2013-03-14 5:50 ` Peter Chen
2013-03-14 9:00 ` Felipe Balbi
13 siblings, 1 reply; 24+ messages in thread
From: Peter Chen @ 2013-03-14 5:50 UTC (permalink / raw)
To: linux-arm-kernel
- If there is no vbus control to indicate connection.
and disconnect, we can pullup dp when we load gadget module.
- If we have vbus control logic, the dp is better pull up
when there is a vbus session.
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/gadget/udc-core.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index 4d90bdf..4b56f7c 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -278,7 +278,10 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri
driver->unbind(gadget);
goto err1;
}
- usb_gadget_connect(gadget);
+ if (!gadget->ops->vbus_session ||
+ (gadget->ops->vbus_session
+ && gadget->vbus_active))
+ usb_gadget_connect(gadget);
kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
return 0;
@@ -384,7 +387,10 @@ static ssize_t usb_udc_softconn_store(struct device *dev,
if (sysfs_streq(buf, "connect")) {
usb_gadget_udc_start(gadget, udc->driver);
- usb_gadget_connect(gadget);
+ if (!gadget->ops->vbus_session ||
+ (gadget->ops->vbus_session
+ && gadget->vbus_active))
+ usb_gadget_connect(gadget);
} else if (sysfs_streq(buf, "disconnect")) {
usb_gadget_disconnect(gadget);
usb_gadget_udc_stop(gadget, udc->driver);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect
2013-03-14 5:50 ` [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect Peter Chen
@ 2013-03-14 9:00 ` Felipe Balbi
2013-03-14 9:24 ` Peter Chen
0 siblings, 1 reply; 24+ messages in thread
From: Felipe Balbi @ 2013-03-14 9:00 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
On Thu, Mar 14, 2013 at 01:50:42PM +0800, Peter Chen wrote:
> - If there is no vbus control to indicate connection.
> and disconnect, we can pullup dp when we load gadget module.
> - If we have vbus control logic, the dp is better pull up
> when there is a vbus session.
>
> Signed-off-by: Peter Chen <peter.chen@freescale.com>
> ---
> drivers/usb/gadget/udc-core.c | 10 ++++++++--
> 1 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
> index 4d90bdf..4b56f7c 100644
> --- a/drivers/usb/gadget/udc-core.c
> +++ b/drivers/usb/gadget/udc-core.c
> @@ -278,7 +278,10 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri
> driver->unbind(gadget);
> goto err1;
> }
> - usb_gadget_connect(gadget);
> + if (!gadget->ops->vbus_session ||
> + (gadget->ops->vbus_session
> + && gadget->vbus_active))
> + usb_gadget_connect(gadget);
>
> kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
> return 0;
> @@ -384,7 +387,10 @@ static ssize_t usb_udc_softconn_store(struct device *dev,
>
> if (sysfs_streq(buf, "connect")) {
> usb_gadget_udc_start(gadget, udc->driver);
> - usb_gadget_connect(gadget);
> + if (!gadget->ops->vbus_session ||
> + (gadget->ops->vbus_session
> + && gadget->vbus_active))
> + usb_gadget_connect(gadget);
this patch is incomplete. What happens if this test fails ? Who will
connect pullup then ?
--
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130314/6cfd0ff2/attachment.sig>
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect
2013-03-14 9:00 ` Felipe Balbi
@ 2013-03-14 9:24 ` Peter Chen
2013-03-14 10:19 ` Felipe Balbi
0 siblings, 1 reply; 24+ messages in thread
From: Peter Chen @ 2013-03-14 9:24 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Mar 14, 2013 at 11:00:05AM +0200, Felipe Balbi wrote:
> Hi,
>
> On Thu, Mar 14, 2013 at 01:50:42PM +0800, Peter Chen wrote:
> > - If there is no vbus control to indicate connection.
> > and disconnect, we can pullup dp when we load gadget module.
> > - If we have vbus control logic, the dp is better pull up
> > when there is a vbus session.
> >
> > Signed-off-by: Peter Chen <peter.chen@freescale.com>
> > ---
> > drivers/usb/gadget/udc-core.c | 10 ++++++++--
> > 1 files changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
> > index 4d90bdf..4b56f7c 100644
> > --- a/drivers/usb/gadget/udc-core.c
> > +++ b/drivers/usb/gadget/udc-core.c
> > @@ -278,7 +278,10 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri
> > driver->unbind(gadget);
> > goto err1;
> > }
> > - usb_gadget_connect(gadget);
> > + if (!gadget->ops->vbus_session ||
> > + (gadget->ops->vbus_session
> > + && gadget->vbus_active))
> > + usb_gadget_connect(gadget);
> >
> > kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
> > return 0;
> > @@ -384,7 +387,10 @@ static ssize_t usb_udc_softconn_store(struct device *dev,
> >
> > if (sysfs_streq(buf, "connect")) {
> > usb_gadget_udc_start(gadget, udc->driver);
> > - usb_gadget_connect(gadget);
> > + if (!gadget->ops->vbus_session ||
> > + (gadget->ops->vbus_session
> > + && gadget->vbus_active))
> > + usb_gadget_connect(gadget);
>
> this patch is incomplete. What happens if this test fails ? Who will
> connect pullup then ?
gadget->ops->vbus_session will handle it when the vbus interrupt comes
>
> --
> balbi
--
Best Regards,
Peter Chen
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect
2013-03-14 9:24 ` Peter Chen
@ 2013-03-14 10:19 ` Felipe Balbi
2013-03-15 6:06 ` Peter Chen
0 siblings, 1 reply; 24+ messages in thread
From: Felipe Balbi @ 2013-03-14 10:19 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
On Thu, Mar 14, 2013 at 05:24:39PM +0800, Peter Chen wrote:
> > > @@ -278,7 +278,10 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri
> > > driver->unbind(gadget);
> > > goto err1;
> > > }
> > > - usb_gadget_connect(gadget);
> > > + if (!gadget->ops->vbus_session ||
> > > + (gadget->ops->vbus_session
> > > + && gadget->vbus_active))
> > > + usb_gadget_connect(gadget);
> > >
> > > kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
> > > return 0;
> > > @@ -384,7 +387,10 @@ static ssize_t usb_udc_softconn_store(struct device *dev,
> > >
> > > if (sysfs_streq(buf, "connect")) {
> > > usb_gadget_udc_start(gadget, udc->driver);
> > > - usb_gadget_connect(gadget);
> > > + if (!gadget->ops->vbus_session ||
> > > + (gadget->ops->vbus_session
> > > + && gadget->vbus_active))
> > > + usb_gadget_connect(gadget);
> >
> > this patch is incomplete. What happens if this test fails ? Who will
> > connect pullup then ?
>
> gadget->ops->vbus_session will handle it when the vbus interrupt comes
for your driver, what about all the others ? Also, we shouldn't allow
this ping-pong between who handles pullup and who handles vbus_session.
It should all be managed by udc-core with UDC drivers just providing
enough hooks. If we allow the UDC driver to connect pullups when VBUS
IRQ comes, we could fall into all sorts of traps:
a) we could connect cable with no gadget driver loaded
b) there will be code duplication among all UDC drivers to call
usb_gadge_connect() from vbus_session
c) we might screw up the usb_function_activate()/deactivate() counter
Need to be very careful with all these details, there are many, many
users to udc-core with different requirements. So unless we can come up
with a way which wouldn't cause code duplication or regressions, I don't
think we can solve the real problem.
I guess the best solution to all problems is to start deferring
pullup to when gadget driver says it's ok to connect them. It's far more
likely that we will already have connection to a host and VBUS will be
alive.
Also, I'm not sure what does this all mean for SRP. Should we connect
pullup before or after SRP ?
--
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130314/4423ce01/attachment-0001.sig>
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect
2013-03-14 10:19 ` Felipe Balbi
@ 2013-03-15 6:06 ` Peter Chen
2013-03-15 7:51 ` Felipe Balbi
0 siblings, 1 reply; 24+ messages in thread
From: Peter Chen @ 2013-03-15 6:06 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Mar 14, 2013 at 12:19:04PM +0200, Felipe Balbi wrote:
> Hi,
>
> On Thu, Mar 14, 2013 at 05:24:39PM +0800, Peter Chen wrote:
> > > > @@ -278,7 +278,10 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri
> > > > driver->unbind(gadget);
> > > > goto err1;
> > > > }
> > > > - usb_gadget_connect(gadget);
> > > > + if (!gadget->ops->vbus_session ||
> > > > + (gadget->ops->vbus_session
> > > > + && gadget->vbus_active))
> > > > + usb_gadget_connect(gadget);
> > > >
> > > > kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
> > > > return 0;
> > > > @@ -384,7 +387,10 @@ static ssize_t usb_udc_softconn_store(struct device *dev,
> > > >
> > > > if (sysfs_streq(buf, "connect")) {
> > > > usb_gadget_udc_start(gadget, udc->driver);
> > > > - usb_gadget_connect(gadget);
> > > > + if (!gadget->ops->vbus_session ||
> > > > + (gadget->ops->vbus_session
> > > > + && gadget->vbus_active))
> > > > + usb_gadget_connect(gadget);
> > >
> > > this patch is incomplete. What happens if this test fails ? Who will
> > > connect pullup then ?
> >
> > gadget->ops->vbus_session will handle it when the vbus interrupt comes
>
> for your driver, what about all the others ?
All drivers have .vbus_session will try to pullup, but some still check
if .pullup (using .softconnect) is called beforehand, it is duplicated
with this patch. Sorry, my careless.
If you have a look with these drivers, even usb_gadget_connect is called
at udc_bind_to_driver, they will NOT pull up if vbus is not there.
The most strict condition is :
gadget_is_loaded && vbus_session_is_called && pullup_is_called
In fact, calling usb_gadget_connect(gadget) unconditionally at udc-core
may hang system if low power is enabled as udc will enter low
power mode after udc_start if no vbus is there.
> Also, we shouldn't allow
> this ping-pong between who handles pullup and who handles vbus_session.
>
> It should all be managed by udc-core with UDC drivers just providing
> enough hooks. If we allow the UDC driver to connect pullups when VBUS
> IRQ comes, we could fall into all sorts of traps:
>
> a) we could connect cable with no gadget driver loaded
In that case, the pullup will not be called, it will check if gadget module
is loaded.
> b) there will be code duplication among all UDC drivers to call
> usb_gadge_connect() from vbus_session
Yes
> c) we might screw up the usb_function_activate()/deactivate() counter
>
why?
> Need to be very careful with all these details, there are many, many
> users to udc-core with different requirements. So unless we can come up
> with a way which wouldn't cause code duplication or regressions, I don't
> think we can solve the real problem.
Yes, udc has vendor specific, no uniform spec like host.
>
> I guess the best solution to all problems is to start deferring
> pullup to when gadget driver says it's ok to connect them. It's far more
> likely that we will already have connection to a host and VBUS will be
> alive.
I still think (gadget_is_loaded && vbus_is_there) is enough.
>
> Also, I'm not sure what does this all mean for SRP. Should we connect
> pullup before or after SRP ?
I am not familiar with SRP, but I think vbus is pre-condition.
--
Best Regards,
Peter Chen
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect
2013-03-15 6:06 ` Peter Chen
@ 2013-03-15 7:51 ` Felipe Balbi
2013-03-15 10:04 ` Peter Chen
0 siblings, 1 reply; 24+ messages in thread
From: Felipe Balbi @ 2013-03-15 7:51 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
On Fri, Mar 15, 2013 at 02:06:16PM +0800, Peter Chen wrote:
> > > > > @@ -278,7 +278,10 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri
> > > > > driver->unbind(gadget);
> > > > > goto err1;
> > > > > }
> > > > > - usb_gadget_connect(gadget);
> > > > > + if (!gadget->ops->vbus_session ||
> > > > > + (gadget->ops->vbus_session
> > > > > + && gadget->vbus_active))
> > > > > + usb_gadget_connect(gadget);
> > > > >
> > > > > kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE);
> > > > > return 0;
> > > > > @@ -384,7 +387,10 @@ static ssize_t usb_udc_softconn_store(struct device *dev,
> > > > >
> > > > > if (sysfs_streq(buf, "connect")) {
> > > > > usb_gadget_udc_start(gadget, udc->driver);
> > > > > - usb_gadget_connect(gadget);
> > > > > + if (!gadget->ops->vbus_session ||
> > > > > + (gadget->ops->vbus_session
> > > > > + && gadget->vbus_active))
> > > > > + usb_gadget_connect(gadget);
> > > >
> > > > this patch is incomplete. What happens if this test fails ? Who will
> > > > connect pullup then ?
> > >
> > > gadget->ops->vbus_session will handle it when the vbus interrupt comes
> >
> > for your driver, what about all the others ?
>
> All drivers have .vbus_session will try to pullup, but some still check
> if .pullup (using .softconnect) is called beforehand, it is duplicated
> with this patch. Sorry, my careless.
> If you have a look with these drivers, even usb_gadget_connect is called
> at udc_bind_to_driver, they will NOT pull up if vbus is not there.
that's all wrong and needs to be fixed. UDC-core has to be the central
point for all these details. We start with the easiest way (call connect
unconditionally after gadget driver is loaded) and optimize it as we go
(making sure that there is VBUS before connecting pullups); but we can't
bypass UDC-core and call usb_gadget_connect() directly from UDC driver.
> The most strict condition is :
> gadget_is_loaded && vbus_session_is_called && pullup_is_called
>
> In fact, calling usb_gadget_connect(gadget) unconditionally at udc-core
> may hang system if low power is enabled as udc will enter low
> power mode after udc_start if no vbus is there.
that's a bug in the UDC driver though. It should add proper
pm_runtime_get_sync() and pm_runtime_put() (or put_sync()) around
register accesses, which means that ->pullup() should take care of that
too.
> > Also, we shouldn't allow
> > this ping-pong between who handles pullup and who handles vbus_session.
> >
> > It should all be managed by udc-core with UDC drivers just providing
> > enough hooks. If we allow the UDC driver to connect pullups when VBUS
> > IRQ comes, we could fall into all sorts of traps:
> >
> > a) we could connect cable with no gadget driver loaded
>
> In that case, the pullup will not be called, it will check if gadget
> module is loaded.
I don't see that in your patch.
> > b) there will be code duplication among all UDC drivers to call
> > usb_gadge_connect() from vbus_session
>
> Yes
yeah, we need to avoid it.
> > c) we might screw up the usb_function_activate()/deactivate() counter
> >
>
> why?
(USB cable already attached to a host, VBUS alive) gadget driver is
loaded, gadget driver calls usb_function_deactive() to prevent
enumeration until userland is ready, UDC driver calls
usb_gadget_connect() because there is a gadget driver and vbus is alive.
> > Need to be very careful with all these details, there are many, many
> > users to udc-core with different requirements. So unless we can come up
> > with a way which wouldn't cause code duplication or regressions, I don't
> > think we can solve the real problem.
>
> Yes, udc has vendor specific, no uniform spec like host.
there are plenty of non-uniform hosts as well. MUSB and dwc2 are just
two instances of them. Still usbcore works just fine with those and the
standard ones.
> > I guess the best solution to all problems is to start deferring
> > pullup to when gadget driver says it's ok to connect them. It's far more
> > likely that we will already have connection to a host and VBUS will be
> > alive.
>
> I still think (gadget_is_loaded && vbus_is_there) is enough.
it's not, see above.
> > Also, I'm not sure what does this all mean for SRP. Should we connect
> > pullup before or after SRP ?
>
> I am not familiar with SRP, but I think vbus is pre-condition.
hehe, google SRP.
Nah, I'll save you the trouble. SRP is a mechanism for the USB
peripheral to ask the host to enable VBUS. This means that we can keep
the VBUS charge pump disabled, and thus save power, until peripheral
requests for a session.
--
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130315/75ace05b/attachment-0001.sig>
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect
2013-03-15 7:51 ` Felipe Balbi
@ 2013-03-15 10:04 ` Peter Chen
2013-03-15 10:37 ` Felipe Balbi
0 siblings, 1 reply; 24+ messages in thread
From: Peter Chen @ 2013-03-15 10:04 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Mar 15, 2013 at 09:51:29AM +0200, Felipe Balbi wrote:
>
> that's all wrong and needs to be fixed. UDC-core has to be the central
> point for all these details. We start with the easiest way (call connect
> unconditionally after gadget driver is loaded) and optimize it as we go
> (making sure that there is VBUS before connecting pullups); but we can't
> bypass UDC-core and call usb_gadget_connect() directly from UDC driver.
I have an idea that let the gadget driver call usb_gadget_connect/disconnect,
and make a refcount for calling .pullup at usb_gadget_connect/disconnect.
Below is an initial idea for it, I think it can also cover both udc
and uvc case.
drivers/usb/chipidea/udc.c | 6 ++----
drivers/usb/gadget/composite.c | 6 ++++++
include/linux/usb/gadget.h | 21 +++++++++++++++++++--
3 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 81184b9..4b6b2d8 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1386,17 +1386,15 @@ static int ci13xxx_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);
- ci13xxx_pullup(_gadget, true);
+ ci->driver->connect(&ci->gadget);
dev_dbg(ci->dev, "Connected to host\n");
} else {
- if (ci->driver)
- ci->driver->disconnect(&ci->gadget);
+ ci->driver->disconnect(&ci->gadget);
hw_device_state(ci, 0);
if (ci->platdata->notify_event)
ci->platdata->notify_event(ci,
CI13XXX_CONTROLLER_STOPPED_EVENT);
_gadget_stop_activity(&ci->gadget);
- ci13xxx_pullup(_gadget, false);
pm_runtime_put_sync(&_gadget->dev);
dev_dbg(ci->dev, "Disconnected from host\n");
}
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 7c821de..b7bf5ae 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1479,6 +1479,11 @@ done:
return value;
}
+void composite_connect(struct usb_gadget *gadget)
+{
+ usb_gadget_connect(gadget);
+}
+
void composite_disconnect(struct usb_gadget *gadget)
{
struct usb_composite_dev *cdev = get_gadget_data(gadget);
@@ -1492,6 +1497,7 @@ void composite_disconnect(struct usb_gadget *gadget)
reset_config(cdev);
if (cdev->driver->disconnect)
cdev->driver->disconnect(cdev);
+ usb_gadget_disconnect(gadget);
spin_unlock_irqrestore(&cdev->lock, flags);
}
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 7e373a2..7f7e6bf 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -536,6 +536,7 @@ struct usb_gadget {
struct device dev;
unsigned out_epnum;
unsigned in_epnum;
+ int connection;
};
static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
@@ -722,9 +723,16 @@ static inline int usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
*/
static inline int usb_gadget_connect(struct usb_gadget *gadget)
{
+ int ret = 0;
if (!gadget->ops->pullup)
return -EOPNOTSUPP;
- return gadget->ops->pullup(gadget, 1);
+
+ if (gadget->connection == 0)
+ ret = gadget->ops->pullup(gadget, 1);
+ if (!ret)
+ gadget->connection ++;
+
+ return ret;
}
/**
@@ -744,9 +752,18 @@ static inline int usb_gadget_connect(struct usb_gadget *gadget)
*/
static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
{
+ int ret = 0;
+
if (!gadget->ops->pullup)
return -EOPNOTSUPP;
- return gadget->ops->pullup(gadget, 0);
+
+ if (gadget->connection == 1)
+ ret = gadget->ops->pullup(gadget, 0);
+
+ if (!ret)
+ gadget->connection --;
+
+ return ret;
}
> >
> > In that case, the pullup will not be called, it will check if gadget
> > module is loaded.
>
> I don't see that in your patch.
At each udc driver, it makes sure it, maybe we can move it to usb_gaget_connect
/usb_gadget_disconnect or its abstract layer.
> >
> > I am not familiar with SRP, but I think vbus is pre-condition.
>
> hehe, google SRP.
>
> Nah, I'll save you the trouble. SRP is a mechanism for the USB
> peripheral to ask the host to enable VBUS. This means that we can keep
> the VBUS charge pump disabled, and thus save power, until peripheral
> requests for a session.
Thanks.
>
> --
> balbi
--
Best Regards,
Peter Chen
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect
2013-03-15 10:04 ` Peter Chen
@ 2013-03-15 10:37 ` Felipe Balbi
2013-03-15 12:26 ` Peter Chen
2013-03-18 6:52 ` Peter Chen
0 siblings, 2 replies; 24+ messages in thread
From: Felipe Balbi @ 2013-03-15 10:37 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
On Fri, Mar 15, 2013 at 06:04:08PM +0800, Peter Chen wrote:
> On Fri, Mar 15, 2013 at 09:51:29AM +0200, Felipe Balbi wrote:
> >
> > that's all wrong and needs to be fixed. UDC-core has to be the central
> > point for all these details. We start with the easiest way (call connect
> > unconditionally after gadget driver is loaded) and optimize it as we go
> > (making sure that there is VBUS before connecting pullups); but we can't
> > bypass UDC-core and call usb_gadget_connect() directly from UDC driver.
>
> I have an idea that let the gadget driver call usb_gadget_connect/disconnect,
> and make a refcount for calling .pullup at usb_gadget_connect/disconnect.
> Below is an initial idea for it, I think it can also cover both udc
> and uvc case.
>
> drivers/usb/chipidea/udc.c | 6 ++----
> drivers/usb/gadget/composite.c | 6 ++++++
> include/linux/usb/gadget.h | 21 +++++++++++++++++++--
> 3 files changed, 27 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index 81184b9..4b6b2d8 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -1386,17 +1386,15 @@ static int ci13xxx_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);
> - ci13xxx_pullup(_gadget, true);
> + ci->driver->connect(&ci->gadget);
> dev_dbg(ci->dev, "Connected to host\n");
> } else {
> - if (ci->driver)
> - ci->driver->disconnect(&ci->gadget);
> + ci->driver->disconnect(&ci->gadget);
> hw_device_state(ci, 0);
> if (ci->platdata->notify_event)
> ci->platdata->notify_event(ci,
> CI13XXX_CONTROLLER_STOPPED_EVENT);
> _gadget_stop_activity(&ci->gadget);
> - ci13xxx_pullup(_gadget, false);
> pm_runtime_put_sync(&_gadget->dev);
> dev_dbg(ci->dev, "Disconnected from host\n");
> }
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index 7c821de..b7bf5ae 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -1479,6 +1479,11 @@ done:
> return value;
> }
>
> +void composite_connect(struct usb_gadget *gadget)
> +{
> + usb_gadget_connect(gadget);
> +}
> +
> void composite_disconnect(struct usb_gadget *gadget)
> {
> struct usb_composite_dev *cdev = get_gadget_data(gadget);
> @@ -1492,6 +1497,7 @@ void composite_disconnect(struct usb_gadget *gadget)
> reset_config(cdev);
> if (cdev->driver->disconnect)
> cdev->driver->disconnect(cdev);
> + usb_gadget_disconnect(gadget);
> spin_unlock_irqrestore(&cdev->lock, flags);
> }
>
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index 7e373a2..7f7e6bf 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -536,6 +536,7 @@ struct usb_gadget {
> struct device dev;
> unsigned out_epnum;
> unsigned in_epnum;
> + int connection;
> };
>
> static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
> @@ -722,9 +723,16 @@ static inline int usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
> */
> static inline int usb_gadget_connect(struct usb_gadget *gadget)
> {
> + int ret = 0;
> if (!gadget->ops->pullup)
> return -EOPNOTSUPP;
> - return gadget->ops->pullup(gadget, 1);
> +
> + if (gadget->connection == 0)
> + ret = gadget->ops->pullup(gadget, 1);
> + if (!ret)
> + gadget->connection ++;
> +
> + return ret;
> }
>
> /**
> @@ -744,9 +752,18 @@ static inline int usb_gadget_connect(struct usb_gadget *gadget)
> */
> static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
> {
> + int ret = 0;
> +
> if (!gadget->ops->pullup)
> return -EOPNOTSUPP;
> - return gadget->ops->pullup(gadget, 0);
> +
> + if (gadget->connection == 1)
> + ret = gadget->ops->pullup(gadget, 0);
> +
> + if (!ret)
> + gadget->connection --;
> +
> + return ret;
> }
this might be a good idea. But we already have something similar,
although it's managed at composite device level. Maybe we need to move
that to the gadget layer. Still, I don't want to let UDC drivers call
usb_gadget_connect()/disconnect() directly.
It's easy enough for udc-core to handle that.
> > > In that case, the pullup will not be called, it will check if gadget
> > > module is loaded.
> >
> > I don't see that in your patch.
>
> At each udc driver, it makes sure it, maybe we can move it to usb_gaget_connect
> /usb_gadget_disconnect or its abstract layer.
we shouldn't add more clutter to all UDC drivers. The target has to be
into concentrating generic/duplicated code in udc-core.c
--
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130315/2782da5a/attachment.sig>
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect
2013-03-15 10:37 ` Felipe Balbi
@ 2013-03-15 12:26 ` Peter Chen
2013-03-18 6:52 ` Peter Chen
1 sibling, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-15 12:26 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Mar 15, 2013 at 12:37:01PM +0200, Felipe Balbi wrote:
> > */
> > static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
> > {
> > + int ret = 0;
> > +
> > if (!gadget->ops->pullup)
> > return -EOPNOTSUPP;
> > - return gadget->ops->pullup(gadget, 0);
> > +
> > + if (gadget->connection == 1)
> > + ret = gadget->ops->pullup(gadget, 0);
> > +
> > + if (!ret)
> > + gadget->connection --;
> > +
> > + return ret;
> > }
>
> this might be a good idea. But we already have something similar,
> although it's managed at composite device level.
Yes, I know, it should only be managed at one place at last.
> Maybe we need to move
> that to the gadget layer. Still, I don't want to let UDC drivers call
> usb_gadget_connect()/disconnect() directly.
>
> It's easy enough for udc-core to handle that.
Below are all cases I can think about pullup_dp
1. No vbus interrupt support udc driver, manage pullup at load/unload
gadget module.
2. For vbus interrupt supported udc driver, manage pullup at vbus interrupt
3. For gadget module, like uvc, it will call pullup_dp through its app.
Are there any cases? We need to design one solution to cover all
cases, then, we can try to delete the duplicate pullup calling at
all udc drivers, and make it be generic.
--
Best Regards,
Peter Chen
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect
2013-03-15 10:37 ` Felipe Balbi
2013-03-15 12:26 ` Peter Chen
@ 2013-03-18 6:52 ` Peter Chen
1 sibling, 0 replies; 24+ messages in thread
From: Peter Chen @ 2013-03-18 6:52 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Mar 15, 2013 at 12:37:01PM +0200, Felipe Balbi wrote:
> Hi,
>
> On Fri, Mar 15, 2013 at 06:04:08PM +0800, Peter Chen wrote:
> > On Fri, Mar 15, 2013 at 09:51:29AM +0200, Felipe Balbi wrote:
> > >
> > > that's all wrong and needs to be fixed. UDC-core has to be the central
> > > point for all these details. We start with the easiest way (call connect
> > > unconditionally after gadget driver is loaded) and optimize it as we go
> > > (making sure that there is VBUS before connecting pullups); but we can't
> > > bypass UDC-core and call usb_gadget_connect() directly from UDC driver.
> >
> > I have an idea that let the gadget driver call usb_gadget_connect/disconnect,
> > and make a refcount for calling .pullup at usb_gadget_connect/disconnect.
> > Below is an initial idea for it, I think it can also cover both udc
> > and uvc case.
> >
> > drivers/usb/chipidea/udc.c | 6 ++----
> > drivers/usb/gadget/composite.c | 6 ++++++
> > include/linux/usb/gadget.h | 21 +++++++++++++++++++--
> > 3 files changed, 27 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> > index 81184b9..4b6b2d8 100644
> > --- a/drivers/usb/chipidea/udc.c
> > +++ b/drivers/usb/chipidea/udc.c
> > @@ -1386,17 +1386,15 @@ static int ci13xxx_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);
> > - ci13xxx_pullup(_gadget, true);
> > + ci->driver->connect(&ci->gadget);
> > dev_dbg(ci->dev, "Connected to host\n");
> > } else {
> > - if (ci->driver)
> > - ci->driver->disconnect(&ci->gadget);
> > + ci->driver->disconnect(&ci->gadget);
> > hw_device_state(ci, 0);
> > if (ci->platdata->notify_event)
> > ci->platdata->notify_event(ci,
> > CI13XXX_CONTROLLER_STOPPED_EVENT);
> > _gadget_stop_activity(&ci->gadget);
> > - ci13xxx_pullup(_gadget, false);
> > pm_runtime_put_sync(&_gadget->dev);
> > dev_dbg(ci->dev, "Disconnected from host\n");
> > }
> > diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> > index 7c821de..b7bf5ae 100644
> > --- a/drivers/usb/gadget/composite.c
> > +++ b/drivers/usb/gadget/composite.c
> > @@ -1479,6 +1479,11 @@ done:
> > return value;
> > }
> >
> > +void composite_connect(struct usb_gadget *gadget)
> > +{
> > + usb_gadget_connect(gadget);
> > +}
> > +
> > void composite_disconnect(struct usb_gadget *gadget)
> > {
> > struct usb_composite_dev *cdev = get_gadget_data(gadget);
> > @@ -1492,6 +1497,7 @@ void composite_disconnect(struct usb_gadget *gadget)
> > reset_config(cdev);
> > if (cdev->driver->disconnect)
> > cdev->driver->disconnect(cdev);
> > + usb_gadget_disconnect(gadget);
> > spin_unlock_irqrestore(&cdev->lock, flags);
> > }
> >
> > diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> > index 7e373a2..7f7e6bf 100644
> > --- a/include/linux/usb/gadget.h
> > +++ b/include/linux/usb/gadget.h
> > @@ -536,6 +536,7 @@ struct usb_gadget {
> > struct device dev;
> > unsigned out_epnum;
> > unsigned in_epnum;
> > + int connection;
> > };
> >
> > static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
> > @@ -722,9 +723,16 @@ static inline int usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
> > */
> > static inline int usb_gadget_connect(struct usb_gadget *gadget)
> > {
> > + int ret = 0;
> > if (!gadget->ops->pullup)
> > return -EOPNOTSUPP;
> > - return gadget->ops->pullup(gadget, 1);
> > +
> > + if (gadget->connection == 0)
> > + ret = gadget->ops->pullup(gadget, 1);
> > + if (!ret)
> > + gadget->connection ++;
> > +
> > + return ret;
> > }
> >
> > /**
> > @@ -744,9 +752,18 @@ static inline int usb_gadget_connect(struct usb_gadget *gadget)
> > */
> > static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
> > {
> > + int ret = 0;
> > +
> > if (!gadget->ops->pullup)
> > return -EOPNOTSUPP;
> > - return gadget->ops->pullup(gadget, 0);
> > +
> > + if (gadget->connection == 1)
> > + ret = gadget->ops->pullup(gadget, 0);
> > +
> > + if (!ret)
> > + gadget->connection --;
> > +
> > + return ret;
> > }
>
> this might be a good idea. But we already have something similar,
> although it's managed at composite device level. Maybe we need to move
> that to the gadget layer. Still, I don't want to let UDC drivers call
> usb_gadget_connect()/disconnect() directly.
>
> It's easy enough for udc-core to handle that.
>
Not so easy, how let udc-core know vbus interrupt?
And we need to consider the udc drivers which support or not
support vbus interrupt together.
--
Best Regards,
Peter Chen
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2013-03-18 6:52 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-14 5:50 [PATCH 00/14] Add vbus status to udc-core Peter Chen
2013-03-14 5:50 ` [PATCH 01/14] usb: udc-core: introduce vbus_active for struct usb_gadget Peter Chen
2013-03-14 5:50 ` [PATCH 02/14] usb: chipidea: using common vbus_active Peter Chen
2013-03-14 5:50 ` [PATCH 03/14] usb: at91_udc: " Peter Chen
2013-03-14 5:50 ` [PATCH 04/14] usb: fsl_udc_core: " Peter Chen
2013-03-14 5:50 ` [PATCH 05/14] usb: lpc32xx_udc: " Peter Chen
2013-03-14 5:50 ` [PATCH 06/14] usb: mv_u3d_core: " Peter Chen
2013-03-14 5:50 ` [PATCH 07/14] usb: mv_udc: " Peter Chen
2013-03-14 5:50 ` [PATCH 08/14] usb: omap_udc: " Peter Chen
2013-03-14 5:50 ` [PATCH 09/14] usb: pch_udc: " Peter Chen
2013-03-14 5:50 ` [PATCH 10/14] usb: pxa25x_udc: " Peter Chen
2013-03-14 5:50 ` [PATCH 11/14] usb: pxa27x_udc: " Peter Chen
2013-03-14 5:50 ` [PATCH 12/14] usb: s3c2410_udc: " Peter Chen
2013-03-14 5:50 ` [PATCH 13/14] usb: udc-core: small cleanup for udc->gadget Peter Chen
2013-03-14 5:50 ` [PATCH 14/14] usb: udc-core: add judgement logic for usb_gadget_connect Peter Chen
2013-03-14 9:00 ` Felipe Balbi
2013-03-14 9:24 ` Peter Chen
2013-03-14 10:19 ` Felipe Balbi
2013-03-15 6:06 ` Peter Chen
2013-03-15 7:51 ` Felipe Balbi
2013-03-15 10:04 ` Peter Chen
2013-03-15 10:37 ` Felipe Balbi
2013-03-15 12:26 ` Peter Chen
2013-03-18 6:52 ` Peter Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).