diff mbox series

[2/4] usb: usb251xb: add vdd supply support

Message ID 20190917144449.32739-3-m.felsch@pengutronix.de (mailing list archive)
State Mainlined
Commit 4d7201cda226d7cffb591d94ca66ca0960891126
Headers show
Series Add simple-pm ops | expand

Commit Message

Marco Felsch Sept. 17, 2019, 2:44 p.m. UTC
Currently we don't handle the supply. We need to add the supply support
to be able to switch the supply off e.g. during a suspend-to-ram
operation. So we can guarantee a correct (re-)initialization.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 drivers/usb/misc/usb251xb.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Richard Leitner Sept. 18, 2019, 8:14 a.m. UTC | #1
On 17/09/2019 16:44, Marco Felsch wrote:
> Currently we don't handle the supply. We need to add the supply support
> to be able to switch the supply off e.g. during a suspend-to-ram
> operation. So we can guarantee a correct (re-)initialization.
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>

Hi,
tested it on a i.MX6 based platform with an usb2512.
Therefore please feel free to add:

Reviewed-by: Richard Leitner <richard.leitner@skidata.com>

and/or

Tested-by: Richard Leitner <richard.leitner@skidata.com>

regards;Richard.L

> ---
>   drivers/usb/misc/usb251xb.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
> index 6ca9111d150a..05819167604d 100644
> --- a/drivers/usb/misc/usb251xb.c
> +++ b/drivers/usb/misc/usb251xb.c
> @@ -17,6 +17,7 @@
>   #include <linux/module.h>
>   #include <linux/nls.h>
>   #include <linux/of_device.h>
> +#include <linux/regulator/consumer.h>
>   #include <linux/slab.h>
>   
>   /* Internal Register Set Addresses & Default Values acc. to DS00001692C */
> @@ -116,6 +117,7 @@
>   struct usb251xb {
>   	struct device *dev;
>   	struct i2c_client *i2c;
> +	struct regulator *vdd;
>   	u8 skip_config;
>   	struct gpio_desc *gpio_reset;
>   	u16 vendor_id;
> @@ -420,6 +422,10 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
>   		return err;
>   	}
>   
> +	hub->vdd = devm_regulator_get(dev, "vdd");
> +	if (IS_ERR(hub->vdd))
> +		return PTR_ERR(hub->vdd);
> +
>   	if (of_property_read_u16_array(np, "vendor-id", &hub->vendor_id, 1))
>   		hub->vendor_id = USB251XB_DEF_VENDOR_ID;
>   
> @@ -665,6 +671,10 @@ static int usb251xb_probe(struct usb251xb *hub)
>   	if (err)
>   		return err;
>   
> +	err = regulator_enable(hub->vdd);
> +	if (err)
> +		return err;
> +
>   	err = usb251xb_connect(hub);
>   	if (err) {
>   		dev_err(dev, "Failed to connect hub (%d)\n", err);
>
diff mbox series

Patch

diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 6ca9111d150a..05819167604d 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -17,6 +17,7 @@ 
 #include <linux/module.h>
 #include <linux/nls.h>
 #include <linux/of_device.h>
+#include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 
 /* Internal Register Set Addresses & Default Values acc. to DS00001692C */
@@ -116,6 +117,7 @@ 
 struct usb251xb {
 	struct device *dev;
 	struct i2c_client *i2c;
+	struct regulator *vdd;
 	u8 skip_config;
 	struct gpio_desc *gpio_reset;
 	u16 vendor_id;
@@ -420,6 +422,10 @@  static int usb251xb_get_ofdata(struct usb251xb *hub,
 		return err;
 	}
 
+	hub->vdd = devm_regulator_get(dev, "vdd");
+	if (IS_ERR(hub->vdd))
+		return PTR_ERR(hub->vdd);
+
 	if (of_property_read_u16_array(np, "vendor-id", &hub->vendor_id, 1))
 		hub->vendor_id = USB251XB_DEF_VENDOR_ID;
 
@@ -665,6 +671,10 @@  static int usb251xb_probe(struct usb251xb *hub)
 	if (err)
 		return err;
 
+	err = regulator_enable(hub->vdd);
+	if (err)
+		return err;
+
 	err = usb251xb_connect(hub);
 	if (err) {
 		dev_err(dev, "Failed to connect hub (%d)\n", err);