regulator: palmas: Simplify code by not indexing regulator_desc unnecessarily
Palmas regulator needs to full up the regulator_desc based on PMIC and type of regulator. However, we dont need to do desc[id] every time. we can simplify by using a pointer to desc[id] and filling up the parameters. Signed-off-by: Nishanth Menon <nm@ti.com> Tested-by: Stephen Warren <swarren@nvidia.com> Tested-by: Keerthy <j-keerthy@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
6839cd6f64
commit
429222d005
1 changed files with 112 additions and 136 deletions
|
@ -866,6 +866,7 @@ static int palmas_ldo_registration(struct palmas_pmic *pmic,
|
||||||
struct regulator_dev *rdev;
|
struct regulator_dev *rdev;
|
||||||
struct palmas_reg_init *reg_init;
|
struct palmas_reg_init *reg_init;
|
||||||
struct palmas_regs_info *rinfo;
|
struct palmas_regs_info *rinfo;
|
||||||
|
struct regulator_desc *desc;
|
||||||
|
|
||||||
for (id = ddata->ldo_begin; id < ddata->max_reg; id++) {
|
for (id = ddata->ldo_begin; id < ddata->max_reg; id++) {
|
||||||
if (pdata && pdata->reg_init[id])
|
if (pdata && pdata->reg_init[id])
|
||||||
|
@ -879,57 +880,51 @@ static int palmas_ldo_registration(struct palmas_pmic *pmic,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Register the regulators */
|
/* Register the regulators */
|
||||||
pmic->desc[id].name = rinfo->name;
|
desc = &pmic->desc[id];
|
||||||
pmic->desc[id].id = id;
|
desc->name = rinfo->name;
|
||||||
pmic->desc[id].type = REGULATOR_VOLTAGE;
|
desc->id = id;
|
||||||
pmic->desc[id].owner = THIS_MODULE;
|
desc->type = REGULATOR_VOLTAGE;
|
||||||
|
desc->owner = THIS_MODULE;
|
||||||
|
|
||||||
if (id < PALMAS_REG_REGEN1) {
|
if (id < PALMAS_REG_REGEN1) {
|
||||||
pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES;
|
desc->n_voltages = PALMAS_LDO_NUM_VOLTAGES;
|
||||||
if (reg_init && reg_init->roof_floor)
|
if (reg_init && reg_init->roof_floor)
|
||||||
pmic->desc[id].ops =
|
desc->ops = &palmas_ops_ext_control_ldo;
|
||||||
&palmas_ops_ext_control_ldo;
|
|
||||||
else
|
else
|
||||||
pmic->desc[id].ops = &palmas_ops_ldo;
|
desc->ops = &palmas_ops_ldo;
|
||||||
pmic->desc[id].min_uV = 900000;
|
desc->min_uV = 900000;
|
||||||
pmic->desc[id].uV_step = 50000;
|
desc->uV_step = 50000;
|
||||||
pmic->desc[id].linear_min_sel = 1;
|
desc->linear_min_sel = 1;
|
||||||
pmic->desc[id].enable_time = 500;
|
desc->enable_time = 500;
|
||||||
pmic->desc[id].vsel_reg =
|
desc->vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
|
||||||
PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
|
rinfo->vsel_addr);
|
||||||
rinfo->vsel_addr);
|
desc->vsel_mask = PALMAS_LDO1_VOLTAGE_VSEL_MASK;
|
||||||
pmic->desc[id].vsel_mask =
|
desc->enable_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
|
||||||
PALMAS_LDO1_VOLTAGE_VSEL_MASK;
|
rinfo->ctrl_addr);
|
||||||
pmic->desc[id].enable_reg =
|
desc->enable_mask = PALMAS_LDO1_CTRL_MODE_ACTIVE;
|
||||||
PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
|
|
||||||
rinfo->ctrl_addr);
|
|
||||||
pmic->desc[id].enable_mask =
|
|
||||||
PALMAS_LDO1_CTRL_MODE_ACTIVE;
|
|
||||||
|
|
||||||
/* Check if LDO8 is in tracking mode or not */
|
/* Check if LDO8 is in tracking mode or not */
|
||||||
if (pdata && (id == PALMAS_REG_LDO8) &&
|
if (pdata && (id == PALMAS_REG_LDO8) &&
|
||||||
pdata->enable_ldo8_tracking) {
|
pdata->enable_ldo8_tracking) {
|
||||||
palmas_enable_ldo8_track(pmic->palmas);
|
palmas_enable_ldo8_track(pmic->palmas);
|
||||||
pmic->desc[id].min_uV = 450000;
|
desc->min_uV = 450000;
|
||||||
pmic->desc[id].uV_step = 25000;
|
desc->uV_step = 25000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LOD6 in vibrator mode will have enable time 2000us */
|
/* LOD6 in vibrator mode will have enable time 2000us */
|
||||||
if (pdata && pdata->ldo6_vibrator &&
|
if (pdata && pdata->ldo6_vibrator &&
|
||||||
(id == PALMAS_REG_LDO6))
|
(id == PALMAS_REG_LDO6))
|
||||||
pmic->desc[id].enable_time = 2000;
|
desc->enable_time = 2000;
|
||||||
} else {
|
} else {
|
||||||
pmic->desc[id].n_voltages = 1;
|
desc->n_voltages = 1;
|
||||||
if (reg_init && reg_init->roof_floor)
|
if (reg_init && reg_init->roof_floor)
|
||||||
pmic->desc[id].ops =
|
desc->ops = &palmas_ops_ext_control_extreg;
|
||||||
&palmas_ops_ext_control_extreg;
|
|
||||||
else
|
else
|
||||||
pmic->desc[id].ops = &palmas_ops_extreg;
|
desc->ops = &palmas_ops_extreg;
|
||||||
pmic->desc[id].enable_reg =
|
desc->enable_reg =
|
||||||
PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE,
|
PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE,
|
||||||
rinfo->ctrl_addr);
|
rinfo->ctrl_addr);
|
||||||
pmic->desc[id].enable_mask =
|
desc->enable_mask = PALMAS_REGEN1_CTRL_MODE_ACTIVE;
|
||||||
PALMAS_REGEN1_CTRL_MODE_ACTIVE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdata)
|
if (pdata)
|
||||||
|
@ -937,11 +932,10 @@ static int palmas_ldo_registration(struct palmas_pmic *pmic,
|
||||||
else
|
else
|
||||||
config.init_data = NULL;
|
config.init_data = NULL;
|
||||||
|
|
||||||
pmic->desc[id].supply_name = rinfo->sname;
|
desc->supply_name = rinfo->sname;
|
||||||
config.of_node = ddata->palmas_matches[id].of_node;
|
config.of_node = ddata->palmas_matches[id].of_node;
|
||||||
|
|
||||||
rdev = devm_regulator_register(pmic->dev, &pmic->desc[id],
|
rdev = devm_regulator_register(pmic->dev, desc, &config);
|
||||||
&config);
|
|
||||||
if (IS_ERR(rdev)) {
|
if (IS_ERR(rdev)) {
|
||||||
dev_err(pmic->dev,
|
dev_err(pmic->dev,
|
||||||
"failed to register %s regulator\n",
|
"failed to register %s regulator\n",
|
||||||
|
@ -981,6 +975,7 @@ static int tps65917_ldo_registration(struct palmas_pmic *pmic,
|
||||||
struct regulator_dev *rdev;
|
struct regulator_dev *rdev;
|
||||||
struct palmas_reg_init *reg_init;
|
struct palmas_reg_init *reg_init;
|
||||||
struct palmas_regs_info *rinfo;
|
struct palmas_regs_info *rinfo;
|
||||||
|
struct regulator_desc *desc;
|
||||||
|
|
||||||
for (id = ddata->ldo_begin; id < ddata->max_reg; id++) {
|
for (id = ddata->ldo_begin; id < ddata->max_reg; id++) {
|
||||||
if (pdata && pdata->reg_init[id])
|
if (pdata && pdata->reg_init[id])
|
||||||
|
@ -994,49 +989,43 @@ static int tps65917_ldo_registration(struct palmas_pmic *pmic,
|
||||||
rinfo = &ddata->palmas_regs_info[id];
|
rinfo = &ddata->palmas_regs_info[id];
|
||||||
|
|
||||||
/* Register the regulators */
|
/* Register the regulators */
|
||||||
pmic->desc[id].name = rinfo->name;
|
desc = &pmic->desc[id];
|
||||||
pmic->desc[id].id = id;
|
desc->name = rinfo->name;
|
||||||
pmic->desc[id].type = REGULATOR_VOLTAGE;
|
desc->id = id;
|
||||||
pmic->desc[id].owner = THIS_MODULE;
|
desc->type = REGULATOR_VOLTAGE;
|
||||||
|
desc->owner = THIS_MODULE;
|
||||||
|
|
||||||
if (id < TPS65917_REG_REGEN1) {
|
if (id < TPS65917_REG_REGEN1) {
|
||||||
pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES;
|
desc->n_voltages = PALMAS_LDO_NUM_VOLTAGES;
|
||||||
if (reg_init && reg_init->roof_floor)
|
if (reg_init && reg_init->roof_floor)
|
||||||
pmic->desc[id].ops =
|
desc->ops = &palmas_ops_ext_control_ldo;
|
||||||
&palmas_ops_ext_control_ldo;
|
|
||||||
else
|
else
|
||||||
pmic->desc[id].ops = &tps65917_ops_ldo;
|
desc->ops = &tps65917_ops_ldo;
|
||||||
pmic->desc[id].min_uV = 900000;
|
desc->min_uV = 900000;
|
||||||
pmic->desc[id].uV_step = 50000;
|
desc->uV_step = 50000;
|
||||||
pmic->desc[id].linear_min_sel = 1;
|
desc->linear_min_sel = 1;
|
||||||
pmic->desc[id].enable_time = 500;
|
desc->enable_time = 500;
|
||||||
pmic->desc[id].vsel_reg =
|
desc->vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
|
||||||
PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
|
rinfo->vsel_addr);
|
||||||
rinfo->vsel_addr);
|
desc->vsel_mask = PALMAS_LDO1_VOLTAGE_VSEL_MASK;
|
||||||
pmic->desc[id].vsel_mask =
|
desc->enable_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
|
||||||
PALMAS_LDO1_VOLTAGE_VSEL_MASK;
|
rinfo->ctrl_addr);
|
||||||
pmic->desc[id].enable_reg =
|
desc->enable_mask = PALMAS_LDO1_CTRL_MODE_ACTIVE;
|
||||||
PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
|
|
||||||
rinfo->ctrl_addr);
|
|
||||||
pmic->desc[id].enable_mask =
|
|
||||||
PALMAS_LDO1_CTRL_MODE_ACTIVE;
|
|
||||||
/*
|
/*
|
||||||
* To be confirmed. Discussion on going with PMIC Team.
|
* To be confirmed. Discussion on going with PMIC Team.
|
||||||
* It is of the order of ~60mV/uS.
|
* It is of the order of ~60mV/uS.
|
||||||
*/
|
*/
|
||||||
pmic->desc[id].ramp_delay = 2500;
|
desc->ramp_delay = 2500;
|
||||||
} else {
|
} else {
|
||||||
pmic->desc[id].n_voltages = 1;
|
desc->n_voltages = 1;
|
||||||
if (reg_init && reg_init->roof_floor)
|
if (reg_init && reg_init->roof_floor)
|
||||||
pmic->desc[id].ops =
|
desc->ops = &palmas_ops_ext_control_extreg;
|
||||||
&palmas_ops_ext_control_extreg;
|
|
||||||
else
|
else
|
||||||
pmic->desc[id].ops = &palmas_ops_extreg;
|
desc->ops = &palmas_ops_extreg;
|
||||||
pmic->desc[id].enable_reg =
|
desc->enable_reg =
|
||||||
PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE,
|
PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE,
|
||||||
rinfo->ctrl_addr);
|
rinfo->ctrl_addr);
|
||||||
pmic->desc[id].enable_mask =
|
desc->enable_mask = PALMAS_REGEN1_CTRL_MODE_ACTIVE;
|
||||||
PALMAS_REGEN1_CTRL_MODE_ACTIVE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdata)
|
if (pdata)
|
||||||
|
@ -1044,11 +1033,10 @@ static int tps65917_ldo_registration(struct palmas_pmic *pmic,
|
||||||
else
|
else
|
||||||
config.init_data = NULL;
|
config.init_data = NULL;
|
||||||
|
|
||||||
pmic->desc[id].supply_name = rinfo->sname;
|
desc->supply_name = rinfo->sname;
|
||||||
config.of_node = ddata->palmas_matches[id].of_node;
|
config.of_node = ddata->palmas_matches[id].of_node;
|
||||||
|
|
||||||
rdev = devm_regulator_register(pmic->dev, &pmic->desc[id],
|
rdev = devm_regulator_register(pmic->dev, desc, &config);
|
||||||
&config);
|
|
||||||
if (IS_ERR(rdev)) {
|
if (IS_ERR(rdev)) {
|
||||||
dev_err(pmic->dev,
|
dev_err(pmic->dev,
|
||||||
"failed to register %s regulator\n",
|
"failed to register %s regulator\n",
|
||||||
|
@ -1089,6 +1077,7 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
|
||||||
struct regulator_dev *rdev;
|
struct regulator_dev *rdev;
|
||||||
struct palmas_reg_init *reg_init;
|
struct palmas_reg_init *reg_init;
|
||||||
struct palmas_regs_info *rinfo;
|
struct palmas_regs_info *rinfo;
|
||||||
|
struct regulator_desc *desc;
|
||||||
|
|
||||||
for (id = ddata->smps_start; id <= ddata->smps_end; id++) {
|
for (id = ddata->smps_start; id <= ddata->smps_end; id++) {
|
||||||
bool ramp_delay_support = false;
|
bool ramp_delay_support = false;
|
||||||
|
@ -1128,6 +1117,7 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
rinfo = &ddata->palmas_regs_info[id];
|
rinfo = &ddata->palmas_regs_info[id];
|
||||||
|
desc = &pmic->desc[id];
|
||||||
|
|
||||||
if ((id == PALMAS_REG_SMPS6) || (id == PALMAS_REG_SMPS8))
|
if ((id == PALMAS_REG_SMPS6) || (id == PALMAS_REG_SMPS8))
|
||||||
ramp_delay_support = true;
|
ramp_delay_support = true;
|
||||||
|
@ -1140,9 +1130,8 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
|
||||||
"reading TSTEP reg failed: %d\n", ret);
|
"reading TSTEP reg failed: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
pmic->desc[id].ramp_delay =
|
desc->ramp_delay = palmas_smps_ramp_delay[reg & 0x3];
|
||||||
palmas_smps_ramp_delay[reg & 0x3];
|
pmic->ramp_delay[id] = desc->ramp_delay;
|
||||||
pmic->ramp_delay[id] = pmic->desc[id].ramp_delay;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialise sleep/init values from platform data */
|
/* Initialise sleep/init values from platform data */
|
||||||
|
@ -1156,31 +1145,28 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register the regulators */
|
/* Register the regulators */
|
||||||
pmic->desc[id].name = rinfo->name;
|
desc->name = rinfo->name;
|
||||||
pmic->desc[id].id = id;
|
desc->id = id;
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case PALMAS_REG_SMPS10_OUT1:
|
case PALMAS_REG_SMPS10_OUT1:
|
||||||
case PALMAS_REG_SMPS10_OUT2:
|
case PALMAS_REG_SMPS10_OUT2:
|
||||||
pmic->desc[id].n_voltages = PALMAS_SMPS10_NUM_VOLTAGES;
|
desc->n_voltages = PALMAS_SMPS10_NUM_VOLTAGES;
|
||||||
pmic->desc[id].ops = &palmas_ops_smps10;
|
desc->ops = &palmas_ops_smps10;
|
||||||
pmic->desc[id].vsel_reg =
|
desc->vsel_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
|
||||||
PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
|
PALMAS_SMPS10_CTRL);
|
||||||
PALMAS_SMPS10_CTRL);
|
desc->vsel_mask = SMPS10_VSEL;
|
||||||
pmic->desc[id].vsel_mask = SMPS10_VSEL;
|
desc->enable_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
|
||||||
pmic->desc[id].enable_reg =
|
PALMAS_SMPS10_CTRL);
|
||||||
PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
|
|
||||||
PALMAS_SMPS10_CTRL);
|
|
||||||
if (id == PALMAS_REG_SMPS10_OUT1)
|
if (id == PALMAS_REG_SMPS10_OUT1)
|
||||||
pmic->desc[id].enable_mask = SMPS10_SWITCH_EN;
|
desc->enable_mask = SMPS10_SWITCH_EN;
|
||||||
else
|
else
|
||||||
pmic->desc[id].enable_mask = SMPS10_BOOST_EN;
|
desc->enable_mask = SMPS10_BOOST_EN;
|
||||||
pmic->desc[id].bypass_reg =
|
desc->bypass_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
|
||||||
PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
|
PALMAS_SMPS10_CTRL);
|
||||||
PALMAS_SMPS10_CTRL);
|
desc->bypass_mask = SMPS10_BYPASS_EN;
|
||||||
pmic->desc[id].bypass_mask = SMPS10_BYPASS_EN;
|
desc->min_uV = 3750000;
|
||||||
pmic->desc[id].min_uV = 3750000;
|
desc->uV_step = 1250000;
|
||||||
pmic->desc[id].uV_step = 1250000;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/*
|
/*
|
||||||
|
@ -1190,7 +1176,7 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
|
||||||
* ranges. Read the current smps mode for later use.
|
* ranges. Read the current smps mode for later use.
|
||||||
*/
|
*/
|
||||||
addr = rinfo->vsel_addr;
|
addr = rinfo->vsel_addr;
|
||||||
pmic->desc[id].n_linear_ranges = 3;
|
desc->n_linear_ranges = 3;
|
||||||
|
|
||||||
ret = palmas_smps_read(pmic->palmas, addr, ®);
|
ret = palmas_smps_read(pmic->palmas, addr, ®);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -1198,21 +1184,18 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
|
||||||
if (reg & PALMAS_SMPS12_VOLTAGE_RANGE)
|
if (reg & PALMAS_SMPS12_VOLTAGE_RANGE)
|
||||||
pmic->range[id] = 1;
|
pmic->range[id] = 1;
|
||||||
if (pmic->range[id])
|
if (pmic->range[id])
|
||||||
pmic->desc[id].linear_ranges = smps_high_ranges;
|
desc->linear_ranges = smps_high_ranges;
|
||||||
else
|
else
|
||||||
pmic->desc[id].linear_ranges = smps_low_ranges;
|
desc->linear_ranges = smps_low_ranges;
|
||||||
|
|
||||||
if (reg_init && reg_init->roof_floor)
|
if (reg_init && reg_init->roof_floor)
|
||||||
pmic->desc[id].ops =
|
desc->ops = &palmas_ops_ext_control_smps;
|
||||||
&palmas_ops_ext_control_smps;
|
|
||||||
else
|
else
|
||||||
pmic->desc[id].ops = &palmas_ops_smps;
|
desc->ops = &palmas_ops_smps;
|
||||||
pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES;
|
desc->n_voltages = PALMAS_SMPS_NUM_VOLTAGES;
|
||||||
pmic->desc[id].vsel_reg =
|
desc->vsel_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
|
||||||
PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
|
rinfo->vsel_addr);
|
||||||
rinfo->vsel_addr);
|
desc->vsel_mask = PALMAS_SMPS12_VOLTAGE_VSEL_MASK;
|
||||||
pmic->desc[id].vsel_mask =
|
|
||||||
PALMAS_SMPS12_VOLTAGE_VSEL_MASK;
|
|
||||||
|
|
||||||
/* Read the smps mode for later use. */
|
/* Read the smps mode for later use. */
|
||||||
addr = rinfo->ctrl_addr;
|
addr = rinfo->ctrl_addr;
|
||||||
|
@ -1222,28 +1205,25 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
|
||||||
pmic->current_reg_mode[id] = reg &
|
pmic->current_reg_mode[id] = reg &
|
||||||
PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
|
PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
|
||||||
|
|
||||||
pmic->desc[id].enable_reg =
|
desc->enable_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
|
||||||
PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
|
rinfo->ctrl_addr);
|
||||||
rinfo->ctrl_addr);
|
desc->enable_mask = PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
|
||||||
pmic->desc[id].enable_mask =
|
|
||||||
PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
|
|
||||||
/* set_mode overrides this value */
|
/* set_mode overrides this value */
|
||||||
pmic->desc[id].enable_val = SMPS_CTRL_MODE_ON;
|
desc->enable_val = SMPS_CTRL_MODE_ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
pmic->desc[id].type = REGULATOR_VOLTAGE;
|
desc->type = REGULATOR_VOLTAGE;
|
||||||
pmic->desc[id].owner = THIS_MODULE;
|
desc->owner = THIS_MODULE;
|
||||||
|
|
||||||
if (pdata)
|
if (pdata)
|
||||||
config.init_data = pdata->reg_data[id];
|
config.init_data = pdata->reg_data[id];
|
||||||
else
|
else
|
||||||
config.init_data = NULL;
|
config.init_data = NULL;
|
||||||
|
|
||||||
pmic->desc[id].supply_name = rinfo->sname;
|
desc->supply_name = rinfo->sname;
|
||||||
config.of_node = ddata->palmas_matches[id].of_node;
|
config.of_node = ddata->palmas_matches[id].of_node;
|
||||||
|
|
||||||
rdev = devm_regulator_register(pmic->dev, &pmic->desc[id],
|
rdev = devm_regulator_register(pmic->dev, desc, &config);
|
||||||
&config);
|
|
||||||
if (IS_ERR(rdev)) {
|
if (IS_ERR(rdev)) {
|
||||||
dev_err(pmic->dev,
|
dev_err(pmic->dev,
|
||||||
"failed to register %s regulator\n",
|
"failed to register %s regulator\n",
|
||||||
|
@ -1269,13 +1249,15 @@ static int tps65917_smps_registration(struct palmas_pmic *pmic,
|
||||||
struct regulator_dev *rdev;
|
struct regulator_dev *rdev;
|
||||||
struct palmas_reg_init *reg_init;
|
struct palmas_reg_init *reg_init;
|
||||||
struct palmas_regs_info *rinfo;
|
struct palmas_regs_info *rinfo;
|
||||||
|
struct regulator_desc *desc;
|
||||||
|
|
||||||
for (id = ddata->smps_start; id <= ddata->smps_end; id++) {
|
for (id = ddata->smps_start; id <= ddata->smps_end; id++) {
|
||||||
/*
|
/*
|
||||||
* Miss out regulators which are not available due
|
* Miss out regulators which are not available due
|
||||||
* to slaving configurations.
|
* to slaving configurations.
|
||||||
*/
|
*/
|
||||||
pmic->desc[id].n_linear_ranges = 3;
|
desc = &pmic->desc[id];
|
||||||
|
desc->n_linear_ranges = 3;
|
||||||
if ((id == TPS65917_REG_SMPS2) && pmic->smps12)
|
if ((id == TPS65917_REG_SMPS2) && pmic->smps12)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1291,8 +1273,8 @@ static int tps65917_smps_registration(struct palmas_pmic *pmic,
|
||||||
rinfo = &ddata->palmas_regs_info[id];
|
rinfo = &ddata->palmas_regs_info[id];
|
||||||
|
|
||||||
/* Register the regulators */
|
/* Register the regulators */
|
||||||
pmic->desc[id].name = rinfo->name;
|
desc->name = rinfo->name;
|
||||||
pmic->desc[id].id = id;
|
desc->id = id;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read and store the RANGE bit for later use
|
* Read and store the RANGE bit for later use
|
||||||
|
@ -1309,24 +1291,19 @@ static int tps65917_smps_registration(struct palmas_pmic *pmic,
|
||||||
pmic->range[id] = 1;
|
pmic->range[id] = 1;
|
||||||
|
|
||||||
if (pmic->range[id])
|
if (pmic->range[id])
|
||||||
pmic->desc[id].linear_ranges = smps_high_ranges;
|
desc->linear_ranges = smps_high_ranges;
|
||||||
else
|
else
|
||||||
pmic->desc[id].linear_ranges = smps_low_ranges;
|
desc->linear_ranges = smps_low_ranges;
|
||||||
|
|
||||||
|
|
||||||
if (reg_init && reg_init->roof_floor)
|
if (reg_init && reg_init->roof_floor)
|
||||||
pmic->desc[id].ops =
|
desc->ops = &tps65917_ops_ext_control_smps;
|
||||||
&tps65917_ops_ext_control_smps;
|
|
||||||
else
|
else
|
||||||
pmic->desc[id].ops = &tps65917_ops_smps;
|
desc->ops = &tps65917_ops_smps;
|
||||||
pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES;
|
desc->n_voltages = PALMAS_SMPS_NUM_VOLTAGES;
|
||||||
pmic->desc[id].vsel_reg =
|
desc->vsel_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
|
||||||
PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
|
rinfo->vsel_addr);
|
||||||
rinfo->vsel_addr);
|
desc->vsel_mask = PALMAS_SMPS12_VOLTAGE_VSEL_MASK;
|
||||||
pmic->desc[id].vsel_mask =
|
desc->ramp_delay = 2500;
|
||||||
PALMAS_SMPS12_VOLTAGE_VSEL_MASK;
|
|
||||||
|
|
||||||
pmic->desc[id].ramp_delay = 2500;
|
|
||||||
|
|
||||||
/* Read the smps mode for later use. */
|
/* Read the smps mode for later use. */
|
||||||
addr = rinfo->ctrl_addr;
|
addr = rinfo->ctrl_addr;
|
||||||
|
@ -1336,19 +1313,18 @@ static int tps65917_smps_registration(struct palmas_pmic *pmic,
|
||||||
pmic->current_reg_mode[id] = reg &
|
pmic->current_reg_mode[id] = reg &
|
||||||
PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
|
PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
|
||||||
|
|
||||||
pmic->desc[id].type = REGULATOR_VOLTAGE;
|
desc->type = REGULATOR_VOLTAGE;
|
||||||
pmic->desc[id].owner = THIS_MODULE;
|
desc->owner = THIS_MODULE;
|
||||||
|
|
||||||
if (pdata)
|
if (pdata)
|
||||||
config.init_data = pdata->reg_data[id];
|
config.init_data = pdata->reg_data[id];
|
||||||
else
|
else
|
||||||
config.init_data = NULL;
|
config.init_data = NULL;
|
||||||
|
|
||||||
pmic->desc[id].supply_name = rinfo->sname;
|
desc->supply_name = rinfo->sname;
|
||||||
config.of_node = ddata->palmas_matches[id].of_node;
|
config.of_node = ddata->palmas_matches[id].of_node;
|
||||||
|
|
||||||
rdev = devm_regulator_register(pmic->dev, &pmic->desc[id],
|
rdev = devm_regulator_register(pmic->dev, desc, &config);
|
||||||
&config);
|
|
||||||
if (IS_ERR(rdev)) {
|
if (IS_ERR(rdev)) {
|
||||||
dev_err(pmic->dev,
|
dev_err(pmic->dev,
|
||||||
"failed to register %s regulator\n",
|
"failed to register %s regulator\n",
|
||||||
|
|
Loading…
Reference in a new issue