Commit graph

30 commits

Author SHA1 Message Date
Roger Quadros
762982db33 usb: phy: phy-generic: Fix reset behaviour on legacy boot
The gpio-desc migration done in v4.0 caused a regression
with legacy boots due to reversed reset logic.
e.g. omap3-beagle USB host breaks on legacy boot.

Request the reset GPIO with GPIOF_ACTIVE_LOW flag so that
it matches the driver logic and pin behaviour.

Fixes: e9f2cefb0c ("usb: phy: generic: migrate to gpio_desc")
Cc: <stable@vger.kernel.org> # 4.0+
Tested-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-09-14 10:15:08 -05:00
Uwe Kleine-König
88167fc0b2 usb: pass flags parameter to gpiod_get functions
Since 39b2bbe3d7 (gpio: add flags argument to gpiod_get*() functions)
which appeared in v3.17-rc1, the gpiod_get* functions take an additional
parameter that allows to specify direction and initial value for output.

Currently this parameter is made optional with the help of a cpp trick.
To allow dropping this hack convert callers to explictly pass a value
for flags.

Acked-by: Felipe Balbi <balbi@ti.com>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-07-29 09:59:19 -05:00
Fabio Estevam
168bdb88c3 usb: phy: phy-generic: No need to call gpiod_direction_output() twice
Commit 9eb0797722 ("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>
2015-03-11 10:19:38 -05:00
Fabio Estevam
74379991f6 usb: phy: phy-generic: Fix USB PHY gpio reset
Since commit e9f2cefb0c ("usb: phy: generic: migrate to gpio_desc") a
kernel hang is observed on imx51-babbage board:

[    1.392824] ci_hdrc ci_hdrc.1: doesn't support gadget
[    1.397975] ci_hdrc ci_hdrc.1: EHCI Host Controller
[    1.403205] ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 1
[    1.422335] ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00
[    1.432962] hub 1-0:1.0: USB hub found
[    1.437119] hub 1-0:1.0: 1 port detected

This hang happens because the reset GPIO stays at logic level 0.

The USB PHY reset gpio is defined in the dts file as:

reset-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;

, which means it is active low, so what the gpio reset pin needs to do in this
case is the following:

- Go to logic level 0 to reset the USB PHY
- Stay at 0 for a bit
- Go back to logic level 1

When switching to gpiod API we need to following according to
Documentation/gpio/consumer.txt:

"The first thing a driver must do with a GPIO is setting its direction. If no
direction-setting flags have been given to gpiod_get*(), this is done by
invoking one of the gpiod_direction_*() functions:

	int gpiod_direction_input(struct gpio_desc *desc)
	int gpiod_direction_output(struct gpio_desc *desc, int value)"

Since no direction-setting flags have been given to devm_gpiod_get_optional()
in our case, we need to use gpiod_direction_output to comply with the gpiod API.

With this change the USB PHY reset performs a proper reset, the kernel boots
fine and USB host is functional.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-30 10:38:51 -06:00
Robert Jarzmik
0f4ff5f1f9 usb: phy: generic: fix the vbus interrupt request
Declare the interrupt as "one shot" so that it is masked until the end
of the threaded handler. This prevents the irq core from spitting out an
error :
  "Threaded irq requested with handler=NULL and !ONESHOT for irq 63"

This was introduced by commit "usb: phy: generic: add vbus support".

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-30 10:35:17 -06:00
Robert Jarzmik
9eb0797722 usb: phy: generic: fix the gpios to be optional
All the gpios, ie. reset-gpios and vbus-detect-gpio, should be optional
and not prevent the driver from working. Fix the regression in the
behavior introduced by commit "usb: phy: generic: migrate to gpio_desc".

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Tested-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-30 10:35:15 -06:00
Paul Zimmerman
da89dba1a0 usb: phy: make GPIOs optional for the generic phy
The use of GPIOs should be optional for the generic phy, otherwise
the Altera SOCFPGA platform at least is broken.

Fixes breakage caused by a combination of e9f2cefb0c "usb: phy:
generic: migrate to gpio_desc" and 135b3c4304 "usb: dwc2: platform:
add generic PHY framework support".

Reviewed-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-19 12:53:32 -06:00
Robert Jarzmik
7acc9973e3 usb: phy: generic: add vbus support
Add support for vbus detection and power supply. This code is more or
less stolen from phy-gpio-vbus-usb.c, and aims at providing a detection
mechanism for VBus (ie. usb cable plug) based on a GPIO line, and a
power supply activation which draws current from the VBus.

[ balbi@ti.com : fix build break ]

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:29 -06:00
Robert Jarzmik
e9f2cefb0c usb: phy: generic: migrate to gpio_desc
Change internal gpio handling from integer gpios into gpio
descriptors. This change only addresses the internal API and
device-tree/ACPI, while the legacy platform data remains integer space
based.

This change is only build compile tested, and very prone to error. I
leave this comment for now in the commit message so that this patch gets
some testing as I'm pretty sure it's buggy.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:29 -06:00
Linus Torvalds
e6b5be2be4 Driver core patches for 3.19-rc1
Here's the set of driver core patches for 3.19-rc1.
 
 They are dominated by the removal of the .owner field in platform
 drivers.  They touch a lot of files, but they are "simple" changes, just
 removing a line in a structure.
 
 Other than that, a few minor driver core and debugfs changes.  There are
 some ath9k patches coming in through this tree that have been acked by
 the wireless maintainers as they relied on the debugfs changes.
 
 Everything has been in linux-next for a while.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iEYEABECAAYFAlSOD20ACgkQMUfUDdst+ylLPACg2QrW1oHhdTMT9WI8jihlHVRM
 53kAoLeteByQ3iVwWurwwseRPiWa8+MI
 =OVRS
 -----END PGP SIGNATURE-----

Merge tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core update from Greg KH:
 "Here's the set of driver core patches for 3.19-rc1.

  They are dominated by the removal of the .owner field in platform
  drivers.  They touch a lot of files, but they are "simple" changes,
  just removing a line in a structure.

  Other than that, a few minor driver core and debugfs changes.  There
  are some ath9k patches coming in through this tree that have been
  acked by the wireless maintainers as they relied on the debugfs
  changes.

  Everything has been in linux-next for a while"

* tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (324 commits)
  Revert "ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries"
  fs: debugfs: add forward declaration for struct device type
  firmware class: Deletion of an unnecessary check before the function call "vunmap"
  firmware loader: fix hung task warning dump
  devcoredump: provide a one-way disable function
  device: Add dev_<level>_once variants
  ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries
  ath: use seq_file api for ath9k debugfs files
  debugfs: add helper function to create device related seq_file
  drivers/base: cacheinfo: remove noisy error boot message
  Revert "core: platform: add warning if driver has no owner"
  drivers: base: support cpu cache information interface to userspace via sysfs
  drivers: base: add cpu_device_create to support per-cpu devices
  topology: replace custom attribute macros with standard DEVICE_ATTR*
  cpumask: factor out show_cpumap into separate helper function
  driver core: Fix unbalanced device reference in drivers_probe
  driver core: fix race with userland in device_add()
  sysfs/kernfs: make read requests on pre-alloc files use the buffer.
  sysfs/kernfs: allow attributes to request write buffer be pre-allocated.
  fs: sysfs: return EGBIG on write if offset is larger than file size
  ...
2014-12-14 16:10:09 -08:00
Sergei Shtylyov
7901842044 usb: phy: remove file names from heading comments
File names in the heading comments fell out of favor long ago, and these weren't
even changed when the drivers were moved from drivers/usb/otg/, so remove them
at last...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-11-05 16:25:29 -06:00
Antoine Tenart
19c1eac268 usb: rename phy to usb_phy in OTG
This patch prepares the introduction of the generic PHY support in the
USB OTG common functions. The USB PHY member of the OTG structure is
renamed to 'usb_phy' and modifications are done in all drivers accessing
it. Renaming this pointer will allow to keep the compatibility for USB
PHY drivers.

Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-11-03 10:01:25 -06:00
Antoine Tenart
e47d92545c usb: move the OTG state from the USB PHY to the OTG structure
Before using the PHY framework instead of the USB PHY one, we need to
move the OTG state into another place, since it won't be available when
USB PHY isn't used. This patch moves the OTG state into the OTG
structure, and makes all the needed modifications in the drivers
using the OTG state.

[ balbi@ti.com : fix build regressions with phy-tahvo.c, musb_dsps.c,
		phy-isp1301-omap, and chipidea's debug.c ]

Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-11-03 10:01:25 -06:00
Wolfram Sang
a25f10c27c usb: phy: drop owner assignment from platform_drivers
A platform_driver does not need to set an owner, it will be populated by the
driver core.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2014-10-20 16:21:50 +02:00
Felipe Balbi
2f36ff6915 usb: phy: generic: allow multiples calls to usb_phy_generic_register()
it's now very easy to return a platform_device pointer
and have the caller pass it as argument when calling
usb_phy_generic_unregister().

Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-04-21 14:07:25 -05:00
Felipe Balbi
d7078df6be usb: phy: rename <linux/usb/usb_phy_gen_xceiv.h> to <linux/usb/usb_phy_generic.h>
now that all functions match the driver name,
the only missing piece is to rename the header
file itself.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-04-21 14:07:24 -05:00
Felipe Balbi
4525beeb9a usb: phy: rename usb_nop_xceiv to usb_phy_generic
no functional changes, just renaming the function
in order to make it slightly clearer what it should
be used for, also matching the driver name.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-04-21 14:07:24 -05:00
Felipe Balbi
0700faaf73 usb: gadget: only GPL drivers in the gadget and phy framework
We only support GPL drivers in the USB Gadget Framework,
it sounds correct to make all exported symbols GPL too.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-04-21 14:07:12 -05:00
Felipe Balbi
c139e1425f Linux 3.13-rc4
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.15 (GNU/Linux)
 
 iQEcBAABAgAGBQJSrhGrAAoJEHm+PkMAQRiGsNoH/jIK3CsQ2lbW7yRLXmfgtbzz
 i2Kep6D4SDvmaLpLYOVC8xNYTiE8jtTbSXHomwP5wMZ63MQDhBfnEWsEWqeZ9+D9
 3Q46p0QWuoBgYu2VGkoxTfygkT6hhSpwWIi3SeImbY4fg57OHiUil/+YGhORM4Qc
 K4549OCTY3sIrgmWL77gzqjRUo+pQ4C73NKqZ3+5nlOmYBZC1yugk8mFwEpQkwhK
 4NRNU760Fo+XIht/bINqRiPMddzC15p0mxvJy3cDW8bZa1tFSS9SB7AQUULBbcHL
 +2dFlFOEb5SV1sNiNPrJ0W+h2qUh2e7kPB0F8epaBppgbwVdyQoC2u4uuLV2ZN0=
 =lI2r
 -----END PGP SIGNATURE-----

Merge tag 'v3.13-rc4' into next

Linux 3.13-rc4

* tag 'v3.13-rc4': (1001 commits)
  Linux 3.13-rc4
  null_blk: mem garbage on NUMA systems during init
  radeon_pm: fix oops in hwmon_attributes_visible() and radeon_hwmon_show_temp_thresh()
  Revert "selinux: consider filesystem subtype in policies"
  igb: Fix for issue where values could be too high for udelay function.
  i40e: fix null dereference
  ARM: fix asm/memory.h build error
  dm array: fix a reference counting bug in shadow_ablock
  dm space map: disallow decrementing a reference count below zero
  mm: memcg: do not allow task about to OOM kill to bypass the limit
  mm: memcg: fix race condition between memcg teardown and swapin
  thp: move preallocated PTE page table on move_huge_pmd()
  mfd/rtc: s5m: fix register updating by adding regmap for RTC
  rtc: s5m: enable IRQ wake during suspend
  rtc: s5m: limit endless loop waiting for register update
  rtc: s5m: fix unsuccesful IRQ request during probe
  drivers/rtc/rtc-s5m.c: fix info->rtc assignment
  include/linux/kernel.h: make might_fault() a nop for !MMU
  drivers/rtc/rtc-at91rm9200.c: correct alarm over day/month wrap
  procfs: also fix proc_reg_get_unmapped_area() for !MMU case
  ...

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-12-19 09:18:53 -06:00
Neil Zhang
31e322272d usb: phy: initialize the notifier when add a new phy
We need to initialize the notifer before use it.

So lets initialize it when add a new phy device to
reduce the code redundancy.

Signed-off-by: Neil Zhang <zhangwm@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-12-12 13:43:34 -06:00
Wei Yongjun
e8d68f88bc usb: phy: phy-generic: fix return value check in usb_nop_xceiv_register()
In case of error, the function platform_device_register_simple() returns
ERR_PTR() and never returns NULL. The NULL test in the return value check
should be replaced with IS_ERR().

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-11-25 10:56:48 -06:00
Heikki Krogerus
37cfbc4288 usb: phy: generic: fix a compiler warning
Just because it annoys me.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-11-25 10:25:59 -06:00
Aaro Koskinen
dc52c57411 usb: phy-generic: fix nop xceiv probe
Commit bd27fa44e1 (usb: phy: generic:
Don't use regulator framework for RESET line) introduced regression: All
users of usb_nop_xceiv_register() will fail because there is no platform
data and the default reset GPIO is 0 which is a valid GPIO. Fix that.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Acked-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-11-25 10:25:59 -06:00
Felipe Balbi
af9f51c551 usb: phy: generic: fix how we find out about our resources
instead of having each user of generic phy find
out about its own resources and pass it to the
core layer, have th core layer itself figure that
out. It's as simple as moving a piece of code
around. This fixes a big regression caused during
the merge window where am335x-based platforms
wouldn't be able to probe their PHY driver.

Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-11-25 10:25:57 -06:00
Michal Nazarewicz
39189c98d1 usb: phy: remove dead code
Commit [4d175f34: usb: phy: nop: Defer clock prepare until PHY init]
removed a goto reaching behind a “return ret” at the end of the function
thus removing the only possible way that statement could be reached, and
so rendering it a dead code.  This commit cleans it up by removing said
dead code.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-11-25 10:25:39 -06:00
Roger Quadros
bd27fa44e1 usb: phy: generic: Don't use regulator framework for RESET line
Modelling the RESET line as a regulator supply wasn't a good idea
as it kind of abuses the regulator framework and also makes adaptation
code more complex.

Instead, manage the RESET gpio line directly in the driver. Update
the device tree binding information.

This also makes us easy to migrate to a dedicated GPIO RESET controller
whenever it becomes available.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-10-04 09:29:03 -05:00
Mark Brown
4d175f340c usb: phy: nop: Defer clock prepare until PHY init
Since we only enable the PHY clock on init and the PHY init and shutdown
does not occur in atomitc context there is no need to prepare the clock
before it is enabled.  Move the clk_prepare() operations to go along
with the enables, allowing the clock to be fully idle when not in use.

Signed-off-by: Mark Brown <broonie@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-10-01 09:31:10 -05:00
Sebastian Andrzej Siewior
53b6fc28ea usb: phy: phy-generic: export init functions
This patch exports the mostly generic functions so they can be used from
other phy driver instead of duplicating the code.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-08-09 17:34:02 +03:00
Felipe Balbi
9e5f9c8aa8 Merge branch 'nop-phy-rename' into next
Signed-off-by: Felipe Balbi <balbi@ti.com>

Conflicts:
	drivers/usb/phy/phy-generic.c
2013-08-09 17:31:23 +03:00
Sebastian Andrzej Siewior
3fa4d7344b usb: phy: rename nop_usb_xceiv => usb_phy_gen_xceiv
The "nop" driver isn't a do-nothing-stub but supports a couple functions
like clock on/off or is able to use a voltage regulator. This patch
simply renames the driver to "generic" since it is easy possible to
extend it by a simple function istead of writing a complete driver.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-08-09 17:26:00 +03:00
Renamed from drivers/usb/phy/phy-nop.c (Browse further)