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

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>

authored by

Brian Austin and committed by
Mark Brown
391fc59d 44b2ed54

+42 -3
+42 -3
sound/soc/codecs/cs42l52.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/input.h> ··· 1193 1193 int ret; 1194 1194 unsigned int devid = 0; 1195 1195 unsigned int reg; 1196 + u32 val32; 1196 1197 1197 1198 cs42l52 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l52_private), 1198 1199 GFP_KERNEL); ··· 1207 1206 dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); 1208 1207 return ret; 1209 1208 } 1210 - 1211 - if (pdata) 1209 + if (pdata) { 1212 1210 cs42l52->pdata = *pdata; 1211 + } else { 1212 + pdata = devm_kzalloc(&i2c_client->dev, 1213 + sizeof(struct cs42l52_platform_data), 1214 + GFP_KERNEL); 1215 + if (!pdata) { 1216 + dev_err(&i2c_client->dev, "could not allocate pdata\n"); 1217 + return -ENOMEM; 1218 + } 1219 + if (i2c_client->dev.of_node) { 1220 + if (of_property_read_bool(i2c_client->dev.of_node, 1221 + "cirrus,mica-differential-cfg")) 1222 + pdata->mica_diff_cfg = true; 1223 + 1224 + if (of_property_read_bool(i2c_client->dev.of_node, 1225 + "cirrus,micb-differential-cfg")) 1226 + pdata->micb_diff_cfg = true; 1227 + 1228 + if (of_property_read_u32(i2c_client->dev.of_node, 1229 + "cirrus,micbias-lvl", &val32) >= 0) 1230 + pdata->micbias_lvl = val32; 1231 + 1232 + if (of_property_read_u32(i2c_client->dev.of_node, 1233 + "cirrus,chgfreq-divisor", &val32) >= 0) 1234 + pdata->chgfreq_divisor = val32; 1235 + 1236 + pdata->reset_gpio = 1237 + of_get_named_gpio(i2c_client->dev.of_node, 1238 + "cirrus,reset-gpio", 0); 1239 + } 1240 + cs42l52->pdata = *pdata; 1241 + } 1213 1242 1214 1243 if (cs42l52->pdata.reset_gpio) { 1215 1244 ret = gpio_request_one(cs42l52->pdata.reset_gpio, ··· 1311 1280 return 0; 1312 1281 } 1313 1282 1283 + static const struct of_device_id cs42l52_of_match[] = { 1284 + { .compatible = "cirrus,cs42l52", }, 1285 + {}, 1286 + }; 1287 + MODULE_DEVICE_TABLE(of, cs42l52_of_match); 1288 + 1289 + 1314 1290 static const struct i2c_device_id cs42l52_id[] = { 1315 1291 { "cs42l52", 0 }, 1316 1292 { } ··· 1328 1290 .driver = { 1329 1291 .name = "cs42l52", 1330 1292 .owner = THIS_MODULE, 1293 + .of_match_table = cs42l52_of_match, 1331 1294 }, 1332 1295 .id_table = cs42l52_id, 1333 1296 .probe = cs42l52_i2c_probe,