diff options
author | Jarkko Nikula <jhnikula@gmail.com> | 2010-09-20 03:39:11 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-09-20 13:40:46 -0400 |
commit | 2f24111a08d60e6db92ed2867a339ddde2195b88 (patch) | |
tree | d3e8872e2ecc63169abc48a2feeeb86fce58ce33 | |
parent | 826ca0bd53f443c830630c1532bf142c4e0f7d13 (diff) |
ASoC: tlv320aic3x: Move regulator management from i2c to soc domain
It will be easier to keep regulator enable/disable calls in sync when dynamic
regulator management is added if regulator management is moved from
aic3x_i2c_probe/_remove to aic3x_probe/_remove.
Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
-rw-r--r-- | sound/soc/codecs/tlv320aic3x.c | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 6190351965a4..c60ead948ea6 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c | |||
@@ -1266,7 +1266,7 @@ static int aic3x_init(struct snd_soc_codec *codec) | |||
1266 | static int aic3x_probe(struct snd_soc_codec *codec) | 1266 | static int aic3x_probe(struct snd_soc_codec *codec) |
1267 | { | 1267 | { |
1268 | struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); | 1268 | struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); |
1269 | int ret; | 1269 | int ret, i; |
1270 | 1270 | ||
1271 | codec->control_data = aic3x->control_data; | 1271 | codec->control_data = aic3x->control_data; |
1272 | 1272 | ||
@@ -1276,6 +1276,35 @@ static int aic3x_probe(struct snd_soc_codec *codec) | |||
1276 | return ret; | 1276 | return ret; |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | if (aic3x->gpio_reset >= 0) { | ||
1280 | ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset"); | ||
1281 | if (ret != 0) | ||
1282 | goto err_gpio; | ||
1283 | gpio_direction_output(aic3x->gpio_reset, 0); | ||
1284 | } | ||
1285 | |||
1286 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) | ||
1287 | aic3x->supplies[i].supply = aic3x_supply_names[i]; | ||
1288 | |||
1289 | ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(aic3x->supplies), | ||
1290 | aic3x->supplies); | ||
1291 | if (ret != 0) { | ||
1292 | dev_err(codec->dev, "Failed to request supplies: %d\n", ret); | ||
1293 | goto err_get; | ||
1294 | } | ||
1295 | |||
1296 | ret = regulator_bulk_enable(ARRAY_SIZE(aic3x->supplies), | ||
1297 | aic3x->supplies); | ||
1298 | if (ret != 0) { | ||
1299 | dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); | ||
1300 | goto err_enable; | ||
1301 | } | ||
1302 | |||
1303 | if (aic3x->gpio_reset >= 0) { | ||
1304 | udelay(1); | ||
1305 | gpio_set_value(aic3x->gpio_reset, 1); | ||
1306 | } | ||
1307 | |||
1279 | aic3x_init(codec); | 1308 | aic3x_init(codec); |
1280 | 1309 | ||
1281 | if (aic3x->setup) { | 1310 | if (aic3x->setup) { |
@@ -1294,11 +1323,29 @@ static int aic3x_probe(struct snd_soc_codec *codec) | |||
1294 | aic3x_add_widgets(codec); | 1323 | aic3x_add_widgets(codec); |
1295 | 1324 | ||
1296 | return 0; | 1325 | return 0; |
1326 | |||
1327 | err_enable: | ||
1328 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | ||
1329 | err_get: | ||
1330 | if (aic3x->gpio_reset >= 0) | ||
1331 | gpio_free(aic3x->gpio_reset); | ||
1332 | err_gpio: | ||
1333 | kfree(aic3x); | ||
1334 | return ret; | ||
1297 | } | 1335 | } |
1298 | 1336 | ||
1299 | static int aic3x_remove(struct snd_soc_codec *codec) | 1337 | static int aic3x_remove(struct snd_soc_codec *codec) |
1300 | { | 1338 | { |
1339 | struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); | ||
1340 | |||
1301 | aic3x_set_bias_level(codec, SND_SOC_BIAS_OFF); | 1341 | aic3x_set_bias_level(codec, SND_SOC_BIAS_OFF); |
1342 | if (aic3x->gpio_reset >= 0) { | ||
1343 | gpio_set_value(aic3x->gpio_reset, 0); | ||
1344 | gpio_free(aic3x->gpio_reset); | ||
1345 | } | ||
1346 | regulator_bulk_disable(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | ||
1347 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | ||
1348 | |||
1302 | return 0; | 1349 | return 0; |
1303 | } | 1350 | } |
1304 | 1351 | ||
@@ -1336,7 +1383,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
1336 | { | 1383 | { |
1337 | struct aic3x_pdata *pdata = i2c->dev.platform_data; | 1384 | struct aic3x_pdata *pdata = i2c->dev.platform_data; |
1338 | struct aic3x_priv *aic3x; | 1385 | struct aic3x_priv *aic3x; |
1339 | int ret, i; | 1386 | int ret; |
1340 | const struct i2c_device_id *tbl; | 1387 | const struct i2c_device_id *tbl; |
1341 | 1388 | ||
1342 | aic3x = kzalloc(sizeof(struct aic3x_priv), GFP_KERNEL); | 1389 | aic3x = kzalloc(sizeof(struct aic3x_priv), GFP_KERNEL); |
@@ -1356,68 +1403,21 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
1356 | aic3x->gpio_reset = -1; | 1403 | aic3x->gpio_reset = -1; |
1357 | } | 1404 | } |
1358 | 1405 | ||
1359 | if (aic3x->gpio_reset >= 0) { | ||
1360 | ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset"); | ||
1361 | if (ret != 0) | ||
1362 | goto err_gpio; | ||
1363 | gpio_direction_output(aic3x->gpio_reset, 0); | ||
1364 | } | ||
1365 | |||
1366 | for (tbl = aic3x_i2c_id; tbl->name[0]; tbl++) { | 1406 | for (tbl = aic3x_i2c_id; tbl->name[0]; tbl++) { |
1367 | if (!strcmp(tbl->name, id->name)) | 1407 | if (!strcmp(tbl->name, id->name)) |
1368 | break; | 1408 | break; |
1369 | } | 1409 | } |
1370 | aic3x->model = tbl - aic3x_i2c_id; | 1410 | aic3x->model = tbl - aic3x_i2c_id; |
1371 | 1411 | ||
1372 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) | ||
1373 | aic3x->supplies[i].supply = aic3x_supply_names[i]; | ||
1374 | |||
1375 | ret = regulator_bulk_get(&i2c->dev, ARRAY_SIZE(aic3x->supplies), | ||
1376 | aic3x->supplies); | ||
1377 | if (ret != 0) { | ||
1378 | dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); | ||
1379 | goto err_get; | ||
1380 | } | ||
1381 | |||
1382 | ret = regulator_bulk_enable(ARRAY_SIZE(aic3x->supplies), | ||
1383 | aic3x->supplies); | ||
1384 | if (ret != 0) { | ||
1385 | dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); | ||
1386 | goto err_enable; | ||
1387 | } | ||
1388 | |||
1389 | if (aic3x->gpio_reset >= 0) { | ||
1390 | udelay(1); | ||
1391 | gpio_set_value(aic3x->gpio_reset, 1); | ||
1392 | } | ||
1393 | |||
1394 | ret = snd_soc_register_codec(&i2c->dev, | 1412 | ret = snd_soc_register_codec(&i2c->dev, |
1395 | &soc_codec_dev_aic3x, &aic3x_dai, 1); | 1413 | &soc_codec_dev_aic3x, &aic3x_dai, 1); |
1396 | if (ret < 0) | 1414 | if (ret < 0) |
1397 | goto err_enable; | 1415 | kfree(aic3x); |
1398 | return ret; | ||
1399 | |||
1400 | err_enable: | ||
1401 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | ||
1402 | err_get: | ||
1403 | if (aic3x->gpio_reset >= 0) | ||
1404 | gpio_free(aic3x->gpio_reset); | ||
1405 | err_gpio: | ||
1406 | kfree(aic3x); | ||
1407 | return ret; | 1416 | return ret; |
1408 | } | 1417 | } |
1409 | 1418 | ||
1410 | static int aic3x_i2c_remove(struct i2c_client *client) | 1419 | static int aic3x_i2c_remove(struct i2c_client *client) |
1411 | { | 1420 | { |
1412 | struct aic3x_priv *aic3x = i2c_get_clientdata(client); | ||
1413 | |||
1414 | if (aic3x->gpio_reset >= 0) { | ||
1415 | gpio_set_value(aic3x->gpio_reset, 0); | ||
1416 | gpio_free(aic3x->gpio_reset); | ||
1417 | } | ||
1418 | regulator_bulk_disable(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | ||
1419 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | ||
1420 | |||
1421 | snd_soc_unregister_codec(&client->dev); | 1421 | snd_soc_unregister_codec(&client->dev); |
1422 | kfree(i2c_get_clientdata(client)); | 1422 | kfree(i2c_get_clientdata(client)); |
1423 | return 0; | 1423 | return 0; |