Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 272409
b: refs/heads/master
c: 1c3ede0
h: refs/heads/master
i:
  272407: 423196e
v: v3
  • Loading branch information
Marcus Folkesson authored and Liam Girdwood committed Aug 28, 2011
1 parent bc3aa1d commit e194c19
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 22 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: cc17ef3f0463ba17c8767578da8c4e5fbdd4b447
refs/heads/master: 1c3ede05d123f1484b28fa7c8500a1a29e34e3ba
96 changes: 75 additions & 21 deletions trunk/drivers/regulator/tps65023-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
#define TPS65023_MAX_REG_ID TPS65023_LDO_2

/* Supported voltage values for regulators */
static const u16 VDCDC1_VSEL_table[] = {
static const u16 VCORE_VSEL_table[] = {
800, 825, 850, 875,
900, 925, 950, 975,
1000, 1025, 1050, 1075,
Expand All @@ -110,20 +110,20 @@ static const u16 VDCDC1_VSEL_table[] = {
1500, 1525, 1550, 1600,
};

static const u16 LDO1_VSEL_table[] = {


/* Supported voltage values for LDO regulators
* for tps65021 and tps65023 */
static const u16 TPS65023_LDO1_VSEL_table[] = {
1000, 1100, 1300, 1800,
2200, 2600, 2800, 3150,
};

static const u16 LDO2_VSEL_table[] = {
static const u16 TPS65023_LDO2_VSEL_table[] = {
1050, 1200, 1300, 1800,
2500, 2800, 3000, 3300,
};

static unsigned int num_voltages[] = {ARRAY_SIZE(VDCDC1_VSEL_table),
0, 0, ARRAY_SIZE(LDO1_VSEL_table),
ARRAY_SIZE(LDO2_VSEL_table)};

/* Regulator specific details */
struct tps_info {
const char *name;
Expand All @@ -141,6 +141,13 @@ struct tps_pmic {
struct regulator_dev *rdev[TPS65023_NUM_REGULATOR];
const struct tps_info *info[TPS65023_NUM_REGULATOR];
struct regmap *regmap;
u8 core_regulator;
};

/* Struct passed as driver data */
struct tps_driver_data {
const struct tps_info *info;
u8 core_regulator;
};

static int tps_65023_set_bits(struct tps_pmic *tps, u8 reg, u8 mask)
Expand Down Expand Up @@ -267,7 +274,7 @@ static int tps65023_dcdc_get_voltage(struct regulator_dev *dev)
if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
return -EINVAL;

if (dcdc == TPS65023_DCDC_1) {
if (dcdc == tps->core_regulator) {
data = tps_65023_reg_read(tps, TPS65023_REG_DEF_CORE);
if (data < 0)
return data;
Expand All @@ -286,9 +293,8 @@ static int tps65023_dcdc_set_voltage(struct regulator_dev *dev,
int vsel;
int ret;

if (dcdc != TPS65023_DCDC_1)
if (dcdc != tps->core_regulator)
return -EINVAL;

if (min_uV < tps->info[dcdc]->min_uV
|| min_uV > tps->info[dcdc]->max_uV)
return -EINVAL;
Expand Down Expand Up @@ -387,7 +393,7 @@ static int tps65023_dcdc_list_voltage(struct regulator_dev *dev,
if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
return -EINVAL;

if (dcdc == TPS65023_DCDC_1) {
if (dcdc == tps->core_regulator) {
if (selector >= tps->info[dcdc]->table_len)
return -EINVAL;
else
Expand Down Expand Up @@ -439,7 +445,8 @@ static struct regmap_config tps65023_regmap_config = {
static int __devinit tps_65023_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
const struct tps_info *info = (void *)id->driver_data;
const struct tps_driver_data *drv_data = (void *)id->driver_data;
const struct tps_info *info = drv_data->info;
struct regulator_init_data *init_data;
struct regulator_dev *rdev;
struct tps_pmic *tps;
Expand Down Expand Up @@ -471,14 +478,15 @@ static int __devinit tps_65023_probe(struct i2c_client *client,

/* common for all regulators */
tps->client = client;
tps->core_regulator = drv_data->core_regulator;

for (i = 0; i < TPS65023_NUM_REGULATOR; i++, info++, init_data++) {
/* Store regulator specific information */
tps->info[i] = info;

tps->desc[i].name = info->name;
tps->desc[i].id = i;
tps->desc[i].n_voltages = num_voltages[i];
tps->desc[i].n_voltages = info->table_len;
tps->desc[i].ops = (i > TPS65023_DCDC_3 ?
&tps65023_ldo_ops : &tps65023_dcdc_ops);
tps->desc[i].type = REGULATOR_VOLTAGE;
Expand Down Expand Up @@ -540,13 +548,49 @@ static int __devexit tps_65023_remove(struct i2c_client *client)
return 0;
}

static const struct tps_info tps65021_regs[] = {
{
.name = "VDCDC1",
.min_uV = 3300000,
.max_uV = 3300000,
.fixed = 1,
},
{
.name = "VDCDC2",
.min_uV = 1800000,
.max_uV = 1800000,
.fixed = 1,
},
{
.name = "VDCDC3",
.min_uV = 800000,
.max_uV = 1600000,
.table_len = ARRAY_SIZE(VCORE_VSEL_table),
.table = VCORE_VSEL_table,
},
{
.name = "LDO1",
.min_uV = 1000000,
.max_uV = 3150000,
.table_len = ARRAY_SIZE(TPS65023_LDO1_VSEL_table),
.table = TPS65023_LDO1_VSEL_table,
},
{
.name = "LDO2",
.min_uV = 1050000,
.max_uV = 3300000,
.table_len = ARRAY_SIZE(TPS65023_LDO2_VSEL_table),
.table = TPS65023_LDO2_VSEL_table,
},
};

static const struct tps_info tps65023_regs[] = {
{
.name = "VDCDC1",
.min_uV = 800000,
.max_uV = 1600000,
.table_len = ARRAY_SIZE(VDCDC1_VSEL_table),
.table = VDCDC1_VSEL_table,
.table_len = ARRAY_SIZE(VCORE_VSEL_table),
.table = VCORE_VSEL_table,
},
{
.name = "VDCDC2",
Expand All @@ -564,23 +608,33 @@ static const struct tps_info tps65023_regs[] = {
.name = "LDO1",
.min_uV = 1000000,
.max_uV = 3150000,
.table_len = ARRAY_SIZE(LDO1_VSEL_table),
.table = LDO1_VSEL_table,
.table_len = ARRAY_SIZE(TPS65023_LDO1_VSEL_table),
.table = TPS65023_LDO1_VSEL_table,
},
{
.name = "LDO2",
.min_uV = 1050000,
.max_uV = 3300000,
.table_len = ARRAY_SIZE(LDO2_VSEL_table),
.table = LDO2_VSEL_table,
.table_len = ARRAY_SIZE(TPS65023_LDO2_VSEL_table),
.table = TPS65023_LDO2_VSEL_table,
},
};

static struct tps_driver_data tps65021_drv_data = {
.info = tps65021_regs,
.core_regulator = TPS65023_DCDC_3,
};

static struct tps_driver_data tps65023_drv_data = {
.info = tps65023_regs,
.core_regulator = TPS65023_DCDC_1,
};

static const struct i2c_device_id tps_65023_id[] = {
{.name = "tps65023",
.driver_data = (unsigned long) tps65023_regs,},
.driver_data = (unsigned long) &tps65023_drv_data},
{.name = "tps65021",
.driver_data = (unsigned long) tps65023_regs,},
.driver_data = (unsigned long) &tps65021_drv_data,},
{ },
};

Expand Down

0 comments on commit e194c19

Please sign in to comment.