summaryrefslogtreecommitdiff
path: root/drivers/regulator
diff options
context:
space:
mode:
authorTomasz Figa <t.figa@samsung.com>2013-06-24 14:39:53 +0200
committerChanho Park <chanho61.park@samsung.com>2014-08-08 14:36:05 +0900
commit71aaa6479481a52bf4f9e964226be8ed46d3bd59 (patch)
treec094009e5e6fba6d4a38a8dde826ca1ffb9b3f14 /drivers/regulator
parent1005dd0e2378c60d8b7f1ec4bd6c72b831e93439 (diff)
downloadlinux-3.10-71aaa6479481a52bf4f9e964226be8ed46d3bd59.tar.gz
linux-3.10-71aaa6479481a52bf4f9e964226be8ed46d3bd59.tar.bz2
linux-3.10-71aaa6479481a52bf4f9e964226be8ed46d3bd59.zip
regulator: max8998: Use arrays for specifying voltages in platform data
This patch modifies the platform data of max8998 to use arrays for specifying predefined voltages of buck1 and buck2 instead of separate field for each voltage. This allows to simplify the code a bit and will help in adding support for Device Tree, which will be introduced in further patch. Signed-off-by: Tomasz Figa <t.figa@samsung.com> Acked-by: Mark Brown <broonie@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/max8998.c96
1 files changed, 29 insertions, 67 deletions
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index a57a1b15cdb..8c45b93b733 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -630,6 +630,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
struct max8998_data *max8998;
struct i2c_client *i2c;
int i, ret, size;
+ unsigned int v;
if (!pdata) {
dev_err(pdev->dev.parent, "No platform init data supplied\n");
@@ -688,53 +689,21 @@ static int max8998_pmic_probe(struct platform_device *pdev)
gpio_request(pdata->buck1_set2, "MAX8998 BUCK1_SET2");
gpio_direction_output(pdata->buck1_set2,
(max8998->buck1_idx >> 1) & 0x1);
- /* Set predefined value for BUCK1 register 1 */
- i = 0;
- while (buck12_voltage_map_desc.min +
- buck12_voltage_map_desc.step*i
- < pdata->buck1_voltage1)
- i++;
- max8998->buck1_vol[0] = i;
- ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i);
- if (ret)
- goto err_out;
-
- /* Set predefined value for BUCK1 register 2 */
- i = 0;
- while (buck12_voltage_map_desc.min +
- buck12_voltage_map_desc.step*i
- < pdata->buck1_voltage2)
- i++;
-
- max8998->buck1_vol[1] = i;
- ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i);
- if (ret)
- goto err_out;
-
- /* Set predefined value for BUCK1 register 3 */
- i = 0;
- while (buck12_voltage_map_desc.min +
- buck12_voltage_map_desc.step*i
- < pdata->buck1_voltage3)
- i++;
-
- max8998->buck1_vol[2] = i;
- ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i);
- if (ret)
- goto err_out;
-
- /* Set predefined value for BUCK1 register 4 */
- i = 0;
- while (buck12_voltage_map_desc.min +
- buck12_voltage_map_desc.step*i
- < pdata->buck1_voltage4)
- i++;
-
- max8998->buck1_vol[3] = i;
- ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i);
- if (ret)
- goto err_out;
+ /* Set predefined values for BUCK1 registers */
+ for (v = 0; v < ARRAY_SIZE(pdata->buck1_voltage); ++v) {
+ i = 0;
+ while (buck12_voltage_map_desc.min +
+ buck12_voltage_map_desc.step*i
+ < pdata->buck1_voltage[v])
+ i++;
+
+ max8998->buck1_vol[v] = i;
+ ret = max8998_write_reg(i2c,
+ MAX8998_REG_BUCK1_VOLTAGE1 + v, i);
+ if (ret)
+ goto err_out;
+ }
}
if (gpio_is_valid(pdata->buck2_set3)) {
@@ -750,27 +719,20 @@ static int max8998_pmic_probe(struct platform_device *pdev)
gpio_direction_output(pdata->buck2_set3,
max8998->buck2_idx & 0x1);
- /* BUCK2 register 1 */
- i = 0;
- while (buck12_voltage_map_desc.min +
- buck12_voltage_map_desc.step*i
- < pdata->buck2_voltage1)
- i++;
- max8998->buck2_vol[0] = i;
- ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i);
- if (ret)
- goto err_out;
-
- /* BUCK2 register 2 */
- i = 0;
- while (buck12_voltage_map_desc.min +
- buck12_voltage_map_desc.step*i
- < pdata->buck2_voltage2)
- i++;
- max8998->buck2_vol[1] = i;
- ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i);
- if (ret)
- goto err_out;
+ /* Set predefined values for BUCK2 registers */
+ for (v = 0; v < ARRAY_SIZE(pdata->buck2_voltage); ++v) {
+ i = 0;
+ while (buck12_voltage_map_desc.min +
+ buck12_voltage_map_desc.step*i
+ < pdata->buck2_voltage[v])
+ i++;
+
+ max8998->buck2_vol[v] = i;
+ ret = max8998_write_reg(i2c,
+ MAX8998_REG_BUCK2_VOLTAGE1 + v, i);
+ if (ret)
+ goto err_out;
+ }
}
for (i = 0; i < pdata->num_regulators; i++) {