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

ASoC: nau8825: Add registers patch for NAU8825C

The patch is to update default regmap and register a set of registers
for NAU8825C.

Signed-off-by: David Lin <CTLIN0@nuvoton.com>
Link: https://lore.kernel.org/r/20230602040924.188913-2-CTLIN0@nuvoton.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

David Lin and committed by
Mark Brown
b81a2cc9 1fbcc5ab

+38 -3
+34 -3
sound/soc/codecs/nau8825.c
··· 178 178 { NAU8825_REG_CLASSG_CTRL, 0x0 }, 179 179 { NAU8825_REG_OPT_EFUSE_CTRL, 0x0 }, 180 180 { NAU8825_REG_MISC_CTRL, 0x0 }, 181 + { NAU8825_REG_FLL2_LOWER, 0x0 }, 182 + { NAU8825_REG_FLL2_UPPER, 0x0 }, 181 183 { NAU8825_REG_BIAS_ADJ, 0x0 }, 182 184 { NAU8825_REG_TRIM_SETTINGS, 0x0 }, 183 185 { NAU8825_REG_ANALOG_CONTROL_1, 0x0 }, ··· 201 199 { NAU8825_REG_DACL_CTRL, 0x00cf }, 202 200 { NAU8825_REG_DACR_CTRL, 0x02cf }, 203 201 }; 202 + 203 + /* The regmap patch for Rev C */ 204 + static const struct reg_sequence nau8825_regmap_patch[] = { 205 + { NAU8825_REG_FLL2, 0x0000 }, 206 + { NAU8825_REG_FLL4, 0x8010 }, 207 + { NAU8825_REG_FLL_VCO_RSV, 0x0bc0 }, 208 + { NAU8825_REG_INTERRUPT_MASK, 0x0800 }, 209 + { NAU8825_REG_DACL_CTRL, 0x00cf }, 210 + { NAU8825_REG_DACR_CTRL, 0x02cf }, 211 + { NAU8825_REG_OPT_EFUSE_CTRL, 0x0400 }, 212 + { NAU8825_REG_FLL2_LOWER, 0x26e9 }, 213 + { NAU8825_REG_FLL2_UPPER, 0x0031 }, 214 + { NAU8825_REG_ANALOG_CONTROL_2, 0x0020 }, 215 + { NAU8825_REG_ANALOG_ADC_2, 0x0220 }, 216 + { NAU8825_REG_MIC_BIAS, 0x0046 }, 217 + }; 218 + 204 219 205 220 static const unsigned short logtable[256] = { 206 221 0x0000, 0x0171, 0x02e0, 0x044e, 0x05ba, 0x0725, 0x088e, 0x09f7, ··· 874 855 case NAU8825_REG_IMM_MODE_CTRL ... NAU8825_REG_IMM_RMS_R: 875 856 case NAU8825_REG_CLASSG_CTRL ... NAU8825_REG_OPT_EFUSE_CTRL: 876 857 case NAU8825_REG_MISC_CTRL: 877 - case NAU8825_REG_I2C_DEVICE_ID ... NAU8825_REG_SARDOUT_RAM_STATUS: 858 + case NAU8825_REG_I2C_DEVICE_ID ... NAU8825_REG_FLL2_UPPER: 878 859 case NAU8825_REG_BIAS_ADJ: 879 860 case NAU8825_REG_TRIM_SETTINGS ... NAU8825_REG_ANALOG_CONTROL_2: 880 861 case NAU8825_REG_ANALOG_ADC_1 ... NAU8825_REG_MIC_BIAS: ··· 900 881 case NAU8825_REG_IMM_MODE_CTRL: 901 882 case NAU8825_REG_CLASSG_CTRL ... NAU8825_REG_OPT_EFUSE_CTRL: 902 883 case NAU8825_REG_MISC_CTRL: 884 + case NAU8825_REG_FLL2_LOWER ... NAU8825_REG_FLL2_UPPER: 903 885 case NAU8825_REG_BIAS_ADJ: 904 886 case NAU8825_REG_TRIM_SETTINGS ... NAU8825_REG_ANALOG_CONTROL_2: 905 887 case NAU8825_REG_ANALOG_ADC_1 ... NAU8825_REG_MIC_BIAS: ··· 2950 2930 ret); 2951 2931 return ret; 2952 2932 } 2953 - if ((value & NAU8825_SOFTWARE_ID_MASK) != 2954 - NAU8825_SOFTWARE_ID_NAU8825) { 2933 + nau8825->sw_id = value & NAU8825_SOFTWARE_ID_MASK; 2934 + switch (nau8825->sw_id) { 2935 + case NAU8825_SOFTWARE_ID_NAU8825: 2936 + break; 2937 + case NAU8825_SOFTWARE_ID_NAU8825C: 2938 + ret = regmap_register_patch(nau8825->regmap, nau8825_regmap_patch, 2939 + ARRAY_SIZE(nau8825_regmap_patch)); 2940 + if (ret) { 2941 + dev_err(dev, "Failed to register Rev C patch: %d\n", ret); 2942 + return ret; 2943 + } 2944 + break; 2945 + default: 2955 2946 dev_err(dev, "Not a NAU8825 chip\n"); 2956 2947 return -ENODEV; 2957 2948 }
+4
sound/soc/codecs/nau8825.h
··· 75 75 #define NAU8825_REG_MISC_CTRL 0x55 76 76 #define NAU8825_REG_I2C_DEVICE_ID 0x58 77 77 #define NAU8825_REG_SARDOUT_RAM_STATUS 0x59 78 + #define NAU8825_REG_FLL2_LOWER 0x5a 79 + #define NAU8825_REG_FLL2_UPPER 0x5b 78 80 #define NAU8825_REG_BIAS_ADJ 0x66 79 81 #define NAU8825_REG_TRIM_SETTINGS 0x68 80 82 #define NAU8825_REG_ANALOG_CONTROL_1 0x69 ··· 388 386 #define NAU8825_GPIO2JD1 (1 << 7) 389 387 #define NAU8825_SOFTWARE_ID_MASK 0x3 390 388 #define NAU8825_SOFTWARE_ID_NAU8825 0x0 389 + #define NAU8825_SOFTWARE_ID_NAU8825C 0x1 391 390 392 391 /* BIAS_ADJ (0x66) */ 393 392 #define NAU8825_BIAS_HPR_IMP (1 << 15) ··· 500 497 struct clk *mclk; 501 498 struct work_struct xtalk_work; 502 499 struct semaphore xtalk_sem; 500 + int sw_id; 503 501 int irq; 504 502 int mclk_freq; /* 0 - mclk is disabled */ 505 503 int button_pressed;