Re: [PATCH v4 1/1] USB: core: let USB device know device node

2016-02-05 Thread Arnd Bergmann
On Friday 05 February 2016 14:11:25 Peter Chen wrote:
> On Thu, Feb 04, 2016 at 11:44:50AM +0100, Philipp Zabel wrote:
> > Am Montag, den 25.01.2016, 15:24 +0800 schrieb Peter Chen:
> > > diff --git a/Documentation/devicetree/bindings/usb/usb-device.txt 
> > > b/Documentation/devicetree/bindings/usb/usb-device.txt
> > > new file mode 100644
> > > index 000..c702885
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/usb/usb-device.txt
> > > @@ -0,0 +1,25 @@
> > > +Generic USB Device Properties
> > > +
> > > +Usually, we only use device tree for hard wired USB device.
> > > +The reference binding doc is from:
> > > +http://www.firmware.org/1275/bindings/usb/usb-1_0.ps
> > > +
> > > +Required properties:
> > > +- compatible: usbVID,PID
> > 
> > The reference recommendation states that for single-configuration USB
> > devices the compatible should contain all of the applicable strings from
> > the list starting with 2) "usbVID,PID.REV" and ending with 11)
> > "usb,device". Are we going to ignore this?
> > 
> 
> I have not seen benefits if we write several compatibles in dts,
> the information of compatibles listed in doc can be got during
> the enumeration.
> 
> I suggest we use the simple pattern for this compatible, in that
> case, every one can be easy to follow it, and will not be confused
> which compatibles should be used, and the style can be unify.

It seems fine, as we don't expect any OS to ever use the compatible
strings for binding to the driver. I think you should add a sentence
to explain this, and maybe clarify that the compatible strings from
the standard binding may also be used, but that a device adhering
to this binding may leave out all except for usbVID,PID

> > 
> > > + compatible = "usb05e3,0608";
> > > + reg = <0x1>;
> > > + };
> > 
> > I'd have written this node as:
> > 
> > hub: hub@1 {
> > compatible = "usb5e3,608", "usb5e3,class9",
> >  "usb,class9", "usb,device";
> > reg = <1>;
> > };
> 
> The reg should be hexadecimal, do we need to add "0x" before the value?

The formatting of the numbers in properties is not normative, either
one works and has the same meaning. I would leave out the leading 0x
here too, as we are just enumerating the ports.

I don't think that any USB hub has more than 9 ports, so it's not
ambiguous to the reader.

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 v4 1/1] USB: core: let USB device know device node

2016-02-05 Thread Philipp Zabel
Am Freitag, den 05.02.2016, 14:11 +0800 schrieb Peter Chen:
[...]
> > The reference recommendation states that for single-configuration USB
> > devices the compatible should contain all of the applicable strings from
> > the list starting with 2) "usbVID,PID.REV" and ending with 11)
> > "usb,device". Are we going to ignore this?
>
> I have not seen benefits if we write several compatibles in dts,
> the information of compatibles listed in doc can be got during
> the enumeration.
> 
> I suggest we use the simple pattern for this compatible, in that
> case, every one can be easy to follow it, and will not be confused
> which compatibles should be used, and the style can be unify.

Just pointing it out, a comment why this differs from the recommendation
would be nice to avoid confusion.

[...]
> > > + compatible = "usb05e3,0608";
> > > + reg = <0x1>;
> > > + };
> > 
> > I'd have written this node as:
> > 
> > hub: hub@1 {
> > compatible = "usb5e3,608", "usb5e3,class9",
> >  "usb,class9", "usb,device";
> > reg = <1>;
> > };
> 
> The reg should be hexadecimal, do we need to add "0x" before the value?

The unit-address name part should be hexadecimal, the reg property value
doesn't have to be. As long as the value is < 10 I don't see a problem.

> > As another example, I'd like to introduce the USB WLAN Adapter soldered
> > onto the imx6q-gk802 board to its power enable GPIO via the device tree:
> > 
> > /* Internal USB port (USBH1) */
> > &usbh1 {
> > #address-cells = <1>;
> > #size-cells = <0>;
> > status = "okay";
> > 
> > /* RTL8192CU 802.11n WLAN Adapter */
> > device@1 {
> > compatible = "usbbda,8176.200", "usbbda,8176",
> >  "usb,device";
> > reg = <1>;
> > 
> > enable-gpios = <&gpio2 0 GPIO_ACTIVE_LOW>;
> > };
> > };
> > 
> 
> It is okay to use your example, but I still insist like below:

Sorry for being imprecise. The hub example is fine for the
documentation. I just wanted to illustrate how and why I am interested
in this discussion.

best regards
Philipp

--
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 v4 1/1] USB: core: let USB device know device node

2016-02-05 Thread Peter Chen
On Fri, Feb 5, 2016 at 12:36 AM, Alan Stern  wrote:
> On Thu, 4 Feb 2016, Peter Chen wrote:
>
>> On Mon, Jan 25, 2016 at 03:24:39PM +0800, Peter Chen wrote:
>> > Although most of USB devices are hot-plug's, there are still some devices
>> > are hard wired on the board, eg, for HSIC and SSIC interface USB devices.
>> > If these kinds of USB devices are multiple functions, and they can supply
>> > other interfaces like i2c, gpios for other devices, we may need to
>> > describe these at device tree.
>> >
>> > In this commit, it uses "reg" in dts as physical port number to match
>> > the phyiscal port number decided by USB core, if they are the same,
>> > then the device node is for the device we are creating for USB core.
>> >
>> > Signed-off-by: Peter Chen 
>> > ---
>> > Changes for v4:
>> > - The range of "reg" should be 1-31, changing device node address
>> >   style as in lower case hexadecimal with leading zeroes suppressed
>> >   [binding doc, usb-device.txt]
>> > - Improve the example at binding doc, it describes node from the top
>> >   (the controller)
>> > - Delete the struct of_node * within struct usb_device
>> > - Using usb_hcd_find_raw_port_number to get raw port number under root
>> >   hub port
>> >
>>
>> Hi Alan, Arnd, and others, would you please give Ack for it if you
>> are OK with this patch? I am not sure if Greg will queue it or not
>> if no one Acks it, thanks.
>
>
>> > @@ -508,11 +509,20 @@ struct usb_device *usb_alloc_dev(struct usb_device 
>> > *parent,
>> > dev->connect_time = jiffies;
>> > dev->active_duration = -jiffies;
>> >  #endif
>> > -   if (root_hub)   /* Root hub always ok [and always wired] */
>> > +   if (root_hub) { /* Root hub always ok [and always wired] */
>> > dev->authorized = 1;
>> > -   else {
>> > +   dev->dev.of_node = bus->controller->of_node;
>> > +   } else {
>> > dev->authorized = !!HCD_DEV_AUTHORIZED(usb_hcd);
>> > dev->wusb = usb_bus_is_wusb(bus) ? 1 : 0;
>> > +
>> > +   if (dev->dev.parent->parent == bus->controller)
>> > +   /* device under root hub's port */
>> > +   port1 = usb_hcd_find_raw_port_number(usb_hcd,
>> > +   port1);
>
> I would change the test to "if (!parent->parent)" and add {} around the
> body (since it's 3 lines long).  Also, although this doesn't really
> matter, you could consider putting the new code inside the previous big
> "if" statement instead of down here at the end of the function.
>

Sorry, Alan, I can understand using (!parent->parent) to stands for
the device connects to the root hub port, others I can't understand.

-- 
BR,
Peter Chen
--
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 v4 1/1] USB: core: let USB device know device node

2016-02-05 Thread Peter Chen
On Fri, Feb 5, 2016 at 5:37 PM, Philipp Zabel  wrote:
> Am Freitag, den 05.02.2016, 14:11 +0800 schrieb Peter Chen:
> [...]
>> > The reference recommendation states that for single-configuration USB
>> > devices the compatible should contain all of the applicable strings from
>> > the list starting with 2) "usbVID,PID.REV" and ending with 11)
>> > "usb,device". Are we going to ignore this?
>>
>> I have not seen benefits if we write several compatibles in dts,
>> the information of compatibles listed in doc can be got during
>> the enumeration.
>>
>> I suggest we use the simple pattern for this compatible, in that
>> case, every one can be easy to follow it, and will not be confused
>> which compatibles should be used, and the style can be unify.
>
> Just pointing it out, a comment why this differs from the recommendation
> would be nice to avoid confusion.
>

Thanks, I will.

> [...]
>> > > + compatible = "usb05e3,0608";
>> > > + reg = <0x1>;
>> > > + };
>> >
>> > I'd have written this node as:
>> >
>> > hub: hub@1 {
>> > compatible = "usb5e3,608", "usb5e3,class9",
>> >  "usb,class9", "usb,device";
>> > reg = <1>;
>> > };
>>
>> The reg should be hexadecimal, do we need to add "0x" before the value?
>
> The unit-address name part should be hexadecimal, the reg property value
> doesn't have to be. As long as the value is < 10 I don't see a problem.
>

I see.

>> > As another example, I'd like to introduce the USB WLAN Adapter soldered
>> > onto the imx6q-gk802 board to its power enable GPIO via the device tree:
>> >
>> > /* Internal USB port (USBH1) */
>> > &usbh1 {
>> > #address-cells = <1>;
>> > #size-cells = <0>;
>> > status = "okay";
>> >
>> > /* RTL8192CU 802.11n WLAN Adapter */
>> > device@1 {
>> > compatible = "usbbda,8176.200", "usbbda,8176",
>> >  "usb,device";
>> > reg = <1>;
>> >
>> > enable-gpios = <&gpio2 0 GPIO_ACTIVE_LOW>;
>> > };
>> > };
>> >
>>
>> It is okay to use your example, but I still insist like below:
>
> Sorry for being imprecise. The hub example is fine for the
> documentation. I just wanted to illustrate how and why I am interested
> in this discussion.
>

Thanks for commenting it.

I will be in Chinese New Year holiday, will send next version after Feb 15th.

-- 
BR,
Peter Chen
--
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: f_midi: fix missing unlock on error in f_midi_alloc()

2016-02-05 Thread weiyj_lk
From: Wei Yongjun 

Add the missing unlock before return from function f_midi_alloc()
when kfifo_alloc() failed.

Signed-off-by: Wei Yongjun 
---
 drivers/usb/gadget/function/f_midi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_midi.c 
b/drivers/usb/gadget/function/f_midi.c
index fb1fe96d..18119f3 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -1188,7 +1188,6 @@ static struct usb_function *f_midi_alloc(struct 
usb_function_instance *fi)
 
if (!port) {
status = -ENOMEM;
-   mutex_unlock(&opts->lock);
goto setup_fail;
}
 
@@ -1202,7 +1201,6 @@ static struct usb_function *f_midi_alloc(struct 
usb_function_instance *fi)
midi->id = kstrdup(opts->id, GFP_KERNEL);
if (opts->id && !midi->id) {
status = -ENOMEM;
-   mutex_unlock(&opts->lock);
goto setup_fail;
}
midi->in_ports = opts->in_ports;
@@ -1229,6 +1227,7 @@ static struct usb_function *f_midi_alloc(struct 
usb_function_instance *fi)
return &midi->func;
 
 setup_fail:
+   mutex_unlock(&opts->lock);
for (--i; i >= 0; i--)
kfree(midi->in_port[i]);
kfree(midi);

--
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 v4 1/1] USB: core: let USB device know device node

2016-02-05 Thread Alan Stern
On Fri, 5 Feb 2016, Peter Chen wrote:

> >> > @@ -508,11 +509,20 @@ struct usb_device *usb_alloc_dev(struct usb_device 
> >> > *parent,
> >> > dev->connect_time = jiffies;
> >> > dev->active_duration = -jiffies;
> >> >  #endif
> >> > -   if (root_hub)   /* Root hub always ok [and always wired] */
> >> > +   if (root_hub) { /* Root hub always ok [and always wired] */
> >> > dev->authorized = 1;
> >> > -   else {
> >> > +   dev->dev.of_node = bus->controller->of_node;
> >> > +   } else {
> >> > dev->authorized = !!HCD_DEV_AUTHORIZED(usb_hcd);
> >> > dev->wusb = usb_bus_is_wusb(bus) ? 1 : 0;
> >> > +
> >> > +   if (dev->dev.parent->parent == bus->controller)
> >> > +   /* device under root hub's port */
> >> > +   port1 = usb_hcd_find_raw_port_number(usb_hcd,
> >> > +   port1);
> >
> > I would change the test to "if (!parent->parent)" and add {} around the
> > body (since it's 3 lines long).  Also, although this doesn't really
> > matter, you could consider putting the new code inside the previous big
> > "if" statement instead of down here at the end of the function.
> >
> 
> Sorry, Alan, I can understand using (!parent->parent) to stands for
> the device connects to the root hub port, others I can't understand.

Change it to

+   if (!parent->parent) {
+   /* device under root hub's port */
+   port1 = usb_hcd_find_raw_port_number(usb_hcd,
+   port1);
+   }

That is, add braces { }.
  
If you look at the whole usb_alloc_dev() function, you'll see it has
one big "if" statement and then a small "if" statement near the end.  
You added your new code to the small "if" statement; I'm suggesting you
add it into the big "if" statement instead.

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] usb: host: xhci: Replace bus lock with host controller lock

2016-02-05 Thread Chris Bainbridge
Running task list at fail point:

[8.978405] kworker/3:0 R  running task1176024  2 0x
[8.979624] Workqueue: usb_hub_wq hub_event
[8.980831]  880260613af8 880260613ac0 811247ed 
8802604597c0
[8.982061]  880260608000 880260614000 0100 
880260613b70
[8.983280]  880260613c14 1388 880260613b10 
81b9bab7
[8.984500] Call Trace:
[8.985698]  [] schedule+0x37/0x90
[8.986918]  [] usb_kill_urb+0x8d/0xd0
[8.988130]  [] ? wake_up_atomic_t+0x30/0x30
[8.989343]  [] usb_start_wait_urb+0xbe/0x150
[8.990561]  [] usb_control_msg+0xbc/0xf0
[8.991766]  [] hub_port_init+0x51e/0xb70
[8.992964]  [] hub_event+0x817/0x1570
[8.994156]  [] process_one_work+0x1ff/0x620
[8.995342]  [] ? process_one_work+0x15f/0x620
[8.996528]  [] worker_thread+0x64/0x4b0
[8.997707]  [] ? rescuer_thread+0x390/0x390  
[8.998883]  [] kthread+0x105/0x120
[9.56]  [] ? kthread_create_on_node+0x200/0x200
[9.001241]  [] ret_from_fork+0x3f/0x70
[9.002420]  [] ? kthread_create_on_node+0x200/0x200

[9.094152] kworker/3:1 R  running task11496   238  2 0x
[9.095361] Workqueue: pm pm_runtime_work
[9.096545]  88025fc13ae0 88025fc13aa8 0003811247ed 
880260bc
[9.097767]  8802603aaf80 88025fc14000 88025cc7a520 
88007c4b7978
[9.098986]  88025cc7a520 88007c4b7978 88025fc13af8 
81b9bab7
[9.100213] Call Trace:
[9.101415]  [] schedule+0x37/0x90
[9.102626]  [] usb_kill_urb+0x8d/0xd0
[9.103835]  [] ? wake_up_atomic_t+0x30/0x30
[9.105035]  [] hub_quiesce+0x6b/0xa0
[9.106226]  [] hub_suspend+0x12a/0x250
[9.107417]  [] usb_suspend_both+0x95/0x1d0
[9.108600]  [] usb_runtime_suspend+0x2e/0x70
[9.109783]  [] ? usb_probe_interface+0x310/0x310
[9.110958]  [] __rpm_callback+0x2d/0x70
[9.112130]  [] ? usb_probe_interface+0x310/0x310
[9.113305]  [] rpm_callback+0x1d/0x90
[9.114482]  [] rpm_suspend+0x14b/0x750
[9.115664]  [] __pm_runtime_suspend+0x57/0x90
[9.116852]  [] ? usb_runtime_resume+0x20/0x20
[9.118034]  [] usb_runtime_idle+0x25/0x30
[9.119210]  [] __rpm_callback+0x2d/0x70
[9.120382]  [] rpm_idle+0x221/0x410
[9.121541]  [] pm_runtime_work+0xa9/0xc0
[9.122693]  [] process_one_work+0x1ff/0x620
[9.123850]  [] ? process_one_work+0x15f/0x620
[9.124993]  [] worker_thread+0x64/0x4b0
[9.126134]  [] ? rescuer_thread+0x390/0x390
[9.127272]  [] ? rescuer_thread+0x390/0x390  
[9.128403]  [] kthread+0x105/0x120
[9.129524]  [] ? kthread_create_on_node+0x200/0x200
[9.130653]  [] ret_from_fork+0x3f/0x70
[9.131781]  [] ? kthread_create_on_node+0x200/0x200

[9.864737] kworker/3:2 R  running task11888  1348  2 0x0008
[9.865947] Workqueue: usb_hub_wq hub_event
[9.867152]  88025dbcdf00 88025dbd3b88 81109a8c 
811099a9
[9.868386]  88025dbcdf00  88025dbce270 
88025dbd3bb8
[9.869610]  81109c04 88025dac8000 88025dac8368 
88025c8a4000
[9.870837] Call Trace:
[9.872044]  [] sched_show_task+0x15c/0x260
[9.873248]  [] ? sched_show_task+0x79/0x260
[9.874456]  [] show_state_filter+0x74/0xc0   
[9.875664]  [] xhci_setup_device+0x53d/0xa40 
[9.876871]  [] xhci_address_device+0xe/0x10
[9.878068]  [] hub_port_init+0x1bf/0xb70
[9.879262]  [] ? trace_hardirqs_on+0xd/0x10
[9.880465]  [] hub_event+0x817/0x1570
[9.881668]  [] process_one_work+0x1ff/0x620
[9.882869]  [] ? process_one_work+0x15f/0x620
[9.884074]  [] worker_thread+0x64/0x4b0
[9.885268]  [] ? rescuer_thread+0x390/0x390
[9.886457]  [] kthread+0x105/0x120
[9.887634]  [] ? kthread_create_on_node+0x200/0x200
[9.17]  [] ret_from_fork+0x3f/0x70
[9.889995]  [] ? kthread_create_on_node+0x200/0x200

[9.891174] kworker/3:3 R  running task10808  1350  2 0x
[9.892367] Workqueue: events_freezable usb_stor_scan_dwork
[9.893560]  88025dbdbb78 88026a0ccd80 6a0ccd80 
8802604597c0
[9.894773]  88025dbcc740 88025dbdc000 88025dbdbbb0 
88026a0ccd80
[9.896004]  88026a0ccd80 0003 88025dbdbb90 
81b9bab7
[9.897233] Call Trace:
[9.898444]  [] schedule+0x37/0x90
[9.899670]  [] schedule_timeout+0x17c/0x2f0
[9.900893]  [] ? init_timer_on_stack_key+0x40/0x40
[9.902099]  [] 
wait_for_completion_interruptible_timeout+0xcd/0x160
[9.903324]  [] ? wake_up_q+0x70/0x70
[9.904536]  [] usb_stor_msg_common+0xd8/0x130
[9.905751]  [] usb_stor_control_msg+0x96/0xb0
[9.906961]  [] usb_stor_Bulk_max_lun+0x51/0xa0
[9.908163]  [] usb_stor_scan_dwork+0x7f/0xe0 
[9.909361]  [] process_one_work+0x1ff/0x620
[9.910563]  [] ? process_one_work+0x15f/0x620
[9.911762]  [] worker_thread+0x64/0x4b0
[

RE: Multiple Digi Edgeport devices on CentOS 7

2016-02-05 Thread Howard Lum (holum)
Hi Greg,

The symlinks under /dev/serial/by-id are exactly what I am looking for. Thanks 
for the tip!

Howard

-Original Message-
From: Greg KH [mailto:gre...@linuxfoundation.org] 
Sent: Thursday, February 04, 2016 6:34 PM
To: Howard Lum (holum) 
Cc: linux-usb@vger.kernel.org
Subject: Re: Multiple Digi Edgeport devices on CentOS 7

On Thu, Feb 04, 2016 at 11:10:33PM +, Howard Lum (holum) wrote:
> Hi Greg,
> 
> We have two Digi Edgeport devices. I will call them A and B. If I only 
> have A then ttyUSB0-7 correspond to ports 1-8 on A respectively. The 
> same applies if I only have B. When I have A and B, then I get 
> something like this:
> 
> ttyUSB0 - Unit B port 3
> ttyUSB1 - Unit B port 4
> ttyUSB2 - Unit B port 5
> ttyUSB3 - Unit B port 6
> ttyUSB4 - Unit B port 1
> ttyUSB5 - Unit B port 2
> ttyUSB6 - Unit A port 3
> ttyUSB7 - Unit A port 4
> ttyUSB8 - Unit A port 1
> ttyUSB9 - Unit A port 2
> ttyUSB10 - Unit B port 7
> ttyUSB11 - Unit B port 8
> ttyUSB12 - Unit A port 5
> ttyUSB13 - Unit A port 6
> ttyUSB14 - Unit A port 7
> ttyUSB15 - Unit A port 8

Makes sense, these devices have an internal hub inside of them, so they 
enumerate at different rates.

Use the /dev/serial/ symlinks to get a "persistant" device name to use instead 
of /dev/ttyUSB??? as those names will change all the time as you have found out.

> I have not contacted Red Hat or CentOS yet.

I'd recommend that, that's what you are paying support for :)

good luck!

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


RE: USB suspend resume issue on Vybrid (Chipidea IP/MXS PHY)

2016-02-05 Thread Peter Chen

 
> 
> Hello Peter,
> 
> On 16-01-14 11:12:32, Peter Chen wrote:
> > On Wed, Jan 13, 2016 at 6:12 PM,   wrote:
> > > Hello Peter,
> > >
> > > On 16-01-13 10:33:06, Peter Chen wrote:
> > >> On Tue, Jan 12, 2016 at 06:34:47PM +0530, maitysancha...@gmail.com
> wrote:
> > >> > Hello Peter,
> > >> >
> > >> > I had reported the suspend resume issues on Vybrid and recently
> > >> > there have been some developments after one of our customers
> > >> > reported the below sequence of operations which worked for them.
> > >> >
> > >> > By doing the following sequence of operations after resume
> > >> >
> > >> > echo ci_hdrc.1 > /sys/bus/platform/drivers/ci_hdrc/unbind
> > >> > echo ci_hdrc.1 > /sys/bus/platform/drivers/ci_hdrc/bind
> > >> >
> > >> > the USB ports start working. This is observed in presence of
> > >> > external hub connected to the root hub or in the presence of root hub
> alone.
> > >> >
> > >> > After trying to trace through the sequence of operations which
> > >> > happen on bind, roughly are as below,
> > >> >
> > >> > probe() call in chipidea/core.c
> > >> > -> probe() call in hub.c
> > >> > > hub_configure()
> > >> > ---> hub_activate(hub, HUB_INIT)
> > >> > -> hub_power_on(hub, false)
> > >>
> > >> Clear PORT_PP (bit 12 at portsc)
> > >> > -> set_port_feature(hub->hdev, USB_PORT_FEAT_POWER)
> > >>
> > >> Set PORT_PP (bit 12 at portsc)
> > >
> > > Sorry it's not clear to me what you are implying below.
> > >
> > > As in I should implement this in suspend resume path or are you just
> > > implying that this is what happens in the above case?
> > >
> > >> >
> > >> > set_port_feature() now sends a control urb. Exactly after this
> > >> > the ports start working.
> > >> >
> > >> > This hub_configure() is not called during the regular resume() 
> > >> > sequence.
> > >> > I am not well versed with USB specifications or stack to draw an
> > >> > inference from this concretely.
> > >> >
> > >> > Can you throw some light on this if possible? Is it possible, to
> > >> > accomodate this somehow in the regular sequence of operations which
> happen on resume?
> > >> > The set_port_feature is in the core usb code and am not sure how
> > >> > to generically access it.
> > >> >
> > >>
> > >> Just try to toggle port power to see if it can work for you.
> > >
> > > Can you clarify how and at what point?
> > >
> > > At first I assumed you are referring to the fact this could be done
> > > from user space as well. So I used a test code to send a usb control
> > > msg with request as USB_REQ_(SET/CLEAR)_FEATURE and feature as
> > > USB_PORT_FEAT_POWER using libusb and I can control the USB power
> > > on/off for any of the ports. This does not work however after resume from
> suspend.
> > >
> >
> > Hi Sanchayan
> >
> > I just tried below commands, it will remove the chipidea core device,
> > and re-initialize it.
> > It means it will reset controller as well as reset PHY. (the
> > connection will be lost).
> > But we do not reset them during the suspend/resume routine.
> >
> > >> > echo ci_hdrc.1 > /sys/bus/platform/drivers/ci_hdrc/unbind
> > >> > echo ci_hdrc.1 > /sys/bus/platform/drivers/ci_hdrc/bind
> >
> > If you would like to try if toggle port power can work or not during
> > the resume routine, try below code please:
> >
> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > index 7404064..00d73c9 100644
> > --- a/drivers/usb/chipidea/core.c
> > +++ b/drivers/usb/chipidea/core.c
> > @@ -1195,6 +1195,10 @@ static int ci_resume(struct device *dev)
> > if (ret)
> > return ret;
> >
> > +   hw_write(ci, OP_PORTSC, BIT(12), ~BIT(12));
> > +   udelay(10);
> > +   hw_write(ci, OP_PORTSC, BIT(12), BIT(12));
> > +
> > if (ci->supports_runtime_pm) {
> > pm_runtime_disable(dev);
> > pm_runtime_set_active(dev);
> >
> 
> Do you have any further suggestions that I might try?
> 
> I also implemented the below changes which exist in Freescale iMX 3.14.52
> kernel, to see if they work. Earlier I had implemented only the mxs_phy
> specific code in the suspend/resume path which did not work. This time I
> implemented the complete relevant code.
> 

Since I don't cover Vybrid, I don't know what's any special for it.
From your original post, the phypwd is still 1 even you clear it.
It means the PHY (or it's clock) is abnormal, try to reset PHY (using 
mxs_phy_init)
after system resumes. 

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

Re: [PATCH 1/2] usb: dwc3: drop FIFO resizing logic

2016-02-05 Thread Kishon Vijay Abraham I
Hi Felipe,

On Thursday 04 February 2016 05:48 PM, Felipe Balbi wrote:
> That FIFO resizing logic was added to support OMAP5
> ES1.0 which had a bogus default FIFO size. I can't
> remember the exact size of default FIFO, but it was
> less than one bulk superspeed packet (<1024) which
> would prevent USB3 from ever working on OMAP5 ES1.0.
> 
> However, OMAP5 ES1.0 support has been dropped by
> commit aa2f4b16f830 ("ARM: OMAP5: id: Remove ES1.0
> support") which renders FIFO resizing unnecessary.
> 
> Signed-off-by: Felipe Balbi 

tested this series on both dra7-evm and dra72-evm using mass storage gadget and
msc.sh

dra72-evm: http://pastebin.ubuntu.com/14887997/
dra7-evm: http://pastebin.ubuntu.com/14887975/

Tested-by: Kishon Vijay Abraham I 

Let me know if you want me to do any other testing on dra7.

Thanks
Kishon

> ---
>  Documentation/devicetree/bindings/usb/dwc3.txt |  4 +-
>  .../devicetree/bindings/usb/qcom,dwc3.txt  |  1 -
>  drivers/usb/dwc3/core.c|  4 -
>  drivers/usb/dwc3/core.h|  5 --
>  drivers/usb/dwc3/ep0.c |  9 ---
>  drivers/usb/dwc3/gadget.c  | 86 
> --
>  drivers/usb/dwc3/platform_data.h   |  1 -
>  7 files changed, 2 insertions(+), 108 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
> b/Documentation/devicetree/bindings/usb/dwc3.txt
> index fb2ad0acedbd..15695682a480 100644
> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
> @@ -14,7 +14,6 @@ Optional properties:
> the second element is expected to be a handle to the USB3/SS PHY
>   - phys: from the *Generic PHY* bindings
>   - phy-names: from the *Generic PHY* bindings
> - - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
>   - snps,usb3_lpm_capable: determines if platform is USB3 LPM capable
>   - snps,disable_scramble_quirk: true when SW should disable data scrambling.
>   Only really useful for FPGA builds.
> @@ -47,6 +46,8 @@ Optional properties:
>   register for post-silicon frame length adjustment when the
>   fladj_30mhz_sdbnd signal is invalid or incorrect.
>  
> + -  tx-fifo-resize: determines if the FIFO *has* to be 
> reallocated.
> +
>  This is usually a subnode to DWC3 glue to which it is connected.
>  
>  dwc3@4a03 {
> @@ -54,5 +55,4 @@ dwc3@4a03 {
>   reg = <0x4a03 0xcfff>;
>   interrupts = <0 92 4>
>   usb-phy = <&usb2_phy>, <&usb3,phy>;
> - tx-fifo-resize;
>  };
> diff --git a/Documentation/devicetree/bindings/usb/qcom,dwc3.txt 
> b/Documentation/devicetree/bindings/usb/qcom,dwc3.txt
> index ca164e71dd50..39acb084bce9 100644
> --- a/Documentation/devicetree/bindings/usb/qcom,dwc3.txt
> +++ b/Documentation/devicetree/bindings/usb/qcom,dwc3.txt
> @@ -59,7 +59,6 @@ Example device nodes:
>   interrupts = <0 205 0x4>;
>   phys = <&hs_phy>, <&ss_phy>;
>   phy-names = "usb2-phy", "usb3-phy";
> - tx-fifo-resize;
>   dr_mode = "host";
>   };
>   };
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index de5e01f41bc2..ed03820ebedd 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -894,9 +894,6 @@ static int dwc3_probe(struct platform_device *pdev)
>   dwc->usb3_lpm_capable = device_property_read_bool(dev,
>   "snps,usb3_lpm_capable");
>  
> - dwc->needs_fifo_resize = device_property_read_bool(dev,
> - "tx-fifo-resize");
> -
>   dwc->disable_scramble_quirk = device_property_read_bool(dev,
>   "snps,disable_scramble_quirk");
>   dwc->u2exit_lfps_quirk = device_property_read_bool(dev,
> @@ -938,7 +935,6 @@ static int dwc3_probe(struct platform_device *pdev)
>   if (pdata->hird_threshold)
>   hird_threshold = pdata->hird_threshold;
>  
> - dwc->needs_fifo_resize = pdata->tx_fifo_resize;
>   dwc->usb3_lpm_capable = pdata->usb3_lpm_capable;
>   dwc->dr_mode = pdata->dr_mode;
>  
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index 29130682e547..c6960541c38c 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -706,9 +706,7 @@ struct dwc3_scratchpad_array {
>   *   0   - utmi_sleep_n
>   *   1   - utmi_l1_suspend_n
>   * @is_fpga: true when we are using the FPGA board
> - * @needs_fifo_resize: not all users might want fifo resizing, flag it
>   * @pullups_connected: true when Run/Stop bit is set
> - * @resize_fifos: tells us it's ok to reconfigure our TxFIFO sizes.
>   * @setup_packet_pending: true when there's a Setup Packet in FIFO. 
> Workaround
>   * @start_config_issued: true when StartConfig command 

Re: [PATCH] USB: cp210x: add IDs for GE B650V3 and B850V3 boards

2016-02-05 Thread Martyn Welch



On 01/02/16 19:57, Akshay Bhat wrote:

From: Ken Lin 

Add USB ID for cp2104/5 devices on GE B650v3 and B850v3 boards.

Signed-off-by: Ken Lin 
Signed-off-by: Akshay Bhat 


Acked-by: Martyn Welch 


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

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 987813b..7c319e7 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -163,6 +163,8 @@ static const struct usb_device_id id_table[] = {
{ USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
{ USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
{ USB_DEVICE(0x18EF, 0xE025) }, /* ELV Marble Sound Board 1 */
+   { USB_DEVICE(0x1901, 0x0190) }, /* GE B850 CP2105 Recorder interface */
+   { USB_DEVICE(0x1901, 0x0193) }, /* GE B650 CP2104 PMC interface */
{ USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
{ USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */
{ USB_DEVICE(0x1BA4, 0x0002) }, /* Silicon Labs 358x factory default */


--
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/1] Drivers: USB: DA8xx MUSB: added DT support

2016-02-05 Thread Petr Kulhavy
TI DA8xx MUSB driver equipped with DeviceTree support.
Tested with AM1808 board and USB2.0 (OTG) in host mode.

Signed-off-by: Petr Kulhavy 
---
 .../devicetree/bindings/usb/da8xx-usb.txt  |  63 
 drivers/usb/musb/da8xx.c   | 162 +
 include/linux/platform_data/usb-davinci.h  |   3 +-
 3 files changed, 227 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/usb/da8xx-usb.txt

diff --git a/Documentation/devicetree/bindings/usb/da8xx-usb.txt 
b/Documentation/devicetree/bindings/usb/da8xx-usb.txt
new file mode 100644
index 000..69c0961
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/da8xx-usb.txt
@@ -0,0 +1,63 @@
+TI DA8xx MUSB
+~
+
+Required properties:
+
+ - compatible : Should be "ti,da8xx-musb"
+
+ - reg: offset and length of the usbss register sets
+
+ - interrupts: USB interrupt number
+
+ - interrupt-names: should be set to "mc"
+
+ - dr_mode: The USB operation mode. Should be one of "host", "peripheral" or 
"otg".
+
+ - mentor,power : Specifies the maximum current in milli-ampers the controller 
can
+ supply in host mode. The maximum configurable value is 510mA.
+
+ - mentor,num-eps : Valid only in host mode. Specifies the number of target 
endpoints
+ supported by the controller. For DA8xx it is "5".
+
+ - mentor,multipoint : Valid only in host mode. Enables addressing of USB hubs,
+ which is normally something you want and therefore should be set to "1".
+ If set to "0" only point-to-point communication is enabled, i.e. only a 
single
+ device can be attached.
+
+ - mentor,ram-bits : This 2-base logarithm value defines the RAM FIFO size of 
the controller.
+ The FIFO size is calculated in 32-bit words. E.g. if your controller has 
4kiB of RAM FIFO
+ this value should be set to "10": 2^10 = 1024 words of 32-bits, i.e. 4096 
bytes.
+ For the DA8xx controller this value should be set to 10.
+
+
+Optional properties:
+
+ - ti,phy20-clkmux-cfg: Integer. Defines the USB 2.0 PHY reference clock 
source.
+ Supported values: "0" for external pin, "1" for internal PLL.
+
+ - ti,phy20-refclock-frequency : Integer. Defines the USB 2.0 PHY reference 
clock input
+ frequency in Hz in case the clock is generated by the internal PLL.
+ Supported values are 12MHz, 13MHz, 19.2MHz, 20MHz, 24MHz, 26MHz, 38.4MHz, 
40MHz, 48MHz
+
+
+Example:
+
+   usb20: usb@1e0 {
+   compatible = "ti,da8xx-musb";
+   ti,hwmods = "usb_otg_hs";
+   reg =   <0x0020 0x1>;
+   interrupt-parent = <&intc>;
+   interrupts = <58>;
+   interrupt-names = "mc";
+
+   dr_mode = "host";
+   mentor,power = <500>;
+   mentor,multipoint = <1>;
+   mentor,num-eps = <5>;
+   mentor,ram-bits = <10>;
+
+   ti,phy20-clkmux-cfg = <1>;  /* PHY clock internally 
generated from the PLL */
+   ti,phy20-refclock-frequency = <2400>;
+
+   status = "okay";
+   };
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 4e13fe2..281d503 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -1,6 +1,9 @@
 /*
  * Texas Instruments DA8xx/OMAP-L1x "glue layer"
  *
+ * DT support
+ * Copyright (c) 2015-2016 Petr Kulhavy, Barix AG 
+ *
  * Copyright (c) 2008-2009 MontaVista Software, Inc. 
  *
  * Based on the DaVinci "glue layer" code.
@@ -36,6 +39,8 @@
 
 #include 
 #include 
+#include 
+#include 
 
 #include "musb_core.h"
 
@@ -134,6 +139,35 @@ static inline void phy_off(void)
__raw_writel(cfgchip2, CFGCHIP2);
 }
 
+/* converts PHY refclk frequency in HZ into USB0REF_FREQ config value
+ * on unsupported frequency returns -1
+ */
+static inline int phy_refclk_cfg(int frequency)
+{
+   switch (frequency) {
+   case 1200:
+   return 0x01;
+   case 1300:
+   return 0x06;
+   case 1920:
+   return 0x05;
+   case 2000:
+   return 0x08;
+   case 2400:
+   return 0x02;
+   case 2600:
+   return 0x07;
+   case 3840:
+   return 0x05;
+   case 4000:
+   return 0x09;
+   case 4800:
+   return 0x03;
+   default:
+   return -1;
+   }
+}
+
 /*
  * Because we don't set CTRL.UINT, it's "important" to:
  * - not read/write INTRUSB/INTRUSBE (except during
@@ -527,6 +561,35 @@ static const struct platform_device_info da8xx_dev_info = {
.dma_mask   = DMA_BIT_MASK(32),
 };
 
+static int get_musb_port_mode(struct device_node *np)
+{
+   enum usb_dr_mode mode;
+
+   mode = of_usb_get_dr_mode(np);
+   switch (mode) {
+   case USB_DR_MODE_HOST:
+   return MUSB_HOST;
+
+   case USB_DR_MODE_PERIPHERAL:
+   return MUSB_PERIP

[PATCH] usb: phy: msm: Trigger USB state detection work in DRD mode

2016-02-05 Thread Srinivas Kandagatla
From: "Ivan T. Ivanov" 

When working in Dual Role Device mode, USB state machine is not kicked,
when host or gadget drivers are loaded. Fix this be explicitly triggering
state detection on client driver load.

Issue is that if the board is booted without micro usb cable and usb
device attached, kernel fails to populate the usb host and device.
The reason for this is that the state machine worker logic only checks
for USB_DR_MODE_PERIPHERAL and USB_DR_MODE_HOST modes to run worker
thread. However if the phy is configured in OTG mode it would fail
to run the state machine, resulting in failure to detect for very
first time.

This patch fixes the issue by removing the explicit checks.

Issue is noticed on Qualcomm Dragon board DB410C.

[srinivas.kandaga...@linaro.org: Added more details to log]
Signed-off-by: Ivan T. Ivanov 
Signed-off-by: Srinivas Kandagatla 
---
 drivers/usb/phy/phy-msm-usb.c | 20 
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 970a30e..72b387d 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -757,14 +757,8 @@ static int msm_otg_set_host(struct usb_otg *otg, struct 
usb_bus *host)
otg->host = host;
dev_dbg(otg->usb_phy->dev, "host driver registered w/ tranceiver\n");
 
-   /*
-* Kick the state machine work, if peripheral is not supported
-* or peripheral is already registered with us.
-*/
-   if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) {
-   pm_runtime_get_sync(otg->usb_phy->dev);
-   schedule_work(&motg->sm_work);
-   }
+   pm_runtime_get_sync(otg->usb_phy->dev);
+   schedule_work(&motg->sm_work);
 
return 0;
 }
@@ -827,14 +821,8 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
dev_dbg(otg->usb_phy->dev,
"peripheral driver registered w/ tranceiver\n");
 
-   /*
-* Kick the state machine work, if host is not supported
-* or host is already registered with us.
-*/
-   if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) {
-   pm_runtime_get_sync(otg->usb_phy->dev);
-   schedule_work(&motg->sm_work);
-   }
+   pm_runtime_get_sync(otg->usb_phy->dev);
+   schedule_work(&motg->sm_work);
 
return 0;
 }
-- 
1.9.1

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


Re: Writing to USB3 memory stick with 4.4 is 52 times slower than Win7 inside virtualbox

2016-02-05 Thread Greg Kroah-Hartman
On Thu, Feb 04, 2016 at 06:47:06PM -0800, Marc MERLIN wrote:
> On Thu, Feb 04, 2016 at 09:49:22AM +0100, Oliver Neukum wrote:
> > On Wed, 2016-02-03 at 22:20 -0800, Marc MERLIN wrote:
> > 
> > > But the main point remains that default mount options and default cp
> > > work at horrible speed. I'm happy to try stuff to get around that
> > > (nosync might be one, but having my stick write after I unmounted it,
> > > makes me very nervous), so I'd love a solution where cp succeeds when
> > 
> > It should. Have you tried to time a manual sync after writing?
> 
> Mmmh, this time it worked as expected:
> legolas:~# mount -o async /dev/sdd1 /mnt/mnt
> legolas:~# time cp /var/local/space/vid/282MB /mnt/mnt; time umount /mnt/mnt; 
> time sync
> 
> real  0m0.598s
> user  0m0.004s
> sys   0m0.572s
> 
> real  0m11.454s
> user  0m0.000s
> sys   0m0.256s
> 
> real  0m0.117s
> user  0m0.004s
> sys   0m0.028s
> 
> This goes back to 23MB/s (size/time), which is proper speed.
> I also verified that this time the LED wasn't flashing after unmount.

Great, so all is good now?

> > Still, it's a more appropriate value, indicating that the actual 
> > transfer speed is reasonably close to what it should be.
>  
> Correct. There seems to be a problem between sync and the underlying
> usb-storage driver?
> Maybe the windows driver takes many packets at a time, and returns sync
> for a bunch of them while linux syncs them one by one, which ends up
> being 50 times slower.

That's up to the filesystem layer, what it wants to do, not the
usb-storage driver.

> > > If I had to guess, sync causes cp(1) to be very conservative and wait
> > > for a sync after each 4KB block while windows probably blasts all the
> > > data with fewer sync calls in between?
> > > (wild guess at this point)
> > 
> > Probably something like that.  It doesn't actually change the behavior 
> > of the cp program; it changes the behavior of the kernel's filesystem 
> > layer.  The end effect is the same, though.
>  
> Right. Since running in async mode, especially with usb automounting, is
> not safe, it would be good if usb-storage or whichever underlying driver
> could do the same batching of blocks and sync them 100 or 1000 at a
> time?

usb-storage is just a tiny scsi driver, no real "logic" is in it, it's
up to the filesystem above it to tell it what to do with the blocks it
has.  So it's up to the distro's settings of the vfat filesystem rules
for ejectable hardware as to if it wants to sync more aggressively or
not.

So you get to go poke your favorite distro about this, it's not
something the kernel can do much, if anything, about. :)

> 
> > > But the main point remains that default mount options and default cp
> > > work at horrible speed.
> > 
> > That's a new main point.  Your original main point was that write 
> > transfers under Linux were horribly slow.  You now know this was due to 
> > the sync option, not any fault in the USB driver stack.
> > The default mount options are a question for another mailing list; they 
> > have nothing at all to do with USB.
>  
> You're correct.
> Let's forget about async for now since it's not very safe for the
> average user and windows gets async like speed in close enough to sync
> mode.
> Could the usb system aggregate requests and ack them by block?
> (yes, I guess that means lying to cp and acking packets that haven't
> been written yet, but I think everyone expects that if they pull a USB
> stick in the middle of a copy, they'll lose data, so if we ack some data
> that really hasn't made it to flash and won't for another second or so,
> this likely would not cause problems to most (hopefully all?) users.
> 
> Either way, sync mode is so excruciatingly slow that few people must be
> using it for any reasonable data.

Some distros default to this as they value data integrity over
_perceived_ speed.  I know openSUSE used to do this, but people did
complain, I don't know if they changed it back or not.

So again, it's not something the kernel can do anything about.

thanks,

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


Re: Writing to USB3 memory stick with 4.4 is 52 times slower than Win7 inside virtualbox

2016-02-05 Thread Marc MERLIN
On Fri, Feb 05, 2016 at 12:27:25PM -0800, Greg Kroah-Hartman wrote:
> > This goes back to 23MB/s (size/time), which is proper speed.
> > I also verified that this time the LED wasn't flashing after unmount.
> 
> Great, so all is good now?
> 
> > > Still, it's a more appropriate value, indicating that the actual 
> > > transfer speed is reasonably close to what it should be.
> >  
> > Correct. There seems to be a problem between sync and the underlying
> > usb-storage driver?
> > Maybe the windows driver takes many packets at a time, and returns sync
> > for a bunch of them while linux syncs them one by one, which ends up
> > being 50 times slower.
> 
> That's up to the filesystem layer, what it wants to do, not the
> usb-storage driver.
 
Understood.

> So you get to go poke your favorite distro about this, it's not
> something the kernel can do much, if anything, about. :)

The thing is async isn't great either.
I hate to say, but windows does this right, linux does not as far as I
can tell.
When a windows copy is finished, it's pretty much on flash (maybe with a
second delay)
On linux, it is if I accept a speed that 50x slower, or it's not and
data is lost if I pull my usb device after the copy is over without
unmount (I have automatic mount).
In other words, with linux, the copy either finishes way before it's on
flash, or takes many times longer.

However, I agree that apparently the usb layer is apparently not the
place that can fix it.
I also understant that this problem has been there for as long as USB
devices have existed, so if it hasn't been fixed in a better way by now,
it's likely not trivial.

Either way thanks all for the answers.

Marc
-- 
"A mouse is a device used to point at the xterm you want to type in" - A.S.R.
Microsoft is to operating systems 
   what McDonalds is to gourmet cooking
Home page: http://marc.merlins.org/ | PGP 1024R/763BE901
--
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: Writing to USB3 memory stick with 4.4 is 52 times slower than Win7 inside virtualbox

2016-02-05 Thread Alan Stern
On Fri, 5 Feb 2016, Marc MERLIN wrote:

> The thing is async isn't great either.
> I hate to say, but windows does this right, linux does not as far as I
> can tell.
> When a windows copy is finished, it's pretty much on flash (maybe with a
> second delay)
> On linux, it is if I accept a speed that 50x slower, or it's not and
> data is lost if I pull my usb device after the copy is over without
> unmount (I have automatic mount).
> In other words, with linux, the copy either finishes way before it's on
> flash, or takes many times longer.

This is more of a user interface issue than anything else.  In Windows
the copy command waits until the data has been transfered to the disk,
whereas in Linux the cp command doesn't wait (more correctly, it waits
for the operating system to accept the data but no longer).  If you do
want to wait, you could write a little script or shell alias that does
the cp command followed by a sync.

In theory, the copy command in Windows shouldn't need to wait either.  
But then you'd run into trouble if you unplugged the USB device without 
first clicking on the "Safely remove hardware" button -- which 
essentially does a sync.

> However, I agree that apparently the usb layer is apparently not the
> place that can fix it.
> I also understant that this problem has been there for as long as USB
> devices have existed, so if it hasn't been fixed in a better way by now,
> it's likely not trivial.
> 
> Either way thanks all for the answers.

You're welcome.

Alan Stern

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


Re: usb audio popping on low cpu speed device

2016-02-05 Thread Bill Brown
Shawn Lewis  writes:

> 
> Hi list, I've been looking into an issue wherein a cheap usb sound
> card [1] plugged into a host system with a 400MHz mips core [2] makes
> audible popping noises, at a rate of up to a few times per second. I
> don't believe the problem is at the application or alsa layers, as I
> don't get underflow errors.
> 
> I'm running a 3.3.8 kernel from openwrt. The usb host uses the ehci
> driver. The sound card uses the snd-usb-audio driver.
> 
> This only happens when the wifi built into the chip is enabled, and
> wifi traffic is occuring. If I disable it there are no audible pops. A
> different cheap usb sound card produces less pop noises, but it still
> makes them.
> 
> My theory is that the wifi processing throws off the timing for the
> usb driver, so sometimes the isochronous schedule and data is not
> updated in time for the next usb frame. My understanding of usb/ehci
> is limited as I have only read the spec this weekend so I could be way
> off base. I might also be having a hardware/electrical issue rather
> than software/kernel.
> 
> Any tips or advice appreciated.
> 
> I can provide usbmon output for popping and non-popping cases. I also
> have audio recordings, and usb analyzer traces. The analyzer trace
> shows partial packets arriving during pops, with the rest arriving
> 200us later. There were sometimes other errors as well (sorry I don't
> have the analyzer trace on this machine).
> 
> [1]
http://www.amazon.com/Syba-SD-CM-UAUD-Adapter-C-Media-Chipset/dp/B001MSS6CS
> [2] http://wiki.openwrt.org/toh/tp-link/tl-mr3020
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@...
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

I just completed debug on an off-the-shelf WiFi access point with the
identical signature...several pops per second before the audio quits
altogether.  The other symptom was messages of "retire_capture_urb: 4984
callbacks suppressed" in the dmesg output that began when the audio disappeared.

Configuration: A MIPS-based MCU running OpenWRT with one USB root port, a
Terminus FE 1.1s USB 2.0 hub directly connected to it on the PCB, and an
audio card plugged into the external USB port downstream of the Terminus hub.

The hub chip was missing a 10uF capacitor on the VD18 pin (1.8V for the
internal PLL), not even a pair of pads for one.  Probing this pin showed
enough noise on this pin (which WiFi would exacerbate at times) to take the
voltage above spec and cause problems with USB connectivity w/the MCU's root
port.  I could only get a CATC trace between the hub and audio card, which
showed requests from the host disappearing altogether, but SOFs continuing
to the audio card (no more IN/DATA0 packets).

I deadbugged a 10uF cap across the VD18 and GND pins, and the router has
been running fine for 4 days now without issue.



--
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: Writing to USB3 memory stick with 4.4 is 52 times slower than Win7 inside virtualbox

2016-02-05 Thread Marc MERLIN
On Fri, Feb 05, 2016 at 04:11:17PM -0500, Alan Stern wrote:
> On Fri, 5 Feb 2016, Marc MERLIN wrote:
> 
> > The thing is async isn't great either.
> > I hate to say, but windows does this right, linux does not as far as I
> > can tell.
> > When a windows copy is finished, it's pretty much on flash (maybe with a
> > second delay)
> > On linux, it is if I accept a speed that 50x slower, or it's not and
> > data is lost if I pull my usb device after the copy is over without
> > unmount (I have automatic mount).
> > In other words, with linux, the copy either finishes way before it's on
> > flash, or takes many times longer.
> 
> This is more of a user interface issue than anything else.  In Windows
> the copy command waits until the data has been transfered to the disk,
> whereas in Linux the cp command doesn't wait (more correctly, it waits
> for the operating system to accept the data but no longer).  If you do
> want to wait, you could write a little script or shell alias that does
> the cp command followed by a sync.
> 
> In theory, the copy command in Windows shouldn't need to wait either.  
> But then you'd run into trouble if you unplugged the USB device without 
> first clicking on the "Safely remove hardware" button -- which 
> essentially does a sync.

I agree. The nice thing though is that I think they do intermediate
syncs, so you get a progress bar that looks like everything is ok.
It's quite seemless to the user, hence my dream of having selective
syncs going through (one out of 100 or 1000) and the other ones being
skipped, to give that illusion of normal copy without slowing down the
speed and being done when the tool is done.
But I can see how on linux this would take extra cooperation between
userland and the underlying kernel code, just to do this, and likely
hasn't been deemed worth it.

Cheers,
Marc
-- 
"A mouse is a device used to point at the xterm you want to type in" - A.S.R.
Microsoft is to operating systems 
   what McDonalds is to gourmet cooking
Home page: http://marc.merlins.org/ | PGP 1024R/763BE901
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] dwc3: gadget: fix for no-resource condition in dwc3 device controller

2016-02-05 Thread John Youn
On 2/5/2016 6:30 AM, B, Ravi wrote:
> Hi Felipe
> 
> Sorry for delay in response. 
> 
>>> Yes, when there is on-going transfer on one endpoint in in/out 
>>> direction (say ep1-in), then trying to start transfer on another 
>>> endpoint in same direction (say ep2-in), leads to resource conflict.
> 
>> that shouldn't be the case. Resources for EP1 are different than those of 
>> EP2.
> 
> I agree, the issue was not seen when DEPSTARTCFG issued once to dwc3 core 
> while enabling single interface by host. The failing scenario is, in case of 
> the composite gadget
> with two interfaces (NCM + ACM) when each interface enabled by host, the 
> DEPSTARTCFG is issued to core. 
> Finally the DEPSTARCFG is issued twice to dwc3, which leads to this behavior.
> As per SNPS, the DESPARTCFG must be issued only once even if multiple 
> interfaces are enabled,
> Otherwise this leads to resource conflict.

Hi Ravi, Felipe,

Sorry, I didn't notice this in my backlog until Ravi's response this
morning.

I think I see the problem but I'm not sure how to solve it right now.

How the resources should be allocated is that each endpoint of a
configuration should be assigned a different transfer resource. This
includes all endpoints for every interface in the configuration.

How resources are assigned is that you do a DEPSTARTCFG for the
configuration to reset the transfer resource index (TRI). Then you do
DEPXFERCFG for each endpoint in the configuration and each DEPXFERCFG
assigns it the resource indicated by the TRI and increments it.

The previous bug came about because after a SET_CONFIGURATION you may
want to do multiple SET_INTERFACE to a single interface to set
different alt-settings. Then eventually you run out of resources
because you never reset the resources between calls to SET_INTERFACE.

The current bug is that you have a composite device with multiple
interfaces and possibly alt-settings for one or more of them. But you
don't neccessarily want to reset the resources between each
SET_INTERFACE because each one is to a different interface within the
same configuration. However if you don't, and there are again multiple
SET_INTERFACE requests you can run out of resources.

It might not be possible to solve both scenarios with the current way
that it is programmed.

One way I see to solve it is if we reallocate the resources more
intelligently after each SET_CONFIG/SET_INTERFACE and control which
resource is assigned to each endpoint. This requires assigning the TRI
manually which might be possible by calling DEPSTARTCFG before every
DEPXFERCFG.

I'm not completely sure about that so I have to consult with an one of
the RTL engineers but he is out of the office today. I'll get back to
you on this.

Regards,
John

--
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/1] Drivers: USB: DA8xx MUSB: added DT support

2016-02-05 Thread Arnd Bergmann
On Friday 05 February 2016 18:34:36 Petr Kulhavy wrote:
> TI DA8xx MUSB driver equipped with DeviceTree support.
> Tested with AM1808 board and USB2.0 (OTG) in host mode.
> 
> Signed-off-by: Petr Kulhavy 
> ---
>  .../devicetree/bindings/usb/da8xx-usb.txt  |  63 
>  drivers/usb/musb/da8xx.c   | 162 
> +
>  include/linux/platform_data/usb-davinci.h  |   3 +-

The changes look good, thanks.

One more thing:

>  3 files changed, 227 insertions(+), 1 deletion(-)
>  create mode 100644 Documentation/devicetree/bindings/usb/da8xx-usb.txt
> 
> diff --git a/Documentation/devicetree/bindings/usb/da8xx-usb.txt 
> b/Documentation/devicetree/bindings/usb/da8xx-usb.txt
> new file mode 100644
> index 000..69c0961
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/da8xx-usb.txt
> @@ -0,0 +1,63 @@
> +TI DA8xx MUSB
> +~
> +
> +Required properties:
> +
> + - compatible : Should be "ti,da8xx-musb"
> +

Please make this

Should be one of "ti,da850-musb" or "ti,da830-musb"

We don't use wildcards in compatible strings, so better use specific model
names in case we later find something that is different betweent the models.

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] usb: gadget: f_midi: fix missing unlock on error in f_midi_alloc()

2016-02-05 Thread Michal Nazarewicz
On Fri, Feb 05 2016, weiyj...@163.com wrote:
> From: Wei Yongjun 
>
> Add the missing unlock before return from function f_midi_alloc()
> when kfifo_alloc() failed.

There already is a patchset addressing this:
http://comments.gmane.org/gmane.linux.kernel/2135768

>
> Signed-off-by: Wei Yongjun 
> ---
>  drivers/usb/gadget/function/f_midi.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_midi.c 
> b/drivers/usb/gadget/function/f_midi.c
> index fb1fe96d..18119f3 100644
> --- a/drivers/usb/gadget/function/f_midi.c
> +++ b/drivers/usb/gadget/function/f_midi.c
> @@ -1188,7 +1188,6 @@ static struct usb_function *f_midi_alloc(struct 
> usb_function_instance *fi)
>  
>   if (!port) {
>   status = -ENOMEM;
> - mutex_unlock(&opts->lock);
>   goto setup_fail;
>   }
>  
> @@ -1202,7 +1201,6 @@ static struct usb_function *f_midi_alloc(struct 
> usb_function_instance *fi)
>   midi->id = kstrdup(opts->id, GFP_KERNEL);
>   if (opts->id && !midi->id) {
>   status = -ENOMEM;
> - mutex_unlock(&opts->lock);
>   goto setup_fail;
>   }
>   midi->in_ports = opts->in_ports;
> @@ -1229,6 +1227,7 @@ static struct usb_function *f_midi_alloc(struct 
> usb_function_instance *fi)
>   return &midi->func;
>  
>  setup_fail:
> + mutex_unlock(&opts->lock);
>   for (--i; i >= 0; i--)
>   kfree(midi->in_port[i]);
>   kfree(midi);
>

-- 
Best regards
Liege of Serenely Enlightened Majesty of Computer Science,
ミハウ “mina86” ナザレヴイツ   
--
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/1] Drivers: USB: DA8xx MUSB: added DT support

2016-02-05 Thread Petr Kulhavy
On 5 February 2016 at 23:22, Arnd Bergmann  wrote:

> One more thing:
>
>>  3 files changed, 227 insertions(+), 1 deletion(-)
>>  create mode 100644 Documentation/devicetree/bindings/usb/da8xx-usb.txt
>>
>> diff --git a/Documentation/devicetree/bindings/usb/da8xx-usb.txt 
>> b/Documentation/devicetree/bindings/usb/da8xx-usb.txt
>> new file mode 100644
>> index 000..69c0961
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/da8xx-usb.txt
>> @@ -0,0 +1,63 @@
>> +TI DA8xx MUSB
>> +~
>> +
>> +Required properties:
>> +
>> + - compatible : Should be "ti,da8xx-musb"
>> +
>
> Please make this
>
> Should be one of "ti,da850-musb" or "ti,da830-musb"
>
> We don't use wildcards in compatible strings, so better use specific model
> names in case we later find something that is different betweent the models.

OK, I will update the binding. But is the MODULE_DEVICE_TABLE() in the
code able to handle wildcards?
Or do I need to create 2 entries in the code? I mean something like this:

static const struct of_device_id da8xx_id_table[] = {
   {
   .compatible = "ti,da850-musb"
   },
   {
   .compatible = "ti,da830-musb"
   },
  {},
};

MODULE_DEVICE_TABLE(of, da8xx_id_table);

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


[PATCH 00/19] usb: gadget: Add support for SuperSpeedPlus

2016-02-05 Thread John Youn
This series of patches adds SuperSpeedPlus support to the composite
gadget framework. After this series the composite gadget framework
should be able to support SuperSpeedPlus functions and gadgets.

Additionally, the f_mass_storage function and the DWC3 gadget are
updated to support SuperSpeedPlus.

Tested on:
- Synopsys HAPS, DWC_usb3 IP, v2.90a
- Synopsys HAPS, DWC_usb3 IP, v3.00a
- Synopsys HAPS, DWC_usb31 IP, v1.10a

v2:
- Updated commit message for bcdUSB (Sergei Shtylyov and Bjorn Mork)
- Simplified case statement (Sergei Shtylyov)

John Youn (19):
  usb: ch9: Add USB_SPEED_SUPER_PLUS
  usb: ch9: Add size macro for SSP dev cap descriptor
  usb: gadget: Add gadget_is_superspeed_plus()
  usb: gadget: composite: Return bcdUSB 0x0310
  usb: gadget: composite: Return SSP Dev Cap descriptor
  usb: gadget: Update usb_assign_descriptors for SuperSpeedPlus
  usb: gadget: Update function for SuperSpeedPlus
  usb: gadget: Update config for SuperSpeedPlus
  usb: gadget: composite: Count configs for SuperSpeedPlus
  usb: gadget: composite: Add function to get descriptors
  usb: gadget: composite: Write SuperSpeedPlus config descriptors
  usb: gadget: composite: Configure the usb_ep for SuperSpeedPlus
  usb: gadget: composite: Update debug message for SuperSpeedPlus
  usb: gadget: f_mass_storage: Enable SuperSpeedPlus
  usb: dwc3: DWC_usb31 controller check
  usb: dwc3: Update register fields for SuperSpeedPlus
  usb: dwc3: Update speed checks for SuperSpeedPlus
  usb: dwc3: Update maximum_speed for SuperSpeedPlus
  usb: dwc3: Enable SuperSpeedPlus

 drivers/usb/common/common.c  |   1 +
 drivers/usb/dwc3/core.c  |  17 +++-
 drivers/usb/dwc3/core.h  |  11 ++-
 drivers/usb/dwc3/ep0.c   |   9 +-
 drivers/usb/dwc3/gadget.c|  21 +++--
 drivers/usb/gadget/composite.c   | 125 +--
 drivers/usb/gadget/config.c  |   9 +-
 drivers/usb/gadget/configfs.c|   1 +
 drivers/usb/gadget/function/f_acm.c  |   2 +-
 drivers/usb/gadget/function/f_ecm.c  |   2 +-
 drivers/usb/gadget/function/f_eem.c  |   2 +-
 drivers/usb/gadget/function/f_hid.c  |   2 +-
 drivers/usb/gadget/function/f_loopback.c |   2 +-
 drivers/usb/gadget/function/f_mass_storage.c |   2 +-
 drivers/usb/gadget/function/f_ncm.c  |   2 +-
 drivers/usb/gadget/function/f_obex.c |   3 +-
 drivers/usb/gadget/function/f_phonet.c   |   2 +-
 drivers/usb/gadget/function/f_printer.c  |   2 +-
 drivers/usb/gadget/function/f_rndis.c|   2 +-
 drivers/usb/gadget/function/f_serial.c   |   2 +-
 drivers/usb/gadget/function/f_sourcesink.c   |   2 +-
 drivers/usb/gadget/function/f_subset.c   |   2 +-
 drivers/usb/gadget/function/f_tcm.c  |   2 +-
 drivers/usb/gadget/function/f_uac1.c |   3 +-
 drivers/usb/gadget/function/f_uac2.c |   3 +-
 include/linux/usb/composite.h|   6 ++
 include/linux/usb/gadget.h   |  13 ++-
 include/uapi/linux/usb/ch9.h |   6 ++
 28 files changed, 198 insertions(+), 58 deletions(-)

-- 
2.6.3

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


[PATCH 01/19] usb: ch9: Add USB_SPEED_SUPER_PLUS

2016-02-05 Thread John Youn
Add USB_SPEED_SUPER_PLUS to usb_device_speed enumeration and add an
entry in the speed_names array for it.

Signed-off-by: John Youn 
---
 drivers/usb/common/common.c  | 1 +
 include/uapi/linux/usb/ch9.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index e6ec125..49fbfe8 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -51,6 +51,7 @@ static const char *const speed_names[] = {
[USB_SPEED_HIGH] = "high-speed",
[USB_SPEED_WIRELESS] = "wireless",
[USB_SPEED_SUPER] = "super-speed",
+   [USB_SPEED_SUPER_PLUS] = "super-speed-plus",
 };
 
 const char *usb_speed_string(enum usb_device_speed speed)
diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
index 4338eb7..779a62a 100644
--- a/include/uapi/linux/usb/ch9.h
+++ b/include/uapi/linux/usb/ch9.h
@@ -954,6 +954,7 @@ enum usb_device_speed {
USB_SPEED_HIGH, /* usb 2.0 */
USB_SPEED_WIRELESS, /* wireless (usb 2.5) */
USB_SPEED_SUPER,/* usb 3.0 */
+   USB_SPEED_SUPER_PLUS,   /* usb 3.1 */
 };
 
 
-- 
2.6.3

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


[PATCH 04/19] usb: gadget: composite: Return bcdUSB 0x0310

2016-02-05 Thread John Youn
The USB 3.1 specification replaces the USB 3.0 specification and all new
devices that are running at SuperSpeed or higher speeds must report a
bcdUSB of 0x0310.

Refer to USB 3.1 Specification, Revision 1.0, Section 9.6.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 8b14c2a..ce5dbc5 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1499,7 +1499,7 @@ composite_setup(struct usb_gadget *gadget, const struct 
usb_ctrlrequest *ctrl)
cdev->gadget->ep0->maxpacket;
if (gadget_is_superspeed(gadget)) {
if (gadget->speed >= USB_SPEED_SUPER) {
-   cdev->desc.bcdUSB = cpu_to_le16(0x0300);
+   cdev->desc.bcdUSB = cpu_to_le16(0x0310);
cdev->desc.bMaxPacketSize0 = 9;
} else {
cdev->desc.bcdUSB = cpu_to_le16(0x0210);
-- 
2.6.3

--
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 03/19] usb: gadget: Add gadget_is_superspeed_plus()

2016-02-05 Thread John Youn
Add a function to check for SuperSpeedPlus capable gadgets.

Signed-off-by: John Youn 
---
 include/linux/usb/gadget.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index d82d006..d6a1bda 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -729,6 +729,16 @@ static inline int gadget_is_superspeed(struct usb_gadget 
*g)
 }
 
 /**
+ * gadget_is_superspeed_plus() - return true if the hardware handles
+ * superspeed plus
+ * @g: controller that might support superspeed plus
+ */
+static inline int gadget_is_superspeed_plus(struct usb_gadget *g)
+{
+   return g->max_speed >= USB_SPEED_SUPER_PLUS;
+}
+
+/**
  * gadget_is_otg - return true iff the hardware is OTG-ready
  * @g: controller that might have a Mini-AB connector
  *
-- 
2.6.3

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


[PATCH 05/19] usb: gadget: composite: Return SSP Dev Cap descriptor

2016-02-05 Thread John Youn
If a gadget supports SuperSpeedPlus or higher speeds, return a
SuperSpeedPlus USB Device Capability descriptor.

Currently this implementation returns a fixed descriptor with typical
values set.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index ce5dbc5..11d2433 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -597,6 +597,48 @@ static int bos_desc(struct usb_composite_dev *cdev)
ss_cap->bU1devExitLat = dcd_config_params.bU1devExitLat;
ss_cap->bU2DevExitLat = dcd_config_params.bU2DevExitLat;
 
+   /* The SuperSpeedPlus USB Device Capability descriptor */
+   if (gadget_is_superspeed_plus(cdev->gadget)) {
+   struct usb_ssp_cap_descriptor *ssp_cap;
+
+   ssp_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength);
+   bos->bNumDeviceCaps++;
+
+   /*
+* Report typical values.
+*/
+
+   le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SSP_CAP_SIZE(1));
+   ssp_cap->bLength = USB_DT_USB_SSP_CAP_SIZE(1);
+   ssp_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
+   ssp_cap->bDevCapabilityType = USB_SSP_CAP_TYPE;
+
+   /* SSAC = 1 (2 attributes) */
+   ssp_cap->bmAttributes = cpu_to_le32(1);
+
+   /* Min RX/TX Lane Count = 1 */
+   ssp_cap->wFunctionalitySupport = (1 << 8) | (1 << 12);
+
+   /*
+* bmSublinkSpeedAttr[0]:
+*   ST  = Symmetric, RX
+*   LSE =  3 (Gbps)
+*   LP  =  1 (SuperSpeedPlus)
+*   LSM = 10 (10 Gbps)
+*/
+   ssp_cap->bmSublinkSpeedAttr[0] =
+   (3 << 4) | (1 << 14) | (0xa << 16);
+   /*
+* bmSublinkSpeedAttr[1] =
+*   ST  = Symmetric, TX
+*   LSE =  3 (Gbps)
+*   LP  =  1 (SuperSpeedPlus)
+*   LSM = 10 (10 Gbps)
+*/
+   ssp_cap->bmSublinkSpeedAttr[1] =
+   (3 << 4) | (1 << 14) | (0xa << 16) | (1 << 7);
+   }
+
return le16_to_cpu(bos->wTotalLength);
 }
 
-- 
2.6.3

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


[PATCH 06/19] usb: gadget: Update usb_assign_descriptors for SuperSpeedPlus

2016-02-05 Thread John Youn
Add the 'ssp_descriptors' parameter to the usb_assign_descriptors()
function. This allows a function driver to add descriptors for
SuperSpeedPlus speeds if it supports it.

Also update all uses of this function in the gadget subsystem so that
they pass NULL for the ssp_descriptors parameters.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/config.c  | 3 ++-
 drivers/usb/gadget/function/f_acm.c  | 2 +-
 drivers/usb/gadget/function/f_ecm.c  | 2 +-
 drivers/usb/gadget/function/f_eem.c  | 2 +-
 drivers/usb/gadget/function/f_hid.c  | 2 +-
 drivers/usb/gadget/function/f_loopback.c | 2 +-
 drivers/usb/gadget/function/f_mass_storage.c | 2 +-
 drivers/usb/gadget/function/f_ncm.c  | 2 +-
 drivers/usb/gadget/function/f_obex.c | 3 ++-
 drivers/usb/gadget/function/f_phonet.c   | 2 +-
 drivers/usb/gadget/function/f_printer.c  | 2 +-
 drivers/usb/gadget/function/f_rndis.c| 2 +-
 drivers/usb/gadget/function/f_serial.c   | 2 +-
 drivers/usb/gadget/function/f_sourcesink.c   | 2 +-
 drivers/usb/gadget/function/f_subset.c   | 2 +-
 drivers/usb/gadget/function/f_tcm.c  | 2 +-
 drivers/usb/gadget/function/f_uac1.c | 3 ++-
 drivers/usb/gadget/function/f_uac2.c | 3 ++-
 include/linux/usb/gadget.h   | 3 ++-
 19 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index 0fafa7a..62ba4c1 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -163,7 +163,8 @@ EXPORT_SYMBOL_GPL(usb_copy_descriptors);
 int usb_assign_descriptors(struct usb_function *f,
struct usb_descriptor_header **fs,
struct usb_descriptor_header **hs,
-   struct usb_descriptor_header **ss)
+   struct usb_descriptor_header **ss,
+   struct usb_descriptor_header **ssp)
 {
struct usb_gadget *g = f->config->cdev->gadget;
 
diff --git a/drivers/usb/gadget/function/f_acm.c 
b/drivers/usb/gadget/function/f_acm.c
index 2fa1e80..dc13b28 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -685,7 +685,7 @@ acm_bind(struct usb_configuration *c, struct usb_function 
*f)
acm_ss_out_desc.bEndpointAddress = acm_fs_out_desc.bEndpointAddress;
 
status = usb_assign_descriptors(f, acm_fs_function, acm_hs_function,
-   acm_ss_function);
+   acm_ss_function, NULL);
if (status)
goto fail;
 
diff --git a/drivers/usb/gadget/function/f_ecm.c 
b/drivers/usb/gadget/function/f_ecm.c
index 7ad60ee..4c488d1 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -786,7 +786,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
fs_ecm_notify_desc.bEndpointAddress;
 
status = usb_assign_descriptors(f, ecm_fs_function, ecm_hs_function,
-   ecm_ss_function);
+   ecm_ss_function, NULL);
if (status)
goto fail;
 
diff --git a/drivers/usb/gadget/function/f_eem.c 
b/drivers/usb/gadget/function/f_eem.c
index cad35a5..d58bfc3 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -309,7 +309,7 @@ static int eem_bind(struct usb_configuration *c, struct 
usb_function *f)
eem_ss_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress;
 
status = usb_assign_descriptors(f, eem_fs_function, eem_hs_function,
-   eem_ss_function);
+   eem_ss_function, NULL);
if (status)
goto fail;
 
diff --git a/drivers/usb/gadget/function/f_hid.c 
b/drivers/usb/gadget/function/f_hid.c
index 99285b4..51980c5 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -646,7 +646,7 @@ static int hidg_bind(struct usb_configuration *c, struct 
usb_function *f)
hidg_fs_out_ep_desc.bEndpointAddress;
 
status = usb_assign_descriptors(f, hidg_fs_descriptors,
-   hidg_hs_descriptors, NULL);
+   hidg_hs_descriptors, NULL, NULL);
if (status)
goto fail;
 
diff --git a/drivers/usb/gadget/function/f_loopback.c 
b/drivers/usb/gadget/function/f_loopback.c
index ddc3aad..3a9f8f9 100644
--- a/drivers/usb/gadget/function/f_loopback.c
+++ b/drivers/usb/gadget/function/f_loopback.c
@@ -211,7 +211,7 @@ autoconf_fail:
ss_loop_sink_desc.bEndpointAddress = fs_loop_sink_desc.bEndpointAddress;
 
ret = usb_assign_descriptors(f, fs_loopback_descs, hs_loopback_descs,
-   ss_loopback_descs);
+   ss_loopback_descs, NULL);
if (ret)
return ret;
 
diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index 223ccf8..321a631 100644
--- a/drive

[PATCH 08/19] usb: gadget: Update config for SuperSpeedPlus

2016-02-05 Thread John Youn
When a function is added to a configuration with usb_add_function(), the
configuration speed flags are updated. These flags indicate for which
speeds the configuration is valid for.

This patch adds a flag in the configuration for SuperSpeedPlus and
also updates this based on the existence of ssp_descriptors.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 2 ++
 drivers/usb/gadget/configfs.c  | 1 +
 include/linux/usb/composite.h  | 1 +
 3 files changed, 4 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 11d2433..560330f 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -237,6 +237,8 @@ int usb_add_function(struct usb_configuration *config,
config->highspeed = true;
if (!config->superspeed && function->ss_descriptors)
config->superspeed = true;
+   if (!config->superspeed_plus && function->ssp_descriptors)
+   config->superspeed_plus = true;
 
 done:
if (value)
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 590c449..c6cc15e 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -1229,6 +1229,7 @@ static void purge_configs_funcs(struct gadget_info *gi)
}
c->next_interface_id = 0;
memset(c->interface, 0, sizeof(c->interface));
+   c->superspeed_plus = 0;
c->superspeed = 0;
c->highspeed = 0;
c->fullspeed = 0;
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 9ff1e46..2b81b24 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -322,6 +322,7 @@ struct usb_configuration {
unsignedsuperspeed:1;
unsignedhighspeed:1;
unsignedfullspeed:1;
+   unsignedsuperspeed_plus:1;
struct usb_function *interface[MAX_CONFIG_INTERFACES];
 };
 
-- 
2.6.3

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


[PATCH 02/19] usb: ch9: Add size macro for SSP dev cap descriptor

2016-02-05 Thread John Youn
The SuperspeedPlus Device Capability Descriptor has a variable size
depending on the number of sublink speed attributes.

This patch adds a macro to calculate that size. The macro takes one
argument, the Sublink Speed Attribute Count (SSAC) as reported by the
descriptor in bmAttributes[4:0].

See USB 3.1 9.6.2.5, Table 9-19.

Signed-off-by: John Youn 
---
 include/uapi/linux/usb/ch9.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
index 779a62a..9ff 100644
--- a/include/uapi/linux/usb/ch9.h
+++ b/include/uapi/linux/usb/ch9.h
@@ -894,6 +894,11 @@ struct usb_ssp_cap_descriptor {
 #define USB_SSP_SUBLINK_SPEED_LSM  (0xff << 16)/* Lanespeed mantissa */
 } __attribute__((packed));
 
+/*
+ * The size of the descriptor for the Sublink Speed Attribute Count
+ * (SSAC) specified in bmAttributes[4:0].
+ */
+#define USB_DT_USB_SSP_CAP_SIZE(ssac)  (16 + ssac * 4)
 
 /*-*/
 
-- 
2.6.3

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


[PATCH 10/19] usb: gadget: composite: Add function to get descriptors

2016-02-05 Thread John Youn
There are a couple places in the code that get the function descriptors
based on the speed. Move this lookup into a function call and add
support to handle the SuperSpeedPlus descriptors as well.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 53 +-
 1 file changed, 32 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 44ad7aa..1d4f324 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -54,6 +54,36 @@ static struct usb_gadget_strings **get_containers_gs(
 }
 
 /**
+ * function_descriptors() - get function descriptors for speed
+ * @f: the function
+ * @speed: the speed
+ *
+ * Returns the descriptors or NULL if not set.
+ */
+static struct usb_descriptor_header **
+function_descriptors(struct usb_function *f,
+enum usb_device_speed speed)
+{
+   struct usb_descriptor_header **descriptors;
+
+   switch (speed) {
+   case USB_SPEED_SUPER_PLUS:
+   descriptors = f->ssp_descriptors;
+   break;
+   case USB_SPEED_SUPER:
+   descriptors = f->ss_descriptors;
+   break;
+   case USB_SPEED_HIGH:
+   descriptors = f->hs_descriptors;
+   break;
+   default:
+   descriptors = f->fs_descriptors;
+   }
+
+   return descriptors;
+}
+
+/**
  * next_ep_desc() - advance to the next EP descriptor
  * @t: currect pointer within descriptor array
  *
@@ -419,17 +449,7 @@ static int config_buf(struct usb_configuration *config,
list_for_each_entry(f, &config->functions, list) {
struct usb_descriptor_header **descriptors;
 
-   switch (speed) {
-   case USB_SPEED_SUPER:
-   descriptors = f->ss_descriptors;
-   break;
-   case USB_SPEED_HIGH:
-   descriptors = f->hs_descriptors;
-   break;
-   default:
-   descriptors = f->fs_descriptors;
-   }
-
+   descriptors = function_descriptors(f, speed);
if (!descriptors)
continue;
status = usb_descriptor_fillbuf(next, len,
@@ -740,16 +760,7 @@ static int set_config(struct usb_composite_dev *cdev,
 * function's setup callback instead of the current
 * configuration's setup callback.
 */
-   switch (gadget->speed) {
-   case USB_SPEED_SUPER:
-   descriptors = f->ss_descriptors;
-   break;
-   case USB_SPEED_HIGH:
-   descriptors = f->hs_descriptors;
-   break;
-   default:
-   descriptors = f->fs_descriptors;
-   }
+   descriptors = function_descriptors(f, gadget->speed);
 
for (; *descriptors; ++descriptors) {
struct usb_endpoint_descriptor *ep;
-- 
2.6.3

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


[PATCH 13/19] usb: gadget: composite: Update debug message for SuperSpeedPlus

2016-02-05 Thread John Youn
Update the debug message reporting the speeds that a configuration
supports for SuperSpeedPlus.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 60b6e4b..64ad1be 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -891,8 +891,9 @@ int usb_add_config(struct usb_composite_dev *cdev,
} else {
unsignedi;
 
-   DBG(cdev, "cfg %d/%p speeds:%s%s%s\n",
+   DBG(cdev, "cfg %d/%p speeds:%s%s%s%s\n",
config->bConfigurationValue, config,
+   config->superspeed_plus ? " superplus" : "",
config->superspeed ? " super" : "",
config->highspeed ? " high" : "",
config->fullspeed
-- 
2.6.3

--
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 07/19] usb: gadget: Update function for SuperSpeedPlus

2016-02-05 Thread John Youn
Add a ssp_descriptors member to struct usb_function and handle the
initialization and cleanup of it. This holds the SuperSpeedPlus
descriptors for a function that supports SuperSpeedPlus. This is added
by usb_assign_descriptors().

Signed-off-by: John Youn 
---
 drivers/usb/gadget/config.c   | 6 ++
 include/linux/usb/composite.h | 5 +
 2 files changed, 11 insertions(+)

diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index 62ba4c1..e6c0542 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -183,6 +183,11 @@ int usb_assign_descriptors(struct usb_function *f,
if (!f->ss_descriptors)
goto err;
}
+   if (ssp && gadget_is_superspeed_plus(g)) {
+   f->ssp_descriptors = usb_copy_descriptors(ssp);
+   if (!f->ssp_descriptors)
+   goto err;
+   }
return 0;
 err:
usb_free_all_descriptors(f);
@@ -195,6 +200,7 @@ void usb_free_all_descriptors(struct usb_function *f)
usb_free_descriptors(f->fs_descriptors);
usb_free_descriptors(f->hs_descriptors);
usb_free_descriptors(f->ss_descriptors);
+   usb_free_descriptors(f->ssp_descriptors);
 }
 EXPORT_SYMBOL_GPL(usb_free_all_descriptors);
 
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 1074b89..9ff1e46 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -126,6 +126,10 @@ struct usb_os_desc_table {
  * string identifiers assigned during @bind(). If this
  * pointer is null after initiation, the function will not
  * be available at super speed.
+ * @ssp_descriptors: Table of super speed plus descriptors, using
+ * interface and string identifiers assigned during @bind(). If
+ * this pointer is null after initiation, the function will not
+ * be available at super speed plus.
  * @config: assigned when @usb_add_function() is called; this is the
  * configuration with which this function is associated.
  * @os_desc_table: Table of (interface id, os descriptors) pairs. The function
@@ -186,6 +190,7 @@ struct usb_function {
struct usb_descriptor_header**fs_descriptors;
struct usb_descriptor_header**hs_descriptors;
struct usb_descriptor_header**ss_descriptors;
+   struct usb_descriptor_header**ssp_descriptors;
 
struct usb_configuration*config;
 
-- 
2.6.3

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


[PATCH 12/19] usb: gadget: composite: Configure the usb_ep for SuperSpeedPlus

2016-02-05 Thread John Youn
Configure the usb_ep using the SuperSpeedPlus descriptors if connected
in SuperSpeedPlus.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index b938fcf..60b6e4b 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -148,6 +148,13 @@ int config_ep_by_speed(struct usb_gadget *g,
 
/* select desired speed */
switch (g->speed) {
+   case USB_SPEED_SUPER_PLUS:
+   if (gadget_is_superspeed_plus(g)) {
+   speed_desc = f->ssp_descriptors;
+   want_comp_desc = 1;
+   break;
+   }
+   /* else: Fall trough */
case USB_SPEED_SUPER:
if (gadget_is_superspeed(g)) {
speed_desc = f->ss_descriptors;
@@ -191,7 +198,7 @@ ep_found:
(comp_desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP))
return -EIO;
_ep->comp_desc = comp_desc;
-   if (g->speed == USB_SPEED_SUPER) {
+   if (g->speed >= USB_SPEED_SUPER) {
switch (usb_endpoint_type(_ep->desc)) {
case USB_ENDPOINT_XFER_ISOC:
/* mult: bits 1:0 of bmAttributes */
-- 
2.6.3

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


[PATCH 11/19] usb: gadget: composite: Write SuperSpeedPlus config descriptors

2016-02-05 Thread John Youn
Enable writing of SuperSpeedPlus descriptors for any SuperSpeedPlus
capable configuration when connected in SuperSpeedPlus.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 1d4f324..b938fcf 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -473,7 +473,7 @@ static int config_desc(struct usb_composite_dev *cdev, 
unsigned w_value)
u8  type = w_value >> 8;
enum usb_device_speed   speed = USB_SPEED_UNKNOWN;
 
-   if (gadget->speed == USB_SPEED_SUPER)
+   if (gadget->speed >= USB_SPEED_SUPER)
speed = gadget->speed;
else if (gadget_is_dualspeed(gadget)) {
int hs = 0;
@@ -504,6 +504,10 @@ static int config_desc(struct usb_composite_dev *cdev, 
unsigned w_value)
 check_config:
/* ignore configs that won't work at this speed */
switch (speed) {
+   case USB_SPEED_SUPER_PLUS:
+   if (!c->superspeed_plus)
+   continue;
+   break;
case USB_SPEED_SUPER:
if (!c->superspeed)
continue;
-- 
2.6.3

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


[PATCH 09/19] usb: gadget: composite: Count configs for SuperSpeedPlus

2016-02-05 Thread John Youn
If enumerated in SuperSpeedPlus, count the configurations that support
it.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 560330f..44ad7aa 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -511,18 +511,24 @@ static int count_configs(struct usb_composite_dev *cdev, 
unsigned type)
unsignedcount = 0;
int hs = 0;
int ss = 0;
+   int ssp = 0;
 
if (gadget_is_dualspeed(gadget)) {
if (gadget->speed == USB_SPEED_HIGH)
hs = 1;
if (gadget->speed == USB_SPEED_SUPER)
ss = 1;
+   if (gadget->speed == USB_SPEED_SUPER_PLUS)
+   ssp = 1;
if (type == USB_DT_DEVICE_QUALIFIER)
hs = !hs;
}
list_for_each_entry(c, &cdev->configs, list) {
/* ignore configs that won't work at this speed */
-   if (ss) {
+   if (ssp) {
+   if (!c->superspeed_plus)
+   continue;
+   } else if (ss) {
if (!c->superspeed)
continue;
} else if (hs) {
-- 
2.6.3

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


[PATCH 15/19] usb: dwc3: DWC_usb31 controller check

2016-02-05 Thread John Youn
Add a convenience function to check if the controller is DWC_usb31.

Signed-off-by: John Youn 
---
 drivers/usb/dwc3/core.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 2913068..15281c1 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -1025,6 +1025,12 @@ struct dwc3_gadget_ep_cmd_params {
 void dwc3_set_mode(struct dwc3 *dwc, u32 mode);
 int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc);
 
+/* check whether we are on the DWC_usb31 core */
+static inline bool dwc3_is_usb31(struct dwc3 *dwc)
+{
+   return !!(dwc->revision & DWC3_REVISION_IS_DWC31);
+}
+
 #if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
 int dwc3_host_init(struct dwc3 *dwc);
 void dwc3_host_exit(struct dwc3 *dwc);
-- 
2.6.3

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


[PATCH 16/19] usb: dwc3: Update register fields for SuperSpeedPlus

2016-02-05 Thread John Youn
Update various registers fields definitions for the DWC_usb31 controller
for SuperSpeedPlus support.

Signed-off-by: John Youn 
---
 drivers/usb/dwc3/core.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 15281c1..6b13ea4 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -223,7 +223,8 @@
 /* Global HWPARAMS3 Register */
 #define DWC3_GHWPARAMS3_SSPHY_IFC(n)   ((n) & 3)
 #define DWC3_GHWPARAMS3_SSPHY_IFC_DIS  0
-#define DWC3_GHWPARAMS3_SSPHY_IFC_ENA  1
+#define DWC3_GHWPARAMS3_SSPHY_IFC_GEN1 1
+#define DWC3_GHWPARAMS3_SSPHY_IFC_GEN2 2 /* DWC_usb31 only */
 #define DWC3_GHWPARAMS3_HSPHY_IFC(n)   (((n) & (3 << 2)) >> 2)
 #define DWC3_GHWPARAMS3_HSPHY_IFC_DIS  0
 #define DWC3_GHWPARAMS3_HSPHY_IFC_UTMI 1
@@ -249,6 +250,7 @@
 #define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f)
 
 #define DWC3_DCFG_SPEED_MASK   (7 << 0)
+#define DWC3_DCFG_SUPERSPEED_PLUS (5 << 0)  /* DWC_usb31 only */
 #define DWC3_DCFG_SUPERSPEED   (4 << 0)
 #define DWC3_DCFG_HIGHSPEED(0 << 0)
 #define DWC3_DCFG_FULLSPEED2   (1 << 0)
@@ -339,6 +341,7 @@
 
 #define DWC3_DSTS_CONNECTSPD   (7 << 0)
 
+#define DWC3_DSTS_SUPERSPEED_PLUS  (5 << 0) /* DWC_usb31 only */
 #define DWC3_DSTS_SUPERSPEED   (4 << 0)
 #define DWC3_DSTS_HIGHSPEED(0 << 0)
 #define DWC3_DSTS_FULLSPEED2   (1 << 0)
-- 
2.6.3

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


[PATCH 14/19] usb: gadget: f_mass_storage: Enable SuperSpeedPlus

2016-02-05 Thread John Youn
Enable superspeed plus configuration for the mass storage gadget.

The mass storage function doesn't do anything special for
SuperSpeedPlus. Just pass in the same SuperSpeed descriptors for
SuperSpeedPlus.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/function/f_mass_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index 321a631..ee9390b 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -3093,7 +3093,7 @@ static int fsg_bind(struct usb_configuration *c, struct 
usb_function *f)
fsg_ss_bulk_out_comp_desc.bMaxBurst = max_burst;
 
ret = usb_assign_descriptors(f, fsg_fs_function, fsg_hs_function,
-   fsg_ss_function, NULL);
+   fsg_ss_function, fsg_ss_function);
if (ret)
goto autoconf_fail;
 
-- 
2.6.3

--
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 19/19] usb: dwc3: Enable SuperSpeedPlus

2016-02-05 Thread John Youn
Enable SuperSpeedPlus by programming the DCFG.speed and after
enumerating, set gadget->speed appropriately.

Signed-off-by: John Youn 
---
 drivers/usb/dwc3/gadget.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 73db723..5bbdf5d 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1629,6 +1629,9 @@ static int dwc3_gadget_start(struct usb_gadget *g,
case USB_SPEED_HIGH:
reg |= DWC3_DSTS_HIGHSPEED;
break;
+   case USB_SPEED_SUPER_PLUS:
+   reg |= DWC3_DSTS_SUPERSPEED_PLUS;
+   break;
case USB_SPEED_SUPER:   /* FALLTHROUGH */
case USB_SPEED_UNKNOWN: /* FALTHROUGH */
default:
@@ -2337,6 +2340,11 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 
*dwc)
dwc3_update_ram_clk_sel(dwc, speed);
 
switch (speed) {
+   case DWC3_DCFG_SUPERSPEED_PLUS:
+   dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);
+   dwc->gadget.ep0->maxpacket = 512;
+   dwc->gadget.speed = USB_SPEED_SUPER_PLUS;
+   break;
case DWC3_DCFG_SUPERSPEED:
/*
 * WORKAROUND: DWC3 revisions <1.90a have an issue which
-- 
2.6.3

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


[PATCH 18/19] usb: dwc3: Update maximum_speed for SuperSpeedPlus

2016-02-05 Thread John Youn
If the maximum_speed is not set, set it to a known value, either
SuperSpeed or SuperSpeedPlus based on the type of controller we are
using. If we are on DWC_usb31 controller, check the PHY interface to see
if it is capable of SuperSpeedPlus.

Also this check is moved after dwc3_core_init() so that we can check
dwc->revision.

Signed-off-by: John Youn 
---
 drivers/usb/dwc3/core.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index de5e01f..001c755 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -962,10 +962,6 @@ static int dwc3_probe(struct platform_device *pdev)
fladj = pdata->fladj_value;
}
 
-   /* default to superspeed if no maximum_speed passed */
-   if (dwc->maximum_speed == USB_SPEED_UNKNOWN)
-   dwc->maximum_speed = USB_SPEED_SUPER;
-
dwc->lpm_nyet_threshold = lpm_nyet_threshold;
dwc->tx_de_emphasis = tx_de_emphasis;
 
@@ -1016,6 +1012,19 @@ static int dwc3_probe(struct platform_device *pdev)
goto err1;
}
 
+   /* default to superspeed if no maximum_speed passed */
+   if (dwc->maximum_speed == USB_SPEED_UNKNOWN) {
+   dwc->maximum_speed = USB_SPEED_SUPER;
+
+   /*
+* default to superspeed plus if we are capable.
+*/
+   if (dwc3_is_usb31(dwc) &&
+   (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
+DWC3_GHWPARAMS3_SSPHY_IFC_GEN2))
+   dwc->maximum_speed = USB_SPEED_SUPER_PLUS;
+   }
+
/* Adjust Frame Length */
dwc3_frame_length_adjustment(dwc, fladj);
 
-- 
2.6.3

--
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 17/19] usb: dwc3: Update speed checks for SuperSpeedPlus

2016-02-05 Thread John Youn
Update various places where the speed is checked so that it takes into
account SuperSpeedPlus properly.

Signed-off-by: John Youn 
---
 drivers/usb/dwc3/ep0.c|  9 ++---
 drivers/usb/dwc3/gadget.c | 13 -
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 3a9354a..0f1497c 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -356,7 +356,8 @@ static int dwc3_ep0_handle_status(struct dwc3 *dwc,
 */
usb_status |= dwc->gadget.is_selfpowered;
 
-   if (dwc->speed == DWC3_DSTS_SUPERSPEED) {
+   if ((dwc->speed == DWC3_DSTS_SUPERSPEED) ||
+   (dwc->speed == DWC3_DSTS_SUPERSPEED_PLUS)) {
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
if (reg & DWC3_DCTL_INITU1ENA)
usb_status |= 1 << USB_DEV_STAT_U1_ENABLED;
@@ -426,7 +427,8 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
case USB_DEVICE_U1_ENABLE:
if (state != USB_STATE_CONFIGURED)
return -EINVAL;
-   if (dwc->speed != DWC3_DSTS_SUPERSPEED)
+   if ((dwc->speed != DWC3_DSTS_SUPERSPEED) &&
+   (dwc->speed != DWC3_DSTS_SUPERSPEED_PLUS))
return -EINVAL;
 
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
@@ -440,7 +442,8 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
case USB_DEVICE_U2_ENABLE:
if (state != USB_STATE_CONFIGURED)
return -EINVAL;
-   if (dwc->speed != DWC3_DSTS_SUPERSPEED)
+   if ((dwc->speed != DWC3_DSTS_SUPERSPEED) &&
+   (dwc->speed != DWC3_DSTS_SUPERSPEED_PLUS))
return -EINVAL;
 
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 7d1dd82..73db723 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -421,7 +421,7 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, 
struct dwc3_ep *dep,
| DWC3_DEPCFG_MAX_PACKET_SIZE(usb_endpoint_maxp(desc));
 
/* Burst size is only needed in SuperSpeed mode */
-   if (dwc->gadget.speed == USB_SPEED_SUPER) {
+   if (dwc->gadget.speed >= USB_SPEED_SUPER) {
u32 burst = dep->endpoint.maxburst - 1;
 
params.param0 |= DWC3_DEPCFG_BURST_SIZE(burst);
@@ -1403,7 +1403,8 @@ static int dwc3_gadget_wakeup(struct usb_gadget *g)
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
 
speed = reg & DWC3_DSTS_CONNECTSPD;
-   if (speed == DWC3_DSTS_SUPERSPEED) {
+   if ((speed == DWC3_DSTS_SUPERSPEED) ||
+   (speed == DWC3_DSTS_SUPERSPEED_PLUS)) {
dwc3_trace(trace_dwc3_gadget, "no wakeup on SuperSpeed\n");
ret = -EINVAL;
goto out;
@@ -2306,7 +2307,8 @@ static void dwc3_update_ram_clk_sel(struct dwc3 *dwc, u32 
speed)
 * this. Maybe it becomes part of the power saving plan.
 */
 
-   if (speed != DWC3_DSTS_SUPERSPEED)
+   if ((speed != DWC3_DSTS_SUPERSPEED) &&
+   (speed != DWC3_DSTS_SUPERSPEED_PLUS))
return;
 
/*
@@ -2376,8 +2378,9 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 
*dwc)
 
/* Enable USB2 LPM Capability */
 
-   if ((dwc->revision > DWC3_REVISION_194A)
-   && (speed != DWC3_DCFG_SUPERSPEED)) {
+   if ((dwc->revision > DWC3_REVISION_194A) &&
+   (speed != DWC3_DCFG_SUPERSPEED) &&
+   (speed != DWC3_DCFG_SUPERSPEED_PLUS)) {
reg = dwc3_readl(dwc->regs, DWC3_DCFG);
reg |= DWC3_DCFG_LPM_CAP;
dwc3_writel(dwc->regs, DWC3_DCFG, reg);
-- 
2.6.3

--
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: dwc3: pci: use build-in properties instead of platform data

2016-02-05 Thread John Youn
On 2/3/2016 1:03 AM, Heikki Krogerus wrote:
> This should allow the core driver to drop handling of
> platform data and expect the platform specific details to
> always come from properties.
> 
> Signed-off-by: Heikki Krogerus 
> Cc: Huang Rui 
> CC: John Youn 
> ---
>  drivers/usb/dwc3/dwc3-pci.c | 81 
> +++--
>  1 file changed, 41 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
> index 009d830..96dbf24 100644
> --- a/drivers/usb/dwc3/dwc3-pci.c
> +++ b/drivers/usb/dwc3/dwc3-pci.c
> @@ -23,8 +23,7 @@
>  #include 
>  #include 
>  #include 
> -
> -#include "platform_data.h"
> +#include 
>  
>  #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3  0xabcd
>  #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3_AXI  0xabce
> @@ -46,38 +45,42 @@ static const struct acpi_gpio_mapping 
> acpi_dwc3_byt_gpios[] = {
>   { },
>  };
>  
> +static inline int
> +dwc3_pci_add_pset(struct platform_device *dwc3, struct property_entry *ent)
> +{
> + struct property_set pset;
> +
> + pset.properties = ent;
> + return platform_device_add_properties(dwc3, &pset);
> +}
> +
>  static int dwc3_pci_quirks(struct pci_dev *pdev)
>  {
>   if (pdev->vendor == PCI_VENDOR_ID_AMD &&
>   pdev->device == PCI_DEVICE_ID_AMD_NL_USB) {
> - struct dwc3_platform_data pdata;
> -
> - memset(&pdata, 0, sizeof(pdata));
> -
> - pdata.has_lpm_erratum = true;
> - pdata.lpm_nyet_threshold = 0xf;
> -
> - pdata.u2exit_lfps_quirk = true;
> - pdata.u2ss_inp3_quirk = true;
> - pdata.req_p1p2p3_quirk = true;
> - pdata.del_p1p2p3_quirk = true;
> - pdata.del_phy_power_chg_quirk = true;
> - pdata.lfps_filter_quirk = true;
> - pdata.rx_detect_poll_quirk = true;
> -
> - pdata.tx_de_emphasis_quirk = true;
> - pdata.tx_de_emphasis = 1;
> -
> - /*
> -  * FIXME these quirks should be removed when AMD NL
> -  * taps out
> -  */
> - pdata.disable_scramble_quirk = true;
> - pdata.dis_u3_susphy_quirk = true;
> - pdata.dis_u2_susphy_quirk = true;
> -
> - return platform_device_add_data(pci_get_drvdata(pdev), &pdata,
> - sizeof(pdata));
> + struct property_entry pentry[] = {
> + PROPERTY_ENTRY_BOOL("snps,has-lpm-erratum"),
> + PROPERTY_ENTRY_U8("snps,lpm-nyet-threshold", 0xf),
> + PROPERTY_ENTRY_BOOL("snps,u2exit_lfps_quirk"),
> + PROPERTY_ENTRY_BOOL("snps,u2ss_inp3_quirk"),
> + PROPERTY_ENTRY_BOOL("snps,req_p1p2p3_quirk"),
> + PROPERTY_ENTRY_BOOL("snps,del_p1p2p3_quirk"),
> + PROPERTY_ENTRY_BOOL("snps,del_phy_power_chg_quirk"),
> + PROPERTY_ENTRY_BOOL("snps,lfps_filter_quirk"),
> + PROPERTY_ENTRY_BOOL("snps,rx_detect_poll_quirk"),
> + PROPERTY_ENTRY_BOOL("snps,tx_de_emphasis_quirk"),
> + PROPERTY_ENTRY_U8("snps,tx_de_emphasis", 1),
> + /*
> +  * FIXME these quirks should be removed when AMD NL
> +  * tapes out
> +  */
> + PROPERTY_ENTRY_BOOL("snps,disable_scramble_quirk"),
> + PROPERTY_ENTRY_BOOL("snps,dis_u3_susphy_quirk"),
> + PROPERTY_ENTRY_BOOL("snps,dis_u2_susphy_quirk"),
> + { },
> + };
> +
> + return dwc3_pci_add_pset(pci_get_drvdata(pdev), pentry);
>   }
>  
>   if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
> @@ -114,16 +117,14 @@ static int dwc3_pci_quirks(struct pci_dev *pdev)
>   (pdev->device == PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 ||
>pdev->device == PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3_AXI ||
>pdev->device == PCI_DEVICE_ID_SYNOPSYS_HAPSUSB31)) {
> -
> - struct dwc3_platform_data pdata;
> -
> - memset(&pdata, 0, sizeof(pdata));
> - pdata.usb3_lpm_capable = true;
> - pdata.has_lpm_erratum = true;
> - pdata.dis_enblslpm_quirk = true;
> -
> - return platform_device_add_data(pci_get_drvdata(pdev), &pdata,
> - sizeof(pdata));
> + struct property_entry pentry[] = {
> + PROPERTY_ENTRY_BOOL("snps,usb3_lpm_capable"),
> + PROPERTY_ENTRY_BOOL("snps,has-lpm-erratum"),
> + PROPERTY_ENTRY_BOOL("snps,dis_enblslpm_quirk"),

I tried testing in Synopsys HAPS platform.

The properties are being set here successfully but when queried in
core.c they all report 0.

Any ideas?

Regards,
John
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" 

[PATCH v3 02/19] usb: ch9: Add size macro for SSP dev cap descriptor

2016-02-05 Thread John Youn
The SuperspeedPlus Device Capability Descriptor has a variable size
depending on the number of sublink speed attributes.

This patch adds a macro to calculate that size. The macro takes one
argument, the Sublink Speed Attribute Count (SSAC) as reported by the
descriptor in bmAttributes[4:0].

See USB 3.1 9.6.2.5, Table 9-19.

Signed-off-by: John Youn 
---
 include/uapi/linux/usb/ch9.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
index 779a62a..9ff 100644
--- a/include/uapi/linux/usb/ch9.h
+++ b/include/uapi/linux/usb/ch9.h
@@ -894,6 +894,11 @@ struct usb_ssp_cap_descriptor {
 #define USB_SSP_SUBLINK_SPEED_LSM  (0xff << 16)/* Lanespeed mantissa */
 } __attribute__((packed));
 
+/*
+ * The size of the descriptor for the Sublink Speed Attribute Count
+ * (SSAC) specified in bmAttributes[4:0].
+ */
+#define USB_DT_USB_SSP_CAP_SIZE(ssac)  (16 + ssac * 4)
 
 /*-*/
 
-- 
2.6.3

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


[PATCH v3 00/19] usb: gadget: Add support for SuperSpeedPlus

2016-02-05 Thread John Youn
RESENDING with Felipe's correct email and proper version tag. Sorry!

This series of patches adds SuperSpeedPlus support to the composite
gadget framework. After this series the composite gadget framework
should be able to support SuperSpeedPlus functions and gadgets.

Additionally, the f_mass_storage function and the DWC3 gadget are
updated to support SuperSpeedPlus.

Tested on:
- Synopsys HAPS, DWC_usb3 IP, v2.90a
- Synopsys HAPS, DWC_usb3 IP, v3.00a
- Synopsys HAPS, DWC_usb31 IP, v1.10a

v3:
- Resend. Fixed headers and emails.

v2:
- Updated commit message for bcdUSB (Sergei Shtylyov and Bjorn Mork)
- Simplified case statement (Sergei Shtylyov)

John Youn (19):
  usb: ch9: Add USB_SPEED_SUPER_PLUS
  usb: ch9: Add size macro for SSP dev cap descriptor
  usb: gadget: Add gadget_is_superspeed_plus()
  usb: gadget: composite: Return bcdUSB 0x0310
  usb: gadget: composite: Return SSP Dev Cap descriptor
  usb: gadget: Update usb_assign_descriptors for SuperSpeedPlus
  usb: gadget: Update function for SuperSpeedPlus
  usb: gadget: Update config for SuperSpeedPlus
  usb: gadget: composite: Count configs for SuperSpeedPlus
  usb: gadget: composite: Add function to get descriptors
  usb: gadget: composite: Write SuperSpeedPlus config descriptors
  usb: gadget: composite: Configure the usb_ep for SuperSpeedPlus
  usb: gadget: composite: Update debug message for SuperSpeedPlus
  usb: gadget: f_mass_storage: Enable SuperSpeedPlus
  usb: dwc3: DWC_usb31 controller check
  usb: dwc3: Update register fields for SuperSpeedPlus
  usb: dwc3: Update speed checks for SuperSpeedPlus
  usb: dwc3: Update maximum_speed for SuperSpeedPlus
  usb: dwc3: Enable SuperSpeedPlus

 drivers/usb/common/common.c  |   1 +
 drivers/usb/dwc3/core.c  |  17 +++-
 drivers/usb/dwc3/core.h  |  11 ++-
 drivers/usb/dwc3/ep0.c   |   9 +-
 drivers/usb/dwc3/gadget.c|  21 +++--
 drivers/usb/gadget/composite.c   | 125 +--
 drivers/usb/gadget/config.c  |   9 +-
 drivers/usb/gadget/configfs.c|   1 +
 drivers/usb/gadget/function/f_acm.c  |   2 +-
 drivers/usb/gadget/function/f_ecm.c  |   2 +-
 drivers/usb/gadget/function/f_eem.c  |   2 +-
 drivers/usb/gadget/function/f_hid.c  |   2 +-
 drivers/usb/gadget/function/f_loopback.c |   2 +-
 drivers/usb/gadget/function/f_mass_storage.c |   2 +-
 drivers/usb/gadget/function/f_ncm.c  |   2 +-
 drivers/usb/gadget/function/f_obex.c |   3 +-
 drivers/usb/gadget/function/f_phonet.c   |   2 +-
 drivers/usb/gadget/function/f_printer.c  |   2 +-
 drivers/usb/gadget/function/f_rndis.c|   2 +-
 drivers/usb/gadget/function/f_serial.c   |   2 +-
 drivers/usb/gadget/function/f_sourcesink.c   |   2 +-
 drivers/usb/gadget/function/f_subset.c   |   2 +-
 drivers/usb/gadget/function/f_tcm.c  |   2 +-
 drivers/usb/gadget/function/f_uac1.c |   3 +-
 drivers/usb/gadget/function/f_uac2.c |   3 +-
 include/linux/usb/composite.h|   6 ++
 include/linux/usb/gadget.h   |  13 ++-
 include/uapi/linux/usb/ch9.h |   6 ++
 28 files changed, 198 insertions(+), 58 deletions(-)

-- 
2.6.3

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


[PATCH v3 04/19] usb: gadget: composite: Return bcdUSB 0x0310

2016-02-05 Thread John Youn
The USB 3.1 specification replaces the USB 3.0 specification and all new
devices that are running at SuperSpeed or higher speeds must report a
bcdUSB of 0x0310.

Refer to USB 3.1 Specification, Revision 1.0, Section 9.6.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 8b14c2a..ce5dbc5 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1499,7 +1499,7 @@ composite_setup(struct usb_gadget *gadget, const struct 
usb_ctrlrequest *ctrl)
cdev->gadget->ep0->maxpacket;
if (gadget_is_superspeed(gadget)) {
if (gadget->speed >= USB_SPEED_SUPER) {
-   cdev->desc.bcdUSB = cpu_to_le16(0x0300);
+   cdev->desc.bcdUSB = cpu_to_le16(0x0310);
cdev->desc.bMaxPacketSize0 = 9;
} else {
cdev->desc.bcdUSB = cpu_to_le16(0x0210);
-- 
2.6.3

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


[PATCH v3 05/19] usb: gadget: composite: Return SSP Dev Cap descriptor

2016-02-05 Thread John Youn
If a gadget supports SuperSpeedPlus or higher speeds, return a
SuperSpeedPlus USB Device Capability descriptor.

Currently this implementation returns a fixed descriptor with typical
values set.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index ce5dbc5..11d2433 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -597,6 +597,48 @@ static int bos_desc(struct usb_composite_dev *cdev)
ss_cap->bU1devExitLat = dcd_config_params.bU1devExitLat;
ss_cap->bU2DevExitLat = dcd_config_params.bU2DevExitLat;
 
+   /* The SuperSpeedPlus USB Device Capability descriptor */
+   if (gadget_is_superspeed_plus(cdev->gadget)) {
+   struct usb_ssp_cap_descriptor *ssp_cap;
+
+   ssp_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength);
+   bos->bNumDeviceCaps++;
+
+   /*
+* Report typical values.
+*/
+
+   le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SSP_CAP_SIZE(1));
+   ssp_cap->bLength = USB_DT_USB_SSP_CAP_SIZE(1);
+   ssp_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
+   ssp_cap->bDevCapabilityType = USB_SSP_CAP_TYPE;
+
+   /* SSAC = 1 (2 attributes) */
+   ssp_cap->bmAttributes = cpu_to_le32(1);
+
+   /* Min RX/TX Lane Count = 1 */
+   ssp_cap->wFunctionalitySupport = (1 << 8) | (1 << 12);
+
+   /*
+* bmSublinkSpeedAttr[0]:
+*   ST  = Symmetric, RX
+*   LSE =  3 (Gbps)
+*   LP  =  1 (SuperSpeedPlus)
+*   LSM = 10 (10 Gbps)
+*/
+   ssp_cap->bmSublinkSpeedAttr[0] =
+   (3 << 4) | (1 << 14) | (0xa << 16);
+   /*
+* bmSublinkSpeedAttr[1] =
+*   ST  = Symmetric, TX
+*   LSE =  3 (Gbps)
+*   LP  =  1 (SuperSpeedPlus)
+*   LSM = 10 (10 Gbps)
+*/
+   ssp_cap->bmSublinkSpeedAttr[1] =
+   (3 << 4) | (1 << 14) | (0xa << 16) | (1 << 7);
+   }
+
return le16_to_cpu(bos->wTotalLength);
 }
 
-- 
2.6.3

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


[PATCH v3 03/19] usb: gadget: Add gadget_is_superspeed_plus()

2016-02-05 Thread John Youn
Add a function to check for SuperSpeedPlus capable gadgets.

Signed-off-by: John Youn 
---
 include/linux/usb/gadget.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index d82d006..d6a1bda 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -729,6 +729,16 @@ static inline int gadget_is_superspeed(struct usb_gadget 
*g)
 }
 
 /**
+ * gadget_is_superspeed_plus() - return true if the hardware handles
+ * superspeed plus
+ * @g: controller that might support superspeed plus
+ */
+static inline int gadget_is_superspeed_plus(struct usb_gadget *g)
+{
+   return g->max_speed >= USB_SPEED_SUPER_PLUS;
+}
+
+/**
  * gadget_is_otg - return true iff the hardware is OTG-ready
  * @g: controller that might have a Mini-AB connector
  *
-- 
2.6.3

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


[PATCH v3 01/19] usb: ch9: Add USB_SPEED_SUPER_PLUS

2016-02-05 Thread John Youn
Add USB_SPEED_SUPER_PLUS to usb_device_speed enumeration and add an
entry in the speed_names array for it.

Signed-off-by: John Youn 
---
 drivers/usb/common/common.c  | 1 +
 include/uapi/linux/usb/ch9.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index e6ec125..49fbfe8 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -51,6 +51,7 @@ static const char *const speed_names[] = {
[USB_SPEED_HIGH] = "high-speed",
[USB_SPEED_WIRELESS] = "wireless",
[USB_SPEED_SUPER] = "super-speed",
+   [USB_SPEED_SUPER_PLUS] = "super-speed-plus",
 };
 
 const char *usb_speed_string(enum usb_device_speed speed)
diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
index 4338eb7..779a62a 100644
--- a/include/uapi/linux/usb/ch9.h
+++ b/include/uapi/linux/usb/ch9.h
@@ -954,6 +954,7 @@ enum usb_device_speed {
USB_SPEED_HIGH, /* usb 2.0 */
USB_SPEED_WIRELESS, /* wireless (usb 2.5) */
USB_SPEED_SUPER,/* usb 3.0 */
+   USB_SPEED_SUPER_PLUS,   /* usb 3.1 */
 };
 
 
-- 
2.6.3

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


[PATCH v3 08/19] usb: gadget: Update config for SuperSpeedPlus

2016-02-05 Thread John Youn
When a function is added to a configuration with usb_add_function(), the
configuration speed flags are updated. These flags indicate for which
speeds the configuration is valid for.

This patch adds a flag in the configuration for SuperSpeedPlus and
also updates this based on the existence of ssp_descriptors.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 2 ++
 drivers/usb/gadget/configfs.c  | 1 +
 include/linux/usb/composite.h  | 1 +
 3 files changed, 4 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 11d2433..560330f 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -237,6 +237,8 @@ int usb_add_function(struct usb_configuration *config,
config->highspeed = true;
if (!config->superspeed && function->ss_descriptors)
config->superspeed = true;
+   if (!config->superspeed_plus && function->ssp_descriptors)
+   config->superspeed_plus = true;
 
 done:
if (value)
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 590c449..c6cc15e 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -1229,6 +1229,7 @@ static void purge_configs_funcs(struct gadget_info *gi)
}
c->next_interface_id = 0;
memset(c->interface, 0, sizeof(c->interface));
+   c->superspeed_plus = 0;
c->superspeed = 0;
c->highspeed = 0;
c->fullspeed = 0;
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 9ff1e46..2b81b24 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -322,6 +322,7 @@ struct usb_configuration {
unsignedsuperspeed:1;
unsignedhighspeed:1;
unsignedfullspeed:1;
+   unsignedsuperspeed_plus:1;
struct usb_function *interface[MAX_CONFIG_INTERFACES];
 };
 
-- 
2.6.3

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


[PATCH v3 07/19] usb: gadget: Update function for SuperSpeedPlus

2016-02-05 Thread John Youn
Add a ssp_descriptors member to struct usb_function and handle the
initialization and cleanup of it. This holds the SuperSpeedPlus
descriptors for a function that supports SuperSpeedPlus. This is added
by usb_assign_descriptors().

Signed-off-by: John Youn 
---
 drivers/usb/gadget/config.c   | 6 ++
 include/linux/usb/composite.h | 5 +
 2 files changed, 11 insertions(+)

diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index 62ba4c1..e6c0542 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -183,6 +183,11 @@ int usb_assign_descriptors(struct usb_function *f,
if (!f->ss_descriptors)
goto err;
}
+   if (ssp && gadget_is_superspeed_plus(g)) {
+   f->ssp_descriptors = usb_copy_descriptors(ssp);
+   if (!f->ssp_descriptors)
+   goto err;
+   }
return 0;
 err:
usb_free_all_descriptors(f);
@@ -195,6 +200,7 @@ void usb_free_all_descriptors(struct usb_function *f)
usb_free_descriptors(f->fs_descriptors);
usb_free_descriptors(f->hs_descriptors);
usb_free_descriptors(f->ss_descriptors);
+   usb_free_descriptors(f->ssp_descriptors);
 }
 EXPORT_SYMBOL_GPL(usb_free_all_descriptors);
 
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 1074b89..9ff1e46 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -126,6 +126,10 @@ struct usb_os_desc_table {
  * string identifiers assigned during @bind(). If this
  * pointer is null after initiation, the function will not
  * be available at super speed.
+ * @ssp_descriptors: Table of super speed plus descriptors, using
+ * interface and string identifiers assigned during @bind(). If
+ * this pointer is null after initiation, the function will not
+ * be available at super speed plus.
  * @config: assigned when @usb_add_function() is called; this is the
  * configuration with which this function is associated.
  * @os_desc_table: Table of (interface id, os descriptors) pairs. The function
@@ -186,6 +190,7 @@ struct usb_function {
struct usb_descriptor_header**fs_descriptors;
struct usb_descriptor_header**hs_descriptors;
struct usb_descriptor_header**ss_descriptors;
+   struct usb_descriptor_header**ssp_descriptors;
 
struct usb_configuration*config;
 
-- 
2.6.3

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


[PATCH v3 09/19] usb: gadget: composite: Count configs for SuperSpeedPlus

2016-02-05 Thread John Youn
If enumerated in SuperSpeedPlus, count the configurations that support
it.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 560330f..44ad7aa 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -511,18 +511,24 @@ static int count_configs(struct usb_composite_dev *cdev, 
unsigned type)
unsignedcount = 0;
int hs = 0;
int ss = 0;
+   int ssp = 0;
 
if (gadget_is_dualspeed(gadget)) {
if (gadget->speed == USB_SPEED_HIGH)
hs = 1;
if (gadget->speed == USB_SPEED_SUPER)
ss = 1;
+   if (gadget->speed == USB_SPEED_SUPER_PLUS)
+   ssp = 1;
if (type == USB_DT_DEVICE_QUALIFIER)
hs = !hs;
}
list_for_each_entry(c, &cdev->configs, list) {
/* ignore configs that won't work at this speed */
-   if (ss) {
+   if (ssp) {
+   if (!c->superspeed_plus)
+   continue;
+   } else if (ss) {
if (!c->superspeed)
continue;
} else if (hs) {
-- 
2.6.3

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


[PATCH v3 06/19] usb: gadget: Update usb_assign_descriptors for SuperSpeedPlus

2016-02-05 Thread John Youn
Add the 'ssp_descriptors' parameter to the usb_assign_descriptors()
function. This allows a function driver to add descriptors for
SuperSpeedPlus speeds if it supports it.

Also update all uses of this function in the gadget subsystem so that
they pass NULL for the ssp_descriptors parameters.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/config.c  | 3 ++-
 drivers/usb/gadget/function/f_acm.c  | 2 +-
 drivers/usb/gadget/function/f_ecm.c  | 2 +-
 drivers/usb/gadget/function/f_eem.c  | 2 +-
 drivers/usb/gadget/function/f_hid.c  | 2 +-
 drivers/usb/gadget/function/f_loopback.c | 2 +-
 drivers/usb/gadget/function/f_mass_storage.c | 2 +-
 drivers/usb/gadget/function/f_ncm.c  | 2 +-
 drivers/usb/gadget/function/f_obex.c | 3 ++-
 drivers/usb/gadget/function/f_phonet.c   | 2 +-
 drivers/usb/gadget/function/f_printer.c  | 2 +-
 drivers/usb/gadget/function/f_rndis.c| 2 +-
 drivers/usb/gadget/function/f_serial.c   | 2 +-
 drivers/usb/gadget/function/f_sourcesink.c   | 2 +-
 drivers/usb/gadget/function/f_subset.c   | 2 +-
 drivers/usb/gadget/function/f_tcm.c  | 2 +-
 drivers/usb/gadget/function/f_uac1.c | 3 ++-
 drivers/usb/gadget/function/f_uac2.c | 3 ++-
 include/linux/usb/gadget.h   | 3 ++-
 19 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index 0fafa7a..62ba4c1 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -163,7 +163,8 @@ EXPORT_SYMBOL_GPL(usb_copy_descriptors);
 int usb_assign_descriptors(struct usb_function *f,
struct usb_descriptor_header **fs,
struct usb_descriptor_header **hs,
-   struct usb_descriptor_header **ss)
+   struct usb_descriptor_header **ss,
+   struct usb_descriptor_header **ssp)
 {
struct usb_gadget *g = f->config->cdev->gadget;
 
diff --git a/drivers/usb/gadget/function/f_acm.c 
b/drivers/usb/gadget/function/f_acm.c
index 2fa1e80..dc13b28 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -685,7 +685,7 @@ acm_bind(struct usb_configuration *c, struct usb_function 
*f)
acm_ss_out_desc.bEndpointAddress = acm_fs_out_desc.bEndpointAddress;
 
status = usb_assign_descriptors(f, acm_fs_function, acm_hs_function,
-   acm_ss_function);
+   acm_ss_function, NULL);
if (status)
goto fail;
 
diff --git a/drivers/usb/gadget/function/f_ecm.c 
b/drivers/usb/gadget/function/f_ecm.c
index 7ad60ee..4c488d1 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -786,7 +786,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
fs_ecm_notify_desc.bEndpointAddress;
 
status = usb_assign_descriptors(f, ecm_fs_function, ecm_hs_function,
-   ecm_ss_function);
+   ecm_ss_function, NULL);
if (status)
goto fail;
 
diff --git a/drivers/usb/gadget/function/f_eem.c 
b/drivers/usb/gadget/function/f_eem.c
index cad35a5..d58bfc3 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -309,7 +309,7 @@ static int eem_bind(struct usb_configuration *c, struct 
usb_function *f)
eem_ss_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress;
 
status = usb_assign_descriptors(f, eem_fs_function, eem_hs_function,
-   eem_ss_function);
+   eem_ss_function, NULL);
if (status)
goto fail;
 
diff --git a/drivers/usb/gadget/function/f_hid.c 
b/drivers/usb/gadget/function/f_hid.c
index 99285b4..51980c5 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -646,7 +646,7 @@ static int hidg_bind(struct usb_configuration *c, struct 
usb_function *f)
hidg_fs_out_ep_desc.bEndpointAddress;
 
status = usb_assign_descriptors(f, hidg_fs_descriptors,
-   hidg_hs_descriptors, NULL);
+   hidg_hs_descriptors, NULL, NULL);
if (status)
goto fail;
 
diff --git a/drivers/usb/gadget/function/f_loopback.c 
b/drivers/usb/gadget/function/f_loopback.c
index ddc3aad..3a9f8f9 100644
--- a/drivers/usb/gadget/function/f_loopback.c
+++ b/drivers/usb/gadget/function/f_loopback.c
@@ -211,7 +211,7 @@ autoconf_fail:
ss_loop_sink_desc.bEndpointAddress = fs_loop_sink_desc.bEndpointAddress;
 
ret = usb_assign_descriptors(f, fs_loopback_descs, hs_loopback_descs,
-   ss_loopback_descs);
+   ss_loopback_descs, NULL);
if (ret)
return ret;
 
diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index 223ccf8..321a631 100644
--- a/drive

[PATCH v3 10/19] usb: gadget: composite: Add function to get descriptors

2016-02-05 Thread John Youn
There are a couple places in the code that get the function descriptors
based on the speed. Move this lookup into a function call and add
support to handle the SuperSpeedPlus descriptors as well.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 53 +-
 1 file changed, 32 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 44ad7aa..1d4f324 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -54,6 +54,36 @@ static struct usb_gadget_strings **get_containers_gs(
 }
 
 /**
+ * function_descriptors() - get function descriptors for speed
+ * @f: the function
+ * @speed: the speed
+ *
+ * Returns the descriptors or NULL if not set.
+ */
+static struct usb_descriptor_header **
+function_descriptors(struct usb_function *f,
+enum usb_device_speed speed)
+{
+   struct usb_descriptor_header **descriptors;
+
+   switch (speed) {
+   case USB_SPEED_SUPER_PLUS:
+   descriptors = f->ssp_descriptors;
+   break;
+   case USB_SPEED_SUPER:
+   descriptors = f->ss_descriptors;
+   break;
+   case USB_SPEED_HIGH:
+   descriptors = f->hs_descriptors;
+   break;
+   default:
+   descriptors = f->fs_descriptors;
+   }
+
+   return descriptors;
+}
+
+/**
  * next_ep_desc() - advance to the next EP descriptor
  * @t: currect pointer within descriptor array
  *
@@ -419,17 +449,7 @@ static int config_buf(struct usb_configuration *config,
list_for_each_entry(f, &config->functions, list) {
struct usb_descriptor_header **descriptors;
 
-   switch (speed) {
-   case USB_SPEED_SUPER:
-   descriptors = f->ss_descriptors;
-   break;
-   case USB_SPEED_HIGH:
-   descriptors = f->hs_descriptors;
-   break;
-   default:
-   descriptors = f->fs_descriptors;
-   }
-
+   descriptors = function_descriptors(f, speed);
if (!descriptors)
continue;
status = usb_descriptor_fillbuf(next, len,
@@ -740,16 +760,7 @@ static int set_config(struct usb_composite_dev *cdev,
 * function's setup callback instead of the current
 * configuration's setup callback.
 */
-   switch (gadget->speed) {
-   case USB_SPEED_SUPER:
-   descriptors = f->ss_descriptors;
-   break;
-   case USB_SPEED_HIGH:
-   descriptors = f->hs_descriptors;
-   break;
-   default:
-   descriptors = f->fs_descriptors;
-   }
+   descriptors = function_descriptors(f, gadget->speed);
 
for (; *descriptors; ++descriptors) {
struct usb_endpoint_descriptor *ep;
-- 
2.6.3

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


[PATCH v3 11/19] usb: gadget: composite: Write SuperSpeedPlus config descriptors

2016-02-05 Thread John Youn
Enable writing of SuperSpeedPlus descriptors for any SuperSpeedPlus
capable configuration when connected in SuperSpeedPlus.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 1d4f324..b938fcf 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -473,7 +473,7 @@ static int config_desc(struct usb_composite_dev *cdev, 
unsigned w_value)
u8  type = w_value >> 8;
enum usb_device_speed   speed = USB_SPEED_UNKNOWN;
 
-   if (gadget->speed == USB_SPEED_SUPER)
+   if (gadget->speed >= USB_SPEED_SUPER)
speed = gadget->speed;
else if (gadget_is_dualspeed(gadget)) {
int hs = 0;
@@ -504,6 +504,10 @@ static int config_desc(struct usb_composite_dev *cdev, 
unsigned w_value)
 check_config:
/* ignore configs that won't work at this speed */
switch (speed) {
+   case USB_SPEED_SUPER_PLUS:
+   if (!c->superspeed_plus)
+   continue;
+   break;
case USB_SPEED_SUPER:
if (!c->superspeed)
continue;
-- 
2.6.3

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


[PATCH v3 12/19] usb: gadget: composite: Configure the usb_ep for SuperSpeedPlus

2016-02-05 Thread John Youn
Configure the usb_ep using the SuperSpeedPlus descriptors if connected
in SuperSpeedPlus.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index b938fcf..60b6e4b 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -148,6 +148,13 @@ int config_ep_by_speed(struct usb_gadget *g,
 
/* select desired speed */
switch (g->speed) {
+   case USB_SPEED_SUPER_PLUS:
+   if (gadget_is_superspeed_plus(g)) {
+   speed_desc = f->ssp_descriptors;
+   want_comp_desc = 1;
+   break;
+   }
+   /* else: Fall trough */
case USB_SPEED_SUPER:
if (gadget_is_superspeed(g)) {
speed_desc = f->ss_descriptors;
@@ -191,7 +198,7 @@ ep_found:
(comp_desc->bDescriptorType != USB_DT_SS_ENDPOINT_COMP))
return -EIO;
_ep->comp_desc = comp_desc;
-   if (g->speed == USB_SPEED_SUPER) {
+   if (g->speed >= USB_SPEED_SUPER) {
switch (usb_endpoint_type(_ep->desc)) {
case USB_ENDPOINT_XFER_ISOC:
/* mult: bits 1:0 of bmAttributes */
-- 
2.6.3

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


[PATCH v3 13/19] usb: gadget: composite: Update debug message for SuperSpeedPlus

2016-02-05 Thread John Youn
Update the debug message reporting the speeds that a configuration
supports for SuperSpeedPlus.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/composite.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 60b6e4b..64ad1be 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -891,8 +891,9 @@ int usb_add_config(struct usb_composite_dev *cdev,
} else {
unsignedi;
 
-   DBG(cdev, "cfg %d/%p speeds:%s%s%s\n",
+   DBG(cdev, "cfg %d/%p speeds:%s%s%s%s\n",
config->bConfigurationValue, config,
+   config->superspeed_plus ? " superplus" : "",
config->superspeed ? " super" : "",
config->highspeed ? " high" : "",
config->fullspeed
-- 
2.6.3

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


[PATCH v3 16/19] usb: dwc3: Update register fields for SuperSpeedPlus

2016-02-05 Thread John Youn
Update various registers fields definitions for the DWC_usb31 controller
for SuperSpeedPlus support.

Signed-off-by: John Youn 
---
 drivers/usb/dwc3/core.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 15281c1..6b13ea4 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -223,7 +223,8 @@
 /* Global HWPARAMS3 Register */
 #define DWC3_GHWPARAMS3_SSPHY_IFC(n)   ((n) & 3)
 #define DWC3_GHWPARAMS3_SSPHY_IFC_DIS  0
-#define DWC3_GHWPARAMS3_SSPHY_IFC_ENA  1
+#define DWC3_GHWPARAMS3_SSPHY_IFC_GEN1 1
+#define DWC3_GHWPARAMS3_SSPHY_IFC_GEN2 2 /* DWC_usb31 only */
 #define DWC3_GHWPARAMS3_HSPHY_IFC(n)   (((n) & (3 << 2)) >> 2)
 #define DWC3_GHWPARAMS3_HSPHY_IFC_DIS  0
 #define DWC3_GHWPARAMS3_HSPHY_IFC_UTMI 1
@@ -249,6 +250,7 @@
 #define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f)
 
 #define DWC3_DCFG_SPEED_MASK   (7 << 0)
+#define DWC3_DCFG_SUPERSPEED_PLUS (5 << 0)  /* DWC_usb31 only */
 #define DWC3_DCFG_SUPERSPEED   (4 << 0)
 #define DWC3_DCFG_HIGHSPEED(0 << 0)
 #define DWC3_DCFG_FULLSPEED2   (1 << 0)
@@ -339,6 +341,7 @@
 
 #define DWC3_DSTS_CONNECTSPD   (7 << 0)
 
+#define DWC3_DSTS_SUPERSPEED_PLUS  (5 << 0) /* DWC_usb31 only */
 #define DWC3_DSTS_SUPERSPEED   (4 << 0)
 #define DWC3_DSTS_HIGHSPEED(0 << 0)
 #define DWC3_DSTS_FULLSPEED2   (1 << 0)
-- 
2.6.3

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


[PATCH v3 15/19] usb: dwc3: DWC_usb31 controller check

2016-02-05 Thread John Youn
Add a convenience function to check if the controller is DWC_usb31.

Signed-off-by: John Youn 
---
 drivers/usb/dwc3/core.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 2913068..15281c1 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -1025,6 +1025,12 @@ struct dwc3_gadget_ep_cmd_params {
 void dwc3_set_mode(struct dwc3 *dwc, u32 mode);
 int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc);
 
+/* check whether we are on the DWC_usb31 core */
+static inline bool dwc3_is_usb31(struct dwc3 *dwc)
+{
+   return !!(dwc->revision & DWC3_REVISION_IS_DWC31);
+}
+
 #if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
 int dwc3_host_init(struct dwc3 *dwc);
 void dwc3_host_exit(struct dwc3 *dwc);
-- 
2.6.3

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


[PATCH v3 14/19] usb: gadget: f_mass_storage: Enable SuperSpeedPlus

2016-02-05 Thread John Youn
Enable superspeed plus configuration for the mass storage gadget.

The mass storage function doesn't do anything special for
SuperSpeedPlus. Just pass in the same SuperSpeed descriptors for
SuperSpeedPlus.

Signed-off-by: John Youn 
---
 drivers/usb/gadget/function/f_mass_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index 321a631..ee9390b 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -3093,7 +3093,7 @@ static int fsg_bind(struct usb_configuration *c, struct 
usb_function *f)
fsg_ss_bulk_out_comp_desc.bMaxBurst = max_burst;
 
ret = usb_assign_descriptors(f, fsg_fs_function, fsg_hs_function,
-   fsg_ss_function, NULL);
+   fsg_ss_function, fsg_ss_function);
if (ret)
goto autoconf_fail;
 
-- 
2.6.3

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


[PATCH v3 19/19] usb: dwc3: Enable SuperSpeedPlus

2016-02-05 Thread John Youn
Enable SuperSpeedPlus by programming the DCFG.speed and after
enumerating, set gadget->speed appropriately.

Signed-off-by: John Youn 
---
 drivers/usb/dwc3/gadget.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 73db723..5bbdf5d 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1629,6 +1629,9 @@ static int dwc3_gadget_start(struct usb_gadget *g,
case USB_SPEED_HIGH:
reg |= DWC3_DSTS_HIGHSPEED;
break;
+   case USB_SPEED_SUPER_PLUS:
+   reg |= DWC3_DSTS_SUPERSPEED_PLUS;
+   break;
case USB_SPEED_SUPER:   /* FALLTHROUGH */
case USB_SPEED_UNKNOWN: /* FALTHROUGH */
default:
@@ -2337,6 +2340,11 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 
*dwc)
dwc3_update_ram_clk_sel(dwc, speed);
 
switch (speed) {
+   case DWC3_DCFG_SUPERSPEED_PLUS:
+   dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);
+   dwc->gadget.ep0->maxpacket = 512;
+   dwc->gadget.speed = USB_SPEED_SUPER_PLUS;
+   break;
case DWC3_DCFG_SUPERSPEED:
/*
 * WORKAROUND: DWC3 revisions <1.90a have an issue which
-- 
2.6.3

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


[PATCH v3 17/19] usb: dwc3: Update speed checks for SuperSpeedPlus

2016-02-05 Thread John Youn
Update various places where the speed is checked so that it takes into
account SuperSpeedPlus properly.

Signed-off-by: John Youn 
---
 drivers/usb/dwc3/ep0.c|  9 ++---
 drivers/usb/dwc3/gadget.c | 13 -
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 3a9354a..0f1497c 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -356,7 +356,8 @@ static int dwc3_ep0_handle_status(struct dwc3 *dwc,
 */
usb_status |= dwc->gadget.is_selfpowered;
 
-   if (dwc->speed == DWC3_DSTS_SUPERSPEED) {
+   if ((dwc->speed == DWC3_DSTS_SUPERSPEED) ||
+   (dwc->speed == DWC3_DSTS_SUPERSPEED_PLUS)) {
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
if (reg & DWC3_DCTL_INITU1ENA)
usb_status |= 1 << USB_DEV_STAT_U1_ENABLED;
@@ -426,7 +427,8 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
case USB_DEVICE_U1_ENABLE:
if (state != USB_STATE_CONFIGURED)
return -EINVAL;
-   if (dwc->speed != DWC3_DSTS_SUPERSPEED)
+   if ((dwc->speed != DWC3_DSTS_SUPERSPEED) &&
+   (dwc->speed != DWC3_DSTS_SUPERSPEED_PLUS))
return -EINVAL;
 
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
@@ -440,7 +442,8 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
case USB_DEVICE_U2_ENABLE:
if (state != USB_STATE_CONFIGURED)
return -EINVAL;
-   if (dwc->speed != DWC3_DSTS_SUPERSPEED)
+   if ((dwc->speed != DWC3_DSTS_SUPERSPEED) &&
+   (dwc->speed != DWC3_DSTS_SUPERSPEED_PLUS))
return -EINVAL;
 
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 7d1dd82..73db723 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -421,7 +421,7 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, 
struct dwc3_ep *dep,
| DWC3_DEPCFG_MAX_PACKET_SIZE(usb_endpoint_maxp(desc));
 
/* Burst size is only needed in SuperSpeed mode */
-   if (dwc->gadget.speed == USB_SPEED_SUPER) {
+   if (dwc->gadget.speed >= USB_SPEED_SUPER) {
u32 burst = dep->endpoint.maxburst - 1;
 
params.param0 |= DWC3_DEPCFG_BURST_SIZE(burst);
@@ -1403,7 +1403,8 @@ static int dwc3_gadget_wakeup(struct usb_gadget *g)
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
 
speed = reg & DWC3_DSTS_CONNECTSPD;
-   if (speed == DWC3_DSTS_SUPERSPEED) {
+   if ((speed == DWC3_DSTS_SUPERSPEED) ||
+   (speed == DWC3_DSTS_SUPERSPEED_PLUS)) {
dwc3_trace(trace_dwc3_gadget, "no wakeup on SuperSpeed\n");
ret = -EINVAL;
goto out;
@@ -2306,7 +2307,8 @@ static void dwc3_update_ram_clk_sel(struct dwc3 *dwc, u32 
speed)
 * this. Maybe it becomes part of the power saving plan.
 */
 
-   if (speed != DWC3_DSTS_SUPERSPEED)
+   if ((speed != DWC3_DSTS_SUPERSPEED) &&
+   (speed != DWC3_DSTS_SUPERSPEED_PLUS))
return;
 
/*
@@ -2376,8 +2378,9 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 
*dwc)
 
/* Enable USB2 LPM Capability */
 
-   if ((dwc->revision > DWC3_REVISION_194A)
-   && (speed != DWC3_DCFG_SUPERSPEED)) {
+   if ((dwc->revision > DWC3_REVISION_194A) &&
+   (speed != DWC3_DCFG_SUPERSPEED) &&
+   (speed != DWC3_DCFG_SUPERSPEED_PLUS)) {
reg = dwc3_readl(dwc->regs, DWC3_DCFG);
reg |= DWC3_DCFG_LPM_CAP;
dwc3_writel(dwc->regs, DWC3_DCFG, reg);
-- 
2.6.3

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


[PATCH v3 18/19] usb: dwc3: Update maximum_speed for SuperSpeedPlus

2016-02-05 Thread John Youn
If the maximum_speed is not set, set it to a known value, either
SuperSpeed or SuperSpeedPlus based on the type of controller we are
using. If we are on DWC_usb31 controller, check the PHY interface to see
if it is capable of SuperSpeedPlus.

Also this check is moved after dwc3_core_init() so that we can check
dwc->revision.

Signed-off-by: John Youn 
---
 drivers/usb/dwc3/core.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index de5e01f..001c755 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -962,10 +962,6 @@ static int dwc3_probe(struct platform_device *pdev)
fladj = pdata->fladj_value;
}
 
-   /* default to superspeed if no maximum_speed passed */
-   if (dwc->maximum_speed == USB_SPEED_UNKNOWN)
-   dwc->maximum_speed = USB_SPEED_SUPER;
-
dwc->lpm_nyet_threshold = lpm_nyet_threshold;
dwc->tx_de_emphasis = tx_de_emphasis;
 
@@ -1016,6 +1012,19 @@ static int dwc3_probe(struct platform_device *pdev)
goto err1;
}
 
+   /* default to superspeed if no maximum_speed passed */
+   if (dwc->maximum_speed == USB_SPEED_UNKNOWN) {
+   dwc->maximum_speed = USB_SPEED_SUPER;
+
+   /*
+* default to superspeed plus if we are capable.
+*/
+   if (dwc3_is_usb31(dwc) &&
+   (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) ==
+DWC3_GHWPARAMS3_SSPHY_IFC_GEN2))
+   dwc->maximum_speed = USB_SPEED_SUPER_PLUS;
+   }
+
/* Adjust Frame Length */
dwc3_frame_length_adjustment(dwc, fladj);
 
-- 
2.6.3

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