diff mbox series

[U-Boot,v2,2/2] regulator: Allow enabling GPIO regulator

Message ID 20190624110334.16451-2-sven@svenschwermer.de
State Accepted
Commit aa2067a8692ece9b4ce470a2c6c6704987bfd56c
Delegated to: Tom Rini
Headers show
Series [U-Boot,v2,1/2] regulator: Factor out common enable code | expand

Commit Message

Sven Schwermer June 24, 2019, 11:03 a.m. UTC
From: Sven Schwermer <sven@svenschwermer.de>

Drivers need to be able to enable regulators that may be implemented as
GPIO regulators. Example: fsl_esdhc enables the vqmmc supply which is
commonly implemented as a GPIO regulator in order to switch between I/O
voltage levels.

Signed-off-by: Sven Schwermer <sven@svenschwermer.de>
---
 drivers/power/regulator/Kconfig          |  2 ++
 drivers/power/regulator/gpio-regulator.c | 18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

Comments

Lukasz Majewski June 28, 2019, 9:46 a.m. UTC | #1
On Mon, 24 Jun 2019 13:03:34 +0200
sven@svenschwermer.de wrote:

> From: Sven Schwermer <sven@svenschwermer.de>
> 
> Drivers need to be able to enable regulators that may be implemented
> as GPIO regulators. Example: fsl_esdhc enables the vqmmc supply which
> is commonly implemented as a GPIO regulator in order to switch
> between I/O voltage levels.
> 
> Signed-off-by: Sven Schwermer <sven@svenschwermer.de>
> ---
>  drivers/power/regulator/Kconfig          |  2 ++
>  drivers/power/regulator/gpio-regulator.c | 18 +++++++++++++++++-
>  2 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/regulator/Kconfig
> b/drivers/power/regulator/Kconfig index e0b8398ef4..bb10d20545 100644
> --- a/drivers/power/regulator/Kconfig
> +++ b/drivers/power/regulator/Kconfig
> @@ -120,6 +120,7 @@ config SPL_DM_REGULATOR_FIXED
>  config DM_REGULATOR_GPIO
>  	bool "Enable Driver Model for GPIO REGULATOR"
>  	depends on DM_REGULATOR && DM_GPIO
> +	select DM_REGULATOR_COMMON
>  	---help---
>  	This config enables implementation of driver-model regulator
> uclass features for gpio regulators. The driver implements get/set for
> @@ -128,6 +129,7 @@ config DM_REGULATOR_GPIO
>  config SPL_DM_REGULATOR_GPIO
>  	bool "Enable Driver Model for GPIO REGULATOR in SPL"
>  	depends on DM_REGULATOR_GPIO && SPL_GPIO_SUPPORT
> +	select SPL_DM_REGULATOR_COMMON
>  	---help---
>  	This config enables implementation of driver-model regulator
> uclass features for gpio regulators in SPL.
> diff --git a/drivers/power/regulator/gpio-regulator.c
> b/drivers/power/regulator/gpio-regulator.c index
> d18e5d8d2c..ec1dcb64b3 100644 ---
> a/drivers/power/regulator/gpio-regulator.c +++
> b/drivers/power/regulator/gpio-regulator.c @@ -4,6 +4,7 @@
>   * Keerthy <j-keerthy@ti.com>
>   */
>  
> +#include "regulator_common.h"
>  #include <common.h>
>  #include <fdtdec.h>
>  #include <errno.h>
> @@ -18,6 +19,7 @@
>  DECLARE_GLOBAL_DATA_PTR;
>  
>  struct gpio_regulator_platdata {
> +	struct regulator_common_platdata common;
>  	struct gpio_desc gpio; /* GPIO for regulator voltage control
> */ int states[GPIO_REGULATOR_MAX_STATES];
>  	int voltages[GPIO_REGULATOR_MAX_STATES];
> @@ -65,7 +67,7 @@ static int gpio_regulator_ofdata_to_platdata(struct
> udevice *dev) j++;
>  	}
>  
> -	return 0;
> +	return regulator_common_ofdata_to_platdata(dev,
> &dev_pdata->common, "enable-gpios"); }
>  
>  static int gpio_regulator_get_value(struct udevice *dev)
> @@ -116,9 +118,23 @@ static int gpio_regulator_set_value(struct
> udevice *dev, int uV) return 0;
>  }
>  
> +static int gpio_regulator_get_enable(struct udevice *dev)
> +{
> +	struct gpio_regulator_platdata *dev_pdata =
> dev_get_platdata(dev);
> +	return regulator_common_get_enable(dev, &dev_pdata->common);
> +}
> +
> +static int gpio_regulator_set_enable(struct udevice *dev, bool
> enable) +{
> +	struct gpio_regulator_platdata *dev_pdata =
> dev_get_platdata(dev);
> +	return regulator_common_set_enable(dev, &dev_pdata->common,
> enable); +}
> +
>  static const struct dm_regulator_ops gpio_regulator_ops = {
>  	.get_value	= gpio_regulator_get_value,
>  	.set_value	= gpio_regulator_set_value,
> +	.get_enable	= gpio_regulator_get_enable,
> +	.set_enable	= gpio_regulator_set_enable,
>  };
>  
>  static const struct udevice_id gpio_regulator_ids[] = {

Reviewed-by: Lukasz Majewski <lukma@denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Sven Schwermer July 10, 2019, 10:02 a.m. UTC | #2
Hi again,

Is there anything else I should do in order to get this applied?

Best regards
Sven

> On 28 Jun 2019, at 11:46, Lukasz Majewski <lukma@denx.de> wrote:
> 
> On Mon, 24 Jun 2019 13:03:34 +0200
> sven@svenschwermer.de wrote:
> 
>> From: Sven Schwermer <sven@svenschwermer.de>
>> 
>> Drivers need to be able to enable regulators that may be implemented
>> as GPIO regulators. Example: fsl_esdhc enables the vqmmc supply which
>> is commonly implemented as a GPIO regulator in order to switch
>> between I/O voltage levels.
>> 
>> Signed-off-by: Sven Schwermer <sven@svenschwermer.de>
>> ---
>> drivers/power/regulator/Kconfig          |  2 ++
>> drivers/power/regulator/gpio-regulator.c | 18 +++++++++++++++++-
>> 2 files changed, 19 insertions(+), 1 deletion(-)
>> 
>> diff --git a/drivers/power/regulator/Kconfig
>> b/drivers/power/regulator/Kconfig index e0b8398ef4..bb10d20545 100644
>> --- a/drivers/power/regulator/Kconfig
>> +++ b/drivers/power/regulator/Kconfig
>> @@ -120,6 +120,7 @@ config SPL_DM_REGULATOR_FIXED
>> config DM_REGULATOR_GPIO
>> 	bool "Enable Driver Model for GPIO REGULATOR"
>> 	depends on DM_REGULATOR && DM_GPIO
>> +	select DM_REGULATOR_COMMON
>> 	---help---
>> 	This config enables implementation of driver-model regulator
>> uclass features for gpio regulators. The driver implements get/set for
>> @@ -128,6 +129,7 @@ config DM_REGULATOR_GPIO
>> config SPL_DM_REGULATOR_GPIO
>> 	bool "Enable Driver Model for GPIO REGULATOR in SPL"
>> 	depends on DM_REGULATOR_GPIO && SPL_GPIO_SUPPORT
>> +	select SPL_DM_REGULATOR_COMMON
>> 	---help---
>> 	This config enables implementation of driver-model regulator
>> uclass features for gpio regulators in SPL.
>> diff --git a/drivers/power/regulator/gpio-regulator.c
>> b/drivers/power/regulator/gpio-regulator.c index
>> d18e5d8d2c..ec1dcb64b3 100644 ---
>> a/drivers/power/regulator/gpio-regulator.c +++
>> b/drivers/power/regulator/gpio-regulator.c @@ -4,6 +4,7 @@
>>  * Keerthy <j-keerthy@ti.com>
>>  */
>> 
>> +#include "regulator_common.h"
>> #include <common.h>
>> #include <fdtdec.h>
>> #include <errno.h>
>> @@ -18,6 +19,7 @@
>> DECLARE_GLOBAL_DATA_PTR;
>> 
>> struct gpio_regulator_platdata {
>> +	struct regulator_common_platdata common;
>> 	struct gpio_desc gpio; /* GPIO for regulator voltage control
>> */ int states[GPIO_REGULATOR_MAX_STATES];
>> 	int voltages[GPIO_REGULATOR_MAX_STATES];
>> @@ -65,7 +67,7 @@ static int gpio_regulator_ofdata_to_platdata(struct
>> udevice *dev) j++;
>> 	}
>> 
>> -	return 0;
>> +	return regulator_common_ofdata_to_platdata(dev,
>> &dev_pdata->common, "enable-gpios"); }
>> 
>> static int gpio_regulator_get_value(struct udevice *dev)
>> @@ -116,9 +118,23 @@ static int gpio_regulator_set_value(struct
>> udevice *dev, int uV) return 0;
>> }
>> 
>> +static int gpio_regulator_get_enable(struct udevice *dev)
>> +{
>> +	struct gpio_regulator_platdata *dev_pdata =
>> dev_get_platdata(dev);
>> +	return regulator_common_get_enable(dev, &dev_pdata->common);
>> +}
>> +
>> +static int gpio_regulator_set_enable(struct udevice *dev, bool
>> enable) +{
>> +	struct gpio_regulator_platdata *dev_pdata =
>> dev_get_platdata(dev);
>> +	return regulator_common_set_enable(dev, &dev_pdata->common,
>> enable); +}
>> +
>> static const struct dm_regulator_ops gpio_regulator_ops = {
>> 	.get_value	= gpio_regulator_get_value,
>> 	.set_value	= gpio_regulator_set_value,
>> +	.get_enable	= gpio_regulator_get_enable,
>> +	.set_enable	= gpio_regulator_set_enable,
>> };
>> 
>> static const struct udevice_id gpio_regulator_ids[] = {
> 
> Reviewed-by: Lukasz Majewski <lukma@denx.de>
> 
> 
> Best regards,
> 
> Lukasz Majewski
> 
> --
> 
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Peng Fan July 10, 2019, 10:07 a.m. UTC | #3
> Subject: Re: [U-Boot] [PATCH v2 2/2] regulator: Allow enabling GPIO regulator
> 
> Hi again,
> 
> Is there anything else I should do in order to get this applied?

+ Tom

> 
> Best regards
> Sven
> 
> > On 28 Jun 2019, at 11:46, Lukasz Majewski <lukma@denx.de> wrote:
> >
> > On Mon, 24 Jun 2019 13:03:34 +0200
> > sven@svenschwermer.de wrote:
> >
> >> From: Sven Schwermer <sven@svenschwermer.de>
> >>
> >> Drivers need to be able to enable regulators that may be implemented
> >> as GPIO regulators. Example: fsl_esdhc enables the vqmmc supply which
> >> is commonly implemented as a GPIO regulator in order to switch
> >> between I/O voltage levels.
> >>
> >> Signed-off-by: Sven Schwermer <sven@svenschwermer.de>
> >> ---
> >> drivers/power/regulator/Kconfig          |  2 ++
> >> drivers/power/regulator/gpio-regulator.c | 18 +++++++++++++++++-
> >> 2 files changed, 19 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/power/regulator/Kconfig
> >> b/drivers/power/regulator/Kconfig index e0b8398ef4..bb10d20545 100644
> >> --- a/drivers/power/regulator/Kconfig
> >> +++ b/drivers/power/regulator/Kconfig
> >> @@ -120,6 +120,7 @@ config SPL_DM_REGULATOR_FIXED config
> >> DM_REGULATOR_GPIO
> >> 	bool "Enable Driver Model for GPIO REGULATOR"
> >> 	depends on DM_REGULATOR && DM_GPIO
> >> +	select DM_REGULATOR_COMMON
> >> 	---help---
> >> 	This config enables implementation of driver-model regulator uclass
> >> features for gpio regulators. The driver implements get/set for @@
> >> -128,6 +129,7 @@ config DM_REGULATOR_GPIO config
> >> SPL_DM_REGULATOR_GPIO
> >> 	bool "Enable Driver Model for GPIO REGULATOR in SPL"
> >> 	depends on DM_REGULATOR_GPIO && SPL_GPIO_SUPPORT
> >> +	select SPL_DM_REGULATOR_COMMON
> >> 	---help---
> >> 	This config enables implementation of driver-model regulator uclass
> >> features for gpio regulators in SPL.
> >> diff --git a/drivers/power/regulator/gpio-regulator.c
> >> b/drivers/power/regulator/gpio-regulator.c index
> >> d18e5d8d2c..ec1dcb64b3 100644 ---
> >> a/drivers/power/regulator/gpio-regulator.c +++
> >> b/drivers/power/regulator/gpio-regulator.c @@ -4,6 +4,7 @@
> >>  * Keerthy <j-keerthy@ti.com>
> >>  */
> >>
> >> +#include "regulator_common.h"
> >> #include <common.h>
> >> #include <fdtdec.h>
> >> #include <errno.h>
> >> @@ -18,6 +19,7 @@
> >> DECLARE_GLOBAL_DATA_PTR;
> >>
> >> struct gpio_regulator_platdata {
> >> +	struct regulator_common_platdata common;
> >> 	struct gpio_desc gpio; /* GPIO for regulator voltage control */ int
> >> states[GPIO_REGULATOR_MAX_STATES];
> >> 	int voltages[GPIO_REGULATOR_MAX_STATES];
> >> @@ -65,7 +67,7 @@ static int gpio_regulator_ofdata_to_platdata(struct
> >> udevice *dev) j++;
> >> 	}
> >>
> >> -	return 0;
> >> +	return regulator_common_ofdata_to_platdata(dev,
> >> &dev_pdata->common, "enable-gpios"); }
> >>
> >> static int gpio_regulator_get_value(struct udevice *dev) @@ -116,9
> >> +118,23 @@ static int gpio_regulator_set_value(struct udevice *dev,
> >> int uV) return 0; }
> >>
> >> +static int gpio_regulator_get_enable(struct udevice *dev) {
> >> +	struct gpio_regulator_platdata *dev_pdata =
> >> dev_get_platdata(dev);
> >> +	return regulator_common_get_enable(dev, &dev_pdata->common); }
> >> +
> >> +static int gpio_regulator_set_enable(struct udevice *dev, bool
> >> enable) +{
> >> +	struct gpio_regulator_platdata *dev_pdata =
> >> dev_get_platdata(dev);
> >> +	return regulator_common_set_enable(dev, &dev_pdata->common,
> >> enable); +}
> >> +
> >> static const struct dm_regulator_ops gpio_regulator_ops = {
> >> 	.get_value	= gpio_regulator_get_value,
> >> 	.set_value	= gpio_regulator_set_value,
> >> +	.get_enable	= gpio_regulator_get_enable,
> >> +	.set_enable	= gpio_regulator_set_enable,
> >> };
> >>
> >> static const struct udevice_id gpio_regulator_ids[] = {
> >
> > Reviewed-by: Lukasz Majewski <lukma@denx.de>
> >
> >
> > Best regards,
> >
> > Lukasz Majewski
> >
> > --
> >
> > DENX Software Engineering GmbH,      Managing Director: Wolfgang
> Denk
> > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> > Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
> > lukma@denx.de
Tom Rini July 18, 2019, 11:56 p.m. UTC | #4
On Mon, Jun 24, 2019 at 01:03:34PM +0200, sven@svenschwermer.de wrote:

> From: Sven Schwermer <sven@svenschwermer.de>
> 
> Drivers need to be able to enable regulators that may be implemented as
> GPIO regulators. Example: fsl_esdhc enables the vqmmc supply which is
> commonly implemented as a GPIO regulator in order to switch between I/O
> voltage levels.
> 
> Signed-off-by: Sven Schwermer <sven@svenschwermer.de>
> Reviewed-by: Lukasz Majewski <lukma@denx.de>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig
index e0b8398ef4..bb10d20545 100644
--- a/drivers/power/regulator/Kconfig
+++ b/drivers/power/regulator/Kconfig
@@ -120,6 +120,7 @@  config SPL_DM_REGULATOR_FIXED
 config DM_REGULATOR_GPIO
 	bool "Enable Driver Model for GPIO REGULATOR"
 	depends on DM_REGULATOR && DM_GPIO
+	select DM_REGULATOR_COMMON
 	---help---
 	This config enables implementation of driver-model regulator uclass
 	features for gpio regulators. The driver implements get/set for
@@ -128,6 +129,7 @@  config DM_REGULATOR_GPIO
 config SPL_DM_REGULATOR_GPIO
 	bool "Enable Driver Model for GPIO REGULATOR in SPL"
 	depends on DM_REGULATOR_GPIO && SPL_GPIO_SUPPORT
+	select SPL_DM_REGULATOR_COMMON
 	---help---
 	This config enables implementation of driver-model regulator uclass
 	features for gpio regulators in SPL.
diff --git a/drivers/power/regulator/gpio-regulator.c b/drivers/power/regulator/gpio-regulator.c
index d18e5d8d2c..ec1dcb64b3 100644
--- a/drivers/power/regulator/gpio-regulator.c
+++ b/drivers/power/regulator/gpio-regulator.c
@@ -4,6 +4,7 @@ 
  * Keerthy <j-keerthy@ti.com>
  */
 
+#include "regulator_common.h"
 #include <common.h>
 #include <fdtdec.h>
 #include <errno.h>
@@ -18,6 +19,7 @@ 
 DECLARE_GLOBAL_DATA_PTR;
 
 struct gpio_regulator_platdata {
+	struct regulator_common_platdata common;
 	struct gpio_desc gpio; /* GPIO for regulator voltage control */
 	int states[GPIO_REGULATOR_MAX_STATES];
 	int voltages[GPIO_REGULATOR_MAX_STATES];
@@ -65,7 +67,7 @@  static int gpio_regulator_ofdata_to_platdata(struct udevice *dev)
 		j++;
 	}
 
-	return 0;
+	return regulator_common_ofdata_to_platdata(dev, &dev_pdata->common, "enable-gpios");
 }
 
 static int gpio_regulator_get_value(struct udevice *dev)
@@ -116,9 +118,23 @@  static int gpio_regulator_set_value(struct udevice *dev, int uV)
 	return 0;
 }
 
+static int gpio_regulator_get_enable(struct udevice *dev)
+{
+	struct gpio_regulator_platdata *dev_pdata = dev_get_platdata(dev);
+	return regulator_common_get_enable(dev, &dev_pdata->common);
+}
+
+static int gpio_regulator_set_enable(struct udevice *dev, bool enable)
+{
+	struct gpio_regulator_platdata *dev_pdata = dev_get_platdata(dev);
+	return regulator_common_set_enable(dev, &dev_pdata->common, enable);
+}
+
 static const struct dm_regulator_ops gpio_regulator_ops = {
 	.get_value	= gpio_regulator_get_value,
 	.set_value	= gpio_regulator_set_value,
+	.get_enable	= gpio_regulator_get_enable,
+	.set_enable	= gpio_regulator_set_enable,
 };
 
 static const struct udevice_id gpio_regulator_ids[] = {