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

Merge remote-tracking branches 'asoc/topic/wm8741', 'asoc/topic/wm8753', 'asoc/topic/wm8904', 'asoc/topic/wm8960' and 'asoc/topic/wm8983' into asoc-next

+211 -162
+14 -48
sound/soc/codecs/wm8741.c
··· 61 61 { 32, 0x0002 }, /* R32 - ADDITONAL_CONTROL_1 */ 62 62 }; 63 63 64 - static bool wm8741_readable(struct device *dev, unsigned int reg) 65 - { 66 - switch (reg) { 67 - case WM8741_DACLLSB_ATTENUATION: 68 - case WM8741_DACLMSB_ATTENUATION: 69 - case WM8741_DACRLSB_ATTENUATION: 70 - case WM8741_DACRMSB_ATTENUATION: 71 - case WM8741_VOLUME_CONTROL: 72 - case WM8741_FORMAT_CONTROL: 73 - case WM8741_FILTER_CONTROL: 74 - case WM8741_MODE_CONTROL_1: 75 - case WM8741_MODE_CONTROL_2: 76 - case WM8741_ADDITIONAL_CONTROL_1: 77 - return true; 78 - default: 79 - return false; 80 - } 81 - } 82 - 83 64 static int wm8741_reset(struct snd_soc_codec *codec) 84 65 { 85 66 return snd_soc_write(codec, WM8741_RESET, 0); ··· 259 278 switch (freq) { 260 279 case 0: 261 280 wm8741->sysclk_constraints = NULL; 262 - wm8741->sysclk = freq; 263 - return 0; 264 - 281 + break; 265 282 case 11289600: 266 283 wm8741->sysclk_constraints = &constraints_11289; 267 - wm8741->sysclk = freq; 268 - return 0; 269 - 284 + break; 270 285 case 12288000: 271 286 wm8741->sysclk_constraints = &constraints_12288; 272 - wm8741->sysclk = freq; 273 - return 0; 274 - 287 + break; 275 288 case 16384000: 276 289 wm8741->sysclk_constraints = &constraints_16384; 277 - wm8741->sysclk = freq; 278 - return 0; 279 - 290 + break; 280 291 case 16934400: 281 292 wm8741->sysclk_constraints = &constraints_16934; 282 - wm8741->sysclk = freq; 283 - return 0; 284 - 293 + break; 285 294 case 18432000: 286 295 wm8741->sysclk_constraints = &constraints_18432; 287 - wm8741->sysclk = freq; 288 - return 0; 289 - 296 + break; 290 297 case 22579200: 291 298 case 33868800: 292 299 wm8741->sysclk_constraints = &constraints_22579; 293 - wm8741->sysclk = freq; 294 - return 0; 295 - 300 + break; 296 301 case 24576000: 297 302 wm8741->sysclk_constraints = &constraints_24576; 298 - wm8741->sysclk = freq; 299 - return 0; 300 - 303 + break; 301 304 case 36864000: 302 305 wm8741->sysclk_constraints = &constraints_36864; 303 - wm8741->sysclk = freq; 304 - return 0; 306 + break; 307 + default: 308 + return -EINVAL; 305 309 } 306 - return -EINVAL; 310 + 311 + wm8741->sysclk = freq; 312 + return 0; 307 313 } 308 314 309 315 static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai, ··· 522 554 .reg_defaults = wm8741_reg_defaults, 523 555 .num_reg_defaults = ARRAY_SIZE(wm8741_reg_defaults), 524 556 .cache_type = REGCACHE_RBTREE, 525 - 526 - .readable_reg = wm8741_readable, 527 557 }; 528 558 529 559 static int wm8741_set_pdata(struct device *dev, struct wm8741_priv *wm8741)
-6
sound/soc/codecs/wm8753.c
··· 138 138 return reg == WM8753_RESET; 139 139 } 140 140 141 - static bool wm8753_writeable(struct device *dev, unsigned int reg) 142 - { 143 - return reg <= WM8753_ADCTL2; 144 - } 145 - 146 141 /* codec private data */ 147 142 struct wm8753_priv { 148 143 struct regmap *regmap; ··· 1504 1509 .val_bits = 9, 1505 1510 1506 1511 .max_register = WM8753_ADCTL2, 1507 - .writeable_reg = wm8753_writeable, 1508 1512 .volatile_reg = wm8753_volatile, 1509 1513 1510 1514 .cache_type = REGCACHE_RBTREE,
+3 -1
sound/soc/codecs/wm8904.c
··· 1837 1837 1838 1838 switch (level) { 1839 1839 case SND_SOC_BIAS_ON: 1840 - clk_prepare_enable(wm8904->mclk); 1840 + ret = clk_prepare_enable(wm8904->mclk); 1841 + if (ret) 1842 + return ret; 1841 1843 break; 1842 1844 1843 1845 case SND_SOC_BIAS_PREPARE:
+179 -41
sound/soc/codecs/wm8960.c
··· 48 48 #define WM8960_DISOP 0x40 49 49 #define WM8960_DRES_MASK 0x30 50 50 51 + static bool is_pll_freq_available(unsigned int source, unsigned int target); 52 + static int wm8960_set_pll(struct snd_soc_codec *codec, 53 + unsigned int freq_in, unsigned int freq_out); 51 54 /* 52 55 * wm8960 register cache 53 56 * We can't read the WM8960 register space when we are ··· 129 126 struct snd_soc_dapm_widget *rout1; 130 127 struct snd_soc_dapm_widget *out3; 131 128 bool deemph; 132 - int playback_fs; 129 + int lrclk; 133 130 int bclk; 134 131 int sysclk; 132 + int clk_id; 133 + int freq_in; 134 + bool is_stream_in_use[2]; 135 135 struct wm8960_data pdata; 136 136 }; 137 137 ··· 170 164 if (wm8960->deemph) { 171 165 best = 1; 172 166 for (i = 2; i < ARRAY_SIZE(deemph_settings); i++) { 173 - if (abs(deemph_settings[i] - wm8960->playback_fs) < 174 - abs(deemph_settings[best] - wm8960->playback_fs)) 167 + if (abs(deemph_settings[i] - wm8960->lrclk) < 168 + abs(deemph_settings[best] - wm8960->lrclk)) 175 169 best = i; 176 170 } 177 171 ··· 571 565 { 8000, 5 }, 572 566 }; 573 567 568 + /* -1 for reserved value */ 569 + static const int sysclk_divs[] = { 1, -1, 2, -1 }; 570 + 574 571 /* Multiply 256 for internal 256 div */ 575 572 static const int dac_divs[] = { 256, 384, 512, 768, 1024, 1408, 1536 }; 576 573 ··· 583 574 120, 160, 220, 240, 320, 320, 320 584 575 }; 585 576 586 - static void wm8960_configure_clocking(struct snd_soc_codec *codec, 587 - bool tx, int lrclk) 577 + static int wm8960_configure_clocking(struct snd_soc_codec *codec) 588 578 { 589 579 struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); 580 + int sysclk, bclk, lrclk, freq_out, freq_in; 590 581 u16 iface1 = snd_soc_read(codec, WM8960_IFACE1); 591 - u16 iface2 = snd_soc_read(codec, WM8960_IFACE2); 592 - u32 sysclk; 593 - int i, j; 582 + int i, j, k; 594 583 595 584 if (!(iface1 & (1<<6))) { 596 585 dev_dbg(codec->dev, 597 586 "Codec is slave mode, no need to configure clock\n"); 598 - return; 587 + return 0; 599 588 } 600 589 601 - if (!wm8960->sysclk) { 602 - dev_dbg(codec->dev, "No SYSCLK configured\n"); 603 - return; 590 + if (wm8960->clk_id != WM8960_SYSCLK_MCLK && !wm8960->freq_in) { 591 + dev_err(codec->dev, "No MCLK configured\n"); 592 + return -EINVAL; 604 593 } 605 594 606 - if (!wm8960->bclk || !lrclk) { 607 - dev_dbg(codec->dev, "No audio clocks configured\n"); 608 - return; 595 + freq_in = wm8960->freq_in; 596 + bclk = wm8960->bclk; 597 + lrclk = wm8960->lrclk; 598 + /* 599 + * If it's sysclk auto mode, check if the MCLK can provide sysclk or 600 + * not. If MCLK can provide sysclk, using MCLK to provide sysclk 601 + * directly. Otherwise, auto select a available pll out frequency 602 + * and set PLL. 603 + */ 604 + if (wm8960->clk_id == WM8960_SYSCLK_AUTO) { 605 + /* disable the PLL and using MCLK to provide sysclk */ 606 + wm8960_set_pll(codec, 0, 0); 607 + freq_out = freq_in; 608 + } else if (wm8960->sysclk) { 609 + freq_out = wm8960->sysclk; 610 + } else { 611 + dev_err(codec->dev, "No SYSCLK configured\n"); 612 + return -EINVAL; 609 613 } 610 614 611 - for (i = 0; i < ARRAY_SIZE(dac_divs); ++i) { 612 - if (wm8960->sysclk == lrclk * dac_divs[i]) { 613 - for (j = 0; j < ARRAY_SIZE(bclk_divs); ++j) { 614 - sysclk = wm8960->bclk * bclk_divs[j] / 10; 615 - if (wm8960->sysclk == sysclk) 615 + /* check if the sysclk frequency is available. */ 616 + for (i = 0; i < ARRAY_SIZE(sysclk_divs); ++i) { 617 + if (sysclk_divs[i] == -1) 618 + continue; 619 + sysclk = freq_out / sysclk_divs[i]; 620 + for (j = 0; j < ARRAY_SIZE(dac_divs); ++j) { 621 + if (sysclk == dac_divs[j] * lrclk) { 622 + for (k = 0; k < ARRAY_SIZE(bclk_divs); ++k) 623 + if (sysclk == bclk * bclk_divs[k] / 10) 624 + break; 625 + if (k != ARRAY_SIZE(bclk_divs)) 616 626 break; 617 627 } 618 - if(j != ARRAY_SIZE(bclk_divs)) 628 + } 629 + if (j != ARRAY_SIZE(dac_divs)) 630 + break; 631 + } 632 + 633 + if (i != ARRAY_SIZE(sysclk_divs)) { 634 + goto configure_clock; 635 + } else if (wm8960->clk_id != WM8960_SYSCLK_AUTO) { 636 + dev_err(codec->dev, "failed to configure clock\n"); 637 + return -EINVAL; 638 + } 639 + /* get a available pll out frequency and set pll */ 640 + for (i = 0; i < ARRAY_SIZE(sysclk_divs); ++i) { 641 + if (sysclk_divs[i] == -1) 642 + continue; 643 + for (j = 0; j < ARRAY_SIZE(dac_divs); ++j) { 644 + sysclk = lrclk * dac_divs[j]; 645 + freq_out = sysclk * sysclk_divs[i]; 646 + 647 + for (k = 0; k < ARRAY_SIZE(bclk_divs); ++k) { 648 + if (sysclk == bclk * bclk_divs[k] / 10 && 649 + is_pll_freq_available(freq_in, freq_out)) { 650 + wm8960_set_pll(codec, 651 + freq_in, freq_out); 652 + break; 653 + } else { 654 + continue; 655 + } 656 + } 657 + if (k != ARRAY_SIZE(bclk_divs)) 619 658 break; 620 659 } 660 + if (j != ARRAY_SIZE(dac_divs)) 661 + break; 621 662 } 622 663 623 - if (i == ARRAY_SIZE(dac_divs)) { 624 - dev_err(codec->dev, "Unsupported sysclk %d\n", wm8960->sysclk); 625 - return; 664 + if (i == ARRAY_SIZE(sysclk_divs)) { 665 + dev_err(codec->dev, "failed to configure clock\n"); 666 + return -EINVAL; 626 667 } 627 668 628 - /* 629 - * configure frame clock. If ADCLRC configure as GPIO pin, DACLRC 630 - * pin is used as a frame clock for ADCs and DACs. 631 - */ 632 - if (iface2 & (1<<6)) 633 - snd_soc_update_bits(codec, WM8960_CLOCK1, 0x7 << 3, i << 3); 634 - else if (tx) 635 - snd_soc_update_bits(codec, WM8960_CLOCK1, 0x7 << 3, i << 3); 636 - else if (!tx) 637 - snd_soc_update_bits(codec, WM8960_CLOCK1, 0x7 << 6, i << 6); 669 + configure_clock: 670 + /* configure sysclk clock */ 671 + snd_soc_update_bits(codec, WM8960_CLOCK1, 3 << 1, i << 1); 672 + 673 + /* configure frame clock */ 674 + snd_soc_update_bits(codec, WM8960_CLOCK1, 0x7 << 3, j << 3); 675 + snd_soc_update_bits(codec, WM8960_CLOCK1, 0x7 << 6, j << 6); 638 676 639 677 /* configure bit clock */ 640 - snd_soc_update_bits(codec, WM8960_CLOCK2, 0xf, j); 678 + snd_soc_update_bits(codec, WM8960_CLOCK2, 0xf, k); 679 + 680 + return 0; 641 681 } 642 682 643 683 static int wm8960_hw_params(struct snd_pcm_substream *substream, ··· 725 667 return -EINVAL; 726 668 } 727 669 670 + wm8960->lrclk = params_rate(params); 728 671 /* Update filters for the new rate */ 729 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 730 - wm8960->playback_fs = params_rate(params); 672 + if (tx) { 731 673 wm8960_set_deemph(codec); 732 674 } else { 733 675 for (i = 0; i < ARRAY_SIZE(alc_rates); i++) ··· 740 682 /* set iface */ 741 683 snd_soc_write(codec, WM8960_IFACE1, iface); 742 684 743 - wm8960_configure_clocking(codec, tx, params_rate(params)); 685 + wm8960->is_stream_in_use[tx] = true; 686 + 687 + if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON && 688 + !wm8960->is_stream_in_use[!tx]) 689 + return wm8960_configure_clocking(codec); 690 + 691 + return 0; 692 + } 693 + 694 + static int wm8960_hw_free(struct snd_pcm_substream *substream, 695 + struct snd_soc_dai *dai) 696 + { 697 + struct snd_soc_codec *codec = dai->codec; 698 + struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); 699 + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; 700 + 701 + wm8960->is_stream_in_use[tx] = false; 744 702 745 703 return 0; 746 704 } ··· 776 702 enum snd_soc_bias_level level) 777 703 { 778 704 struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); 705 + u16 pm2 = snd_soc_read(codec, WM8960_POWER2); 779 706 int ret; 780 707 781 708 switch (level) { ··· 796 721 } 797 722 } 798 723 724 + ret = wm8960_configure_clocking(codec); 725 + if (ret) 726 + return ret; 727 + 799 728 /* Set VMID to 2x50k */ 800 729 snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x80); 801 730 break; 802 731 803 732 case SND_SOC_BIAS_ON: 733 + /* 734 + * If it's sysclk auto mode, and the pll is enabled, 735 + * disable the pll 736 + */ 737 + if (wm8960->clk_id == WM8960_SYSCLK_AUTO && (pm2 & 0x1)) 738 + wm8960_set_pll(codec, 0, 0); 739 + 804 740 if (!IS_ERR(wm8960->mclk)) 805 741 clk_disable_unprepare(wm8960->mclk); 806 742 break; ··· 866 780 enum snd_soc_bias_level level) 867 781 { 868 782 struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); 783 + u16 pm2 = snd_soc_read(codec, WM8960_POWER2); 869 784 int reg, ret; 870 785 871 786 switch (level) { ··· 918 831 return ret; 919 832 } 920 833 } 834 + 835 + ret = wm8960_configure_clocking(codec); 836 + if (ret) 837 + return ret; 838 + 921 839 break; 922 840 923 841 case SND_SOC_BIAS_ON: 842 + /* 843 + * If it's sysclk auto mode, and the pll is enabled, 844 + * disable the pll 845 + */ 846 + if (wm8960->clk_id == WM8960_SYSCLK_AUTO && (pm2 & 0x1)) 847 + wm8960_set_pll(codec, 0, 0); 848 + 924 849 if (!IS_ERR(wm8960->mclk)) 925 850 clk_disable_unprepare(wm8960->mclk); 926 851 ··· 991 892 u32 k:24; 992 893 }; 993 894 895 + static bool is_pll_freq_available(unsigned int source, unsigned int target) 896 + { 897 + unsigned int Ndiv; 898 + 899 + if (source == 0 || target == 0) 900 + return false; 901 + 902 + /* Scale up target to PLL operating frequency */ 903 + target *= 4; 904 + Ndiv = target / source; 905 + 906 + if (Ndiv < 6) { 907 + source >>= 1; 908 + Ndiv = target / source; 909 + } 910 + 911 + if ((Ndiv < 6) || (Ndiv > 12)) 912 + return false; 913 + 914 + return true; 915 + } 916 + 994 917 /* The size in bits of the pll divide multiplied by 10 995 918 * to allow rounding later */ 996 919 #define FIXED_PLL_SIZE ((1 << 24) * 10) ··· 1064 943 return 0; 1065 944 } 1066 945 1067 - static int wm8960_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, 1068 - int source, unsigned int freq_in, unsigned int freq_out) 946 + static int wm8960_set_pll(struct snd_soc_codec *codec, 947 + unsigned int freq_in, unsigned int freq_out) 1069 948 { 1070 - struct snd_soc_codec *codec = codec_dai->codec; 1071 949 u16 reg; 1072 950 static struct _pll_div pll_div; 1073 951 int ret; ··· 1104 984 snd_soc_update_bits(codec, WM8960_CLOCK1, 0x1, 0x1); 1105 985 1106 986 return 0; 987 + } 988 + 989 + static int wm8960_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, 990 + int source, unsigned int freq_in, unsigned int freq_out) 991 + { 992 + struct snd_soc_codec *codec = codec_dai->codec; 993 + struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); 994 + 995 + wm8960->freq_in = freq_in; 996 + 997 + if (pll_id == WM8960_SYSCLK_AUTO) 998 + return 0; 999 + 1000 + return wm8960_set_pll(codec, freq_in, freq_out); 1107 1001 } 1108 1002 1109 1003 static int wm8960_set_dai_clkdiv(struct snd_soc_dai *codec_dai, ··· 1177 1043 snd_soc_update_bits(codec, WM8960_CLOCK1, 1178 1044 0x1, WM8960_SYSCLK_PLL); 1179 1045 break; 1046 + case WM8960_SYSCLK_AUTO: 1047 + break; 1180 1048 default: 1181 1049 return -EINVAL; 1182 1050 } 1183 1051 1184 1052 wm8960->sysclk = freq; 1053 + wm8960->clk_id = clk_id; 1185 1054 1186 1055 return 0; 1187 1056 } ··· 1197 1060 1198 1061 static const struct snd_soc_dai_ops wm8960_dai_ops = { 1199 1062 .hw_params = wm8960_hw_params, 1063 + .hw_free = wm8960_hw_free, 1200 1064 .digital_mute = wm8960_mute, 1201 1065 .set_fmt = wm8960_set_dai_fmt, 1202 1066 .set_clkdiv = wm8960_set_dai_clkdiv,
+1
sound/soc/codecs/wm8960.h
··· 82 82 83 83 #define WM8960_SYSCLK_MCLK (0 << 0) 84 84 #define WM8960_SYSCLK_PLL (1 << 0) 85 + #define WM8960_SYSCLK_AUTO (2 << 0) 85 86 86 87 #define WM8960_DAC_DIV_1 (0 << 3) 87 88 #define WM8960_DAC_DIV_1_5 (1 << 3)
+14 -66
sound/soc/codecs/wm8983.c
··· 84 84 { 0x3D, 0x0000 }, /* R61 - BIAS CTRL */ 85 85 }; 86 86 87 - static const struct wm8983_reg_access { 88 - u16 read; /* Mask of readable bits */ 89 - u16 write; /* Mask of writable bits */ 90 - } wm8983_access_masks[WM8983_MAX_REGISTER + 1] = { 91 - [0x00] = { 0x0000, 0x01FF }, /* R0 - Software Reset */ 92 - [0x01] = { 0x0000, 0x01FF }, /* R1 - Power management 1 */ 93 - [0x02] = { 0x0000, 0x01FF }, /* R2 - Power management 2 */ 94 - [0x03] = { 0x0000, 0x01EF }, /* R3 - Power management 3 */ 95 - [0x04] = { 0x0000, 0x01FF }, /* R4 - Audio Interface */ 96 - [0x05] = { 0x0000, 0x003F }, /* R5 - Companding control */ 97 - [0x06] = { 0x0000, 0x01FD }, /* R6 - Clock Gen control */ 98 - [0x07] = { 0x0000, 0x000F }, /* R7 - Additional control */ 99 - [0x08] = { 0x0000, 0x003F }, /* R8 - GPIO Control */ 100 - [0x09] = { 0x0000, 0x0070 }, /* R9 - Jack Detect Control 1 */ 101 - [0x0A] = { 0x0000, 0x004F }, /* R10 - DAC Control */ 102 - [0x0B] = { 0x0000, 0x01FF }, /* R11 - Left DAC digital Vol */ 103 - [0x0C] = { 0x0000, 0x01FF }, /* R12 - Right DAC digital vol */ 104 - [0x0D] = { 0x0000, 0x00FF }, /* R13 - Jack Detect Control 2 */ 105 - [0x0E] = { 0x0000, 0x01FB }, /* R14 - ADC Control */ 106 - [0x0F] = { 0x0000, 0x01FF }, /* R15 - Left ADC Digital Vol */ 107 - [0x10] = { 0x0000, 0x01FF }, /* R16 - Right ADC Digital Vol */ 108 - [0x12] = { 0x0000, 0x017F }, /* R18 - EQ1 - low shelf */ 109 - [0x13] = { 0x0000, 0x017F }, /* R19 - EQ2 - peak 1 */ 110 - [0x14] = { 0x0000, 0x017F }, /* R20 - EQ3 - peak 2 */ 111 - [0x15] = { 0x0000, 0x017F }, /* R21 - EQ4 - peak 3 */ 112 - [0x16] = { 0x0000, 0x007F }, /* R22 - EQ5 - high shelf */ 113 - [0x18] = { 0x0000, 0x01FF }, /* R24 - DAC Limiter 1 */ 114 - [0x19] = { 0x0000, 0x007F }, /* R25 - DAC Limiter 2 */ 115 - [0x1B] = { 0x0000, 0x01FF }, /* R27 - Notch Filter 1 */ 116 - [0x1C] = { 0x0000, 0x017F }, /* R28 - Notch Filter 2 */ 117 - [0x1D] = { 0x0000, 0x017F }, /* R29 - Notch Filter 3 */ 118 - [0x1E] = { 0x0000, 0x017F }, /* R30 - Notch Filter 4 */ 119 - [0x20] = { 0x0000, 0x01BF }, /* R32 - ALC control 1 */ 120 - [0x21] = { 0x0000, 0x00FF }, /* R33 - ALC control 2 */ 121 - [0x22] = { 0x0000, 0x01FF }, /* R34 - ALC control 3 */ 122 - [0x23] = { 0x0000, 0x000F }, /* R35 - Noise Gate */ 123 - [0x24] = { 0x0000, 0x001F }, /* R36 - PLL N */ 124 - [0x25] = { 0x0000, 0x003F }, /* R37 - PLL K 1 */ 125 - [0x26] = { 0x0000, 0x01FF }, /* R38 - PLL K 2 */ 126 - [0x27] = { 0x0000, 0x01FF }, /* R39 - PLL K 3 */ 127 - [0x29] = { 0x0000, 0x000F }, /* R41 - 3D control */ 128 - [0x2A] = { 0x0000, 0x01E7 }, /* R42 - OUT4 to ADC */ 129 - [0x2B] = { 0x0000, 0x01BF }, /* R43 - Beep control */ 130 - [0x2C] = { 0x0000, 0x0177 }, /* R44 - Input ctrl */ 131 - [0x2D] = { 0x0000, 0x01FF }, /* R45 - Left INP PGA gain ctrl */ 132 - [0x2E] = { 0x0000, 0x01FF }, /* R46 - Right INP PGA gain ctrl */ 133 - [0x2F] = { 0x0000, 0x0177 }, /* R47 - Left ADC BOOST ctrl */ 134 - [0x30] = { 0x0000, 0x0177 }, /* R48 - Right ADC BOOST ctrl */ 135 - [0x31] = { 0x0000, 0x007F }, /* R49 - Output ctrl */ 136 - [0x32] = { 0x0000, 0x01FF }, /* R50 - Left mixer ctrl */ 137 - [0x33] = { 0x0000, 0x01FF }, /* R51 - Right mixer ctrl */ 138 - [0x34] = { 0x0000, 0x01FF }, /* R52 - LOUT1 (HP) volume ctrl */ 139 - [0x35] = { 0x0000, 0x01FF }, /* R53 - ROUT1 (HP) volume ctrl */ 140 - [0x36] = { 0x0000, 0x01FF }, /* R54 - LOUT2 (SPK) volume ctrl */ 141 - [0x37] = { 0x0000, 0x01FF }, /* R55 - ROUT2 (SPK) volume ctrl */ 142 - [0x38] = { 0x0000, 0x004F }, /* R56 - OUT3 mixer ctrl */ 143 - [0x39] = { 0x0000, 0x00FF }, /* R57 - OUT4 (MONO) mix ctrl */ 144 - [0x3D] = { 0x0000, 0x0100 } /* R61 - BIAS CTRL */ 145 - }; 146 - 147 87 /* vol/gain update regs */ 148 88 static const int vol_update_regs[] = { 149 89 WM8983_LEFT_DAC_DIGITAL_VOL, ··· 545 605 return 0; 546 606 } 547 607 548 - static bool wm8983_readable(struct device *dev, unsigned int reg) 608 + static bool wm8983_writeable(struct device *dev, unsigned int reg) 549 609 { 550 - if (reg > WM8983_MAX_REGISTER) 551 - return 0; 552 - 553 - return wm8983_access_masks[reg].read != 0; 610 + switch (reg) { 611 + case WM8983_SOFTWARE_RESET ... WM8983_RIGHT_ADC_DIGITAL_VOL: 612 + case WM8983_EQ1_LOW_SHELF ... WM8983_DAC_LIMITER_2: 613 + case WM8983_NOTCH_FILTER_1 ... WM8983_NOTCH_FILTER_4: 614 + case WM8983_ALC_CONTROL_1 ... WM8983_PLL_K_3: 615 + case WM8983_3D_CONTROL ... WM8983_OUT4_MONO_MIX_CTRL: 616 + case WM8983_BIAS_CTRL: 617 + return true; 618 + default: 619 + return false; 620 + } 554 621 } 555 622 556 623 static int wm8983_dac_mute(struct snd_soc_dai *dai, int mute) ··· 995 1048 .reg_defaults = wm8983_defaults, 996 1049 .num_reg_defaults = ARRAY_SIZE(wm8983_defaults), 997 1050 .cache_type = REGCACHE_RBTREE, 1051 + .max_register = WM8983_MAX_REGISTER, 998 1052 999 - .readable_reg = wm8983_readable, 1053 + .writeable_reg = wm8983_writeable, 1000 1054 }; 1001 1055 1002 1056 #if defined(CONFIG_SPI_MASTER)