move ZTE CDMA device pid from zte_ev.c back to option.c and modify a parameter in zte_ev.ko

2014-06-20 Thread 刘磊

dear linuxfoundation:
    I'm very sorry has some problems in before's submit. now i divided the 
problems in two patches.

    patch1:move ZTE CDMA device pid from zte_ev.c back to option.c.
    reason: the pid of 0xfffe device can't re-connect succusfull when driven by 
zte_ev, but work fine when driven by option.
move the pid 0xfffe from zte_ev.c back to option.c.


Signed-off-by:lei liu
diff -uprN -X linux-3.15.1/Documentation/dontdiff 
linux-3.15.1/drivers/usb/serial/option.c 
linux-3.15.1-update/drivers/usb/serial/option.c
--- linux-3.15.1/drivers/usb/serial/option.c2014-06-17 04:44:27.0 
+0800
+++ linux-3.15.1-update/drivers/usb/serial/option.c 2014-06-18 
15:19:21.936561280 +0800
@@ -1542,6 +1542,7 @@ static const struct usb_device_id option
{ USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) },
{ USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 
0xff, 0xff, 0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xfffe, 0xff, 0xff, 
0xff) },
 
{ USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
{ USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
diff -uprN -X linux-3.15.1/Documentation/dontdiff 
linux-3.15.1/drivers/usb/serial/zte_ev.c 
linux-3.15.1-update/drivers/usb/serial/zte_ev.c
--- linux-3.15.1/drivers/usb/serial/zte_ev.c2014-06-17 04:44:27.0 
+0800
+++ linux-3.15.1-update/drivers/usb/serial/zte_ev.c 2014-06-20 
15:13:40.537941903 +0800
@@ -274,8 +274,6 @@ static void zte_ev_usb_serial_close(stru
 static const struct usb_device_id id_table[] = {
/* AC8710, AC8710T */
{ USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0x, 0xff, 0xff, 0xff) },
-/* AC8700 */
-   { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xfffe, 0xff, 0xff, 0xff) },
/* MG880 */
{ USB_DEVICE(0x19d2, 0xfffd) },
{ USB_DEVICE(0x19d2, 0xfffc) },




patch2: Modify the parameter from 0x0003 to 0x. you must submit patch1 at 
first.
Reason:In the USB serial protocol,  if set the control state 
(SET_CONTROL_LINE_STATE(22h)) and the parameter of RTS must be 0x 
that make the carrier signal invalid state when close network. otherwise can't 
disconnect the network.


Signed-off-by:lei liu
--- linux-3.15.1-update/drivers/usb/serial/zte_ev.c.orig2014-06-20 
16:17:12.449795593 +0800
+++ linux-3.15.1-update/drivers/usb/serial/zte_ev.c 2014-06-20 
16:14:56.193800822 +0800
@@ -257,12 +257,12 @@ static void zte_ev_usb_serial_close(stru
 
/* send 8th cmd */
/*
-* 16.0 CTL21 22 03 00  00 00 00 00
+* 16.0 CTL21 22 00 00  00 00 00 00
 */
len = 0;
result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
 0x22, 0x21,
-0x0003, 0x, NULL, len,
+0x, 0x, NULL, len,
 USB_CTRL_GET_TIMEOUT);
dev_dbg(dev, "result = %d\n", result);
 



thanks 
lei liu


[GIT PULL] USB fixes for v3.16-rc2

2014-06-20 Thread Felipe Balbi
Hi Greg,

Here's my first set of fixes for this -rc cycle. Please consider merging
to your usb-linus branch.

cheers

The following changes since commit 7171511eaec5bf23fb06078f59784a3a0626b38f:

  Linux 3.16-rc1 (2014-06-15 17:45:28 -1000)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
tags/fixes-for-v3.16-rc2

for you to fetch changes up to 5d881802c407d83c169c875dad88fe2bba066c33:

  usb: musb: core: Handle Babble condition only in HOST mode (2014-06-19 
15:43:07 -0500)


usb: fixes for v3.16-rc2

dwc3-omap won't crash anymore on module removal and suspend/resume won't kill
xHCI interrupts.

MUSB got a fix to handle Babble condition only in host mode, how it should be.

The f_fs function driver got a fix for a NULL pointer dereference.

Renesas gadget got a fix for Status stage handling.

Signed-of-by: Felipe Balbi 


Andrzej Pietrasiewicz (2):
  usb: gadget: OS descriptors configfs cleanup
  usb: gadget: OS descriptors: provide interface directory names

Dan Carpenter (1):
  usb: gadget: f_rndis: fix an error code on allocation failure

George Cherian (3):
  usb: dwc3: dwc3-omap: Fix the crash on module removal
  usb: dwc3: dwc3-omap: Disable/Enable only wrapper interrupts in 
prepare/complete
  usb: musb: core: Handle Babble condition only in HOST mode

Jeff Westfahl (1):
  usb: gadget: u_ether: synchronize with transmit when stopping queue

Kuninori Morimoto (1):
  usb: renesas: gadget: fixup: complete STATUS stage after receiving

Linus Walleij (1):
  usb: musb: ux500: don't propagate the OF node

Marcus Nutzinger (1):
  usb: gadget: gadgetfs: correct dev state

Michal Nazarewicz (2):
  tools: ffs-test: convert to new descriptor format fixing compilation error
  usb: gadget: f_fs: fix NULL pointer dereference when there are no strings

Zhuang Jin Can (1):
  usb: dwc3: gadget: check link trb after free_slot is increased

 drivers/usb/dwc3/Kconfig|  1 +
 drivers/usb/dwc3/dwc3-omap.c| 17 ++---
 drivers/usb/dwc3/gadget.c   |  8 
 drivers/usb/gadget/configfs.c   | 37 +++--
 drivers/usb/gadget/configfs.h   |  1 +
 drivers/usb/gadget/f_fs.c   | 12 +++-
 drivers/usb/gadget/f_rndis.c|  6 --
 drivers/usb/gadget/inode.c  |  7 ++-
 drivers/usb/gadget/u_ether.c|  3 +++
 drivers/usb/musb/musb_core.c|  2 +-
 drivers/usb/musb/ux500.c|  1 -
 drivers/usb/renesas_usbhs/fifo.c|  8 
 include/uapi/linux/usb/functionfs.h |  2 +-
 tools/usb/Makefile  |  6 +-
 tools/usb/ffs-test.c| 20 ++--
 15 files changed, 92 insertions(+), 39 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [usb resume regression] in 3.16-rc1

2014-06-20 Thread Alan Stern
On Fri, 20 Jun 2014, Jörg Otte wrote:

> 2014-06-19 19:35 GMT+02:00 Alan Stern :
> > On Thu, 19 Jun 2014, Jörg Otte wrote:
> >
> >> I don't know how to do this.
> >
> > To enable dynamic debugging (as root):
> >
> > echo 'module usbcore =p' >/sys/kernel/debug/dynamic_debug/control
> > echo 'module ehci_hcd =p' >/sys/kernel/debug/dynamic_debug/control
> >
> > Do this before you carry out the suspend, and post the resulting dmesg
> > log.
> >
> > Alan Stern
> >
> here it is.

Now I see the reason for the regression.  There already is a patch to 
fix it:

http://marc.info/?l=linux-usb&m=140304702623966&w=2

The fix will probably be included in 3.16-rc2 or -rc3.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/15] usb: dwc2: add necessary function declares for dual role

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

There are functions in gadget driver that needs to get exported so that
the common interrupt handler can call.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core.h |   52 +++
 drivers/usb/dwc2/hcd.h  |   12 +--
 2 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 95fc6e9..a064d48 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -953,4 +953,56 @@ extern void dwc2_dump_global_registers(struct dwc2_hsotg 
*hsotg);
  */
 extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
 
+/* Gadget defines */
+#if defined(CONFIG_USB_DWC2_PERIPHERAL) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
+extern void s3c_hsotg_irq_enumdone(struct dwc2_hsotg *dwc2);
+extern void s3c_hsotg_epint(struct dwc2_hsotg *dwc2, unsigned int idx,
+   int dir_in);
+extern void kill_all_requests(struct dwc2_hsotg *dwc2,
+   struct s3c_hsotg_ep *ep, int result, bool force);
+extern void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2);
+extern void s3c_hsotg_disable_gsint(struct dwc2_hsotg *dwc2, u32 ints);
+extern void s3c_hsotg_irq_fifoempty(struct dwc2_hsotg *dwc2, bool periodic);
+extern void s3c_hsotg_handle_rx(struct dwc2_hsotg *dwc2);
+extern void s3c_hsotg_remove(struct dwc2_hsotg *dwc2);
+extern void s3c_hsotg_dump(struct dwc2_hsotg *dwc2);
+extern int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2);
+extern int s3c_hsotg_resume(struct dwc2_hsotg *dwc2);
+#else
+static inline void s3c_hsotg_irq_enumdone(struct dwc2_hsotg *dwc2) {}
+static inline void s3c_hsotg_epint(struct dwc2_hsotg *dwc2, unsigned int idx,
+   int dir_in) {}
+static inline void kill_all_requests(struct dwc2_hsotg *dwc2,
+   struct s3c_hsotg_ep *ep, int result, bool force) {}
+static inline void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2) {}
+static inline void s3c_hsotg_disable_gsint(struct dwc2_hsotg *dwc2, u32 ints)
+{}
+static inline void s3c_hsotg_irq_fifoempty(struct dwc2_hsotg *dwc2,
+   bool periodic) {}
+static inline void s3c_hsotg_handle_rx(struct dwc2_hsotg *dwc2) {}
+static inline void s3c_hsotg_remove(struct dwc2_hsotg *dwc2) {}
+static inline void s3c_hsotg_dump(struct dwc2_hsotg *dwc2) {}
+static inline int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
+{ return 0; }
+static inline int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
+{ return 0; }
+#endif
+
+extern void dwc2_set_all_params(struct dwc2_core_params *params, int value);
+#if defined(CONFIG_USB_DWC2_HOST) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
+/**
+ * dwc2_hcd_get_frame_number() - Returns current frame number
+ *
+ * @hsotg: The DWC2 HCD
+ */
+extern int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg);
+extern void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg);
+extern void dwc2_hcd_start(struct dwc2_hsotg *hsotg);
+#else
+static inline int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg)
+{ return 0; }
+static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg) {}
+static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {}
+#endif
+
 #endif /* __DWC2_CORE_H__ */
diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h
index fdc6d48..9705abf 100644
--- a/drivers/usb/dwc2/hcd.h
+++ b/drivers/usb/dwc2/hcd.h
@@ -449,12 +449,12 @@ static inline u8 dwc2_hcd_is_pipe_out(struct 
dwc2_hcd_pipe_info *pipe)
return !dwc2_hcd_is_pipe_in(pipe);
 }
 
+extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
 extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 const struct dwc2_core_params *params);
 extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg);
 extern void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
const struct dwc2_core_params *params);
-extern void dwc2_set_all_params(struct dwc2_core_params *params, int value);
 extern int dwc2_get_hwparams(struct dwc2_hsotg *hsotg);
 
 /* Transaction Execution Functions */
@@ -666,9 +666,6 @@ extern irqreturn_t dwc2_handle_hcd_intr(struct dwc2_hsotg 
*hsotg);
  */
 extern void dwc2_hcd_stop(struct dwc2_hsotg *hsotg);
 
-extern void dwc2_hcd_start(struct dwc2_hsotg *hsotg);
-extern void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg);
-
 /**
  * dwc2_hcd_is_b_host() - Returns 1 if core currently is acting as B host,
  * and 0 otherwise
@@ -678,13 +675,6 @@ extern void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg);
 extern int dwc2_hcd_is_b_host(struct dwc2_hsotg *hsotg);
 
 /**
- * dwc2_hcd_get_frame_number() - Returns current frame number
- *
- * @hsotg: The DWC2 HCD
- */
-extern int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg);
-
-/**
  * dwc2_hcd_dump_state() - Dumps hsotg state
  *
  * @hsotg: The DWC2 HCD
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.h

[PATCH 00/15] usb: dwc2: Add support for dual-role

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Hi,

This patch series combines the dwc2 host and gadget driver into a single
dual-role driver. I have tested this on the SOCFPGA platform. I compile
tested for bcm2835_defconfig and a PCI platform.

I split up the patches to make the review a bit easier, but each individual
patch can't really stand on it's own. Any comments/testing is greatly
appreciated.

I have pushed this to:

git://git.rocketboards.org/linux-socfpga-next.git/dwc2_dual_role_v1


Dinh Nguyen (15):
  usb: dwc2: Moves s3c_hsotg gadget data structure into dwc2_hsotg
  usb: dwc2: add necessary function declares for dual role
  usb: dwc2: gadget: convert gadget driver to use common dwc2_hsotg
structure
  usb: dwc2: gadget: Change the gadget probe function into gadget_init
  usb: dwc2: Move gadget interrupts to common interrupt handler
  usb: dwc2: gadget: remove gadget module defines
  usb: dwc2: gadget: Do not fail probe if there isn't a clock node
  usb: dwc2: Add the appropriate init calls in platform code
  usb: dwc2: move allocation of core_params
  usb: dwc2: initialize the spin_lock for both host and gadget
  usb: dwc2: Add suspend/resume for gadget
  usb: dwc2: move dwc2_set_all_params to platform code
  usb: dwc2: check that the host work queue is valid
  usb: dwc2: pci: Update pci portion of the dwc2 driver
  usb: dwc2: Update Kconfig to support dual-role

 drivers/usb/dwc2/Kconfig |   52 +-
 drivers/usb/dwc2/Makefile|   21 +-
 drivers/usb/dwc2/core.c  |   15 +
 drivers/usb/dwc2/core.h  |   62 +-
 drivers/usb/dwc2/core_intr.c |  119 +++-
 drivers/usb/dwc2/gadget.c| 1433 +-
 drivers/usb/dwc2/hcd.c   |   23 +-
 drivers/usb/dwc2/hcd.h   |   12 +-
 drivers/usb/dwc2/pci.c   |   28 +-
 drivers/usb/dwc2/platform.c  |   58 +-
 10 files changed, 902 insertions(+), 921 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/15] usb: dwc2: Moves s3c_hsotg gadget data structure into dwc2_hsotg

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Adds the gadget data structure and appropriate data structure pointers
to the common dwc2_hsotg data structure. This is needed so that the
dwc2_hsotg data structure can be used by the hcd and gadget drivers.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core.h |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 1efd10c..95fc6e9 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -84,7 +84,7 @@ static const char * const s3c_hsotg_supply_names[] = {
  */
 #define EP0_MPS_LIMIT   64
 
-struct s3c_hsotg;
+struct dwc2_hsotg;
 struct s3c_hsotg_req;
 
 /**
@@ -130,7 +130,7 @@ struct s3c_hsotg_req;
 struct s3c_hsotg_ep {
struct usb_ep   ep;
struct list_headqueue;
-   struct s3c_hsotg*parent;
+   struct dwc2_hsotg   *parent;
struct s3c_hsotg_req*req;
struct dentry   *debugfs;
 
@@ -601,6 +601,12 @@ struct dwc2_hsotg {
struct timer_list wkp_timer;
enum dwc2_lx_state lx_state;
 
+   /* Gadget structures */
+   struct s3c_hsotg *s3c_hsotg;
+   struct usb_gadget   gadget;
+   struct usb_gadget_driver *driver;
+   struct s3c_hsotg_ep *eps;
+
union dwc2_hcd_internal_flags {
u32 d32;
struct {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/15] usb: dwc2: gadget: Change the gadget probe function into gadget_init

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

gadget_init() will get called from the platform probe function.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/gadget.c |  144 +
 1 file changed, 55 insertions(+), 89 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 171ed28..e74656c 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3372,25 +3372,24 @@ static void s3c_hsotg_delete_debug(struct dwc2_hsotg 
*dwc2)
 }
 
 /**
- * s3c_hsotg_probe - probe function for hsotg driver
- * @pdev: The platform information for the driver
+ * dwc2_gadget_init - init function for gadget
+ * @dwc2: The data structure for the DWC2 driver.
+ * @irq: The IRQ number for the controller.
  */
 
-static int s3c_hsotg_probe(struct platform_device *pdev)
+static int dwc2_gadget_init(struct dwc2_hsotg *dwc2, int irq)
 {
-   struct s3c_hsotg_plat *plat = dev_get_platdata(&pdev->dev);
+   struct s3c_hsotg_plat *plat = dwc2->dev->platform_data;
struct phy *phy;
struct usb_phy *uphy;
-   struct device *dev = &pdev->dev;
+   struct device *dev = dwc2->dev;
struct s3c_hsotg_ep *eps;
-   struct s3c_hsotg *hsotg;
-   struct resource *res;
int epnum;
int ret;
int i;
 
-   hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
-   if (!hsotg) {
+   dwc2->s3c_hsotg = devm_kzalloc(dev, sizeof(struct s3c_hsotg), 
GFP_KERNEL);
+   if (!dwc2->s3c_hsotg) {
dev_err(dev, "cannot get memory\n");
return -ENOMEM;
}
@@ -3399,117 +3398,84 @@ static int s3c_hsotg_probe(struct platform_device 
*pdev)
 * Attempt to find a generic PHY, then look for an old style
 * USB PHY, finally fall back to pdata
 */
-   phy = devm_phy_get(&pdev->dev, "usb2-phy");
+   phy = devm_phy_get(dev, "usb2-phy");
if (IS_ERR(phy)) {
uphy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
if (IS_ERR(uphy)) {
/* Fallback for pdata */
-   plat = dev_get_platdata(&pdev->dev);
+   plat = dev_get_platdata(dev);
if (!plat) {
-   dev_err(&pdev->dev,
+   dev_err(dev,
"no platform data or transceiver defined\n");
return -EPROBE_DEFER;
}
-   hsotg->plat = plat;
+   dwc2->s3c_hsotg->plat = plat;
} else
-   hsotg->uphy = uphy;
+   dwc2->s3c_hsotg->uphy = uphy;
} else
-   hsotg->phy = phy;
+   dwc2->s3c_hsotg->phy = phy;
 
-   hsotg->dev = dev;
-
-   hsotg->clk = devm_clk_get(&pdev->dev, "otg");
-   if (IS_ERR(hsotg->clk)) {
+   dwc2->s3c_hsotg->clk = devm_clk_get(dev, "otg");
+   if (IS_ERR(dwc2->s3c_hsotg->clk)) {
dev_err(dev, "cannot get otg clock\n");
-   return PTR_ERR(hsotg->clk);
-   }
-
-   platform_set_drvdata(pdev, hsotg);
-
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-   hsotg->regs = devm_ioremap_resource(&pdev->dev, res);
-   if (IS_ERR(hsotg->regs)) {
-   ret = PTR_ERR(hsotg->regs);
-   goto err_clk;
-   }
-
-   ret = platform_get_irq(pdev, 0);
-   if (ret < 0) {
-   dev_err(dev, "cannot find IRQ\n");
-   goto err_clk;
-   }
-
-   spin_lock_init(&hsotg->lock);
-
-   hsotg->irq = ret;
-
-   ret = devm_request_irq(&pdev->dev, hsotg->irq, s3c_hsotg_irq, 0,
-   dev_name(dev), hsotg);
-   if (ret < 0) {
-   dev_err(dev, "cannot claim IRQ\n");
-   goto err_clk;
+   return PTR_ERR(dwc2->s3c_hsotg->clk);
}
 
-   dev_info(dev, "regs %p, irq %d\n", hsotg->regs, hsotg->irq);
-
-   hsotg->gadget.max_speed = USB_SPEED_HIGH;
-   hsotg->gadget.ops = &s3c_hsotg_gadget_ops;
-   hsotg->gadget.name = dev_name(dev);
+   dwc2->gadget.max_speed = USB_SPEED_HIGH;
+   dwc2->gadget.ops = &s3c_hsotg_gadget_ops;
+   dwc2->gadget.name = dev_name(dev);
 
-   /* reset the system */
-
-   clk_prepare_enable(hsotg->clk);
+   clk_prepare_enable(dwc2->s3c_hsotg->clk);
 
/* regulators */
 
-   for (i = 0; i < ARRAY_SIZE(hsotg->supplies); i++)
-   hsotg->supplies[i].supply = s3c_hsotg_supply_names[i];
+   for (i = 0; i < ARRAY_SIZE(dwc2->s3c_hsotg->supplies); i++)
+   dwc2->s3c_hsotg->supplies[i].supply = s3c_hsotg_supply_names[i];
 
-   ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(hsotg->supplies),
-hsotg->supplies);
+   ret = devm_regulator_bulk_get(dev, 
ARRAY_SIZE(dwc2->s3c_hsotg->supplies),
+d

[PATCH 07/15] usb: dwc2: gadget: Do not fail probe if there isn't a clock node

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Since the dwc2 hcd driver is currently not looking for a clock node during
init, we should not completely fail if there isn't a clock provided.
Add a check for a valid clock before calling clock functions.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/gadget.c |   15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index ca5c64a..51ee052 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3228,16 +3228,15 @@ static int dwc2_gadget_init(struct dwc2_hsotg *dwc2, 
int irq)
dwc2->s3c_hsotg->phy = phy;
 
dwc2->s3c_hsotg->clk = devm_clk_get(dev, "otg");
-   if (IS_ERR(dwc2->s3c_hsotg->clk)) {
-   dev_err(dev, "cannot get otg clock\n");
-   return PTR_ERR(dwc2->s3c_hsotg->clk);
-   }
+   if (IS_ERR(dwc2->s3c_hsotg->clk))
+   dev_warn(dev, "cannot get otg clock\n");
 
dwc2->gadget.max_speed = USB_SPEED_HIGH;
dwc2->gadget.ops = &s3c_hsotg_gadget_ops;
dwc2->gadget.name = dev_name(dev);
 
-   clk_prepare_enable(dwc2->s3c_hsotg->clk);
+   if (dwc2->s3c_hsotg->clk)
+   clk_prepare_enable(dwc2->s3c_hsotg->clk);
 
/* regulators */
 
@@ -3342,7 +3341,8 @@ err_ep_mem:
 err_supplies:
s3c_hsotg_phy_disable(dwc2);
 err_clk:
-   clk_disable_unprepare(dwc2->s3c_hsotg->clk);
+   if (dwc2->s3c_hsotg->clk)
+   clk_disable_unprepare(dwc2->s3c_hsotg->clk);
 
return ret;
 }
@@ -3365,7 +3365,8 @@ static int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
s3c_hsotg_phy_disable(dwc2);
if (dwc2->s3c_hsotg->phy)
phy_exit(dwc2->s3c_hsotg->phy);
-   clk_disable_unprepare(dwc2->s3c_hsotg->clk);
+   if (dwc2->s3c_hsotg->clk)
+   clk_disable_unprepare(dwc2->s3c_hsotg->clk);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/15] usb: dwc2: check that the host work queue is valid

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

The Host workqueue will not get initialized if the driver is configured for
peripheral mode only. Thus we need to check for wq_otg before calling
queue_work().

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core_intr.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 7500621..dbf31e4 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -288,7 +288,8 @@ static void dwc2_handle_conn_id_status_change_intr(struct 
dwc2_hsotg *hsotg)
 * scheduling.
 */
spin_unlock(&hsotg->lock);
-   queue_work(hsotg->wq_otg, &hsotg->wf_otg);
+   if (hsotg->wq_otg)
+   queue_work(hsotg->wq_otg, &hsotg->wf_otg);
spin_lock(&hsotg->lock);
 
/* Clear interrupt */
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/15] usb: dwc2: Update Kconfig to support dual-role

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Update DWC2 kconfig and makefile to support dual-role mode. The platform
file will always get compiled for the case where the controller is directly
connected to the CPU. So for loadable modules, only dwc2.ko is needed.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/Kconfig  |   52 +
 drivers/usb/dwc2/Makefile |   21 +-
 2 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/dwc2/Kconfig b/drivers/usb/dwc2/Kconfig
index f93807b..68a96cb0 100644
--- a/drivers/usb/dwc2/Kconfig
+++ b/drivers/usb/dwc2/Kconfig
@@ -1,41 +1,31 @@
 config USB_DWC2
-   bool "DesignWare USB2 DRD Core Support"
+   tristate "DesignWare USB2 DRD Core Support"
depends on USB
help
  Say Y here if your system has a Dual Role Hi-Speed USB
  controller based on the DesignWare HSOTG IP Core.
 
- For host mode, if you choose to build the driver as dynamically
- linked modules, the core module will be called dwc2.ko, the PCI
- bus interface module (if you have a PCI bus system) will be
- called dwc2_pci.ko, and the platform interface module (for
- controllers directly connected to the CPU) will be called
- dwc2_platform.ko. For gadget mode, there will be a single
- module called dwc2_gadget.ko.
+ If you choose to build the driver as dynamically
+ linked modules, a single dwc2.ko will get built for both
+ platform IPs and PCI.
 
- NOTE: The s3c-hsotg driver is now renamed to dwc2_gadget. The
- host and gadget drivers are still currently separate drivers.
- There are plans to merge the dwc2_gadget driver with the dwc2
- host driver in the near future to create a dual-role driver.
+ NOTE: The s3c-hsotg driver is now renamed to dwc2_gadget.
 
 if USB_DWC2
 
+choice
+   bool "DWC2 Mode Selection"
+   default USB_DWC2_DUAL_ROLE if (USB && USB_GADGET)
+   default USB_DWC2_HOST if (USB && !USB_GADGET)
+   default USB_DWC2_PERIPHERAL if (!USB && USB_GADGET)
+
 config USB_DWC2_HOST
-   tristate "Host only mode"
+   bool "Host only mode"
depends on USB
help
  The Designware USB2.0 high-speed host controller
  integrated into many SoCs.
 
-config USB_DWC2_PLATFORM
-   bool "DWC2 Platform"
-   depends on USB_DWC2_HOST
-   default USB_DWC2_HOST
-   help
- The Designware USB2.0 platform interface module for
- controllers directly connected to the CPU. This is only
- used for host mode.
-
 config USB_DWC2_PCI
bool "DWC2 PCI"
depends on USB_DWC2_HOST && PCI
@@ -47,12 +37,28 @@ config USB_DWC2_PCI
 comment "Gadget mode requires USB Gadget support to be enabled"
 
 config USB_DWC2_PERIPHERAL
-   tristate "Gadget only mode"
+   bool "Gadget only mode"
depends on USB_GADGET
help
  The Designware USB2.0 high-speed gadget controller
  integrated into many SoCs.
 
+config USB_DWC2_DUAL_ROLE
+   bool "Dual Role mode"
+   depends on ((USB=y || USB=USB_DWC2) && (USB_GADGET=y))
+   help
+ This is the default mode of working of DWC2 controller where
+ both host and gadget features are enabled.
+endchoice
+
+config USB_DWC2_PLATFORM
+   bool
+depends on !PCI
+default y
+help
+  The Designware USB2.0 platform interface module for
+  controllers directly connected to the CPU.
+
 config USB_DWC2_DEBUG
bool "Enable Debugging Messages"
help
diff --git a/drivers/usb/dwc2/Makefile b/drivers/usb/dwc2/Makefile
index b73d2a5..3026135 100644
--- a/drivers/usb/dwc2/Makefile
+++ b/drivers/usb/dwc2/Makefile
@@ -1,10 +1,17 @@
 ccflags-$(CONFIG_USB_DWC2_DEBUG)   += -DDEBUG
 ccflags-$(CONFIG_USB_DWC2_VERBOSE) += -DVERBOSE_DEBUG
 
-obj-$(CONFIG_USB_DWC2_HOST)+= dwc2.o
+obj-$(CONFIG_USB_DWC2) += dwc2.o
 dwc2-y := core.o core_intr.o
-dwc2-y += hcd.o hcd_intr.o
-dwc2-y += hcd_queue.o hcd_ddma.o
+
+ifneq ($(filter y,$(CONFIG_USB_DWC2_HOST) $(CONFIG_USB_DWC2_DUAL_ROLE)),)
+   dwc2-y  += hcd.o hcd_intr.o
+   dwc2-y  += hcd_queue.o hcd_ddma.o
+endif
+
+ifneq ($(filter y,$(CONFIG_USB_DWC2_PERIPHERAL) $(CONFIG_USB_DWC2_DUAL_ROLE)),)
+   dwc2-y  += gadget.o
+endif
 
 # NOTE: The previous s3c-hsotg peripheral mode only driver has been moved to
 # this location and renamed gadget.c. When building for dynamically linked
@@ -19,10 +26,4 @@ ifneq ($(CONFIG_USB_DWC2_PCI),)
dwc2_pci-y  := pci.o
 endif
 
-ifneq ($(CONFIG_USB_DWC2_PLATFORM),)
-   obj-$(CONFIG_USB_DWC2_HOST) += dwc2_platform.o
-   dwc2_platform-y := platform.o
-endif
-
-obj-$(CONF

[PATCH 11/15] usb: dwc2: Add suspend/resume for gadget

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Move suspend/resume code to common platform code.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/gadget.c   |4 ++--
 drivers/usb/dwc2/platform.c |   23 +++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 8992fe1..7ddf5a4a 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3369,7 +3369,7 @@ void s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
clk_disable_unprepare(dwc2->s3c_hsotg->clk);
 }
 
-static int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
+int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
 {
unsigned long flags;
int ret = 0;
@@ -3396,7 +3396,7 @@ static int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
return ret;
 }
 
-static int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
+int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
 {
unsigned long flags;
int ret = 0;
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 67f95ac..88a70c0 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -207,6 +207,27 @@ static int dwc2_driver_probe(struct platform_device *dev)
return retval;
 }
 
+static int dwc2_suspend(struct platform_device *dev, pm_message_t state)
+{
+   struct dwc2_hsotg *dwc2 = platform_get_drvdata(dev);
+   int ret = 0;
+
+   if (dwc2_is_device_mode(dwc2))
+   ret = s3c_hsotg_suspend(dwc2);
+   return ret;
+}
+
+static int dwc2_resume(struct platform_device *dev)
+{
+   struct dwc2_hsotg *dwc2 = platform_get_drvdata(dev);
+   int ret = 0;
+
+   if (dwc2_is_device_mode(dwc2))
+   ret = s3c_hsotg_resume(dwc2);
+
+   return ret;
+}
+
 static struct platform_driver dwc2_platform_driver = {
.driver = {
.name = dwc2_driver_name,
@@ -214,6 +235,8 @@ static struct platform_driver dwc2_platform_driver = {
},
.probe = dwc2_driver_probe,
.remove = dwc2_driver_remove,
+   .suspend = dwc2_suspend,
+   .resume = dwc2_resume,
 };
 
 module_platform_driver(dwc2_platform_driver);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/15] usb: dwc2: pci: Update pci portion of the dwc2 driver

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Update pci portion of the dwc2 driver to call the appropriate init functions
for host, gadget, and dual-role.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/pci.c |   28 ++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
index c291fca..69bd27a 100644
--- a/drivers/usb/dwc2/pci.c
+++ b/drivers/usb/dwc2/pci.c
@@ -102,7 +102,14 @@ static void dwc2_driver_remove(struct pci_dev *dev)
 {
struct dwc2_hsotg *hsotg = pci_get_drvdata(dev);
 
-   dwc2_hcd_remove(hsotg);
+   if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL))
+   s3c_hsotg_remove(hsotg);
+   else if (IS_ENABLED(CONFIG_USB_DWC2_HOST))
+   dwc2_hcd_remove(hsotg);
+   else { /* dual role */
+   s3c_hsotg_remove(hsotg);
+   dwc2_hcd_remove(hsotg);
+   }
pci_disable_device(dev);
 }
 
@@ -141,13 +148,30 @@ static int dwc2_driver_probe(struct pci_dev *dev,
 
pci_set_master(dev);
 
-   retval = dwc2_hcd_init(hsotg, dev->irq, &dwc2_module_params);
+   if (IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)) {
+   retval = dwc2_gadget_init(hsotg, dev->irq);
+   if (retval)
+   return retval;
+   retval = dwc2_hcd_init(hsotg, dev->irq, &dwc2_module_params);
+   if (retval)
+   return retval;
+   } else if (IS_ENABLED(CONFIG_USB_DWC2_HOST)) {
+   retval = dwc2_hcd_init(hsotg, dev->irq, &dwc2_module_params);
+   if (retval)
+   return retval;
+   } else if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL)) {
+   retval = dwc2_gadget_init(hsotg, dev->irq);
+   if (retval)
+   return retval;
+   }
+
if (retval) {
pci_disable_device(dev);
return retval;
}
 
pci_set_drvdata(dev, hsotg);
+   spin_lock_init(&hsotg->lock);
 
return retval;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/15] usb: dwc2: Move gadget interrupts to common interrupt handler

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Update dwc2_handle_common_intr() to handle both hcd and gadget interrupts.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core_intr.c |  116 +-
 drivers/usb/dwc2/gadget.c|  188 --
 2 files changed, 114 insertions(+), 190 deletions(-)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index c93918b..7500621 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -337,6 +337,7 @@ static void dwc2_handle_wakeup_detected_intr(struct 
dwc2_hsotg *hsotg)
}
/* Change to L0 state */
hsotg->lx_state = DWC2_L0;
+   call_gadget(hsotg, resume);
} else {
if (hsotg->lx_state != DWC2_L1) {
u32 pcgcctl = readl(hsotg->regs + PCGCTL);
@@ -397,6 +398,8 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
"DSTS.Suspend Status=%d HWCFG4.Power Optimize=%d\n",
!!(dsts & DSTS_SUSPSTS),
hsotg->hw_params.power_optimized);
+
+   call_gadget(hsotg, suspend);
} else {
if (hsotg->op_state == OTG_STATE_A_PERIPHERAL) {
dev_dbg(hsotg->dev, "a_peripheral->a_host\n");
@@ -421,6 +424,11 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
 GINTSTS_MODEMIS | GINTSTS_DISCONNINT | \
 GINTSTS_USBSUSP | GINTSTS_PRTINT)
 
+/* IRQ flags which will trigger a retry around the IRQ loop */
+#define IRQ_RETRY_MASK (GINTSTS_NPTXFEMP | \
+   GINTSTS_PTXFEMP |  \
+   GINTSTS_RXFLVL)
+
 /*
  * This function returns the Core Interrupt register
  */
@@ -441,7 +449,7 @@ static u32 dwc2_read_common_intr(struct dwc2_hsotg *hsotg)
gintsts, gintmsk);
 
if (gahbcfg & GAHBCFG_GLBL_INTR_EN)
-   return gintsts & gintmsk & gintmsk_common;
+   return gintsts & gintmsk;
else
return 0;
 }
@@ -463,7 +471,8 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
 {
struct dwc2_hsotg *hsotg = dev;
u32 gintsts;
-   irqreturn_t retval = IRQ_NONE;
+   int retry_count = 8;
+   irqreturn_t retval = IRQ_HANDLED;
 
if (!dwc2_is_controller_alive(hsotg)) {
dev_warn(hsotg->dev, "Controller is dead\n");
@@ -472,16 +481,90 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
 
spin_lock(&hsotg->lock);
 
+irq_retry:
gintsts = dwc2_read_common_intr(hsotg);
if (gintsts & ~GINTSTS_PRTINT)
retval = IRQ_HANDLED;
 
+   if (gintsts & GINTSTS_ENUMDONE) {
+   writel(GINTSTS_ENUMDONE, hsotg->regs + GINTSTS);
+   s3c_hsotg_irq_enumdone(hsotg);
+   }
+
if (gintsts & GINTSTS_MODEMIS)
dwc2_handle_mode_mismatch_intr(hsotg);
if (gintsts & GINTSTS_OTGINT)
dwc2_handle_otg_intr(hsotg);
if (gintsts & GINTSTS_CONIDSTSCHNG)
dwc2_handle_conn_id_status_change_intr(hsotg);
+
+   if (gintsts & (GINTSTS_OEPINT | GINTSTS_IEPINT)) {
+   u32 daint = readl(hsotg->regs + DAINT);
+   u32 daint_out = daint >> DAINT_OUTEP_SHIFT;
+   u32 daint_in = daint & ~(daint_out << DAINT_OUTEP_SHIFT);
+   int ep;
+
+   dev_dbg(hsotg->dev, "%s: daint=%08x\n", __func__, daint);
+   for (ep = 0; ep < 15 && daint_out; ep++, daint_out >>= 1) {
+   if (daint_out & 1)
+   s3c_hsotg_epint(hsotg, ep, 0);
+   }
+
+   for (ep = 0; ep < 15 && daint_in; ep++, daint_in >>= 1) {
+   if (daint_in & 1)
+   s3c_hsotg_epint(hsotg, ep, 1);
+   }
+   }
+
+   if (gintsts & GINTSTS_USBRST) {
+   u32 usb_status = readl(hsotg->regs + GOTGCTL);
+
+   dev_dbg(hsotg->dev, "%s: USBRST\n", __func__);
+   dev_dbg(hsotg->dev, "GNPTXSTS=%08x\n",
+   readl(hsotg->regs + GNPTXSTS));
+
+   writel(GINTSTS_USBRST, hsotg->regs + GINTSTS);
+
+   if (usb_status & GOTGCTL_BSESVLD) {
+   if (time_after(jiffies, hsotg->s3c_hsotg->last_rst +
+   msecs_to_jiffies(200))) {
+   kill_all_requests(hsotg, &hsotg->eps[0],
+   -ECONNRESET, true);
+   s3c_hsotg_core_init(hsotg);
+   hsotg->s3c_hsotg->last_rst = jiffies;
+   }
+   }
+   }
+
+   if (gintsts & GINTSTS_NPTXFEMP) {
+   dev_dbg(hsotg->dev, "NPTXFEMP\n");
+
+   /*
+* Disable the interrupt to stop it happening aga

[PATCH 08/15] usb: dwc2: Add the appropriate init calls in platform code

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Add the proper init calls for either host, gadget or both in platform.c

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/gadget.c   |6 ++
 drivers/usb/dwc2/hcd.c  |1 +
 drivers/usb/dwc2/platform.c |   29 +
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 51ee052..8992fe1 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3189,7 +3189,7 @@ static void s3c_hsotg_delete_debug(struct dwc2_hsotg 
*dwc2)
  * @irq: The IRQ number for the controller.
  */
 
-static int dwc2_gadget_init(struct dwc2_hsotg *dwc2, int irq)
+int dwc2_gadget_init(struct dwc2_hsotg *dwc2, int irq)
 {
struct s3c_hsotg_plat *plat = dwc2->dev->platform_data;
struct phy *phy;
@@ -3351,7 +3351,7 @@ err_clk:
  * s3c_hsotg_remove - remove function for hsotg driver
  * @pdev: The platform information for the driver
  */
-static int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
+void s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
 {
usb_del_gadget_udc(&dwc2->gadget);
 
@@ -3367,8 +3367,6 @@ static int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
phy_exit(dwc2->s3c_hsotg->phy);
if (dwc2->s3c_hsotg->clk)
clk_disable_unprepare(dwc2->s3c_hsotg->clk);
-
-   return 0;
 }
 
 static int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 4d918ed..07a7bcd 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1355,6 +1355,7 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
hsotg->op_state = OTG_STATE_B_PERIPHERAL;
dwc2_core_init(hsotg, false, -1);
dwc2_enable_global_interrupts(hsotg);
+   s3c_hsotg_core_init(hsotg);
} else {
/* A-Device connector (Host Mode) */
dev_dbg(hsotg->dev, "connId A\n");
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index e5747f2..259d3f4 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "core.h"
 #include "hcd.h"
@@ -90,7 +91,14 @@ static int dwc2_driver_remove(struct platform_device *dev)
 {
struct dwc2_hsotg *hsotg = platform_get_drvdata(dev);
 
-   dwc2_hcd_remove(hsotg);
+   if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL))
+   s3c_hsotg_remove(hsotg);
+   else if (IS_ENABLED(CONFIG_USB_DWC2_HOST))
+   dwc2_hcd_remove(hsotg);
+   else { /* dual role */
+   s3c_hsotg_remove(hsotg);
+   dwc2_hcd_remove(hsotg);
+   }
 
return 0;
 }
@@ -172,9 +180,22 @@ static int dwc2_driver_probe(struct platform_device *dev)
dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n",
(unsigned long)res->start, hsotg->regs);
 
-   retval = dwc2_hcd_init(hsotg, irq, params);
-   if (retval)
-   return retval;
+   if (IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)) {
+   retval = dwc2_gadget_init(hsotg, irq);
+   if (retval)
+   return retval;
+   retval = dwc2_hcd_init(hsotg, irq, params);
+   if (retval)
+   return retval;
+   } else if (IS_ENABLED(CONFIG_USB_DWC2_HOST)) {
+   retval = dwc2_hcd_init(hsotg, irq, params);
+   if (retval)
+   return retval;
+   } else if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL)) {
+   retval = dwc2_gadget_init(hsotg, irq);
+   if (retval)
+   return retval;
+   }
 
platform_set_drvdata(dev, hsotg);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/15] usb: dwc2: move dwc2_set_all_params to platform code

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Moves dwc2_set_all_params() to core.c so that it's shared between host
and gadget.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core.c |   15 +++
 drivers/usb/dwc2/hcd.c  |   16 
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 27d2c9b..1f316ca 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -56,6 +56,21 @@
 #include "core.h"
 #include "hcd.h"
 
+/*
+ * Sets all parameters to the given value.
+ *
+ * Assumes that the dwc2_core_params struct contains only integers.
+ */
+void dwc2_set_all_params(struct dwc2_core_params *params, int value)
+{
+   int *p = (int *)params;
+   size_t size = sizeof(*params) / sizeof(*p);
+   int i;
+
+   for (i = 0; i < size; i++)
+   p[i] = value;
+}
+
 /**
  * dwc2_enable_common_interrupts() - Initializes the commmon interrupts,
  * used in both device and host modes
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index a9b35f5..e44625f 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2733,22 +2733,6 @@ static void dwc2_hcd_release(struct dwc2_hsotg *hsotg)
 }
 
 /*
- * Sets all parameters to the given value.
- *
- * Assumes that the dwc2_core_params struct contains only integers.
- */
-void dwc2_set_all_params(struct dwc2_core_params *params, int value)
-{
-   int *p = (int *)params;
-   size_t size = sizeof(*params) / sizeof(*p);
-   int i;
-
-   for (i = 0; i < size; i++)
-   p[i] = value;
-}
-EXPORT_SYMBOL_GPL(dwc2_set_all_params);
-
-/*
  * Initializes the HCD. This function allocates memory for and initializes the
  * static parts of the usb_hcd and dwc2_hsotg structures. It also registers the
  * USB bus with the core and calls the hc_driver->start() function. It returns
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/15] usb: dwc2: initialize the spin_lock for both host and gadget

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Move spin_lock_init to common location for both host and gadget.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/hcd.c  |1 -
 drivers/usb/dwc2/platform.c |1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 1936544..a9b35f5 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2819,7 +2819,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 
hcd->has_tt = 1;
 
-   spin_lock_init(&hsotg->lock);
((struct wrapper_priv_data *) &hcd->hcd_priv)->hsotg = hsotg;
hsotg->priv = hcd;
 
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 2354c78..67f95ac 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -202,6 +202,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
}
 
platform_set_drvdata(dev, hsotg);
+   spin_lock_init(&hsotg->lock);
 
return retval;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/15] usb: dwc2: move allocation of core_params

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Move the allocation of the core_params to a share place for use by both host
and gadget.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/hcd.c  |5 -
 drivers/usb/dwc2/platform.c |4 
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 07a7bcd..1936544 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2788,11 +2788,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
goto error1;
hsotg->last_frame_num = HFNUM_MAX_FRNUM;
 #endif
-
-   hsotg->core_params = kzalloc(sizeof(*hsotg->core_params), GFP_KERNEL);
-   if (!hsotg->core_params)
-   goto error1;
-
dwc2_set_all_params(hsotg->core_params, -1);
 
/* Validate parameter values */
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 259d3f4..2354c78 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -155,6 +155,10 @@ static int dwc2_driver_probe(struct platform_device *dev)
if (!hsotg)
return -ENOMEM;
 
+   hsotg->core_params = kzalloc(sizeof(*hsotg->core_params), GFP_KERNEL);
+   if (!hsotg->core_params)
+   return -ENOMEM;
+
hsotg->dev = &dev->dev;
 
/*
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/15] usb: dwc2: gadget: remove gadget module defines

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Delete module defines in gadget.c. Most of this should be handled in
the dwc2 platform code.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/gadget.c   |   28 
 drivers/usb/dwc2/platform.c |1 +
 2 files changed, 1 insertion(+), 28 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 9bfd906..ca5c64a 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3417,31 +3417,3 @@ static int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
 
return ret;
 }
-
-#ifdef CONFIG_OF
-static const struct of_device_id s3c_hsotg_of_ids[] = {
-   { .compatible = "samsung,s3c6400-hsotg", },
-   { .compatible = "snps,dwc2", },
-   { /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, s3c_hsotg_of_ids);
-#endif
-
-static struct platform_driver s3c_hsotg_driver = {
-   .driver = {
-   .name   = "s3c-hsotg",
-   .owner  = THIS_MODULE,
-   .of_match_table = of_match_ptr(s3c_hsotg_of_ids),
-   },
-   .probe  = s3c_hsotg_probe,
-   .remove = s3c_hsotg_remove,
-   .suspend= s3c_hsotg_suspend,
-   .resume = s3c_hsotg_resume,
-};
-
-module_platform_driver(s3c_hsotg_driver);
-
-MODULE_DESCRIPTION("Samsung S3C USB High-speed/OtG device");
-MODULE_AUTHOR("Ben Dooks ");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:s3c-hsotg");
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index a10e7a3..e5747f2 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -97,6 +97,7 @@ static int dwc2_driver_remove(struct platform_device *dev)
 
 static const struct of_device_id dwc2_of_match_table[] = {
{ .compatible = "brcm,bcm2835-usb", .data = ¶ms_bcm2835 },
+   { .compatible = "samsung,s3c6400-hsotg", },
{ .compatible = "snps,dwc2", .data = NULL },
{},
 };
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 01/15] usb: dwc2: Moves s3c_hsotg gadget data structure into dwc2_hsotg

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Adds the gadget data structure and appropriate data structure pointers
to the common dwc2_hsotg data structure. This is needed so that the
dwc2_hsotg data structure can be used by the hcd and gadget drivers.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core.h |   10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 1efd10c..95fc6e9 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -84,7 +84,7 @@ static const char * const s3c_hsotg_supply_names[] = {
  */
 #define EP0_MPS_LIMIT   64
 
-struct s3c_hsotg;
+struct dwc2_hsotg;
 struct s3c_hsotg_req;
 
 /**
@@ -130,7 +130,7 @@ struct s3c_hsotg_req;
 struct s3c_hsotg_ep {
struct usb_ep   ep;
struct list_headqueue;
-   struct s3c_hsotg*parent;
+   struct dwc2_hsotg   *parent;
struct s3c_hsotg_req*req;
struct dentry   *debugfs;
 
@@ -601,6 +601,12 @@ struct dwc2_hsotg {
struct timer_list wkp_timer;
enum dwc2_lx_state lx_state;
 
+   /* Gadget structures */
+   struct s3c_hsotg *s3c_hsotg;
+   struct usb_gadget   gadget;
+   struct usb_gadget_driver *driver;
+   struct s3c_hsotg_ep *eps;
+
union dwc2_hcd_internal_flags {
u32 d32;
struct {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 05/15] usb: dwc2: Move gadget interrupts to common interrupt handler

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Update dwc2_handle_common_intr() to handle both hcd and gadget interrupts.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core_intr.c |  116 +-
 drivers/usb/dwc2/gadget.c|  188 --
 2 files changed, 114 insertions(+), 190 deletions(-)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index c93918b..7500621 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -337,6 +337,7 @@ static void dwc2_handle_wakeup_detected_intr(struct 
dwc2_hsotg *hsotg)
}
/* Change to L0 state */
hsotg->lx_state = DWC2_L0;
+   call_gadget(hsotg, resume);
} else {
if (hsotg->lx_state != DWC2_L1) {
u32 pcgcctl = readl(hsotg->regs + PCGCTL);
@@ -397,6 +398,8 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
"DSTS.Suspend Status=%d HWCFG4.Power Optimize=%d\n",
!!(dsts & DSTS_SUSPSTS),
hsotg->hw_params.power_optimized);
+
+   call_gadget(hsotg, suspend);
} else {
if (hsotg->op_state == OTG_STATE_A_PERIPHERAL) {
dev_dbg(hsotg->dev, "a_peripheral->a_host\n");
@@ -421,6 +424,11 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
 GINTSTS_MODEMIS | GINTSTS_DISCONNINT | \
 GINTSTS_USBSUSP | GINTSTS_PRTINT)
 
+/* IRQ flags which will trigger a retry around the IRQ loop */
+#define IRQ_RETRY_MASK (GINTSTS_NPTXFEMP | \
+   GINTSTS_PTXFEMP |  \
+   GINTSTS_RXFLVL)
+
 /*
  * This function returns the Core Interrupt register
  */
@@ -441,7 +449,7 @@ static u32 dwc2_read_common_intr(struct dwc2_hsotg *hsotg)
gintsts, gintmsk);
 
if (gahbcfg & GAHBCFG_GLBL_INTR_EN)
-   return gintsts & gintmsk & gintmsk_common;
+   return gintsts & gintmsk;
else
return 0;
 }
@@ -463,7 +471,8 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
 {
struct dwc2_hsotg *hsotg = dev;
u32 gintsts;
-   irqreturn_t retval = IRQ_NONE;
+   int retry_count = 8;
+   irqreturn_t retval = IRQ_HANDLED;
 
if (!dwc2_is_controller_alive(hsotg)) {
dev_warn(hsotg->dev, "Controller is dead\n");
@@ -472,16 +481,90 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
 
spin_lock(&hsotg->lock);
 
+irq_retry:
gintsts = dwc2_read_common_intr(hsotg);
if (gintsts & ~GINTSTS_PRTINT)
retval = IRQ_HANDLED;
 
+   if (gintsts & GINTSTS_ENUMDONE) {
+   writel(GINTSTS_ENUMDONE, hsotg->regs + GINTSTS);
+   s3c_hsotg_irq_enumdone(hsotg);
+   }
+
if (gintsts & GINTSTS_MODEMIS)
dwc2_handle_mode_mismatch_intr(hsotg);
if (gintsts & GINTSTS_OTGINT)
dwc2_handle_otg_intr(hsotg);
if (gintsts & GINTSTS_CONIDSTSCHNG)
dwc2_handle_conn_id_status_change_intr(hsotg);
+
+   if (gintsts & (GINTSTS_OEPINT | GINTSTS_IEPINT)) {
+   u32 daint = readl(hsotg->regs + DAINT);
+   u32 daint_out = daint >> DAINT_OUTEP_SHIFT;
+   u32 daint_in = daint & ~(daint_out << DAINT_OUTEP_SHIFT);
+   int ep;
+
+   dev_dbg(hsotg->dev, "%s: daint=%08x\n", __func__, daint);
+   for (ep = 0; ep < 15 && daint_out; ep++, daint_out >>= 1) {
+   if (daint_out & 1)
+   s3c_hsotg_epint(hsotg, ep, 0);
+   }
+
+   for (ep = 0; ep < 15 && daint_in; ep++, daint_in >>= 1) {
+   if (daint_in & 1)
+   s3c_hsotg_epint(hsotg, ep, 1);
+   }
+   }
+
+   if (gintsts & GINTSTS_USBRST) {
+   u32 usb_status = readl(hsotg->regs + GOTGCTL);
+
+   dev_dbg(hsotg->dev, "%s: USBRST\n", __func__);
+   dev_dbg(hsotg->dev, "GNPTXSTS=%08x\n",
+   readl(hsotg->regs + GNPTXSTS));
+
+   writel(GINTSTS_USBRST, hsotg->regs + GINTSTS);
+
+   if (usb_status & GOTGCTL_BSESVLD) {
+   if (time_after(jiffies, hsotg->s3c_hsotg->last_rst +
+   msecs_to_jiffies(200))) {
+   kill_all_requests(hsotg, &hsotg->eps[0],
+   -ECONNRESET, true);
+   s3c_hsotg_core_init(hsotg);
+   hsotg->s3c_hsotg->last_rst = jiffies;
+   }
+   }
+   }
+
+   if (gintsts & GINTSTS_NPTXFEMP) {
+   dev_dbg(hsotg->dev, "NPTXFEMP\n");
+
+   /*
+* Disable the interrupt to stop it happening aga

[RESEND PATCH 04/15] usb: dwc2: gadget: Change the gadget probe function into gadget_init

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

gadget_init() will get called from the platform probe function.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/gadget.c |  144 +
 1 file changed, 55 insertions(+), 89 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 171ed28..e74656c 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3372,25 +3372,24 @@ static void s3c_hsotg_delete_debug(struct dwc2_hsotg 
*dwc2)
 }
 
 /**
- * s3c_hsotg_probe - probe function for hsotg driver
- * @pdev: The platform information for the driver
+ * dwc2_gadget_init - init function for gadget
+ * @dwc2: The data structure for the DWC2 driver.
+ * @irq: The IRQ number for the controller.
  */
 
-static int s3c_hsotg_probe(struct platform_device *pdev)
+static int dwc2_gadget_init(struct dwc2_hsotg *dwc2, int irq)
 {
-   struct s3c_hsotg_plat *plat = dev_get_platdata(&pdev->dev);
+   struct s3c_hsotg_plat *plat = dwc2->dev->platform_data;
struct phy *phy;
struct usb_phy *uphy;
-   struct device *dev = &pdev->dev;
+   struct device *dev = dwc2->dev;
struct s3c_hsotg_ep *eps;
-   struct s3c_hsotg *hsotg;
-   struct resource *res;
int epnum;
int ret;
int i;
 
-   hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
-   if (!hsotg) {
+   dwc2->s3c_hsotg = devm_kzalloc(dev, sizeof(struct s3c_hsotg), 
GFP_KERNEL);
+   if (!dwc2->s3c_hsotg) {
dev_err(dev, "cannot get memory\n");
return -ENOMEM;
}
@@ -3399,117 +3398,84 @@ static int s3c_hsotg_probe(struct platform_device 
*pdev)
 * Attempt to find a generic PHY, then look for an old style
 * USB PHY, finally fall back to pdata
 */
-   phy = devm_phy_get(&pdev->dev, "usb2-phy");
+   phy = devm_phy_get(dev, "usb2-phy");
if (IS_ERR(phy)) {
uphy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
if (IS_ERR(uphy)) {
/* Fallback for pdata */
-   plat = dev_get_platdata(&pdev->dev);
+   plat = dev_get_platdata(dev);
if (!plat) {
-   dev_err(&pdev->dev,
+   dev_err(dev,
"no platform data or transceiver defined\n");
return -EPROBE_DEFER;
}
-   hsotg->plat = plat;
+   dwc2->s3c_hsotg->plat = plat;
} else
-   hsotg->uphy = uphy;
+   dwc2->s3c_hsotg->uphy = uphy;
} else
-   hsotg->phy = phy;
+   dwc2->s3c_hsotg->phy = phy;
 
-   hsotg->dev = dev;
-
-   hsotg->clk = devm_clk_get(&pdev->dev, "otg");
-   if (IS_ERR(hsotg->clk)) {
+   dwc2->s3c_hsotg->clk = devm_clk_get(dev, "otg");
+   if (IS_ERR(dwc2->s3c_hsotg->clk)) {
dev_err(dev, "cannot get otg clock\n");
-   return PTR_ERR(hsotg->clk);
-   }
-
-   platform_set_drvdata(pdev, hsotg);
-
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-   hsotg->regs = devm_ioremap_resource(&pdev->dev, res);
-   if (IS_ERR(hsotg->regs)) {
-   ret = PTR_ERR(hsotg->regs);
-   goto err_clk;
-   }
-
-   ret = platform_get_irq(pdev, 0);
-   if (ret < 0) {
-   dev_err(dev, "cannot find IRQ\n");
-   goto err_clk;
-   }
-
-   spin_lock_init(&hsotg->lock);
-
-   hsotg->irq = ret;
-
-   ret = devm_request_irq(&pdev->dev, hsotg->irq, s3c_hsotg_irq, 0,
-   dev_name(dev), hsotg);
-   if (ret < 0) {
-   dev_err(dev, "cannot claim IRQ\n");
-   goto err_clk;
+   return PTR_ERR(dwc2->s3c_hsotg->clk);
}
 
-   dev_info(dev, "regs %p, irq %d\n", hsotg->regs, hsotg->irq);
-
-   hsotg->gadget.max_speed = USB_SPEED_HIGH;
-   hsotg->gadget.ops = &s3c_hsotg_gadget_ops;
-   hsotg->gadget.name = dev_name(dev);
+   dwc2->gadget.max_speed = USB_SPEED_HIGH;
+   dwc2->gadget.ops = &s3c_hsotg_gadget_ops;
+   dwc2->gadget.name = dev_name(dev);
 
-   /* reset the system */
-
-   clk_prepare_enable(hsotg->clk);
+   clk_prepare_enable(dwc2->s3c_hsotg->clk);
 
/* regulators */
 
-   for (i = 0; i < ARRAY_SIZE(hsotg->supplies); i++)
-   hsotg->supplies[i].supply = s3c_hsotg_supply_names[i];
+   for (i = 0; i < ARRAY_SIZE(dwc2->s3c_hsotg->supplies); i++)
+   dwc2->s3c_hsotg->supplies[i].supply = s3c_hsotg_supply_names[i];
 
-   ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(hsotg->supplies),
-hsotg->supplies);
+   ret = devm_regulator_bulk_get(dev, 
ARRAY_SIZE(dwc2->s3c_hsotg->supplies),
+d

[RESEND PATCH 02/15] usb: dwc2: add necessary function declares for dual role

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

There are functions in gadget driver that needs to get exported so that
the common interrupt handler can call.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core.h |   52 +++
 drivers/usb/dwc2/hcd.h  |   12 +--
 2 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 95fc6e9..a064d48 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -953,4 +953,56 @@ extern void dwc2_dump_global_registers(struct dwc2_hsotg 
*hsotg);
  */
 extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg);
 
+/* Gadget defines */
+#if defined(CONFIG_USB_DWC2_PERIPHERAL) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
+extern void s3c_hsotg_irq_enumdone(struct dwc2_hsotg *dwc2);
+extern void s3c_hsotg_epint(struct dwc2_hsotg *dwc2, unsigned int idx,
+   int dir_in);
+extern void kill_all_requests(struct dwc2_hsotg *dwc2,
+   struct s3c_hsotg_ep *ep, int result, bool force);
+extern void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2);
+extern void s3c_hsotg_disable_gsint(struct dwc2_hsotg *dwc2, u32 ints);
+extern void s3c_hsotg_irq_fifoempty(struct dwc2_hsotg *dwc2, bool periodic);
+extern void s3c_hsotg_handle_rx(struct dwc2_hsotg *dwc2);
+extern void s3c_hsotg_remove(struct dwc2_hsotg *dwc2);
+extern void s3c_hsotg_dump(struct dwc2_hsotg *dwc2);
+extern int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2);
+extern int s3c_hsotg_resume(struct dwc2_hsotg *dwc2);
+#else
+static inline void s3c_hsotg_irq_enumdone(struct dwc2_hsotg *dwc2) {}
+static inline void s3c_hsotg_epint(struct dwc2_hsotg *dwc2, unsigned int idx,
+   int dir_in) {}
+static inline void kill_all_requests(struct dwc2_hsotg *dwc2,
+   struct s3c_hsotg_ep *ep, int result, bool force) {}
+static inline void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2) {}
+static inline void s3c_hsotg_disable_gsint(struct dwc2_hsotg *dwc2, u32 ints)
+{}
+static inline void s3c_hsotg_irq_fifoempty(struct dwc2_hsotg *dwc2,
+   bool periodic) {}
+static inline void s3c_hsotg_handle_rx(struct dwc2_hsotg *dwc2) {}
+static inline void s3c_hsotg_remove(struct dwc2_hsotg *dwc2) {}
+static inline void s3c_hsotg_dump(struct dwc2_hsotg *dwc2) {}
+static inline int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
+{ return 0; }
+static inline int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
+{ return 0; }
+#endif
+
+extern void dwc2_set_all_params(struct dwc2_core_params *params, int value);
+#if defined(CONFIG_USB_DWC2_HOST) || defined(CONFIG_USB_DWC2_DUAL_ROLE)
+/**
+ * dwc2_hcd_get_frame_number() - Returns current frame number
+ *
+ * @hsotg: The DWC2 HCD
+ */
+extern int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg);
+extern void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg);
+extern void dwc2_hcd_start(struct dwc2_hsotg *hsotg);
+#else
+static inline int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg)
+{ return 0; }
+static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg) {}
+static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {}
+#endif
+
 #endif /* __DWC2_CORE_H__ */
diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h
index fdc6d48..9705abf 100644
--- a/drivers/usb/dwc2/hcd.h
+++ b/drivers/usb/dwc2/hcd.h
@@ -449,12 +449,12 @@ static inline u8 dwc2_hcd_is_pipe_out(struct 
dwc2_hcd_pipe_info *pipe)
return !dwc2_hcd_is_pipe_in(pipe);
 }
 
+extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq);
 extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 const struct dwc2_core_params *params);
 extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg);
 extern void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
const struct dwc2_core_params *params);
-extern void dwc2_set_all_params(struct dwc2_core_params *params, int value);
 extern int dwc2_get_hwparams(struct dwc2_hsotg *hsotg);
 
 /* Transaction Execution Functions */
@@ -666,9 +666,6 @@ extern irqreturn_t dwc2_handle_hcd_intr(struct dwc2_hsotg 
*hsotg);
  */
 extern void dwc2_hcd_stop(struct dwc2_hsotg *hsotg);
 
-extern void dwc2_hcd_start(struct dwc2_hsotg *hsotg);
-extern void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg);
-
 /**
  * dwc2_hcd_is_b_host() - Returns 1 if core currently is acting as B host,
  * and 0 otherwise
@@ -678,13 +675,6 @@ extern void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg);
 extern int dwc2_hcd_is_b_host(struct dwc2_hsotg *hsotg);
 
 /**
- * dwc2_hcd_get_frame_number() - Returns current frame number
- *
- * @hsotg: The DWC2 HCD
- */
-extern int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg);
-
-/**
  * dwc2_hcd_dump_state() - Dumps hsotg state
  *
  * @hsotg: The DWC2 HCD
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.h

[RESEND PATCH 06/15] usb: dwc2: gadget: remove gadget module defines

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Delete module defines in gadget.c. Most of this should be handled in
the dwc2 platform code.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/gadget.c   |   28 
 drivers/usb/dwc2/platform.c |1 +
 2 files changed, 1 insertion(+), 28 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 9bfd906..ca5c64a 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3417,31 +3417,3 @@ static int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
 
return ret;
 }
-
-#ifdef CONFIG_OF
-static const struct of_device_id s3c_hsotg_of_ids[] = {
-   { .compatible = "samsung,s3c6400-hsotg", },
-   { .compatible = "snps,dwc2", },
-   { /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, s3c_hsotg_of_ids);
-#endif
-
-static struct platform_driver s3c_hsotg_driver = {
-   .driver = {
-   .name   = "s3c-hsotg",
-   .owner  = THIS_MODULE,
-   .of_match_table = of_match_ptr(s3c_hsotg_of_ids),
-   },
-   .probe  = s3c_hsotg_probe,
-   .remove = s3c_hsotg_remove,
-   .suspend= s3c_hsotg_suspend,
-   .resume = s3c_hsotg_resume,
-};
-
-module_platform_driver(s3c_hsotg_driver);
-
-MODULE_DESCRIPTION("Samsung S3C USB High-speed/OtG device");
-MODULE_AUTHOR("Ben Dooks ");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:s3c-hsotg");
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index a10e7a3..e5747f2 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -97,6 +97,7 @@ static int dwc2_driver_remove(struct platform_device *dev)
 
 static const struct of_device_id dwc2_of_match_table[] = {
{ .compatible = "brcm,bcm2835-usb", .data = ¶ms_bcm2835 },
+   { .compatible = "samsung,s3c6400-hsotg", },
{ .compatible = "snps,dwc2", .data = NULL },
{},
 };
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 11/15] usb: dwc2: Add suspend/resume for gadget

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Move suspend/resume code to common platform code.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/gadget.c   |4 ++--
 drivers/usb/dwc2/platform.c |   23 +++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 8992fe1..7ddf5a4a 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3369,7 +3369,7 @@ void s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
clk_disable_unprepare(dwc2->s3c_hsotg->clk);
 }
 
-static int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
+int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
 {
unsigned long flags;
int ret = 0;
@@ -3396,7 +3396,7 @@ static int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
return ret;
 }
 
-static int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
+int s3c_hsotg_resume(struct dwc2_hsotg *dwc2)
 {
unsigned long flags;
int ret = 0;
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 67f95ac..88a70c0 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -207,6 +207,27 @@ static int dwc2_driver_probe(struct platform_device *dev)
return retval;
 }
 
+static int dwc2_suspend(struct platform_device *dev, pm_message_t state)
+{
+   struct dwc2_hsotg *dwc2 = platform_get_drvdata(dev);
+   int ret = 0;
+
+   if (dwc2_is_device_mode(dwc2))
+   ret = s3c_hsotg_suspend(dwc2);
+   return ret;
+}
+
+static int dwc2_resume(struct platform_device *dev)
+{
+   struct dwc2_hsotg *dwc2 = platform_get_drvdata(dev);
+   int ret = 0;
+
+   if (dwc2_is_device_mode(dwc2))
+   ret = s3c_hsotg_resume(dwc2);
+
+   return ret;
+}
+
 static struct platform_driver dwc2_platform_driver = {
.driver = {
.name = dwc2_driver_name,
@@ -214,6 +235,8 @@ static struct platform_driver dwc2_platform_driver = {
},
.probe = dwc2_driver_probe,
.remove = dwc2_driver_remove,
+   .suspend = dwc2_suspend,
+   .resume = dwc2_resume,
 };
 
 module_platform_driver(dwc2_platform_driver);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 08/15] usb: dwc2: Add the appropriate init calls in platform code

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Add the proper init calls for either host, gadget or both in platform.c

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/gadget.c   |6 ++
 drivers/usb/dwc2/hcd.c  |1 +
 drivers/usb/dwc2/platform.c |   29 +
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 51ee052..8992fe1 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3189,7 +3189,7 @@ static void s3c_hsotg_delete_debug(struct dwc2_hsotg 
*dwc2)
  * @irq: The IRQ number for the controller.
  */
 
-static int dwc2_gadget_init(struct dwc2_hsotg *dwc2, int irq)
+int dwc2_gadget_init(struct dwc2_hsotg *dwc2, int irq)
 {
struct s3c_hsotg_plat *plat = dwc2->dev->platform_data;
struct phy *phy;
@@ -3351,7 +3351,7 @@ err_clk:
  * s3c_hsotg_remove - remove function for hsotg driver
  * @pdev: The platform information for the driver
  */
-static int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
+void s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
 {
usb_del_gadget_udc(&dwc2->gadget);
 
@@ -3367,8 +3367,6 @@ static int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
phy_exit(dwc2->s3c_hsotg->phy);
if (dwc2->s3c_hsotg->clk)
clk_disable_unprepare(dwc2->s3c_hsotg->clk);
-
-   return 0;
 }
 
 static int s3c_hsotg_suspend(struct dwc2_hsotg *dwc2)
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 4d918ed..07a7bcd 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1355,6 +1355,7 @@ static void dwc2_conn_id_status_change(struct work_struct 
*work)
hsotg->op_state = OTG_STATE_B_PERIPHERAL;
dwc2_core_init(hsotg, false, -1);
dwc2_enable_global_interrupts(hsotg);
+   s3c_hsotg_core_init(hsotg);
} else {
/* A-Device connector (Host Mode) */
dev_dbg(hsotg->dev, "connId A\n");
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index e5747f2..259d3f4 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "core.h"
 #include "hcd.h"
@@ -90,7 +91,14 @@ static int dwc2_driver_remove(struct platform_device *dev)
 {
struct dwc2_hsotg *hsotg = platform_get_drvdata(dev);
 
-   dwc2_hcd_remove(hsotg);
+   if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL))
+   s3c_hsotg_remove(hsotg);
+   else if (IS_ENABLED(CONFIG_USB_DWC2_HOST))
+   dwc2_hcd_remove(hsotg);
+   else { /* dual role */
+   s3c_hsotg_remove(hsotg);
+   dwc2_hcd_remove(hsotg);
+   }
 
return 0;
 }
@@ -172,9 +180,22 @@ static int dwc2_driver_probe(struct platform_device *dev)
dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n",
(unsigned long)res->start, hsotg->regs);
 
-   retval = dwc2_hcd_init(hsotg, irq, params);
-   if (retval)
-   return retval;
+   if (IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)) {
+   retval = dwc2_gadget_init(hsotg, irq);
+   if (retval)
+   return retval;
+   retval = dwc2_hcd_init(hsotg, irq, params);
+   if (retval)
+   return retval;
+   } else if (IS_ENABLED(CONFIG_USB_DWC2_HOST)) {
+   retval = dwc2_hcd_init(hsotg, irq, params);
+   if (retval)
+   return retval;
+   } else if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL)) {
+   retval = dwc2_gadget_init(hsotg, irq);
+   if (retval)
+   return retval;
+   }
 
platform_set_drvdata(dev, hsotg);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 07/15] usb: dwc2: gadget: Do not fail probe if there isn't a clock node

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Since the dwc2 hcd driver is currently not looking for a clock node during
init, we should not completely fail if there isn't a clock provided.
Add a check for a valid clock before calling clock functions.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/gadget.c |   15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index ca5c64a..51ee052 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3228,16 +3228,15 @@ static int dwc2_gadget_init(struct dwc2_hsotg *dwc2, 
int irq)
dwc2->s3c_hsotg->phy = phy;
 
dwc2->s3c_hsotg->clk = devm_clk_get(dev, "otg");
-   if (IS_ERR(dwc2->s3c_hsotg->clk)) {
-   dev_err(dev, "cannot get otg clock\n");
-   return PTR_ERR(dwc2->s3c_hsotg->clk);
-   }
+   if (IS_ERR(dwc2->s3c_hsotg->clk))
+   dev_warn(dev, "cannot get otg clock\n");
 
dwc2->gadget.max_speed = USB_SPEED_HIGH;
dwc2->gadget.ops = &s3c_hsotg_gadget_ops;
dwc2->gadget.name = dev_name(dev);
 
-   clk_prepare_enable(dwc2->s3c_hsotg->clk);
+   if (dwc2->s3c_hsotg->clk)
+   clk_prepare_enable(dwc2->s3c_hsotg->clk);
 
/* regulators */
 
@@ -3342,7 +3341,8 @@ err_ep_mem:
 err_supplies:
s3c_hsotg_phy_disable(dwc2);
 err_clk:
-   clk_disable_unprepare(dwc2->s3c_hsotg->clk);
+   if (dwc2->s3c_hsotg->clk)
+   clk_disable_unprepare(dwc2->s3c_hsotg->clk);
 
return ret;
 }
@@ -3365,7 +3365,8 @@ static int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
s3c_hsotg_phy_disable(dwc2);
if (dwc2->s3c_hsotg->phy)
phy_exit(dwc2->s3c_hsotg->phy);
-   clk_disable_unprepare(dwc2->s3c_hsotg->clk);
+   if (dwc2->s3c_hsotg->clk)
+   clk_disable_unprepare(dwc2->s3c_hsotg->clk);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 13/15] usb: dwc2: check that the host work queue is valid

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

The Host workqueue will not get initialized if the driver is configured for
peripheral mode only. Thus we need to check for wq_otg before calling
queue_work().

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core_intr.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 7500621..dbf31e4 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -288,7 +288,8 @@ static void dwc2_handle_conn_id_status_change_intr(struct 
dwc2_hsotg *hsotg)
 * scheduling.
 */
spin_unlock(&hsotg->lock);
-   queue_work(hsotg->wq_otg, &hsotg->wf_otg);
+   if (hsotg->wq_otg)
+   queue_work(hsotg->wq_otg, &hsotg->wf_otg);
spin_lock(&hsotg->lock);
 
/* Clear interrupt */
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 09/15] usb: dwc2: move allocation of core_params

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Move the allocation of the core_params to a share place for use by both host
and gadget.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/hcd.c  |5 -
 drivers/usb/dwc2/platform.c |4 
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 07a7bcd..1936544 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2788,11 +2788,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
goto error1;
hsotg->last_frame_num = HFNUM_MAX_FRNUM;
 #endif
-
-   hsotg->core_params = kzalloc(sizeof(*hsotg->core_params), GFP_KERNEL);
-   if (!hsotg->core_params)
-   goto error1;
-
dwc2_set_all_params(hsotg->core_params, -1);
 
/* Validate parameter values */
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 259d3f4..2354c78 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -155,6 +155,10 @@ static int dwc2_driver_probe(struct platform_device *dev)
if (!hsotg)
return -ENOMEM;
 
+   hsotg->core_params = kzalloc(sizeof(*hsotg->core_params), GFP_KERNEL);
+   if (!hsotg->core_params)
+   return -ENOMEM;
+
hsotg->dev = &dev->dev;
 
/*
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 15/15] usb: dwc2: Update Kconfig to support dual-role

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Update DWC2 kconfig and makefile to support dual-role mode. The platform
file will always get compiled for the case where the controller is directly
connected to the CPU. So for loadable modules, only dwc2.ko is needed.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/Kconfig  |   52 +
 drivers/usb/dwc2/Makefile |   21 +-
 2 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/dwc2/Kconfig b/drivers/usb/dwc2/Kconfig
index f93807b..68a96cb0 100644
--- a/drivers/usb/dwc2/Kconfig
+++ b/drivers/usb/dwc2/Kconfig
@@ -1,41 +1,31 @@
 config USB_DWC2
-   bool "DesignWare USB2 DRD Core Support"
+   tristate "DesignWare USB2 DRD Core Support"
depends on USB
help
  Say Y here if your system has a Dual Role Hi-Speed USB
  controller based on the DesignWare HSOTG IP Core.
 
- For host mode, if you choose to build the driver as dynamically
- linked modules, the core module will be called dwc2.ko, the PCI
- bus interface module (if you have a PCI bus system) will be
- called dwc2_pci.ko, and the platform interface module (for
- controllers directly connected to the CPU) will be called
- dwc2_platform.ko. For gadget mode, there will be a single
- module called dwc2_gadget.ko.
+ If you choose to build the driver as dynamically
+ linked modules, a single dwc2.ko will get built for both
+ platform IPs and PCI.
 
- NOTE: The s3c-hsotg driver is now renamed to dwc2_gadget. The
- host and gadget drivers are still currently separate drivers.
- There are plans to merge the dwc2_gadget driver with the dwc2
- host driver in the near future to create a dual-role driver.
+ NOTE: The s3c-hsotg driver is now renamed to dwc2_gadget.
 
 if USB_DWC2
 
+choice
+   bool "DWC2 Mode Selection"
+   default USB_DWC2_DUAL_ROLE if (USB && USB_GADGET)
+   default USB_DWC2_HOST if (USB && !USB_GADGET)
+   default USB_DWC2_PERIPHERAL if (!USB && USB_GADGET)
+
 config USB_DWC2_HOST
-   tristate "Host only mode"
+   bool "Host only mode"
depends on USB
help
  The Designware USB2.0 high-speed host controller
  integrated into many SoCs.
 
-config USB_DWC2_PLATFORM
-   bool "DWC2 Platform"
-   depends on USB_DWC2_HOST
-   default USB_DWC2_HOST
-   help
- The Designware USB2.0 platform interface module for
- controllers directly connected to the CPU. This is only
- used for host mode.
-
 config USB_DWC2_PCI
bool "DWC2 PCI"
depends on USB_DWC2_HOST && PCI
@@ -47,12 +37,28 @@ config USB_DWC2_PCI
 comment "Gadget mode requires USB Gadget support to be enabled"
 
 config USB_DWC2_PERIPHERAL
-   tristate "Gadget only mode"
+   bool "Gadget only mode"
depends on USB_GADGET
help
  The Designware USB2.0 high-speed gadget controller
  integrated into many SoCs.
 
+config USB_DWC2_DUAL_ROLE
+   bool "Dual Role mode"
+   depends on ((USB=y || USB=USB_DWC2) && (USB_GADGET=y))
+   help
+ This is the default mode of working of DWC2 controller where
+ both host and gadget features are enabled.
+endchoice
+
+config USB_DWC2_PLATFORM
+   bool
+depends on !PCI
+default y
+help
+  The Designware USB2.0 platform interface module for
+  controllers directly connected to the CPU.
+
 config USB_DWC2_DEBUG
bool "Enable Debugging Messages"
help
diff --git a/drivers/usb/dwc2/Makefile b/drivers/usb/dwc2/Makefile
index b73d2a5..3026135 100644
--- a/drivers/usb/dwc2/Makefile
+++ b/drivers/usb/dwc2/Makefile
@@ -1,10 +1,17 @@
 ccflags-$(CONFIG_USB_DWC2_DEBUG)   += -DDEBUG
 ccflags-$(CONFIG_USB_DWC2_VERBOSE) += -DVERBOSE_DEBUG
 
-obj-$(CONFIG_USB_DWC2_HOST)+= dwc2.o
+obj-$(CONFIG_USB_DWC2) += dwc2.o
 dwc2-y := core.o core_intr.o
-dwc2-y += hcd.o hcd_intr.o
-dwc2-y += hcd_queue.o hcd_ddma.o
+
+ifneq ($(filter y,$(CONFIG_USB_DWC2_HOST) $(CONFIG_USB_DWC2_DUAL_ROLE)),)
+   dwc2-y  += hcd.o hcd_intr.o
+   dwc2-y  += hcd_queue.o hcd_ddma.o
+endif
+
+ifneq ($(filter y,$(CONFIG_USB_DWC2_PERIPHERAL) $(CONFIG_USB_DWC2_DUAL_ROLE)),)
+   dwc2-y  += gadget.o
+endif
 
 # NOTE: The previous s3c-hsotg peripheral mode only driver has been moved to
 # this location and renamed gadget.c. When building for dynamically linked
@@ -19,10 +26,4 @@ ifneq ($(CONFIG_USB_DWC2_PCI),)
dwc2_pci-y  := pci.o
 endif
 
-ifneq ($(CONFIG_USB_DWC2_PLATFORM),)
-   obj-$(CONFIG_USB_DWC2_HOST) += dwc2_platform.o
-   dwc2_platform-y := platform.o
-endif
-
-obj-$(CONF

[RESEND PATCH 12/15] usb: dwc2: move dwc2_set_all_params to platform code

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Moves dwc2_set_all_params() to core.c so that it's shared between host
and gadget.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/core.c |   15 +++
 drivers/usb/dwc2/hcd.c  |   16 
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 27d2c9b..1f316ca 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -56,6 +56,21 @@
 #include "core.h"
 #include "hcd.h"
 
+/*
+ * Sets all parameters to the given value.
+ *
+ * Assumes that the dwc2_core_params struct contains only integers.
+ */
+void dwc2_set_all_params(struct dwc2_core_params *params, int value)
+{
+   int *p = (int *)params;
+   size_t size = sizeof(*params) / sizeof(*p);
+   int i;
+
+   for (i = 0; i < size; i++)
+   p[i] = value;
+}
+
 /**
  * dwc2_enable_common_interrupts() - Initializes the commmon interrupts,
  * used in both device and host modes
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index a9b35f5..e44625f 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2733,22 +2733,6 @@ static void dwc2_hcd_release(struct dwc2_hsotg *hsotg)
 }
 
 /*
- * Sets all parameters to the given value.
- *
- * Assumes that the dwc2_core_params struct contains only integers.
- */
-void dwc2_set_all_params(struct dwc2_core_params *params, int value)
-{
-   int *p = (int *)params;
-   size_t size = sizeof(*params) / sizeof(*p);
-   int i;
-
-   for (i = 0; i < size; i++)
-   p[i] = value;
-}
-EXPORT_SYMBOL_GPL(dwc2_set_all_params);
-
-/*
  * Initializes the HCD. This function allocates memory for and initializes the
  * static parts of the usb_hcd and dwc2_hsotg structures. It also registers the
  * USB bus with the core and calls the hc_driver->start() function. It returns
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 14/15] usb: dwc2: pci: Update pci portion of the dwc2 driver

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Update pci portion of the dwc2 driver to call the appropriate init functions
for host, gadget, and dual-role.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/pci.c |   28 ++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
index c291fca..69bd27a 100644
--- a/drivers/usb/dwc2/pci.c
+++ b/drivers/usb/dwc2/pci.c
@@ -102,7 +102,14 @@ static void dwc2_driver_remove(struct pci_dev *dev)
 {
struct dwc2_hsotg *hsotg = pci_get_drvdata(dev);
 
-   dwc2_hcd_remove(hsotg);
+   if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL))
+   s3c_hsotg_remove(hsotg);
+   else if (IS_ENABLED(CONFIG_USB_DWC2_HOST))
+   dwc2_hcd_remove(hsotg);
+   else { /* dual role */
+   s3c_hsotg_remove(hsotg);
+   dwc2_hcd_remove(hsotg);
+   }
pci_disable_device(dev);
 }
 
@@ -141,13 +148,30 @@ static int dwc2_driver_probe(struct pci_dev *dev,
 
pci_set_master(dev);
 
-   retval = dwc2_hcd_init(hsotg, dev->irq, &dwc2_module_params);
+   if (IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)) {
+   retval = dwc2_gadget_init(hsotg, dev->irq);
+   if (retval)
+   return retval;
+   retval = dwc2_hcd_init(hsotg, dev->irq, &dwc2_module_params);
+   if (retval)
+   return retval;
+   } else if (IS_ENABLED(CONFIG_USB_DWC2_HOST)) {
+   retval = dwc2_hcd_init(hsotg, dev->irq, &dwc2_module_params);
+   if (retval)
+   return retval;
+   } else if (IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL)) {
+   retval = dwc2_gadget_init(hsotg, dev->irq);
+   if (retval)
+   return retval;
+   }
+
if (retval) {
pci_disable_device(dev);
return retval;
}
 
pci_set_drvdata(dev, hsotg);
+   spin_lock_init(&hsotg->lock);
 
return retval;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 00/15] usb: dwc2: Add support for dual-role

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Apologies for the noise, but I got Paul Zimmerman's address wrong on the
first send.

Hi,

This patch series combines the dwc2 host and gadget driver into a single
dual-role driver. I have tested this on the SOCFPGA platform. I compile
tested for bcm2835_defconfig and a PCI platform.

I split up the patches to make the review a bit easier, but each individual
patch can't really stand on it's own. Any comments/testing is greatly
appreciated.

I have pushed this to:

git://git.rocketboards.org/linux-socfpga-next.git/dwc2_dual_role_v1


Dinh Nguyen (15):
  usb: dwc2: Moves s3c_hsotg gadget data structure into dwc2_hsotg
  usb: dwc2: add necessary function declares for dual role
  usb: dwc2: gadget: convert gadget driver to use common dwc2_hsotg
structure
  usb: dwc2: gadget: Change the gadget probe function into gadget_init
  usb: dwc2: Move gadget interrupts to common interrupt handler
  usb: dwc2: gadget: remove gadget module defines
  usb: dwc2: gadget: Do not fail probe if there isn't a clock node
  usb: dwc2: Add the appropriate init calls in platform code
  usb: dwc2: move allocation of core_params
  usb: dwc2: initialize the spin_lock for both host and gadget
  usb: dwc2: Add suspend/resume for gadget
  usb: dwc2: move dwc2_set_all_params to platform code
  usb: dwc2: check that the host work queue is valid
  usb: dwc2: pci: Update pci portion of the dwc2 driver
  usb: dwc2: Update Kconfig to support dual-role

 drivers/usb/dwc2/Kconfig |   52 +-
 drivers/usb/dwc2/Makefile|   21 +-
 drivers/usb/dwc2/core.c  |   15 +
 drivers/usb/dwc2/core.h  |   62 +-
 drivers/usb/dwc2/core_intr.c |  119 +++-
 drivers/usb/dwc2/gadget.c| 1433 +-
 drivers/usb/dwc2/hcd.c   |   23 +-
 drivers/usb/dwc2/hcd.h   |   12 +-
 drivers/usb/dwc2/pci.c   |   28 +-
 drivers/usb/dwc2/platform.c  |   58 +-
 10 files changed, 902 insertions(+), 921 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH 10/15] usb: dwc2: initialize the spin_lock for both host and gadget

2014-06-20 Thread dinguyen
From: Dinh Nguyen 

Move spin_lock_init to common location for both host and gadget.

Signed-off-by: Dinh Nguyen 
---
 drivers/usb/dwc2/hcd.c  |1 -
 drivers/usb/dwc2/platform.c |1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 1936544..a9b35f5 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2819,7 +2819,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 
hcd->has_tt = 1;
 
-   spin_lock_init(&hsotg->lock);
((struct wrapper_priv_data *) &hcd->hcd_priv)->hsotg = hsotg;
hsotg->priv = hcd;
 
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 2354c78..67f95ac 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -202,6 +202,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
}
 
platform_set_drvdata(dev, hsotg);
+   spin_lock_init(&hsotg->lock);
 
return retval;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: move ZTE CDMA device pid from zte_ev.c back to option.c and modify a parameter in zte_ev.ko

2014-06-20 Thread Dan Williams
On Fri, 2014-06-20 at 18:30 +0800, 刘磊 wrote:
> dear linuxfoundation:
> I'm very sorry has some problems in before's submit. now i divided the 
> problems in two patches.
> 
> patch1:move ZTE CDMA device pid from zte_ev.c back to option.c.
> reason: the pid of 0xfffe device can't re-connect succusfull when driven 
> by zte_ev, but work fine when driven by option.
> move the pid 0xfffe from zte_ev.c back to option.c.

Each patch should be in a separate email.  Also, the emails should be
formatted as described in Documentation/SubmittingPatches:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/Documentation/SubmittingPatches

An example of the format which the emails should follow is:

http://lkml.org/lkml/2014/6/20/273

Dan

> 
> Signed-off-by:lei liu
> diff -uprN -X linux-3.15.1/Documentation/dontdiff 
> linux-3.15.1/drivers/usb/serial/option.c 
> linux-3.15.1-update/drivers/usb/serial/option.c
> --- linux-3.15.1/drivers/usb/serial/option.c  2014-06-17 04:44:27.0 
> +0800
> +++ linux-3.15.1-update/drivers/usb/serial/option.c   2014-06-18 
> 15:19:21.936561280 +0800
> @@ -1542,6 +1542,7 @@ static const struct usb_device_id option
>   { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) },
>   { USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) },
>   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 
> 0xff, 0xff, 0xff) },
> + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xfffe, 0xff, 0xff, 
> 0xff) },
>  
>   { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
>   { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
> diff -uprN -X linux-3.15.1/Documentation/dontdiff 
> linux-3.15.1/drivers/usb/serial/zte_ev.c 
> linux-3.15.1-update/drivers/usb/serial/zte_ev.c
> --- linux-3.15.1/drivers/usb/serial/zte_ev.c  2014-06-17 04:44:27.0 
> +0800
> +++ linux-3.15.1-update/drivers/usb/serial/zte_ev.c   2014-06-20 
> 15:13:40.537941903 +0800
> @@ -274,8 +274,6 @@ static void zte_ev_usb_serial_close(stru
>  static const struct usb_device_id id_table[] = {
>   /* AC8710, AC8710T */
>   { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0x, 0xff, 0xff, 0xff) },
> -  /* AC8700 */
> - { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xfffe, 0xff, 0xff, 0xff) },
>   /* MG880 */
>   { USB_DEVICE(0x19d2, 0xfffd) },
>   { USB_DEVICE(0x19d2, 0xfffc) },
> 
> 
> 
> 
> patch2: Modify the parameter from 0x0003 to 0x. you must submit patch1 at 
> first.
> Reason:In the USB serial protocol,  if set the control state 
> (SET_CONTROL_LINE_STATE(22h)) and the parameter of RTS must be 0x 
> that make the carrier signal invalid state when close network. otherwise 
> can't disconnect the network.
> 
> 
> Signed-off-by:lei liu
> --- linux-3.15.1-update/drivers/usb/serial/zte_ev.c.orig  2014-06-20 
> 16:17:12.449795593 +0800
> +++ linux-3.15.1-update/drivers/usb/serial/zte_ev.c   2014-06-20 
> 16:14:56.193800822 +0800
> @@ -257,12 +257,12 @@ static void zte_ev_usb_serial_close(stru
>  
>   /* send 8th cmd */
>   /*
> -  * 16.0 CTL21 22 03 00  00 00 00 00
> +  * 16.0 CTL21 22 00 00  00 00 00 00
>*/
>   len = 0;
>   result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
>0x22, 0x21,
> -  0x0003, 0x, NULL, len,
> +  0x, 0x, NULL, len,
>USB_CTRL_GET_TIMEOUT);
>   dev_dbg(dev, "result = %d\n", result);
>  
> 
> 
> 
> thanks 
> lei liu
> NrybXǧv^)޺{.n+{^nrzh&Gh(階ݢj"mzޖfh~m


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [usb resume regression] in 3.16-rc1

2014-06-20 Thread Jörg Otte
2014-06-20 16:57 GMT+02:00 Alan Stern :
> On Fri, 20 Jun 2014, Jörg Otte wrote:
>
>> 2014-06-19 19:35 GMT+02:00 Alan Stern :
>> > On Thu, 19 Jun 2014, Jörg Otte wrote:
>> >
>> >> I don't know how to do this.
>> >
>> > To enable dynamic debugging (as root):
>> >
>> > echo 'module usbcore =p' >/sys/kernel/debug/dynamic_debug/control
>> > echo 'module ehci_hcd =p' >/sys/kernel/debug/dynamic_debug/control
>> >
>> > Do this before you carry out the suspend, and post the resulting dmesg
>> > log.
>> >
>> > Alan Stern
>> >
>> here it is.
>
> Now I see the reason for the regression.  There already is a patch to
> fix it:
>
> http://marc.info/?l=linux-usb&m=140304702623966&w=2
>
> The fix will probably be included in 3.16-rc2 or -rc3.
>
> Alan Stern
>
The patch works for me.

Thanks, Jörg
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: host: xhci-plat: use devm_functions

2014-06-20 Thread Himangi Saraogi
This patch introduces the use of managed interface devm_ioremap_resource
for ioremap_nocache and request_mem_region and removes the corresponding
free functions in the probe and remove functions.

Signed-off-by: Himangi Saraogi 
---
 drivers/usb/host/xhci-plat.c | 25 +
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 29d8adb..31d14a5 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -140,18 +140,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res);
 
-   if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
-   driver->description)) {
-   dev_dbg(&pdev->dev, "controller already in use\n");
-   ret = -EBUSY;
-   goto put_hcd;
-   }
-
-   hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
-   if (!hcd->regs) {
+   hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+   if (IS_ERR(hcd->regs)) {
dev_dbg(&pdev->dev, "error mapping memory\n");
-   ret = -EFAULT;
-   goto release_mem_region;
+   ret = PTR_ERR(hcd->regs);
+   goto put_hcd;
}
 
/*
@@ -162,7 +155,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (!IS_ERR(clk)) {
ret = clk_prepare_enable(clk);
if (ret)
-   goto unmap_registers;
+   goto put_hcd;
}
 
ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
@@ -207,12 +200,6 @@ disable_clk:
if (!IS_ERR(clk))
clk_disable_unprepare(clk);
 
-unmap_registers:
-   iounmap(hcd->regs);
-
-release_mem_region:
-   release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
-
 put_hcd:
usb_put_hcd(hcd);
 
@@ -231,8 +218,6 @@ static int xhci_plat_remove(struct platform_device *dev)
usb_remove_hcd(hcd);
if (!IS_ERR(clk))
clk_disable_unprepare(clk);
-   iounmap(hcd->regs);
-   release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd(hcd);
kfree(xhci);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: host: xhci-plat: use devm_functions

2014-06-20 Thread Felipe Balbi
Hi,

On Fri, Jun 20, 2014 at 10:18:53PM +0530, Himangi Saraogi wrote:
> This patch introduces the use of managed interface devm_ioremap_resource
> for ioremap_nocache and request_mem_region and removes the corresponding
> free functions in the probe and remove functions.
> 
> Signed-off-by: Himangi Saraogi 
> ---
>  drivers/usb/host/xhci-plat.c | 25 +
>  1 file changed, 5 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 29d8adb..31d14a5 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -140,18 +140,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
>   hcd->rsrc_start = res->start;
>   hcd->rsrc_len = resource_size(res);
>  
> - if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
> - driver->description)) {
> - dev_dbg(&pdev->dev, "controller already in use\n");
> - ret = -EBUSY;
> - goto put_hcd;
> - }
> -
> - hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
> - if (!hcd->regs) {
> + hcd->regs = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(hcd->regs)) {
>   dev_dbg(&pdev->dev, "error mapping memory\n");

you can remove this dev_dbg() message now that you're using
devm_ioremap_resource().

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v1 6/9] usb: xhci: Add NVIDIA Tegra XHCI host-controller driver

2014-06-20 Thread Julius Werner
> +static const struct hc_driver tegra_xhci_hc_driver = {
> +   .description =  "tegra-xhci-hcd",
> +   .product_desc = "Tegra xHCI Host Controller",
> +   .hcd_priv_size =sizeof(struct xhci_hcd *),
> +
> +   /*
> +* generic hardware linkage
> +*/
> +   .irq =  xhci_irq,
> +   .flags =HCD_MEMORY | HCD_USB3 | HCD_SHARED,
> +
> +   /*
> +* basic lifecycle operations
> +*/
> +   .reset =tegra_xhci_setup,
> +   .start =xhci_run,
> +   .stop = xhci_stop,
> +   .shutdown = xhci_shutdown,
> +
> +   /*
> +* managing i/o requests and associated device resources
> +*/
> +   .urb_enqueue =  xhci_urb_enqueue,
> +   .urb_dequeue =  xhci_urb_dequeue,
> +   .alloc_dev =xhci_alloc_dev,
> +   .free_dev = xhci_free_dev,
> +   .alloc_streams =xhci_alloc_streams,
> +   .free_streams = xhci_free_streams,
> +   .add_endpoint = xhci_add_endpoint,
> +   .drop_endpoint =xhci_drop_endpoint,
> +   .endpoint_reset =   xhci_endpoint_reset,
> +   .check_bandwidth =  xhci_check_bandwidth,
> +   .reset_bandwidth =  xhci_reset_bandwidth,
> +   .address_device =   xhci_address_device,
> +   .enable_device =xhci_enable_device,
> +   .update_hub_device =xhci_update_hub_device,
> +   .reset_device = xhci_discover_or_reset_device,
> +
> +   /*
> +* scheduling support
> +*/
> +   .get_frame_number = xhci_get_frame,
> +
> +   /* Root hub support */
> +   .hub_control =  xhci_hub_control,
> +   .hub_status_data =  xhci_hub_status_data,
> +   .bus_suspend =  xhci_bus_suspend,
> +   .bus_resume =   xhci_bus_resume,
> +};

I know I missed the first round of discussion where this was
suggested, but I don't think it's a good idea to pull the whole
hc_driver structure out into every platform implementation. It will
lead to duplication, then to future additions only being applied to
some of the implementations and everything getting out of sync. This
is already a problem with the PCI/plat split (e.g. the LPM functions
were only added to xhci-pci even though they should apply to both).
Also, if I'm not mistaken this code would fail to compile as a module
(you are referencing lots of symbols that are internal to the xhci-hcd
module).

I think at the very least you should add a function
"xhci_default_driver(struct hc_driver *driver)" to xhci-plat.c (or
even better to xhci.c and use it for PCI as well) that initializes all
function pointers to the default (internal) symbols, and can then be
overridden afterwards.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: host: xhci-plat: use devm_functions

2014-06-20 Thread Himangi Saraogi
This patch introduces the use of managed interface devm_ioremap_resource
for ioremap_nocache and request_mem_region and removes the corresponding
free functions in the probe and remove functions.

Signed-off-by: Himangi Saraogi 
Acked-by: Julia Lawall 
---
 drivers/usb/host/xhci-plat.c | 24 
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 29d8adb..23eeb15 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -140,20 +140,12 @@ static int xhci_plat_probe(struct platform_device *pdev)
hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res);
 
-   if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
-   driver->description)) {
-   dev_dbg(&pdev->dev, "controller already in use\n");
-   ret = -EBUSY;
+   hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+   if (IS_ERR(hcd->regs)) {
+   ret = PTR_ERR(hcd->regs);
goto put_hcd;
}
 
-   hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
-   if (!hcd->regs) {
-   dev_dbg(&pdev->dev, "error mapping memory\n");
-   ret = -EFAULT;
-   goto release_mem_region;
-   }
-
/*
 * Not all platforms have a clk so it is not an error if the
 * clock does not exists.
@@ -162,7 +154,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (!IS_ERR(clk)) {
ret = clk_prepare_enable(clk);
if (ret)
-   goto unmap_registers;
+   goto put_hcd;
}
 
ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
@@ -207,12 +199,6 @@ disable_clk:
if (!IS_ERR(clk))
clk_disable_unprepare(clk);
 
-unmap_registers:
-   iounmap(hcd->regs);
-
-release_mem_region:
-   release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
-
 put_hcd:
usb_put_hcd(hcd);
 
@@ -231,8 +217,6 @@ static int xhci_plat_remove(struct platform_device *dev)
usb_remove_hcd(hcd);
if (!IS_ERR(clk))
clk_disable_unprepare(clk);
-   iounmap(hcd->regs);
-   release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd(hcd);
kfree(xhci);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: host: xhci-plat: use devm_functions

2014-06-20 Thread Felipe Balbi
On Fri, Jun 20, 2014 at 11:11:23PM +0530, Himangi Saraogi wrote:
> This patch introduces the use of managed interface devm_ioremap_resource
> for ioremap_nocache and request_mem_region and removes the corresponding
> free functions in the probe and remove functions.
> 
> Signed-off-by: Himangi Saraogi 
> Acked-by: Julia Lawall 

Reviewed-by: Felipe Balbi 
Acked-by: Felipe Balbi 

> ---
>  drivers/usb/host/xhci-plat.c | 24 
>  1 file changed, 4 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 29d8adb..23eeb15 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -140,20 +140,12 @@ static int xhci_plat_probe(struct platform_device *pdev)
>   hcd->rsrc_start = res->start;
>   hcd->rsrc_len = resource_size(res);
>  
> - if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
> - driver->description)) {
> - dev_dbg(&pdev->dev, "controller already in use\n");
> - ret = -EBUSY;
> + hcd->regs = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(hcd->regs)) {
> + ret = PTR_ERR(hcd->regs);
>   goto put_hcd;
>   }
>  
> - hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
> - if (!hcd->regs) {
> - dev_dbg(&pdev->dev, "error mapping memory\n");
> - ret = -EFAULT;
> - goto release_mem_region;
> - }
> -
>   /*
>* Not all platforms have a clk so it is not an error if the
>* clock does not exists.
> @@ -162,7 +154,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
>   if (!IS_ERR(clk)) {
>   ret = clk_prepare_enable(clk);
>   if (ret)
> - goto unmap_registers;
> + goto put_hcd;
>   }
>  
>   ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
> @@ -207,12 +199,6 @@ disable_clk:
>   if (!IS_ERR(clk))
>   clk_disable_unprepare(clk);
>  
> -unmap_registers:
> - iounmap(hcd->regs);
> -
> -release_mem_region:
> - release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
> -
>  put_hcd:
>   usb_put_hcd(hcd);
>  
> @@ -231,8 +217,6 @@ static int xhci_plat_remove(struct platform_device *dev)
>   usb_remove_hcd(hcd);
>   if (!IS_ERR(clk))
>   clk_disable_unprepare(clk);
> - iounmap(hcd->regs);
> - release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
>   usb_put_hcd(hcd);
>   kfree(xhci);
>  
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] usb: host: xhci-plat: use devm_functions

2014-06-20 Thread Sergei Shtylyov

Hello.

On 06/20/2014 08:48 PM, Himangi Saraogi wrote:


This patch introduces the use of managed interface devm_ioremap_resource
for ioremap_nocache and request_mem_region and removes the corresponding
free functions in the probe and remove functions.



Signed-off-by: Himangi Saraogi 
---
  drivers/usb/host/xhci-plat.c | 25 +
  1 file changed, 5 insertions(+), 20 deletions(-)



diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 29d8adb..31d14a5 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -140,18 +140,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res);

-   if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
-   driver->description)) {
-   dev_dbg(&pdev->dev, "controller already in use\n");
-   ret = -EBUSY;
-   goto put_hcd;
-   }
-
-   hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
-   if (!hcd->regs) {
+   hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+   if (IS_ERR(hcd->regs)) {
dev_dbg(&pdev->dev, "error mapping memory\n");


   This line is worth removing -- devm_ioremap_resource() complains loudly on 
errors.



-   ret = -EFAULT;
-   goto release_mem_region;
+   ret = PTR_ERR(hcd->regs);
+   goto put_hcd;
}


WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[GIT PULL] USB driver fixes for 3.16-rc2

2014-06-20 Thread Greg KH
The following changes since commit 7171511eaec5bf23fb06078f59784a3a0626b38f:

  Linux 3.16-rc1 (2014-06-15 17:45:28 -1000)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/ 
tags/usb-3.16-rc2

for you to fetch changes up to 32b36eeae6a859670d2939a7d6136cb5e9ed64f8:

  USB: usbtest: add a timeout for scatter-gather tests (2014-06-17 17:05:50 
-0700)


USB fixes for 3.16-rc2

Here are some USB fixes for 3.16-rc2 that resolve some reported issues.
All of these have been in linux-next for a while with no problems.

Signed-off-by: Greg Kroah-Hartman 


Alan Stern (2):
  USB: EHCI: avoid BIOS handover on the HASEE E200
  USB: usbtest: add a timeout for scatter-gather tests

Dan Williams (4):
  usb: fix ->update_hub_device() vs hdev->maxchild
  usb: improve "not suspended yet" message in hub_suspend()
  usb: quiet peer failure warning, disable poweroff
  usb: fix hub-port pm_runtime_enable() vs runtime pm transitions

Mathias Nyman (1):
  xhci: Fix sleeping with IRQs disabled in xhci_stop_device()

 drivers/usb/core/hub.c| 33 +---
 drivers/usb/core/hub.h|  2 +
 drivers/usb/core/port.c   | 89 +++
 drivers/usb/host/pci-quirks.c | 19 +++--
 drivers/usb/host/xhci-hub.c   |  2 +-
 drivers/usb/misc/usbtest.c| 16 +++-
 6 files changed, 119 insertions(+), 42 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [GIT PULL] USB fixes for v3.16-rc2

2014-06-20 Thread Greg KH
On Fri, Jun 20, 2014 at 09:44:37AM -0500, Felipe Balbi wrote:
> Hi Greg,
> 
> Here's my first set of fixes for this -rc cycle. Please consider merging
> to your usb-linus branch.

I'll do it after Linus picks up my last round of changes I sent him.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: musb: ux500: use devm_ functions

2014-06-20 Thread Himangi Saraogi
This patch introduces the use of managed interfaces for clk_get and
kzalloc and removes the corresponding free function calls in the probe
and remove functions.

Signed-off-by: Himangi Saraogi 
Acked-by: Julia Lawall 
---
 drivers/usb/musb/ux500.c | 28 ++--
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index c2e45e6..10c9cb0 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -246,7 +246,7 @@ static int ux500_probe(struct platform_device *pdev)
}
}
 
-   glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+   glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
if (!glue) {
dev_err(&pdev->dev, "failed to allocate glue context\n");
goto err0;
@@ -255,20 +255,20 @@ static int ux500_probe(struct platform_device *pdev)
musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
if (!musb) {
dev_err(&pdev->dev, "failed to allocate musb device\n");
-   goto err1;
+   goto err0;
}
 
-   clk = clk_get(&pdev->dev, NULL);
+   clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(clk)) {
dev_err(&pdev->dev, "failed to get clock\n");
ret = PTR_ERR(clk);
-   goto err3;
+   goto err1;
}
 
ret = clk_prepare_enable(clk);
if (ret) {
dev_err(&pdev->dev, "failed to enable clock\n");
-   goto err4;
+   goto err1;
}
 
musb->dev.parent= &pdev->dev;
@@ -302,34 +302,28 @@ static int ux500_probe(struct platform_device *pdev)
ARRAY_SIZE(musb_resources));
if (ret) {
dev_err(&pdev->dev, "failed to add resources\n");
-   goto err5;
+   goto err2;
}
 
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
if (ret) {
dev_err(&pdev->dev, "failed to add platform_data\n");
-   goto err5;
+   goto err2;
}
 
ret = platform_device_add(musb);
if (ret) {
dev_err(&pdev->dev, "failed to register musb device\n");
-   goto err5;
+   goto err2;
}
 
return 0;
 
-err5:
+err2:
clk_disable_unprepare(clk);
 
-err4:
-   clk_put(clk);
-
-err3:
-   platform_device_put(musb);
-
 err1:
-   kfree(glue);
+   platform_device_put(musb);
 
 err0:
return ret;
@@ -341,8 +335,6 @@ static int ux500_remove(struct platform_device *pdev)
 
platform_device_unregister(glue->musb);
clk_disable_unprepare(glue->clk);
-   clk_put(glue->clk);
-   kfree(glue);
 
return 0;
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] drivers/net/usb/asix_devices.c: inline ax88772_unbind

2014-06-20 Thread Fabian Frederick
inline this one line function used in driver_info structure

Cc: "David S. Miller" 
Cc: Emil Goode 
Cc: linux-usb@vger.kernel.org
Signed-off-by: Fabian Frederick 
---
 drivers/net/usb/asix_devices.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 8a7582b..a41926a 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -497,7 +497,7 @@ static int ax88772_bind(struct usbnet *dev, struct 
usb_interface *intf)
return 0;
 }
 
-static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf)
+static inline void ax88772_unbind(struct usbnet *dev, struct usb_interface 
*intf)
 {
kfree(dev->driver_priv);
 }
-- 
1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] drivers/net/usb/asix_devices.c: remove null test before kfree

2014-06-20 Thread Fabian Frederick
Fix checkpatch warning:
WARNING: kfree(NULL) is safe this check is probably not required

Cc: "David S. Miller" 
Cc: Emil Goode 
Cc: linux-usb@vger.kernel.org
Signed-off-by: Fabian Frederick 
---
 drivers/net/usb/asix_devices.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 5d19409..8a7582b 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -499,8 +499,7 @@ static int ax88772_bind(struct usbnet *dev, struct 
usb_interface *intf)
 
 static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-   if (dev->driver_priv)
-   kfree(dev->driver_priv);
+   kfree(dev->driver_priv);
 }
 
 static const struct ethtool_ops ax88178_ethtool_ops = {
-- 
1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Hardware bug in Intel USB-2 hub?

2014-06-20 Thread Alan Stern
On Sun, 15 Jun 2014, Toralf Förster wrote:

> >>> Toralf and Adam:
> >>>
> >>> Does this patch (for 3.14 or 3.15) fix the problems you observed?
> >>
> >> No, neither for 3.14.7 nor for 3.15.
> >>
> >> USB wakeup signals from hibernation don't work, the power button does.
> >> Wakeup from suspend still works (unlike the situation before
> >> c1db30a2a79eb59997b13b8cabf2a50bea9f04e1, the commit I bisected the
> >> hibernation problem to).
> > 
> > I don't get it.
> > 
> > What happens if you run a kernel built from the commit preceding 
> > 0aa2832dd0d9?  Such a kernel should behave the same as what you get 
> > with this patch installed, regardless of whether c1db30a2a79e is 
> > present or not.
> > 
> > If it doesn't then something else has changed in the meantime.
> > 
> > Alan Stern
> > 
> > 
> Ok, I made this with kernel 3.15 :

You mean 3.15 plus the patch I sent?

> tfoerste@n22 ~/tmp $ sudo su -
> n22 ~ # cat /sys/kernel/debug/usb/usbmon/2u >/tmp/right
> ^C
> 
> n22 ~ # cat /sys/kernel/debug/usb/usbmon/2u >/tmp/wrong
> ^C
> 
> For the second command : Before I s2ram'ed the system I switched the USB hub 
> (where the keyboardm, the mouse and a printer was attached) from the "right" 
> port to the "wrong" port.

Is this the same as what you get from plain 3.15 with no patches?

Sorry I've been too busy with other things to look at this yet.  I'll
try to get to it next week.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: usb audio breaks ohci-pci

2014-06-20 Thread Dennis New
On Thu, 19 Jun 2014 17:44:39 -0400 (EDT), Alan Stern wrote:
> On Thu, 19 Jun 2014, Dennis New wrote:
> 
> > On Thu, 19 Jun 2014 17:03:55 -0400 (EDT), Alan Stern wrote:
> > > On Tue, 17 Jun 2014, Dennis New wrote:
> > > 
> > > > On Thu, 12 Jun 2014 10:20:54 -0400 (EDT), Alan Stern wrote:
> > > > > Dennis and Matteo:
> > > > > 
> > > > > I promised to send both of you a patch changing the way
> > > > > ohci-hcd handles hardware bugs.  Well, it's finally ready for
> > > > > testing. There's only a limited amount I can do on my own
> > > > > machine, so now it's up to you guys.
> > > > > 
> > > > > The patch was made against an early -rc version of 3.15, but
> > > > > it will apply okay to 3.14 and maybe even earlier kernels.
> > > > 
> > > > So, it happened again, after a random few days, this time with
> > > > dmesg a bit different:
> > > > 
> > > > [210263.872368] ohci-pci :00:13.0: frame counter not
> > > > updating; disabled
> > > > [210263.872377] ohci-pci :00:13.0: HC died; cleaning up
> > > > [210263.872456] usb 2-4: USB disconnect, device number 4
> > > > [210264.872344] timeout: still 2 active urbs on EP #3
> > > > 
> > > > The frame counter indeed was not updating. I notice that this
> > > > time, it says there are "still 2 active urbs", whereas before
> > > > it always said 3. I also noticed that before I would still get
> > > > "USB disconnect" messages when I unplugged my device, but not
> > > > this time. It looks like there was a more thorough disabling of
> > > > the usb/ohci system this time.
> > > 
> > > That "timeout:" message came from the snd-usb-audio driver.  I
> > > don't know if the number of URBs is especially significant,
> > > probably not. The lack of "USB disconnect" messages is expected,
> > > because as you realized, the OHCI driver was disabled.
> > > 
> > > Anyway, it looks like things are working better than they did
> > > before. Your system isn't crashing when the problem occurs, right?
> > > This might not be the solution you wanted, but I think it's the
> > > best we can do.
> > 
> > My system didn't really crash before either -- just the ohci. I
> > forget if the process that was using the snd-usb-audio driver
> > remained hung in the background, but commands like "lsusb" do not
> > work. I am forced to reboot to get ohci-usb working again :\. Isn't
> > there a way to reset the ohci subsystem? :s
> 
> And with the patch, lsusb and the sound processes do work after the
> fault?  I want to make sure, since you didn't say explicitly.
> 
> You can restart the OHCI controller by this sequence of commands:
> 
>   echo :00:13.0 >/sys/bus/pci/drivers/ohci_pci/unbind
>   echo :00:13.0 >/sys/bus/pci/drivers/ohci_pci/bind
> 
> However, some USB devices can't recover from this sort of event until
> they have been unplugged.  I tried it with two flash drives plugged
> in; afterwards one of them worked and the other didn't.

With the new patch, mplayer is able to close gracefully, with pcm
errors like "No such device". This time, my dmesg was slightly
different, with an "HcDoneHead" message:

[139650.866080] ohci-pci :00:13.0: HcDoneHead not written back;
disabled
[139650.866089] ohci-pci :00:13.0: HC died; cleaning up
[139650.866166] usb 2-4: USB disconnect, device number 3
[139651.866074] timeout: still 2 active urbs on EP #3

However, lsusb does not work, and I cannot kill it -- it remains in D
(uninterruptible sleep) state. I am also unable to rmmod the
snd_usb_audio module -- rmmod gets stuck in D state too.

When I tried echoing (:00:13.0) to ohci_pci/unbind, although dmesg
says:

[140078.654462] ohci-pci :00:13.0: remove, state 1
[140078.654480] usb usb2: USB disconnect, device number 1

... the echo command (a bash internal) does not terminate, and also gets
stuck in D state.

Although the symlink to :00:13.0 does get removed from that
directory. But trying to echo this back to ohci_pci/bind doesn't work:

  "write error: No such device"

Even though :00:13.0 is still listed in /sys/kernel/debug/usb/ohci.

Try to "cat" /sys/kernel/debug/usb/devices also fails, and cat gets
stuck in D state too.

My usb thumbdrive also no longer works after this occurs, although I'm
pretty sure it uses EHCI. I'm forced to reboot to get usb working
again :s.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: usb audio breaks ohci-pci

2014-06-20 Thread Dennis New
On Fri, 20 Jun 2014 17:33:14 -0400, Dennis New wrote:
> On Thu, 19 Jun 2014 17:44:39 -0400 (EDT), Alan Stern wrote:
> > On Thu, 19 Jun 2014, Dennis New wrote:
> > 
> > > On Thu, 19 Jun 2014 17:03:55 -0400 (EDT), Alan Stern wrote:
> > > > On Tue, 17 Jun 2014, Dennis New wrote:
> > > > 
> > > > > On Thu, 12 Jun 2014 10:20:54 -0400 (EDT), Alan Stern wrote:
> > > > > > Dennis and Matteo:
> > > > > > 
> > > > > > I promised to send both of you a patch changing the way
> > > > > > ohci-hcd handles hardware bugs.  Well, it's finally ready
> > > > > > for testing. There's only a limited amount I can do on my
> > > > > > own machine, so now it's up to you guys.
> > > > > > 
> > > > > > The patch was made against an early -rc version of 3.15, but
> > > > > > it will apply okay to 3.14 and maybe even earlier kernels.
> > > > > 
> > > > > So, it happened again, after a random few days, this time with
> > > > > dmesg a bit different:
> > > > > 
> > > > > [210263.872368] ohci-pci :00:13.0: frame counter not
> > > > > updating; disabled
> > > > > [210263.872377] ohci-pci :00:13.0: HC died; cleaning up
> > > > > [210263.872456] usb 2-4: USB disconnect, device number 4
> > > > > [210264.872344] timeout: still 2 active urbs on EP #3
> > > > > 
> > > > > The frame counter indeed was not updating. I notice that this
> > > > > time, it says there are "still 2 active urbs", whereas before
> > > > > it always said 3. I also noticed that before I would still get
> > > > > "USB disconnect" messages when I unplugged my device, but not
> > > > > this time. It looks like there was a more thorough disabling
> > > > > of the usb/ohci system this time.
> > > > 
> > > > That "timeout:" message came from the snd-usb-audio driver.  I
> > > > don't know if the number of URBs is especially significant,
> > > > probably not. The lack of "USB disconnect" messages is expected,
> > > > because as you realized, the OHCI driver was disabled.
> > > > 
> > > > Anyway, it looks like things are working better than they did
> > > > before. Your system isn't crashing when the problem occurs,
> > > > right? This might not be the solution you wanted, but I think
> > > > it's the best we can do.
> > > 
> > > My system didn't really crash before either -- just the ohci. I
> > > forget if the process that was using the snd-usb-audio driver
> > > remained hung in the background, but commands like "lsusb" do not
> > > work. I am forced to reboot to get ohci-usb working again :\.
> > > Isn't there a way to reset the ohci subsystem? :s
> > 
> > And with the patch, lsusb and the sound processes do work after the
> > fault?  I want to make sure, since you didn't say explicitly.
> > 
> > You can restart the OHCI controller by this sequence of commands:
> > 
> > echo :00:13.0 >/sys/bus/pci/drivers/ohci_pci/unbind
> > echo :00:13.0 >/sys/bus/pci/drivers/ohci_pci/bind
> > 
> > However, some USB devices can't recover from this sort of event
> > until they have been unplugged.  I tried it with two flash drives
> > plugged in; afterwards one of them worked and the other didn't.
> 
> With the new patch, mplayer is able to close gracefully, with pcm
> errors like "No such device". This time, my dmesg was slightly
> different, with an "HcDoneHead" message:
> 
> [139650.866080] ohci-pci :00:13.0: HcDoneHead not written back;
> disabled
> [139650.866089] ohci-pci :00:13.0: HC died; cleaning up
> [139650.866166] usb 2-4: USB disconnect, device number 3
> [139651.866074] timeout: still 2 active urbs on EP #3
> 
> However, lsusb does not work, and I cannot kill it -- it remains in D
> (uninterruptible sleep) state. I am also unable to rmmod the
> snd_usb_audio module -- rmmod gets stuck in D state too.
> 
> When I tried echoing (:00:13.0) to ohci_pci/unbind, although dmesg
> says:
> 
> [140078.654462] ohci-pci :00:13.0: remove, state 1
> [140078.654480] usb usb2: USB disconnect, device number 1
> 
> ... the echo command (a bash internal) does not terminate, and also
> gets stuck in D state.
> 
> Although the symlink to :00:13.0 does get removed from that
> directory. But trying to echo this back to ohci_pci/bind doesn't work:
> 
>   "write error: No such device"
> 
> Even though :00:13.0 is still listed
> in /sys/kernel/debug/usb/ohci.
> 
> Try to "cat" /sys/kernel/debug/usb/devices also fails, and cat gets
> stuck in D state too.
> 
> My usb thumbdrive also no longer works after this occurs, although I'm
> pretty sure it uses EHCI. I'm forced to reboot to get usb working
> again :s.

cat'ing the stuff in /sys/kernel/debug/usb/ohci/:00:13:0/ in the
hung state:

==> async <==

==> periodic <==
size = 32
 0 [ 22]: ed1/880021853000 (fs dev3 ep1in-int qlen 1 max 16
00101083) 1 [ 22]: ed1/880021853000
 2 [ 22]: ed1/880021853000
 3 [ 22]: ed1/880021853000
 4 [ 22]: ed1/880021853000
 5 [ 22]: ed1/880021853000
 6 [ 22]: ed1/880021853000
 7 [ 22]: ed1/880021853000
 8 [ 22]: ed1/880021853000
 9 [ 22]: 

usb: musb: Ensure that cppi41 timer gets armed on premature DMA TX irq

2014-06-20 Thread Thomas Gleixner
Some TI chips raise the DMA complete interrupt before the actual
transfer has been completed. The code tries to busy wait for a few
microseconds and if that fails it arms an hrtimer to recheck. So far
so good, but that has the following issue:

CPU 0   CPU1

start_next_transfer(RQ1);

DMA interrupt
  if (premature_irq(RQ1))
if (!hrtimer_active(timer))
   hrtimer_start(timer);

hrtimer expires
  timer->state = CALLBACK_RUNNING;
  timer->fn() 
cppi41_recheck_tx_req()
  complete_request(RQ1); 
  if (requests_pending())
start_next_transfer(RQ2);

DMA interrupt
  if (premature_irq(RQ2))
if (!hrtimer_active(timer))
   hrtimer_start(timer);
  timer->state = INACTIVE; 

The premature interrupt of request2 on CPU1 does not arm the timer and
therefor the request completion never happens because it checks for
!hrtimer_active(). hrtimer_active() evaluates:

  timer->state != HRTIMER_STATE_INACTIVE

which of course evaluates to true in the above case as timer->state is
CALLBACK_RUNNING.

That's clearly documented:

 * A timer is active, when it is enqueued into the rbtree or the
 * callback function is running or it's in the state of being migrated  
 * to another cpu. 

But that's not what the code wants to check. The code wants to check
whether the timer is queued, i.e. whether its armed and waiting for
expiry.

We have a helper function for this: hrtimer_is_queued(). This
evaluates:

  timer->state & HRTIMER_STATE_QUEUED

So in the above case this evaluates to false and therefor forces the
DMA interrupt on CPU1 to call hrtimer_start().

Use hrtimer_is_queued() instead of hrtimer_active() and evrything is
good.

Reported-by: Torben Hohn 
Signed-off-by: Thomas Gleixner 
Cc: sta...@vger.kernel.org
---
 drivers/usb/musb/musb_cppi41.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux/drivers/usb/musb/musb_cppi41.c
===
--- linux.orig/drivers/usb/musb/musb_cppi41.c
+++ linux/drivers/usb/musb/musb_cppi41.c
@@ -318,7 +318,7 @@ static void cppi41_dma_callback(void *pr
}
list_add_tail(&cppi41_channel->tx_check,
&controller->early_tx_list);
-   if (!hrtimer_active(&controller->early_tx)) {
+   if (!hrtimer_is_queued(&controller->early_tx)) {
hrtimer_start_range_ns(&controller->early_tx,
ktime_set(0, 140 * NSEC_PER_USEC),
40 * NSEC_PER_USEC,
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [RESEND PATCH 00/15] usb: dwc2: Add support for dual-role

2014-06-20 Thread Paul Zimmerman
> From: dingu...@altera.com [mailto:dingu...@altera.com]
> Sent: Friday, June 20, 2014 8:35 AM
> 
> From: Dinh Nguyen 
> 
> Apologies for the noise, but I got Paul Zimmerman's address wrong on the
> first send.
> 
> Hi,
> 
> This patch series combines the dwc2 host and gadget driver into a single
> dual-role driver. I have tested this on the SOCFPGA platform. I compile
> tested for bcm2835_defconfig and a PCI platform.
> 
> I split up the patches to make the review a bit easier, but each individual
> patch can't really stand on it's own. Any comments/testing is greatly
> appreciated.

Hi Dinh,

I really appreciate your work on this, and from a quick glance, it looks
like this will be acceptable once a few issues are taken care of.

However, I am not going to do an in-depth review, or do any testing,
until you submit a patch series that can be applied.

Why? If I do a review and test of this series, then I will have to ask
you to redo it into a form that can be applied. Then I would have to do
a full review and test of _that_ series as well, to make sure that
nothing got broken in the translation. So you are creating more work for
me, yourself, and anyone else who might want to review/test this.

Also, please do not post a patch series titled "[PATCH]" if you know
that it should not be applied as-is. At least put an "RFC" in there so
people will know it shouldn't be applied.

Really, you should learn to use git properly, instead of doing a bunch of
work without it, and then throwing everything in at the last minute so
you can create a patch series. Git should be your friend, not your enemy ;)

-- 
Paul

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] drivers/net/usb/asix_devices.c: inline ax88772_unbind

2014-06-20 Thread Sergei Shtylyov

Hello.

On 06/21/2014 12:40 AM, Fabian Frederick wrote:


inline this one line function used in driver_info structure



Cc: "David S. Miller" 
Cc: Emil Goode 
Cc: linux-usb@vger.kernel.org
Signed-off-by: Fabian Frederick 
---
  drivers/net/usb/asix_devices.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)



diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 8a7582b..a41926a 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -497,7 +497,7 @@ static int ax88772_bind(struct usbnet *dev, struct 
usb_interface *intf)
return 0;
  }

-static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf)
+static inline void ax88772_unbind(struct usbnet *dev, struct usb_interface 
*intf)
  {
kfree(dev->driver_priv);
  }


   gcc is perfectly capable of figuring that out. No need to use *inline* 
outside the *.h files.


WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


move ZTE CDMA device pid from zte_ev.c back to option.c

2014-06-20 Thread 刘磊
dear linuxfoundation:
I'm very sorry, i think i had been according to the 
Documentation/SubmittingPatches  to submit.

The pid of 0xfffe device re-connect network failed when driven by zte_ev, 
but work fine when driven by option if we move the pid 0xfffe to option. 
in order to re-connect sucessfull, we should move the pid 0xfffe from zte_ev.c 
back to option.c.


Signed-off-by:lei liu
diff -uprN -X linux-3.15.1/Documentation/dontdiff 
linux-3.15.1/drivers/usb/serial/option.c 
linux-3.15.1-update/drivers/usb/serial/option.c
--- linux-3.15.1/drivers/usb/serial/option.c2014-06-17 04:44:27.0 
+0800
+++ linux-3.15.1-update/drivers/usb/serial/option.c 2014-06-18 
15:19:21.936561280 +0800
@@ -1542,6 +1542,7 @@ static const struct usb_device_id option
{ USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x02, 0x05) },
{ USB_VENDOR_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xff, 0x86, 0x10) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 
0xff, 0xff, 0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0xfffe, 0xff, 0xff, 
0xff) },
 
{ USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
{ USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
diff -uprN -X linux-3.15.1/Documentation/dontdiff 
linux-3.15.1/drivers/usb/serial/zte_ev.c 
linux-3.15.1-update/drivers/usb/serial/zte_ev.c
--- linux-3.15.1/drivers/usb/serial/zte_ev.c2014-06-17 04:44:27.0 
+0800
+++ linux-3.15.1-update/drivers/usb/serial/zte_ev.c 2014-06-20 
15:13:40.537941903 +0800
@@ -274,8 +274,6 @@ static void zte_ev_usb_serial_close(stru
 static const struct usb_device_id id_table[] = {
/* AC8710, AC8710T */
{ USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0x, 0xff, 0xff, 0xff) },
-/* AC8700 */
-   { USB_DEVICE_AND_INTERFACE_INFO(0x19d2, 0xfffe, 0xff, 0xff, 0xff) },
/* MG880 */
{ USB_DEVICE(0x19d2, 0xfffd) },
{ USB_DEVICE(0x19d2, 0xfffc) },



thanks
leiliuN�r��yb�X��ǧv�^�)޺{.n�+{��^n�r���z���h�&���G���h�(�階�ݢj"���m��z�ޖ���f���h���~�m�

uas regression in 3.15 with ASMedia 2105 SATA bridge / ASMT1051

2014-06-20 Thread Jonathan
After upgrading to kernel 3.15 my USB 3.0 HDD dock no longer works. In fact, as 
soon as I connect and power up a drive with the uas module loaded, I get a hard 
lockup and have to restart the system. Without the uas module loaded, the dock 
is detected but the drive is not, rendering it unusable. I had no problems at 
all with this hardware on kernel 3.14.

Output from lsusb -v:

Bus 003 Device 002: ID 174c:55aa ASMedia Technology Inc. ASMedia 2105 SATA 
bridge
Device Descriptor:
  bLength18
  bDescriptorType 1
  bcdUSB   3.00
  bDeviceClass0 (Defined at Interface level)
  bDeviceSubClass 0 
  bDeviceProtocol 0 
  bMaxPacketSize0 9
  idVendor   0x174c ASMedia Technology Inc.
  idProduct  0x55aa ASMedia 2105 SATA bridge
  bcdDevice1.00
  iManufacturer   2 asmedia
  iProduct3 ASMT1051
  iSerial 1 123456789012
  bNumConfigurations  1
  Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength   44
bNumInterfaces  1
bConfigurationValue 1
iConfiguration  0 
bmAttributes 0xc0
  Self Powered
MaxPower   36mA
Interface Descriptor:
  bLength 9
  bDescriptorType 4
  bInterfaceNumber0
  bAlternateSetting   0
  bNumEndpoints   2
  bInterfaceClass 8 Mass Storage
  bInterfaceSubClass  6 SCSI
  bInterfaceProtocol 80 Bulk-Only
  iInterface  0 
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81  EP 1 IN
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0400  1x 1024 bytes
bInterval   0
bMaxBurst  15
  Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02  EP 2 OUT
bmAttributes2
  Transfer TypeBulk
  Synch Type   None
  Usage Type   Data
wMaxPacketSize 0x0400  1x 1024 bytes
bInterval   0
bMaxBurst  15
Binary Object Store Descriptor:
  bLength 5
  bDescriptorType15
  wTotalLength   22
  bNumDeviceCaps  2
  USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType16
bDevCapabilityType  2
bmAttributes   0x0002
  Link Power Management (LPM) Supported
  SuperSpeed USB Device Capability:
bLength10
bDescriptorType16
bDevCapabilityType  3
bmAttributes 0x00
wSpeedsSupported   0x000e
  Device can operate at Full Speed (12Mbps)
  Device can operate at High Speed (480Mbps)
  Device can operate at SuperSpeed (5Gbps)
bFunctionalitySupport   1
  Lowest fully-functional device speed is Full Speed (12Mbps)
bU1DevExitLat  10 micro seconds
bU2DevExitLat2047 micro seconds
Device Status: 0x0001
  Self Powered

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html