2010-12-10 10:10:24

by Bengt Jönsson

[permalink] [raw]
Subject: [PATCH 0/9] regulators: Update ab8500 regulator driver

This patchset updates the ab8500 regulator driver:
* The first patch modifies the ab8500 platform configuration structure.
* Patches two through eight updates the ab8500 regulator driver.
* The ninth patch modifies the ab8500 regulator configuration.

The eighth patch is optional as discussed before.

Bengt Jonsson (9):
regulators: Moved define for number of regulators in ab8500
regulators: Fixed errors in ab8500 register mapping
regulators: Clean out unused code in ab8500 regulators
regulators: Added ab8500 v2 support
regulators: Updated ab8500 variable names, macro names and comments
regulators: Modified ab8500 error handling
regulators: Added verbose debug messages to ab8500 regulators
regulators: Removed macros for initialization of ab8500 regulators
mach-ux500: Updated and connected ab8500 regulator board
configuration

arch/arm/mach-ux500/board-mop500-regulators.c | 153 ++++-----
arch/arm/mach-ux500/board-mop500-regulators.h | 19 +
arch/arm/mach-ux500/board-mop500.c | 3 +
drivers/regulator/ab8500.c | 448 +++++++++++++++++--------
include/linux/mfd/ab8500.h | 5 +-
include/linux/regulator/ab8500.h | 24 +-
6 files changed, 426 insertions(+), 226 deletions(-)
create mode 100644 arch/arm/mach-ux500/board-mop500-regulators.h

--
1.7.2.2


2010-12-10 10:10:21

by Bengt Jönsson

[permalink] [raw]
Subject: [PATCH 1/9] regulators: Moved define for number of regulators in ab8500

The define for number of regulators is moved from ab8500-core to
ab8500-regulator so that the regulator driver can be updated
independently of ab8500-core. This also changes the platform
configuration structure of ab8500-core so that it contains a
pointer to the regulator_init_data array plus number of
regulators instead of an fixed size array of pointers to
regulator_init_data.

Signed-off-by: Bengt Jonsson <[email protected]>
Acked-by: Linus Walleij <[email protected]>
---
drivers/regulator/ab8500.c | 8 +++++++-
include/linux/mfd/ab8500.h | 5 ++---
include/linux/regulator/ab8500.h | 24 +++++++++++++-----------
3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 2f4ec0f..5670775 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -370,6 +370,12 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
}
pdata = dev_get_platdata(ab8500->dev);

+ /* make sure the platform data has the correct size */
+ if (pdata->num_regulator != ARRAY_SIZE(ab8500_regulator_info)) {
+ dev_err(&pdev->dev, "platform configuration error\n");
+ return -EINVAL;
+ }
+
/* register all regulators */
for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) {
struct ab8500_regulator_info *info = NULL;
@@ -380,7 +386,7 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
info->ab8500 = ab8500;

info->regulator = regulator_register(&info->desc, &pdev->dev,
- pdata->regulator[i], info);
+ &pdata->regulator[i], info);
if (IS_ERR(info->regulator)) {
err = PTR_ERR(info->regulator);
dev_err(&pdev->dev, "failed to register regulator %s\n",
diff --git a/include/linux/mfd/ab8500.h b/include/linux/mfd/ab8500.h
index d63b605..85cf2c2 100644
--- a/include/linux/mfd/ab8500.h
+++ b/include/linux/mfd/ab8500.h
@@ -99,8 +99,6 @@
#define AB8500_NR_IRQS 104
#define AB8500_NUM_IRQ_REGS 13

-#define AB8500_NUM_REGULATORS 15
-
/**
* struct ab8500 - ab8500 internal structure
* @dev: parent device
@@ -145,7 +143,8 @@ struct regulator_init_data;
struct ab8500_platform_data {
int irq_base;
void (*init) (struct ab8500 *);
- struct regulator_init_data *regulator[AB8500_NUM_REGULATORS];
+ int num_regulator;
+ struct regulator_init_data *regulator;
};

extern int __devinit ab8500_init(struct ab8500 *ab8500);
diff --git a/include/linux/regulator/ab8500.h b/include/linux/regulator/ab8500.h
index f509877..6a210f1 100644
--- a/include/linux/regulator/ab8500.h
+++ b/include/linux/regulator/ab8500.h
@@ -11,15 +11,17 @@
#define __LINUX_MFD_AB8500_REGULATOR_H

/* AB8500 regulators */
-#define AB8500_LDO_AUX1 0
-#define AB8500_LDO_AUX2 1
-#define AB8500_LDO_AUX3 2
-#define AB8500_LDO_INTCORE 3
-#define AB8500_LDO_TVOUT 4
-#define AB8500_LDO_AUDIO 5
-#define AB8500_LDO_ANAMIC1 6
-#define AB8500_LDO_ANAMIC2 7
-#define AB8500_LDO_DMIC 8
-#define AB8500_LDO_ANA 9
-
+enum ab8500_regulator_id {
+ AB8500_LDO_AUX1,
+ AB8500_LDO_AUX2,
+ AB8500_LDO_AUX3,
+ AB8500_LDO_INTCORE,
+ AB8500_LDO_TVOUT,
+ AB8500_LDO_AUDIO,
+ AB8500_LDO_ANAMIC1,
+ AB8500_LDO_ANAMIC2,
+ AB8500_LDO_DMIC,
+ AB8500_LDO_ANA,
+ AB8500_NUM_REGULATORS,
+};
#endif
--
1.7.2.2

2010-12-10 10:10:31

by Bengt Jönsson

[permalink] [raw]
Subject: [PATCH 6/9] regulators: Modified ab8500 error handling

Error handling is updated to catch NULL pointer errors.

Signed-off-by: Bengt Jonsson <[email protected]>
Acked-by: Linus Walleij <[email protected]>
---
drivers/regulator/ab8500.c | 53 +++++++++++++++++++++++++------------------
1 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index ccb0bfd..2a15b63 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -100,12 +100,13 @@ static const int ldo_vintcore_voltages[] = {

static int ab8500_regulator_enable(struct regulator_dev *rdev)
{
- int regulator_id, ret;
+ int ret;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);

- regulator_id = rdev_get_id(rdev);
- if (regulator_id >= AB8500_NUM_REGULATORS)
+ if (info == NULL) {
+ dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
return -EINVAL;
+ }

ret = abx500_mask_and_set_register_interruptible(info->dev,
info->update_bank, info->update_reg,
@@ -118,12 +119,13 @@ static int ab8500_regulator_enable(struct regulator_dev *rdev)

static int ab8500_regulator_disable(struct regulator_dev *rdev)
{
- int regulator_id, ret;
+ int ret;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);

- regulator_id = rdev_get_id(rdev);
- if (regulator_id >= AB8500_NUM_REGULATORS)
+ if (info == NULL) {
+ dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
return -EINVAL;
+ }

ret = abx500_mask_and_set_register_interruptible(info->dev,
info->update_bank, info->update_reg,
@@ -136,13 +138,14 @@ static int ab8500_regulator_disable(struct regulator_dev *rdev)

static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
{
- int regulator_id, ret;
+ int ret;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
u8 value;

- regulator_id = rdev_get_id(rdev);
- if (regulator_id >= AB8500_NUM_REGULATORS)
+ if (info == NULL) {
+ dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
return -EINVAL;
+ }

ret = abx500_get_register_interruptible(info->dev,
info->update_bank, info->update_reg, &value);
@@ -160,12 +163,12 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)

static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector)
{
- int regulator_id;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);

- regulator_id = rdev_get_id(rdev);
- if (regulator_id >= AB8500_NUM_REGULATORS)
+ if (info == NULL) {
+ dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
return -EINVAL;
+ }

/* return the uV for the fixed regulators */
if (info->fixed_uV)
@@ -179,13 +182,14 @@ static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector)

static int ab8500_regulator_get_voltage(struct regulator_dev *rdev)
{
- int regulator_id, ret;
+ int ret;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
u8 value;

- regulator_id = rdev_get_id(rdev);
- if (regulator_id >= AB8500_NUM_REGULATORS)
+ if (info == NULL) {
+ dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
return -EINVAL;
+ }

ret = abx500_get_register_interruptible(info->dev, info->voltage_bank,
info->voltage_reg, &value);
@@ -197,7 +201,7 @@ static int ab8500_regulator_get_voltage(struct regulator_dev *rdev)

/* vintcore has a different layout */
value &= info->voltage_mask;
- if (regulator_id == AB8500_LDO_INTCORE)
+ if (info->desc.id == AB8500_LDO_INTCORE)
ret = info->voltages[value >> 0x3];
else
ret = info->voltages[value];
@@ -225,12 +229,13 @@ static int ab8500_regulator_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV,
unsigned *selector)
{
- int regulator_id, ret;
+ int ret;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);

- regulator_id = rdev_get_id(rdev);
- if (regulator_id >= AB8500_NUM_REGULATORS)
+ if (info == NULL) {
+ dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
return -EINVAL;
+ }

/* get the appropriate voltages within the range */
ret = ab8500_get_best_voltage_index(rdev, min_uV, max_uV);
@@ -264,12 +269,12 @@ static struct regulator_ops ab8500_regulator_ops = {

static int ab8500_fixed_get_voltage(struct regulator_dev *rdev)
{
- int regulator_id;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);

- regulator_id = rdev_get_id(rdev);
- if (regulator_id >= AB8500_NUM_REGULATORS)
+ if (info == NULL) {
+ dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
return -EINVAL;
+ }

return info->fixed_uV;
}
@@ -368,6 +373,10 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
return -EINVAL;
}
pdata = dev_get_platdata(ab8500->dev);
+ if (!pdata) {
+ dev_err(&pdev->dev, "null pdata\n");
+ return -EINVAL;
+ }

/* make sure the platform data has the correct size */
if (pdata->num_regulator != ARRAY_SIZE(ab8500_regulator_info)) {
--
1.7.2.2

2010-12-10 10:10:32

by Bengt Jönsson

[permalink] [raw]
Subject: [PATCH 5/9] regulators: Updated ab8500 variable names, macro names and comments

The regulator enumeration is used for putting the regulator data
in correct place in the info array. This should be matched in the
board configuration.

Variable names are updated to be more consistent, comments are
corrected and macros have been edited to be consistent.

Signed-off-by: Bengt Jonsson <[email protected]>
Acked-by: Linus Walleij <[email protected]>
---
drivers/regulator/ab8500.c | 161 ++++++++++++++++++++++---------------------
1 files changed, 82 insertions(+), 79 deletions(-)

diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 9a3dc79..ccb0bfd 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -3,18 +3,13 @@
*
* License Terms: GNU General Public License v2
*
- * Author: Sundar Iyer <[email protected]> for ST-Ericsson
+ * Authors: Sundar Iyer <[email protected]> for ST-Ericsson
+ * Bengt Jonsson <[email protected]> for ST-Ericsson
*
* AB8500 peripheral regulators
*
- * AB8500 supports the following regulators,
- * LDOs - VAUDIO, VANAMIC2/2, VDIGMIC, VINTCORE12, VTVOUT,
- * VAUX1/2/3, VANA
- *
- * for DB8500 cut 1.0 and previous versions of the silicon, all accesses
- * to registers are through the DB8500 SPI. In cut 1.1 onwards, these
- * accesses are through the DB8500 PRCMU I2C
- *
+ * AB8500 supports the following regulators:
+ * VAUX1/2/3, VINTCORE, VTVOUT, VAUDIO, VAMIC1/2, VDMIC, VANA
*/
#include <linux/init.h>
#include <linux/kernel.h>
@@ -28,6 +23,7 @@

/**
* struct ab8500_regulator_info - ab8500 regulator information
+ * @dev: device pointer
* @desc: regulator description
* @regulator_dev: regulator device
* @max_uV: maximum voltage (for variable voltage supplies)
@@ -35,12 +31,12 @@
* @fixed_uV: typical voltage (for fixed voltage supplies)
* @update_bank: bank to control on/off
* @update_reg: register to control on/off
- * @mask: mask to enable/disable regulator
- * @enable: bits to enable the regulator in normal(high power) mode
+ * @update_mask: mask to enable/disable regulator
+ * @update_val_enable: bits to enable the regulator in normal (high power) mode
* @voltage_bank: bank to control regulator voltage
* @voltage_reg: register to control regulator voltage
* @voltage_mask: mask to control regulator voltage
- * @supported_voltages: supported voltage table
+ * @voltages: supported voltage table
* @voltages_len: number of supported voltages for the regulator
*/
struct ab8500_regulator_info {
@@ -52,12 +48,12 @@ struct ab8500_regulator_info {
int fixed_uV;
u8 update_bank;
u8 update_reg;
- u8 mask;
- u8 enable;
+ u8 update_mask;
+ u8 update_val_enable;
u8 voltage_bank;
u8 voltage_reg;
u8 voltage_mask;
- int const *supported_voltages;
+ int const *voltages;
int voltages_len;
};

@@ -112,7 +108,8 @@ static int ab8500_regulator_enable(struct regulator_dev *rdev)
return -EINVAL;

ret = abx500_mask_and_set_register_interruptible(info->dev,
- info->update_bank, info->update_reg, info->mask, info->enable);
+ info->update_bank, info->update_reg,
+ info->update_mask, info->update_val_enable);
if (ret < 0)
dev_err(rdev_get_dev(rdev),
"couldn't set enable bits for regulator\n");
@@ -129,7 +126,8 @@ static int ab8500_regulator_disable(struct regulator_dev *rdev)
return -EINVAL;

ret = abx500_mask_and_set_register_interruptible(info->dev,
- info->update_bank, info->update_reg, info->mask, 0x0);
+ info->update_bank, info->update_reg,
+ info->update_mask, 0x0);
if (ret < 0)
dev_err(rdev_get_dev(rdev),
"couldn't set disable bits for regulator\n");
@@ -154,7 +152,7 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
return ret;
}

- if (value & info->mask)
+ if (value & info->update_mask)
return true;
else
return false;
@@ -176,7 +174,7 @@ static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector)
if (selector >= info->voltages_len)
return -EINVAL;

- return info->supported_voltages[selector];
+ return info->voltages[selector];
}

static int ab8500_regulator_get_voltage(struct regulator_dev *rdev)
@@ -200,9 +198,9 @@ static int ab8500_regulator_get_voltage(struct regulator_dev *rdev)
/* vintcore has a different layout */
value &= info->voltage_mask;
if (regulator_id == AB8500_LDO_INTCORE)
- ret = info->supported_voltages[value >> 0x3];
+ ret = info->voltages[value >> 0x3];
else
- ret = info->supported_voltages[value];
+ ret = info->voltages[value];

return ret;
}
@@ -215,8 +213,8 @@ static int ab8500_get_best_voltage_index(struct regulator_dev *rdev,

/* check the supported voltage */
for (i = 0; i < info->voltages_len; i++) {
- if ((info->supported_voltages[i] >= min_uV) &&
- (info->supported_voltages[i] <= max_uV))
+ if ((info->voltages[i] >= min_uV) &&
+ (info->voltages[i] <= max_uV))
return i;
}

@@ -284,74 +282,79 @@ static struct regulator_ops ab8500_ldo_fixed_ops = {
.list_voltage = ab8500_list_voltage,
};

-#define AB8500_LDO(_id, min, max, bank, reg, reg_mask, \
- reg_enable, volt_bank, volt_reg, volt_mask, \
- voltages, len_volts) \
-{ \
+#define AB8500_LDO(_id, _min_mV, _max_mV, \
+ _u_bank, _u_reg, _u_mask, _u_val_enable, \
+ _v_bank, _v_reg, _v_mask, _v_table, _v_table_len) \
+[AB8500_LDO_##_id] = { \
.desc = { \
- .name = "LDO-" #_id, \
- .ops = &ab8500_regulator_ops, \
- .type = REGULATOR_VOLTAGE, \
- .id = AB8500_LDO_##_id, \
- .owner = THIS_MODULE, \
+ .name = "LDO-" #_id, \
+ .ops = &ab8500_regulator_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .id = AB8500_LDO_##_id, \
+ .owner = THIS_MODULE, \
}, \
- .min_uV = (min) * 1000, \
- .max_uV = (max) * 1000, \
- .update_bank = bank, \
- .update_reg = reg, \
- .mask = reg_mask, \
- .enable = reg_enable, \
- .voltage_bank = volt_bank, \
- .voltage_reg = volt_reg, \
- .voltage_mask = volt_mask, \
- .supported_voltages = voltages, \
- .voltages_len = len_volts, \
- .fixed_uV = 0, \
+ .min_uV = (_min_mV) * 1000, \
+ .max_uV = (_max_mV) * 1000, \
+ .update_bank = _u_bank, \
+ .update_reg = _u_reg, \
+ .update_mask = _u_mask, \
+ .update_val_enable = _u_val_enable, \
+ .voltage_bank = _v_bank, \
+ .voltage_reg = _v_reg, \
+ .voltage_mask = _v_mask, \
+ .voltages = _v_table, \
+ .voltages_len = _v_table_len, \
+ .fixed_uV = 0, \
}

-#define AB8500_FIXED_LDO(_id, fixed, bank, reg, \
- reg_mask, reg_enable) \
-{ \
- .desc = { \
- .name = "LDO-" #_id, \
- .ops = &ab8500_ldo_fixed_ops, \
- .type = REGULATOR_VOLTAGE, \
- .id = AB8500_LDO_##_id, \
- .owner = THIS_MODULE, \
- }, \
- .fixed_uV = fixed * 1000, \
- .update_bank = bank, \
- .update_reg = reg, \
- .mask = reg_mask, \
- .enable = reg_enable, \
+#define AB8500_FIXED_LDO(_id, _fixed_mV, \
+ _u_bank, _u_reg, _u_mask, _u_val_enable) \
+[AB8500_LDO_##_id] = { \
+ .desc = { \
+ .name = "LDO-" #_id, \
+ .ops = &ab8500_ldo_fixed_ops, \
+ .type = REGULATOR_VOLTAGE, \
+ .id = AB8500_LDO_##_id, \
+ .owner = THIS_MODULE, \
+ }, \
+ .fixed_uV = (_fixed_mV) * 1000, \
+ .update_bank = _u_bank, \
+ .update_reg = _u_reg, \
+ .update_mask = _u_mask, \
+ .update_val_enable = _u_val_enable, \
}

static struct ab8500_regulator_info ab8500_regulator_info[] = {
/*
- * Variable Voltage LDOs
- * name, min uV, max uV, ctrl bank, ctrl reg, reg mask, enable mask,
- * volt ctrl bank, volt ctrl reg, volt ctrl mask, volt table,
- * num supported volts
+ * Variable Voltage Regulators
+ * name, min mV, max mV,
+ * update bank, reg, mask, enable val
+ * volt bank, reg, mask, table, table length
*/
- AB8500_LDO(AUX1, 1100, 3300, 0x04, 0x09, 0x3, 0x1, 0x04, 0x1f, 0xf,
- ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)),
- AB8500_LDO(AUX2, 1100, 3300, 0x04, 0x09, 0xc, 0x4, 0x04, 0x20, 0xf,
- ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)),
- AB8500_LDO(AUX3, 1100, 3300, 0x04, 0x0a, 0x3, 0x1, 0x04, 0x21, 0x7,
- ldo_vaux3_voltages, ARRAY_SIZE(ldo_vaux3_voltages)),
- AB8500_LDO(INTCORE, 1100, 3300, 0x03, 0x80, 0x44, 0x4, 0x03, 0x80, 0x38,
+ AB8500_LDO(AUX1, 1100, 3300,
+ 0x04, 0x09, 0x03, 0x01, 0x04, 0x1f, 0x0f,
+ ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)),
+ AB8500_LDO(AUX2, 1100, 3300,
+ 0x04, 0x09, 0x0c, 0x04, 0x04, 0x20, 0x0f,
+ ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)),
+ AB8500_LDO(AUX3, 1100, 3300,
+ 0x04, 0x0a, 0x03, 0x01, 0x04, 0x21, 0x07,
+ ldo_vaux3_voltages, ARRAY_SIZE(ldo_vaux3_voltages)),
+ AB8500_LDO(INTCORE, 1100, 3300,
+ 0x03, 0x80, 0x44, 0x04, 0x03, 0x80, 0x38,
ldo_vintcore_voltages, ARRAY_SIZE(ldo_vintcore_voltages)),

/*
- * Fixed Voltage LDOs
- * name, o/p uV, ctrl bank, ctrl reg, enable, disable
+ * Fixed Voltage Regulators
+ * name, fixed mV,
+ * update bank, reg, mask, enable val
*/
- AB8500_FIXED_LDO(TVOUT, 2000, 0x03, 0x80, 0x82, 0x2),
- AB8500_FIXED_LDO(AUDIO, 2000, 0x03, 0x83, 0x2, 0x2),
- AB8500_FIXED_LDO(ANAMIC1, 2050, 0x03, 0x83, 0x08, 0x08),
- AB8500_FIXED_LDO(ANAMIC2, 2050, 0x03, 0x83, 0x10, 0x10),
- AB8500_FIXED_LDO(DMIC, 1800, 0x03, 0x83, 0x04, 0x04),
- AB8500_FIXED_LDO(ANA, 1200, 0x04, 0x06, 0xc, 0x4),
+ AB8500_FIXED_LDO(TVOUT, 2000, 0x03, 0x80, 0x82, 0x02),
+ AB8500_FIXED_LDO(AUDIO, 2000, 0x03, 0x83, 0x02, 0x02),
+ AB8500_FIXED_LDO(ANAMIC1, 2050, 0x03, 0x83, 0x08, 0x08),
+ AB8500_FIXED_LDO(ANAMIC2, 2050, 0x03, 0x83, 0x10, 0x10),
+ AB8500_FIXED_LDO(DMIC, 1800, 0x03, 0x83, 0x04, 0x04),
+ AB8500_FIXED_LDO(ANA, 1200, 0x04, 0x06, 0x0c, 0x04),
};

static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
@@ -385,7 +388,7 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
if (info->desc.id == AB8500_LDO_AUX3) {
info->desc.n_voltages =
ARRAY_SIZE(ldo_vauxn_voltages);
- info->supported_voltages = ldo_vauxn_voltages;
+ info->voltages = ldo_vauxn_voltages;
info->voltages_len =
ARRAY_SIZE(ldo_vauxn_voltages);
info->voltage_mask = 0xf;
--
1.7.2.2

2010-12-10 10:11:02

by Bengt Jönsson

[permalink] [raw]
Subject: [PATCH 2/9] regulators: Fixed errors in ab8500 register mapping

For INTCORE and TVOUT regulators, the low power register bit is
included in the mask so that enable will set the regulator in
normal (high power) mode.

ANAMIC1, ANAMIC2, DMIC regulator settings are swapped with each
other so that the correct regulator gets enabled/disabled.

ANA regulator register address is corrected.

Signed-off-by: Bengt Jonsson <[email protected]>
Acked-by: Linus Walleij <[email protected]>
---
drivers/regulator/ab8500.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 5670775..4efe3cf 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -330,19 +330,19 @@ static struct ab8500_regulator_info ab8500_regulator_info[] = {
ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)),
AB8500_LDO(AUX3, 1100, 3300, 0x04, 0x0a, 0x3, 0x1, 0x04, 0x21, 0xf,
ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)),
- AB8500_LDO(INTCORE, 1100, 3300, 0x03, 0x80, 0x4, 0x4, 0x03, 0x80, 0x38,
+ AB8500_LDO(INTCORE, 1100, 3300, 0x03, 0x80, 0x44, 0x4, 0x03, 0x80, 0x38,
ldo_vintcore_voltages, ARRAY_SIZE(ldo_vintcore_voltages)),

/*
* Fixed Voltage LDOs
* name, o/p uV, ctrl bank, ctrl reg, enable, disable
*/
- AB8500_FIXED_LDO(TVOUT, 2000, 0x03, 0x80, 0x2, 0x2),
+ AB8500_FIXED_LDO(TVOUT, 2000, 0x03, 0x80, 0x82, 0x2),
AB8500_FIXED_LDO(AUDIO, 2000, 0x03, 0x83, 0x2, 0x2),
- AB8500_FIXED_LDO(ANAMIC1, 2050, 0x03, 0x83, 0x4, 0x4),
- AB8500_FIXED_LDO(ANAMIC2, 2050, 0x03, 0x83, 0x8, 0x8),
- AB8500_FIXED_LDO(DMIC, 1800, 0x03, 0x83, 0x10, 0x10),
- AB8500_FIXED_LDO(ANA, 1200, 0x03, 0x83, 0xc, 0x4),
+ AB8500_FIXED_LDO(ANAMIC1, 2050, 0x03, 0x83, 0x08, 0x08),
+ AB8500_FIXED_LDO(ANAMIC2, 2050, 0x03, 0x83, 0x10, 0x10),
+ AB8500_FIXED_LDO(DMIC, 1800, 0x03, 0x83, 0x04, 0x04),
+ AB8500_FIXED_LDO(ANA, 1200, 0x04, 0x06, 0xc, 0x4),
};

static inline struct ab8500_regulator_info *find_regulator_info(int id)
--
1.7.2.2

2010-12-10 10:11:10

by Bengt Jönsson

[permalink] [raw]
Subject: [PATCH 4/9] regulators: Added ab8500 v2 support

The AUX3 regulator voltage setting is changed in ab8500 v2 compared
to ab8500 v1. This patch adds v2 support while keeping support for
v1.

Signed-off-by: Bengt Jonsson <[email protected]>
Acked-by: Linus Walleij <[email protected]>
---
drivers/regulator/ab8500.c | 28 ++++++++++++++++++++++++++--
1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 51ff569..9a3dc79 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -81,6 +81,17 @@ static const int ldo_vauxn_voltages[] = {
3300000,
};

+static const int ldo_vaux3_voltages[] = {
+ 1200000,
+ 1500000,
+ 1800000,
+ 2100000,
+ 2500000,
+ 2750000,
+ 2790000,
+ 2910000,
+};
+
static const int ldo_vintcore_voltages[] = {
1200000,
1225000,
@@ -326,8 +337,8 @@ static struct ab8500_regulator_info ab8500_regulator_info[] = {
ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)),
AB8500_LDO(AUX2, 1100, 3300, 0x04, 0x09, 0xc, 0x4, 0x04, 0x20, 0xf,
ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)),
- AB8500_LDO(AUX3, 1100, 3300, 0x04, 0x0a, 0x3, 0x1, 0x04, 0x21, 0xf,
- ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)),
+ AB8500_LDO(AUX3, 1100, 3300, 0x04, 0x0a, 0x3, 0x1, 0x04, 0x21, 0x7,
+ ldo_vaux3_voltages, ARRAY_SIZE(ldo_vaux3_voltages)),
AB8500_LDO(INTCORE, 1100, 3300, 0x03, 0x80, 0x44, 0x4, 0x03, 0x80, 0x38,
ldo_vintcore_voltages, ARRAY_SIZE(ldo_vintcore_voltages)),

@@ -369,6 +380,19 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
info = &ab8500_regulator_info[i];
info->dev = &pdev->dev;

+ /* fix for hardware before ab8500v2.0 */
+ if (abx500_get_chip_id(info->dev) < 0x20) {
+ if (info->desc.id == AB8500_LDO_AUX3) {
+ info->desc.n_voltages =
+ ARRAY_SIZE(ldo_vauxn_voltages);
+ info->supported_voltages = ldo_vauxn_voltages;
+ info->voltages_len =
+ ARRAY_SIZE(ldo_vauxn_voltages);
+ info->voltage_mask = 0xf;
+ }
+ }
+
+ /* register regulator with framework */
info->regulator = regulator_register(&info->desc, &pdev->dev,
&pdata->regulator[i], info);
if (IS_ERR(info->regulator)) {
--
1.7.2.2

2010-12-10 10:10:53

by Bengt Jönsson

[permalink] [raw]
Subject: [PATCH 7/9] regulators: Added verbose debug messages to ab8500 regulators

The verbose debug outputs register writes and reads that can be
used to debug the driver.

Signed-off-by: Bengt Jonsson <[email protected]>
Acked-by: Linus Walleij <[email protected]>
---
drivers/regulator/ab8500.c | 63 +++++++++++++++++++++++++++++++++++--------
1 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 2a15b63..7d372b8 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -114,6 +114,12 @@ static int ab8500_regulator_enable(struct regulator_dev *rdev)
if (ret < 0)
dev_err(rdev_get_dev(rdev),
"couldn't set enable bits for regulator\n");
+
+ dev_vdbg(rdev_get_dev(rdev),
+ "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
+ info->desc.name, info->update_bank, info->update_reg,
+ info->update_mask, info->update_val_enable);
+
return ret;
}

@@ -133,6 +139,12 @@ static int ab8500_regulator_disable(struct regulator_dev *rdev)
if (ret < 0)
dev_err(rdev_get_dev(rdev),
"couldn't set disable bits for regulator\n");
+
+ dev_vdbg(rdev_get_dev(rdev),
+ "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
+ info->desc.name, info->update_bank, info->update_reg,
+ info->update_mask, 0x0);
+
return ret;
}

@@ -140,7 +152,7 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
{
int ret;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
- u8 value;
+ u8 regval;

if (info == NULL) {
dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
@@ -148,14 +160,20 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
}

ret = abx500_get_register_interruptible(info->dev,
- info->update_bank, info->update_reg, &value);
+ info->update_bank, info->update_reg, &regval);
if (ret < 0) {
dev_err(rdev_get_dev(rdev),
"couldn't read 0x%x register\n", info->update_reg);
return ret;
}

- if (value & info->update_mask)
+ dev_vdbg(rdev_get_dev(rdev),
+ "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
+ " 0x%x\n",
+ info->desc.name, info->update_bank, info->update_reg,
+ info->update_mask, regval);
+
+ if (regval & info->update_mask)
return true;
else
return false;
@@ -182,29 +200,35 @@ static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector)

static int ab8500_regulator_get_voltage(struct regulator_dev *rdev)
{
- int ret;
+ int ret, val;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
- u8 value;
+ u8 regval;

if (info == NULL) {
dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
return -EINVAL;
}

- ret = abx500_get_register_interruptible(info->dev, info->voltage_bank,
- info->voltage_reg, &value);
+ ret = abx500_get_register_interruptible(info->dev,
+ info->voltage_bank, info->voltage_reg, &regval);
if (ret < 0) {
dev_err(rdev_get_dev(rdev),
"couldn't read voltage reg for regulator\n");
return ret;
}

+ dev_vdbg(rdev_get_dev(rdev),
+ "%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
+ " 0x%x\n",
+ info->desc.name, info->voltage_bank, info->voltage_reg,
+ info->voltage_mask, regval);
+
/* vintcore has a different layout */
- value &= info->voltage_mask;
+ val = regval & info->voltage_mask;
if (info->desc.id == AB8500_LDO_INTCORE)
- ret = info->voltages[value >> 0x3];
+ ret = info->voltages[val >> 0x3];
else
- ret = info->voltages[value];
+ ret = info->voltages[val];

return ret;
}
@@ -231,6 +255,7 @@ static int ab8500_regulator_set_voltage(struct regulator_dev *rdev,
{
int ret;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
+ u8 regval;

if (info == NULL) {
dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
@@ -248,13 +273,20 @@ static int ab8500_regulator_set_voltage(struct regulator_dev *rdev,
*selector = ret;

/* set the registers for the request */
+ regval = (u8)ret;
ret = abx500_mask_and_set_register_interruptible(info->dev,
- info->voltage_bank, info->voltage_reg,
- info->voltage_mask, (u8)ret);
+ info->voltage_bank, info->voltage_reg,
+ info->voltage_mask, regval);
if (ret < 0)
dev_err(rdev_get_dev(rdev),
"couldn't set voltage reg for regulator\n");

+ dev_vdbg(rdev_get_dev(rdev),
+ "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
+ " 0x%x\n",
+ info->desc.name, info->voltage_bank, info->voltage_reg,
+ info->voltage_mask, regval);
+
return ret;
}

@@ -418,6 +450,9 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
}
return err;
}
+
+ dev_vdbg(rdev_get_dev(info->regulator),
+ "%s-probed\n", info->desc.name);
}

return 0;
@@ -430,6 +465,10 @@ static __devexit int ab8500_regulator_remove(struct platform_device *pdev)
for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) {
struct ab8500_regulator_info *info = NULL;
info = &ab8500_regulator_info[i];
+
+ dev_vdbg(rdev_get_dev(info->regulator),
+ "%s-remove\n", info->desc.name);
+
regulator_unregister(info->regulator);
}

--
1.7.2.2

2010-12-10 10:10:51

by Bengt Jönsson

[permalink] [raw]
Subject: [PATCH 9/9] mach-ux500: Updated and connected ab8500 regulator board configuration

The ab8500 regulator board configuration is updated and put in an
array which can easily be used in the MFD board configuration. The
regulator board configuration is also added to the MFD
configuration in this patch.

Signed-off-by: Bengt Jonsson <[email protected]>
Acked-by: Linus Walleij <[email protected]>
---
arch/arm/mach-ux500/board-mop500-regulators.c | 153 ++++++++++++-------------
arch/arm/mach-ux500/board-mop500-regulators.h | 19 +++
arch/arm/mach-ux500/board-mop500.c | 3 +
3 files changed, 96 insertions(+), 79 deletions(-)
create mode 100644 arch/arm/mach-ux500/board-mop500-regulators.h

diff --git a/arch/arm/mach-ux500/board-mop500-regulators.c b/arch/arm/mach-ux500/board-mop500-regulators.c
index 1187f1f..533967c 100644
--- a/arch/arm/mach-ux500/board-mop500-regulators.c
+++ b/arch/arm/mach-ux500/board-mop500-regulators.c
@@ -3,99 +3,94 @@
*
* License Terms: GNU General Public License v2
*
- * Author: Sundar Iyer <[email protected]>
+ * Authors: Sundar Iyer <[email protected]>
+ * Bengt Jonsson <[email protected]>
*
* MOP500 board specific initialization for regulators
*/
#include <linux/kernel.h>
#include <linux/regulator/machine.h>
+#include <linux/regulator/ab8500.h>

-/* supplies to the display/camera */
-static struct regulator_init_data ab8500_vaux1_regulator = {
- .constraints = {
- .name = "V-DISPLAY",
- .min_uV = 2500000,
- .max_uV = 2900000,
- .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE|
- REGULATOR_CHANGE_STATUS,
+/* AB8500 regulators */
+struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = {
+ /* supplies to the display/camera */
+ [AB8500_LDO_AUX1] = {
+ .constraints = {
+ .name = "V-DISPLAY",
+ .min_uV = 2500000,
+ .max_uV = 2900000,
+ .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
+ REGULATOR_CHANGE_STATUS,
+ },
},
-};
-
-/* supplies to the on-board eMMC */
-static struct regulator_init_data ab8500_vaux2_regulator = {
- .constraints = {
- .name = "V-eMMC1",
- .min_uV = 1100000,
- .max_uV = 3300000,
- .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE|
- REGULATOR_CHANGE_STATUS,
+ /* supplies to the on-board eMMC */
+ [AB8500_LDO_AUX2] = {
+ .constraints = {
+ .name = "V-eMMC1",
+ .min_uV = 1100000,
+ .max_uV = 3300000,
+ .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
+ REGULATOR_CHANGE_STATUS,
+ },
},
-};
-
-/* supply for VAUX3, supplies to SDcard slots */
-static struct regulator_init_data ab8500_vaux3_regulator = {
- .constraints = {
- .name = "V-MMC-SD",
- .min_uV = 1100000,
- .max_uV = 3300000,
- .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE|
- REGULATOR_CHANGE_STATUS,
+ /* supply for VAUX3, supplies to SDcard slots */
+ [AB8500_LDO_AUX3] = {
+ .constraints = {
+ .name = "V-MMC-SD",
+ .min_uV = 1100000,
+ .max_uV = 3300000,
+ .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
+ REGULATOR_CHANGE_STATUS,
+ },
},
-};
-
-/* supply for tvout, gpadc, TVOUT LDO */
-static struct regulator_init_data ab8500_vtvout_init = {
- .constraints = {
- .name = "V-TVOUT",
- .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ /* supply for tvout, gpadc, TVOUT LDO */
+ [AB8500_LDO_TVOUT] = {
+ .constraints = {
+ .name = "V-TVOUT",
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ },
},
-};
-
-/* supply for ab8500-vaudio, VAUDIO LDO */
-static struct regulator_init_data ab8500_vaudio_init = {
- .constraints = {
- .name = "V-AUD",
- .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ /* supply for ab8500-vaudio, VAUDIO LDO */
+ [AB8500_LDO_AUDIO] = {
+ .constraints = {
+ .name = "V-AUD",
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ },
},
-};
-
-/* supply for v-anamic1 VAMic1-LDO */
-static struct regulator_init_data ab8500_vamic1_init = {
- .constraints = {
- .name = "V-AMIC1",
- .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ /* supply for v-anamic1 VAMic1-LDO */
+ [AB8500_LDO_ANAMIC1] = {
+ .constraints = {
+ .name = "V-AMIC1",
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ },
},
-};
-
-/* supply for v-amic2, VAMIC2 LDO, reuse constants for AMIC1 */
-static struct regulator_init_data ab8500_vamic2_init = {
- .constraints = {
- .name = "V-AMIC2",
- .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ /* supply for v-amic2, VAMIC2 LDO, reuse constants for AMIC1 */
+ [AB8500_LDO_ANAMIC2] = {
+ .constraints = {
+ .name = "V-AMIC2",
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ },
},
-};
-
-/* supply for v-dmic, VDMIC LDO */
-static struct regulator_init_data ab8500_vdmic_init = {
- .constraints = {
- .name = "V-DMIC",
- .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ /* supply for v-dmic, VDMIC LDO */
+ [AB8500_LDO_DMIC] = {
+ .constraints = {
+ .name = "V-DMIC",
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ },
},
-};
-
-/* supply for v-intcore12, VINTCORE12 LDO */
-static struct regulator_init_data ab8500_vintcore_init = {
- .constraints = {
- .name = "V-INTCORE",
- .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ /* supply for v-intcore12, VINTCORE12 LDO */
+ [AB8500_LDO_INTCORE] = {
+ .constraints = {
+ .name = "V-INTCORE",
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ },
},
-};
-
-/* supply for U8500 CSI/DSI, VANA LDO */
-static struct regulator_init_data ab8500_vana_init = {
- .constraints = {
- .name = "V-CSI/DSI",
- .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ /* supply for U8500 CSI/DSI, VANA LDO */
+ [AB8500_LDO_ANA] = {
+ .constraints = {
+ .name = "V-CSI/DSI",
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+ },
},
};
-
diff --git a/arch/arm/mach-ux500/board-mop500-regulators.h b/arch/arm/mach-ux500/board-mop500-regulators.h
new file mode 100644
index 0000000..2675fae
--- /dev/null
+++ b/arch/arm/mach-ux500/board-mop500-regulators.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2010
+ *
+ * License Terms: GNU General Public License v2
+ *
+ * Author: Bengt Jonsson <[email protected]> for ST-Ericsson
+ *
+ * MOP500 board specific initialization for regulators
+ */
+
+#ifndef __BOARD_MOP500_REGULATORS_H
+#define __BOARD_MOP500_REGULATORS_H
+
+#include <linux/regulator/machine.h>
+#include <linux/regulator/ab8500.h>
+
+extern struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS];
+
+#endif
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index cac83a6..41285ad 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -34,6 +34,7 @@

#include "pins-db8500.h"
#include "board-mop500.h"
+#include "board-mop500-regulators.h"

static pin_cfg_t mop500_pins[] = {
/* SSP0 */
@@ -89,6 +90,8 @@ struct pl022_config_chip ab4500_chip_info = {

static struct ab8500_platform_data ab8500_platdata = {
.irq_base = MOP500_AB8500_IRQ_BASE,
+ .regulator = ab8500_regulators,
+ .num_regulator = ARRAY_SIZE(ab8500_regulators),
};

static struct resource ab8500_resources[] = {
--
1.7.2.2

2010-12-10 10:11:17

by Bengt Jönsson

[permalink] [raw]
Subject: [PATCH 8/9] regulators: Removed macros for initialization of ab8500 regulators

This patch removes the macros for initializing the regulators.
The purpose is to remove one layer of abstraction and make the
code easier to read.

Signed-off-by: Bengt Jonsson <[email protected]>
Acked-by: Linus Walleij <[email protected]>
---
drivers/regulator/ab8500.c | 241 ++++++++++++++++++++++++++++++++-----------
1 files changed, 179 insertions(+), 62 deletions(-)

diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 7d372b8..d9a052c 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -311,7 +311,7 @@ static int ab8500_fixed_get_voltage(struct regulator_dev *rdev)
return info->fixed_uV;
}

-static struct regulator_ops ab8500_ldo_fixed_ops = {
+static struct regulator_ops ab8500_regulator_fixed_ops = {
.enable = ab8500_regulator_enable,
.disable = ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled,
@@ -319,79 +319,196 @@ static struct regulator_ops ab8500_ldo_fixed_ops = {
.list_voltage = ab8500_list_voltage,
};

-#define AB8500_LDO(_id, _min_mV, _max_mV, \
- _u_bank, _u_reg, _u_mask, _u_val_enable, \
- _v_bank, _v_reg, _v_mask, _v_table, _v_table_len) \
-[AB8500_LDO_##_id] = { \
- .desc = { \
- .name = "LDO-" #_id, \
- .ops = &ab8500_regulator_ops, \
- .type = REGULATOR_VOLTAGE, \
- .id = AB8500_LDO_##_id, \
- .owner = THIS_MODULE, \
- }, \
- .min_uV = (_min_mV) * 1000, \
- .max_uV = (_max_mV) * 1000, \
- .update_bank = _u_bank, \
- .update_reg = _u_reg, \
- .update_mask = _u_mask, \
- .update_val_enable = _u_val_enable, \
- .voltage_bank = _v_bank, \
- .voltage_reg = _v_reg, \
- .voltage_mask = _v_mask, \
- .voltages = _v_table, \
- .voltages_len = _v_table_len, \
- .fixed_uV = 0, \
-}
-
-#define AB8500_FIXED_LDO(_id, _fixed_mV, \
- _u_bank, _u_reg, _u_mask, _u_val_enable) \
-[AB8500_LDO_##_id] = { \
- .desc = { \
- .name = "LDO-" #_id, \
- .ops = &ab8500_ldo_fixed_ops, \
- .type = REGULATOR_VOLTAGE, \
- .id = AB8500_LDO_##_id, \
- .owner = THIS_MODULE, \
- }, \
- .fixed_uV = (_fixed_mV) * 1000, \
- .update_bank = _u_bank, \
- .update_reg = _u_reg, \
- .update_mask = _u_mask, \
- .update_val_enable = _u_val_enable, \
-}
-
-static struct ab8500_regulator_info ab8500_regulator_info[] = {
+static struct ab8500_regulator_info
+ ab8500_regulator_info[AB8500_NUM_REGULATORS] = {
/*
* Variable Voltage Regulators
* name, min mV, max mV,
* update bank, reg, mask, enable val
* volt bank, reg, mask, table, table length
*/
- AB8500_LDO(AUX1, 1100, 3300,
- 0x04, 0x09, 0x03, 0x01, 0x04, 0x1f, 0x0f,
- ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)),
- AB8500_LDO(AUX2, 1100, 3300,
- 0x04, 0x09, 0x0c, 0x04, 0x04, 0x20, 0x0f,
- ldo_vauxn_voltages, ARRAY_SIZE(ldo_vauxn_voltages)),
- AB8500_LDO(AUX3, 1100, 3300,
- 0x04, 0x0a, 0x03, 0x01, 0x04, 0x21, 0x07,
- ldo_vaux3_voltages, ARRAY_SIZE(ldo_vaux3_voltages)),
- AB8500_LDO(INTCORE, 1100, 3300,
- 0x03, 0x80, 0x44, 0x04, 0x03, 0x80, 0x38,
- ldo_vintcore_voltages, ARRAY_SIZE(ldo_vintcore_voltages)),
+ [AB8500_LDO_AUX1] = {
+ .desc = {
+ .name = "LDO-AUX1",
+ .ops = &ab8500_regulator_ops,
+ .type = REGULATOR_VOLTAGE,
+ .id = AB8500_LDO_AUX1,
+ .owner = THIS_MODULE,
+ .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
+ },
+ .min_uV = 1100000,
+ .max_uV = 3300000,
+ .update_bank = 0x04,
+ .update_reg = 0x09,
+ .update_mask = 0x03,
+ .update_val_enable = 0x01,
+ .voltage_bank = 0x04,
+ .voltage_reg = 0x1f,
+ .voltage_mask = 0x0f,
+ .voltages = ldo_vauxn_voltages,
+ .voltages_len = ARRAY_SIZE(ldo_vauxn_voltages),
+ },
+ [AB8500_LDO_AUX2] = {
+ .desc = {
+ .name = "LDO-AUX2",
+ .ops = &ab8500_regulator_ops,
+ .type = REGULATOR_VOLTAGE,
+ .id = AB8500_LDO_AUX2,
+ .owner = THIS_MODULE,
+ .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
+ },
+ .min_uV = 1100000,
+ .max_uV = 3300000,
+ .update_bank = 0x04,
+ .update_reg = 0x09,
+ .update_mask = 0x0c,
+ .update_val_enable = 0x04,
+ .voltage_bank = 0x04,
+ .voltage_reg = 0x20,
+ .voltage_mask = 0x0f,
+ .voltages = ldo_vauxn_voltages,
+ .voltages_len = ARRAY_SIZE(ldo_vauxn_voltages),
+ },
+ [AB8500_LDO_AUX3] = {
+ .desc = {
+ .name = "LDO-AUX3",
+ .ops = &ab8500_regulator_ops,
+ .type = REGULATOR_VOLTAGE,
+ .id = AB8500_LDO_AUX3,
+ .owner = THIS_MODULE,
+ .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
+ },
+ .min_uV = 1100000,
+ .max_uV = 3300000,
+ .update_bank = 0x04,
+ .update_reg = 0x0a,
+ .update_mask = 0x03,
+ .update_val_enable = 0x01,
+ .voltage_bank = 0x04,
+ .voltage_reg = 0x21,
+ .voltage_mask = 0x07,
+ .voltages = ldo_vaux3_voltages,
+ .voltages_len = ARRAY_SIZE(ldo_vaux3_voltages),
+ },
+ [AB8500_LDO_INTCORE] = {
+ .desc = {
+ .name = "LDO-INTCORE",
+ .ops = &ab8500_regulator_ops,
+ .type = REGULATOR_VOLTAGE,
+ .id = AB8500_LDO_INTCORE,
+ .owner = THIS_MODULE,
+ .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
+ },
+ .min_uV = 1100000,
+ .max_uV = 3300000,
+ .update_bank = 0x03,
+ .update_reg = 0x80,
+ .update_mask = 0x44,
+ .update_val_enable = 0x04,
+ .voltage_bank = 0x03,
+ .voltage_reg = 0x80,
+ .voltage_mask = 0x38,
+ .voltages = ldo_vintcore_voltages,
+ .voltages_len = ARRAY_SIZE(ldo_vintcore_voltages),
+ },

/*
* Fixed Voltage Regulators
* name, fixed mV,
* update bank, reg, mask, enable val
*/
- AB8500_FIXED_LDO(TVOUT, 2000, 0x03, 0x80, 0x82, 0x02),
- AB8500_FIXED_LDO(AUDIO, 2000, 0x03, 0x83, 0x02, 0x02),
- AB8500_FIXED_LDO(ANAMIC1, 2050, 0x03, 0x83, 0x08, 0x08),
- AB8500_FIXED_LDO(ANAMIC2, 2050, 0x03, 0x83, 0x10, 0x10),
- AB8500_FIXED_LDO(DMIC, 1800, 0x03, 0x83, 0x04, 0x04),
- AB8500_FIXED_LDO(ANA, 1200, 0x04, 0x06, 0x0c, 0x04),
+ [AB8500_LDO_TVOUT] = {
+ .desc = {
+ .name = "LDO-TVOUT",
+ .ops = &ab8500_regulator_fixed_ops,
+ .type = REGULATOR_VOLTAGE,
+ .id = AB8500_LDO_TVOUT,
+ .owner = THIS_MODULE,
+ .n_voltages = 1,
+ },
+ .fixed_uV = 2000000,
+ .update_bank = 0x03,
+ .update_reg = 0x80,
+ .update_mask = 0x82,
+ .update_val_enable = 0x02,
+ },
+ [AB8500_LDO_AUDIO] = {
+ .desc = {
+ .name = "LDO-AUDIO",
+ .ops = &ab8500_regulator_fixed_ops,
+ .type = REGULATOR_VOLTAGE,
+ .id = AB8500_LDO_AUDIO,
+ .owner = THIS_MODULE,
+ .n_voltages = 1,
+ },
+ .fixed_uV = 2000000,
+ .update_bank = 0x03,
+ .update_reg = 0x83,
+ .update_mask = 0x02,
+ .update_val_enable = 0x02,
+ },
+ [AB8500_LDO_ANAMIC1] = {
+ .desc = {
+ .name = "LDO-ANAMIC1",
+ .ops = &ab8500_regulator_fixed_ops,
+ .type = REGULATOR_VOLTAGE,
+ .id = AB8500_LDO_ANAMIC1,
+ .owner = THIS_MODULE,
+ .n_voltages = 1,
+ },
+ .fixed_uV = 2050000,
+ .update_bank = 0x03,
+ .update_reg = 0x83,
+ .update_mask = 0x08,
+ .update_val_enable = 0x08,
+ },
+ [AB8500_LDO_ANAMIC2] = {
+ .desc = {
+ .name = "LDO-ANAMIC2",
+ .ops = &ab8500_regulator_fixed_ops,
+ .type = REGULATOR_VOLTAGE,
+ .id = AB8500_LDO_ANAMIC2,
+ .owner = THIS_MODULE,
+ .n_voltages = 1,
+ },
+ .fixed_uV = 2050000,
+ .update_bank = 0x03,
+ .update_reg = 0x83,
+ .update_mask = 0x10,
+ .update_val_enable = 0x10,
+ },
+ [AB8500_LDO_DMIC] = {
+ .desc = {
+ .name = "LDO-DMIC",
+ .ops = &ab8500_regulator_fixed_ops,
+ .type = REGULATOR_VOLTAGE,
+ .id = AB8500_LDO_DMIC,
+ .owner = THIS_MODULE,
+ .n_voltages = 1,
+ },
+ .fixed_uV = 1800000,
+ .update_bank = 0x03,
+ .update_reg = 0x83,
+ .update_mask = 0x04,
+ .update_val_enable = 0x04,
+ },
+ [AB8500_LDO_ANA] = {
+ .desc = {
+ .name = "LDO-ANA",
+ .ops = &ab8500_regulator_fixed_ops,
+ .type = REGULATOR_VOLTAGE,
+ .id = AB8500_LDO_ANA,
+ .owner = THIS_MODULE,
+ .n_voltages = 1,
+ },
+ .fixed_uV = 1200000,
+ .update_bank = 0x04,
+ .update_reg = 0x06,
+ .update_mask = 0x0c,
+ .update_val_enable = 0x04,
+ },
+
+
};

static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
--
1.7.2.2

2010-12-10 10:11:50

by Bengt Jönsson

[permalink] [raw]
Subject: [PATCH 3/9] regulators: Clean out unused code in ab8500 regulators

The find_regulator function was unused so it has been removed. The
ab8500 pointer in the regulator info structure was unused and so it
has also been removed.

Signed-off-by: Bengt Jonsson <[email protected]>
Acked-by: Linus Walleij <[email protected]>
---
drivers/regulator/ab8500.c | 16 ----------------
1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 4efe3cf..51ff569 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -29,7 +29,6 @@
/**
* struct ab8500_regulator_info - ab8500 regulator information
* @desc: regulator description
- * @ab8500: ab8500 parent
* @regulator_dev: regulator device
* @max_uV: maximum voltage (for variable voltage supplies)
* @min_uV: minimum voltage (for variable voltage supplies)
@@ -47,7 +46,6 @@
struct ab8500_regulator_info {
struct device *dev;
struct regulator_desc desc;
- struct ab8500 *ab8500;
struct regulator_dev *regulator;
int max_uV;
int min_uV;
@@ -345,19 +343,6 @@ static struct ab8500_regulator_info ab8500_regulator_info[] = {
AB8500_FIXED_LDO(ANA, 1200, 0x04, 0x06, 0xc, 0x4),
};

-static inline struct ab8500_regulator_info *find_regulator_info(int id)
-{
- struct ab8500_regulator_info *info;
- int i;
-
- for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) {
- info = &ab8500_regulator_info[i];
- if (info->desc.id == id)
- return info;
- }
- return NULL;
-}
-
static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
{
struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
@@ -383,7 +368,6 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
/* assign per-regulator data */
info = &ab8500_regulator_info[i];
info->dev = &pdev->dev;
- info->ab8500 = ab8500;

info->regulator = regulator_register(&info->desc, &pdev->dev,
&pdata->regulator[i], info);
--
1.7.2.2

2010-12-10 10:52:16

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 1/9] regulators: Moved define for number of regulators in ab8500

On Fri, Dec 10, 2010 at 11:08:40AM +0100, Bengt Jonsson wrote:
> The define for number of regulators is moved from ab8500-core to
> ab8500-regulator so that the regulator driver can be updated
> independently of ab8500-core. This also changes the platform
> configuration structure of ab8500-core so that it contains a
> pointer to the regulator_init_data array plus number of
> regulators instead of an fixed size array of pointers to
> regulator_init_data.

Acked-by: Mark Brown <[email protected]>

2010-12-10 12:25:04

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 2/9] regulators: Fixed errors in ab8500 register mapping

On Fri, Dec 10, 2010 at 11:08:41AM +0100, Bengt Jonsson wrote:
> For INTCORE and TVOUT regulators, the low power register bit is
> included in the mask so that enable will set the regulator in
> normal (high power) mode.

Acked-by: Mark Brown <[email protected]>

2010-12-10 12:25:39

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 3/9] regulators: Clean out unused code in ab8500 regulators

On Fri, Dec 10, 2010 at 11:08:42AM +0100, Bengt Jonsson wrote:
> The find_regulator function was unused so it has been removed. The
> ab8500 pointer in the regulator info structure was unused and so it
> has also been removed.

Acked-by: Mark Brown <[email protected]>

2010-12-10 12:27:38

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 4/9] regulators: Added ab8500 v2 support

On Fri, Dec 10, 2010 at 11:08:43AM +0100, Bengt Jonsson wrote:
> The AUX3 regulator voltage setting is changed in ab8500 v2 compared
> to ab8500 v1. This patch adds v2 support while keeping support for
> v1.

Acked-by: Mark Brown <[email protected]>

2010-12-10 12:28:55

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 5/9] regulators: Updated ab8500 variable names, macro names and comments

On Fri, Dec 10, 2010 at 11:08:44AM +0100, Bengt Jonsson wrote:
> The regulator enumeration is used for putting the regulator data
> in correct place in the info array. This should be matched in the
> board configuration.

Acked-by: Mark Brown <[email protected]>

2010-12-10 12:31:53

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 6/9] regulators: Modified ab8500 error handling

On Fri, Dec 10, 2010 at 11:08:45AM +0100, Bengt Jonsson wrote:
> Error handling is updated to catch NULL pointer errors.
>
> Signed-off-by: Bengt Jonsson <[email protected]>
> Acked-by: Linus Walleij <[email protected]>

This is also removing an awful lot of unused regulator_id lookups.

Acked-by: Mark Brown <[email protected]>

2010-12-10 12:32:47

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 7/9] regulators: Added verbose debug messages to ab8500 regulators

On Fri, Dec 10, 2010 at 11:08:46AM +0100, Bengt Jonsson wrote:
> The verbose debug outputs register writes and reads that can be
> used to debug the driver.

Acked-by: Mark Brown <[email protected]>

2010-12-10 12:36:00

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 8/9] regulators: Removed macros for initialization of ab8500 regulators

On Fri, Dec 10, 2010 at 11:08:47AM +0100, Bengt Jonsson wrote:
> This patch removes the macros for initializing the regulators.
> The purpose is to remove one layer of abstraction and make the
> code easier to read.

Acked-by: Mark Brown <[email protected]>

2010-12-10 12:36:26

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 9/9] mach-ux500: Updated and connected ab8500 regulator board configuration

On Fri, Dec 10, 2010 at 11:08:48AM +0100, Bengt Jonsson wrote:
> The ab8500 regulator board configuration is updated and put in an
> array which can easily be used in the MFD board configuration. The
> regulator board configuration is also added to the MFD
> configuration in this patch.

Acked-by: Mark Brown <[email protected]>

2010-12-10 23:00:59

by Liam Girdwood

[permalink] [raw]
Subject: Re: [PATCH 0/9] regulators: Update ab8500 regulator driver

On Fri, 2010-12-10 at 11:08 +0100, Bengt Jonsson wrote:
> This patchset updates the ab8500 regulator driver:
> * The first patch modifies the ab8500 platform configuration structure.
> * Patches two through eight updates the ab8500 regulator driver.
> * The ninth patch modifies the ab8500 regulator configuration.
>
> The eighth patch is optional as discussed before.
>
> Bengt Jonsson (9):
> regulators: Moved define for number of regulators in ab8500
> regulators: Fixed errors in ab8500 register mapping
> regulators: Clean out unused code in ab8500 regulators
> regulators: Added ab8500 v2 support
> regulators: Updated ab8500 variable names, macro names and comments
> regulators: Modified ab8500 error handling
> regulators: Added verbose debug messages to ab8500 regulators
> regulators: Removed macros for initialization of ab8500 regulators
> mach-ux500: Updated and connected ab8500 regulator board
> configuration
>
> arch/arm/mach-ux500/board-mop500-regulators.c | 153 ++++-----
> arch/arm/mach-ux500/board-mop500-regulators.h | 19 +
> arch/arm/mach-ux500/board-mop500.c | 3 +
> drivers/regulator/ab8500.c | 448 +++++++++++++++++--------
> include/linux/mfd/ab8500.h | 5 +-
> include/linux/regulator/ab8500.h | 24 +-
> 6 files changed, 426 insertions(+), 226 deletions(-)
> create mode 100644 arch/arm/mach-ux500/board-mop500-regulators.h
>

All applied.

Thanks

Liam
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk