public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFT 1/2] regulator: 88pm8607: Use generic regmap enable/disable operations
@ 2012-04-17  3:32 Axel Lin
  2012-04-17  3:34 ` [PATCH RFT 2/2] regulator: da9052: " Axel Lin
  2012-04-23 12:20 ` [PATCH RFT 1/2] regulator: 88pm8607: " Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2012-04-17  3:32 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 |   50 ++++++++++-------------------------------
 1 files changed, 12 insertions(+), 38 deletions(-)

diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index d04fbe9..ad748db 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -31,8 +31,6 @@ struct pm8607_regulator_info {
 	int	vol_shift;
 	int	update_reg;
 	int	update_bit;
-	int	enable_reg;
-	int	enable_bit;
 	int	slope_double;
 };
 
@@ -262,42 +260,13 @@ static int pm8607_get_voltage_sel(struct regulator_dev *rdev)
 	return val;
 }
 
-static int pm8607_enable(struct regulator_dev *rdev)
-{
-	struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
-
-	return pm860x_set_bits(info->i2c, info->enable_reg,
-			       1 << info->enable_bit,
-			       1 << info->enable_bit);
-}
-
-static int pm8607_disable(struct regulator_dev *rdev)
-{
-	struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
-
-	return pm860x_set_bits(info->i2c, info->enable_reg,
-			       1 << info->enable_bit, 0);
-}
-
-static int pm8607_is_enabled(struct regulator_dev *rdev)
-{
-	struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
-	int ret;
-
-	ret = pm860x_reg_read(info->i2c, info->enable_reg);
-	if (ret < 0)
-		return ret;
-
-	return !!((unsigned char)ret & (1 << info->enable_bit));
-}
-
 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,
-	.enable		= pm8607_enable,
-	.disable	= pm8607_disable,
-	.is_enabled	= pm8607_is_enabled,
+	.enable = regulator_enable_regmap,
+	.disable = regulator_disable_regmap,
+	.is_enabled = regulator_is_enabled_regmap,
 };
 
 #define PM8607_DVC(vreg, ureg, ubit, ereg, ebit)			\
@@ -309,13 +278,13 @@ static struct regulator_ops pm8607_regulator_ops = {
 		.id	= PM8607_ID_##vreg,				\
 		.owner	= THIS_MODULE,					\
 		.n_voltages = ARRAY_SIZE(vreg##_table),			\
+		.enable_reg = PM8607_##ereg,				\
+		.enable_mask = 1 << (ebit),				\
 	},								\
 	.vol_reg	= PM8607_##vreg,				\
 	.vol_shift	= (0),						\
 	.update_reg	= PM8607_##ureg,				\
 	.update_bit	= (ubit),					\
-	.enable_reg	= PM8607_##ereg,				\
-	.enable_bit	= (ebit),					\
 	.slope_double	= (0),						\
 	.vol_table	= (unsigned int *)&vreg##_table,		\
 	.vol_suspend	= (unsigned int *)&vreg##_suspend_table,	\
@@ -330,11 +299,11 @@ static struct regulator_ops pm8607_regulator_ops = {
 		.id	= PM8607_ID_LDO##_id,				\
 		.owner	= THIS_MODULE,					\
 		.n_voltages = ARRAY_SIZE(LDO##_id##_table),		\
+		.enable_reg = PM8607_##ereg,				\
+		.enable_mask = 1 << (ebit),				\
 	},								\
 	.vol_reg	= PM8607_##vreg,				\
 	.vol_shift	= (shift),					\
-	.enable_reg	= PM8607_##ereg,				\
-	.enable_bit	= (ebit),					\
 	.slope_double	= (0),						\
 	.vol_table	= (unsigned int *)&LDO##_id##_table,		\
 	.vol_suspend	= (unsigned int *)&LDO##_id##_suspend_table,	\
@@ -395,6 +364,11 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
 	config.init_data = pdata;
 	config.driver_data = info;
 
+	if (chip->id == CHIP_PM8607)
+		config.regmap = chip->regmap;
+	else
+		config.regmap = chip->regmap_companion;
+
 	/* replace driver_data with info */
 	info->regulator = regulator_register(&info->desc, &config);
 	if (IS_ERR(info->regulator)) {
-- 
1.7.5.4




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

* [PATCH RFT 2/2] regulator: da9052: Use generic regmap enable/disable operations
  2012-04-17  3:32 [PATCH RFT 1/2] regulator: 88pm8607: Use generic regmap enable/disable operations Axel Lin
@ 2012-04-17  3:34 ` Axel Lin
  2012-04-23 12:20 ` [PATCH RFT 1/2] regulator: 88pm8607: " Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2012-04-17  3:34 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 |   56 +++++++---------------------------
 1 files changed, 11 insertions(+), 45 deletions(-)

diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
index eaa91cc5..4f2e6f9 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -71,7 +71,6 @@ struct da9052_regulator_info {
 	int min_uV;
 	int max_uV;
 	unsigned char volt_shift;
-	unsigned char en_bit;
 	unsigned char activate_bit;
 };
 
@@ -90,42 +89,6 @@ static int verify_range(struct da9052_regulator_info *info,
 	return 0;
 }
 
-static int da9052_regulator_enable(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);
-
-	return da9052_reg_update(regulator->da9052,
-				 DA9052_BUCKCORE_REG + offset,
-				 1 << info->en_bit, 1 << info->en_bit);
-}
-
-static int da9052_regulator_disable(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);
-
-	return da9052_reg_update(regulator->da9052,
-				 DA9052_BUCKCORE_REG + offset,
-				 1 << info->en_bit, 0);
-}
-
-static int da9052_regulator_is_enabled(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;
-
-	return ret & (1 << info->en_bit);
-}
-
 static int da9052_dcdc_get_current_limit(struct regulator_dev *rdev)
 {
 	struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
@@ -292,9 +255,9 @@ static struct regulator_ops da9052_dcdc_ops = {
 
 	.list_voltage = da9052_list_voltage,
 	.get_voltage_sel = da9052_get_regulator_voltage_sel,
-	.is_enabled = da9052_regulator_is_enabled,
-	.enable = da9052_regulator_enable,
-	.disable = da9052_regulator_disable,
+	.is_enabled = regulator_is_enabled_regmap,
+	.enable = regulator_enable_regmap,
+	.disable = regulator_disable_regmap,
 };
 
 static struct regulator_ops da9052_ldo_ops = {
@@ -302,9 +265,9 @@ static struct regulator_ops da9052_ldo_ops = {
 
 	.list_voltage = da9052_list_voltage,
 	.get_voltage_sel = da9052_get_regulator_voltage_sel,
-	.is_enabled = da9052_regulator_is_enabled,
-	.enable = da9052_regulator_enable,
-	.disable = da9052_regulator_disable,
+	.is_enabled = regulator_is_enabled_regmap,
+	.enable = regulator_enable_regmap,
+	.disable = regulator_disable_regmap,
 };
 
 #define DA9052_LDO(_id, step, min, max, sbits, ebits, abits) \
@@ -316,12 +279,13 @@ static struct regulator_ops da9052_ldo_ops = {
 		.id = DA9052_ID_##_id,\
 		.n_voltages = (max - min) / step + 1, \
 		.owner = THIS_MODULE,\
+		.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),\
-	.en_bit = (ebits),\
 	.activate_bit = (abits),\
 }
 
@@ -334,12 +298,13 @@ static struct regulator_ops da9052_ldo_ops = {
 		.id = DA9052_ID_##_id,\
 		.n_voltages = (max - min) / step + 1, \
 		.owner = THIS_MODULE,\
+		.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),\
-	.en_bit = (ebits),\
 	.activate_bit = (abits),\
 }
 
@@ -430,6 +395,7 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev)
 
 	config.dev = &pdev->dev;
 	config.driver_data = regulator;
+	config.regmap = da9052->regmap;
 	if (pdata && pdata->regulators) {
 		config.init_data = pdata->regulators[pdev->id];
 	} else {
-- 
1.7.5.4




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

* Re: [PATCH RFT 1/2] regulator: 88pm8607: Use generic regmap enable/disable operations
  2012-04-17  3:32 [PATCH RFT 1/2] regulator: 88pm8607: Use generic regmap enable/disable operations Axel Lin
  2012-04-17  3:34 ` [PATCH RFT 2/2] regulator: da9052: " Axel Lin
@ 2012-04-23 12:20 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-04-23 12:20 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Haojian Zhuang, Liam Girdwood, Jett.Zhou

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

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

Applied both, thanks.

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

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

end of thread, other threads:[~2012-04-23 12:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-17  3:32 [PATCH RFT 1/2] regulator: 88pm8607: Use generic regmap enable/disable operations Axel Lin
2012-04-17  3:34 ` [PATCH RFT 2/2] regulator: da9052: " Axel Lin
2012-04-23 12:20 ` [PATCH RFT 1/2] 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