Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Brian Austin and committed by
Mark Brown
7b09eea5 f9ca0606

+49 -2
+22
Documentation/devicetree/bindings/sound/cs42l73.txt
··· 1 + CS42L73 audio CODEC 2 + 3 + Required properties: 4 + 5 + - compatible : "cirrus,cs42l73" 6 + 7 + - reg : the I2C address of the device for I2C 8 + 9 + Optional properties: 10 + 11 + - reset_gpio : a GPIO spec for the reset pin. 12 + - chgfreq : Charge Pump Frequency values 0x00-0x0F 13 + 14 + 15 + Example: 16 + 17 + codec: cs42l73@4a { 18 + compatible = "cirrus,cs42l73"; 19 + reg = <0x4a>; 20 + reset_gpio = <&gpio 10 0>; 21 + chgfreq = <0x05>; 22 + };
+27 -2
sound/soc/codecs/cs42l73.c
··· 17 17 #include <linux/kernel.h> 18 18 #include <linux/init.h> 19 19 #include <linux/delay.h> 20 - #include <linux/gpio.h> 20 + #include <linux/of_gpio.h> 21 21 #include <linux/pm.h> 22 22 #include <linux/i2c.h> 23 23 #include <linux/regmap.h> ··· 1416 1416 int ret; 1417 1417 unsigned int devid = 0; 1418 1418 unsigned int reg; 1419 + u32 val32; 1419 1420 1420 1421 cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private), 1421 1422 GFP_KERNEL); ··· 1432 1431 return ret; 1433 1432 } 1434 1433 1435 - if (pdata) 1434 + if (pdata) { 1436 1435 cs42l73->pdata = *pdata; 1436 + } else { 1437 + pdata = devm_kzalloc(&i2c_client->dev, 1438 + sizeof(struct cs42l73_platform_data), 1439 + GFP_KERNEL); 1440 + if (!pdata) { 1441 + dev_err(&i2c_client->dev, "could not allocate pdata\n"); 1442 + return -ENOMEM; 1443 + } 1444 + if (i2c_client->dev.of_node) { 1445 + if (of_property_read_u32(i2c_client->dev.of_node, 1446 + "chgfreq", &val32) >= 0) 1447 + pdata->chgfreq = val32; 1448 + } 1449 + pdata->reset_gpio = of_get_named_gpio(i2c_client->dev.of_node, 1450 + "reset-gpio", 0); 1451 + cs42l73->pdata = *pdata; 1452 + } 1437 1453 1438 1454 i2c_set_clientdata(i2c_client, cs42l73); 1439 1455 ··· 1511 1493 return 0; 1512 1494 } 1513 1495 1496 + static const struct of_device_id cs42l73_of_match[] = { 1497 + { .compatible = "cirrus,cs42l73", }, 1498 + {}, 1499 + }; 1500 + MODULE_DEVICE_TABLE(of, cs42l73_of_match); 1501 + 1514 1502 static const struct i2c_device_id cs42l73_id[] = { 1515 1503 {"cs42l73", 0}, 1516 1504 {} ··· 1528 1504 .driver = { 1529 1505 .name = "cs42l73", 1530 1506 .owner = THIS_MODULE, 1507 + .of_match_table = cs42l73_of_match, 1531 1508 }, 1532 1509 .id_table = cs42l73_id, 1533 1510 .probe = cs42l73_i2c_probe,