2018-07-21 00:13:47

by Daniel Kurtz

[permalink] [raw]
Subject: [PATCH] ASoC: da7219: Allow pdata to specify a VDDIO

Some systems do not have software controllable regulators driving the
DA7219's supplies, nor can they use device tree to create "always-on fixed
regulators" to easily pretend like they do.

On these systems the call to devm_regulator_bulk_get() just creates
a set of dummy registers. Calling regulator_get_voltage() on a dummy
regulator just returns -EINVAL, in which case the DA7219 is always set up
to use the default VDDIO voltage range of 2.5-3.6V.

Provide a new device property to let such systems specify a different
VDDIO if needed (e.g., 1.8V).

Signed-off-by: Daniel Kurtz <[email protected]>
---

This patch tries to solve the same problem as in the following patches,
but does so in a way that doesn't require registering fixed regulators in
the audio machine-driver:
https://patchwork.kernel.org/patch/10531097 & 10531099
https://patchwork.kernel.org/patch/10536023/

include/sound/da7219.h | 2 ++
sound/soc/codecs/da7219.c | 19 +++++++++++++------
2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/include/sound/da7219.h b/include/sound/da7219.h
index 1bfcb16f2d10ab..16ab125ad4adbf 100644
--- a/include/sound/da7219.h
+++ b/include/sound/da7219.h
@@ -38,6 +38,8 @@ struct da7219_pdata {

const char *dai_clks_name;

+ u32 vddio;
+
/* Mic */
enum da7219_micbias_voltage micbias_lvl;
enum da7219_mic_amp_in_sel mic_amp_in_sel;
diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c
index 980a6a8bf56d38..d8f202c57f958d 100644
--- a/sound/soc/codecs/da7219.c
+++ b/sound/soc/codecs/da7219.c
@@ -1634,6 +1634,9 @@ static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_component *compone
else
pdata->mic_amp_in_sel = DA7219_MIC_AMP_IN_SEL_DIFF;

+ if (!device_property_read_string(dev, "dlg,vddio", &of_val32))
+ pdata->vddio = of_val32;
+
return pdata;
}

@@ -1717,8 +1720,12 @@ static int da7219_handle_supplies(struct snd_soc_component *component)
/* Determine VDDIO voltage provided */
vddio = da7219->supplies[DA7219_SUPPLY_VDDIO].consumer;
ret = regulator_get_voltage(vddio);
+ /* If regulator_get_voltage() fails, try to use vddio from pdata. */
+ if (ret < 0 && da7219->pdata)
+ ret = da7219->pdata->vddio;
if (ret < 1200000)
- dev_warn(component->dev, "Invalid VDDIO voltage\n");
+ dev_warn(component->dev, "Invalid VDDIO voltage: %d mV\n",
+ ret);
else if (ret < 2800000)
io_voltage_lvl = DA7219_IO_VOLTAGE_LEVEL_1_2V_2_8V;

@@ -1872,6 +1879,11 @@ static int da7219_probe(struct snd_soc_component *component)
mutex_init(&da7219->ctrl_lock);
mutex_init(&da7219->pll_lock);

+ /* Handle DT/ACPI/Platform data */
+ da7219->pdata = dev_get_platdata(component->dev);
+ if (!da7219->pdata)
+ da7219->pdata = da7219_fw_to_pdata(component);
+
/* Regulator configuration */
ret = da7219_handle_supplies(component);
if (ret)
@@ -1897,11 +1909,6 @@ static int da7219_probe(struct snd_soc_component *component)
break;
}

- /* Handle DT/ACPI/Platform data */
- da7219->pdata = dev_get_platdata(component->dev);
- if (!da7219->pdata)
- da7219->pdata = da7219_fw_to_pdata(component);
-
da7219_handle_pdata(component);

/* Check if MCLK provided */
--
2.18.0.233.g985f88cf7e-goog



2018-07-21 01:24:21

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] ASoC: da7219: Allow pdata to specify a VDDIO

Hi Daniel,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[also build test ERROR on v4.18-rc5 next-20180720]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Daniel-Kurtz/ASoC-da7219-Allow-pdata-to-specify-a-VDDIO/20180721-082411
base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: x86_64-randconfig-x011-201828 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

All errors (new ones prefixed by >>):

sound/soc/codecs/da7219.c: In function 'da7219_fw_to_pdata':
>> sound/soc/codecs/da7219.c:1637:53: error: passing argument 3 of 'device_property_read_string' from incompatible pointer type [-Werror=incompatible-pointer-types]
if (!device_property_read_string(dev, "dlg,vddio", &of_val32))
^
In file included from include/linux/acpi.h:28:0,
from sound/soc/codecs/da7219.c:14:
include/linux/property.h:49:5: note: expected 'const char **' but argument is of type 'u32 * {aka unsigned int *}'
int device_property_read_string(struct device *dev, const char *propname,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +/device_property_read_string +1637 sound/soc/codecs/da7219.c

1607
1608 static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_component *component)
1609 {
1610 struct device *dev = component->dev;
1611 struct da7219_pdata *pdata;
1612 const char *of_str;
1613 u32 of_val32;
1614
1615 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
1616 if (!pdata)
1617 return NULL;
1618
1619 pdata->wakeup_source = device_property_read_bool(dev, "wakeup-source");
1620
1621 pdata->dai_clks_name = "da7219-dai-clks";
1622 if (device_property_read_string(dev, "clock-output-names",
1623 &pdata->dai_clks_name))
1624 dev_warn(dev, "Using default clk name: %s\n",
1625 pdata->dai_clks_name);
1626
1627 if (device_property_read_u32(dev, "dlg,micbias-lvl", &of_val32) >= 0)
1628 pdata->micbias_lvl = da7219_fw_micbias_lvl(dev, of_val32);
1629 else
1630 pdata->micbias_lvl = DA7219_MICBIAS_2_2V;
1631
1632 if (!device_property_read_string(dev, "dlg,mic-amp-in-sel", &of_str))
1633 pdata->mic_amp_in_sel = da7219_fw_mic_amp_in_sel(dev, of_str);
1634 else
1635 pdata->mic_amp_in_sel = DA7219_MIC_AMP_IN_SEL_DIFF;
1636
> 1637 if (!device_property_read_string(dev, "dlg,vddio", &of_val32))
1638 pdata->vddio = of_val32;
1639
1640 return pdata;
1641 }
1642

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (2.96 kB)
.config.gz (33.90 kB)
Download all attachments

2018-07-21 03:20:20

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] ASoC: da7219: Allow pdata to specify a VDDIO

Hi Daniel,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on asoc/for-next]
[also build test WARNING on v4.18-rc5 next-20180720]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Daniel-Kurtz/ASoC-da7219-Allow-pdata-to-specify-a-VDDIO/20180721-082411
base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: i386-randconfig-sb0-07210849 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

All warnings (new ones prefixed by >>):

sound/soc//codecs/da7219.c: In function 'da7219_fw_to_pdata':
>> sound/soc//codecs/da7219.c:1637:53: warning: passing argument 3 of 'device_property_read_string' from incompatible pointer type
if (!device_property_read_string(dev, "dlg,vddio", &of_val32))
^
In file included from include/linux/acpi.h:28:0,
from sound/soc//codecs/da7219.c:14:
include/linux/property.h:49:5: note: expected 'const char **' but argument is of type 'u32 *'
int device_property_read_string(struct device *dev, const char *propname,
^

vim +/device_property_read_string +1637 sound/soc//codecs/da7219.c

1607
1608 static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_component *component)
1609 {
1610 struct device *dev = component->dev;
1611 struct da7219_pdata *pdata;
1612 const char *of_str;
1613 u32 of_val32;
1614
1615 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
1616 if (!pdata)
1617 return NULL;
1618
1619 pdata->wakeup_source = device_property_read_bool(dev, "wakeup-source");
1620
1621 pdata->dai_clks_name = "da7219-dai-clks";
1622 if (device_property_read_string(dev, "clock-output-names",
1623 &pdata->dai_clks_name))
1624 dev_warn(dev, "Using default clk name: %s\n",
1625 pdata->dai_clks_name);
1626
1627 if (device_property_read_u32(dev, "dlg,micbias-lvl", &of_val32) >= 0)
1628 pdata->micbias_lvl = da7219_fw_micbias_lvl(dev, of_val32);
1629 else
1630 pdata->micbias_lvl = DA7219_MICBIAS_2_2V;
1631
1632 if (!device_property_read_string(dev, "dlg,mic-amp-in-sel", &of_str))
1633 pdata->mic_amp_in_sel = da7219_fw_mic_amp_in_sel(dev, of_str);
1634 else
1635 pdata->mic_amp_in_sel = DA7219_MIC_AMP_IN_SEL_DIFF;
1636
> 1637 if (!device_property_read_string(dev, "dlg,vddio", &of_val32))
1638 pdata->vddio = of_val32;
1639
1640 return pdata;
1641 }
1642

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (2.85 kB)
.config.gz (27.21 kB)
Download all attachments

2018-07-21 03:39:16

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] ASoC: da7219: Allow pdata to specify a VDDIO

Hi Daniel,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on asoc/for-next]
[also build test WARNING on v4.18-rc5 next-20180720]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Daniel-Kurtz/ASoC-da7219-Allow-pdata-to-specify-a-VDDIO/20180721-082411
base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

sound/soc/codecs/da7219.c:440:44: sparse: cast to restricted __le16
sound/soc/codecs/da7219.c:461:13: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [unsigned] [usertype] val @@ got short [unsigned] [usertype] val @@
sound/soc/codecs/da7219.c:461:13: expected unsigned short [unsigned] [usertype] val
sound/soc/codecs/da7219.c:461:13: got restricted __le16 [usertype] <noident>
sound/soc/codecs/da7219.c:817:57: sparse: dubious: x & !y
sound/soc/codecs/da7219.c:1427:16: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [unsigned] [usertype] offset @@ got short [unsigned] [usertype] offset @@
sound/soc/codecs/da7219.c:1427:16: expected unsigned short [unsigned] [usertype] offset
sound/soc/codecs/da7219.c:1427:16: got restricted __le16 [usertype] <noident>
>> sound/soc/codecs/da7219.c:1637:61: sparse: incorrect type in argument 3 (different base types) @@ expected char const **val @@ got uchar const **val @@
sound/soc/codecs/da7219.c:1637:61: expected char const **val
sound/soc/codecs/da7219.c:1637:61: got unsigned int *<noident>
sound/soc/codecs/da7219.c: In function 'da7219_fw_to_pdata':
sound/soc/codecs/da7219.c:1637:53: error: passing argument 3 of 'device_property_read_string' from incompatible pointer type [-Werror=incompatible-pointer-types]
if (!device_property_read_string(dev, "dlg,vddio", &of_val32))
^
In file included from include/linux/acpi.h:28:0,
from sound/soc/codecs/da7219.c:14:
include/linux/property.h:49:5: note: expected 'const char **' but argument is of type 'u32 * {aka unsigned int *}'
int device_property_read_string(struct device *dev, const char *propname,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +1637 sound/soc/codecs/da7219.c

1607
1608 static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_component *component)
1609 {
1610 struct device *dev = component->dev;
1611 struct da7219_pdata *pdata;
1612 const char *of_str;
1613 u32 of_val32;
1614
1615 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
1616 if (!pdata)
1617 return NULL;
1618
1619 pdata->wakeup_source = device_property_read_bool(dev, "wakeup-source");
1620
1621 pdata->dai_clks_name = "da7219-dai-clks";
1622 if (device_property_read_string(dev, "clock-output-names",
1623 &pdata->dai_clks_name))
1624 dev_warn(dev, "Using default clk name: %s\n",
1625 pdata->dai_clks_name);
1626
1627 if (device_property_read_u32(dev, "dlg,micbias-lvl", &of_val32) >= 0)
1628 pdata->micbias_lvl = da7219_fw_micbias_lvl(dev, of_val32);
1629 else
1630 pdata->micbias_lvl = DA7219_MICBIAS_2_2V;
1631
1632 if (!device_property_read_string(dev, "dlg,mic-amp-in-sel", &of_str))
1633 pdata->mic_amp_in_sel = da7219_fw_mic_amp_in_sel(dev, of_str);
1634 else
1635 pdata->mic_amp_in_sel = DA7219_MIC_AMP_IN_SEL_DIFF;
1636
> 1637 if (!device_property_read_string(dev, "dlg,vddio", &of_val32))
1638 pdata->vddio = of_val32;
1639
1640 return pdata;
1641 }
1642

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation