Re: [PATCH 2/2] usb: musb: cppi41: Enable in device-TX mode

2013-08-14 Thread Sebastian Andrzej Siewior
On 08/13/2013 08:11 PM, Bin Liu wrote:
 Sebastian,

Hi Bin,

 On Tue, Aug 13, 2013 at 12:38 PM, Sebastian Andrzej Siewior
 bige...@linutronix.de wrote:
 Since the musb-gadget code now calls the dma engine properly it is
 possible to enable it for the TX path in device mode.
 AM335x Advisory 1.0.13 says that we may lose the toggle bit on multiple
 RX transfers. There is a workaround in host mode but none in device mode
 and therefore RX transfers are disabled.
 1.0.13 only presents in PG1.0. It has been fixed in PG2.x. Maybe we
 should check for silicon rev here?

Where do you have this from? My document says won't be fixed.
If you say this is fixed in PG2+, then we don't this the workaround in
host mode either, right?

 
 Regards,
 -Bin.

Sebastian
--
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: [RFC PATCH v2 1/3] usb: dwc3: msm: Add device tree binding information

2013-08-14 Thread Ivan T. Ivanov
Hi,

On Tue, 2013-08-13 at 13:57 -0600, Stephen Warren wrote: 
 On 08/09/2013 03:53 AM, Ivan T. Ivanov wrote:
  From: Ivan T. Ivanov iiva...@mm-sol.com
  
  MSM USB3.0 core wrapper consist of USB3.0 IP (SNPS)
  and HS, SS PHY's controll and configuration registers.
 
 s/controll/control/
 

Thanks.

  It could operate in device mode (SS, HS, FS) and host
  mode (SS, HS, FS, LS).
 
  diff --git a/Documentation/devicetree/bindings/usb/msm-ssusb.txt 
  b/Documentation/devicetree/bindings/usb/msm-ssusb.txt
 
  +MSM SuperSpeed DWC3 USB SoC controller
  +
  +Required properities :
  +- compatible : sould be qcom,dwc3-hsphy;
 ...
  +Required properities :
  +- compatible : sould be qcom,dwc3-ssphy;
 
 I would expect different compatible values to be documented in different
 files.

It is easy to see connection between them when they are in
one file. Drivers are useless without each other. 

 
  +Optional properties :
  +- gdsc-supply : phandle to the globally distributed switch controller
  +  regulator node to the USB controller.
 
 Which of the 3 compatible values that were described above is that
 property optional for?

qcom,dwc3. I will make this more explicit. 

 
  +Sub nodes:
  +- Sub node for DWC3 USB3 controller.
  +  This sub node is required property for device node. The properties
  +  of this subnode are specified in dwc3.txt.
 
 Why not represent the PHY and USB controller as separate top-level
 nodes? They can point at each-other with phandles if they need to know
 each-others' identity.

qcom,dwc3 (glue layer) driver have to be loaded before snps,dwc3,
actual USB3 IP. qcom,dwc3 provide required clocks and power supplies
to the USB3 IP core.

Regards,
Ivan


--
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] usb: musb: cppi41: Enable in device-TX mode

2013-08-14 Thread Sebastian Andrzej Siewior
On 08/13/2013 09:21 PM, Felipe Balbi wrote:
 1.0.13 only presents in PG1.0. It has been fixed in PG2.x. Maybe
 we should check for silicon rev here?
 
 it would be quite difficult to check PG revision from this driver.
 It would have to be passed as a flag through DT or something
 similar.

If DT then u-boot has to detect it and set the flag. I don't want two
device trees one for people with PG1 and one for people with PG2+
especially since this is something that can be detected at run time.
Isn't this printed by the core code at boot time? Then we could save
this in a variable unless it is done already and access it.

Sebastian
--
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 0/7] phy: omap-usb: Support multiple instances and new types

2013-08-14 Thread Roger Quadros
+Benoit

Hi Felipe,

Any comments on this series?

cheers,
-roger

On 08/01/2013 05:05 PM, Roger Quadros wrote:
 Hi,
 
 This patchset does the following:
 
 * Restructure and add support for new PHY types. We now support the follwing
 four types
 
  TYPE1 - if it has otghs_control mailbox register (e.g. on OMAP4)
  TYPE2 - if it has Power down bit in control_dev_conf register. e.g. USB2 PHY
  TYPE3 - if it has DPLL and individual Rx  Tx power control. e.g. USB3 PHY 
 or SATA PHY
  TYPE4 - if it has both power down and power aux registers. e.g. USB2 PHY on 
 DRA7
 
 * Have only one power control API omap_control_usb_phy_power() instead of a
 different one for each PHY type.
 
 * Get rid of omap_get_control_dev() so that we can support multiple instances
 of the control device. We take advantage of the fact that omap control USB 
 device
 is only present on OMAP4 onwards and hence only supports DT boot. The users
 of control USB device can get a reference to it from the device node's 
 phandle.
 
 Patches are based on top of v3.11-rc3 with balbi/next on top.
 
 Smoke tested on OMAP4 panda with MUSB in gadget mode (g_zero).
 
 You can find the patches in branch
  usb-control-module
 in git tree
  git://github.com/rogerq/linux.git
 
 cheers,
 -roger
 
 Roger Quadros (7):
   usb: phy: omap: Add new PHY types and remove
 omap_control_usb3_phy_power()
   usb: phy: omap-usb2: Don't use omap_get_control_dev()
   usb: phy: omap-usb3: Don't use omap_get_control_dev()
   usb: musb: omap2430: Don't use omap_get_control_dev()
   usb: phy: omap: get rid of omap_get_control_dev()
   ARM: dts: omap4: update omap-control-usb nodes
   ARM: dts: omap5: update omap-control-usb node
 
  Documentation/devicetree/bindings/usb/omap-usb.txt |   23 ++--
  arch/arm/boot/dts/omap4.dtsi   |   17 ++-
  arch/arm/boot/dts/omap5.dtsi   |   18 ++-
  drivers/usb/musb/omap2430.c|   22 +++-
  drivers/usb/phy/phy-omap-control.c |  160 ++-
  drivers/usb/phy/phy-omap-usb2.c|   20 ++-
  drivers/usb/phy/phy-omap-usb3.c|   26 +++-
  include/linux/usb/omap_control_usb.h   |   23 +--
  8 files changed, 182 insertions(+), 127 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: [PATCH 6/7] ARM: dts: omap4: update omap-control-usb nodes

2013-08-14 Thread Roger Quadros
+Benoit

On 08/01/2013 05:05 PM, Roger Quadros wrote:
 Split otghs_ctrl and USB2 PHY power down into separate
 omap-control-usb nodes. Update ti,mode property.
 
 CC: Benoit Cousson benoit.cous...@linaro.org
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  arch/arm/boot/dts/omap4.dtsi |   17 -
  1 files changed, 12 insertions(+), 5 deletions(-)
 
 diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
 index 22d9f2b..9a6fa27 100644
 --- a/arch/arm/boot/dts/omap4.dtsi
 +++ b/arch/arm/boot/dts/omap4.dtsi
 @@ -519,7 +519,7 @@
   usb2_phy: usb2phy@4a0ad080 {
   compatible = ti,omap-usb2;
   reg = 0x4a0ad080 0x58;
 - ctrl-module = omap_control_usb;
 + ctrl-module = omap_control_usb2phy;
   };
   };
  
 @@ -643,11 +643,17 @@
   };
   };
  
 - omap_control_usb: omap-control-usb@4a002300 {
 + omap_control_usb2phy: omap-control-usb@4a002300 {
   compatible = ti,omap-control-usb;
 - reg = 0x4a002300 0x4,
 -   0x4a00233c 0x4;
 - reg-names = control_dev_conf, otghs_control;
 + reg = 0x4a002300 0x4;
 + reg-names = power;
 + ti,type = 2;
 + };
 +
 + omap_control_usbotg: omap-control-usb@4a00233c {
 + compatible = ti,omap-control-usb;
 + reg = 0x4a00233c 0x4;
 + reg-names = otghs_control;
   ti,type = 1;
   };
  
 @@ -662,6 +668,7 @@
   num-eps = 16;
   ram-bits = 12;
   ti,has-mailbox;
 + ctrl-module = omap_control_usbotg;
   };
   };
  };
 

--
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 7/7] ARM: dts: omap5: update omap-control-usb node

2013-08-14 Thread Roger Quadros
+Benoit

On 08/01/2013 05:05 PM, Roger Quadros wrote:
 Split USB2 PHY and USB3 PHY into separate omap-control-usb
 nodes. Update ti,mode property.
 
 CC: Benoit Cousson benoit.cous...@linaro.org
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
  arch/arm/boot/dts/omap5.dtsi |   18 --
  1 files changed, 12 insertions(+), 6 deletions(-)
 
 diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
 index 07be2cd..af8ef77 100644
 --- a/arch/arm/boot/dts/omap5.dtsi
 +++ b/arch/arm/boot/dts/omap5.dtsi
 @@ -626,14 +626,20 @@
   hw-caps-temp-alert;
   };
  
 - omap_control_usb: omap-control-usb@4a002300 {
 + omap_control_usb2phy: omap-control-usb@4a002300 {
   compatible = ti,omap-control-usb;
 - reg = 0x4a002300 0x4,
 -   0x4a002370 0x4;
 - reg-names = control_dev_conf, phy_power_usb;
 + reg = 0x4a002300 0x4;
 + reg-names = power;
   ti,type = 2;
   };
  
 + omap_control_usb3phy: omap-control-usb@0x4a002370 {
 + compatible = ti,omap-control-usb;
 + reg = 0x4a002370 0x4;
 + reg-names = power;
 + ti,type = 3;
 + };
 +
   omap_dwc3@4a02 {
   compatible = ti,dwc3;
   ti,hwmods = usb_otg_ss;
 @@ -661,7 +667,7 @@
   usb2_phy: usb2phy@4a084000 {
   compatible = ti,omap-usb2;
   reg = 0x4a084000 0x7c;
 - ctrl-module = omap_control_usb;
 + ctrl-module = omap_control_usb2phy;
   };
  
   usb3_phy: usb3phy@4a084400 {
 @@ -670,7 +676,7 @@
 0x4a084800 0x64,
 0x4a084c00 0x40;
   reg-names = phy_rx, phy_tx, pll_ctrl;
 - ctrl-module = omap_control_usb;
 + ctrl-module = omap_control_usb3phy;
   };
   };
  
 

--
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


USB suspend/resume sequence

2013-08-14 Thread Vivek Gautam
Hi all,


Going through the power suspend/resume sequence of USB, got hit by a doubt.

I am not able to figure out how the USB core driver takes care of
devices and root-hubs across suspend/resume. Are the device contexts
saved somewhere and then restored back on resume ?
How does the suspend/resume sequence taken care by drivers/usb/core/.. ?

One more question here:
If a hub on USB bus is getting re-enumerated, is it really necessary
that its child devices shall also be re-enumerated ? Is there someway
out in which we can save the child-devices' context pointers and then
once hub has been re-enumerated back, we restore back them.

Can someone please give some pointers on this.

Thanks!!


-- 
Best Regards
Vivek
--
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 suspend/resume sequence

2013-08-14 Thread Vivek Gautam
CCing myself

On Wed, Aug 14, 2013 at 1:24 PM, Vivek Gautam gautamvivek1...@gmail.com wrote:
 Hi all,


 Going through the power suspend/resume sequence of USB, got hit by a doubt.

 I am not able to figure out how the USB core driver takes care of
 devices and root-hubs across suspend/resume. Are the device contexts
 saved somewhere and then restored back on resume ?
 How does the suspend/resume sequence taken care by drivers/usb/core/.. ?

 One more question here:
 If a hub on USB bus is getting re-enumerated, is it really necessary
 that its child devices shall also be re-enumerated ? Is there someway
 out in which we can save the child-devices' context pointers and then
 once hub has been re-enumerated back, we restore back them.

 Can someone please give some pointers on this.

 Thanks!!


 --
 Best Regards
 Vivek



-- 
Best Regards
Vivek
--
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] usb: musb: cppi41: Enable in device-TX mode

2013-08-14 Thread Sebastian Andrzej Siewior
On 08/13/2013 11:19 PM, Felipe Balbi wrote:
 true, I'm sure Sebastian has plans on adding RX support, but only
 after he knows it's working fine ;-)

I actually have none. I am not sure how likely it is that this bug will
trigger in device I just have the errata. Usually there is at least one
customer hitting it in the field :)

Saying that I would prefer the PG check for v3.13.

Sebastian
--
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: WUSBCORE: clear RPIPE stall for control endpoints

2013-08-14 Thread Oliver Neukum
On Tue, 2013-08-13 at 11:40 -0500, Thomas Pugliese wrote:
  static void wa_xfer_result_chew(struct wahc *wa, struct wa_xfer
 *xfer)
  {
 @@ -1488,17 +1532,38 @@ error_submit_buf_in:
 seg-result = result;
 kfree(wa-buf_in_urb-sg);
  error_sg_alloc:
 +   __wa_xfer_abort(xfer);
  error_complete:
 seg-status = WA_SEG_ERROR;
 xfer-segs_done++;
 rpipe_ready = rpipe_avail_inc(rpipe);
 -   __wa_xfer_abort(xfer);
 done = __wa_xfer_is_done(xfer);
 -   spin_unlock_irqrestore(xfer-lock, flags);
 -   if (done)
 -   wa_xfer_completion(xfer);
 -   if (rpipe_ready)
 -   wa_xfer_delayed_run(rpipe);
 +   /*
 +* queue work item to clear STALL for control endpoints.
 +* Otherwise, let endpoint_reset take care of it.
 +*/
 +   if (((usb_status  0x3f) == WA_XFER_STATUS_HALTED) 
 +   usb_endpoint_xfer_control(xfer-ep-desc) 
 +   done) {
 +   unsigned long flags2;
 +
 +   dev_info(dev, Control EP stall.  Queue delayed
 work.\n);
 +   spin_lock_irqsave(wa-xfer_list_lock, flags2);
 +   /* remove xfer from xfer_list. */
 +   list_del(xfer-list_node);
 +   /* add xfer to xfer_errored_list. */
 +   list_add_tail(xfer-list_node,
 wa-xfer_errored_list);
 +   spin_unlock_irqrestore(wa-xfer_list_lock, flags2);
 +   spin_unlock_irqrestore(xfer-lock, flags);


Hi,

there is no use in taking irqsave spinlocks in a nested manner.
Just do:

spin_lock_irqsave()
spin_lock()

spin_unlock()
spin_unlock_irqrestore()

Regards
Oliver


--
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] xhci: Fix race between ep halt and URB cancellation

2013-08-14 Thread Florian Wolter
The halted state of a endpoint cannot be cleared over CLEAR_HALT from a
user process, because the stopped_td variable was overwritten in the 
handle_stopped_endpoint() function. So the xhci_endpoint_reset() function will 
refuse the reset and communication with device can not run over this endpoint.
https://bugzilla.kernel.org/show_bug.cgi?id=60699


Signed-off-by: Florian Wolter woll...@web.de
---
 drivers/usb/host/xhci-ring.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 5b08cd8..c2daaf7 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -847,8 +847,12 @@ remove_finished_td:
/* Otherwise ring the doorbell(s) to restart queued transfers */
ring_doorbell_for_active_rings(xhci, slot_id, ep_index);
}
-   ep-stopped_td = NULL;
-   ep-stopped_trb = NULL;
+
+   /* Clear stopped_td and stopped_trb if endpoint is not halted */
+   if (!(ep-ep_state  EP_HALTED)) {
+   ep-stopped_td = NULL;
+   ep-stopped_trb = NULL;
+   }
 
/*
 * Drop the lock and complete the URBs in the cancelled TD list.
-- 
1.7.10.4

--
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, FOR LINUX-OMAP] usb: nop phy rename

2013-08-14 Thread Tony Lindgren
* Felipe Balbi ba...@ti.com [130809 07:35]:
 Hi Tony,
 
 here's a pull request of one patch to avoid conflicts during the merge
 window.
 
 Please consider applying to your tree and I'll take this same patch
 upstream.

Thanks, pulling into omap-for-v3.12/usb.

Regards,

Tony
 
 The following changes since commit 5ae90d8e467e625e447000cb4335c4db973b1095:
 
   Linux 3.11-rc3 (2013-07-28 20:53:33 -0700)
 
 are available in the git repository at:
 
   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git nop-phy-rename
 
 for you to fetch changes up to 3fa4d7344be0afebd80382ffeea6b1787cccf971:
 
   usb: phy: rename nop_usb_xceiv = usb_phy_gen_xceiv (2013-08-09 17:26:00 
 +0300)
 
 
 Sebastian Andrzej Siewior (1):
   usb: phy: rename nop_usb_xceiv = usb_phy_gen_xceiv
 
  arch/arm/mach-omap2/board-omap3beagle.c|  4 +-
  arch/arm/mach-omap2/board-omap3evm.c   |  4 +-
  arch/arm/mach-omap2/board-omap3pandora.c   |  2 +-
  arch/arm/mach-omap2/usb-host.c | 10 ++---
  drivers/usb/dwc3/dwc3-exynos.c |  8 ++--
  drivers/usb/dwc3/dwc3-pci.c|  8 ++--
  drivers/usb/musb/am35x.c   |  2 +-
  drivers/usb/musb/blackfin.c|  2 +-
  drivers/usb/musb/da8xx.c   |  2 +-
  drivers/usb/musb/davinci.c |  2 +-
  drivers/usb/musb/musb_dsps.c   |  2 +-
  drivers/usb/musb/tusb6010.c|  2 +-
  drivers/usb/phy/Makefile   |  2 +-
  drivers/usb/phy/{phy-nop.c = phy-generic.c}   | 44 
 +++---
  .../usb/{nop-usb-xceiv.h = usb_phy_gen_xceiv.h}   |  4 +-
  15 files changed, 49 insertions(+), 49 deletions(-)
  rename drivers/usb/phy/{phy-nop.c = phy-generic.c} (83%)
  rename include/linux/usb/{nop-usb-xceiv.h = usb_phy_gen_xceiv.h} (81%)
 
 -- 
 balbi


--
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 6/7] ARM: dts: omap4: update omap-control-usb nodes

2013-08-14 Thread Benoit Cousson
Hi Roger,

On 01/08/2013 16:05, Roger Quadros wrote:
 Split otghs_ctrl and USB2 PHY power down into separate
 omap-control-usb nodes. Update ti,mode property.

Nit: I guess you mean ti,type?

 CC: Benoit Cousson benoit.cous...@linaro.org
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
   arch/arm/boot/dts/omap4.dtsi |   17 -
   1 files changed, 12 insertions(+), 5 deletions(-)
 
 diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
 index 22d9f2b..9a6fa27 100644
 --- a/arch/arm/boot/dts/omap4.dtsi
 +++ b/arch/arm/boot/dts/omap4.dtsi
 @@ -519,7 +519,7 @@
   usb2_phy: usb2phy@4a0ad080 {
   compatible = ti,omap-usb2;
   reg = 0x4a0ad080 0x58;
 - ctrl-module = omap_control_usb;
 + ctrl-module = omap_control_usb2phy;
   };
   };
   
 @@ -643,11 +643,17 @@
   };
   };
   
 - omap_control_usb: omap-control-usb@4a002300 {
 + omap_control_usb2phy: omap-control-usb@4a002300 {
   compatible = ti,omap-control-usb;
 - reg = 0x4a002300 0x4,
 -   0x4a00233c 0x4;
 - reg-names = control_dev_conf, otghs_control;
 + reg = 0x4a002300 0x4;
 + reg-names = power;
 + ti,type = 2;

Now that we can use the C preprocessor, it will be nice to use a macro instead 
of the value.

TYPE1 - if it has otghs_control mailbox register (e.g. on OMAP4)
TYPE2 - if it has Power down bit in control_dev_conf register. e.g. USB2 PHY
TYPE3 - if it has DPLL and individual Rx  Tx power control. e.g. USB3 PHY or 
SATA PHY
TYPE4 - if it has both power down and power aux registers. e.g. USB2 PHY on DRA7

Well, assuming you can find macro names that can explain a little bit what the 
type is about :-)

That being said...
Do you really need to expose the type here? Maybe with just a set of different 
compatible string you can figure out in the driver what type we are talking 
about.
It is always better to minimize the amount of information we put in DT as soon 
as we can infer it from the compatible string.

So instead of using a generic ti,omap-control-usb string + ti,type you can 
potentially use several specific strings: ti,omap4-control-usb, 
ti,dra7-control-usb...
Since the DT gurus are recommending to use specific compatible string as much 
as possible, this is maybe a better approach.

Regards,
Benoit

--
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 suspend/resume sequence

2013-08-14 Thread Oliver Neukum
On Wed, 2013-08-14 at 13:24 +0530, Vivek Gautam wrote:
 Hi all,
 
 
 Going through the power suspend/resume sequence of USB, got hit by a doubt.
 
 I am not able to figure out how the USB core driver takes care of

It doesn't.

 devices and root-hubs across suspend/resume. Are the device contexts
 saved somewhere and then restored back on resume ?

Usually not. The state of interfaces are the responsibility of interface
drivers (colloquially called device drivers). Most devices just don't
offer an API for saving state. The drivers recreate as opposed to
restore the state.

 How does the suspend/resume sequence taken care by drivers/usb/core/.. ?

The generic driver core guarantees that suspend()/resume() are called
in the right sequence.

 One more question here:
 If a hub on USB bus is getting re-enumerated, is it really necessary
 that its child devices shall also be re-enumerated ? Is there someway

Yes.

 out in which we can save the child-devices' context pointers and then
 once hub has been re-enumerated back, we restore back them.

How do you know they are identical?

HTH
Oliver


--
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: add two quirky touchscreen

2013-08-14 Thread oliver
From: Oliver Neukum oneu...@suse.de

These devices tend to become unresponsive after S3

Signed-off-by: Oliver Neukum oneu...@suse.de
CC: sta...@vger.kernel.org
---
 drivers/usb/core/quirks.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index a635988..5b44cd4 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -78,6 +78,12 @@ static const struct usb_device_id usb_quirk_list[] = {
{ USB_DEVICE(0x04d8, 0x000c), .driver_info =
USB_QUIRK_CONFIG_INTF_STRINGS },
 
+   /* CarrolTouch 4000U */
+   { USB_DEVICE(0x04e7, 0x0009), .driver_info = USB_QUIRK_RESET_RESUME },
+
+   /* CarrolTouch 4500U */
+   { USB_DEVICE(0x04e7, 0x0030), .driver_info = USB_QUIRK_RESET_RESUME },
+
/* Samsung Android phone modem - ID conflict with SPH-I500 */
{ USB_DEVICE(0x04e8, 0x6601), .driver_info =
USB_QUIRK_CONFIG_INTF_STRINGS },
-- 
1.8.3.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 6/7] ARM: dts: omap4: update omap-control-usb nodes

2013-08-14 Thread Roger Quadros
On 08/14/2013 11:41 AM, Benoit Cousson wrote:
 Hi Roger,
 
 On 01/08/2013 16:05, Roger Quadros wrote:
 Split otghs_ctrl and USB2 PHY power down into separate
 omap-control-usb nodes. Update ti,mode property.
 
 Nit: I guess you mean ti,type?

Right :).

 
 CC: Benoit Cousson benoit.cous...@linaro.org
 Signed-off-by: Roger Quadros rog...@ti.com
 ---
   arch/arm/boot/dts/omap4.dtsi |   17 -
   1 files changed, 12 insertions(+), 5 deletions(-)

 diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
 index 22d9f2b..9a6fa27 100644
 --- a/arch/arm/boot/dts/omap4.dtsi
 +++ b/arch/arm/boot/dts/omap4.dtsi
 @@ -519,7 +519,7 @@
  usb2_phy: usb2phy@4a0ad080 {
  compatible = ti,omap-usb2;
  reg = 0x4a0ad080 0x58;
 -ctrl-module = omap_control_usb;
 +ctrl-module = omap_control_usb2phy;
  };
  };
   
 @@ -643,11 +643,17 @@
  };
  };
   
 -omap_control_usb: omap-control-usb@4a002300 {
 +omap_control_usb2phy: omap-control-usb@4a002300 {
  compatible = ti,omap-control-usb;
 -reg = 0x4a002300 0x4,
 -  0x4a00233c 0x4;
 -reg-names = control_dev_conf, otghs_control;
 +reg = 0x4a002300 0x4;
 +reg-names = power;
 +ti,type = 2;
 
 Now that we can use the C preprocessor, it will be nice to use a macro 
 instead of the value.
 
 TYPE1 - if it has otghs_control mailbox register (e.g. on OMAP4)
 TYPE2 - if it has Power down bit in control_dev_conf register. e.g. USB2 PHY
 TYPE3 - if it has DPLL and individual Rx  Tx power control. e.g. USB3 PHY or 
 SATA PHY
 TYPE4 - if it has both power down and power aux registers. e.g. USB2 PHY on 
 DRA7
 
 Well, assuming you can find macro names that can explain a little bit what 
 the type is about :-)
 
 That being said...
 Do you really need to expose the type here? Maybe with just a set of 
 different compatible string you can figure out in the driver what type we are 
 talking about.
 It is always better to minimize the amount of information we put in DT as 
 soon as we can infer it from the compatible string.
 
 So instead of using a generic ti,omap-control-usb string + ti,type you 
 can potentially use several specific strings: ti,omap4-control-usb, 
 ti,dra7-control-usb...
 Since the DT gurus are recommending to use specific compatible string as much 
 as possible, this is maybe a better approach.
 

Good point. I'll get rid of the type altogether and use the compatible string 
instead.

cheers,
-roger
--
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 29/29] usb: dwc3: omap: simplify use of devm_ioremap_resource

2013-08-14 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Remove unneeded error handling on the result of a call to
platform_get_resource when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) }
  ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  e = devm_ioremap_resource(e1, res);
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/usb/dwc3/dwc3-omap.c |5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 7f7ea62..cbcd972 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -432,11 +432,6 @@ static int dwc3_omap_probe(struct platform_device *pdev)
}
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   dev_err(dev, missing memory base resource\n);
-   return -EINVAL;
-   }
-
base = devm_ioremap_resource(dev, res);
if (IS_ERR(base))
return PTR_ERR(base);

--
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 suspend/resume sequence

2013-08-14 Thread Vivek Gautam
Hi Oliver,


On Wed, Aug 14, 2013 at 2:19 PM, Oliver Neukum oneu...@suse.de wrote:

Thanks for you response.

 On Wed, 2013-08-14 at 13:24 +0530, Vivek Gautam wrote:
 Hi all,


 Going through the power suspend/resume sequence of USB, got hit by a doubt.

 I am not able to figure out how the USB core driver takes care of

 It doesn't.

 devices and root-hubs across suspend/resume. Are the device contexts
 saved somewhere and then restored back on resume ?

 Usually not. The state of interfaces are the responsibility of interface
 drivers (colloquially called device drivers). Most devices just don't
 offer an API for saving state. The drivers recreate as opposed to
 restore the state.

How does then PERSIST_ENABLED option work then ? With this option enabled,
on a system resume, the USB device attached to the root-hub are not
re-enumerated, right ?
Possibly i am getting confused here.
How would a usb_suspend_interface() and usb_suspend_device() differ.


 How does the suspend/resume sequence taken care by drivers/usb/core/.. ?

 The generic driver core guarantees that suspend()/resume() are called
 in the right sequence.

 One more question here:
 If a hub on USB bus is getting re-enumerated, is it really necessary
 that its child devices shall also be re-enumerated ? Is there someway

 Yes.

 out in which we can save the child-devices' context pointers and then
 once hub has been re-enumerated back, we restore back them.

 How do you know they are identical?

Is it that, from the interface only the device information is extracted ?
Can't we catch hold of usb_device pointers of hub and child devices ?


 HTH
 Oliver





-- 
Best Regards
Vivek
--
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 0/1] Documentation sysfs-bus-usb: Document all files used by libusb v3

2013-08-14 Thread Hans de Goede
Hi All,

This patch adds documentation for all sysfs files used by libusb.

Changes in v2:
-Spelling fixes
-Add text about writing to bConfigurationValue, suggested by Alan Stern

Changes in v3:
-Rebase on latest usb-next

Regards,

Hans
--
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] Documentation sysfs-bus-usb: Document all files used by libusb

2013-08-14 Thread Hans de Goede
Signed-off-by: Hans de Goede hdego...@redhat.com
---
 Documentation/ABI/testing/sysfs-bus-usb | 38 +
 1 file changed, 38 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
b/Documentation/ABI/testing/sysfs-bus-usb
index 9c8926c..b0b9bb4 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -263,3 +263,41 @@ Description:
Supported values are 0 - 15.
More information on how besl values map to microseconds can be 
found in
USB 2.0 ECN Errata for Link Power Management, section 4.10)
+
+What:  /sys/bus/usb/devices/.../devnum
+KernelVersion: since at least 2.6.18
+Description:
+   Device address on the USB bus.
+
+What:  /sys/bus/usb/devices/.../bConfigurationValue
+KernelVersion: since at least 2.6.18
+Description:
+   bConfigurationValue of the *active* configuration for the
+   device. Writing 0 or -1 to bConfigurationValue will reset the
+   active configuration (unconfigure the device). Writing
+   another value will change the active configuration.
+
+   Note that some devices, in violation of the USB spec, have a
+   configuration with a value equal to 0. Writing 0 to
+   bConfigurationValue for these devices will install that
+   configuration, rather then unconfigure the device.
+
+   Writing -1 will always unconfigure the device.
+
+What:  /sys/bus/usb/devices/.../busnum
+KernelVersion: 2.6.22
+Description:
+   Bus-number of the USB-bus the device is connected to.
+
+What:  /sys/bus/usb/devices/.../descriptors
+KernelVersion: 2.6.26
+Description:
+   Binary file containing cached descriptors of the device. The
+   binary data consists of first the device descriptor, and when
+   the descriptors for each configuration of the device.
+   Note that the wTotalLength of the config descriptors can not
+   be trusted, as the device may have a smaller config descriptor
+   than it advertises. The bLength field of each (sub) descriptor
+   can be trusted, and can be used to seek forward one (sub)
+   descriptor at a time until the next config descriptor is found.
+   All descriptors read from this file are in bus-endian format
-- 
1.8.3.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 0/29] simplify use of devm_ioremap_resource

2013-08-14 Thread Julia Lawall
devm_ioremap_resource often uses the result of a call to
platform_get_resource as its last argument.  devm_ioremap_resource does
appropriate error handling on this argument, so error handling can be
removed from the call site.  To make the connection between the call to
platform_get_resource and the call to devm_ioremap_resource more clear, the
former is also moved down to be adjacent to the latter.

In many cases, this patch changes the specific error value that is
returned on failure of platform_get_resource.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

(
  res = platform_get_resource(pdev, IORESOURCE_MEM, n);
- if (res == NULL) { ... \(goto l;\|return ret;\) }
  e = devm_ioremap_resource(e1, res);
|
- res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) }
  ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  e = devm_ioremap_resource(e1, res);
)
// /smpl

--
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: [RFC 2/2] usb: dwc3: Add Qualcomm DWC3 glue layer driver

2013-08-14 Thread Ivan T. Ivanov

Hi, 

On Mon, 2013-08-12 at 13:24 -0500, Felipe Balbi wrote: 
 On Fri, Aug 09, 2013 at 07:09:18PM +0300, Ivan T. Ivanov wrote:
  Hi, 
  
  On Fri, 2013-08-09 at 16:23 +0300, Felipe Balbi wrote:
   Hi,
   
   On Tue, Aug 06, 2013 at 02:53:11PM +0300, Ivan T. Ivanov wrote:
diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c
new file mode 100644
index 000..e509abc
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-msm.c
@@ -0,0 +1,175 @@
+#undef CONFIG_REGULATOR
   
   why ??
   
  
  1. This shows that driver is still not fully tested 
 Regulators support is still missing in the MSM
  2. Helps me to load driver successfully. 
 
 Then remove all the regulator-related code from this.

I would like to keep them. I will just remove #undef line. 
Code will continue to build fine. And once regulators drivers 
are upstreamed this driver 'will not' require further
modifications.

 
+   clk_prepare_enable(mdwc-core_clk);
+   clk_prepare_enable(mdwc-iface_clk);
+   clk_prepare_enable(mdwc-sleep_clk);
+   clk_prepare_enable(mdwc-utmi_clk);
   
   do you really need to enable your clocks here ? Why don't you enable
   them on runtime_resume and disable on runtime_suspend ?
  
  I will like to make it working first and then will improve
  power management.
 
 alright, makes sense.
 
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   tcsr = devm_ioremap_resource(pdev-dev, res);
+   if (!tcsr) {
+   dev_dbg(pdev-dev, tcsr ioremap failed\n);
   
   no need to ioremap, also you're likely leaking clocks and regulators
   enabled here.
   
   Make sure to have something like:
   
 if (!tcsr)
 goto err_disable_clocks;
   
 /* TODO This has to be revised */\
   
 [...]
   
  
  Sure.
 
 just to make it clear, I meant to say that you don't need to print the
 error message :-)

Yes. I got it.

Regards,
Ivan


--
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 1/6] usb: phy-nop: Use RESET Controller for managing the reset line

2013-08-14 Thread Roger Quadros
Hi Felipe,

On 07/25/2013 08:28 PM, Felipe Balbi wrote:
 On Thu, Jul 18, 2013 at 11:53:05AM +0300, Roger Quadros wrote:
 Till now we were modelling the RESET line as a voltage regulator and
 using the regulator framework to manage it.

 [1] introduces a GPIO based reset controller driver. We use that
 to manage the PHY reset line, at least for DT boots. For legacy boots,
 will still need to use the regulator framework for reset lines.

 [1] - http://thread.gmane.org/gmane.linux.drivers.devicetree/41348

 Signed-off-by: Roger Quadros rog...@ti.com
 
 that's not in mainline yet, right ? Is it guaranteed that it will hit
 v3.12 merge window ?
 

Looks like the gpio reset driver might not make it into 3.12.

Now we have two options. 

1) leave the nop-phy driver as it is
2) get rid of using regulator framework for reset line and handle the reset
gpio directly in the nop-phy driver.

Is it already too late to get (2) into 3.12 if I send the patches in a day or 2?

cheers,
-roger

--
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: [RFC 2/2] usb: dwc3: Add Qualcomm DWC3 glue layer driver

2013-08-14 Thread Ivan T. Ivanov
Hi, 

On Fri, 2013-08-09 at 16:23 +0300, Felipe Balbi wrote:

snip

 
  +   /*
  +* DWC3 Core requires its CORE CLK (aka master / bus clk) to
  +* run at 125Mhz in SSUSB mode and 60MHZ for HSUSB mode.
  +*/
  +   clk_set_rate(mdwc-core_clk, 12500);
 
 if this is dwc3's core clock, why don't we teach dwc3.ko about this
 requirement ? Just make sure to have it optional, since x86 and OMAP
 wouldn't need direct fiddling with the clocks.

I believe this is Qualcomm specific requirement. Something is modified
inside DWC in respect of the clocks. I will like to keep this here, in
the glue layer driver.

Regards,
Ivan


--
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 00/22] usb: chipidea: updates for v3.12

2013-08-14 Thread Alexander Shishkin
Hi,

These are chipidea patches for v3.12. The highlight of the series is
vbus detection support. Other than that, a few cleanups and fixes,
mostly concerning imx platforms. Everything is sparse, smatch and
coccinelle clean and bisectable.

Fabio Estevam (3):
  usb: chipidea: ci_hdrc_imx: remove unused variable 'res'
  usb: chipidea: move hw_phymode_configure() into probe
  usb: chipidea: remove previous MODULE_ALIAS

Lothar Waßmann (4):
  usb: chipidea: improve kconfig 2.0
  usb: chipidea: ci_hdrc_imx: remove an unsolicited module_put() call
from ci_hdrc_imx_remove()
  usb: chipidea: don't clobber return value of ci_role_start()
  usb: chipidea: prevent endless loop registering platform_devices when
probe fails

Peter Chen (14):
  usb: chipidea: imx: delete the dead code
  usb: chipidea: move vbus regulator operation to core
  usb: chipidea: host: add vbus regulator control
  usb: chipidea: udc: otg_set_peripheral is useless for some chipidea
users
  usb: chipidea: otg: add otg file used to access otgsc
  usb: chipidea: add role init and destroy APIs
  usb: chipidea: add flag CI_HDRC_DUAL_ROLE_NOT_OTG
  usb: chipidea: disable all interrupts and clear all interrupts status
  usb: chipidea: move otg related things to otg file
  usb: chipidea: add vbus interrupt handler
  usb: chipidea: add wait vbus lower than OTGSC_BSV before role starts
  usb: chipidea: udc: fix misuse of REGS_SHARED and PULLUP_ON_VBUS flags
  usb: chipidea: retire flag CI_HDRC_PULLUP_ON_VBUS
  usb: chipidea: udc: .pullup is valid only when vbus is there

Sascha Hauer (1):
  USB: chipidea: i.MX: simplify usbmisc

 drivers/usb/chipidea/Kconfig   |   7 +-
 drivers/usb/chipidea/Makefile  |   2 +-
 drivers/usb/chipidea/bits.h|  10 ++
 drivers/usb/chipidea/ci.h  |   8 ++
 drivers/usb/chipidea/ci_hdrc_imx.c | 110 +++--
 drivers/usb/chipidea/ci_hdrc_imx.h |  17 +---
 drivers/usb/chipidea/ci_hdrc_msm.c |   1 -
 drivers/usb/chipidea/core.c| 197 +
 drivers/usb/chipidea/host.c|  30 +-
 drivers/usb/chipidea/host.h|   6 ++
 drivers/usb/chipidea/otg.c | 120 ++
 drivers/usb/chipidea/otg.h |  35 +++
 drivers/usb/chipidea/udc.c |  78 +--
 drivers/usb/chipidea/udc.h |   6 ++
 drivers/usb/chipidea/usbmisc_imx.c |  95 --
 include/linux/usb/chipidea.h   |   7 +-
 16 files changed, 485 insertions(+), 244 deletions(-)
 create mode 100644 drivers/usb/chipidea/otg.c
 create mode 100644 drivers/usb/chipidea/otg.h

-- 
1.8.4.rc2

--
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/22] usb: chipidea: move hw_phymode_configure() into probe

2013-08-14 Thread Alexander Shishkin
From: Fabio Estevam fabio.este...@freescale.com

Currently hw_phymode_configure() is located inside hw_device_reset(), which is
only called by chipidea udc driver.

When operating in host mode, we also need to call hw_phymode_configure() in
order to properly configure the PHY mode, so move this function into probe.

After this change, USB Host1 port on mx53qsb board is functional.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
Tested-by: Arnaud Patard arnaud.pat...@rtp-net.org
Reviewed-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index a5df24c..a5b3774 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -264,8 +264,6 @@ int hw_device_reset(struct ci_hdrc *ci, u32 mode)
while (hw_read(ci, OP_USBCMD, USBCMD_RST))
udelay(10); /* not RTOS friendly */
 
-   hw_phymode_configure(ci);
-
if (ci-platdata-notify_event)
ci-platdata-notify_event(ci,
CI_HDRC_CONTROLLER_RESET_EVENT);
@@ -457,6 +455,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
if (!ci-platdata-phy_mode)
ci-platdata-phy_mode = of_usb_get_phy_mode(dev-of_node);
 
+   hw_phymode_configure(ci);
+
if (!ci-platdata-dr_mode)
ci-platdata-dr_mode = of_usb_get_dr_mode(dev-of_node);
 
-- 
1.8.4.rc2

--
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/22] usb: chipidea: ci_hdrc_imx: remove unused variable 'res'

2013-08-14 Thread Alexander Shishkin
From: Fabio Estevam fabio.este...@freescale.com

'res' is not used anywhere, so let's get rid of it.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
Acked-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index 14362c0..06bc775 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -96,7 +96,6 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
  CI_HDRC_PULLUP_ON_VBUS |
  CI_HDRC_DISABLE_STREAMING,
};
-   struct resource *res;
int ret;
 
if (of_find_property(pdev-dev.of_node, fsl,usbmisc, NULL)
@@ -109,12 +108,6 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
-   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!res) {
-   dev_err(pdev-dev, Can't get device resources!\n);
-   return -ENOENT;
-   }
-
data-clk = devm_clk_get(pdev-dev, NULL);
if (IS_ERR(data-clk)) {
dev_err(pdev-dev,
-- 
1.8.4.rc2

--
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/22] usb: chipidea: ci_hdrc_imx: remove an unsolicited module_put() call from ci_hdrc_imx_remove()

2013-08-14 Thread Alexander Shishkin
From: Lothar Waßmann l...@karo-electronics.de

This prevents the USB PHY refcount to be decremented below zero upon
unloading the ci-hdrc-imx module.

Signed-off-by: Lothar Waßmann l...@karo-electronics.de
Acked-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index a9a3bcf..005ad5f 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -208,10 +208,8 @@ static int ci_hdrc_imx_remove(struct platform_device *pdev)
if (data-reg_vbus)
regulator_disable(data-reg_vbus);
 
-   if (data-phy) {
+   if (data-phy)
usb_phy_shutdown(data-phy);
-   module_put(data-phy-dev-driver-owner);
-   }
 
clk_disable_unprepare(data-clk);
 
-- 
1.8.4.rc2

--
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/22] usb: chipidea: move vbus regulator operation to core

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

The vbus regulator is a common element for USB vbus operation,
So, move it from glue layer to core.

Tested-by: Marek Vasut ma...@denx.de
Signed-off-by: Michael Grzeschik m.grzesc...@pengutronix.de
Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 26 ++
 drivers/usb/chipidea/core.c| 23 +++
 include/linux/usb/chipidea.h   |  1 +
 3 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index 005ad5f..30fdc2f 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -19,7 +19,6 @@
 #include linux/dma-mapping.h
 #include linux/usb/chipidea.h
 #include linux/clk.h
-#include linux/regulator/consumer.h
 
 #include ci.h
 #include ci_hdrc_imx.h
@@ -28,7 +27,6 @@ struct ci_hdrc_imx_data {
struct usb_phy *phy;
struct platform_device *ci_pdev;
struct clk *clk;
-   struct regulator *reg_vbus;
 };
 
 static const struct usbmisc_ops *usbmisc_ops;
@@ -131,20 +129,6 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
goto err_clk;
}
 
-   /* we only support host now, so enable vbus here */
-   data-reg_vbus = devm_regulator_get(pdev-dev, vbus);
-   if (!IS_ERR(data-reg_vbus)) {
-   ret = regulator_enable(data-reg_vbus);
-   if (ret) {
-   dev_err(pdev-dev,
-   Failed to enable vbus regulator, err=%d\n,
-   ret);
-   goto err_clk;
-   }
-   } else {
-   data-reg_vbus = NULL;
-   }
-
pdata.phy = data-phy;
 
if (!pdev-dev.dma_mask)
@@ -157,7 +141,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
if (ret) {
dev_err(pdev-dev,
usbmisc init failed, ret=%d\n, ret);
-   goto err;
+   goto err_clk;
}
}
 
@@ -169,7 +153,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
dev_err(pdev-dev,
Can't register ci_hdrc platform device, err=%d\n,
ret);
-   goto err;
+   goto err_clk;
}
 
if (usbmisc_ops  usbmisc_ops-post) {
@@ -190,9 +174,6 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 
 disable_device:
ci_hdrc_remove_device(data-ci_pdev);
-err:
-   if (data-reg_vbus)
-   regulator_disable(data-reg_vbus);
 err_clk:
clk_disable_unprepare(data-clk);
return ret;
@@ -205,9 +186,6 @@ static int ci_hdrc_imx_remove(struct platform_device *pdev)
pm_runtime_disable(pdev-dev);
ci_hdrc_remove_device(data-ci_pdev);
 
-   if (data-reg_vbus)
-   regulator_disable(data-reg_vbus);
-
if (data-phy)
usb_phy_shutdown(data-phy);
 
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 5bb3e81..13dbd51 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -65,6 +65,7 @@
 #include linux/usb/chipidea.h
 #include linux/usb/of.h
 #include linux/phy.h
+#include linux/regulator/consumer.h
 
 #include ci.h
 #include udc.h
@@ -342,6 +343,24 @@ static irqreturn_t ci_irq(int irq, void *data)
return ret;
 }
 
+static int ci_get_platdata(struct device *dev,
+   struct ci_hdrc_platform_data *platdata)
+{
+   /* Get the vbus regulator */
+   platdata-reg_vbus = devm_regulator_get(dev, vbus);
+   if (PTR_ERR(platdata-reg_vbus) == -EPROBE_DEFER) {
+   return -EPROBE_DEFER;
+   } else if (PTR_ERR(platdata-reg_vbus) == -ENODEV) {
+   platdata-reg_vbus = NULL; /* no vbus regualator is needed */
+   } else if (IS_ERR(platdata-reg_vbus)) {
+   dev_err(dev, Getting regulator error: %ld\n,
+   PTR_ERR(platdata-reg_vbus));
+   return PTR_ERR(platdata-reg_vbus);
+   }
+
+   return 0;
+}
+
 static DEFINE_IDA(ci_ida);
 
 struct platform_device *ci_hdrc_add_device(struct device *dev,
@@ -351,6 +370,10 @@ struct platform_device *ci_hdrc_add_device(struct device 
*dev,
struct platform_device *pdev;
int id, ret;
 
+   ret = ci_get_platdata(dev, platdata);
+   if (ret)
+   return ERR_PTR(ret);
+
id = ida_simple_get(ci_ida, 0, 0, GFP_KERNEL);
if (id  0)
return ERR_PTR(id);
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index 2562994..ce4e1aa 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -24,6 +24,7 @@ struct ci_hdrc_platform_data {
 #define CI_HDRC_CONTROLLER_RESET_EVENT 0
 

[PATCH 20/22] usb: chipidea: retire flag CI_HDRC_PULLUP_ON_VBUS

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

Currently, the controller only runs when the ci-vbus_active is true.
So the flag CI_HDRC_PULLUP_ON_VBUS is useless no longer.
If the user doesn't have otgsc, he/she needs to change ci_handle_vbus_change
to update ci-vbus_active.

Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/ci_hdrc_imx.c |  1 -
 drivers/usb/chipidea/ci_hdrc_msm.c |  1 -
 drivers/usb/chipidea/udc.c | 24 ++--
 include/linux/usb/chipidea.h   |  1 -
 4 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index 30fdc2f..cc53e63 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -88,7 +88,6 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
.name   = ci_hdrc_imx,
.capoffset  = DEF_CAPOFFSET,
.flags  = CI_HDRC_REQUIRE_TRANSCEIVER |
- CI_HDRC_PULLUP_ON_VBUS |
  CI_HDRC_DISABLE_STREAMING,
};
int ret;
diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c 
b/drivers/usb/chipidea/ci_hdrc_msm.c
index fb657ef..2d51d85 100644
--- a/drivers/usb/chipidea/ci_hdrc_msm.c
+++ b/drivers/usb/chipidea/ci_hdrc_msm.c
@@ -49,7 +49,6 @@ static struct ci_hdrc_platform_data ci_hdrc_msm_platdata = {
.name   = ci_hdrc_msm,
.flags  = CI_HDRC_REGS_SHARED |
  CI_HDRC_REQUIRE_TRANSCEIVER |
- CI_HDRC_PULLUP_ON_VBUS |
  CI_HDRC_DISABLE_STREAMING,
 
.notify_event   = ci_hdrc_msm_notify_event,
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 45abf4d..90c3572 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1448,9 +1448,6 @@ static int ci_udc_vbus_session(struct usb_gadget 
*_gadget, int is_active)
unsigned long flags;
int gadget_ready = 0;
 
-   if (!(ci-platdata-flags  CI_HDRC_PULLUP_ON_VBUS))
-   return -EOPNOTSUPP;
-
spin_lock_irqsave(ci-lock, flags);
ci-vbus_active = is_active;
if (ci-driver)
@@ -1635,13 +1632,11 @@ static int ci_udc_start(struct usb_gadget *gadget,
 
ci-driver = driver;
pm_runtime_get_sync(ci-gadget.dev);
-   if (ci-platdata-flags  CI_HDRC_PULLUP_ON_VBUS) {
-   if (ci-vbus_active) {
-   hw_device_reset(ci, USBMODE_CM_DC);
-   } else {
-   pm_runtime_put_sync(ci-gadget.dev);
-   goto done;
-   }
+   if (ci-vbus_active) {
+   hw_device_reset(ci, USBMODE_CM_DC);
+   } else {
+   pm_runtime_put_sync(ci-gadget.dev);
+   goto done;
}
 
retval = hw_device_state(ci, ci-ep0out-qh.dma);
@@ -1664,8 +1659,7 @@ static int ci_udc_stop(struct usb_gadget *gadget,
 
spin_lock_irqsave(ci-lock, flags);
 
-   if (!(ci-platdata-flags  CI_HDRC_PULLUP_ON_VBUS) ||
-   ci-vbus_active) {
+   if (ci-vbus_active) {
hw_device_state(ci, 0);
if (ci-platdata-notify_event)
ci-platdata-notify_event(ci,
@@ -1800,12 +1794,6 @@ static int udc_start(struct ci_hdrc *ci)
}
}
 
-   if (!(ci-platdata-flags  CI_HDRC_PULLUP_ON_VBUS)) {
-   retval = hw_device_reset(ci, USBMODE_CM_DC);
-   if (retval)
-   goto put_transceiver;
-   }
-
if (ci-transceiver) {
retval = otg_set_peripheral(ci-transceiver-otg,
ci-gadget);
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index 10a607c..7d39967 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -18,7 +18,6 @@ struct ci_hdrc_platform_data {
unsigned longflags;
 #define CI_HDRC_REGS_SHAREDBIT(0)
 #define CI_HDRC_REQUIRE_TRANSCEIVERBIT(1)
-#define CI_HDRC_PULLUP_ON_VBUS BIT(2)
 #define CI_HDRC_DISABLE_STREAMING  BIT(3)
/*
 * Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1,
-- 
1.8.4.rc2

--
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 08/22] usb: chipidea: remove previous MODULE_ALIAS

2013-08-14 Thread Alexander Shishkin
From: Fabio Estevam fabio.este...@freescale.com

After the rename to ci_hdrc we ended up with two MODULE_ALIAS entries, so
remove the old one.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
Reviewed-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 075b419..5bb3e81 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -545,7 +545,6 @@ static struct platform_driver ci_hdrc_driver = {
 module_platform_driver(ci_hdrc_driver);
 
 MODULE_ALIAS(platform:ci_hdrc);
-MODULE_ALIAS(platform:ci13xxx);
 MODULE_LICENSE(GPL v2);
 MODULE_AUTHOR(David Lopo dl...@chipidea.mips.com);
 MODULE_DESCRIPTION(ChipIdea HDRC Driver);
-- 
1.8.4.rc2

--
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/22] usb: chipidea: disable all interrupts and clear all interrupts status

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

During the initialization, it needs to disable all interrupts
enable bit as well as clear all interrupts status bits to avoid
exceptional interrupt.

Tested-by: Marek Vasut ma...@denx.de
Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/core.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index ab01e18..e9cfd31 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -199,6 +199,12 @@ static int hw_device_init(struct ci_hdrc *ci, void __iomem 
*base)
if (ci-hw_ep_max  ENDPT_MAX)
return -ENODEV;
 
+   /* Disable all interrupts bits */
+   hw_write(ci, OP_USBINTR, 0x, 0);
+
+   /* Clear all interrupts status bits*/
+   hw_write(ci, OP_USBSTS, 0x, 0x);
+
dev_dbg(ci-dev, ChipIdea HDRC found, lpm: %d; cap: %p op: %p\n,
ci-hw_bank.lpm, ci-hw_bank.cap, ci-hw_bank.op);
 
@@ -434,8 +440,11 @@ static void ci_get_otg_capable(struct ci_hdrc *ci)
ci-is_otg = (hw_read(ci, CAP_DCCPARAMS,
DCCPARAMS_DC | DCCPARAMS_HC)
== (DCCPARAMS_DC | DCCPARAMS_HC));
-   if (ci-is_otg)
+   if (ci-is_otg) {
dev_dbg(ci-dev, It is OTG capable controller\n);
+   ci_disable_otg_interrupt(ci, OTGSC_INT_EN_BITS);
+   ci_clear_otg_interrupt(ci, OTGSC_INT_STATUS_BITS);
+   }
 }
 
 static int ci_hdrc_probe(struct platform_device *pdev)
-- 
1.8.4.rc2

--
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 11/22] usb: chipidea: udc: otg_set_peripheral is useless for some chipidea users

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

It is useless at below cases:
- If we implement both usb host and device at chipidea driver.
- If we don't need phy-otg.

Tested-by: Marek Vasut ma...@denx.de
Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/udc.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index e475fcd..116c762 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1805,7 +1805,12 @@ static int udc_start(struct ci_hdrc *ci)
if (ci-transceiver) {
retval = otg_set_peripheral(ci-transceiver-otg,
ci-gadget);
-   if (retval)
+   /*
+* If we implement all USB functions using chipidea drivers,
+* it doesn't need to call above API, meanwhile, if we only
+* use gadget function, calling above API is useless.
+*/
+   if (retval  retval != -ENOTSUPP)
goto put_transceiver;
}
 
-- 
1.8.4.rc2

--
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 21/22] usb: chipidea: udc: .pullup is valid only when vbus is there

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

For chipidea, the IP must know vbus before the controller
begins to run. So the .pullup should only be called when
the vbus is there.

Tested-by: Marek Vasut ma...@denx.de
Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/udc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 90c3572..6b4c2f2 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1511,6 +1511,9 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int 
is_on)
 {
struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
 
+   if (!ci-vbus_active)
+   return -EOPNOTSUPP;
+
if (is_on)
hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS);
else
-- 
1.8.4.rc2

--
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/22] usb: chipidea: otg: add otg file used to access otgsc

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

This file is mainly used to access otgsc currently, it may
add otg related things in the future.

Tested-by: Marek Vasut ma...@denx.de
Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/Makefile |  2 +-
 drivers/usb/chipidea/bits.h   | 10 ++
 drivers/usb/chipidea/core.c   |  3 ++-
 drivers/usb/chipidea/otg.c| 35 +++
 drivers/usb/chipidea/otg.h| 32 
 5 files changed, 80 insertions(+), 2 deletions(-)
 create mode 100644 drivers/usb/chipidea/otg.c
 create mode 100644 drivers/usb/chipidea/otg.h

diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 6cf5f68..a99d980 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -2,7 +2,7 @@ ccflags-$(CONFIG_USB_CHIPIDEA_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc.o
 
-ci_hdrc-y  := core.o
+ci_hdrc-y  := core.o otg.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_UDC) += udc.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_HOST)+= host.o
 ci_hdrc-$(CONFIG_USB_CHIPIDEA_DEBUG)   += debug.o
diff --git a/drivers/usb/chipidea/bits.h b/drivers/usb/chipidea/bits.h
index 1b23e35..464584c 100644
--- a/drivers/usb/chipidea/bits.h
+++ b/drivers/usb/chipidea/bits.h
@@ -79,11 +79,21 @@
 #define OTGSC_ASVIS  BIT(18)
 #define OTGSC_BSVIS  BIT(19)
 #define OTGSC_BSEIS  BIT(20)
+#define OTGSC_1MSIS  BIT(21)
+#define OTGSC_DPIS   BIT(22)
 #define OTGSC_IDIE   BIT(24)
 #define OTGSC_AVVIE  BIT(25)
 #define OTGSC_ASVIE  BIT(26)
 #define OTGSC_BSVIE  BIT(27)
 #define OTGSC_BSEIE  BIT(28)
+#define OTGSC_1MSIE  BIT(29)
+#define OTGSC_DPIE   BIT(30)
+#define OTGSC_INT_EN_BITS  (OTGSC_IDIE | OTGSC_AVVIE | OTGSC_ASVIE \
+   | OTGSC_BSVIE | OTGSC_BSEIE | OTGSC_1MSIE \
+   | OTGSC_DPIE)
+#define OTGSC_INT_STATUS_BITS  (OTGSC_IDIS | OTGSC_AVVIS | OTGSC_ASVIS \
+   | OTGSC_BSVIS | OTGSC_BSEIS | OTGSC_1MSIS \
+   | OTGSC_DPIS)
 
 /* USBMODE */
 #define USBMODE_CM(0x03UL   0)
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 13dbd51..2f70080 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -72,6 +72,7 @@
 #include bits.h
 #include host.h
 #include debug.h
+#include otg.h
 
 /* Controller register map */
 static uintptr_t ci_regs_nolpm[] = {
@@ -528,7 +529,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
goto stop;
 
if (ci-is_otg)
-   hw_write(ci, OP_OTGSC, OTGSC_IDIE, OTGSC_IDIE);
+   ci_hdrc_otg_init(ci);
 
ret = dbg_create_files(ci);
if (!ret)
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
new file mode 100644
index 000..999a085
--- /dev/null
+++ b/drivers/usb/chipidea/otg.c
@@ -0,0 +1,35 @@
+/*
+ * otg.c - ChipIdea USB IP core OTG driver
+ *
+ * Copyright (C) 2013 Freescale Semiconductor, Inc.
+ *
+ * Author: Peter Chen
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * This file mainly handles otgsc register, it may include OTG operation
+ * in the future.
+ */
+
+#include linux/usb/otg.h
+#include linux/usb/gadget.h
+#include linux/usb/chipidea.h
+
+#include ci.h
+#include bits.h
+#include otg.h
+
+/**
+ * ci_hdrc_otg_init - initialize otgsc bits
+ * ci: the controller
+ */
+int ci_hdrc_otg_init(struct ci_hdrc *ci)
+{
+   ci_enable_otg_interrupt(ci, OTGSC_IDIE);
+
+   return 0;
+}
diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h
new file mode 100644
index 000..376eaee
--- /dev/null
+++ b/drivers/usb/chipidea/otg.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2013 Freescale Semiconductor, Inc.
+ *
+ * Author: Peter Chen
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __DRIVERS_USB_CHIPIDEA_OTG_H
+#define __DRIVERS_USB_CHIPIDEA_OTG_H
+
+static inline void ci_clear_otg_interrupt(struct ci_hdrc *ci, u32 bits)
+{
+   /* Only clear request bits */
+   hw_write(ci, OP_OTGSC, OTGSC_INT_STATUS_BITS, bits);
+}
+
+static inline void ci_enable_otg_interrupt(struct ci_hdrc *ci, u32 bits)
+{
+   hw_write(ci, OP_OTGSC, bits, bits);
+}
+
+static inline void ci_disable_otg_interrupt(struct ci_hdrc *ci, u32 bits)
+{
+   hw_write(ci, OP_OTGSC, bits, 0);
+}
+
+int ci_hdrc_otg_init(struct ci_hdrc *ci);
+
+#endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */
-- 
1.8.4.rc2


[PATCH 17/22] usb: chipidea: add vbus interrupt handler

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

We add vbus interrupt handler at ci_otg_work, it uses OTGSC_BSV(at otgsc)
to know it is connect or disconnet event.
Meanwhile, we introduce two flags id_event and b_sess_valid_event to
indicate it is an id interrupt or a vbus interrupt.

Tested-by: Marek Vasut ma...@denx.de
Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/ci.h   |  5 +
 drivers/usb/chipidea/core.c | 28 +++-
 drivers/usb/chipidea/otg.c  | 42 +++---
 drivers/usb/chipidea/otg.h  |  1 +
 drivers/usb/chipidea/udc.c  |  7 +++
 5 files changed, 71 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 33cb29f..3160363 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -132,6 +132,9 @@ struct hw_bank {
  * @transceiver: pointer to USB PHY, if any
  * @hcd: pointer to usb_hcd for ehci host driver
  * @debugfs: root dentry for this controller in debugfs
+ * @id_event: indicates there is an id event, and handled at ci_otg_work
+ * @b_sess_valid_event: indicates there is a vbus event, and handled
+ * at ci_otg_work
  */
 struct ci_hdrc {
struct device   *dev;
@@ -168,6 +171,8 @@ struct ci_hdrc {
struct usb_phy  *transceiver;
struct usb_hcd  *hcd;
struct dentry   *debugfs;
+   boolid_event;
+   boolb_sess_valid_event;
 };
 
 static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci)
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index ec6c984..c95e098 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -303,16 +303,34 @@ static irqreturn_t ci_irq(int irq, void *data)
if (ci-is_otg)
otgsc = hw_read(ci, OP_OTGSC, ~0);
 
-   if (ci-role != CI_ROLE_END)
-   ret = ci_role(ci)-irq(ci);
+   /*
+* Handle id change interrupt, it indicates device/host function
+* switch.
+*/
+   if (ci-is_otg  (otgsc  OTGSC_IDIE)  (otgsc  OTGSC_IDIS)) {
+   ci-id_event = true;
+   ci_clear_otg_interrupt(ci, OTGSC_IDIS);
+   disable_irq_nosync(ci-irq);
+   queue_work(ci-wq, ci-work);
+   return IRQ_HANDLED;
+   }
 
-   if (ci-is_otg  (otgsc  OTGSC_IDIS)) {
-   hw_write(ci, OP_OTGSC, OTGSC_IDIS, OTGSC_IDIS);
+   /*
+* Handle vbus change interrupt, it indicates device connection
+* and disconnection events.
+*/
+   if (ci-is_otg  (otgsc  OTGSC_BSVIE)  (otgsc  OTGSC_BSVIS)) {
+   ci-b_sess_valid_event = true;
+   ci_clear_otg_interrupt(ci, OTGSC_BSVIS);
disable_irq_nosync(ci-irq);
queue_work(ci-wq, ci-work);
-   ret = IRQ_HANDLED;
+   return IRQ_HANDLED;
}
 
+   /* Handle device/host interrupt */
+   if (ci-role != CI_ROLE_END)
+   ret = ci_role(ci)-irq(ci);
+
return ret;
 }
 
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 3b66cbe..7f37484 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -37,13 +37,23 @@ enum ci_role ci_otg_role(struct ci_hdrc *ci)
return role;
 }
 
-/**
- * ci_role_work - perform role changing based on ID pin
- * @work: work struct
- */
-static void ci_role_work(struct work_struct *work)
+void ci_handle_vbus_change(struct ci_hdrc *ci)
+{
+   u32 otgsc;
+
+   if (!ci-is_otg)
+   return;
+
+   otgsc = hw_read(ci, OP_OTGSC, ~0);
+
+   if (otgsc  OTGSC_BSV)
+   usb_gadget_vbus_connect(ci-gadget);
+   else
+   usb_gadget_vbus_disconnect(ci-gadget);
+}
+
+static void ci_handle_id_switch(struct ci_hdrc *ci)
 {
-   struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work);
enum ci_role role = ci_otg_role(ci);
 
if (role != ci-role) {
@@ -53,17 +63,35 @@ static void ci_role_work(struct work_struct *work)
ci_role_stop(ci);
ci_role_start(ci, role);
}
+}
+/**
+ * ci_otg_work - perform otg (vbus/id) event handle
+ * @work: work struct
+ */
+static void ci_otg_work(struct work_struct *work)
+{
+   struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work);
+
+   if (ci-id_event) {
+   ci-id_event = false;
+   ci_handle_id_switch(ci);
+   } else if (ci-b_sess_valid_event) {
+   ci-b_sess_valid_event = false;
+   ci_handle_vbus_change(ci);
+   } else
+   dev_err(ci-dev, unexpected event occurs at %s\n, __func__);
 
enable_irq(ci-irq);
 }
 
+
 /**
  * ci_hdrc_otg_init - initialize otg struct
  * ci: the controller
  */
 int 

[PATCH 13/22] usb: chipidea: add role init and destroy APIs

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

- The role's init will be called at probe procedure.
- The role's destroy will be called at fail patch
at probe and driver's removal.
- The role's start/stop will be called when specific
role has started.

Tested-by: Marek Vasut ma...@denx.de
Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/core.c | 10 --
 drivers/usb/chipidea/host.c |  7 +++
 drivers/usb/chipidea/host.h |  6 ++
 drivers/usb/chipidea/udc.c  | 36 +++-
 drivers/usb/chipidea/udc.h  |  6 ++
 5 files changed, 54 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 2f70080..75afc52 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -420,6 +420,12 @@ void ci_hdrc_remove_device(struct platform_device *pdev)
 }
 EXPORT_SYMBOL_GPL(ci_hdrc_remove_device);
 
+static inline void ci_role_destroy(struct ci_hdrc *ci)
+{
+   ci_hdrc_gadget_destroy(ci);
+   ci_hdrc_host_destroy(ci);
+}
+
 static int ci_hdrc_probe(struct platform_device *pdev)
 {
struct device   *dev = pdev-dev;
@@ -537,7 +543,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 
free_irq(ci-irq, ci);
 stop:
-   ci_role_stop(ci);
+   ci_role_destroy(ci);
 rm_wq:
flush_workqueue(ci-wq);
destroy_workqueue(ci-wq);
@@ -553,7 +559,7 @@ static int ci_hdrc_remove(struct platform_device *pdev)
flush_workqueue(ci-wq);
destroy_workqueue(ci-wq);
free_irq(ci-irq, ci);
-   ci_role_stop(ci);
+   ci_role_destroy(ci);
 
return 0;
 }
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 8cf8d28..6f96795 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -106,6 +106,13 @@ static void host_stop(struct ci_hdrc *ci)
regulator_disable(ci-platdata-reg_vbus);
 }
 
+
+void ci_hdrc_host_destroy(struct ci_hdrc *ci)
+{
+   if (ci-role == CI_ROLE_HOST)
+   host_stop(ci);
+}
+
 int ci_hdrc_host_init(struct ci_hdrc *ci)
 {
struct ci_role_driver *rdrv;
diff --git a/drivers/usb/chipidea/host.h b/drivers/usb/chipidea/host.h
index 058875c..5707bf3 100644
--- a/drivers/usb/chipidea/host.h
+++ b/drivers/usb/chipidea/host.h
@@ -4,6 +4,7 @@
 #ifdef CONFIG_USB_CHIPIDEA_HOST
 
 int ci_hdrc_host_init(struct ci_hdrc *ci);
+void ci_hdrc_host_destroy(struct ci_hdrc *ci);
 
 #else
 
@@ -12,6 +13,11 @@ static inline int ci_hdrc_host_init(struct ci_hdrc *ci)
return -ENXIO;
 }
 
+static inline void ci_hdrc_host_destroy(struct ci_hdrc *ci)
+{
+
+}
+
 #endif
 
 #endif /* __DRIVERS_USB_CHIPIDEA_HOST_H */
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 116c762..24a100d 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -27,6 +27,7 @@
 #include udc.h
 #include bits.h
 #include debug.h
+#include otg.h
 
 /* control endpoint description */
 static const struct usb_endpoint_descriptor
@@ -1844,13 +1845,13 @@ free_qh_pool:
 }
 
 /**
- * udc_remove: parent remove must call this to remove UDC
+ * ci_hdrc_gadget_destroy: parent remove must call this to remove UDC
  *
  * No interrupts active, the IRQ has been released
  */
-static void udc_stop(struct ci_hdrc *ci)
+void ci_hdrc_gadget_destroy(struct ci_hdrc *ci)
 {
-   if (ci == NULL)
+   if (!ci-roles[CI_ROLE_GADGET])
return;
 
usb_del_gadget_udc(ci-gadget);
@@ -1865,15 +1866,32 @@ static void udc_stop(struct ci_hdrc *ci)
if (ci-global_phy)
usb_put_phy(ci-transceiver);
}
-   /* my kobject is dynamic, I swear! */
-   memset(ci-gadget, 0, sizeof(ci-gadget));
+}
+
+static int udc_id_switch_for_device(struct ci_hdrc *ci)
+{
+   if (ci-is_otg) {
+   ci_clear_otg_interrupt(ci, OTGSC_BSVIS);
+   ci_enable_otg_interrupt(ci, OTGSC_BSVIE);
+   }
+
+   return 0;
+}
+
+static void udc_id_switch_for_host(struct ci_hdrc *ci)
+{
+   if (ci-is_otg) {
+   /* host doesn't care B_SESSION_VALID event */
+   ci_clear_otg_interrupt(ci, OTGSC_BSVIS);
+   ci_disable_otg_interrupt(ci, OTGSC_BSVIE);
+   }
 }
 
 /**
  * ci_hdrc_gadget_init - initialize device related bits
  * ci: the controller
  *
- * This function enables the gadget role, if the device is device capable.
+ * This function initializes the gadget, if the device is device capable.
  */
 int ci_hdrc_gadget_init(struct ci_hdrc *ci)
 {
@@ -1886,11 +1904,11 @@ int ci_hdrc_gadget_init(struct ci_hdrc *ci)
if (!rdrv)
return -ENOMEM;
 
-   rdrv-start = udc_start;
-   rdrv-stop  = udc_stop;
+   rdrv-start = udc_id_switch_for_device;
+   rdrv-stop  = udc_id_switch_for_host;
rdrv-irq   = udc_irq;
rdrv-name  = gadget;

[PATCH 03/22] usb: chipidea: imx: delete the dead code

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

Remove an unused macro leftover from the old initialization code.

Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index 06bc775..a9a3bcf 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -24,9 +24,6 @@
 #include ci.h
 #include ci_hdrc_imx.h
 
-#define pdev_to_phy(pdev) \
-   ((struct usb_phy *)platform_get_drvdata(pdev))
-
 struct ci_hdrc_imx_data {
struct usb_phy *phy;
struct platform_device *ci_pdev;
-- 
1.8.4.rc2

--
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 16/22] usb: chipidea: move otg related things to otg file

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

Move otg related things to otg file.

Tested-by: Marek Vasut ma...@denx.de
Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/core.c | 63 ++---
 drivers/usb/chipidea/otg.c  | 57 ++--
 drivers/usb/chipidea/otg.h  |  2 ++
 3 files changed, 70 insertions(+), 52 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index e9cfd31..ec6c984 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -294,40 +294,6 @@ int hw_device_reset(struct ci_hdrc *ci, u32 mode)
return 0;
 }
 
-/**
- * ci_otg_role - pick role based on ID pin state
- * @ci: the controller
- */
-static enum ci_role ci_otg_role(struct ci_hdrc *ci)
-{
-   u32 sts = hw_read(ci, OP_OTGSC, ~0);
-   enum ci_role role = sts  OTGSC_ID
-   ? CI_ROLE_GADGET
-   : CI_ROLE_HOST;
-
-   return role;
-}
-
-/**
- * ci_role_work - perform role changing based on ID pin
- * @work: work struct
- */
-static void ci_role_work(struct work_struct *work)
-{
-   struct ci_hdrc *ci = container_of(work, struct ci_hdrc, work);
-   enum ci_role role = ci_otg_role(ci);
-
-   if (role != ci-role) {
-   dev_dbg(ci-dev, switching from %s to %s\n,
-   ci_role(ci)-name, ci-roles[role]-name);
-
-   ci_role_stop(ci);
-   ci_role_start(ci, role);
-   }
-
-   enable_irq(ci-irq);
-}
-
 static irqreturn_t ci_irq(int irq, void *data)
 {
struct ci_hdrc *ci = data;
@@ -430,6 +396,8 @@ static inline void ci_role_destroy(struct ci_hdrc *ci)
 {
ci_hdrc_gadget_destroy(ci);
ci_hdrc_host_destroy(ci);
+   if (ci-is_otg)
+   ci_hdrc_otg_destroy(ci);
 }
 
 static void ci_get_otg_capable(struct ci_hdrc *ci)
@@ -494,13 +462,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}
 
-   INIT_WORK(ci-work, ci_role_work);
-   ci-wq = create_singlethread_workqueue(ci_otg);
-   if (!ci-wq) {
-   dev_err(dev, can't create workqueue\n);
-   return -ENODEV;
-   }
-
ci_get_otg_capable(ci);
 
if (!ci-platdata-phy_mode)
@@ -530,8 +491,15 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 
if (!ci-roles[CI_ROLE_HOST]  !ci-roles[CI_ROLE_GADGET]) {
dev_err(dev, no supported roles\n);
-   ret = -ENODEV;
-   goto rm_wq;
+   return -ENODEV;
+   }
+
+   if (ci-is_otg) {
+   ret = ci_hdrc_otg_init(ci);
+   if (ret) {
+   dev_err(dev, init otg fails, ret = %d\n, ret);
+   goto stop;
+   }
}
 
if (ci-roles[CI_ROLE_HOST]  ci-roles[CI_ROLE_GADGET]) {
@@ -542,7 +510,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 */
mdelay(2);
ci-role = ci_otg_role(ci);
-   ci_hdrc_otg_init(ci);
+   ci_enable_otg_interrupt(ci, OTGSC_IDIE);
} else {
/*
 * If the controller is not OTG capable, but support
@@ -560,7 +528,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
ret = ci_role_start(ci, ci-role);
if (ret) {
dev_err(dev, can't start %s role\n, ci_role(ci)-name);
-   goto rm_wq;
+   goto stop;
}
 
platform_set_drvdata(pdev, ci);
@@ -576,9 +544,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
free_irq(ci-irq, ci);
 stop:
ci_role_destroy(ci);
-rm_wq:
-   flush_workqueue(ci-wq);
-   destroy_workqueue(ci-wq);
 
return ret;
 }
@@ -588,8 +553,6 @@ static int ci_hdrc_remove(struct platform_device *pdev)
struct ci_hdrc *ci = platform_get_drvdata(pdev);
 
dbg_remove_files(ci);
-   flush_workqueue(ci-wq);
-   destroy_workqueue(ci-wq);
free_irq(ci-irq, ci);
ci_role_destroy(ci);
 
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 999a085..3b66cbe 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -24,12 +24,65 @@
 #include otg.h
 
 /**
- * ci_hdrc_otg_init - initialize otgsc bits
+ * ci_otg_role - pick role based on ID pin state
+ * @ci: the controller
+ */
+enum ci_role ci_otg_role(struct ci_hdrc *ci)
+{
+   u32 sts = hw_read(ci, OP_OTGSC, ~0);
+   enum ci_role role = sts  OTGSC_ID
+   ? CI_ROLE_GADGET
+   : CI_ROLE_HOST;
+
+   return role;
+}
+
+/**
+ * ci_role_work - perform role changing based on ID pin
+ * @work: work struct
+ */
+static void ci_role_work(struct work_struct *work)
+{
+   struct ci_hdrc *ci = container_of(work, 

[PATCH 19/22] usb: chipidea: udc: fix misuse of REGS_SHARED and PULLUP_ON_VBUS flags

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

CI_HDRC_REGS_SHARED stands for the controller registers is shared
with other USB drivers, if all USB drivers are at chipidea/, it doesn't
needed to be set.
CI_HDRC_PULLUP_ON_VBUS stands for pullup dp when the vbus is on. This
flag doesn't need to be set if the vbus is always on for gadget
since dp has always pulled up after the gadget has initialized.

So, the current code seems to misuse this two flags.
- When the gadget initializes, the controller doesn't need to run if
it depends on vbus (CI_HDRC_PULLUP_ON_VBUS), it does not relate to
shared register.
- When the gadget starts (load one gadget module), the controller
can run if vbus is on (CI_HDRC_PULLUP_ON_VBUS), it also does not
relate to shared register.

Tested-by: Marek Vasut ma...@denx.de
Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/udc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index c70ce38..45abf4d 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1637,8 +1637,7 @@ static int ci_udc_start(struct usb_gadget *gadget,
pm_runtime_get_sync(ci-gadget.dev);
if (ci-platdata-flags  CI_HDRC_PULLUP_ON_VBUS) {
if (ci-vbus_active) {
-   if (ci-platdata-flags  CI_HDRC_REGS_SHARED)
-   hw_device_reset(ci, USBMODE_CM_DC);
+   hw_device_reset(ci, USBMODE_CM_DC);
} else {
pm_runtime_put_sync(ci-gadget.dev);
goto done;
@@ -1801,7 +1800,7 @@ static int udc_start(struct ci_hdrc *ci)
}
}
 
-   if (!(ci-platdata-flags  CI_HDRC_REGS_SHARED)) {
+   if (!(ci-platdata-flags  CI_HDRC_PULLUP_ON_VBUS)) {
retval = hw_device_reset(ci, USBMODE_CM_DC);
if (retval)
goto put_transceiver;
-- 
1.8.4.rc2

--
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/22] usb: chipidea: don't clobber return value of ci_role_start()

2013-08-14 Thread Alexander Shishkin
From: Lothar Waßmann l...@karo-electronics.de

If a role fails to start, propagate the error code up the call stack
from probe.

Signed-off-by: Lothar Waßmann l...@karo-electronics.de
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index a5b3774..2400b7f 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -497,7 +497,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
ret = ci_role_start(ci, ci-role);
if (ret) {
dev_err(dev, can't start %s role\n, ci_role(ci)-name);
-   ret = -ENODEV;
goto rm_wq;
}
 
-- 
1.8.4.rc2

--
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/22] usb: chipidea: host: add vbus regulator control

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

For boards which have board level vbus control (eg, through gpio), we
need to vbus operation according to below rules:
- For host, we need open vbus before start hcd, and close it
after remove hcd.
- For otg, the vbus needs to be on/off when usb role switches.
When the host roles begins, it opens vbus; when the host role
finishes, it closes vbus.

We put vbus operation to host as host is the only vbus user,
When we are at host mode, the vbus is on, when we are not at
host mode, vbus should be off.

Tested-by: Marek Vasut ma...@denx.de
Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/host.c | 23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 9b3aaf1..8cf8d28 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -24,6 +24,7 @@
 #include linux/usb.h
 #include linux/usb/hcd.h
 #include linux/usb/chipidea.h
+#include linux/regulator/consumer.h
 
 #include ../host/ehci.h
 
@@ -65,9 +66,19 @@ static int host_start(struct ci_hdrc *ci)
ehci-has_hostpc = ci-hw_bank.lpm;
ehci-has_tdi_phy_lpm = ci-hw_bank.lpm;
 
+   if (ci-platdata-reg_vbus) {
+   ret = regulator_enable(ci-platdata-reg_vbus);
+   if (ret) {
+   dev_err(ci-dev,
+   Failed to enable vbus regulator, ret=%d\n,
+   ret);
+   goto put_hcd;
+   }
+   }
+
ret = usb_add_hcd(hcd, 0, 0);
if (ret)
-   usb_put_hcd(hcd);
+   goto disable_reg;
else
ci-hcd = hcd;
 
@@ -75,6 +86,14 @@ static int host_start(struct ci_hdrc *ci)
hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS);
 
return ret;
+
+disable_reg:
+   regulator_disable(ci-platdata-reg_vbus);
+
+put_hcd:
+   usb_put_hcd(hcd);
+
+   return ret;
 }
 
 static void host_stop(struct ci_hdrc *ci)
@@ -83,6 +102,8 @@ static void host_stop(struct ci_hdrc *ci)
 
usb_remove_hcd(hcd);
usb_put_hcd(hcd);
+   if (ci-platdata-reg_vbus)
+   regulator_disable(ci-platdata-reg_vbus);
 }
 
 int ci_hdrc_host_init(struct ci_hdrc *ci)
-- 
1.8.4.rc2

--
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/22] usb: chipidea: add flag CI_HDRC_DUAL_ROLE_NOT_OTG

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

Since we need otgsc to know vbus's status at some chipidea
controllers even it is peripheral-only mode. Besides, some
SoCs (eg, AR9331 SoC) don't have otgsc register even
the DCCPARAMS_DC and DCCPARAMS_HC are both 1 at CAP_DCCPARAMS.

We inroduce flag CI_HDRC_DUAL_ROLE_NOT_OTG to indicate if the
controller is dual role, but not supports OTG. If this flag is
not set, we follow the rule that if DCCPARAMS_DC and DCCPARAMS_HC
are both 1 at CAP_DCCPARAMS, then this controller is otg capable.

Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/core.c  | 37 ++---
 include/linux/usb/chipidea.h |  5 +
 2 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 75afc52..ab01e18 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -426,6 +426,18 @@ static inline void ci_role_destroy(struct ci_hdrc *ci)
ci_hdrc_host_destroy(ci);
 }
 
+static void ci_get_otg_capable(struct ci_hdrc *ci)
+{
+   if (ci-platdata-flags  CI_HDRC_DUAL_ROLE_NOT_OTG)
+   ci-is_otg = false;
+   else
+   ci-is_otg = (hw_read(ci, CAP_DCCPARAMS,
+   DCCPARAMS_DC | DCCPARAMS_HC)
+   == (DCCPARAMS_DC | DCCPARAMS_HC));
+   if (ci-is_otg)
+   dev_dbg(ci-dev, It is OTG capable controller\n);
+}
+
 static int ci_hdrc_probe(struct platform_device *pdev)
 {
struct device   *dev = pdev-dev;
@@ -480,6 +492,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}
 
+   ci_get_otg_capable(ci);
+
if (!ci-platdata-phy_mode)
ci-platdata-phy_mode = of_usb_get_phy_mode(of_node);
 
@@ -512,10 +526,22 @@ static int ci_hdrc_probe(struct platform_device *pdev)
}
 
if (ci-roles[CI_ROLE_HOST]  ci-roles[CI_ROLE_GADGET]) {
-   ci-is_otg = true;
-   /* ID pin needs 1ms debouce time, we delay 2ms for safe */
-   mdelay(2);
-   ci-role = ci_otg_role(ci);
+   if (ci-is_otg) {
+   /*
+* ID pin needs 1ms debouce time,
+* we delay 2ms for safe.
+*/
+   mdelay(2);
+   ci-role = ci_otg_role(ci);
+   ci_hdrc_otg_init(ci);
+   } else {
+   /*
+* If the controller is not OTG capable, but support
+* role switch, the defalt role is gadget, and the
+* user can switch it through debugfs.
+*/
+   ci-role = CI_ROLE_GADGET;
+   }
} else {
ci-role = ci-roles[CI_ROLE_HOST]
? CI_ROLE_HOST
@@ -534,9 +560,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
if (ret)
goto stop;
 
-   if (ci-is_otg)
-   ci_hdrc_otg_init(ci);
-
ret = dbg_create_files(ci);
if (!ret)
return 0;
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index ce4e1aa..10a607c 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -20,6 +20,11 @@ struct ci_hdrc_platform_data {
 #define CI_HDRC_REQUIRE_TRANSCEIVERBIT(1)
 #define CI_HDRC_PULLUP_ON_VBUS BIT(2)
 #define CI_HDRC_DISABLE_STREAMING  BIT(3)
+   /*
+* Only set it when DCCPARAMS.DC==1 and DCCPARAMS.HC==1,
+* but otg is not supported (no register otgsc).
+*/
+#define CI_HDRC_DUAL_ROLE_NOT_OTG  BIT(4)
enum usb_dr_modedr_mode;
 #define CI_HDRC_CONTROLLER_RESET_EVENT 0
 #define CI_HDRC_CONTROLLER_STOPPED_EVENT   1
-- 
1.8.4.rc2

--
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 18/22] usb: chipidea: add wait vbus lower than OTGSC_BSV before role starts

2013-08-14 Thread Alexander Shishkin
From: Peter Chen peter.c...@freescale.com

When the gadget role starts, we need to make sure the vbus is lower
than OTGSC_BSV, or there will be an vbus interrupt since we use
B_SESSION_VALID as vbus interrupt to indicate connect and disconnect.
When the host role starts, it may not be useful to wait vbus to lower
than OTGSC_BSV, but it can indicate some hardware problems like the
vbus is still higher than OTGSC_BSV after we disconnect to host some
time later (5000 milliseconds currently), which is obvious not correct.

Tested-by: Marek Vasut ma...@denx.de
Signed-off-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/ci.h   |  3 +++
 drivers/usb/chipidea/core.c | 32 
 drivers/usb/chipidea/otg.c  |  4 
 3 files changed, 39 insertions(+)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 3160363..1c94fc5 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -308,4 +308,7 @@ int hw_port_test_set(struct ci_hdrc *ci, u8 mode);
 
 u8 hw_port_test_get(struct ci_hdrc *ci);
 
+int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask,
+   u32 value, unsigned int timeout_ms);
+
 #endif /* __DRIVERS_USB_CHIPIDEA_CI_H */
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index c95e098..9462640 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -294,6 +294,38 @@ int hw_device_reset(struct ci_hdrc *ci, u32 mode)
return 0;
 }
 
+/**
+ * hw_wait_reg: wait the register value
+ *
+ * Sometimes, it needs to wait register value before going on.
+ * Eg, when switch to device mode, the vbus value should be lower
+ * than OTGSC_BSV before connects to host.
+ *
+ * @ci: the controller
+ * @reg: register index
+ * @mask: mast bit
+ * @value: the bit value to wait
+ * @timeout_ms: timeout in millisecond
+ *
+ * This function returns an error code if timeout
+ */
+int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask,
+   u32 value, unsigned int timeout_ms)
+{
+   unsigned long elapse = jiffies + msecs_to_jiffies(timeout_ms);
+
+   while (hw_read(ci, reg, mask) != value) {
+   if (time_after(jiffies, elapse)) {
+   dev_err(ci-dev, timeout waiting for %08x in %d\n,
+   mask, reg);
+   return -ETIMEDOUT;
+   }
+   msleep(20);
+   }
+
+   return 0;
+}
+
 static irqreturn_t ci_irq(int irq, void *data)
 {
struct ci_hdrc *ci = data;
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index 7f37484..39bd7ec 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -52,6 +52,7 @@ void ci_handle_vbus_change(struct ci_hdrc *ci)
usb_gadget_vbus_disconnect(ci-gadget);
 }
 
+#define CI_VBUS_STABLE_TIMEOUT_MS 5000
 static void ci_handle_id_switch(struct ci_hdrc *ci)
 {
enum ci_role role = ci_otg_role(ci);
@@ -61,6 +62,9 @@ static void ci_handle_id_switch(struct ci_hdrc *ci)
ci_role(ci)-name, ci-roles[role]-name);
 
ci_role_stop(ci);
+   /* wait vbus lower than OTGSC_BSV */
+   hw_wait_reg(ci, OP_OTGSC, OTGSC_BSV, 0,
+   CI_VBUS_STABLE_TIMEOUT_MS);
ci_role_start(ci, role);
}
 }
-- 
1.8.4.rc2

--
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 22/22] USB: chipidea: i.MX: simplify usbmisc

2013-08-14 Thread Alexander Shishkin
From: Sascha Hauer s.ha...@pengutronix.de

The chipidea i.MX driver is split into two drivers. The ci_hdrc_imx driver
handles the chipidea cores and the usbmisc_imx driver handles the noncore
registers common to all chipidea cores (but SoC specific). Current flow is:

- usbmisc sets an ops pointer in the ci_hdrc_imx driver during probe
- ci_hdrc_imx checks if the pointer is valid during probe, if yes calls
  the functions in the ops pointer.
- usbmisc_imx calls back into the ci_hdrc_imx driver to get additional
  data

This is overly complicated and has problems if the drivers are compiled
as modules. In this case the usbmisc_imx driver can be unloaded even if
the ci_hdrc_imx driver still needs usbmisc functionality.

This patch changes this by letting the ci_hdrc_imx driver calling functions
from the usbmisc_imx driver. This way the symbol resolving during module
load makes sure the ci_hdrc_imx driver depends on the usbmisc_imx driver.

Also instead of letting the usbmisc_imx driver call back into the ci_hdrc_imx
driver, pass the needed data in the first place.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
Acked-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 71 +---
 drivers/usb/chipidea/ci_hdrc_imx.h | 17 ++-
 drivers/usb/chipidea/usbmisc_imx.c | 95 +-
 3 files changed, 76 insertions(+), 107 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index cc53e63..74d998d 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -27,57 +27,48 @@ struct ci_hdrc_imx_data {
struct usb_phy *phy;
struct platform_device *ci_pdev;
struct clk *clk;
+   struct imx_usbmisc_data *usbmisc_data;
 };
 
-static const struct usbmisc_ops *usbmisc_ops;
-
 /* Common functions shared by usbmisc drivers */
 
-int usbmisc_set_ops(const struct usbmisc_ops *ops)
-{
-   if (usbmisc_ops)
-   return -EBUSY;
-
-   usbmisc_ops = ops;
-
-   return 0;
-}
-EXPORT_SYMBOL_GPL(usbmisc_set_ops);
-
-void usbmisc_unset_ops(const struct usbmisc_ops *ops)
-{
-   usbmisc_ops = NULL;
-}
-EXPORT_SYMBOL_GPL(usbmisc_unset_ops);
-
-int usbmisc_get_init_data(struct device *dev, struct usbmisc_usb_device 
*usbdev)
+static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
 {
struct device_node *np = dev-of_node;
struct of_phandle_args args;
+   struct imx_usbmisc_data *data;
int ret;
 
-   usbdev-dev = dev;
+   /*
+* In case the fsl,usbmisc property is not present this device doesn't
+* need usbmisc. Return NULL (which is no error here)
+*/
+   if (!of_get_property(np, fsl,usbmisc, NULL))
+   return NULL;
+
+   data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+   if (!data)
+   return ERR_PTR(-ENOMEM);
 
ret = of_parse_phandle_with_args(np, fsl,usbmisc, #index-cells,
0, args);
if (ret) {
dev_err(dev, Failed to parse property fsl,usbmisc, errno %d\n,
ret);
-   memset(usbdev, 0, sizeof(*usbdev));
-   return ret;
+   return ERR_PTR(ret);
}
-   usbdev-index = args.args[0];
+
+   data-index = args.args[0];
of_node_put(args.np);
 
if (of_find_property(np, disable-over-current, NULL))
-   usbdev-disable_oc = 1;
+   data-disable_oc = 1;
 
if (of_find_property(np, external-vbus-divider, NULL))
-   usbdev-evdo = 1;
+   data-evdo = 1;
 
-   return 0;
+   return data;
 }
-EXPORT_SYMBOL_GPL(usbmisc_get_init_data);
 
 /* End of common functions shared by usbmisc drivers*/
 
@@ -92,16 +83,16 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
};
int ret;
 
-   if (of_find_property(pdev-dev.of_node, fsl,usbmisc, NULL)
-!usbmisc_ops)
-   return -EPROBE_DEFER;
-
data = devm_kzalloc(pdev-dev, sizeof(*data), GFP_KERNEL);
if (!data) {
dev_err(pdev-dev, Failed to allocate ci_hdrc-imx data!\n);
return -ENOMEM;
}
 
+   data-usbmisc_data = usbmisc_get_init_data(pdev-dev);
+   if (IS_ERR(data-usbmisc_data))
+   return PTR_ERR(data-usbmisc_data);
+
data-clk = devm_clk_get(pdev-dev, NULL);
if (IS_ERR(data-clk)) {
dev_err(pdev-dev,
@@ -135,11 +126,11 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
if (!pdev-dev.coherent_dma_mask)
pdev-dev.coherent_dma_mask = DMA_BIT_MASK(32);
 
-   if (usbmisc_ops  usbmisc_ops-init) {
-   ret = usbmisc_ops-init(pdev-dev);
+   if (data-usbmisc_data) {
+   ret = 

[PATCH 04/22] usb: chipidea: improve kconfig 2.0

2013-08-14 Thread Alexander Shishkin
From: Lothar Waßmann l...@karo-electronics.de

This patch provides a cleaner solution to the problem described in
commit 20a677fd (usb: chipidea: improve kconfig).

The goal to be achieved is to force USB_CHIPIDEA=m if either
USB_EHCI_HCD=m or USB_GADGET=m.
If both are 'y' USB_CHIPIDEA may be selected to be 'm' or 'y'.

The old patch had the drawback, that USB_CHIPIDEA could be chosen as
'y' though USB_EHCI_HCD or USB_GADGET (or both) were 'm' leading to a
situation where USB_CHIPIDEA_HOST or USB_CHIPIDEA_UDC vanished from
the config options producing a compilable but dysfunctional driver.

Signed-off-by: Lothar Waßmann l...@karo-electronics.de
Reviewed-by: Peter Chen peter.c...@freescale.com
Signed-off-by: Alexander Shishkin alexander.shish...@linux.intel.com
---
 drivers/usb/chipidea/Kconfig | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig
index d1bd8ef..4a851e1 100644
--- a/drivers/usb/chipidea/Kconfig
+++ b/drivers/usb/chipidea/Kconfig
@@ -1,6 +1,6 @@
 config USB_CHIPIDEA
tristate ChipIdea Highspeed Dual Role Controller
-   depends on USB || USB_GADGET
+   depends on (USB_EHCI_HCD  USB_GADGET) || (USB_EHCI_HCD  
!USB_GADGET) || (!USB_EHCI_HCD  USB_GADGET)
help
  Say Y here if your system has a dual role high speed USB
  controller based on ChipIdea silicon IP. Currently, only the
@@ -12,15 +12,14 @@ if USB_CHIPIDEA
 
 config USB_CHIPIDEA_UDC
bool ChipIdea device controller
-   depends on USB_GADGET=y || (USB_CHIPIDEA=m  USB_GADGET=m)
+   depends on USB_GADGET
help
  Say Y here to enable device controller functionality of the
  ChipIdea driver.
 
 config USB_CHIPIDEA_HOST
bool ChipIdea host controller
-   depends on USB=y
-   depends on USB_EHCI_HCD=y || (USB_CHIPIDEA=m  USB_EHCI_HCD=m)
+   depends on USB_EHCI_HCD
select USB_EHCI_ROOT_HUB_TT
help
  Say Y here to enable host controller functionality of the
-- 
1.8.4.rc2

--
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 v15 00/13] Add tested id switch and vbus connect detect support for Chipidea

2013-08-14 Thread Alexander Shishkin
Peter Chen peter.c...@freescale.com writes:

 On Mon, Aug 12, 2013 at 09:22:46AM +0800, Peter Chen wrote:
 This patchset adds tested otg id switch function and vbus connect
 and disconnect detection for chipidea driver. And fix kinds of 
 bugs found at chipidea drivers after enabling id and vbus detection.
 
 This patch are fully tested at imx6 sabresd and imx28evk platform by me.
 Besides, marek tested it on two STMP3780-based boards (not yet mainline)
 and two MX28-based boards.
 
 My chipidea repo: https://github.com/hzpeterchen/linux-usb.git

 Hi Alex,

 I see Felipe has already sent his pull request for 3.12 merge
 windows. Would you please speed up review my chipidea patches?
 At least, I hope this serial can be queued at 3.12. Thanks.

Yes, it is about time.

Thanks,
--
Alex
--
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] USB: chipidea: i.MX: simplify usbmisc

2013-08-14 Thread Alexander Shishkin
Sascha Hauer s.ha...@pengutronix.de writes:

 The chipidea i.MX driver is split into two drivers. The ci_hdrc_imx driver
 handles the chipidea cores and the usbmisc_imx driver handles the noncore
 registers common to all chipidea cores (but SoC specific). Current flow is:

 - usbmisc sets an ops pointer in the ci_hdrc_imx driver during probe
 - ci_hdrc_imx checks if the pointer is valid during probe, if yes calls
   the functions in the ops pointer.
 - usbmisc_imx calls back into the ci_hdrc_imx driver to get additional
   data

 This is overly complicated and has problems if the drivers are compiled
 as modules. In this case the usbmisc_imx driver can be unloaded even if
 the ci_hdrc_imx driver still needs usbmisc functionality.

 This patch changes this by letting the ci_hdrc_imx driver calling functions
 from the usbmisc_imx driver. This way the symbol resolving during module
 load makes sure the ci_hdrc_imx driver depends on the usbmisc_imx driver.

 Also instead of letting the usbmisc_imx driver call back into the ci_hdrc_imx
 driver, pass the needed data in the first place.

 Signed-off-by: Sascha Hauer s.ha...@pengutronix.de

Applied and pushed, thanks!
--
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] dwc3: dwc3-pci: Use SIMPLE_DEV_PM_OPS

2013-08-14 Thread Mark Brown
On Wed, Aug 14, 2013 at 09:19:44AM +0800, Peter Chen wrote:

 If CONFIG_PM_SLEEP is not defined, the current value is .pm = NULL,
 but your version .pm != NULL (its content is NULL).

 I am not sure if it will cause any problems.

It would cause a small amount of additional memory usage if the compiler
doesn't figure things out but it's not obvious that this is worth
additional ifdefs.


signature.asc
Description: Digital signature


Re: [PATCH] Documentation sysfs-bus-usb: Document all files used by libusb

2013-08-14 Thread Johan Hovold
On Wed, Aug 14, 2013 at 11:17:57AM +0200, Hans de Goede wrote:
 +What:/sys/bus/usb/devices/.../busnum
 +KernelVersion:   2.6.22
 +Description:
 + Bus-number of the USB-bus the device is connected to.
 +
 +What:/sys/bus/usb/devices/.../descriptors
 +KernelVersion:   2.6.26
 +Description:
 + Binary file containing cached descriptors of the device. The
 + binary data consists of first the device descriptor, and when
 + the descriptors for each configuration of the device.

You probably want s/when/then/ here, but perhaps

The binary data consists of the device descriptor followed by
 the descriptors for each configuration of the device.

would be more clear?

Thanks,
Johan

 + Note that the wTotalLength of the config descriptors can not
 + be trusted, as the device may have a smaller config descriptor
 + than it advertises. The bLength field of each (sub) descriptor
 + can be trusted, and can be used to seek forward one (sub)
 + descriptor at a time until the next config descriptor is found.
 + All descriptors read from this file are in bus-endian format
--
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


PCIe USB 3.0 card not working with kernel 3.9 and 3.10

2013-08-14 Thread Italo Madalozo
Dear people,

I have recently bought a transcend USB3.0/ SATA III  PCIe card combo. The 
sataIII works fine but, the USB does not work with either kernel 3.9 or 
3.10 (I have only tried these two).

For the kernel 3.9 I get outputs of:
dmesg | grep xhci

[1.243092] xhci_hcd :05:00.0: Refused to change power state, 
currently in D3

[1.243153] xhci_hcd :05:00.0: xHCI Host Controller

[1.243393] xhci_hcd :05:00.0: new USB bus registered, assigned bus 
number 2

[1.243429] xhci_hcd :05:00.0: Host not halted after 16000 
microseconds.

[1.243431] xhci_hcd :05:00.0: can't setup

[1.243499] xhci_hcd :05:00.0: USB bus 2 deregistered

[1.243541] xhci_hcd :05:00.0: init :05:00.0 fail, -19

[1.243657] xhci_hcd :06:00.0: xHCI Host Controller

[1.243661] xhci_hcd :06:00.0: new USB bus registered, assigned bus 
number 2

[1.306601] xhci_hcd :06:00.0: irq 47 for MSI/MSI-X

[1.306607] xhci_hcd :06:00.0: irq 48 for MSI/MSI-X

[1.306611] xhci_hcd :06:00.0: irq 49 for MSI/MSI-X

[1.306616] xhci_hcd :06:00.0: irq 50 for MSI/MSI-X

[1.306620] xhci_hcd :06:00.0: irq 51 for MSI/MSI-X

[1.306625] xhci_hcd :06:00.0: irq 52 for MSI/MSI-X

[1.306629] xhci_hcd :06:00.0: irq 53 for MSI/MSI-X

[1.306791] xHCI xhci_add_endpoint called for root hub

[1.306792] xHCI xhci_check_bandwidth called for root hub

[1.306883] xhci_hcd :06:00.0: xHCI Host Controller

[1.306886] xhci_hcd :06:00.0: new USB bus registered, assigned bus 
number 5

[1.306972] xHCI xhci_add_endpoint called for root hub

[1.306973] xHCI xhci_check_bandwidth called for root hub



lspci

00:00.0 Host bridge: Advanced Micro Devices, Inc. [AMD] RS780 Host Bridge

00:02.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] RS780 PCI to PCI 
bridge (ext gfx port 0)

00:04.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] RS780/RS880 PCI to 
PCI bridge (PCIE port 0)

00:07.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] RS780/RS880 PCI to 
PCI bridge (PCIE port 3)

00:0a.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] RS780/RS880 PCI to 
PCI bridge (PCIE port 5)

00:11.0 SATA controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/
SB9x0 SATA Controller [IDE mode]

00:12.0 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/
SB9x0 USB OHCI0 Controller

00:12.1 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0 USB 
OHCI1 Controller

00:12.2 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/
SB9x0 USB EHCI Controller

00:13.0 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/
SB9x0 USB OHCI0 Controller

00:13.1 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0 USB 
OHCI1 Controller

00:13.2 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/
SB9x0 USB EHCI Controller

00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD/ATI] SBx00 SMBus 
Controller (rev 3c)

00:14.1 IDE interface: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/
SB9x0 IDE Controller

00:14.2 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] SBx00 Azalia 
(Intel HDA)

00:14.3 ISA bridge: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/
SB9x0 LPC host controller

00:14.4 PCI bridge: Advanced Micro Devices, Inc. [AMD/ATI] SBx00 PCI to PCI 
Bridge

00:14.5 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/
SB9x0 USB OHCI2 Controller

00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h 
Processor Function 0

00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h 
Processor Function 1

00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h 
Processor Function 2

00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h 
Processor Function 3

00:18.4 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h 
Processor Function 4

00:18.5 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 15h 
Processor Function 5

01:00.0 VGA compatible controller: NVIDIA Corporation G98 [Quadro NVS 295] 
(rev a1)

02:00.0 PCI bridge: PLX Technology, Inc. Device 8603 (rev aa)

03:01.0 PCI bridge: PLX Technology, Inc. Device 8603 (rev aa)

03:02.0 PCI bridge: PLX Technology, Inc. Device 8603 (rev aa)

04:00.0 SATA controller: ASMedia Technology Inc. ASM1062 Serial ATA 
Controller (rev 01)

05:00.0 USB controller: Device 0012:0015 (rev ff)

06:00.0 USB controller: ASMedia Technology Inc. ASM1042 SuperSpeed USB Host 
Controller

07:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168 
PCI Express Gigabit Ethernet controller (rev 09)

08:06.0 Network controller: Ralink corp. RT2561/RT61 802.11g PCI

I would get a similar output with 3.10 but today when I first booted the 
latest kernel the output was slightly more promising. 

dmesg  | grep xhci
[1.376709] xhci_hcd :05:00.0: xHCI Host Controller
[1.376718] xhci_hcd :05:00.0: new USB bus registered, assigned bus 
number 1
[

Re: [PATCH v2 0/4] Add phy support for AM335X platform using Generic PHy framework

2013-08-14 Thread Sebastian Andrzej Siewior
On 08/10/2013 01:59 PM, Ezequiel Garcia wrote:
 Is there any reason why there's no DT binding patch to this
 series? (aka Documentation/devicetree/... + sent to devicetree list)
 
 (sorry if this has been already explained somewhere...)
 

Completely forgot. There are existent documents which need be updated.
Will do  post.

Sebastian
--
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 suspend/resume sequence

2013-08-14 Thread Oliver Neukum
On Wed, 2013-08-14 at 14:46 +0530, Vivek Gautam wrote:

Hi,

  devices and root-hubs across suspend/resume. Are the device contexts
  saved somewhere and then restored back on resume ?
 
  Usually not. The state of interfaces are the responsibility of interface
  drivers (colloquially called device drivers). Most devices just don't
  offer an API for saving state. The drivers recreate as opposed to
  restore the state.
 
 How does then PERSIST_ENABLED option work then ? With this option enabled,
 on a system resume, the USB device attached to the root-hub are not
 re-enumerated, right ?

Exactly that way. You recreate the state of the device.

 Possibly i am getting confused here.

Well. There are two ways to make a device go to the same state

a) you have primitives to save and restore that state
b) you recognize that the state is the result of a sequence
of operations. You repeat that sequence.

That is the basic idea from a high level of abstraction.

 How would a usb_suspend_interface() and usb_suspend_device() differ.

Have a look at drivers/usb/core/generic.c

 Is it that, from the interface only the device information is extracted ?
 Can't we catch hold of usb_device pointers of hub and child devices ?

We can. And that is how persist works. But it may fail.
Possibly I am misunderstanding you.

Regards
Oliver


--
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: misc: usb3503: Force late initialization

2013-08-14 Thread Tushar Behera
USB3503 chip needs to be reset after the USB PHY controller has been
intiliazed, otherwise it is not detected as plugged in.

Currently there is no other way to ensure that USB3503 chip is probed
after the USB PHY has been initialized, hence the last resort.

Signed-off-by: Tushar Behera tushar.beh...@linaro.org
---
 drivers/usb/misc/usb3503.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usb3503.c b/drivers/usb/misc/usb3503.c
index a31641e..ad8368d 100644
--- a/drivers/usb/misc/usb3503.c
+++ b/drivers/usb/misc/usb3503.c
@@ -339,7 +339,7 @@ static int __init usb3503_init(void)
 
return 0;
 }
-module_init(usb3503_init);
+late_initcall(usb3503_init);
 
 static void __exit usb3503_exit(void)
 {
-- 
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


Investment

2013-08-14 Thread Mr. Milos Antic
ATTENTION.

Let me use the liberty of this medium to inform you that my principal is 
interested in investing his bond as a silent business partner in your company. 
He would like to invest in private sector projects with an established company 
in any project(s) which are already in the market and have market value or new 
company requiring the injection of huge funds, provided there are lots of 
opportunities available, taking into proper consideration the Return on 
Investment (ROI) based on a ten (10) year strategic plan.

Kindly indicate your interest in my client’s proposition by furnishing me 
with your Bio data, business/personal contact details and any other 
information/detail that may help in the actualization of the impending 
investment portfolio.

Thanks,

Milos

Note response back on this email below milox.an...@yahoo.com
--
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: Non-enumerable devices on USB and other enumerable buses

2013-08-14 Thread Mark Brown
On Mon, Aug 12, 2013 at 09:04:00PM -0400, Alan Stern wrote:

 The bus code would need hooks installed wherever the platform wants to 
 do something extra.  This could end up growing to a lot of hooks.  How 
 can the whole thing be done in a reasonable fashion?

I'd expect that we're just looking at hooks around connection and
disconnection here here - if we're looking at much more it seems like we
must be doing something wrong.


signature.asc
Description: Digital signature


[PATCH 5/5] usbfs: Add support for allocating / freeing streams

2013-08-14 Thread Hans de Goede
Signed-off-by: Hans de Goede hdego...@redhat.com
---
 drivers/usb/core/devio.c  | 103 ++
 include/uapi/linux/usbdevice_fs.h |   7 +++
 2 files changed, 110 insertions(+)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 94e7839..83caad5 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -762,6 +762,70 @@ static struct usb_host_endpoint 
*ep_to_host_endpoint(struct usb_device *dev,
return dev-ep_out[ep  USB_ENDPOINT_NUMBER_MASK];
 }
 
+static int parse_usbdevfs_streams(struct usb_device *dev,
+ struct usbdevfs_streams __user *streams,
+ unsigned int *num_streams_ret,
+ unsigned int *num_eps_ret,
+ struct usb_host_endpoint ***eps_ret,
+ struct usb_interface **intf_ret)
+{
+   unsigned int i, num_streams, num_eps;
+   struct usb_host_endpoint **eps;
+   struct usb_interface *intf = NULL;
+   unsigned char ep;
+   int ret;
+
+   if (get_user(num_streams, streams-num_streams) ||
+   get_user(num_eps, streams-num_eps))
+   return -EFAULT;
+
+   if (num_eps == 0 || (num_streams_ret  num_streams = 1))
+   return -EINVAL;
+
+   eps = kmalloc(num_eps * sizeof(*eps), GFP_KERNEL);
+   if (!eps)
+   return -ENOMEM;
+
+   for (i = 0; i  num_eps; i++) {
+   if (get_user(ep, streams-eps[i])) {
+   ret = -EFAULT;
+   goto error;
+   }
+   eps[i] = ep_to_host_endpoint(dev, ep);
+   if (!eps[i]) {
+   ret = -EINVAL;
+   goto error;
+   }
+
+   /* usb_alloc/free_streams operate on an usb_interface */
+   ret = findintfep(dev, ep);
+   if (ret  0)
+   goto error;
+
+   if (i == 0) {
+   intf = usb_ifnum_to_if(dev, ret);
+   } else {
+   /* Verify all eps belong to the same interface */
+   if (ret != intf-altsetting-desc.bInterfaceNumber) {
+   ret = -EINVAL;
+   goto error;
+   }
+   }
+   }
+
+   if (num_streams_ret)
+   *num_streams_ret = num_streams;
+   *num_eps_ret = num_eps;
+   *eps_ret = eps;
+   *intf_ret = intf;
+
+   return 0;
+
+error:
+   kfree(eps);
+   return ret;
+}
+
 static int match_devt(struct device *dev, void *data)
 {
return dev-devt == (dev_t) (unsigned long) data;
@@ -1975,6 +2039,39 @@ static int proc_disconnect_claim(struct dev_state *ps, 
void __user *arg)
return claimintf(ps, dc.interface);
 }
 
+static int proc_alloc_streams(struct dev_state *ps, void __user *arg)
+{
+   unsigned num_streams, num_eps;
+   struct usb_host_endpoint **eps;
+   struct usb_interface *intf;
+   int r;
+
+   r = parse_usbdevfs_streams(ps-dev, arg, num_streams, num_eps,
+  eps, intf);
+   if (r)
+   return r;
+
+   r = usb_alloc_streams(intf, eps, num_eps, num_streams, GFP_KERNEL);
+   kfree(eps);
+   return r;
+}
+
+static int proc_free_streams(struct dev_state *ps, void __user *arg)
+{
+   unsigned num_eps;
+   struct usb_host_endpoint **eps;
+   struct usb_interface *intf;
+   int r;
+
+   r = parse_usbdevfs_streams(ps-dev, arg, NULL, num_eps, eps, intf);
+   if (r)
+   return r;
+
+   usb_free_streams(intf, eps, num_eps, GFP_KERNEL);
+   kfree(eps);
+   return 0;
+}
+
 /*
  * NOTE:  All requests here that have interface numbers as parameters
  * are assuming that somehow the configuration has been prevented from
@@ -2151,6 +2248,12 @@ static long usbdev_do_ioctl(struct file *file, unsigned 
int cmd,
case USBDEVFS_DISCONNECT_CLAIM:
ret = proc_disconnect_claim(ps, p);
break;
+   case USBDEVFS_ALLOC_STREAMS:
+   ret = proc_alloc_streams(ps, p);
+   break;
+   case USBDEVFS_FREE_STREAMS:
+   ret = proc_free_streams(ps, p);
+   break;
}
usb_unlock_device(dev);
if (ret = 0)
diff --git a/include/uapi/linux/usbdevice_fs.h 
b/include/uapi/linux/usbdevice_fs.h
index 695476d..e58539d 100644
--- a/include/uapi/linux/usbdevice_fs.h
+++ b/include/uapi/linux/usbdevice_fs.h
@@ -147,6 +147,11 @@ struct usbdevfs_disconnect_claim {
char driver[USBDEVFS_MAXDRIVERNAME + 1];
 };
 
+struct usbdevfs_streams {
+   unsigned int num_streams; /* Not used by USBDEVFS_FREE_STREAMS */
+   unsigned int num_eps;
+   unsigned char eps[0];
+};
 
 #define USBDEVFS_CONTROL   _IOWR('U', 0, struct usbdevfs_ctrltransfer)
 

[PATCH 1/5] usbfs: proc_do_submiturb use a local variable for number_of_packets

2013-08-14 Thread Hans de Goede
This is a preparation patch for adding support for bulk streams.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 drivers/usb/core/devio.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 737e3c1..229f874 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1175,6 +1175,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct 
usbdevfs_urb *uurb,
struct usb_ctrlrequest *dr = NULL;
unsigned int u, totlen, isofrmlen;
int i, ret, is_in, num_sgs = 0, ifnum = -1;
+   int number_of_packets = 0;
void *buf;
 
if (uurb-flags  ~(USBDEVFS_URB_ISO_ASAP |
@@ -1228,7 +1229,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct 
usbdevfs_urb *uurb,
  le16_to_cpup(dr-wIndex));
if (ret)
goto error;
-   uurb-number_of_packets = 0;
uurb-buffer_length = le16_to_cpup(dr-wLength);
uurb-buffer += 8;
if ((dr-bRequestType  USB_DIR_IN)  uurb-buffer_length) {
@@ -1256,9 +1256,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct 
usbdevfs_urb *uurb,
case USB_ENDPOINT_XFER_INT:
/* allow single-shot interrupt transfers */
uurb-type = USBDEVFS_URB_TYPE_INTERRUPT;
-   goto interrupt_urb;
+   break;
}
-   uurb-number_of_packets = 0;
num_sgs = DIV_ROUND_UP(uurb-buffer_length, USB_SG_SIZE);
if (num_sgs == 1 || num_sgs  ps-dev-bus-sg_tablesize)
num_sgs = 0;
@@ -1267,8 +1266,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct 
usbdevfs_urb *uurb,
case USBDEVFS_URB_TYPE_INTERRUPT:
if (!usb_endpoint_xfer_int(ep-desc))
return -EINVAL;
- interrupt_urb:
-   uurb-number_of_packets = 0;
break;
 
case USBDEVFS_URB_TYPE_ISO:
@@ -1278,15 +1275,16 @@ static int proc_do_submiturb(struct dev_state *ps, 
struct usbdevfs_urb *uurb,
return -EINVAL;
if (!usb_endpoint_xfer_isoc(ep-desc))
return -EINVAL;
+   number_of_packets = uurb-number_of_packets;
isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) *
-  uurb-number_of_packets;
+  number_of_packets;
if (!(isopkt = kmalloc(isofrmlen, GFP_KERNEL)))
return -ENOMEM;
if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) {
ret = -EFAULT;
goto error;
}
-   for (totlen = u = 0; u  uurb-number_of_packets; u++) {
+   for (totlen = u = 0; u  number_of_packets; u++) {
/*
 * arbitrary limit need for USB 3.0
 * bMaxBurst (0~15 allowed, 1~16 packets)
@@ -1317,7 +1315,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct 
usbdevfs_urb *uurb,
ret = -EFAULT;
goto error;
}
-   as = alloc_async(uurb-number_of_packets);
+   as = alloc_async(number_of_packets);
if (!as) {
ret = -ENOMEM;
goto error;
@@ -1411,7 +1409,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct 
usbdevfs_urb *uurb,
as-urb-setup_packet = (unsigned char *)dr;
dr = NULL;
as-urb-start_frame = uurb-start_frame;
-   as-urb-number_of_packets = uurb-number_of_packets;
+   as-urb-number_of_packets = number_of_packets;
if (uurb-type == USBDEVFS_URB_TYPE_ISO ||
ps-dev-speed == USB_SPEED_HIGH)
as-urb-interval = 1  min(15, ep-desc.bInterval - 1);
@@ -1419,7 +1417,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct 
usbdevfs_urb *uurb,
as-urb-interval = ep-desc.bInterval;
as-urb-context = as;
as-urb-complete = async_completed;
-   for (totlen = u = 0; u  uurb-number_of_packets; u++) {
+   for (totlen = u = 0; u  number_of_packets; u++) {
as-urb-iso_frame_desc[u].offset = totlen;
as-urb-iso_frame_desc[u].length = isopkt[u].length;
totlen += isopkt[u].length;
-- 
1.8.3.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 3/5] usbfs: Add support for bulk stream ids

2013-08-14 Thread Hans de Goede
This patch makes it possible to specify a bulk stream id when submitting
an urb using the async usbfs API. It overloads the number_of_packets
usbdevfs_urb field for this. This is not pretty, but given other
constraints it is the best we can do. The reasoning leading to this goes
as follows:

1) We want to support bulk streams in the usbfs API
2) We do not want to extend the usbdevfs_urb struct with a new member, as
   that would mean defining new ioctl numbers for all async API ioctls +
   adding compat versions for the old ones (times 2 for 32 bit support)
3) 1 + 2 means we need to re-use an existing field
4) number_of_packets is only used for isoc urbs, and streams are bulk only
   so it is the best (and only) candidate for re-using

Note that:
1) This patch only uses number_of_packets as stream_id if the app has
   actually allocated streams on the ep, so that old apps which may have
   garbage in there (as it was unused until now in the bulk case), will not
   break
2) This patch does not add support for allocating / freeing bulk-streams, that
   is done in a follow up patch

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 drivers/usb/core/devio.c  | 4 
 include/uapi/linux/usbdevice_fs.h | 5 -
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 229f874..c7e946f 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1176,6 +1176,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct 
usbdevfs_urb *uurb,
unsigned int u, totlen, isofrmlen;
int i, ret, is_in, num_sgs = 0, ifnum = -1;
int number_of_packets = 0;
+   int stream_id = 0;
void *buf;
 
if (uurb-flags  ~(USBDEVFS_URB_ISO_ASAP |
@@ -1261,6 +1262,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct 
usbdevfs_urb *uurb,
num_sgs = DIV_ROUND_UP(uurb-buffer_length, USB_SG_SIZE);
if (num_sgs == 1 || num_sgs  ps-dev-bus-sg_tablesize)
num_sgs = 0;
+   if (ep-has_streams)
+   stream_id = uurb-stream_id;
break;
 
case USBDEVFS_URB_TYPE_INTERRUPT:
@@ -1410,6 +1413,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct 
usbdevfs_urb *uurb,
dr = NULL;
as-urb-start_frame = uurb-start_frame;
as-urb-number_of_packets = number_of_packets;
+   as-urb-stream_id = stream_id;
if (uurb-type == USBDEVFS_URB_TYPE_ISO ||
ps-dev-speed == USB_SPEED_HIGH)
as-urb-interval = 1  min(15, ep-desc.bInterval - 1);
diff --git a/include/uapi/linux/usbdevice_fs.h 
b/include/uapi/linux/usbdevice_fs.h
index 0c65e4b..695476d 100644
--- a/include/uapi/linux/usbdevice_fs.h
+++ b/include/uapi/linux/usbdevice_fs.h
@@ -102,7 +102,10 @@ struct usbdevfs_urb {
int buffer_length;
int actual_length;
int start_frame;
-   int number_of_packets;
+   union {
+   int number_of_packets;  /* Only used for isoc urbs */
+   int stream_id;  /* Only used with bulk streams */
+   };
int error_count;
unsigned int signr; /* signal to be sent on completion,
  or 0 if none should be sent. */
-- 
1.8.3.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


[RFC 0/5] usbfs: Add support for bulk streams

2013-08-14 Thread Hans de Goede
Hi All,

As discussed a long while back, usbfs is currently missing bulk streams
support, and we ought to fix this. So this patch extends the usbfs API with
bulk stream support. Please review.

Note this patch-set is compile-tested only, since I don't have access to
any USB-3 devices using bulk streams. I've 4 different USB-3 disk-enclosures,
but none of them supports uasp :|  Yesterday I've finally managed to find
an USB-3 disk enclosure online which in its description actually advertises
uasp support, I should receive that in a couple of days, at which point I can
actually test this (which is why I wrote this patch set now).

Regards,

Hans
--
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/5] usb-core: Track if an endpoint has streams

2013-08-14 Thread Hans de Goede
This is a preparation patch for adding support for bulk streams to usbfs.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 drivers/usb/core/hcd.c | 28 ++--
 include/linux/usb.h|  1 +
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 5aa1d13..2a9888a 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2040,7 +2040,7 @@ int usb_alloc_streams(struct usb_interface *interface,
 {
struct usb_hcd *hcd;
struct usb_device *dev;
-   int i;
+   int i, ret;
 
dev = interface_to_usbdev(interface);
hcd = bus_to_hcd(dev-bus);
@@ -2049,13 +2049,24 @@ int usb_alloc_streams(struct usb_interface *interface,
if (dev-speed != USB_SPEED_SUPER)
return -EINVAL;
 
-   /* Streams only apply to bulk endpoints. */
-   for (i = 0; i  num_eps; i++)
+   for (i = 0; i  num_eps; i++) {
+   /* Streams only apply to bulk endpoints. */
if (!usb_endpoint_xfer_bulk(eps[i]-desc))
return -EINVAL;
+   /* Re-alloc is not allowed */
+   if (eps[i]-has_streams)
+   return -EINVAL;
+   }
 
-   return hcd-driver-alloc_streams(hcd, dev, eps, num_eps,
+   ret = hcd-driver-alloc_streams(hcd, dev, eps, num_eps,
num_streams, mem_flags);
+   if (ret  0)
+   return ret;
+
+   for (i = 0; i  num_eps; i++)
+   eps[i]-has_streams = 1;
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(usb_alloc_streams);
 
@@ -2075,7 +2086,7 @@ void usb_free_streams(struct usb_interface *interface,
 {
struct usb_hcd *hcd;
struct usb_device *dev;
-   int i;
+   int i, ret;
 
dev = interface_to_usbdev(interface);
hcd = bus_to_hcd(dev-bus);
@@ -2087,7 +2098,12 @@ void usb_free_streams(struct usb_interface *interface,
if (!eps[i] || !usb_endpoint_xfer_bulk(eps[i]-desc))
return;
 
-   hcd-driver-free_streams(hcd, dev, eps, num_eps, mem_flags);
+   ret = hcd-driver-free_streams(hcd, dev, eps, num_eps, mem_flags);
+   if (ret  0)
+   return;
+
+   for (i = 0; i  num_eps; i++)
+   eps[i]-has_streams = 0;
 }
 EXPORT_SYMBOL_GPL(usb_free_streams);
 
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 001629c..4512eb3 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -71,6 +71,7 @@ struct usb_host_endpoint {
unsigned char *extra;   /* Extra descriptors */
int extralen;
int enabled;
+   int has_streams;
 };
 
 /* host-side wrapper for one interface setting's parsed descriptors */
-- 
1.8.3.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 4/5] usbfs: Add ep_to_host_endpoint helper function

2013-08-14 Thread Hans de Goede
Signed-off-by: Hans de Goede hdego...@redhat.com
---
 drivers/usb/core/devio.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index c7e946f..94e7839 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -753,6 +753,15 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned 
int requesttype,
return ret;
 }
 
+static struct usb_host_endpoint *ep_to_host_endpoint(struct usb_device *dev,
+unsigned char ep)
+{
+   if (ep  USB_ENDPOINT_DIR_MASK)
+   return dev-ep_in[ep  USB_ENDPOINT_NUMBER_MASK];
+   else
+   return dev-ep_out[ep  USB_ENDPOINT_NUMBER_MASK];
+}
+
 static int match_devt(struct device *dev, void *data)
 {
return dev-devt == (dev_t) (unsigned long) data;
@@ -1197,15 +1206,10 @@ static int proc_do_submiturb(struct dev_state *ps, 
struct usbdevfs_urb *uurb,
if (ret)
return ret;
}
-   if ((uurb-endpoint  USB_ENDPOINT_DIR_MASK) != 0) {
-   is_in = 1;
-   ep = ps-dev-ep_in[uurb-endpoint  USB_ENDPOINT_NUMBER_MASK];
-   } else {
-   is_in = 0;
-   ep = ps-dev-ep_out[uurb-endpoint  USB_ENDPOINT_NUMBER_MASK];
-   }
+   ep = ep_to_host_endpoint(ps-dev, uurb-endpoint);
if (!ep)
return -ENOENT;
+   is_in = (uurb-endpoint  USB_ENDPOINT_DIR_MASK) != 0;
 
u = 0;
switch(uurb-type) {
-- 
1.8.3.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 2/2] usb: musb: cppi41: Enable in device-TX mode

2013-08-14 Thread Bin Liu
Sebastian,

On Wed, Aug 14, 2013 at 2:16 AM, Sebastian Andrzej Siewior
bige...@linutronix.de wrote:
 On 08/13/2013 08:11 PM, Bin Liu wrote:
 Sebastian,

 Hi Bin,

 On Tue, Aug 13, 2013 at 12:38 PM, Sebastian Andrzej Siewior
 bige...@linutronix.de wrote:
 Since the musb-gadget code now calls the dma engine properly it is
 possible to enable it for the TX path in device mode.
 AM335x Advisory 1.0.13 says that we may lose the toggle bit on multiple
 RX transfers. There is a workaround in host mode but none in device mode
 and therefore RX transfers are disabled.
 1.0.13 only presents in PG1.0. It has been fixed in PG2.x. Maybe we
 should check for silicon rev here?

 Where do you have this from? My document says won't be fixed.

http://www.ti.com/lit/er/sprz360e/sprz360e.pdf
Table 4 shows 1.0.13 only affects PG1.0.

 If you say this is fixed in PG2+, then we don't this the workaround in
 host mode either, right?

Right.



 Regards,
 -Bin.

 Sebastian
--
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 net-next v2 2/3] net/usb/r8152: enable tx checksum

2013-08-14 Thread Hayes Wang
Enable tx checksum.

Signed-off-by: Hayes Wang hayesw...@realtek.com
---
 drivers/net/usb/r8152.c | 64 +
 1 file changed, 59 insertions(+), 5 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index abb0b9f..4d938a7 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -20,6 +20,8 @@
 #include linux/if_vlan.h
 #include linux/uaccess.h
 #include linux/list.h
+#include linux/ip.h
+#include linux/ipv6.h
 
 /* Version Information */
 #define DRIVER_VERSION v1.01.0 (2013/08/12)
@@ -314,8 +316,13 @@ struct tx_desc {
u32 opts1;
 #define TX_FS  (1  31) /* First segment of a packet */
 #define TX_LS  (1  30) /* Final segment of a packet */
-#define TX_LEN_MASK0x
+#define TX_LEN_MASK0x3
+
u32 opts2;
+#define UDP_CS (1  31) /* Calculate UDP/IP checksum */
+#define TCP_CS (1  30) /* Calculate TCP/IP checksum */
+#define IPV4_CS(1  29) /* Calculate IPv4 checksum */
+#define IPV6_CS(1  28) /* Calculate IPv6 checksum */
 };
 
 struct rx_agg {
@@ -968,6 +975,52 @@ err1:
return -ENOMEM;
 }
 
+static void
+r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc, struct sk_buff *skb)
+{
+   memset(desc, 0, sizeof(*desc));
+
+   desc-opts1 = cpu_to_le32((skb-len  TX_LEN_MASK) | TX_FS | TX_LS);
+
+   if (skb-ip_summed == CHECKSUM_PARTIAL) {
+   __be16 protocol;
+   u8 ip_protocol;
+   u32 opts2 = 0;
+
+   if (skb-protocol == htons(ETH_P_8021Q))
+   protocol = vlan_eth_hdr(skb)-h_vlan_encapsulated_proto;
+   else
+   protocol = skb-protocol;
+
+   switch (protocol) {
+   case htons(ETH_P_IP):
+   opts2 |= IPV4_CS;
+   ip_protocol = ip_hdr(skb)-protocol;
+   break;
+
+   case htons(ETH_P_IPV6):
+   opts2 |= IPV6_CS;
+   ip_protocol = ipv6_hdr(skb)-nexthdr;
+   break;
+
+   default:
+   ip_protocol = IPPROTO_RAW;
+   break;
+   }
+
+   if (ip_protocol == IPPROTO_TCP) {
+   opts2 |= TCP_CS;
+   opts2 |= (skb_transport_offset(skb)  0x7fff)  17;
+   } else if (ip_protocol == IPPROTO_UDP) {
+   opts2 |= UDP_CS;
+   } else {
+   WARN_ON_ONCE(1);
+   }
+
+   desc-opts2 = cpu_to_le32(opts2);
+   }
+}
+
 static void rx_bottom(struct r8152 *tp)
 {
struct net_device_stats *stats;
@@ -1097,8 +1150,7 @@ next_agg:
tx_desc = (struct tx_desc *)tx_data;
tx_data += sizeof(*tx_desc);
 
-   tx_desc-opts1 = cpu_to_le32((skb-len  TX_LEN_MASK) | TX_FS |
-TX_LS);
+   r8152_tx_csum(tp, tx_desc, skb);
memcpy(tx_data, skb-data, len);
agg-skb_num++;
agg-skb_len += len;
@@ -1256,7 +1308,7 @@ static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb,
agg-skb_num = agg-skb_len = 0;
 
len = skb-len;
-   tx_desc-opts1 = cpu_to_le32((skb-len  TX_LEN_MASK) | TX_FS | TX_LS);
+   r8152_tx_csum(tp, tx_desc, skb);
memcpy(tx_data, skb-data, len);
dev_kfree_skb_any(skb);
agg-skb_num++;
@@ -1977,7 +2029,9 @@ static int rtl8152_probe(struct usb_interface *intf,
tp-netdev = netdev;
netdev-netdev_ops = rtl8152_netdev_ops;
netdev-watchdog_timeo = RTL8152_TX_TIMEOUT;
-   netdev-features = ~NETIF_F_IP_CSUM;
+
+   netdev-features |= NETIF_F_IP_CSUM;
+   netdev-hw_features = NETIF_F_IP_CSUM;
SET_ETHTOOL_OPS(netdev, ops);
tp-speed = 0;
 
-- 
1.8.3.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 net-next v2 3/3] net/usb/r8152: enable interrupt transfer

2013-08-14 Thread Hayes Wang
Use the interrupt transfer to replace polling link status.

Signed-off-by: Hayes Wang hayesw...@realtek.com
---
 drivers/net/usb/r8152.c | 140 ++--
 1 file changed, 113 insertions(+), 27 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 4d938a7..ef2498c 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -272,6 +272,9 @@ enum rtl_register_content {
 
 #define RTL8152_MAX_TX 10
 #define RTL8152_MAX_RX 10
+#define INTBUFSIZE 2
+
+#define INTR_LINK  0x0004
 
 #define RTL8152_REQT_READ  0xc0
 #define RTL8152_REQT_WRITE 0x40
@@ -292,7 +295,8 @@ enum rtl_register_content {
 enum rtl8152_flags {
RTL8152_UNPLUG = 0,
RTL8152_SET_RX_MODE,
-   WORK_ENABLE
+   WORK_ENABLE,
+   RTL8152_LINK_CHG,
 };
 
 /* Define these values to match your device */
@@ -347,7 +351,9 @@ struct r8152 {
unsigned long flags;
struct usb_device *udev;
struct tasklet_struct tl;
+   struct usb_interface *intf;
struct net_device *netdev;
+   struct urb *intr_urb;
struct tx_agg tx_info[RTL8152_MAX_TX];
struct rx_agg rx_info[RTL8152_MAX_RX];
struct list_head rx_done, tx_free;
@@ -355,8 +361,10 @@ struct r8152 {
spinlock_t rx_lock, tx_lock;
struct delayed_work schedule;
struct mii_if_info mii;
+   int intr_interval;
u32 msg_enable;
u16 ocp_base;
+   u8 *intr_buff;
u8 version;
u8 speed;
 };
@@ -860,6 +868,62 @@ static void write_bulk_callback(struct urb *urb)
tasklet_schedule(tp-tl);
 }
 
+static void intr_callback(struct urb *urb)
+{
+   struct r8152 *tp;
+   __u16 *d;
+   int status = urb-status;
+   int res;
+
+   tp = urb-context;
+   if (!tp)
+   return;
+
+   if (!test_bit(WORK_ENABLE, tp-flags))
+   return;
+
+   if (test_bit(RTL8152_UNPLUG, tp-flags))
+   return;
+
+   switch (status) {
+   case 0: /* success */
+   break;
+   case -ECONNRESET:   /* unlink */
+   case -ESHUTDOWN:
+   netif_device_detach(tp-netdev);
+   case -ENOENT:
+   return;
+   case -EOVERFLOW:
+   netif_info(tp, intr, tp-netdev, intr status -EOVERFLOW\n);
+   goto resubmit;
+   /* -EPIPE:  should clear the halt */
+   default:
+   netif_info(tp, intr, tp-netdev, intr status %d\n, status);
+   goto resubmit;
+   }
+
+   d = urb-transfer_buffer;
+   if (INTR_LINK  __le16_to_cpu(d[0])) {
+   if (!(tp-speed  LINK_STATUS)) {
+   set_bit(RTL8152_LINK_CHG, tp-flags);
+   schedule_delayed_work(tp-schedule, 0);
+   }
+   } else {
+   if (tp-speed  LINK_STATUS) {
+   set_bit(RTL8152_LINK_CHG, tp-flags);
+   schedule_delayed_work(tp-schedule, 0);
+   }
+   }
+
+resubmit:
+   res = usb_submit_urb(urb, GFP_ATOMIC);
+   if (res == -ENODEV)
+   netif_device_detach(tp-netdev);
+   else if (res)
+   netif_err(tp, intr, tp-netdev,
+   can't resubmit intr, status %d\n, res);
+}
+
 static inline void *rx_agg_align(void *data)
 {
return (void *)ALIGN((uintptr_t)data, 8);
@@ -899,11 +963,24 @@ static void free_all_mem(struct r8152 *tp)
tp-tx_info[i].head = NULL;
}
}
+
+   if (tp-intr_urb) {
+   usb_free_urb(tp-intr_urb);
+   tp-intr_urb = NULL;
+   }
+
+   if (tp-intr_buff) {
+   kfree(tp-intr_buff);
+   tp-intr_buff = NULL;
+   }
 }
 
 static int alloc_all_mem(struct r8152 *tp)
 {
struct net_device *netdev = tp-netdev;
+   struct usb_interface *intf = tp-intf;
+   struct usb_host_interface *alt = intf-cur_altsetting;
+   struct usb_host_endpoint *ep_intr = alt-endpoint + 2;
struct urb *urb;
int node, i;
u8 *buf;
@@ -968,6 +1045,19 @@ static int alloc_all_mem(struct r8152 *tp)
list_add_tail(tp-tx_info[i].list, tp-tx_free);
}
 
+   tp-intr_urb = usb_alloc_urb(0, GFP_KERNEL);
+   if (!tp-intr_urb)
+   goto err1;
+
+   tp-intr_buff = kmalloc(INTBUFSIZE, GFP_KERNEL);
+   if (!tp-intr_buff)
+   goto err1;
+
+   tp-intr_interval = (int)ep_intr-desc.bInterval;
+   usb_fill_int_urb(tp-intr_urb, tp-udev, usb_rcvintpipe(tp-udev, 3),
+tp-intr_buff, INTBUFSIZE, intr_callback,
+tp, tp-intr_interval);
+
return 0;
 
 err1:
@@ -1228,8 +1318,10 @@ static void rtl8152_set_rx_mode(struct net_device 
*netdev)
 {
struct r8152 *tp = netdev_priv(netdev);
 
-   if (tp-speed  LINK_STATUS)
+   if (tp-speed  

[PATCH net-next v2 1/3] net/usb/r8152: support aggregation

2013-08-14 Thread Hayes Wang
Enable the tx/rx aggregation which could contain one or more packets
for each bulk in/out. This could reduce the loading of the host
controller by sending less bulk transfer.

The rx packets in the bulk in buffer should be 8-byte aligned, and
the tx packets in the bulk out buffer should be 4-byte aligned.

Signed-off-by: Hayes Wang hayesw...@realtek.com
---
 drivers/net/usb/r8152.c | 647 
 1 file changed, 486 insertions(+), 161 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 11c51f2..abb0b9f 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -19,9 +19,10 @@
 #include linux/crc32.h
 #include linux/if_vlan.h
 #include linux/uaccess.h
+#include linux/list.h
 
 /* Version Information */
-#define DRIVER_VERSION v1.0.0 (2013/05/03)
+#define DRIVER_VERSION v1.01.0 (2013/08/12)
 #define DRIVER_AUTHOR Realtek linux nic maintainers nic_s...@realtek.com
 #define DRIVER_DESC Realtek RTL8152 Based USB 2.0 Ethernet Adapters
 #define MODULENAME r8152
@@ -267,6 +268,9 @@ enum rtl_register_content {
FULL_DUP= 0x01,
 };
 
+#define RTL8152_MAX_TX 10
+#define RTL8152_MAX_RX 10
+
 #define RTL8152_REQT_READ  0xc0
 #define RTL8152_REQT_WRITE 0x40
 #define RTL8152_REQ_GET_REGS   0x05
@@ -285,7 +289,6 @@ enum rtl_register_content {
 /* rtl8152 flags */
 enum rtl8152_flags {
RTL8152_UNPLUG = 0,
-   RX_URB_FAIL,
RTL8152_SET_RX_MODE,
WORK_ENABLE
 };
@@ -315,13 +318,34 @@ struct tx_desc {
u32 opts2;
 };
 
+struct rx_agg {
+   struct list_head list;
+   struct urb *urb;
+   void *context;
+   void *buffer;
+   void *head;
+};
+
+struct tx_agg {
+   struct list_head list;
+   struct urb *urb;
+   void *context;
+   void *buffer;
+   void *head;
+   u32 skb_num;
+   u32 skb_len;
+};
+
 struct r8152 {
unsigned long flags;
struct usb_device *udev;
struct tasklet_struct tl;
struct net_device *netdev;
-   struct urb *rx_urb, *tx_urb;
-   struct sk_buff *tx_skb, *rx_skb;
+   struct tx_agg tx_info[RTL8152_MAX_TX];
+   struct rx_agg rx_info[RTL8152_MAX_RX];
+   struct list_head rx_done, tx_free;
+   struct sk_buff_head tx_queue;
+   spinlock_t rx_lock, tx_lock;
struct delayed_work schedule;
struct mii_if_info mii;
u32 msg_enable;
@@ -340,6 +364,7 @@ enum rtl_version {
  * The RTL chips use a 64 element hash table based on the Ethernet CRC.
  */
 static const int multicast_filter_limit = 32;
+static unsigned int rx_buf_sz = 16384;
 
 static
 int get_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data)
@@ -686,6 +711,9 @@ static void ocp_reg_write(struct r8152 *tp, u16 addr, u16 
data)
ocp_write_word(tp, MCU_TYPE_PLA, ocp_index, data);
 }
 
+static
+int r8152_submit_rx(struct r8152 *tp, struct rx_agg *agg, gfp_t mem_flags);
+
 static inline void set_ethernet_addr(struct r8152 *tp)
 {
struct net_device *dev = tp-netdev;
@@ -716,26 +744,6 @@ static int rtl8152_set_mac_address(struct net_device 
*netdev, void *p)
return 0;
 }
 
-static int alloc_all_urbs(struct r8152 *tp)
-{
-   tp-rx_urb = usb_alloc_urb(0, GFP_KERNEL);
-   if (!tp-rx_urb)
-   return 0;
-   tp-tx_urb = usb_alloc_urb(0, GFP_KERNEL);
-   if (!tp-tx_urb) {
-   usb_free_urb(tp-rx_urb);
-   return 0;
-   }
-
-   return 1;
-}
-
-static void free_all_urbs(struct r8152 *tp)
-{
-   usb_free_urb(tp-rx_urb);
-   usb_free_urb(tp-tx_urb);
-}
-
 static struct net_device_stats *rtl8152_get_stats(struct net_device *dev)
 {
return dev-stats;
@@ -743,129 +751,425 @@ static struct net_device_stats 
*rtl8152_get_stats(struct net_device *dev)
 
 static void read_bulk_callback(struct urb *urb)
 {
-   struct r8152 *tp;
-   unsigned pkt_len;
-   struct sk_buff *skb;
struct net_device *netdev;
-   struct net_device_stats *stats;
+   unsigned long lockflags;
int status = urb-status;
+   struct rx_agg *agg;
+   struct r8152 *tp;
int result;
-   struct rx_desc *rx_desc;
 
-   tp = urb-context;
+   agg = urb-context;
+   if (!agg)
+   return;
+
+   tp = agg-context;
if (!tp)
return;
+
if (test_bit(RTL8152_UNPLUG, tp-flags))
return;
+
+   if (!test_bit(WORK_ENABLE, tp-flags))
+   return;
+
netdev = tp-netdev;
-   if (!netif_device_present(netdev))
+   if (!netif_carrier_ok(netdev))
return;
 
-   stats = rtl8152_get_stats(netdev);
switch (status) {
case 0:
-   break;
+   if (urb-actual_length  ETH_ZLEN)
+   break;
+
+   spin_lock_irqsave(tp-rx_lock, lockflags);
+   list_add_tail(agg-list, tp-rx_done);
+   

[PATCH v3 3/3] usb: dwc3: Add Qualcomm DWC3 glue layer driver

2013-08-14 Thread Ivan T. Ivanov
From: Ivan T. Ivanov iiva...@mm-sol.com

DWC3 glue layer is hardware layer around Synopsys DesignWare
USB3 core. Its purpose is to supply Synopsys IP with required
clocks, voltages and interface it with the rest of the SoC.

Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com
---
 drivers/usb/dwc3/Kconfig|8 ++
 drivers/usb/dwc3/Makefile   |1 +
 drivers/usb/dwc3/dwc3-msm.c |  169 +++
 3 files changed, 178 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-msm.c

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index f969ea2..d845966 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -71,6 +71,14 @@ config USB_DWC3_PCI
  One such PCIe-based platform is Synopsys' PCIe HAPS model of
  this IP.
 
+config USB_DWC3_MSM
+   tristate Qualcomm MSM/APQ Platforms
+   default USB_DWC3
+   select USB_MSM_DWC3_PHYS
+   help
+ Recent Qualcomm SoCs ship with one DesignWare Core USB3 IP inside,
+ say 'Y' or 'M' if you have one such device.
+
 comment Debugging features
 
 config USB_DWC3_DEBUG
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index dd17601..5226681 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -32,3 +32,4 @@ endif
 obj-$(CONFIG_USB_DWC3_OMAP)+= dwc3-omap.o
 obj-$(CONFIG_USB_DWC3_EXYNOS)  += dwc3-exynos.o
 obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o
+obj-$(CONFIG_USB_DWC3_MSM) += dwc3-msm.o
diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c
new file mode 100644
index 000..5fb0a19
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-msm.c
@@ -0,0 +1,169 @@
+/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include linux/clk.h
+#include linux/err.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_platform.h
+#include linux/platform_device.h
+#include linux/regulator/consumer.h
+#include linux/usb/phy.h
+
+struct dwc3_msm {
+   struct device   *dev;
+   void __iomem*base;
+
+   struct clk  *core_clk;
+   struct clk  *iface_clk;
+   struct clk  *sleep_clk;
+   struct clk  *utmi_clk;
+
+   struct regulator*gdsc;
+};
+
+static int dwc3_msm_probe(struct platform_device *pdev)
+{
+   struct device_node *node = pdev-dev.of_node;
+   struct dwc3_msm *mdwc;
+   struct resource *res;
+   void __iomem *tcsr;
+   int ret = 0;
+
+   mdwc = devm_kzalloc(pdev-dev, sizeof(*mdwc), GFP_KERNEL);
+   if (!mdwc)
+   return -ENOMEM;
+
+   platform_set_drvdata(pdev, mdwc);
+   mdwc-dev = pdev-dev;
+
+   mdwc-gdsc = devm_regulator_get(mdwc-dev, gdsc);
+
+   mdwc-core_clk = devm_clk_get(pdev-dev, core_clk);
+   if (IS_ERR(mdwc-core_clk)) {
+   dev_err(pdev-dev, failed to get core_clk\n);
+   return PTR_ERR(mdwc-core_clk);
+   }
+
+   mdwc-iface_clk = devm_clk_get(pdev-dev, iface_clk);
+   if (IS_ERR(mdwc-iface_clk)) {
+   dev_err(pdev-dev, failed to get iface_clk\n);
+   return PTR_ERR(mdwc-iface_clk);
+   }
+
+   mdwc-sleep_clk = devm_clk_get(pdev-dev, sleep_clk);
+   if (IS_ERR(mdwc-sleep_clk)) {
+   dev_err(pdev-dev, failed to get sleep_clk\n);
+   return  PTR_ERR(mdwc-sleep_clk);
+   }
+
+   mdwc-utmi_clk = devm_clk_get(pdev-dev, utmi_clk);
+   if (IS_ERR(mdwc-utmi_clk)) {
+   dev_err(pdev-dev, failed to get utmi_clk\n);
+   return  PTR_ERR(mdwc-utmi_clk);
+   }
+
+   if (!IS_ERR(mdwc-gdsc)) {
+   ret = regulator_enable(mdwc-gdsc);
+   if (ret)
+   dev_err(mdwc-dev, cannot enable usb3 gdsc\n);
+   }
+
+   /*
+* DWC3 Core requires its CORE CLK (aka master / bus clk) to
+* run at 125Mhz in SSUSB mode and 60MHZ for HSUSB mode.
+*/
+   clk_set_rate(mdwc-core_clk, 12500);
+   clk_prepare_enable(mdwc-core_clk);
+   clk_prepare_enable(mdwc-iface_clk);
+   clk_prepare_enable(mdwc-sleep_clk);
+   clk_prepare_enable(mdwc-utmi_clk);
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   tcsr = devm_ioremap_resource(pdev-dev, res);
+   if (!tcsr) {
+   ret = PTR_ERR(tcsr);
+   goto dis_clks;
+   }
+
+   /*
+* Primary USB port is 

[PATCH v3 1/3] usb: dwc3: msm: Add device tree binding information

2013-08-14 Thread Ivan T. Ivanov
From: Ivan T. Ivanov iiva...@mm-sol.com

MSM USB3.0 core wrapper consist of USB3.0 IP from Synopsys
(SNPS) and HS, SS PHY's control and configuration registers.

It could operate in device mode (SS, HS, FS) and host
mode (SS, HS, FS, LS).

Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com
---
 .../devicetree/bindings/usb/msm-ssusb.txt  |  108 
 1 file changed, 108 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/msm-ssusb.txt

diff --git a/Documentation/devicetree/bindings/usb/msm-ssusb.txt 
b/Documentation/devicetree/bindings/usb/msm-ssusb.txt
new file mode 100644
index 000..43c73d8
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/msm-ssusb.txt
@@ -0,0 +1,108 @@
+MSM SuperSpeed DWC3 USB SoC controller
+
+
+DWC3 Highspeed USB PHY
+==
+Required properities :
+- compatible : sould be qcom,dwc3-hsphy;
+- reg : offset and length of the register set in the memory map
+- clocks : phandles to clock instances of the device tree nodes
+- clock-names :
+   xo : External reference clock 19 MHz
+   sleep_a_clk : Sleep clock, used when USB3 core goes into low
+   power mode (U3).
+supply-name-supply : phandle to the regulator device tree node
+Required supply-name are:
+   v1p8 : 1.8v supply for HSPHY
+   v3p3 : 3.3v supply for HSPHY
+   vbus : vbus supply for host mode
+   vddcx : vdd supply for HS-PHY digital circuit operation
+
+DWC3 Superspeed USB PHY
+===
+Required properities :
+- compatible : sould be qcom,dwc3-ssphy;
+- reg : offset and length of the register set in the memory map
+- clocks : phandles to clock instances of the device tree nodes
+- clock-names :
+   xo : External reference clock 19 MHz
+   ref_clk : Reference clock - used in host mode.
+supply-name-supply : phandle to the regulator device tree node
+Required supply-name are:
+   v1p8 : 1.8v supply for SS-PHY
+   vddcx : vdd supply for SS-PHY digital circuit operation
+
+DWC3 controller wrapper
+===
+Required properties :
+- compatible : should be qcom,dwc3
+- reg : offset and length of the register set in the memory map
+   offset and length of the TCSR register for routing USB
+   signals to either picoPHY0 or picoPHY1.
+- clocks : phandles to clock instances of the device tree nodes
+- clock-names :
+   core_clk : Master/Core clock, have to be = 125 MHz for SS
+   operation and = 60MHz for HS operation
+   iface_clk : System bus AXI clock
+   sleep_clk : Sleep clock, used when USB3 core goes into low
+   power mode (U3).
+   utmi_clk : Generated by HS-PHY. Used to clock the low power
+   parts of thr HS Link layer.
+Optional properties :
+- gdsc-supply : phandle to the globally distributed switch controller
+  regulator node to the USB controller.
+
+
+Sub nodes:
+==
+- Sub node for DWC3 USB3 controller.
+  This sub node is required property for device node. The properties
+  of this subnode are specified in dwc3.txt.
+
+Example device nodes:
+
+   dwc3_hsphy: phy@f92f8800 {
+   compatible = qcom,dwc3-hsphy;
+   reg = 0xf92f8800 0x30;
+
+   clocks = cxo, usb2a_phy_sleep_cxc;
+   clock-names = xo, sleep_a_clk;
+
+   vbus-supply = supply;
+   vddcx-supply = supply;
+   v1p8-supply = supply;
+   v3p3-supply = supply;
+   };
+
+   dwc3_ssphy: phy@f92f8830 {
+   compatible = qcom,dwc3-ssphy;
+   reg = 0xf92f8830 0x30;
+
+   clocks = cxo, usb30_mock_utmi_cxc;
+   clock-names = xo, ref_clk;
+
+   vddcx-supply = supply;
+   v1p8-supply = supply;
+   };
+
+   usb@fd4ab000 {
+   compatible = qcom,dwc3;
+   #address-cells = 1;
+   #size-cells = 1;
+   reg = 0xfd4ab000 0x4;
+
+   clocks = usb30_master_cxc, sys_noc_usb3_axi_cxc,
+   usb30_sleep_cxc, usb30_mock_utmi_cxc;
+   clock-names = core_clk, iface_clk, sleep_clk, utmi_clk;
+
+   gdsc-supply = supply;
+
+   ranges;
+   dwc3@f920 {
+   compatible = snps,dwc3;
+   reg = 0xf920 0xcd00;
+   interrupts = 0 131 0;
+   usb-phy = dwc3_hsphy, dwc3_ssphy;
+   tx-fifo-resize;
+   };
+   };
-- 
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 v3 0/3] DWC3 USB support for Qualcomm platform

2013-08-14 Thread Ivan T. Ivanov
From: Ivan T. Ivanov iiva...@mm-sol.com

Hi,

These patches add basic support for USB3.0 controllers found
on MSM platforms. USB3.0 core is based on Synopsys DesignWare 
SuperSpeed IP. 

Changes since v2:
* Several improvements in devicetree bindings description
* Disable regulators in glue layer if there is error during 
  ioremap.

Changes since first version:
* Split devicetree bindings description file to separate patch
* Address comments for device bindings description
* Fix typo in 'gdsc' requlator name.

Generated on top of Felipe 'testing' branch.

Regards,
Ivan

Ivan T. Ivanov (3):
  usb: dwc3: msm: Add device tree binding information
  usb: phy: Add Qualcomm SS-USB and HS-USB drivers for DWC3 core
  usb: dwc3: Add Qualcomm DWC3 glue layer driver

 .../devicetree/bindings/usb/msm-ssusb.txt  |  108 ++
 drivers/usb/dwc3/Kconfig   |8 +
 drivers/usb/dwc3/Makefile  |1 +
 drivers/usb/dwc3/dwc3-msm.c|  169 +
 drivers/usb/phy/Kconfig|   11 +
 drivers/usb/phy/Makefile   |2 +
 drivers/usb/phy/phy-msm-dwc3-hs.c  |  336 +
 drivers/usb/phy/phy-msm-dwc3-ss.c  |  383 
 8 files changed, 1018 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/msm-ssusb.txt
 create mode 100644 drivers/usb/dwc3/dwc3-msm.c
 create mode 100644 drivers/usb/phy/phy-msm-dwc3-hs.c
 create mode 100644 drivers/usb/phy/phy-msm-dwc3-ss.c

-- 
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 v3 2/3] usb: phy: Add Qualcomm SS-USB and HS-USB drivers for DWC3 core

2013-08-14 Thread Ivan T. Ivanov
From: Ivan T. Ivanov iiva...@mm-sol.com

These drivers handles control and configuration of the HS
and SS USB PHY transceivers. They are part of the driver
which manage Synopsys DesignWare USB3 controller stack
inside Qualcomm SoC's.

Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com
---
 drivers/usb/phy/Kconfig   |   11 ++
 drivers/usb/phy/Makefile  |2 +
 drivers/usb/phy/phy-msm-dwc3-hs.c |  336 
 drivers/usb/phy/phy-msm-dwc3-ss.c |  383 +
 4 files changed, 732 insertions(+)
 create mode 100644 drivers/usb/phy/phy-msm-dwc3-hs.c
 create mode 100644 drivers/usb/phy/phy-msm-dwc3-ss.c

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 5443958..40e83b5 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -202,6 +202,17 @@ config USB_RCAR_PHY
  To compile this driver as a module, choose M here: the
  module will be called phy-rcar-usb.
 
+config USB_MSM_DWC3_PHYS
+   tristate Qualcomm DWC3 USB controller PHY's support
+   depends on (USB || USB_GADGET)  ARCH_MSM
+   select USB_PHY
+   help
+ Enable this to support the USB PHY transceivers on MSM chips with
+ DWC3 USB core. It handles PHY initialization, clock management
+ required after resetting the hardware and power management.
+ This driver is required even for peripheral only or host only
+ mode configurations.
+
 config USB_ULPI
bool Generic ULPI Transceiver Driver
depends on ARM
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 98730ca..ddaa11c 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -24,6 +24,8 @@ obj-$(CONFIG_USB_EHCI_TEGRA)  += phy-tegra-usb.o
 obj-$(CONFIG_USB_GPIO_VBUS)+= phy-gpio-vbus-usb.o
 obj-$(CONFIG_USB_ISP1301)  += phy-isp1301.o
 obj-$(CONFIG_USB_MSM_OTG)  += phy-msm-usb.o
+obj-$(CONFIG_USB_MSM_DWC3_PHYS)+= phy-msm-dwc3-hs.o
+obj-$(CONFIG_USB_MSM_DWC3_PHYS)+= phy-msm-dwc3-ss.o
 obj-$(CONFIG_USB_MV_OTG)   += phy-mv-usb.o
 obj-$(CONFIG_USB_MXS_PHY)  += phy-mxs-usb.o
 obj-$(CONFIG_USB_RCAR_PHY) += phy-rcar-usb.o
diff --git a/drivers/usb/phy/phy-msm-dwc3-hs.c 
b/drivers/usb/phy/phy-msm-dwc3-hs.c
new file mode 100644
index 000..465a8f5
--- /dev/null
+++ b/drivers/usb/phy/phy-msm-dwc3-hs.c
@@ -0,0 +1,336 @@
+/* Copyright (c) 2013, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ */
+
+#include linux/clk.h
+#include linux/err.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of.h
+#include linux/platform_device.h
+#include linux/regulator/consumer.h
+#include linux/usb/phy.h
+
+/**
+ *  USB QSCRATCH Hardware registers
+ */
+#define QSCRATCH_CTRL_REG  (0x04)
+#define QSCRATCH_GENERAL_CFG   (0x08)
+#define PHY_CTRL_REG   (0x10)
+#define PARAMETER_OVERRIDE_X_REG   (0x14)
+#define CHARGING_DET_CTRL_REG  (0x18)
+#define CHARGING_DET_OUTPUT_REG(0x1c)
+#define ALT_INTERRUPT_EN_REG   (0x20)
+#define PHY_IRQ_STAT_REG   (0x24)
+#define CGCTL_REG  (0x28)
+
+#define PHY_3P3_VOL_MIN305 /* uV */
+#define PHY_3P3_VOL_MAX330 /* uV */
+#define PHY_3P3_HPM_LOAD   16000   /* uA */
+
+#define PHY_1P8_VOL_MIN180 /* uV */
+#define PHY_1P8_VOL_MAX180 /* uV */
+#define PHY_1P8_HPM_LOAD   19000   /* uA */
+
+/* TODO: these are suspicious */
+#define USB_VDDCX_NO   1   /* uV */
+#define USB_VDDCX_MIN  5   /* uV */
+#define USB_VDDCX_MAX  7   /* uV */
+
+struct msm_dwc3_hs_phy {
+   struct usb_phy  phy;
+   void __iomem*base;
+   struct device   *dev;
+
+   struct clk  *xo_clk;
+   struct clk  *sleep_a_clk;
+
+   struct regulator*v3p3;
+   struct regulator*v1p8;
+   struct regulator*vddcx;
+   struct regulator*vbus;
+};
+
+#definephy_to_dwc3_phy(x)  container_of((x), struct 

Re: kernel Oops: 0003 on usbhid_submit_report

2013-08-14 Thread Andreas Lillebø Holm
Hi,

On Tuesday, August 13, 2013 at 8:40 PM, Greg KH wrote:
  When communicating with AT90USB1287, at random intervals (1/25 boots)
  the linux hid_output_field Oopses and kills the communicating thread.
  The AT90USB1287 microcontroller uses LUFA library for usb/hid
  communication. It is trigged by a ioctl call from userspace and fails
  in a kernel paging request. The system is after the oops in a state
  where no hid commands is sent anymore and only a boot can fix the
  system.
   
  Keywords: usbhid hid
   
  Kernel version: Linux version 3.8.13-03081301-generic (apw@gomeisa) (gcc 
  version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #201305311535 SMP Fri May 31 
  19:44:30 UTC 2013
   
  Oopses:
  http://paste.debian.net/24305
  http://paste.debian.net/24306
  http://paste.debian.net/24307
   
  Code:
  The error is triggered by:
  ioctl(fd,HIDIOCSUSAGES, ref_multi_u);
  ioctl(fd,HIDIOCSREPORT, rep_info_u);
   
  Notes:
  It is very hard to reproduce so seems like race condition…
   
  Any tips to resolve/workaround this issue is appreciated and please
  let me know if my information is incomplete (This is my first kernel
  bug report)
  
  
  
  
 Any chance you can try a supported kernel, like 3.10.6 or 3.11-rc5 to
 see if that also causes problems? We can't do anything with
 distro-specific kernel releases like your 3.8.13 release from Ubuntu,
 sorry.


I've now tried with kernel 3.10.6 
(http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.6-saucy/) and I can 
trigger the same issue on this kernel.

Here is a paste from last Oops on this kernel:
http://paste.debian.net/24993/  

I am also using usbmon to monitor the usb bus traffic, but cannot see anything 
that should cause the driver to Oops.

Is there any way to find out what can trigger this issue?

Thanks
Andreas L. Holm


--
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] Documentation sysfs-bus-usb: Document all files used by libusb

2013-08-14 Thread Hans de Goede

Hi,

On 08/14/2013 12:18 PM, Johan Hovold wrote:

On Wed, Aug 14, 2013 at 11:17:57AM +0200, Hans de Goede wrote:

+What:  /sys/bus/usb/devices/.../busnum
+KernelVersion: 2.6.22
+Description:
+   Bus-number of the USB-bus the device is connected to.
+
+What:  /sys/bus/usb/devices/.../descriptors
+KernelVersion: 2.6.26
+Description:
+   Binary file containing cached descriptors of the device. The
+   binary data consists of first the device descriptor, and when
+   the descriptors for each configuration of the device.


You probably want s/when/then/ here, but perhaps

The binary data consists of the device descriptor followed by
 the descriptors for each configuration of the device.

would be more clear?


Yes, thanks, v4 is on its way :)

Regards,

Hans
--
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 0/1] Documentation sysfs-bus-usb: Document all files used by libusb v4

2013-08-14 Thread Hans de Goede
Hi All,

This patch adds documentation for all sysfs files used by libusb.

Changes in v2:
-Spelling fixes
-Add text about writing to bConfigurationValue, suggested by Alan Stern

Changes in v3:
-Rebase on latest usb-next

Changes in v4:
-Improve the wording for the descriptors text, suggested by Johan Hovold

Regards,

Hans
--
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] Documentation sysfs-bus-usb: Document all files used by libusb

2013-08-14 Thread Hans de Goede
Signed-off-by: Hans de Goede hdego...@redhat.com
---
 Documentation/ABI/testing/sysfs-bus-usb | 38 +
 1 file changed, 38 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-usb 
b/Documentation/ABI/testing/sysfs-bus-usb
index 9c8926c..0053ae2 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -263,3 +263,41 @@ Description:
Supported values are 0 - 15.
More information on how besl values map to microseconds can be 
found in
USB 2.0 ECN Errata for Link Power Management, section 4.10)
+
+What:  /sys/bus/usb/devices/.../devnum
+KernelVersion: since at least 2.6.18
+Description:
+   Device address on the USB bus.
+
+What:  /sys/bus/usb/devices/.../bConfigurationValue
+KernelVersion: since at least 2.6.18
+Description:
+   bConfigurationValue of the *active* configuration for the
+   device. Writing 0 or -1 to bConfigurationValue will reset the
+   active configuration (unconfigure the device). Writing
+   another value will change the active configuration.
+
+   Note that some devices, in violation of the USB spec, have a
+   configuration with a value equal to 0. Writing 0 to
+   bConfigurationValue for these devices will install that
+   configuration, rather then unconfigure the device.
+
+   Writing -1 will always unconfigure the device.
+
+What:  /sys/bus/usb/devices/.../busnum
+KernelVersion: 2.6.22
+Description:
+   Bus-number of the USB-bus the device is connected to.
+
+What:  /sys/bus/usb/devices/.../descriptors
+KernelVersion: 2.6.26
+Description:
+   Binary file containing cached descriptors of the device. The
+   binary data consists of the device descriptor followed by the
+   descriptors for each configuration of the device.
+   Note that the wTotalLength of the config descriptors can not
+   be trusted, as the device may have a smaller config descriptor
+   than it advertises. The bLength field of each (sub) descriptor
+   can be trusted, and can be used to seek forward one (sub)
+   descriptor at a time until the next config descriptor is found.
+   All descriptors read from this file are in bus-endian format
-- 
1.8.3.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 7/9] ARM: dts: omap5-uevm: Use reset-gpios for hsusb2_reset

2013-08-14 Thread Roger Quadros
We no longer need to model the RESET line as a regulator since
the USB phy-nop driver accepts reset-gpios property.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap5-uevm.dts |   13 +
 1 files changed, 1 insertions(+), 12 deletions(-)

diff --git a/arch/arm/boot/dts/omap5-uevm.dts b/arch/arm/boot/dts/omap5-uevm.dts
index 65d7b60..61eca53 100644
--- a/arch/arm/boot/dts/omap5-uevm.dts
+++ b/arch/arm/boot/dts/omap5-uevm.dts
@@ -27,21 +27,10 @@
regulator-max-microvolt = 300;
};
 
-   /* HS USB Port 2 RESET */
-   hsusb2_reset: hsusb2_reset_reg {
-   compatible = regulator-fixed;
-   regulator-name = hsusb2_reset;
-   regulator-min-microvolt = 330;
-   regulator-max-microvolt = 330;
-   gpio = gpio3 16 GPIO_ACTIVE_HIGH; /* gpio3_80 HUB_NRESET */
-   startup-delay-us = 7;
-   enable-active-high;
-   };
-
/* HS USB Host PHY on PORT 2 */
hsusb2_phy: hsusb2_phy {
compatible = usb-nop-xceiv;
-   reset-supply = hsusb2_reset;
+   reset-gpios = gpio3 16 0; /* gpio3_80 HUB_NRESET */
/**
  * FIXME
  * Put the right clock phandle here when available
-- 
1.7.4.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 5/9] ARM: dts: omap3-beagle: Use reset-gpios for hsusb2_reset

2013-08-14 Thread Roger Quadros
We no longer need to model the RESET line as a regulator since
the USB phy-nop driver accepts reset-gpios property.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap3-beagle.dts |   13 +
 1 files changed, 1 insertions(+), 12 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-beagle.dts 
b/arch/arm/boot/dts/omap3-beagle.dts
index dfd8310..a6dcc71 100644
--- a/arch/arm/boot/dts/omap3-beagle.dts
+++ b/arch/arm/boot/dts/omap3-beagle.dts
@@ -44,17 +44,6 @@
};
};
 
-   /* HS USB Port 2 RESET */
-   hsusb2_reset: hsusb2_reset_reg {
-   compatible = regulator-fixed;
-   regulator-name = hsusb2_reset;
-   regulator-min-microvolt = 330;
-   regulator-max-microvolt = 330;
-   gpio = gpio5 19 0;   /* gpio_147 */
-   startup-delay-us = 7;
-   enable-active-high;
-   };
-
/* HS USB Port 2 Power */
hsusb2_power: hsusb2_power_reg {
compatible = regulator-fixed;
@@ -68,7 +57,7 @@
/* HS USB Host PHY on PORT 2 */
hsusb2_phy: hsusb2_phy {
compatible = usb-nop-xceiv;
-   reset-supply = hsusb2_reset;
+   reset-gpios = gpio5 19 0;/* gpio_147 */
vcc-supply = hsusb2_power;
};
 
-- 
1.7.4.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 3/9] ARM: OMAP2+: omap-usb-host: Get rid of platform_data from struct usbhs_phy_data

2013-08-14 Thread Roger Quadros
The platform data bits can be inferred from the other members of
struct usbhs_phy_data. So get rid of the platform_data member.

Build the platform data for the PHY device in usbhs_init_phys() instead.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/mach-omap2/board-omap3beagle.c |6 --
 arch/arm/mach-omap2/usb-host.c  |   11 ++-
 arch/arm/mach-omap2/usb.h   |1 -
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c 
b/arch/arm/mach-omap2/board-omap3beagle.c
index 04c1165..47bca8f 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -278,18 +278,12 @@ static struct regulator_consumer_supply 
beagle_vsim_supply[] = {
 
 static struct gpio_led gpio_leds[];
 
-/* PHY's VCC regulator might be added later, so flag that we need it */
-static struct nop_usb_xceiv_platform_data hsusb2_phy_data = {
-   .needs_vcc = true,
-};
-
 static struct usbhs_phy_data phy_data[] = {
{
.port = 2,
.reset_gpio = 147,
.vcc_gpio = -1, /* updated in beagle_twl_gpio_setup */
.vcc_polarity = 1,  /* updated in beagle_twl_gpio_setup */
-   .platform_data = hsusb2_phy_data,
},
 };
 
diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c
index 2eb19d4..1626801 100644
--- a/arch/arm/mach-omap2/usb-host.c
+++ b/arch/arm/mach-omap2/usb-host.c
@@ -435,6 +435,7 @@ int usbhs_init_phys(struct usbhs_phy_data *phy, int 
num_phys)
struct platform_device *pdev;
char *phy_id;
struct platform_device_info pdevinfo;
+   struct nop_usb_xceiv_platform_data nop_pdata;
 
for (i = 0; i  num_phys; i++) {
 
@@ -455,11 +456,19 @@ int usbhs_init_phys(struct usbhs_phy_data *phy, int 
num_phys)
return -ENOMEM;
}
 
+   /* set platform data */
+   memset(nop_pdata, 0, sizeof(nop_pdata));
+   if (gpio_is_valid(phy-vcc_gpio))
+   nop_pdata.needs_vcc = true;
+   if (gpio_is_valid(phy-reset_gpio))
+   nop_pdata.needs_reset = true;
+   nop_pdata.type = USB_PHY_TYPE_USB2;
+
/* create a NOP PHY device */
memset(pdevinfo, 0, sizeof(pdevinfo));
pdevinfo.name = nop_name;
pdevinfo.id = phy-port;
-   pdevinfo.data = phy-platform_data;
+   pdevinfo.data = nop_pdata;
pdevinfo.size_data = sizeof(struct nop_usb_xceiv_platform_data);
 
scnprintf(phy_id, MAX_STR, nop_usb_xceiv.%d,
diff --git a/arch/arm/mach-omap2/usb.h b/arch/arm/mach-omap2/usb.h
index e7261eb..4ba2ae7 100644
--- a/arch/arm/mach-omap2/usb.h
+++ b/arch/arm/mach-omap2/usb.h
@@ -58,7 +58,6 @@ struct usbhs_phy_data {
int reset_gpio;
int vcc_gpio;
bool vcc_polarity;  /* 1 active high, 0 active low */
-   void *platform_data;
 };
 
 extern void usb_musb_init(struct omap_musb_board_data *board_data);
-- 
1.7.4.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 0/9] USB: phy: phy-nop: Manage RESET GPIO in the driver

2013-08-14 Thread Roger Quadros
Hi,

Modelling the RESET line as a regulator supply wasn't a good idea
as it abuses the regulator framework and makes adaptation
code/data more complex.

Instead, manage the RESET gpio line directly in the driver.

This also makes us easy to migrate to a dedicated GPIO RESET controller
whenever it becomes available. As of now, it doesn't seem to be making
it into 3.12.

*NOTE:* As there are changes to platform data, Patch 1 needs to be shared
between the arm-soc tree and usb tree.

Patch 1 is available at repo
git://github.com/rogerq/linux.git
in branch
phy-reset-common

Patch 2 contains the phy-nop driver changes
Patches 3 and 4 adapt legacy boot code to the phy-nop driver changes.
Patches 5, 6 and 7 adapt DT data to the binding changes.
Patch 8 is cleanup of omap3-beagle DT.
Patch 9 adds USB host support to omap3-beagle-xm using the new binding.

Patches are based on v3.11-rc5.
Tested leacy boot on omap3-beagle and omap3-beagle-xm
Tested DT boot on omap3-beagle, omap3-beagle-xm and omap4-panda-es

cheers,
-roger

---
Roger Quadros (9):
  usb: phy: nop: Add gpio_reset to platform data
  usb: phy: nop: Don't use regulator framework for RESET line
  ARM: OMAP2+: omap-usb-host: Get rid of platform_data from struct
usbhs_phy_data
  ARM: OMAP2+: usb-host: Adapt to USB phy-nop RESET line changes
  ARM: dts: omap3-beagle: Use reset-gpios for hsusb2_reset
  ARM: dts: omap4-panda: Use reset-gpios for hsusb1_reset
  ARM: dts: omap5-uevm: Use reset-gpios for hsusb2_reset
  ARM: dts: omap3-beagle: Make USB host pin naming consistent
  ARM: dts: omap3-beagle-xm: Add USB Host support

 .../devicetree/bindings/usb/usb-nop-xceiv.txt  |7 +-
 arch/arm/boot/dts/omap3-beagle-xm.dts  |   65 +---
 arch/arm/boot/dts/omap3-beagle.dts |   37 ---
 arch/arm/boot/dts/omap4-panda-common.dtsi  |   18 +-
 arch/arm/boot/dts/omap5-uevm.dts   |   13 +
 arch/arm/mach-omap2/board-omap3beagle.c|6 --
 arch/arm/mach-omap2/usb-host.c |   18 +++---
 arch/arm/mach-omap2/usb.h  |1 -
 drivers/usb/phy/phy-nop.c  |   48 +--
 include/linux/usb/nop-usb-xceiv.h  |4 +-
 10 files changed, 115 insertions(+), 102 deletions(-)

-- 
1.7.4.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 6/9] ARM: dts: omap4-panda: Use reset-gpios for hsusb1_reset

2013-08-14 Thread Roger Quadros
We no longer need to model the RESET line as a regulator since
the USB phy-nop driver accepts reset-gpios property.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap4-panda-common.dtsi |   18 +-
 1 files changed, 1 insertions(+), 17 deletions(-)

diff --git a/arch/arm/boot/dts/omap4-panda-common.dtsi 
b/arch/arm/boot/dts/omap4-panda-common.dtsi
index faa95b5..cf2b518 100644
--- a/arch/arm/boot/dts/omap4-panda-common.dtsi
+++ b/arch/arm/boot/dts/omap4-panda-common.dtsi
@@ -60,22 +60,6 @@
AFMR, Line In;
};
 
-   /*
-* Temp hack: Need to be replaced with the proper gpio-controlled
-* reset driver as soon it will be merged.
-* http://thread.gmane.org/gmane.linux.drivers.devicetree/36830
-*/
-   /* HS USB Port 1 RESET */
-   hsusb1_reset: hsusb1_reset_reg {
-   compatible = regulator-fixed;
-   regulator-name = hsusb1_reset;
-   regulator-min-microvolt = 330;
-   regulator-max-microvolt = 330;
-   gpio = gpio2 30 0;   /* gpio_62 */
-   startup-delay-us = 7;
-   enable-active-high;
-   };
-
/* HS USB Port 1 Power */
hsusb1_power: hsusb1_power_reg {
compatible = regulator-fixed;
@@ -97,7 +81,7 @@
/* HS USB Host PHY on PORT 1 */
hsusb1_phy: hsusb1_phy {
compatible = usb-nop-xceiv;
-   reset-supply = hsusb1_reset;
+   reset-gpios = gpio2 30 0;   /* gpio_62 */
vcc-supply = hsusb1_power;
/**
 * FIXME:
-- 
1.7.4.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 1/9] usb: phy: nop: Add gpio_reset to platform data

2013-08-14 Thread Roger Quadros
The GPIO number of the RESET line can be passed to the
driver using the gpio_reset member.

Signed-off-by: Roger Quadros rog...@ti.com
---
 include/linux/usb/nop-usb-xceiv.h |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/include/linux/usb/nop-usb-xceiv.h 
b/include/linux/usb/nop-usb-xceiv.h
index 148d351..1e57acb 100644
--- a/include/linux/usb/nop-usb-xceiv.h
+++ b/include/linux/usb/nop-usb-xceiv.h
@@ -9,7 +9,9 @@ struct nop_usb_xceiv_platform_data {
 
/* if set fails with -EPROBE_DEFER if can't get regulator */
unsigned int needs_vcc:1;
-   unsigned int needs_reset:1;
+   unsigned int needs_reset:1; /* Deprecated */
+
+   int gpio_reset;
 };
 
 #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE)  
defined(MODULE))
-- 
1.7.4.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 8/9] ARM: dts: omap3-beagle: Make USB host pin naming consistent

2013-08-14 Thread Roger Quadros
Use a common naming scheme mode0name.modename flags for the
USB host pins to be consistent.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap3-beagle.dts |   24 
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-beagle.dts 
b/arch/arm/boot/dts/omap3-beagle.dts
index a6dcc71..30f51f4 100644
--- a/arch/arm/boot/dts/omap3-beagle.dts
+++ b/arch/arm/boot/dts/omap3-beagle.dts
@@ -90,18 +90,18 @@
 
hsusbb2_pins: pinmux_hsusbb2_pins {
pinctrl-single,pins = 
-   0x5c0 (PIN_OUTPUT | MUX_MODE3)  /* 
usbb2_ulpitll_clk.usbb1_ulpiphy_clk */
-   0x5c2 (PIN_OUTPUT | MUX_MODE3)  /* 
usbb2_ulpitll_clk.usbb1_ulpiphy_stp */
-   0x5c4 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
usbb2_ulpitll_clk.usbb1_ulpiphy_dir */
-   0x5c6 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
usbb2_ulpitll_clk.usbb1_ulpiphy_nxt */
-   0x5c8 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
usbb2_ulpitll_clk.usbb1_ulpiphy_dat0 */
-   0x5cA (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
usbb2_ulpitll_clk.usbb1_ulpiphy_dat1 */
-   0x1a4 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
usbb2_ulpitll_clk.usbb1_ulpiphy_dat2 */
-   0x1a6 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
usbb2_ulpitll_clk.usbb1_ulpiphy_dat3 */
-   0x1a8 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
usbb2_ulpitll_clk.usbb1_ulpiphy_dat4 */
-   0x1aa (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
usbb2_ulpitll_clk.usbb1_ulpiphy_dat5 */
-   0x1ac (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
usbb2_ulpitll_clk.usbb1_ulpiphy_dat6 */
-   0x1ae (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
usbb2_ulpitll_clk.usbb1_ulpiphy_dat7 */
+   0x5c0 (PIN_OUTPUT | MUX_MODE3)  /* 
etk_d10.hsusb2_clk */
+   0x5c2 (PIN_OUTPUT | MUX_MODE3)  /* 
etk_d11.hsusb2_stp */
+   0x5c4 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
etk_d12.hsusb2_dir */
+   0x5c6 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
etk_d13.hsusb2_nxt */
+   0x5c8 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
etk_d14.hsusb2_data0 */
+   0x5cA (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
etk_d15.hsusb2_data1 */
+   0x1a4 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
mcspi1_cs3.hsusb2_data2 */
+   0x1a6 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
mcspi2_clk.hsusb2_data7 */
+   0x1a8 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
mcspi2_simo.hsusb2_data4 */
+   0x1aa (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
mcspi2_somi.hsusb2_data5 */
+   0x1ac (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
mcspi2_cs0.hsusb2_data6 */
+   0x1ae (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
mcspi2_cs1.hsusb2_data3 */
;
};
 
-- 
1.7.4.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/9] usb: phy: nop: Don't use regulator framework for RESET line

2013-08-14 Thread Roger Quadros
Modelling the RESET line as a regulator supply wasn't a good idea
as it kind of abuses the regulator framework and also makes adaptation
code more complex.

Instead, manage the RESET gpio line directly in the driver. Update
the device tree binding information.

This also makes us easy to migrate to a dedicated GPIO RESET controller
whenever it becomes available.

Signed-off-by: Roger Quadros rog...@ti.com
---
 .../devicetree/bindings/usb/usb-nop-xceiv.txt  |7 +--
 drivers/usb/phy/phy-nop.c  |   48 
 2 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt 
b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
index d7e2726..5535f3b 100644
--- a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
+++ b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
@@ -15,7 +15,7 @@ Optional properties:
 
 - vcc-supply: phandle to the regulator that provides RESET to the PHY.
 
-- reset-supply: phandle to the regulator that provides power to the PHY.
+- reset-gpios: Should specify the GPIO for reset.
 
 Example:
 
@@ -25,10 +25,9 @@ Example:
clocks = osc 0;
clock-names = main_clk;
vcc-supply = hsusb1_vcc_regulator;
-   reset-supply = hsusb1_reset_regulator;
+   reset-gpios = gpio1 7;
};
 
 hsusb1_phy is a NOP USB PHY device that gets its clock from an oscillator
 and expects that clock to be configured to 19.2MHz by the NOP PHY driver.
-hsusb1_vcc_regulator provides power to the PHY and hsusb1_reset_regulator
-controls RESET.
+hsusb1_vcc_regulator provides power to the PHY and GPIO 7 controls RESET.
diff --git a/drivers/usb/phy/phy-nop.c b/drivers/usb/phy/phy-nop.c
index 55445e5d..af5e1a6 100644
--- a/drivers/usb/phy/phy-nop.c
+++ b/drivers/usb/phy/phy-nop.c
@@ -35,6 +35,9 @@
 #include linux/clk.h
 #include linux/regulator/consumer.h
 #include linux/of.h
+#include linux/of_gpio.h
+#include linux/gpio.h
+#include linux/delay.h
 
 struct nop_usb_xceiv {
struct usb_phy phy;
@@ -42,6 +45,7 @@ struct nop_usb_xceiv {
struct clk *clk;
struct regulator *vcc;
struct regulator *reset;
+   int gpio_reset;
 };
 
 static struct platform_device *pd;
@@ -70,6 +74,15 @@ static int nop_set_suspend(struct usb_phy *x, int suspend)
return 0;
 }
 
+static void nop_gpio_reset(int gpio, int state)
+{
+   if (gpio_is_valid(gpio))
+   gpio_set_value(gpio, state);
+
+   if (state)
+   usleep_range(1, 2);
+}
+
 static int nop_init(struct usb_phy *phy)
 {
struct nop_usb_xceiv *nop = dev_get_drvdata(phy-dev);
@@ -82,11 +95,8 @@ static int nop_init(struct usb_phy *phy)
if (!IS_ERR(nop-clk))
clk_enable(nop-clk);
 
-   if (!IS_ERR(nop-reset)) {
-   /* De-assert RESET */
-   if (regulator_enable(nop-reset))
-   dev_err(phy-dev, Failed to de-assert reset\n);
-   }
+   /* De-assert RESET */
+   nop_gpio_reset(nop-gpio_reset, 1);
 
return 0;
 }
@@ -95,11 +105,8 @@ static void nop_shutdown(struct usb_phy *phy)
 {
struct nop_usb_xceiv *nop = dev_get_drvdata(phy-dev);
 
-   if (!IS_ERR(nop-reset)) {
-   /* Assert RESET */
-   if (regulator_disable(nop-reset))
-   dev_err(phy-dev, Failed to assert reset\n);
-   }
+   /* Assert RESET */
+   nop_gpio_reset(nop-gpio_reset, 0);
 
if (!IS_ERR(nop-clk))
clk_disable(nop-clk);
@@ -148,7 +155,6 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev)
int err;
u32 clk_rate = 0;
bool needs_vcc = false;
-   bool needs_reset = false;
 
nop = devm_kzalloc(pdev-dev, sizeof(*nop), GFP_KERNEL);
if (!nop)
@@ -166,13 +172,15 @@ static int nop_usb_xceiv_probe(struct platform_device 
*pdev)
clk_rate = 0;
 
needs_vcc = of_property_read_bool(node, vcc-supply);
-   needs_reset = of_property_read_bool(node, reset-supply);
+   nop-gpio_reset = of_get_named_gpio(node, reset-gpios, 0);
+   if (nop-gpio_reset == -EPROBE_DEFER)
+   return -EPROBE_DEFER;
 
} else if (pdata) {
type = pdata-type;
clk_rate = pdata-clk_rate;
needs_vcc = pdata-needs_vcc;
-   needs_reset = pdata-needs_reset;
+   nop-gpio_reset = pdata-gpio_reset;
}
 
nop-clk = devm_clk_get(pdev-dev, main_clk);
@@ -205,12 +213,14 @@ static int nop_usb_xceiv_probe(struct platform_device 
*pdev)
return -EPROBE_DEFER;
}
 
-   nop-reset = devm_regulator_get(pdev-dev, reset);
-   if (IS_ERR(nop-reset)) {
-   dev_dbg(pdev-dev, Error getting reset regulator: %ld\n,
-   

[PATCH 4/9] ARM: OMAP2+: usb-host: Adapt to USB phy-nop RESET line changes

2013-08-14 Thread Roger Quadros
The USB phy-nop nop driver expects the RESET line information
to be sent as a GPIO number via platform data. Adapt to that.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/mach-omap2/usb-host.c |   11 +--
 1 files changed, 1 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/usb-host.c b/arch/arm/mach-omap2/usb-host.c
index 1626801..4528b40 100644
--- a/arch/arm/mach-omap2/usb-host.c
+++ b/arch/arm/mach-omap2/usb-host.c
@@ -460,8 +460,7 @@ int usbhs_init_phys(struct usbhs_phy_data *phy, int 
num_phys)
memset(nop_pdata, 0, sizeof(nop_pdata));
if (gpio_is_valid(phy-vcc_gpio))
nop_pdata.needs_vcc = true;
-   if (gpio_is_valid(phy-reset_gpio))
-   nop_pdata.needs_reset = true;
+   nop_pdata.gpio_reset = phy-reset_gpio;
nop_pdata.type = USB_PHY_TYPE_USB2;
 
/* create a NOP PHY device */
@@ -483,14 +482,6 @@ int usbhs_init_phys(struct usbhs_phy_data *phy, int 
num_phys)
 
usb_bind_phy(ehci-omap.0, phy-port - 1, phy_id);
 
-   /* Do we need RESET regulator ? */
-   if (gpio_is_valid(phy-reset_gpio)) {
-   scnprintf(rail_name, MAX_STR,
-   hsusb%d_reset, phy-port);
-   usbhs_add_regulator(rail_name, phy_id, reset,
-   phy-reset_gpio, 1);
-   }
-
/* Do we need VCC regulator ? */
if (gpio_is_valid(phy-vcc_gpio)) {
scnprintf(rail_name, MAX_STR, hsusb%d_vcc, phy-port);
-- 
1.7.4.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 9/9] ARM: dts: omap3-beagle-xm: Add USB Host support

2013-08-14 Thread Roger Quadros
Provide RESET GPIO and Power regulator for the USB PHY,
the USB Host port mode and the PHY device for the controller.
Also provide pin multiplexer information for USB host pins.

We also relocate omap3_pmx_core pin definations so that they
are close to omap3_pmx_wkup pin definations.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/boot/dts/omap3-beagle-xm.dts |   65 -
 1 files changed, 56 insertions(+), 9 deletions(-)

diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts 
b/arch/arm/boot/dts/omap3-beagle-xm.dts
index afdb164..41df447 100644
--- a/arch/arm/boot/dts/omap3-beagle-xm.dts
+++ b/arch/arm/boot/dts/omap3-beagle-xm.dts
@@ -69,6 +69,23 @@
};
 
};
+
+   /* HS USB Port 2 Power */
+   hsusb2_power: hsusb2_power_reg {
+   compatible = regulator-fixed;
+   regulator-name = hsusb2_vbus;
+   regulator-min-microvolt = 330;
+   regulator-max-microvolt = 330;
+   gpio = twl_gpio 18 0;/* GPIO LEDA */
+   startup-delay-us = 7;
+   };
+
+   /* HS USB Host PHY on PORT 2 */
+   hsusb2_phy: hsusb2_phy {
+   compatible = usb-nop-xceiv;
+   reset-gpios = gpio5 19 0; /* gpio_147 */
+   vcc-supply = hsusb2_power;
+   };
 };
 
 omap3_pmx_wkup {
@@ -79,6 +96,37 @@
};
 };
 
+omap3_pmx_core {
+   pinctrl-names = default;
+   pinctrl-0 = 
+   hsusbb2_pins
+   ;
+
+   uart3_pins: pinmux_uart3_pins {
+   pinctrl-single,pins = 
+   0x16e (PIN_INPUT | PIN_OFF_WAKEUPENABLE | MUX_MODE0) /* 
uart3_rx_irrx.uart3_rx_irrx */
+   0x170 (PIN_OUTPUT | MUX_MODE0) /* 
uart3_tx_irtx.uart3_tx_irtx OUTPUT | MODE0 */
+   ;
+   };
+
+   hsusbb2_pins: pinmux_hsusbb2_pins {
+   pinctrl-single,pins = 
+   0x5c0 (PIN_OUTPUT | MUX_MODE3)  /* 
etk_d10.hsusb2_clk */
+   0x5c2 (PIN_OUTPUT | MUX_MODE3)  /* 
etk_d11.hsusb2_stp */
+   0x5c4 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
etk_d12.hsusb2_dir */
+   0x5c6 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
etk_d13.hsusb2_nxt */
+   0x5c8 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
etk_d14.hsusb2_data0 */
+   0x5cA (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
etk_d15.hsusb2_data1 */
+   0x1a4 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
mcspi1_cs3.hsusb2_data2 */
+   0x1a6 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
mcspi2_clk.hsusb2_data7 */
+   0x1a8 (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
mcspi2_simo.hsusb2_data4 */
+   0x1aa (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
mcspi2_somi.hsusb2_data5 */
+   0x1ac (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
mcspi2_cs0.hsusb2_data6 */
+   0x1ae (PIN_INPUT_PULLDOWN | MUX_MODE3)  /* 
mcspi2_cs1.hsusb2_data3 */
+   ;
+   };
+};
+
 i2c1 {
clock-frequency = 260;
 
@@ -148,15 +196,6 @@
power = 50;
 };
 
-omap3_pmx_core {
-   uart3_pins: pinmux_uart3_pins {
-   pinctrl-single,pins = 
-   0x16e (PIN_INPUT | PIN_OFF_WAKEUPENABLE | MUX_MODE0) /* 
uart3_rx_irrx.uart3_rx_irrx */
-   0x170 (PIN_OUTPUT | MUX_MODE0) /* 
uart3_tx_irtx.uart3_tx_irtx OUTPUT | MODE0 */
-   ;
-   };
-};
-
 uart3 {
pinctrl-names = default;
pinctrl-0 = uart3_pins;
@@ -166,3 +205,11 @@
pinctrl-names = default;
pinctrl-0 = gpio1_pins;
 };
+
+usbhshost {
+   port2-mode = ehci-phy;
+};
+
+usbhsehci {
+   phys = 0 hsusb2_phy;
+};
-- 
1.7.4.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: 3.10.4: kmemleak in usb_get_bos_descriptor()?

2013-08-14 Thread Alan Stern
On Tue, 13 Aug 2013, Sarah Sharp wrote:

  Martin is right; the BOS descriptors are leaked in 
  usb_reset_and_verify_device().  We need to store the old descriptor,
  compare it with the new one following the reset, and delete one of them 
  afterward.  I haven't had time to fix this.
 
 I'll put it in my list of future tasks to give to Xenia. :)
 
 Alan, if you have any other small tasks for OPW interns, please let me
 know.

Good idea.  I'll keep it in mind.

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: [GIT PULL] USB patches for v3.12 merge window

2013-08-14 Thread Felipe Balbi
Hi,

On Tue, Aug 13, 2013 at 03:29:45PM -0700, Greg KH wrote:
 On Tue, Aug 13, 2013 at 03:01:23PM -0500, Felipe Balbi wrote:
  Hi,
  
  On Tue, Aug 13, 2013 at 02:48:42PM -0500, Felipe Balbi wrote:
   On Tue, Aug 13, 2013 at 02:41:25PM -0500, Felipe Balbi wrote:
Hi Greg,

Here's my pull request for v3.12 merge window. I know there are a bunch
of patches pending in the mailing list but I won't have time to fully
review them before merging so I decided that it's best to delay a merge
window than it is to cause a bunch of regressions.

Oh yeah, the patches under arch/arm got Acked by Tony Lindgren.

Let me know if you want any changes to the pull request.
   
   just now I saw the build failure Stephen reported. Please don't merge
   this in yet, I'll put a patch on top to fix the build failure.
  
  now fixed, here's the pull updated pull request:
  
  The following changes since commit 5ae90d8e467e625e447000cb4335c4db973b1095:
  
Linux 3.11-rc3 (2013-07-28 20:53:33 -0700)
  
  are available in the git repository at:
  
git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git 
  tags/usb-for-v3.12
  
  for you to fetch changes up to 8b841cb217fac676498de3dfe8fabe38b39cba4e:
  
usb: phy: am335x: include linux/err.h (2013-08-13 14:59:13 -0500)
 
 I've pulled this now.  There were some merge conflicts that I had to
 resolve by hand.  Please check that I got it all correct, it builds for
 me, but that doesn't always mean much...

your resolution looks correct to me.

thanks

-- 
balbi


signature.asc
Description: Digital signature


Re: USB suspend/resume sequence

2013-08-14 Thread Alan Stern
On Wed, 14 Aug 2013, Oliver Neukum wrote:

 On Wed, 2013-08-14 at 13:24 +0530, Vivek Gautam wrote:
  Hi all,
  
  
  Going through the power suspend/resume sequence of USB, got hit by a doubt.
  
  I am not able to figure out how the USB core driver takes care of
 
 It doesn't.

All it does is enable the remote wakeup feature, if needed, and carry 
out the low-level port operations for suspend and resume.  It also 
invokes the interface drivers' suspend and resume callbacks.

  devices and root-hubs across suspend/resume. Are the device contexts
  saved somewhere and then restored back on resume ?
 
 Usually not. The state of interfaces are the responsibility of interface
 drivers (colloquially called device drivers). Most devices just don't
 offer an API for saving state. The drivers recreate as opposed to
 restore the state.

Most of the time, the drivers don't do either.  USB devices are
required to preserve their state across a suspend; this is part of the
USB spec.

  How does the suspend/resume sequence taken care by drivers/usb/core/.. ?
 
 The generic driver core guarantees that suspend()/resume() are called
 in the right sequence.
 
  One more question here:
  If a hub on USB bus is getting re-enumerated, is it really necessary
  that its child devices shall also be re-enumerated ? Is there someway
 
 Yes.

It depends on what you mean by re-enumerated.  It is indeed necessary
to query the child devices for their descriptors.  But it may not be
necessary to assign addresses to the devices or use their descriptor
values to create new data structures (if the descriptors haven't
changed then we can keep using the old structures).

  out in which we can save the child-devices' context pointers and then
  once hub has been re-enumerated back, we restore back them.
 
 How do you know they are identical?

What do you mean by context pointer?

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: [PATCH v3 2/3] usb: phy: Add Qualcomm SS-USB and HS-USB drivers for DWC3 core

2013-08-14 Thread Josh Cartwright
On Wed, Aug 14, 2013 at 03:59:42PM +0300, Ivan T. Ivanov wrote:
 From: Ivan T. Ivanov iiva...@mm-sol.com
 
 These drivers handles control and configuration of the HS
 and SS USB PHY transceivers. They are part of the driver
 which manage Synopsys DesignWare USB3 controller stack
 inside Qualcomm SoC's.
 
 Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com
 ---
[..]
 diff --git a/drivers/usb/phy/phy-msm-dwc3-hs.c 
 b/drivers/usb/phy/phy-msm-dwc3-hs.c
 new file mode 100644
 index 000..465a8f5
 --- /dev/null
 +++ b/drivers/usb/phy/phy-msm-dwc3-hs.c
[..]
 +
 +struct msm_dwc3_hs_phy {
 + struct usb_phy  phy;
 + void __iomem*base;
 + struct device   *dev;
 +
 + struct clk  *xo_clk;
 + struct clk  *sleep_a_clk;
 +
 + struct regulator*v3p3;
 + struct regulator*v1p8;
 + struct regulator*vddcx;
 + struct regulator*vbus;
 +};
 +
 +#define  phy_to_dwc3_phy(x)  container_of((x), struct 
 msm_dwc3_hs_phy, phy)
 +
 +
 +/**
 + *
 + * Write register with debug info.

what debug info?

 + *
 + * @base - DWC3 base virtual address.
 + * @offset - register offset.
 + * @val - value to write.
 + *
 + */
 +static inline void msm_dwc3_hs_write(void *base, u32 offset, u32 val)

You've dropped __iomem here; have you run through sparse?

 +{
 + iowrite32(val, base + offset);
 +}
 +
 +/**
 + * Write register and read back masked value to confirm it is written
 + *
 + * @base - DWC3 base virtual address.
 + * @offset - register offset.
 + * @mask - register bitmask specifying what should be updated
 + * @val - value to write.
 + *
 + */
 +static inline void msm_dwc3_hs_write_readback(void *base, u32 offset,
 + const u32 mask, u32 val)
 +{

Same comment here.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
--
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 suspend/resume sequence

2013-08-14 Thread Alan Stern
On Wed, 14 Aug 2013, Oliver Neukum wrote:

 On Wed, 2013-08-14 at 14:46 +0530, Vivek Gautam wrote:
 
 Hi,
 
   devices and root-hubs across suspend/resume. Are the device contexts
   saved somewhere and then restored back on resume ?
  
   Usually not. The state of interfaces are the responsibility of interface
   drivers (colloquially called device drivers). Most devices just don't
   offer an API for saving state. The drivers recreate as opposed to
   restore the state.
  
  How does then PERSIST_ENABLED option work then ? With this option enabled,

The Persist mechanism is explained in Documentation/usb/persist.txt.

  on a system resume, the USB device attached to the root-hub are not
  re-enumerated, right ?

Again, it depends on what you mean by re-enumerated.

 Exactly that way. You recreate the state of the device.
 
  Possibly i am getting confused here.
 
 Well. There are two ways to make a device go to the same state
 
 a) you have primitives to save and restore that state
 b) you recognize that the state is the result of a sequence
 of operations. You repeat that sequence.
 
 That is the basic idea from a high level of abstraction.
 
  How would a usb_suspend_interface() and usb_suspend_device() differ.
 
 Have a look at drivers/usb/core/generic.c

Those two routines are part of drivers.c, not generic.c.  Broadly 
speaking, usb_suspend_interface() notifies the interface drivers about 
the upcoming suspend, whereas usb_suspend_device() carries out the 
actual suspend operation.

  Is it that, from the interface only the device information is extracted ?
  Can't we catch hold of usb_device pointers of hub and child devices ?
 
 We can. And that is how persist works. But it may fail.
 Possibly I am misunderstanding you.

The questions aren't very clear.

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: Non-enumerable devices on USB and other enumerable buses

2013-08-14 Thread Alan Stern
On Wed, 14 Aug 2013, Mark Brown wrote:

 On Mon, Aug 12, 2013 at 09:04:00PM -0400, Alan Stern wrote:
 
  The bus code would need hooks installed wherever the platform wants to 
  do something extra.  This could end up growing to a lot of hooks.  How 
  can the whole thing be done in a reasonable fashion?
 
 I'd expect that we're just looking at hooks around connection and
 disconnection here here - if we're looking at much more it seems like we
 must be doing something wrong.

Connection and disconnection of what?

In the example mentioned earlier, the GPIOs to power an on-board USB
hub would have to be initialized when the host controller was started.  
You wouldn't want to wait for the on-board hub to be detected, because
without those GPIOs set properly, it never would be discovered on the
USB bus.  Right?

Perhaps the platform-level code would need to hook into the places
where the discoverable bus is registered and unregistered.

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: [PATCH v3 2/3] usb: phy: Add Qualcomm SS-USB and HS-USB drivers for DWC3 core

2013-08-14 Thread Ivan T. Ivanov

Hi, 

On Wed, 2013-08-14 at 09:20 -0500, Josh Cartwright wrote: 
 On Wed, Aug 14, 2013 at 03:59:42PM +0300, Ivan T. Ivanov wrote:
  From: Ivan T. Ivanov iiva...@mm-sol.com
  
  These drivers handles control and configuration of the HS
  and SS USB PHY transceivers. They are part of the driver
  which manage Synopsys DesignWare USB3 controller stack
  inside Qualcomm SoC's.
  
  Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com
  ---
 [..]
  diff --git a/drivers/usb/phy/phy-msm-dwc3-hs.c 
  b/drivers/usb/phy/phy-msm-dwc3-hs.c
  new file mode 100644
  index 000..465a8f5
  --- /dev/null
  +++ b/drivers/usb/phy/phy-msm-dwc3-hs.c
 [..]
  +
  +struct msm_dwc3_hs_phy {
  +   struct usb_phy  phy;
  +   void __iomem*base;
  +   struct device   *dev;
  +
  +   struct clk  *xo_clk;
  +   struct clk  *sleep_a_clk;
  +
  +   struct regulator*v3p3;
  +   struct regulator*v1p8;
  +   struct regulator*vddcx;
  +   struct regulator*vbus;
  +};
  +
  +#definephy_to_dwc3_phy(x)  container_of((x), struct 
  msm_dwc3_hs_phy, phy)
  +
  +
  +/**
  + *
  + * Write register with debug info.
 
 what debug info?

Will fix this. It was left from the earliest versions of the functions. 

 
  + *
  + * @base - DWC3 base virtual address.
  + * @offset - register offset.
  + * @val - value to write.
  + *
  + */
  +static inline void msm_dwc3_hs_write(void *base, u32 offset, u32 val)
 
 You've dropped __iomem here; have you run through sparse?

Obviously not :-). Thanks for noticing this.

 
  +{
  +   iowrite32(val, base + offset);
  +}
  +
  +/**
  + * Write register and read back masked value to confirm it is written
  + *
  + * @base - DWC3 base virtual address.
  + * @offset - register offset.
  + * @mask - register bitmask specifying what should be updated
  + * @val - value to write.
  + *
  + */
  +static inline void msm_dwc3_hs_write_readback(void *base, u32 offset,
  +   const u32 mask, u32 val)
  +{
 
 Same comment here.

Will be fixed in next version.

Thanks,
Ivan

--
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: RTL8192CU module device HW:ID support

2013-08-14 Thread srenaud20
Well... finally it doesn't work.

When added to sw.c, the key is powered on, it's MAC address and few networks 
can be seen.

But I can't connect to any network.
--
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 01/15] drivers: phy: add generic PHY framework

2013-08-14 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 14 August 2013 04:34 AM, Tomasz Figa wrote:
 On Wednesday 14 of August 2013 00:19:28 Sylwester Nawrocki wrote:
 W dniu 2013-08-13 14:05, Kishon Vijay Abraham I pisze:
 On Tuesday 13 August 2013 05:07 PM, Tomasz Figa wrote:
 On Tuesday 13 of August 2013 16:14:44 Kishon Vijay Abraham I wrote:
 On Wednesday 31 July 2013 11:45 AM, Felipe Balbi wrote:
 On Wed, Jul 31, 2013 at 11:14:32AM +0530, Kishon Vijay Abraham I 
 wrote:
 IMHO we need a lookup method for PHYs, just like for clocks,
 regulators, PWMs or even i2c busses because there are complex
 cases
 when passing just a name using platform data will not work. I
 would
 second what Stephen said [1] and define a structure doing
 things
 in a
 DT-like way.

 Example;

 [platform code]

 static const struct phy_lookup my_phy_lookup[] = {

PHY_LOOKUP(s3c-hsotg.0, otg, samsung-usbphy.1,
phy.2),

 The only problem here is that if *PLATFORM_DEVID_AUTO* is used
 while
 creating the device, the ids in the device name would change
 and
 PHY_LOOKUP wont be useful.

 I don't think this is a problem. All the existing lookup
 methods
 already
 use ID to identify devices (see regulators, clkdev, PWMs, i2c,
 ...). You
 can simply add a requirement that the ID must be assigned
 manually,
 without using PLATFORM_DEVID_AUTO to use PHY lookup.

 And I'm saying that this idea, of using a specific name and id,
 is
 frought with fragility and will break in the future in various
 ways
 when
 devices get added to systems, making these strings constantly
 have
 to be
 kept up to date with different board configurations.

 People, NEVER, hardcode something like an id.  The fact that
 this
 happens today with the clock code, doesn't make it right, it
 makes
 the
 clock code wrong.  Others have already said that this is wrong
 there
 as
 well, as systems change and dynamic ids get used more and more.

 Let's not repeat the same mistakes of the past just because we
 refuse to
 learn from them...

 So again, the find a phy by a string functions should be
 removed,
 the
 device id should be automatically created by the phy core just
 to
 make
 things unique in sysfs, and no driver code should _ever_ be
 reliant
 on
 the number that is being created, and the pointer to the phy
 structure
 should be used everywhere instead.

 With those types of changes, I will consider merging this
 subsystem,
 but
 without them, sorry, I will not.

 I'll agree with Greg here, the very fact that we see people
 trying to
 add a requirement of *NOT* using PLATFORM_DEVID_AUTO already
 points
 to a big problem in the framework.

 The fact is that if we don't allow PLATFORM_DEVID_AUTO we will
 end up
 adding similar infrastructure to the driver themselves to make
 sure
 we
 don't end up with duplicate names in sysfs in case we have
 multiple
 instances of the same IP in the SoC (or several of the same PCIe
 card).
 I really don't want to go back to that.

 If we are using PLATFORM_DEVID_AUTO, then I dont see any way we
 can
 give the correct binding information to the PHY framework. I think
 we
 can drop having this non-dt support in PHY framework? I see only
 one
 platform (OMAP3) going to be needing this non-dt support and we
 can
 use the USB PHY library for it.

 you shouldn't drop support for non-DT platform, in any case we
 lived
 without DT (and still do) for years. Gotta find a better way ;-)

 hmm..

 how about passing the device names of PHY in platform data of the
 controller? It should be deterministic as the PHY framework assigns
 its
 own id and we *don't* want to add any requirement that the ID must
 be
 assigned manually without using PLATFORM_DEVID_AUTO. We can get rid
 of
 *phy_init_data* in the v10 patch series.

 OK, so the PHY device name would have a fixed part, passed as
 platform data of the controller and a variable part appended
 by the PHY core, depending on the number of registered PHYs ?

 Then same PHY names would be passed as the PHY provider driver's
 platform data ?

 Then if there are 2 instances of the above (same names in platform
 data) how would be determined which PHY controller is linked to
 which PHY supplier ?

 I guess you want each device instance to have different PHY device
 names already in platform data ? That might work. We probably will
 be focused mostly on DT anyway. It seem without DT we are trying
 to find some layer that would allow us to couple relevant devices
 and overcome driver core inconvenience that it provides to means
 to identify specific devices in advance. :) Your proposal sounds
 reasonable, however I might be missing some details or corner cases.

 What about slightly altering the concept of v9 to pass a pointer to
 struct device instead of device name inside phy_init_data?

 As Felipe said, we don't want to pass pointers in platform_data
 to/from random subsystems. We pass data, passing pointers would
 be a total mess IMHO.
 
 Well, this is a total mess anyway... I don't really get the point of using 
 

Re: [PATCH 2/9] usb: phy: nop: Don't use regulator framework for RESET line

2013-08-14 Thread Philipp Zabel
Hi Roger,

Am Mittwoch, den 14.08.2013, 16:58 +0300 schrieb Roger Quadros:
 Modelling the RESET line as a regulator supply wasn't a good idea
 as it kind of abuses the regulator framework and also makes adaptation
 code more complex.
 
 Instead, manage the RESET gpio line directly in the driver. Update
 the device tree binding information.
 
 This also makes us easy to migrate to a dedicated GPIO RESET controller
 whenever it becomes available.
 
 Signed-off-by: Roger Quadros rog...@ti.com

using the reset-gpios property
Acked-by: Philipp Zabel p.za...@pengutronix.de

 ---
  .../devicetree/bindings/usb/usb-nop-xceiv.txt  |7 +--
  drivers/usb/phy/phy-nop.c  |   48 
 
  2 files changed, 32 insertions(+), 23 deletions(-)
 
 diff --git a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt 
 b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
 index d7e2726..5535f3b 100644
 --- a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
 +++ b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt
 @@ -15,7 +15,7 @@ Optional properties:
  
  - vcc-supply: phandle to the regulator that provides RESET to the PHY.
  
 -- reset-supply: phandle to the regulator that provides power to the PHY.
 +- reset-gpios: Should specify the GPIO for reset.

  Example:
  
 @@ -25,10 +25,9 @@ Example:
   clocks = osc 0;
   clock-names = main_clk;
   vcc-supply = hsusb1_vcc_regulator;
 - reset-supply = hsusb1_reset_regulator;
 + reset-gpios = gpio1 7;

Yes, although the example should probably include GPIO_ACTIVE_LOW or
GPIO_ACTIVE_HIGH flags.

   };
  
  hsusb1_phy is a NOP USB PHY device that gets its clock from an oscillator
  and expects that clock to be configured to 19.2MHz by the NOP PHY driver.
 -hsusb1_vcc_regulator provides power to the PHY and hsusb1_reset_regulator
 -controls RESET.
 +hsusb1_vcc_regulator provides power to the PHY and GPIO 7 controls RESET.
 diff --git a/drivers/usb/phy/phy-nop.c b/drivers/usb/phy/phy-nop.c
 index 55445e5d..af5e1a6 100644
 --- a/drivers/usb/phy/phy-nop.c
 +++ b/drivers/usb/phy/phy-nop.c
 @@ -35,6 +35,9 @@
  #include linux/clk.h
  #include linux/regulator/consumer.h
  #include linux/of.h
 +#include linux/of_gpio.h
 +#include linux/gpio.h
 +#include linux/delay.h
  
  struct nop_usb_xceiv {
   struct usb_phy phy;
 @@ -42,6 +45,7 @@ struct nop_usb_xceiv {
   struct clk *clk;
   struct regulator *vcc;
   struct regulator *reset;
 + int gpio_reset;
  };
  
  static struct platform_device *pd;
 @@ -70,6 +74,15 @@ static int nop_set_suspend(struct usb_phy *x, int suspend)
   return 0;
  }
  
 +static void nop_gpio_reset(int gpio, int state)
 +{
 + if (gpio_is_valid(gpio))
 + gpio_set_value(gpio, state);
 +
 + if (state)
 + usleep_range(1, 2);
 +}
 +
  static int nop_init(struct usb_phy *phy)
  {
   struct nop_usb_xceiv *nop = dev_get_drvdata(phy-dev);
 @@ -82,11 +95,8 @@ static int nop_init(struct usb_phy *phy)
   if (!IS_ERR(nop-clk))
   clk_enable(nop-clk);
  
 - if (!IS_ERR(nop-reset)) {
 - /* De-assert RESET */
 - if (regulator_enable(nop-reset))
 - dev_err(phy-dev, Failed to de-assert reset\n);
 - }
 + /* De-assert RESET */
 + nop_gpio_reset(nop-gpio_reset, 1);
  
   return 0;
  }
 @@ -95,11 +105,8 @@ static void nop_shutdown(struct usb_phy *phy)
  {
   struct nop_usb_xceiv *nop = dev_get_drvdata(phy-dev);
  
 - if (!IS_ERR(nop-reset)) {
 - /* Assert RESET */
 - if (regulator_disable(nop-reset))
 - dev_err(phy-dev, Failed to assert reset\n);
 - }
 + /* Assert RESET */
 + nop_gpio_reset(nop-gpio_reset, 0);
  
   if (!IS_ERR(nop-clk))
   clk_disable(nop-clk);
 @@ -148,7 +155,6 @@ static int nop_usb_xceiv_probe(struct platform_device 
 *pdev)
   int err;
   u32 clk_rate = 0;
   bool needs_vcc = false;
 - bool needs_reset = false;
  
   nop = devm_kzalloc(pdev-dev, sizeof(*nop), GFP_KERNEL);
   if (!nop)
 @@ -166,13 +172,15 @@ static int nop_usb_xceiv_probe(struct platform_device 
 *pdev)
   clk_rate = 0;
  
   needs_vcc = of_property_read_bool(node, vcc-supply);
 - needs_reset = of_property_read_bool(node, reset-supply);
 + nop-gpio_reset = of_get_named_gpio(node, reset-gpios, 0);

I'd suggest to use of_get_named_gpio_flags to also obtain the polarity
from the flags.

 + if (nop-gpio_reset == -EPROBE_DEFER)
 + return -EPROBE_DEFER;
  
   } else if (pdata) {
   type = pdata-type;
   clk_rate = pdata-clk_rate;
   needs_vcc = pdata-needs_vcc;
 - needs_reset = pdata-needs_reset;
 + nop-gpio_reset = pdata-gpio_reset;
   }
  
   nop-clk = devm_clk_get(pdev-dev, 

Re: Non-enumerable devices on USB and other enumerable buses

2013-08-14 Thread Mark Brown
On Wed, Aug 14, 2013 at 10:27:26AM -0400, Alan Stern wrote:
 On Wed, 14 Aug 2013, Mark Brown wrote:

  I'd expect that we're just looking at hooks around connection and
  disconnection here here - if we're looking at much more it seems like we
  must be doing something wrong.

 Connection and disconnection of what?

The device on the bus.

 In the example mentioned earlier, the GPIOs to power an on-board USB
 hub would have to be initialized when the host controller was started.  
 You wouldn't want to wait for the on-board hub to be detected, because
 without those GPIOs set properly, it never would be discovered on the
 USB bus.  Right?

Yes, so you'd want callbacks when the device actually appears and
disappears.

 Perhaps the platform-level code would need to hook into the places
 where the discoverable bus is registered and unregistered.

We'd need some way to get information to the drivers still, and to
handle drivers that want to stop and start things.


signature.asc
Description: Digital signature


Re: RTL8192CU module device HW:ID support

2013-08-14 Thread Fabio Estevam
On Wed, Aug 14, 2013 at 12:07 PM,  srenau...@free.fr wrote:
 Well... finally it doesn't work.

 When added to sw.c, the key is powered on, it's MAC address and few networks 
 can be seen.

 But I can't connect to any network.

Have you tried it on 3.11-rc5?
--
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 v3 3/3] usb: dwc3: Add Qualcomm DWC3 glue layer driver

2013-08-14 Thread Stephen Boyd
On 08/14/13 05:59, Ivan T. Ivanov wrote:
 +}
 +
 +static const struct of_device_id of_dwc3_matach[] = {

match? Maybe you can make it all one line too { .compatible = qcom,dwc3 }

 + {
 + .compatible = qcom,dwc3,
 + },
 + { },
 +};
 +MODULE_DEVICE_TABLE(of, of_dwc3_matach);
 +

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

--
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: Non-enumerable devices on USB and other enumerable buses

2013-08-14 Thread Alan Stern
On Wed, 14 Aug 2013, Mark Brown wrote:

 On Wed, Aug 14, 2013 at 10:27:26AM -0400, Alan Stern wrote:
  On Wed, 14 Aug 2013, Mark Brown wrote:
 
   I'd expect that we're just looking at hooks around connection and
   disconnection here here - if we're looking at much more it seems like we
   must be doing something wrong.
 
  Connection and disconnection of what?
 
 The device on the bus.
 
  In the example mentioned earlier, the GPIOs to power an on-board USB
  hub would have to be initialized when the host controller was started.  
  You wouldn't want to wait for the on-board hub to be detected, because
  without those GPIOs set properly, it never would be discovered on the
  USB bus.  Right?
 
 Yes, so you'd want callbacks when the device actually appears and
 disappears.

No, no -- this is exactly the point I was trying to make.  The on-board
hub _won't_ appear on the USB bus until the GPIOs are set.  Therefore
the callback to set the GPIOs needs to be at a different place, not
when the device appears.

  Perhaps the platform-level code would need to hook into the places
  where the discoverable bus is registered and unregistered.
 
 We'd need some way to get information to the drivers still, and to
 handle drivers that want to stop and start things.

Um...  What exactly does this mean?  It's so generic, it could apply to
anything under drivers/.  After all, what driver doesn't want to stop
and start things?

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: Dynamic debug on by default?

2013-08-14 Thread Joe Perches
On Wed, 2013-08-14 at 09:40 -0700, Sarah Sharp wrote:
 Hi Xenia,
 
 I'm a bit confused.  I thought that debugging messages would be turned
 off by default for a module if CONFIG_DYNAMIC_DEBUG was turned on.  When
 I tested your patch to remove the CONFIG_USB_XHCI_HCD_DEBUGGING and just
 use dev_dbg, the messages from the xHCI driver appeared in dmesg by
 default.
 
 That generates a lot of log spew.  We can have distros add a boot
 parameter option to turn off debug messages, but that boot parameter is
 limited to 1023 characters.  I'm concerned that if more drivers add
 dynamic debugging, the distros will eventually run out of space in the
 dynamic debugging boot parameter.  I know Greg was ripping out debugging
 config options in other USB drivers, so this is a bit concerning.
 
 Jason, is there a way within the xHCI driver to say that dynamic
 debugging should be off by default?  I've looked through the
 documentation, and I can't find anything like that documented.

#undefine DEBUG

 I've attached my .config file, in case I have something misconfigured.

Because of:

drivers/usb/host/Makefile:ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG

you probably want to turn this off

CONFIG_USB_DEBUG=y

when dynamic_debug is on.

CONFIG_DYNAMIC_DEBUG=y

This will cause all pr_debug/dev_dbg statements to be
emitted without specific enabling via the dynamic_debug
control file.

(from include/linux/dynamic_debug.h)

#if defined DEBUG
#define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT
#else
#define _DPRINTK_FLAGS_DEFAULT 0
#endif


--
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: Dynamic debug on by default?

2013-08-14 Thread Greg KH
On Wed, Aug 14, 2013 at 09:51:54AM -0700, Joe Perches wrote:
 On Wed, 2013-08-14 at 09:40 -0700, Sarah Sharp wrote:
  Hi Xenia,
  
  I'm a bit confused.  I thought that debugging messages would be turned
  off by default for a module if CONFIG_DYNAMIC_DEBUG was turned on.  When
  I tested your patch to remove the CONFIG_USB_XHCI_HCD_DEBUGGING and just
  use dev_dbg, the messages from the xHCI driver appeared in dmesg by
  default.
  
  That generates a lot of log spew.  We can have distros add a boot
  parameter option to turn off debug messages, but that boot parameter is
  limited to 1023 characters.  I'm concerned that if more drivers add
  dynamic debugging, the distros will eventually run out of space in the
  dynamic debugging boot parameter.  I know Greg was ripping out debugging
  config options in other USB drivers, so this is a bit concerning.
  
  Jason, is there a way within the xHCI driver to say that dynamic
  debugging should be off by default?  I've looked through the
  documentation, and I can't find anything like that documented.
 
 #undefine DEBUG
 
  I've attached my .config file, in case I have something misconfigured.
 
 Because of:
 
 drivers/usb/host/Makefile:ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG

Yes, that's the problem, I'm trying to get rid of the CONFIG_USB_DEBUG
flag, and I'm almost there.  There are some host controllers that still
use it for some things that I have not cleaned up fully yet.

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


  1   2   >