linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] regulator: pbias: Fix is_enabled callback implementation
@ 2014-03-07 15:41 Axel Lin
  2014-03-07 15:43 ` [PATCH 2/3] regulator: pbias: Convert to use regmap helper functions Axel Lin
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Axel Lin @ 2014-03-07 15:41 UTC (permalink / raw)
  To: Chris Ball, Liam Girdwood, Mark Brown
  Cc: Balaji T K, Florian Vaussard, Stefan Roese, linux-kernel,
	linux-mmc

The is_enabled implementation is wrong in some cases:
e.g. for pbias_mmc_omap5: emable_mask is : BIT(27) | BIT(25) | BIT(26)
However, pbias_regulator_enable() only sets BIT(26) | BIT(22) bits.
So is_enabled callback will always return false in this case.
Fix the logic to compare the register value with info->enable rather than
info->enable_mask.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/pbias-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c
index ded3b35..d89a1d8 100644
--- a/drivers/regulator/pbias-regulator.c
+++ b/drivers/regulator/pbias-regulator.c
@@ -108,7 +108,7 @@ static int pbias_regulator_is_enable(struct regulator_dev *rdev)
 
 	regmap_read(data->syscon, data->pbias_reg, &value);
 
-	return (value & info->enable_mask) == info->enable_mask;
+	return (value & info->enable_mask) == info->enable;
 }
 
 static struct regulator_ops pbias_regulator_voltage_ops = {
-- 
1.8.1.2




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

* [PATCH 2/3] regulator: pbias: Convert to use regmap helper functions
  2014-03-07 15:41 [PATCH 1/3] regulator: pbias: Fix is_enabled callback implementation Axel Lin
@ 2014-03-07 15:43 ` Axel Lin
  2014-03-07 16:46   ` Balaji T K
  2014-03-07 15:50 ` [PATCH 3/3] regulator: pbias: Convert to use regulator_[enable|is_enabled]_regmap Axel Lin
  2014-03-07 16:48 ` [PATCH 1/3] regulator: pbias: Fix is_enabled callback implementation Balaji T K
  2 siblings, 1 reply; 6+ messages in thread
From: Axel Lin @ 2014-03-07 15:43 UTC (permalink / raw)
  To: Chris Ball
  Cc: Liam Girdwood, Mark Brown, Balaji T K, Florian Vaussard,
	Stefan Roese, linux-kernel, linux-mmc

This patch converts this driver to use the regmap helper functions provided by
regulator core.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/pbias-regulator.c | 74 ++++++++++---------------------------
 1 file changed, 19 insertions(+), 55 deletions(-)

diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c
index d89a1d8..6d38be3 100644
--- a/drivers/regulator/pbias-regulator.c
+++ b/drivers/regulator/pbias-regulator.c
@@ -38,66 +38,24 @@ struct pbias_reg_info {
 struct pbias_regulator_data {
 	struct regulator_desc desc;
 	void __iomem *pbias_addr;
-	unsigned int pbias_reg;
 	struct regulator_dev *dev;
 	struct regmap *syscon;
 	const struct pbias_reg_info *info;
 	int voltage;
 };
 
-static int pbias_regulator_set_voltage(struct regulator_dev *dev,
-			int min_uV, int max_uV, unsigned *selector)
-{
-	struct pbias_regulator_data *data = rdev_get_drvdata(dev);
-	const struct pbias_reg_info *info = data->info;
-	int ret, vmode;
-
-	if (min_uV <= 1800000)
-		vmode = 0;
-	else if (min_uV > 1800000)
-		vmode = info->vmode;
-
-	ret = regmap_update_bits(data->syscon, data->pbias_reg,
-						info->vmode, vmode);
-
-	return ret;
-}
-
-static int pbias_regulator_get_voltage(struct regulator_dev *rdev)
-{
-	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
-	const struct pbias_reg_info *info = data->info;
-	int value, voltage;
-
-	regmap_read(data->syscon, data->pbias_reg, &value);
-	value &= info->vmode;
-
-	voltage = value ? 3000000 : 1800000;
-
-	return voltage;
-}
+static const unsigned int pbias_volt_table[] = {
+	1800000,
+	3000000
+};
 
 static int pbias_regulator_enable(struct regulator_dev *rdev)
 {
 	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
 	const struct pbias_reg_info *info = data->info;
-	int ret;
-
-	ret = regmap_update_bits(data->syscon, data->pbias_reg,
-					info->enable_mask, info->enable);
-
-	return ret;
-}
-
-static int pbias_regulator_disable(struct regulator_dev *rdev)
-{
-	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
-	const struct pbias_reg_info *info = data->info;
-	int ret;
 
-	ret = regmap_update_bits(data->syscon, data->pbias_reg,
-						info->enable_mask, 0);
-	return ret;
+	return regmap_update_bits(data->syscon, rdev->desc->enable_reg,
+				  info->enable_mask, info->enable);
 }
 
 static int pbias_regulator_is_enable(struct regulator_dev *rdev)
@@ -106,17 +64,18 @@ static int pbias_regulator_is_enable(struct regulator_dev *rdev)
 	const struct pbias_reg_info *info = data->info;
 	int value;
 
-	regmap_read(data->syscon, data->pbias_reg, &value);
+	regmap_read(data->syscon, rdev->desc->enable_reg, &value);
 
 	return (value & info->enable_mask) == info->enable;
 }
 
 static struct regulator_ops pbias_regulator_voltage_ops = {
-	.set_voltage	= pbias_regulator_set_voltage,
-	.get_voltage	= pbias_regulator_get_voltage,
-	.enable		= pbias_regulator_enable,
-	.disable	= pbias_regulator_disable,
-	.is_enabled	= pbias_regulator_is_enable,
+	.list_voltage = regulator_list_voltage_table,
+	.get_voltage_sel = regulator_get_voltage_sel_regmap,
+	.set_voltage_sel = regulator_set_voltage_sel_regmap,
+	.enable = pbias_regulator_enable,
+	.disable = regulator_disable_regmap,
+	.is_enabled = pbias_regulator_is_enable,
 };
 
 static const struct pbias_reg_info pbias_mmc_omap2430 = {
@@ -192,6 +151,7 @@ static int pbias_regulator_probe(struct platform_device *pdev)
 	if (IS_ERR(syscon))
 		return PTR_ERR(syscon);
 
+	cfg.regmap = syscon;
 	cfg.dev = &pdev->dev;
 
 	for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) {
@@ -207,15 +167,19 @@ static int pbias_regulator_probe(struct platform_device *pdev)
 		if (!res)
 			return -EINVAL;
 
-		drvdata[data_idx].pbias_reg = res->start;
 		drvdata[data_idx].syscon = syscon;
 		drvdata[data_idx].info = info;
 		drvdata[data_idx].desc.name = info->name;
 		drvdata[data_idx].desc.owner = THIS_MODULE;
 		drvdata[data_idx].desc.type = REGULATOR_VOLTAGE;
 		drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops;
+		drvdata[data_idx].desc.volt_table = pbias_volt_table;
 		drvdata[data_idx].desc.n_voltages = 2;
 		drvdata[data_idx].desc.enable_time = info->enable_time;
+		drvdata[data_idx].desc.vsel_reg = res->start;
+		drvdata[data_idx].desc.vsel_mask = info->vmode;
+		drvdata[data_idx].desc.enable_reg = res->start;
+		drvdata[data_idx].desc.enable_mask = info->enable_mask;
 
 		cfg.init_data = pbias_matches[idx].init_data;
 		cfg.driver_data = &drvdata[data_idx];
-- 
1.8.1.2

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

* [PATCH 3/3] regulator: pbias: Convert to use regulator_[enable|is_enabled]_regmap
  2014-03-07 15:41 [PATCH 1/3] regulator: pbias: Fix is_enabled callback implementation Axel Lin
  2014-03-07 15:43 ` [PATCH 2/3] regulator: pbias: Convert to use regmap helper functions Axel Lin
@ 2014-03-07 15:50 ` Axel Lin
  2014-03-07 16:46   ` Balaji T K
  2014-03-07 16:48 ` [PATCH 1/3] regulator: pbias: Fix is_enabled callback implementation Balaji T K
  2 siblings, 1 reply; 6+ messages in thread
From: Axel Lin @ 2014-03-07 15:50 UTC (permalink / raw)
  To: Chris Ball
  Cc: Liam Girdwood, Mark Brown, Balaji T K, Florian Vaussard,
	Stefan Roese, linux-kernel, linux-mmc

Since commit ca5d1b3524b4d
"regulator: helpers: Modify helpers enabling multi-bit control",
we can set enable_val setting for device that use multiple bits for control
when using regmap enable/disable/bypass ops.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
Note:
This patch depends on below commit which is only in regulator tree now:
http://git.kernel.org/cgit/linux/kernel/git/broonie/regulator.git/commit/?h=topic/enable

I sent this for reveiw and test now.
if it works, I'll resend it once 3.5-rc1 is released.

 drivers/regulator/pbias-regulator.c | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c
index 6d38be3..708ddbb 100644
--- a/drivers/regulator/pbias-regulator.c
+++ b/drivers/regulator/pbias-regulator.c
@@ -49,33 +49,13 @@ static const unsigned int pbias_volt_table[] = {
 	3000000
 };
 
-static int pbias_regulator_enable(struct regulator_dev *rdev)
-{
-	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
-	const struct pbias_reg_info *info = data->info;
-
-	return regmap_update_bits(data->syscon, rdev->desc->enable_reg,
-				  info->enable_mask, info->enable);
-}
-
-static int pbias_regulator_is_enable(struct regulator_dev *rdev)
-{
-	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
-	const struct pbias_reg_info *info = data->info;
-	int value;
-
-	regmap_read(data->syscon, rdev->desc->enable_reg, &value);
-
-	return (value & info->enable_mask) == info->enable;
-}
-
 static struct regulator_ops pbias_regulator_voltage_ops = {
 	.list_voltage = regulator_list_voltage_table,
 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
-	.enable = pbias_regulator_enable,
+	.enable = regulator_enable_regmap,
 	.disable = regulator_disable_regmap,
-	.is_enabled = pbias_regulator_is_enable,
+	.is_enabled = regulator_is_enabled_regmap,
 };
 
 static const struct pbias_reg_info pbias_mmc_omap2430 = {
@@ -180,6 +160,7 @@ static int pbias_regulator_probe(struct platform_device *pdev)
 		drvdata[data_idx].desc.vsel_mask = info->vmode;
 		drvdata[data_idx].desc.enable_reg = res->start;
 		drvdata[data_idx].desc.enable_mask = info->enable_mask;
+		drvdata[data_idx].desc.enable_val = info->enable;
 
 		cfg.init_data = pbias_matches[idx].init_data;
 		cfg.driver_data = &drvdata[data_idx];
-- 
1.8.1.2




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

* Re: [PATCH 3/3] regulator: pbias: Convert to use regulator_[enable|is_enabled]_regmap
  2014-03-07 15:50 ` [PATCH 3/3] regulator: pbias: Convert to use regulator_[enable|is_enabled]_regmap Axel Lin
@ 2014-03-07 16:46   ` Balaji T K
  0 siblings, 0 replies; 6+ messages in thread
From: Balaji T K @ 2014-03-07 16:46 UTC (permalink / raw)
  To: Axel Lin
  Cc: Chris Ball, Liam Girdwood, Mark Brown, Florian Vaussard,
	Stefan Roese, linux-kernel, linux-mmc

On Friday 07 March 2014 09:20 PM, Axel Lin wrote:
> Since commit ca5d1b3524b4d
> "regulator: helpers: Modify helpers enabling multi-bit control",
> we can set enable_val setting for device that use multiple bits for control
> when using regmap enable/disable/bypass ops.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> Note:
> This patch depends on below commit which is only in regulator tree now:
> http://git.kernel.org/cgit/linux/kernel/git/broonie/regulator.git/commit/?h=topic/enable
>
> I sent this for reveiw and test now.
> if it works, I'll resend it once 3.5-rc1 is released.
Hi,

I tested this series with above dependent commit and it works as excepted
So you can add my,
Tested-by: Balaji T K <balajitk@ti.com>

Thanks for doing regmap conversion, now pbias driver looks as minimal as possible.

>
>   drivers/regulator/pbias-regulator.c | 25 +++----------------------
>   1 file changed, 3 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c
> index 6d38be3..708ddbb 100644
> --- a/drivers/regulator/pbias-regulator.c
> +++ b/drivers/regulator/pbias-regulator.c
> @@ -49,33 +49,13 @@ static const unsigned int pbias_volt_table[] = {
>   	3000000
>   };
>
> -static int pbias_regulator_enable(struct regulator_dev *rdev)
> -{
> -	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
> -	const struct pbias_reg_info *info = data->info;
> -
> -	return regmap_update_bits(data->syscon, rdev->desc->enable_reg,
> -				  info->enable_mask, info->enable);
> -}
> -
> -static int pbias_regulator_is_enable(struct regulator_dev *rdev)
> -{
> -	struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
> -	const struct pbias_reg_info *info = data->info;
> -	int value;
> -
> -	regmap_read(data->syscon, rdev->desc->enable_reg, &value);
> -
> -	return (value & info->enable_mask) == info->enable;
> -}
> -
>   static struct regulator_ops pbias_regulator_voltage_ops = {
>   	.list_voltage = regulator_list_voltage_table,
>   	.get_voltage_sel = regulator_get_voltage_sel_regmap,
>   	.set_voltage_sel = regulator_set_voltage_sel_regmap,
> -	.enable = pbias_regulator_enable,
> +	.enable = regulator_enable_regmap,
>   	.disable = regulator_disable_regmap,
> -	.is_enabled = pbias_regulator_is_enable,
> +	.is_enabled = regulator_is_enabled_regmap,
>   };
>
>   static const struct pbias_reg_info pbias_mmc_omap2430 = {
> @@ -180,6 +160,7 @@ static int pbias_regulator_probe(struct platform_device *pdev)
>   		drvdata[data_idx].desc.vsel_mask = info->vmode;
>   		drvdata[data_idx].desc.enable_reg = res->start;
>   		drvdata[data_idx].desc.enable_mask = info->enable_mask;
> +		drvdata[data_idx].desc.enable_val = info->enable;
>
>   		cfg.init_data = pbias_matches[idx].init_data;
>   		cfg.driver_data = &drvdata[data_idx];
>

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

* Re: [PATCH 2/3] regulator: pbias: Convert to use regmap helper functions
  2014-03-07 15:43 ` [PATCH 2/3] regulator: pbias: Convert to use regmap helper functions Axel Lin
@ 2014-03-07 16:46   ` Balaji T K
  0 siblings, 0 replies; 6+ messages in thread
From: Balaji T K @ 2014-03-07 16:46 UTC (permalink / raw)
  To: Axel Lin
  Cc: Chris Ball, Liam Girdwood, Mark Brown, Florian Vaussard,
	Stefan Roese, linux-kernel, linux-mmc

On Friday 07 March 2014 09:13 PM, Axel Lin wrote:
> This patch converts this driver to use the regmap helper functions provided by
> regulator core.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Acked-by: Balaji T K <balajitk@ti.com>

> ---
>   drivers/regulator/pbias-regulator.c | 74 ++++++++++---------------------------
>   1 file changed, 19 insertions(+), 55 deletions(-)
>

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

* Re: [PATCH 1/3] regulator: pbias: Fix is_enabled callback implementation
  2014-03-07 15:41 [PATCH 1/3] regulator: pbias: Fix is_enabled callback implementation Axel Lin
  2014-03-07 15:43 ` [PATCH 2/3] regulator: pbias: Convert to use regmap helper functions Axel Lin
  2014-03-07 15:50 ` [PATCH 3/3] regulator: pbias: Convert to use regulator_[enable|is_enabled]_regmap Axel Lin
@ 2014-03-07 16:48 ` Balaji T K
  2 siblings, 0 replies; 6+ messages in thread
From: Balaji T K @ 2014-03-07 16:48 UTC (permalink / raw)
  To: Axel Lin
  Cc: Chris Ball, Liam Girdwood, Mark Brown, Florian Vaussard,
	Stefan Roese, linux-kernel, linux-mmc

On Friday 07 March 2014 09:11 PM, Axel Lin wrote:
> The is_enabled implementation is wrong in some cases:
> e.g. for pbias_mmc_omap5: emable_mask is : BIT(27) | BIT(25) | BIT(26)
Hi Axel,

s/emable_mask/enable_mask

> However, pbias_regulator_enable() only sets BIT(26) | BIT(22) bits.

You mixed up enable_mask of omap5 with .enable of omap4 :-)
above comment should be
"However, pbias_regulator_enable() only sets BIT(27) | BIT(26) bits"
Other than that
Acked-by: Balaji T K <balajitk@ti.com>

> So is_enabled callback will always return false in this case.
> Fix the logic to compare the register value with info->enable rather than
> info->enable_mask.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>   drivers/regulator/pbias-regulator.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c
> index ded3b35..d89a1d8 100644
> --- a/drivers/regulator/pbias-regulator.c
> +++ b/drivers/regulator/pbias-regulator.c
> @@ -108,7 +108,7 @@ static int pbias_regulator_is_enable(struct regulator_dev *rdev)
>
>   	regmap_read(data->syscon, data->pbias_reg, &value);
>
> -	return (value & info->enable_mask) == info->enable_mask;
> +	return (value & info->enable_mask) == info->enable;
>   }
>
>   static struct regulator_ops pbias_regulator_voltage_ops = {
>


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

end of thread, other threads:[~2014-03-07 16:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-07 15:41 [PATCH 1/3] regulator: pbias: Fix is_enabled callback implementation Axel Lin
2014-03-07 15:43 ` [PATCH 2/3] regulator: pbias: Convert to use regmap helper functions Axel Lin
2014-03-07 16:46   ` Balaji T K
2014-03-07 15:50 ` [PATCH 3/3] regulator: pbias: Convert to use regulator_[enable|is_enabled]_regmap Axel Lin
2014-03-07 16:46   ` Balaji T K
2014-03-07 16:48 ` [PATCH 1/3] regulator: pbias: Fix is_enabled callback implementation Balaji T K

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).