diff options
author | Brian Austin <brian.austin@cirrus.com> | 2013-10-18 15:30:01 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-10-20 13:15:44 -0400 |
commit | 7b09eea52939d2b979f19de40e34b8670feff4c5 (patch) | |
tree | 06271708558f7f5882cdea7d0607a4f04c2e5543 /sound/soc/codecs/cs42l73.c | |
parent | f9ca060680e7c26a88d990ad9370572274b0d54b (diff) |
ASoC: cs42l73: Add Device Tree support for CS42L73
This patch adds support for device tree for the CS42L73 CODEC
Signed-off-by: Brian Austin <brian.austin@cirrus.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/codecs/cs42l73.c')
-rw-r--r-- | sound/soc/codecs/cs42l73.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c index 89efc3c6aefc..549d5d6a3fef 100644 --- a/sound/soc/codecs/cs42l73.c +++ b/sound/soc/codecs/cs42l73.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/regmap.h> | 23 | #include <linux/regmap.h> |
@@ -1416,6 +1416,7 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, | |||
1416 | int ret; | 1416 | int ret; |
1417 | unsigned int devid = 0; | 1417 | unsigned int devid = 0; |
1418 | unsigned int reg; | 1418 | unsigned int reg; |
1419 | u32 val32; | ||
1419 | 1420 | ||
1420 | cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private), | 1421 | cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private), |
1421 | GFP_KERNEL); | 1422 | GFP_KERNEL); |
@@ -1431,8 +1432,25 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, | |||
1431 | return ret; | 1432 | return ret; |
1432 | } | 1433 | } |
1433 | 1434 | ||
1434 | if (pdata) | 1435 | if (pdata) { |
1435 | cs42l73->pdata = *pdata; | 1436 | cs42l73->pdata = *pdata; |
1437 | } else { | ||
1438 | pdata = devm_kzalloc(&i2c_client->dev, | ||
1439 | sizeof(struct cs42l73_platform_data), | ||
1440 | GFP_KERNEL); | ||
1441 | if (!pdata) { | ||
1442 | dev_err(&i2c_client->dev, "could not allocate pdata\n"); | ||
1443 | return -ENOMEM; | ||
1444 | } | ||
1445 | if (i2c_client->dev.of_node) { | ||
1446 | if (of_property_read_u32(i2c_client->dev.of_node, | ||
1447 | "chgfreq", &val32) >= 0) | ||
1448 | pdata->chgfreq = val32; | ||
1449 | } | ||
1450 | pdata->reset_gpio = of_get_named_gpio(i2c_client->dev.of_node, | ||
1451 | "reset-gpio", 0); | ||
1452 | cs42l73->pdata = *pdata; | ||
1453 | } | ||
1436 | 1454 | ||
1437 | i2c_set_clientdata(i2c_client, cs42l73); | 1455 | i2c_set_clientdata(i2c_client, cs42l73); |
1438 | 1456 | ||
@@ -1493,6 +1511,12 @@ static int cs42l73_i2c_remove(struct i2c_client *client) | |||
1493 | return 0; | 1511 | return 0; |
1494 | } | 1512 | } |
1495 | 1513 | ||
1514 | static const struct of_device_id cs42l73_of_match[] = { | ||
1515 | { .compatible = "cirrus,cs42l73", }, | ||
1516 | {}, | ||
1517 | }; | ||
1518 | MODULE_DEVICE_TABLE(of, cs42l73_of_match); | ||
1519 | |||
1496 | static const struct i2c_device_id cs42l73_id[] = { | 1520 | static const struct i2c_device_id cs42l73_id[] = { |
1497 | {"cs42l73", 0}, | 1521 | {"cs42l73", 0}, |
1498 | {} | 1522 | {} |
@@ -1504,6 +1528,7 @@ static struct i2c_driver cs42l73_i2c_driver = { | |||
1504 | .driver = { | 1528 | .driver = { |
1505 | .name = "cs42l73", | 1529 | .name = "cs42l73", |
1506 | .owner = THIS_MODULE, | 1530 | .owner = THIS_MODULE, |
1531 | .of_match_table = cs42l73_of_match, | ||
1507 | }, | 1532 | }, |
1508 | .id_table = cs42l73_id, | 1533 | .id_table = cs42l73_id, |
1509 | .probe = cs42l73_i2c_probe, | 1534 | .probe = cs42l73_i2c_probe, |