usb: musb: dsps: implement ->set_mode()

this will let us support broken designs such
as AM335x EVM SK where ID pin isn't routed
anywhere on a host port.

With this we can toggle internal IDDIG signal
and make sure MUSB goes into host mode as
necessary.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: core: call musb_platform_set_mode() during probe

This will tell glue layer which mode we want port
to be in.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: dwc3: dwc3-omap: return PROBE_DEFER if extcon is missing and found in dt

Due to inter dependencies of I2C and extcon by the time dwc3
checks for extcon device its not registered especially in case of J6.
In O5 the vbus regulator save us from getting to this point.
So for tiime being return PROBE_DEFER if extcon is enabled in dt.

Signed-off-by: George Cherian <george.cherian@ti.com>
usb: musb: unconditionally save and restore the context on suspend

It appears not all platforms featuring a musb core need to save the musb
core registers at suspend time and restore them on resume.

The dsps platform does, however, and because it shouldn't cause any
trouble on other platforms, do it unconditionally for all of them.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: call musb_port_suspend from musb_bus_suspend

Make musb_port_suspend() externally available, and call it when to host
goes into suspend. This allows the core to go into suspend while a
device is connected.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: dsps: add {tx,rx}_mode to wrapper

rx_mode and tx_mode need to be read at suspend time and restored on
resume for dsps platforms. So add it to the wrapper struct first, and
initialize the values.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: dsps: add support for suspend and resume

The dsps platform needs to save save some registers at suspend time and
restore them after resume. This patch adds a struct for these registers,
and also lets the musb core know that the core registers need to be
saved as well.

We also have to explicitly de-assert the port reset upon resume on this
platform, but musb_port_reset() should not be called from glue layers.

Hence, introduce a flag in struct musb_hdrc_config for this.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: gadget: epautoconf: switch over to usb_endpoint_type()

we have a helper to fetch endpoint type out of
a descriptor, let's use it.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: gadget: goku: remove unused argument

The stop_activity function never uses driver argument (even
though it modifies it) and thus it is safe to remove it.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: gadget: remove superfluous name casts

device_driver.name is "const char *"

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: gadget: update some out of date comments

These functions used to return negative errror codes but now they return
ERR_PTRs.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: phy: fsm: don't depend on indirect includes

this header uses spinlocks and errno values, so
we must include <linux/spinlock.h> and <linux/errno.h>
to avoid build errors.

Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: phy: fsm: protect against multiple inclusions

if this header is included twice, we would have
redefinition build errors. Fix this.

Signed-off-by: Anton Tikhomirov <av.tikhomirov@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: phy: replace spinlock with mutex in OTG FSM

OTG Final State Machine calls functions which may sleep.

For example, start_gadget callback implementation can use
usb_gadget_vbus_connect(), whose context: can sleep.

If so, mutex should be used instead of spinlock.

Signed-off-by: Anton Tikhomirov <av.tikhomirov@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: phy: move OTG FSM header

Other USB drivers may want to use OTG final state machine
implementation, so make this header available for them.

Signed-off-by: Anton Tikhomirov <av.tikhomirov@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: phy: Add OTG FSM configuration option

This patch removes dependency on Freescale USB UTG Transceiver
driver and makes OTG FSM implementation selectable.

Signed-off-by: Anton Tikhomirov <av.tikhomirov@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: dsps: polling ID pin status only in otg mode

Only start the otg_timer in dual role mode; otherwise in peripheral mode
when musb is disconnected from the host port, otg_timer starts and
continuously toggles the session, which causes VBUS pulse.

Signed-off-by: Bin Liu <b-liu@ti.com>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: gadget: composite: redirect setup requests

If there are setup requests not directed to an endpont or an interface,
current config's setup() has been attempted so far.
This patch, in case the above fails, adds code which tries the setup() of
configuration's function if there is only one function in the configuration.

This behavior is required to provide equivalent of gadget zero with configfs.

The gadget zero has a "config driver" for sourcesink, but all it does is
delegating the request to the function proper. So when the equivalent gadget
is set up with configfs it needs to handle requests directed to
"config driver", but with configfs it is not possible to specify
"config drivers".

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: gadget: factor out alloc_ep_req

alloc_ep_req() is a function repeated in several modules.
Make a common implementation and use it.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: gadget: f_loopback: add configfs support

Add support for using the loopback USB function in gadgets composed with
configfs.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>