14 #include <linux/module.h>
21 #include <linux/i2c.h>
22 #include <linux/input.h>
26 #include <linux/slab.h>
40 #define WM8962_NUM_SUPPLIES 8
76 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
77 struct input_dev *beep;
83 struct gpio_chip gpio_chip;
93 #define WM8962_REGULATOR_EVENT(n) \
94 static int wm8962_regulator_event_##n(struct notifier_block *nb, \
95 unsigned long event, void *data) \
97 struct wm8962_priv *wm8962 = container_of(nb, struct wm8962_priv, \
99 if (event & REGULATOR_EVENT_DISABLE) { \
100 regcache_mark_dirty(wm8962->regmap); \
788 static bool wm8962_volatile_register(
struct device *
dev,
unsigned int reg)
808 static bool wm8962_readable_register(
struct device *dev,
unsigned int reg)
1444 static int wm8962_reset(
struct wm8962_priv *wm8962)
1457 static const unsigned int mixinpga_tlv[] = {
1472 static const unsigned int classd_tlv[] = {
1510 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
1512 wm8962_dsp2_write_config(codec);
1516 wm8962_dsp2_set_enable(codec, wm8962->
dsp2_ena);
1523 wm8962_dsp2_set_enable(codec, 0);
1530 #define WM8962_DSP2_ENABLE(xname, xshift) \
1531 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
1532 .info = wm8962_dsp2_ena_info, \
1533 .get = wm8962_dsp2_ena_get, .put = wm8962_dsp2_ena_put, \
1534 .private_value = xshift }
1536 static int wm8962_dsp2_ena_info(
struct snd_kcontrol *kcontrol,
1548 static int wm8962_dsp2_ena_get(
struct snd_kcontrol *kcontrol,
1553 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
1555 ucontrol->
value.integer.value[0] = !!(wm8962->
dsp2_ena & 1 << shift);
1560 static int wm8962_dsp2_ena_put(
struct snd_kcontrol *kcontrol,
1565 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
1573 if (ucontrol->
value.integer.value[0])
1585 wm8962_dsp2_set_enable(codec, wm8962->
dsp2_ena);
1587 wm8962_dsp2_stop(codec);
1599 static int wm8962_put_hp_sw(
struct snd_kcontrol *kcontrol,
1627 static int wm8962_put_spk_sw(
struct snd_kcontrol *kcontrol,
1654 static const char *cap_hpf_mode_text[] = {
1655 "Hi-fi",
"Application"
1658 static const struct soc_enum cap_hpf_mode =
1662 static const char *cap_lhpf_mode_text[] = {
1666 static const struct soc_enum cap_lhpf_mode =
1695 SOC_ENUM(
"Capture HPF Mode", cap_hpf_mode),
1698 SOC_ENUM(
"Capture LHPF Mode", cap_lhpf_mode),
1727 3, 7, 0, bypass_tlv),
1729 0, 7, 0, bypass_tlv),
1731 7, 1, 1, inmix_tlv),
1733 6, 1, 1, inmix_tlv),
1736 3, 7, 0, bypass_tlv),
1738 0, 7, 0, bypass_tlv),
1740 7, 1, 1, inmix_tlv),
1742 6, 1, 1, inmix_tlv),
1785 3, 7, 0, bypass_tlv),
1787 0, 7, 0, bypass_tlv),
1789 7, 1, 1, inmix_tlv),
1791 6, 1, 1, inmix_tlv),
1793 7, 1, 0, inmix_tlv),
1795 6, 1, 0, inmix_tlv),
1810 3, 7, 0, bypass_tlv),
1812 0, 7, 0, bypass_tlv),
1814 7, 1, 1, inmix_tlv),
1816 6, 1, 1, inmix_tlv),
1818 7, 1, 0, inmix_tlv),
1820 6, 1, 0, inmix_tlv),
1823 3, 7, 0, bypass_tlv),
1825 0, 7, 0, bypass_tlv),
1827 7, 1, 1, inmix_tlv),
1829 6, 1, 1, inmix_tlv),
1831 5, 1, 0, inmix_tlv),
1833 4, 1, 0, inmix_tlv),
1888 "Failed to read DCS status: %d\n",
1892 dev_dbg(codec->
dev,
"DCS status: %x\n", reg);
1893 }
while (++timeout < 200 && (reg & expected) != expected);
1895 if ((reg & expected) != expected)
1898 dev_dbg(codec->
dev,
"DC servo complete after %dms\n",
1983 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
1988 wm8962_dsp2_start(codec);
1993 wm8962_dsp2_stop(codec);
2004 static const char *st_text[] = {
"None",
"Left",
"Right" };
2006 static const struct soc_enum str_enum =
2012 static const struct soc_enum stl_enum =
2018 static const char *outmux_text[] = {
"DAC",
"Mixer" };
2020 static const struct soc_enum spkoutr_enum =
2026 static const struct soc_enum spkoutl_enum =
2032 static const struct soc_enum hpoutr_enum =
2038 static const struct soc_enum hpoutl_enum =
2199 {
"INPGAL",
"IN1L Switch",
"IN1L" },
2200 {
"INPGAL",
"IN2L Switch",
"IN2L" },
2201 {
"INPGAL",
"IN3L Switch",
"IN3L" },
2202 {
"INPGAL",
"IN4L Switch",
"IN4L" },
2204 {
"INPGAR",
"IN1R Switch",
"IN1R" },
2205 {
"INPGAR",
"IN2R Switch",
"IN2R" },
2206 {
"INPGAR",
"IN3R Switch",
"IN3R" },
2207 {
"INPGAR",
"IN4R Switch",
"IN4R" },
2209 {
"MIXINL",
"IN2L Switch",
"IN2L" },
2210 {
"MIXINL",
"IN3L Switch",
"IN3L" },
2211 {
"MIXINL",
"PGA Switch",
"INPGAL" },
2213 {
"MIXINR",
"IN2R Switch",
"IN2R" },
2214 {
"MIXINR",
"IN3R Switch",
"IN3R" },
2215 {
"MIXINR",
"PGA Switch",
"INPGAR" },
2217 {
"MICBIAS",
NULL,
"SYSCLK" },
2219 {
"DMIC_ENA",
NULL,
"DMICDAT" },
2221 {
"ADCL",
NULL,
"SYSCLK" },
2222 {
"ADCL",
NULL,
"TOCLK" },
2223 {
"ADCL",
NULL,
"MIXINL" },
2224 {
"ADCL",
NULL,
"DMIC_ENA" },
2225 {
"ADCL",
NULL,
"DSP2" },
2227 {
"ADCR",
NULL,
"SYSCLK" },
2228 {
"ADCR",
NULL,
"TOCLK" },
2229 {
"ADCR",
NULL,
"MIXINR" },
2230 {
"ADCR",
NULL,
"DMIC_ENA" },
2231 {
"ADCR",
NULL,
"DSP2" },
2233 {
"STL",
"Left",
"ADCL" },
2234 {
"STL",
"Right",
"ADCR" },
2235 {
"STL",
NULL,
"Class G" },
2237 {
"STR",
"Left",
"ADCL" },
2238 {
"STR",
"Right",
"ADCR" },
2239 {
"STR",
NULL,
"Class G" },
2241 {
"DACL",
NULL,
"SYSCLK" },
2242 {
"DACL",
NULL,
"TOCLK" },
2243 {
"DACL",
NULL,
"Beep" },
2244 {
"DACL",
NULL,
"STL" },
2245 {
"DACL",
NULL,
"DSP2" },
2247 {
"DACR",
NULL,
"SYSCLK" },
2248 {
"DACR",
NULL,
"TOCLK" },
2249 {
"DACR",
NULL,
"Beep" },
2250 {
"DACR",
NULL,
"STR" },
2251 {
"DACR",
NULL,
"DSP2" },
2253 {
"HPMIXL",
"IN4L Switch",
"IN4L" },
2254 {
"HPMIXL",
"IN4R Switch",
"IN4R" },
2255 {
"HPMIXL",
"DACL Switch",
"DACL" },
2256 {
"HPMIXL",
"DACR Switch",
"DACR" },
2257 {
"HPMIXL",
"MIXINL Switch",
"MIXINL" },
2258 {
"HPMIXL",
"MIXINR Switch",
"MIXINR" },
2260 {
"HPMIXR",
"IN4L Switch",
"IN4L" },
2261 {
"HPMIXR",
"IN4R Switch",
"IN4R" },
2262 {
"HPMIXR",
"DACL Switch",
"DACL" },
2263 {
"HPMIXR",
"DACR Switch",
"DACR" },
2264 {
"HPMIXR",
"MIXINL Switch",
"MIXINL" },
2265 {
"HPMIXR",
"MIXINR Switch",
"MIXINR" },
2267 {
"Left Bypass",
NULL,
"HPMIXL" },
2268 {
"Left Bypass",
NULL,
"Class G" },
2270 {
"Right Bypass",
NULL,
"HPMIXR" },
2271 {
"Right Bypass",
NULL,
"Class G" },
2273 {
"HPOUTL PGA",
"Mixer",
"Left Bypass" },
2274 {
"HPOUTL PGA",
"DAC",
"DACL" },
2276 {
"HPOUTR PGA",
"Mixer",
"Right Bypass" },
2277 {
"HPOUTR PGA",
"DAC",
"DACR" },
2279 {
"HPOUT",
NULL,
"HPOUTL PGA" },
2280 {
"HPOUT",
NULL,
"HPOUTR PGA" },
2281 {
"HPOUT",
NULL,
"Charge Pump" },
2282 {
"HPOUT",
NULL,
"SYSCLK" },
2283 {
"HPOUT",
NULL,
"TOCLK" },
2285 {
"HPOUTL",
NULL,
"HPOUT" },
2286 {
"HPOUTR",
NULL,
"HPOUT" },
2288 {
"HPOUTL",
NULL,
"TEMP_HP" },
2289 {
"HPOUTR",
NULL,
"TEMP_HP" },
2293 {
"Speaker Mixer",
"IN4L Switch",
"IN4L" },
2294 {
"Speaker Mixer",
"IN4R Switch",
"IN4R" },
2295 {
"Speaker Mixer",
"DACL Switch",
"DACL" },
2296 {
"Speaker Mixer",
"DACR Switch",
"DACR" },
2297 {
"Speaker Mixer",
"MIXINL Switch",
"MIXINL" },
2298 {
"Speaker Mixer",
"MIXINR Switch",
"MIXINR" },
2300 {
"Speaker PGA",
"Mixer",
"Speaker Mixer" },
2301 {
"Speaker PGA",
"DAC",
"DACL" },
2303 {
"Speaker Output",
NULL,
"Speaker PGA" },
2304 {
"Speaker Output",
NULL,
"SYSCLK" },
2305 {
"Speaker Output",
NULL,
"TOCLK" },
2306 {
"Speaker Output",
NULL,
"TEMP_SPK" },
2308 {
"SPKOUT",
NULL,
"Speaker Output" },
2312 {
"SPKOUTL Mixer",
"IN4L Switch",
"IN4L" },
2313 {
"SPKOUTL Mixer",
"IN4R Switch",
"IN4R" },
2314 {
"SPKOUTL Mixer",
"DACL Switch",
"DACL" },
2315 {
"SPKOUTL Mixer",
"DACR Switch",
"DACR" },
2316 {
"SPKOUTL Mixer",
"MIXINL Switch",
"MIXINL" },
2317 {
"SPKOUTL Mixer",
"MIXINR Switch",
"MIXINR" },
2319 {
"SPKOUTR Mixer",
"IN4L Switch",
"IN4L" },
2320 {
"SPKOUTR Mixer",
"IN4R Switch",
"IN4R" },
2321 {
"SPKOUTR Mixer",
"DACL Switch",
"DACL" },
2322 {
"SPKOUTR Mixer",
"DACR Switch",
"DACR" },
2323 {
"SPKOUTR Mixer",
"MIXINL Switch",
"MIXINL" },
2324 {
"SPKOUTR Mixer",
"MIXINR Switch",
"MIXINR" },
2326 {
"SPKOUTL PGA",
"Mixer",
"SPKOUTL Mixer" },
2327 {
"SPKOUTL PGA",
"DAC",
"DACL" },
2329 {
"SPKOUTR PGA",
"Mixer",
"SPKOUTR Mixer" },
2330 {
"SPKOUTR PGA",
"DAC",
"DACR" },
2332 {
"SPKOUTL Output",
NULL,
"SPKOUTL PGA" },
2333 {
"SPKOUTL Output",
NULL,
"SYSCLK" },
2334 {
"SPKOUTL Output",
NULL,
"TOCLK" },
2335 {
"SPKOUTL Output",
NULL,
"TEMP_SPK" },
2337 {
"SPKOUTR Output",
NULL,
"SPKOUTR PGA" },
2338 {
"SPKOUTR Output",
NULL,
"SYSCLK" },
2339 {
"SPKOUTR Output",
NULL,
"TOCLK" },
2340 {
"SPKOUTR Output",
NULL,
"TEMP_SPK" },
2342 {
"SPKOUTL",
NULL,
"SPKOUTL Output" },
2343 {
"SPKOUTR",
NULL,
"SPKOUTR Output" },
2386 static const int bclk_divs[] = {
2387 1, -1, 2, 3, 4, -1, 6, 8, -1, 12, 16, 24, -1, 32, 32, 32
2390 static const int sysclk_rates[] = {
2391 64, 128, 192, 256, 384, 512, 768, 1024, 1408, 1536, 3072, 6144
2394 static void wm8962_configure_bclk(
struct snd_soc_codec *codec)
2396 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
2403 dev_dbg(codec->
dev,
"No SYSCLK configured\n");
2408 dev_dbg(codec->
dev,
"No audio clocks configured\n");
2412 for (i = 0; i <
ARRAY_SIZE(sysclk_rates); i++) {
2420 dev_err(codec->
dev,
"Unsupported sysclk ratio %d\n",
2425 dev_dbg(codec->
dev,
"Selected sysclk ratio %d\n", sysclk_rates[i]);
2432 dev_err(codec->
dev,
"Failed to read DSPCLK: %d\n", dspclk);
2448 dev_warn(codec->
dev,
"Unknown DSPCLK divisor read back\n");
2452 dev_dbg(codec->
dev,
"DSPCLK is %dHz, BCLK %d\n", dspclk, wm8962->
bclk);
2455 for (i = 0; i <
ARRAY_SIZE(bclk_divs); i++) {
2456 if (bclk_divs[i] < 0)
2459 if (dspclk / bclk_divs[i] == wm8962->
bclk) {
2460 dev_dbg(codec->
dev,
"Selected BCLK_DIV %d for %dHz\n",
2461 bclk_divs[i], wm8962->
bclk);
2467 dev_err(codec->
dev,
"Unsupported BCLK ratio %d\n",
2468 dspclk / wm8962->
bclk);
2473 dev_dbg(codec->
dev,
"Selected LRCLK divisor %d for %dHz\n",
2482 static int wm8962_set_bias_level(
struct snd_soc_codec *codec,
2485 if (level == codec->
dapm.bias_level)
2497 wm8962_configure_bclk(codec);
2517 static const struct {
2539 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
2552 adctl3 |= sr_vals[
i].reg;
2561 if (wm8962->
lrclk % 8000 == 0)
2586 dev_dbg(codec->
dev,
"hw_params set BCLK %dHz LRCLK %dHz\n",
2590 wm8962_configure_bclk(codec);
2595 static int wm8962_set_dai_sysclk(
struct snd_soc_dai *dai,
int clk_id,
2596 unsigned int freq,
int dir)
2599 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
2620 wm8962_configure_bclk(codec);
2625 static int wm8962_set_dai_fmt(
struct snd_soc_dai *dai,
unsigned int fmt)
2701 #define FIXED_FLL_SIZE ((1 << 16) * 10)
2709 { 0, 64000, 4, 16 },
2710 { 64000, 128000, 3, 8 },
2711 { 128000, 256000, 2, 4 },
2712 { 256000, 1000000, 1, 2 },
2713 { 1000000, 13500000, 0, 1 },
2721 unsigned int fratio, gcd_fll;
2727 while ((Fref / div) > 13500000) {
2732 pr_err(
"Can't scale %dMHz input down to <=13.5MHz\n",
2738 pr_debug(
"FLL Fref=%u Fout=%u\n", Fref, Fout);
2745 while (Fout * div < 90000000) {
2748 pr_err(
"Unable to find FLL_OUTDIV for Fout=%uHz\n",
2753 target = Fout *
div;
2756 pr_debug(
"FLL Fvco=%dHz\n", target);
2759 for (i = 0; i <
ARRAY_SIZE(fll_fratios); i++) {
2760 if (fll_fratios[i].
min <= Fref && Fref <= fll_fratios[i].
max) {
2762 fratio = fll_fratios[
i].ratio;
2767 pr_err(
"Unable to find FLL_FRATIO for Fref=%uHz\n", Fref);
2771 fll_div->
n = target / (fratio * Fref);
2773 if (target % Fref == 0) {
2777 gcd_fll =
gcd(target, fratio * Fref);
2779 fll_div->
theta = (target - (fll_div->
n * fratio * Fref))
2781 fll_div->
lambda = (fratio * Fref) / gcd_fll;
2784 pr_debug(
"FLL N=%x THETA=%x LAMBDA=%x\n",
2786 pr_debug(
"FLL_FRATIO=%x FLL_OUTDIV=%x FLL_REFCLK_DIV=%x\n",
2794 unsigned int Fref,
unsigned int Fout)
2796 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
2798 unsigned long timeout;
2816 pm_runtime_put(codec->
dev);
2841 dev_err(codec->
dev,
"Unknown FLL source %d\n", ret);
2866 pm_runtime_get_sync(codec->
dev);
2872 dev_dbg(codec->
dev,
"FLL configured for %dHz->%dHz\n", Fref, Fout);
2888 if (timeout == 0 && wm8962->
irq) {
2915 #define WM8962_RATES SNDRV_PCM_RATE_8000_96000
2917 #define WM8962_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
2918 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
2921 .hw_params = wm8962_hw_params,
2922 .set_sysclk = wm8962_set_dai_sysclk,
2923 .set_fmt = wm8962_set_dai_fmt,
2924 .digital_mute = wm8962_mute,
2930 .stream_name =
"Playback",
2937 .stream_name =
"Capture",
2943 .ops = &wm8962_dai_ops,
2944 .symmetric_rates = 1,
2988 dev_err(dev,
"Failed to read interrupt mask: %d\n",
2995 dev_err(dev,
"Failed to read interrupt: %d\n", ret);
3007 dev_warn(dev,
"Failed to ack interrupt: %d\n", ret);
3018 dev_crit(dev,
"Thermal shutdown\n");
3023 dev_warn(dev,
"Failed to read thermal status: %d\n",
3029 dev_crit(dev,
"Headphone thermal error\n");
3031 dev_crit(dev,
"Headphone thermal warning\n");
3033 dev_crit(dev,
"Speaker thermal error\n");
3035 dev_crit(dev,
"Speaker thermal warning\n");
3039 dev_dbg(dev,
"Microphone event detected\n");
3041 #ifndef CONFIG_SND_SOC_WM8962_MODULE
3042 trace_snd_soc_jack_irq(dev_name(dev));
3069 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
3102 #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
3103 static int beep_rates[] = {
3104 500, 1000, 2000, 4000,
3107 static void wm8962_beep_work(
struct work_struct *work)
3117 if (wm8962->beep_rate) {
3118 for (i = 0; i <
ARRAY_SIZE(beep_rates); i++) {
3119 if (
abs(wm8962->beep_rate - beep_rates[i]) <
3120 abs(wm8962->beep_rate - beep_rates[best]))
3124 dev_dbg(codec->
dev,
"Set beep rate %dHz for requested %dHz\n",
3125 beep_rates[best], wm8962->beep_rate);
3144 static int wm8962_beep_event(
struct input_dev *dev,
unsigned int type,
3145 unsigned int code,
int hz)
3148 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
3150 dev_dbg(codec->
dev,
"Beep event %x %x\n", code, hz);
3163 wm8962->beep_rate = hz;
3189 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
3192 wm8962->beep = input_allocate_device();
3193 if (!wm8962->beep) {
3194 dev_err(codec->
dev,
"Failed to allocate beep device\n");
3198 INIT_WORK(&wm8962->beep_work, wm8962_beep_work);
3199 wm8962->beep_rate = 0;
3201 wm8962->beep->name =
"WM8962 Beep Generator";
3202 wm8962->beep->phys = dev_name(codec->
dev);
3203 wm8962->beep->id.bustype =
BUS_I2C;
3207 wm8962->beep->event = wm8962_beep_event;
3208 wm8962->beep->dev.parent = codec->
dev;
3209 input_set_drvdata(wm8962->beep, codec);
3211 ret = input_register_device(wm8962->beep);
3213 input_free_device(wm8962->beep);
3214 wm8962->beep =
NULL;
3215 dev_err(codec->
dev,
"Failed to register beep device\n");
3220 dev_err(codec->
dev,
"Failed to create keyclick file: %d\n",
3227 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
3230 input_unregister_device(wm8962->beep);
3232 wm8962->beep =
NULL;
3271 #ifdef CONFIG_GPIOLIB
3272 static inline struct wm8962_priv *gpio_to_wm8962(
struct gpio_chip *
chip)
3277 static int wm8962_gpio_request(
struct gpio_chip *
chip,
unsigned offset)
3279 struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
3286 switch (offset + 1) {
3296 wm8962_set_gpio_mode(codec, offset + 1);
3301 static void wm8962_gpio_set(
struct gpio_chip *chip,
unsigned offset,
int value)
3303 struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
3310 static int wm8962_gpio_direction_out(
struct gpio_chip *chip,
3311 unsigned offset,
int value)
3313 struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
3328 static struct gpio_chip wm8962_template_chip = {
3331 .request = wm8962_gpio_request,
3332 .direction_output = wm8962_gpio_direction_out,
3333 .set = wm8962_gpio_set,
3339 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
3343 wm8962->gpio_chip = wm8962_template_chip;
3345 wm8962->gpio_chip.dev = codec->
dev;
3348 wm8962->gpio_chip.base = pdata->
gpio_base;
3350 wm8962->gpio_chip.base = -1;
3354 dev_err(codec->
dev,
"Failed to add GPIOs: %d\n", ret);
3359 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
3364 dev_err(codec->
dev,
"Failed to remove GPIOs: %d\n", ret);
3379 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
3383 bool dmicclk, dmicdat;
3390 dev_err(codec->
dev,
"Failed to set cache I/O: %d\n", ret);
3394 wm8962->
disable_nb[0].notifier_call = wm8962_regulator_event_0;
3395 wm8962->
disable_nb[1].notifier_call = wm8962_regulator_event_1;
3396 wm8962->
disable_nb[2].notifier_call = wm8962_regulator_event_2;
3397 wm8962->
disable_nb[3].notifier_call = wm8962_regulator_event_3;
3398 wm8962->
disable_nb[4].notifier_call = wm8962_regulator_event_4;
3399 wm8962->
disable_nb[5].notifier_call = wm8962_regulator_event_5;
3400 wm8962->
disable_nb[6].notifier_call = wm8962_regulator_event_6;
3401 wm8962->
disable_nb[7].notifier_call = wm8962_regulator_event_7;
3409 "Failed to register regulator notifier: %d\n",
3432 wm8962_set_gpio_mode(codec, i + 1);
3484 wm8962_add_widgets(codec);
3502 if (!dmicclk || !dmicdat) {
3503 dev_dbg(codec->
dev,
"DMIC not in use, disabling\n");
3506 if (dmicclk != dmicdat)
3507 dev_warn(codec->
dev,
"DMIC GPIOs partially configured\n");
3509 wm8962_init_beep(codec);
3510 wm8962_init_gpio(codec);
3526 "wm8962", codec->
dev);
3528 dev_err(codec->
dev,
"Failed to request IRQ %d: %d\n",
3536 WM8962_FLL_LOCK_EINT |
3537 WM8962_TEMP_SHUT_EINT |
3538 WM8962_FIFOS_ERR_EINT, 0);
3547 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
3555 wm8962_free_gpio(codec);
3556 wm8962_free_beep(codec);
3565 .probe = wm8962_probe,
3566 .remove = wm8962_remove,
3567 .set_bias_level = wm8962_set_bias_level,
3568 .set_pll = wm8962_set_fll,
3569 .idle_bias_off =
true,
3573 static const struct reg_default wm8962_dc_measure[] = {
3579 static const struct regmap_config wm8962_regmap = {
3584 .reg_defaults = wm8962_reg,
3586 .volatile_reg = wm8962_volatile_register,
3587 .readable_reg = wm8962_readable_register,
3604 i2c_set_clientdata(i2c, wm8962);
3607 init_completion(&wm8962->
fll_lock);
3611 wm8962->
supplies[i].supply = wm8962_supply_names[i];
3616 dev_err(&i2c->
dev,
"Failed to request supplies: %d\n", ret);
3623 dev_err(&i2c->
dev,
"Failed to enable supplies: %d\n", ret);
3628 if (IS_ERR(wm8962->
regmap)) {
3629 ret = PTR_ERR(wm8962->
regmap);
3630 dev_err(&i2c->
dev,
"Failed to allocate regmap: %d\n", ret);
3643 dev_err(&i2c->
dev,
"Failed to read ID register\n");
3646 if (reg != 0x6243) {
3648 "Device is not a WM8962, ID %x != 0x6243\n", reg);
3655 dev_err(&i2c->
dev,
"Failed to read device revision: %d\n",
3660 dev_info(&i2c->
dev,
"customer id %x revision %c\n",
3667 ret = wm8962_reset(wm8962);
3669 dev_err(&i2c->
dev,
"Failed to issue reset\n");
3679 "Failed to configure for DC mesurement: %d\n",
3684 pm_request_idle(&i2c->
dev);
3687 &soc_codec_dev_wm8962, &wm8962_dai, 1);
3716 #ifdef CONFIG_PM_RUNTIME
3717 static int wm8962_runtime_resume(
struct device *dev)
3726 "Failed to enable supplies: %d\n", ret);
3732 wm8962_reset(wm8962);
3739 static int wm8962_runtime_suspend(
struct device *dev)
3769 static struct i2c_driver wm8962_i2c_driver = {
3775 .probe = wm8962_i2c_probe,
3777 .id_table = wm8962_i2c_id,