Re: About gadget configfs

2014-05-06 Thread Andrzej Pietrasiewicz

Hi Peter,

W dniu 06.05.2014 03:01, Peter Chen pisze:

On Mon, May 05, 2014 at 11:09:30AM +0200, Andrzej Pietrasiewicz wrote:

W dniu 04.05.2014 09:48, Peter Chen pisze:

Hi Sebastian  Andrzej,


snip



1. I have setup successfully for running mass storage and CDC ACM at the
same time with below steps:

- Using CDC ACM config (CONFIG_USB_CONFIGFS_ACM), I thought the gser at
configfs is the same with g_serial, but in fact, it is not. The gser at
configfs seems to work not well at my linux pc, it can't create serial
port, but the acm and g_serial can let the pc create /dev/ttyACM0.



It is the same function.
g_serial in fact offers _three_ different functions:

- acm proper
- gser
- obex

Which is chosen depends on g_serial's module parameters.
Please do modinfo g_serial.
If use_acm is true, ACM is used [use_acm is true by default].
Else if use_obex is true, obex is used [use_obex is false by default].
Else gser is used.
So if you load g_serial without using any parameters, in fact you
get acm, not gser.

Please add use_acm=0 to modprobe/insmod g_serial and try again,
and see if the host creates a new node in /dev.
Please note, that if you use generic serial (gser), then the host
creates /dev/ttyUSBn, not /dev/ttyACMn.

Only if you successfully see /dev/ttyUSBn at host using g_serial,
you can start suspecting gser set up through configfs interface
of not working correctly.

Please note that g_serial by default uses 0x0525 as vendor id
and as product id it uses 0xa4a7 for ACM, 0xa4a9 for obex and
0xa4a6 for generic serial. If your PC host can only talk to gadgets
with these ids you need to use the same with configfs,
or configure your host to accept different ids.


snip



3. Besides, I have tried two configurations, and each configuration with
one function, I find the host PC always set configuration 1 (The first
configuration), any ways to switch configuration at host
side? libusb?


You either have a driver/class driver at the host side, or use libusb.

AP

--
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 0/7] USB support for DRA7-evm

2014-05-06 Thread Roger Quadros
Hi Kishon,

Could you please pick the first 2 patches in this series for phy-next?
They are independent of the rest. Thanks.

cheers,
-roger

On 05/05/2014 12:54 PM, Roger Quadros wrote:
 Hi,
 
 This series enables the 2 USB ports on the DRA7-evm.
 
 NOTE: USB1 port is hard coded to work in peripheral mode and USB2 port
 in host mode. This is due to missing ID pin interrupt in pre ver.E boards.
 
 USB1 port doesn't in peripheral mode out of the box due to missing VBUS 
 detection
 and mailbox write. To test this I had to do a manual write to enable VBUSVALID
 in the USB_UTMI_OTG_STATUS register.
   omapconf set bit 0x48880084 1
 
 USB2 port works well in host mode.
 
 Patches are based on 3.15-rc3.
 
 cheers,
 -roger
 
 Changelog:
 
 v3:
 -Rearraged patches. PHY related stuff first.
 -Addressed backward compatibility issue for phy-omap-usb2.
 
 v2:
 -Rebased on v3.15-rc3
 
 ---
 Roger Quadros (7):
   phy: omap-usb2: Use generic clock names wkupclk and refclk
   phy: omap-usb2: Add clock names to Documentation binding
   ARM: dts: omap4+: Add clocks to USB2 PHY node
   ARM: dts: dra7-clock: Add l3init_960m_gfclk clock gate
   ARM: DRA7: hwmod: Add SYSCONFIG for usb_otg_ss
   ARM: dts: dra7: Add USB related nodes
   dts: dra7-evm: add USB support
 
  Documentation/devicetree/bindings/phy/ti-phy.txt |   7 ++
  arch/arm/boot/dts/dra7-evm.dts   |  24 
  arch/arm/boot/dts/dra7.dtsi  | 149 
 +++
  arch/arm/boot/dts/dra7xx-clocks.dtsi |  12 +-
  arch/arm/boot/dts/omap4.dtsi |   2 +
  arch/arm/boot/dts/omap5.dtsi |   2 +
  arch/arm/mach-omap2/omap_hwmod_7xx_data.c|  22 ++--
  drivers/phy/phy-omap-usb2.c  |  30 +++--
  8 files changed, 229 insertions(+), 19 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 v3 0/7] USB support for DRA7-evm

2014-05-06 Thread Kishon Vijay Abraham I


On Tuesday 06 May 2014 12:49 PM, Roger Quadros wrote:
 Hi Kishon,
 
 Could you please pick the first 2 patches in this series for phy-next?
 They are independent of the rest. Thanks.

sure.. will be queuing it shortly.

Thanks
Kishon

 
 cheers,
 -roger
 
 On 05/05/2014 12:54 PM, Roger Quadros wrote:
 Hi,

 This series enables the 2 USB ports on the DRA7-evm.

 NOTE: USB1 port is hard coded to work in peripheral mode and USB2 port
 in host mode. This is due to missing ID pin interrupt in pre ver.E boards.

 USB1 port doesn't in peripheral mode out of the box due to missing VBUS 
 detection
 and mailbox write. To test this I had to do a manual write to enable 
 VBUSVALID
 in the USB_UTMI_OTG_STATUS register.
  omapconf set bit 0x48880084 1

 USB2 port works well in host mode.

 Patches are based on 3.15-rc3.

 cheers,
 -roger

 Changelog:

 v3:
 -Rearraged patches. PHY related stuff first.
 -Addressed backward compatibility issue for phy-omap-usb2.

 v2:
 -Rebased on v3.15-rc3

 ---
 Roger Quadros (7):
   phy: omap-usb2: Use generic clock names wkupclk and refclk
   phy: omap-usb2: Add clock names to Documentation binding
   ARM: dts: omap4+: Add clocks to USB2 PHY node
   ARM: dts: dra7-clock: Add l3init_960m_gfclk clock gate
   ARM: DRA7: hwmod: Add SYSCONFIG for usb_otg_ss
   ARM: dts: dra7: Add USB related nodes
   dts: dra7-evm: add USB support

  Documentation/devicetree/bindings/phy/ti-phy.txt |   7 ++
  arch/arm/boot/dts/dra7-evm.dts   |  24 
  arch/arm/boot/dts/dra7.dtsi  | 149 
 +++
  arch/arm/boot/dts/dra7xx-clocks.dtsi |  12 +-
  arch/arm/boot/dts/omap4.dtsi |   2 +
  arch/arm/boot/dts/omap5.dtsi |   2 +
  arch/arm/mach-omap2/omap_hwmod_7xx_data.c|  22 ++--
  drivers/phy/phy-omap-usb2.c  |  30 +++--
  8 files changed, 229 insertions(+), 19 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: Clarification regarding USB Data Card (3G Dongle) enumeration in Linux udev

2014-05-06 Thread Suresh Kumar N.
On Mon, May 5, 2014 at 8:38 PM, Dan Williams d...@redhat.com wrote:
 On Mon, 2014-05-05 at 11:07 +0530, Suresh Kumar N. wrote:
 Hi,

 I am new to udev and device enumeration.

 I am interested to know how USB Data Card would get enumerated.

 Based on my understanding Data Card can get enumerated below 2 possible ways 
 -
   1. As a modem
   2. As a Network Interface Card (NIC)

 Or both at the same time.

 Is there a Standard defining the way a Data Card should be enumerated?

 There is no single standard.  There is a few standards and multiple
 proprietary mechanisms, and sometimes these are combined in the same
 device.

 The device simply enumerates as a normal USB device, providing to the
 host computer one or more USB interfaces.

 Each USB interface can be any one of:

 1) serial interface (AT, QCDM, WMC, WDM, CDC-ACM, etc)
 2) pseudo-ethernet NIC (proprietary, CDC-ETHER, CDC-NCM, etc)

In such case (pseudo-ethernet NIC) do we assume that the firmware on
the USB Dongle is responsible to establish IP address?
In other words how does IP address allocation occur in this case?

 3) proprietary control protocols (CnS, QMI, etc)
 4) standard non-serial control protocols (MBIM)

 A modem can provide any of these in combination.  Which port speaks what
 protocol is detected by one or more of the following methods:

 a) USB VID/PID and interface number hardcoded in the drivers or in
 userland udev rules
 b) USB interface type (eg, serial port or NIC port, done in userland)
 c) probing with known request/response to determine different
 communication protocols used if the port type is indeterminate

Thanks for the information.


 Dan

 Please correct if my understanding is not correct or incomplete.

 Thanks in advance for your clarifications.

 Warm Regards,
 Suresh
 --
 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


--
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 3/9] usb: gadget: OS Feature Descriptors support

2014-05-06 Thread Andrzej Pietrasiewicz

Hello Michal,

W dniu 05.05.2014 20:41, Michal Nazarewicz pisze:

On Mon, May 05 2014, Andrzej Pietrasiewicz wrote:

When a gadget is composed with configfs the usb_add_config() is invoked
each time a configuration's directory is created, so this way configurations'
indices are determined. If we were to rearrange the configurations if
one of them becomes special then we loose the information about the original
sequence of configurations (i.e. which was index 0, index 1 etc). If the user
then decides that they don't want to use OS descriptors (= no special
configuration) than we end up with configurations presented to the host in
different order than they were created.


What I'm worried about is situation where configuration number visible
on the device disagrees with what host sees.  This may cause confusion
or bugs at configfs level as well as in the code.  I.e. the
bConfigurationValue for the special configuration will be zero when
accessed by the host, but might be non-zero when read via configfs or
directly by the composite function driver.


Isn't bConfigurationValue a label only? The host accesses configurations
by index (which is effectively generated at the gadget side by iterating
over a list of configurations and incrementing a counter), which is a different
thing that bConfigurationValue.
Consider for example the serial gadget (serial.c before applying the discussed
patch series): it defines 3 configurations,
but it registers only one, depending on module parameters.
Yet bConfigurationValue is eiter 1, 2 or 3 and is defined statically, so
for example when ACM is chosen, the only configuration presented to the host
has bConfigurationValue equal 2 even though it is reported at index 0.

AP
--
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 4/7] ARM: dts: dra7-clock: Add l3init_960m_gfclk clock gate

2014-05-06 Thread Tero Kristo

On 05/05/2014 12:54 PM, Roger Quadros wrote:

This clock gate description is missing in the older Reference manuals.
It is present on the SoC to provide 960MHz reference clock to the
internal USB PHYs.

Reference: DRA75x_DRA74x_ES1.1_NDA_TRM_vO.pdf, pg. 900,
Table 3-812. CM_COREAON_L3INIT_60M_GFCLK_CLKCTRL

Use l3init_960m_gfclk as parent of usb_otg_ss1_refclk960m and
usb_otg_ss2_refclk960m.

CC: Benoît Cousson bcous...@baylibre.com
CC: Tero Kristo t-kri...@ti.com
Signed-off-by: Roger Quadros rog...@ti.com


Got myself to download the latest copy of the TRM, so this patch looks 
valid.


Acked-by: Tero Kristo t-kri...@ti.com


---
  arch/arm/boot/dts/dra7xx-clocks.dtsi | 12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/dra7xx-clocks.dtsi 
b/arch/arm/boot/dts/dra7xx-clocks.dtsi
index cfb8fc7..c767687 100644
--- a/arch/arm/boot/dts/dra7xx-clocks.dtsi
+++ b/arch/arm/boot/dts/dra7xx-clocks.dtsi
@@ -1386,6 +1386,14 @@
ti,dividers = 1, 8;
};

+   l3init_960m_gfclk: l3init_960m_gfclk {
+   #clock-cells = 0;
+   compatible = ti,gate-clock;
+   clocks = dpll_usb_clkdcoldo;
+   ti,bit-shift = 8;
+   reg = 0x06c0;
+   };
+
dss_32khz_clk: dss_32khz_clk {
#clock-cells = 0;
compatible = ti,gate-clock;
@@ -1533,7 +1541,7 @@
usb_otg_ss1_refclk960m: usb_otg_ss1_refclk960m {
#clock-cells = 0;
compatible = ti,gate-clock;
-   clocks = dpll_usb_clkdcoldo;
+   clocks = l3init_960m_gfclk;
ti,bit-shift = 8;
reg = 0x13f0;
};
@@ -1541,7 +1549,7 @@
usb_otg_ss2_refclk960m: usb_otg_ss2_refclk960m {
#clock-cells = 0;
compatible = ti,gate-clock;
-   clocks = dpll_usb_clkdcoldo;
+   clocks = l3init_960m_gfclk;
ti,bit-shift = 8;
reg = 0x1340;
};



--
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 0/9] cdc_ncm: add buffer tuning and stats using ethtool

2014-05-06 Thread David Laight
From: Bjørn Mork
 I have got quite a few reports from frustrated users of OpenWRT
 hosts trying to use some powerful LTE modem, but not achieving
 full speed.  This is typically caused by a combination of
 big buffers and little memory, giving in allocation errors and
 bad performance as a result.
 
 This series is an attempt to let users adjust the size of these
 buffers without having to rebuild the driver.

I think that the usbnet rx framework needs some TLC.

There is no reason to pass large rx URB to the usb device.
Because the end of a USB bulk 'message' is indicated by a non-maximal
fragment (possibly zero length) it is sufficient to provide multiple
rx URB provided the URB are each a multiple of the packet size of the
underlying USB link (512 bytes for USB2 and 1k for USB3).

The usb driver might then have to split and merge data from
multiple URB to generate the data skbs.
I'd guess that for sub-Ge speeds a data copy in the rx path
won't matter - simplifying many of the drivers.

Some of the drivers allocate 16k skb, then set true_size small!

David

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

Re: [PATCH v3 06/20] usb: host: xhci-plat: Add support for the Armada 38x

2014-05-06 Thread Bartlomiej Zolnierkiewicz

Hi,

On Tuesday, May 06, 2014 02:14:01 AM Gregory CLEMENT wrote:
 For the Armada 38x SoCs which come with an xhci controller, specific
 initialization must be done during probe related to the MBus windows
 configuration. This patch adds the support of this quirk.
 
 Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
 ---
  drivers/usb/host/Kconfig  |  7 +
  drivers/usb/host/Makefile |  1 +
  drivers/usb/host/xhci-mvebu.c | 71 
 +++
  drivers/usb/host/xhci-mvebu.h | 21 +
  drivers/usb/host/xhci-plat.c  |  6 
  5 files changed, 106 insertions(+)
  create mode 100644 drivers/usb/host/xhci-mvebu.c
  create mode 100644 drivers/usb/host/xhci-mvebu.h
 
 diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
 index 3d9e54062d62..e70943fac4a1 100644
 --- a/drivers/usb/host/Kconfig
 +++ b/drivers/usb/host/Kconfig
 @@ -29,6 +29,13 @@ if USB_XHCI_HCD
  config USB_XHCI_PLATFORM
   tristate
  
 +config USB_XHCI_MVEBU
 + tristate xHCI support for Marvell Armada 38x

Please limit this driver to mvebu arch and compile testing, i.e.

depends on ARCH_MVEBU || COMPILE_TEST

 + select USB_XHCI_PLATFORM
 + ---help---
 +   Say 'Y' to enable the support for the xHCI host controller
 +   found in Marvell Armada 38x ARM SOCs.
 +
  endif # USB_XHCI_HCD
  
  config USB_EHCI_HCD

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung RD Institute Poland
Samsung Electronics

--
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 17/20] phy: Add support for USB cluster on the Armada 375 SoC

2014-05-06 Thread Bartlomiej Zolnierkiewicz

Hi,

On Tuesday, May 06, 2014 02:14:12 AM Gregory CLEMENT wrote:
 The Armada 375 SoC comes with an USB2 host and device controller and
 an USB3 controller. The USB cluster control register allows to manage
 common features of both USB controllers. It uses the generic PHY
 framework
 
 Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
 ---
  drivers/phy/Kconfig  |   5 ++
  drivers/phy/Makefile |   1 +
  drivers/phy/phy-armada375-usb2.c | 154 
 +++
  3 files changed, 160 insertions(+)
  create mode 100644 drivers/phy/phy-armada375-usb2.c
 
 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index 3bb05f17b9b4..cdf3e2c24e3a 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -15,6 +15,11 @@ config GENERIC_PHY
 phy users can obtain reference to the PHY. All the users of this
 framework should select this config.
  
 +config ARMADA375_USBCLUSTER_PHY
 + def_bool y
 + depends on OF

Please limit this driver to Armada 375 or compile testing, i.e. add additional

depends on (ARCH_MVEBU  MACH_ARMADA_375) || COMPILE_TEST

 + select GENERIC_PHY
 +
  config PHY_EXYNOS_MIPI_VIDEO
   tristate S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver
   depends on HAS_IOMEM

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung RD Institute Poland
Samsung Electronics

--
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: [regression 3.15-rc3] Resume from s4 broken by 1f81b6d22a5980955b01e08cf27fb745dc9b686f

2014-05-06 Thread Ville Syrjälä
On Mon, May 05, 2014 at 12:32:22PM -0700, Julius Werner wrote:
 Hmmm... very odd. I unfortunately don't have a machine that can easily
 do S4 at hand, but I did test this on an IVB with XHCI_RESET_ON_RESUME
 in S3 (essentially the same code path), and I didn't run into any
 problems.
 
 How exactly does your machine fail on resume? Is it a kernel crash or
 just a hang? Can you try getting some debug output (by setting 'echo N
  /sys/module/printk/parameters/console_suspend' and trying to catch
 the crash on the screen or a serial line, or maybe through pstore)? I
 really don't see much that could go wrong with this patch, so without
 more info it will be hard to understand your problem.
 
 Also, I noticed that you have two HID devices plugged in during
 suspend. Does it make a difference if you have different devices (e.g.
 a mass storage stick) or none at all?

Looks like it doesn't like it when there's anything plugged into the
SS ports. I tried with just a HID keyboard or with just a hub. In
both cases it fails to resume. If I have nothing connected to the SS
ports then it resumes just fine.

I managed to catch something with ramoops. Looks like it's hitting
POISON_FREE when trying to delete some list entry.

Oops#1 Part1
4[  106.321876]  [8106bb10] ? kthread_create_on_node+0x210/0x210
4[  106.321878]  [8151522c] ret_from_fork+0x7c/0xb0
4[  106.321879]  [8106bb10] ? kthread_create_on_node+0x210/0x210
4[  106.321879] ---[ end trace f5b8b9411bd5e24b ]---
6[  106.719552] PM: freeze of devices complete after 513.577 msecs
6[  106.720978] PM: late freeze of devices complete after 1.377 msecs
6[  106.723388] PM: noirq freeze of devices complete after 2.378 msecs
6[  106.723795] ACPI: Preparing to enter system sleep state S4
6[  106.727934] PM: Saving platform NVS memory
4[  106.740582] Disabling non-boot CPUs ...
6[  106.743252] kvm: disabling virtualization on CPU1
6[  106.743332] smpboot: CPU 1 is now offline
6[  106.750476] kvm: disabling virtualization on CPU2
6[  106.750518] smpboot: CPU 2 is now offline
6[  106.754634] kvm: disabling virtualization on CPU3
6[  106.754682] smpboot: CPU 3 is now offline
6[  106.758510] kvm: disabling virtualization on CPU4
6[  106.758817] smpboot: CPU 4 is now offline
6[  106.761210] kvm: disabling virtualization on CPU5
6[  106.761253] smpboot: CPU 5 is now offline
6[  106.763567] kvm: disabling virtualization on CPU6
6[  106.763596] smpboot: CPU 6 is now offline
6[  106.765906] kvm: disabling virtualization on CPU7
6[  106.765943] smpboot: CPU 7 is now offline
6[  106.766958] PM: Creating hibernation image:
6[  106.786249] PM: Need to copy 73589 pages
6[  106.768456] PM: Restoring platform NVS memory
6[  106.769104] microcode: CPU0 sig=0x306a9, pf=0x2, revision=0x19
6[  106.770518] Enabling non-boot CPUs ...
6[  106.771473] x86: Booting SMP configuration:
6[  106.771536] smpboot: Booting Node 0 Processor 1 APIC 0x2
6[  106.783221] CPU1 microcode updated early to revision 0x19, date = 
2013-06-13
6[  106.783921] kvm: enabling virtualization on CPU1
6[  106.788131] microcode: CPU1 sig=0x306a9, pf=0x2, revision=0x19
6[  106.794579] CPU1 is up
6[  106.795048] smpboot: Booting Node 0 Processor 2 APIC 0x4
6[  106.806241] CPU2 microcode updated early to revision 0x19, date = 
2013-06-13
6[  106.806963] kvm: enabling virtualization on CPU2
6[  106.811056] microcode: CPU2 sig=0x306a9, pf=0x2, revision=0x19
6[  106.817512] CPU2 is up
6[  106.817999] smpboot: Booting Node 0 Processor 3 APIC 0x6
6[  106.829157] CPU3 microcode updated early to revision 0x19, date = 
2013-06-13
6[  106.829918] kvm: enabling virtualization on CPU3
6[  106.834104] microcode: CPU3 sig=0x306a9, pf=0x2, revision=0x19
6[  106.840666] CPU3 is up
6[  106.841118] smpboot: Booting Node 0 Processor 4 APIC 0x1
6[  106.852238] CPU4 microcode updated early to revision 0x19, date = 
2013-06-13
6[  106.853485] kvm: enabling virtualization on CPU4
6[  106.857868] microcode: CPU4 sig=0x306a9, pf=0x2, revision=0x19
6[  106.864443] CPU4 is up
6[  106.864911] smpboot: Booting Node 0 Processor 5 APIC 0x3
6[  106.876633] kvm: enabling virtualization on CPU5
6[  106.881188] microcode: CPU5 sig=0x306a9, pf=0x2, revision=0x19
6[  106.887793] CPU5 is up
6[  106.888264] smpboot: Booting Node 0 Processor 6 APIC 0x5
6[  106.96] kvm: enabling virtualization on CPU6
6[  106.904526] microcode: CPU6 sig=0x306a9, pf=0x2, revision=0x19
6[  106.911141] CPU6 is up
6[  106.911605] smpboot: Booting Node 0 Processor 7 APIC 0x7
6[  106.923408] kvm: enabling virtualization on CPU7
6[  106.928161] microcode: CPU7 sig=0x306a9, pf=0x2, revision=0x19
6[  106.934883] CPU7 is up
6[  106.957959] ACPI: Waking up from system sleep state S4
6[  106.990680] PM: noirq restore of devices complete after 11.474 msecs
6[  106.993975] PM: early restore of devices complete after 3.024 msecs
4[  107.046519] usb usb3: root hub lost power or was reset
4[  107.046549] usb usb1: root hub lost power or was reset
4[  107.046694] usb usb4: 

Re: [PATCH v3 06/20] usb: host: xhci-plat: Add support for the Armada 38x

2014-05-06 Thread Arnd Bergmann
On Tuesday 06 May 2014 13:34:46 Bartlomiej Zolnierkiewicz wrote:
 On Tuesday, May 06, 2014 02:14:01 AM Gregory CLEMENT wrote:
  For the Armada 38x SoCs which come with an xhci controller, specific
  initialization must be done during probe related to the MBus windows
  configuration. This patch adds the support of this quirk.
  
  Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
  ---
   drivers/usb/host/Kconfig  |  7 +
   drivers/usb/host/Makefile |  1 +
   drivers/usb/host/xhci-mvebu.c | 71 
  +++
   drivers/usb/host/xhci-mvebu.h | 21 +
   drivers/usb/host/xhci-plat.c  |  6 
   5 files changed, 106 insertions(+)
   create mode 100644 drivers/usb/host/xhci-mvebu.c
   create mode 100644 drivers/usb/host/xhci-mvebu.h
  
  diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
  index 3d9e54062d62..e70943fac4a1 100644
  --- a/drivers/usb/host/Kconfig
  +++ b/drivers/usb/host/Kconfig
  @@ -29,6 +29,13 @@ if USB_XHCI_HCD
   config USB_XHCI_PLATFORM
tristate
   
  +config USB_XHCI_MVEBU
  + tristate xHCI support for Marvell Armada 38x
 
 Please limit this driver to mvebu arch and compile testing, i.e.
 
 depends on ARCH_MVEBU || COMPILE_TEST

I think it actually needs a dependency on MVEBU_MBUS.

You probably need something like

depends on MVEBU_MBUS=y || (MVEBU_MBUS=m  USB_XHCI=m)

Also, having the option 'tristate' makes no sense, since you
can't have it as a loadable module.

Arnd
--
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 06/20] usb: host: xhci-plat: Add support for the Armada 38x

2014-05-06 Thread Thomas Petazzoni
Dear Arnd Bergmann,

On Tue, 06 May 2014 13:57:44 +0200, Arnd Bergmann wrote:

  Please limit this driver to mvebu arch and compile testing, i.e.
  
  depends on ARCH_MVEBU || COMPILE_TEST
 
 I think it actually needs a dependency on MVEBU_MBUS.

That's not what we do for any of the other drivers that use the
MVEBU_MBUS functions.

 You probably need something like
 
   depends on MVEBU_MBUS=y || (MVEBU_MBUS=m  USB_XHCI=m)

MVEBU_MBUS is a bool, so there is no way is can be =m.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.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: [PATCH v3 06/20] usb: host: xhci-plat: Add support for the Armada 38x

2014-05-06 Thread Arnd Bergmann
On Tuesday 06 May 2014 14:10:23 Thomas Petazzoni wrote:
 On Tue, 06 May 2014 13:57:44 +0200, Arnd Bergmann wrote:
 
   Please limit this driver to mvebu arch and compile testing, i.e.
   
   depends on ARCH_MVEBU || COMPILE_TEST
  
  I think it actually needs a dependency on MVEBU_MBUS.
 
 That's not what we do for any of the other drivers that use the
 MVEBU_MBUS functions.

Fair enough. I guess using ARCH_MVEBU as the dependency works as well
because it implies MVEBU_MBUS. However, you can't use COMPILE_TEST
then because the driver itself needs the interfaces provided by MBUS.

It could be

depends on ARCH_MVEBU || (MVEBU_MBUS  COMPILE_TEST)

to describe the dependency most accurately.

  You probably need something like
  
depends on MVEBU_MBUS=y || (MVEBU_MBUS=m  USB_XHCI=m)
 
 MVEBU_MBUS is a bool, so there is no way is can be =m.

Yes, that helps.

Arnd
--
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/8] usb: gadget: configfs: OS Extended Properties descriptors support

2014-05-06 Thread Andrzej Pietrasiewicz
Add handling of OS Extended Properties descriptors from configfs interface.
One kind of OS Descriptors are Extended Properties descriptors, which
need to be specified per interface or per group of interfaces described
by an IAD. This patch adds support for creating subdirectories
in interface.n directory located in the function's directory.
Names of subdirectories created become names of properties.
Each property contains two attributes: type and data.
The type can be a numeric value 1..7 while data is a blob interpreted
depending on the type specified.
The types are:
1 - unicode string
2 - unicode string with environment variables
3 - binary
4 - little-endian 32-bit
5 - big-endian 32-bit
6 - unicode string with a symbolic link
7 - multiple unicode strings

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
---
 Documentation/ABI/testing/configfs-usb-gadget |  21 +++
 drivers/usb/gadget/configfs.c | 201 ++
 include/linux/usb/composite.h |   4 +
 3 files changed, 226 insertions(+)

diff --git a/Documentation/ABI/testing/configfs-usb-gadget 
b/Documentation/ABI/testing/configfs-usb-gadget
index 5c0b3e6..95a3658 100644
--- a/Documentation/ABI/testing/configfs-usb-gadget
+++ b/Documentation/ABI/testing/configfs-usb-gadget
@@ -75,6 +75,27 @@ Description:
compatible_id   - 8-byte string for Compatible ID
sub_compatible_id   - 8-byte string for Sub Compatible ID
 
+What:  
/config/usb-gadget/gadget/functions/func.inst/interface.n/property
+Date:  May 2014
+KernelVersion: 3.16
+Description:
+   This group contains Extended Property Descriptors specific 
for one
+   gadget's USB interface or one interface group described
+   by an IAD.
+
+   The attributes:
+
+   type- value 1..7 for interpreting the data
+   1: unicode string
+   2: unicode string with environment variable
+   3: binary
+   4: little-endian 32-bit
+   5: big-endian 32-bit
+   6: unicode string with a symbolic link
+   7: multiple unicode strings
+   data- blob of data to be interpreted depending on
+   type
+
 What:  /config/usb-gadget/gadget/strings
 Date:  Jun 2013
 KernelVersion: 3.11
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 1fd1e14..87ba35c 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -7,6 +7,7 @@
 #include linux/usb/gadget_configfs.h
 #include configfs.h
 #include u_f.h
+#include u_os_desc.h
 
 int check_user_usb_string(const char *name,
struct usb_gadget_strings *stringtab_dev)
@@ -941,6 +942,204 @@ static struct config_item_type os_desc_type = {
 CONFIGFS_ATTR_STRUCT(usb_os_desc);
 CONFIGFS_ATTR_OPS(usb_os_desc);
 
+
+static inline struct usb_os_desc_ext_prop
+*to_usb_os_desc_ext_prop(struct config_item *item)
+{
+   return container_of(item, struct usb_os_desc_ext_prop, item);
+}
+
+CONFIGFS_ATTR_STRUCT(usb_os_desc_ext_prop);
+CONFIGFS_ATTR_OPS(usb_os_desc_ext_prop);
+
+static ssize_t ext_prop_type_show(struct usb_os_desc_ext_prop *ext_prop,
+ char *page)
+{
+   return sprintf(page, %d, ext_prop-type);
+}
+
+static ssize_t ext_prop_type_store(struct usb_os_desc_ext_prop *ext_prop,
+  const char *page, size_t len)
+{
+   struct usb_os_desc *desc = to_usb_os_desc(ext_prop-item.ci_parent);
+   u8 type;
+   int ret;
+
+   if (desc-opts_mutex)
+   mutex_lock(desc-opts_mutex);
+   ret = kstrtou8(page, 0, type);
+   if (ret)
+   goto end;
+   if (type  USB_EXT_PROP_UNICODE || type  USB_EXT_PROP_UNICODE_MULTI) {
+   ret = -EINVAL;
+   goto end;
+   }
+
+   if ((ext_prop-type == USB_EXT_PROP_BINARY ||
+   ext_prop-type == USB_EXT_PROP_LE32 ||
+   ext_prop-type == USB_EXT_PROP_BE32) 
+   (type == USB_EXT_PROP_UNICODE ||
+   type == USB_EXT_PROP_UNICODE_ENV ||
+   type == USB_EXT_PROP_UNICODE_LINK))
+   ext_prop-data_len = 1;
+   else if ((ext_prop-type == USB_EXT_PROP_UNICODE ||
+  ext_prop-type == USB_EXT_PROP_UNICODE_ENV ||
+  ext_prop-type == USB_EXT_PROP_UNICODE_LINK) 
+  (type == USB_EXT_PROP_BINARY ||
+  type == USB_EXT_PROP_LE32 ||
+  type == USB_EXT_PROP_BE32))
+   ext_prop-data_len = 1;
+   ext_prop-type = type;
+   ret = len;
+
+end:
+   if (desc-opts_mutex)
+   mutex_unlock(desc-opts_mutex);
+   return ret;
+}
+
+static ssize_t ext_prop_data_show(struct 

[PATCH 1/8] usb: gadget: FunctionFS: share VLA macros with all usb gadget files

2014-05-06 Thread Andrzej Pietrasiewicz
Variable Length Array macros allow portable (compilable with both gcc
and clang) way of allocating a number of structures using a single
memory chunk. They can be useful for files other than f_fs.c,
so move them to a header file.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_fs.c | 27 +--
 drivers/usb/gadget/u_f.h  | 26 ++
 2 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index de92bd3..74202d6 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -33,36 +33,11 @@
 #include linux/poll.h
 
 #include u_fs.h
+#include u_f.h
 #include configfs.h
 
 #define FUNCTIONFS_MAGIC   0xa647361 /* Chosen by a honest dice roll ;) */
 
-/* Variable Length Array Macros **/
-#define vla_group(groupname) size_t groupname##__next = 0
-#define vla_group_size(groupname) groupname##__next
-
-#define vla_item(groupname, type, name, n) \
-   size_t groupname##_##name##__offset = ({   \
-   size_t align_mask = __alignof__(type) - 1; \
-   size_t offset = (groupname##__next + align_mask)  ~align_mask;\
-   size_t size = (n) * sizeof(type);  \
-   groupname##__next = offset + size; \
-   offset;\
-   })
-
-#define vla_item_with_sz(groupname, type, name, n) \
-   size_t groupname##_##name##__sz = (n) * sizeof(type);  \
-   size_t groupname##_##name##__offset = ({   \
-   size_t align_mask = __alignof__(type) - 1; \
-   size_t offset = (groupname##__next + align_mask)  ~align_mask;\
-   size_t size = groupname##_##name##__sz;\
-   groupname##__next = offset + size; \
-   offset;\
-   })
-
-#define vla_ptr(ptr, groupname, name) \
-   ((void *) ((char *)ptr + groupname##_##name##__offset))
-
 /* Reference counter handling */
 static void ffs_data_get(struct ffs_data *ffs);
 static void ffs_data_put(struct ffs_data *ffs);
diff --git a/drivers/usb/gadget/u_f.h b/drivers/usb/gadget/u_f.h
index 71034c0..1d5f0eb 100644
--- a/drivers/usb/gadget/u_f.h
+++ b/drivers/usb/gadget/u_f.h
@@ -16,6 +16,32 @@
 #ifndef __U_F_H__
 #define __U_F_H__
 
+/* Variable Length Array Macros **/
+#define vla_group(groupname) size_t groupname##__next = 0
+#define vla_group_size(groupname) groupname##__next
+
+#define vla_item(groupname, type, name, n) \
+   size_t groupname##_##name##__offset = ({   \
+   size_t align_mask = __alignof__(type) - 1; \
+   size_t offset = (groupname##__next + align_mask)  ~align_mask;\
+   size_t size = (n) * sizeof(type);  \
+   groupname##__next = offset + size; \
+   offset;\
+   })
+
+#define vla_item_with_sz(groupname, type, name, n) \
+   size_t groupname##_##name##__sz = (n) * sizeof(type);  \
+   size_t groupname##_##name##__offset = ({   \
+   size_t align_mask = __alignof__(type) - 1; \
+   size_t offset = (groupname##__next + align_mask)  ~align_mask;\
+   size_t size = groupname##_##name##__sz;\
+   groupname##__next = offset + size; \
+   offset;\
+   })
+
+#define vla_ptr(ptr, groupname, name) \
+   ((void *) ((char *)ptr + groupname##_##name##__offset))
+
 struct usb_ep;
 struct usb_request;
 
-- 
1.8.3.2

--
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/8] OS Descriptors support

2014-05-06 Thread Andrzej Pietrasiewicz
There is a custom (non-USB IF) extension to the USB standard:

http://msdn.microsoft.com/library/windows/hardware/gg463182

They grant permission to use the specification - there is
Microsoft OS Descriptor Specification License Agreement
under the link mentioned above, and its Section 2 Grant
of License, letter (b) reads:

Patent license. Microsoft hereby grants to You a nonexclusive,
royalty-free, nontransferable, worldwide license under Microsoft’s
patents embodied solely within the Specification and that are owned
or licensable by Microsoft to make, use, import, offer to sell,
sell and distribute directly or indirectly to Your Licensees Your
Implementation. You may sublicense this patent license to Your
Licensees under the same terms and conditions.

The said extension is maintained by Microsoft for Microsoft.

Yet it is fairly common for various devices to use it, and a
popular proprietary operating system expects devices to provide
OS descriptors, so Linux-based USB gadgets whishing to be able
to talk to a variety of operating systems should be able to provide
the OS descriptors.

This patch series adds (optional) support for gadgets whishing to expose
the so-called OS Descriptors.

The sequence of operations when a gadget is enumerated by an OS which expects
the said descriptors is as following:

1) the host issues a standard GET_DESCRIPTOR request of type 0x03 (string)
for a string at index 0xEE in language 0, named OS String
2) if the device responds, the hosts interprets the response, and if it is
of expected form the host assumes the device supports OS Descriptors
3) the host issues requests to get Feature Descriptors it expects

There are two kinds of Feature Descriptors: Extended Compatibility
descriptors and Extended Properties descriptors.
They are specified per USB interface or per USB interface group described
by an IAD.

Legacy gadgets (compiled as separate modules, like g_ether, g_serial etc)
can stay as they are and not use this extension.
The intended use of the extension is with configfs interface.

This series contains an extension to the f_rndis function; if a function
whishes to support OS Descriptors it needs to be patched with a fairly
simple change: PATCH 4/8 contains code for supporting the extension proper,
while PATCH 7/8 contains code for using it with configfs.

Example gadget is created with the following commands
(I assume s3c-hsotg is used):

$ #USUAL STUFF
$ #===
$
$ modprobe libcomposite
$ mount none cfg -t configfs
$ mkdir cfg/usb_gadget/g1
$ cd cfg/usb_gadget/g1
$ mkdir configs/c.1
$ mkdir functions/rndis.usb0
$ mkdir strings/0x409
$ mkdir configs/c.1/strings/0x409
$ echo 0x  idProduct
$ echo 0x  idVendor
$ echo 123  strings/0x409/serialnumber
$ echo manufacturer  strings/0x409/manufacturer
$ echo RNDIS Gadget  strings/0x409/product
$ echo Conf 1  configs/c.1/strings/0x409/configuration
$ echo 120  configs/c.1/MaxPower
$
$ #OS DESCRIPTORS
$ #==
$
$ #OS STRING
$ #-
$
$echo 1  os_desc/use
$ echo 0xcd  os_desc/b_vendor_code
$ echo MSFT100  os_desc/qw_sign
$
$ #COMPATIBLE ID (SUB COMPATIBLE ID UNUSED)
$ #-
$
$ echo RNDIS  functions/rndis.usb0/os_desc/interface.0/compatible_id
$
$ #MAKE c.1 THE ONE ASSOCIATED WITH OS DESCRIPTORS
$ #---
$
$ ln -s configs/c.1 os_desc
$
$ #MAKE Icons EXTENDED PROPERTY
$ #--
$
$ mkdir functions/rndis.usb0/os_desc/interface.0/Icons
$ echo 2  functions/rndis.usb0/os_desc/interface.0/Icons/type
$ echo %SystemRoot%\\system32\\shell32.dll,-233  
functions/rndis.usb0/os_desc/interface.0/Icons/data
$
$ #MAKE Label EXTENDED PROPERTY
$ #--
$
$ mkdir functions/rndis.usb0/os_desc/interface.0/Label
$ echo 1  functions/rndis.usb0/os_desc/interface.0/Label/type
$ echo XYZ Device  functions/rndis.usb0/os_desc/interface.0/Label/data
$
$ #USUAL STUFF, CONTINUED
$ #==
$
$ ln -s functions/rndis.usb0 configs/c.1
$ echo s3c-hsotg  UDC


Andrzej Pietrasiewicz (8):
  usb: gadget: FunctionFS: share VLA macros with all usb gadget files
  usb: gadget: OS String support
  usb: gadget: OS Feature Descriptors support
  usb: gadget: f_rndis: OS descriptors support
  usb: gadget: configfs: OS String support
  usb: gadget: configfs: OS Extended Compatibility descriptors support
  usb: gadget: f_rndis: OS Descriptors configfs support
  usb: gadget: configfs: OS Extended Properties descriptors support

 Documentation/ABI/testing/configfs-usb-gadget |  45 +++
 drivers/usb/gadget/composite.c| 342 +++-
 drivers/usb/gadget/configfs.c | 550 +-
 drivers/usb/gadget/configfs.h |  12 +
 drivers/usb/gadget/f_fs.c |  27 +-
 drivers/usb/gadget/f_rndis.c  |  31 +-
 drivers/usb/gadget/u_f.h  |  26 ++
 drivers/usb/gadget/u_os_desc.h|  90 +
 drivers/usb/gadget/u_rndis.h 

[PATCH 7/8] usb: gadget: f_rndis: OS Descriptors configfs support

2014-05-06 Thread Andrzej Pietrasiewicz
Added handling of OS Descriptors support for f_rndis.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
---
 drivers/usb/gadget/f_rndis.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index a7633d6..eed3ad8 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -27,6 +27,7 @@
 #include u_ether_configfs.h
 #include u_rndis.h
 #include rndis.h
+#include configfs.h
 
 /*
  * This function is an RNDIS Ethernet port -- a Microsoft protocol that's
@@ -895,12 +896,15 @@ static void rndis_free_inst(struct usb_function_instance 
*f)
else
free_netdev(opts-net);
}
+
+   kfree(opts-rndis_os_desc.group.default_groups); /* single VLA chunk */
kfree(opts);
 }
 
 static struct usb_function_instance *rndis_alloc_inst(void)
 {
struct f_rndis_opts *opts;
+   struct usb_os_desc *descs[1];
 
opts = kzalloc(sizeof(*opts), GFP_KERNEL);
if (!opts)
@@ -917,6 +921,9 @@ static struct usb_function_instance *rndis_alloc_inst(void)
}
INIT_LIST_HEAD(opts-rndis_os_desc.ext_prop);
 
+   descs[0] = opts-rndis_os_desc;
+   usb_os_desc_prepare_interf_dir(opts-func_inst.group, 1, descs,
+  THIS_MODULE);
config_group_init_type_name(opts-func_inst.group, ,
rndis_func_type);
 
-- 
1.8.3.2

--
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/8] usb: gadget: f_rndis: OS descriptors support

2014-05-06 Thread Andrzej Pietrasiewicz
In order for usb functions to expose OS descriptors they
need to be made aware of OS descriptors. This involves
extending the options structure and setting up
appropriate associations.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
---
 drivers/usb/gadget/f_rndis.c | 24 +---
 drivers/usb/gadget/u_rndis.h |  3 +++
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 004b3a1..a7633d6 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -682,6 +682,15 @@ rndis_bind(struct usb_configuration *c, struct 
usb_function *f)
 
rndis_opts = container_of(f-fi, struct f_rndis_opts, func_inst);
 
+   if (cdev-use_os_string) {
+   f-os_desc_table = kzalloc(sizeof(*f-os_desc_table),
+  GFP_KERNEL);
+   if (!f-os_desc_table)
+   return PTR_ERR(f-os_desc_table);
+   f-os_desc_n = 1;
+   f-os_desc_table[0].os_desc = rndis_opts-rndis_os_desc;
+   }
+
/*
 * in drivers/usb/gadget/configfs.c:configfs_composite_bind()
 * configurations are bound in sequence with list_for_each_entry,
@@ -693,14 +702,16 @@ rndis_bind(struct usb_configuration *c, struct 
usb_function *f)
gether_set_gadget(rndis_opts-net, cdev-gadget);
status = gether_register_netdev(rndis_opts-net);
if (status)
-   return status;
+   goto fail;
rndis_opts-bound = true;
}
 
us = usb_gstrings_attach(cdev, rndis_strings,
 ARRAY_SIZE(rndis_string_defs));
-   if (IS_ERR(us))
-   return PTR_ERR(us);
+   if (IS_ERR(us)) {
+   status = PTR_ERR(us);
+   goto fail;
+   }
rndis_control_intf.iInterface = us[0].id;
rndis_data_intf.iInterface = us[1].id;
rndis_iad_descriptor.iFunction = us[2].id;
@@ -802,6 +813,8 @@ rndis_bind(struct usb_configuration *c, struct usb_function 
*f)
return 0;
 
 fail:
+   kfree(f-os_desc_table);
+   f-os_desc_n = 0;
usb_free_all_descriptors(f);
 
if (rndis-notify_req) {
@@ -892,6 +905,8 @@ static struct usb_function_instance *rndis_alloc_inst(void)
opts = kzalloc(sizeof(*opts), GFP_KERNEL);
if (!opts)
return ERR_PTR(-ENOMEM);
+   opts-rndis_os_desc.ext_compat_id = opts-rndis_ext_compat_id;
+
mutex_init(opts-lock);
opts-func_inst.free_func_inst = rndis_free_inst;
opts-net = gether_setup_default();
@@ -900,6 +915,7 @@ static struct usb_function_instance *rndis_alloc_inst(void)
kfree(opts);
return ERR_CAST(net);
}
+   INIT_LIST_HEAD(opts-rndis_os_desc.ext_prop);
 
config_group_init_type_name(opts-func_inst.group, ,
rndis_func_type);
@@ -925,6 +941,8 @@ static void rndis_unbind(struct usb_configuration *c, 
struct usb_function *f)
 {
struct f_rndis  *rndis = func_to_rndis(f);
 
+   kfree(f-os_desc_table);
+   f-os_desc_n = 0;
usb_free_all_descriptors(f);
 
kfree(rndis-notify_req-buf);
diff --git a/drivers/usb/gadget/u_rndis.h b/drivers/usb/gadget/u_rndis.h
index 7291b15..e902aa4 100644
--- a/drivers/usb/gadget/u_rndis.h
+++ b/drivers/usb/gadget/u_rndis.h
@@ -26,6 +26,9 @@ struct f_rndis_opts {
boolbound;
boolborrowed_net;
 
+   struct usb_os_desc  rndis_os_desc;
+   charrndis_ext_compat_id[16];
+
/*
 * Read/write access to configfs attributes is handled by configfs.
 *
-- 
1.8.3.2

--
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/8] usb: gadget: OS Feature Descriptors support

2014-05-06 Thread Andrzej Pietrasiewicz
There is a custom (non-USB IF) extension to the USB standard:

http://msdn.microsoft.com/library/windows/hardware/gg463182

They grant permission to use the specification - there is
Microsoft OS Descriptor Specification License Agreement
under the link mentioned above, and its Section 2 Grant
of License, letter (b) reads:

Patent license. Microsoft hereby grants to You a nonexclusive,
royalty-free, nontransferable, worldwide license under Microsoft’s
patents embodied solely within the Specification and that are owned
or licensable by Microsoft to make, use, import, offer to sell,
sell and distribute directly or indirectly to Your Licensees Your
Implementation. You may sublicense this patent license to Your
Licensees under the same terms and conditions.

The said extension is maintained by Microsoft for Microsoft.

Yet it is fairly common for various devices to use it, and a
popular proprietary operating system expects devices to provide
OS descriptors, so Linux-based USB gadgets whishing to be able
to talk to a variety of operating systems should be able to provide
the OS descriptors.

This patch adds optional support for gadgets whishing to expose
the so called OS Feature Descriptors, that is Extended Compatibility ID
and Extended Properties.

Hosts which do request OS descriptors from gadgets do so during
the enumeration phase and before the configuration is set with
SET_CONFIGURATION. What is more, those hosts never ask for configurations
at indices other than 0. Therefore, gadgets whishing to provide
OS descriptors must designate one configuration to be used with
this kind of hosts - this is what os_desc_config is added for in
struct usb_composite_dev. There is an additional advantage to it:
if a gadget provides OS descriptors and designates one configuration
to be used with such non-USB-compliant hosts it can invoke
usb_add_config in any order because the designated configuration
will be reported to be at index 0 anyway.

This patch also adds handling vendor-specific requests addressed
at device or interface and related to handling OS descriptors.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
---
 drivers/usb/gadget/composite.c | 315 -
 drivers/usb/gadget/u_os_desc.h |  90 
 include/linux/usb/composite.h  |  58 
 3 files changed, 462 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/gadget/u_os_desc.h

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 4e8aaa6..47a6f4e 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -21,6 +21,8 @@
 #include linux/usb/composite.h
 #include asm/unaligned.h
 
+#include u_os_desc.h
+
 /**
  * struct usb_os_string - represents OS String to be reported by a gadget
  * @bLength: total length of the entire descritor, always 0x12
@@ -454,8 +456,46 @@ static int config_desc(struct usb_composite_dev *cdev, 
unsigned w_value)
 
}
 
-   /* This is a lookup by config *INDEX* */
w_value = 0xff;
+   /*
+* This is a lookup to make non-compliant USB hosts happy.
+*
+* By non-compliant USB hosts I mean those which only ask for
+* configuration @index 0.
+* If one configuration is marked special by storing
+* its address in cdev-os_desc_config, we try returning
+* exactly this configuration.
+*
+* Otherwise, regular list lookup is performed.
+*
+* If we are connected to a compliant USB host _and_
+* one configuration is special we report it @ index 0,
+* but report remaining configurations as well - with adjusted
+* indices.
+*/
+   c = cdev-os_desc_config;
+   if (c) {
+   if (!w_value) {
+   switch (speed) {
+   case USB_SPEED_SUPER:
+   if (!c-superspeed)
+   goto list_lookup;
+   break;
+   case USB_SPEED_HIGH:
+   if (!c-highspeed)
+   goto list_lookup;
+   break;
+   default:
+   if (!c-fullspeed)
+   goto list_lookup;
+   }
+
+   return config_buf(c, speed, cdev-req-buf, type);
+   }
+   --w_value; /* account for conf returned @ index 0 */
+   }
+list_lookup:
+   /* This is a lookup by config *INDEX* */
list_for_each_entry(c, cdev-configs, list) {
/* ignore configs that won't work at this speed */
switch (speed) {
@@ -471,6 +511,9 @@ static int config_desc(struct usb_composite_dev *cdev, 
unsigned w_value)
if (!c-fullspeed)
continue;
}
+   /* account for 

[PATCH 5/8] usb: gadget: configfs: OS String support

2014-05-06 Thread Andrzej Pietrasiewicz
Add handling of OS String extension from the configfs interface.
A directory os_desc is added at the top level of a gadget's
directories hierarchy. In the os_desc directory there are
three attributes: use, b_vendor_code and qw_sign.
If use contains 0 the OS string is not reported to the host.
b_vendor_code contains a one-byte value which is used
for custom per-device and per-interface requests.
qw_sign contains an identifier to be reported as the OS String
proper.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
---
 Documentation/ABI/testing/configfs-usb-gadget |  11 ++
 drivers/usb/gadget/configfs.c | 159 +-
 2 files changed, 169 insertions(+), 1 deletion(-)

diff --git a/Documentation/ABI/testing/configfs-usb-gadget 
b/Documentation/ABI/testing/configfs-usb-gadget
index 37559a0..0e7b786 100644
--- a/Documentation/ABI/testing/configfs-usb-gadget
+++ b/Documentation/ABI/testing/configfs-usb-gadget
@@ -79,3 +79,14 @@ Description:
product - gadget's product description
manufacturer- gadget's manufacturer description
 
+What:  /config/usb-gadget/gadget/os_desc
+Date:  May 2014
+KernelVersion: 3.16
+Description:
+   This group contains OS String extension handling attributes.
+
+   use - flag turning OS Desctiptors support on/off
+   b_vendor_code   - one-byte value used for custom per-device and
+   per-interface requests
+   qw_sign - an identifier to be reported as OS String
+   proper
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index dcead55..4c781fc 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -2,6 +2,7 @@
 #include linux/module.h
 #include linux/slab.h
 #include linux/device.h
+#include linux/nls.h
 #include linux/usb/composite.h
 #include linux/usb/gadget_configfs.h
 #include configfs.h
@@ -43,7 +44,8 @@ struct gadget_info {
struct config_group functions_group;
struct config_group configs_group;
struct config_group strings_group;
-   struct config_group *default_groups[4];
+   struct config_group os_desc_group;
+   struct config_group *default_groups[5];
 
struct mutex lock;
struct usb_gadget_strings *gstrings[MAX_USB_STRING_LANGS + 1];
@@ -56,6 +58,9 @@ struct gadget_info {
 #endif
struct usb_composite_driver composite;
struct usb_composite_dev cdev;
+   bool use_os_desc;
+   char b_vendor_code;
+   char qw_sign[OS_STRING_QW_SIGN_LEN];
 };
 
 struct config_usb_cfg {
@@ -79,6 +84,10 @@ struct gadget_strings {
struct list_head list;
 };
 
+struct os_desc {
+   struct config_group group;
+};
+
 struct gadget_config_name {
struct usb_gadget_strings stringtab_dev;
struct usb_string strings;
@@ -736,6 +745,145 @@ static void gadget_strings_attr_release(struct 
config_item *item)
 USB_CONFIG_STRING_RW_OPS(gadget_strings);
 USB_CONFIG_STRINGS_LANG(gadget_strings, gadget_info);
 
+static inline struct os_desc *to_os_desc(struct config_item *item)
+{
+   return container_of(to_config_group(item), struct os_desc, group);
+}
+
+CONFIGFS_ATTR_STRUCT(os_desc);
+CONFIGFS_ATTR_OPS(os_desc);
+
+static ssize_t os_desc_use_show(struct os_desc *os_desc, char *page)
+{
+   struct gadget_info *gi;
+
+   gi = to_gadget_info(os_desc-group.cg_item.ci_parent);
+
+   return sprintf(page, %d, gi-use_os_desc);
+}
+
+static ssize_t os_desc_use_store(struct os_desc *os_desc, const char *page,
+size_t len)
+{
+   struct gadget_info *gi;
+   int ret;
+   bool use;
+
+   gi = to_gadget_info(os_desc-group.cg_item.ci_parent);
+
+   mutex_lock(gi-lock);
+   ret = strtobool(page, use);
+   if (!ret) {
+   gi-use_os_desc = use;
+   ret = len;
+   }
+   mutex_unlock(gi-lock);
+
+   return ret;
+}
+
+static struct os_desc_attribute os_desc_use =
+   __CONFIGFS_ATTR(use, S_IRUGO | S_IWUSR,
+   os_desc_use_show,
+   os_desc_use_store);
+
+static ssize_t os_desc_b_vendor_code_show(struct os_desc *os_desc, char *page)
+{
+   struct gadget_info *gi;
+
+   gi = to_gadget_info(os_desc-group.cg_item.ci_parent);
+
+   return sprintf(page, %d, gi-b_vendor_code);
+}
+
+static ssize_t os_desc_b_vendor_code_store(struct os_desc *os_desc,
+  const char *page, size_t len)
+{
+   struct gadget_info *gi;
+   int ret;
+   u8 b_vendor_code;
+
+   gi = to_gadget_info(os_desc-group.cg_item.ci_parent);
+
+   mutex_lock(gi-lock);
+   ret = kstrtou8(page, 0, b_vendor_code);
+   if (!ret) {
+   gi-b_vendor_code = b_vendor_code;
+   ret = len;
+   }
+   mutex_unlock(gi-lock);
+
+   return ret;
+}

[PATCH 6/8] usb: gadget: configfs: OS Extended Compatibility descriptors support

2014-05-06 Thread Andrzej Pietrasiewicz
Add handling of OS Extended Compatibility descriptors from configfs interface.
Hosts which expect the OS Descriptors ask only for configurations @ index 0,
but linux-based USB devices can provide more than one configuration.
This patch adds marking one of gadget's configurations the configuration
to be reported at index 0, regardless of the actual sequence of usb_add_config
invocations used for adding the configurations. The configuration is selected
by creating a symbolic link pointing to it from the os_desc directory
located at the top of a gadget's directory hierarchy.

One kind of OS Descriptors are Extended Compatibility Descriptors,
which need to be specified per interface. This patch adds interface.n
directory in function's configfs directory to represent each interface
defined by the function. Each interface's directory contains two attributes:
compatible_id and sub_compatible_id, which represent 8-byte
strings to be reported to the host as the Compatible ID and Sub Compatible
ID.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
---
 Documentation/ABI/testing/configfs-usb-gadget |  13 ++
 drivers/usb/gadget/configfs.c | 190 ++
 drivers/usb/gadget/configfs.h |  12 ++
 include/linux/usb/composite.h |   6 +
 4 files changed, 221 insertions(+)

diff --git a/Documentation/ABI/testing/configfs-usb-gadget 
b/Documentation/ABI/testing/configfs-usb-gadget
index 0e7b786..5c0b3e6 100644
--- a/Documentation/ABI/testing/configfs-usb-gadget
+++ b/Documentation/ABI/testing/configfs-usb-gadget
@@ -62,6 +62,19 @@ KernelVersion:   3.11
 Description:
This group contains functions available to this USB gadget.
 
+What:  /config/usb-gadget/gadget/functions/func.inst/interface.n
+Date:  May 2014
+KernelVersion: 3.16
+Description:
+   This group contains Feature Descriptors specific for one
+   gadget's USB interface or one interface group described
+   by an IAD.
+
+   The attributes:
+
+   compatible_id   - 8-byte string for Compatible ID
+   sub_compatible_id   - 8-byte string for Sub Compatible ID
+
 What:  /config/usb-gadget/gadget/strings
 Date:  Jun 2013
 KernelVersion: 3.11
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 4c781fc..1fd1e14 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -6,6 +6,7 @@
 #include linux/usb/composite.h
 #include linux/usb/gadget_configfs.h
 #include configfs.h
+#include u_f.h
 
 int check_user_usb_string(const char *name,
struct usb_gadget_strings *stringtab_dev)
@@ -872,10 +873,63 @@ static void os_desc_attr_release(struct config_item *item)
kfree(os_desc);
 }
 
+static int os_desc_link(struct config_item *os_desc_ci,
+   struct config_item *usb_cfg_ci)
+{
+   struct gadget_info *gi = container_of(to_config_group(os_desc_ci),
+   struct gadget_info, os_desc_group);
+   struct usb_composite_dev *cdev = gi-cdev;
+   struct config_usb_cfg *c_target =
+   container_of(to_config_group(usb_cfg_ci),
+struct config_usb_cfg, group);
+   struct usb_configuration *c;
+   int ret;
+
+   mutex_lock(gi-lock);
+   list_for_each_entry(c, cdev-configs, list) {
+   if (c == c_target-c)
+   break;
+   }
+   if (c != c_target-c) {
+   ret = -EINVAL;
+   goto out;
+   }
+
+   if (cdev-os_desc_config) {
+   ret = -EBUSY;
+   goto out;
+   }
+
+   cdev-os_desc_config = c_target-c;
+   ret = 0;
+
+out:
+   mutex_unlock(gi-lock);
+   return ret;
+}
+
+static int os_desc_unlink(struct config_item *os_desc_ci,
+ struct config_item *usb_cfg_ci)
+{
+   struct gadget_info *gi = container_of(to_config_group(os_desc_ci),
+   struct gadget_info, os_desc_group);
+   struct usb_composite_dev *cdev = gi-cdev;
+
+   mutex_lock(gi-lock);
+   if (gi-udc_name)
+   unregister_gadget(gi);
+   cdev-os_desc_config = NULL;
+   WARN_ON(gi-udc_name);
+   mutex_unlock(gi-lock);
+   return 0;
+}
+
 static struct configfs_item_operations os_desc_ops = {
.release= os_desc_attr_release,
.show_attribute = os_desc_attr_show,
.store_attribute= os_desc_attr_store,
+   .allow_link = os_desc_link,
+   .drop_link  = os_desc_unlink,
 };
 
 static struct config_item_type os_desc_type = {
@@ -884,6 +938,133 @@ static struct config_item_type os_desc_type = {
.ct_owner   = THIS_MODULE,
 };
 
+CONFIGFS_ATTR_STRUCT(usb_os_desc);
+CONFIGFS_ATTR_OPS(usb_os_desc);
+
+static struct configfs_item_operations 

[PATCH 2/8] usb: gadget: OS String support

2014-05-06 Thread Andrzej Pietrasiewicz
There is a custom (non-USB IF) extension to the USB standard:

http://msdn.microsoft.com/library/windows/hardware/gg463182

They grant permission to use the specification - there is
Microsoft OS Descriptor Specification License Agreement
under the link mentioned above, and its Section 2 Grant
of License, letter (b) reads:

Patent license. Microsoft hereby grants to You a nonexclusive,
royalty-free, nontransferable, worldwide license under Microsoft’s
patents embodied solely within the Specification and that are owned
or licensable by Microsoft to make, use, import, offer to sell,
sell and distribute directly or indirectly to Your Licensees Your
Implementation. You may sublicense this patent license to Your
Licensees under the same terms and conditions.

The said extension is maintained by Microsoft for Microsoft.

Yet it is fairly common for various devices to use it, and a
popular proprietary operating system expects devices to provide
OS descriptors, so Linux-based USB gadgets whishing to be able
to talk to a variety of operating systems should be able to provide
the OS descriptors.

This patch adds optional support for gadgets whishing to expose
the so called OS String under index 0xEE of language 0.
The contents of the string is generated based on the qw_sign
array and b_vendor_code.

Interested gadgets need to set the cdev-use_os_string flag,
fill cdev-qw_sign with appropriate values and fill cdev-b_vendor_code
with a value of their choice.

This patch does not however implement responding to any vendor-specific
USB requests.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
---
 drivers/usb/gadget/composite.c | 27 +++
 include/linux/usb/composite.h  | 11 +++
 2 files changed, 38 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index fab9064..4e8aaa6 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -21,6 +21,22 @@
 #include linux/usb/composite.h
 #include asm/unaligned.h
 
+/**
+ * struct usb_os_string - represents OS String to be reported by a gadget
+ * @bLength: total length of the entire descritor, always 0x12
+ * @bDescriptorType: USB_DT_STRING
+ * @qwSignature: the OS String proper
+ * @bMS_VendorCode: code used by the host for subsequent requests
+ * @bPad: not used
+ */
+struct usb_os_string {
+   __u8bLength;
+   __u8bDescriptorType;
+   __u8qwSignature[OS_STRING_QW_SIGN_LEN];
+   __u8bMS_VendorCode;
+   __u8bPad;
+} __packed;
+
 /*
  * The code in this file is utility code, used to build a gadget driver
  * from one or more function drivers, one or more configuration
@@ -960,6 +976,17 @@ static int get_string(struct usb_composite_dev *cdev,
return s-bLength;
}
 
+   if (cdev-use_os_string  language == 0  id == OS_STRING_IDX) {
+   struct usb_os_string *b = buf;
+   b-bLength = sizeof(*b);
+   b-bDescriptorType = USB_DT_STRING;
+   BUG_ON(sizeof(b-qwSignature) != sizeof(cdev-qw_sign));
+   memcpy(b-qwSignature, cdev-qw_sign, sizeof(b-qwSignature));
+   b-bMS_VendorCode = cdev-b_vendor_code;
+   b-bPad = 0;
+   return sizeof(*b);
+   }
+
list_for_each_entry(uc, cdev-gstrings, list) {
struct usb_gadget_strings **sp;
 
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index d3ca3b5..7d29ee9 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -335,11 +335,17 @@ static inline struct usb_composite_driver *to_cdriver(
return container_of(gdrv, struct usb_composite_driver, gadget_driver);
 }
 
+#define OS_STRING_QW_SIGN_LEN  14
+#define OS_STRING_IDX  0xEE
+
 /**
  * struct usb_composite_device - represents one composite usb gadget
  * @gadget: read-only, abstracts the gadget's usb peripheral controller
  * @req: used for control responses; buffer is pre-allocated
  * @config: the currently active configuration
+ * @qw_sign: qwSignature part of the OS string
+ * @b_vendor_code: bMS_VendorCode part of the OS string
+ * @use_os_string: false by default, interested gadgets set it
  *
  * One of these devices is allocated and initialized before the
  * associated device driver's bind() is called.
@@ -372,6 +378,11 @@ struct usb_composite_dev {
 
struct usb_configuration*config;
 
+   /* OS String is a custom (yet popular) extension to the USB standard. */
+   u8  qw_sign[OS_STRING_QW_SIGN_LEN];
+   u8  b_vendor_code;
+   unsigned intuse_os_string:1;
+
/* private: */
/* internals */
unsigned intsuspended:1;
-- 
1.8.3.2

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

[PATCH] usb: gadget: ether: example usage of OS descriptors

2014-05-06 Thread Andrzej Pietrasiewicz
Example of using OS Descriptors in a legacy gadget.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
---
 drivers/usb/gadget/ether.c | 61 +-
 1 file changed, 55 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index c1c113e..eab4b3a 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -24,6 +24,8 @@
 #endif
 
 #include u_ether.h
+#include u_rndis.h
+#include u_os_desc.h
 
 
 /*
@@ -316,6 +318,11 @@ static struct usb_configuration eth_config_driver = {
.bmAttributes   = USB_CONFIG_ATT_SELFPOWER,
 };
 
+static struct usb_os_desc_ext_prop icon_prop;
+static struct usb_os_desc_ext_prop label_prop;
+static const char *os_string = MSFT100;
+static const char *rndis_label = RNDIS;
+
 /*-*/
 
 static int __init eth_bind(struct usb_composite_dev *cdev)
@@ -324,6 +331,7 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
struct f_eem_opts   *eem_opts = NULL;
struct f_ecm_opts   *ecm_opts = NULL;
struct f_gether_opts*geth_opts = NULL;
+   struct f_rndis_opts *rndis_opts = NULL;
struct net_device   *net;
int status;
 
@@ -416,18 +424,53 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
 
-   /* register our configuration(s); RNDIS first, if it's used */
+   /* register our configuration(s); RNDIS reported first, if it's used */
+   status = usb_add_config(cdev, eth_config_driver, eth_do_config);
+   if (status  0)
+   goto fail1;
+
if (has_rndis()) {
+   rndis_opts = container_of(fi_rndis, struct f_rndis_opts,
+ func_inst);
+   cdev-use_os_string = true;
+   cdev-b_vendor_code = 0xCA;
+   status = utf8s_to_utf16s(os_string, strlen(os_string),
+   UTF16_LITTLE_ENDIAN,
+   (wchar_t *) cdev-qw_sign[0], OS_STRING_QW_SIGN_LEN);
+   if (status  0)
+   goto fail1;
+
+   list_add_tail(icon_prop.entry,
+   rndis_opts-rndis_os_desc.ext_prop);
+   list_add_tail(label_prop.entry,
+   rndis_opts-rndis_os_desc.ext_prop);
+
+   cdev-os_desc_config = rndis_config_driver;
+   memcpy(rndis_opts-rndis_os_desc.ext_compat_id[0],
+   rndis_label, 5);
+
+   icon_prop.type = USB_EXT_PROP_UNICODE_ENV;
+   icon_prop.name = Icons;
+   icon_prop.name_len = 2 * strlen(icon_prop.name) + 2;
+   icon_prop.data = %SystemRoot%\\system32\\shell32.dll,-233;
+   icon_prop.data_len = 2 * strlen(icon_prop.data) + 2;
+
+   label_prop.type = USB_EXT_PROP_UNICODE;
+   label_prop.name = Label;
+   label_prop.name_len = 2 * strlen(label_prop.name) + 2;
+   label_prop.data = XYZ Device;
+   label_prop.data_len = 2 * strlen(label_prop.data) + 2;
+
+   rndis_opts-rndis_os_desc.ext_prop_len =
+   icon_prop.name_len + icon_prop.data_len + 14 +
+   label_prop.name_len + label_prop.data_len + 14;
+   rndis_opts-rndis_os_desc.ext_prop_count = 2;
status = usb_add_config(cdev, rndis_config_driver,
rndis_do_config);
if (status  0)
goto fail1;
}
 
-   status = usb_add_config(cdev, eth_config_driver, eth_do_config);
-   if (status  0)
-   goto fail1;
-
usb_composite_overwrite_options(cdev, coverwrite);
dev_info(gadget-dev, %s, version:  DRIVER_VERSION \n,
DRIVER_DESC);
@@ -435,8 +478,11 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
return 0;
 
 fail1:
-   if (has_rndis())
+   if (has_rndis()) {
+   label_prop.data = NULL;
+   icon_prop.data = NULL;
usb_put_function_instance(fi_rndis);
+   }
 fail:
if (use_eem)
usb_put_function_instance(fi_eem);
@@ -449,7 +495,10 @@ fail:
 
 static int __exit eth_unbind(struct usb_composite_dev *cdev)
 {
+
if (has_rndis()) {
+   label_prop.data = NULL;
+   icon_prop.data = NULL;
usb_put_function(f_rndis);
usb_put_function_instance(fi_rndis);
}
-- 
1.8.3.2

--
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 06/20] usb: host: xhci-plat: Add support for the Armada 38x

2014-05-06 Thread Thomas Petazzoni
Dear Arnd Bergmann,

On Tue, 06 May 2014 14:21:55 +0200, Arnd Bergmann wrote:

  That's not what we do for any of the other drivers that use the
  MVEBU_MBUS functions.
 
 Fair enough. I guess using ARCH_MVEBU as the dependency works as well
 because it implies MVEBU_MBUS. However, you can't use COMPILE_TEST
 then because the driver itself needs the interfaces provided by MBUS.
 
 It could be
 
   depends on ARCH_MVEBU || (MVEBU_MBUS  COMPILE_TEST)
 
 to describe the dependency most accurately.

Right, that would work indeed, but is in fact not necessary, at least
for this driver. The only mbus function used by this driver is
mv_mbus_dram_info(), and linux/mbus.h provides an empty stub for this
function (returning NULL) when MVEBU_MBUS is disabled. So from a
compile time point of view, there is no problem with compiling the
xhci-plat driver with MVEBU_MBUS disabled, so in fact:

depends on ARCH_MVEBU || COMPILE_TEST

will work just fine.

The only case where this doesn't work is for drivers that use the other
mbus functions to create/remove windows, because no stubs are provided
for these ones. However, as things are today, the only driver in this
situation is the pci-mvebu driver, and its dependency is:

depends on ARCH_MVEBU || ARCH_DOVE || ARCH_KIRKWOOD

For this one, we could indeed add || (MVEBU_MBUS  COMPILE_TEST)

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.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


[PATCH/RFC] usb: gadget: CONFIG_USB_S3C_HSOTG should depend on HAS_DMA

2014-05-06 Thread Geert Uytterhoeven
If NO_DMA=y:

drivers/built-in.o: In function `s3c_hsotg_map_dma':
s3c-hsotg.c:(.text+0x375b2c): undefined reference to `usb_gadget_map_request'
drivers/built-in.o: In function `s3c_hsotg_unmap_dma':
s3c-hsotg.c:(.text+0x376a32): undefined reference to `usb_gadget_unmap_request'
make[3]: *** [vmlinux] Error 1

Note that all callers of s3c_hsotg_map_dma()/s3c_hsotg_unmap_dma() are
protected by a call into the using_dma() checking function:

static inline bool using_dma(struct s3c_hsotg *hsotg)
{
return false;   /* support is not complete */
}

but not all versions of gcc manage to optimize the check away, causing a
link error.

Signed-off-by: Geert Uytterhoeven ge...@linux-m68k.org
---
Perhaps the DMA code should be removed completely, as its unused, or be
protected by #ifdef CONFIG_HAS_DMA instead?

 drivers/usb/gadget/Kconfig |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 3557c7e5040d..0e9dead51a27 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -302,6 +302,7 @@ config USB_PXA27X
 
 config USB_S3C_HSOTG
tristate Designware/S3C HS/OtG USB Device controller
+   depends on HAS_DMA
help
  The Designware USB2.0 high-speed gadget controller
  integrated into many SoCs.
-- 
1.7.9.5

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


RE: [PATCH/RFC] usb: gadget: CONFIG_USB_S3C_HSOTG should depend on HAS_DMA

2014-05-06 Thread David Laight
From: Geert Uytterhoeven
 If NO_DMA=y:
 
 drivers/built-in.o: In function `s3c_hsotg_map_dma':
 s3c-hsotg.c:(.text+0x375b2c): undefined reference to `usb_gadget_map_request'
 drivers/built-in.o: In function `s3c_hsotg_unmap_dma':
 s3c-hsotg.c:(.text+0x376a32): undefined reference to 
 `usb_gadget_unmap_request'
 make[3]: *** [vmlinux] Error 1
 
 Note that all callers of s3c_hsotg_map_dma()/s3c_hsotg_unmap_dma() are
 protected by a call into the using_dma() checking function:
 
 static inline bool using_dma(struct s3c_hsotg *hsotg)
 {
 return false;   /* support is not complete */
 }
 
 but not all versions of gcc manage to optimize the check away, causing a
 link error.

A have seen gcc optimise away a call, but leave the undefined symbol
in the symbol table.
That might be what is happening here.

I don't know a generic solution, I used 'objcopy -N__udivdi3' to remove
the explicit unwanted reference from my driver.

David



--
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 05/20] usb: host: xhci-plat: Add clocks support

2014-05-06 Thread Jason Cooper
On Tue, May 06, 2014 at 02:14:00AM +0200, Gregory CLEMENT wrote:
 Some platform (such as the Armada 38x ones) can gate the clock of
 their USB controller. This patch add the support for the clock, by
 enabling them during probe and disabling them on remove.
 
 As not all platforms have clock support then enabling and disabling
 the clocks have been placed in separate functions. Then if the clocks
 are not supported we still can use the same calls, and there is no

... ?

thx,

Jason.

 
 Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
 ---
  drivers/usb/host/xhci-plat.c | 57 
 +---
  1 file changed, 54 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
 index f5351af4b2c5..bb37b941c8ec 100644
 --- a/drivers/usb/host/xhci-plat.c
 +++ b/drivers/usb/host/xhci-plat.c
 @@ -11,6 +11,7 @@
   * version 2 as published by the Free Software Foundation.
   */
  
 +#include linux/clk.h
  #include linux/dma-mapping.h
  #include linux/module.h
  #include linux/of.h
 @@ -19,6 +20,10 @@
  
  #include xhci.h
  
 +struct xhci_plat_priv {
 + struct clk *clk;
 +};
 +
  static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
  {
   /*
 @@ -38,7 +43,8 @@ static int xhci_plat_setup(struct usb_hcd *hcd)
  static const struct hc_driver xhci_plat_xhci_driver = {
   .description =  xhci-hcd,
   .product_desc = xHCI Host Controller,
 - .hcd_priv_size =sizeof(struct xhci_hcd *),
 + .hcd_priv_size =sizeof(struct xhci_hcd *) +
 + sizeof(struct xhci_plat_priv),
  
   /*
* generic hardware linkage
 @@ -85,6 +91,40 @@ static const struct hc_driver xhci_plat_xhci_driver = {
   .bus_resume =   xhci_bus_resume,
  };
  
 +static int xhci_plat_enable_clk(struct platform_device *pdev)
 +{
 + struct usb_hcd *hcd = platform_get_drvdata(pdev);
 + struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 + struct xhci_plat_priv *priv = (struct xhci_plat_priv *) xhci-priv;
 +
 + priv-clk = devm_clk_get(pdev-dev, NULL);
 +
 + /*
 +  * Not all platforms have a clk so it is not an error if the
 +  * clock does not exists.
 +  */
 + if (IS_ERR(priv-clk))
 + return 0;
 +
 + return clk_prepare_enable(priv-clk);
 +}
 +
 +static void xhci_plat_disable_clk(struct platform_device *pdev)
 +{
 + struct usb_hcd *hcd = platform_get_drvdata(pdev);
 + struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 + struct xhci_plat_priv *priv = (struct xhci_plat_priv *) xhci-priv;
 +
 + /*
 +  * Not all platforms have a clk so it is not an error if the
 +  * clock does not exists.
 +  */
 + if (IS_ERR(priv-clk))
 + return;
 +
 + clk_disable_unprepare(priv-clk);
 +}
 +
  static int xhci_plat_probe(struct platform_device *pdev)
  {
   const struct hc_driver  *driver;
 @@ -118,7 +158,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
  
   hcd = usb_create_hcd(driver, pdev-dev, dev_name(pdev-dev));
   if (!hcd)
 - return -ENOMEM;
 + ret = -ENOMEM;
  
   hcd-rsrc_start = res-start;
   hcd-rsrc_len = resource_size(res);
 @@ -140,6 +180,13 @@ static int xhci_plat_probe(struct platform_device *pdev)
   ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
   if (ret)
   goto unmap_registers;
 +
 + ret = xhci_plat_enable_clk(pdev);
 + if (ret) {
 + dev_dbg(pdev-dev, error enabling clocks\n);
 + goto dealloc_usb2_hcd;
 + }
 +
   device_wakeup_enable(hcd-self.controller);
  
   /* USB 2.0 roothub is stored in the platform_device now. */
 @@ -149,7 +196,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
   dev_name(pdev-dev), hcd);
   if (!xhci-shared_hcd) {
   ret = -ENOMEM;
 - goto dealloc_usb2_hcd;
 + goto disable_clk;
   }
  
   /*
 @@ -170,6 +217,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
  put_usb3_hcd:
   usb_put_hcd(xhci-shared_hcd);
  
 +disable_clk:
 + xhci_plat_disable_clk(pdev);
 +
  dealloc_usb2_hcd:
   usb_remove_hcd(hcd);
  
 @@ -193,6 +243,7 @@ static int xhci_plat_remove(struct platform_device *dev)
   usb_remove_hcd(xhci-shared_hcd);
   usb_put_hcd(xhci-shared_hcd);
  
 + xhci_plat_disable_clk(dev);
   usb_remove_hcd(hcd);
   iounmap(hcd-regs);
   release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
 -- 
 1.8.1.2
 
--
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: Bugs in xhci-hcd isochronous support

2014-05-06 Thread Alan Stern
On Mon, 5 May 2014, Russel Hughes wrote:

 
  Can you put the entire file some place where I can download it?
 
 Hi,
 
 You should have a link now to the file.

I got it.  There doesn't seem to be anything wrong with the data in the 
file.  This means whatever the problem is, there's a good chance we 
can't find it through software.

Does your computer have any USB-2 ports?  Or is it possible to disable 
the USB-3 controllers in the BIOS?  It would be worthwhile to see if 
the audio works when the device is attached to a non-USB-3 controller.

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 02/20] usb: ehci-orion: Add the optional PHY support

2014-05-06 Thread Andrew Lunn
On Tue, May 06, 2014 at 02:13:57AM +0200, Gregory CLEMENT wrote:
 This commit allows to use the PHY provided through the device tree. It
 will be useful for the Armada 375 SoCs. if no PHY is provided then the
 behavior of the driver is unchanged.
 
 Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
 ---
  drivers/usb/host/ehci-orion.c | 25 +++--
  1 file changed, 23 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
 index d6c19c37c76b..f6d9eb2e33cd 100644
 --- a/drivers/usb/host/ehci-orion.c
 +++ b/drivers/usb/host/ehci-orion.c
 @@ -15,6 +15,7 @@
  #include linux/clk.h
  #include linux/platform_data/usb-ehci-orion.h
  #include linux/of.h
 +#include linux/phy/phy.h
  #include linux/of_device.h
  #include linux/of_irq.h
  #include linux/usb.h
 @@ -46,6 +47,7 @@
  
  struct orion_ehci_hcd {
   struct clk *clk;
 + struct phy *phy;
  };
  
  static const char hcd_name[] = ehci-orion;
 @@ -224,6 +226,18 @@ static int ehci_orion_drv_probe(struct platform_device 
 *pdev)
   if (!IS_ERR(priv-clk))
   clk_prepare_enable(priv-clk);
  
 +
 + priv-phy = devm_phy_get(pdev-dev, usb);
 + if (!IS_ERR(priv-phy)) {
 + err = phy_init(priv-phy);
 + if (err)
 + goto err2;
 +
 + err = phy_power_on(priv-phy);
 + if (err)
 + goto err3;
 + }

Hi Gregory

What about EPROBE_DEFERRED?

 Andrew
--
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 08/20] ARM: mvebu: Add Device Tree description of xHCI hosts on Armada 38x

2014-05-06 Thread Andrew Lunn
On Tue, May 06, 2014 at 02:14:03AM +0200, Gregory CLEMENT wrote:
 The Marvell Armada 38x SoCs contains two xHCI host. This commit adds
 the Device Tree description of those interfaces at the SoC level, and
 also enables the two USB3 ports on the Armada 385 DB platform and one
 USB3 port on the Armada 385 RD platform.
 
 Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
 ---
  arch/arm/boot/dts/armada-385-db.dts |  8 
  arch/arm/boot/dts/armada-385-rd.dts |  4 
  arch/arm/boot/dts/armada-38x.dtsi   | 17 +
  3 files changed, 29 insertions(+)
 
 diff --git a/arch/arm/boot/dts/armada-385-db.dts 
 b/arch/arm/boot/dts/armada-385-db.dts
 index 6828d77696a6..d5db1466da82 100644
 --- a/arch/arm/boot/dts/armada-385-db.dts
 +++ b/arch/arm/boot/dts/armada-385-db.dts
 @@ -101,6 +101,14 @@
   reg = 0x100 0x3f00;
   };
   };
 +
 + usb3@f {
 + status = okay;
 + };
 +
 + usb3@f8000 {
 + status = okay;
 + };
   };
  
   pcie-controller {
 diff --git a/arch/arm/boot/dts/armada-385-rd.dts 
 b/arch/arm/boot/dts/armada-385-rd.dts
 index 45250c88814b..a505fe94ff37 100644
 --- a/arch/arm/boot/dts/armada-385-rd.dts
 +++ b/arch/arm/boot/dts/armada-385-rd.dts
 @@ -77,6 +77,10 @@
   reg = 1;
   };
   };
 +
 + usb3@f {
 + status = okay;
 + };
   };
  
   pcie-controller {
 diff --git a/arch/arm/boot/dts/armada-38x.dtsi 
 b/arch/arm/boot/dts/armada-38x.dtsi
 index a064f59da02d..5913ce1cc601 100644
 --- a/arch/arm/boot/dts/armada-38x.dtsi
 +++ b/arch/arm/boot/dts/armada-38x.dtsi
 @@ -355,6 +355,23 @@
   clocks = coredivclk 0;
   status = disabled;
   };
 +
 + usb3@f {
 + compatible = marvell,armada-380-xhci;
 + reg = 0xf 0x3fff,0xf4000 0x3fff;

0x3fff?

I would expect that to be 0x4000.

Andrew
--
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 v7 1/2] phy: Add new Exynos5 USB 3.0 PHY driver

2014-05-06 Thread Kishon Vijay Abraham I


On Wednesday 30 April 2014 08:54 AM, Vivek Gautam wrote:
 Hi Kishon, Tomasz,
 
 
 On Mon, Apr 28, 2014 at 11:47 AM, Vivek Gautam gautam.vi...@samsung.com 
 wrote:
 Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs.
 The new driver uses the generic PHY framework and will interact
 with DWC3 controller present on Exynos5 series of SoCs.
 Thereby, removing old phy-samsung-usb3 driver and related code
 used untill now which was based on usb/phy framework.

 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 ---
 
 Does this patch looks Ok now ?

fine by me. Tomasz, if you are OK with this patch pls give you Acked by.

Cheers
Kishon

 Actually we plan to get this in for 3.16, so if things are good we can
 get a go ahead for this :-)
 

 Changes from v6:
  - Addressed review comments:
-- Sorted config entries in Kconfig and Makefile
-- Made #define to_usbdrd_phy(inst) to a static inline routine.
-- Restructured exynos5_rate_to_clk() as suggested.
-- Amended 'val' field for regmap_update_bits() in the routine
   exynos5_usbdrd_phy_isol().
-- Removed sentinel entry from exynos5_usbdrd_phy_cfg[] struct.
-- Removed check for 'match' entry in probe().

  .../devicetree/bindings/phy/samsung-phy.txt|   40 ++
  drivers/phy/Kconfig|   11 +
  drivers/phy/Makefile   |1 +
  drivers/phy/phy-exynos5-usbdrd.c   |  627 
 
  4 files changed, 679 insertions(+)
  create mode 100644 drivers/phy/phy-exynos5-usbdrd.c

 diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
 b/Documentation/devicetree/bindings/phy/samsung-phy.txt
 index b422e38..51efe4c 100644
 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
 +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
 @@ -114,3 +114,43 @@ Example:
 compatible = samsung,exynos-sataphy-i2c;
 reg = 0x38;
 };
 +
 +Samsung Exynos5 SoC series USB DRD PHY controller
 +--
 +
 +Required properties:
 +- compatible : Should be set to one of the following supported values:
 +   - samsung,exynos5250-usbdrd-phy - for exynos5250 SoC,
 +   - samsung,exynos5420-usbdrd-phy - for exynos5420 SoC.
 +- reg : Register offset and length of USB DRD PHY register set;
 +- clocks: Clock IDs array as required by the controller
 +- clock-names: names of clocks correseponding to IDs in the clock property;
 +  Required clocks:
 +   - phy: main PHY clock (same as USB DRD controller i.e. DWC3 IP 
 clock),
 +  used for register access.
 +   - ref: PHY's reference clock (usually crystal clock), used for
 +  PHY operations, associated by phy name. It is used to
 +  determine bit values for clock settings register.
 +  For Exynos5420 this is given as 'sclk_usbphy30' in CMU.
 +- samsung,pmu-syscon: phandle for PMU system controller interface, used to
 + control pmu registers for power isolation.
 +- samsung,pmu-offset: phy power control register offset to 
 pmu-system-controller
 + base.
 +- #phy-cells : from the generic PHY bindings, must be 1;
 +
 +For samsung,exynos5250-usbdrd-phy and samsung,exynos5420-usbdrd-phy
 +compatible PHYs, the second cell in the PHY specifier identifies the
 +PHY id, which is interpreted as follows:
 +  0 - UTMI+ type phy,
 +  1 - PIPE3 type phy,
 +
 +Example:
 +   usb3_phy: usbphy@1210 {
 +   compatible = samsung,exynos5250-usbdrd-phy;
 +   reg = 0x1210 0x100;
 +   clocks = clock 286, clock 1;
 +   clock-names = phy, ref;
 +   samsung,pmu-syscon = pmu_system_controller;
 +   samsung,pmu-offset = 0x704;
 +   #phy-cells = 1;
 +   };
 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index 3bb05f1..daa1707 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -159,6 +159,17 @@ config PHY_EXYNOS5250_USB2
   particular SoC is compiled in the driver. In case of Exynos 5250 
 four
   phys are available - device, host, HSIC0 and HSIC.

 +config PHY_EXYNOS5_USBDRD
 +   tristate Exynos5 SoC series USB DRD PHY driver
 +   depends on ARCH_EXYNOS5  OF
 +   depends on HAS_IOMEM
 +   select GENERIC_PHY
 +   select MFD_SYSCON
 +   help
 + Enable USB DRD PHY support for Exynos 5 SoC series.
 + This driver provides PHY interface for USB 3.0 DRD controller
 + present on Exynos5 SoC series.
 +
  config PHY_XGENE
 tristate APM X-Gene 15Gbps PHY support
 depends on HAS_IOMEM  OF  (ARM64 || COMPILE_TEST)
 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
 index 2faf78e..333ba98 100644
 --- a/drivers/phy/Makefile
 +++ b/drivers/phy/Makefile
 @@ -17,4 +17,5 @@ obj-$(CONFIG_PHY_SAMSUNG_USB2)+= 
 phy-samsung-usb2.o
  

Re: [PATCH v3 17/20] phy: Add support for USB cluster on the Armada 375 SoC

2014-05-06 Thread Andrew Lunn
On Tue, May 06, 2014 at 02:14:12AM +0200, Gregory CLEMENT wrote:
 The Armada 375 SoC comes with an USB2 host and device controller and
 an USB3 controller. The USB cluster control register allows to manage
 common features of both USB controllers. It uses the generic PHY
 framework
 
 Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
 ---
  drivers/phy/Kconfig  |   5 ++
  drivers/phy/Makefile |   1 +
  drivers/phy/phy-armada375-usb2.c | 154 
 +++
  3 files changed, 160 insertions(+)
  create mode 100644 drivers/phy/phy-armada375-usb2.c
 
 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index 3bb05f17b9b4..cdf3e2c24e3a 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -15,6 +15,11 @@ config GENERIC_PHY
 phy users can obtain reference to the PHY. All the users of this
 framework should select this config.
  
 +config ARMADA375_USBCLUSTER_PHY
 + def_bool y
 + depends on OF
 + select GENERIC_PHY
 +
  config PHY_EXYNOS_MIPI_VIDEO
   tristate S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver
   depends on HAS_IOMEM
 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
 index 2faf78edc864..47d5a86807b6 100644
 --- a/drivers/phy/Makefile
 +++ b/drivers/phy/Makefile
 @@ -3,6 +3,7 @@
  #
  
  obj-$(CONFIG_GENERIC_PHY)+= phy-core.o
 +obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY)   += phy-armada375-usb2.o
  obj-$(CONFIG_BCM_KONA_USB2_PHY)  += phy-bcm-kona-usb2.o
  obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)+= phy-exynos-dp-video.o
  obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)  += phy-exynos-mipi-video.o
 diff --git a/drivers/phy/phy-armada375-usb2.c 
 b/drivers/phy/phy-armada375-usb2.c
 new file mode 100644
 index ..8bbac45e72c8
 --- /dev/null
 +++ b/drivers/phy/phy-armada375-usb2.c
 @@ -0,0 +1,154 @@
 +/*
 + * USB cluster support for Armada 375 platform.
 + *
 + * Copyright (C) 2014 Marvell
 + *
 + * Gregory CLEMENT gregory.clem...@free-electrons.com
 + *
 + * This file is licensed under the terms of the GNU General Public
 + * License version 2 or later. This program is licensed as is
 + * without any warranty of any kind, whether express or implied.
 + *
 + * Armada 375 comes with an USB2 host and device controller and an
 + * USB3 controller. The USB cluster control register allows to manage
 + * common features of both USB controller.
 + */
 +
 +#include linux/init.h
 +#include linux/io.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/of_address.h
 +#include linux/phy/phy.h
 +#include linux/platform_device.h
 +#include linux/slab.h
 +
 +#define USB2_PHY_CONFIG_ENABLE BIT(0) /* active low */
 +
 +/* the USB cluster allow to choose between two PHYs*/
 +#define NB_PHY 2
 +
 +enum {
 + PHY_USB2 = 0,
 + PHY_USB3 = 1,
 +};
 +
 +struct armada375_cluster_phy {
 + struct phy *phy;
 + void __iomem *reg;
 + bool enable;
 + bool use_usb3;

Hi Gregory

nit: How about using the enum you just defined?

 +};
 +
 +struct armada375_cluster_phy usb_cluster_phy[NB_PHY];
 +
 +static int armada375_usb_phy_init(struct phy *phy)
 +{
 + struct armada375_cluster_phy *cluster_phy = phy_get_drvdata(phy);
 + u32 reg;
 +
 + if (cluster_phy-enable) {
 + reg = readl(cluster_phy-reg);
 + if (cluster_phy-use_usb3)
 + reg |= USB2_PHY_CONFIG_ENABLE;
 + else
 + reg = ~USB2_PHY_CONFIG_ENABLE;
 + writel(reg, cluster_phy-reg);
 +
 + return 0;
 + } else {
 + return -ENODEV;
 + }
 +}
 +
 +static struct phy_ops armada375_usb_phy_ops = {
 + .init = armada375_usb_phy_init,
 + .owner  = THIS_MODULE,
 +};
 +
 +static struct phy *armada375_usb_phy_xlate(struct device *dev,
 + struct of_phandle_args *args)
 +{
 + if (WARN_ON(args-args[0] = NB_PHY))
 + return ERR_PTR(-ENODEV);
 +
 + return usb_cluster_phy[args-args[0]].phy;
 +}
 +
 +static int armada375_usb_phy_probe(struct platform_device *pdev)
 +{
 + struct device *dev = pdev-dev;
 + struct phy *phy;
 + struct device_node *np = dev-of_node;
 + struct phy_provider *phy_provider;
 + void __iomem *usb_cluster_base;
 + struct device_node *xhci_node;
 + int i;
 +
 + usb_cluster_base = of_iomap(np, 0);

devm_ API?

Check the return value for an error?

 + BUG_ON(!usb_cluster_base);
 +
 + for (i = 0; i  NB_PHY; i++) {
 + phy = devm_phy_create(dev, armada375_usb_phy_ops, NULL);
 + if (IS_ERR(phy))
 + dev_err(dev, failed to create PHY n%d\n, i);
 +
 + usb_cluster_phy[i].phy = phy;
 + usb_cluster_phy[i].reg = usb_cluster_base;
 + usb_cluster_phy[i].enable = false;
 + phy_set_drvdata(phy, usb_cluster_phy[i]);
 + }
 +
 + usb_cluster_phy[PHY_USB2].use_usb3 = false;
 + 

Re: About gadget configfs

2014-05-06 Thread Alan Stern
On Tue, 6 May 2014, Peter Chen wrote:

 3. Besides, I have tried two configurations, and each configuration with
 one function, I find the host PC always set configuration 1 (The first
   configuration), any ways to switch configuration at host
 side? libusb?

You can switch configurations on a Linux host by writing to a sysfs 
file:

echo N /sys/bus/usb/devices/.../bConfigurationValue

where N is the bConfigurationValue of the config you want to use and 
... is the pathname for the device.

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 v7 1/2] phy: Add new Exynos5 USB 3.0 PHY driver

2014-05-06 Thread Sylwester Nawrocki
On 28/04/14 08:17, Vivek Gautam wrote:
 Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs.
 The new driver uses the generic PHY framework and will interact
 with DWC3 controller present on Exynos5 series of SoCs.
 Thereby, removing old phy-samsung-usb3 driver and related code
 used untill now which was based on usb/phy framework.
 
 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 ---
 
 Changes from v6:
  - Addressed review comments:
-- Sorted config entries in Kconfig and Makefile
-- Made #define to_usbdrd_phy(inst) to a static inline routine.
-- Restructured exynos5_rate_to_clk() as suggested.
-- Amended 'val' field for regmap_update_bits() in the routine
   exynos5_usbdrd_phy_isol().
-- Removed sentinel entry from exynos5_usbdrd_phy_cfg[] struct.
-- Removed check for 'match' entry in probe().
 
  .../devicetree/bindings/phy/samsung-phy.txt|   40 ++
  drivers/phy/Kconfig|   11 +
  drivers/phy/Makefile   |1 +
  drivers/phy/phy-exynos5-usbdrd.c   |  627 
 
  4 files changed, 679 insertions(+)
  create mode 100644 drivers/phy/phy-exynos5-usbdrd.c
 
 diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
 b/Documentation/devicetree/bindings/phy/samsung-phy.txt
 index b422e38..51efe4c 100644
 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
 +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
 @@ -114,3 +114,43 @@ Example:
   compatible = samsung,exynos-sataphy-i2c;
   reg = 0x38;
   };
 +
 +Samsung Exynos5 SoC series USB DRD PHY controller
 +--
 +
 +Required properties:
 +- compatible : Should be set to one of the following supported values:
 + - samsung,exynos5250-usbdrd-phy - for exynos5250 SoC,
 + - samsung,exynos5420-usbdrd-phy - for exynos5420 SoC.
 +- reg : Register offset and length of USB DRD PHY register set;
 +- clocks: Clock IDs array as required by the controller
 +- clock-names: names of clocks correseponding to IDs in the clock property;
 +Required clocks:
 + - phy: main PHY clock (same as USB DRD controller i.e. DWC3 IP clock),
 +used for register access.
 + - ref: PHY's reference clock (usually crystal clock), used for
 +PHY operations, associated by phy name. It is used to
 +determine bit values for clock settings register.
 +For Exynos5420 this is given as 'sclk_usbphy30' in CMU.
 +- samsung,pmu-syscon: phandle for PMU system controller interface, used to
 +   control pmu registers for power isolation.
 +- samsung,pmu-offset: phy power control register offset to 
 pmu-system-controller
 +   base.

It doesn't seem right to have register offset encoded in the device tree
like this. I think it'd be more appropriate to associate such an offset
with the compatible string's value in the driver.

Also it might be sensible to create a new header file in include/linux/mfd/
syscon/ for Exynos5 SoCs and put any required PMU offset definitions there. 
Instead having them scattered and possibly duplicated in various drivers.

 +- #phy-cells : from the generic PHY bindings, must be 1;
 +
 +For samsung,exynos5250-usbdrd-phy and samsung,exynos5420-usbdrd-phy
 +compatible PHYs, the second cell in the PHY specifier identifies the
 +PHY id, which is interpreted as follows:
 +  0 - UTMI+ type phy,
 +  1 - PIPE3 type phy,
 +
 +Example:
 + usb3_phy: usbphy@1210 {
 + compatible = samsung,exynos5250-usbdrd-phy;
 + reg = 0x1210 0x100;
 + clocks = clock 286, clock 1;
 + clock-names = phy, ref;
 + samsung,pmu-syscon = pmu_system_controller;
 + samsung,pmu-offset = 0x704;
 + #phy-cells = 1;
 + };
[...]
 +struct usbdrd_phy_config {

Isn't name of this data structure too generic ? 
Perhaps rename it to exynos_usbdrd_phy_config ?

 + u32 id;
 + void (*phy_isol)(struct phy_usb_instance *inst, u32 on);
 + void (*phy_init)(struct exynos5_usbdrd_phy *phy_drd);
 + unsigned int (*set_refclk)(struct phy_usb_instance *inst);
 +};
 +
 +struct exynos5_usbdrd_phy_drvdata {
 + const struct usbdrd_phy_config *phy_cfg;
 +};
 +
[...]
 +const struct exynos5_usbdrd_phy_drvdata exynos5420_usbdrd_phy = {
 + .phy_cfg= exynos5_usbdrd_phy_cfg,
 +};
 +
 +const struct exynos5_usbdrd_phy_drvdata exynos5250_usbdrd_phy = {
 + .phy_cfg= exynos5_usbdrd_phy_cfg,
 +};
 +
 +static const struct of_device_id exynos5_usbdrd_phy_of_match[] = {
 + {
 + .compatible = samsung,exynos5250-usbdrd-phy,
 + .data = exynos5250_usbdrd_phy
 + }, {
 + .compatible = samsung,exynos5420-usbdrd-phy,
 + .data = exynos5420_usbdrd_phy
 + },
 + { },
 +};
 +
 +static int 

Re: [PATCH v3 01/20] usb: ehci-orion: Fix clock reference leaking

2014-05-06 Thread Alan Stern
On Tue, 6 May 2014, Gregory CLEMENT wrote:

 In order to disable the clock while the module was removing, a call to
 devm_clk_get() was made. This was wrong and lead to a leak module
 ref-counts.
 
 In order to have a reference of the clock get, a private structure was
 added using the override mechanism provided by the ehci framework.
 
 The bug was introduced in v3.6, however the ehci framework allowing to
 use the override mechanism have only been introduced in v3.8, so this
 patch won't apply before it.
 
 Fixes: 8c869edaee07c623066266827371235fb9c12e01 ('ARM: Orion: EHCI: Add 
 support for enabling clocks')
 Cc: sta...@vger.kernel.org # v3.8+
 Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com


   hcd = usb_create_hcd(ehci_orion_hc_driver,
   pdev-dev, dev_name(pdev-dev));
   if (!hcd) {
   err = -ENOMEM;
 - goto err2;
 + goto err1;
   }
  
   hcd-rsrc_start = res-start;
 @@ -211,6 +215,15 @@ static int ehci_orion_drv_probe(struct platform_device 
 *pdev)
   ehci-caps = hcd-regs + 0x100;
   hcd-has_tt = 1;
  
 + priv = hcd_to_orion_priv(hcd);
 + /*
 +  * Not all platforms can gate the clock, so it is not an error if
 +  * the clock does not exists.
 +  */
 + priv-clk = devm_clk_get(pdev-dev, NULL);
 + if (!IS_ERR(priv-clk))
 + clk_prepare_enable(priv-clk);
 +
   /*
* (Re-)program MBUS remapping windows if we are asked to.
*/
 @@ -240,16 +253,16 @@ static int ehci_orion_drv_probe(struct platform_device 
 *pdev)
  
   err = usb_add_hcd(hcd, irq, IRQF_SHARED);
   if (err)
 - goto err3;
 + goto err2;
  
   device_wakeup_enable(hcd-self.controller);
   return 0;
  
 -err3:
 - usb_put_hcd(hcd);
  err2:
 - if (!IS_ERR(clk))
 - clk_disable_unprepare(clk);
 + usb_put_hcd(hcd);

At this point, priv has just become a dangling pointer, because it
points to something that was allocated along with hcd.

 +
 + if (!IS_ERR(priv-clk))
 + clk_disable_unprepare(priv-clk);

And now you are dereferencing memory that has been deallocated.  The
real problem is that you get and enable the clock _after_ creating hcd,
but you don't disable it _before_ deallocating hcd.

  err1:
   dev_err(pdev-dev, init %s fail, %d\n,
   dev_name(pdev-dev), err);
 @@ -260,14 +273,14 @@ err1:
  static int ehci_orion_drv_remove(struct platform_device *pdev)
  {
   struct usb_hcd *hcd = platform_get_drvdata(pdev);
 - struct clk *clk;
 + struct orion_ehci_hcd *priv = hcd_to_orion_priv(hcd);
  
   usb_remove_hcd(hcd);
   usb_put_hcd(hcd);
  
 - clk = devm_clk_get(pdev-dev, NULL);
 - if (!IS_ERR(clk))
 - clk_disable_unprepare(clk);
 + if (!IS_ERR(priv-clk))
 + clk_disable_unprepare(priv-clk);

This has the same problem as above.

Also, for both this patch and 02/20, it would be better to replace the
errN labels with something more descriptive, so that it's not
necessary to renumber them every time something changes.

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/RFC] usb: gadget: CONFIG_USB_S3C_HSOTG should depend on HAS_DMA

2014-05-06 Thread Geert Uytterhoeven
Hi David,

On Tue, May 6, 2014 at 3:17 PM, David Laight david.lai...@aculab.com wrote:
 If NO_DMA=y:

 drivers/built-in.o: In function `s3c_hsotg_map_dma':
 s3c-hsotg.c:(.text+0x375b2c): undefined reference to `usb_gadget_map_request'
 drivers/built-in.o: In function `s3c_hsotg_unmap_dma':
 s3c-hsotg.c:(.text+0x376a32): undefined reference to 
 `usb_gadget_unmap_request'
 make[3]: *** [vmlinux] Error 1

 Note that all callers of s3c_hsotg_map_dma()/s3c_hsotg_unmap_dma() are
 protected by a call into the using_dma() checking function:

 static inline bool using_dma(struct s3c_hsotg *hsotg)
 {
 return false;   /* support is not complete */
 }

 but not all versions of gcc manage to optimize the check away, causing a
 link error.

 A have seen gcc optimise away a call, but leave the undefined symbol
 in the symbol table.
 That might be what is happening here.

Indeed, the unused functions s3c_hsotg_{,un}map_dma() are still there,
but the calls to them have been optimized away.

Marking s3c_hsotg_{,un}map_dma() inline fixes that. I'll send a new patch
doing that, as it's a bit silly to require depends on HAS_DMA for a driver
which has DMA disabled.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
-- Linus Torvalds
--
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: serial: option: add support for Novatel E371 PCIe card

2014-05-06 Thread Alexej Starschenko


Adds product ID for the Novatel E371 PCI Express Mini Card.

$ lsusb
Bus 001 Device 024: ID 1410:9011 Novatel Wireless

$ usb-devices
T:  Bus=01 Lev=01 Prnt=01 Port=03 Cnt=01 Dev#= 24 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1410 ProdID=9011 Rev=00.03
S:  Manufacturer=Novatel Wireless, Inc.
S:  Product=Novatel Wireless HSPA
S:  SerialNumber=012773002115811
C:  #Ifs= 6 Cfg#= 1 Atr=e0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#= 6 Alt= 0 #EPs= 1 Cls=02(commc) Sub=06 Prot=00 Driver=cdc_ether
I:  If#= 7 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether

Tested with kernel 3.2.0.

Signed-off-by: Alexej Starschenko starsche...@gmail.com

Patch:
---
 drivers/usb/serial/option.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index f213ee9..948a19f 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -161,6 +161,7 @@ static void option_instat_callback(struct urb *urb);
 #define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED0x9000
 #define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED0x9001
 #define NOVATELWIRELESS_PRODUCT_E362   0x9010
+#define NOVATELWIRELESS_PRODUCT_E371   0x9011
 #define NOVATELWIRELESS_PRODUCT_G2 0xA010
 #define NOVATELWIRELESS_PRODUCT_MC551  0xB001

@@ -1012,6 +1013,7 @@ static const struct usb_device_id option_ids[] = {
/* Novatel Ovation MC551 a.k.a. Verizon USB551L */
{ USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, 
NOVATELWIRELESS_PRODUCT_MC551, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, 
NOVATELWIRELESS_PRODUCT_E362, 0xff, 0xff, 0xff) },
+   { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, 
NOVATELWIRELESS_PRODUCT_E371, 0xff, 0xff, 0xff) },

{ USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) },
{ USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) },
--
--
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: gadget: atmel_usba: always test udc-driver

2014-05-06 Thread Alexandre Belloni
Found using smatch: drivers/usb/gadget/atmel_usba_udc.c:1689 usba_udc_irq()
error: we previously assumed 'udc-driver' could be null (see line 1636)

Always test udc-driver before using its members.

Signed-off-by: Alexandre Belloni alexandre.bell...@free-electrons.com
---
 drivers/usb/gadget/atmel_usba_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/atmel_usba_udc.c 
b/drivers/usb/gadget/atmel_usba_udc.c
index 9f65324f9ae0..76023ce449a3 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1686,7 +1686,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
reset_all_endpoints(udc);
 
if (udc-gadget.speed != USB_SPEED_UNKNOWN
-udc-driver-disconnect) {
+udc-driver  udc-driver-disconnect) {
udc-gadget.speed = USB_SPEED_UNKNOWN;
spin_unlock(udc-lock);
udc-driver-disconnect(udc-gadget);
-- 
1.9.1

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


Re: [PATCH 1/2] usb: dwc2: Option to disable dma descriptor mode

2014-05-06 Thread Sergei Shtylyov

Hello.

On 05/06/2014 02:23 AM, dingu...@altera.com wrote:


From: Dinh Nguyen dingu...@altera.com



Even though the IP supports Descriptor DMA mode, it does not support SPLIT
transactions in this mode. Since the driver can get the Descriptor DMA mode
support from hardware, the driver in its currently form cannot fully support
LS/FS devices connected to a HS Hub when Descriptor DMA mode is enabled in the
driver. Thus, we give the option to disable Descriptor DMA from device tree.



Signed-off-by: Dinh Nguyen dingu...@altera.com
---
  drivers/usb/dwc2/platform.c |3 +++
  1 file changed, 3 insertions(+)



diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index eaba547..cb2133c 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -123,6 +123,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
struct resource *res;
int retval;
int irq;
+   u32 prop;

if (usb_disabled())
return -ENODEV;
@@ -135,6 +136,8 @@ static int dwc2_driver_probe(struct platform_device *dev)
dwc2_set_all_params(defparams, -1);
params = defparams;
}
+   if (!of_property_read_u32(dev-dev.of_node, dma-desc-enable, prop))
+   defparams.dma_desc_enable = prop;


   You don't really need a helper local variable here, the variable receiving 
the property value won't be changed if there was an error retrieving it.


WBR, Sergei

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


Re: [PATCH v3 06/20] usb: host: xhci-plat: Add support for the Armada 38x

2014-05-06 Thread Felipe Balbi
Hi,

On Tue, May 06, 2014 at 02:14:01AM +0200, Gregory CLEMENT wrote:
 For the Armada 38x SoCs which come with an xhci controller, specific
 initialization must be done during probe related to the MBus windows
 configuration. This patch adds the support of this quirk.
 
 Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
 ---
  drivers/usb/host/Kconfig  |  7 +
  drivers/usb/host/Makefile |  1 +
  drivers/usb/host/xhci-mvebu.c | 71 
 +++
  drivers/usb/host/xhci-mvebu.h | 21 +
  drivers/usb/host/xhci-plat.c  |  6 
  5 files changed, 106 insertions(+)
  create mode 100644 drivers/usb/host/xhci-mvebu.c
  create mode 100644 drivers/usb/host/xhci-mvebu.h
 
 diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
 index 3d9e54062d62..e70943fac4a1 100644
 --- a/drivers/usb/host/Kconfig
 +++ b/drivers/usb/host/Kconfig
 @@ -29,6 +29,13 @@ if USB_XHCI_HCD
  config USB_XHCI_PLATFORM
   tristate
  
 +config USB_XHCI_MVEBU
 + tristate xHCI support for Marvell Armada 38x
 + select USB_XHCI_PLATFORM
 + ---help---
 +   Say 'Y' to enable the support for the xHCI host controller
 +   found in Marvell Armada 38x ARM SOCs.
 +
  endif # USB_XHCI_HCD
  
  config USB_EHCI_HCD
 diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
 index 7530468c9a4f..7a8db7f7dc01 100644
 --- a/drivers/usb/host/Makefile
 +++ b/drivers/usb/host/Makefile
 @@ -19,6 +19,7 @@ xhci-hcd-$(CONFIG_PCI)  += xhci-pci.o
  
  ifneq ($(CONFIG_USB_XHCI_PLATFORM), )
   xhci-hcd-y  += xhci-plat.o
 + xhci-hcd-$(CONFIG_USB_XHCI_MVEBU)   += xhci-mvebu.o

hmm, this has the potential of resulting in:

xhci-hcd-m += xhci-mvebu.o

I guess it's best to turn this into:

ifneq ($(CONFIG_USB_XHCI_PLATFORM), )
xhci-hcd-y += xhci-mvebu.o
endif

no ? Other than this comment:

Acked-by: Felipe Balbi ba...@ti.com

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH V3 0/5] Enable U1/U2 initiation from dwc3 xhci host

2014-05-06 Thread Felipe Balbi
Hi,

On Tue, May 06, 2014 at 09:24:15AM +0530, Pratyush Anand wrote:
 These patches provide support of LPM capability to the dwc3 xhci hosts.
 Patches have been tested on STih407.

I also asked for the test-results themselves. Which kernel was this
tested against ? v3.15-rc4 ? v3.14 ? Please share your dmesg output and
some sort of proof that LPM is, indeed, enabled and link transitions are
happening.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v3 04/20] usb: xhci: add a platform-private field

2014-05-06 Thread Felipe Balbi
On Tue, May 06, 2014 at 02:13:59AM +0200, Gregory CLEMENT wrote:
 This patch adds an xhci-priv field for private use by xHCI platform
 drivers. This field was present for OHCI and EHCI and it was not
 needed until now for xHCI. With the introduction of the clock support,
 then a private field will be useful, so let's mimic what have been
 done for the other HCI.
 
 Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com

Acked-by: Felipe Balbi ba...@ti.com

 ---
  drivers/usb/host/xhci.h | 3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
 index d280e9213d08..054017f66246 100644
 --- a/drivers/usb/host/xhci.h
 +++ b/drivers/usb/host/xhci.h
 @@ -1584,6 +1584,9 @@ struct xhci_hcd {
   u32 port_status_u0;
  /* Compliance Mode Timer Triggered every 2 seconds */
  #define COMP_MODE_RCVRY_MSECS 2000
 +
 + /* platform-specific data -- must come last */
 + unsigned long   priv[0] __aligned(sizeof(s64));
  };
  
  /* convert between an HCD pointer and the corresponding EHCI_HCD */
 -- 
 1.8.1.2
 

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 1/2] usb: dwc2: Option to disable dma descriptor mode

2014-05-06 Thread Dinh Nguyen
On Tue, 2014-05-06 at 19:39 +0400, Sergei Shtylyov wrote:
 Hello.
 
 On 05/06/2014 02:23 AM, dingu...@altera.com wrote:
 
  From: Dinh Nguyen dingu...@altera.com
 
  Even though the IP supports Descriptor DMA mode, it does not support SPLIT
  transactions in this mode. Since the driver can get the Descriptor DMA mode
  support from hardware, the driver in its currently form cannot fully support
  LS/FS devices connected to a HS Hub when Descriptor DMA mode is enabled in 
  the
  driver. Thus, we give the option to disable Descriptor DMA from device tree.
 
  Signed-off-by: Dinh Nguyen dingu...@altera.com
  ---
drivers/usb/dwc2/platform.c |3 +++
1 file changed, 3 insertions(+)
 
  diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
  index eaba547..cb2133c 100644
  --- a/drivers/usb/dwc2/platform.c
  +++ b/drivers/usb/dwc2/platform.c
  @@ -123,6 +123,7 @@ static int dwc2_driver_probe(struct platform_device 
  *dev)
  struct resource *res;
  int retval;
  int irq;
  +   u32 prop;
 
  if (usb_disabled())
  return -ENODEV;
  @@ -135,6 +136,8 @@ static int dwc2_driver_probe(struct platform_device 
  *dev)
  dwc2_set_all_params(defparams, -1);
  params = defparams;
  }
  +   if (!of_property_read_u32(dev-dev.of_node, dma-desc-enable, prop))
  +   defparams.dma_desc_enable = prop;
 
 You don't really need a helper local variable here, the variable 
 receiving 
 the property value won't be changed if there was an error retrieving it.
 

Ah yes, you're right. Thanks for the review.

Dinh
 WBR, Sergei
 


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


Re: Clarification regarding USB Data Card (3G Dongle) enumeration in Linux udev

2014-05-06 Thread Dan Williams
On Tue, 2014-05-06 at 14:27 +0530, Suresh Kumar N. wrote:
 On Mon, May 5, 2014 at 8:38 PM, Dan Williams d...@redhat.com wrote:
  On Mon, 2014-05-05 at 11:07 +0530, Suresh Kumar N. wrote:
  Hi,
 
  I am new to udev and device enumeration.
 
  I am interested to know how USB Data Card would get enumerated.
 
  Based on my understanding Data Card can get enumerated below 2 possible 
  ways -
1. As a modem
2. As a Network Interface Card (NIC)
 
  Or both at the same time.
 
  Is there a Standard defining the way a Data Card should be enumerated?
 
  There is no single standard.  There is a few standards and multiple
  proprietary mechanisms, and sometimes these are combined in the same
  device.
 
  The device simply enumerates as a normal USB device, providing to the
  host computer one or more USB interfaces.
 
  Each USB interface can be any one of:
 
  1) serial interface (AT, QCDM, WMC, WDM, CDC-ACM, etc)
  2) pseudo-ethernet NIC (proprietary, CDC-ETHER, CDC-NCM, etc)
 
 In such case (pseudo-ethernet NIC) do we assume that the firmware on
 the USB Dongle is responsible to establish IP address?
 In other words how does IP address allocation occur in this case?

The firmware is always involved, because the IP address comes from the
cellular network, and the firmware is what receives it.  The firmware
must then provide that address to the host, so that the host can
communicate with the network.  This happens in a few ways:

1) firmware implements a DHCP server, IPv6 Router, etc; host uses DHCP
client or IPv6 Router Discovery to obtain IP address and DNS details

2) firmware provides static IP address and DNS details over AT commands

3) firmware provides static IP address and DNS details via proprietary
protocols (QMI, MBIM, etc)

4) firmware implements PPP over serial port and provides IP address and
DNS details via IPCP/IPV6CP

Most modems still support #4 over at least one AT-capable serial port.
Many modems implement multiple methods (eg, Qualcomm firmware often does
#1, #3, and #4).

Note that in all cases, connection setup (with the APN and other
details) must occur via control channels (with AT, QMI, MBIM, etc)
before you can use any of these methods to obtain an IP address from the
firmware.

There is actually another class of plug and play 3G dongle that
provides a NAT-ed IP network (192.168.0.x or 10.x) to the host over what
looks like a USB ethernet NIC.  These appear exactly like a normal USB
ethernet dongle or a home router to the host, and to configure the
device, you use a web browser on the host like you would with a home
router.  None of the 3G stuff is exposed to the host.  One example is
Huawei HiLink devices like the E3256, though not all HiLink-branded
devices operate this way.

Dan

  3) proprietary control protocols (CnS, QMI, etc)
  4) standard non-serial control protocols (MBIM)
 
  A modem can provide any of these in combination.  Which port speaks what
  protocol is detected by one or more of the following methods:
 
  a) USB VID/PID and interface number hardcoded in the drivers or in
  userland udev rules
  b) USB interface type (eg, serial port or NIC port, done in userland)
  c) probing with known request/response to determine different
  communication protocols used if the port type is indeterminate
 
 Thanks for the information.
 
 
  Dan
 
  Please correct if my understanding is not correct or incomplete.
 
  Thanks in advance for your clarifications.
 
  Warm Regards,
  Suresh
  --
  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
 
 
 --
 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


--
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 3/8] usb: gadget: OS Feature Descriptors support

2014-05-06 Thread Michal Nazarewicz
On Tue, May 06 2014, Andrzej Pietrasiewicz wrote:
 Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com

Acked-by: Michal Nazarewicz min...@mina86.com

 diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
 index 4e8aaa6..47a6f4e 100644
 --- a/drivers/usb/gadget/composite.c
 +++ b/drivers/usb/gadget/composite.c
 @@ -454,8 +456,46 @@ static int config_desc(struct usb_composite_dev *cdev, 
 unsigned w_value)
  
   }
  
 - /* This is a lookup by config *INDEX* */
   w_value = 0xff;
 + /*
 +  * This is a lookup to make non-compliant USB hosts happy.
 +  *
 +  * By non-compliant USB hosts I mean those which only ask for
 +  * configuration @index 0.
 +  * If one configuration is marked special by storing
 +  * its address in cdev-os_desc_config, we try returning
 +  * exactly this configuration.
 +  *
 +  * Otherwise, regular list lookup is performed.
 +  *
 +  * If we are connected to a compliant USB host _and_
 +  * one configuration is special we report it @ index 0,
 +  * but report remaining configurations as well - with adjusted
 +  * indices.
 +  */
 + c = cdev-os_desc_config;
 + if (c) {
 + if (!w_value) {
 + switch (speed) {
 + case USB_SPEED_SUPER:
 + if (!c-superspeed)
 + goto list_lookup;
 + break;
 + case USB_SPEED_HIGH:
 + if (!c-highspeed)
 + goto list_lookup;
 + break;
 + default:
 + if (!c-fullspeed)
 + goto list_lookup;
 + }
 +
 + return config_buf(c, speed, cdev-req-buf, type);
 + }
 + --w_value; /* account for conf returned @ index 0 */
 + }

This is non-ideal since the body of the if is repeated twice.  Perhaps
it could be folded into the loop, something like:

/* This is a lookup by config *INDEX* */
w_value = 0xff;

struct list_head *pos = cdev-configs;
c = cdev-os_desc_config;
if (c) 
goto check_config;

while ((pos = pos-next) != cdev-configs) {
c = list_entry(pos, typeof(*c), list);

/* skip OS config which is handled separately */
if (c == cdev-os_desc_config)
continue;

check_config:
/* ignore configs that won't work at this speed */
switch (speed) {
case USB_SPEED_SUPER:
if (!c-superspeed)
continue;
break;
case USB_SPEED_HIGH:
if (!c-highspeed)
continue;
break;
default:
if (!c-fullspeed)
continue;
}

if (w_value == 0)
return config_buf(c, speed, cdev-req-buf, type);
w_value--;
}

Not tested.

 +list_lookup:
 + /* This is a lookup by config *INDEX* */
   list_for_each_entry(c, cdev-configs, list) {
   /* ignore configs that won't work at this speed */
   switch (speed) {

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo--


signature.asc
Description: PGP signature


Re: [PATCH 4/8] usb: gadget: f_rndis: OS descriptors support

2014-05-06 Thread Michal Nazarewicz
On Tue, May 06 2014, Andrzej Pietrasiewicz wrote:
 In order for usb functions to expose OS descriptors they
 need to be made aware of OS descriptors. This involves
 extending the options structure and setting up
 appropriate associations.

 Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com

Acked-by: Michal Nazarewicz min...@mina86.com

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo--


signature.asc
Description: PGP signature


Re: [PATCH] usb: gadget: s3c-hsotg: Mark s3c_hsotg_map_dma()/s3c_hsotg_unmap_dma() inline

2014-05-06 Thread Bartlomiej Zolnierkiewicz

Hi,

On Tuesday, May 06, 2014 07:37:01 PM Geert Uytterhoeven wrote:
 If NO_DMA=y, depending on the gcc version:
 
 drivers/built-in.o: In function `s3c_hsotg_map_dma':
 s3c-hsotg.c:(.text+0x375b2c): undefined reference to 
 `usb_gadget_map_request'
 drivers/built-in.o: In function `s3c_hsotg_unmap_dma':
 s3c-hsotg.c:(.text+0x376a32): undefined reference to 
 `usb_gadget_unmap_request'
 make[3]: *** [vmlinux] Error 1
 
 The obvious fix of making USB_S3C_HSOTG depend on HAS_DMA is a bit overkill,
 as DMA is never actually used. All (two) calls to s3c_hsotg_map_dma() and
 s3c_hsotg_unmap_dma() are protected by a call into the using_dma() checking
 function, which always returns false:
 
 static inline bool using_dma(struct s3c_hsotg *hsotg)
 {
 return false;   /* support is not complete */
 }
 
 Due to the constant return value, gcc optimizes away the calls to
 s3c_hsotg_map_dma() and s3c_hsotg_unmap_dma(). But some versions of gcc
 (e.g. 4.1.2) still emit the functions themselves, causing link errors.
 
 Marking s3c_hsotg_map_dma()/s3c_hsotg_unmap_dma() inline fixes this.

How's about just removing the dead code instead?  It has never worked since
the driver introduction back in June 2009 (almost 5 years) and it is trivial
to bring it back from kernel git repository if needed in the future.

PS Could you please fix -next kernels as well (drivers/usb/gadget/s3c-hsotg.c
has moved to drivers/usb/dwc2/gadget.c recently)?

 Signed-off-by: Geert Uytterhoeven ge...@linux-m68k.org
 ---
 This replaces [PATCH/RFC] usb: gadget: CONFIG_USB_S3C_HSOTG should depend on
 HAS_DMA
 
  drivers/usb/gadget/s3c-hsotg.c |   12 ++--
  1 file changed, 6 insertions(+), 6 deletions(-)
 
 diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
 index 2a9cb674926a..2740042228a4 100644
 --- a/drivers/usb/gadget/s3c-hsotg.c
 +++ b/drivers/usb/gadget/s3c-hsotg.c
 @@ -437,9 +437,9 @@ static inline int is_ep_periodic(struct s3c_hsotg_ep 
 *hs_ep)
   * This is the reverse of s3c_hsotg_map_dma(), called for the completion
   * of a request to ensure the buffer is ready for access by the caller.
   */
 -static void s3c_hsotg_unmap_dma(struct s3c_hsotg *hsotg,
 - struct s3c_hsotg_ep *hs_ep,
 - struct s3c_hsotg_req *hs_req)
 +static inline void s3c_hsotg_unmap_dma(struct s3c_hsotg *hsotg,
 +struct s3c_hsotg_ep *hs_ep,
 +struct s3c_hsotg_req *hs_req)
  {
   struct usb_request *req = hs_req-req;
  
 @@ -861,9 +861,9 @@ static void s3c_hsotg_start_req(struct s3c_hsotg *hsotg,
   * DMA memory, then we map the memory and mark our request to allow us to
   * cleanup on completion.
   */
 -static int s3c_hsotg_map_dma(struct s3c_hsotg *hsotg,
 -  struct s3c_hsotg_ep *hs_ep,
 -  struct usb_request *req)
 +static inline int s3c_hsotg_map_dma(struct s3c_hsotg *hsotg,
 + struct s3c_hsotg_ep *hs_ep,
 + struct usb_request *req)
  {
   struct s3c_hsotg_req *hs_req = our_req(req);
   int ret;

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung RD Institute Poland
Samsung Electronics

--
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/2] usb: dwc2: Option to disable dma descriptor mode

2014-05-06 Thread Paul Zimmerman
 From: dingu...@altera.com [mailto:dingu...@altera.com]
 Sent: Monday, May 05, 2014 3:23 PM
 
 Even though the IP supports Descriptor DMA mode, it does not support SPLIT
 transactions in this mode. Since the driver can get the Descriptor DMA mode
 support from hardware, the driver in its currently form cannot fully support
 LS/FS devices connected to a HS Hub when Descriptor DMA mode is enabled in the
 driver. Thus, we give the option to disable Descriptor DMA from device tree.

Hi Dinh,

Instead of this patch, how about if we make the driver default to buffer
DMA mode instead, and if anyone wants to use descriptor DMA mode, they
can add a DT property for that? I don't think anyone will want that,
since as you say it doesn't fully support LS/FS devices in that mode.

The driver originally worked like that. I guess the default got changed by
one of Matthijs' patches, and I didn't notice it.

-- 
Paul

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


Re: [PATCH 1/2] usb: dwc2: Option to disable dma descriptor mode

2014-05-06 Thread Felipe Balbi
On Tue, May 06, 2014 at 06:21:02PM +, Paul Zimmerman wrote:
  From: dingu...@altera.com [mailto:dingu...@altera.com]
  Sent: Monday, May 05, 2014 3:23 PM
  
  Even though the IP supports Descriptor DMA mode, it does not support SPLIT
  transactions in this mode. Since the driver can get the Descriptor DMA mode
  support from hardware, the driver in its currently form cannot fully support
  LS/FS devices connected to a HS Hub when Descriptor DMA mode is enabled in 
  the
  driver. Thus, we give the option to disable Descriptor DMA from device tree.
 
 Hi Dinh,
 
 Instead of this patch, how about if we make the driver default to buffer
 DMA mode instead, and if anyone wants to use descriptor DMA mode, they
 can add a DT property for that? I don't think anyone will want that,
 since as you say it doesn't fully support LS/FS devices in that mode.
 
 The driver originally worked like that. I guess the default got changed by
 one of Matthijs' patches, and I didn't notice it.

if this is the case, I guess you could call it a regression - well, it
_did_ break LS/FS use cases - and still merge it during the -rc cycle.

cheers

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH 1/2] usb: dwc2: Option to disable dma descriptor mode

2014-05-06 Thread Dinh Nguyen
On Tue, 2014-05-06 at 18:21 +, Paul Zimmerman wrote:
  From: dingu...@altera.com [mailto:dingu...@altera.com]
  Sent: Monday, May 05, 2014 3:23 PM
  
  Even though the IP supports Descriptor DMA mode, it does not support SPLIT
  transactions in this mode. Since the driver can get the Descriptor DMA mode
  support from hardware, the driver in its currently form cannot fully support
  LS/FS devices connected to a HS Hub when Descriptor DMA mode is enabled in 
  the
  driver. Thus, we give the option to disable Descriptor DMA from device tree.
 
 Hi Dinh,
 
 Instead of this patch, how about if we make the driver default to buffer
 DMA mode instead, and if anyone wants to use descriptor DMA mode, they
 can add a DT property for that? I don't think anyone will want that,
 since as you say it doesn't fully support LS/FS devices in that mode.

Yes, I think that's a good idea. Let me spin up a patchset to do that.

Dinh
 
 The driver originally worked like that. I guess the default got changed by
 one of Matthijs' patches, and I didn't notice it.
 


--
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/2] usb: dwc2: Option to disable dma descriptor mode

2014-05-06 Thread Paul Zimmerman
 From: Felipe Balbi [mailto:ba...@ti.com]
 Sent: Tuesday, May 06, 2014 11:37 AM
 
 On Tue, May 06, 2014 at 06:21:02PM +, Paul Zimmerman wrote:
   From: dingu...@altera.com [mailto:dingu...@altera.com]
   Sent: Monday, May 05, 2014 3:23 PM
  
   Even though the IP supports Descriptor DMA mode, it does not support SPLIT
   transactions in this mode. Since the driver can get the Descriptor DMA 
   mode
   support from hardware, the driver in its currently form cannot fully 
   support
   LS/FS devices connected to a HS Hub when Descriptor DMA mode is enabled 
   in the
   driver. Thus, we give the option to disable Descriptor DMA from device 
   tree.
 
  Hi Dinh,
 
  Instead of this patch, how about if we make the driver default to buffer
  DMA mode instead, and if anyone wants to use descriptor DMA mode, they
  can add a DT property for that? I don't think anyone will want that,
  since as you say it doesn't fully support LS/FS devices in that mode.
 
  The driver originally worked like that. I guess the default got changed by
  one of Matthijs' patches, and I didn't notice it.
 
 if this is the case, I guess you could call it a regression - well, it
 _did_ break LS/FS use cases - and still merge it during the -rc cycle.

Well, the change from Matthijs went in on August 30th last year. So it's
not exactly a recent regression ;)

-- 
Paul

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


RE: [PATCH] usb: dwc2: Remove '0x' notation when using %pad format

2014-05-06 Thread Paul Zimmerman
 From: Fabio Estevam [mailto:feste...@gmail.com]
 Sent: Monday, April 28, 2014 8:50 PM
 
 %pad notation automatically prints in hexadecimal format (with '0x'), so 
 remove
 the unneeded '0x' to avoid a '0x0x' string.
 
 Signed-off-by: Fabio Estevam fabio.este...@freescale.com
 ---
  drivers/usb/dwc2/gadget.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
 index 2057c38..f3c56a2 100644
 --- a/drivers/usb/dwc2/gadget.c
 +++ b/drivers/usb/dwc2/gadget.c
 @@ -551,7 +551,7 @@ static void s3c_hsotg_start_req(struct s3c_hsotg *hsotg,
   ureq-length, ureq-actual);
   if (0)
   dev_dbg(hsotg-dev,
 - REQ buf %p len %d dma 0x%pad noi=%d zp=%d snok=%d\n,
 + REQ buf %p len %d dma %pad noi=%d zp=%d snok=%d\n,
   ureq-buf, length, ureq-dma,
   ureq-no_interrupt, ureq-zero, ureq-short_not_ok);
 
 @@ -620,7 +620,7 @@ static void s3c_hsotg_start_req(struct s3c_hsotg *hsotg,
   dma_reg = dir_in ? DIEPDMA(index) : DOEPDMA(index);
   writel(ureq-dma, hsotg-regs + dma_reg);
 
 - dev_dbg(hsotg-dev, %s: 0x%pad = 0x%08x\n,
 + dev_dbg(hsotg-dev, %s: %pad = 0x%08x\n,
   __func__, ureq-dma, dma_reg);
   }
 
 --

Acked-by: Paul Zimmerman pa...@synopsys.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


xHCI LPM Support

2014-05-06 Thread Felipe Balbi
Hi Mathias,

I was using (up until today) v3.13 (on my desktop PC) to test LPM
transitions against OMAP5. Since I was having some issues with U1 exit
after some 200 iterations I decided to make sure v3.15-rc4 would have
the same behavior but, to my surprise, xHCI doesn't do any LPM
transitions anymore.

What changed since v3.13 ? Why aren't LPM transitions enabled anymore ?

I _do_ have an Intel chipset so XHCI_LPM_SUPPORT should be set.

Any ideas ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v3 17/20] phy: Add support for USB cluster on the Armada 375 SoC

2014-05-06 Thread Ezequiel Garcia
Hi Greg,

On 06 May 02:14 AM, Gregory CLEMENT wrote:
 +
 +#define USB2_PHY_CONFIG_ENABLE BIT(0) /* active low */
 +

I still think it's more readable to use USB2_PHY_CONFIG_DISABLE.
It's just a nitpick, though.

 +static int armada375_usb_phy_probe(struct platform_device *pdev)
 +{
 + struct device *dev = pdev-dev;
 + struct phy *phy;
 + struct device_node *np = dev-of_node;
 + struct phy_provider *phy_provider;
 + void __iomem *usb_cluster_base;
 + struct device_node *xhci_node;
 + int i;
 +
 + usb_cluster_base = of_iomap(np, 0);
 + BUG_ON(!usb_cluster_base);
 +

Isn't a bit extreme to call BUG_ON (and thus bring down the whole system)
in a phy driver?

 + for (i = 0; i  NB_PHY; i++) {
 + phy = devm_phy_create(dev, armada375_usb_phy_ops, NULL);
 + if (IS_ERR(phy))
 + dev_err(dev, failed to create PHY n%d\n, i);
 +

I think you're missing a continue/break here.

 + usb_cluster_phy[i].phy = phy;
 + usb_cluster_phy[i].reg = usb_cluster_base;
 + usb_cluster_phy[i].enable = false;
 + phy_set_drvdata(phy, usb_cluster_phy[i]);
 + }
 +
 + usb_cluster_phy[PHY_USB2].use_usb3 = false;
 + usb_cluster_phy[PHY_USB3].use_usb3 = true;
 +
[..]
 +
 +MODULE_DESCRIPTION(Armada 375 USB cluster driver);
 +MODULE_AUTHOR(Gregory CLEMENT gregory.clem...@free-electrons.com);
 +MODULE_LICENSE(GPL);

GPL v2 ?

-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.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


[PATCHv2 1/2] usb: dwc2: Disable descriptor dma mode by default

2014-05-06 Thread dinguyen
From: Dinh Nguyen dingu...@altera.com

Even though the IP supports Descriptor DMA mode, it does not support SPLIT
transactions in this mode. So the driver, in its currently form, will not
support LS/FS devices when connected to a HS Hub if Descriptor DMA mode is
enabled.

So we disable descriptor dma mode by default and a provide device tree property
for users to enable it if they really want to.

Signed-off-by: Dinh Nguyen dingu...@altera.com
---
v2:
- Reworked patch to disable descriptor dma by default
- Removed unneeded helper variable
- Reword patch commit header
---
 drivers/usb/dwc2/platform.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index eaba547..cc50d00 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -134,6 +134,16 @@ static int dwc2_driver_probe(struct platform_device *dev)
/* Default all params to autodetect */
dwc2_set_all_params(defparams, -1);
params = defparams;
+
+   /*
+* Disable descriptor dma mode by default as the HW can support
+* it, but does not support it for SPLIT transactions. One can
+* use the device tree property dma-desc-enable, if one really
+* wants to enable descriptor dma mode.
+*/
+   defparams.dma_desc_enable = 0;
+   of_property_read_u32(dev-dev.of_node, dma-desc-enable,
+   defparams.dma_desc_enable);
}
 
hsotg = devm_kzalloc(dev-dev, sizeof(*hsotg), GFP_KERNEL);
-- 
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


[PATCHv2 2/2] Documentation: dt: add an optional dma-desc-enable property for dwc2 usb

2014-05-06 Thread dinguyen
From: Dinh Nguyen dingu...@altera.com

The dma-desc-enable property can be used to enable descriptor DMA mode
for the DWC2 USB IP.

Signed-off-by: Dinh Nguyen dingu...@altera.com
---
v2: Reword property description to enable instead of disable
---
 Documentation/devicetree/bindings/usb/dwc2.txt |7 +++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt 
b/Documentation/devicetree/bindings/usb/dwc2.txt
index b8b6871..9b471b5 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.txt
+++ b/Documentation/devicetree/bindings/usb/dwc2.txt
@@ -14,6 +14,13 @@ Refer to clk/clock-bindings.txt for generic clock consumer 
properties
 Optional properties:
 - phys: phy provider specifier
 - phy-names: shall be device
+- dma-desc-enable: Should be 1 to enable descriptor dma mode. This
+   property is used to enable descriptor DMA support. The reason why
+   this property is needed is because the HW supports descriptor DMA
+   mode, but descriptor dma mode will not support SPLIT transactions.
+   So this property can be used to optionally enable descriptor DMA
+   support.
+
 Refer to phy/phy-bindings.txt for generic phy consumer properties
 
 Example:
-- 
1.7.9.5

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


RE: [PATCHv2 1/2] usb: dwc2: Disable descriptor dma mode by default

2014-05-06 Thread Paul Zimmerman
 From: dingu...@altera.com [mailto:dingu...@altera.com]
 Sent: Tuesday, May 06, 2014 4:01 PM
 
 Even though the IP supports Descriptor DMA mode, it does not support SPLIT
 transactions in this mode. So the driver, in its currently form, will not
 support LS/FS devices when connected to a HS Hub if Descriptor DMA mode is
 enabled.
 
 So we disable descriptor dma mode by default and a provide device tree 
 property
 for users to enable it if they really want to.

Hi Dinh,

I'd prefer not to add the DT property, at least for now. I doubt if
anyone will want to enable it. Besides, I'm not sure that a property
which only enables a driver feature is appropriate for DT.

So, if you redo patch 1 to remove the DT property read, and drop patch
2, you can add my acked-by. Thanks.

-- 
Paul

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


Re: [PATCH 1/2] usb: dwc2: Option to disable dma descriptor mode

2014-05-06 Thread Felipe Balbi
On Tue, May 06, 2014 at 08:11:34PM +, Paul Zimmerman wrote:
  From: Felipe Balbi [mailto:ba...@ti.com]
  Sent: Tuesday, May 06, 2014 11:37 AM
  
  On Tue, May 06, 2014 at 06:21:02PM +, Paul Zimmerman wrote:
From: dingu...@altera.com [mailto:dingu...@altera.com]
Sent: Monday, May 05, 2014 3:23 PM
   
Even though the IP supports Descriptor DMA mode, it does not support 
SPLIT
transactions in this mode. Since the driver can get the Descriptor DMA 
mode
support from hardware, the driver in its currently form cannot fully 
support
LS/FS devices connected to a HS Hub when Descriptor DMA mode is enabled 
in the
driver. Thus, we give the option to disable Descriptor DMA from device 
tree.
  
   Hi Dinh,
  
   Instead of this patch, how about if we make the driver default to buffer
   DMA mode instead, and if anyone wants to use descriptor DMA mode, they
   can add a DT property for that? I don't think anyone will want that,
   since as you say it doesn't fully support LS/FS devices in that mode.
  
   The driver originally worked like that. I guess the default got changed by
   one of Matthijs' patches, and I didn't notice it.
  
  if this is the case, I guess you could call it a regression - well, it
  _did_ break LS/FS use cases - and still merge it during the -rc cycle.
 
 Well, the change from Matthijs went in on August 30th last year. So it's
 not exactly a recent regression ;)

damn :-) alright, then merge window possibly with a stable tag, so it
gets backported ?

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v7 14/16] usb: resume (wakeup) child device when port is powered on

2014-05-06 Thread Dan Williams
On Fri, May 2, 2014 at 12:09 PM, Alan Stern st...@rowland.harvard.edu wrote:
 On Thu, 1 May 2014, Dan Williams wrote:

 I've been testing this and the pm_request_resume() ends up leaving the
 usb device enabled indefinitely.  It needs to be paired with a
 pm_runtime_autosuspend(), but at that point why not just add a
 usb_autoresume_device_async() helper.

 Why didn't pm_request_resume() result in an autosuspend?

Found it.

The last thing pm_runtime_barrier() does is pm_runtime_put_noidle()
which may cause the autosuspend timer to never be reset.

The other bug I had was that my power down scripts were errant in
unbinding the hub driver from 3rd level hubs.

I now have the following in khubd before running port_event() and it
is passing my initial tests (fixes the missed suspend mentioned
above).  Will hit it a bit harder with my tests and then re-submit the
series.

/*
 * Revalidate the device if it was requested by
 * usb_port_runtime_resume.
 */
if (test_and_clear_bit(i,
hub-wakeup_bits)  udev) {
pm_runtime_get_noresume(udev-dev);
pm_runtime_barrier(udev-dev);
pm_runtime_put_autosuspend(udev-dev);
}

Thanks.

--
Dan
--
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/7] ARM: sun6i: Add the USB clocks to the DTSI.

2014-05-06 Thread Maxime Ripard
The USB clocks of the A31 seems to be parented to the 24MHz oscillator, and
handle the clocks for the USB phys and OHCI devices.

Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 arch/arm/boot/dts/sun6i-a31.dtsi | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index eec1afa257a5..13aa56ed5858 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -269,6 +269,17 @@
clocks = osc24M, pll6;
clock-output-names = spi3;
};
+
+   usb_clk: clk@01c200cc {
+   #clock-cells = 1;
+   #reset-cells = 1;
+   compatible = allwinner,sun6i-a31-usb-clk;
+   reg = 0x01c200cc 0x4;
+   clocks = osc24M;
+   clock-output-names = usb_phy0, usb_phy1, usb_phy2,
+usb_ohci0, usb_ohci1,
+usb_ohci2;
+   };
};
 
soc@01c0 {
-- 
1.9.1

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


[PATCH 1/7] clk: sunxi: Implement A31 USB clock

2014-05-06 Thread Maxime Ripard
The A31 USB clock slightly differ from its older counterparts, mostly because
it has a different gate for each PHY, while the older one had a single gate for
all the phy.

Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 drivers/clk/sunxi/clk-sunxi.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index bd7dc733c1ca..d9bab75f128b 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -972,6 +972,11 @@ static const struct gates_data sun5i_a13_usb_gates_data 
__initconst = {
.reset_mask = 0x03,
 };
 
+static const struct gates_data sun6i_a31_usb_gates_data __initconst = {
+   .mask = { BIT(18) | BIT(17) | BIT(16) | BIT(10) | BIT(9) | BIT(8) },
+   .reset_mask = BIT(2) | BIT(1) | BIT(0),
+};
+
 static void __init sunxi_gates_clk_setup(struct device_node *node,
 struct gates_data *data)
 {
@@ -1267,6 +1272,7 @@ static const struct of_device_id clk_gates_match[] 
__initconst = {
{.compatible = allwinner,sun6i-a31-apb2-gates-clk, .data = 
sun6i_a31_apb2_gates_data,},
{.compatible = allwinner,sun4i-a10-usb-clk, .data = 
sun4i_a10_usb_gates_data,},
{.compatible = allwinner,sun5i-a13-usb-clk, .data = 
sun5i_a13_usb_gates_data,},
+   {.compatible = allwinner,sun6i-a31-usb-clk, .data = 
sun6i_a31_usb_gates_data,},
{}
 };
 
-- 
1.9.1

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


[PATCH 5/7] usb: ohci-platform: Enable optional use of reset controller

2014-05-06 Thread Maxime Ripard
The OHCI controllers used in the Allwinner A31 are asserted in reset using a
global reset controller.

Add optional support for such a controller in the OHCI platform driver.

Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 Documentation/devicetree/bindings/usb/usb-ohci.txt |  1 +
 drivers/usb/host/ohci-platform.c   | 25 +-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-ohci.txt 
b/Documentation/devicetree/bindings/usb/usb-ohci.txt
index 45f67d91e888..b968a1aea995 100644
--- a/Documentation/devicetree/bindings/usb/usb-ohci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-ohci.txt
@@ -12,6 +12,7 @@ Optional properties:
 - clocks : a list of phandle + clock specifier pairs
 - phys : phandle + phy specifier pair
 - phy-names : usb
+- resets : phandle + reset specifier pair
 
 Example:
 
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index b6002c951c5c..55f6c87628eb 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -24,6 +24,7 @@
 #include linux/err.h
 #include linux/phy/phy.h
 #include linux/platform_device.h
+#include linux/reset.h
 #include linux/usb/ohci_pdriver.h
 #include linux/usb.h
 #include linux/usb/hcd.h
@@ -36,6 +37,7 @@
 
 struct ohci_platform_priv {
struct clk *clks[OHCI_MAX_CLKS];
+   struct reset_control *rst;
struct phy *phy;
 };
 
@@ -67,10 +69,16 @@ static int ohci_platform_power_on(struct platform_device 
*dev)
goto err_disable_clks;
}
 
+   if (priv-rst) {
+   ret = reset_control_deassert(priv-rst);
+   if (ret)
+   goto err_disable_clks;
+   }
+
if (priv-phy) {
ret = phy_init(priv-phy);
if (ret)
-   goto err_disable_clks;
+   goto err_assert_rst;
 
ret = phy_power_on(priv-phy);
if (ret)
@@ -81,6 +89,9 @@ static int ohci_platform_power_on(struct platform_device *dev)
 
 err_exit_phy:
phy_exit(priv-phy);
+err_assert_rst:
+   if (priv-rst)
+   reset_control_assert(priv-rst);
 err_disable_clks:
while (--clk = 0)
clk_disable_unprepare(priv-clks[clk]);
@@ -99,6 +110,9 @@ static void ohci_platform_power_off(struct platform_device 
*dev)
phy_exit(priv-phy);
}
 
+   if (priv-rst)
+   reset_control_assert(priv-rst);
+
for (clk = OHCI_MAX_CLKS - 1; clk = 0; clk--)
if (priv-clks[clk])
clk_disable_unprepare(priv-clks[clk]);
@@ -191,6 +205,15 @@ static int ohci_platform_probe(struct platform_device *dev)
break;
}
}
+
+   priv-rst = devm_reset_control_get_optional(dev-dev,
+   NULL);
+   if (IS_ERR(priv-rst)) {
+   err = PTR_ERR(priv-rst);
+   if (err ==  -EPROBE_DEFER)
+   goto err_put_clks;
+   priv-rst = NULL;
+   }
}
 
if (pdata-big_endian_desc)
-- 
1.9.1

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


[PATCH 6/7] ARM: sun6i: dt: Add support for the USB controllers

2014-05-06 Thread Maxime Ripard
The A31 has two ECHI/OHCI controllers, and one OHCI-only phy-less controller.

Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 arch/arm/boot/dts/sun6i-a31.dtsi | 77 
 1 file changed, 77 insertions(+)

diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index 13aa56ed5858..5e9f01af6d99 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -341,6 +341,83 @@
status = disabled;
};
 
+   usbphy: phy@01c19400 {
+   compatible = allwinner,sun6i-a31-usb-phy;
+   reg = 0x01c19400 0x10,
+ 0x01c1a800 0x4,
+ 0x01c1b800 0x4;
+   reg-names = phy_ctrl,
+   pmu1,
+   pmu2;
+   clocks = usb_clk 8,
+usb_clk 9,
+usb_clk 10;
+   clock-names = usb0_phy,
+ usb1_phy,
+ usb2_phy;
+   resets = usb_clk 0,
+usb_clk 1,
+usb_clk 2;
+   reset-names = usb0_reset,
+ usb1_reset,
+ usb2_reset;
+   status = disabled;
+   #phy-cells = 1;
+   };
+
+   ehci0: usb@01c1a000 {
+   compatible = allwinner,sun6i-a31-ehci, generic-ehci;
+   reg = 0x01c1a000 0x100;
+   interrupts = 0 72 4;
+   clocks = ahb1_gates 26;
+   resets = ahb1_rst 26;
+   phys = usbphy 1;
+   phy-names = usb;
+   status = disabled;
+   };
+
+   ohci0: usb@01c1a400 {
+   compatible = allwinner,sun6i-a31-ohci, generic-ohci;
+   reg = 0x01c1a400 0x100;
+   interrupts = 0 73 4;
+   clocks = ahb1_gates 29, usb_clk 16;
+   resets = ahb1_rst 29;
+   phys = usbphy 1;
+   phy-names = usb;
+   status = disabled;
+   };
+
+   ehci1: usb@01c1b000 {
+   compatible = allwinner,sun6i-a31-ehci, generic-ehci;
+   reg = 0x01c1b000 0x100;
+   interrupts = 0 74 4;
+   clocks = ahb1_gates 27;
+   resets = ahb1_rst 27;
+   phys = usbphy 2;
+   phy-names = usb;
+   status = disabled;
+   };
+
+   ohci1: usb@01c1b400 {
+   compatible = allwinner,sun6i-a31-ohci, generic-ohci;
+   reg = 0x01c1b400 0x100;
+   interrupts = 0 75 4;
+   clocks = ahb1_gates 30, usb_clk 17;
+   resets = ahb1_rst 30;
+   phys = usbphy 2;
+   phy-names = usb;
+   status = disabled;
+   };
+
+   ohci2: usb@01c1c000 {
+   compatible = allwinner,sun6i-a31-ohci, generic-ohci;
+   reg = 0x01c1c400 0x100;
+   interrupts = 0 77 4;
+   clocks = ahb1_gates 31, usb_clk 18;
+   resets = ahb1_rst 31;
+   status = disabled;
+   };
+
pio: pinctrl@01c20800 {
compatible = allwinner,sun6i-a31-pinctrl;
reg = 0x01c20800 0x400;
-- 
1.9.1

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


[PATCH 4/7] usb: ehci-platform: add optional reset controller retrieval

2014-05-06 Thread Maxime Ripard
From: Boris BREZILLON boris.brezil...@free-electrons.com

On the Allwinner's A31 SoC the reset line connected to the EHCI IP has to
be deasserted for the EHCI block to be usable.

Add support for an optional reset controller that will be deasserted on
power off and asserted on power on.

Signed-off-by: Boris BREZILLON boris.brezil...@free-electrons.com
Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 Documentation/devicetree/bindings/usb/usb-ehci.txt |  1 +
 drivers/usb/host/ehci-platform.c   | 25 +-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-ehci.txt 
b/Documentation/devicetree/bindings/usb/usb-ehci.txt
index ff151ec084c4..43c1a4e06767 100644
--- a/Documentation/devicetree/bindings/usb/usb-ehci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-ehci.txt
@@ -15,6 +15,7 @@ Optional properties:
  - clocks : a list of phandle + clock specifier pairs
  - phys : phandle + phy specifier pair
  - phy-names : usb
+ - resets : phandle + reset specifier pair
 
 Example (Sequoia 440EPx):
 ehci@e300 {
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index c7dd93aad20c..4ee67728e443 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -29,6 +29,7 @@
 #include linux/of.h
 #include linux/phy/phy.h
 #include linux/platform_device.h
+#include linux/reset.h
 #include linux/usb.h
 #include linux/usb/hcd.h
 #include linux/usb/ehci_pdriver.h
@@ -41,6 +42,7 @@
 
 struct ehci_platform_priv {
struct clk *clks[EHCI_MAX_CLKS];
+   struct reset_control *rst;
struct phy *phy;
 };
 
@@ -84,10 +86,16 @@ static int ehci_platform_power_on(struct platform_device 
*dev)
goto err_disable_clks;
}
 
+   if (priv-rst) {
+   ret = reset_control_deassert(priv-rst);
+   if (ret)
+   goto err_disable_clks;
+   }
+
if (priv-phy) {
ret = phy_init(priv-phy);
if (ret)
-   goto err_disable_clks;
+   goto err_assert_rst;
 
ret = phy_power_on(priv-phy);
if (ret)
@@ -98,6 +106,9 @@ static int ehci_platform_power_on(struct platform_device 
*dev)
 
 err_exit_phy:
phy_exit(priv-phy);
+err_assert_rst:
+   if (priv-rst)
+   reset_control_assert(priv-rst);
 err_disable_clks:
while (--clk = 0)
clk_disable_unprepare(priv-clks[clk]);
@@ -119,6 +130,9 @@ static void ehci_platform_power_off(struct platform_device 
*dev)
for (clk = EHCI_MAX_CLKS - 1; clk = 0; clk--)
if (priv-clks[clk])
clk_disable_unprepare(priv-clks[clk]);
+
+   if (priv-rst)
+   reset_control_assert(priv-rst);
 }
 
 static struct hc_driver __read_mostly ehci_platform_hc_driver;
@@ -206,6 +220,15 @@ static int ehci_platform_probe(struct platform_device *dev)
break;
}
}
+
+   priv-rst = devm_reset_control_get_optional(dev-dev,
+   NULL);
+   if (IS_ERR(priv-rst)) {
+   err = PTR_ERR(priv-rst);
+   if (err ==  -EPROBE_DEFER)
+   goto err_put_clks;
+   priv-rst = NULL;
+   }
}
 
if (pdata-big_endian_desc)
-- 
1.9.1

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


[PATCH 3/7] phy: usb: sunxi: Introduce Allwinner A31 USB PHY support

2014-05-06 Thread Maxime Ripard
The USB phy controller in the A31 differs mostly from the older controllers
because it has a clock dedicated for each phy, while the older ones were having
a single clock for all the phys.

Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 drivers/phy/phy-sun4i-usb.c | 35 ++-
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
index e6e6c4ba7145..1d83abe07a29 100644
--- a/drivers/phy/phy-sun4i-usb.c
+++ b/drivers/phy/phy-sun4i-usb.c
@@ -61,16 +61,17 @@
 #define MAX_PHYS   3
 
 struct sun4i_usb_phy_data {
-   struct clk *clk;
void __iomem *base;
struct mutex mutex;
int num_phys;
u32 disc_thresh;
+   bool dedicated_clocks;
struct sun4i_usb_phy {
struct phy *phy;
void __iomem *pmu;
struct regulator *vbus;
struct reset_control *reset;
+   struct clk *clk;
int index;
} phys[MAX_PHYS];
 };
@@ -146,13 +147,13 @@ static int sun4i_usb_phy_init(struct phy *_phy)
struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy);
int ret;
 
-   ret = clk_prepare_enable(data-clk);
+   ret = clk_prepare_enable(phy-clk);
if (ret)
return ret;
 
ret = reset_control_deassert(phy-reset);
if (ret) {
-   clk_disable_unprepare(data-clk);
+   clk_disable_unprepare(phy-clk);
return ret;
}
 
@@ -170,11 +171,10 @@ static int sun4i_usb_phy_init(struct phy *_phy)
 static int sun4i_usb_phy_exit(struct phy *_phy)
 {
struct sun4i_usb_phy *phy = phy_get_drvdata(_phy);
-   struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy);
 
sun4i_usb_phy_passby(phy, 0);
reset_control_assert(phy-reset);
-   clk_disable_unprepare(data-clk);
+   clk_disable_unprepare(phy-clk);
 
return 0;
 }
@@ -230,6 +230,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
struct regulator *vbus;
struct resource *res;
struct phy *phy;
+   struct clk *clk;
char name[16];
int i;
 
@@ -249,15 +250,20 @@ static int sun4i_usb_phy_probe(struct platform_device 
*pdev)
else
data-disc_thresh = 2;
 
+   if (of_device_is_compatible(np, allwinner,sun6i-a31-usb-phy))
+   data-dedicated_clocks = true;
+
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, phy_ctrl);
data-base = devm_ioremap_resource(dev, res);
if (IS_ERR(data-base))
return PTR_ERR(data-base);
 
-   data-clk = devm_clk_get(dev, usb_phy);
-   if (IS_ERR(data-clk)) {
-   dev_err(dev, could not get usb_phy clock\n);
-   return PTR_ERR(data-clk);
+   if (!data-dedicated_clocks) {
+   clk = devm_clk_get(dev, usb_phy);
+   if (IS_ERR(clk)) {
+   dev_err(dev, could not get usb_phy clock\n);
+   return PTR_ERR(clk);
+   }
}
 
/* Skip 0, 0 is the phy for otg which is not yet supported. */
@@ -270,6 +276,15 @@ static int sun4i_usb_phy_probe(struct platform_device 
*pdev)
vbus = NULL;
}
 
+   if (data-dedicated_clocks) {
+   snprintf(name, sizeof(name), usb%d_phy, i);
+   clk = devm_clk_get(dev, name);
+   if (IS_ERR(clk)) {
+   dev_err(dev, failed to get clock %s\n, name);
+   return PTR_ERR(clk);
+   }
+   }
+
snprintf(name, sizeof(name), usb%d_reset, i);
reset = devm_reset_control_get(dev, name);
if (IS_ERR(reset)) {
@@ -296,6 +311,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
data-phys[i].pmu = pmu;
data-phys[i].vbus = vbus;
data-phys[i].reset = reset;
+   data-phys[i].clk = clk;
data-phys[i].index = i;
phy_set_drvdata(phy, data-phys[i]);
}
@@ -311,6 +327,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
 static const struct of_device_id sun4i_usb_phy_of_match[] = {
{ .compatible = allwinner,sun4i-a10-usb-phy },
{ .compatible = allwinner,sun5i-a13-usb-phy },
+   { .compatible = allwinner,sun6i-a31-usb-phy },
{ .compatible = allwinner,sun7i-a20-usb-phy },
{ },
 };
-- 
1.9.1

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


[PATCH 0/7] Add Allwinner A31 USB support

2014-05-06 Thread Maxime Ripard
Hi everyone,

This patchset adds support for the USB controllers found in the
Allwinner A31.

While the design is similar to the earlier Allwinner SoCs that are
already supported, a few details here and there change, like the fact
that the PHYs now have one clock per phy, while it used to be only one
for all the PHYs.

Thanks,
Maxime

Boris BREZILLON (2):
  usb: ehci-platform: add optional reset controller retrieval
  ARM: sunxi: dt: add APP4-EVB1 board support

Maxime Ripard (5):
  clk: sunxi: Implement A31 USB clock
  ARM: sun6i: Add the USB clocks to the DTSI.
  phy: usb: sunxi: Introduce Allwinner A31 USB PHY support
  usb: ohci-platform: Enable optional use of reset controller
  ARM: sun6i: dt: Add support for the USB controllers

 Documentation/devicetree/bindings/usb/usb-ehci.txt |  1 +
 Documentation/devicetree/bindings/usb/usb-ohci.txt |  1 +
 arch/arm/boot/dts/Makefile |  1 +
 arch/arm/boot/dts/sun6i-a31-app4-evb1.dts  | 63 
 arch/arm/boot/dts/sun6i-a31.dtsi   | 88 ++
 drivers/clk/sunxi/clk-sunxi.c  |  6 ++
 drivers/phy/phy-sun4i-usb.c| 35 ++---
 drivers/usb/host/ehci-platform.c   | 25 +-
 drivers/usb/host/ohci-platform.c   | 25 +-
 9 files changed, 234 insertions(+), 11 deletions(-)
 create mode 100644 arch/arm/boot/dts/sun6i-a31-app4-evb1.dts

-- 
1.9.1

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


[PATCH 7/7] ARM: sunxi: dt: add APP4-EVB1 board support

2014-05-06 Thread Maxime Ripard
From: Boris BREZILLON boris.brezil...@free-electrons.com

The APP4 EVB1 development boards embeds an A31, together with some NAND, one SD
card slot, and one SDIO + UART WiFi and Bluetooth chip, a few I2C buses, USB,
and a LCD display.

Signed-off-by: Boris BREZILLON boris.brezil...@free-electrons.com
Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
---
 arch/arm/boot/dts/Makefile|  1 +
 arch/arm/boot/dts/sun6i-a31-app4-evb1.dts | 63 +++
 2 files changed, 64 insertions(+)
 create mode 100644 arch/arm/boot/dts/sun6i-a31-app4-evb1.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index ffa3f5ef27d3..d50c0895a9d5 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -343,6 +343,7 @@ dtb-$(CONFIG_ARCH_SUNXI) += \
sun5i-a10s-olinuxino-micro.dtb \
sun5i-a13-olinuxino.dtb \
sun5i-a13-olinuxino-micro.dtb \
+   sun6i-a31-app4-evb1.dtb \
sun6i-a31-colombus.dtb \
sun6i-a31-m9.dtb \
sun7i-a20-cubieboard2.dtb \
diff --git a/arch/arm/boot/dts/sun6i-a31-app4-evb1.dts 
b/arch/arm/boot/dts/sun6i-a31-app4-evb1.dts
new file mode 100644
index ..270ab978f858
--- /dev/null
+++ b/arch/arm/boot/dts/sun6i-a31-app4-evb1.dts
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2014 Boris Brezillon
+ *
+ * Boris Brezillon boris.brezil...@free-electrons.com
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+/include/ sun6i-a31.dtsi
+
+/ {
+   model = Allwinner A31 APP4 EVB1 Evaluation Board;
+   compatible = allwinner,app4-evb1, allwinner,sun6i-a31;
+
+   chosen {
+   bootargs = earlyprintk console=ttyS0,115200;
+   };
+
+   soc@01c0 {
+   pio: pinctrl@01c20800 {
+   usb1_vbus_pin_a: usb1_vbus_pin@0 {
+   allwinner,pins = PH27;
+   allwinner,function = gpio_out;
+   allwinner,drive = 0;
+   allwinner,pull = 0;
+   };
+   };
+
+   usbphy: phy@01c19400 {
+   usb1_vbus-supply = reg_usb1_vbus;
+   status = okay;
+   };
+
+   ehci0: usb@01c1a000 {
+   status = okay;
+   };
+
+   uart0: serial@01c28000 {
+   pinctrl-names = default;
+   pinctrl-0 = uart0_pins_a;
+   status = okay;
+   };
+   };
+
+   reg_usb1_vbus: usb1-vbus {
+   compatible = regulator-fixed;
+   pinctrl-names = default;
+   pinctrl-0 = usb1_vbus_pin_a;
+   regulator-name = usb1-vbus;
+   regulator-min-microvolt = 500;
+   regulator-max-microvolt = 500;
+   enable-active-high;
+   gpio = pio 7 27 0;
+   status = okay;
+   };
+
+};
-- 
1.9.1

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


Re: [linux-sunxi] [PATCH 7/7] ARM: sunxi: dt: add APP4-EVB1 board support

2014-05-06 Thread Koen Kooi

Op 7 mei 2014, om 05:50 heeft Maxime Ripard maxime.rip...@free-electrons.com 
het volgende geschreven:

 From: Boris BREZILLON boris.brezil...@free-electrons.com
 
 The APP4 EVB1 development boards embeds an A31, together with some NAND, one 
 SD
 card slot, and one SDIO + UART WiFi and Bluetooth chip, a few I2C buses, USB,
 and a LCD display.
 
 Signed-off-by: Boris BREZILLON boris.brezil...@free-electrons.com
 Signed-off-by: Maxime Ripard maxime.rip...@free-electrons.com
 ---
 arch/arm/boot/dts/Makefile|  1 +
 arch/arm/boot/dts/sun6i-a31-app4-evb1.dts | 63 +++
 2 files changed, 64 insertions(+)
 create mode 100644 arch/arm/boot/dts/sun6i-a31-app4-evb1.dts
 
 diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
 index ffa3f5ef27d3..d50c0895a9d5 100644
 --- a/arch/arm/boot/dts/Makefile
 +++ b/arch/arm/boot/dts/Makefile
 @@ -343,6 +343,7 @@ dtb-$(CONFIG_ARCH_SUNXI) += \
   sun5i-a10s-olinuxino-micro.dtb \
   sun5i-a13-olinuxino.dtb \
   sun5i-a13-olinuxino-micro.dtb \
 + sun6i-a31-app4-evb1.dtb \
   sun6i-a31-colombus.dtb \
   sun6i-a31-m9.dtb \
   sun7i-a20-cubieboard2.dtb \
 diff --git a/arch/arm/boot/dts/sun6i-a31-app4-evb1.dts 
 b/arch/arm/boot/dts/sun6i-a31-app4-evb1.dts
 new file mode 100644
 index ..270ab978f858
 --- /dev/null
 +++ b/arch/arm/boot/dts/sun6i-a31-app4-evb1.dts
 @@ -0,0 +1,63 @@
 +/*
 + * Copyright 2014 Boris Brezillon
 + *
 + * Boris Brezillon boris.brezil...@free-electrons.com
 + *
 + * The code contained herein is licensed under the GNU General Public
 + * License. You may obtain a copy of the GNU General Public License
 + * Version 2 or later at the following locations:

Doesn't the kernel try to avoid the 'or later' clause?

regards,

Koen


 + *
 + * http://www.opensource.org/licenses/gpl-license.html
 + * http://www.gnu.org/copyleft/gpl.html
 + */
 +
 +/dts-v1/;
 +/include/ sun6i-a31.dtsi
 +
 +/ {
 + model = Allwinner A31 APP4 EVB1 Evaluation Board;
 + compatible = allwinner,app4-evb1, allwinner,sun6i-a31;
 +
 + chosen {
 + bootargs = earlyprintk console=ttyS0,115200;
 + };
 +
 + soc@01c0 {
 + pio: pinctrl@01c20800 {
 + usb1_vbus_pin_a: usb1_vbus_pin@0 {
 + allwinner,pins = PH27;
 + allwinner,function = gpio_out;
 + allwinner,drive = 0;
 + allwinner,pull = 0;
 + };
 + };
 +
 + usbphy: phy@01c19400 {
 + usb1_vbus-supply = reg_usb1_vbus;
 + status = okay;
 + };
 +
 + ehci0: usb@01c1a000 {
 + status = okay;
 + };
 +
 + uart0: serial@01c28000 {
 + pinctrl-names = default;
 + pinctrl-0 = uart0_pins_a;
 + status = okay;
 + };
 + };
 +
 + reg_usb1_vbus: usb1-vbus {
 + compatible = regulator-fixed;
 + pinctrl-names = default;
 + pinctrl-0 = usb1_vbus_pin_a;
 + regulator-name = usb1-vbus;
 + regulator-min-microvolt = 500;
 + regulator-max-microvolt = 500;
 + enable-active-high;
 + gpio = pio 7 27 0;
 + status = okay;
 + };
 +
 +};
 -- 
 1.9.1
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 linux-sunxi group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to linux-sunxi+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.
 

--
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 4/5] dwc3: host: Enable USB3 LPM capability

2014-05-06 Thread Pratyush Anand
Hi Paul,

On Tue, May 06, 2014 at 11:54:19AM +0800, Pratyush ANAND wrote:
 All dwc3 based xhci host controller supports USB3.0 LPM functionality.
 Therefore enable it in platform data for all dwc3 based xhci device.
 
 Signed-off-by: Pratyush Anand pratyush.an...@st.com
 ---
  drivers/usb/dwc3/host.c | 12 
  1 file changed, 12 insertions(+)
 
 diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
 index 32db328..1fda6e8 100644
 --- a/drivers/usb/dwc3/host.c
 +++ b/drivers/usb/dwc3/host.c
 @@ -16,12 +16,14 @@
   */
  
  #include linux/platform_device.h
 +#include linux/usb/xhci_pdriver.h
  
  #include core.h
  
  int dwc3_host_init(struct dwc3 *dwc)
  {
   struct platform_device  *xhci;
 + struct usb_xhci_pdata   pdata;
   int ret;
  
   xhci = platform_device_alloc(xhci-hcd, PLATFORM_DEVID_AUTO);
 @@ -46,6 +48,16 @@ int dwc3_host_init(struct dwc3 *dwc)
   goto err1;
   }
  
 + memset(pdata, 0, sizeof(pdata));
 +
 + pdata.usb3_lpm_capable = 1;

Even though all dwc3 platform is usb3 lpm capable, I would like to
make it optional, as I see some performance impact when capability is
enabled vs not enabled.

When enabled:
./testusb -a -t 2 -c 100 -s 1024
takes 198 sec to execute
vs when not enabled , it takes 169 sec to execute.

And this impact is with a gadget with maxburst and mult as 0.
Performance will be impacted more with higher maxburst and mult.

So making it optional would be a better choice. What do you say.

Pratyush


 +
 + ret = platform_device_add_data(xhci, pdata, sizeof(pdata));
 + if (ret) {
 + dev_err(dwc-dev, couldn't add platform data to xHCI 
 device\n);
 + goto err1;
 + }
 +
   ret = platform_device_add(xhci);
   if (ret) {
   dev_err(dwc-dev, failed to register xHCI device\n);
 -- 
 1.8.1.2
--
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