Merge remote-tracking branch 'regulator/topic/qcom_spmi' into regulator-next

This commit is contained in:
Mark Brown 2018-01-26 17:57:01 +00:00
commit 27556467e0
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 31 additions and 53 deletions

View File

@ -486,24 +486,6 @@ static int spmi_vreg_update_bits(struct spmi_regulator *vreg, u16 addr, u8 val,
return regmap_update_bits(vreg->regmap, vreg->base + addr, mask, val); return regmap_update_bits(vreg->regmap, vreg->base + addr, mask, val);
} }
static int spmi_regulator_common_is_enabled(struct regulator_dev *rdev)
{
struct spmi_regulator *vreg = rdev_get_drvdata(rdev);
u8 reg;
spmi_vreg_read(vreg, SPMI_COMMON_REG_ENABLE, &reg, 1);
return (reg & SPMI_COMMON_ENABLE_MASK) == SPMI_COMMON_ENABLE;
}
static int spmi_regulator_common_enable(struct regulator_dev *rdev)
{
struct spmi_regulator *vreg = rdev_get_drvdata(rdev);
return spmi_vreg_update_bits(vreg, SPMI_COMMON_REG_ENABLE,
SPMI_COMMON_ENABLE, SPMI_COMMON_ENABLE_MASK);
}
static int spmi_regulator_vs_enable(struct regulator_dev *rdev) static int spmi_regulator_vs_enable(struct regulator_dev *rdev)
{ {
struct spmi_regulator *vreg = rdev_get_drvdata(rdev); struct spmi_regulator *vreg = rdev_get_drvdata(rdev);
@ -513,7 +495,7 @@ static int spmi_regulator_vs_enable(struct regulator_dev *rdev)
vreg->vs_enable_time = ktime_get(); vreg->vs_enable_time = ktime_get();
} }
return spmi_regulator_common_enable(rdev); return regulator_enable_regmap(rdev);
} }
static int spmi_regulator_vs_ocp(struct regulator_dev *rdev) static int spmi_regulator_vs_ocp(struct regulator_dev *rdev)
@ -524,14 +506,6 @@ static int spmi_regulator_vs_ocp(struct regulator_dev *rdev)
return spmi_vreg_write(vreg, SPMI_VS_REG_OCP, &reg, 1); return spmi_vreg_write(vreg, SPMI_VS_REG_OCP, &reg, 1);
} }
static int spmi_regulator_common_disable(struct regulator_dev *rdev)
{
struct spmi_regulator *vreg = rdev_get_drvdata(rdev);
return spmi_vreg_update_bits(vreg, SPMI_COMMON_REG_ENABLE,
SPMI_COMMON_DISABLE, SPMI_COMMON_ENABLE_MASK);
}
static int spmi_regulator_select_voltage(struct spmi_regulator *vreg, static int spmi_regulator_select_voltage(struct spmi_regulator *vreg,
int min_uV, int max_uV) int min_uV, int max_uV)
{ {
@ -1062,9 +1036,9 @@ static irqreturn_t spmi_regulator_vs_ocp_isr(int irq, void *data)
} }
static struct regulator_ops spmi_smps_ops = { static struct regulator_ops spmi_smps_ops = {
.enable = spmi_regulator_common_enable, .enable = regulator_enable_regmap,
.disable = spmi_regulator_common_disable, .disable = regulator_disable_regmap,
.is_enabled = spmi_regulator_common_is_enabled, .is_enabled = regulator_is_enabled_regmap,
.set_voltage_sel = spmi_regulator_common_set_voltage, .set_voltage_sel = spmi_regulator_common_set_voltage,
.set_voltage_time_sel = spmi_regulator_set_voltage_time_sel, .set_voltage_time_sel = spmi_regulator_set_voltage_time_sel,
.get_voltage_sel = spmi_regulator_common_get_voltage, .get_voltage_sel = spmi_regulator_common_get_voltage,
@ -1077,9 +1051,9 @@ static struct regulator_ops spmi_smps_ops = {
}; };
static struct regulator_ops spmi_ldo_ops = { static struct regulator_ops spmi_ldo_ops = {
.enable = spmi_regulator_common_enable, .enable = regulator_enable_regmap,
.disable = spmi_regulator_common_disable, .disable = regulator_disable_regmap,
.is_enabled = spmi_regulator_common_is_enabled, .is_enabled = regulator_is_enabled_regmap,
.set_voltage_sel = spmi_regulator_common_set_voltage, .set_voltage_sel = spmi_regulator_common_set_voltage,
.get_voltage_sel = spmi_regulator_common_get_voltage, .get_voltage_sel = spmi_regulator_common_get_voltage,
.map_voltage = spmi_regulator_common_map_voltage, .map_voltage = spmi_regulator_common_map_voltage,
@ -1094,9 +1068,9 @@ static struct regulator_ops spmi_ldo_ops = {
}; };
static struct regulator_ops spmi_ln_ldo_ops = { static struct regulator_ops spmi_ln_ldo_ops = {
.enable = spmi_regulator_common_enable, .enable = regulator_enable_regmap,
.disable = spmi_regulator_common_disable, .disable = regulator_disable_regmap,
.is_enabled = spmi_regulator_common_is_enabled, .is_enabled = regulator_is_enabled_regmap,
.set_voltage_sel = spmi_regulator_common_set_voltage, .set_voltage_sel = spmi_regulator_common_set_voltage,
.get_voltage_sel = spmi_regulator_common_get_voltage, .get_voltage_sel = spmi_regulator_common_get_voltage,
.map_voltage = spmi_regulator_common_map_voltage, .map_voltage = spmi_regulator_common_map_voltage,
@ -1107,8 +1081,8 @@ static struct regulator_ops spmi_ln_ldo_ops = {
static struct regulator_ops spmi_vs_ops = { static struct regulator_ops spmi_vs_ops = {
.enable = spmi_regulator_vs_enable, .enable = spmi_regulator_vs_enable,
.disable = spmi_regulator_common_disable, .disable = regulator_disable_regmap,
.is_enabled = spmi_regulator_common_is_enabled, .is_enabled = regulator_is_enabled_regmap,
.set_pull_down = spmi_regulator_common_set_pull_down, .set_pull_down = spmi_regulator_common_set_pull_down,
.set_soft_start = spmi_regulator_common_set_soft_start, .set_soft_start = spmi_regulator_common_set_soft_start,
.set_over_current_protection = spmi_regulator_vs_ocp, .set_over_current_protection = spmi_regulator_vs_ocp,
@ -1117,9 +1091,9 @@ static struct regulator_ops spmi_vs_ops = {
}; };
static struct regulator_ops spmi_boost_ops = { static struct regulator_ops spmi_boost_ops = {
.enable = spmi_regulator_common_enable, .enable = regulator_enable_regmap,
.disable = spmi_regulator_common_disable, .disable = regulator_disable_regmap,
.is_enabled = spmi_regulator_common_is_enabled, .is_enabled = regulator_is_enabled_regmap,
.set_voltage_sel = spmi_regulator_single_range_set_voltage, .set_voltage_sel = spmi_regulator_single_range_set_voltage,
.get_voltage_sel = spmi_regulator_single_range_get_voltage, .get_voltage_sel = spmi_regulator_single_range_get_voltage,
.map_voltage = spmi_regulator_single_map_voltage, .map_voltage = spmi_regulator_single_map_voltage,
@ -1128,9 +1102,9 @@ static struct regulator_ops spmi_boost_ops = {
}; };
static struct regulator_ops spmi_ftsmps_ops = { static struct regulator_ops spmi_ftsmps_ops = {
.enable = spmi_regulator_common_enable, .enable = regulator_enable_regmap,
.disable = spmi_regulator_common_disable, .disable = regulator_disable_regmap,
.is_enabled = spmi_regulator_common_is_enabled, .is_enabled = regulator_is_enabled_regmap,
.set_voltage_sel = spmi_regulator_common_set_voltage, .set_voltage_sel = spmi_regulator_common_set_voltage,
.set_voltage_time_sel = spmi_regulator_set_voltage_time_sel, .set_voltage_time_sel = spmi_regulator_set_voltage_time_sel,
.get_voltage_sel = spmi_regulator_common_get_voltage, .get_voltage_sel = spmi_regulator_common_get_voltage,
@ -1143,9 +1117,9 @@ static struct regulator_ops spmi_ftsmps_ops = {
}; };
static struct regulator_ops spmi_ult_lo_smps_ops = { static struct regulator_ops spmi_ult_lo_smps_ops = {
.enable = spmi_regulator_common_enable, .enable = regulator_enable_regmap,
.disable = spmi_regulator_common_disable, .disable = regulator_disable_regmap,
.is_enabled = spmi_regulator_common_is_enabled, .is_enabled = regulator_is_enabled_regmap,
.set_voltage_sel = spmi_regulator_ult_lo_smps_set_voltage, .set_voltage_sel = spmi_regulator_ult_lo_smps_set_voltage,
.set_voltage_time_sel = spmi_regulator_set_voltage_time_sel, .set_voltage_time_sel = spmi_regulator_set_voltage_time_sel,
.get_voltage_sel = spmi_regulator_ult_lo_smps_get_voltage, .get_voltage_sel = spmi_regulator_ult_lo_smps_get_voltage,
@ -1157,9 +1131,9 @@ static struct regulator_ops spmi_ult_lo_smps_ops = {
}; };
static struct regulator_ops spmi_ult_ho_smps_ops = { static struct regulator_ops spmi_ult_ho_smps_ops = {
.enable = spmi_regulator_common_enable, .enable = regulator_enable_regmap,
.disable = spmi_regulator_common_disable, .disable = regulator_disable_regmap,
.is_enabled = spmi_regulator_common_is_enabled, .is_enabled = regulator_is_enabled_regmap,
.set_voltage_sel = spmi_regulator_single_range_set_voltage, .set_voltage_sel = spmi_regulator_single_range_set_voltage,
.set_voltage_time_sel = spmi_regulator_set_voltage_time_sel, .set_voltage_time_sel = spmi_regulator_set_voltage_time_sel,
.get_voltage_sel = spmi_regulator_single_range_get_voltage, .get_voltage_sel = spmi_regulator_single_range_get_voltage,
@ -1172,9 +1146,9 @@ static struct regulator_ops spmi_ult_ho_smps_ops = {
}; };
static struct regulator_ops spmi_ult_ldo_ops = { static struct regulator_ops spmi_ult_ldo_ops = {
.enable = spmi_regulator_common_enable, .enable = regulator_enable_regmap,
.disable = spmi_regulator_common_disable, .disable = regulator_disable_regmap,
.is_enabled = spmi_regulator_common_is_enabled, .is_enabled = regulator_is_enabled_regmap,
.set_voltage_sel = spmi_regulator_single_range_set_voltage, .set_voltage_sel = spmi_regulator_single_range_set_voltage,
.get_voltage_sel = spmi_regulator_single_range_get_voltage, .get_voltage_sel = spmi_regulator_single_range_get_voltage,
.map_voltage = spmi_regulator_single_map_voltage, .map_voltage = spmi_regulator_single_map_voltage,
@ -1711,6 +1685,9 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
vreg->desc.id = -1; vreg->desc.id = -1;
vreg->desc.owner = THIS_MODULE; vreg->desc.owner = THIS_MODULE;
vreg->desc.type = REGULATOR_VOLTAGE; vreg->desc.type = REGULATOR_VOLTAGE;
vreg->desc.enable_reg = reg->base + SPMI_COMMON_REG_ENABLE;
vreg->desc.enable_mask = SPMI_COMMON_ENABLE_MASK;
vreg->desc.enable_val = SPMI_COMMON_ENABLE;
vreg->desc.name = name = reg->name; vreg->desc.name = name = reg->name;
vreg->desc.supply_name = reg->supply; vreg->desc.supply_name = reg->supply;
vreg->desc.of_match = reg->name; vreg->desc.of_match = reg->name;
@ -1723,6 +1700,7 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
config.dev = dev; config.dev = dev;
config.driver_data = vreg; config.driver_data = vreg;
config.regmap = regmap;
rdev = devm_regulator_register(dev, &vreg->desc, &config); rdev = devm_regulator_register(dev, &vreg->desc, &config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
dev_err(dev, "failed to register %s\n", name); dev_err(dev, "failed to register %s\n", name);