linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFT 1/3] regulator: 88pm8607: Use regulator_get_voltage_sel_regmap()
@ 2012-04-24  1:52 Axel Lin
  2012-04-24  1:54 ` [PATCH RFT 2/3] regulator: da9052: " Axel Lin
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Axel Lin @ 2012-04-24  1:52 UTC (permalink / raw)
  To: linux-kernel; +Cc: Haojian Zhuang, Liam Girdwood, Mark Brown, Jett.Zhou

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/88pm8607.c |   36 +++++++++---------------------------
 1 files changed, 9 insertions(+), 27 deletions(-)

diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index f5de1c5..c3482b9 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -27,8 +27,6 @@ struct pm8607_regulator_info {
 	unsigned int	*vol_table;
 	unsigned int	*vol_suspend;
 
-	int	vol_reg;
-	int	vol_shift;
 	int	update_reg;
 	int	update_bit;
 	int	slope_double;
@@ -224,13 +222,13 @@ static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
 static int pm8607_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
 {
 	struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
-	uint8_t val, mask;
+	uint8_t val;
 	int ret;
 
-	val = (uint8_t)(selector << info->vol_shift);
-	mask = (rdev->desc->n_voltages - 1)  << info->vol_shift;
+	val = (uint8_t)(selector << (ffs(rdev->desc->vsel_mask) - 1));
 
-	ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, val);
+	ret = pm860x_set_bits(info->i2c, rdev->desc->vsel_reg,
+			      rdev->desc->vsel_mask, val);
 	if (ret)
 		return ret;
 	switch (info->desc.id) {
@@ -244,26 +242,10 @@ static int pm8607_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
 	return ret;
 }
 
-static int pm8607_get_voltage_sel(struct regulator_dev *rdev)
-{
-	struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
-	uint8_t val, mask;
-	int ret;
-
-	ret = pm860x_reg_read(info->i2c, info->vol_reg);
-	if (ret < 0)
-		return ret;
-
-	mask = (rdev->desc->n_voltages - 1)  << info->vol_shift;
-	val = ((unsigned char)ret & mask) >> info->vol_shift;
-
-	return val;
-}
-
 static struct regulator_ops pm8607_regulator_ops = {
 	.list_voltage	= pm8607_list_voltage,
 	.set_voltage_sel = pm8607_set_voltage_sel,
-	.get_voltage_sel = pm8607_get_voltage_sel,
+	.get_voltage_sel = regulator_get_voltage_sel_regmap,
 	.enable = regulator_enable_regmap,
 	.disable = regulator_disable_regmap,
 	.is_enabled = regulator_is_enabled_regmap,
@@ -278,11 +260,11 @@ static struct regulator_ops pm8607_regulator_ops = {
 		.id	= PM8607_ID_##vreg,				\
 		.owner	= THIS_MODULE,					\
 		.n_voltages = ARRAY_SIZE(vreg##_table),			\
+		.vsel_reg = PM8607_##vreg,				\
+		.vsel_mask = ARRAY_SIZE(vreg##_table) - 1,		\
 		.enable_reg = PM8607_##ereg,				\
 		.enable_mask = 1 << (ebit),				\
 	},								\
-	.vol_reg	= PM8607_##vreg,				\
-	.vol_shift	= (0),						\
 	.update_reg	= PM8607_##ureg,				\
 	.update_bit	= (ubit),					\
 	.slope_double	= (0),						\
@@ -299,11 +281,11 @@ static struct regulator_ops pm8607_regulator_ops = {
 		.id	= PM8607_ID_LDO##_id,				\
 		.owner	= THIS_MODULE,					\
 		.n_voltages = ARRAY_SIZE(LDO##_id##_table),		\
+		.vsel_reg = PM8607_##vreg,				\
+		.vsel_mask = (ARRAY_SIZE(LDO##_id##_table) - 1) << (shift), \
 		.enable_reg = PM8607_##ereg,				\
 		.enable_mask = 1 << (ebit),				\
 	},								\
-	.vol_reg	= PM8607_##vreg,				\
-	.vol_shift	= (shift),					\
 	.slope_double	= (0),						\
 	.vol_table	= (unsigned int *)&LDO##_id##_table,		\
 	.vol_suspend	= (unsigned int *)&LDO##_id##_suspend_table,	\
-- 
1.7.5.4




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

* [PATCH RFT 2/3] regulator: da9052: Use regulator_get_voltage_sel_regmap()
  2012-04-24  1:52 [PATCH RFT 1/3] regulator: 88pm8607: Use regulator_get_voltage_sel_regmap() Axel Lin
@ 2012-04-24  1:54 ` Axel Lin
  2012-05-04 12:30   ` Mark Brown
  2012-04-24  1:56 ` [PATCH RFT 3/3] regulator: rc5t583: " Axel Lin
  2012-05-04 12:38 ` [PATCH RFT 1/3] regulator: 88pm8607: " Mark Brown
  2 siblings, 1 reply; 6+ messages in thread
From: Axel Lin @ 2012-04-24  1:54 UTC (permalink / raw)
  To: linux-kernel
  Cc: David Dajun Chen, Ashish Jangam, Ying-Chun Liu (PaulLiu),
	Mark Brown, Liam Girdwood

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/da9052-regulator.c |   32 ++++++++------------------------
 1 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
index 4f2e6f9..16815f1 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -70,7 +70,6 @@ struct da9052_regulator_info {
 	int step_uV;
 	int min_uV;
 	int max_uV;
-	unsigned char volt_shift;
 	unsigned char activate_bit;
 };
 
@@ -209,9 +208,8 @@ static int da9052_regulator_set_voltage(struct regulator_dev *rdev,
 	if (ret < 0)
 		return ret;
 
-	ret = da9052_reg_update(regulator->da9052,
-				 DA9052_BUCKCORE_REG + id,
-				 (1 << info->volt_shift) - 1, *selector);
+	ret = da9052_reg_update(regulator->da9052, rdev->desc->vsel_reg,
+				rdev->desc->vsel_mask, *selector);
 	if (ret < 0)
 		return ret;
 
@@ -232,29 +230,13 @@ static int da9052_regulator_set_voltage(struct regulator_dev *rdev,
 	return ret;
 }
 
-static int da9052_get_regulator_voltage_sel(struct regulator_dev *rdev)
-{
-	struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
-	struct da9052_regulator_info *info = regulator->info;
-	int offset = rdev_get_id(rdev);
-	int ret;
-
-	ret = da9052_reg_read(regulator->da9052, DA9052_BUCKCORE_REG + offset);
-	if (ret < 0)
-		return ret;
-
-	ret &= ((1 << info->volt_shift) - 1);
-
-	return ret;
-}
-
 static struct regulator_ops da9052_dcdc_ops = {
 	.set_voltage = da9052_regulator_set_voltage,
 	.get_current_limit = da9052_dcdc_get_current_limit,
 	.set_current_limit = da9052_dcdc_set_current_limit,
 
 	.list_voltage = da9052_list_voltage,
-	.get_voltage_sel = da9052_get_regulator_voltage_sel,
+	.get_voltage_sel = regulator_get_voltage_sel_regmap,
 	.is_enabled = regulator_is_enabled_regmap,
 	.enable = regulator_enable_regmap,
 	.disable = regulator_disable_regmap,
@@ -264,7 +246,7 @@ static struct regulator_ops da9052_ldo_ops = {
 	.set_voltage = da9052_regulator_set_voltage,
 
 	.list_voltage = da9052_list_voltage,
-	.get_voltage_sel = da9052_get_regulator_voltage_sel,
+	.get_voltage_sel = regulator_get_voltage_sel_regmap,
 	.is_enabled = regulator_is_enabled_regmap,
 	.enable = regulator_enable_regmap,
 	.disable = regulator_disable_regmap,
@@ -279,13 +261,14 @@ static struct regulator_ops da9052_ldo_ops = {
 		.id = DA9052_ID_##_id,\
 		.n_voltages = (max - min) / step + 1, \
 		.owner = THIS_MODULE,\
+		.vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
+		.vsel_mask = (1 << (sbits)) - 1,\
 		.enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
 		.enable_mask = 1 << (ebits),\
 	},\
 	.min_uV = (min) * 1000,\
 	.max_uV = (max) * 1000,\
 	.step_uV = (step) * 1000,\
-	.volt_shift = (sbits),\
 	.activate_bit = (abits),\
 }
 
@@ -298,13 +281,14 @@ static struct regulator_ops da9052_ldo_ops = {
 		.id = DA9052_ID_##_id,\
 		.n_voltages = (max - min) / step + 1, \
 		.owner = THIS_MODULE,\
+		.vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
+		.vsel_mask = (1 << (sbits)) - 1,\
 		.enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \
 		.enable_mask = 1 << (ebits),\
 	},\
 	.min_uV = (min) * 1000,\
 	.max_uV = (max) * 1000,\
 	.step_uV = (step) * 1000,\
-	.volt_shift = (sbits),\
 	.activate_bit = (abits),\
 }
 
-- 
1.7.5.4




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

* [PATCH RFT 3/3] regulator: rc5t583: Use regulator_get_voltage_sel_regmap()
  2012-04-24  1:52 [PATCH RFT 1/3] regulator: 88pm8607: Use regulator_get_voltage_sel_regmap() Axel Lin
  2012-04-24  1:54 ` [PATCH RFT 2/3] regulator: da9052: " Axel Lin
@ 2012-04-24  1:56 ` Axel Lin
  2012-05-04 12:32   ` Mark Brown
  2012-05-04 12:38 ` [PATCH RFT 1/3] regulator: 88pm8607: " Mark Brown
  2 siblings, 1 reply; 6+ messages in thread
From: Axel Lin @ 2012-04-24  1:56 UTC (permalink / raw)
  To: linux-kernel; +Cc: Laxman Dewangan, Liam Girdwood, Mark Brown

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/rc5t583-regulator.c |   33 +++++++++------------------------
 1 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c
index f35dc527..7951260 100644
--- a/drivers/regulator/rc5t583-regulator.c
+++ b/drivers/regulator/rc5t583-regulator.c
@@ -38,8 +38,6 @@ struct rc5t583_regulator_info {
 	/* Regulator register address.*/
 	uint8_t			reg_disc_reg;
 	uint8_t			disc_bit;
-	uint8_t			vout_reg;
-	uint8_t			vout_mask;
 	uint8_t			deepsleep_reg;
 
 	/* Chip constraints on regulator behavior */
@@ -90,33 +88,20 @@ static int rc5t583_set_voltage(struct regulator_dev *rdev,
 
 	*selector = sel;
 
-	ret = rc5t583_update(reg->mfd->dev, ri->vout_reg, sel, ri->vout_mask);
+	ret = rc5t583_update(reg->mfd->dev, rdev->desc->vsel_reg, sel,
+			     rdev->desc->vsel_mask);
 	if (ret < 0)
-		dev_err(&rdev->dev,
-		    "Error in update voltage register 0x%02x\n", ri->vout_reg);
+		dev_err(&rdev->dev, "Error in update voltage register 0x%02x\n",
+			rdev->desc->vsel_reg);
 	return ret;
 }
 
-static int rc5t583_get_voltage_sel(struct regulator_dev *rdev)
-{
-	struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
-	struct rc5t583_regulator_info *ri = reg->reg_info;
-	uint8_t vsel;
-	int ret;
-	ret = rc5t583_read(reg->mfd->dev, ri->vout_reg, &vsel);
-	if (ret < 0) {
-		dev_err(&rdev->dev,
-		    "Error in reading voltage register 0x%02x\n", ri->vout_reg);
-		return ret;
-	}
-	return vsel & ri->vout_mask;
-}
-
 static int rc5t583_regulator_enable_time(struct regulator_dev *rdev)
 {
 	struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
-	int vsel = rc5t583_get_voltage_sel(rdev);
+	int vsel = regulator_get_voltage_sel_regmap(rdev);
 	int curr_uV = rc5t583_list_voltage(rdev, vsel);
+
 	return DIV_ROUND_UP(curr_uV, reg->reg_info->enable_uv_per_us);
 }
 
@@ -144,7 +129,7 @@ static struct regulator_ops rc5t583_ops = {
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
 	.enable_time		= rc5t583_regulator_enable_time,
-	.get_voltage_sel	= rc5t583_get_voltage_sel,
+	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
 	.set_voltage		= rc5t583_set_voltage,
 	.list_voltage		= rc5t583_list_voltage,
 	.set_voltage_time_sel	= rc5t583_set_voltage_time_sel,
@@ -155,8 +140,6 @@ static struct regulator_ops rc5t583_ops = {
 {								\
 	.reg_disc_reg	= RC5T583_REG_##_disc_reg,		\
 	.disc_bit	= _disc_bit,				\
-	.vout_reg	= RC5T583_REG_##_id##DAC,		\
-	.vout_mask	= _vout_mask,				\
 	.deepsleep_reg	= RC5T583_REG_##_id##DAC_DS,		\
 	.min_uV		= _min_mv * 1000,			\
 	.max_uV		= _max_mv * 1000,			\
@@ -171,6 +154,8 @@ static struct regulator_ops rc5t583_ops = {
 		.ops = &rc5t583_ops,				\
 		.type = REGULATOR_VOLTAGE,			\
 		.owner = THIS_MODULE,				\
+		.vsel_reg = RC5T583_REG_##_id##DAC,		\
+		.vsel_mask = _vout_mask,			\
 		.enable_reg = RC5T583_REG_##_en_reg,		\
 		.enable_mask = BIT(_en_bit),			\
 	},							\
-- 
1.7.5.4




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

* Re: [PATCH RFT 2/3] regulator: da9052: Use regulator_get_voltage_sel_regmap()
  2012-04-24  1:54 ` [PATCH RFT 2/3] regulator: da9052: " Axel Lin
@ 2012-05-04 12:30   ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2012-05-04 12:30 UTC (permalink / raw)
  To: Axel Lin
  Cc: linux-kernel, David Dajun Chen, Ashish Jangam,
	Ying-Chun Liu (PaulLiu),
	Liam Girdwood

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

On Tue, Apr 24, 2012 at 09:54:38AM +0800, Axel Lin wrote:
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied, thanks.

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

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

* Re: [PATCH RFT 3/3] regulator: rc5t583: Use regulator_get_voltage_sel_regmap()
  2012-04-24  1:56 ` [PATCH RFT 3/3] regulator: rc5t583: " Axel Lin
@ 2012-05-04 12:32   ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2012-05-04 12:32 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Laxman Dewangan, Liam Girdwood

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

On Tue, Apr 24, 2012 at 09:56:43AM +0800, Axel Lin wrote:
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied, thanks.

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

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

* Re: [PATCH RFT 1/3] regulator: 88pm8607: Use regulator_get_voltage_sel_regmap()
  2012-04-24  1:52 [PATCH RFT 1/3] regulator: 88pm8607: Use regulator_get_voltage_sel_regmap() Axel Lin
  2012-04-24  1:54 ` [PATCH RFT 2/3] regulator: da9052: " Axel Lin
  2012-04-24  1:56 ` [PATCH RFT 3/3] regulator: rc5t583: " Axel Lin
@ 2012-05-04 12:38 ` Mark Brown
  2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2012-05-04 12:38 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Haojian Zhuang, Liam Girdwood, Jett.Zhou

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

On Tue, Apr 24, 2012 at 09:52:32AM +0800, Axel Lin wrote:
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied, thanks.

[-- 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:[~2012-05-04 12:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-24  1:52 [PATCH RFT 1/3] regulator: 88pm8607: Use regulator_get_voltage_sel_regmap() Axel Lin
2012-04-24  1:54 ` [PATCH RFT 2/3] regulator: da9052: " Axel Lin
2012-05-04 12:30   ` Mark Brown
2012-04-24  1:56 ` [PATCH RFT 3/3] regulator: rc5t583: " Axel Lin
2012-05-04 12:32   ` Mark Brown
2012-05-04 12:38 ` [PATCH RFT 1/3] regulator: 88pm8607: " 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).