static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode)
{
+ int id = rdev_get_id(dev);
struct palmas_pmic *pmic = rdev_get_drvdata(dev);
struct palmas_pmic_driver_data *ddata = pmic->palmas->pmic_ddata;
- int id = rdev_get_id(dev);
+ struct palmas_regs_info *rinfo = &ddata->palmas_regs_info[id];
unsigned int reg;
bool rail_enable = true;
- palmas_smps_read(pmic->palmas, ddata->palmas_regs_info[id].ctrl_addr,
- ®);
+ palmas_smps_read(pmic->palmas, rinfo->ctrl_addr, ®);
reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
pmic->current_reg_mode[id] = reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
if (rail_enable)
- palmas_smps_write(pmic->palmas,
- ddata->palmas_regs_info[id].ctrl_addr, reg);
+ palmas_smps_write(pmic->palmas, rinfo->ctrl_addr, reg);
/* Switch the enable value to ensure this is used for enable */
pmic->desc[id].enable_val = pmic->current_reg_mode[id];
static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev,
int ramp_delay)
{
+ int id = rdev_get_id(rdev);
struct palmas_pmic *pmic = rdev_get_drvdata(rdev);
struct palmas_pmic_driver_data *ddata = pmic->palmas->pmic_ddata;
- int id = rdev_get_id(rdev);
+ struct palmas_regs_info *rinfo = &ddata->palmas_regs_info[id];
unsigned int reg = 0;
- unsigned int addr = ddata->palmas_regs_info[id].tstep_addr;
int ret;
/* SMPS3 and SMPS7 do not have tstep_addr setting */
else
reg = 1;
- ret = palmas_smps_write(pmic->palmas, addr, reg);
+ ret = palmas_smps_write(pmic->palmas, rinfo->tstep_addr, reg);
if (ret < 0) {
dev_err(pmic->palmas->dev, "TSTEP write failed: %d\n", ret);
return ret;
static int palmas_is_enabled_ldo(struct regulator_dev *dev)
{
+ int id = rdev_get_id(dev);
struct palmas_pmic *pmic = rdev_get_drvdata(dev);
struct palmas_pmic_driver_data *ddata = pmic->palmas->pmic_ddata;
- int id = rdev_get_id(dev);
+ struct palmas_regs_info *rinfo = &ddata->palmas_regs_info[id];
unsigned int reg;
- palmas_ldo_read(pmic->palmas,
- ddata->palmas_regs_info[id].ctrl_addr, ®);
+ palmas_ldo_read(pmic->palmas, rinfo->ctrl_addr, ®);
reg &= PALMAS_LDO1_CTRL_STATUS;
static int palmas_regulator_config_external(struct palmas *palmas, int id,
struct palmas_reg_init *reg_init)
{
- int sleep_id = palmas_regs_info[id].sleep_id;
+ struct palmas_pmic_driver_data *ddata = palmas->pmic_ddata;
+ struct palmas_regs_info *rinfo = &ddata->palmas_regs_info[id];
int ret;
- ret = palmas_ext_control_req_config(palmas, sleep_id,
- reg_init->roof_floor, true);
+ ret = palmas_ext_control_req_config(palmas, rinfo->sleep_id,
+ reg_init->roof_floor, true);
if (ret < 0)
dev_err(palmas->dev,
"Ext control config for regulator %d failed %d\n",
struct palmas_reg_init *reg_init)
{
unsigned int reg;
- unsigned int addr;
int ret;
-
struct palmas_pmic_driver_data *ddata = palmas->pmic_ddata;
-
- addr = ddata->palmas_regs_info[id].ctrl_addr;
+ struct palmas_regs_info *rinfo = &ddata->palmas_regs_info[id];
+ unsigned int addr = rinfo->ctrl_addr;
ret = palmas_smps_read(palmas, addr, ®);
if (ret)
if (ret)
return ret;
- if (ddata->palmas_regs_info[id].vsel_addr && reg_init->vsel) {
- addr = ddata->palmas_regs_info[id].vsel_addr;
+ if (rinfo->vsel_addr && reg_init->vsel) {
reg = reg_init->vsel;
- ret = palmas_smps_write(palmas, addr, reg);
+ ret = palmas_smps_write(palmas, rinfo->vsel_addr, reg);
if (ret)
return ret;
}
if (reg_init->roof_floor && (id != PALMAS_REG_SMPS10_OUT1) &&
(id != PALMAS_REG_SMPS10_OUT2)) {
/* Enable externally controlled regulator */
- addr = ddata->palmas_regs_info[id].ctrl_addr;
ret = palmas_smps_read(palmas, addr, ®);
if (ret < 0)
return ret;
unsigned int reg;
unsigned int addr;
int ret;
-
struct palmas_pmic_driver_data *ddata = palmas->pmic_ddata;
+ struct palmas_regs_info *rinfo = &ddata->palmas_regs_info[id];
- addr = ddata->palmas_regs_info[id].ctrl_addr;
+ addr = rinfo->ctrl_addr;
ret = palmas_ldo_read(palmas, addr, ®);
if (ret)
if (reg_init->roof_floor) {
/* Enable externally controlled regulator */
- addr = ddata->palmas_regs_info[id].ctrl_addr;
ret = palmas_update_bits(palmas, PALMAS_LDO_BASE,
addr, PALMAS_LDO1_CTRL_MODE_ACTIVE,
PALMAS_LDO1_CTRL_MODE_ACTIVE);
unsigned int addr;
int ret;
unsigned int val = 0;
-
struct palmas_pmic_driver_data *ddata = palmas->pmic_ddata;
+ struct palmas_regs_info *rinfo = &ddata->palmas_regs_info[id];
- addr = ddata->palmas_regs_info[id].ctrl_addr;
+ addr = rinfo->ctrl_addr;
if (reg_init->mode_sleep)
val = PALMAS_REGEN1_CTRL_MODE_SLEEP;
if (reg_init->roof_floor) {
/* Enable externally controlled regulator */
- addr = ddata->palmas_regs_info[id].ctrl_addr;
ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE,
addr, PALMAS_REGEN1_CTRL_MODE_ACTIVE,
PALMAS_REGEN1_CTRL_MODE_ACTIVE);
unsigned int reg;
unsigned int addr;
int ret;
-
struct palmas_pmic_driver_data *ddata = palmas->pmic_ddata;
+ struct palmas_regs_info *rinfo;
- addr = ddata->palmas_regs_info[PALMAS_REG_LDO8].ctrl_addr;
+ rinfo = &ddata->palmas_regs_info[PALMAS_REG_LDO8];
+ addr = rinfo->ctrl_addr;
ret = palmas_ldo_read(palmas, addr, ®);
if (ret) {
* output is defined by the LDO8_VOLTAGE.VSEL register divided by two,
* and can be set from 0.45 to 1.65 V.
*/
- addr = ddata->palmas_regs_info[PALMAS_REG_LDO8].vsel_addr;
+ addr = rinfo->vsel_addr;
ret = palmas_ldo_read(palmas, addr, ®);
if (ret) {
dev_err(palmas->dev, "Error in reading ldo8 voltage reg\n");
int id, ret;
struct regulator_dev *rdev;
struct palmas_reg_init *reg_init;
+ struct palmas_regs_info *rinfo;
for (id = ddata->ldo_begin; id < ddata->max_reg; id++) {
if (pdata && pdata->reg_init[id])
else
reg_init = NULL;
+ rinfo = &ddata->palmas_regs_info[id];
/* Miss out regulators which are not available due
* to alternate functions.
*/
/* Register the regulators */
- pmic->desc[id].name = ddata->palmas_regs_info[id].name;
+ pmic->desc[id].name = rinfo->name;
pmic->desc[id].id = id;
pmic->desc[id].type = REGULATOR_VOLTAGE;
pmic->desc[id].owner = THIS_MODULE;
pmic->desc[id].enable_time = 500;
pmic->desc[id].vsel_reg =
PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
- ddata->palmas_regs_info[id].vsel_addr);
+ rinfo->vsel_addr);
pmic->desc[id].vsel_mask =
PALMAS_LDO1_VOLTAGE_VSEL_MASK;
pmic->desc[id].enable_reg =
PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
- ddata->palmas_regs_info[id].ctrl_addr);
+ rinfo->ctrl_addr);
pmic->desc[id].enable_mask =
PALMAS_LDO1_CTRL_MODE_ACTIVE;
pmic->desc[id].ops = &palmas_ops_extreg;
pmic->desc[id].enable_reg =
PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE,
- ddata->palmas_regs_info[id].ctrl_addr);
+ rinfo->ctrl_addr);
pmic->desc[id].enable_mask =
PALMAS_REGEN1_CTRL_MODE_ACTIVE;
}
else
config.init_data = NULL;
- pmic->desc[id].supply_name = ddata->palmas_regs_info[id].sname;
+ pmic->desc[id].supply_name = rinfo->sname;
config.of_node = ddata->palmas_matches[id].of_node;
rdev = devm_regulator_register(pmic->dev, &pmic->desc[id],
int id, ret;
struct regulator_dev *rdev;
struct palmas_reg_init *reg_init;
+ struct palmas_regs_info *rinfo;
for (id = ddata->ldo_begin; id < ddata->max_reg; id++) {
if (pdata && pdata->reg_init[id])
/* Miss out regulators which are not available due
* to alternate functions.
*/
+ rinfo = &ddata->palmas_regs_info[id];
/* Register the regulators */
- pmic->desc[id].name = ddata->palmas_regs_info[id].name;
+ pmic->desc[id].name = rinfo->name;
pmic->desc[id].id = id;
pmic->desc[id].type = REGULATOR_VOLTAGE;
pmic->desc[id].owner = THIS_MODULE;
pmic->desc[id].enable_time = 500;
pmic->desc[id].vsel_reg =
PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
- ddata->palmas_regs_info[id].vsel_addr);
+ rinfo->vsel_addr);
pmic->desc[id].vsel_mask =
PALMAS_LDO1_VOLTAGE_VSEL_MASK;
pmic->desc[id].enable_reg =
PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
- ddata->palmas_regs_info[id].ctrl_addr);
+ rinfo->ctrl_addr);
pmic->desc[id].enable_mask =
PALMAS_LDO1_CTRL_MODE_ACTIVE;
/*
pmic->desc[id].ops = &palmas_ops_extreg;
pmic->desc[id].enable_reg =
PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE,
- ddata->palmas_regs_info[id].ctrl_addr);
+ rinfo->ctrl_addr);
pmic->desc[id].enable_mask =
PALMAS_REGEN1_CTRL_MODE_ACTIVE;
}
else
config.init_data = NULL;
- pmic->desc[id].supply_name = ddata->palmas_regs_info[id].sname;
+ pmic->desc[id].supply_name = rinfo->sname;
config.of_node = ddata->palmas_matches[id].of_node;
rdev = devm_regulator_register(pmic->dev, &pmic->desc[id],
unsigned int addr, reg;
struct regulator_dev *rdev;
struct palmas_reg_init *reg_init;
+ struct palmas_regs_info *rinfo;
for (id = ddata->smps_start; id <= ddata->smps_end; id++) {
bool ramp_delay_support = false;
if (!PALMAS_PMIC_HAS(pmic->palmas, SMPS10_BOOST))
continue;
}
+ rinfo = &ddata->palmas_regs_info[id];
if ((id == PALMAS_REG_SMPS6) || (id == PALMAS_REG_SMPS8))
ramp_delay_support = true;
if (ramp_delay_support) {
- addr = ddata->palmas_regs_info[id].tstep_addr;
+ addr = rinfo->tstep_addr;
ret = palmas_smps_read(pmic->palmas, addr, ®);
if (ret < 0) {
dev_err(pmic->dev,
}
/* Register the regulators */
- pmic->desc[id].name = ddata->palmas_regs_info[id].name;
+ pmic->desc[id].name = rinfo->name;
pmic->desc[id].id = id;
switch (id) {
* otherwise we error in probe with unsupportable
* ranges. Read the current smps mode for later use.
*/
- addr = palmas_regs_info[id].vsel_addr;
+ addr = rinfo->vsel_addr;
pmic->desc[id].n_linear_ranges = 3;
ret = palmas_smps_read(pmic->palmas, addr, ®);
pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES;
pmic->desc[id].vsel_reg =
PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
- palmas_regs_info[id].vsel_addr);
+ rinfo->vsel_addr);
pmic->desc[id].vsel_mask =
PALMAS_SMPS12_VOLTAGE_VSEL_MASK;
/* Read the smps mode for later use. */
- addr = palmas_regs_info[id].ctrl_addr;
+ addr = rinfo->ctrl_addr;
ret = palmas_smps_read(pmic->palmas, addr, ®);
if (ret)
return ret;
pmic->desc[id].enable_reg =
PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
- palmas_regs_info[id].ctrl_addr);
+ rinfo->ctrl_addr);
pmic->desc[id].enable_mask =
PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
/* set_mode overrides this value */
else
config.init_data = NULL;
- pmic->desc[id].supply_name = ddata->palmas_regs_info[id].sname;
+ pmic->desc[id].supply_name = rinfo->sname;
config.of_node = ddata->palmas_matches[id].of_node;
rdev = devm_regulator_register(pmic->dev, &pmic->desc[id],
unsigned int addr, reg;
struct regulator_dev *rdev;
struct palmas_reg_init *reg_init;
+ struct palmas_regs_info *rinfo;
for (id = ddata->smps_start; id <= ddata->smps_end; id++) {
/*
} else {
reg_init = NULL;
}
+ rinfo = &ddata->palmas_regs_info[id];
/* Register the regulators */
- pmic->desc[id].name = ddata->palmas_regs_info[id].name;
+ pmic->desc[id].name = rinfo->name;
pmic->desc[id].id = id;
/*
* otherwise we error in probe with unsupportable
* ranges. Read the current smps mode for later use.
*/
- addr = ddata->palmas_regs_info[id].vsel_addr;
+ addr = rinfo->vsel_addr;
ret = palmas_smps_read(pmic->palmas, addr, ®);
if (ret)
pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES;
pmic->desc[id].vsel_reg =
PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
- tps65917_regs_info[id].vsel_addr);
+ rinfo->vsel_addr);
pmic->desc[id].vsel_mask =
PALMAS_SMPS12_VOLTAGE_VSEL_MASK;
pmic->desc[id].ramp_delay = 2500;
/* Read the smps mode for later use. */
- addr = ddata->palmas_regs_info[id].ctrl_addr;
+ addr = rinfo->ctrl_addr;
ret = palmas_smps_read(pmic->palmas, addr, ®);
if (ret)
return ret;
else
config.init_data = NULL;
- pmic->desc[id].supply_name = ddata->palmas_regs_info[id].sname;
+ pmic->desc[id].supply_name = rinfo->sname;
config.of_node = ddata->palmas_matches[id].of_node;
rdev = devm_regulator_register(pmic->dev, &pmic->desc[id],