linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/RFT][PATCH 1/3] regulator: core: Add enable_pulldown flag to indicate pulldown on EN input
@ 2013-02-15  9:19 Axel Lin
  2013-02-15  9:20 ` [RFC/RFT][PATCH 2/3] regulator: 88pm8607: Use enable_pulldown flag with regulator_enable_regmap and friends APIs Axel Lin
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Axel Lin @ 2013-02-15  9:19 UTC (permalink / raw)
  To: Mark Brown; +Cc: Haojian Zhuang, Jett.Zhou, Liam Girdwood, linux-kernel

Add enable_pulldown flag to indicate pulldown on EN input when using
regulator_enable_regmap and friends APIs.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/core.c         |   24 ++++++++++++++++++++----
 include/linux/regulator/driver.h |    3 +++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index da9782b..aff977f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1794,7 +1794,10 @@ int regulator_is_enabled_regmap(struct regulator_dev *rdev)
 	if (ret != 0)
 		return ret;
 
-	return (val & rdev->desc->enable_mask) != 0;
+	if (rdev->desc->enable_pulldown)
+		return (val & rdev->desc->enable_mask) == 0;
+	else
+		return (val & rdev->desc->enable_mask) != 0;
 }
 EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap);
 
@@ -1809,9 +1812,15 @@ EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap);
  */
 int regulator_enable_regmap(struct regulator_dev *rdev)
 {
+	unsigned int val;
+
+	if (rdev->desc->enable_pulldown)
+		val = 0;
+	else
+		val = rdev->desc->enable_mask;
+
 	return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
-				  rdev->desc->enable_mask,
-				  rdev->desc->enable_mask);
+				  rdev->desc->enable_mask, val);
 }
 EXPORT_SYMBOL_GPL(regulator_enable_regmap);
 
@@ -1826,8 +1835,15 @@ EXPORT_SYMBOL_GPL(regulator_enable_regmap);
  */
 int regulator_disable_regmap(struct regulator_dev *rdev)
 {
+	unsigned int val;
+
+	if (rdev->desc->enable_pulldown)
+		val = rdev->desc->enable_mask;
+	else
+		val = 0;
+
 	return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
-				  rdev->desc->enable_mask, 0);
+				  rdev->desc->enable_mask, val);
 }
 EXPORT_SYMBOL_GPL(regulator_disable_regmap);
 
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 23070fd..7ce1d0c 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -199,6 +199,8 @@ enum regulator_type {
  *                output when using regulator_set_voltage_sel_regmap
  * @enable_reg: Register for control when using regmap enable/disable ops
  * @enable_mask: Mask for control when using regmap enable/disable ops
+ * @enable_pulldown: A flag to indicate pulldown on EN input when using
+ *                   regulator_enable_regmap and friends APIs.
  *
  * @enable_time: Time taken for initial enable of regulator (in uS).
  */
@@ -226,6 +228,7 @@ struct regulator_desc {
 	unsigned int apply_bit;
 	unsigned int enable_reg;
 	unsigned int enable_mask;
+	bool enable_pulldown;
 	unsigned int bypass_reg;
 	unsigned int bypass_mask;
 
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RFC/RFT][PATCH 2/3] regulator: 88pm8607: Use enable_pulldown flag with regulator_enable_regmap and friends APIs
  2013-02-15  9:19 [RFC/RFT][PATCH 1/3] regulator: core: Add enable_pulldown flag to indicate pulldown on EN input Axel Lin
@ 2013-02-15  9:20 ` Axel Lin
  2013-02-15  9:21 ` [RFC/RFT][PATCH 3/3] regulator: max8649: " Axel Lin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Axel Lin @ 2013-02-15  9:20 UTC (permalink / raw)
  To: Mark Brown; +Cc: Haojian Zhuang, Jett.Zhou, Liam Girdwood, linux-kernel

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/88pm8607.c |   36 ++++--------------------------------
 1 file changed, 4 insertions(+), 32 deletions(-)

diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index c79ab84..0a8d514 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -220,35 +220,6 @@ static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
 	return ret;
 }
 
-static int pm8606_preg_enable(struct regulator_dev *rdev)
-{
-	struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
-
-	return pm860x_set_bits(info->i2c, rdev->desc->enable_reg,
-			       1 << rdev->desc->enable_mask, 0);
-}
-
-static int pm8606_preg_disable(struct regulator_dev *rdev)
-{
-	struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
-
-	return pm860x_set_bits(info->i2c, rdev->desc->enable_reg,
-			       1 << rdev->desc->enable_mask,
-			       1 << rdev->desc->enable_mask);
-}
-
-static int pm8606_preg_is_enabled(struct regulator_dev *rdev)
-{
-	struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
-	int ret;
-
-	ret = pm860x_reg_read(info->i2c, rdev->desc->enable_reg);
-	if (ret < 0)
-		return ret;
-
-	return !((unsigned char)ret & (1 << rdev->desc->enable_mask));
-}
-
 static struct regulator_ops pm8607_regulator_ops = {
 	.list_voltage	= pm8607_list_voltage,
 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
@@ -259,9 +230,9 @@ static struct regulator_ops pm8607_regulator_ops = {
 };
 
 static struct regulator_ops pm8606_preg_ops = {
-	.enable		= pm8606_preg_enable,
-	.disable	= pm8606_preg_disable,
-	.is_enabled	= pm8606_preg_is_enabled,
+	.enable		= regulator_enable_regmap,
+	.disable	= regulator_disable_regmap,
+	.is_enabled	= regulator_is_enabled_regmap,
 };
 
 #define PM8606_PREG(ereg, ebit)						\
@@ -274,6 +245,7 @@ static struct regulator_ops pm8606_preg_ops = {
 		.owner	= THIS_MODULE,					\
 		.enable_reg = PM8606_##ereg,				\
 		.enable_mask = (ebit),					\
+		.enable_pulldown = true,				\
 	},								\
 }
 
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RFC/RFT][PATCH 3/3] regulator: max8649: Use enable_pulldown flag with regulator_enable_regmap and friends APIs
  2013-02-15  9:19 [RFC/RFT][PATCH 1/3] regulator: core: Add enable_pulldown flag to indicate pulldown on EN input Axel Lin
  2013-02-15  9:20 ` [RFC/RFT][PATCH 2/3] regulator: 88pm8607: Use enable_pulldown flag with regulator_enable_regmap and friends APIs Axel Lin
@ 2013-02-15  9:21 ` Axel Lin
  2013-02-16  2:51 ` [RFC/RFT][PATCH 1/3] regulator: core: Add enable_pulldown flag to indicate pulldown on EN input Haojian Zhuang
  2013-03-01  9:22 ` Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Axel Lin @ 2013-02-15  9:21 UTC (permalink / raw)
  To: Mark Brown; +Cc: Haojian Zhuang, Jett.Zhou, Liam Girdwood, linux-kernel

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/max8649.c |   39 ++++++---------------------------------
 1 file changed, 6 insertions(+), 33 deletions(-)

diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c
index 3ca1438..55556dab 100644
--- a/drivers/regulator/max8649.c
+++ b/drivers/regulator/max8649.c
@@ -60,36 +60,6 @@ struct max8649_regulator_info {
 	unsigned	ramp_down:1;
 };
 
-/* EN_PD means pulldown on EN input */
-static int max8649_enable(struct regulator_dev *rdev)
-{
-	struct max8649_regulator_info *info = rdev_get_drvdata(rdev);
-	return regmap_update_bits(info->regmap, MAX8649_CONTROL, MAX8649_EN_PD, 0);
-}
-
-/*
- * Applied internal pulldown resistor on EN input pin.
- * If pulldown EN pin outside, it would be better.
- */
-static int max8649_disable(struct regulator_dev *rdev)
-{
-	struct max8649_regulator_info *info = rdev_get_drvdata(rdev);
-	return regmap_update_bits(info->regmap, MAX8649_CONTROL, MAX8649_EN_PD,
-				MAX8649_EN_PD);
-}
-
-static int max8649_is_enabled(struct regulator_dev *rdev)
-{
-	struct max8649_regulator_info *info = rdev_get_drvdata(rdev);
-	unsigned int val;
-	int ret;
-
-	ret = regmap_read(info->regmap, MAX8649_CONTROL, &val);
-	if (ret != 0)
-		return ret;
-	return !((unsigned char)val & MAX8649_EN_PD);
-}
-
 static int max8649_enable_time(struct regulator_dev *rdev)
 {
 	struct max8649_regulator_info *info = rdev_get_drvdata(rdev);
@@ -151,9 +121,9 @@ static struct regulator_ops max8649_dcdc_ops = {
 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
 	.list_voltage	= regulator_list_voltage_linear,
 	.map_voltage	= regulator_map_voltage_linear,
-	.enable		= max8649_enable,
-	.disable	= max8649_disable,
-	.is_enabled	= max8649_is_enabled,
+	.enable		= regulator_enable_regmap,
+	.disable	= regulator_disable_regmap,
+	.is_enabled	= regulator_is_enabled_regmap,
 	.enable_time	= max8649_enable_time,
 	.set_mode	= max8649_set_mode,
 	.get_mode	= max8649_get_mode,
@@ -169,6 +139,9 @@ static struct regulator_desc dcdc_desc = {
 	.vsel_mask	= MAX8649_VOL_MASK,
 	.min_uV		= MAX8649_DCDC_VMIN,
 	.uV_step	= MAX8649_DCDC_STEP,
+	.enable_reg	= MAX8649_CONTROL,
+	.enable_mask	= MAX8649_EN_PD,
+	.enable_pulldown = true,
 };
 
 static struct regmap_config max8649_regmap_config = {
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [RFC/RFT][PATCH 1/3] regulator: core: Add enable_pulldown flag to indicate pulldown on EN input
  2013-02-15  9:19 [RFC/RFT][PATCH 1/3] regulator: core: Add enable_pulldown flag to indicate pulldown on EN input Axel Lin
  2013-02-15  9:20 ` [RFC/RFT][PATCH 2/3] regulator: 88pm8607: Use enable_pulldown flag with regulator_enable_regmap and friends APIs Axel Lin
  2013-02-15  9:21 ` [RFC/RFT][PATCH 3/3] regulator: max8649: " Axel Lin
@ 2013-02-16  2:51 ` Haojian Zhuang
       [not found]   ` <CAFRkauBxV6sqN7w-YSE_tMZAJAOF2YANGzrU51btRT2Mz+fsNQ@mail.gmail.com>
  2013-03-01  9:22 ` Mark Brown
  3 siblings, 1 reply; 6+ messages in thread
From: Haojian Zhuang @ 2013-02-16  2:51 UTC (permalink / raw)
  To: Axel Lin; +Cc: Mark Brown, Jett.Zhou, Liam Girdwood, linux-kernel

On Fri, Feb 15, 2013 at 5:19 PM, Axel Lin <axel.lin@ingics.com> wrote:
> Add enable_pulldown flag to indicate pulldown on EN input when using
> regulator_enable_regmap and friends APIs.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  drivers/regulator/core.c         |   24 ++++++++++++++++++++----
>  include/linux/regulator/driver.h |    3 +++
>  2 files changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index da9782b..aff977f 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -1794,7 +1794,10 @@ int regulator_is_enabled_regmap(struct regulator_dev *rdev)
>         if (ret != 0)
>                 return ret;
>
> -       return (val & rdev->desc->enable_mask) != 0;
> +       if (rdev->desc->enable_pulldown)
> +               return (val & rdev->desc->enable_mask) == 0;
> +       else
> +               return (val & rdev->desc->enable_mask) != 0;
>  }
>  EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap);
>
> @@ -1809,9 +1812,15 @@ EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap);
>   */
>  int regulator_enable_regmap(struct regulator_dev *rdev)
>  {
> +       unsigned int val;
> +
> +       if (rdev->desc->enable_pulldown)
> +               val = 0;
> +       else
> +               val = rdev->desc->enable_mask;
> +
I think that enable_pulldown is a little hard to understand. How about change
the name, like set_to_disable or something else?

>         return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
> -                                 rdev->desc->enable_mask,
> -                                 rdev->desc->enable_mask);
> +                                 rdev->desc->enable_mask, val);
>  }
>  EXPORT_SYMBOL_GPL(regulator_enable_regmap);
>
> @@ -1826,8 +1835,15 @@ EXPORT_SYMBOL_GPL(regulator_enable_regmap);
>   */
>  int regulator_disable_regmap(struct regulator_dev *rdev)
>  {
> +       unsigned int val;
> +
> +       if (rdev->desc->enable_pulldown)
> +               val = rdev->desc->enable_mask;
> +       else
> +               val = 0;
> +
>         return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
> -                                 rdev->desc->enable_mask, 0);
> +                                 rdev->desc->enable_mask, val);
>  }
>  EXPORT_SYMBOL_GPL(regulator_disable_regmap);
>
> diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
> index 23070fd..7ce1d0c 100644
> --- a/include/linux/regulator/driver.h
> +++ b/include/linux/regulator/driver.h
> @@ -199,6 +199,8 @@ enum regulator_type {
>   *                output when using regulator_set_voltage_sel_regmap
>   * @enable_reg: Register for control when using regmap enable/disable ops
>   * @enable_mask: Mask for control when using regmap enable/disable ops
> + * @enable_pulldown: A flag to indicate pulldown on EN input when using
> + *                   regulator_enable_regmap and friends APIs.
>   *
>   * @enable_time: Time taken for initial enable of regulator (in uS).
>   */
> @@ -226,6 +228,7 @@ struct regulator_desc {
>         unsigned int apply_bit;
>         unsigned int enable_reg;
>         unsigned int enable_mask;
> +       bool enable_pulldown;
>         unsigned int bypass_reg;
>         unsigned int bypass_mask;
>
> --
> 1.7.9.5
>
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC/RFT][PATCH 1/3] regulator: core: Add enable_pulldown flag to indicate pulldown on EN input
       [not found]   ` <CAFRkauBxV6sqN7w-YSE_tMZAJAOF2YANGzrU51btRT2Mz+fsNQ@mail.gmail.com>
@ 2013-02-16  5:57     ` Haojian Zhuang
  0 siblings, 0 replies; 6+ messages in thread
From: Haojian Zhuang @ 2013-02-16  5:57 UTC (permalink / raw)
  To: Axel Lin; +Cc: Mark Brown, Jett.Zhou, Liam Girdwood, linux-kernel

On Sat, Feb 16, 2013 at 1:35 PM, Axel Lin <axel.lin@ingics.com> wrote:
>
>> I think that enable_pulldown is a little hard to understand. How about
>> change
>> the name, like set_to_disable or something else?
>
>
> How about "enable_invert"?
> ( We have ena_gpio_invert setting for GPIO controlled enable lines )
>
> Then I'll update the comments to:
> @enable_invert: A flag to indicate set enable_mask bits to disable when
> using
>                 regulator_enable_regmap and friends APIs.
>
> Axel

enable_is_inverted is better.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC/RFT][PATCH 1/3] regulator: core: Add enable_pulldown flag to indicate pulldown on EN input
  2013-02-15  9:19 [RFC/RFT][PATCH 1/3] regulator: core: Add enable_pulldown flag to indicate pulldown on EN input Axel Lin
                   ` (2 preceding siblings ...)
  2013-02-16  2:51 ` [RFC/RFT][PATCH 1/3] regulator: core: Add enable_pulldown flag to indicate pulldown on EN input Haojian Zhuang
@ 2013-03-01  9:22 ` Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2013-03-01  9:22 UTC (permalink / raw)
  To: Axel Lin; +Cc: Haojian Zhuang, Jett.Zhou, Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 718 bytes --]

On Fri, Feb 15, 2013 at 05:19:21PM +0800, Axel Lin wrote:
> Add enable_pulldown flag to indicate pulldown on EN input when using
> regulator_enable_regmap and friends APIs.

> -	return (val & rdev->desc->enable_mask) != 0;
> +	if (rdev->desc->enable_pulldown)
> +		return (val & rdev->desc->enable_mask) == 0;
> +	else
> +		return (val & rdev->desc->enable_mask) != 0;

Pulldown isn't the word here...  it's saying that enable is inverted,
not that it's pulled down.  Pulling something down is more an electrical
engineering thing saying what the default value for a signal is if it's
not otherwise driven, it doesn't really make sense in terms of a
register value.

Something like enable_active_low or enable_invert?

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-03-01  9:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-15  9:19 [RFC/RFT][PATCH 1/3] regulator: core: Add enable_pulldown flag to indicate pulldown on EN input Axel Lin
2013-02-15  9:20 ` [RFC/RFT][PATCH 2/3] regulator: 88pm8607: Use enable_pulldown flag with regulator_enable_regmap and friends APIs Axel Lin
2013-02-15  9:21 ` [RFC/RFT][PATCH 3/3] regulator: max8649: " Axel Lin
2013-02-16  2:51 ` [RFC/RFT][PATCH 1/3] regulator: core: Add enable_pulldown flag to indicate pulldown on EN input Haojian Zhuang
     [not found]   ` <CAFRkauBxV6sqN7w-YSE_tMZAJAOF2YANGzrU51btRT2Mz+fsNQ@mail.gmail.com>
2013-02-16  5:57     ` Haojian Zhuang
2013-03-01  9:22 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).