Commit 2da34b23 authored by Richard Fitzgerald's avatar Richard Fitzgerald Committed by Mark Brown

regulator: arizona-micsupp: Don't hardcode use of ARIZONA defines

When Madera support was added to this driver the code was left
using ARIZONA_* defines. This wasn't causing any problem because
those defines just happened to have the same value as the
equivalent MADERA_* defines. But it is not ideal to assume this,
and future devices that can share this driver do not have the
same register map.

Fix the code to refer to the register data in struct regulator_desc.
Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20221109165331.29332-7-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent db6f6ba7
...@@ -34,7 +34,7 @@ struct arizona_micsupp { ...@@ -34,7 +34,7 @@ struct arizona_micsupp {
struct regulator_dev *regulator; struct regulator_dev *regulator;
struct regmap *regmap; struct regmap *regmap;
struct snd_soc_dapm_context **dapm; struct snd_soc_dapm_context **dapm;
unsigned int enable_reg; const struct regulator_desc *desc;
struct device *dev; struct device *dev;
struct regulator_consumer_supply supply; struct regulator_consumer_supply supply;
...@@ -49,10 +49,11 @@ static void arizona_micsupp_check_cp(struct work_struct *work) ...@@ -49,10 +49,11 @@ static void arizona_micsupp_check_cp(struct work_struct *work)
container_of(work, struct arizona_micsupp, check_cp_work); container_of(work, struct arizona_micsupp, check_cp_work);
struct snd_soc_dapm_context *dapm = *micsupp->dapm; struct snd_soc_dapm_context *dapm = *micsupp->dapm;
struct snd_soc_component *component; struct snd_soc_component *component;
const struct regulator_desc *desc = micsupp->desc;
unsigned int val; unsigned int val;
int ret; int ret;
ret = regmap_read(micsupp->regmap, micsupp->enable_reg, &val); ret = regmap_read(micsupp->regmap, desc->enable_reg, &val);
if (ret != 0) { if (ret != 0) {
dev_err(micsupp->dev, dev_err(micsupp->dev,
"Failed to read CP state: %d\n", ret); "Failed to read CP state: %d\n", ret);
...@@ -62,8 +63,8 @@ static void arizona_micsupp_check_cp(struct work_struct *work) ...@@ -62,8 +63,8 @@ static void arizona_micsupp_check_cp(struct work_struct *work)
if (dapm) { if (dapm) {
component = snd_soc_dapm_to_component(dapm); component = snd_soc_dapm_to_component(dapm);
if ((val & (ARIZONA_CPMIC_ENA | ARIZONA_CPMIC_BYPASS)) == if ((val & (desc->enable_mask | desc->bypass_mask)) ==
ARIZONA_CPMIC_ENA) desc->enable_mask)
snd_soc_component_force_enable_pin(component, snd_soc_component_force_enable_pin(component,
"MICSUPP"); "MICSUPP");
else else
...@@ -209,7 +210,6 @@ static const struct regulator_desc madera_micsupp = { ...@@ -209,7 +210,6 @@ static const struct regulator_desc madera_micsupp = {
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
.n_voltages = 40, .n_voltages = 40,
.ops = &arizona_micsupp_ops, .ops = &arizona_micsupp_ops,
.vsel_reg = MADERA_LDO2_CONTROL_1, .vsel_reg = MADERA_LDO2_CONTROL_1,
.vsel_mask = MADERA_LDO2_VSEL_MASK, .vsel_mask = MADERA_LDO2_VSEL_MASK,
.enable_reg = MADERA_MIC_CHARGE_PUMP_1, .enable_reg = MADERA_MIC_CHARGE_PUMP_1,
...@@ -264,7 +264,7 @@ static int arizona_micsupp_common_init(struct platform_device *pdev, ...@@ -264,7 +264,7 @@ static int arizona_micsupp_common_init(struct platform_device *pdev,
micsupp->init_data.consumer_supplies = &micsupp->supply; micsupp->init_data.consumer_supplies = &micsupp->supply;
micsupp->supply.supply = "MICVDD"; micsupp->supply.supply = "MICVDD";
micsupp->supply.dev_name = dev_name(micsupp->dev); micsupp->supply.dev_name = dev_name(micsupp->dev);
micsupp->enable_reg = desc->enable_reg; micsupp->desc = desc;
config.dev = micsupp->dev; config.dev = micsupp->dev;
config.driver_data = micsupp; config.driver_data = micsupp;
...@@ -285,8 +285,7 @@ static int arizona_micsupp_common_init(struct platform_device *pdev, ...@@ -285,8 +285,7 @@ static int arizona_micsupp_common_init(struct platform_device *pdev,
config.init_data = &micsupp->init_data; config.init_data = &micsupp->init_data;
/* Default to regulated mode */ /* Default to regulated mode */
regmap_update_bits(micsupp->regmap, micsupp->enable_reg, regmap_update_bits(micsupp->regmap, desc->enable_reg, desc->bypass_mask, 0);
ARIZONA_CPMIC_BYPASS, 0);
micsupp->regulator = devm_regulator_register(&pdev->dev, micsupp->regulator = devm_regulator_register(&pdev->dev,
desc, desc,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment