aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/cs42l52.c
diff options
context:
space:
mode:
authorBrian Austin <brian.austin@cirrus.com>2013-11-15 10:35:33 -0500
committerMark Brown <broonie@linaro.org>2013-11-28 05:57:01 -0500
commit391fc59db87615e07e8a6ab5fbffe3cc04f2b19c (patch)
tree2f8fa05c3126cf5ea30d56b7549a4c2af15fd058 /sound/soc/codecs/cs42l52.c
parent44b2ed54036ecec36ad27adf356f0274a72e5f05 (diff)
ASoC: cs42l52: Add devicetree support for CS42L52
This patch adds device tree support for the CS42L52 Codec Signed-off-by: Brian Austin <brian.austin@cirrus.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/codecs/cs42l52.c')
-rw-r--r--sound/soc/codecs/cs42l52.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index 78d2dd669e89..4a47a634f376 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -17,7 +17,7 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/gpio.h> 20#include <linux/of_gpio.h>
21#include <linux/pm.h> 21#include <linux/pm.h>
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <linux/input.h> 23#include <linux/input.h>
@@ -1193,6 +1193,7 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client,
1193 int ret; 1193 int ret;
1194 unsigned int devid = 0; 1194 unsigned int devid = 0;
1195 unsigned int reg; 1195 unsigned int reg;
1196 u32 val32;
1196 1197
1197 cs42l52 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l52_private), 1198 cs42l52 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l52_private),
1198 GFP_KERNEL); 1199 GFP_KERNEL);
@@ -1206,9 +1207,39 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client,
1206 dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); 1207 dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret);
1207 return ret; 1208 return ret;
1208 } 1209 }
1209 1210 if (pdata) {
1210 if (pdata) 1211 cs42l52->pdata = *pdata;
1212 } else {
1213 pdata = devm_kzalloc(&i2c_client->dev,
1214 sizeof(struct cs42l52_platform_data),
1215 GFP_KERNEL);
1216 if (!pdata) {
1217 dev_err(&i2c_client->dev, "could not allocate pdata\n");
1218 return -ENOMEM;
1219 }
1220 if (i2c_client->dev.of_node) {
1221 if (of_property_read_bool(i2c_client->dev.of_node,
1222 "cirrus,mica-differential-cfg"))
1223 pdata->mica_diff_cfg = true;
1224
1225 if (of_property_read_bool(i2c_client->dev.of_node,
1226 "cirrus,micb-differential-cfg"))
1227 pdata->micb_diff_cfg = true;
1228
1229 if (of_property_read_u32(i2c_client->dev.of_node,
1230 "cirrus,micbias-lvl", &val32) >= 0)
1231 pdata->micbias_lvl = val32;
1232
1233 if (of_property_read_u32(i2c_client->dev.of_node,
1234 "cirrus,chgfreq-divisor", &val32) >= 0)
1235 pdata->chgfreq_divisor = val32;
1236
1237 pdata->reset_gpio =
1238 of_get_named_gpio(i2c_client->dev.of_node,
1239 "cirrus,reset-gpio", 0);
1240 }
1211 cs42l52->pdata = *pdata; 1241 cs42l52->pdata = *pdata;
1242 }
1212 1243
1213 if (cs42l52->pdata.reset_gpio) { 1244 if (cs42l52->pdata.reset_gpio) {
1214 ret = gpio_request_one(cs42l52->pdata.reset_gpio, 1245 ret = gpio_request_one(cs42l52->pdata.reset_gpio,
@@ -1280,6 +1311,13 @@ static int cs42l52_i2c_remove(struct i2c_client *client)
1280 return 0; 1311 return 0;
1281} 1312}
1282 1313
1314static const struct of_device_id cs42l52_of_match[] = {
1315 { .compatible = "cirrus,cs42l52", },
1316 {},
1317};
1318MODULE_DEVICE_TABLE(of, cs42l52_of_match);
1319
1320
1283static const struct i2c_device_id cs42l52_id[] = { 1321static const struct i2c_device_id cs42l52_id[] = {
1284 { "cs42l52", 0 }, 1322 { "cs42l52", 0 },
1285 { } 1323 { }
@@ -1290,6 +1328,7 @@ static struct i2c_driver cs42l52_i2c_driver = {
1290 .driver = { 1328 .driver = {
1291 .name = "cs42l52", 1329 .name = "cs42l52",
1292 .owner = THIS_MODULE, 1330 .owner = THIS_MODULE,
1331 .of_match_table = cs42l52_of_match,
1293 }, 1332 },
1294 .id_table = cs42l52_id, 1333 .id_table = cs42l52_id,
1295 .probe = cs42l52_i2c_probe, 1334 .probe = cs42l52_i2c_probe,