diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-09-22 18:47:58 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-09-22 18:47:58 -0400 |
commit | 2ef39e606bb43d6041b6d820e2a9156110a82d21 (patch) | |
tree | 7c4cb8bd147d962344d357569172dfbe35f098a6 /sound/soc/codecs | |
parent | a89be93c28cd656d1c3c49fe627666b3bbecd45a (diff) | |
parent | b4cad7af6665743647f28119b689e1552326d4da (diff) |
Merge remote-tracking branch 'asoc/topic/ux500' into for-3.7
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r-- | sound/soc/codecs/ab8500-codec.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index 2c1c2524ef8c..af547490b4f7 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/mfd/abx500/ab8500-sysctrl.h> | 34 | #include <linux/mfd/abx500/ab8500-sysctrl.h> |
35 | #include <linux/mfd/abx500/ab8500-codec.h> | 35 | #include <linux/mfd/abx500/ab8500-codec.h> |
36 | #include <linux/regulator/consumer.h> | 36 | #include <linux/regulator/consumer.h> |
37 | #include <linux/of.h> | ||
37 | 38 | ||
38 | #include <sound/core.h> | 39 | #include <sound/core.h> |
39 | #include <sound/pcm.h> | 40 | #include <sound/pcm.h> |
@@ -2394,9 +2395,65 @@ struct snd_soc_dai_driver ab8500_codec_dai[] = { | |||
2394 | } | 2395 | } |
2395 | }; | 2396 | }; |
2396 | 2397 | ||
2398 | static void ab8500_codec_of_probe(struct device *dev, struct device_node *np, | ||
2399 | struct ab8500_codec_platform_data *codec) | ||
2400 | { | ||
2401 | u32 value; | ||
2402 | |||
2403 | if (of_get_property(np, "stericsson,amic1-type-single-ended", NULL)) | ||
2404 | codec->amics.mic1_type = AMIC_TYPE_SINGLE_ENDED; | ||
2405 | else | ||
2406 | codec->amics.mic1_type = AMIC_TYPE_DIFFERENTIAL; | ||
2407 | |||
2408 | if (of_get_property(np, "stericsson,amic2-type-single-ended", NULL)) | ||
2409 | codec->amics.mic2_type = AMIC_TYPE_SINGLE_ENDED; | ||
2410 | else | ||
2411 | codec->amics.mic2_type = AMIC_TYPE_DIFFERENTIAL; | ||
2412 | |||
2413 | /* Has a non-standard Vamic been requested? */ | ||
2414 | if (of_get_property(np, "stericsson,amic1a-bias-vamic2", NULL)) | ||
2415 | codec->amics.mic1a_micbias = AMIC_MICBIAS_VAMIC2; | ||
2416 | else | ||
2417 | codec->amics.mic1a_micbias = AMIC_MICBIAS_VAMIC1; | ||
2418 | |||
2419 | if (of_get_property(np, "stericsson,amic1b-bias-vamic2", NULL)) | ||
2420 | codec->amics.mic1b_micbias = AMIC_MICBIAS_VAMIC2; | ||
2421 | else | ||
2422 | codec->amics.mic1b_micbias = AMIC_MICBIAS_VAMIC1; | ||
2423 | |||
2424 | if (of_get_property(np, "stericsson,amic2-bias-vamic1", NULL)) | ||
2425 | codec->amics.mic2_micbias = AMIC_MICBIAS_VAMIC1; | ||
2426 | else | ||
2427 | codec->amics.mic2_micbias = AMIC_MICBIAS_VAMIC2; | ||
2428 | |||
2429 | if (!of_property_read_u32(np, "stericsson,earpeice-cmv", &value)) { | ||
2430 | switch (value) { | ||
2431 | case 950 : | ||
2432 | codec->ear_cmv = EAR_CMV_0_95V; | ||
2433 | break; | ||
2434 | case 1100 : | ||
2435 | codec->ear_cmv = EAR_CMV_1_10V; | ||
2436 | break; | ||
2437 | case 1270 : | ||
2438 | codec->ear_cmv = EAR_CMV_1_27V; | ||
2439 | break; | ||
2440 | case 1580 : | ||
2441 | codec->ear_cmv = EAR_CMV_1_58V; | ||
2442 | break; | ||
2443 | default : | ||
2444 | codec->ear_cmv = EAR_CMV_UNKNOWN; | ||
2445 | dev_err(dev, "Unsuitable earpiece voltage found in DT\n"); | ||
2446 | } | ||
2447 | } else { | ||
2448 | dev_warn(dev, "No earpiece voltage found in DT - using default\n"); | ||
2449 | codec->ear_cmv = EAR_CMV_0_95V; | ||
2450 | } | ||
2451 | } | ||
2452 | |||
2397 | static int ab8500_codec_probe(struct snd_soc_codec *codec) | 2453 | static int ab8500_codec_probe(struct snd_soc_codec *codec) |
2398 | { | 2454 | { |
2399 | struct device *dev = codec->dev; | 2455 | struct device *dev = codec->dev; |
2456 | struct device_node *np = dev->of_node; | ||
2400 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(dev); | 2457 | struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(dev); |
2401 | struct ab8500_platform_data *pdata; | 2458 | struct ab8500_platform_data *pdata; |
2402 | struct filter_control *fc; | 2459 | struct filter_control *fc; |
@@ -2407,6 +2464,30 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) | |||
2407 | /* Setup AB8500 according to board-settings */ | 2464 | /* Setup AB8500 according to board-settings */ |
2408 | pdata = dev_get_platdata(dev->parent); | 2465 | pdata = dev_get_platdata(dev->parent); |
2409 | 2466 | ||
2467 | if (np) { | ||
2468 | if (!pdata) | ||
2469 | pdata = devm_kzalloc(dev, | ||
2470 | sizeof(struct ab8500_platform_data), | ||
2471 | GFP_KERNEL); | ||
2472 | |||
2473 | if (pdata && !pdata->codec) | ||
2474 | pdata->codec | ||
2475 | = devm_kzalloc(dev, | ||
2476 | sizeof(struct ab8500_codec_platform_data), | ||
2477 | GFP_KERNEL); | ||
2478 | |||
2479 | if (!(pdata && pdata->codec)) | ||
2480 | return -ENOMEM; | ||
2481 | |||
2482 | ab8500_codec_of_probe(dev, np, pdata->codec); | ||
2483 | |||
2484 | } else { | ||
2485 | if (!(pdata && pdata->codec)) { | ||
2486 | dev_err(dev, "No codec platform data or DT found\n"); | ||
2487 | return -EINVAL; | ||
2488 | } | ||
2489 | } | ||
2490 | |||
2410 | status = ab8500_audio_setup_mics(codec, &pdata->codec->amics); | 2491 | status = ab8500_audio_setup_mics(codec, &pdata->codec->amics); |
2411 | if (status < 0) { | 2492 | if (status < 0) { |
2412 | pr_err("%s: Failed to setup mics (%d)!\n", __func__, status); | 2493 | pr_err("%s: Failed to setup mics (%d)!\n", __func__, status); |