Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1234109 > unrolled thread
| Started by | Richard Fitzgerald <rf@opensource.wolfsonmicro.com> |
|---|---|
| First post | 2015-09-28 14:50 +0200 |
| Last post | 2015-09-28 14:50 +0200 |
| Articles | 6 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 0/6 RESEND] mfd: arizona: Various improvements and refactoring Richard Fitzgerald <rf@opensource.wolfsonmicro.com> - 2015-09-28 14:50 +0200
[PATCH 5/6 RESEND] mfd: arizona: Remove use of codec build config #ifdefs Richard Fitzgerald <rf@opensource.wolfsonmicro.com> - 2015-09-28 14:50 +0200
Re: [PATCH 5/6 RESEND] mfd: arizona: Remove use of codec build config #ifdefs Lee Jones <lee.jones@linaro.org> - 2015-10-01 13:50 +0200
Re: [PATCH 5/6 RESEND] mfd: arizona: Remove use of codec build config #ifdefs Charles Keepax <ckeepax@opensource.wolfsonmicro.com> - 2015-10-02 11:50 +0200
[PATCH 1/6 RESEND] mfd: arizona: factor out DCVDD isolation control Richard Fitzgerald <rf@opensource.wolfsonmicro.com> - 2015-09-28 14:50 +0200
[PATCH 2/6 RESEND] mfd: arizona: factor out checking of jack detection state Richard Fitzgerald <rf@opensource.wolfsonmicro.com> - 2015-09-28 14:50 +0200
| From | Richard Fitzgerald <rf@opensource.wolfsonmicro.com> |
|---|---|
| Date | 2015-09-28 14:50 +0200 |
| Subject | [PATCH 0/6 RESEND] mfd: arizona: Various improvements and refactoring |
| Message-ID | <qdG2u-5Zh-7@gated-at.bofh.it> |
This selection of patches fixes review comments from the CS47L24 driver review that were requests for changes in the general Arizona code, plus a couple of preparatory patches that factor out some code into functions. I will rebase the CS47L24 driver patch on top of these. This patch set is based on Lee Jones's for-mfd-next branch Richard Fitzgerald (6): mfd: arizona: factor out DCVDD isolation control mfd: arizona: factor out checking of jack detection state mfd: arizona: Downgrade type mismatch messages to dev_warn() mfd: arizona: Simplify adding subdevices mfd: arizona: Remove use of codec build config #ifdefs mfd: arizona: use correct type ID for device tree config drivers/mfd/arizona-core.c | 228 +++++++++++++++++++++++++++------------------ drivers/mfd/arizona-i2c.c | 33 +++---- drivers/mfd/arizona-spi.c | 23 +++-- 3 files changed, 166 insertions(+), 118 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Richard Fitzgerald <rf@opensource.wolfsonmicro.com> |
|---|---|
| Date | 2015-09-28 14:50 +0200 |
| Subject | [PATCH 5/6 RESEND] mfd: arizona: Remove use of codec build config #ifdefs |
| Message-ID | <qdG2v-5Zh-35@gated-at.bofh.it> |
| In reply to | #1234109 |
Remove the use of #ifdefs around each case statement of the chip ID
and type validation switches.
We must ensure that the contained code still compiles to nothing if
support for that codec was not built into the kernel, to prevent
creation of link references to missing functions. So the ifdefs are
replaced with a use of the IS_ENABLED() macro.
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
---
drivers/mfd/arizona-core.c | 29 +++++++++++++++++++++--------
drivers/mfd/arizona-i2c.c | 28 +++++++++++++++-------------
drivers/mfd/arizona-spi.c | 18 +++++++++++-------
3 files changed, 47 insertions(+), 28 deletions(-)
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 2512192..cc2117e 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -1130,22 +1130,26 @@ int arizona_dev_init(struct arizona *arizona)
arizona->rev &= ARIZONA_DEVICE_REVISION_MASK;
switch (reg) {
-#ifdef CONFIG_MFD_WM5102
case 0x5102:
+ if (!IS_ENABLED(CONFIG_MFD_WM5102))
+ break;
+
type_name = "WM5102";
if (arizona->type != WM5102) {
dev_warn(arizona->dev, "WM5102 registered as %d\n",
arizona->type);
arizona->type = WM5102;
}
+
apply_patch = wm5102_patch;
arizona->rev &= 0x7;
subdevs = wm5102_devs;
n_subdevs = ARRAY_SIZE(wm5102_devs);
break;
-#endif
-#ifdef CONFIG_MFD_WM5110
case 0x5110:
+ if (!IS_ENABLED(CONFIG_MFD_WM5110))
+ break;
+
switch (arizona->type) {
case WM5110:
type_name = "WM5110";
@@ -1160,26 +1164,30 @@ int arizona_dev_init(struct arizona *arizona)
arizona->type = WM5110;
break;
}
+
apply_patch = wm5110_patch;
subdevs = wm5110_devs;
n_subdevs = ARRAY_SIZE(wm5110_devs);
break;
-#endif
-#ifdef CONFIG_MFD_WM8997
case 0x8997:
+ if (!IS_ENABLED(CONFIG_MFD_WM8997))
+ break;
+
type_name = "WM8997";
if (arizona->type != WM8997) {
dev_warn(arizona->dev, "WM8997 registered as %d\n",
arizona->type);
arizona->type = WM8997;
}
+
apply_patch = wm8997_patch;
subdevs = wm8997_devs;
n_subdevs = ARRAY_SIZE(wm8997_devs);
break;
-#endif
-#ifdef CONFIG_MFD_WM8998
case 0x6349:
+ if (!IS_ENABLED(CONFIG_MFD_WM8998))
+ break;
+
switch (arizona->type) {
case WM8998:
type_name = "WM8998";
@@ -1200,12 +1208,17 @@ int arizona_dev_init(struct arizona *arizona)
subdevs = wm8998_devs;
n_subdevs = ARRAY_SIZE(wm8998_devs);
break;
-#endif
default:
dev_err(arizona->dev, "Unknown device ID %x\n", reg);
goto err_reset;
}
+ if (!subdevs) {
+ dev_err(arizona->dev,
+ "No kernel support for device ID %x\n", reg);
+ goto err_reset;
+ }
+
dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A');
if (apply_patch) {
diff --git a/drivers/mfd/arizona-i2c.c b/drivers/mfd/arizona-i2c.c
index cea1b40..914bdce 100644
--- a/drivers/mfd/arizona-i2c.c
+++ b/drivers/mfd/arizona-i2c.c
@@ -27,7 +27,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct arizona *arizona;
- const struct regmap_config *regmap_config;
+ const struct regmap_config *regmap_config = NULL;
unsigned long type;
int ret;
@@ -37,34 +37,36 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
type = id->driver_data;
switch (type) {
-#ifdef CONFIG_MFD_WM5102
case WM5102:
- regmap_config = &wm5102_i2c_regmap;
+ if (IS_ENABLED(CONFIG_MFD_WM5102))
+ regmap_config = &wm5102_i2c_regmap;
break;
-#endif
-#ifdef CONFIG_MFD_WM5110
case WM5110:
case WM8280:
- regmap_config = &wm5110_i2c_regmap;
+ if (IS_ENABLED(CONFIG_MFD_WM5110))
+ regmap_config = &wm5110_i2c_regmap;
break;
-#endif
-#ifdef CONFIG_MFD_WM8997
case WM8997:
- regmap_config = &wm8997_i2c_regmap;
+ if (IS_ENABLED(CONFIG_MFD_WM8997))
+ regmap_config = &wm8997_i2c_regmap;
break;
-#endif
-#ifdef CONFIG_MFD_WM8998
case WM8998:
case WM1814:
- regmap_config = &wm8998_i2c_regmap;
+ if (IS_ENABLED(CONFIG_MFD_WM8998))
+ regmap_config = &wm8998_i2c_regmap;
break;
-#endif
default:
dev_err(&i2c->dev, "Unknown device type %ld\n",
id->driver_data);
return -EINVAL;
}
+ if (!regmap_config) {
+ dev_err(&i2c->dev,
+ "No kernel support for device type %ld\n", type);
+ return -EINVAL;
+ }
+
arizona = devm_kzalloc(&i2c->dev, sizeof(*arizona), GFP_KERNEL);
if (arizona == NULL)
return -ENOMEM;
diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c
index 1e845f6..850a63a 100644
--- a/drivers/mfd/arizona-spi.c
+++ b/drivers/mfd/arizona-spi.c
@@ -27,7 +27,7 @@ static int arizona_spi_probe(struct spi_device *spi)
{
const struct spi_device_id *id = spi_get_device_id(spi);
struct arizona *arizona;
- const struct regmap_config *regmap_config;
+ const struct regmap_config *regmap_config = NULL;
unsigned long type;
int ret;
@@ -37,23 +37,27 @@ static int arizona_spi_probe(struct spi_device *spi)
type = id->driver_data;
switch (type) {
-#ifdef CONFIG_MFD_WM5102
case WM5102:
- regmap_config = &wm5102_spi_regmap;
+ if (IS_ENABLED(CONFIG_MFD_WM5102))
+ regmap_config = &wm5102_spi_regmap;
break;
-#endif
-#ifdef CONFIG_MFD_WM5110
case WM5110:
case WM8280:
- regmap_config = &wm5110_spi_regmap;
+ if (IS_ENABLED(CONFIG_MFD_WM5110))
+ regmap_config = &wm5110_spi_regmap;
break;
-#endif
default:
dev_err(&spi->dev, "Unknown device type %ld\n",
id->driver_data);
return -EINVAL;
}
+ if (!regmap_config) {
+ dev_err(&spi->dev,
+ "No kernel support for device type %ld\n", type);
+ return -EINVAL;
+ }
+
arizona = devm_kzalloc(&spi->dev, sizeof(*arizona), GFP_KERNEL);
if (arizona == NULL)
return -ENOMEM;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Lee Jones <lee.jones@linaro.org> |
|---|---|
| Date | 2015-10-01 13:50 +0200 |
| Subject | Re: [PATCH 5/6 RESEND] mfd: arizona: Remove use of codec build config #ifdefs |
| Message-ID | <qeKx4-2WG-25@gated-at.bofh.it> |
| In reply to | #1234110 |
On Mon, 28 Sep 2015, Richard Fitzgerald wrote:
> Remove the use of #ifdefs around each case statement of the chip ID
> and type validation switches.
>
> We must ensure that the contained code still compiles to nothing if
> support for that codec was not built into the kernel, to prevent
> creation of link references to missing functions. So the ifdefs are
> replaced with a use of the IS_ENABLED() macro.
>
> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> ---
> drivers/mfd/arizona-core.c | 29 +++++++++++++++++++++--------
> drivers/mfd/arizona-i2c.c | 28 +++++++++++++++-------------
> drivers/mfd/arizona-spi.c | 18 +++++++++++-------
> 3 files changed, 47 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index 2512192..cc2117e 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -1130,22 +1130,26 @@ int arizona_dev_init(struct arizona *arizona)
> arizona->rev &= ARIZONA_DEVICE_REVISION_MASK;
>
> switch (reg) {
> -#ifdef CONFIG_MFD_WM5102
> case 0x5102:
> + if (!IS_ENABLED(CONFIG_MFD_WM5102))
> + break;
> +
Are you sure this statement effects the code below?
I'm not sure it will. How have you tested it?
> type_name = "WM5102";
> if (arizona->type != WM5102) {
> dev_warn(arizona->dev, "WM5102 registered as %d\n",
> arizona->type);
> arizona->type = WM5102;
> }
> +
> apply_patch = wm5102_patch;
> arizona->rev &= 0x7;
> subdevs = wm5102_devs;
> n_subdevs = ARRAY_SIZE(wm5102_devs);
> break;
> -#endif
> -#ifdef CONFIG_MFD_WM5110
> case 0x5110:
> + if (!IS_ENABLED(CONFIG_MFD_WM5110))
> + break;
> +
> switch (arizona->type) {
> case WM5110:
> type_name = "WM5110";
> @@ -1160,26 +1164,30 @@ int arizona_dev_init(struct arizona *arizona)
> arizona->type = WM5110;
> break;
> }
> +
> apply_patch = wm5110_patch;
> subdevs = wm5110_devs;
> n_subdevs = ARRAY_SIZE(wm5110_devs);
> break;
> -#endif
> -#ifdef CONFIG_MFD_WM8997
> case 0x8997:
> + if (!IS_ENABLED(CONFIG_MFD_WM8997))
> + break;
> +
> type_name = "WM8997";
> if (arizona->type != WM8997) {
> dev_warn(arizona->dev, "WM8997 registered as %d\n",
> arizona->type);
> arizona->type = WM8997;
> }
> +
> apply_patch = wm8997_patch;
> subdevs = wm8997_devs;
> n_subdevs = ARRAY_SIZE(wm8997_devs);
> break;
> -#endif
> -#ifdef CONFIG_MFD_WM8998
> case 0x6349:
> + if (!IS_ENABLED(CONFIG_MFD_WM8998))
> + break;
> +
> switch (arizona->type) {
> case WM8998:
> type_name = "WM8998";
> @@ -1200,12 +1208,17 @@ int arizona_dev_init(struct arizona *arizona)
> subdevs = wm8998_devs;
> n_subdevs = ARRAY_SIZE(wm8998_devs);
> break;
> -#endif
> default:
> dev_err(arizona->dev, "Unknown device ID %x\n", reg);
> goto err_reset;
> }
>
> + if (!subdevs) {
> + dev_err(arizona->dev,
> + "No kernel support for device ID %x\n", reg);
> + goto err_reset;
> + }
> +
> dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A');
>
> if (apply_patch) {
> diff --git a/drivers/mfd/arizona-i2c.c b/drivers/mfd/arizona-i2c.c
> index cea1b40..914bdce 100644
> --- a/drivers/mfd/arizona-i2c.c
> +++ b/drivers/mfd/arizona-i2c.c
> @@ -27,7 +27,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
> const struct i2c_device_id *id)
> {
> struct arizona *arizona;
> - const struct regmap_config *regmap_config;
> + const struct regmap_config *regmap_config = NULL;
> unsigned long type;
> int ret;
>
> @@ -37,34 +37,36 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
> type = id->driver_data;
>
> switch (type) {
> -#ifdef CONFIG_MFD_WM5102
> case WM5102:
> - regmap_config = &wm5102_i2c_regmap;
> + if (IS_ENABLED(CONFIG_MFD_WM5102))
> + regmap_config = &wm5102_i2c_regmap;
> break;
> -#endif
> -#ifdef CONFIG_MFD_WM5110
> case WM5110:
> case WM8280:
> - regmap_config = &wm5110_i2c_regmap;
> + if (IS_ENABLED(CONFIG_MFD_WM5110))
> + regmap_config = &wm5110_i2c_regmap;
> break;
> -#endif
> -#ifdef CONFIG_MFD_WM8997
> case WM8997:
> - regmap_config = &wm8997_i2c_regmap;
> + if (IS_ENABLED(CONFIG_MFD_WM8997))
> + regmap_config = &wm8997_i2c_regmap;
> break;
> -#endif
> -#ifdef CONFIG_MFD_WM8998
> case WM8998:
> case WM1814:
> - regmap_config = &wm8998_i2c_regmap;
> + if (IS_ENABLED(CONFIG_MFD_WM8998))
> + regmap_config = &wm8998_i2c_regmap;
> break;
> -#endif
> default:
> dev_err(&i2c->dev, "Unknown device type %ld\n",
> id->driver_data);
> return -EINVAL;
> }
>
> + if (!regmap_config) {
> + dev_err(&i2c->dev,
> + "No kernel support for device type %ld\n", type);
> + return -EINVAL;
> + }
> +
> arizona = devm_kzalloc(&i2c->dev, sizeof(*arizona), GFP_KERNEL);
> if (arizona == NULL)
> return -ENOMEM;
> diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c
> index 1e845f6..850a63a 100644
> --- a/drivers/mfd/arizona-spi.c
> +++ b/drivers/mfd/arizona-spi.c
> @@ -27,7 +27,7 @@ static int arizona_spi_probe(struct spi_device *spi)
> {
> const struct spi_device_id *id = spi_get_device_id(spi);
> struct arizona *arizona;
> - const struct regmap_config *regmap_config;
> + const struct regmap_config *regmap_config = NULL;
> unsigned long type;
> int ret;
>
> @@ -37,23 +37,27 @@ static int arizona_spi_probe(struct spi_device *spi)
> type = id->driver_data;
>
> switch (type) {
> -#ifdef CONFIG_MFD_WM5102
> case WM5102:
> - regmap_config = &wm5102_spi_regmap;
> + if (IS_ENABLED(CONFIG_MFD_WM5102))
> + regmap_config = &wm5102_spi_regmap;
> break;
> -#endif
> -#ifdef CONFIG_MFD_WM5110
> case WM5110:
> case WM8280:
> - regmap_config = &wm5110_spi_regmap;
> + if (IS_ENABLED(CONFIG_MFD_WM5110))
> + regmap_config = &wm5110_spi_regmap;
> break;
> -#endif
> default:
> dev_err(&spi->dev, "Unknown device type %ld\n",
> id->driver_data);
> return -EINVAL;
> }
>
> + if (!regmap_config) {
> + dev_err(&spi->dev,
> + "No kernel support for device type %ld\n", type);
> + return -EINVAL;
> + }
> +
> arizona = devm_kzalloc(&spi->dev, sizeof(*arizona), GFP_KERNEL);
> if (arizona == NULL)
> return -ENOMEM;
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Charles Keepax <ckeepax@opensource.wolfsonmicro.com> |
|---|---|
| Date | 2015-10-02 11:50 +0200 |
| Subject | Re: [PATCH 5/6 RESEND] mfd: arizona: Remove use of codec build config #ifdefs |
| Message-ID | <qf58u-83i-25@gated-at.bofh.it> |
| In reply to | #1237308 |
On Thu, Oct 01, 2015 at 12:44:52PM +0100, Lee Jones wrote:
> On Mon, 28 Sep 2015, Richard Fitzgerald wrote:
>
> > Remove the use of #ifdefs around each case statement of the chip ID
> > and type validation switches.
> >
> > We must ensure that the contained code still compiles to nothing if
> > support for that codec was not built into the kernel, to prevent
> > creation of link references to missing functions. So the ifdefs are
> > replaced with a use of the IS_ENABLED() macro.
> >
> > Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> > ---
> > drivers/mfd/arizona-core.c | 29 +++++++++++++++++++++--------
> > drivers/mfd/arizona-i2c.c | 28 +++++++++++++++-------------
> > drivers/mfd/arizona-spi.c | 18 +++++++++++-------
> > 3 files changed, 47 insertions(+), 28 deletions(-)
> >
> > diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> > index 2512192..cc2117e 100644
> > --- a/drivers/mfd/arizona-core.c
> > +++ b/drivers/mfd/arizona-core.c
> > @@ -1130,22 +1130,26 @@ int arizona_dev_init(struct arizona *arizona)
> > arizona->rev &= ARIZONA_DEVICE_REVISION_MASK;
> >
> > switch (reg) {
> > -#ifdef CONFIG_MFD_WM5102
> > case 0x5102:
> > + if (!IS_ENABLED(CONFIG_MFD_WM5102))
> > + break;
> > +
>
> Are you sure this statement effects the code below?
>
> I'm not sure it will. How have you tested it?
Yeah looking at that again I am not sure that is going to cause
that code to be elimated either. Richard is on holiday this week
and next. I will try to find time to have a look at this today.
Thanks,
Charles
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Richard Fitzgerald <rf@opensource.wolfsonmicro.com> |
|---|---|
| Date | 2015-09-28 14:50 +0200 |
| Subject | [PATCH 1/6 RESEND] mfd: arizona: factor out DCVDD isolation control |
| Message-ID | <qdG2v-5Zh-29@gated-at.bofh.it> |
| In reply to | #1234109 |
Currently DCVDD isolation is enabled and disabled for
runtime_suspend and runtime_resume. Future codecs will not
have the isolation control so to prepare for these codecs
this patch factors out the isolation control allowing it to
be called as needed in the existing codec-specific switch cases.
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
---
drivers/mfd/arizona-core.c | 108 ++++++++++++++++++++++++++-------------------
1 file changed, 62 insertions(+), 46 deletions(-)
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 908c69b..6dd47a7 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -462,6 +462,33 @@ static int wm5102_clear_write_sequencer(struct arizona *arizona)
}
#ifdef CONFIG_PM
+static int arizona_isolate_dcvdd(struct arizona *arizona)
+{
+ int ret;
+
+ ret = regmap_update_bits(arizona->regmap,
+ ARIZONA_ISOLATION_CONTROL,
+ ARIZONA_ISOLATE_DCVDD1,
+ ARIZONA_ISOLATE_DCVDD1);
+ if (ret != 0)
+ dev_err(arizona->dev, "Failed to isolate DCVDD: %d\n", ret);
+
+ return ret;
+}
+
+static int arizona_connect_dcvdd(struct arizona *arizona)
+{
+ int ret;
+
+ ret = regmap_update_bits(arizona->regmap,
+ ARIZONA_ISOLATION_CONTROL,
+ ARIZONA_ISOLATE_DCVDD1, 0);
+ if (ret != 0)
+ dev_err(arizona->dev, "Failed to connect DCVDD: %d\n", ret);
+
+ return ret;
+}
+
static int arizona_runtime_resume(struct device *dev)
{
struct arizona *arizona = dev_get_drvdata(dev);
@@ -501,14 +528,9 @@ static int arizona_runtime_resume(struct device *dev)
switch (arizona->type) {
case WM5102:
if (arizona->external_dcvdd) {
- ret = regmap_update_bits(arizona->regmap,
- ARIZONA_ISOLATION_CONTROL,
- ARIZONA_ISOLATE_DCVDD1, 0);
- if (ret != 0) {
- dev_err(arizona->dev,
- "Failed to connect DCVDD: %d\n", ret);
+ ret = arizona_connect_dcvdd(arizona);
+ if (ret != 0)
goto err;
- }
}
ret = wm5102_patch(arizona);
@@ -533,14 +555,9 @@ static int arizona_runtime_resume(struct device *dev)
goto err;
if (arizona->external_dcvdd) {
- ret = regmap_update_bits(arizona->regmap,
- ARIZONA_ISOLATION_CONTROL,
- ARIZONA_ISOLATE_DCVDD1, 0);
- if (ret) {
- dev_err(arizona->dev,
- "Failed to connect DCVDD: %d\n", ret);
+ ret = arizona_connect_dcvdd(arizona);
+ if (ret != 0)
goto err;
- }
} else {
/*
* As this is only called for the internal regulator
@@ -571,14 +588,9 @@ static int arizona_runtime_resume(struct device *dev)
goto err;
if (arizona->external_dcvdd) {
- ret = regmap_update_bits(arizona->regmap,
- ARIZONA_ISOLATION_CONTROL,
- ARIZONA_ISOLATE_DCVDD1, 0);
- if (ret != 0) {
- dev_err(arizona->dev,
- "Failed to connect DCVDD: %d\n", ret);
+ ret = arizona_connect_dcvdd(arizona);
+ if (ret != 0)
goto err;
- }
}
break;
}
@@ -611,37 +623,36 @@ static int arizona_runtime_suspend(struct device *dev)
return ret;
}
- if (arizona->external_dcvdd) {
- ret = regmap_update_bits(arizona->regmap,
- ARIZONA_ISOLATION_CONTROL,
- ARIZONA_ISOLATE_DCVDD1,
- ARIZONA_ISOLATE_DCVDD1);
- if (ret != 0) {
- dev_err(arizona->dev, "Failed to isolate DCVDD: %d\n",
- ret);
- return ret;
- }
- }
-
switch (arizona->type) {
case WM5110:
case WM8280:
- if (arizona->external_dcvdd)
- break;
-
- /*
- * As this is only called for the internal regulator
- * (where we know voltage ranges available) it is ok
- * to request an exact range.
- */
- ret = regulator_set_voltage(arizona->dcvdd, 1175000, 1175000);
- if (ret < 0) {
- dev_err(arizona->dev,
- "Failed to set suspend voltage: %d\n", ret);
- return ret;
+ if (arizona->external_dcvdd) {
+ ret = arizona_isolate_dcvdd(arizona);
+ if (ret != 0)
+ return ret;
+ } else {
+ /*
+ * As this is only called for the internal regulator
+ * (where we know voltage ranges available) it is ok
+ * to request an exact range.
+ */
+ ret = regulator_set_voltage(arizona->dcvdd,
+ 1175000, 1175000);
+ if (ret < 0) {
+ dev_err(arizona->dev,
+ "Failed to set suspend voltage: %d\n",
+ ret);
+ return ret;
+ }
}
break;
case WM5102:
+ if (arizona->external_dcvdd) {
+ ret = arizona_isolate_dcvdd(arizona);
+ if (ret != 0)
+ return ret;
+ }
+
if (!(val & ARIZONA_JD1_ENA)) {
ret = regmap_write(arizona->regmap,
ARIZONA_WRITE_SEQUENCER_CTRL_3, 0x0);
@@ -654,6 +665,11 @@ static int arizona_runtime_suspend(struct device *dev)
}
break;
default:
+ if (arizona->external_dcvdd) {
+ ret = arizona_isolate_dcvdd(arizona);
+ if (ret != 0)
+ return ret;
+ }
break;
}
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Richard Fitzgerald <rf@opensource.wolfsonmicro.com> |
|---|---|
| Date | 2015-09-28 14:50 +0200 |
| Subject | [PATCH 2/6 RESEND] mfd: arizona: factor out checking of jack detection state |
| Message-ID | <qdG2v-5Zh-31@gated-at.bofh.it> |
| In reply to | #1234109 |
Currently runtime_suspend will fully power off the codec if
the jack detection is not enabled. Not all future codecs will
have jack detection so to prepare for these codecs this patch
factors out the check so that it be called as needed in the
existing codec-specific switch cases.
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
---
drivers/mfd/arizona-core.c | 41 ++++++++++++++++++++++++++++++++---------
1 file changed, 32 insertions(+), 9 deletions(-)
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 6dd47a7..73d26dd 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -489,6 +489,23 @@ static int arizona_connect_dcvdd(struct arizona *arizona)
return ret;
}
+static int arizona_is_jack_det_active(struct arizona *arizona)
+{
+ unsigned int val;
+ int ret;
+
+ ret = regmap_read(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE, &val);
+ if (ret) {
+ dev_err(arizona->dev,
+ "Failed to check jack det status: %d\n", ret);
+ return ret;
+ } else if (val & ARIZONA_JD1_ENA) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
static int arizona_runtime_resume(struct device *dev)
{
struct arizona *arizona = dev_get_drvdata(dev);
@@ -612,20 +629,18 @@ err:
static int arizona_runtime_suspend(struct device *dev)
{
struct arizona *arizona = dev_get_drvdata(dev);
- unsigned int val;
+ unsigned int jd_active = 0;
int ret;
dev_dbg(arizona->dev, "Entering AoD mode\n");
- ret = regmap_read(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE, &val);
- if (ret) {
- dev_err(dev, "Failed to check jack det status: %d\n", ret);
- return ret;
- }
-
switch (arizona->type) {
case WM5110:
case WM8280:
+ jd_active = arizona_is_jack_det_active(arizona);
+ if (jd_active < 0)
+ return jd_active;
+
if (arizona->external_dcvdd) {
ret = arizona_isolate_dcvdd(arizona);
if (ret != 0)
@@ -647,13 +662,17 @@ static int arizona_runtime_suspend(struct device *dev)
}
break;
case WM5102:
+ jd_active = arizona_is_jack_det_active(arizona);
+ if (jd_active < 0)
+ return jd_active;
+
if (arizona->external_dcvdd) {
ret = arizona_isolate_dcvdd(arizona);
if (ret != 0)
return ret;
}
- if (!(val & ARIZONA_JD1_ENA)) {
+ if (!jd_active) {
ret = regmap_write(arizona->regmap,
ARIZONA_WRITE_SEQUENCER_CTRL_3, 0x0);
if (ret) {
@@ -665,6 +684,10 @@ static int arizona_runtime_suspend(struct device *dev)
}
break;
default:
+ jd_active = arizona_is_jack_det_active(arizona);
+ if (jd_active < 0)
+ return jd_active;
+
if (arizona->external_dcvdd) {
ret = arizona_isolate_dcvdd(arizona);
if (ret != 0)
@@ -678,7 +701,7 @@ static int arizona_runtime_suspend(struct device *dev)
regulator_disable(arizona->dcvdd);
/* Allow us to completely power down if no jack detection */
- if (!(val & ARIZONA_JD1_ENA)) {
+ if (!jd_active) {
dev_dbg(arizona->dev, "Fully powering off\n");
arizona->has_fully_powered_off = true;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web