summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 22:06:37 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:41:59 -0500
commit98020a71c2c135b7c24e8fa8c2b3e947fe465909 (patch)
tree0f5f6098e8727c91134d31dceca5dfc676ed3a28 /sound
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: wm8978: replace codec to component
Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/wm8978.c185
1 files changed, 89 insertions, 96 deletions
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c
index cf761e2d7546..bae4fe89dbf1 100644
--- a/sound/soc/codecs/wm8978.c
+++ b/sound/soc/codecs/wm8978.c
@@ -408,7 +408,7 @@ struct wm8978_pll_div {
408 408
409#define FIXED_PLL_SIZE (1 << 24) 409#define FIXED_PLL_SIZE (1 << 24)
410 410
411static void pll_factors(struct snd_soc_codec *codec, 411static void pll_factors(struct snd_soc_component *component,
412 struct wm8978_pll_div *pll_div, unsigned int target, unsigned int source) 412 struct wm8978_pll_div *pll_div, unsigned int target, unsigned int source)
413{ 413{
414 u64 k_part; 414 u64 k_part;
@@ -424,7 +424,7 @@ static void pll_factors(struct snd_soc_codec *codec,
424 } 424 }
425 425
426 if (n_div < 6 || n_div > 12) 426 if (n_div < 6 || n_div > 12)
427 dev_warn(codec->dev, 427 dev_warn(component->dev,
428 "WM8978 N value exceeds recommended range! N = %u\n", 428 "WM8978 N value exceeds recommended range! N = %u\n",
429 n_div); 429 n_div);
430 430
@@ -471,9 +471,9 @@ static int wm8978_enum_mclk(unsigned int f_out, unsigned int f_mclk,
471 * Calculate internal frequencies and dividers, according to Figure 40 471 * Calculate internal frequencies and dividers, according to Figure 40
472 * "PLL and Clock Select Circuit" in WM8978 datasheet Rev. 2.6 472 * "PLL and Clock Select Circuit" in WM8978 datasheet Rev. 2.6
473 */ 473 */
474static int wm8978_configure_pll(struct snd_soc_codec *codec) 474static int wm8978_configure_pll(struct snd_soc_component *component)
475{ 475{
476 struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); 476 struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component);
477 struct wm8978_pll_div pll_div; 477 struct wm8978_pll_div pll_div;
478 unsigned int f_opclk = wm8978->f_opclk, f_mclk = wm8978->f_mclk, 478 unsigned int f_opclk = wm8978->f_opclk, f_mclk = wm8978->f_mclk,
479 f_256fs = wm8978->f_256fs; 479 f_256fs = wm8978->f_256fs;
@@ -505,9 +505,9 @@ static int wm8978_configure_pll(struct snd_soc_codec *codec)
505 else 505 else
506 opclk_div = 1; 506 opclk_div = 1;
507 507
508 dev_dbg(codec->dev, "%s: OPCLKDIV=%d\n", __func__, opclk_div); 508 dev_dbg(component->dev, "%s: OPCLKDIV=%d\n", __func__, opclk_div);
509 509
510 snd_soc_update_bits(codec, WM8978_GPIO_CONTROL, 0x30, 510 snd_soc_component_update_bits(component, WM8978_GPIO_CONTROL, 0x30,
511 (opclk_div - 1) << 4); 511 (opclk_div - 1) << 4);
512 512
513 wm8978->f_pllout = f_opclk * opclk_div; 513 wm8978->f_pllout = f_opclk * opclk_div;
@@ -533,28 +533,28 @@ static int wm8978_configure_pll(struct snd_soc_codec *codec)
533 533
534 f2 = wm8978->f_pllout * 4; 534 f2 = wm8978->f_pllout * 4;
535 535
536 dev_dbg(codec->dev, "%s: f_MCLK=%uHz, f_PLLOUT=%uHz\n", __func__, 536 dev_dbg(component->dev, "%s: f_MCLK=%uHz, f_PLLOUT=%uHz\n", __func__,
537 wm8978->f_mclk, wm8978->f_pllout); 537 wm8978->f_mclk, wm8978->f_pllout);
538 538
539 pll_factors(codec, &pll_div, f2, wm8978->f_mclk); 539 pll_factors(component, &pll_div, f2, wm8978->f_mclk);
540 540
541 dev_dbg(codec->dev, "%s: calculated PLL N=0x%x, K=0x%x, div2=%d\n", 541 dev_dbg(component->dev, "%s: calculated PLL N=0x%x, K=0x%x, div2=%d\n",
542 __func__, pll_div.n, pll_div.k, pll_div.div2); 542 __func__, pll_div.n, pll_div.k, pll_div.div2);
543 543
544 /* Turn PLL off for configuration... */ 544 /* Turn PLL off for configuration... */
545 snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0); 545 snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0);
546 546
547 snd_soc_write(codec, WM8978_PLL_N, (pll_div.div2 << 4) | pll_div.n); 547 snd_soc_component_write(component, WM8978_PLL_N, (pll_div.div2 << 4) | pll_div.n);
548 snd_soc_write(codec, WM8978_PLL_K1, pll_div.k >> 18); 548 snd_soc_component_write(component, WM8978_PLL_K1, pll_div.k >> 18);
549 snd_soc_write(codec, WM8978_PLL_K2, (pll_div.k >> 9) & 0x1ff); 549 snd_soc_component_write(component, WM8978_PLL_K2, (pll_div.k >> 9) & 0x1ff);
550 snd_soc_write(codec, WM8978_PLL_K3, pll_div.k & 0x1ff); 550 snd_soc_component_write(component, WM8978_PLL_K3, pll_div.k & 0x1ff);
551 551
552 /* ...and on again */ 552 /* ...and on again */
553 snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20); 553 snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20);
554 554
555 if (f_opclk) 555 if (f_opclk)
556 /* Output PLL (OPCLK) to GPIO1 */ 556 /* Output PLL (OPCLK) to GPIO1 */
557 snd_soc_update_bits(codec, WM8978_GPIO_CONTROL, 7, 4); 557 snd_soc_component_update_bits(component, WM8978_GPIO_CONTROL, 7, 4);
558 558
559 return 0; 559 return 0;
560} 560}
@@ -565,8 +565,8 @@ static int wm8978_configure_pll(struct snd_soc_codec *codec)
565static int wm8978_set_dai_clkdiv(struct snd_soc_dai *codec_dai, 565static int wm8978_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
566 int div_id, int div) 566 int div_id, int div)
567{ 567{
568 struct snd_soc_codec *codec = codec_dai->codec; 568 struct snd_soc_component *component = codec_dai->component;
569 struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); 569 struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component);
570 int ret = 0; 570 int ret = 0;
571 571
572 switch (div_id) { 572 switch (div_id) {
@@ -588,18 +588,18 @@ static int wm8978_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
588 * find an exact MCLK divider configuration - it will 588 * find an exact MCLK divider configuration - it will
589 * be equal to or double the OPCLK divisor. 589 * be equal to or double the OPCLK divisor.
590 */ 590 */
591 ret = wm8978_configure_pll(codec); 591 ret = wm8978_configure_pll(component);
592 break; 592 break;
593 case WM8978_BCLKDIV: 593 case WM8978_BCLKDIV:
594 if (div & ~0x1c) 594 if (div & ~0x1c)
595 return -EINVAL; 595 return -EINVAL;
596 snd_soc_update_bits(codec, WM8978_CLOCKING, 0x1c, div); 596 snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x1c, div);
597 break; 597 break;
598 default: 598 default:
599 return -EINVAL; 599 return -EINVAL;
600 } 600 }
601 601
602 dev_dbg(codec->dev, "%s: ID %d, value %u\n", __func__, div_id, div); 602 dev_dbg(component->dev, "%s: ID %d, value %u\n", __func__, div_id, div);
603 603
604 return ret; 604 return ret;
605} 605}
@@ -610,18 +610,18 @@ static int wm8978_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
610static int wm8978_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, 610static int wm8978_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id,
611 unsigned int freq, int dir) 611 unsigned int freq, int dir)
612{ 612{
613 struct snd_soc_codec *codec = codec_dai->codec; 613 struct snd_soc_component *component = codec_dai->component;
614 struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); 614 struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component);
615 int ret = 0; 615 int ret = 0;
616 616
617 dev_dbg(codec->dev, "%s: ID %d, freq %u\n", __func__, clk_id, freq); 617 dev_dbg(component->dev, "%s: ID %d, freq %u\n", __func__, clk_id, freq);
618 618
619 if (freq) { 619 if (freq) {
620 wm8978->f_mclk = freq; 620 wm8978->f_mclk = freq;
621 621
622 /* Even if MCLK is used for system clock, might have to drive OPCLK */ 622 /* Even if MCLK is used for system clock, might have to drive OPCLK */
623 if (wm8978->f_opclk) 623 if (wm8978->f_opclk)
624 ret = wm8978_configure_pll(codec); 624 ret = wm8978_configure_pll(component);
625 625
626 /* Our sysclk is fixed to 256 * fs, will configure in .hw_params() */ 626 /* Our sysclk is fixed to 256 * fs, will configure in .hw_params() */
627 627
@@ -631,13 +631,13 @@ static int wm8978_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id,
631 631
632 if (wm8978->sysclk == WM8978_PLL && (!freq || clk_id == WM8978_MCLK)) { 632 if (wm8978->sysclk == WM8978_PLL && (!freq || clk_id == WM8978_MCLK)) {
633 /* Clock CODEC directly from MCLK */ 633 /* Clock CODEC directly from MCLK */
634 snd_soc_update_bits(codec, WM8978_CLOCKING, 0x100, 0); 634 snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x100, 0);
635 635
636 /* GPIO1 into default mode as input - before configuring PLL */ 636 /* GPIO1 into default mode as input - before configuring PLL */
637 snd_soc_update_bits(codec, WM8978_GPIO_CONTROL, 7, 0); 637 snd_soc_component_update_bits(component, WM8978_GPIO_CONTROL, 7, 0);
638 638
639 /* Turn off PLL */ 639 /* Turn off PLL */
640 snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0); 640 snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0);
641 wm8978->sysclk = WM8978_MCLK; 641 wm8978->sysclk = WM8978_MCLK;
642 wm8978->f_pllout = 0; 642 wm8978->f_pllout = 0;
643 wm8978->f_opclk = 0; 643 wm8978->f_opclk = 0;
@@ -651,15 +651,15 @@ static int wm8978_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id,
651 */ 651 */
652static int wm8978_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) 652static int wm8978_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
653{ 653{
654 struct snd_soc_codec *codec = codec_dai->codec; 654 struct snd_soc_component *component = codec_dai->component;
655 /* 655 /*
656 * BCLK polarity mask = 0x100, LRC clock polarity mask = 0x80, 656 * BCLK polarity mask = 0x100, LRC clock polarity mask = 0x80,
657 * Data Format mask = 0x18: all will be calculated anew 657 * Data Format mask = 0x18: all will be calculated anew
658 */ 658 */
659 u16 iface = snd_soc_read(codec, WM8978_AUDIO_INTERFACE) & ~0x198; 659 u16 iface = snd_soc_component_read32(component, WM8978_AUDIO_INTERFACE) & ~0x198;
660 u16 clk = snd_soc_read(codec, WM8978_CLOCKING); 660 u16 clk = snd_soc_component_read32(component, WM8978_CLOCKING);
661 661
662 dev_dbg(codec->dev, "%s\n", __func__); 662 dev_dbg(component->dev, "%s\n", __func__);
663 663
664 /* set master/slave audio interface */ 664 /* set master/slave audio interface */
665 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 665 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -707,8 +707,8 @@ static int wm8978_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
707 return -EINVAL; 707 return -EINVAL;
708 } 708 }
709 709
710 snd_soc_write(codec, WM8978_AUDIO_INTERFACE, iface); 710 snd_soc_component_write(component, WM8978_AUDIO_INTERFACE, iface);
711 snd_soc_write(codec, WM8978_CLOCKING, clk); 711 snd_soc_component_write(component, WM8978_CLOCKING, clk);
712 712
713 return 0; 713 return 0;
714} 714}
@@ -720,13 +720,13 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream,
720 struct snd_pcm_hw_params *params, 720 struct snd_pcm_hw_params *params,
721 struct snd_soc_dai *dai) 721 struct snd_soc_dai *dai)
722{ 722{
723 struct snd_soc_codec *codec = dai->codec; 723 struct snd_soc_component *component = dai->component;
724 struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); 724 struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component);
725 /* Word length mask = 0x60 */ 725 /* Word length mask = 0x60 */
726 u16 iface_ctl = snd_soc_read(codec, WM8978_AUDIO_INTERFACE) & ~0x60; 726 u16 iface_ctl = snd_soc_component_read32(component, WM8978_AUDIO_INTERFACE) & ~0x60;
727 /* Sampling rate mask = 0xe (for filters) */ 727 /* Sampling rate mask = 0xe (for filters) */
728 u16 add_ctl = snd_soc_read(codec, WM8978_ADDITIONAL_CONTROL) & ~0xe; 728 u16 add_ctl = snd_soc_component_read32(component, WM8978_ADDITIONAL_CONTROL) & ~0xe;
729 u16 clking = snd_soc_read(codec, WM8978_CLOCKING); 729 u16 clking = snd_soc_component_read32(component, WM8978_CLOCKING);
730 enum wm8978_sysclk_src current_clk_id = clking & 0x100 ? 730 enum wm8978_sysclk_src current_clk_id = clking & 0x100 ?
731 WM8978_PLL : WM8978_MCLK; 731 WM8978_PLL : WM8978_MCLK;
732 unsigned int f_sel, diff, diff_best = INT_MAX; 732 unsigned int f_sel, diff, diff_best = INT_MAX;
@@ -781,7 +781,7 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream,
781 } else { 781 } else {
782 if (!wm8978->f_opclk) { 782 if (!wm8978->f_opclk) {
783 /* We only enter here, if OPCLK is not used */ 783 /* We only enter here, if OPCLK is not used */
784 int ret = wm8978_configure_pll(codec); 784 int ret = wm8978_configure_pll(component);
785 if (ret < 0) 785 if (ret < 0)
786 return ret; 786 return ret;
787 } 787 }
@@ -812,28 +812,28 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream,
812 } 812 }
813 813
814 if (diff) 814 if (diff)
815 dev_warn(codec->dev, "Imprecise sampling rate: %uHz%s\n", 815 dev_warn(component->dev, "Imprecise sampling rate: %uHz%s\n",
816 f_sel * mclk_denominator[best] / mclk_numerator[best] / 256, 816 f_sel * mclk_denominator[best] / mclk_numerator[best] / 256,
817 wm8978->sysclk == WM8978_MCLK ? 817 wm8978->sysclk == WM8978_MCLK ?
818 ", consider using PLL" : ""); 818 ", consider using PLL" : "");
819 819
820 dev_dbg(codec->dev, "%s: width %d, rate %u, MCLK divisor #%d\n", __func__, 820 dev_dbg(component->dev, "%s: width %d, rate %u, MCLK divisor #%d\n", __func__,
821 params_width(params), params_rate(params), best); 821 params_width(params), params_rate(params), best);
822 822
823 /* MCLK divisor mask = 0xe0 */ 823 /* MCLK divisor mask = 0xe0 */
824 snd_soc_update_bits(codec, WM8978_CLOCKING, 0xe0, best << 5); 824 snd_soc_component_update_bits(component, WM8978_CLOCKING, 0xe0, best << 5);
825 825
826 snd_soc_write(codec, WM8978_AUDIO_INTERFACE, iface_ctl); 826 snd_soc_component_write(component, WM8978_AUDIO_INTERFACE, iface_ctl);
827 snd_soc_write(codec, WM8978_ADDITIONAL_CONTROL, add_ctl); 827 snd_soc_component_write(component, WM8978_ADDITIONAL_CONTROL, add_ctl);
828 828
829 if (wm8978->sysclk != current_clk_id) { 829 if (wm8978->sysclk != current_clk_id) {
830 if (wm8978->sysclk == WM8978_PLL) 830 if (wm8978->sysclk == WM8978_PLL)
831 /* Run CODEC from PLL instead of MCLK */ 831 /* Run CODEC from PLL instead of MCLK */
832 snd_soc_update_bits(codec, WM8978_CLOCKING, 832 snd_soc_component_update_bits(component, WM8978_CLOCKING,
833 0x100, 0x100); 833 0x100, 0x100);
834 else 834 else
835 /* Clock CODEC directly from MCLK */ 835 /* Clock CODEC directly from MCLK */
836 snd_soc_update_bits(codec, WM8978_CLOCKING, 0x100, 0); 836 snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x100, 0);
837 } 837 }
838 838
839 return 0; 839 return 0;
@@ -841,52 +841,52 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream,
841 841
842static int wm8978_mute(struct snd_soc_dai *dai, int mute) 842static int wm8978_mute(struct snd_soc_dai *dai, int mute)
843{ 843{
844 struct snd_soc_codec *codec = dai->codec; 844 struct snd_soc_component *component = dai->component;
845 845
846 dev_dbg(codec->dev, "%s: %d\n", __func__, mute); 846 dev_dbg(component->dev, "%s: %d\n", __func__, mute);
847 847
848 if (mute) 848 if (mute)
849 snd_soc_update_bits(codec, WM8978_DAC_CONTROL, 0x40, 0x40); 849 snd_soc_component_update_bits(component, WM8978_DAC_CONTROL, 0x40, 0x40);
850 else 850 else
851 snd_soc_update_bits(codec, WM8978_DAC_CONTROL, 0x40, 0); 851 snd_soc_component_update_bits(component, WM8978_DAC_CONTROL, 0x40, 0);
852 852
853 return 0; 853 return 0;
854} 854}
855 855
856static int wm8978_set_bias_level(struct snd_soc_codec *codec, 856static int wm8978_set_bias_level(struct snd_soc_component *component,
857 enum snd_soc_bias_level level) 857 enum snd_soc_bias_level level)
858{ 858{
859 u16 power1 = snd_soc_read(codec, WM8978_POWER_MANAGEMENT_1) & ~3; 859 u16 power1 = snd_soc_component_read32(component, WM8978_POWER_MANAGEMENT_1) & ~3;
860 860
861 switch (level) { 861 switch (level) {
862 case SND_SOC_BIAS_ON: 862 case SND_SOC_BIAS_ON:
863 case SND_SOC_BIAS_PREPARE: 863 case SND_SOC_BIAS_PREPARE:
864 power1 |= 1; /* VMID 75k */ 864 power1 |= 1; /* VMID 75k */
865 snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, power1); 865 snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, power1);
866 break; 866 break;
867 case SND_SOC_BIAS_STANDBY: 867 case SND_SOC_BIAS_STANDBY:
868 /* bit 3: enable bias, bit 2: enable I/O tie off buffer */ 868 /* bit 3: enable bias, bit 2: enable I/O tie off buffer */
869 power1 |= 0xc; 869 power1 |= 0xc;
870 870
871 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { 871 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
872 /* Initial cap charge at VMID 5k */ 872 /* Initial cap charge at VMID 5k */
873 snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, 873 snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1,
874 power1 | 0x3); 874 power1 | 0x3);
875 mdelay(100); 875 mdelay(100);
876 } 876 }
877 877
878 power1 |= 0x2; /* VMID 500k */ 878 power1 |= 0x2; /* VMID 500k */
879 snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, power1); 879 snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, power1);
880 break; 880 break;
881 case SND_SOC_BIAS_OFF: 881 case SND_SOC_BIAS_OFF:
882 /* Preserve PLL - OPCLK may be used by someone */ 882 /* Preserve PLL - OPCLK may be used by someone */
883 snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, ~0x20, 0); 883 snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, ~0x20, 0);
884 snd_soc_write(codec, WM8978_POWER_MANAGEMENT_2, 0); 884 snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_2, 0);
885 snd_soc_write(codec, WM8978_POWER_MANAGEMENT_3, 0); 885 snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_3, 0);
886 break; 886 break;
887 } 887 }
888 888
889 dev_dbg(codec->dev, "%s: %d, %x\n", __func__, level, power1); 889 dev_dbg(component->dev, "%s: %d, %x\n", __func__, level, power1);
890 890
891 return 0; 891 return 0;
892} 892}
@@ -923,31 +923,31 @@ static struct snd_soc_dai_driver wm8978_dai = {
923 .symmetric_rates = 1, 923 .symmetric_rates = 1,
924}; 924};
925 925
926static int wm8978_suspend(struct snd_soc_codec *codec) 926static int wm8978_suspend(struct snd_soc_component *component)
927{ 927{
928 struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); 928 struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component);
929 929
930 snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); 930 snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
931 /* Also switch PLL off */ 931 /* Also switch PLL off */
932 snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, 0); 932 snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, 0);
933 933
934 regcache_mark_dirty(wm8978->regmap); 934 regcache_mark_dirty(wm8978->regmap);
935 935
936 return 0; 936 return 0;
937} 937}
938 938
939static int wm8978_resume(struct snd_soc_codec *codec) 939static int wm8978_resume(struct snd_soc_component *component)
940{ 940{
941 struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); 941 struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component);
942 942
943 /* Sync reg_cache with the hardware */ 943 /* Sync reg_cache with the hardware */
944 regcache_sync(wm8978->regmap); 944 regcache_sync(wm8978->regmap);
945 945
946 snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); 946 snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
947 947
948 if (wm8978->f_pllout) 948 if (wm8978->f_pllout)
949 /* Switch PLL on */ 949 /* Switch PLL on */
950 snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20); 950 snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20);
951 951
952 return 0; 952 return 0;
953} 953}
@@ -971,9 +971,9 @@ static const int update_reg[] = {
971 WM8978_ROUT2_SPK_CONTROL, 971 WM8978_ROUT2_SPK_CONTROL,
972}; 972};
973 973
974static int wm8978_probe(struct snd_soc_codec *codec) 974static int wm8978_probe(struct snd_soc_component *component)
975{ 975{
976 struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); 976 struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component);
977 int i; 977 int i;
978 978
979 /* 979 /*
@@ -988,25 +988,26 @@ static int wm8978_probe(struct snd_soc_codec *codec)
988 * written. 988 * written.
989 */ 989 */
990 for (i = 0; i < ARRAY_SIZE(update_reg); i++) 990 for (i = 0; i < ARRAY_SIZE(update_reg); i++)
991 snd_soc_update_bits(codec, update_reg[i], 0x100, 0x100); 991 snd_soc_component_update_bits(component, update_reg[i], 0x100, 0x100);
992 992
993 return 0; 993 return 0;
994} 994}
995 995
996static const struct snd_soc_codec_driver soc_codec_dev_wm8978 = { 996static const struct snd_soc_component_driver soc_component_dev_wm8978 = {
997 .probe = wm8978_probe, 997 .probe = wm8978_probe,
998 .suspend = wm8978_suspend, 998 .suspend = wm8978_suspend,
999 .resume = wm8978_resume, 999 .resume = wm8978_resume,
1000 .set_bias_level = wm8978_set_bias_level, 1000 .set_bias_level = wm8978_set_bias_level,
1001 1001 .controls = wm8978_snd_controls,
1002 .component_driver = { 1002 .num_controls = ARRAY_SIZE(wm8978_snd_controls),
1003 .controls = wm8978_snd_controls, 1003 .dapm_widgets = wm8978_dapm_widgets,
1004 .num_controls = ARRAY_SIZE(wm8978_snd_controls), 1004 .num_dapm_widgets = ARRAY_SIZE(wm8978_dapm_widgets),
1005 .dapm_widgets = wm8978_dapm_widgets, 1005 .dapm_routes = wm8978_dapm_routes,
1006 .num_dapm_widgets = ARRAY_SIZE(wm8978_dapm_widgets), 1006 .num_dapm_routes = ARRAY_SIZE(wm8978_dapm_routes),
1007 .dapm_routes = wm8978_dapm_routes, 1007 .idle_bias_on = 1,
1008 .num_dapm_routes = ARRAY_SIZE(wm8978_dapm_routes), 1008 .use_pmdown_time = 1,
1009 }, 1009 .endianness = 1,
1010 .non_legacy_dai_naming = 1,
1010}; 1011};
1011 1012
1012static const struct regmap_config wm8978_regmap_config = { 1013static const struct regmap_config wm8978_regmap_config = {
@@ -1048,8 +1049,8 @@ static int wm8978_i2c_probe(struct i2c_client *i2c,
1048 return ret; 1049 return ret;
1049 } 1050 }
1050 1051
1051 ret = snd_soc_register_codec(&i2c->dev, 1052 ret = devm_snd_soc_register_component(&i2c->dev,
1052 &soc_codec_dev_wm8978, &wm8978_dai, 1); 1053 &soc_component_dev_wm8978, &wm8978_dai, 1);
1053 if (ret != 0) { 1054 if (ret != 0) {
1054 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); 1055 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
1055 return ret; 1056 return ret;
@@ -1058,13 +1059,6 @@ static int wm8978_i2c_probe(struct i2c_client *i2c,
1058 return 0; 1059 return 0;
1059} 1060}
1060 1061
1061static int wm8978_i2c_remove(struct i2c_client *client)
1062{
1063 snd_soc_unregister_codec(&client->dev);
1064
1065 return 0;
1066}
1067
1068static const struct i2c_device_id wm8978_i2c_id[] = { 1062static const struct i2c_device_id wm8978_i2c_id[] = {
1069 { "wm8978", 0 }, 1063 { "wm8978", 0 },
1070 { } 1064 { }
@@ -1083,7 +1077,6 @@ static struct i2c_driver wm8978_i2c_driver = {
1083 .of_match_table = wm8978_of_match, 1077 .of_match_table = wm8978_of_match,
1084 }, 1078 },
1085 .probe = wm8978_i2c_probe, 1079 .probe = wm8978_i2c_probe,
1086 .remove = wm8978_i2c_remove,
1087 .id_table = wm8978_i2c_id, 1080 .id_table = wm8978_i2c_id,
1088}; 1081};
1089 1082