Skip to contentSkip to conversation

ARM: dts: exynos: fix polarity of VBUS GPIO

PATCH Applied Dmitry Torokhov 4 participants 6 messages Sep 27, 2022 – Sep 30, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ARM: dts: exynos: fix polarity of VBUS GPIO

EHCI Oxynos (drivers/usb/host/ehci-exynos.c) drives VBUS GPIO high when trying to power up the bus, therefore the GPIO in DTS must be marked as "active high". This will be important when EHCI driver is converted to gpiod API that respects declared polarities.

Fixes 4e8991def565 ("ARM: dts: exynos: Enable AX88760 USB hub on Origen board")
---
 arch/arm/boot/dts/exynos4412-origen.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/exynos4412-origen.dts +1 -1
index 6db09dba07ff..a3905e27b9cd 100644
@@ -95,7 +95,7 @@ &exynos_usbphy {
 };
 
 &ehci {
-	samsung,vbus-gpio = <&gpx3 5 1>;
+	samsung,vbus-gpio = <&gpx3 5 GPIO_ACTIVE_HIGH>;
 	status = "okay";
 	phys = <&exynos_usbphy 2>, <&exynos_usbphy 3>;
 	phy-names = "hsic0", "hsic1";
Signature · 1 line
2.38.0.rc1.362.ged0d419d3c-goog
#1 lore raw

PATCH 2/2 usb: host: ehci-exynos: switch to using gpiod API

This patch switches the driver from using legacy gpio API to the newer gpiod API.

---
 drivers/usb/host/ehci-exynos.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/usb/host/ehci-exynos.c +5 -12
index c8e152c2e0ce..a333231616f4 100644
@@ -13,7 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/usb.h>
@@ -131,20 +131,13 @@ static void exynos_ehci_phy_disable(struct device *dev)
 
 static void exynos_setup_vbus_gpio(struct device *dev)
 {
+	struct gpio_desc *gpio;
 	int err;
-	int gpio;
 
-	if (!dev->of_node)
-		return;
-
-	gpio = of_get_named_gpio(dev->of_node, "samsung,vbus-gpio", 0);
-	if (!gpio_is_valid(gpio))
-		return;
-
-	err = devm_gpio_request_one(dev, gpio, GPIOF_OUT_INIT_HIGH,
-				    "ehci_vbus_gpio");
+	gpio = devm_gpiod_get_optional(dev, "samsung,vbus", GPIOD_OUT_HIGH);
+	err = PTR_ERR_OR_ZERO(gpio);
 	if (err)
-		dev_err(dev, "can't request ehci vbus gpio %d", gpio);
+		dev_err(dev, "can't request ehci vbus gpio: %d\n", err);
 }
 
 static int exynos_ehci_probe(struct platform_device *pdev)
Signature · 1 line
2.38.0.rc1.362.ged0d419d3c-goog
maintainer Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] usb: host: ehci-exynos: switch to using gpiod API

In reply to Dmitry Torokhov
Quoted 5 lines · Dmitry Torokhov

This patch switches the driver from using legacy gpio API to the newer gpiod API.

---

Quoted 44 lines
 drivers/usb/host/ehci-exynos.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/usb/host/ehci-exynos.c +5 -12
index c8e152c2e0ce..a333231616f4 100644
@@ -13,7 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/usb.h>
@@ -131,20 +131,13 @@ static void exynos_ehci_phy_disable(struct device *dev)
 
 static void exynos_setup_vbus_gpio(struct device *dev)
 {
+	struct gpio_desc *gpio;
 	int err;
-	int gpio;
 
-	if (!dev->of_node)
-		return;
-
-	gpio = of_get_named_gpio(dev->of_node, "samsung,vbus-gpio", 0);
-	if (!gpio_is_valid(gpio))
-		return;
-
-	err = devm_gpio_request_one(dev, gpio, GPIOF_OUT_INIT_HIGH,
-				    "ehci_vbus_gpio");
+	gpio = devm_gpiod_get_optional(dev, "samsung,vbus", GPIOD_OUT_HIGH);
+	err = PTR_ERR_OR_ZERO(gpio);
 	if (err)
-		dev_err(dev, "can't request ehci vbus gpio %d", gpio);
+		dev_err(dev, "can't request ehci vbus gpio: %d\n", err);
 }
 
 static int exynos_ehci_probe(struct platform_device *pdev)
Signature · 1 line
2.38.0.rc1.362.ged0d419d3c-goog
#5 lore raw

Re: (subset) [PATCH 1/2] ARM: dts: exynos: fix polarity of VBUS GPIO

In reply to Dmitry Torokhov
Quoted 6 lines · Dmitry Torokhov

EHCI Oxynos (drivers/usb/host/ehci-exynos.c) drives VBUS GPIO high when trying to power up the bus, therefore the GPIO in DTS must be marked as "active high". This will be important when EHCI driver is converted to gpiod API that respects declared polarities.

Applied, thanks!

[1/2] ARM: dts: exynos: fix polarity of VBUS GPIO

      https://git.kernel.org/krzk/linux/c/a08137bd1e0a7ce951dce9ce4a83e39d379b6e1b

Best regards,

Signature · 1 line
Krzysztof Kozlowski <[email protected]>