diff options
Diffstat (limited to 'sound/soc/codecs/wm5100.c')
-rw-r--r-- | sound/soc/codecs/wm5100.c | 47 |
1 files changed, 9 insertions, 38 deletions
diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c index b9c185ce64e4..cb6d5372103a 100644 --- a/sound/soc/codecs/wm5100.c +++ b/sound/soc/codecs/wm5100.c | |||
@@ -1265,29 +1265,12 @@ static const __devinitdata struct reg_default wm5100_reva_patches[] = { | |||
1265 | { WM5100_AUDIO_IF_3_19, 1 }, | 1265 | { WM5100_AUDIO_IF_3_19, 1 }, |
1266 | }; | 1266 | }; |
1267 | 1267 | ||
1268 | static int wm5100_dai_to_base(struct snd_soc_dai *dai) | ||
1269 | { | ||
1270 | switch (dai->id) { | ||
1271 | case 0: | ||
1272 | return WM5100_AUDIO_IF_1_1 - 1; | ||
1273 | case 1: | ||
1274 | return WM5100_AUDIO_IF_2_1 - 1; | ||
1275 | case 2: | ||
1276 | return WM5100_AUDIO_IF_3_1 - 1; | ||
1277 | default: | ||
1278 | BUG(); | ||
1279 | return -EINVAL; | ||
1280 | } | ||
1281 | } | ||
1282 | |||
1283 | static int wm5100_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | 1268 | static int wm5100_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) |
1284 | { | 1269 | { |
1285 | struct snd_soc_codec *codec = dai->codec; | 1270 | struct snd_soc_codec *codec = dai->codec; |
1286 | int lrclk, bclk, mask, base; | 1271 | int lrclk, bclk, mask, base; |
1287 | 1272 | ||
1288 | base = wm5100_dai_to_base(dai); | 1273 | base = dai->driver->base; |
1289 | if (base < 0) | ||
1290 | return base; | ||
1291 | 1274 | ||
1292 | lrclk = 0; | 1275 | lrclk = 0; |
1293 | bclk = 0; | 1276 | bclk = 0; |
@@ -1414,9 +1397,7 @@ static int wm5100_hw_params(struct snd_pcm_substream *substream, | |||
1414 | int i, base, bclk, aif_rate, lrclk, wl, fl, sr; | 1397 | int i, base, bclk, aif_rate, lrclk, wl, fl, sr; |
1415 | int *bclk_rates; | 1398 | int *bclk_rates; |
1416 | 1399 | ||
1417 | base = wm5100_dai_to_base(dai); | 1400 | base = dai->driver->base; |
1418 | if (base < 0) | ||
1419 | return base; | ||
1420 | 1401 | ||
1421 | /* Data sizes if not using TDM */ | 1402 | /* Data sizes if not using TDM */ |
1422 | wl = snd_pcm_format_width(params_format(params)); | 1403 | wl = snd_pcm_format_width(params_format(params)); |
@@ -1897,6 +1878,7 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, | |||
1897 | static struct snd_soc_dai_driver wm5100_dai[] = { | 1878 | static struct snd_soc_dai_driver wm5100_dai[] = { |
1898 | { | 1879 | { |
1899 | .name = "wm5100-aif1", | 1880 | .name = "wm5100-aif1", |
1881 | .base = WM5100_AUDIO_IF_1_1 - 1, | ||
1900 | .playback = { | 1882 | .playback = { |
1901 | .stream_name = "AIF1 Playback", | 1883 | .stream_name = "AIF1 Playback", |
1902 | .channels_min = 2, | 1884 | .channels_min = 2, |
@@ -1916,6 +1898,7 @@ static struct snd_soc_dai_driver wm5100_dai[] = { | |||
1916 | { | 1898 | { |
1917 | .name = "wm5100-aif2", | 1899 | .name = "wm5100-aif2", |
1918 | .id = 1, | 1900 | .id = 1, |
1901 | .base = WM5100_AUDIO_IF_2_1 - 1, | ||
1919 | .playback = { | 1902 | .playback = { |
1920 | .stream_name = "AIF2 Playback", | 1903 | .stream_name = "AIF2 Playback", |
1921 | .channels_min = 2, | 1904 | .channels_min = 2, |
@@ -1935,6 +1918,7 @@ static struct snd_soc_dai_driver wm5100_dai[] = { | |||
1935 | { | 1918 | { |
1936 | .name = "wm5100-aif3", | 1919 | .name = "wm5100-aif3", |
1937 | .id = 2, | 1920 | .id = 2, |
1921 | .base = WM5100_AUDIO_IF_3_1 - 1, | ||
1938 | .playback = { | 1922 | .playback = { |
1939 | .stream_name = "AIF3 Playback", | 1923 | .stream_name = "AIF3 Playback", |
1940 | .channels_min = 2, | 1924 | .channels_min = 2, |
@@ -2454,7 +2438,7 @@ static __devinit int wm5100_i2c_probe(struct i2c_client *i2c, | |||
2454 | 2438 | ||
2455 | wm5100->dev = &i2c->dev; | 2439 | wm5100->dev = &i2c->dev; |
2456 | 2440 | ||
2457 | wm5100->regmap = regmap_init_i2c(i2c, &wm5100_regmap); | 2441 | wm5100->regmap = devm_regmap_init_i2c(i2c, &wm5100_regmap); |
2458 | if (IS_ERR(wm5100->regmap)) { | 2442 | if (IS_ERR(wm5100->regmap)) { |
2459 | ret = PTR_ERR(wm5100->regmap); | 2443 | ret = PTR_ERR(wm5100->regmap); |
2460 | dev_err(&i2c->dev, "Failed to allocate register map: %d\n", | 2444 | dev_err(&i2c->dev, "Failed to allocate register map: %d\n", |
@@ -2479,7 +2463,7 @@ static __devinit int wm5100_i2c_probe(struct i2c_client *i2c, | |||
2479 | if (ret != 0) { | 2463 | if (ret != 0) { |
2480 | dev_err(&i2c->dev, "Failed to request core supplies: %d\n", | 2464 | dev_err(&i2c->dev, "Failed to request core supplies: %d\n", |
2481 | ret); | 2465 | ret); |
2482 | goto err_regmap; | 2466 | goto err; |
2483 | } | 2467 | } |
2484 | 2468 | ||
2485 | ret = regulator_bulk_enable(ARRAY_SIZE(wm5100->core_supplies), | 2469 | ret = regulator_bulk_enable(ARRAY_SIZE(wm5100->core_supplies), |
@@ -2487,7 +2471,7 @@ static __devinit int wm5100_i2c_probe(struct i2c_client *i2c, | |||
2487 | if (ret != 0) { | 2471 | if (ret != 0) { |
2488 | dev_err(&i2c->dev, "Failed to enable core supplies: %d\n", | 2472 | dev_err(&i2c->dev, "Failed to enable core supplies: %d\n", |
2489 | ret); | 2473 | ret); |
2490 | goto err_regmap; | 2474 | goto err; |
2491 | } | 2475 | } |
2492 | 2476 | ||
2493 | if (wm5100->pdata.ldo_ena) { | 2477 | if (wm5100->pdata.ldo_ena) { |
@@ -2660,8 +2644,6 @@ err_ldo: | |||
2660 | err_enable: | 2644 | err_enable: |
2661 | regulator_bulk_disable(ARRAY_SIZE(wm5100->core_supplies), | 2645 | regulator_bulk_disable(ARRAY_SIZE(wm5100->core_supplies), |
2662 | wm5100->core_supplies); | 2646 | wm5100->core_supplies); |
2663 | err_regmap: | ||
2664 | regmap_exit(wm5100->regmap); | ||
2665 | err: | 2647 | err: |
2666 | return ret; | 2648 | return ret; |
2667 | } | 2649 | } |
@@ -2682,7 +2664,6 @@ static __devexit int wm5100_i2c_remove(struct i2c_client *i2c) | |||
2682 | gpio_set_value_cansleep(wm5100->pdata.ldo_ena, 0); | 2664 | gpio_set_value_cansleep(wm5100->pdata.ldo_ena, 0); |
2683 | gpio_free(wm5100->pdata.ldo_ena); | 2665 | gpio_free(wm5100->pdata.ldo_ena); |
2684 | } | 2666 | } |
2685 | regmap_exit(wm5100->regmap); | ||
2686 | 2667 | ||
2687 | return 0; | 2668 | return 0; |
2688 | } | 2669 | } |
@@ -2749,17 +2730,7 @@ static struct i2c_driver wm5100_i2c_driver = { | |||
2749 | .id_table = wm5100_i2c_id, | 2730 | .id_table = wm5100_i2c_id, |
2750 | }; | 2731 | }; |
2751 | 2732 | ||
2752 | static int __init wm5100_modinit(void) | 2733 | module_i2c_driver(wm5100_i2c_driver); |
2753 | { | ||
2754 | return i2c_add_driver(&wm5100_i2c_driver); | ||
2755 | } | ||
2756 | module_init(wm5100_modinit); | ||
2757 | |||
2758 | static void __exit wm5100_exit(void) | ||
2759 | { | ||
2760 | i2c_del_driver(&wm5100_i2c_driver); | ||
2761 | } | ||
2762 | module_exit(wm5100_exit); | ||
2763 | 2734 | ||
2764 | MODULE_DESCRIPTION("ASoC WM5100 driver"); | 2735 | MODULE_DESCRIPTION("ASoC WM5100 driver"); |
2765 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); | 2736 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); |