Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312511
b: refs/heads/master
c: 96d2522
h: refs/heads/master
i:
  312509: 122f2d6
  312507: 5aa6751
  312503: be864ca
  312495: b5cbb1b
  312479: e9f04db
  312447: ab5a34e
v: v3
  • Loading branch information
Axel Lin authored and Mark Brown committed Jun 4, 2012
1 parent 446efe8 commit 663a7a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fc492f9bd13cb4c7c1299f5d390a203c1ad9a85b
refs/heads/master: 96d25221d28646fc2ce0a64a725c67c1ee2f2f0a
35 changes: 12 additions & 23 deletions trunk/drivers/regulator/max1586.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ struct max1586_data {
struct regulator_dev *rdev[0];
};

/*
* V6 voltage
* On I2C bus, sending a "x" byte to the max1586 means :
* set V6 to either 0V, 1.8V, 2.5V, 3V depending on (x & 0x3)
* As regulator framework doesn't accept voltages to be 0V, we use 1uV.
*/
static int v6_voltages_uv[] = { 1, 1800000, 2500000, 3000000 };

/*
* V3 voltage
* On I2C bus, sending a "x" byte to the max1586 means :
Expand Down Expand Up @@ -97,19 +105,6 @@ static int max1586_v3_list(struct regulator_dev *rdev, unsigned selector)
return max1586_v3_calc_voltage(max1586, selector);
}

/*
* V6 voltage
* On I2C bus, sending a "x" byte to the max1586 means :
* set V6 to either 0V, 1.8V, 2.5V, 3V depending on (x & 0x3)
* As regulator framework doesn't accept voltages to be 0V, we use 1uV.
*/
static int max1586_v6_calc_voltage(unsigned selector)
{
static int voltages_uv[] = { 1, 1800000, 2500000, 3000000 };

return voltages_uv[selector];
}

static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV,
unsigned int *selector)
{
Expand All @@ -130,23 +125,16 @@ static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV,
else if (min_uV >= 3000000)
*selector = 3;

if (max1586_v6_calc_voltage(*selector) > max_uV)
if (rdev->desc->volt_table[*selector] > max_uV)
return -EINVAL;

dev_dbg(&client->dev, "changing voltage v6 to %dmv\n",
max1586_v6_calc_voltage(*selector) / 1000);
rdev->desc->volt_table[*selector] / 1000);

v6_prog = I2C_V6_SELECT | (u8) *selector;
return i2c_smbus_write_byte(client, v6_prog);
}

static int max1586_v6_list(struct regulator_dev *rdev, unsigned selector)
{
if (selector > MAX1586_V6_MAX_VSEL)
return -EINVAL;
return max1586_v6_calc_voltage(selector);
}

/*
* The Maxim 1586 controls V3 and V6 voltages, but offers no way of reading back
* the set up value.
Expand All @@ -158,7 +146,7 @@ static struct regulator_ops max1586_v3_ops = {

static struct regulator_ops max1586_v6_ops = {
.set_voltage = max1586_v6_set,
.list_voltage = max1586_v6_list,
.list_voltage = regulator_list_voltage_table,
};

static const struct regulator_desc max1586_reg[] = {
Expand All @@ -176,6 +164,7 @@ static const struct regulator_desc max1586_reg[] = {
.ops = &max1586_v6_ops,
.type = REGULATOR_VOLTAGE,
.n_voltages = MAX1586_V6_MAX_VSEL + 1,
.volt_table = v6_voltages_uv,
.owner = THIS_MODULE,
},
};
Expand Down

0 comments on commit 663a7a1

Please sign in to comment.