Commit 0e54153b authored by Adam Thomson's avatar Adam Thomson Committed by Mark Brown

ASoC: da7213: Update driver to use device_property* FW functions

The driver now supports ACPI based initialisation as well as DT
and old pdata methods. However the FW data handling still uses
DT specific calls to read firmware data (of_property*) so for
ACPI based initialisation the FW data will only be set to default
values. This patch updates the FW handling to use device_property*
calls instead so that both ACPI and DT are handled as expected.
Signed-off-by: default avatarAdam Thomson <Adam.Thomson.Opensource@diasemi.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 14f814fb
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
*/ */
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/of_device.h>
#include <linux/property.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/i2c.h> #include <linux/i2c.h>
...@@ -1606,12 +1608,12 @@ static enum da7213_dmic_clk_rate ...@@ -1606,12 +1608,12 @@ static enum da7213_dmic_clk_rate
} }
static struct da7213_platform_data static struct da7213_platform_data
*da7213_of_to_pdata(struct snd_soc_codec *codec) *da7213_fw_to_pdata(struct snd_soc_codec *codec)
{ {
struct device_node *np = codec->dev->of_node; struct device *dev = codec->dev;
struct da7213_platform_data *pdata; struct da7213_platform_data *pdata;
const char *of_str; const char *fw_str;
u32 of_val32; u32 fw_val32;
pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL); pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata) { if (!pdata) {
...@@ -1619,29 +1621,29 @@ static struct da7213_platform_data ...@@ -1619,29 +1621,29 @@ static struct da7213_platform_data
return NULL; return NULL;
} }
if (of_property_read_u32(np, "dlg,micbias1-lvl", &of_val32) >= 0) if (device_property_read_u32(dev, "dlg,micbias1-lvl", &fw_val32) >= 0)
pdata->micbias1_lvl = da7213_of_micbias_lvl(codec, of_val32); pdata->micbias1_lvl = da7213_of_micbias_lvl(codec, fw_val32);
else else
pdata->micbias1_lvl = DA7213_MICBIAS_2_2V; pdata->micbias1_lvl = DA7213_MICBIAS_2_2V;
if (of_property_read_u32(np, "dlg,micbias2-lvl", &of_val32) >= 0) if (device_property_read_u32(dev, "dlg,micbias2-lvl", &fw_val32) >= 0)
pdata->micbias2_lvl = da7213_of_micbias_lvl(codec, of_val32); pdata->micbias2_lvl = da7213_of_micbias_lvl(codec, fw_val32);
else else
pdata->micbias2_lvl = DA7213_MICBIAS_2_2V; pdata->micbias2_lvl = DA7213_MICBIAS_2_2V;
if (!of_property_read_string(np, "dlg,dmic-data-sel", &of_str)) if (!device_property_read_string(dev, "dlg,dmic-data-sel", &fw_str))
pdata->dmic_data_sel = da7213_of_dmic_data_sel(codec, of_str); pdata->dmic_data_sel = da7213_of_dmic_data_sel(codec, fw_str);
else else
pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL; pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL;
if (!of_property_read_string(np, "dlg,dmic-samplephase", &of_str)) if (!device_property_read_string(dev, "dlg,dmic-samplephase", &fw_str))
pdata->dmic_samplephase = pdata->dmic_samplephase =
da7213_of_dmic_samplephase(codec, of_str); da7213_of_dmic_samplephase(codec, fw_str);
else else
pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE; pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE;
if (of_property_read_u32(np, "dlg,dmic-clkrate", &of_val32) >= 0) if (device_property_read_u32(dev, "dlg,dmic-clkrate", &fw_val32) >= 0)
pdata->dmic_clk_rate = da7213_of_dmic_clkrate(codec, of_val32); pdata->dmic_clk_rate = da7213_of_dmic_clkrate(codec, fw_val32);
else else
pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ; pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ;
...@@ -1713,10 +1715,9 @@ static int da7213_probe(struct snd_soc_codec *codec) ...@@ -1713,10 +1715,9 @@ static int da7213_probe(struct snd_soc_codec *codec)
DA7213_LINE_AMP_OE, DA7213_LINE_AMP_OE); DA7213_LINE_AMP_OE, DA7213_LINE_AMP_OE);
/* Handle DT/Platform data */ /* Handle DT/Platform data */
if (codec->dev->of_node)
da7213->pdata = da7213_of_to_pdata(codec);
else
da7213->pdata = dev_get_platdata(codec->dev); da7213->pdata = dev_get_platdata(codec->dev);
if (!da7213->pdata)
da7213->pdata = da7213_fw_to_pdata(codec);
/* Set platform data values */ /* Set platform data values */
if (da7213->pdata) { if (da7213->pdata) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment