static int adau1701_probe(struct snd_soc_codec *codec) { int i, ret; unsigned int val; struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); /* * Let the pll_clkdiv variable default to something that won't happen * at runtime. That way, we can postpone the firmware download from * adau1701_reset() to a point in time when we know the correct PLL * mode parameters. */ adau1701->pll_clkdiv = ADAU1707_CLKDIV_UNSET; /* initalize with pre-configured pll mode settings */ ret = adau1701_reset(codec, adau1701->pll_clkdiv); if (ret < 0) return ret; /* set up pin config */ val = 0; for (i = 0; i < 6; i++) val |= adau1701->pin_config[i] << (i * 4); regmap_write(adau1701->regmap, ADAU1701_PINCONF_0, val); val = 0; for (i = 0; i < 6; i++) val |= adau1701->pin_config[i + 6] << (i * 4); regmap_write(adau1701->regmap, ADAU1701_PINCONF_1, val); return 0; }
static int adau1701_resume(struct snd_soc_codec *codec) { struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); int ret; ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); if (ret < 0) { dev_err(codec->dev, "Failed to enable regulators: %d\n", ret); return ret; } return adau1701_reset(codec, adau1701->pll_clkdiv, 0); }
static int adau1701_probe(struct snd_soc_codec *codec) { int i, ret; unsigned int val; struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); ret = sigmadsp_attach(adau1701->sigmadsp, &codec->component); if (ret) return ret; ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); if (ret < 0) { dev_err(codec->dev, "Failed to enable regulators: %d\n", ret); return ret; } /* * Let the pll_clkdiv variable default to something that won't happen * at runtime. That way, we can postpone the firmware download from * adau1701_reset() to a point in time when we know the correct PLL * mode parameters. */ adau1701->pll_clkdiv = ADAU1707_CLKDIV_UNSET; /* initalize with pre-configured pll mode settings */ ret = adau1701_reset(codec, adau1701->pll_clkdiv, 0); if (ret < 0) goto exit_regulators_disable; /* set up pin config */ val = 0; for (i = 0; i < 6; i++) val |= adau1701->pin_config[i] << (i * 4); regmap_write(adau1701->regmap, ADAU1701_PINCONF_0, val); val = 0; for (i = 0; i < 6; i++) val |= adau1701->pin_config[i + 6] << (i * 4); regmap_write(adau1701->regmap, ADAU1701_PINCONF_1, val); return 0; exit_regulators_disable: regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); return ret; }
static int adau1701_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct snd_soc_codec *codec = dai->codec; struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); unsigned int clkdiv = adau1701->sysclk / params_rate(params); snd_pcm_format_t format; unsigned int val; int ret; /* * If the mclk/lrclk ratio changes, the chip needs updated PLL * mode GPIO settings, and a full reset cycle, including a new * firmware upload. */ if (clkdiv != adau1701->pll_clkdiv) { ret = adau1701_reset(codec, clkdiv); if (ret < 0) return ret; } switch (params_rate(params)) { case 192000: val = ADAU1701_DSPCTRL_SR_192; break; case 96000: val = ADAU1701_DSPCTRL_SR_96; break; case 48000: val = ADAU1701_DSPCTRL_SR_48; break; default: return -EINVAL; } regmap_update_bits(adau1701->regmap, ADAU1701_DSPCTRL, ADAU1701_DSPCTRL_SR_MASK, val); format = params_format(params); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) return adau1701_set_playback_pcm_format(codec, format); else return adau1701_set_capture_pcm_format(codec, format); }