lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 28 Jan 2021 23:12:55 +0100
From:   Adrien Grassein <adrien.grassein@...il.com>
To:     unlisted-recipients:; (no To-header on input)
Cc:     kishon@...com, vkoul@...nel.org, robh+dt@...nel.org,
        shawnguo@...nel.org, s.hauer@...gutronix.de, kernel@...gutronix.de,
        festevam@...il.com, linux-imx@....com, rikard.falkeborn@...il.com,
        peter.chen@....com, jun.li@....com, linux-kernel@...r.kernel.org,
        devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        Adrien Grassein <adrien.grassein@...il.com>
Subject: [PATCH 2/2] phy: fsl-imx8mq-usb: handle resettable hubs

Add an optional GPIO in the dtb description that will
be used to reset the connected hub (if any).

Signed-off-by: Adrien Grassein <adrien.grassein@...il.com>
---
 drivers/phy/freescale/phy-fsl-imx8mq-usb.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
index a29b4a6f7c24..00abf7814fe9 100644
--- a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
+++ b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
@@ -4,6 +4,7 @@
 #include <linux/bitfield.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of_platform.h>
@@ -36,6 +37,7 @@ struct imx8mq_usb_phy {
 	struct clk *clk;
 	void __iomem *base;
 	struct regulator *vbus;
+	struct gpio_desc *reset_gpio;
 };
 
 static int imx8mq_usb_phy_init(struct phy *phy)
@@ -111,6 +113,9 @@ static int imx8mq_phy_power_on(struct phy *phy)
 	if (ret)
 		return ret;
 
+	if (imx_phy->reset_gpio)
+		gpiod_set_value_cansleep(imx_phy->reset_gpio, 0);
+
 	return clk_prepare_enable(imx_phy->clk);
 }
 
@@ -120,6 +125,8 @@ static int imx8mq_phy_power_off(struct phy *phy)
 
 	clk_disable_unprepare(imx_phy->clk);
 	regulator_disable(imx_phy->vbus);
+	if (imx_phy->reset_gpio)
+		gpiod_set_value_cansleep(imx_phy->reset_gpio, 1);
 
 	return 0;
 }
@@ -153,6 +160,7 @@ static int imx8mq_usb_phy_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct imx8mq_usb_phy *imx_phy;
 	const struct phy_ops *phy_ops;
+	int ret;
 
 	imx_phy = devm_kzalloc(dev, sizeof(*imx_phy), GFP_KERNEL);
 	if (!imx_phy)
@@ -180,6 +188,15 @@ static int imx8mq_usb_phy_probe(struct platform_device *pdev)
 	if (IS_ERR(imx_phy->vbus))
 		return PTR_ERR(imx_phy->vbus);
 
+	imx_phy->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(imx_phy->reset_gpio)) {
+		ret = PTR_ERR(imx_phy->reset_gpio);
+		if (ret == -ENXIO || ret == -ENODEV)
+			imx_phy->reset_gpio = NULL;
+		else
+			return PTR_ERR(imx_phy->reset_gpio);
+	}
+
 	phy_set_drvdata(imx_phy->phy, imx_phy);
 
 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ