Commit Graph

19 Commits (a10d206ef1a83121ab7430cb196e0376a7145b22)

Author SHA1 Message Date
Kishon Vijay Abraham I 662dca54ca usb: otg: support for multiple transceivers by a single controller
Add a linked list for keeping multiple PHY instances with different
types so that we can have separate USB2 and USB3 PHYs on one single
board. _get_phy_ has been changed so that the controller gets
the transceiver by type. _remove_phy_ has been added to let the phy
be removed from the phy list.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2012-06-25 14:05:35 +03:00
Kishon Vijay Abraham I 721002ec1d usb: otg: utils: rename function name in OTG utils
_transceiver() in otg.c is replaced with _phy. usb_set_transceiver is
replaced with usb_add_phy to make it similar to other usb standard
function names like usb_add_hcd.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2012-06-25 14:04:26 +03:00
Shinya Kuribayashi 7cbb062ade USB: gpio_vbus: wakeup support on GPIO VBUS interrupts
We'd like to see the system waking up from the system-wide suspend
when it gets plugged-in, or the USB cable is pulled out.

Also makes it configurable via platform data 'wakeup'.

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-17 11:20:34 -07:00
Shinya Kuribayashi ec1ac6e169 USB: gpio_vbus: a missing cancellation of workqueue in remove() function
Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-17 11:20:34 -07:00
Shinya Kuribayashi c8240c1b81 USB: gpio_vbus: handle IRQ flags properly
Currently, 'res->flags' handlings are wrong in three respects:
* the driver _modifies_ the contents of platform data
* res->flags is set up, but not used anywhere in the driver
* request_irq() always takes VBUS_IRQ_FLAGS, regardless of refs->flags

This patch tries to fix this with a policy: If a platform IRQ resource
is available, give preference to its IRQ flag(s) over a default one
(VBUS_IRQ_FLAGS).

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-17 11:20:34 -07:00
Shinya Kuribayashi da020b49fa USB: gpio_vbus: remove IRQF_SAMPLE_RANDOM use
IRQF_SAMPLE_RANDOM has been scheduled for removal for years (it was
scheduled by July 2009, but not yet remvoed).

I'm not sure when it's going to take place, but would be better to
remove it now.  Thanks for scripts/checkpatch secretary.

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-17 11:20:34 -07:00
Shinya Kuribayashi 123bbceebe USB: gpio_vbus: use cached IRQ number for consistency with the probed one
gpio_vbus is designed to be able to get an IRQ number for VBUS change
interrupt either (1) through platform_get_resource(IORESOURCE_IRQ) or
(2) by processing gpio_to_irq(pdata->gpio_vbus), in probe() function.

On the other hand, gpio_vbus_set_peripheral() and gpio_vbus_remove()
are always doing gpio_to_irq(pdata->gpio_vbus) to get an IRQ number.

This is not just inconsistent, but also broken.  There is no guarantee
that an IRQ number obtained by platform_get_resource() is equal to
gpio_to_irq(pdata->gpio_vbus).

Cache an IRQ number in probe() function, and use it where necessary.

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-17 11:20:34 -07:00
Shinya Kuribayashi e44694e858 USB: gpio_vbus: avoid consecutive vbus_session calls with the same "is_active"
Basically, ->vbus_session() calls should be served when VBUS session
starts and ends (it's not whenever transciever drivers detect VBUS
_changes_).  Otherwise, if UDC gadget drivers don't want for some
reason ->vbus_session() calls with the same "is_active" value, either
OTG or UDC drivers need to have some protection handlings.

Also, on platforms using this 'gpio_vbus' driver, the driver is only
allowed to check whether VBUS is applied.  There is no kernel-standard
way prepared for UDC gadget drivers to do that.

With this in mind, gpio_vbus should try to prevent unnecessary
consecutive vbus_session calls being served with the same "in_active"
value.

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-14 09:02:23 -07:00
Shinya Kuribayashi a6dc9cf76b USB: gpio_vbus: put a missing regulator_put() on error
Note that regulator_put() doesn't care about whether ->vbus_draw is
valid or not.

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-14 09:02:23 -07:00
Shinya Kuribayashi 934ccec4da USB: gpio_vbus: provide an appropriate debounce interval
In commit c2344f13b5 (USB: gpio_vbus:
add delayed vbus_session calls, 2009-01-24), usb_gadget_vbus_connect()
and ...disconnect() were extracted from the interrupt handler, so to
allow vbus_session handlers to deal with msleep() calls.

This patch takes the approach one step further.

USB2.0 specification (7.1.7.3 Connect and Disconnect Signaling) says
that the USB system software (shall) provide a debounce interval with
a minimum duration of 100 ms, which ensures that the electrical and
mechanical connection is stable before software attempts to reset
the attached device.

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-14 09:01:50 -07:00
Shinya Kuribayashi 0d13eebcab USB: gpio_vbus: fix inconsistent 'dev_id' parameters at free_irq()
'dev_id' has to be the same with the one passed to request_irq().

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-14 09:01:50 -07:00
Heiko Stübner 662c738d99 usb: otg: gpio_vbus: Add otg transceiver events and notifiers
Commit 9ad63986c6 (pda_power: Add support for using otg transceiver events)
converted the pda-power driver to use otg events to determine the status
of the power supply.

As gpio-vbus didn't use otg events until now, this change breaks setups
of pda-power with a gpio-vbus transceiver.

This patch adds the necessary otg events and notifiers to gpio-vbus.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Dima Zavin <dima@android.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2012-04-12 14:59:41 +03:00
Heikki Krogerus 16bc1bb2d8 usb: otg: gpio_vbus: Start using struct usb_otg
Use struct usb_otg members with OTG specific functions instead
of usb_phy members.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2012-02-13 13:35:31 +02:00
Heikki Krogerus 8675381109 usb: otg: Rename otg_transceiver to usb_phy
This is the first step in separating USB transceivers from
USB OTG utilities.

Includes fixes to IMX code from Sascha Hauer.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Acked-by: Li Yang <leoli@freescale.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Igor Grinberg <grinberg@compulab.co.il>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2012-02-13 13:34:36 +02:00
Paul Gortmaker 6eb0de8270 usb: Add module.h to drivers/usb consumers who really use it.
The situation up to this point meant that module.h was pretty
much everywhere, regardless of whether you asked for it or not.
We are fixing that, so give the USB folks who want it an actual
include of it.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2011-10-31 19:31:25 -04:00
Dmitry Eremin-Solenikov 2887ba9e3e USB: gpio-vbus: ask for vbus_draw regulator before registering xceiv
Ask for vbus_draw regulator before registering tranceiver to disallow possible
race between registration and set_power/etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-03 10:17:14 -07:00
Tejun Heo 5a0e3ad6af include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files.  percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed.  Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability.  As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

  http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
  only the necessary includes are there.  ie. if only gfp is used,
  gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
  blocks and try to put the new include such that its order conforms
  to its surrounding.  It's put in the include block which contains
  core kernel includes, in the same order that the rest are ordered -
  alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
  doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
  because the file doesn't have fitting include block), it prints out
  an error message indicating which .h file needs to be added to the
  file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
   over 4000 files, deleting around 700 includes and adding ~480 gfp.h
   and ~3000 slab.h inclusions.  The script emitted errors for ~400
   files.

2. Each error was manually checked.  Some didn't need the inclusion,
   some needed manual addition while adding it to implementation .h or
   embedding .c file was more appropriate for others.  This step added
   inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
   from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
   e.g. lib/decompress_*.c used malloc/free() wrappers around slab
   APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
   editing them as sprinkling gfp.h and slab.h inclusions around .h
   files could easily lead to inclusion dependency hell.  Most gfp.h
   inclusion directives were ignored as stuff from gfp.h was usually
   wildly available and often used in preprocessor macros.  Each
   slab.h inclusion directive was examined and added manually as
   necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
   were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
   distributed build env didn't work with gcov compiles) and a few
   more options had to be turned off depending on archs to make things
   build (like ipr on powerpc/64 which failed due to missing writeq).

   * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
   * powerpc and powerpc64 SMP allmodconfig
   * sparc and sparc64 SMP allmodconfig
   * ia64 SMP allmodconfig
   * s390 SMP allmodconfig
   * alpha SMP allmodconfig
   * um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
   a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-30 22:02:32 +09:00
Robert Jarzmik c2344f13b5 USB: gpio_vbus: add delayed vbus_session calls
Call usb_gadget_vbus_connect() and ...disconnect() from a
workqueue rather than from an irq handler, allowing msleep()
calls in vbus_session.  Update kerneldoc to match.

[ dbrownell@users.sourceforge.net: more kerneldoc updates ]

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-03-24 16:20:26 -07:00
Philipp Zabel 6084f1bf0c USB: otg: gpio_vbus transceiver stub
gpio_vbus provides simple GPIO VBUS sensing for peripheral
controllers with an internal transceiver.
Optionally, a second GPIO can be used to control D+ pullup.

It also interfaces with the regulator framework to limit charging
currents when powered via USB. gpio_vbus requests the regulator
supplying "vbus_draw" and can enable/disable it or limit its
current depending on USB state.

[dbrownell@users.sourceforge.net: use drivers/otg, cleanups ]

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-01-07 10:00:02 -08:00