All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] ASoC: cs42l52: Add DeviceTree Support for CS42L52
@ 2013-11-13 15:44 Brian Austin
       [not found] ` <1384357474-28653-1-git-send-email-brian.austin-jGc1dHjMKG3QT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 16+ messages in thread
From: Brian Austin @ 2013-11-13 15:44 UTC (permalink / raw)
  To: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	broonie-DgEjT+Ai2ygdnm+yROfE0A, lgirdwood-Re5JQEeQqe8AvxtiuMwx3w,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, mark.rutland-5wv7dgnIgG8,
	Brian Austin

This patch adds device tree support for the CS42L52 CODEC

v2 changes dt bindings to use '-' instead of '_'.
reset_gpio = reset-gpio. Pdata variables are not changed.

Signed-off-by: Brian Austin <brian.austin-jGc1dHjMKG3QT0dZR+AlfA@public.gmane.org>
---
 sound/soc/codecs/cs42l52.c | 51 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 49 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index 8b427c9..ea55ee5 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -17,7 +17,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/of_gpio.h>
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/input.h>
@@ -1174,6 +1174,7 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client,
 	struct cs42l52_private *cs42l52;
 	struct cs42l52_platform_data *pdata = dev_get_platdata(&i2c_client->dev);
 	int ret;
+	u32 val32;
 	unsigned int devid = 0;
 	unsigned int reg;
 
@@ -1190,8 +1191,47 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client,
 		return ret;
 	}
 
-	if (pdata)
+	if (pdata) {
 		cs42l52->pdata = *pdata;
+	} else {
+		pdata = devm_kzalloc(&i2c_client->dev,
+				     sizeof(struct cs42l52_platform_data),
+				GFP_KERNEL);
+		if (!pdata) {
+			dev_err(&i2c_client->dev, "could not allocate pdata\n");
+			return -ENOMEM;
+		}
+		if (i2c_client->dev.of_node) {
+			if (of_property_read_u32(i2c_client->dev.of_node,
+				"mica-cfg", &val32) >= 0)
+				pdata->mica_cfg = val32;
+
+			if (of_property_read_u32(i2c_client->dev.of_node,
+				"micb-cfg", &val32) >= 0)
+				pdata->micb_cfg = val32;
+
+			if (of_property_read_u32(i2c_client->dev.of_node,
+				"mica-sel", &val32) >= 0)
+				pdata->mica_sel = val32;
+
+			if (of_property_read_u32(i2c_client->dev.of_node,
+				"micb-sel", &val32) >= 0)
+				pdata->micb_sel = val32;
+
+			if (of_property_read_u32(i2c_client->dev.of_node,
+				"micbias-lvl", &val32) >= 0)
+				pdata->micbias_lvl = val32;
+
+			if (of_property_read_u32(i2c_client->dev.of_node,
+				"chgfreq", &val32) >= 0)
+				pdata->chgfreq = val32;
+
+			pdata->reset_gpio =
+				of_get_named_gpio(i2c_client->dev.of_node,
+						"reset-gpio", 0);
+		}
+		cs42l52->pdata = *pdata;
+	}
 
 	if (cs42l52->pdata.reset_gpio) {
 		ret = gpio_request_one(cs42l52->pdata.reset_gpio,
@@ -1274,6 +1314,12 @@ static int cs42l52_i2c_remove(struct i2c_client *client)
 	return 0;
 }
 
+static const struct of_device_id cs42l52_of_match[] = {
+	{ .compatible = "cirrus,cs42l52", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, cs42l52_of_match);
+
 static const struct i2c_device_id cs42l52_id[] = {
 	{ "cs42l52", 0 },
 	{ }
@@ -1284,6 +1330,7 @@ static struct i2c_driver cs42l52_i2c_driver = {
 	.driver = {
 		.name = "cs42l52",
 		.owner = THIS_MODULE,
+		.of_match_table = cs42l52_of_match,
 	},
 	.id_table = cs42l52_id,
 	.probe =    cs42l52_i2c_probe,
-- 
1.8.4.rc3


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2013-11-13 20:24 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-13 15:44 [PATCH v2 1/2] ASoC: cs42l52: Add DeviceTree Support for CS42L52 Brian Austin
     [not found] ` <1384357474-28653-1-git-send-email-brian.austin-jGc1dHjMKG3QT0dZR+AlfA@public.gmane.org>
2013-11-13 15:44   ` [PATCH v2 2/2] dt: binding: sound cs42l52 driver Brian Austin
     [not found]     ` <1384357474-28653-2-git-send-email-brian.austin-jGc1dHjMKG3QT0dZR+AlfA@public.gmane.org>
2013-11-13 15:53       ` Kumar Gala
     [not found]         ` <9097292C-9233-49B3-995D-27574D544237-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2013-11-13 16:21           ` Brian Austin
2013-11-13 16:33       ` Tomasz Figa
2013-11-13 16:43         ` Mark Brown
     [not found]           ` <20131113164328.GW878-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-11-13 16:47             ` Tomasz Figa
2013-11-13 18:16               ` Mark Brown
     [not found]                 ` <20131113181622.GZ878-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-11-13 18:24                   ` Tomasz Figa
2013-11-13 19:49                     ` Mark Brown
     [not found]                       ` <20131113194915.GF878-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-11-13 20:13                         ` Tomasz Figa
2013-11-13 18:58         ` Brian Austin
     [not found]           ` <alpine.DEB.2.10.1311131248290.28828-QCF2GsvuTPME07tKKVU2gpqQE7yCjDx5@public.gmane.org>
2013-11-13 19:01             ` Tomasz Figa
2013-11-13 19:10               ` Brian Austin
     [not found]                 ` <alpine.DEB.2.10.1311131306150.28828-QCF2GsvuTPME07tKKVU2gpqQE7yCjDx5@public.gmane.org>
2013-11-13 19:29                   ` Tomasz Figa
2013-11-13 20:24                     ` Brian Austin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.