From 474c689930942a2d41e8ee00a404dc7b3d6f3e1d Mon Sep 17 00:00:00 2001 From: Kevin Kim Date: Tue, 26 Jun 2018 18:51:41 +0900 Subject: [PATCH] ODROID-C3: usb/phy: GPIO pin init for usb3.0 hub enable/reset. Change-Id: If46fce7fd85922ffb6a77ab5937a7be2373c8370 --- .../boot/dts/amlogic/s905d2_odroidc3.dts | 6 +++- drivers/amlogic/usb/phy/phy-aml-new-usb3-v2.c | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/amlogic/s905d2_odroidc3.dts b/arch/arm64/boot/dts/amlogic/s905d2_odroidc3.dts index 6be582f96698..597c5fb8c666 100644 --- a/arch/arm64/boot/dts/amlogic/s905d2_odroidc3.dts +++ b/arch/arm64/boot/dts/amlogic/s905d2_odroidc3.dts @@ -865,7 +865,11 @@ portnum = <1>; otg = <1>; gpio-vbus-power = "GPIOH_6"; - gpios = <&gpio GPIOH_6 GPIO_ACTIVE_HIGH>; + hub-en = "GPIOH_5"; + hub-rst = "GPIOH_4"; + gpios = <&gpio GPIOH_6 GPIO_ACTIVE_HIGH + &gpio GPIOH_5 GPIO_ACTIVE_HIGH + &gpio GPIOH_4 GPIO_ACTIVE_HIGH>; }; &dwc2_a { diff --git a/drivers/amlogic/usb/phy/phy-aml-new-usb3-v2.c b/drivers/amlogic/usb/phy/phy-aml-new-usb3-v2.c index 3f360b589a79..f3483e7d656e 100644 --- a/drivers/amlogic/usb/phy/phy-aml-new-usb3-v2.c +++ b/drivers/amlogic/usb/phy/phy-aml-new-usb3-v2.c @@ -491,6 +491,10 @@ static int amlogic_new_usb3_v2_probe(struct platform_device *pdev) int otg = 0; int ret; struct device_node *tsi_pci; +#if defined(CONFIG_ARCH_MESON64_ODROIDC3) + struct gpio_desc *huben_gd = NULL; + struct gpio_desc *hubrst_gd = NULL; +#endif gpio_name = of_get_property(dev->of_node, "gpio-vbus-power", NULL); if (gpio_name) { @@ -501,6 +505,32 @@ static int amlogic_new_usb3_v2_probe(struct platform_device *pdev) return -1; } +#if defined(CONFIG_ARCH_MESON64_ODROIDC3) + gpio_name = of_get_property(dev->of_node, "hub-en", NULL); + if (gpio_name) { + huben_gd = gpiod_get_index(&pdev->dev, + NULL, 1, GPIOD_OUT_HIGH); + if (IS_ERR(huben_gd)) + return -1; + gpiod_direction_output(huben_gd, 1); + mdelay(20); + gpiod_put(huben_gd); + } + + gpio_name = of_get_property(dev->of_node, "hub-rst", NULL); + if (gpio_name) { + hubrst_gd = gpiod_get_index(&pdev->dev, + NULL, 2, GPIOD_OUT_HIGH); + if (IS_ERR(hubrst_gd)) + return -1; + gpiod_direction_output(hubrst_gd, 0); + mdelay(20); + gpiod_direction_output(hubrst_gd, 1); + mdelay(20); + gpiod_put(hubrst_gd); + } +#endif + prop = of_get_property(dev->of_node, "portnum", NULL); if (prop) portnum = of_read_ulong(prop, 1);