These patches make various changes to the Arizona regulators so that they
can be re-used for the Cirrus Madera codecs:
- pdata is moves out of struct arizona_pdata into driver-specific structs
- all unnecessary dependence on struct arizona is removed
- generic init that doesn't depend on struct arizona is factored out
- The ldo and micsupp drivers now have separate KConfig options because
only the CS47L85/WM1840 Madera codecs have an LDO1, no other Madera
codecs will.
The Exynos based Cragganmore platform is a user of struct arizona_pdata
for the LDO1 so patch #5 updates it to the new pdata.
Richard Fitzgerald (7):
regulator: arizona: Split KConfig options for LDO1 and MICSUPP
regulators
regulator: arizona-micsupp: Move pdata into a separate structure
regulator: arizona-micsupp: Make arizona_micsupp independent of struct
arizona
regulator: arizona-micsupp: Factor out generic initialization
regulator: arizona-ldo1: Move pdata into a separate structure
regulator: arizona-ldo1: Make arizona_ldo1 independent of struct
arizona
regulator: arizona-ldo1: Factor out generic initialization
MAINTAINERS | 1 +
arch/arm/mach-s3c64xx/mach-crag6410-module.c | 8 +-
drivers/regulator/Kconfig | 14 ++-
drivers/regulator/Makefile | 3 +-
drivers/regulator/arizona-ldo1.c | 143 +++++++++++++++------------
drivers/regulator/arizona-micsupp.c | 122 +++++++++++++----------
include/linux/mfd/arizona/pdata.h | 7 +-
include/linux/regulator/arizona-ldo1.h | 24 +++++
include/linux/regulator/arizona-micsupp.h | 21 ++++
9 files changed, 221 insertions(+), 122 deletions(-)
create mode 100644 include/linux/regulator/arizona-ldo1.h
create mode 100644 include/linux/regulator/arizona-micsupp.h
--
1.9.1
In preparation for supporting Madera codecs, remove the dependency on
struct arizona in the regulator callbacks and struct arizona_ldo1.
Signed-off-by: Richard Fitzgerald <[email protected]>
---
drivers/regulator/arizona-ldo1.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index f5bc75a..678f81f 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -33,7 +33,7 @@
struct arizona_ldo1 {
struct regulator_dev *regulator;
- struct arizona *arizona;
+ struct regmap *regmap;
struct regulator_consumer_supply supply;
struct regulator_init_data init_data;
@@ -67,7 +67,7 @@ static int arizona_ldo1_hc_set_voltage_sel(struct regulator_dev *rdev,
unsigned sel)
{
struct arizona_ldo1 *ldo = rdev_get_drvdata(rdev);
- struct regmap *regmap = ldo->arizona->regmap;
+ struct regmap *regmap = ldo->regmap;
unsigned int val;
int ret;
@@ -93,7 +93,7 @@ static int arizona_ldo1_hc_set_voltage_sel(struct regulator_dev *rdev,
static int arizona_ldo1_hc_get_voltage_sel(struct regulator_dev *rdev)
{
struct arizona_ldo1 *ldo = rdev_get_drvdata(rdev);
- struct regmap *regmap = ldo->arizona->regmap;
+ struct regmap *regmap = ldo->regmap;
unsigned int val;
int ret;
@@ -247,7 +247,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
if (!ldo1)
return -ENOMEM;
- ldo1->arizona = arizona;
+ ldo1->regmap = arizona->regmap;
/*
* Since the chip usually supplies itself we provide some
--
1.9.1
In preparation for sharing this driver with Madera codecs, factor out
the parts of initialization that aren't dependent on struct arizona.
Signed-off-by: Richard Fitzgerald <[email protected]>
---
drivers/regulator/arizona-ldo1.c | 114 ++++++++++++++++++++++-----------------
1 file changed, 66 insertions(+), 48 deletions(-)
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index 678f81f..96fddff 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -234,67 +234,40 @@ static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata,
return 0;
}
-static int arizona_ldo1_probe(struct platform_device *pdev)
+static int arizona_ldo1_common_init(struct platform_device *pdev,
+ struct arizona_ldo1 *ldo1,
+ const struct regulator_desc *desc,
+ struct arizona_ldo1_pdata *pdata,
+ bool *external_dcvdd)
{
- struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
- const struct regulator_desc *desc;
+ struct device *parent_dev = pdev->dev.parent;
struct regulator_config config = { };
- struct arizona_ldo1 *ldo1;
- bool external_dcvdd = false;
int ret;
- ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);
- if (!ldo1)
- return -ENOMEM;
-
- ldo1->regmap = arizona->regmap;
-
- /*
- * Since the chip usually supplies itself we provide some
- * default init_data for it. This will be overridden with
- * platform data if provided.
- */
- switch (arizona->type) {
- case WM5102:
- case WM8997:
- case WM8998:
- case WM1814:
- desc = &arizona_ldo1_hc;
- ldo1->init_data = arizona_ldo1_dvfs;
- break;
- case WM5110:
- case WM8280:
- desc = &arizona_ldo1;
- ldo1->init_data = arizona_ldo1_wm5110;
- break;
- default:
- desc = &arizona_ldo1;
- ldo1->init_data = arizona_ldo1_default;
- break;
- }
+ *external_dcvdd = false;
- ldo1->init_data.consumer_supplies = &ldo1->supply;
ldo1->supply.supply = "DCVDD";
- ldo1->supply.dev_name = dev_name(arizona->dev);
+ ldo1->init_data.consumer_supplies = &ldo1->supply;
+ ldo1->supply.dev_name = dev_name(parent_dev);
- config.dev = arizona->dev;
+ config.dev = parent_dev;
config.driver_data = ldo1;
- config.regmap = arizona->regmap;
+ config.regmap = ldo1->regmap;
if (IS_ENABLED(CONFIG_OF)) {
- if (!dev_get_platdata(arizona->dev)) {
- ret = arizona_ldo1_of_get_pdata(&arizona->pdata.ldo1,
+ if (!dev_get_platdata(parent_dev)) {
+ ret = arizona_ldo1_of_get_pdata(pdata,
&config, desc,
- &external_dcvdd);
+ external_dcvdd);
if (ret < 0)
return ret;
}
}
- config.ena_gpio = arizona->pdata.ldo1.ldoena;
+ config.ena_gpio = pdata->ldoena;
- if (arizona->pdata.ldo1.init_data)
- config.init_data = arizona->pdata.ldo1.init_data;
+ if (pdata->init_data)
+ config.init_data = pdata->init_data;
else
config.init_data = &ldo1->init_data;
@@ -303,9 +276,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
* consumers then DCVDD is supplied externally.
*/
if (config.init_data->num_consumer_supplies == 0)
- arizona->external_dcvdd = true;
- else
- arizona->external_dcvdd = external_dcvdd;
+ *external_dcvdd = true;
ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config);
@@ -313,7 +284,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
if (IS_ERR(ldo1->regulator)) {
ret = PTR_ERR(ldo1->regulator);
- dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n",
+ dev_err(&pdev->dev, "Failed to register LDO1 supply: %d\n",
ret);
return ret;
}
@@ -323,6 +294,53 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
return 0;
}
+static int arizona_ldo1_probe(struct platform_device *pdev)
+{
+ struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
+ struct arizona_ldo1 *ldo1;
+ const struct regulator_desc *desc;
+ bool external_dcvdd;
+ int ret;
+
+ ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);
+ if (!ldo1)
+ return -ENOMEM;
+
+ ldo1->regmap = arizona->regmap;
+
+ /*
+ * Since the chip usually supplies itself we provide some
+ * default init_data for it. This will be overridden with
+ * platform data if provided.
+ */
+ switch (arizona->type) {
+ case WM5102:
+ case WM8997:
+ case WM8998:
+ case WM1814:
+ desc = &arizona_ldo1_hc;
+ ldo1->init_data = arizona_ldo1_dvfs;
+ break;
+ case WM5110:
+ case WM8280:
+ desc = &arizona_ldo1;
+ ldo1->init_data = arizona_ldo1_wm5110;
+ break;
+ default:
+ desc = &arizona_ldo1;
+ ldo1->init_data = arizona_ldo1_default;
+ break;
+ }
+
+ ret = arizona_ldo1_common_init(pdev, ldo1, desc,
+ &arizona->pdata.ldo1,
+ &external_dcvdd);
+ if (ret == 0)
+ arizona->external_dcvdd = external_dcvdd;
+
+ return ret;
+}
+
static struct platform_driver arizona_ldo1_driver = {
.probe = arizona_ldo1_probe,
.driver = {
--
1.9.1
In preparation for supporting Madera codecs, remove the dependency on
struct arizona in the regulator callbacks and struct arizona_micsupp.
Signed-off-by: Richard Fitzgerald <[email protected]>
---
drivers/regulator/arizona-micsupp.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index 5f8b5a7..db4fecf 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -34,7 +34,10 @@
struct arizona_micsupp {
struct regulator_dev *regulator;
- struct arizona *arizona;
+ struct regmap *regmap;
+ struct snd_soc_dapm_context **dapm;
+ unsigned int enable_reg;
+ struct device *dev;
struct regulator_consumer_supply supply;
struct regulator_init_data init_data;
@@ -46,21 +49,22 @@ static void arizona_micsupp_check_cp(struct work_struct *work)
{
struct arizona_micsupp *micsupp =
container_of(work, struct arizona_micsupp, check_cp_work);
- struct snd_soc_dapm_context *dapm = micsupp->arizona->dapm;
- struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
- struct arizona *arizona = micsupp->arizona;
- struct regmap *regmap = arizona->regmap;
- unsigned int reg;
+ struct snd_soc_dapm_context *dapm = *micsupp->dapm;
+ struct snd_soc_component *component;
+ unsigned int val;
int ret;
- ret = regmap_read(regmap, ARIZONA_MIC_CHARGE_PUMP_1, ®);
+ ret = regmap_read(micsupp->regmap, micsupp->enable_reg, &val);
if (ret != 0) {
- dev_err(arizona->dev, "Failed to read CP state: %d\n", ret);
+ dev_err(micsupp->dev,
+ "Failed to read CP state: %d\n", ret);
return;
}
if (dapm) {
- if ((reg & (ARIZONA_CPMIC_ENA | ARIZONA_CPMIC_BYPASS)) ==
+ component = snd_soc_dapm_to_component(dapm);
+
+ if ((val & (ARIZONA_CPMIC_ENA | ARIZONA_CPMIC_BYPASS)) ==
ARIZONA_CPMIC_ENA)
snd_soc_component_force_enable_pin(component,
"MICSUPP");
@@ -240,7 +244,9 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
if (!micsupp)
return -ENOMEM;
- micsupp->arizona = arizona;
+ micsupp->regmap = arizona->regmap;
+ micsupp->dapm = &arizona->dapm;
+ micsupp->dev = arizona->dev;
INIT_WORK(&micsupp->check_cp_work, arizona_micsupp_check_cp);
/*
@@ -263,6 +269,7 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
micsupp->init_data.consumer_supplies = &micsupp->supply;
micsupp->supply.supply = "MICVDD";
micsupp->supply.dev_name = dev_name(arizona->dev);
+ micsupp->enable_reg = desc->enable_reg;
config.dev = arizona->dev;
config.driver_data = micsupp;
--
1.9.1
These patches make various changes to the Arizona regulators so that they
can be re-used for the Cirrus Madera codecs:
- pdata is moves out of struct arizona_pdata into driver-specific structs
- all unnecessary dependence on struct arizona is removed
- generic init that doesn't depend on struct arizona is factored out
- The ldo and micsupp drivers now have separate KConfig options because
only the CS47L85/WM1840 Madera codecs have an LDO1, no other Madera
codecs will.
The Exynos based Cragganmore platform is a user of struct arizona_pdata
for the LDO1 so patch 0005 updates it to the new pdata.
Richard Fitzgerald (7):
regulator: arizona: Split KConfig options for LDO1 and MICSUPP
regulators
regulator: arizona-micsupp: Move pdata into a separate structure
regulator: arizona-micsupp: Make arizona_micsupp independent of struct
arizona
regulator: arizona-micsupp: Factor out generic initialization
regulator: arizona-ldo1: Move pdata into a separate structure
regulator: arizona-ldo1: Make arizona_ldo1 independent of struct
arizona
regulator: arizona-ldo1: Factor out generic initialization
MAINTAINERS | 1 +
arch/arm/mach-s3c64xx/mach-crag6410-module.c | 8 +-
drivers/regulator/Kconfig | 14 ++-
drivers/regulator/Makefile | 3 +-
drivers/regulator/arizona-ldo1.c | 143 +++++++++++++++------------
drivers/regulator/arizona-micsupp.c | 122 +++++++++++++----------
include/linux/mfd/arizona/pdata.h | 7 +-
include/linux/regulator/arizona-ldo1.h | 24 +++++
include/linux/regulator/arizona-micsupp.h | 21 ++++
9 files changed, 221 insertions(+), 122 deletions(-)
create mode 100644 include/linux/regulator/arizona-ldo1.h
create mode 100644 include/linux/regulator/arizona-micsupp.h
--
1.9.1
In preparation for sharing this driver with Madera, move the pdata
for the LDO1 regulator out of struct arizona_pdata into a dedicated
pdata struct for this driver. As a result the code in
arizona_ldo1_of_get_pdata() can be made independent of struct arizona.
This patch also updates the definition of struct arizona_pdata and
the use of this pdata in mach-crag6410-module.c
Signed-off-by: Richard Fitzgerald <[email protected]>
---
arch/arm/mach-s3c64xx/mach-crag6410-module.c | 8 ++++--
drivers/regulator/arizona-ldo1.c | 39 +++++++++++++++-------------
include/linux/mfd/arizona/pdata.h | 4 +--
include/linux/regulator/arizona-ldo1.h | 24 +++++++++++++++++
4 files changed, 53 insertions(+), 22 deletions(-)
create mode 100644 include/linux/regulator/arizona-ldo1.h
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
index ccc3ab8..ea5f216 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
@@ -209,7 +209,9 @@
};
static struct arizona_pdata wm5102_reva_pdata = {
- .ldoena = S3C64XX_GPN(7),
+ .ldo1 = {
+ .ldoena = S3C64XX_GPN(7),
+ },
.gpio_base = CODEC_GPIO_BASE,
.irq_flags = IRQF_TRIGGER_HIGH,
.micd_pol_gpio = CODEC_GPIO_BASE + 4,
@@ -239,7 +241,9 @@
};
static struct arizona_pdata wm5102_pdata = {
- .ldoena = S3C64XX_GPN(7),
+ .ldo1 = {
+ .ldoena = S3C64XX_GPN(7),
+ },
.gpio_base = CODEC_GPIO_BASE,
.irq_flags = IRQF_TRIGGER_HIGH,
.micd_pol_gpio = CODEC_GPIO_BASE + 2,
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index b726fa1..f5bc75a 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -25,6 +25,8 @@
#include <linux/gpio.h>
#include <linux/slab.h>
+#include <linux/regulator/arizona-ldo1.h>
+
#include <linux/mfd/arizona/core.h>
#include <linux/mfd/arizona/pdata.h>
#include <linux/mfd/arizona/registers.h>
@@ -186,20 +188,19 @@ static int arizona_ldo1_hc_get_voltage_sel(struct regulator_dev *rdev)
.num_consumer_supplies = 1,
};
-static int arizona_ldo1_of_get_pdata(struct device *dev,
- struct arizona *arizona,
+static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata,
struct regulator_config *config,
- const struct regulator_desc *desc)
+ const struct regulator_desc *desc,
+ bool *external_dcvdd)
{
- struct arizona_pdata *pdata = &arizona->pdata;
struct arizona_ldo1 *ldo1 = config->driver_data;
- struct device_node *np = arizona->dev->of_node;
+ struct device_node *np = config->dev->of_node;
struct device_node *init_node, *dcvdd_node;
struct regulator_init_data *init_data;
pdata->ldoena = of_get_named_gpio(np, "wlf,ldoena", 0);
if (pdata->ldoena < 0) {
- dev_warn(arizona->dev,
+ dev_warn(config->dev,
"LDOENA GPIO property missing/malformed: %d\n",
pdata->ldoena);
pdata->ldoena = 0;
@@ -213,19 +214,19 @@ static int arizona_ldo1_of_get_pdata(struct device *dev,
if (init_node) {
config->of_node = init_node;
- init_data = of_get_regulator_init_data(dev, init_node, desc);
-
+ init_data = of_get_regulator_init_data(config->dev, init_node,
+ desc);
if (init_data) {
init_data->consumer_supplies = &ldo1->supply;
init_data->num_consumer_supplies = 1;
if (dcvdd_node && dcvdd_node != init_node)
- arizona->external_dcvdd = true;
+ *external_dcvdd = true;
- pdata->ldo1 = init_data;
+ pdata->init_data = init_data;
}
} else if (dcvdd_node) {
- arizona->external_dcvdd = true;
+ *external_dcvdd = true;
}
of_node_put(dcvdd_node);
@@ -239,10 +240,9 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
const struct regulator_desc *desc;
struct regulator_config config = { };
struct arizona_ldo1 *ldo1;
+ bool external_dcvdd = false;
int ret;
- arizona->external_dcvdd = false;
-
ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);
if (!ldo1)
return -ENOMEM;
@@ -283,17 +283,18 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
if (IS_ENABLED(CONFIG_OF)) {
if (!dev_get_platdata(arizona->dev)) {
- ret = arizona_ldo1_of_get_pdata(&pdev->dev, arizona,
- &config, desc);
+ ret = arizona_ldo1_of_get_pdata(&arizona->pdata.ldo1,
+ &config, desc,
+ &external_dcvdd);
if (ret < 0)
return ret;
}
}
- config.ena_gpio = arizona->pdata.ldoena;
+ config.ena_gpio = arizona->pdata.ldo1.ldoena;
- if (arizona->pdata.ldo1)
- config.init_data = arizona->pdata.ldo1;
+ if (arizona->pdata.ldo1.init_data)
+ config.init_data = arizona->pdata.ldo1.init_data;
else
config.init_data = &ldo1->init_data;
@@ -303,6 +304,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
*/
if (config.init_data->num_consumer_supplies == 0)
arizona->external_dcvdd = true;
+ else
+ arizona->external_dcvdd = external_dcvdd;
ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config);
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
index 43e875f..bfeecf1 100644
--- a/include/linux/mfd/arizona/pdata.h
+++ b/include/linux/mfd/arizona/pdata.h
@@ -12,6 +12,7 @@
#define _ARIZONA_PDATA_H
#include <dt-bindings/mfd/arizona.h>
+#include <linux/regulator/arizona-ldo1.h>
#include <linux/regulator/arizona-micsupp.h>
#define ARIZONA_GPN_DIR_MASK 0x8000 /* GPN_DIR */
@@ -77,13 +78,12 @@ struct arizona_micd_range {
struct arizona_pdata {
int reset; /** GPIO controlling /RESET, if any */
- int ldoena; /** GPIO controlling LODENA, if any */
/** Regulator configuration for MICVDD */
struct arizona_micsupp_pdata micvdd;
/** Regulator configuration for LDO1 */
- struct regulator_init_data *ldo1;
+ struct arizona_ldo1_pdata ldo1;
/** If a direct 32kHz clock is provided on an MCLK specify it here */
int clk32k_src;
diff --git a/include/linux/regulator/arizona-ldo1.h b/include/linux/regulator/arizona-ldo1.h
new file mode 100644
index 0000000..c685f12
--- /dev/null
+++ b/include/linux/regulator/arizona-ldo1.h
@@ -0,0 +1,24 @@
+/*
+ * Platform data for Arizona LDO1 regulator
+ *
+ * Copyright 2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef ARIZONA_LDO1_H
+#define ARIZONA_LDO1_H
+
+struct regulator_init_data;
+
+struct arizona_ldo1_pdata {
+ /** GPIO controlling LDOENA, if any */
+ int ldoena;
+
+ /** Regulator configuration for LDO1 */
+ const struct regulator_init_data *init_data;
+};
+
+#endif
--
1.9.1
In preparation for sharing this driver with Madera, move the pdata
for the micsupp regulator out of struct arizona_pdata into a dedicated
pdata struct for this driver. As a result the code in
arizona_micsupp_of_get_pdata() can be made independent of struct arizona.
This patch also updates the definition of struct arizona_pdata and
the use of this pdata in mach-crag6410-module.c
Signed-off-by: Richard Fitzgerald <[email protected]>
---
MAINTAINERS | 1 +
drivers/regulator/arizona-micsupp.c | 21 +++++++++++----------
include/linux/mfd/arizona/pdata.h | 3 ++-
include/linux/regulator/arizona-micsupp.h | 21 +++++++++++++++++++++
4 files changed, 35 insertions(+), 11 deletions(-)
create mode 100644 include/linux/regulator/arizona-micsupp.h
diff --git a/MAINTAINERS b/MAINTAINERS
index c35e0ce..6ed8ef1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13623,6 +13623,7 @@ F: include/linux/mfd/arizona/
F: include/linux/mfd/wm831x/
F: include/linux/mfd/wm8350/
F: include/linux/mfd/wm8400*
+F: include/linux/regulator/arizona*
F: include/linux/wm97xx.h
F: include/sound/wm????.h
F: sound/soc/codecs/arizona.?
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index 5e38861..5f8b5a7 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -30,6 +30,8 @@
#include <linux/mfd/arizona/pdata.h>
#include <linux/mfd/arizona/registers.h>
+#include <linux/regulator/arizona-micsupp.h>
+
struct arizona_micsupp {
struct regulator_dev *regulator;
struct arizona *arizona;
@@ -199,28 +201,26 @@ static int arizona_micsupp_set_bypass(struct regulator_dev *rdev, bool ena)
.num_consumer_supplies = 1,
};
-static int arizona_micsupp_of_get_pdata(struct device *dev,
- struct arizona *arizona,
+static int arizona_micsupp_of_get_pdata(struct arizona_micsupp_pdata *pdata,
struct regulator_config *config,
const struct regulator_desc *desc)
{
- struct arizona_pdata *pdata = &arizona->pdata;
struct arizona_micsupp *micsupp = config->driver_data;
struct device_node *np;
struct regulator_init_data *init_data;
- np = of_get_child_by_name(arizona->dev->of_node, "micvdd");
+ np = of_get_child_by_name(config->dev->of_node, "micvdd");
if (np) {
config->of_node = np;
- init_data = of_get_regulator_init_data(dev, np, desc);
+ init_data = of_get_regulator_init_data(config->dev, np, desc);
if (init_data) {
init_data->consumer_supplies = &micsupp->supply;
init_data->num_consumer_supplies = 1;
- pdata->micvdd = init_data;
+ pdata->init_data = init_data;
}
}
@@ -232,6 +232,7 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
const struct regulator_desc *desc;
struct regulator_config config = { };
+ struct arizona_micsupp_pdata *pdata = &arizona->pdata.micvdd;
struct arizona_micsupp *micsupp;
int ret;
@@ -269,15 +270,15 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
if (IS_ENABLED(CONFIG_OF)) {
if (!dev_get_platdata(arizona->dev)) {
- ret = arizona_micsupp_of_get_pdata(&pdev->dev, arizona,
- &config, desc);
+ ret = arizona_micsupp_of_get_pdata(pdata, &config,
+ desc);
if (ret < 0)
return ret;
}
}
- if (arizona->pdata.micvdd)
- config.init_data = arizona->pdata.micvdd;
+ if (pdata->init_data)
+ config.init_data = pdata->init_data;
else
config.init_data = &micsupp->init_data;
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
index 64faeef..43e875f 100644
--- a/include/linux/mfd/arizona/pdata.h
+++ b/include/linux/mfd/arizona/pdata.h
@@ -12,6 +12,7 @@
#define _ARIZONA_PDATA_H
#include <dt-bindings/mfd/arizona.h>
+#include <linux/regulator/arizona-micsupp.h>
#define ARIZONA_GPN_DIR_MASK 0x8000 /* GPN_DIR */
#define ARIZONA_GPN_DIR_SHIFT 15 /* GPN_DIR */
@@ -79,7 +80,7 @@ struct arizona_pdata {
int ldoena; /** GPIO controlling LODENA, if any */
/** Regulator configuration for MICVDD */
- struct regulator_init_data *micvdd;
+ struct arizona_micsupp_pdata micvdd;
/** Regulator configuration for LDO1 */
struct regulator_init_data *ldo1;
diff --git a/include/linux/regulator/arizona-micsupp.h b/include/linux/regulator/arizona-micsupp.h
new file mode 100644
index 0000000..6168426
--- /dev/null
+++ b/include/linux/regulator/arizona-micsupp.h
@@ -0,0 +1,21 @@
+/*
+ * Platform data for Arizona micsupp regulator
+ *
+ * Copyright 2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef ARIZONA_MICSUPP_H
+#define ARIZONA_MICSUPP_H
+
+struct regulator_init_data;
+
+struct arizona_micsupp_pdata {
+ /** Regulator configuration for micsupp */
+ const struct regulator_init_data *init_data;
+};
+
+#endif
--
1.9.1
The CS47L24 Arizona codec and most Madera codecs do not have a LDO1
regulator. Split the LDO1 and MICSUPP regulators into separate KConfig
options so the LDO1 is only built into the kernel if needed.
Signed-off-by: Richard Fitzgerald <[email protected]>
---
drivers/regulator/Kconfig | 14 +++++++++++---
drivers/regulator/Makefile | 3 ++-
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 290eeb8..8647538 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -125,12 +125,20 @@ config REGULATOR_AB8500
This driver supports the regulators found on the ST-Ericsson mixed
signal AB8500 PMIC
-config REGULATOR_ARIZONA
- tristate "Wolfson Arizona class devices"
+config REGULATOR_ARIZONA_LDO1
+ tristate "Wolfson Arizona class devices LDO1"
depends on MFD_ARIZONA
depends on SND_SOC
help
- Support for the regulators found on Wolfson Arizona class
+ Support for the LDO1 regulators found on Wolfson Arizona class
+ devices.
+
+config REGULATOR_ARIZONA_MICSUPP
+ tristate "Wolfson Arizona class devices MICSUPP"
+ depends on MFD_ARIZONA
+ depends on SND_SOC
+ help
+ Support for the MICSUPP regulators found on Wolfson Arizona class
devices.
config REGULATOR_AS3711
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index bf5ed7a..8a439a2 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -19,7 +19,8 @@ obj-$(CONFIG_REGULATOR_ACT8865) += act8865-regulator.o
obj-$(CONFIG_REGULATOR_ACT8945A) += act8945a-regulator.o
obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
-obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
+obj-$(CONFIG_REGULATOR_ARIZONA_LDO1) += arizona-ldo1.o
+obj-$(CONFIG_REGULATOR_ARIZONA_MICSUPP) += arizona-micsupp.o
obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
--
1.9.1
In preparation for sharing this driver with Madera codecs, factor out
the parts of initialization that aren't dependent on struct arizona.
Signed-off-by: Richard Fitzgerald <[email protected]>
---
drivers/regulator/arizona-micsupp.c | 82 +++++++++++++++++++++----------------
1 file changed, 46 insertions(+), 36 deletions(-)
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index db4fecf..120de94 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -231,52 +231,27 @@ static int arizona_micsupp_of_get_pdata(struct arizona_micsupp_pdata *pdata,
return 0;
}
-static int arizona_micsupp_probe(struct platform_device *pdev)
+static int arizona_micsupp_common_init(struct platform_device *pdev,
+ struct arizona_micsupp *micsupp,
+ const struct regulator_desc *desc,
+ struct arizona_micsupp_pdata *pdata)
{
- struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
- const struct regulator_desc *desc;
struct regulator_config config = { };
- struct arizona_micsupp_pdata *pdata = &arizona->pdata.micvdd;
- struct arizona_micsupp *micsupp;
int ret;
- micsupp = devm_kzalloc(&pdev->dev, sizeof(*micsupp), GFP_KERNEL);
- if (!micsupp)
- return -ENOMEM;
-
- micsupp->regmap = arizona->regmap;
- micsupp->dapm = &arizona->dapm;
- micsupp->dev = arizona->dev;
INIT_WORK(&micsupp->check_cp_work, arizona_micsupp_check_cp);
- /*
- * Since the chip usually supplies itself we provide some
- * default init_data for it. This will be overridden with
- * platform data if provided.
- */
- switch (arizona->type) {
- case WM5110:
- case WM8280:
- desc = &arizona_micsupp_ext;
- micsupp->init_data = arizona_micsupp_ext_default;
- break;
- default:
- desc = &arizona_micsupp;
- micsupp->init_data = arizona_micsupp_default;
- break;
- }
-
micsupp->init_data.consumer_supplies = &micsupp->supply;
micsupp->supply.supply = "MICVDD";
- micsupp->supply.dev_name = dev_name(arizona->dev);
+ micsupp->supply.dev_name = dev_name(micsupp->dev);
micsupp->enable_reg = desc->enable_reg;
- config.dev = arizona->dev;
+ config.dev = micsupp->dev;
config.driver_data = micsupp;
- config.regmap = arizona->regmap;
+ config.regmap = micsupp->regmap;
if (IS_ENABLED(CONFIG_OF)) {
- if (!dev_get_platdata(arizona->dev)) {
+ if (!dev_get_platdata(micsupp->dev)) {
ret = arizona_micsupp_of_get_pdata(pdata, &config,
desc);
if (ret < 0)
@@ -289,8 +264,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
else
config.init_data = &micsupp->init_data;
- /* Default to regulated mode until the API supports bypass */
- regmap_update_bits(arizona->regmap, ARIZONA_MIC_CHARGE_PUMP_1,
+ /* Default to regulated mode */
+ regmap_update_bits(micsupp->regmap, micsupp->enable_reg,
ARIZONA_CPMIC_BYPASS, 0);
micsupp->regulator = devm_regulator_register(&pdev->dev,
@@ -301,7 +276,7 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
if (IS_ERR(micsupp->regulator)) {
ret = PTR_ERR(micsupp->regulator);
- dev_err(arizona->dev, "Failed to register mic supply: %d\n",
+ dev_err(micsupp->dev, "Failed to register mic supply: %d\n",
ret);
return ret;
}
@@ -311,6 +286,41 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
return 0;
}
+static int arizona_micsupp_probe(struct platform_device *pdev)
+{
+ struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
+ const struct regulator_desc *desc;
+ struct arizona_micsupp *micsupp;
+
+ micsupp = devm_kzalloc(&pdev->dev, sizeof(*micsupp), GFP_KERNEL);
+ if (!micsupp)
+ return -ENOMEM;
+
+ micsupp->regmap = arizona->regmap;
+ micsupp->dapm = &arizona->dapm;
+ micsupp->dev = arizona->dev;
+
+ /*
+ * Since the chip usually supplies itself we provide some
+ * default init_data for it. This will be overridden with
+ * platform data if provided.
+ */
+ switch (arizona->type) {
+ case WM5110:
+ case WM8280:
+ desc = &arizona_micsupp_ext;
+ micsupp->init_data = arizona_micsupp_ext_default;
+ break;
+ default:
+ desc = &arizona_micsupp;
+ micsupp->init_data = arizona_micsupp_default;
+ break;
+ }
+
+ return arizona_micsupp_common_init(pdev, micsupp, desc,
+ &arizona->pdata.micvdd);
+}
+
static struct platform_driver arizona_micsupp_driver = {
.probe = arizona_micsupp_probe,
.driver = {
--
1.9.1
On Tue, Apr 18, 2017 at 12:43 PM, Richard Fitzgerald
<[email protected]> wrote:
> In preparation for sharing this driver with Madera, move the pdata
> for the LDO1 regulator out of struct arizona_pdata into a dedicated
> pdata struct for this driver. As a result the code in
> arizona_ldo1_of_get_pdata() can be made independent of struct arizona.
>
> This patch also updates the definition of struct arizona_pdata and
> the use of this pdata in mach-crag6410-module.c
>
> Signed-off-by: Richard Fitzgerald <[email protected]>
> ---
> arch/arm/mach-s3c64xx/mach-crag6410-module.c | 8 ++++--
> drivers/regulator/arizona-ldo1.c | 39 +++++++++++++++-------------
> include/linux/mfd/arizona/pdata.h | 4 +--
> include/linux/regulator/arizona-ldo1.h | 24 +++++++++++++++++
> 4 files changed, 53 insertions(+), 22 deletions(-)
> create mode 100644 include/linux/regulator/arizona-ldo1.h
>
> diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
> index ccc3ab8..ea5f216 100644
> --- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c
> +++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
> @@ -209,7 +209,9 @@
> };
>
> static struct arizona_pdata wm5102_reva_pdata = {
> - .ldoena = S3C64XX_GPN(7),
> + .ldo1 = {
> + .ldoena = S3C64XX_GPN(7),
> + },
> .gpio_base = CODEC_GPIO_BASE,
> .irq_flags = IRQF_TRIGGER_HIGH,
> .micd_pol_gpio = CODEC_GPIO_BASE + 4,
> @@ -239,7 +241,9 @@
> };
>
> static struct arizona_pdata wm5102_pdata = {
> - .ldoena = S3C64XX_GPN(7),
> + .ldo1 = {
> + .ldoena = S3C64XX_GPN(7),
> + },
> .gpio_base = CODEC_GPIO_BASE,
> .irq_flags = IRQF_TRIGGER_HIGH,
> .micd_pol_gpio = CODEC_GPIO_BASE + 2,
Acked-by: Krzysztof Kozlowski <[email protected]>
Best regards,
Krzysztof
On Tue, Apr 18, 2017 at 11:43:46AM +0100, Richard Fitzgerald wrote:
> These patches make various changes to the Arizona regulators so that they
> can be re-used for the Cirrus Madera codecs:
This all looks good to me but needs review from Lee for the MFD overlap.
On Tue, 18 Apr 2017, Richard Fitzgerald wrote:
> In preparation for sharing this driver with Madera, move the pdata
> for the micsupp regulator out of struct arizona_pdata into a dedicated
> pdata struct for this driver. As a result the code in
> arizona_micsupp_of_get_pdata() can be made independent of struct arizona.
>
> This patch also updates the definition of struct arizona_pdata and
> the use of this pdata in mach-crag6410-module.c
>
> Signed-off-by: Richard Fitzgerald <[email protected]>
> ---
> MAINTAINERS | 1 +
> drivers/regulator/arizona-micsupp.c | 21 +++++++++++----------
> include/linux/mfd/arizona/pdata.h | 3 ++-
Acked-by: Lee Jones <[email protected]>
> include/linux/regulator/arizona-micsupp.h | 21 +++++++++++++++++++++
> 4 files changed, 35 insertions(+), 11 deletions(-)
> create mode 100644 include/linux/regulator/arizona-micsupp.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index c35e0ce..6ed8ef1 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13623,6 +13623,7 @@ F: include/linux/mfd/arizona/
> F: include/linux/mfd/wm831x/
> F: include/linux/mfd/wm8350/
> F: include/linux/mfd/wm8400*
> +F: include/linux/regulator/arizona*
> F: include/linux/wm97xx.h
> F: include/sound/wm????.h
> F: sound/soc/codecs/arizona.?
> diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
> index 5e38861..5f8b5a7 100644
> --- a/drivers/regulator/arizona-micsupp.c
> +++ b/drivers/regulator/arizona-micsupp.c
> @@ -30,6 +30,8 @@
> #include <linux/mfd/arizona/pdata.h>
> #include <linux/mfd/arizona/registers.h>
>
> +#include <linux/regulator/arizona-micsupp.h>
> +
> struct arizona_micsupp {
> struct regulator_dev *regulator;
> struct arizona *arizona;
> @@ -199,28 +201,26 @@ static int arizona_micsupp_set_bypass(struct regulator_dev *rdev, bool ena)
> .num_consumer_supplies = 1,
> };
>
> -static int arizona_micsupp_of_get_pdata(struct device *dev,
> - struct arizona *arizona,
> +static int arizona_micsupp_of_get_pdata(struct arizona_micsupp_pdata *pdata,
> struct regulator_config *config,
> const struct regulator_desc *desc)
> {
> - struct arizona_pdata *pdata = &arizona->pdata;
> struct arizona_micsupp *micsupp = config->driver_data;
> struct device_node *np;
> struct regulator_init_data *init_data;
>
> - np = of_get_child_by_name(arizona->dev->of_node, "micvdd");
> + np = of_get_child_by_name(config->dev->of_node, "micvdd");
>
> if (np) {
> config->of_node = np;
>
> - init_data = of_get_regulator_init_data(dev, np, desc);
> + init_data = of_get_regulator_init_data(config->dev, np, desc);
>
> if (init_data) {
> init_data->consumer_supplies = &micsupp->supply;
> init_data->num_consumer_supplies = 1;
>
> - pdata->micvdd = init_data;
> + pdata->init_data = init_data;
> }
> }
>
> @@ -232,6 +232,7 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
> struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
> const struct regulator_desc *desc;
> struct regulator_config config = { };
> + struct arizona_micsupp_pdata *pdata = &arizona->pdata.micvdd;
> struct arizona_micsupp *micsupp;
> int ret;
>
> @@ -269,15 +270,15 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
>
> if (IS_ENABLED(CONFIG_OF)) {
> if (!dev_get_platdata(arizona->dev)) {
> - ret = arizona_micsupp_of_get_pdata(&pdev->dev, arizona,
> - &config, desc);
> + ret = arizona_micsupp_of_get_pdata(pdata, &config,
> + desc);
> if (ret < 0)
> return ret;
> }
> }
>
> - if (arizona->pdata.micvdd)
> - config.init_data = arizona->pdata.micvdd;
> + if (pdata->init_data)
> + config.init_data = pdata->init_data;
> else
> config.init_data = &micsupp->init_data;
>
> diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
> index 64faeef..43e875f 100644
> --- a/include/linux/mfd/arizona/pdata.h
> +++ b/include/linux/mfd/arizona/pdata.h
> @@ -12,6 +12,7 @@
> #define _ARIZONA_PDATA_H
>
> #include <dt-bindings/mfd/arizona.h>
> +#include <linux/regulator/arizona-micsupp.h>
>
> #define ARIZONA_GPN_DIR_MASK 0x8000 /* GPN_DIR */
> #define ARIZONA_GPN_DIR_SHIFT 15 /* GPN_DIR */
> @@ -79,7 +80,7 @@ struct arizona_pdata {
> int ldoena; /** GPIO controlling LODENA, if any */
>
> /** Regulator configuration for MICVDD */
> - struct regulator_init_data *micvdd;
> + struct arizona_micsupp_pdata micvdd;
>
> /** Regulator configuration for LDO1 */
> struct regulator_init_data *ldo1;
> diff --git a/include/linux/regulator/arizona-micsupp.h b/include/linux/regulator/arizona-micsupp.h
> new file mode 100644
> index 0000000..6168426
> --- /dev/null
> +++ b/include/linux/regulator/arizona-micsupp.h
> @@ -0,0 +1,21 @@
> +/*
> + * Platform data for Arizona micsupp regulator
> + *
> + * Copyright 2017 Cirrus Logic
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef ARIZONA_MICSUPP_H
> +#define ARIZONA_MICSUPP_H
> +
> +struct regulator_init_data;
> +
> +struct arizona_micsupp_pdata {
> + /** Regulator configuration for micsupp */
> + const struct regulator_init_data *init_data;
> +};
> +
> +#endif
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
On Tue, 18 Apr 2017, Richard Fitzgerald wrote:
> In preparation for sharing this driver with Madera, move the pdata
> for the LDO1 regulator out of struct arizona_pdata into a dedicated
> pdata struct for this driver. As a result the code in
> arizona_ldo1_of_get_pdata() can be made independent of struct arizona.
>
> This patch also updates the definition of struct arizona_pdata and
> the use of this pdata in mach-crag6410-module.c
>
> Signed-off-by: Richard Fitzgerald <[email protected]>
> ---
> arch/arm/mach-s3c64xx/mach-crag6410-module.c | 8 ++++--
> drivers/regulator/arizona-ldo1.c | 39 +++++++++++++++-------------
> include/linux/mfd/arizona/pdata.h | 4 +--
Acked-by: Lee Jones <[email protected]>
> include/linux/regulator/arizona-ldo1.h | 24 +++++++++++++++++
> 4 files changed, 53 insertions(+), 22 deletions(-)
> create mode 100644 include/linux/regulator/arizona-ldo1.h
>
> diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
> index ccc3ab8..ea5f216 100644
> --- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c
> +++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
> @@ -209,7 +209,9 @@
> };
>
> static struct arizona_pdata wm5102_reva_pdata = {
> - .ldoena = S3C64XX_GPN(7),
> + .ldo1 = {
> + .ldoena = S3C64XX_GPN(7),
> + },
> .gpio_base = CODEC_GPIO_BASE,
> .irq_flags = IRQF_TRIGGER_HIGH,
> .micd_pol_gpio = CODEC_GPIO_BASE + 4,
> @@ -239,7 +241,9 @@
> };
>
> static struct arizona_pdata wm5102_pdata = {
> - .ldoena = S3C64XX_GPN(7),
> + .ldo1 = {
> + .ldoena = S3C64XX_GPN(7),
> + },
> .gpio_base = CODEC_GPIO_BASE,
> .irq_flags = IRQF_TRIGGER_HIGH,
> .micd_pol_gpio = CODEC_GPIO_BASE + 2,
> diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
> index b726fa1..f5bc75a 100644
> --- a/drivers/regulator/arizona-ldo1.c
> +++ b/drivers/regulator/arizona-ldo1.c
> @@ -25,6 +25,8 @@
> #include <linux/gpio.h>
> #include <linux/slab.h>
>
> +#include <linux/regulator/arizona-ldo1.h>
> +
> #include <linux/mfd/arizona/core.h>
> #include <linux/mfd/arizona/pdata.h>
> #include <linux/mfd/arizona/registers.h>
> @@ -186,20 +188,19 @@ static int arizona_ldo1_hc_get_voltage_sel(struct regulator_dev *rdev)
> .num_consumer_supplies = 1,
> };
>
> -static int arizona_ldo1_of_get_pdata(struct device *dev,
> - struct arizona *arizona,
> +static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata,
> struct regulator_config *config,
> - const struct regulator_desc *desc)
> + const struct regulator_desc *desc,
> + bool *external_dcvdd)
> {
> - struct arizona_pdata *pdata = &arizona->pdata;
> struct arizona_ldo1 *ldo1 = config->driver_data;
> - struct device_node *np = arizona->dev->of_node;
> + struct device_node *np = config->dev->of_node;
> struct device_node *init_node, *dcvdd_node;
> struct regulator_init_data *init_data;
>
> pdata->ldoena = of_get_named_gpio(np, "wlf,ldoena", 0);
> if (pdata->ldoena < 0) {
> - dev_warn(arizona->dev,
> + dev_warn(config->dev,
> "LDOENA GPIO property missing/malformed: %d\n",
> pdata->ldoena);
> pdata->ldoena = 0;
> @@ -213,19 +214,19 @@ static int arizona_ldo1_of_get_pdata(struct device *dev,
> if (init_node) {
> config->of_node = init_node;
>
> - init_data = of_get_regulator_init_data(dev, init_node, desc);
> -
> + init_data = of_get_regulator_init_data(config->dev, init_node,
> + desc);
> if (init_data) {
> init_data->consumer_supplies = &ldo1->supply;
> init_data->num_consumer_supplies = 1;
>
> if (dcvdd_node && dcvdd_node != init_node)
> - arizona->external_dcvdd = true;
> + *external_dcvdd = true;
>
> - pdata->ldo1 = init_data;
> + pdata->init_data = init_data;
> }
> } else if (dcvdd_node) {
> - arizona->external_dcvdd = true;
> + *external_dcvdd = true;
> }
>
> of_node_put(dcvdd_node);
> @@ -239,10 +240,9 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
> const struct regulator_desc *desc;
> struct regulator_config config = { };
> struct arizona_ldo1 *ldo1;
> + bool external_dcvdd = false;
> int ret;
>
> - arizona->external_dcvdd = false;
> -
> ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);
> if (!ldo1)
> return -ENOMEM;
> @@ -283,17 +283,18 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
>
> if (IS_ENABLED(CONFIG_OF)) {
> if (!dev_get_platdata(arizona->dev)) {
> - ret = arizona_ldo1_of_get_pdata(&pdev->dev, arizona,
> - &config, desc);
> + ret = arizona_ldo1_of_get_pdata(&arizona->pdata.ldo1,
> + &config, desc,
> + &external_dcvdd);
> if (ret < 0)
> return ret;
> }
> }
>
> - config.ena_gpio = arizona->pdata.ldoena;
> + config.ena_gpio = arizona->pdata.ldo1.ldoena;
>
> - if (arizona->pdata.ldo1)
> - config.init_data = arizona->pdata.ldo1;
> + if (arizona->pdata.ldo1.init_data)
> + config.init_data = arizona->pdata.ldo1.init_data;
> else
> config.init_data = &ldo1->init_data;
>
> @@ -303,6 +304,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
> */
> if (config.init_data->num_consumer_supplies == 0)
> arizona->external_dcvdd = true;
> + else
> + arizona->external_dcvdd = external_dcvdd;
>
> ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config);
>
> diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
> index 43e875f..bfeecf1 100644
> --- a/include/linux/mfd/arizona/pdata.h
> +++ b/include/linux/mfd/arizona/pdata.h
> @@ -12,6 +12,7 @@
> #define _ARIZONA_PDATA_H
>
> #include <dt-bindings/mfd/arizona.h>
> +#include <linux/regulator/arizona-ldo1.h>
> #include <linux/regulator/arizona-micsupp.h>
>
> #define ARIZONA_GPN_DIR_MASK 0x8000 /* GPN_DIR */
> @@ -77,13 +78,12 @@ struct arizona_micd_range {
>
> struct arizona_pdata {
> int reset; /** GPIO controlling /RESET, if any */
> - int ldoena; /** GPIO controlling LODENA, if any */
>
> /** Regulator configuration for MICVDD */
> struct arizona_micsupp_pdata micvdd;
>
> /** Regulator configuration for LDO1 */
> - struct regulator_init_data *ldo1;
> + struct arizona_ldo1_pdata ldo1;
>
> /** If a direct 32kHz clock is provided on an MCLK specify it here */
> int clk32k_src;
> diff --git a/include/linux/regulator/arizona-ldo1.h b/include/linux/regulator/arizona-ldo1.h
> new file mode 100644
> index 0000000..c685f12
> --- /dev/null
> +++ b/include/linux/regulator/arizona-ldo1.h
> @@ -0,0 +1,24 @@
> +/*
> + * Platform data for Arizona LDO1 regulator
> + *
> + * Copyright 2017 Cirrus Logic
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef ARIZONA_LDO1_H
> +#define ARIZONA_LDO1_H
> +
> +struct regulator_init_data;
> +
> +struct arizona_ldo1_pdata {
> + /** GPIO controlling LDOENA, if any */
> + int ldoena;
> +
> + /** Regulator configuration for LDO1 */
> + const struct regulator_init_data *init_data;
> +};
> +
> +#endif
> --
> 1.9.1
>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
The patch
regulator: arizona-micsupp: Move pdata into a separate structure
has been applied to the regulator tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From 22161f3eb65dc29434325736c4d780908fe3bf6a Mon Sep 17 00:00:00 2001
From: Richard Fitzgerald <[email protected]>
Date: Tue, 18 Apr 2017 11:43:49 +0100
Subject: [PATCH] regulator: arizona-micsupp: Move pdata into a separate
structure
In preparation for sharing this driver with Madera, move the pdata
for the micsupp regulator out of struct arizona_pdata into a dedicated
pdata struct for this driver. As a result the code in
arizona_micsupp_of_get_pdata() can be made independent of struct arizona.
This patch also updates the definition of struct arizona_pdata and
the use of this pdata in mach-crag6410-module.c
Signed-off-by: Richard Fitzgerald <[email protected]>
Acked-by: Lee Jones <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
MAINTAINERS | 1 +
drivers/regulator/arizona-micsupp.c | 21 +++++++++++----------
include/linux/mfd/arizona/pdata.h | 3 ++-
include/linux/regulator/arizona-micsupp.h | 21 +++++++++++++++++++++
4 files changed, 35 insertions(+), 11 deletions(-)
create mode 100644 include/linux/regulator/arizona-micsupp.h
diff --git a/MAINTAINERS b/MAINTAINERS
index c35e0cea7831..6ed8ef18e7b6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13623,6 +13623,7 @@ F: include/linux/mfd/arizona/
F: include/linux/mfd/wm831x/
F: include/linux/mfd/wm8350/
F: include/linux/mfd/wm8400*
+F: include/linux/regulator/arizona*
F: include/linux/wm97xx.h
F: include/sound/wm????.h
F: sound/soc/codecs/arizona.?
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index 5e38861e71d8..5f8b5a713311 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -30,6 +30,8 @@
#include <linux/mfd/arizona/pdata.h>
#include <linux/mfd/arizona/registers.h>
+#include <linux/regulator/arizona-micsupp.h>
+
struct arizona_micsupp {
struct regulator_dev *regulator;
struct arizona *arizona;
@@ -199,28 +201,26 @@ static const struct regulator_init_data arizona_micsupp_ext_default = {
.num_consumer_supplies = 1,
};
-static int arizona_micsupp_of_get_pdata(struct device *dev,
- struct arizona *arizona,
+static int arizona_micsupp_of_get_pdata(struct arizona_micsupp_pdata *pdata,
struct regulator_config *config,
const struct regulator_desc *desc)
{
- struct arizona_pdata *pdata = &arizona->pdata;
struct arizona_micsupp *micsupp = config->driver_data;
struct device_node *np;
struct regulator_init_data *init_data;
- np = of_get_child_by_name(arizona->dev->of_node, "micvdd");
+ np = of_get_child_by_name(config->dev->of_node, "micvdd");
if (np) {
config->of_node = np;
- init_data = of_get_regulator_init_data(dev, np, desc);
+ init_data = of_get_regulator_init_data(config->dev, np, desc);
if (init_data) {
init_data->consumer_supplies = &micsupp->supply;
init_data->num_consumer_supplies = 1;
- pdata->micvdd = init_data;
+ pdata->init_data = init_data;
}
}
@@ -232,6 +232,7 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
const struct regulator_desc *desc;
struct regulator_config config = { };
+ struct arizona_micsupp_pdata *pdata = &arizona->pdata.micvdd;
struct arizona_micsupp *micsupp;
int ret;
@@ -269,15 +270,15 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
if (IS_ENABLED(CONFIG_OF)) {
if (!dev_get_platdata(arizona->dev)) {
- ret = arizona_micsupp_of_get_pdata(&pdev->dev, arizona,
- &config, desc);
+ ret = arizona_micsupp_of_get_pdata(pdata, &config,
+ desc);
if (ret < 0)
return ret;
}
}
- if (arizona->pdata.micvdd)
- config.init_data = arizona->pdata.micvdd;
+ if (pdata->init_data)
+ config.init_data = pdata->init_data;
else
config.init_data = &micsupp->init_data;
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
index 64faeeff698c..43e875f9850c 100644
--- a/include/linux/mfd/arizona/pdata.h
+++ b/include/linux/mfd/arizona/pdata.h
@@ -12,6 +12,7 @@
#define _ARIZONA_PDATA_H
#include <dt-bindings/mfd/arizona.h>
+#include <linux/regulator/arizona-micsupp.h>
#define ARIZONA_GPN_DIR_MASK 0x8000 /* GPN_DIR */
#define ARIZONA_GPN_DIR_SHIFT 15 /* GPN_DIR */
@@ -79,7 +80,7 @@ struct arizona_pdata {
int ldoena; /** GPIO controlling LODENA, if any */
/** Regulator configuration for MICVDD */
- struct regulator_init_data *micvdd;
+ struct arizona_micsupp_pdata micvdd;
/** Regulator configuration for LDO1 */
struct regulator_init_data *ldo1;
diff --git a/include/linux/regulator/arizona-micsupp.h b/include/linux/regulator/arizona-micsupp.h
new file mode 100644
index 000000000000..616842619c00
--- /dev/null
+++ b/include/linux/regulator/arizona-micsupp.h
@@ -0,0 +1,21 @@
+/*
+ * Platform data for Arizona micsupp regulator
+ *
+ * Copyright 2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef ARIZONA_MICSUPP_H
+#define ARIZONA_MICSUPP_H
+
+struct regulator_init_data;
+
+struct arizona_micsupp_pdata {
+ /** Regulator configuration for micsupp */
+ const struct regulator_init_data *init_data;
+};
+
+#endif
--
2.11.0
The patch
regulator: arizona-micsupp: Make arizona_micsupp independent of struct arizona
has been applied to the regulator tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From e165983e5102c953d68bd935048e95567564e438 Mon Sep 17 00:00:00 2001
From: Richard Fitzgerald <[email protected]>
Date: Tue, 18 Apr 2017 11:43:50 +0100
Subject: [PATCH] regulator: arizona-micsupp: Make arizona_micsupp independent
of struct arizona
In preparation for supporting Madera codecs, remove the dependency on
struct arizona in the regulator callbacks and struct arizona_micsupp.
Signed-off-by: Richard Fitzgerald <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
drivers/regulator/arizona-micsupp.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index 5f8b5a713311..db4fecf228b7 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -34,7 +34,10 @@
struct arizona_micsupp {
struct regulator_dev *regulator;
- struct arizona *arizona;
+ struct regmap *regmap;
+ struct snd_soc_dapm_context **dapm;
+ unsigned int enable_reg;
+ struct device *dev;
struct regulator_consumer_supply supply;
struct regulator_init_data init_data;
@@ -46,21 +49,22 @@ static void arizona_micsupp_check_cp(struct work_struct *work)
{
struct arizona_micsupp *micsupp =
container_of(work, struct arizona_micsupp, check_cp_work);
- struct snd_soc_dapm_context *dapm = micsupp->arizona->dapm;
- struct snd_soc_component *component = snd_soc_dapm_to_component(dapm);
- struct arizona *arizona = micsupp->arizona;
- struct regmap *regmap = arizona->regmap;
- unsigned int reg;
+ struct snd_soc_dapm_context *dapm = *micsupp->dapm;
+ struct snd_soc_component *component;
+ unsigned int val;
int ret;
- ret = regmap_read(regmap, ARIZONA_MIC_CHARGE_PUMP_1, ®);
+ ret = regmap_read(micsupp->regmap, micsupp->enable_reg, &val);
if (ret != 0) {
- dev_err(arizona->dev, "Failed to read CP state: %d\n", ret);
+ dev_err(micsupp->dev,
+ "Failed to read CP state: %d\n", ret);
return;
}
if (dapm) {
- if ((reg & (ARIZONA_CPMIC_ENA | ARIZONA_CPMIC_BYPASS)) ==
+ component = snd_soc_dapm_to_component(dapm);
+
+ if ((val & (ARIZONA_CPMIC_ENA | ARIZONA_CPMIC_BYPASS)) ==
ARIZONA_CPMIC_ENA)
snd_soc_component_force_enable_pin(component,
"MICSUPP");
@@ -240,7 +244,9 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
if (!micsupp)
return -ENOMEM;
- micsupp->arizona = arizona;
+ micsupp->regmap = arizona->regmap;
+ micsupp->dapm = &arizona->dapm;
+ micsupp->dev = arizona->dev;
INIT_WORK(&micsupp->check_cp_work, arizona_micsupp_check_cp);
/*
@@ -263,6 +269,7 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
micsupp->init_data.consumer_supplies = &micsupp->supply;
micsupp->supply.supply = "MICVDD";
micsupp->supply.dev_name = dev_name(arizona->dev);
+ micsupp->enable_reg = desc->enable_reg;
config.dev = arizona->dev;
config.driver_data = micsupp;
--
2.11.0
The patch
regulator: arizona-ldo1: Make arizona_ldo1 independent of struct arizona
has been applied to the regulator tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From 80a55f41aef4ee808f53f1a356491d7eaeefdd3c Mon Sep 17 00:00:00 2001
From: Richard Fitzgerald <[email protected]>
Date: Tue, 18 Apr 2017 11:43:53 +0100
Subject: [PATCH] regulator: arizona-ldo1: Make arizona_ldo1 independent of
struct arizona
In preparation for supporting Madera codecs, remove the dependency on
struct arizona in the regulator callbacks and struct arizona_ldo1.
Signed-off-by: Richard Fitzgerald <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
drivers/regulator/arizona-ldo1.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index f5bc75ab85fa..678f81fda22a 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -33,7 +33,7 @@
struct arizona_ldo1 {
struct regulator_dev *regulator;
- struct arizona *arizona;
+ struct regmap *regmap;
struct regulator_consumer_supply supply;
struct regulator_init_data init_data;
@@ -67,7 +67,7 @@ static int arizona_ldo1_hc_set_voltage_sel(struct regulator_dev *rdev,
unsigned sel)
{
struct arizona_ldo1 *ldo = rdev_get_drvdata(rdev);
- struct regmap *regmap = ldo->arizona->regmap;
+ struct regmap *regmap = ldo->regmap;
unsigned int val;
int ret;
@@ -93,7 +93,7 @@ static int arizona_ldo1_hc_set_voltage_sel(struct regulator_dev *rdev,
static int arizona_ldo1_hc_get_voltage_sel(struct regulator_dev *rdev)
{
struct arizona_ldo1 *ldo = rdev_get_drvdata(rdev);
- struct regmap *regmap = ldo->arizona->regmap;
+ struct regmap *regmap = ldo->regmap;
unsigned int val;
int ret;
@@ -247,7 +247,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
if (!ldo1)
return -ENOMEM;
- ldo1->arizona = arizona;
+ ldo1->regmap = arizona->regmap;
/*
* Since the chip usually supplies itself we provide some
--
2.11.0
The patch
regulator: arizona: Split KConfig options for LDO1 and MICSUPP regulators
has been applied to the regulator tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From 7e6425968bf742b9772aa5bae1250158c9312e31 Mon Sep 17 00:00:00 2001
From: Richard Fitzgerald <[email protected]>
Date: Tue, 18 Apr 2017 11:43:48 +0100
Subject: [PATCH] regulator: arizona: Split KConfig options for LDO1 and
MICSUPP regulators
The CS47L24 Arizona codec and most Madera codecs do not have a LDO1
regulator. Split the LDO1 and MICSUPP regulators into separate KConfig
options so the LDO1 is only built into the kernel if needed.
Signed-off-by: Richard Fitzgerald <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
drivers/regulator/Kconfig | 14 +++++++++++---
drivers/regulator/Makefile | 3 ++-
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index be06eb29c681..c026b09c479c 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -125,12 +125,20 @@ config REGULATOR_AB8500
This driver supports the regulators found on the ST-Ericsson mixed
signal AB8500 PMIC
-config REGULATOR_ARIZONA
- tristate "Wolfson Arizona class devices"
+config REGULATOR_ARIZONA_LDO1
+ tristate "Wolfson Arizona class devices LDO1"
depends on MFD_ARIZONA
depends on SND_SOC
help
- Support for the regulators found on Wolfson Arizona class
+ Support for the LDO1 regulators found on Wolfson Arizona class
+ devices.
+
+config REGULATOR_ARIZONA_MICSUPP
+ tristate "Wolfson Arizona class devices MICSUPP"
+ depends on MFD_ARIZONA
+ depends on SND_SOC
+ help
+ Support for the MICSUPP regulators found on Wolfson Arizona class
devices.
config REGULATOR_AS3711
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index ef7725e2592a..313a7ca97b4d 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -19,7 +19,8 @@ obj-$(CONFIG_REGULATOR_ACT8865) += act8865-regulator.o
obj-$(CONFIG_REGULATOR_ACT8945A) += act8945a-regulator.o
obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
-obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
+obj-$(CONFIG_REGULATOR_ARIZONA_LDO1) += arizona-ldo1.o
+obj-$(CONFIG_REGULATOR_ARIZONA_MICSUPP) += arizona-micsupp.o
obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
--
2.11.0
The patch
regulator: arizona-ldo1: Factor out generic initialization
has been applied to the regulator tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From af367afafb5ba7ae26defd35e4ba42cfe157ef72 Mon Sep 17 00:00:00 2001
From: Richard Fitzgerald <[email protected]>
Date: Tue, 18 Apr 2017 11:43:54 +0100
Subject: [PATCH] regulator: arizona-ldo1: Factor out generic initialization
In preparation for sharing this driver with Madera codecs, factor out
the parts of initialization that aren't dependent on struct arizona.
Signed-off-by: Richard Fitzgerald <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
drivers/regulator/arizona-ldo1.c | 114 ++++++++++++++++++++++-----------------
1 file changed, 66 insertions(+), 48 deletions(-)
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index 678f81fda22a..96fddfff5dc4 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -234,67 +234,40 @@ static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata,
return 0;
}
-static int arizona_ldo1_probe(struct platform_device *pdev)
+static int arizona_ldo1_common_init(struct platform_device *pdev,
+ struct arizona_ldo1 *ldo1,
+ const struct regulator_desc *desc,
+ struct arizona_ldo1_pdata *pdata,
+ bool *external_dcvdd)
{
- struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
- const struct regulator_desc *desc;
+ struct device *parent_dev = pdev->dev.parent;
struct regulator_config config = { };
- struct arizona_ldo1 *ldo1;
- bool external_dcvdd = false;
int ret;
- ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);
- if (!ldo1)
- return -ENOMEM;
-
- ldo1->regmap = arizona->regmap;
-
- /*
- * Since the chip usually supplies itself we provide some
- * default init_data for it. This will be overridden with
- * platform data if provided.
- */
- switch (arizona->type) {
- case WM5102:
- case WM8997:
- case WM8998:
- case WM1814:
- desc = &arizona_ldo1_hc;
- ldo1->init_data = arizona_ldo1_dvfs;
- break;
- case WM5110:
- case WM8280:
- desc = &arizona_ldo1;
- ldo1->init_data = arizona_ldo1_wm5110;
- break;
- default:
- desc = &arizona_ldo1;
- ldo1->init_data = arizona_ldo1_default;
- break;
- }
+ *external_dcvdd = false;
- ldo1->init_data.consumer_supplies = &ldo1->supply;
ldo1->supply.supply = "DCVDD";
- ldo1->supply.dev_name = dev_name(arizona->dev);
+ ldo1->init_data.consumer_supplies = &ldo1->supply;
+ ldo1->supply.dev_name = dev_name(parent_dev);
- config.dev = arizona->dev;
+ config.dev = parent_dev;
config.driver_data = ldo1;
- config.regmap = arizona->regmap;
+ config.regmap = ldo1->regmap;
if (IS_ENABLED(CONFIG_OF)) {
- if (!dev_get_platdata(arizona->dev)) {
- ret = arizona_ldo1_of_get_pdata(&arizona->pdata.ldo1,
+ if (!dev_get_platdata(parent_dev)) {
+ ret = arizona_ldo1_of_get_pdata(pdata,
&config, desc,
- &external_dcvdd);
+ external_dcvdd);
if (ret < 0)
return ret;
}
}
- config.ena_gpio = arizona->pdata.ldo1.ldoena;
+ config.ena_gpio = pdata->ldoena;
- if (arizona->pdata.ldo1.init_data)
- config.init_data = arizona->pdata.ldo1.init_data;
+ if (pdata->init_data)
+ config.init_data = pdata->init_data;
else
config.init_data = &ldo1->init_data;
@@ -303,9 +276,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
* consumers then DCVDD is supplied externally.
*/
if (config.init_data->num_consumer_supplies == 0)
- arizona->external_dcvdd = true;
- else
- arizona->external_dcvdd = external_dcvdd;
+ *external_dcvdd = true;
ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config);
@@ -313,7 +284,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
if (IS_ERR(ldo1->regulator)) {
ret = PTR_ERR(ldo1->regulator);
- dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n",
+ dev_err(&pdev->dev, "Failed to register LDO1 supply: %d\n",
ret);
return ret;
}
@@ -323,6 +294,53 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
return 0;
}
+static int arizona_ldo1_probe(struct platform_device *pdev)
+{
+ struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
+ struct arizona_ldo1 *ldo1;
+ const struct regulator_desc *desc;
+ bool external_dcvdd;
+ int ret;
+
+ ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);
+ if (!ldo1)
+ return -ENOMEM;
+
+ ldo1->regmap = arizona->regmap;
+
+ /*
+ * Since the chip usually supplies itself we provide some
+ * default init_data for it. This will be overridden with
+ * platform data if provided.
+ */
+ switch (arizona->type) {
+ case WM5102:
+ case WM8997:
+ case WM8998:
+ case WM1814:
+ desc = &arizona_ldo1_hc;
+ ldo1->init_data = arizona_ldo1_dvfs;
+ break;
+ case WM5110:
+ case WM8280:
+ desc = &arizona_ldo1;
+ ldo1->init_data = arizona_ldo1_wm5110;
+ break;
+ default:
+ desc = &arizona_ldo1;
+ ldo1->init_data = arizona_ldo1_default;
+ break;
+ }
+
+ ret = arizona_ldo1_common_init(pdev, ldo1, desc,
+ &arizona->pdata.ldo1,
+ &external_dcvdd);
+ if (ret == 0)
+ arizona->external_dcvdd = external_dcvdd;
+
+ return ret;
+}
+
static struct platform_driver arizona_ldo1_driver = {
.probe = arizona_ldo1_probe,
.driver = {
--
2.11.0
The patch
regulator: arizona-ldo1: Move pdata into a separate structure
has been applied to the regulator tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From aaa84e6a0399df374634c42590e644a698fcc3ff Mon Sep 17 00:00:00 2001
From: Richard Fitzgerald <[email protected]>
Date: Tue, 18 Apr 2017 11:43:52 +0100
Subject: [PATCH] regulator: arizona-ldo1: Move pdata into a separate structure
In preparation for sharing this driver with Madera, move the pdata
for the LDO1 regulator out of struct arizona_pdata into a dedicated
pdata struct for this driver. As a result the code in
arizona_ldo1_of_get_pdata() can be made independent of struct arizona.
This patch also updates the definition of struct arizona_pdata and
the use of this pdata in mach-crag6410-module.c
Signed-off-by: Richard Fitzgerald <[email protected]>
Acked-by: Krzysztof Kozlowski <[email protected]>
Acked-by: Lee Jones <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
arch/arm/mach-s3c64xx/mach-crag6410-module.c | 8 ++++--
drivers/regulator/arizona-ldo1.c | 39 +++++++++++++++-------------
include/linux/mfd/arizona/pdata.h | 4 +--
include/linux/regulator/arizona-ldo1.h | 24 +++++++++++++++++
4 files changed, 53 insertions(+), 22 deletions(-)
create mode 100644 include/linux/regulator/arizona-ldo1.h
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
index ccc3ab8d58e7..ea5f2169c850 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
@@ -209,7 +209,9 @@ static const struct i2c_board_info wm1277_devs[] = {
};
static struct arizona_pdata wm5102_reva_pdata = {
- .ldoena = S3C64XX_GPN(7),
+ .ldo1 = {
+ .ldoena = S3C64XX_GPN(7),
+ },
.gpio_base = CODEC_GPIO_BASE,
.irq_flags = IRQF_TRIGGER_HIGH,
.micd_pol_gpio = CODEC_GPIO_BASE + 4,
@@ -239,7 +241,9 @@ static struct spi_board_info wm5102_reva_spi_devs[] = {
};
static struct arizona_pdata wm5102_pdata = {
- .ldoena = S3C64XX_GPN(7),
+ .ldo1 = {
+ .ldoena = S3C64XX_GPN(7),
+ },
.gpio_base = CODEC_GPIO_BASE,
.irq_flags = IRQF_TRIGGER_HIGH,
.micd_pol_gpio = CODEC_GPIO_BASE + 2,
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index b726fa17f7b2..f5bc75ab85fa 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -25,6 +25,8 @@
#include <linux/gpio.h>
#include <linux/slab.h>
+#include <linux/regulator/arizona-ldo1.h>
+
#include <linux/mfd/arizona/core.h>
#include <linux/mfd/arizona/pdata.h>
#include <linux/mfd/arizona/registers.h>
@@ -186,20 +188,19 @@ static const struct regulator_init_data arizona_ldo1_wm5110 = {
.num_consumer_supplies = 1,
};
-static int arizona_ldo1_of_get_pdata(struct device *dev,
- struct arizona *arizona,
+static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata,
struct regulator_config *config,
- const struct regulator_desc *desc)
+ const struct regulator_desc *desc,
+ bool *external_dcvdd)
{
- struct arizona_pdata *pdata = &arizona->pdata;
struct arizona_ldo1 *ldo1 = config->driver_data;
- struct device_node *np = arizona->dev->of_node;
+ struct device_node *np = config->dev->of_node;
struct device_node *init_node, *dcvdd_node;
struct regulator_init_data *init_data;
pdata->ldoena = of_get_named_gpio(np, "wlf,ldoena", 0);
if (pdata->ldoena < 0) {
- dev_warn(arizona->dev,
+ dev_warn(config->dev,
"LDOENA GPIO property missing/malformed: %d\n",
pdata->ldoena);
pdata->ldoena = 0;
@@ -213,19 +214,19 @@ static int arizona_ldo1_of_get_pdata(struct device *dev,
if (init_node) {
config->of_node = init_node;
- init_data = of_get_regulator_init_data(dev, init_node, desc);
-
+ init_data = of_get_regulator_init_data(config->dev, init_node,
+ desc);
if (init_data) {
init_data->consumer_supplies = &ldo1->supply;
init_data->num_consumer_supplies = 1;
if (dcvdd_node && dcvdd_node != init_node)
- arizona->external_dcvdd = true;
+ *external_dcvdd = true;
- pdata->ldo1 = init_data;
+ pdata->init_data = init_data;
}
} else if (dcvdd_node) {
- arizona->external_dcvdd = true;
+ *external_dcvdd = true;
}
of_node_put(dcvdd_node);
@@ -239,10 +240,9 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
const struct regulator_desc *desc;
struct regulator_config config = { };
struct arizona_ldo1 *ldo1;
+ bool external_dcvdd = false;
int ret;
- arizona->external_dcvdd = false;
-
ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);
if (!ldo1)
return -ENOMEM;
@@ -283,17 +283,18 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
if (IS_ENABLED(CONFIG_OF)) {
if (!dev_get_platdata(arizona->dev)) {
- ret = arizona_ldo1_of_get_pdata(&pdev->dev, arizona,
- &config, desc);
+ ret = arizona_ldo1_of_get_pdata(&arizona->pdata.ldo1,
+ &config, desc,
+ &external_dcvdd);
if (ret < 0)
return ret;
}
}
- config.ena_gpio = arizona->pdata.ldoena;
+ config.ena_gpio = arizona->pdata.ldo1.ldoena;
- if (arizona->pdata.ldo1)
- config.init_data = arizona->pdata.ldo1;
+ if (arizona->pdata.ldo1.init_data)
+ config.init_data = arizona->pdata.ldo1.init_data;
else
config.init_data = &ldo1->init_data;
@@ -303,6 +304,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
*/
if (config.init_data->num_consumer_supplies == 0)
arizona->external_dcvdd = true;
+ else
+ arizona->external_dcvdd = external_dcvdd;
ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config);
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
index 43e875f9850c..bfeecf179895 100644
--- a/include/linux/mfd/arizona/pdata.h
+++ b/include/linux/mfd/arizona/pdata.h
@@ -12,6 +12,7 @@
#define _ARIZONA_PDATA_H
#include <dt-bindings/mfd/arizona.h>
+#include <linux/regulator/arizona-ldo1.h>
#include <linux/regulator/arizona-micsupp.h>
#define ARIZONA_GPN_DIR_MASK 0x8000 /* GPN_DIR */
@@ -77,13 +78,12 @@ struct arizona_micd_range {
struct arizona_pdata {
int reset; /** GPIO controlling /RESET, if any */
- int ldoena; /** GPIO controlling LODENA, if any */
/** Regulator configuration for MICVDD */
struct arizona_micsupp_pdata micvdd;
/** Regulator configuration for LDO1 */
- struct regulator_init_data *ldo1;
+ struct arizona_ldo1_pdata ldo1;
/** If a direct 32kHz clock is provided on an MCLK specify it here */
int clk32k_src;
diff --git a/include/linux/regulator/arizona-ldo1.h b/include/linux/regulator/arizona-ldo1.h
new file mode 100644
index 000000000000..c685f1277c63
--- /dev/null
+++ b/include/linux/regulator/arizona-ldo1.h
@@ -0,0 +1,24 @@
+/*
+ * Platform data for Arizona LDO1 regulator
+ *
+ * Copyright 2017 Cirrus Logic
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef ARIZONA_LDO1_H
+#define ARIZONA_LDO1_H
+
+struct regulator_init_data;
+
+struct arizona_ldo1_pdata {
+ /** GPIO controlling LDOENA, if any */
+ int ldoena;
+
+ /** Regulator configuration for LDO1 */
+ const struct regulator_init_data *init_data;
+};
+
+#endif
--
2.11.0
The patch
regulator: arizona-micsupp: Factor out generic initialization
has been applied to the regulator tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From 7d8d14b51921cbfe082a796e55c22d0c1dd8fc26 Mon Sep 17 00:00:00 2001
From: Richard Fitzgerald <[email protected]>
Date: Tue, 18 Apr 2017 11:43:51 +0100
Subject: [PATCH] regulator: arizona-micsupp: Factor out generic initialization
In preparation for sharing this driver with Madera codecs, factor out
the parts of initialization that aren't dependent on struct arizona.
Signed-off-by: Richard Fitzgerald <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
drivers/regulator/arizona-micsupp.c | 82 +++++++++++++++++++++----------------
1 file changed, 46 insertions(+), 36 deletions(-)
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index db4fecf228b7..120de94caf02 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -231,52 +231,27 @@ static int arizona_micsupp_of_get_pdata(struct arizona_micsupp_pdata *pdata,
return 0;
}
-static int arizona_micsupp_probe(struct platform_device *pdev)
+static int arizona_micsupp_common_init(struct platform_device *pdev,
+ struct arizona_micsupp *micsupp,
+ const struct regulator_desc *desc,
+ struct arizona_micsupp_pdata *pdata)
{
- struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
- const struct regulator_desc *desc;
struct regulator_config config = { };
- struct arizona_micsupp_pdata *pdata = &arizona->pdata.micvdd;
- struct arizona_micsupp *micsupp;
int ret;
- micsupp = devm_kzalloc(&pdev->dev, sizeof(*micsupp), GFP_KERNEL);
- if (!micsupp)
- return -ENOMEM;
-
- micsupp->regmap = arizona->regmap;
- micsupp->dapm = &arizona->dapm;
- micsupp->dev = arizona->dev;
INIT_WORK(&micsupp->check_cp_work, arizona_micsupp_check_cp);
- /*
- * Since the chip usually supplies itself we provide some
- * default init_data for it. This will be overridden with
- * platform data if provided.
- */
- switch (arizona->type) {
- case WM5110:
- case WM8280:
- desc = &arizona_micsupp_ext;
- micsupp->init_data = arizona_micsupp_ext_default;
- break;
- default:
- desc = &arizona_micsupp;
- micsupp->init_data = arizona_micsupp_default;
- break;
- }
-
micsupp->init_data.consumer_supplies = &micsupp->supply;
micsupp->supply.supply = "MICVDD";
- micsupp->supply.dev_name = dev_name(arizona->dev);
+ micsupp->supply.dev_name = dev_name(micsupp->dev);
micsupp->enable_reg = desc->enable_reg;
- config.dev = arizona->dev;
+ config.dev = micsupp->dev;
config.driver_data = micsupp;
- config.regmap = arizona->regmap;
+ config.regmap = micsupp->regmap;
if (IS_ENABLED(CONFIG_OF)) {
- if (!dev_get_platdata(arizona->dev)) {
+ if (!dev_get_platdata(micsupp->dev)) {
ret = arizona_micsupp_of_get_pdata(pdata, &config,
desc);
if (ret < 0)
@@ -289,8 +264,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
else
config.init_data = &micsupp->init_data;
- /* Default to regulated mode until the API supports bypass */
- regmap_update_bits(arizona->regmap, ARIZONA_MIC_CHARGE_PUMP_1,
+ /* Default to regulated mode */
+ regmap_update_bits(micsupp->regmap, micsupp->enable_reg,
ARIZONA_CPMIC_BYPASS, 0);
micsupp->regulator = devm_regulator_register(&pdev->dev,
@@ -301,7 +276,7 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
if (IS_ERR(micsupp->regulator)) {
ret = PTR_ERR(micsupp->regulator);
- dev_err(arizona->dev, "Failed to register mic supply: %d\n",
+ dev_err(micsupp->dev, "Failed to register mic supply: %d\n",
ret);
return ret;
}
@@ -311,6 +286,41 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
return 0;
}
+static int arizona_micsupp_probe(struct platform_device *pdev)
+{
+ struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
+ const struct regulator_desc *desc;
+ struct arizona_micsupp *micsupp;
+
+ micsupp = devm_kzalloc(&pdev->dev, sizeof(*micsupp), GFP_KERNEL);
+ if (!micsupp)
+ return -ENOMEM;
+
+ micsupp->regmap = arizona->regmap;
+ micsupp->dapm = &arizona->dapm;
+ micsupp->dev = arizona->dev;
+
+ /*
+ * Since the chip usually supplies itself we provide some
+ * default init_data for it. This will be overridden with
+ * platform data if provided.
+ */
+ switch (arizona->type) {
+ case WM5110:
+ case WM8280:
+ desc = &arizona_micsupp_ext;
+ micsupp->init_data = arizona_micsupp_ext_default;
+ break;
+ default:
+ desc = &arizona_micsupp;
+ micsupp->init_data = arizona_micsupp_default;
+ break;
+ }
+
+ return arizona_micsupp_common_init(pdev, micsupp, desc,
+ &arizona->pdata.micvdd);
+}
+
static struct platform_driver arizona_micsupp_driver = {
.probe = arizona_micsupp_probe,
.driver = {
--
2.11.0