.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * wm8995.c -- WM8995 ALSA SoC Audio driver |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com> |
---|
7 | 8 | * |
---|
8 | 9 | * Based on wm8994.c and wm_hubs.c by Mark Brown |
---|
9 | | - * |
---|
10 | | - * This program is free software; you can redistribute it and/or modify |
---|
11 | | - * it under the terms of the GNU General Public License version 2 as |
---|
12 | | - * published by the Free Software Foundation. |
---|
13 | 10 | */ |
---|
14 | 11 | |
---|
15 | 12 | #include <linux/module.h> |
---|
.. | .. |
---|
492 | 489 | int reg, reg_r; |
---|
493 | 490 | |
---|
494 | 491 | /* We also need the same setting for L/R and only one path */ |
---|
495 | | - reg = snd_soc_component_read32(component, WM8995_DAC1_LEFT_MIXER_ROUTING); |
---|
| 492 | + reg = snd_soc_component_read(component, WM8995_DAC1_LEFT_MIXER_ROUTING); |
---|
496 | 493 | switch (reg) { |
---|
497 | 494 | case WM8995_AIF2DACL_TO_DAC1L: |
---|
498 | 495 | dev_dbg(component->dev, "Class W source AIF2DAC\n"); |
---|
.. | .. |
---|
512 | 509 | break; |
---|
513 | 510 | } |
---|
514 | 511 | |
---|
515 | | - reg_r = snd_soc_component_read32(component, WM8995_DAC1_RIGHT_MIXER_ROUTING); |
---|
| 512 | + reg_r = snd_soc_component_read(component, WM8995_DAC1_RIGHT_MIXER_ROUTING); |
---|
516 | 513 | if (reg_r != reg) { |
---|
517 | 514 | dev_dbg(component->dev, "Left and right DAC mixers different\n"); |
---|
518 | 515 | enable = 0; |
---|
.. | .. |
---|
538 | 535 | unsigned int reg; |
---|
539 | 536 | const char *clk; |
---|
540 | 537 | |
---|
541 | | - reg = snd_soc_component_read32(component, WM8995_CLOCKING_1); |
---|
| 538 | + reg = snd_soc_component_read(component, WM8995_CLOCKING_1); |
---|
542 | 539 | /* Check what we're currently using for CLK_SYS */ |
---|
543 | 540 | if (reg & WM8995_SYSCLK_SRC) |
---|
544 | 541 | clk = "AIF2CLK"; |
---|
.. | .. |
---|
599 | 596 | snd_soc_component_write(component, reg, val); |
---|
600 | 597 | while (timeout--) { |
---|
601 | 598 | msleep(10); |
---|
602 | | - val = snd_soc_component_read32(component, WM8995_DC_SERVO_READBACK_0); |
---|
| 599 | + val = snd_soc_component_read(component, WM8995_DC_SERVO_READBACK_0); |
---|
603 | 600 | if ((val & mask) == mask) |
---|
604 | 601 | return; |
---|
605 | 602 | } |
---|
.. | .. |
---|
613 | 610 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
---|
614 | 611 | unsigned int reg; |
---|
615 | 612 | |
---|
616 | | - reg = snd_soc_component_read32(component, WM8995_ANALOGUE_HP_1); |
---|
| 613 | + reg = snd_soc_component_read(component, WM8995_ANALOGUE_HP_1); |
---|
617 | 614 | |
---|
618 | 615 | switch (event) { |
---|
619 | 616 | case SND_SOC_DAPM_POST_PMU: |
---|
.. | .. |
---|
1420 | 1417 | } |
---|
1421 | 1418 | } |
---|
1422 | 1419 | |
---|
1423 | | -static int wm8995_aif_mute(struct snd_soc_dai *dai, int mute) |
---|
| 1420 | +static int wm8995_aif_mute(struct snd_soc_dai *dai, int mute, int direction) |
---|
1424 | 1421 | { |
---|
1425 | 1422 | struct snd_soc_component *component = dai->component; |
---|
1426 | 1423 | int mute_reg; |
---|
.. | .. |
---|
1465 | 1462 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
---|
1466 | 1463 | case SND_SOC_DAIFMT_DSP_B: |
---|
1467 | 1464 | aif |= WM8995_AIF1_LRCLK_INV; |
---|
1468 | | - /* fall through */ |
---|
| 1465 | + fallthrough; |
---|
1469 | 1466 | case SND_SOC_DAIFMT_DSP_A: |
---|
1470 | 1467 | aif |= (0x3 << WM8995_AIF1_FMT_SHIFT); |
---|
1471 | 1468 | break; |
---|
.. | .. |
---|
1807 | 1804 | component = dai->component; |
---|
1808 | 1805 | wm8995 = snd_soc_component_get_drvdata(component); |
---|
1809 | 1806 | |
---|
1810 | | - aif1 = snd_soc_component_read32(component, WM8995_AIF1_CLOCKING_1) |
---|
| 1807 | + aif1 = snd_soc_component_read(component, WM8995_AIF1_CLOCKING_1) |
---|
1811 | 1808 | & WM8995_AIF1CLK_ENA; |
---|
1812 | 1809 | |
---|
1813 | | - aif2 = snd_soc_component_read32(component, WM8995_AIF2_CLOCKING_1) |
---|
| 1810 | + aif2 = snd_soc_component_read(component, WM8995_AIF2_CLOCKING_1) |
---|
1814 | 1811 | & WM8995_AIF2CLK_ENA; |
---|
1815 | 1812 | |
---|
1816 | 1813 | switch (id) { |
---|
.. | .. |
---|
1995 | 1992 | return 0; |
---|
1996 | 1993 | } |
---|
1997 | 1994 | |
---|
1998 | | -static void wm8995_remove(struct snd_soc_component *component) |
---|
1999 | | -{ |
---|
2000 | | - struct wm8995_priv *wm8995; |
---|
2001 | | - int i; |
---|
2002 | | - |
---|
2003 | | - wm8995 = snd_soc_component_get_drvdata(component); |
---|
2004 | | - |
---|
2005 | | - for (i = 0; i < ARRAY_SIZE(wm8995->supplies); ++i) |
---|
2006 | | - regulator_unregister_notifier(wm8995->supplies[i].consumer, |
---|
2007 | | - &wm8995->disable_nb[i]); |
---|
2008 | | - |
---|
2009 | | - regulator_bulk_free(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); |
---|
2010 | | -} |
---|
2011 | | - |
---|
2012 | 1995 | static int wm8995_probe(struct snd_soc_component *component) |
---|
2013 | 1996 | { |
---|
2014 | 1997 | struct wm8995_priv *wm8995; |
---|
.. | .. |
---|
2021 | 2004 | for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++) |
---|
2022 | 2005 | wm8995->supplies[i].supply = wm8995_supply_names[i]; |
---|
2023 | 2006 | |
---|
2024 | | - ret = regulator_bulk_get(component->dev, ARRAY_SIZE(wm8995->supplies), |
---|
2025 | | - wm8995->supplies); |
---|
| 2007 | + ret = devm_regulator_bulk_get(component->dev, |
---|
| 2008 | + ARRAY_SIZE(wm8995->supplies), |
---|
| 2009 | + wm8995->supplies); |
---|
2026 | 2010 | if (ret) { |
---|
2027 | 2011 | dev_err(component->dev, "Failed to request supplies: %d\n", ret); |
---|
2028 | 2012 | return ret; |
---|
.. | .. |
---|
2039 | 2023 | |
---|
2040 | 2024 | /* This should really be moved into the regulator core */ |
---|
2041 | 2025 | for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++) { |
---|
2042 | | - ret = regulator_register_notifier(wm8995->supplies[i].consumer, |
---|
2043 | | - &wm8995->disable_nb[i]); |
---|
| 2026 | + ret = devm_regulator_register_notifier( |
---|
| 2027 | + wm8995->supplies[i].consumer, |
---|
| 2028 | + &wm8995->disable_nb[i]); |
---|
2044 | 2029 | if (ret) { |
---|
2045 | 2030 | dev_err(component->dev, |
---|
2046 | 2031 | "Failed to register regulator notifier: %d\n", |
---|
.. | .. |
---|
2052 | 2037 | wm8995->supplies); |
---|
2053 | 2038 | if (ret) { |
---|
2054 | 2039 | dev_err(component->dev, "Failed to enable supplies: %d\n", ret); |
---|
2055 | | - goto err_reg_get; |
---|
| 2040 | + return ret; |
---|
2056 | 2041 | } |
---|
2057 | 2042 | |
---|
2058 | | - ret = snd_soc_component_read32(component, WM8995_SOFTWARE_RESET); |
---|
| 2043 | + ret = snd_soc_component_read(component, WM8995_SOFTWARE_RESET); |
---|
2059 | 2044 | if (ret < 0) { |
---|
2060 | 2045 | dev_err(component->dev, "Failed to read device ID: %d\n", ret); |
---|
2061 | 2046 | goto err_reg_enable; |
---|
.. | .. |
---|
2099 | 2084 | |
---|
2100 | 2085 | err_reg_enable: |
---|
2101 | 2086 | regulator_bulk_disable(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); |
---|
2102 | | -err_reg_get: |
---|
2103 | | - regulator_bulk_free(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); |
---|
2104 | 2087 | return ret; |
---|
2105 | 2088 | } |
---|
2106 | 2089 | |
---|
.. | .. |
---|
2111 | 2094 | .set_sysclk = wm8995_set_dai_sysclk, |
---|
2112 | 2095 | .set_fmt = wm8995_set_dai_fmt, |
---|
2113 | 2096 | .hw_params = wm8995_hw_params, |
---|
2114 | | - .digital_mute = wm8995_aif_mute, |
---|
| 2097 | + .mute_stream = wm8995_aif_mute, |
---|
2115 | 2098 | .set_pll = wm8995_set_fll, |
---|
2116 | 2099 | .set_tristate = wm8995_set_tristate, |
---|
| 2100 | + .no_capture_mute = 1, |
---|
2117 | 2101 | }; |
---|
2118 | 2102 | |
---|
2119 | 2103 | static const struct snd_soc_dai_ops wm8995_aif2_dai_ops = { |
---|
2120 | 2104 | .set_sysclk = wm8995_set_dai_sysclk, |
---|
2121 | 2105 | .set_fmt = wm8995_set_dai_fmt, |
---|
2122 | 2106 | .hw_params = wm8995_hw_params, |
---|
2123 | | - .digital_mute = wm8995_aif_mute, |
---|
| 2107 | + .mute_stream = wm8995_aif_mute, |
---|
2124 | 2108 | .set_pll = wm8995_set_fll, |
---|
2125 | 2109 | .set_tristate = wm8995_set_tristate, |
---|
| 2110 | + .no_capture_mute = 1, |
---|
2126 | 2111 | }; |
---|
2127 | 2112 | |
---|
2128 | 2113 | static const struct snd_soc_dai_ops wm8995_aif3_dai_ops = { |
---|
.. | .. |
---|
2188 | 2173 | |
---|
2189 | 2174 | static const struct snd_soc_component_driver soc_component_dev_wm8995 = { |
---|
2190 | 2175 | .probe = wm8995_probe, |
---|
2191 | | - .remove = wm8995_remove, |
---|
2192 | 2176 | .set_bias_level = wm8995_set_bias_level, |
---|
2193 | 2177 | .controls = wm8995_snd_controls, |
---|
2194 | 2178 | .num_controls = ARRAY_SIZE(wm8995_snd_controls), |
---|