]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/log
mirror_ubuntu-jammy-kernel.git
9 years agousb: gadget: f_printer: fix dependencies
Andrzej Pietrasiewicz [Tue, 24 Mar 2015 09:58:16 +0000 (10:58 +0100)]
usb: gadget: f_printer: fix dependencies

If f_printer is selected without legacy g_printer, it should
depend on USB_CONFIGFS which pulls in libcomposite.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: atmel_usba: use endian agnostic IO on ARM
Ben Dooks [Wed, 18 Mar 2015 15:53:09 +0000 (15:53 +0000)]
usb: gadget: atmel_usba: use endian agnostic IO on ARM

Change from using the __raw IO accesors to the endian agnostic versions
of readl/writel_relaxed when not on AVR32. This fixes issues with running
big endian on ARMv7.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
--
CC: Nicolas Ferre <nicolas.ferre@atmel.com>
CC: Felipe Balbi <balbi@ti.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: linux-usb@vger.kernel.org
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: dwc2: pci: Correctly compile dwc2-pci as a module or built-in
John Youn [Tue, 17 Mar 2015 01:10:02 +0000 (18:10 -0700)]
usb: dwc2: pci: Correctly compile dwc2-pci as a module or built-in

The dwc2-pci driver should be compiled as a module when configured to
do so. If the dwc2-pci is configured as a module but actually
built-in, it can cause build errors due to the fact that the
generic-phy will be allowed to compile as a module causing undefined
references.

Reported-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: constify of_device_id array
Fabian Frederick [Mon, 16 Mar 2015 19:20:27 +0000 (20:20 +0100)]
usb: gadget: constify of_device_id array

of_device_id is always used as const.
(See driver.of_match_table and open firmware functions)

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: goku_udc: Remove uses of seq_<foo> return values
Joe Perches [Mon, 16 Mar 2015 18:09:38 +0000 (11:09 -0700)]
usb: gadget: goku_udc: Remove uses of seq_<foo> return values

The seq_printf/seq_puts/seq_putc return values, because they
are frequently misused, will eventually be converted to void.

See: commit 1f33c41c03da ("seq_file: Rename seq_overflow() to
     seq_has_overflowed() and make public")

Miscellanea:

o Coalesce formats, realign arguments
o Create static functions for statement expression macros
o Use c90 style comments instead of c99

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: renesas_usbhs: fix spinlock suspected in a gadget complete function
Yoshihiro Shimoda [Mon, 16 Mar 2015 07:36:48 +0000 (16:36 +0900)]
usb: renesas_usbhs: fix spinlock suspected in a gadget complete function

According to the gadget.h, a "complete" function will always be called
with interrupts disabled. However, sometimes usbhsg_queue_pop() function
is called with interrupts enabled. So, this function should be held by
usbhs_lock() to disable interruption. Also, this driver has to call
spin_unlock() to avoid spinlock recursion by this driver before calling
usb_gadget_giveback_request().
Otherwise, there is possible to cause a spinlock suspected in a gadget
complete function.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: common: otg-fsm: only signal connect after switching to peripheral
Peter Chen [Thu, 12 Mar 2015 01:47:53 +0000 (09:47 +0800)]
usb: common: otg-fsm: only signal connect after switching to peripheral

We should signal connect (pull up dp) after we have already
at peripheral mode, otherwise, the dp may be toggled due to
we reset controller or do disconnect during the initialization
for peripheral, then, the host may be confused during the
enumeration, eg, it finds the reset can't succeed, but the
device is still there, see below error message.

hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: Cannot enable port 1.  Maybe the USB cable is bad?
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: Cannot enable port 1.  Maybe the USB cable is bad?
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: Cannot enable port 1.  Maybe the USB cable is bad?
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: cannot reset port 1 (err = -32)
hub 1-0:1.0: Cannot enable port 1.  Maybe the USB cable is bad?
hub 1-0:1.0: unable to enumerate USB device on port 1

Fixes: the issue existed when the otg fsm code was added.
Cc: <stable@vger.kernel.org> # v3.16+
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: phy: Find the right match in devm_usb_phy_match
Axel Lin [Thu, 12 Mar 2015 01:15:28 +0000 (09:15 +0800)]
usb: phy: Find the right match in devm_usb_phy_match

The res parameter passed to devm_usb_phy_match() is the location where the
pointer to the usb_phy is stored, hence it needs to be dereferenced before
comparing to the match data in order to find the correct match.

Fixes: 410219dcd2ba ("usb: otg: utils: devres: Add API's to associate a device with the phy")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Cc: <stable@vger.kernel.org> # v3.6+
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: chipidea: udc: apply new usb_udc_vbus_handler interface
Peter Chen [Fri, 6 Mar 2015 02:36:04 +0000 (10:36 +0800)]
usb: chipidea: udc: apply new usb_udc_vbus_handler interface

It can move all pullup/pulldown operation control to udc-core
through usb_gadget_connect/usb_gadget_disconnect according to
vbus status.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: udc: add usb_udc_vbus_handler
Peter Chen [Fri, 6 Mar 2015 02:36:03 +0000 (10:36 +0800)]
usb: udc: add usb_udc_vbus_handler

This commit updates udc core vbus status, and try to connect
or disconnect gadget.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: udc: store usb_udc pointer in struct usb_gadget
Peter Chen [Fri, 6 Mar 2015 02:36:02 +0000 (10:36 +0800)]
usb: udc: store usb_udc pointer in struct usb_gadget

Instead of iterate to find usb_udc according to usb_gadget, this
way is easier.

Alan Stern suggests this way too:
http://marc.info/?l=linux-usb&m=142168496528894&w=2

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: dwc2: avoid leaking DMA channels on disconnection
Vincent Palatin [Sun, 15 Mar 2015 20:24:32 +0000 (13:24 -0700)]
usb: dwc2: avoid leaking DMA channels on disconnection

When the HCD is disconnected, the DMA transfers still in-flight were cleaned-up
but the count of available DMA channels (e.g. available_host_channels) was not
reset.
The pool of DMA channels can be depleted when doing unclean
disconnection of USB peripherals, and reaches the point where no
transfer was possible until the next reboot/reload of the driver.

Tested by putting a programmable USB mux on the port and randomly
plugging/unpluging a USB HUB with USB mass-storage key, USB-audio and
USB-ethernet dongle connected to its downstream ports, and also doing the
disconnection early while the devices are still enumerating to get more URBs
in-flight.
After the patch, the devices are still enumerating after thousands of cycles,
while the port was totally dead before.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: phy: msm: Remove dead code
Stephen Boyd [Fri, 13 Mar 2015 18:09:42 +0000 (11:09 -0700)]
usb: phy: msm: Remove dead code

This code is no longer used now that mach-msm has been removed.
Delete it.

Cc: Felipe Balbi <balbi@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Cc: David Brown <davidb@codeaurora.org>
Cc: Bryan Huntsman <bryanh@codeaurora.org>
Cc: Daniel Walker <dwalker@fifo99.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: renesas_usbhs: add support for USB-DMAC
Yoshihiro Shimoda [Thu, 12 Mar 2015 06:35:20 +0000 (15:35 +0900)]
usb: renesas_usbhs: add support for USB-DMAC

Some Renesas SoCs have the USB-DMAC. It is able to terminate transfers
when a short packet is received, even if less bytes than the transfer
counter size have been received. Also, it is able to send a short
packet even if the packet size is not multiples of 8bytes.

Since the previous code has used the interruption of USBHS controller
when receiving packets even if this driver has used a dmac, a lot of
interruptions has happened. This patch will reduce such interruptions.

This patch allows to use the USB-DMAC on R-Car H2 and M2.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: renesas_usbhs: fix the sequence in xfer_work()
Yoshihiro Shimoda [Thu, 12 Mar 2015 06:35:19 +0000 (15:35 +0900)]
usb: renesas_usbhs: fix the sequence in xfer_work()

This patch fixes the setup sequence in xfer_work(). Otherwise,
sometimes a usb transaction will get stuck.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: renesas_usbhs: add the channel number in dma-names
Yoshihiro Shimoda [Thu, 12 Mar 2015 06:35:18 +0000 (15:35 +0900)]
usb: renesas_usbhs: add the channel number in dma-names

To connect the channel of USB-DMAC to USBHS DnFIFO number, this patch
adds this channel/FIFO number in dma-names. Otherwise, this driver
needs to add analysis code for device tree.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_printer: use non-zero flag for bitwise and
Andrzej Pietrasiewicz [Fri, 13 Mar 2015 10:08:08 +0000 (11:08 +0100)]
usb: gadget: f_printer: use non-zero flag for bitwise and

USB_DIR_OUT happens to be zero, so the result of bitwise and is always 0.
Consequently, break will never happen in the SOFT_RESET case.
This patch uses a compatible condition with a non-zero USB_DIR_IN,
which might or might not evaluate to zero.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: use after free in gprinter_alloc_inst()
Dan Carpenter [Fri, 13 Mar 2015 09:11:42 +0000 (12:11 +0300)]
usb: gadget: printer: use after free in gprinter_alloc_inst()

There was a missing goto so we free "opts" and then dereference it.

Fixes: ee1cd515e889 ('usb: gadget: printer: add configfs support')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: delete some dead code
Dan Carpenter [Fri, 13 Mar 2015 09:11:06 +0000 (12:11 +0300)]
usb: gadget: printer: delete some dead code

"num" is a u16 so it can't go higher than 65535.  kstrtou16() has a
range check built in so this is already handled.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: dwc2: pci: Select the generic PHY for dwc2-pci driver
John Youn [Thu, 12 Mar 2015 17:04:42 +0000 (10:04 -0700)]
usb: dwc2: pci: Select the generic PHY for dwc2-pci driver

The dwc2-pci driver requires the generic PHY. This fixes undefined
reference issues when it is not selected.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: serial: %pf is only for function pointers
Scott Wood [Thu, 12 Mar 2015 21:46:01 +0000 (16:46 -0500)]
usb: gadget: serial: %pf is only for function pointers

Use %ps for actual addresses, otherwise you'll get bad output
on arches like ppc64 where %pf expects a function descriptor
(which is not what __builtin_return_address returns).

Reviewed-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
Cc: linux-usb@vger.kernel.org
CC: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: dwc2: rework initialization of host and gadget in dual-role mode
Marek Szyprowski [Tue, 10 Mar 2015 12:41:10 +0000 (13:41 +0100)]
usb: dwc2: rework initialization of host and gadget in dual-role mode

If device is configured to work only in HOST or DEVICE mode, there is
no point in initializing both subdrivers. This patch also fixes
resource leakage if host subdriver fails to initialize.

Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: dwc2: pci: Add device mode to the dwc2-pci driver
John Youn [Wed, 4 Mar 2015 01:17:49 +0000 (17:17 -0800)]
usb: dwc2: pci: Add device mode to the dwc2-pci driver

The pci driver now registers a platform driver, like in dwc3, and lets
its probe function do all the initialization. This allows it to
account for changes to the platform driver that were not added to the
pci driver. Also future changes to the probe function don't have to be
duplicated. This also has the effect of adding device and DRD mode to
the pci driver. Tested on the Synopsys HAPS PCIe platform.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: lpc32xxx_udc: Fix NULL dereference
Peter Chen [Wed, 11 Mar 2015 02:07:47 +0000 (10:07 +0800)]
usb: gadget: lpc32xxx_udc: Fix NULL dereference

udc is then checked for NULL, if NULL, it is then dereferenced as
udc->dev, it is found using Coccinelle.

We simplify the code to fix this problem, and we delete some conditions
at if {} which will never be met.

Reported-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Reported-by : Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: cppi41: fix condition to call cppi41_trans_done().
Takeyoshi Kikuchi [Mon, 2 Mar 2015 02:03:51 +0000 (11:03 +0900)]
usb: musb: cppi41: fix condition to call cppi41_trans_done().

connect AR9271(USB wifi) to AM335x, and send a flood ping from Mac OSX,
AR9271 is stopped.

on USB bus, the following occurs.

 - OUT transaction is ACKed (NYET).
 - IN transaction is ACKed (512bytes).
 - PING-NAK transaction is continued for about 2 seconds (AR9271 timeout?).

In current imprementation, IN-transaction is not completed because it
checks the empty of TX-FIFO in cppi41_dma_callback().
As a result, communication to AR9271 stops.

This patch modified to check the empty of TX-FIFO only when OUT-transaction.

Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: phy: phy-generic: No need to call gpiod_direction_output() twice
Fabio Estevam [Tue, 3 Feb 2015 21:18:17 +0000 (19:18 -0200)]
usb: phy: phy-generic: No need to call gpiod_direction_output() twice

Commit 9eb0797722895f4309b4 ("usb: phy: generic: fix the gpios to be optional")
calls gpiod_direction_output() in the probe function, so there is no need to
call it again, as we can simply call gpiod_set_value() directly.

Also, in usb_gen_phy_shutdown() we can simply put the GPIO directly in its
active level state and this allows us to simplify the nop_reset function to
treat only the reset case.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_hid: remove unnecessary usb_ep_dequeue()
Robert Baldyga [Tue, 10 Feb 2015 16:30:36 +0000 (17:30 +0100)]
usb: gadget: f_hid: remove unnecessary usb_ep_dequeue()

Function usb_ep_disable() causes completion of all requests queued
for given endpoint, so there is no need to dequeue them after endpoint
disabling.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: dummy-hcd: Remove utf8 from format string
Rasmus Villemoes [Thu, 5 Feb 2015 23:42:00 +0000 (00:42 +0100)]
usb: gadget: dummy-hcd: Remove utf8 from format string

Not everybody uses a utf8 locale (unfortunately), so let's avoid
non-ascii characters in the kernel log. Replace the 3-byte utf8
sequence with a 3-byte ascii equivalent.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: atmel_usba_udc: Add suspend/resume with wakeup support
Sylvain Rochet [Thu, 12 Feb 2015 17:54:07 +0000 (18:54 +0100)]
usb: gadget: atmel_usba_udc: Add suspend/resume with wakeup support

This patch add suspend/resume with wakeup support for Atmel USBA.

On suspend: We stay continuously clocked if Vbus signal is not
available. If Vbus signal is available we set the Vbus signal as a wake
up source then we stop the USBA itself and all clocks used by USBA.

On resume: We recover clocks and USBA if we stopped them. If a device is
currently connected at resume time we enable the controller.

Signed-off-by: Sylvain Rochet <sylvain.rochet@finsecur.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: atmel_usba_udc: condition clocks to vbus state
Sylvain Rochet [Thu, 12 Feb 2015 17:54:06 +0000 (18:54 +0100)]
usb: gadget: atmel_usba_udc: condition clocks to vbus state

If USB PLL is not necessary for other USB drivers (e.g. OHCI and EHCI)
we will reduce power consumption by switching off the USB PLL if no USB
Host is currently connected to this USB Device.

We are using Vbus GPIO signal to detect Host presence. If Vbus signal is
not available then the device stays continuously clocked.

Signed-off-by: Sylvain Rochet <sylvain.rochet@finsecur.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: atmel_usba_udc: Request an auto disabled Vbus signal IRQ
Sylvain Rochet [Thu, 12 Feb 2015 17:54:05 +0000 (18:54 +0100)]
usb: gadget: atmel_usba_udc: Request an auto disabled Vbus signal IRQ

Vbus IRQ handler needs a started UDC driver to work because it uses
udc->driver, which is set by the UDC start handler. The previous way
chosen was to return from interrupt if udc->driver is NULL using a
spinlock around the check.

We now request an auto disabled (IRQ_NOAUTOEN) Vbus signal IRQ instead
of an auto enabled IRQ followed by disable_irq(). This way we remove the
very small timeslot of enabled IRQ which existed previously between
request() and disable(). We don't need anymore to check if udc->driver
is NULL in IRQ handler.

Signed-off-by: Sylvain Rochet <sylvain.rochet@finsecur.com>
Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: atmel_usba_udc: Fixed vbus_prev initial state
Sylvain Rochet [Thu, 12 Feb 2015 17:54:04 +0000 (18:54 +0100)]
usb: gadget: atmel_usba_udc: Fixed vbus_prev initial state

If vbus gpio is high at init, we should set vbus_prev to true
accordingly to the current vbus state. Without that, we skip the first
vbus interrupt because the saved vbus state is not consistent.

Signed-off-by: Sylvain Rochet <sylvain.rochet@finsecur.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: phy: fixed comment typo
Mickael Maison [Sun, 8 Mar 2015 19:26:52 +0000 (19:26 +0000)]
usb: phy: fixed comment typo

Fixed a comment typo in drivers/usb/phy/of.c

Signed-off-by: Mickael Maison <mickael.maison@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: phy: ab8500: fixed comment typo
Mickael Maison [Sun, 8 Mar 2015 19:24:02 +0000 (19:24 +0000)]
usb: phy: ab8500: fixed comment typo

Fixed a comment typo in drivers/usb/phy/phy-ab8500-usb.c

Signed-off-by: Mickael Maison <mickael.maison@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: use defined constant instead of numeric value
Tal Shorer [Fri, 6 Mar 2015 19:53:32 +0000 (21:53 +0200)]
usb: gadget: f_mass_storage: use defined constant instead of numeric value

replace numeric value with TYPE_NO_LUN (defined in <scsi/scsi.h>)

Signed-off-by: Tal Shorer <tal.shorer@gmail.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: Fix typo fond in Documentation/Docbook/gadget.xml
Masanari Iida [Tue, 10 Mar 2015 13:37:46 +0000 (22:37 +0900)]
usb: gadget: Fix typo fond in Documentation/Docbook/gadget.xml

This patch fix some spelling typo found in gadget.xml.
It is because this file is generated from comments in sources,
I had to fix comments in the source, instead of xml file itself.

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: dsps: don't fake of_node to musb core
Felipe Balbi [Tue, 10 Mar 2015 15:42:12 +0000 (10:42 -0500)]
usb: musb: dsps: don't fake of_node to musb core

If we pass our own of_node to musb_core, at least
pinctrl settings will be duplicated, meaning that
pinctrl framework will try to select default pin
state for musb_core when they were already requested
by musb-dsps.

A Warning will be printed however things will still
work.

Reported-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: dsps: request phy using our device pointer
Felipe Balbi [Wed, 11 Mar 2015 15:18:40 +0000 (10:18 -0500)]
usb: musb: dsps: request phy using our device pointer

musb shouldn't have of_node and phy phandle is passed
to dsps device, not musb's.

Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: add configfs support
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:32 +0000 (10:52 +0100)]
usb: gadget: printer: add configfs support

Add support for configfs interface so that f_printer can be used as a
component of usb gadgets composed with it.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: use module_usb_composite_driver helper macro
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:31 +0000 (10:52 +0100)]
usb: gadget: printer: use module_usb_composite_driver helper macro

Substitute some boilerplate code with a dedicated macro.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_printer: remove compatibility layer
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:30 +0000 (10:52 +0100)]
usb: gadget: f_printer: remove compatibility layer

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

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: convert to new interface of f_printer
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:29 +0000 (10:52 +0100)]
usb: gadget: printer: convert to new interface of f_printer

The goal is to remove the old function interface, so its (only) user
must be converted to the new interface.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_printer: convert to new function interface with backward compatibility
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:28 +0000 (10:52 +0100)]
usb: gadget: f_printer: convert to new function interface with backward compatibility

In order to add configfs support, a usb function must be converted to use
the new interface. This patch converts the function to the new interface
and provides backward compatiblity layer, which can be removed after
all its users are converted to use the new interface.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: factor out f_printer
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:27 +0000 (10:52 +0100)]
usb: gadget: printer: factor out f_printer

The legacy printer gadget now contains both a reusable printer function
and legacy gadget proper implementations interwoven, but logically
separate. This patch factors out a reusable f_printer.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: allocate printer_dev instances dynamically
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:26 +0000 (10:52 +0100)]
usb: gadget: printer: allocate printer_dev instances dynamically

With all the obstacles removed it is possible to allow more than one
instance of the printer function. Since the function requires allocating
character device region, a maximum number of allowed instances is defined.
Such an approach is used in f_acm and in f_hid.
With multiple instances it does not make sense to depend on a
lock_printer_io member of a dynamically allocated (and destroyed) struct
printer_dev to clean up after all instances of the printer function.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: add req_match for printer function
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:25 +0000 (10:52 +0100)]
usb: gadget: printer: add req_match for printer function

Verify that a given usb_ctrlrequest is meant for printer function.
The following parts of the request are tested:

- bmRequestType:Data transfer direction
- bmRequestType:Type
- bmRequestType:Recipient
- bRequest
- wValue for bRequest 1 and 2
- wLength

Additionally, the request is considered meant for this function
iff the decoded interface number matches dev->interface.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: name class specific requests
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:24 +0000 (10:52 +0100)]
usb: gadget: printer: name class specific requests

Avoid using magic numbers.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: composite: add req_match method to usb_function
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:23 +0000 (10:52 +0100)]
usb: gadget: composite: add req_match method to usb_function

Non-standard requests can encode the actual interface number in a
non-standard way. For example composite_setup() assumes
that it is w_index && 0xFF, but the printer function encodes the interface
number in a context-dependet way (either w_index or w_index >> 8).
This can lead to such requests being directed to wrong functions.

This patch adds req_match() method to usb_function. Its purpose is to
verify that a given request can be handled by a given function.
If any function within a configuration provides the method and it returns
true, then it is assumed that the right function is found.

If a function uses req_match(), it should try as hard as possible to
determine if the request is meant for it.

If no functions in a configuration provide req_match or none of them
returns true, then fall back to the usual approach.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: add container_of helper for printer_dev
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:22 +0000 (10:52 +0100)]
usb: gadget: printer: add container_of helper for printer_dev

5 uses of container_of() in the same context justify wrapping it
in a static inline function.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: don't access file global usb_printer_gadget in function's code
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:21 +0000 (10:52 +0100)]
usb: gadget: printer: don't access file global usb_printer_gadget in function's code

The printer_dev can be recovered from printer_func_unbind() function's
parameters.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: eliminate file global printer_mutex
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:20 +0000 (10:52 +0100)]
usb: gadget: printer: eliminate file global printer_mutex

The mutex is a legacy after semi-automatic Big Kernel Lock removal.
printer_open() does its own locking, so no need to duplicate it.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: call gprinter_setup() from gadget's bind
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:19 +0000 (10:52 +0100)]
usb: gadget: printer: call gprinter_setup() from gadget's bind

Call gprinter_setup() from gadget's bind instead of module's init.
Call gprinter_cleaup() corerspondingly. This detaches printer function's
logic from legacy printer gadget's implementation.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: add setup and cleanup functions
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:18 +0000 (10:52 +0100)]
usb: gadget: printer: add setup and cleanup functions

Factor out gprinter_setup() and gprinter_cleanup() so that it is
easy to change the place they are called from.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: don't access file global pnp_string in function's code
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:17 +0000 (10:52 +0100)]
usb: gadget: printer: don't access file global pnp_string in function's code

In order to factor out a reusable f_printer, the function's code should
not use file global variables related to legacy printer gadget's
implementation.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: define pnp string buffer length
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:16 +0000 (10:52 +0100)]
usb: gadget: printer: define pnp string buffer length

Avoid using magic numbers.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: move function-related unbind code to function's unbind
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:15 +0000 (10:52 +0100)]
usb: gadget: printer: move function-related unbind code to function's unbind

In order to factor out a reusable f_printer.c, the code related to the
function should be placed in functions related to the function.

printer_cfg_unbind() becomes empty, so it is removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: call usb_add_function() last
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:14 +0000 (10:52 +0100)]
usb: gadget: printer: call usb_add_function() last

Conversion to the new function interface requires splitting a
<something>_bind_config() function into two parts: allocation of
container_of struct usb_function and invocation of usb_add_function().
This patch moves the latter to the end of the f_printer_bind_config()
in order to enable conversion to the new interface.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: move function-related bind code to function's bind
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:13 +0000 (10:52 +0100)]
usb: gadget: printer: move function-related bind code to function's bind

In order to factor out a reusable f_printer.c, the code related to the
function should be placed in functions related to the function.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: standardize printer_do_config
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:12 +0000 (10:52 +0100)]
usb: gadget: printer: standardize printer_do_config

Follow the convention of distributing source code between
<something>_do_config() and <something>_bind_config().

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: follow the naming convention for usb_add_config callback
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:11 +0000 (10:52 +0100)]
usb: gadget: printer: follow the naming convention for usb_add_config callback

Legacy gadgets, before converting them to the new function framework,
used to use the name <something>_do_config() for usb_add_config()'s
callback.

This patch changes the name so that it is easier to follow
the convention.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: eliminate pdev member of struct printer_dev
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:10 +0000 (10:52 +0100)]
usb: gadget: printer: eliminate pdev member of struct printer_dev

The pdev member of struct printer_dev is not used outside
printer_bind_config(), so it can just as well be a local variable there.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: add missing error handling
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:09 +0000 (10:52 +0100)]
usb: gadget: printer: add missing error handling

If cdev_add() in printer_bind_config() fails, care is taken to
reverse the effects of initializations completed until the fail
happens. But if printer_req_alloc() fails, it is just one of the
two lists that is cleaned up while the effects of cdev_add()
and device_create() are not reverted.

This patch changes error handling so that at least as much cleanup is done
as when a failure happens before printer_req_alloc() invocations.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: revert usb_add_function() effect in error recovery
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:08 +0000 (10:52 +0100)]
usb: gadget: printer: revert usb_add_function() effect in error recovery

Whenever the "goto fail" branch is taken, the effect of usb_add_function()
should be reverted.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: eliminate random pointer dereference
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:07 +0000 (10:52 +0100)]
usb: gadget: printer: eliminate random pointer dereference

struct printer_dev contains 3 list heads: tx_reqs, rx_reqs and rx_buffers.
There is just one instance of this structure in the driver and it is
file static, and as such initialized with all zeros.

If device_create() or cdev_add() fails then "goto fail" branch is taken,
which results in printer_cfg_unbind() call. The latter checks if
tx_reqs, rx_reqs and rx_buffers lists are empty. The check for emptiness
is in fact a check whether the "next" member of struct list_head points
to the head of the list. But the heads of the lists in question have
not been initialized yet and, as mentioned above, contain all zeros,
so list_empty() returns false and respective "while" loop body starts
executing. Here, container_of() just subtracts the offset of a struct
usb_request member from an address of this same member, which results in
a value somewhere near 0 or 0xfff...ff. And the argument to list_del()
dereferences such a pointer which causes a disaster.

This patch moves respective INIT_LIST_HEAD() invocations to a point before
"goto fail" branch can be taken.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: remove unused and empty printer_unbind
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:06 +0000 (10:52 +0100)]
usb: gadget: printer: remove unused and empty printer_unbind

The unbind() method is optional is usb_composite_driver.
In this particular driver the method does nothing so it can be removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: printer: enqueue printer's response for setup request
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:05 +0000 (10:52 +0100)]
usb: gadget: printer: enqueue printer's response for setup request

Function-specific setup requests should be handled in such a way, that
apart from filling in the data buffer, the requests are also actually
enqueued: if function-specific setup is called from composte_setup(),
the "usb_ep_queue()" block of code in composite_setup() is skipped.

The printer function lacks this part and it results in e.g. get device id
requests failing: the host expects some response, the device prepares it
but does not equeue it for sending to the host, so the host finally asserts
timeout.

This patch adds enqueueing the prepared responses.

Cc: <stable@vger.kernel.org> # v3.4+
Fixes: 2e87edf49227: "usb: gadget: make g_printer use composite"
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: composite: don't try standard handling for non-standard requests
Andrzej Pietrasiewicz [Tue, 3 Mar 2015 09:52:04 +0000 (10:52 +0100)]
usb: gadget: composite: don't try standard handling for non-standard requests

If a non-standard request is processed and its parameters just happen
to match those of some standard request, the logic of composite_setup()
can be fooled, so don't even try any switch cases, just go to the
proper place where unknown requests are handled.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: dwc3: make LPM configurable in DT
Robert Baldyga [Mon, 9 Mar 2015 14:06:12 +0000 (15:06 +0100)]
usb: dwc3: make LPM configurable in DT

This patch removes "Enable USB3 LPM Capability" option from Kconfig
and adds snps,usb3_lpm_capable devicetree property instead of it.

USB3 LPM (Link Power Management) capability is hardware property, and
it's platform dependent, so if our hardware supports this feature, we
want rather to configure it in devicetree than having it as Kconfig option.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: dsps: just start polling already
Felipe Balbi [Sat, 28 Feb 2015 01:07:49 +0000 (19:07 -0600)]
usb: musb: dsps: just start polling already

there's no need to fake an IRQ, just check
if VBUS is valid already.

Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: dsps: use msecs_to_jiffies instead
Felipe Balbi [Sat, 28 Feb 2015 01:02:41 +0000 (19:02 -0600)]
usb: musb: dsps: use msecs_to_jiffies instead

when polling, we were using n * HZ (where n is
an integer in seconds), however HZ isn't always
correct if we're using cpufreq. A better way
is to use msecs_to_jiffies(n) (where n is now
an integer in miliseconds).

while at that, also rename poll_seconds to poll_timeout
and  change its type to unsigned int.

Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: cppi41: do not call udelay()
Felipe Balbi [Fri, 27 Feb 2015 19:22:27 +0000 (13:22 -0600)]
usb: musb: cppi41: do not call udelay()

according to comment in code, HS completion
will happen pretty fast, instead of using
udelay(), let's just busy loop and drop a
cpu_relax() where udelay() was.

Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: cppi41: exit early when tx fifo is empty
Felipe Balbi [Fri, 27 Feb 2015 19:21:14 +0000 (13:21 -0600)]
usb: musb: cppi41: exit early when tx fifo is empty

as soon as we find out tx fifo is empty, there's
no need to break out of the loop just to have another
branch to complete the transfer. We can just complete
transfer and exit early.

Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: cppi41: decrease indentation level
Felipe Balbi [Fri, 27 Feb 2015 19:19:39 +0000 (13:19 -0600)]
usb: musb: cppi41: decrease indentation level

no functional changes, clean up only.

Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: net2280: silence sparse warning
Felipe Balbi [Fri, 27 Feb 2015 15:44:51 +0000 (09:44 -0600)]
usb: gadget: net2280: silence sparse warning

Silence the following warning:

drivers/usb/gadget/udc/net2280.c:3176:33: warning: context imbalance in
'handle_stat1_irqs' - unexpected unlock

Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: net2280: don't connect from udc_start
Mian Yousaf Kaukab [Mon, 2 Feb 2015 09:55:26 +0000 (10:55 +0100)]
usb: gadget: net2280: don't connect from udc_start

net2280_start can be called with pullup disabled. Don't set
softconnect flag in it. Let net2280_pullup handle the connection part.

Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: net2280: print error in ep_ops error paths
Mian Yousaf Kaukab [Mon, 2 Feb 2015 09:55:25 +0000 (10:55 +0100)]
usb: gadget: net2280: print error in ep_ops error paths

Hopefully, these prints will help localize the problems faster.

[ balbi@ti.com: removed 2 unnecessary OOM error messages ]

Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: net2280: remove fiforegs as it is unused
Mian Yousaf Kaukab [Mon, 2 Feb 2015 09:55:24 +0000 (10:55 +0100)]
usb: gadget: net2280: remove fiforegs as it is unused

Remove fiforegs from struct net2280 and net2280_ep as it is unused.
By the way, ep->fiforegs = &dev->fiforegs[i] assignment is incorrect.
It should be ep->fiforegs = &dev->fiforegs[ne[i]], but it doesn't
matter now.

Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: net2280: use ep_autoconfig compatible names in advance mode
Mian Yousaf Kaukab [Mon, 2 Feb 2015 09:55:23 +0000 (10:55 +0100)]
usb: gadget: net2280: use ep_autoconfig compatible names in advance mode

Each struct usb_ep added for net2280 can be used in either direction.
Whereas, each struct usb_ep for usb3380 has fixed direction. Use
ep_autoconf compatible names so that endpoint with correct direction
can be selected.

Name sequence is due to the logic in usb_reinit_338x() in ne[] and
ep_reg_addr[].

Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: always try to recover from babble
Felipe Balbi [Thu, 26 Feb 2015 20:43:57 +0000 (14:43 -0600)]
usb: musb: core: always try to recover from babble

we can also have babble conditions with LS/FS
and we also want to recover in that case.

Because of that we will drop the check of HSMODE
and always try to run babble recovery.

Suggested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: disable irqs inside babble recovery
Felipe Balbi [Thu, 26 Feb 2015 20:42:19 +0000 (14:42 -0600)]
usb: musb: core: disable irqs inside babble recovery

There's no point is splitting those anymore.

We're now also able to drop another forward
declaration.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: remove unnecessary forward declaration
Felipe Balbi [Thu, 26 Feb 2015 20:33:41 +0000 (14:33 -0600)]
usb: musb: core: remove unnecessary forward declaration

no functional changes, cleanup only.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: drop recover_work
Felipe Balbi [Thu, 26 Feb 2015 20:27:12 +0000 (14:27 -0600)]
usb: musb: core: drop recover_work

that's not needed anymore. Everything that we
call is irq-safe, so we might as well not
have a delayed work for babble recovery.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: rename ->reset() to ->recover()
Felipe Balbi [Thu, 26 Feb 2015 20:20:58 +0000 (14:20 -0600)]
usb: musb: rename ->reset() to ->recover()

recover is a much better name than reset, considering
we don't really reset the IP, just run platform-specific
babble recovery algorithm.

while at that, also fix a typo in comment and add kdoc
for recover memeber of platform_ops.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: simplify musb_recover_work()
Felipe Balbi [Thu, 26 Feb 2015 20:02:35 +0000 (14:02 -0600)]
usb: musb: core: simplify musb_recover_work()

we're not resetting musb at all, just restarting
the session. This means we don't need to touch PHYs
or VBUS or anything like that. Just make sure session
bit is reenabled after MUSB dropped it.

while at that, make sure to tell usbcore that we're
dropping the session and, thus, disconnecting the
device.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: dsps: do not reset musb on babble
Felipe Balbi [Thu, 26 Feb 2015 20:00:52 +0000 (14:00 -0600)]
usb: musb: dsps: do not reset musb on babble

All we have to do is, really, drop session bit
and let the session restart.

Big thanks goes to Bin Liu <b-liu@ti.com> for
inspiring this work.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: decrease delayed_work time
Felipe Balbi [Thu, 26 Feb 2015 17:35:13 +0000 (11:35 -0600)]
usb: musb: core: decrease delayed_work time

When babble IRQ happens, we need to wait only
5.3us (320 cycles of 60MHz clock), we will give
it some slack and schedule our work a 10 usecs into
the future.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: don't touch devctl from babble recovery
Felipe Balbi [Thu, 26 Feb 2015 17:31:49 +0000 (11:31 -0600)]
usb: musb: don't touch devctl from babble recovery

We do *not* want to touch devctl at all when
trying to recover from babble. All we want to
do is mask IRQs until we're done without our
babble recovery, at which point we will unmask
IRQs.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: refactor IRQ enable/disable to separate functions
Felipe Balbi [Thu, 26 Feb 2015 17:26:09 +0000 (11:26 -0600)]
usb: musb: core: refactor IRQ enable/disable to separate functions

sometimes we want to just mask/unmask interrupts
without touching devctl register. For those
cases, let's introduce musb_enable_interrupts and
musb_disable_interrupts()

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: dsps: add dsps_ prefix to sw_babble_control
Felipe Balbi [Thu, 26 Feb 2015 17:11:33 +0000 (11:11 -0600)]
usb: musb: dsps: add dsps_ prefix to sw_babble_control

this makes it easier to filter function traces.
No functional changes.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: controller drops session automatically
Felipe Balbi [Thu, 26 Feb 2015 17:09:20 +0000 (11:09 -0600)]
usb: musb: core: controller drops session automatically

Whenever babble happens, MUSB controller will
drop session automatically.

The only case where it won't drop the session,
is when we're running on AM335x and SW_SESSION_CTRL
bit has been set. In that case, controller will
not touch session bit so SW has a chance to recover
from babble condition.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: dsps: check for the single bit
Felipe Balbi [Thu, 26 Feb 2015 17:01:03 +0000 (11:01 -0600)]
usb: musb: dsps: check for the single bit

We want to check if that particular bit is
set. It could very well be that bootloader
(or romcode) has fiddled with MUSB before
us which could leave other bits set in this
register.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: dsps: remove babble check from dsps irq handler
Felipe Balbi [Wed, 25 Feb 2015 22:04:39 +0000 (16:04 -0600)]
usb: musb: dsps: remove babble check from dsps irq handler

musb->int_usb already contains the correct
information for musb-core to handle babble.

In fact, this very check was just causing a
nonsensical babble interrupt storm.

With this I can get test.sh to run and, even though
all tests fail with timeout, that's still better
than locking up the system due to IRQ storm.

Also, if I remove g_zero and load g_mass_storage,
then everything works fine again.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: there is no connect interrupt in peripheral mode
Felipe Balbi [Wed, 25 Feb 2015 20:48:50 +0000 (14:48 -0600)]
usb: musb: core: there is no connect interrupt in peripheral mode

MUSB does not generate a connect IRQ when working
in peripheral mode.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: remove unnecessary reg access from resume IRQ
Felipe Balbi [Wed, 25 Feb 2015 20:30:55 +0000 (14:30 -0600)]
usb: musb: core: remove unnecessary reg access from resume IRQ

when musb is operating as host and a remote wakeup
fires up, a resume interrupt will be raised. At that
point SUSPENDM bit is automatically cleared and
RESUME bit is automatically set.

Remove those two from IRQ handler.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: break long line
Felipe Balbi [Wed, 25 Feb 2015 20:14:15 +0000 (14:14 -0600)]
usb: musb: core: break long line

no functional changes, clean up only.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: move babble recovery inside babble check
Felipe Balbi [Wed, 25 Feb 2015 20:07:52 +0000 (14:07 -0600)]
usb: musb: core: move babble recovery inside babble check

There was already a proper place where we were
checking for babble interrupts, move babble
recovery there.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: dsps: return error code if reset fails
Felipe Balbi [Thu, 26 Feb 2015 16:55:13 +0000 (10:55 -0600)]
usb: musb: dsps: return error code if reset fails

if reset fails, we should return a *negative*
error code, not a positive value.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: fix highspeed check
Felipe Balbi [Thu, 26 Feb 2015 16:54:27 +0000 (10:54 -0600)]
usb: musb: core: fix highspeed check

FSDEV is set for both HIGH and FULL speeds,
the correct HIGHSPEED check is done through
power register's HSMODE bit.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: add missing curly braces
Felipe Balbi [Wed, 25 Feb 2015 20:05:15 +0000 (14:05 -0600)]
usb: musb: core: add missing curly braces

no functional changes, clean up only.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: musb: core: remove unnecessary logical comparison
Felipe Balbi [Wed, 25 Feb 2015 20:03:23 +0000 (14:03 -0600)]
usb: musb: core: remove unnecessary logical comparison

devctl & MUSB_DEVCTL_HM represents a single bit,
just check for the bit, there's really no need
to compare the result against 0.

Tested-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>