platform/kernel/linux-rpi.git
7 years agoxhci: use correct flags for spin_lock_irqrestore() when setting port power
Mathias Nyman [Thu, 13 Apr 2017 11:01:04 +0000 (14:01 +0300)]
xhci: use correct flags for spin_lock_irqrestore() when setting port power

commit a6ff6cbf1fab ("usb: xhci: Add helper function xhci_set_power_on().")
created a helper to control port power that needs to be called with
xhci->lock held and interrupts disabled.
It released the lock with spin_unlock_irqrestore using a new zero flag
variable instead of the original flag from spin_lock_irqsave.
This regression triggered a static checker warning about bogus flags, and
a null pointer dereference on armada-385.

Fix it by passing a pointer to the correct flags and using it instead

Fixes: a6ff6cbf1fab ("usb: xhci: Add helper function xhci_set_power_on().")
Cc: Guoqing Zhang <guoqing.zhang@intel.com>
Reported-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
Tested-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoMerge tag 'usb-for-v4.12' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi...
Greg Kroah-Hartman [Tue, 11 Apr 2017 14:47:26 +0000 (16:47 +0200)]
Merge tag 'usb-for-v4.12' of git://git./linux/kernel/git/balbi/usb into usb-next

Felipe writes:

usb: changes for v4.12

With 51 non-merge commits, this is one of the smallest USB Gadget pull
requests. Apart from your expected set of non-critical fixes, and
other miscellaneous items, we have most of the changes in dwc3 (52.5%)
with all other UDCs following with 34.8%.

As for the actual changes, the most important of them are all the
recent changes to reduce memory footprint of dwc3, bare minimum
dual-role support on dwc3 and reworked endpoint count and
initialization routines.

7 years agousb: gadget: udc: atmel: Update Kconfig help for fifo_mode = 0
Cristian Birsan [Fri, 7 Apr 2017 16:07:22 +0000 (19:07 +0300)]
usb: gadget: udc: atmel: Update Kconfig help for fifo_mode = 0

Update Kconfig help for fifo_mode = 0 to explain the behavior better.

Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: udc: atmel: Use dev_err() to display EP configuration error
Cristian Birsan [Fri, 7 Apr 2017 16:07:21 +0000 (19:07 +0300)]
usb: gadget: udc: atmel: Use dev_err() to display EP configuration error

Use dev_err() to display EP configuration error to avoid silent failure.

Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: Add dual-role support
Roger Quadros [Wed, 5 Apr 2017 10:39:31 +0000 (13:39 +0300)]
usb: dwc3: Add dual-role support

If dr_mode is "otg" then support dual role mode of operation.
Currently this mode is only supported when an extcon handle is
present in the dwc3 device tree node. This is needed to
get the ID status events of the port.

We're using a workqueue to manage the dual-role state transitions
as the extcon notifier (dwc3_drd_notifier) is called in an atomic
context by extcon_sync() and this doesn't go well with
usb_del_gadget_udc() causing a lockdep and softirq warning.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: core: make dwc3_set_mode() work properly
Roger Quadros [Tue, 4 Apr 2017 09:49:18 +0000 (12:49 +0300)]
usb: dwc3: core: make dwc3_set_mode() work properly

We can't have both Host and Peripheral roles active at the same time
because of one detail on DWC3: it shares the same memory area for both
Host and Peripheral registers.

When swapping roles we must reinitialize the new role every
time. Let's make sure this works for our debugfs interface.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: debugfs: remove unnecessary | operator
Roger Quadros [Tue, 4 Apr 2017 08:27:57 +0000 (11:27 +0300)]
usb: dwc3: debugfs: remove unnecessary | operator

Each role is mutually exclusive, the | operator is unnecessary. Remove
it.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: core: add current_dr_role member
Roger Quadros [Tue, 4 Apr 2017 08:25:27 +0000 (11:25 +0300)]
usb: dwc3: core: add current_dr_role member

We're going to use this member to track which role we're currently
playing, that way we can more easily implement dual-role swap in
upcoming patches.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: udc: allow adding and removing the same gadget device
Roger Quadros [Mon, 3 Apr 2017 12:20:29 +0000 (15:20 +0300)]
usb: udc: allow adding and removing the same gadget device

allow usb_del_gadget_udc() and usb add_gadget_udc() to be called
repeatedly on the same gadget->dev structure.

We need to clear the gadget->dev structure so that kobject_init()
doesn't complain about already initialized object.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: simplify ZLP handling
Felipe Balbi [Fri, 7 Apr 2017 13:34:38 +0000 (16:34 +0300)]
usb: dwc3: simplify ZLP handling

It's much simpler to just add one extra TRB chained to previous TRB to
handle ZLP. This helps us reduce pointless allocations and simplifies
the code a little bit.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: ep0: improve handling of unaligned OUT requests
Felipe Balbi [Fri, 7 Apr 2017 11:09:13 +0000 (14:09 +0300)]
usb: dwc3: ep0: improve handling of unaligned OUT requests

Just like we did for all other endpoint types, let's rely on a chained
TRB pointing to ep0_bounce_addr in order to align transfer size. This
will make the code simpler.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: ep0: pass dep as argument to internal functions
Felipe Balbi [Fri, 7 Apr 2017 10:47:49 +0000 (13:47 +0300)]
usb: dwc3: ep0: pass dep as argument to internal functions

Instead of constantly recomputing how dwc and epnum relate to dep,
just pass dep as argument.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: ep0: use immediate SETUP on TRB
Felipe Balbi [Fri, 7 Apr 2017 10:34:21 +0000 (13:34 +0300)]
usb: dwc3: ep0: use immediate SETUP on TRB

If we pass TRB's own address on bpl/bph fields, we can get our SETUP
packet as immediate data on the TRB itself, without having to allocate
extra memory for it.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: mv_u3d: fix error handling in mv_u3d_probe()
Alexey Khoroshilov [Fri, 31 Mar 2017 21:07:18 +0000 (00:07 +0300)]
usb: gadget: mv_u3d: fix error handling in mv_u3d_probe()

There are several inconsistencies in the error handling code.
1. If clk_get() fails, it goes to clk_put().
2. If pdata->phy_init() fails, it does not disable u3d->clk.
3. In case of failure after stopping u3d, it does pdata->phy_deinit()
   and clk_disable(u3d->clk) twice.
4. It ignores failures in clk_enable().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: udc: atmel: Check fifo configuration values against device tree
Cristian Birsan [Mon, 3 Apr 2017 07:19:51 +0000 (10:19 +0300)]
usb: gadget: udc: atmel: Check fifo configuration values against device tree

Check fifo configuration values against device tree values for endpoint fifo
in auto configuration mode (fifo_mode=0).

Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agofsl_udc_core: add support for devices provided by fsl-mph-dr-of
Michael Grzeschik [Tue, 4 Apr 2017 14:41:54 +0000 (16:41 +0200)]
fsl_udc_core: add support for devices provided by fsl-mph-dr-of

Currently the of glue code in fsl-mph-dr-of will create the platform
device fsl-usb2-udc. As this driver should also be probed by this name,
this patch adds it to the devtypes list.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: expose dwc3_trb_type_string()
Felipe Balbi [Fri, 31 Mar 2017 11:44:09 +0000 (14:44 +0300)]
usb: dwc3: expose dwc3_trb_type_string()

That helper can be used from our tracepoint interface with very minor
edits. Let's do so.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: debugfs: return strings that match tracepoints
Felipe Balbi [Fri, 31 Mar 2017 11:37:21 +0000 (14:37 +0300)]
usb: dwc3: debugfs: return strings that match tracepoints

In order to improve usability a tiny bit, we will return strings that
match what our tracepoints return.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: debugfs: make use of dwc3_gadget_link_string()
Felipe Balbi [Fri, 31 Mar 2017 11:28:33 +0000 (14:28 +0300)]
usb: dwc3: debugfs: make use of dwc3_gadget_link_string()

Instead of redecoding link state into a string, use our helper.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: debugfs: downcase OTG on 'mode' file
Felipe Balbi [Fri, 31 Mar 2017 11:10:40 +0000 (14:10 +0300)]
usb: dwc3: debugfs: downcase OTG on 'mode' file

When writing, we expect the "otg" string. When showing, we return
"OTG". Let's downcase that word to avoid confusion.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: udc: amd5536: split core and PCI layer
Raviteja Garimella [Tue, 28 Mar 2017 11:02:03 +0000 (16:32 +0530)]
usb: gadget: udc: amd5536: split core and PCI layer

This patch splits the amd5536udc driver into two -- one that does
pci device registration and the other file that does the rest of
the driver tasks like the gadget/ep ops etc for Synopsys UDC.

This way of splitting helps in exporting core driver symbols which
can be used by any other platform/pci driver that is written for
the same Synopsys USB device controller.

The current patch also includes a change in the Kconfig and Makefile.
A new config option USB_SNP_CORE will be selected automatically when
any one of the platform or pci driver for the same UDC is selected.

Main changes:
- amd5536udc_pci.c: PCI device registration is moved to this file.

- amd5536udc.c:
  This file does rest of the core UDC fucntionality.
  9 symbols are exported so as to be used by amd5536udc_pci.c.
  Module parameter definitions are moved to header file.

- amd5536udc.h:
  Function declarations, module parameters definitions and few common
  header file includes are added to this file

- Kconfig:
  New USB_SNP_CORE option is added which will be auto selected when
  any pci or platform driver config option for the UDC is chosen.

- Makefile:
  Compiles the core and pci files separately.

Signed-off-by: Raviteja Garimella <raviteja.garimella@broadcom.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: udc: renesas_usb3: add support for usb role swap
Yoshihiro Shimoda [Fri, 31 Mar 2017 03:58:05 +0000 (12:58 +0900)]
usb: gadget: udc: renesas_usb3: add support for usb role swap

This patch adds support for usb role swap via sysfs "role".

For example:
 1) Connect a usb cable using 2 Salvator-X boards.
  - For A-Device, the cable is connected to CN11 (USB3.0 ch0).
  - For B-Device, the cable is connected to CN9 (USB2.0 ch0).
 2) On A-Device, you input the following command:
  # echo peripheral > /sys/devices/platform/soc/ee020000.usb/role
 3) On B-Device, you input the following command:
  # echo host > /sys/devices/platform/soc/ee080200.usb-phy/role

Then, the A-Device acts as a peripheral and the B-Device acts as
a host. Please note that A-Device must input the following command
if you want the board to act as a host again.
 # echo host > /sys/devices/platform/soc/ee020000.usb/role

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: udc: atmel: Minor code cleanup
Cristian Birsan [Tue, 28 Mar 2017 16:07:37 +0000 (19:07 +0300)]
usb: gadget: udc: atmel: Minor code cleanup

Minor code cleanup based on feedback received on mailinglist.

Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: udc: renesas_usb3: add extcon support
Yoshihiro Shimoda [Thu, 30 Mar 2017 02:16:05 +0000 (11:16 +0900)]
usb: gadget: udc: renesas_usb3: add extcon support

This patch adds extcon support to see VBUS/ID signal states.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: udc: renesas_usb3: add USB ID signal monitoring
Yoshihiro Shimoda [Thu, 30 Mar 2017 02:16:04 +0000 (11:16 +0900)]
usb: gadget: udc: renesas_usb3: add USB ID signal monitoring

This usb 3.0 peripheral controller has a register (USB_OTG_STA) to monitor
the USB ID signal. So, this patch adds the ID signal monitoring to change
the mode to host (A-Host) or peripheral (B-Peripheral).
This patch also removes hardcoded setting as B-Peripheral mode.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: otg-fsm: Prevent build warning "VDBG" redefined
Roger Quadros [Thu, 30 Mar 2017 06:46:41 +0000 (09:46 +0300)]
usb: otg-fsm: Prevent build warning "VDBG" redefined

If usb/otg-fsm.h and usb/composite.h are included together
then it results in the build warning [1].

Prevent that by defining VDBG locally.

Also get rid of MPC_LOC which doesn't seem to be used
by anyone.

[1] - warning fixed by this patch:

In file included from drivers/usb/dwc3/core.h:33,
   from drivers/usb/dwc3/ep0.c:33:
   include/linux/usb/otg-fsm.h:30:1: warning: "VDBG" redefined
   In file included from drivers/usb/dwc3/ep0.c:31:
   include/linux/usb/composite.h:615:1: warning: this is the location
   of the previous definition

Signed-off-by: Roger Quadros <rogerq@ti.com>
Reviewed-by: Jun Li <jun.li@nxp.com>
Acked-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: use BIT() macro where possible
Roger Quadros [Thu, 30 Mar 2017 06:46:40 +0000 (09:46 +0300)]
usb: dwc3: use BIT() macro where possible

To avoid checkpatch warnings with new patches let's
start using the BIT() macro wherever possible.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: f_fs: simplify ffs_dev name handling
Michal Nazarewicz [Fri, 10 Mar 2017 21:45:58 +0000 (22:45 +0100)]
usb: gadget: f_fs: simplify ffs_dev name handling

Currently ffs_dev::name can be either allocated by the client of
the ffs_dev structure or by the f_fs.c core itself.  The former
is used by g_ffs while the latter happens with configfs.

Historically, g_ffs did not need to allocate separate buffer for
the name so what is now f_fs.c core never cared about freeing
that space.  With configfs the name needs to be copied since the
memory is not guaranteed to be availeble after ffs_set_inst_name
finishes.

The complication is therefore here to avoid allocations in the
g_ffs case but it complicates the code inproportinally to
benefits it provides.  In particular, g_ffs is considered
‘legacy’ so optimising for its sake is unlikely to be worth the
effort.

With that observation in mind, simplify the code by unifying the
code paths in g_ffs and configfs paths.  Furthermore, instead of
allocating a new buffer for the name, simply embed it in the
ffs_dev structure.  This further makes the memory management
less convoluted and error-prone.

The configfs interface for functionfs imposed a limit of 40
characters for the name so this results in a 41-byte buffer
added to the structure.  (For short names this may lead to
wasted memory but the actual amount is not immediately obvious
and depends on pointer size and which slab buckets the structure
and name would fall into).

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: simplify optional reset handling
Philipp Zabel [Wed, 15 Mar 2017 11:31:53 +0000 (12:31 +0100)]
usb: dwc2: simplify optional reset handling

As of commit bb475230b8e5 ("reset: make optional functions really
optional"), the reset framework API calls use NULL pointers to describe
optional, non-present reset controls.

This allows to return errors from devm_reset_control_get_optional and to
call reset_control_(de)assert unconditionally.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: phy: Remove unused config
Baolin Wang [Thu, 23 Mar 2017 06:08:31 +0000 (14:08 +0800)]
usb: phy: Remove unused config

Since the old common Samsung USB PHY code has been removed by commit ea2fdf8423
("usb: phy: samsung: remove old common USB PHY code"), thus remove the unused
config.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: dummy_hcd: Fix wrong power status bit clear/reset in dummy_hub_control()
Yuyang Du [Thu, 23 Mar 2017 20:06:11 +0000 (04:06 +0800)]
usb: gadget: dummy_hcd: Fix wrong power status bit clear/reset in dummy_hub_control()

This fixes the commit: 1cd8fd2887e1 ("usb: gadget: dummy_hcd: add
SuperSpeed support").

In the case of ClearPortFeature and USB_PORT_FEAT_POWER, simply clear
the right bit regardless of what the wValue is.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Yuyang Du <yuyang.du@intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: mtu3: Replace the extcon API
Chanwoo Choi [Tue, 28 Mar 2017 04:42:02 +0000 (13:42 +0900)]
usb: mtu3: Replace the extcon API

This patch uses the resource-managed extcon API for extcon_register_notifier()
and replaces the deprecated extcon API as following:
- extcon_get_cable_state_() -> extcon_get_state()

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Chunfeng Yun <chunfeng.yun@mediatek.com>
Cc: linux-usb@vger.kernel.org
Tested-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Acked-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: u_ether: conditionally align transfer size
Felipe Balbi [Wed, 22 Mar 2017 11:25:18 +0000 (13:25 +0200)]
usb: gadget: u_ether: conditionally align transfer size

Unless HW sets quirk_ep_out_aligned_size, gadget driver shouldn't make
any efforts towards aligning transfers. If the UDC needs, it *must*
set the quirk flag.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: u_ether: use better list accessors
Felipe Balbi [Wed, 22 Mar 2017 11:24:34 +0000 (13:24 +0200)]
usb: gadget: u_ether: use better list accessors

We have helpers for some of these, let's rely on them instead of open
coding what they do in u_ether.c

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: trace: change format for string to cmd trace
Felipe Balbi [Wed, 22 Mar 2017 11:03:13 +0000 (13:03 +0200)]
usb: dwc3: trace: change format for string to cmd trace

a %x is much easier for a human to parse when reading tracepoint
output. Let's change it.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: reword configuration choices
Romain Izard [Fri, 10 Mar 2017 13:11:42 +0000 (14:11 +0100)]
usb: gadget: reword configuration choices

As USB_CONFIGFS is not a part of the "USB Gadget Drivers" choice
anymore, the name for the option and its attached description needs to
be more descriptive. It appears one level higher in the configuration
menu, and without the context provided by the comments for the choice
entry, it needs to make sense on its own.

Conversely, the "USB Gadget Drivers" entry now only introduces the
legacy drivers, where one or more functions are combined in a single
driver. As the configfs option can be used as a full-fledged
alternative, rename the choice entry to show that it is not the only
way to provice service as an USB gadget.

Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: legacy gadgets are optional
Romain Izard [Fri, 10 Mar 2017 13:11:41 +0000 (14:11 +0100)]
usb: gadget: legacy gadgets are optional

With commit bc49d1d17dcf ("usb: gadget: don't couple configfs to legacy
gadgets"),it is possible to build a modular kernel with both built-in
configfs support and modular legacy gadget drivers.

But when building a kernel without modules, it is also necessary to be
able to build with configfs but without any legacy gadget driver. This
was a possible configuration when the USB_CONFIGFS was a part of the
choice options, but not anymore.

Mark the choice for legacy gadget drivers as optional restores this.

Fixes: bc49d1d17dcf ("usb: gadget: don't couple configfs to legacy gadgets")
Cc: <stable@vger.kernel.org> # 4.9+
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: gadget: Fix starting microframe for ISOC
John Youn [Thu, 26 Jan 2017 19:58:40 +0000 (11:58 -0800)]
usb: dwc3: gadget: Fix starting microframe for ISOC

The gadget wants to set the starting microframe for the first ISOC TRB
to 4 microframes in the future, but it does so by multiplying the
dep->interval. This only works if dep->interval = 1. For other intervals
it will put it 4 *intervals* in the future which may be way too much.

Fix so that it always adds just one interval or at least 4 microframes.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: exynos: change goto labels to meaningful names
Shuah Khan [Mon, 30 Jan 2017 19:25:04 +0000 (12:25 -0700)]
usb: dwc3: exynos: change goto labels to meaningful names

Change goto labels to meaningful names from a series of errNs.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: remove dwc3_gadget_init_hw_endpoints
Bryan O'Donoghue [Tue, 31 Jan 2017 20:58:11 +0000 (20:58 +0000)]
usb: dwc3: remove dwc3_gadget_init_hw_endpoints

A previous patch in the series reduces the number of  callsites of
dwc3_gadget_init_hw_endpoints from two to one. This patch removes the
redundant step of wrappering one function in the other, which can be done
by adding a parameter to dwc3_gadget_init_endpoints and moving the
linked-list initialization of dwc->gadet.ep_list.

Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: refactor gadget endpoint count calculation
Bryan O'Donoghue [Tue, 31 Jan 2017 20:58:10 +0000 (20:58 +0000)]
usb: dwc3: refactor gadget endpoint count calculation

- DWC_USB3_NUM indicates the number of Device mode single directional
  endpoints, including OUT and IN endpoint 0.

- DWC_USB3_NUM_IN_EPS indicates the maximum number of Device mode IN
  endpoints active at any time, including control endpoint 0.

It's possible to configure RTL such that DWC_USB3_NUM_EPS is equal to
DWC_USB3_NUM_IN_EPS.

dwc3-core calculates the number of OUT endpoints as DWC_USB3_NUM minus
DWC_USB3_NUM_IN_EPS. If RTL has been configured with DWC_USB3_NUM_IN_EPS
equal to DWC_USB3_NUM then dwc3-core will calculate the number of OUT
endpoints as zero.

For example a from dwc3_core_num_eps() shows:
[    1.565000]  /usb0@f01d0000: found 8 IN and 0 OUT endpoints

This patch refactors the endpoint calculation down to one variable
dwc->num_eps taking care to maintain the current mapping of endpoints for
fixed FPGA configurations as described in Table 4-7 of version 2.60a of the
DWC USB3 databook.

The endpoint mapping will then be EP-OUT, EP-IN etc, up to DWC_USB3_NUM.
If DWC_USB3_NUM is odd then OUT will take the extra endpoint.

Suggested-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc3: make macros safe to expression arguments
Roger Quadros [Thu, 6 Apr 2017 10:14:28 +0000 (13:14 +0300)]
usb: dwc3: make macros safe to expression arguments

We must make sure that our macros are safe against expressions passed
as arguments. We have seen one problem where GTXFIFOSIZ(n) was failing
when passed the expression (epnum >> 1) as argument. The problem was
caused by operator precedence between >> and *.

To make sure macros are safe, we just wrap argument with () when using
it.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Add support for STM32F429/439/469 USB OTG HS/FS in FS mode (internal PHY)
Bruno Herrera [Wed, 1 Feb 2017 01:25:43 +0000 (23:25 -0200)]
usb: dwc2: Add support for STM32F429/439/469 USB OTG HS/FS in FS mode (internal PHY)

This patch introduces a new parameter to activate USB OTG HS/FS core
embedded phy transceiver. The STM32F4x9 SoC uses the GGPIO register
to enable the transceiver.
Also add the dwc2_set_params function for stm32f4 otg fs.

Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Bruno Herrera <bruherrera@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: udc: remove unnecessary variable and update function prototype
Gustavo A. R. Silva [Tue, 14 Feb 2017 22:03:02 +0000 (16:03 -0600)]
usb: gadget: udc: remove unnecessary variable and update function prototype

Remove unnecessary variable and update function prototype.

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: udc: avoid use of freed pointer
Gustavo A. R. Silva [Tue, 14 Feb 2017 21:58:33 +0000 (15:58 -0600)]
usb: gadget: udc: avoid use of freed pointer

Rewrite udc_free_dma_chain() function to avoid use of pointer after free.

Addresses-Coverity-ID: 1091172
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: dwc2: Make sure we disconnect the gadget state
John Stultz [Tue, 14 Feb 2017 04:08:08 +0000 (20:08 -0800)]
usb: dwc2: Make sure we disconnect the gadget state

I had seen some odd behavior with HiKey's usb-gadget interface
that I finally seemed to have chased down. Basically every other
time I plugged in the OTG port, the gadget interface would
properly initialize. The other times, I'd get a big WARN_ON
in dwc2_hsotg_init_fifo() about the fifo_map not being clear.

Ends up if we don't disconnect the gadget state, the fifo-map
doesn't get cleared properly, which causes WARN_ON messages and
also results in the device not properly being setup as a gadget
every other time the OTG port is connected.

So this patch adds a call to dwc2_hsotg_disconnect() in the
reset path so the state is properly cleared.

With it, the gadget interface initializes properly on every
plug in.

Cc: Wei Xu <xuwei5@hisilicon.com>
Cc: Guodong Xu <guodong.xu@linaro.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: John Youn <johnyoun@synopsys.com>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Chen Yu <chenyu56@huawei.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: f_fs: Fix ExtCompat documentation in uapi header
Vincent Pelletier [Fri, 17 Feb 2017 11:20:38 +0000 (11:20 +0000)]
usb: gadget: f_fs: Fix ExtCompat documentation in uapi header

The code was fixed in
commit 53642399aa71 ("usb: gadget: f_fs: Fix wrong check on reserved1 wof OS_DESC_EXT_COMPAT")
but the in-header documentation kept referencing 0 as the expected value.
Reference 1 instead as per original commit message.

Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agotools/usb: Add .gitignore file
Prarit Bhargava [Mon, 20 Feb 2017 14:04:44 +0000 (09:04 -0500)]
tools/usb: Add .gitignore file

Add .gitignore file for untracked files in tools/usb.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agousb: gadget: uvc: Missing files for configfs interface
Petr Cvek [Mon, 6 Mar 2017 23:57:20 +0000 (00:57 +0100)]
usb: gadget: uvc: Missing files for configfs interface

Commit 76e0da34c7ce ("usb-gadget/uvc: use per-attribute show and store
methods") caused a stringification of an undefined macro argument "aname",
so three UVC parameters (streaming_interval, streaming_maxpacket and
streaming_maxburst) were named "aname".

Add the definition of "aname" to the main macro and name the filenames as
originaly intended.

Signed-off-by: Petr Cvek <petr.cvek@tul.cz>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
7 years agoMerge tag 'phy-for-4.12' of git://git.kernel.org/pub/scm/linux/kernel/git/kishon...
Greg Kroah-Hartman [Mon, 10 Apr 2017 13:45:52 +0000 (15:45 +0200)]
Merge tag 'phy-for-4.12' of git://git./linux/kernel/git/kishon/linux-phy into usb-next

Kishon writes:

phy: for 4.12

 *) Add new PHY driver for Qualcomm's QMP PHY (used by PCIe, UFS and USB)
 *) Add new PHY driver for Qualcomm's QUSB2 PHY
 *) Add support for vbus regulator in rockchip-usb driver
 *) Add support for usb2-phy in rk3328 to rockchip-inno-usb2 driver
 *) Add support for a new version of PHY in phy-mt65xx-usb3 driver
 *) Add support for Allwinner A64 PHY to switch between MUSB and EHCI/OHCI
 *) Cleanups in Exynos driver and phy-mt65xx-usb3 driver

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: qcom-qusb2: add NVMEM dependency
Tobias Regnery [Mon, 10 Apr 2017 09:52:42 +0000 (11:52 +0200)]
phy: qcom-qusb2: add NVMEM dependency

With CONFIG_NVMEM=m and CONFIG_PHY_QCOM_QUSB2=y we get a link error from
calls to devm_nvmem_cell_get and nvmem_cell_read:

drivers/built-in.o: In function `qusb2_phy_probe':
binder.c:(.text+0x4750): undefined reference to `devm_nvmem_cell_get'
drivers/built-in.o: In function `qusb2_phy_init':
binder.c:(.text+0x489c): undefined reference to `nvmem_cell_read'

Fix this by adding a Kconfig dependency to ensure we can only have this
driver built in when the nvmem functions are also built in or we see the
empty stub functions. We can still build this driver as a module when the
nvmem core is build as module, too.

Fixes: deffad633413 ("phy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips")
Signed-off-by: Tobias Regnery <tobias.regnery@gmail.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: rockchip-usb: Add vbus regulator support.
Sjoerd Simons [Wed, 5 Apr 2017 14:06:10 +0000 (16:06 +0200)]
phy: rockchip-usb: Add vbus regulator support.

On rockchip devices vbus is supplied by a separate power supply, often
through a regulator. Add support for describing the the regulator in
device-tree following the same convention as several other usb phy's.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: bcm-ns-usb3: split all writes into reg & val pairs
Rafał Miłecki [Sun, 2 Apr 2017 16:55:22 +0000 (18:55 +0200)]
phy: bcm-ns-usb3: split all writes into reg & val pairs

So far all the PHY initialization was implemented using some totally
magic values. There was some pattern there but it wasn't clear what is
it about.

Thanks to the patch submitted by Broadcom:
[PATCH 5/6] phy: Add USB3 PHY support for Broadcom NSP SoC
and the upstream "iproc-mdio" driver we now know there is a MDIO bus
underneath with PHY(s) and their registers.

It allows us to clean the driver a bit by making all these values less
magical. The next step is switching to using a proper MDIO layer.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Jon Mason <jon.mason@broadcom.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: qcom-qmp: new qmp phy driver for qcom-chipsets
Vivek Gautam [Thu, 6 Apr 2017 05:51:25 +0000 (11:21 +0530)]
phy: qcom-qmp: new qmp phy driver for qcom-chipsets

Qualcomm SOCs have QMP phy controller that provides support
to a number of controller, viz. PCIe, UFS, and USB.
Add a new driver, based on generic phy framework, for this
phy controller.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agodt-bindings: phy: Add support for QMP phy
Vivek Gautam [Thu, 6 Apr 2017 05:51:24 +0000 (11:21 +0530)]
dt-bindings: phy: Add support for QMP phy

Qualcomm chipsets have QMP phy controller that provides
support to a number of controller, viz. PCIe, UFS, and USB.
Adding dt binding information for the same.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips
Vivek Gautam [Thu, 6 Apr 2017 05:51:23 +0000 (11:21 +0530)]
phy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips

PHY transceiver driver for QUSB2 phy controller that provides
HighSpeed functionality for DWC3 controller present on
Qualcomm chipsets.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agodt-bindings: phy: Add support for QUSB2 phy
Vivek Gautam [Thu, 6 Apr 2017 05:51:22 +0000 (11:21 +0530)]
dt-bindings: phy: Add support for QUSB2 phy

Qualcomm chipsets have QUSB2 phy controller that provides
HighSpeed functionality for DWC3 controller.
Adding dt binding information for the same.

Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: rockchip-inno-usb2: add support of usb2-phy for rk3328
Meng Dongyang [Mon, 6 Mar 2017 01:29:38 +0000 (09:29 +0800)]
phy: rockchip-inno-usb2: add support of usb2-phy for rk3328

Add usb2-phy config information in the data of match table for
rk3328.

Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agodt-bindings: add DT bindings for usb2-phy grf
Meng Dongyang [Mon, 6 Mar 2017 01:29:37 +0000 (09:29 +0800)]
dt-bindings: add DT bindings for usb2-phy grf

Adds the device tree bindings description for usb2-phy grf
of RK3328 platform.

Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agodt-bindings: phy-rockchip-inno-usb2: add assign clock property in usb2-phy node
Meng Dongyang [Mon, 6 Mar 2017 01:29:36 +0000 (09:29 +0800)]
dt-bindings: phy-rockchip-inno-usb2: add assign clock property in usb2-phy node

On some platform such as RK3328, the 480m clock may need to assign
clock parent in dts in stead of clock driver. So this patch add
property of assigned-clocks and assigned-clock-parents to assign
parent for 480m clock.

Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agodt-bindings: phy-mt65xx-usb: add support for new version phy
Chunfeng Yun [Fri, 31 Mar 2017 07:35:35 +0000 (15:35 +0800)]
dt-bindings: phy-mt65xx-usb: add support for new version phy

add a new compatible string for "mt2712", and move reference clock
into each port node;

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: phy-mt65xx-usb3: disable 100uA extraction from SS port to HS port
Chunfeng Yun [Fri, 31 Mar 2017 07:35:32 +0000 (15:35 +0800)]
phy: phy-mt65xx-usb3: disable 100uA extraction from SS port to HS port

There will be a problem if SS port is diasbled and HS port extracts
100uA from SS port, so disable extract 100uA from SS port in the case,
when disable it, PA0_RG_USB20_INTR_EN should be set, otherwise HS port
only works on LS.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: phy-mt65xx-usb3: add support for new version phy
Chunfeng Yun [Fri, 31 Mar 2017 07:35:31 +0000 (15:35 +0800)]
phy: phy-mt65xx-usb3: add support for new version phy

There are some variations from mt2701 to mt2712:
1. banks shared by multiple ports are put back into each port,
    such as SPLLC and U2FREQ;
2. add a new bank MISC for u2port, and CHIP for u3port;
3. bank's offset in each port are also rearranged;

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: phy-mt65xx-usb3: move clock from phy node into port nodes
Chunfeng Yun [Fri, 31 Mar 2017 07:35:30 +0000 (15:35 +0800)]
phy: phy-mt65xx-usb3: move clock from phy node into port nodes

each port has its own reference clock, the HighSpeed port is 48M,
and the SuperSpeed port is usually 26M, put them into port node for
flexibility, this can close clock if the port is not used.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: phy-mt65xx-usb3: split SuperSpeed port into two ones
Chunfeng Yun [Fri, 31 Mar 2017 07:35:29 +0000 (15:35 +0800)]
phy: phy-mt65xx-usb3: split SuperSpeed port into two ones

Currently usb3 port in fact includes two sub-ports, but it is not
flexible for some cases, such as following one:
    usb3 port0 includes u2port0 and u3port0;
    usb2 port0 includes u2port1;
If wants to support only HS, we can use u2port0 or u2port1, when
select u2port0, u3port0 is not needed;
If wants to support SS, we can compound u2port0 and u3port0,
or u2port1 and u3port0, if select latter one, u2port0 is not needed.

So it's more flexible to split usb3 port into two ones and also try
best to save power by disabling unnecessary ports.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: phy-mt65xx-usb3: increase LFPS filter threshold
Chunfeng Yun [Fri, 31 Mar 2017 07:35:28 +0000 (15:35 +0800)]
phy: phy-mt65xx-usb3: increase LFPS filter threshold

Increase LFPS filter threshold to avoid some fake remote wakeup
signal which cause U3 link fail and link to U2 only at about
0.01% probability.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: phy-mt65xx-usb3: improve RX detection stable time
Chunfeng Yun [Fri, 31 Mar 2017 07:35:27 +0000 (15:35 +0800)]
phy: phy-mt65xx-usb3: improve RX detection stable time

The default value of RX detection stable time is 10us, and this
margin is too big for some critical cases which cause U3 link fail
and link to U2(probability is about 1%). So change it to 5us.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: sun4i-usb: enable PHY0 dual route switching for A64 USB PHY
Icenowy Zheng [Tue, 4 Apr 2017 18:45:16 +0000 (02:45 +0800)]
phy: sun4i-usb: enable PHY0 dual route switching for A64 USB PHY

Allwinner A64 SoC features a switchable PHY0 like the one in H3, which
can switch between a MUSB controller and a pair of OHCI/EHCI controller.

Enable PHY0 route auto switching for A64.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: rcar-gen3-usb2: fix implementation for runtime PM
Yoshihiro Shimoda [Mon, 13 Mar 2017 23:37:40 +0000 (08:37 +0900)]
phy: rcar-gen3-usb2: fix implementation for runtime PM

This patch fixes an issue that this driver doesn't take care of the runtime
PM. This code assumed that devm_phy_create() called pm_runtime_enable(dev),
but it misunderstood the dev_phy_create()'s specification.
This driver should call its own pm_runtime_enable() before
dev_phy_create().

Fixes: f3b5a8d9b50d ("phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: rockchip-inno-usb2: fix spelling mistake: "connecetd" -> "connected"
Colin Ian King [Wed, 22 Feb 2017 23:30:52 +0000 (23:30 +0000)]
phy: rockchip-inno-usb2: fix spelling mistake: "connecetd" -> "connected"

trivial fix to spelling mistake in dev_dbg message, also rejoin
lines to clean up checkpatch warning

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: exynos: Use one define for enable bit
Krzysztof Kozlowski [Wed, 29 Mar 2017 08:29:57 +0000 (13:59 +0530)]
phy: exynos: Use one define for enable bit

There is no need for separate defines for Exynos4 and Exynos5 phy enable
bit and MIPI phy reset bits.  In both cases there are the same so
simplify it.

This reduces number of defines and allows removal of one header file.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agoMerge tag 'ib-mfd-phy-v4.12' of git://git.kernel.org/pub/scm/linux/kernel/git/lee...
Kishon Vijay Abraham I [Mon, 10 Apr 2017 11:13:09 +0000 (16:43 +0530)]
Merge tag 'ib-mfd-phy-v4.12' of git://git./linux/kernel/git/lee/mfd into next

Immutable branch between MFD and PHY due for the v4.12 merge window

7 years agophy: exynos-mipi-video: Use consistent method to address phy registers
Krzysztof Kozlowski [Tue, 14 Mar 2017 16:46:51 +0000 (18:46 +0200)]
phy: exynos-mipi-video: Use consistent method to address phy registers

Exynos4 MIPI phy registers are defined with macro calculating the offset
for given phyN.  Use the same method for Exynos5420 to be consistent.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: exynos5: Remove duplicated defines of PHY register defines
Krzysztof Kozlowski [Tue, 14 Mar 2017 16:46:50 +0000 (18:46 +0200)]
phy: exynos5: Remove duplicated defines of PHY register defines

Phy drivers access PMU region through regmap provided by exynos-pmu
driver.   However there is no need to duplicate defines for PMU
registers.  Instead just use whatever is defined in exynos-regs-pmu.h.

This reduces number of defines.

Suggested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: exynos4: Remove duplicated defines of PHY register defines
Krzysztof Kozlowski [Wed, 29 Mar 2017 08:25:57 +0000 (13:55 +0530)]
phy: exynos4: Remove duplicated defines of PHY register defines

Phy drivers access PMU region through regmap provided by exynos-pmu
driver.   However there is no need to duplicate defines for PMU
registers.  Instead just use whatever is defined in exynos-regs-pmu.h.

Additionally MIPI PHY registers for Exynos5433 start from the same
address as Exynos4 and Exynos5250 so re-use existing defines.

This reduces number of defines and allows removal of one header file.

Suggested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: meson8b-usb2: fix offsets for some of the registers
Martin Blumenstingl [Sat, 4 Mar 2017 10:20:11 +0000 (11:20 +0100)]
phy: meson8b-usb2: fix offsets for some of the registers

The register offsets for REG_DBG_UART (and all following) were off by
0x4. This was not a problem yet because these registers are currently
not used by the driver.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: sun4i-usb: support automatically switch PHY0 route to MUSB/HCI
Icenowy Zheng [Sat, 25 Mar 2017 14:50:11 +0000 (22:50 +0800)]
phy: sun4i-usb: support automatically switch PHY0 route to MUSB/HCI

On newer Allwinner SoCs (H3 and after), the PHY0 node is routed to both
MUSB controller for peripheral and host support (the host support is
slightly broken), and a pair of EHCI/OHCI controllers, which provide a
better support for host mode.

Add support for automatically switch the route of PHY0 according to the
status of dr_mode and id det pin.

Only H3 have this function enabled in this patch, as further SoCs will
be tested later and then have it enabled.

As H5 is reusing the PHY driver of H3, this function is also enabled.

Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: sun4i-usb: add PHYCTL offset for H3 SoC
Icenowy Zheng [Sat, 25 Mar 2017 14:50:10 +0000 (22:50 +0800)]
phy: sun4i-usb: add PHYCTL offset for H3 SoC

The config structure of H3 in phy-sun4i-usb driver have the PHYCTL
register offset missing.

Add it. From the BSP source code, we know that the offset should be
0x10.

Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: sun4i-usb: change PHYCTL register clearing code
Icenowy Zheng [Sat, 25 Mar 2017 14:50:09 +0000 (22:50 +0800)]
phy: sun4i-usb: change PHYCTL register clearing code

It seems that all SoCs with the PHYCTL register offset as 0x10 need the
PHYCTL register to be cleared before it's written.

Change PHYCTL register clearing code to judge whether clearing is needed
based on the PHYCTL offset.

Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agodt: bindings: add pmu0 regs for USB PHYs on Allwinner H3/V3s/A64
Icenowy Zheng [Sat, 25 Mar 2017 14:50:08 +0000 (22:50 +0800)]
dt: bindings: add pmu0 regs for USB PHYs on Allwinner H3/V3s/A64

Allwinner H3/V3s/A64 SoCs have a special USB PHY0 that can route to two
controllers: one is MUSB and the other is a EHCI/OHCI pair.

When it's routed to EHCI/OHCI pair, it will needs a "pmu0" regs to
tweak, like other EHCI/OHCI pairs in Allwinner SoCs.

Add this to the binding of USB PHYs on Allwinner H3/V3s/A64.

Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agomfd: exynos-lpass: Use common soc/exynos-regs-pmu.h header
Krzysztof Kozlowski [Tue, 14 Mar 2017 16:46:52 +0000 (18:46 +0200)]
mfd: exynos-lpass: Use common soc/exynos-regs-pmu.h header

The MFD-specific header will go away because it duplicates defines from
exynos-regs-pmu.h.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agophy: phy-exynos-pcie: make it explicitly non-modular
Paul Gortmaker [Thu, 23 Feb 2017 21:46:03 +0000 (16:46 -0500)]
phy: phy-exynos-pcie: make it explicitly non-modular

The Kconfig currently controlling compilation of this code is:

drivers/phy/Kconfig:config PHY_EXYNOS_PCIE
drivers/phy/Kconfig:    bool "Exynos PCIe PHY driver"

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modular infrastructure use, so that
when reading the driver there is no doubt it is builtin-only.

Since module_platform_driver() uses the same init level priority as
builtin_platform_driver() the init ordering remains unchanged with
this commit.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We also delete the MODULE_LICENSE tag etc. since all that information
is already contained at the top of the file in the comments.

Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Kukjin Kim <kgene@kernel.org>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Pankaj Dubey <pankaj.dubey@samsung.com>
Cc: Vivek Gautam <vivek.gautam@codeaurora.org>
Cc: Javier Martinez Canillas <javier@osg.samsung.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
7 years agousb: usbip tool: Fix get_nports()
Yuyang Du [Wed, 5 Apr 2017 22:03:23 +0000 (06:03 +0800)]
usb: usbip tool: Fix get_nports()

The commit 0775a9cbc694e8c72 ("usbip: vhci extension: modifications
to vhci driver") introduced multiple controllers, and nports as a sys
file, and claimed to read the nports from it, but it didn't.

In addition, the get_nports() has been so wrong that even with 8 port
lines for instance, it gets 7 (I am guessing it is due to a '\n' mess).
Nevertheless, we fix it by reading the nports attribute.

Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Yuyang Du <yuyang.du@intel.com>
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: bInterval quirk for TI TUSB73x0
Roger Quadros [Fri, 7 Apr 2017 14:57:12 +0000 (17:57 +0300)]
usb: xhci: bInterval quirk for TI TUSB73x0

As per [1] issue #4,
"The periodic EP scheduler always tries to schedule the EPs
that have large intervals (interval equal to or greater than
128 microframes) into different microframes. So it maintains
an internal counter and increments for each large interval
EP added. When the counter is greater than 128, the scheduler
rejects the new EP. So when the hub re-enumerated 128 times,
it triggers this condition."

This results in Bandwidth error when devices with periodic
endpoints (ISO/INT) having bInterval > 7 are plugged and
unplugged several times on a TUSB73x0 XHCI host.

Workaround this issue by limiting the bInterval to 7
(i.e. interval to 6) for High-speed or faster periodic endpoints.

[1] - http://www.ti.com/lit/er/sllz076/sllz076.pdf

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: refine xhci_decode_trb()
Lu Baolu [Fri, 7 Apr 2017 14:57:11 +0000 (17:57 +0300)]
usb: xhci: refine xhci_decode_trb()

Replace 'TRB_FIELD_TO_TYPE(field3)' with 'type' to simplify
code.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: fix link trb decoding
Lu Baolu [Fri, 7 Apr 2017 14:57:10 +0000 (17:57 +0300)]
usb: xhci: fix link trb decoding

xhci_decode_trb() treats a link trb in the same way as that for
an event trb. This patch fixes this by decoding the link trb
according to the spec.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: remove xhci_dbg_ctx()
Lu Baolu [Fri, 7 Apr 2017 14:57:09 +0000 (17:57 +0300)]
usb: xhci: remove xhci_dbg_ctx()

XHCI context changes have already been traced by the trace
events. It's unnecessary to put the same message in kernel
log. This patch removes the use of xhci_dbg_ctx().

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: remove xhci_debug_trb()
Lu Baolu [Fri, 7 Apr 2017 14:57:08 +0000 (17:57 +0300)]
usb: xhci: remove xhci_debug_trb()

Every XHCI TRB has already been traced by the trb trace events.
It is unnecessary to put the same message in kernel log. This
patch removes xhci_debug_trb().

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: remove ring debugging code
Lu Baolu [Fri, 7 Apr 2017 14:57:07 +0000 (17:57 +0300)]
usb: xhci: remove ring debugging code

XHCI ring changes have already been traced by the ring trace
events. It's unnecessary to put the same messages in kernel
log. This patch removes the debugging code for a ring.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: remove enq_updates and deq_updates from ring
Lu Baolu [Fri, 7 Apr 2017 14:57:06 +0000 (17:57 +0300)]
usb: xhci: remove enq_updates and deq_updates from ring

enq_updates and deq_updates were introduced in the first place
to check whether an xhci hardware is able to respond to trbs
enqueued in the ring. We now have trb tracers to trace every
single enqueue/dequeue trb. It's time to remove them and the
associated debugging code.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: remove error messages for failed memory allocation
Lu Baolu [Fri, 7 Apr 2017 14:57:05 +0000 (17:57 +0300)]
usb: xhci: remove error messages for failed memory allocation

Omit extra messages for memory allocation failure.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: make several functions static
Lu Baolu [Fri, 7 Apr 2017 14:57:04 +0000 (17:57 +0300)]
usb: xhci: make several functions static

Several functions have a single user in the same file where it
is defined. There's no need to expose it anywhere else.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: remove xhci_dbg_ep_rings()
Lu Baolu [Fri, 7 Apr 2017 14:57:03 +0000 (17:57 +0300)]
usb: xhci: remove xhci_dbg_ep_rings()

xhci_dbg_ep_rings() isn't used in xhci driver anymore. Remove
it to reduce the module binary size.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: xhci: add xhci_log_ring trace events
Lu Baolu [Fri, 7 Apr 2017 14:57:02 +0000 (17:57 +0300)]
usb: xhci: add xhci_log_ring trace events

This patch creates a new event class called xhci_log_ring, and
defines the events used for tracing the change of all kinds of
rings used by an xhci host. An xHCI ring is basically a memory
block shared between software and hardware. By tracing changes
of rings, it makes the life easier for debugging hardware or
software problems.

This info can be used, later, to print, in a human readable way,
the life cycle of an xHCI ring using the trace-cmd tool and the
appropriate plugin.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoxhci: Rework how we handle unresponsive or hoptlug removed hosts
Mathias Nyman [Fri, 7 Apr 2017 14:57:01 +0000 (17:57 +0300)]
xhci: Rework how we handle unresponsive or hoptlug removed hosts

Introduce a new xhci_hc_died() function that takes care of handling
pending commands and URBs if a host controller becomes unresponsive.

This addresses issues on hotpluggable xhci controllers that disappear
from the bus suddenly, often while the bus (PCI) remove function is
still being processed.

xhci_hc_died() sets a XHCI_STATUS_DYING flag to prevent new URBs and
commands or to be queued. The flag also ensures xhci_hc_died() will
give back pending commands and URBs once.

Host is considered dead if register read returns 0xffffffff, or host
fails to abort the command ring, or fails stopping an endpoint after
trying for 5 seconds.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoxhci: Do not halt the host until both HCD have disconnected their devices.
Joel Stanley [Fri, 7 Apr 2017 14:57:00 +0000 (17:57 +0300)]
xhci: Do not halt the host until both HCD have disconnected their devices.

We can't halt the host controller immediately when first HCD is removed as
it will cause problems if we have devices attached to the second (primary)
HCD, like a keyboard.

We've been carrying this in our Linux-as-a-bootloader environment for a
little while now. The machines all have the same TI TUSB73x0 part,
and when we kexec the devices don't come back until a system power cycle.

[minor adjustments, code comments and remove HALT check  -Mathias]
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoxhci: add slot and endpoint numbers to debug messages in handle_tx_event
Zhengjun Xing [Fri, 7 Apr 2017 14:56:59 +0000 (17:56 +0300)]
xhci: add slot and endpoint numbers to debug messages in handle_tx_event

There's one annoyance in how xhci prints debug messages, we often
get logs with messages but it's hard to say from which device and
endpoint the message originates. Add slot_id, ep_index messages
in handle_tx_event.

Signed-off-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: fix up Control Transfer TRB decoder
Felipe Balbi [Fri, 7 Apr 2017 14:56:58 +0000 (17:56 +0300)]
usb: host: xhci: fix up Control Transfer TRB decoder

Format for each TRB in each control transfer stage differs. Let's make
sure we correctly pretty print these fields to avoid confusion.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: add Slot and EP Context tracers
Felipe Balbi [Fri, 7 Apr 2017 14:56:57 +0000 (17:56 +0300)]
usb: host: xhci: add Slot and EP Context tracers

With these, we can track what's happening with the HW while executing
each and every command. It will give us visibility into how the
different contexts are being modified by xHC which can bring insight
into problems while debugging.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agousb: host: xhci: extract xhci_slot_state_string()
Felipe Balbi [Fri, 7 Apr 2017 14:56:56 +0000 (17:56 +0300)]
usb: host: xhci: extract xhci_slot_state_string()

By extracting and exposing xhci_slot_state_string() in a header file, we
can re-use it to print Slot Context State from our tracepoints, which
can aid in tracking down problems related to command execution.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>