Merge remote-tracking branches 'asoc/topic/wm9712', 'asoc/topic/wm9713' and 'asoc...
authorMark Brown <broonie@kernel.org>
Mon, 12 Dec 2016 15:53:32 +0000 (15:53 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 12 Dec 2016 15:53:32 +0000 (15:53 +0000)
12 files changed:
sound/soc/codecs/Kconfig
sound/soc/codecs/wm9712.c
sound/soc/codecs/wm9712.h [deleted file]
sound/soc/codecs/wm9713.h
sound/soc/pxa/e800_wm9712.c
sound/soc/pxa/em-x270.c
sound/soc/pxa/palm27x.c
sound/soc/pxa/tosa.c
sound/soc/zte/Kconfig
sound/soc/zte/Makefile
sound/soc/zte/zx-i2s.c [moved from sound/soc/zte/zx296702-i2s.c with 100% similarity]
sound/soc/zte/zx-spdif.c [moved from sound/soc/zte/zx296702-spdif.c with 99% similarity]

index a8223a67f26c2a0826aa2ae017b5c69274944c32..9e1718a8cb1ce20a0fd68e2cbe797653b39aadeb 100644 (file)
@@ -1083,6 +1083,7 @@ config SND_SOC_WM9705
 
 config SND_SOC_WM9712
        tristate
+       select REGMAP_AC97
 
 config SND_SOC_WM9713
        tristate
index 85f7c5bb8b825fbba0f14d6ed6f8753b454daaa7..1a3e1797994aa8638c2d939c956fd8f9227c74bc 100644 (file)
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
+#include <linux/regmap.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/ac97_codec.h>
 #include <sound/initval.h>
 #include <sound/soc.h>
 #include <sound/tlv.h>
-#include "wm9712.h"
 
 #define WM9712_VENDOR_ID 0x574d4c12
 #define WM9712_VENDOR_ID_MASK 0xffffffff
@@ -32,31 +32,66 @@ struct wm9712_priv {
        struct mutex lock;
 };
 
-static unsigned int ac97_read(struct snd_soc_codec *codec,
-       unsigned int reg);
-static int ac97_write(struct snd_soc_codec *codec,
-       unsigned int reg, unsigned int val);
+static const struct reg_default wm9712_reg_defaults[] = {
+       { 0x02, 0x8000 },
+       { 0x04, 0x8000 },
+       { 0x06, 0x8000 },
+       { 0x08, 0x0f0f },
+       { 0x0a, 0xaaa0 },
+       { 0x0c, 0xc008 },
+       { 0x0e, 0x6808 },
+       { 0x10, 0xe808 },
+       { 0x12, 0xaaa0 },
+       { 0x14, 0xad00 },
+       { 0x16, 0x8000 },
+       { 0x18, 0xe808 },
+       { 0x1a, 0x3000 },
+       { 0x1c, 0x8000 },
+       { 0x20, 0x0000 },
+       { 0x22, 0x0000 },
+       { 0x26, 0x000f },
+       { 0x28, 0x0605 },
+       { 0x2a, 0x0410 },
+       { 0x2c, 0xbb80 },
+       { 0x2e, 0xbb80 },
+       { 0x32, 0xbb80 },
+       { 0x34, 0x2000 },
+       { 0x4c, 0xf83e },
+       { 0x4e, 0xffff },
+       { 0x50, 0x0000 },
+       { 0x52, 0x0000 },
+       { 0x56, 0xf83e },
+       { 0x58, 0x0008 },
+       { 0x5c, 0x0000 },
+       { 0x60, 0xb032 },
+       { 0x62, 0x3e00 },
+       { 0x64, 0x0000 },
+       { 0x76, 0x0006 },
+       { 0x78, 0x0001 },
+       { 0x7a, 0x0000 },
+};
 
-/*
- * WM9712 register cache
- */
-static const u16 wm9712_reg[] = {
-       0x6174, 0x8000, 0x8000, 0x8000, /*  6 */
-       0x0f0f, 0xaaa0, 0xc008, 0x6808, /*  e */
-       0xe808, 0xaaa0, 0xad00, 0x8000, /* 16 */
-       0xe808, 0x3000, 0x8000, 0x0000, /* 1e */
-       0x0000, 0x0000, 0x0000, 0x000f, /* 26 */
-       0x0405, 0x0410, 0xbb80, 0xbb80, /* 2e */
-       0x0000, 0xbb80, 0x0000, 0x0000, /* 36 */
-       0x0000, 0x2000, 0x0000, 0x0000, /* 3e */
-       0x0000, 0x0000, 0x0000, 0x0000, /* 46 */
-       0x0000, 0x0000, 0xf83e, 0xffff, /* 4e */
-       0x0000, 0x0000, 0x0000, 0xf83e, /* 56 */
-       0x0008, 0x0000, 0x0000, 0x0000, /* 5e */
-       0xb032, 0x3e00, 0x0000, 0x0000, /* 66 */
-       0x0000, 0x0000, 0x0000, 0x0000, /* 6e */
-       0x0000, 0x0000, 0x0000, 0x0006, /* 76 */
-       0x0001, 0x0000, 0x574d, 0x4c12, /* 7e */
+static bool wm9712_volatile_reg(struct device *dev, unsigned int reg)
+{
+       switch (reg) {
+       case AC97_REC_GAIN:
+               return true;
+       default:
+               return regmap_ac97_default_volatile(dev, reg);
+       }
+}
+
+static const struct regmap_config wm9712_regmap_config = {
+       .reg_bits = 16,
+       .reg_stride = 2,
+       .val_bits = 16,
+       .max_register = 0x7e,
+       .cache_type = REGCACHE_RBTREE,
+
+       .volatile_reg = wm9712_volatile_reg,
+
+       .reg_defaults = wm9712_reg_defaults,
+       .num_reg_defaults = ARRAY_SIZE(wm9712_reg_defaults),
 };
 
 #define HPL_MIXER      0x0
@@ -485,75 +520,36 @@ static const struct snd_soc_dapm_route wm9712_audio_map[] = {
        {"ROUT2", NULL, "Speaker PGA"},
 };
 
-static unsigned int ac97_read(struct snd_soc_codec *codec,
-       unsigned int reg)
-{
-       struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
-       u16 *cache = codec->reg_cache;
-
-       if (reg == AC97_RESET || reg == AC97_GPIO_STATUS ||
-               reg == AC97_VENDOR_ID1 || reg == AC97_VENDOR_ID2 ||
-               reg == AC97_REC_GAIN)
-               return soc_ac97_ops->read(wm9712->ac97, reg);
-       else {
-               reg = reg >> 1;
-
-               if (reg >= (ARRAY_SIZE(wm9712_reg)))
-                       return -EIO;
-
-               return cache[reg];
-       }
-}
-
-static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,
-       unsigned int val)
-{
-       struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
-       u16 *cache = codec->reg_cache;
-
-       soc_ac97_ops->write(wm9712->ac97, reg, val);
-       reg = reg >> 1;
-       if (reg < (ARRAY_SIZE(wm9712_reg)))
-               cache[reg] = val;
-
-       return 0;
-}
-
 static int ac97_prepare(struct snd_pcm_substream *substream,
                        struct snd_soc_dai *dai)
 {
        struct snd_soc_codec *codec = dai->codec;
        int reg;
-       u16 vra;
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       vra = ac97_read(codec, AC97_EXTENDED_STATUS);
-       ac97_write(codec, AC97_EXTENDED_STATUS, vra | 0x1);
+       snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1);
 
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
                reg = AC97_PCM_FRONT_DAC_RATE;
        else
                reg = AC97_PCM_LR_ADC_RATE;
 
-       return ac97_write(codec, reg, runtime->rate);
+       return snd_soc_write(codec, reg, runtime->rate);
 }
 
 static int ac97_aux_prepare(struct snd_pcm_substream *substream,
                            struct snd_soc_dai *dai)
 {
        struct snd_soc_codec *codec = dai->codec;
-       u16 vra, xsle;
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       vra = ac97_read(codec, AC97_EXTENDED_STATUS);
-       ac97_write(codec, AC97_EXTENDED_STATUS, vra | 0x1);
-       xsle = ac97_read(codec, AC97_PCI_SID);
-       ac97_write(codec, AC97_PCI_SID, xsle | 0x8000);
+       snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1);
+       snd_soc_update_bits(codec, AC97_PCI_SID, 0x8000, 0x8000);
 
        if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
                return -ENODEV;
 
-       return ac97_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate);
+       return snd_soc_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate);
 }
 
 #define WM9712_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
@@ -605,12 +601,12 @@ static int wm9712_set_bias_level(struct snd_soc_codec *codec,
        case SND_SOC_BIAS_PREPARE:
                break;
        case SND_SOC_BIAS_STANDBY:
-               ac97_write(codec, AC97_POWERDOWN, 0x0000);
+               snd_soc_write(codec, AC97_POWERDOWN, 0x0000);
                break;
        case SND_SOC_BIAS_OFF:
                /* disable everything including AC link */
-               ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff);
-               ac97_write(codec, AC97_POWERDOWN, 0xffff);
+               snd_soc_write(codec, AC97_EXTENDED_MSTATUS, 0xffff);
+               snd_soc_write(codec, AC97_POWERDOWN, 0xffff);
                break;
        }
        return 0;
@@ -619,8 +615,7 @@ static int wm9712_set_bias_level(struct snd_soc_codec *codec,
 static int wm9712_soc_resume(struct snd_soc_codec *codec)
 {
        struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
-       int i, ret;
-       u16 *cache = codec->reg_cache;
+       int ret;
 
        ret = snd_ac97_reset(wm9712->ac97, true, WM9712_VENDOR_ID,
                WM9712_VENDOR_ID_MASK);
@@ -629,15 +624,8 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec)
 
        snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
-       if (ret == 0) {
-               /* Sync reg_cache with the hardware after cold reset */
-               for (i = 2; i < ARRAY_SIZE(wm9712_reg) << 1; i += 2) {
-                       if (i == AC97_INT_PAGING || i == AC97_POWERDOWN ||
-                           (i > 0x58 && i != 0x5c))
-                               continue;
-                       soc_ac97_ops->write(wm9712->ac97, i, cache[i>>1]);
-               }
-       }
+       if (ret == 0)
+               regcache_sync(codec->component.regmap);
 
        return ret;
 }
@@ -645,6 +633,7 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec)
 static int wm9712_soc_probe(struct snd_soc_codec *codec)
 {
        struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
+       struct regmap *regmap;
        int ret;
 
        wm9712->ac97 = snd_soc_new_ac97_codec(codec, WM9712_VENDOR_ID,
@@ -655,16 +644,28 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec)
                return ret;
        }
 
+       regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config);
+       if (IS_ERR(regmap)) {
+               ret = PTR_ERR(regmap);
+               goto err_free_ac97_codec;
+       }
+
+       snd_soc_codec_init_regmap(codec, regmap);
+
        /* set alc mux to none */
-       ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000);
+       snd_soc_update_bits(codec, AC97_VIDEO, 0x3000, 0x3000);
 
        return 0;
+err_free_ac97_codec:
+       snd_soc_free_ac97_codec(wm9712->ac97);
+       return ret;
 }
 
 static int wm9712_soc_remove(struct snd_soc_codec *codec)
 {
        struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
 
+       snd_soc_codec_exit_regmap(codec);
        snd_soc_free_ac97_codec(wm9712->ac97);
        return 0;
 }
@@ -673,14 +674,8 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm9712 = {
        .probe =        wm9712_soc_probe,
        .remove =       wm9712_soc_remove,
        .resume =       wm9712_soc_resume,
-       .read = ac97_read,
-       .write = ac97_write,
        .set_bias_level = wm9712_set_bias_level,
        .suspend_bias_off = true,
-       .reg_cache_size = ARRAY_SIZE(wm9712_reg),
-       .reg_word_size = sizeof(u16),
-       .reg_cache_step = 2,
-       .reg_cache_default = wm9712_reg,
 
        .component_driver = {
                .controls               = wm9712_snd_ac97_controls,
diff --git a/sound/soc/codecs/wm9712.h b/sound/soc/codecs/wm9712.h
deleted file mode 100644 (file)
index fb69c3a..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * wm9712.h  --  WM9712 Soc Audio driver
- */
-
-#ifndef _WM9712_H
-#define _WM9712_H
-
-#define WM9712_DAI_AC97_HIFI   0
-#define WM9712_DAI_AC97_AUX            1
-
-#endif
index 53df11b1f727fae6979b071ea02691293de21c2a..7ecffc563016fb7a66b72470188833e5698786dd 100644 (file)
@@ -41,8 +41,4 @@
 #define WM9713_PCMBCLK_DIV_8   (3 << 9)
 #define WM9713_PCMBCLK_DIV_16  (4 << 9)
 
-#define WM9713_DAI_AC97_HIFI   0
-#define WM9713_DAI_AC97_AUX            1
-#define WM9713_DAI_PCM_VOICE   2
-
 #endif
index 41bf71466a7bb619c06de89e81d4e1b6b731c8fb..07b9c6e17df95591644770f8bfbc134ae055b388 100644 (file)
@@ -21,7 +21,6 @@
 #include <mach/audio.h>
 #include <mach/eseries-gpio.h>
 
-#include "../codecs/wm9712.h"
 #include "pxa2xx-ac97.h"
 
 static int e800_spk_amp_event(struct snd_soc_dapm_widget *w,
index 64743a05aeae96172a3fe18e2163c7e1f453635b..966163d1c813271b5df393e52eb5fe0ebd9e86ac 100644 (file)
@@ -30,7 +30,6 @@
 #include <asm/mach-types.h>
 #include <mach/audio.h>
 
-#include "../codecs/wm9712.h"
 #include "pxa2xx-ac97.h"
 
 static struct snd_soc_dai_link em_x270_dai[] = {
index bcc81e920a67cbfb4132a0bc571041af49b89ff6..387492d46b6c0c848e0497d4218db62a32485228 100644 (file)
@@ -27,7 +27,6 @@
 #include <mach/audio.h>
 #include <linux/platform_data/asoc-palm27x.h>
 
-#include "../codecs/wm9712.h"
 #include "pxa2xx-ac97.h"
 
 static struct snd_soc_jack hs_jack;
index 08b0cf50e91a05a077a7ceba5d01d985ef3285ea..2e312c62e3c75dcb2b60896b42b2ad2ca5fa1b4a 100644 (file)
@@ -31,7 +31,6 @@
 #include <mach/tosa.h>
 #include <mach/audio.h>
 
-#include "../codecs/wm9712.h"
 #include "pxa2xx-ac97.h"
 
 #define TOSA_HP        0
index c47eb25e441fed73ded161d3aabc045ae2dac3f4..6d8a90d363150e808620ae1a655e79d4766e08a8 100644 (file)
@@ -1,17 +1,17 @@
-config ZX296702_SPDIF
-       tristate "ZX296702 spdif"
-       depends on SOC_ZX296702 || COMPILE_TEST
+config ZX_SPDIF
+       tristate "ZTE ZX SPDIF Driver Support"
+       depends on ARCH_ZX || COMPILE_TEST
        depends on COMMON_CLK
        select SND_SOC_GENERIC_DMAENGINE_PCM
        help
          Say Y or M if you want to add support for codecs attached to the
-         zx296702 spdif interface
+         ZTE ZX SPDIF interface
 
-config ZX296702_I2S
-       tristate "ZX296702 i2s"
-       depends on SOC_ZX296702 || COMPILE_TEST
+config ZX_I2S
+       tristate "ZTE ZX I2S Driver Support"
+       depends on ARCH_ZX || COMPILE_TEST
        depends on COMMON_CLK
        select SND_SOC_GENERIC_DMAENGINE_PCM
        help
          Say Y or M if you want to add support for codecs attached to the
-         zx296702 i2s interface
+         ZTE ZX I2S interface
index 254ed2c8c1a00f9a5d256a6a7b91456aa5a5dbbc..77768f5fd10c5f7d6c39f801f1e98bf3e88de189 100644 (file)
@@ -1,2 +1,2 @@
-obj-$(CONFIG_ZX296702_SPDIF)   += zx296702-spdif.o
-obj-$(CONFIG_ZX296702_I2S)     += zx296702-i2s.o
+obj-$(CONFIG_ZX_SPDIF) += zx-spdif.o
+obj-$(CONFIG_ZX_I2S)   += zx-i2s.o
similarity index 99%
rename from sound/soc/zte/zx296702-spdif.c
rename to sound/soc/zte/zx-spdif.c
index 26265ce4caca17da4b6315a4627130ac63851063..9fa6463ce5d75a58f471bfbfd0a64b948755641f 100644 (file)
@@ -71,7 +71,7 @@
 #define ZX_VALID_RIGHT_TRACK           (2 << 0)
 #define ZX_VALID_TRACK_MASK            (3 << 0)
 
-#define ZX_SPDIF_CLK_RAT               (4 * 32)
+#define ZX_SPDIF_CLK_RAT               (2 * 32)
 
 struct zx_spdif_info {
        struct snd_dmaengine_dai_dma_data       dma_data;