platform/kernel/linux-rpi.git
11 years agousb: gadget: f_obex: fix error return code in obex_bind()
Wei Yongjun [Sat, 6 Apr 2013 04:39:49 +0000 (12:39 +0800)]
usb: gadget: f_obex: fix error return code in obex_bind()

Fix to return a negative error code from the error handling
case instead of 0, as returned elsewhere in this function.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: nokia: include f_ecm.c
Felipe Balbi [Wed, 3 Apr 2013 18:01:44 +0000 (21:01 +0300)]
usb: gadget: nokia: include f_ecm.c

recent changes to gadget framework have
exposed a flaw in nokia.c where it uses
f_ecm.c but it wasn't including it like
other gadget drivers.

This is a temporary patch until all other
function drivers are converted to new API
where each function driver becomes a module
and binding is done through configfs.

Solves a linking error when building g_nokia.ko

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: twl6030-usb: check regulator_enable return value
Fabio Baltieri [Wed, 3 Apr 2013 14:02:27 +0000 (16:02 +0200)]
usb: phy: twl6030-usb: check regulator_enable return value

Since regulator_enable() is going to be marked as __must_check in the
next merge window, always check regulator_enable() return value and
print a warning if it fails.

Cc: Hema HK <hemahk@ti.com>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: twl4030-usb: check regulator_enable return value
Fabio Baltieri [Wed, 3 Apr 2013 14:02:26 +0000 (16:02 +0200)]
usb: phy: twl4030-usb: check regulator_enable return value

Since regulator_enable() is going to be marked as __must_check in the
next merge window, always check regulator_enable() return value and
print a warning if it fails.

Reviewed-by: Kalle Jokiniemi <kalle.jokiniemi@jollamobile.com>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: ab8500-usb: check regulator_enable return value
Fabio Baltieri [Wed, 3 Apr 2013 14:02:25 +0000 (16:02 +0200)]
usb: phy: ab8500-usb: check regulator_enable return value

Since regulator_enable() is going to be marked as __must_check in the
next merge window, always check regulator_enable() return value and
print a warning if it fails.

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: f_obex: add configfs support
Andrzej Pietrasiewicz [Wed, 27 Mar 2013 11:13:25 +0000 (12:13 +0100)]
usb: gadget: f_obex: add configfs support

f_obex learns about our new configfs-based interface,
which will allow gadgets to be bound to controllers
through userland.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: serial: convert to new interface of f_obex
Andrzej Pietrasiewicz [Thu, 21 Mar 2013 08:22:30 +0000 (09:22 +0100)]
usb: gadget: serial: convert to new interface of f_obex

f_obex is now a self-contained module. We need to teach
serial.c about it.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: f_obex: convert to new function interface with backward compatibility
Andrzej Pietrasiewicz [Thu, 21 Mar 2013 14:33:42 +0000 (15:33 +0100)]
usb: gadget: f_obex: convert to new function interface with backward compatibility

Converting f_obex to the new function interface requires converting
the f_obex's function code and its users.

This patch converts the f_obex.c to the new function interface.
The file is now compiled into a separate usb_f_obex.ko module.

The old function interface is provided by means of preprocessor
conditional directives. After all users are converted, the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: f_serial: add configfs support
Andrzej Pietrasiewicz [Wed, 27 Mar 2013 08:12:03 +0000 (09:12 +0100)]
usb: gadget: f_serial: add configfs support

this patch implements the new configfs based interface
on f_serial function driver.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: f_serial: remove compatibility layer
Andrzej Pietrasiewicz [Thu, 14 Mar 2013 15:14:26 +0000 (16:14 +0100)]
usb: gadget: f_serial: remove compatibility layer

There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: serial: convert to new interface of f_serial
Andrzej Pietrasiewicz [Thu, 14 Mar 2013 15:02:12 +0000 (16:02 +0100)]
usb: gadget: serial: convert to new interface of f_serial

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: f_serial: convert to new function interface with backward compatibility
Andrzej Pietrasiewicz [Mon, 18 Mar 2013 08:52:57 +0000 (09:52 +0100)]
usb: gadget: f_serial: convert to new function interface with backward compatibility

Converting f_serial to the new function interface requires converting
the f_serial's function code and its users.

This patch converts the f_serial.c to the new function interface.

The file is now compiled into a separate usb_f_serial.ko module.
The old function interface is provided by means of preprocessor
conditional directives. After all users are converted, the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: nokia: remove unused include
Andrzej Pietrasiewicz [Thu, 14 Mar 2013 15:11:57 +0000 (16:11 +0100)]
usb: gadget: nokia: remove unused include

f_serial.c isn't necessary in nokia.c, we can
safely remove it.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: use consistent naming scheme for usb function modules
Andrzej Pietrasiewicz [Thu, 7 Feb 2013 13:36:27 +0000 (14:36 +0100)]
usb: gadget: use consistent naming scheme for usb function modules

In order to convert to configfs the USB functions need to be converted
to the new interface from Sebastian, which also requires turning them
into separate modules. Some of these modules will consist of just
one object file, e.g. f_ncm.o. But some of the modules will eventually
consist of more than one object file, e.g. for mass storage there
will be f_mass_storage.o and storage_common.o. The resulting module
cannot be called f_mass_storage.ko due to cyclic dependency. This patch
introduces a naming scheme for the said resulting modules:

usb_f_xxxxxx.ko

e.g. usb_f_mass_storage.ko, usb_f_ss_lb.ko, usb_f_rndis.ko etc.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: the start of the configfs interface
Sebastian Andrzej Siewior [Sun, 23 Dec 2012 20:10:24 +0000 (21:10 +0100)]
usb: gadget: the start of the configfs interface

|# modprobe dummy_hcd num=2
|# modprobe libcomposite

|# lsmod
|Module                  Size  Used by
|libcomposite           31648  0
|dummy_hcd              19871  0

|# mkdir /sys/kernel/config/usb_gadget/oha
|# cd /sys/kernel/config/usb_gadget/oha
|# mkdir configs/def.1
|# mkdir configs/def.2
|# mkdir functions/acm.ttyS1
|# mkdir strings/0x1
|mkdir: cannot create directory `strings/0x1': Invalid argument
|# mkdir strings/0x409
|# mkdir strings/1033
|mkdir: cannot create directory `strings/1033': File exists
|# mkdir strings/1032
|# mkdir configs/def.1/strings/0x409
|# mkdir configs/def.2/strings/0x409

|#find . -ls
|   975    0 drwxr-xr-x   5 root     root            0 Dec 23 17:40 .
|   978    0 drwxr-xr-x   4 root     root            0 Dec 23 17:43 ./strings
|  4100    0 drwxr-xr-x   2 root     root            0 Dec 23 17:43 ./strings/1032
|   995    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./strings/1032/serialnumber
|   996    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./strings/1032/product
|   997    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./strings/1032/manufacturer
|  2002    0 drwxr-xr-x   2 root     root            0 Dec 23 17:41 ./strings/0x409
|   998    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./strings/0x409/serialnumber
|   999    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./strings/0x409/product
|  1000    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./strings/0x409/manufacturer
|   977    0 drwxr-xr-x   4 root     root            0 Dec 23 17:41 ./configs
|  4081    0 drwxr-xr-x   3 root     root            0 Dec 23 17:41 ./configs/def.2
|  4082    0 drwxr-xr-x   3 root     root            0 Dec 23 17:42 ./configs/def.2/strings
|  2016    0 drwxr-xr-x   2 root     root            0 Dec 23 17:42 ./configs/def.2/strings/0x409
|  1001    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./configs/def.2/strings/0x409/configuration
|  1002    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./configs/def.2/bmAttributes
|  1003    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./configs/def.2/MaxPower
|   979    0 drwxr-xr-x   3 root     root            0 Dec 23 17:42 ./configs/def.1
|   980    0 drwxr-xr-x   3 root     root            0 Dec 23 17:42 ./configs/def.1/strings
|  5122    0 drwxr-xr-x   2 root     root            0 Dec 23 17:42 ./configs/def.1/strings/0x409
|  1004    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./configs/def.1/strings/0x409/configuration
|  1005    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./configs/def.1/bmAttributes
|  1006    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./configs/def.1/MaxPower
|   976    0 drwxr-xr-x   3 root     root            0 Dec 23 17:41 ./functions
|   981    0 drwxr-xr-x   2 root     root            0 Dec 23 17:41 ./functions/acm.ttyS1
|  1007    0 -r--r--r--   1 root     root         4096 Dec 23 17:43 ./functions/acm.ttyS1/port_num
|  1008    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./UDC
|  1009    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./bcdUSB
|  1010    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./bcdDevice
|  1011    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./idProduct
|  1012    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./idVendor
|  1013    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./bMaxPacketSize0
|  1014    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./bDeviceProtocol
|  1015    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./bDeviceSubClass
|  1016    0 -rw-r--r--   1 root     root         4096 Dec 23 17:43 ./bDeviceClass

|# cat functions/acm.ttyS1/port_num
|0
|# ls -lah /dev/ttyGS*
|crw-rw---T 1 root dialout 252, 0 Dec 23 17:41 /dev/ttyGS0
|
|# echo 0x1234 > idProduct
|# echo 0xabcd > idVendor
|# echo 1122 > strings/0x409/serialnumber
|# echo "The manufacturer" > strings/0x409/manufacturer
|# echo 1 > strings/1032/manufacturer
|# echo 1sa > strings/1032/product
|# echo tada > strings/1032/serialnumber
|echo "Primary configuration" > configs/def.1/strings/0x409/configuration
|# echo "Secondary configuration" > configs/def.2/strings/0x409/configuration
|# ln -s functions/acm.ttyS1 configs/def.1/
|# ln -s functions/acm.ttyS1 configs/def.2/
|find configs/def.1/ -ls
|   979    0 drwxr-xr-x   3 root     root            0 Dec 23 17:49 configs/def.1/
|  6264    0 lrwxrwxrwx   1 root     root            0 Dec 23 17:48 configs/def.1/acm.ttyS1 -> ../../../../usb_gadget/oha/functions/acm.ttyS1
|   980    0 drwxr-xr-x   3 root     root            0 Dec 23 17:42 configs/def.1/strings
|  5122    0 drwxr-xr-x   2 root     root            0 Dec 23 17:49 configs/def.1/strings/0x409
|  6284    0 -rw-r--r--   1 root     root         4096 Dec 23 17:47 configs/def.1/strings/0x409/configuration
|  6285    0 -rw-r--r--   1 root     root         4096 Dec 23 17:49 configs/def.1/bmAttributes
|  6286    0 -rw-r--r--   1 root     root         4096 Dec 23 17:49 configs/def.1/MaxPower
|
|echo 120 > configs/def.1/MaxPower
|
|# ls -lh /sys/class/udc/
|total 0
|lrwxrwxrwx 1 root root 0 Dec 23 17:50 dummy_udc.0 -> ../../devices/platform/dummy_udc.0/udc/dummy_udc.0
|lrwxrwxrwx 1 root root 0 Dec 23 17:50 dummy_udc.1 -> ../../devices/platform/dummy_udc.1/udc/dummy_udc.1
|# echo dummy_udc.0 > UDC
|# lsusb
|Bus 001 Device 002: ID abcd:1234 Unknown
|
|lsusb -d abcd:1234 -v
|Device Descriptor:

|  idVendor           0xabcd Unknown
|  idProduct          0x1234
|  bcdDevice            3.06
|  iManufacturer           1 The manufacturer
|  iProduct                2
|  iSerial                 3 1122
|  bNumConfigurations      2

|echo "" > UDC

v5…v6
- wired up strings with usb_gstrings_attach()
- add UDC attribe. Write "udc-name" will bind the gadget. Write an empty
  string (it should contain \n since 0 bytes write get optimzed away)
  will unbind the UDC from the gadget. The name of available UDCs can be
  obtained from /sys/class/udc/

v4…v5
- string rework. This will add a strings folder incl. language code like
    strings/409/manufacturer
  as suggested by Alan.
- rebased ontop reworked functions.c which has usb_function_instance
  which is used prior after "mkdir acm.instance" and can be directly
  used for configuration via configfs.

v3…v4
 - moved functions from the root folde down to the gadget as suggested
   by Michał
 - configs have now their own configs folder as suggested by Michał.
   The folder is still name.bConfigurationValue where name becomes the
   sConfiguration. Is this usefull should we just stilc
   configs/bConfigurationValue/ ?
 - added configfs support to the ACM function. The port_num attribute is
   exported by f_acm. An argument has been added to the USB alloc
   function to distinguish between "old" (use facm_configure() to
   configure and configfs interface (expose a config_node).
   The port_num is currently a dumb counter. It will
   require some function re-work to make it work.

scheduled for v5:
- sym linking function into config.

v2…v3
- replaced one ifndef by ifdef as suggested by Micahał
- strstr()/strchr() function_make as suggested by Micahł
- replace [iSerialNumber|iProduct|iManufacturer] with
  [sSerialNumber|sProduct|sManufacturer] as suggested by Alan
- added creation of config descriptors

v1…v2
- moved gadgets from configfs' root directory into /udcs/ within our
  "usb_gadget" folder. Requested by Andrzej & Michał
- use a dot as a delimiter between function's name and its instance's name
  as suggested by Michał
- renamed all config_item_type, configfs_group_operations, make_group,
  drop_item as suggested by suggested by Andrzej to remain consisten
  within this file and within other configfs users
- Since configfs.c and functions.c are now part of the udc-core module,
  the module itself is now called udc. Also added a tiny ifdef around
  init code becuase udc-core is subsys init and this is too early for
  configfs in the built-in case. In the module case, we can only have
  one init function.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: push tty port allocation from gadget into f_acm
Sebastian Andrzej Siewior [Sun, 23 Dec 2012 20:10:18 +0000 (21:10 +0100)]
usb: gadget: push tty port allocation from gadget into f_acm

It possible to allocate the tty port number within the "instance"
structure of the function and there is no need to expose this
information within the gadget and therefore it is removed here.
This patch converts only f_acm and all its users. The other gadgets will
follow once the function is converted to the function interface.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: move the global the_dev variable to their users
Sebastian Andrzej Siewior [Sun, 23 Dec 2012 20:10:12 +0000 (21:10 +0100)]
usb: gadget: move the global the_dev variable to their users

the u_ether.c file has a global variable named the_dev which keeps a
pointer to the network device after it has been created via
gether_setup_name(). It is only used internally by u_ether. This patches
moves the variable to its users and passes it via the port.ioport where
it is saved later anyway.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: nokia: use function framework for ACM
Sebastian Andrzej Siewior [Fri, 25 Jan 2013 13:09:17 +0000 (14:09 +0100)]
usb: gadget: nokia: use function framework for ACM

This patch converts the acm_ms gadget to make use of the function
framework to request the ACM function.

The "old" include interface for acm is now removed since nokia was the
last user of it (for ACM).

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: ab8500-usb: call phy_dis_work only when necessary
Sakethram Bommisetti [Wed, 3 Apr 2013 08:45:13 +0000 (10:45 +0200)]
usb: phy: ab8500-usb: call phy_dis_work only when necessary

Modify ab8500_usb_set_peripheral() and ab8500_usb_set_host() code to
schedule phy_dis_work only when necessary in order to prevent regulator
count mismatch during reboot/shutdown.

Signed-off-by: Sakethram Bommisetti <sakethram.bommisetti@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: ab8500-usb: drop link status delayed work
Sakethram Bommisetti [Wed, 3 Apr 2013 08:45:12 +0000 (10:45 +0200)]
usb: phy: ab8500-usb: drop link status delayed work

ab8500_usb_delayed_work was implemented as a workaroud for the internal
only and now unsupported v1.0 version of AB850.  This patch removes the
delayed work and just leave a link status update call at probe time.

Signed-off-by: Sakethram Bommisetti <sakethram.bommisetti@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: ab8500-usb: adopt pinctrl support
Patrice Chotard [Wed, 3 Apr 2013 08:45:11 +0000 (10:45 +0200)]
usb: phy: ab8500-usb: adopt pinctrl support

Amend the ab8500-usb driver to optionally take a pin control handle and
set the state of the pins to "default" on ab8500_usb_phy_enable and to
"sleep" on ab8500_usb_phy_disable.

The pinctrl handle is released on ab8500_usb_phy_disable because USB
pins are shared with ab8505_micro_usb_iddet driver.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: ab8500-usb: fix last notifier arguments
Fabio Baltieri [Wed, 3 Apr 2013 08:45:10 +0000 (10:45 +0200)]
usb: phy: ab8500-usb: fix last notifier arguments

Fix last ab->phy.notifier call to use vbus_draw as notifier argument, as
that's used in ab8500_charger to control charging current.

Also drop a related TODO comment, and the additional
ux500_musb_set_vbus(musb, 0), as with this patch it was causing an
erratic behaviour of gadget ep0 state machine.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: ab8500-usb: fix unbalanced clock and regulator disable warnings
Mian Yousaf Kaukab [Wed, 3 Apr 2013 08:45:09 +0000 (10:45 +0200)]
usb: phy: ab8500-usb: fix unbalanced clock and regulator disable warnings

To prevent clock and regulator frameworks from complaining, only disable
the host or peripheral phy if they were enabled.

Reported-by: Sakethram Bommisetti <sakethram.bommisetti@stericsson.com>
Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: ab8500-usb: enable/disable regulator on phy events
Fabio Baltieri [Wed, 3 Apr 2013 08:45:08 +0000 (10:45 +0200)]
usb: phy: ab8500-usb: enable/disable regulator on phy events

Add ab8500_usb_regulator_{enable,disable} functions to control USB phy
regulators on corresponding ab8500_usb_phy_{enable,disable} events.

This contains some workaround and optimization for specific AB8500
versions.

Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
Signed-off-by: Sakethram Bommisetti <sakethram.bommisetti@stericsson.com>
Signed-off-by: Praveena Nadahally <praveen.nadahally@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: ab8500-usb: split ab8500_usb_phy_ctrl
Fabio Baltieri [Wed, 3 Apr 2013 08:45:07 +0000 (10:45 +0200)]
usb: phy: ab8500-usb: split ab8500_usb_phy_ctrl

Split ab8500_usb_phy_ctrl into separate enable/disable functions to make
the code more linear and readable.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: ab8500-usb: add regulator support
Fabio Baltieri [Wed, 3 Apr 2013 08:45:06 +0000 (10:45 +0200)]
usb: phy: ab8500-usb: add regulator support

Add initial regulator support to ab8500-usb by introducing necessary
devm_regulator_get().

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: ab8500-usb: fix eye diagram for ab8500 v2.0
Sakethram Bommisetti [Wed, 3 Apr 2013 08:45:05 +0000 (10:45 +0200)]
usb: phy: ab8500-usb: fix eye diagram for ab8500 v2.0

AB8500 v2.0 has eye diagram issues when drawing more than 100mA from
VBUS.  Force charging current to 100mA in case of standard host.

Signed-off-by: Sakethram Bommisetti <sakethram.bommisetti@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: ab8500-usb: set phy tuning values
Sakethram Bommisetti [Wed, 3 Apr 2013 08:45:04 +0000 (10:45 +0200)]
usb: phy: ab8500-usb: set phy tuning values

Set phy tuning values proposed by the hardware teams for AB8500 and
AB8505 to improve USB eye diagram performances.

Signed-off-by: Sakethram Bommisetti <sakethram.bommisetti@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: ab8500-usb: convert to devm_kzalloc
Fabio Baltieri [Wed, 3 Apr 2013 08:45:03 +0000 (10:45 +0200)]
usb: phy: ab8500-usb: convert to devm_kzalloc

Convert local data allocation to devm_kzalloc and drop unnecessary fail
path code.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: ux500_dma: drop references to U5500
Fabio Baltieri [Wed, 3 Apr 2013 08:45:02 +0000 (10:45 +0200)]
usb: musb: ux500_dma: drop references to U5500

Drop references to deprecated U5500 platform in driver comments.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: samsung: convert to devm_ioremap_resource()
Sachin Kamat [Tue, 26 Mar 2013 09:14:03 +0000 (14:44 +0530)]
usb: phy: samsung: convert to devm_ioremap_resource()

Use the newly introduced devm_ioremap_resource() instead of
devm_request_and_ioremap() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages; so all explicit
error messages can be removed from the failure code paths.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: pxa27x_udc: fix Section Mismatches
Felipe Balbi [Tue, 2 Apr 2013 14:13:40 +0000 (17:13 +0300)]
usb: gadget: pxa27x_udc: fix Section Mismatches

Remove all section annotations to fix the
following section mismatches:

>> WARNING: drivers/usb/gadget/pxa27x_udc.o(.text+0x597c): Section mismatch in
reference from the function .pxa_udc_probe() to the function
.init.text:.udc_init_data.constprop.11()
   The function .pxa_udc_probe() references
   the function __init .udc_init_data.constprop.11().
   This is often because .pxa_udc_probe lacks a __init
   annotation or the annotation of .udc_init_data.constprop.11 is wrong.
--
>> WARNING: drivers/usb/gadget/pxa27x_udc.o(.text+0x5a04): Section mismatch in
reference from the function .pxa_udc_probe() to the function
.init.text:.pxa_ep_setup()
   The function .pxa_udc_probe() references
   the function __init .pxa_ep_setup().
   This is often because .pxa_udc_probe lacks a __init
   annotation or the annotation of .pxa_ep_setup is wrong.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: udc-core: prevent a memory leak
Felipe Balbi [Tue, 2 Apr 2013 14:06:28 +0000 (17:06 +0300)]
usb: gadget: udc-core: prevent a memory leak

udc-core would leak 'udc' memory in some error
cases. Fix it by kfree()ing udc on error path.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: fusb300_udc: bug fix of not doing idma reset for each time
Yuan-Hsin Chen [Tue, 2 Apr 2013 11:18:08 +0000 (11:18 +0000)]
usb: gadget: fusb300_udc: bug fix of not doing idma reset for each time

Enter IDMA_RESET only when the controller has been reset or
the device has been plugged in to or out from a host. In
IDMA_RESET, we should disable the corresponding PRD interrupt.
Also there is a redundant space eliminated.

fusb300_udc driver is tested on FARADAY platform a369 with
FUSB300 FPGA v1.8

Signed-off-by: Yuan-Hsin Chen <yhchen@faraday-tech.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: fusb300_udc: add FUSB300_EPSET0_STL_CLR for clearing EP0 stall
Yuan-Hsin Chen [Tue, 2 Apr 2013 11:15:28 +0000 (11:15 +0000)]
usb: gadget: fusb300_udc: add FUSB300_EPSET0_STL_CLR for clearing EP0 stall

The final version of fusb300 controller adds EPSET0_STL_CLR
for clearing EP0 stall and also removes EPSET0_EPn_TX0BYTE.

fusb300_udc driver is tested on FARADAY platform a369 with
FUSB300 FPGA v1.8

Signed-off-by: Yuan-Hsin Chen <yhchen@faraday-tech.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: dwc3: add CONFIG_PM_SLEEP to suspend/resume functions
Jingoo Han [Tue, 26 Mar 2013 01:52:48 +0000 (01:52 +0000)]
usb: dwc3: add CONFIG_PM_SLEEP to suspend/resume functions

Add CONFIG_PM_SLEEP to suspend/resume functions to fix the following
build warning when CONFIG_PM_SLEEP is not selected. This is because
sleep PM callbacks defined by SET_SYSTEM_SLEEP_PM_OPS are only used
when the CONFIG_PM_SLEEP is enabled. Unnecessary CONFIG_PM ifdefs
are removed.

drivers/usb/dwc3/core.c:682:12: warning: 'dwc3_suspend' defined but not used [-Wunused-function]
drivers/usb/dwc3/core.c:709:12: warning: 'dwc3_resume' defined but not used [-Wunused-function]
drivers/usb/dwc3/dwc3-omap.c:430:12: warning: 'dwc3_omap_suspend' defined but not used [-Wunused-function]
drivers/usb/dwc3/dwc3-omap.c:440:12: warning: 'dwc3_omap_resume' defined but not used [-Wunused-function]
drivers/usb/dwc3/dwc3-exynos.c:185:12: warning: 'dwc3_exynos_suspend' defined but not used [-Wunused-function]
drivers/usb/dwc3/dwc3-exynos.c:194:12: warning: 'dwc3_exynos_resume' defined but not used [-Wunused-function]

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: gadget: read ep0 fifo only if rxcount is non zero
Ravi Babu [Tue, 2 Apr 2013 07:52:42 +0000 (13:22 +0530)]
usb: musb: gadget: read ep0 fifo only if rxcount is non zero

avoid reading fifo rxcount is zero of fifo is empty, hence
read fifo only if rxcount is non-zero

Signed-off-by: Ravi Babu <ravibabu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: dsps: print babble message only when musb is active host
Ravi Babu [Tue, 2 Apr 2013 07:51:54 +0000 (13:21 +0530)]
usb: musb: dsps: print babble message only when musb is active host

The musb controller uses single bit defintion for both reset and
babble events. The babble event is valid only when controller is
active a-host, and hence print the babble message only when the
controller is active a-host.

Signed-off-by: Ravi Babu <ravibabu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: implement (un)map_urb_for_dma hooks
Ruslan Bilovol [Fri, 29 Mar 2013 17:15:21 +0000 (19:15 +0200)]
usb: musb: implement (un)map_urb_for_dma hooks

MUSB controller cannot work in DMA mode with misaligned buffers,
switching in PIO mode.

HCD core has hooks that allow to override the default DMA
mapping and unmapping routines for host controllers that have
special DMA requirements, such as alignment constraints.

It is observed that work in PIO mode is slow and it's better
to align buffers properly before passing them to MUSB

This increased throughput 80->120 MBits/s over musb@omap4 with
USB Gigabit Ethernet adapter attached.

Some ideas are taken from ehci-tegra.c

Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget/uvc: Add support for 'get_unmapped_area' for MMUless architectures
Bhupesh Sharma [Thu, 28 Mar 2013 09:41:53 +0000 (15:11 +0530)]
usb: gadget/uvc: Add support for 'get_unmapped_area' for MMUless architectures

This patch adds the support for 'get_unmapped_area' in UVC gadget
which is called when the 'mmap' system call is executed on MMUless
architectures.

Signed-off-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
11 years agousb: gadget/uvc: Port UVC webcam gadget to use videobuf2 framework
Bhupesh Sharma [Thu, 28 Mar 2013 09:41:52 +0000 (15:11 +0530)]
usb: gadget/uvc: Port UVC webcam gadget to use videobuf2 framework

This patch reworks the videobuffer management logic present in the UVC
webcam gadget and ports it to use the "more apt" videobuf2 framework for
video buffer management.

To support routing video data captured from a real V4L2 video capture
device with a "zero copy" operation on videobuffers (as they pass from
the V4L2 domain to UVC domain via a user-space application), we need to
support USER_PTR IO method at the UVC gadget side.

So the V4L2 capture device driver can still continue to use MMAP IO
method and now the user-space application can just pass a pointer to the
video buffers being dequeued from the V4L2 device side while queueing
them at the UVC gadget end. This ensures that we have a "zero-copy"
design as the videobuffers pass from the V4L2 capture device to the UVC
gadget.

Note that there will still be a need to apply UVC specific payload
headers on top of each UVC payload data, which will still require a copy
operation to be performed in the 'encode' routines of the UVC gadget.

This patch also addresses one issue found out while porting the UVC
gadget to videobuf2 framework:
- In case the usb requests queued by the gadget get completed
  with a status of -ESHUTDOWN (disconnected from host),
  the queue of videobuf2 should be cancelled to ensure that the
  application space daemon is not left in a state waiting for
  a vb2 to be successfully absorbed at the USB side.

Signed-off-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
11 years agousb: renesas_usbhs: fixup sparse errors for common.c
Kuninori Morimoto [Mon, 1 Apr 2013 01:34:43 +0000 (18:34 -0700)]
usb: renesas_usbhs: fixup sparse errors for common.c

This patch fixup below sparse errors

CHECK   ${RENESAS_USB}/common.c
${RENESAS_USB}/common.c:313:17: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/common.c:322:17: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/common.c:384:17: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/common.c:524:9: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/common.c:545:9: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/common.c:574:9: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/common.c:606:9: error: incompatible types in conditional expression (different base types)
${RENESAS_USB}/mod_gadget.c:233:28: warning: symbol 'req_clear_feature' was not declared. Should it be static?
${RENESAS_USB}/mod_gadget.c:274:28: warning: symbol 'req_set_feature' was not declared. Should it be static?
${RENESAS_USB}/mod_gadget.c:375:28: warning: symbol 'req_get_status' was not declared. Should it be static?

[ balbi@ti.com : added three sparse fixes to mod_gadget.c ]

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: mv_usb: remove clock name from pdata
Chao Xie [Mon, 25 Mar 2013 07:06:57 +0000 (03:06 -0400)]
usb: mv_usb: remove clock name from pdata

Using pdata to pass clock name is not correct.
Directly get clock from usb drivers.

Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: mv_u3d_core: remove unused clock
Felipe Balbi [Tue, 2 Apr 2013 08:12:11 +0000 (11:12 +0300)]
usb: gadget: mv_u3d_core: remove unused clock

The origianl understanding of clock is wrong. The UDC controller
only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device
iteself.

Cc: Chao Xie <chao.xie@marvell.com>
Cc: Yu Xu <yuxu@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agoarm: mmp: remove clock name from usb pdata for ttc
Chao Xie [Mon, 25 Mar 2013 07:06:56 +0000 (03:06 -0400)]
arm: mmp: remove clock name from usb pdata for ttc

The clock name will directly get by driver. Removing
the name from pdata.

Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com>
Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agoarm: mmp: remove clock from usb pdata for aspenite
Chao Xie [Mon, 25 Mar 2013 07:06:55 +0000 (03:06 -0400)]
arm: mmp: remove clock from usb pdata for aspenite

The clock name will directly get by driver. Removing
the name from pdata.

Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com>
Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: ehci: mv_ehci: remove unused clock
Chao Xie [Mon, 25 Mar 2013 07:06:54 +0000 (03:06 -0400)]
usb: ehci: mv_ehci: remove unused clock

The origianl understanding of clock is wrong. The EHCI controller
only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device
iteself.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: otg: mv_otg: remove unused clock
Chao Xie [Mon, 25 Mar 2013 07:06:53 +0000 (03:06 -0400)]
usb: otg: mv_otg: remove unused clock

The origianl understanding of clock is wrong. The OTG controller
only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device
iteself.

Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: mv_udc_core: remove unused clock
Chao Xie [Mon, 25 Mar 2013 07:06:52 +0000 (03:06 -0400)]
usb: gadget: mv_udc_core: remove unused clock

The origianl understanding of clock is wrong. The UDC controller
only have one clock input.
Passing clock name by pdata is wrong. The clock is defined by device
iteself.

Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: gadget: use platform callback to enable vbus
Grazvydas Ignotas [Sun, 24 Mar 2013 15:36:55 +0000 (17:36 +0200)]
usb: musb: gadget: use platform callback to enable vbus

On some platform configurations (like OMAP3+twl4030) it's the platform
code that enables VBUS, not OTG transceiver, so call vbus platform
callback instead, it will then call the transceiver if needed.

This fixes a use case where USB cable is plugged first and gadget
driver is loaded later after that.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: omap2430: turn off vbus on cable disconnect
Grazvydas Ignotas [Sun, 24 Mar 2013 15:36:54 +0000 (17:36 +0200)]
usb: musb: omap2430: turn off vbus on cable disconnect

On USB_EVENT_ID event the musb glue enables VBUS by calling
omap2430_musb_set_vbus(musb, 1) that sets the session bit, but on
USB_EVENT_NONE reverse action is never made, and that breaks PM.

Disable VBUS on USB_EVENT_NONE to be sure musb session is ended
on cable unplug so that PM works.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: twl4030-usb: check if vbus is driven by twl itself
Grazvydas Ignotas [Sun, 24 Mar 2013 15:36:53 +0000 (17:36 +0200)]
usb: phy: twl4030-usb: check if vbus is driven by twl itself

At least on pandora, STS_VBUS gets set even when VBUS is driven by twl
itself. Reporting VBUS in this case confuses OMAP musb glue and charger
driver, so check if OTG VBUS charge pump is on before reporting VBUS
event to avoid this problem.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: ux500_dma: fix sparse warning
Felipe Balbi [Fri, 22 Mar 2013 15:03:32 +0000 (17:03 +0200)]
usb: musb: ux500_dma: fix sparse warning

fix the following sparse warning:

drivers/usb/musb/ux500_dma.c:60:6: warning: symbol 'ux500_dma_callback' was not declared. Should it be static?

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: mv_u3d: fix sparse warnings
Felipe Balbi [Fri, 22 Mar 2013 15:01:42 +0000 (17:01 +0200)]
usb: gadget: mv_u3d: fix sparse warnings

fix the following sparse warnings:

drivers/usb/gadget/mv_u3d_core.c:223:20: warning: context imbalance in 'mv_u3d_done' - unexpected unlock
drivers/usb/gadget/mv_u3d_core.c:1562:25: warning: context imbalance in 'mv_u3d_handle_setup_packet' - unexpected unlock

Note that the non-trivial sparse warnings
are left out of this commit due to lack of
HW to test:

drivers/usb/gadget/mv_u3d_core.c:906:42: warning: incorrect type in argument 2 (different address spaces)
drivers/usb/gadget/mv_u3d_core.c:906:42:    expected void [noderef] <asn:2>*<noident>
drivers/usb/gadget/mv_u3d_core.c:906:42:    got unsigned int *<noident>

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: mv_udc_core: fix sparse warnings
Felipe Balbi [Fri, 22 Mar 2013 14:58:18 +0000 (16:58 +0200)]
usb: gadget: mv_udc_core: fix sparse warnings

fix the following sparse warnings:

drivers/usb/gadget/mv_udc_core.c:1850:6: warning: symbol 'irq_process_reset' was not declared. Should it be static?
drivers/usb/gadget/mv_udc_core.c:247:9: warning: context imbalance in 'done' - unexpected unlock
drivers/usb/gadget/mv_udc_core.c:1692:25: warning: context imbalance in 'handle_setup_packet' - unexpected unlock

Note that there are still other sparse warnings
which aren't trivial to fix, so I left them out:

drivers/usb/gadget/mv_udc_core.c:848:34: warning: incorrect type in argument 1 (different address spaces)
drivers/usb/gadget/mv_udc_core.c:848:34:    expected void const volatile [noderef] <asn:2>*addr
drivers/usb/gadget/mv_udc_core.c:848:34:    got unsigned int *<noident>
drivers/usb/gadget/mv_udc_core.c:849:42: warning: incorrect type in argument 2 (different address spaces)
drivers/usb/gadget/mv_udc_core.c:849:42:    expected void volatile [noderef] <asn:2>*addr
drivers/usb/gadget/mv_udc_core.c:849:42:    got unsigned int *<noident>

Acked-by: Neil Zhang <zhangwm@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: pch_udc: fix sparse warnings
Felipe Balbi [Fri, 22 Mar 2013 14:54:01 +0000 (16:54 +0200)]
usb: gadget: pch_udc: fix sparse warnings

fix the following sparse warnings:

drivers/usb/gadget/pch_udc.c:1483:9: warning: context imbalance in 'complete_req' - unexpected unlock
drivers/usb/gadget/pch_udc.c:2408:28: warning: context imbalance in 'pch_udc_svc_control_out' - unexpected unlock

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: dummy: fix sparse warning
Felipe Balbi [Fri, 22 Mar 2013 14:50:47 +0000 (16:50 +0200)]
usb: gadget: dummy: fix sparse warning

fix the following sparse warning:

drivers/usb/gadget/dummy_hcd.c:1912:12: warning: symbol 'usb3_bos_desc' was not declared. Should it be static?

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: net2280: fix sparse warnings
Felipe Balbi [Fri, 22 Mar 2013 14:47:52 +0000 (16:47 +0200)]
usb: gadget: net2280: fix sparse warnings

fix the following sparse warnings:

drivers/usb/gadget/net2280.c:2063:13: warning: Using plain integer as NULL pointer
drivers/usb/gadget/net2280.c:2321:68: warning: Using plain integer as NULL pointer
drivers/usb/gadget/net2280.c:2349:68: warning: Using plain integer as NULL pointer
drivers/usb/gadget/net2280.c:2371:68: warning: Using plain integer as NULL pointer

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: net2272: fix sparse warnings
Felipe Balbi [Thu, 21 Mar 2013 10:19:31 +0000 (12:19 +0200)]
usb: gadget: net2272: fix sparse warnings

Fix the following sparse warnings:

drivers/usb/gadget/net2272.c:916:13: warning: Using plain integer as NULL pointer
drivers/usb/gadget/net2272.c:1624:9: warning: Using plain integer as NULL pointer
drivers/usb/gadget/net2272.c:1552:30: warning: right shift by bigger than source value

Note that the last warning is an actual bug,
since ep->dma is a one bit value which is
shifted by one bit in code.

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: mv_u3d: drop ARCH dependency
Felipe Balbi [Fri, 22 Mar 2013 07:15:45 +0000 (09:15 +0200)]
usb: gadget: mv_u3d: drop ARCH dependency

this driver compiles fine everywhere which
means we can use linux-next to compile it
for us frequently.

By dropping the arch dependency, we also
ensure driver writers don't add virtual
arch-depdencies to the driver by e.g. using
the wrong headers.

While at that, fix Marvell's USB3 PHY dependency,
that's the driver which depends on CPU_MM3, not
mv_u3d_core.

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: mv_u3d: fix sparse warnings
Felipe Balbi [Fri, 22 Mar 2013 07:14:25 +0000 (09:14 +0200)]
usb: gadget: mv_u3d: fix sparse warnings

Fix the following sparse warnings:

drivers/usb/gadget/mv_u3d_core.c: In function ‘mv_u3d_ep_queue’:
drivers/usb/gadget/mv_u3d_core.c:812:2: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c:822:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c:823:4: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c:823:28: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c: In function ‘mv_u3d_ep_dequeue’:
drivers/usb/gadget/mv_u3d_core.c:905:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c: In function ‘mv_u3d_probe’:
drivers/usb/gadget/mv_u3d_core.c:1840:3: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c:1855:51: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c:1855:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
drivers/usb/gadget/mv_u3d_core.c:1858:53: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/usb/gadget/mv_u3d_core.c:1858:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
drivers/usb/gadget/mv_u3d_core.c: In function ‘mv_u3d_irq_process_tr_complete’:
drivers/usb/gadget/mv_u3d_core.c:163:21: warning: ‘remaining_length’ may be used uninitialized in this function [-Wmaybe-uninitialized]
drivers/usb/gadget/mv_u3d_core.c:125:28: note: ‘remaining_length’ was declared here

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: mv_u3d: remove outdated selects
Felipe Balbi [Fri, 22 Mar 2013 07:12:23 +0000 (09:12 +0200)]
usb: gadget: mv_u3d: remove outdated selects

USB_GADGET_{DUAL,SUPER}SPEED symbols have
been removed by commit 85b8614 (usb: gadget:
get rid of USB_GADGET_{DUAL,SUPER}SPEED), for
some reason mv_u3d_core was lost.

Remove those selects now.

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: mv_u3d: remove unused headers
Felipe Balbi [Fri, 22 Mar 2013 07:11:17 +0000 (09:11 +0200)]
usb: gadget: mv_u3d: remove unused headers

none of those headers are used by the driver,
removing them still compiles fine.

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: mv_u3d: make mv_u3d_pm_ops static
Jingoo Han [Tue, 19 Mar 2013 01:28:56 +0000 (01:28 +0000)]
usb: gadget: mv_u3d: make mv_u3d_pm_ops static

Make mv_u3d_pm_ops static because mv_u3d_pm_ops is not exported.
Also, CONFIG_PM_SLEEP is used to remove unnecessary ifdefs.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: core: log VBUS error
Grazvydas Ignotas [Sun, 10 Mar 2013 00:49:28 +0000 (02:49 +0200)]
usb: musb: core: log VBUS error

VBUS_ERROR is a serious error that the driver often doesn't recover from
in my tests, so we should at least inform the user about it.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: gadget: clear gadget_driver when gadget is stopped
Grazvydas Ignotas [Sun, 10 Mar 2013 00:49:14 +0000 (02:49 +0200)]
usb: musb: gadget: clear gadget_driver when gadget is stopped

Some musb glue drivers use gadget_driver pointer to know if any gadget
drivers are loaded at some moment and base further decisions on it,
like to do runtime suspend/resume or not. Right now the pointer is
left alone on stop and OMAP musb glue later does wrong runtime_pm
decisions because of it.

Clear the gadget_driver pointer on remove, it's invalid after stop
anyway.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: core: honour initial transceiver state
Grazvydas Ignotas [Sun, 10 Mar 2013 00:48:55 +0000 (02:48 +0200)]
usb: musb: core: honour initial transceiver state

As the usb transceiver driver usually starts first, it should already
have default_a variable set according to ID pin state, so don't
override it. In case default_a was not changed by trasceiver, it will
default to 0 and this code will work as before.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: host: ehci-tegra: fix PHY error handling
Felipe Balbi [Fri, 15 Mar 2013 09:04:39 +0000 (11:04 +0200)]
usb: host: ehci-tegra: fix PHY error handling

PHY layer no longer returns NULL, we must
switch from IS_ERR_OR_NULL() to IS_ERR().

Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: twl4030-usb: poll for ID disconnect
Grazvydas Ignotas [Sun, 17 Mar 2013 18:23:24 +0000 (20:23 +0200)]
usb: phy: twl4030-usb: poll for ID disconnect

On pandora, STS_USB interrupt doesn't arrive on USB host cable disconnect
for some reason while VBUS is driven by twl itself, but STS_HW_CONDITIONS
is updated correctly. It does work fine when PHY is powered down though.
To work around that we have to poll.

This patch also moves twl->linkstat update code to callers so that
changes can be handled in thread safe way (as polling work can trigger
at the same time as real irq now).

TI PSP kernels have similar workarounds, so (many?) more boards are likely
affected.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: twl4030-usb: don't switch the phy on/off needlessly
Grazvydas Ignotas [Sun, 17 Mar 2013 18:23:23 +0000 (20:23 +0200)]
usb: phy: twl4030-usb: don't switch the phy on/off needlessly

With runtime_pm in place there is no longer need to turn the phy
on/off in OTG layer on cable connect/disconnect, OMAP glue does
this through otg.set_suspend() callback after it's called through
omap_musb_mailbox() on VBUS/ID interrupt. Not doing this will save
power when cable is connected but no gadget driver is loaded.

This will also have side effect of automatic USB charging no longer
working without twl4030_charger driver, because a regulator needed
for charging will no longer be enabled, so be sure to enable charger
driver if charging is needed.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: twl4030-usb: ignore duplicate events
Grazvydas Ignotas [Sun, 17 Mar 2013 18:23:22 +0000 (20:23 +0200)]
usb: phy: twl4030-usb: ignore duplicate events

In some rare cases we may get multiple interrupts that will generate
duplicate omap_musb_mailbox() calls. This is a problem because each
VBUS/ID event generates runtime_pm call in OMAP glue code, causing
unbalanced gets or puts and breaking PM.

The same goes for initial state, glue already defaults to "no cable"
state, so only bother it if we have VBUS or ID.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Reviewed-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: twl4030-usb: don't enable PHY during init
Grazvydas Ignotas [Sun, 17 Mar 2013 18:23:21 +0000 (20:23 +0200)]
usb: phy: twl4030-usb: don't enable PHY during init

There is no need to do it, otg.set_suspend(false) (which itself
comes from runtime_pm OMAP glue calls) will enable it later anyway.
This used to be the place where things were enabled if booted with
cable connected before runtime_pm conversion, but now can be dropped.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agoarm: tegra: fix Kconfig select clauses
Felipe Balbi [Wed, 20 Mar 2013 12:18:28 +0000 (14:18 +0200)]
arm: tegra: fix Kconfig select clauses

USB_ULPI and USB_ULPI_VIEWPORT shouldn't really
be selected directly by anyone, but since Tegra
still needs some time before turning ulpi viewport
into a proper PHY driver, we need to keep the
selects in place.

This patch just fixes the conditional select
so that it will continue to build after merging
the latest PHY layer changes.

Acked-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: gpio-vbus: don't ignore regulator APIs return value
Felipe Balbi [Wed, 20 Mar 2013 06:01:53 +0000 (08:01 +0200)]
usb: phy: gpio-vbus: don't ignore regulator APIs return value

Due to recent changes to regulator API, all
users which don't check regulator_{en,dis}able()'s
return value will generate compile warnings.

Add such checks to gpio-vbus.

Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: samsung: fix sparse warning
Felipe Balbi [Tue, 19 Mar 2013 08:14:35 +0000 (10:14 +0200)]
usb: phy: samsung: fix sparse warning

Fix the following sparse warning:

drivers/usb/phy/phy-samsung-usb2.c:50:26: sparse: incorrect type in argument 1 (different address spaces)
drivers/usb/phy/phy-samsung-usb2.c:50:26:    expected void const volatile [noderef] <asn:2>*addr
drivers/usb/phy/phy-samsung-usb2.c:50:26:    got void *

Cc: Vivek Gautam <gautam.vivek@samsung.com>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: ab8500-usb: update irq handling code
Fabio Baltieri [Fri, 8 Mar 2013 02:27:09 +0000 (10:27 +0800)]
usb: phy: ab8500-usb: update irq handling code

Update irq handling code to notify all possible link status changes of
AB8500 and AB8505 to the ux500-musb glue driver.  The additional event
codes will be used for pm-runtime implementation, and are defined in a
separate ux500-specific header.

This also modify the irq registration code to use devm_* helpers and
drop all non necessary fail path code.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: otg: ab8500-usb: drop support for ab8500 pre v2.0
Fabio Baltieri [Fri, 8 Mar 2013 02:27:08 +0000 (10:27 +0800)]
usb: otg: ab8500-usb: drop support for ab8500 pre v2.0

AB8500 versions preceding 2.0 were only used internally by ST-Ericsson
and are not supported anymore.  This patch drops all v1.0 and v1.1
support code.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: ux500: add otg notifier support
Fabio Baltieri [Fri, 8 Mar 2013 02:27:07 +0000 (10:27 +0800)]
usb: musb: ux500: add otg notifier support

Add transceiver notifier event handling to the ux500 driver to set vbus
on specific transceiver events.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
[ balbi@ti.com: fix build error due to missing
otg_state_string() ]

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: ux500: implement musb_set_vbus
Fabio Baltieri [Fri, 8 Mar 2013 02:27:06 +0000 (10:27 +0800)]
usb: musb: ux500: implement musb_set_vbus

Add ux500_musb_set_vbus() implementation for ux500.

This is based on the version originally developed inside ST-Ericsson.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
[ balbi@ti.com: fix a build error due to
missing otg_state_string() ]

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: ux500_dma: add missing MEM resource check
Virupax Sadashivpetimath [Fri, 8 Mar 2013 02:27:05 +0000 (10:27 +0800)]
usb: musb: ux500_dma: add missing MEM resource check

Fix dma_controller_create() fail path in case memory resource is
missing.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Virupax Sadashivpetimath <virupax.sadashivpetimath@stericsson.com>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: host: ohci-exynos: fix PHY error handling
Felipe Balbi [Fri, 15 Mar 2013 09:05:03 +0000 (11:05 +0200)]
usb: host: ohci-exynos: fix PHY error handling

PHY layer no longer returns NULL. We must
switch from IS_ERR_OR_NULL() to IS_ERR().

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: host: ehci-s5p: fix PHY error handling
Felipe Balbi [Fri, 15 Mar 2013 09:04:15 +0000 (11:04 +0200)]
usb: host: ehci-s5p: fix PHY error handling

PHY layer no longer returns NULL. We must
switch from IS_ERR_OR_NULL() to IS_ERR().

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: host: ehci-mv: fix PHY error handling
Felipe Balbi [Fri, 15 Mar 2013 09:03:30 +0000 (11:03 +0200)]
usb: host: ehci-mv: fix PHY error handling

PHY layer no longer returns NULL. We must
switch from IS_ERR_OR_NULL() to IS_ERR().

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: host: ehci-msm: fix PHY error handling
Felipe Balbi [Fri, 15 Mar 2013 09:02:56 +0000 (11:02 +0200)]
usb: host: ehci-msm: fix PHY error handling

PHY layer no longer returns NULL. We must
switch from IS_ERR_OR_NULL() to IS_ERR().

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: omap2430: fix PHY error handling
Felipe Balbi [Fri, 15 Mar 2013 08:57:40 +0000 (10:57 +0200)]
usb: musb: omap2430: fix PHY error handling

PHY layer no longer returns NULL. It will
return -ENXIO when PHY layer isn't enabled
and we can use that to bail out instead of
request a probe deferral.

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: s3c-hsotg: fix PHY error handling
Felipe Balbi [Fri, 15 Mar 2013 08:56:19 +0000 (10:56 +0200)]
usb: gadget: s3c-hsotg: fix PHY error handling

PHY laye rno longer return NULL. We need to
switch over from IS_ERR_OR_NULL() to IS_ERR().

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: mv_udc_core: fix PHY error handling
Felipe Balbi [Fri, 15 Mar 2013 08:54:59 +0000 (10:54 +0200)]
usb: gadget: mv_udc_core: fix PHY error handling

PHY layer no longer returns NULL. It will
return -ENXIO when PHY layer isn't enabled
and we can use that to bail out instead of
request a probe deferral.

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: dwc3: fix PHY error handling
Felipe Balbi [Fri, 15 Mar 2013 08:52:08 +0000 (10:52 +0200)]
usb: dwc3: fix PHY error handling

PHY layer no longer returns NULL. It will
return -ENXIO when PHY layer isn't enabled
and we can use that to bail out instead of
request a probe deferral.

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: twl4030: fix cold plug on OMAP3
Kishon Vijay Abraham I [Fri, 15 Mar 2013 13:28:52 +0000 (18:58 +0530)]
usb: phy: twl4030: fix cold plug on OMAP3

Having twl4030_usb_phy_init() (detects if a cable is connected before
twl4030 is probed) in twl4030 probe makes cable connect events to be
missed by musb glue, since it gets loaded after twl4030. Having
twl4030_usb_phy_init as a usb_phy ops lets twl4030_usb_phy_init to be
called when glue is ready.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Tested-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: twl4030: use devres API for regulator get and request irq
Kishon Vijay Abraham I [Fri, 15 Mar 2013 13:28:51 +0000 (18:58 +0530)]
usb: phy: twl4030: use devres API for regulator get and request irq

Used devres APIs devm_request_threaded_irq and devm_regulator_get for
requesting irq and for getting regulator respectively.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Tested-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: phy: return -ENXIO when PHY layer isn't enabled
Felipe Balbi [Thu, 14 Mar 2013 15:59:06 +0000 (17:59 +0200)]
usb: phy: return -ENXIO when PHY layer isn't enabled

in cases where PHY layer isn't enabled, we want
to still return an error code (actually an error
pointer) so that our users don't need to cope with
either error pointer of NULL.

This will simplify users as below:

- return IS_ERR(phy) ? PTR_ERR(phy) : -ENODEV;
+ return PTR_ERR(phy);

Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
Reported-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: omap: add usb_phy_init in omap2430_musb_init
Kishon Vijay Abraham I [Thu, 14 Mar 2013 06:23:58 +0000 (11:53 +0530)]
usb: musb: omap: add usb_phy_init in omap2430_musb_init

Some PHYs load too early (twl4030) making omap glue to miss cable connect events
if the board is booted with cable connected. So adding usb_phy_init in
omap2430_musb_init lets PHYs to report events once glue is ready.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: omap: remove the check before calling otg_set_vbus
Kishon Vijay Abraham I [Thu, 14 Mar 2013 06:23:56 +0000 (11:53 +0530)]
usb: musb: omap: remove the check before calling otg_set_vbus

No functional change. otg_set_vbus is already protected so removed the
check before calling otg_set_vbus.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: uvc: use capped length value
Dan Carpenter [Thu, 14 Mar 2013 08:01:05 +0000 (11:01 +0300)]
usb: gadget: uvc: use capped length value

"req->length" is a capped version of "data->length".

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: dwc3: omap: fix sparse warning
Felipe Balbi [Thu, 14 Mar 2013 14:00:58 +0000 (16:00 +0200)]
usb: dwc3: omap: fix sparse warning

our global '_omap' pointer wasn't marked
static. This patch solves the following sparse
warning:

warning: symbol '_omap' was not declared. \
Should it be static?

Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: musb: omap2430: replace *_* with *-* in property names
Kishon Vijay Abraham I [Thu, 7 Mar 2013 13:21:46 +0000 (18:51 +0530)]
usb: musb: omap2430: replace *_* with *-* in property names

No functional change. Replace *_* with *-* in property names of otg to
follow the general convention.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: uvc: Use strlcpy instead of strncpy
Chen Gang [Fri, 1 Mar 2013 19:46:33 +0000 (20:46 +0100)]
usb: gadget: uvc: Use strlcpy instead of strncpy

For NULL terminated string, better notice '\0' in the end.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: uvc: Use GFP_ATOMIC under spin lock
Cyril Roelandt [Fri, 1 Mar 2013 19:46:32 +0000 (20:46 +0100)]
usb: gadget: uvc: Use GFP_ATOMIC under spin lock

Found using the following semantic patch:
<spml>
@@
@@
spin_lock_irqsave(...);
... when != spin_unlock_irqrestore(...);
* GFP_KERNEL
</spml>

Signed-off-by: Cyril Roelandt <tipecaml@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: uvc: Make video streaming buffer size comply with USB3.0 SS
Bhupesh Sharma [Fri, 1 Mar 2013 19:46:31 +0000 (20:46 +0100)]
usb: gadget: uvc: Make video streaming buffer size comply with USB3.0 SS

As per the USB3.0 specs, the bandwidth requirements of a UVC's video
streaming endpoint will change to support super-speed. These changes
will be dependent on whether the UVC video streaming endpoint is Bulk or
Isochronous:

- If video streaming endpoint is Isochronous:
  As per Section 4.4.8.2 (Isochronous Transfer Bandwidth Requirements)
  of the USB3.0 specs:

    A SuperSpeed isochronous endpoint can move up to three burst
    transactions of up to 16 maximum sized packets (3 * 16 * 1024 bytes)
    per service interval.

- If video streaming endpoint is Bulk:
  As per 4.4.6.1 (Bulk Transfer Data Packet Size) of the USB3.0 specs:

    An endpoint for bulk transfers shall set the maximum data packet
    payload size in its endpoint descriptor to 1024 bytes. It also
    specifies the burst size that the endpoint can accept from or
    transmit on the SuperSpeed bus. The allowable burst size for a bulk
    endpoint shall be in the range of 1 to 16.

So, in the Isochronous case, we can define the USB request's buffer to
be equal to = (Maximum packet size) * (bMaxBurst + 1) * (Mult + 1), so
that the UDC driver can try to send out this buffer in one Isochronous
service interval.

The same computation will hold good for the Bulk case as the Mult
value is 0 here and we can have a USB request buffer of maximum
16 * 1024 bytes size, which can be sent out by the UDC driver as
per the Bulk bandwidth allocation on the USB3 bus.

This patch adds the above-mentioned support and is also USB2.0 backward
compliant.

Signed-off-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
11 years agousb: gadget: uvc: Delay the status stage when setting alternate setting 1
Bhupesh Sharma [Fri, 1 Mar 2013 19:46:30 +0000 (20:46 +0100)]
usb: gadget: uvc: Delay the status stage when setting alternate setting 1

This patch adds the support in UVC webcam gadget design for providing
USB_GADGET_DELAYED_STATUS in response to a set_interface(alt setting 1)
command issue by the Host.

The current UVC webcam gadget design generates a STREAMON event
corresponding to a set_interface(alt setting 1) command from the Host.
This STREAMON event will eventually be routed to a real V4L2 device.

To start video streaming, it may be required to perform some register
writes to a camera sensor device over slow external busses like I2C or
SPI. So, it makes sense to ensure that we delay the STATUS stage of the
set_interface (alt setting 1) command.

Otherwise, a lot of ISOC IN tokens sent by the Host will be replied to
by zero-length packets by the webcam device. On certain Hosts this may
even lead to ISOC URBs been cancelled from the Host side.

So, as soon as we finish doing all the "streaming" related stuff on the
real V4L2 device, we call a STREAMON ioctl on the UVC side and from here
we call the 'usb_composite_setup_continue' function to complete the
status stage of the set_interface(alt setting 1) command.

Further, we need to ensure that we queue no video buffers on the UVC
webcam gadget, until we de-queue a video buffer from the V4L2 device.
So, the application should call the STREAMON on UVC side only when it
has dequeued sufficient buffers from the V4L2 side and queued them to
the UVC gadget.

Signed-off-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>