diff mbox

[v2] ASoC: rt5645: Add the device tree parser

Message ID 1434091656-12800-1-git-send-email-oder_chiou@realtek.com (mailing list archive)
State Accepted
Commit 48edaa4b4fb6e75b890942394f0d0c2571d5c90d
Headers show

Commit Message

Oder Chiou June 12, 2015, 6:47 a.m. UTC
Modify the RT5645 driver to parse platform data from device tree. This is
missing from previous patch in sound/soc/codecs/rt5645.c, that was present
in v3.

Signed-off-by: Bard Liao <bardliao@realtek.com>
Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
---
 sound/soc/codecs/rt5645.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

Comments

Mark Brown June 12, 2015, 10:30 a.m. UTC | #1
On Fri, Jun 12, 2015 at 02:47:36PM +0800, Oder Chiou wrote:
> Modify the RT5645 driver to parse platform data from device tree. This is
> missing from previous patch in sound/soc/codecs/rt5645.c, that was present
> in v3.

Applied, thanks.
diff mbox

Patch

diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 7d04b1a..1884264 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -3231,6 +3231,20 @@  static struct dmi_system_id dmi_platform_intel_braswell[] = {
 	{ }
 };
 
+static int rt5645_parse_dt(struct rt5645_priv *rt5645, struct device *dev)
+{
+	rt5645->pdata.in2_diff = device_property_read_bool(dev,
+		"realtek,in2-differential");
+	device_property_read_u32(dev,
+		"realtek,dmic1-data-pin", &rt5645->pdata.dmic1_data_pin);
+	device_property_read_u32(dev,
+		"realtek,dmic2-data-pin", &rt5645->pdata.dmic2_data_pin);
+	device_property_read_u32(dev,
+		"realtek,jd-mode", &rt5645->pdata.jd_mode);
+
+	return 0;
+}
+
 static int rt5645_i2c_probe(struct i2c_client *i2c,
 		    const struct i2c_device_id *id)
 {
@@ -3247,13 +3261,12 @@  static int rt5645_i2c_probe(struct i2c_client *i2c,
 	rt5645->i2c = i2c;
 	i2c_set_clientdata(i2c, rt5645);
 
-	if (pdata) {
+	if (pdata)
 		rt5645->pdata = *pdata;
-	} else {
-		if (dmi_check_system(dmi_platform_intel_braswell)) {
-			rt5645->pdata = *rt5645_pdata;
-		}
-	}
+	else if (dmi_check_system(dmi_platform_intel_braswell))
+		rt5645->pdata = *rt5645_pdata;
+	else
+		rt5645_parse_dt(rt5645, &i2c->dev);
 
 	rt5645->gpiod_hp_det = devm_gpiod_get(&i2c->dev, "hp-detect", GPIOD_IN);