linux/drivers/usb/phy
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
..
am35x-phy-control.h usb: phy: Add AM335x PHY driver 2013-08-09 17:34:15 +03:00
Kconfig PM / Kconfig: Replace PM_RUNTIME with PM in dependencies 2014-12-13 00:44:04 +01:00
Makefile usb: phy: samsung: remove old USB 3.0 PHY driver 2014-09-02 09:16:44 -05:00
of.c usb: add devicetree helpers for determining dr_mode and phy_type 2013-06-17 13:47:09 -07:00
phy-ab8500-usb.c Driver core patches for 3.19-rc1 2014-12-14 16:10:09 -08:00
phy-am335x-control.c Driver core patches for 3.19-rc1 2014-12-14 16:10:09 -08:00
phy-am335x.c usb: phy: drop owner assignment from platform_drivers 2014-10-20 16:21:50 +02:00
phy-fsl-usb.c usb: phy: phy-fsl-usb: Remove some unused functions 2015-01-12 12:13:29 -06:00
phy-fsl-usb.h usb: phy: fsl: Fix build errors 2014-11-12 08:37:37 -06:00
phy-generic.c usb: phy: phy-generic: Fix USB PHY gpio reset 2015-01-30 10:38:51 -06:00
phy-generic.h usb: phy: generic: add vbus support 2015-01-12 12:13:29 -06:00
phy-gpio-vbus-usb.c Driver core patches for 3.19-rc1 2014-12-14 16:10:09 -08:00
phy-isp1301-omap.c Driver core patches for 3.19-rc1 2014-12-14 16:10:09 -08:00
phy-isp1301.c usb: phy: Fix NULL pointer exception during usb_get_phy 2013-05-15 17:32:47 +03:00
phy-keystone.c usb: phy: drop owner assignment from platform_drivers 2014-10-20 16:21:50 +02:00
phy-msm-usb.c USB patches for 3.19-rc1 2014-12-14 14:57:16 -08:00
phy-mv-usb.c usb: phy: mv-usb: fix usb_phy build errors 2015-01-13 09:32:22 -06:00
phy-mv-usb.h usb: otg: mv_otg: remove unused clock 2013-04-02 11:42:45 +03:00
phy-mxs-usb.c usb: phy: mxs: add delay before set phyctrl.clkgate 2015-01-27 09:40:49 -06:00
phy-omap-otg.c usb: phy: drop owner assignment from platform_drivers 2014-10-20 16:21:50 +02:00
phy-rcar-gen2-usb.c usb: phy: phy-rcar-gen2-usb: delete unnecessary 'out of memory' messages 2014-11-03 10:01:05 -06:00
phy-rcar-usb.c usb: phy: rcar-usb: remove duplicate check on resource 2014-11-03 10:01:21 -06:00
phy-tahvo.c Driver core patches for 3.19-rc1 2014-12-14 16:10:09 -08:00
phy-tegra-usb.c Driver core patches for 3.19-rc1 2014-12-14 16:10:09 -08:00
phy-twl6030-usb.c usb: phy: drop owner assignment from platform_drivers 2014-10-20 16:21:50 +02:00
phy-ulpi-viewport.c usb: Remove unnecessary semicolons 2013-10-11 16:26:46 -07:00
phy-ulpi.c usb: rename phy to usb_phy in OTG 2014-11-03 10:01:25 -06:00
phy.c usb: fixes for v3.19-rc5 2015-01-12 10:51:04 -08:00