···3737 struct arizona_haptics,3838 work);3939 struct arizona *arizona = haptics->arizona;4040+ struct snd_soc_component *component =4141+ snd_soc_dapm_to_component(arizona->dapm);4042 int ret;41434244 if (!haptics->arizona->dapm) {···6866 return;6967 }70687171- ret = snd_soc_dapm_enable_pin(arizona->dapm, "HAPTICS");6969+ ret = snd_soc_component_enable_pin(component, "HAPTICS");7270 if (ret != 0) {7371 dev_err(arizona->dev, "Failed to start HAPTICS: %d\n",7472 ret);···8381 }8482 } else {8583 /* This disable sequence will be a noop if already enabled */8686- ret = snd_soc_dapm_disable_pin(arizona->dapm, "HAPTICS");8484+ ret = snd_soc_component_disable_pin(component, "HAPTICS");8785 if (ret != 0) {8886 dev_err(arizona->dev, "Failed to disable HAPTICS: %d\n",8987 ret);···142140static void arizona_haptics_close(struct input_dev *input)143141{144142 struct arizona_haptics *haptics = input_get_drvdata(input);143143+ struct snd_soc_component *component;145144146145 cancel_work_sync(&haptics->work);147146148148- if (haptics->arizona->dapm)149149- snd_soc_dapm_disable_pin(haptics->arizona->dapm, "HAPTICS");147147+ if (haptics->arizona->dapm) {148148+ component = snd_soc_dapm_to_component(haptics->arizona->dapm);149149+ snd_soc_component_disable_pin(component, "HAPTICS");150150+ }150151}151152152153static int arizona_haptics_probe(struct platform_device *pdev)
+1
sound/soc/codecs/Kconfig
···8585 select SND_SOC_MAX98095 if I2C8686 select SND_SOC_MAX98357A if GPIOLIB8787 select SND_SOC_MAX98371 if I2C8888+ select SND_SOC_MAX98504 if I2C8889 select SND_SOC_MAX9867 if I2C8990 select SND_SOC_MAX98925 if I2C9091 select SND_SOC_MAX98926 if I2C
+125-17
sound/soc/codecs/nau8825.c
···4343#define GAIN_AUGMENT 225004444#define SIDETONE_BASE 20700045454646+/* the maximum frequency of CLK_ADC and CLK_DAC */4747+#define CLK_DA_AD_MAX 614400046484749static int nau8825_configure_sysclk(struct nau8825 *nau8825,4850 int clk_id, unsigned int freq);···9593 { 2, 0x1 },9694 { 4, 0x2 },9795 { 8, 0x3 },9696+};9797+9898+/* over sampling rate */9999+struct nau8825_osr_attr {100100+ unsigned int osr;101101+ unsigned int clk_src;102102+};103103+104104+static const struct nau8825_osr_attr osr_dac_sel[] = {105105+ { 64, 2 }, /* OSR 64, SRC 1/4 */106106+ { 256, 0 }, /* OSR 256, SRC 1 */107107+ { 128, 1 }, /* OSR 128, SRC 1/2 */108108+ { 0, 0 },109109+ { 32, 3 }, /* OSR 32, SRC 1/8 */110110+};111111+112112+static const struct nau8825_osr_attr osr_adc_sel[] = {113113+ { 32, 3 }, /* OSR 32, SRC 1/8 */114114+ { 64, 2 }, /* OSR 64, SRC 1/4 */115115+ { 128, 1 }, /* OSR 128, SRC 1/2 */116116+ { 256, 0 }, /* OSR 256, SRC 1 */98117};99118100119static const struct reg_default nau8825_reg_defaults[] = {···12021179 {"HPOR", NULL, "Class G"},12031180};1204118111821182+static int nau8825_clock_check(struct nau8825 *nau8825,11831183+ int stream, int rate, int osr)11841184+{11851185+ int osrate;11861186+11871187+ if (stream == SNDRV_PCM_STREAM_PLAYBACK) {11881188+ if (osr >= ARRAY_SIZE(osr_dac_sel))11891189+ return -EINVAL;11901190+ osrate = osr_dac_sel[osr].osr;11911191+ } else {11921192+ if (osr >= ARRAY_SIZE(osr_adc_sel))11931193+ return -EINVAL;11941194+ osrate = osr_adc_sel[osr].osr;11951195+ }11961196+11971197+ if (!osrate || rate * osr > CLK_DA_AD_MAX) {11981198+ dev_err(nau8825->dev, "exceed the maximum frequency of CLK_ADC or CLK_DAC\n");11991199+ return -EINVAL;12001200+ }12011201+12021202+ return 0;12031203+}12041204+12051205static int nau8825_hw_params(struct snd_pcm_substream *substream,12061206 struct snd_pcm_hw_params *params,12071207 struct snd_soc_dai *dai)12081208{12091209 struct snd_soc_codec *codec = dai->codec;12101210 struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec);12111211- unsigned int val_len = 0;12111211+ unsigned int val_len = 0, osr;1212121212131213- nau8825_sema_acquire(nau8825, 2 * HZ);12131213+ nau8825_sema_acquire(nau8825, 3 * HZ);12141214+12151215+ /* CLK_DAC or CLK_ADC = OSR * FS12161216+ * DAC or ADC clock frequency is defined as Over Sampling Rate (OSR)12171217+ * multiplied by the audio sample rate (Fs). Note that the OSR and Fs12181218+ * values must be selected such that the maximum frequency is less12191219+ * than 6.144 MHz.12201220+ */12211221+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {12221222+ regmap_read(nau8825->regmap, NAU8825_REG_DAC_CTRL1, &osr);12231223+ osr &= NAU8825_DAC_OVERSAMPLE_MASK;12241224+ if (nau8825_clock_check(nau8825, substream->stream,12251225+ params_rate(params), osr))12261226+ return -EINVAL;12271227+ regmap_update_bits(nau8825->regmap, NAU8825_REG_CLK_DIVIDER,12281228+ NAU8825_CLK_DAC_SRC_MASK,12291229+ osr_dac_sel[osr].clk_src << NAU8825_CLK_DAC_SRC_SFT);12301230+ } else {12311231+ regmap_read(nau8825->regmap, NAU8825_REG_ADC_RATE, &osr);12321232+ osr &= NAU8825_ADC_SYNC_DOWN_MASK;12331233+ if (nau8825_clock_check(nau8825, substream->stream,12341234+ params_rate(params), osr))12351235+ return -EINVAL;12361236+ regmap_update_bits(nau8825->regmap, NAU8825_REG_CLK_DIVIDER,12371237+ NAU8825_CLK_ADC_SRC_MASK,12381238+ osr_adc_sel[osr].clk_src << NAU8825_CLK_ADC_SRC_SFT);12391239+ }1214124012151241 switch (params_width(params)) {12161242 case 16:···12931221 struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec);12941222 unsigned int ctrl1_val = 0, ctrl2_val = 0;1295122312961296- nau8825_sema_acquire(nau8825, 2 * HZ);12241224+ nau8825_sema_acquire(nau8825, 3 * HZ);1297122512981226 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {12991227 case SND_SOC_DAIFMT_CBM_CFM:···18461774 * (audible hiss). Set it to something better.18471775 */18481776 regmap_update_bits(regmap, NAU8825_REG_ADC_RATE,18491849- NAU8825_ADC_SYNC_DOWN_MASK, NAU8825_ADC_SYNC_DOWN_128);17771777+ NAU8825_ADC_SYNC_DOWN_MASK | NAU8825_ADC_SINC4_EN,17781778+ NAU8825_ADC_SYNC_DOWN_64);18501779 regmap_update_bits(regmap, NAU8825_REG_DAC_CTRL1,18511851- NAU8825_DAC_OVERSAMPLE_MASK, NAU8825_DAC_OVERSAMPLE_128);17801780+ NAU8825_DAC_OVERSAMPLE_MASK, NAU8825_DAC_OVERSAMPLE_64);18521781 /* Disable DACR/L power */18531782 regmap_update_bits(regmap, NAU8825_REG_CHARGE_PUMP,18541783 NAU8825_POWER_DOWN_DACR | NAU8825_POWER_DOWN_DACL,···18841811 NAU8825_DACL_CH_SEL_MASK, NAU8825_DACL_CH_SEL_L);18851812 regmap_update_bits(nau8825->regmap, NAU8825_REG_DACR_CTRL,18861813 NAU8825_DACL_CH_SEL_MASK, NAU8825_DACL_CH_SEL_R);18141814+ /* Disable short Frame Sync detection logic */18151815+ regmap_update_bits(regmap, NAU8825_REG_LEFT_TIME_SLOT,18161816+ NAU8825_DIS_FS_SHORT_DET, NAU8825_DIS_FS_SHORT_DET);18871817}1888181818891819static const struct regmap_config nau8825_regmap_config = {···19951919 regmap_update_bits(nau8825->regmap, NAU8825_REG_CLK_DIVIDER,19961920 NAU8825_CLK_SRC_MASK | NAU8825_CLK_MCLK_SRC_MASK,19971921 NAU8825_CLK_SRC_MCLK | fll_param->mclk_src);19221922+ /* Make DSP operate at high speed for better performance. */19981923 regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL1,19991999- NAU8825_FLL_RATIO_MASK, fll_param->ratio);19241924+ NAU8825_FLL_RATIO_MASK | NAU8825_ICTRL_LATCH_MASK,19251925+ fll_param->ratio | (0x6 << NAU8825_ICTRL_LATCH_SFT));20001926 /* FLL 16-bit fractional input */20011927 regmap_write(nau8825->regmap, NAU8825_REG_FLL2, fll_param->fll_frac);20021928 /* FLL 10-bit integer input */···20141936 regmap_update_bits(nau8825->regmap,20151937 NAU8825_REG_FLL6, NAU8825_DCO_EN, 0);20161938 if (fll_param->fll_frac) {19391939+ /* set FLL loop filter enable and cutoff frequency at 500Khz */20171940 regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL5,20181941 NAU8825_FLL_PDB_DAC_EN | NAU8825_FLL_LOOP_FTR_EN |20191942 NAU8825_FLL_FTR_SW_MASK,20201943 NAU8825_FLL_PDB_DAC_EN | NAU8825_FLL_LOOP_FTR_EN |20211944 NAU8825_FLL_FTR_SW_FILTER);20221945 regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL6,20232023- NAU8825_SDM_EN, NAU8825_SDM_EN);19461946+ NAU8825_SDM_EN | NAU8825_CUTOFF500,19471947+ NAU8825_SDM_EN | NAU8825_CUTOFF500);20241948 } else {19491949+ /* disable FLL loop filter and cutoff frequency */20251950 regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL5,20261951 NAU8825_FLL_PDB_DAC_EN | NAU8825_FLL_LOOP_FTR_EN |20271952 NAU8825_FLL_FTR_SW_MASK, NAU8825_FLL_FTR_SW_ACCU);20282028- regmap_update_bits(nau8825->regmap,20292029- NAU8825_REG_FLL6, NAU8825_SDM_EN, 0);19531953+ regmap_update_bits(nau8825->regmap, NAU8825_REG_FLL6,19541954+ NAU8825_SDM_EN | NAU8825_CUTOFF500, 0);20301955 }20311956}20321957···20952014 NAU8825_CLK_SRC_MASK, NAU8825_CLK_SRC_MCLK);20962015 regmap_update_bits(regmap, NAU8825_REG_FLL6,20972016 NAU8825_DCO_EN, 0);20172017+ /* Make DSP operate as default setting for power saving. */20182018+ regmap_update_bits(regmap, NAU8825_REG_FLL1,20192019+ NAU8825_ICTRL_LATCH_MASK, 0);20982020}2099202121002022static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id,···21222038 * fered by cross talk process, the driver make the playback21232039 * preparation halted until cross talk process finish.21242040 */21252125- nau8825_sema_acquire(nau8825, 2 * HZ);20412041+ nau8825_sema_acquire(nau8825, 3 * HZ);21262042 nau8825_configure_mclk_as_sysclk(regmap);21272043 /* MCLK not changed by clock tree */21282044 regmap_update_bits(regmap, NAU8825_REG_CLK_DIVIDER,···21412057 NAU8825_DCO_EN, NAU8825_DCO_EN);21422058 regmap_update_bits(regmap, NAU8825_REG_CLK_DIVIDER,21432059 NAU8825_CLK_SRC_MASK, NAU8825_CLK_SRC_VCO);21442144- /* Decrease the VCO frequency for power saving */20602060+ /* Decrease the VCO frequency and make DSP operate20612061+ * as default setting for power saving.20622062+ */21452063 regmap_update_bits(regmap, NAU8825_REG_CLK_DIVIDER,21462064 NAU8825_CLK_MCLK_SRC_MASK, 0xf);21472065 regmap_update_bits(regmap, NAU8825_REG_FLL1,20662066+ NAU8825_ICTRL_LATCH_MASK |21482067 NAU8825_FLL_RATIO_MASK, 0x10);21492068 regmap_update_bits(regmap, NAU8825_REG_FLL6,21502069 NAU8825_SDM_EN, NAU8825_SDM_EN);···21702083 * fered by cross talk process, the driver make the playback21712084 * preparation halted until cross talk process finish.21722085 */21732173- nau8825_sema_acquire(nau8825, 2 * HZ);20862086+ nau8825_sema_acquire(nau8825, 3 * HZ);20872087+ /* Higher FLL reference input frequency can only set lower20882088+ * gain error, such as 0000 for input reference from MCLK20892089+ * 12.288Mhz.20902090+ */21742091 regmap_update_bits(regmap, NAU8825_REG_FLL3,21752175- NAU8825_FLL_CLK_SRC_MASK, NAU8825_FLL_CLK_SRC_MCLK);20922092+ NAU8825_FLL_CLK_SRC_MASK | NAU8825_GAIN_ERR_MASK,20932093+ NAU8825_FLL_CLK_SRC_MCLK | 0);21762094 /* Release the semaphone. */21772095 nau8825_sema_release(nau8825);21782096···21922100 * fered by cross talk process, the driver make the playback21932101 * preparation halted until cross talk process finish.21942102 */21952195- nau8825_sema_acquire(nau8825, 2 * HZ);21032103+ nau8825_sema_acquire(nau8825, 3 * HZ);21042104+ /* If FLL reference input is from low frequency source,21052105+ * higher error gain can apply such as 0xf which has21062106+ * the most sensitive gain error correction threshold,21072107+ * Therefore, FLL has the most accurate DCO to21082108+ * target frequency.21092109+ */21962110 regmap_update_bits(regmap, NAU8825_REG_FLL3,21972197- NAU8825_FLL_CLK_SRC_MASK, NAU8825_FLL_CLK_SRC_BLK);21112111+ NAU8825_FLL_CLK_SRC_MASK | NAU8825_GAIN_ERR_MASK,21122112+ NAU8825_FLL_CLK_SRC_BLK |21132113+ (0xf << NAU8825_GAIN_ERR_SFT));21982114 /* Release the semaphone. */21992115 nau8825_sema_release(nau8825);22002116···22182118 * fered by cross talk process, the driver make the playback22192119 * preparation halted until cross talk process finish.22202120 */22212221- nau8825_sema_acquire(nau8825, 2 * HZ);21212121+ nau8825_sema_acquire(nau8825, 3 * HZ);21222122+ /* If FLL reference input is from low frequency source,21232123+ * higher error gain can apply such as 0xf which has21242124+ * the most sensitive gain error correction threshold,21252125+ * Therefore, FLL has the most accurate DCO to21262126+ * target frequency.21272127+ */22222128 regmap_update_bits(regmap, NAU8825_REG_FLL3,22232223- NAU8825_FLL_CLK_SRC_MASK, NAU8825_FLL_CLK_SRC_FS);21292129+ NAU8825_FLL_CLK_SRC_MASK | NAU8825_GAIN_ERR_MASK,21302130+ NAU8825_FLL_CLK_SRC_FS |21312131+ (0xf << NAU8825_GAIN_ERR_SFT));22242132 /* Release the semaphone. */22252133 nau8825_sema_release(nau8825);22262134