Commit a5de5b74 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/wm9712', 'asoc/topic/wm9713' and...

Merge remote-tracking branches 'asoc/topic/wm9712', 'asoc/topic/wm9713' and 'asoc/topic/zte' into asoc-next
...@@ -1083,6 +1083,7 @@ config SND_SOC_WM9705 ...@@ -1083,6 +1083,7 @@ config SND_SOC_WM9705
config SND_SOC_WM9712 config SND_SOC_WM9712
tristate tristate
select REGMAP_AC97
config SND_SOC_WM9713 config SND_SOC_WM9713
tristate tristate
......
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/regmap.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/ac97_codec.h> #include <sound/ac97_codec.h>
#include <sound/initval.h> #include <sound/initval.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/tlv.h> #include <sound/tlv.h>
#include "wm9712.h"
#define WM9712_VENDOR_ID 0x574d4c12 #define WM9712_VENDOR_ID 0x574d4c12
#define WM9712_VENDOR_ID_MASK 0xffffffff #define WM9712_VENDOR_ID_MASK 0xffffffff
...@@ -32,31 +32,66 @@ struct wm9712_priv { ...@@ -32,31 +32,66 @@ struct wm9712_priv {
struct mutex lock; struct mutex lock;
}; };
static unsigned int ac97_read(struct snd_soc_codec *codec, static const struct reg_default wm9712_reg_defaults[] = {
unsigned int reg); { 0x02, 0x8000 },
static int ac97_write(struct snd_soc_codec *codec, { 0x04, 0x8000 },
unsigned int reg, unsigned int val); { 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 },
};
/* static bool wm9712_volatile_reg(struct device *dev, unsigned int reg)
* WM9712 register cache {
*/ switch (reg) {
static const u16 wm9712_reg[] = { case AC97_REC_GAIN:
0x6174, 0x8000, 0x8000, 0x8000, /* 6 */ return true;
0x0f0f, 0xaaa0, 0xc008, 0x6808, /* e */ default:
0xe808, 0xaaa0, 0xad00, 0x8000, /* 16 */ return regmap_ac97_default_volatile(dev, reg);
0xe808, 0x3000, 0x8000, 0x0000, /* 1e */ }
0x0000, 0x0000, 0x0000, 0x000f, /* 26 */ }
0x0405, 0x0410, 0xbb80, 0xbb80, /* 2e */
0x0000, 0xbb80, 0x0000, 0x0000, /* 36 */ static const struct regmap_config wm9712_regmap_config = {
0x0000, 0x2000, 0x0000, 0x0000, /* 3e */ .reg_bits = 16,
0x0000, 0x0000, 0x0000, 0x0000, /* 46 */ .reg_stride = 2,
0x0000, 0x0000, 0xf83e, 0xffff, /* 4e */ .val_bits = 16,
0x0000, 0x0000, 0x0000, 0xf83e, /* 56 */ .max_register = 0x7e,
0x0008, 0x0000, 0x0000, 0x0000, /* 5e */ .cache_type = REGCACHE_RBTREE,
0xb032, 0x3e00, 0x0000, 0x0000, /* 66 */
0x0000, 0x0000, 0x0000, 0x0000, /* 6e */ .volatile_reg = wm9712_volatile_reg,
0x0000, 0x0000, 0x0000, 0x0006, /* 76 */
0x0001, 0x0000, 0x574d, 0x4c12, /* 7e */ .reg_defaults = wm9712_reg_defaults,
.num_reg_defaults = ARRAY_SIZE(wm9712_reg_defaults),
}; };
#define HPL_MIXER 0x0 #define HPL_MIXER 0x0
...@@ -485,75 +520,36 @@ static const struct snd_soc_dapm_route wm9712_audio_map[] = { ...@@ -485,75 +520,36 @@ static const struct snd_soc_dapm_route wm9712_audio_map[] = {
{"ROUT2", NULL, "Speaker PGA"}, {"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, static int ac97_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_codec *codec = dai->codec;
int reg; int reg;
u16 vra;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
vra = ac97_read(codec, AC97_EXTENDED_STATUS); snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1);
ac97_write(codec, AC97_EXTENDED_STATUS, vra | 0x1);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
reg = AC97_PCM_FRONT_DAC_RATE; reg = AC97_PCM_FRONT_DAC_RATE;
else else
reg = AC97_PCM_LR_ADC_RATE; 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, static int ac97_aux_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_codec *codec = dai->codec;
u16 vra, xsle;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
vra = ac97_read(codec, AC97_EXTENDED_STATUS); snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1);
ac97_write(codec, AC97_EXTENDED_STATUS, vra | 0x1); snd_soc_update_bits(codec, AC97_PCI_SID, 0x8000, 0x8000);
xsle = ac97_read(codec, AC97_PCI_SID);
ac97_write(codec, AC97_PCI_SID, xsle | 0x8000);
if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
return -ENODEV; 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 |\ #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, ...@@ -605,12 +601,12 @@ static int wm9712_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
ac97_write(codec, AC97_POWERDOWN, 0x0000); snd_soc_write(codec, AC97_POWERDOWN, 0x0000);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
/* disable everything including AC link */ /* disable everything including AC link */
ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); snd_soc_write(codec, AC97_EXTENDED_MSTATUS, 0xffff);
ac97_write(codec, AC97_POWERDOWN, 0xffff); snd_soc_write(codec, AC97_POWERDOWN, 0xffff);
break; break;
} }
return 0; return 0;
...@@ -619,8 +615,7 @@ static int wm9712_set_bias_level(struct snd_soc_codec *codec, ...@@ -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) static int wm9712_soc_resume(struct snd_soc_codec *codec)
{ {
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
int i, ret; int ret;
u16 *cache = codec->reg_cache;
ret = snd_ac97_reset(wm9712->ac97, true, WM9712_VENDOR_ID, ret = snd_ac97_reset(wm9712->ac97, true, WM9712_VENDOR_ID,
WM9712_VENDOR_ID_MASK); WM9712_VENDOR_ID_MASK);
...@@ -629,15 +624,8 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec) ...@@ -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); snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY);
if (ret == 0) { if (ret == 0)
/* Sync reg_cache with the hardware after cold reset */ regcache_sync(codec->component.regmap);
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]);
}
}
return ret; return ret;
} }
...@@ -645,6 +633,7 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec) ...@@ -645,6 +633,7 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec)
static int wm9712_soc_probe(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 wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
struct regmap *regmap;
int ret; int ret;
wm9712->ac97 = snd_soc_new_ac97_codec(codec, WM9712_VENDOR_ID, 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) ...@@ -655,16 +644,28 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec)
return ret; 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 */ /* 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; 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) static int wm9712_soc_remove(struct snd_soc_codec *codec)
{ {
struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
snd_soc_codec_exit_regmap(codec);
snd_soc_free_ac97_codec(wm9712->ac97); snd_soc_free_ac97_codec(wm9712->ac97);
return 0; return 0;
} }
...@@ -673,14 +674,8 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm9712 = { ...@@ -673,14 +674,8 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm9712 = {
.probe = wm9712_soc_probe, .probe = wm9712_soc_probe,
.remove = wm9712_soc_remove, .remove = wm9712_soc_remove,
.resume = wm9712_soc_resume, .resume = wm9712_soc_resume,
.read = ac97_read,
.write = ac97_write,
.set_bias_level = wm9712_set_bias_level, .set_bias_level = wm9712_set_bias_level,
.suspend_bias_off = true, .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 = { .component_driver = {
.controls = wm9712_snd_ac97_controls, .controls = wm9712_snd_ac97_controls,
......
/*
* 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
...@@ -41,8 +41,4 @@ ...@@ -41,8 +41,4 @@
#define WM9713_PCMBCLK_DIV_8 (3 << 9) #define WM9713_PCMBCLK_DIV_8 (3 << 9)
#define WM9713_PCMBCLK_DIV_16 (4 << 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 #endif
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <mach/audio.h> #include <mach/audio.h>
#include <mach/eseries-gpio.h> #include <mach/eseries-gpio.h>
#include "../codecs/wm9712.h"
#include "pxa2xx-ac97.h" #include "pxa2xx-ac97.h"
static int e800_spk_amp_event(struct snd_soc_dapm_widget *w, static int e800_spk_amp_event(struct snd_soc_dapm_widget *w,
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <mach/audio.h> #include <mach/audio.h>
#include "../codecs/wm9712.h"
#include "pxa2xx-ac97.h" #include "pxa2xx-ac97.h"
static struct snd_soc_dai_link em_x270_dai[] = { static struct snd_soc_dai_link em_x270_dai[] = {
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <mach/audio.h> #include <mach/audio.h>
#include <linux/platform_data/asoc-palm27x.h> #include <linux/platform_data/asoc-palm27x.h>
#include "../codecs/wm9712.h"
#include "pxa2xx-ac97.h" #include "pxa2xx-ac97.h"
static struct snd_soc_jack hs_jack; static struct snd_soc_jack hs_jack;
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <mach/tosa.h> #include <mach/tosa.h>
#include <mach/audio.h> #include <mach/audio.h>
#include "../codecs/wm9712.h"
#include "pxa2xx-ac97.h" #include "pxa2xx-ac97.h"
#define TOSA_HP 0 #define TOSA_HP 0
......
config ZX296702_SPDIF config ZX_SPDIF
tristate "ZX296702 spdif" tristate "ZTE ZX SPDIF Driver Support"
depends on SOC_ZX296702 || COMPILE_TEST depends on ARCH_ZX || COMPILE_TEST
depends on COMMON_CLK depends on COMMON_CLK
select SND_SOC_GENERIC_DMAENGINE_PCM select SND_SOC_GENERIC_DMAENGINE_PCM
help help
Say Y or M if you want to add support for codecs attached to the 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 config ZX_I2S
tristate "ZX296702 i2s" tristate "ZTE ZX I2S Driver Support"
depends on SOC_ZX296702 || COMPILE_TEST depends on ARCH_ZX || COMPILE_TEST
depends on COMMON_CLK depends on COMMON_CLK
select SND_SOC_GENERIC_DMAENGINE_PCM select SND_SOC_GENERIC_DMAENGINE_PCM
help help
Say Y or M if you want to add support for codecs attached to the Say Y or M if you want to add support for codecs attached to the
zx296702 i2s interface ZTE ZX I2S interface
obj-$(CONFIG_ZX296702_SPDIF) += zx296702-spdif.o obj-$(CONFIG_ZX_SPDIF) += zx-spdif.o
obj-$(CONFIG_ZX296702_I2S) += zx296702-i2s.o obj-$(CONFIG_ZX_I2S) += zx-i2s.o
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
#define ZX_VALID_RIGHT_TRACK (2 << 0) #define ZX_VALID_RIGHT_TRACK (2 << 0)
#define ZX_VALID_TRACK_MASK (3 << 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 zx_spdif_info {
struct snd_dmaengine_dai_dma_data dma_data; struct snd_dmaengine_dai_dma_data dma_data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment