mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
Merge remote-tracking branches 'asoc/topic/stac9766', 'asoc/topic/sti', 'asoc/topic/sti-codec', 'asoc/topic/sunxi' and 'asoc/topic/tegra' into asoc-next
This commit is contained in:
commit
da644e2ede
23 changed files with 1815 additions and 462 deletions
|
@ -1,8 +1,12 @@
|
||||||
* Allwinner A10 Codec
|
* Allwinner A10 Codec
|
||||||
|
|
||||||
Required properties:
|
Required properties:
|
||||||
- compatible: must be either "allwinner,sun4i-a10-codec" or
|
- compatible: must be one of the following compatibles:
|
||||||
"allwinner,sun7i-a20-codec"
|
- "allwinner,sun4i-a10-codec"
|
||||||
|
- "allwinner,sun6i-a31-codec"
|
||||||
|
- "allwinner,sun7i-a20-codec"
|
||||||
|
- "allwinner,sun8i-a23-codec"
|
||||||
|
- "allwinner,sun8i-h3-codec"
|
||||||
- reg: must contain the registers location and length
|
- reg: must contain the registers location and length
|
||||||
- interrupts: must contain the codec interrupt
|
- interrupts: must contain the codec interrupt
|
||||||
- dmas: DMA channels for tx and rx dma. See the DMA client binding,
|
- dmas: DMA channels for tx and rx dma. See the DMA client binding,
|
||||||
|
@ -17,6 +21,43 @@ Required properties:
|
||||||
Optional properties:
|
Optional properties:
|
||||||
- allwinner,pa-gpios: gpio to enable external amplifier
|
- allwinner,pa-gpios: gpio to enable external amplifier
|
||||||
|
|
||||||
|
Required properties for the following compatibles:
|
||||||
|
- "allwinner,sun6i-a31-codec"
|
||||||
|
- "allwinner,sun8i-a23-codec"
|
||||||
|
- "allwinner,sun8i-h3-codec"
|
||||||
|
- resets: phandle to the reset control for this device
|
||||||
|
- allwinner,audio-routing: A list of the connections between audio components.
|
||||||
|
Each entry is a pair of strings, the first being the
|
||||||
|
connection's sink, the second being the connection's
|
||||||
|
source. Valid names include:
|
||||||
|
|
||||||
|
Audio pins on the SoC:
|
||||||
|
"HP"
|
||||||
|
"HPCOM"
|
||||||
|
"LINEIN"
|
||||||
|
"LINEOUT" (not on sun8i-a23)
|
||||||
|
"MIC1"
|
||||||
|
"MIC2"
|
||||||
|
"MIC3" (sun6i-a31 only)
|
||||||
|
|
||||||
|
Microphone biases from the SoC:
|
||||||
|
"HBIAS"
|
||||||
|
"MBIAS"
|
||||||
|
|
||||||
|
Board connectors:
|
||||||
|
"Headphone"
|
||||||
|
"Headset Mic"
|
||||||
|
"Line In"
|
||||||
|
"Line Out"
|
||||||
|
"Mic"
|
||||||
|
"Speaker"
|
||||||
|
|
||||||
|
Required properties for the following compatibles:
|
||||||
|
- "allwinner,sun8i-a23-codec"
|
||||||
|
- "allwinner,sun8i-h3-codec"
|
||||||
|
- allwinner,codec-analog-controls: A phandle to the codec analog controls
|
||||||
|
block in the PRCM.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
codec: codec@01c22c00 {
|
codec: codec@01c22c00 {
|
||||||
#sound-dai-cells = <0>;
|
#sound-dai-cells = <0>;
|
||||||
|
@ -28,3 +69,23 @@ codec: codec@01c22c00 {
|
||||||
dmas = <&dma 0 19>, <&dma 0 19>;
|
dmas = <&dma 0 19>, <&dma 0 19>;
|
||||||
dma-names = "rx", "tx";
|
dma-names = "rx", "tx";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
codec: codec@01c22c00 {
|
||||||
|
#sound-dai-cells = <0>;
|
||||||
|
compatible = "allwinner,sun6i-a31-codec";
|
||||||
|
reg = <0x01c22c00 0x98>;
|
||||||
|
interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>;
|
||||||
|
clocks = <&ccu CLK_APB1_CODEC>, <&ccu CLK_CODEC>;
|
||||||
|
clock-names = "apb", "codec";
|
||||||
|
resets = <&ccu RST_APB1_CODEC>;
|
||||||
|
dmas = <&dma 15>, <&dma 15>;
|
||||||
|
dma-names = "rx", "tx";
|
||||||
|
allwinner,audio-routing =
|
||||||
|
"Headphone", "HP",
|
||||||
|
"Speaker", "LINEOUT",
|
||||||
|
"LINEIN", "Line In",
|
||||||
|
"MIC1", "MBIAS",
|
||||||
|
"MIC1", "Mic",
|
||||||
|
"MIC2", "HBIAS",
|
||||||
|
"MIC2", "Headset Mic";
|
||||||
|
};
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
* Allwinner Codec Analog Controls
|
||||||
|
|
||||||
|
Required properties:
|
||||||
|
- compatible: must be one of the following compatibles:
|
||||||
|
- "allwinner,sun8i-a23-codec-analog"
|
||||||
|
- "allwinner,sun8i-h3-codec-analog"
|
||||||
|
|
||||||
|
Required properties if not a sub-node of the PRCM node:
|
||||||
|
- reg: must contain the registers location and length
|
||||||
|
|
||||||
|
Example:
|
||||||
|
prcm: prcm@01f01400 {
|
||||||
|
codec_analog: codec-analog {
|
||||||
|
compatible = "allwinner,sun8i-a23-codec-analog";
|
||||||
|
};
|
||||||
|
};
|
|
@ -18,6 +18,7 @@
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.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>
|
||||||
|
@ -26,31 +27,56 @@
|
||||||
#include <sound/soc.h>
|
#include <sound/soc.h>
|
||||||
#include <sound/tlv.h>
|
#include <sound/tlv.h>
|
||||||
|
|
||||||
#include "stac9766.h"
|
|
||||||
|
|
||||||
#define STAC9766_VENDOR_ID 0x83847666
|
#define STAC9766_VENDOR_ID 0x83847666
|
||||||
#define STAC9766_VENDOR_ID_MASK 0xffffffff
|
#define STAC9766_VENDOR_ID_MASK 0xffffffff
|
||||||
|
|
||||||
/*
|
#define AC97_STAC_DA_CONTROL 0x6A
|
||||||
* STAC9766 register cache
|
#define AC97_STAC_ANALOG_SPECIAL 0x6E
|
||||||
*/
|
#define AC97_STAC_STEREO_MIC 0x78
|
||||||
static const u16 stac9766_reg[] = {
|
|
||||||
0x6A90, 0x8000, 0x8000, 0x8000, /* 6 */
|
static const struct reg_default stac9766_reg_defaults[] = {
|
||||||
0x0000, 0x0000, 0x8008, 0x8008, /* e */
|
{ 0x02, 0x8000 },
|
||||||
0x8808, 0x8808, 0x8808, 0x8808, /* 16 */
|
{ 0x04, 0x8000 },
|
||||||
0x8808, 0x0000, 0x8000, 0x0000, /* 1e */
|
{ 0x06, 0x8000 },
|
||||||
0x0000, 0x0000, 0x0000, 0x000f, /* 26 */
|
{ 0x0a, 0x0000 },
|
||||||
0x0a05, 0x0400, 0xbb80, 0x0000, /* 2e */
|
{ 0x0c, 0x8008 },
|
||||||
0x0000, 0xbb80, 0x0000, 0x0000, /* 36 */
|
{ 0x0e, 0x8008 },
|
||||||
0x0000, 0x2000, 0x0000, 0x0100, /* 3e */
|
{ 0x10, 0x8808 },
|
||||||
0x0000, 0x0000, 0x0080, 0x0000, /* 46 */
|
{ 0x12, 0x8808 },
|
||||||
0x0000, 0x0000, 0x0003, 0xffff, /* 4e */
|
{ 0x14, 0x8808 },
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, /* 56 */
|
{ 0x16, 0x8808 },
|
||||||
0x4000, 0x0000, 0x0000, 0x0000, /* 5e */
|
{ 0x18, 0x8808 },
|
||||||
0x1201, 0xFFFF, 0xFFFF, 0x0000, /* 66 */
|
{ 0x1a, 0x0000 },
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, /* 6e */
|
{ 0x1c, 0x8000 },
|
||||||
0x0000, 0x0000, 0x0000, 0x0006, /* 76 */
|
{ 0x20, 0x0000 },
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, /* 7e */
|
{ 0x22, 0x0000 },
|
||||||
|
{ 0x28, 0x0a05 },
|
||||||
|
{ 0x2c, 0xbb80 },
|
||||||
|
{ 0x32, 0xbb80 },
|
||||||
|
{ 0x3a, 0x2000 },
|
||||||
|
{ 0x3e, 0x0100 },
|
||||||
|
{ 0x4c, 0x0300 },
|
||||||
|
{ 0x4e, 0xffff },
|
||||||
|
{ 0x50, 0x0000 },
|
||||||
|
{ 0x52, 0x0000 },
|
||||||
|
{ 0x54, 0x0000 },
|
||||||
|
{ 0x6a, 0x0000 },
|
||||||
|
{ 0x6e, 0x1000 },
|
||||||
|
{ 0x72, 0x0000 },
|
||||||
|
{ 0x78, 0x0000 },
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct regmap_config stac9766_regmap_config = {
|
||||||
|
.reg_bits = 16,
|
||||||
|
.reg_stride = 2,
|
||||||
|
.val_bits = 16,
|
||||||
|
.max_register = 0x78,
|
||||||
|
.cache_type = REGCACHE_RBTREE,
|
||||||
|
|
||||||
|
.volatile_reg = regmap_ac97_default_volatile,
|
||||||
|
|
||||||
|
.reg_defaults = stac9766_reg_defaults,
|
||||||
|
.num_reg_defaults = ARRAY_SIZE(stac9766_reg_defaults),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *stac9766_record_mux[] = {"Mic", "CD", "Video", "AUX",
|
static const char *stac9766_record_mux[] = {"Mic", "CD", "Video", "AUX",
|
||||||
|
@ -139,71 +165,22 @@ static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = {
|
||||||
SOC_ENUM("Pop Bypass Mux", stac9766_popbypass_enum),
|
SOC_ENUM("Pop Bypass Mux", stac9766_popbypass_enum),
|
||||||
};
|
};
|
||||||
|
|
||||||
static int stac9766_ac97_write(struct snd_soc_codec *codec, unsigned int reg,
|
|
||||||
unsigned int val)
|
|
||||||
{
|
|
||||||
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
|
|
||||||
u16 *cache = codec->reg_cache;
|
|
||||||
|
|
||||||
if (reg > AC97_STAC_PAGE0) {
|
|
||||||
stac9766_ac97_write(codec, AC97_INT_PAGING, 0);
|
|
||||||
soc_ac97_ops->write(ac97, reg, val);
|
|
||||||
stac9766_ac97_write(codec, AC97_INT_PAGING, 1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (reg / 2 >= ARRAY_SIZE(stac9766_reg))
|
|
||||||
return -EIO;
|
|
||||||
|
|
||||||
soc_ac97_ops->write(ac97, reg, val);
|
|
||||||
cache[reg / 2] = val;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int stac9766_ac97_read(struct snd_soc_codec *codec,
|
|
||||||
unsigned int reg)
|
|
||||||
{
|
|
||||||
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
|
|
||||||
u16 val = 0, *cache = codec->reg_cache;
|
|
||||||
|
|
||||||
if (reg > AC97_STAC_PAGE0) {
|
|
||||||
stac9766_ac97_write(codec, AC97_INT_PAGING, 0);
|
|
||||||
val = soc_ac97_ops->read(ac97, reg - AC97_STAC_PAGE0);
|
|
||||||
stac9766_ac97_write(codec, AC97_INT_PAGING, 1);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
if (reg / 2 >= ARRAY_SIZE(stac9766_reg))
|
|
||||||
return -EIO;
|
|
||||||
|
|
||||||
if (reg == AC97_RESET || reg == AC97_GPIO_STATUS ||
|
|
||||||
reg == AC97_INT_PAGING || reg == AC97_VENDOR_ID1 ||
|
|
||||||
reg == AC97_VENDOR_ID2) {
|
|
||||||
|
|
||||||
val = soc_ac97_ops->read(ac97, reg);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
return cache[reg / 2];
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ac97_analog_prepare(struct snd_pcm_substream *substream,
|
static int ac97_analog_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;
|
||||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||||
unsigned short reg, vra;
|
unsigned short reg;
|
||||||
|
|
||||||
vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS);
|
/* enable variable rate audio, disable SPDIF output */
|
||||||
|
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x5, 0x1);
|
||||||
vra |= 0x1; /* enable variable rate audio */
|
|
||||||
vra &= ~0x4; /* disable SPDIF output */
|
|
||||||
|
|
||||||
stac9766_ac97_write(codec, AC97_EXTENDED_STATUS, vra);
|
|
||||||
|
|
||||||
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 stac9766_ac97_write(codec, reg, runtime->rate);
|
return snd_soc_write(codec, reg, runtime->rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ac97_digital_prepare(struct snd_pcm_substream *substream,
|
static int ac97_digital_prepare(struct snd_pcm_substream *substream,
|
||||||
|
@ -211,18 +188,16 @@ static int ac97_digital_prepare(struct snd_pcm_substream *substream,
|
||||||
{
|
{
|
||||||
struct snd_soc_codec *codec = dai->codec;
|
struct snd_soc_codec *codec = dai->codec;
|
||||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||||
unsigned short reg, vra;
|
unsigned short reg;
|
||||||
|
|
||||||
stac9766_ac97_write(codec, AC97_SPDIF, 0x2002);
|
snd_soc_write(codec, AC97_SPDIF, 0x2002);
|
||||||
|
|
||||||
vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS);
|
/* Enable VRA and SPDIF out */
|
||||||
vra |= 0x5; /* Enable VRA and SPDIF out */
|
snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x5, 0x5);
|
||||||
|
|
||||||
stac9766_ac97_write(codec, AC97_EXTENDED_STATUS, vra);
|
|
||||||
|
|
||||||
reg = AC97_PCM_FRONT_DAC_RATE;
|
reg = AC97_PCM_FRONT_DAC_RATE;
|
||||||
|
|
||||||
return stac9766_ac97_write(codec, reg, runtime->rate);
|
return snd_soc_write(codec, reg, runtime->rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stac9766_set_bias_level(struct snd_soc_codec *codec,
|
static int stac9766_set_bias_level(struct snd_soc_codec *codec,
|
||||||
|
@ -232,11 +207,11 @@ static int stac9766_set_bias_level(struct snd_soc_codec *codec,
|
||||||
case SND_SOC_BIAS_ON: /* full On */
|
case SND_SOC_BIAS_ON: /* full On */
|
||||||
case SND_SOC_BIAS_PREPARE: /* partial On */
|
case SND_SOC_BIAS_PREPARE: /* partial On */
|
||||||
case SND_SOC_BIAS_STANDBY: /* Off, with power */
|
case SND_SOC_BIAS_STANDBY: /* Off, with power */
|
||||||
stac9766_ac97_write(codec, AC97_POWERDOWN, 0x0000);
|
snd_soc_write(codec, AC97_POWERDOWN, 0x0000);
|
||||||
break;
|
break;
|
||||||
case SND_SOC_BIAS_OFF: /* Off, without power */
|
case SND_SOC_BIAS_OFF: /* Off, without power */
|
||||||
/* disable everything including AC link */
|
/* disable everything including AC link */
|
||||||
stac9766_ac97_write(codec, AC97_POWERDOWN, 0xffff);
|
snd_soc_write(codec, AC97_POWERDOWN, 0xffff);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -300,21 +275,34 @@ static struct snd_soc_dai_driver stac9766_dai[] = {
|
||||||
static int stac9766_codec_probe(struct snd_soc_codec *codec)
|
static int stac9766_codec_probe(struct snd_soc_codec *codec)
|
||||||
{
|
{
|
||||||
struct snd_ac97 *ac97;
|
struct snd_ac97 *ac97;
|
||||||
|
struct regmap *regmap;
|
||||||
|
int ret;
|
||||||
|
|
||||||
ac97 = snd_soc_new_ac97_codec(codec, STAC9766_VENDOR_ID,
|
ac97 = snd_soc_new_ac97_codec(codec, STAC9766_VENDOR_ID,
|
||||||
STAC9766_VENDOR_ID_MASK);
|
STAC9766_VENDOR_ID_MASK);
|
||||||
if (IS_ERR(ac97))
|
if (IS_ERR(ac97))
|
||||||
return PTR_ERR(ac97);
|
return PTR_ERR(ac97);
|
||||||
|
|
||||||
|
regmap = regmap_init_ac97(ac97, &stac9766_regmap_config);
|
||||||
|
if (IS_ERR(regmap)) {
|
||||||
|
ret = PTR_ERR(regmap);
|
||||||
|
goto err_free_ac97;
|
||||||
|
}
|
||||||
|
|
||||||
|
snd_soc_codec_init_regmap(codec, regmap);
|
||||||
snd_soc_codec_set_drvdata(codec, ac97);
|
snd_soc_codec_set_drvdata(codec, ac97);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
err_free_ac97:
|
||||||
|
snd_soc_free_ac97_codec(ac97);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stac9766_codec_remove(struct snd_soc_codec *codec)
|
static int stac9766_codec_remove(struct snd_soc_codec *codec)
|
||||||
{
|
{
|
||||||
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
|
struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec);
|
||||||
|
|
||||||
|
snd_soc_codec_exit_regmap(codec);
|
||||||
snd_soc_free_ac97_codec(ac97);
|
snd_soc_free_ac97_codec(ac97);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -324,17 +312,11 @@ static struct snd_soc_codec_driver soc_codec_dev_stac9766 = {
|
||||||
.controls = stac9766_snd_ac97_controls,
|
.controls = stac9766_snd_ac97_controls,
|
||||||
.num_controls = ARRAY_SIZE(stac9766_snd_ac97_controls),
|
.num_controls = ARRAY_SIZE(stac9766_snd_ac97_controls),
|
||||||
},
|
},
|
||||||
.write = stac9766_ac97_write,
|
|
||||||
.read = stac9766_ac97_read,
|
|
||||||
.set_bias_level = stac9766_set_bias_level,
|
.set_bias_level = stac9766_set_bias_level,
|
||||||
.suspend_bias_off = true,
|
.suspend_bias_off = true,
|
||||||
.probe = stac9766_codec_probe,
|
.probe = stac9766_codec_probe,
|
||||||
.remove = stac9766_codec_remove,
|
.remove = stac9766_codec_remove,
|
||||||
.resume = stac9766_codec_resume,
|
.resume = stac9766_codec_resume,
|
||||||
.reg_cache_size = ARRAY_SIZE(stac9766_reg),
|
|
||||||
.reg_word_size = sizeof(u16),
|
|
||||||
.reg_cache_step = 2,
|
|
||||||
.reg_cache_default = stac9766_reg,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int stac9766_probe(struct platform_device *pdev)
|
static int stac9766_probe(struct platform_device *pdev)
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
* stac9766.h -- STAC9766 Soc Audio driver
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _STAC9766_H
|
|
||||||
#define _STAC9766_H
|
|
||||||
|
|
||||||
#define AC97_STAC_PAGE0 0x1000
|
|
||||||
#define AC97_STAC_DA_CONTROL (AC97_STAC_PAGE0 | 0x6A)
|
|
||||||
#define AC97_STAC_ANALOG_SPECIAL (AC97_STAC_PAGE0 | 0x6E)
|
|
||||||
#define AC97_STAC_STEREO_MIC 0x78
|
|
||||||
|
|
||||||
/* STAC9766 DAI ID's */
|
|
||||||
#define STAC9766_DAI_AC97_ANALOG 0
|
|
||||||
#define STAC9766_DAI_AC97_DIGITAL 1
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -14,28 +14,8 @@
|
||||||
#include <sound/soc.h>
|
#include <sound/soc.h>
|
||||||
#include <sound/soc-dapm.h>
|
#include <sound/soc-dapm.h>
|
||||||
|
|
||||||
/* chipID supported */
|
|
||||||
#define CHIPID_STIH416 0
|
|
||||||
#define CHIPID_STIH407 1
|
|
||||||
|
|
||||||
/* DAC definitions */
|
/* DAC definitions */
|
||||||
|
|
||||||
/* stih416 DAC registers */
|
|
||||||
/* sysconf 2517: Audio-DAC-Control */
|
|
||||||
#define STIH416_AUDIO_DAC_CTRL 0x00000814
|
|
||||||
/* sysconf 2519: Audio-Gue-Control */
|
|
||||||
#define STIH416_AUDIO_GLUE_CTRL 0x0000081C
|
|
||||||
|
|
||||||
#define STIH416_DAC_NOT_STANDBY 0x3
|
|
||||||
#define STIH416_DAC_SOFTMUTE 0x4
|
|
||||||
#define STIH416_DAC_ANA_NOT_PWR 0x5
|
|
||||||
#define STIH416_DAC_NOT_PNDBG 0x6
|
|
||||||
|
|
||||||
#define STIH416_DAC_NOT_STANDBY_MASK BIT(STIH416_DAC_NOT_STANDBY)
|
|
||||||
#define STIH416_DAC_SOFTMUTE_MASK BIT(STIH416_DAC_SOFTMUTE)
|
|
||||||
#define STIH416_DAC_ANA_NOT_PWR_MASK BIT(STIH416_DAC_ANA_NOT_PWR)
|
|
||||||
#define STIH416_DAC_NOT_PNDBG_MASK BIT(STIH416_DAC_NOT_PNDBG)
|
|
||||||
|
|
||||||
/* stih407 DAC registers */
|
/* stih407 DAC registers */
|
||||||
/* sysconf 5041: Audio-Gue-Control */
|
/* sysconf 5041: Audio-Gue-Control */
|
||||||
#define STIH407_AUDIO_GLUE_CTRL 0x000000A4
|
#define STIH407_AUDIO_GLUE_CTRL 0x000000A4
|
||||||
|
@ -63,14 +43,9 @@ enum {
|
||||||
STI_SAS_DAI_ANALOG_OUT,
|
STI_SAS_DAI_ANALOG_OUT,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct reg_default stih416_sas_reg_defaults[] = {
|
|
||||||
{ STIH407_AUDIO_GLUE_CTRL, 0x00000040 },
|
|
||||||
{ STIH407_AUDIO_DAC_CTRL, 0x000000000 },
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct reg_default stih407_sas_reg_defaults[] = {
|
static const struct reg_default stih407_sas_reg_defaults[] = {
|
||||||
{ STIH416_AUDIO_DAC_CTRL, 0x000000000 },
|
{ STIH407_AUDIO_DAC_CTRL, 0x000000000 },
|
||||||
{ STIH416_AUDIO_GLUE_CTRL, 0x00000040 },
|
{ STIH407_AUDIO_GLUE_CTRL, 0x00000040 },
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sti_dac_audio {
|
struct sti_dac_audio {
|
||||||
|
@ -89,7 +64,6 @@ struct sti_spdif_audio {
|
||||||
|
|
||||||
/* device data structure */
|
/* device data structure */
|
||||||
struct sti_sas_dev_data {
|
struct sti_sas_dev_data {
|
||||||
const int chipid; /* IC version */
|
|
||||||
const struct regmap_config *regmap;
|
const struct regmap_config *regmap;
|
||||||
const struct snd_soc_dai_ops *dac_ops; /* DAC function callbacks */
|
const struct snd_soc_dai_ops *dac_ops; /* DAC function callbacks */
|
||||||
const struct snd_soc_dapm_widget *dapm_widgets; /* dapms declaration */
|
const struct snd_soc_dapm_widget *dapm_widgets; /* dapms declaration */
|
||||||
|
@ -150,13 +124,11 @@ static int sti_sas_init_sas_registers(struct snd_soc_codec *codec,
|
||||||
ret = snd_soc_update_bits(codec, STIH407_AUDIO_GLUE_CTRL,
|
ret = snd_soc_update_bits(codec, STIH407_AUDIO_GLUE_CTRL,
|
||||||
SPDIF_BIPHASE_IDLE_MASK, 0);
|
SPDIF_BIPHASE_IDLE_MASK, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(codec->dev, "Failed to update SPDIF registers");
|
dev_err(codec->dev, "Failed to update SPDIF registers\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Init DAC configuration */
|
/* Init DAC configuration */
|
||||||
switch (data->dev_data->chipid) {
|
|
||||||
case CHIPID_STIH407:
|
|
||||||
/* init configuration */
|
/* init configuration */
|
||||||
ret = snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL,
|
ret = snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL,
|
||||||
STIH407_DAC_STANDBY_MASK,
|
STIH407_DAC_STANDBY_MASK,
|
||||||
|
@ -170,31 +142,9 @@ static int sti_sas_init_sas_registers(struct snd_soc_codec *codec,
|
||||||
ret = snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL,
|
ret = snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL,
|
||||||
STIH407_DAC_SOFTMUTE_MASK,
|
STIH407_DAC_SOFTMUTE_MASK,
|
||||||
STIH407_DAC_SOFTMUTE_MASK);
|
STIH407_DAC_SOFTMUTE_MASK);
|
||||||
break;
|
|
||||||
case CHIPID_STIH416:
|
|
||||||
ret = snd_soc_update_bits(codec, STIH416_AUDIO_DAC_CTRL,
|
|
||||||
STIH416_DAC_NOT_STANDBY_MASK, 0);
|
|
||||||
if (!ret)
|
|
||||||
ret = snd_soc_update_bits(codec,
|
|
||||||
STIH416_AUDIO_DAC_CTRL,
|
|
||||||
STIH416_DAC_ANA_NOT_PWR, 0);
|
|
||||||
if (!ret)
|
|
||||||
ret = snd_soc_update_bits(codec,
|
|
||||||
STIH416_AUDIO_DAC_CTRL,
|
|
||||||
STIH416_DAC_NOT_PNDBG_MASK,
|
|
||||||
0);
|
|
||||||
if (!ret)
|
|
||||||
ret = snd_soc_update_bits(codec,
|
|
||||||
STIH416_AUDIO_DAC_CTRL,
|
|
||||||
STIH416_DAC_SOFTMUTE_MASK,
|
|
||||||
STIH416_DAC_SOFTMUTE_MASK);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(codec->dev, "Failed to update DAC registers");
|
dev_err(codec->dev, "Failed to update DAC registers\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,37 +167,6 @@ static int sti_sas_dac_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stih416_dac_probe(struct snd_soc_dai *dai)
|
|
||||||
{
|
|
||||||
struct snd_soc_codec *codec = dai->codec;
|
|
||||||
struct sti_sas_data *drvdata = dev_get_drvdata(codec->dev);
|
|
||||||
struct sti_dac_audio *dac = &drvdata->dac;
|
|
||||||
|
|
||||||
/* Get reset control */
|
|
||||||
dac->rst = devm_reset_control_get(codec->dev, "dac_rst");
|
|
||||||
if (IS_ERR(dac->rst)) {
|
|
||||||
dev_err(dai->codec->dev,
|
|
||||||
"%s: ERROR: DAC reset control not defined !\n",
|
|
||||||
__func__);
|
|
||||||
dac->rst = NULL;
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
/* Put the DAC into reset */
|
|
||||||
reset_control_assert(dac->rst);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct snd_soc_dapm_widget stih416_sas_dapm_widgets[] = {
|
|
||||||
SND_SOC_DAPM_PGA("DAC bandgap", STIH416_AUDIO_DAC_CTRL,
|
|
||||||
STIH416_DAC_NOT_PNDBG_MASK, 0, NULL, 0),
|
|
||||||
SND_SOC_DAPM_OUT_DRV("DAC standby ana", STIH416_AUDIO_DAC_CTRL,
|
|
||||||
STIH416_DAC_ANA_NOT_PWR, 0, NULL, 0),
|
|
||||||
SND_SOC_DAPM_DAC("DAC standby", "dac_p", STIH416_AUDIO_DAC_CTRL,
|
|
||||||
STIH416_DAC_NOT_STANDBY, 0),
|
|
||||||
SND_SOC_DAPM_OUTPUT("DAC Output"),
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct snd_soc_dapm_widget stih407_sas_dapm_widgets[] = {
|
static const struct snd_soc_dapm_widget stih407_sas_dapm_widgets[] = {
|
||||||
SND_SOC_DAPM_OUT_DRV("DAC standby ana", STIH407_AUDIO_DAC_CTRL,
|
SND_SOC_DAPM_OUT_DRV("DAC standby ana", STIH407_AUDIO_DAC_CTRL,
|
||||||
STIH407_DAC_STANDBY_ANA, 1, NULL, 0),
|
STIH407_DAC_STANDBY_ANA, 1, NULL, 0),
|
||||||
|
@ -256,30 +175,11 @@ static const struct snd_soc_dapm_widget stih407_sas_dapm_widgets[] = {
|
||||||
SND_SOC_DAPM_OUTPUT("DAC Output"),
|
SND_SOC_DAPM_OUTPUT("DAC Output"),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct snd_soc_dapm_route stih416_sas_route[] = {
|
|
||||||
{"DAC Output", NULL, "DAC bandgap"},
|
|
||||||
{"DAC Output", NULL, "DAC standby ana"},
|
|
||||||
{"DAC standby ana", NULL, "DAC standby"},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct snd_soc_dapm_route stih407_sas_route[] = {
|
static const struct snd_soc_dapm_route stih407_sas_route[] = {
|
||||||
{"DAC Output", NULL, "DAC standby ana"},
|
{"DAC Output", NULL, "DAC standby ana"},
|
||||||
{"DAC standby ana", NULL, "DAC standby"},
|
{"DAC standby ana", NULL, "DAC standby"},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int stih416_sas_dac_mute(struct snd_soc_dai *dai, int mute, int stream)
|
|
||||||
{
|
|
||||||
struct snd_soc_codec *codec = dai->codec;
|
|
||||||
|
|
||||||
if (mute) {
|
|
||||||
return snd_soc_update_bits(codec, STIH416_AUDIO_DAC_CTRL,
|
|
||||||
STIH416_DAC_SOFTMUTE_MASK,
|
|
||||||
STIH416_DAC_SOFTMUTE_MASK);
|
|
||||||
} else {
|
|
||||||
return snd_soc_update_bits(codec, STIH416_AUDIO_DAC_CTRL,
|
|
||||||
STIH416_DAC_SOFTMUTE_MASK, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int stih407_sas_dac_mute(struct snd_soc_dai *dai, int mute, int stream)
|
static int stih407_sas_dac_mute(struct snd_soc_dai *dai, int mute, int stream)
|
||||||
{
|
{
|
||||||
|
@ -392,13 +292,13 @@ static int sti_sas_prepare(struct snd_pcm_substream *substream,
|
||||||
switch (dai->id) {
|
switch (dai->id) {
|
||||||
case STI_SAS_DAI_SPDIF_OUT:
|
case STI_SAS_DAI_SPDIF_OUT:
|
||||||
if ((drvdata->spdif.mclk / runtime->rate) != 128) {
|
if ((drvdata->spdif.mclk / runtime->rate) != 128) {
|
||||||
dev_err(codec->dev, "unexpected mclk-fs ratio");
|
dev_err(codec->dev, "unexpected mclk-fs ratio\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STI_SAS_DAI_ANALOG_OUT:
|
case STI_SAS_DAI_ANALOG_OUT:
|
||||||
if ((drvdata->dac.mclk / runtime->rate) != 256) {
|
if ((drvdata->dac.mclk / runtime->rate) != 256) {
|
||||||
dev_err(codec->dev, "unexpected mclk-fs ratio");
|
dev_err(codec->dev, "unexpected mclk-fs ratio\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -407,13 +307,6 @@ static int sti_sas_prepare(struct snd_pcm_substream *substream,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct snd_soc_dai_ops stih416_dac_ops = {
|
|
||||||
.set_fmt = sti_sas_dac_set_fmt,
|
|
||||||
.mute_stream = stih416_sas_dac_mute,
|
|
||||||
.prepare = sti_sas_prepare,
|
|
||||||
.set_sysclk = sti_sas_set_sysclk,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct snd_soc_dai_ops stih407_dac_ops = {
|
static const struct snd_soc_dai_ops stih407_dac_ops = {
|
||||||
.set_fmt = sti_sas_dac_set_fmt,
|
.set_fmt = sti_sas_dac_set_fmt,
|
||||||
.mute_stream = stih407_sas_dac_mute,
|
.mute_stream = stih407_sas_dac_mute,
|
||||||
|
@ -434,31 +327,7 @@ static const struct regmap_config stih407_sas_regmap = {
|
||||||
.reg_write = sti_sas_write_reg,
|
.reg_write = sti_sas_write_reg,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct regmap_config stih416_sas_regmap = {
|
|
||||||
.reg_bits = 32,
|
|
||||||
.val_bits = 32,
|
|
||||||
|
|
||||||
.max_register = STIH416_AUDIO_DAC_CTRL,
|
|
||||||
.reg_defaults = stih416_sas_reg_defaults,
|
|
||||||
.num_reg_defaults = ARRAY_SIZE(stih416_sas_reg_defaults),
|
|
||||||
.volatile_reg = sti_sas_volatile_register,
|
|
||||||
.cache_type = REGCACHE_RBTREE,
|
|
||||||
.reg_read = sti_sas_read_reg,
|
|
||||||
.reg_write = sti_sas_write_reg,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct sti_sas_dev_data stih416_data = {
|
|
||||||
.chipid = CHIPID_STIH416,
|
|
||||||
.regmap = &stih416_sas_regmap,
|
|
||||||
.dac_ops = &stih416_dac_ops,
|
|
||||||
.dapm_widgets = stih416_sas_dapm_widgets,
|
|
||||||
.num_dapm_widgets = ARRAY_SIZE(stih416_sas_dapm_widgets),
|
|
||||||
.dapm_routes = stih416_sas_route,
|
|
||||||
.num_dapm_routes = ARRAY_SIZE(stih416_sas_route),
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct sti_sas_dev_data stih407_data = {
|
static const struct sti_sas_dev_data stih407_data = {
|
||||||
.chipid = CHIPID_STIH407,
|
|
||||||
.regmap = &stih407_sas_regmap,
|
.regmap = &stih407_sas_regmap,
|
||||||
.dac_ops = &stih407_dac_ops,
|
.dac_ops = &stih407_dac_ops,
|
||||||
.dapm_widgets = stih407_sas_dapm_widgets,
|
.dapm_widgets = stih407_sas_dapm_widgets,
|
||||||
|
@ -532,10 +401,6 @@ static struct snd_soc_codec_driver sti_sas_driver = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct of_device_id sti_sas_dev_match[] = {
|
static const struct of_device_id sti_sas_dev_match[] = {
|
||||||
{
|
|
||||||
.compatible = "st,stih416-sas-codec",
|
|
||||||
.data = &stih416_data,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
.compatible = "st,stih407-sas-codec",
|
.compatible = "st,stih407-sas-codec",
|
||||||
.data = &stih407_data,
|
.data = &stih407_data,
|
||||||
|
@ -558,7 +423,7 @@ static int sti_sas_driver_probe(struct platform_device *pdev)
|
||||||
/* Populate data structure depending on compatibility */
|
/* Populate data structure depending on compatibility */
|
||||||
of_id = of_match_node(sti_sas_dev_match, pnode);
|
of_id = of_match_node(sti_sas_dev_match, pnode);
|
||||||
if (!of_id->data) {
|
if (!of_id->data) {
|
||||||
dev_err(&pdev->dev, "data associated to device is missing");
|
dev_err(&pdev->dev, "data associated to device is missing\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,10 +449,6 @@ static int sti_sas_driver_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
drvdata->spdif.regmap = drvdata->dac.regmap;
|
drvdata->spdif.regmap = drvdata->dac.regmap;
|
||||||
|
|
||||||
/* Set DAC dai probe */
|
|
||||||
if (drvdata->dev_data->chipid == CHIPID_STIH416)
|
|
||||||
sti_sas_dai[STI_SAS_DAI_ANALOG_OUT].probe = stih416_dac_probe;
|
|
||||||
|
|
||||||
sti_sas_dai[STI_SAS_DAI_ANALOG_OUT].ops = drvdata->dev_data->dac_ops;
|
sti_sas_dai[STI_SAS_DAI_ANALOG_OUT].ops = drvdata->dev_data->dac_ops;
|
||||||
|
|
||||||
/* Set dapms*/
|
/* Set dapms*/
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
|
|
||||||
#include "mpc5200_dma.h"
|
#include "mpc5200_dma.h"
|
||||||
#include "mpc5200_psc_ac97.h"
|
#include "mpc5200_psc_ac97.h"
|
||||||
#include "../codecs/stac9766.h"
|
|
||||||
|
|
||||||
#define DRV_NAME "efika-audio-fabric"
|
#define DRV_NAME "efika-audio-fabric"
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/pinctrl/consumer.h>
|
#include <linux/pinctrl/consumer.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
|
|
||||||
#include "uniperif.h"
|
#include "uniperif.h"
|
||||||
|
|
||||||
|
@ -97,6 +98,28 @@ static const struct of_device_id snd_soc_sti_match[] = {
|
||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int sti_uniperiph_reset(struct uniperif *uni)
|
||||||
|
{
|
||||||
|
int count = 10;
|
||||||
|
|
||||||
|
/* Reset uniperipheral uni */
|
||||||
|
SET_UNIPERIF_SOFT_RST_SOFT_RST(uni);
|
||||||
|
|
||||||
|
if (uni->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0) {
|
||||||
|
while (GET_UNIPERIF_SOFT_RST_SOFT_RST(uni) && count) {
|
||||||
|
udelay(5);
|
||||||
|
count--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!count) {
|
||||||
|
dev_err(uni->dev, "Failed to reset uniperif\n");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
|
int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
|
||||||
unsigned int rx_mask, int slots,
|
unsigned int rx_mask, int slots,
|
||||||
int slot_width)
|
int slot_width)
|
||||||
|
@ -293,7 +316,7 @@ static int sti_uniperiph_dai_suspend(struct snd_soc_dai *dai)
|
||||||
|
|
||||||
/* The uniperipheral should be in stopped state */
|
/* The uniperipheral should be in stopped state */
|
||||||
if (uni->state != UNIPERIF_STATE_STOPPED) {
|
if (uni->state != UNIPERIF_STATE_STOPPED) {
|
||||||
dev_err(uni->dev, "%s: invalid uni state( %d)",
|
dev_err(uni->dev, "%s: invalid uni state( %d)\n",
|
||||||
__func__, (int)uni->state);
|
__func__, (int)uni->state);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
@ -301,7 +324,7 @@ static int sti_uniperiph_dai_suspend(struct snd_soc_dai *dai)
|
||||||
/* Pinctrl: switch pinstate to sleep */
|
/* Pinctrl: switch pinstate to sleep */
|
||||||
ret = pinctrl_pm_select_sleep_state(uni->dev);
|
ret = pinctrl_pm_select_sleep_state(uni->dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
dev_err(uni->dev, "%s: failed to select pinctrl state",
|
dev_err(uni->dev, "%s: failed to select pinctrl state\n",
|
||||||
__func__);
|
__func__);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -322,7 +345,7 @@ static int sti_uniperiph_dai_resume(struct snd_soc_dai *dai)
|
||||||
/* pinctrl: switch pinstate to default */
|
/* pinctrl: switch pinstate to default */
|
||||||
ret = pinctrl_pm_select_default_state(uni->dev);
|
ret = pinctrl_pm_select_default_state(uni->dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
dev_err(uni->dev, "%s: failed to select pinctrl state",
|
dev_err(uni->dev, "%s: failed to select pinctrl state\n",
|
||||||
__func__);
|
__func__);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -366,11 +389,12 @@ static int sti_uniperiph_cpu_dai_of(struct device_node *node,
|
||||||
const struct of_device_id *of_id;
|
const struct of_device_id *of_id;
|
||||||
const struct sti_uniperiph_dev_data *dev_data;
|
const struct sti_uniperiph_dev_data *dev_data;
|
||||||
const char *mode;
|
const char *mode;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* Populate data structure depending on compatibility */
|
/* Populate data structure depending on compatibility */
|
||||||
of_id = of_match_node(snd_soc_sti_match, node);
|
of_id = of_match_node(snd_soc_sti_match, node);
|
||||||
if (!of_id->data) {
|
if (!of_id->data) {
|
||||||
dev_err(dev, "data associated to device is missing");
|
dev_err(dev, "data associated to device is missing\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
dev_data = (struct sti_uniperiph_dev_data *)of_id->data;
|
dev_data = (struct sti_uniperiph_dev_data *)of_id->data;
|
||||||
|
@ -389,7 +413,7 @@ static int sti_uniperiph_cpu_dai_of(struct device_node *node,
|
||||||
uni->mem_region = platform_get_resource(priv->pdev, IORESOURCE_MEM, 0);
|
uni->mem_region = platform_get_resource(priv->pdev, IORESOURCE_MEM, 0);
|
||||||
|
|
||||||
if (!uni->mem_region) {
|
if (!uni->mem_region) {
|
||||||
dev_err(dev, "Failed to get memory resource");
|
dev_err(dev, "Failed to get memory resource\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +427,7 @@ static int sti_uniperiph_cpu_dai_of(struct device_node *node,
|
||||||
|
|
||||||
uni->irq = platform_get_irq(priv->pdev, 0);
|
uni->irq = platform_get_irq(priv->pdev, 0);
|
||||||
if (uni->irq < 0) {
|
if (uni->irq < 0) {
|
||||||
dev_err(dev, "Failed to get IRQ resource");
|
dev_err(dev, "Failed to get IRQ resource\n");
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,12 +445,15 @@ static int sti_uniperiph_cpu_dai_of(struct device_node *node,
|
||||||
dai_data->stream = dev_data->stream;
|
dai_data->stream = dev_data->stream;
|
||||||
|
|
||||||
if (priv->dai_data.stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
if (priv->dai_data.stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||||
uni_player_init(priv->pdev, uni);
|
ret = uni_player_init(priv->pdev, uni);
|
||||||
stream = &dai->playback;
|
stream = &dai->playback;
|
||||||
} else {
|
} else {
|
||||||
uni_reader_init(priv->pdev, uni);
|
ret = uni_reader_init(priv->pdev, uni);
|
||||||
stream = &dai->capture;
|
stream = &dai->capture;
|
||||||
}
|
}
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
dai->ops = uni->dai_ops;
|
dai->ops = uni->dai_ops;
|
||||||
|
|
||||||
stream->stream_name = dai->name;
|
stream->stream_name = dai->name;
|
||||||
|
|
|
@ -1397,6 +1397,8 @@ static inline int sti_uniperiph_get_unip_tdm_frame_size(struct uniperif *uni)
|
||||||
return (uni->tdm_slot.slots * uni->tdm_slot.slot_width / 8);
|
return (uni->tdm_slot.slots * uni->tdm_slot.slot_width / 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sti_uniperiph_reset(struct uniperif *uni);
|
||||||
|
|
||||||
int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
|
int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
|
||||||
unsigned int rx_mask, int slots,
|
unsigned int rx_mask, int slots,
|
||||||
int slot_width);
|
int slot_width);
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
#include <linux/delay.h>
|
|
||||||
#include <linux/io.h>
|
|
||||||
#include <linux/mfd/syscon.h>
|
#include <linux/mfd/syscon.h>
|
||||||
|
|
||||||
#include <sound/asoundef.h>
|
#include <sound/asoundef.h>
|
||||||
|
@ -55,25 +53,6 @@ static const struct snd_pcm_hardware uni_player_pcm_hw = {
|
||||||
.buffer_bytes_max = 256 * PAGE_SIZE
|
.buffer_bytes_max = 256 * PAGE_SIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline int reset_player(struct uniperif *player)
|
|
||||||
{
|
|
||||||
int count = 10;
|
|
||||||
|
|
||||||
if (player->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0) {
|
|
||||||
while (GET_UNIPERIF_SOFT_RST_SOFT_RST(player) && count) {
|
|
||||||
udelay(5);
|
|
||||||
count--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!count) {
|
|
||||||
dev_err(player->dev, "Failed to reset uniperif");
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* uni_player_irq_handler
|
* uni_player_irq_handler
|
||||||
* In case of error audio stream is stopped; stop action is protected via PCM
|
* In case of error audio stream is stopped; stop action is protected via PCM
|
||||||
|
@ -97,7 +76,7 @@ static irqreturn_t uni_player_irq_handler(int irq, void *dev_id)
|
||||||
|
|
||||||
/* Check for fifo error (underrun) */
|
/* Check for fifo error (underrun) */
|
||||||
if (unlikely(status & UNIPERIF_ITS_FIFO_ERROR_MASK(player))) {
|
if (unlikely(status & UNIPERIF_ITS_FIFO_ERROR_MASK(player))) {
|
||||||
dev_err(player->dev, "FIFO underflow error detected");
|
dev_err(player->dev, "FIFO underflow error detected\n");
|
||||||
|
|
||||||
/* Interrupt is just for information when underflow recovery */
|
/* Interrupt is just for information when underflow recovery */
|
||||||
if (player->underflow_enabled) {
|
if (player->underflow_enabled) {
|
||||||
|
@ -119,7 +98,7 @@ static irqreturn_t uni_player_irq_handler(int irq, void *dev_id)
|
||||||
|
|
||||||
/* Check for dma error (overrun) */
|
/* Check for dma error (overrun) */
|
||||||
if (unlikely(status & UNIPERIF_ITS_DMA_ERROR_MASK(player))) {
|
if (unlikely(status & UNIPERIF_ITS_DMA_ERROR_MASK(player))) {
|
||||||
dev_err(player->dev, "DMA error detected");
|
dev_err(player->dev, "DMA error detected\n");
|
||||||
|
|
||||||
/* Disable interrupt so doesn't continually fire */
|
/* Disable interrupt so doesn't continually fire */
|
||||||
SET_UNIPERIF_ITM_BCLR_DMA_ERROR(player);
|
SET_UNIPERIF_ITM_BCLR_DMA_ERROR(player);
|
||||||
|
@ -135,11 +114,14 @@ static irqreturn_t uni_player_irq_handler(int irq, void *dev_id)
|
||||||
/* Check for underflow recovery done */
|
/* Check for underflow recovery done */
|
||||||
if (unlikely(status & UNIPERIF_ITM_UNDERFLOW_REC_DONE_MASK(player))) {
|
if (unlikely(status & UNIPERIF_ITM_UNDERFLOW_REC_DONE_MASK(player))) {
|
||||||
if (!player->underflow_enabled) {
|
if (!player->underflow_enabled) {
|
||||||
dev_err(player->dev, "unexpected Underflow recovering");
|
dev_err(player->dev,
|
||||||
|
"unexpected Underflow recovering\n");
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
/* Read the underflow recovery duration */
|
/* Read the underflow recovery duration */
|
||||||
tmp = GET_UNIPERIF_STATUS_1_UNDERFLOW_DURATION(player);
|
tmp = GET_UNIPERIF_STATUS_1_UNDERFLOW_DURATION(player);
|
||||||
|
dev_dbg(player->dev, "Underflow recovered (%d LR clocks max)\n",
|
||||||
|
tmp);
|
||||||
|
|
||||||
/* Clear the underflow recovery duration */
|
/* Clear the underflow recovery duration */
|
||||||
SET_UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION(player);
|
SET_UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION(player);
|
||||||
|
@ -153,7 +135,7 @@ static irqreturn_t uni_player_irq_handler(int irq, void *dev_id)
|
||||||
/* Check if underflow recovery failed */
|
/* Check if underflow recovery failed */
|
||||||
if (unlikely(status &
|
if (unlikely(status &
|
||||||
UNIPERIF_ITM_UNDERFLOW_REC_FAILED_MASK(player))) {
|
UNIPERIF_ITM_UNDERFLOW_REC_FAILED_MASK(player))) {
|
||||||
dev_err(player->dev, "Underflow recovery failed");
|
dev_err(player->dev, "Underflow recovery failed\n");
|
||||||
|
|
||||||
/* Stop the player */
|
/* Stop the player */
|
||||||
snd_pcm_stream_lock(player->substream);
|
snd_pcm_stream_lock(player->substream);
|
||||||
|
@ -336,7 +318,7 @@ static int uni_player_prepare_iec958(struct uniperif *player,
|
||||||
|
|
||||||
/* Oversampling must be multiple of 128 as iec958 frame is 32-bits */
|
/* Oversampling must be multiple of 128 as iec958 frame is 32-bits */
|
||||||
if ((clk_div % 128) || (clk_div <= 0)) {
|
if ((clk_div % 128) || (clk_div <= 0)) {
|
||||||
dev_err(player->dev, "%s: invalid clk_div %d",
|
dev_err(player->dev, "%s: invalid clk_div %d\n",
|
||||||
__func__, clk_div);
|
__func__, clk_div);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -359,7 +341,7 @@ static int uni_player_prepare_iec958(struct uniperif *player,
|
||||||
SET_UNIPERIF_I2S_FMT_DATA_SIZE_24(player);
|
SET_UNIPERIF_I2S_FMT_DATA_SIZE_24(player);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(player->dev, "format not supported");
|
dev_err(player->dev, "format not supported\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,12 +430,12 @@ static int uni_player_prepare_pcm(struct uniperif *player,
|
||||||
* for 16 bits must be a multiple of 64
|
* for 16 bits must be a multiple of 64
|
||||||
*/
|
*/
|
||||||
if ((slot_width == 32) && (clk_div % 128)) {
|
if ((slot_width == 32) && (clk_div % 128)) {
|
||||||
dev_err(player->dev, "%s: invalid clk_div", __func__);
|
dev_err(player->dev, "%s: invalid clk_div\n", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((slot_width == 16) && (clk_div % 64)) {
|
if ((slot_width == 16) && (clk_div % 64)) {
|
||||||
dev_err(player->dev, "%s: invalid clk_div", __func__);
|
dev_err(player->dev, "%s: invalid clk_div\n", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,7 +453,7 @@ static int uni_player_prepare_pcm(struct uniperif *player,
|
||||||
SET_UNIPERIF_I2S_FMT_DATA_SIZE_16(player);
|
SET_UNIPERIF_I2S_FMT_DATA_SIZE_16(player);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(player->dev, "subframe format not supported");
|
dev_err(player->dev, "subframe format not supported\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,7 +473,7 @@ static int uni_player_prepare_pcm(struct uniperif *player,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
dev_err(player->dev, "format not supported");
|
dev_err(player->dev, "format not supported\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -504,7 +486,7 @@ static int uni_player_prepare_pcm(struct uniperif *player,
|
||||||
/* Number of channelsmust be even*/
|
/* Number of channelsmust be even*/
|
||||||
if ((runtime->channels % 2) || (runtime->channels < 2) ||
|
if ((runtime->channels % 2) || (runtime->channels < 2) ||
|
||||||
(runtime->channels > 10)) {
|
(runtime->channels > 10)) {
|
||||||
dev_err(player->dev, "%s: invalid nb of channels", __func__);
|
dev_err(player->dev, "%s: invalid nb of channels\n", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,7 +744,7 @@ static int uni_player_prepare(struct snd_pcm_substream *substream,
|
||||||
|
|
||||||
/* The player should be stopped */
|
/* The player should be stopped */
|
||||||
if (player->state != UNIPERIF_STATE_STOPPED) {
|
if (player->state != UNIPERIF_STATE_STOPPED) {
|
||||||
dev_err(player->dev, "%s: invalid player state %d", __func__,
|
dev_err(player->dev, "%s: invalid player state %d\n", __func__,
|
||||||
player->state);
|
player->state);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -791,7 +773,8 @@ static int uni_player_prepare(struct snd_pcm_substream *substream,
|
||||||
/* Trigger limit must be an even number */
|
/* Trigger limit must be an even number */
|
||||||
if ((!trigger_limit % 2) || (trigger_limit != 1 && transfer_size % 2) ||
|
if ((!trigger_limit % 2) || (trigger_limit != 1 && transfer_size % 2) ||
|
||||||
(trigger_limit > UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK(player))) {
|
(trigger_limit > UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK(player))) {
|
||||||
dev_err(player->dev, "invalid trigger limit %d", trigger_limit);
|
dev_err(player->dev, "invalid trigger limit %d\n",
|
||||||
|
trigger_limit);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -812,7 +795,7 @@ static int uni_player_prepare(struct snd_pcm_substream *substream,
|
||||||
ret = uni_player_prepare_tdm(player, runtime);
|
ret = uni_player_prepare_tdm(player, runtime);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(player->dev, "invalid player type");
|
dev_err(player->dev, "invalid player type\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -852,16 +835,14 @@ static int uni_player_prepare(struct snd_pcm_substream *substream,
|
||||||
SET_UNIPERIF_I2S_FMT_PADDING_SONY_MODE(player);
|
SET_UNIPERIF_I2S_FMT_PADDING_SONY_MODE(player);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(player->dev, "format not supported");
|
dev_err(player->dev, "format not supported\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SET_UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ(player, 0);
|
SET_UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ(player, 0);
|
||||||
|
|
||||||
/* Reset uniperipheral player */
|
|
||||||
SET_UNIPERIF_SOFT_RST_SOFT_RST(player);
|
|
||||||
|
|
||||||
return reset_player(player);
|
return sti_uniperiph_reset(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int uni_player_start(struct uniperif *player)
|
static int uni_player_start(struct uniperif *player)
|
||||||
|
@ -870,13 +851,13 @@ static int uni_player_start(struct uniperif *player)
|
||||||
|
|
||||||
/* The player should be stopped */
|
/* The player should be stopped */
|
||||||
if (player->state != UNIPERIF_STATE_STOPPED) {
|
if (player->state != UNIPERIF_STATE_STOPPED) {
|
||||||
dev_err(player->dev, "%s: invalid player state", __func__);
|
dev_err(player->dev, "%s: invalid player state\n", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = clk_prepare_enable(player->clk);
|
ret = clk_prepare_enable(player->clk);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(player->dev, "%s: Failed to enable clock", __func__);
|
dev_err(player->dev, "%s: Failed to enable clock\n", __func__);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -893,10 +874,7 @@ static int uni_player_start(struct uniperif *player)
|
||||||
SET_UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED(player);
|
SET_UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset uniperipheral player */
|
ret = sti_uniperiph_reset(player);
|
||||||
SET_UNIPERIF_SOFT_RST_SOFT_RST(player);
|
|
||||||
|
|
||||||
ret = reset_player(player);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
clk_disable_unprepare(player->clk);
|
clk_disable_unprepare(player->clk);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -938,17 +916,14 @@ static int uni_player_stop(struct uniperif *player)
|
||||||
|
|
||||||
/* The player should not be in stopped state */
|
/* The player should not be in stopped state */
|
||||||
if (player->state == UNIPERIF_STATE_STOPPED) {
|
if (player->state == UNIPERIF_STATE_STOPPED) {
|
||||||
dev_err(player->dev, "%s: invalid player state", __func__);
|
dev_err(player->dev, "%s: invalid player state\n", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Turn the player off */
|
/* Turn the player off */
|
||||||
SET_UNIPERIF_CTRL_OPERATION_OFF(player);
|
SET_UNIPERIF_CTRL_OPERATION_OFF(player);
|
||||||
|
|
||||||
/* Soft reset the player */
|
ret = sti_uniperiph_reset(player);
|
||||||
SET_UNIPERIF_SOFT_RST_SOFT_RST(player);
|
|
||||||
|
|
||||||
ret = reset_player(player);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -973,7 +948,7 @@ int uni_player_resume(struct uniperif *player)
|
||||||
ret = regmap_field_write(player->clk_sel, 1);
|
ret = regmap_field_write(player->clk_sel, 1);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(player->dev,
|
dev_err(player->dev,
|
||||||
"%s: Failed to select freq synth clock",
|
"%s: Failed to select freq synth clock\n",
|
||||||
__func__);
|
__func__);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1070,7 +1045,7 @@ int uni_player_init(struct platform_device *pdev,
|
||||||
ret = uni_player_parse_dt_audio_glue(pdev, player);
|
ret = uni_player_parse_dt_audio_glue(pdev, player);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(player->dev, "Failed to parse DeviceTree");
|
dev_err(player->dev, "Failed to parse DeviceTree\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1085,15 +1060,17 @@ int uni_player_init(struct platform_device *pdev,
|
||||||
|
|
||||||
/* Get uniperif resource */
|
/* Get uniperif resource */
|
||||||
player->clk = of_clk_get(pdev->dev.of_node, 0);
|
player->clk = of_clk_get(pdev->dev.of_node, 0);
|
||||||
if (IS_ERR(player->clk))
|
if (IS_ERR(player->clk)) {
|
||||||
|
dev_err(player->dev, "Failed to get clock\n");
|
||||||
ret = PTR_ERR(player->clk);
|
ret = PTR_ERR(player->clk);
|
||||||
|
}
|
||||||
|
|
||||||
/* Select the frequency synthesizer clock */
|
/* Select the frequency synthesizer clock */
|
||||||
if (player->clk_sel) {
|
if (player->clk_sel) {
|
||||||
ret = regmap_field_write(player->clk_sel, 1);
|
ret = regmap_field_write(player->clk_sel, 1);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(player->dev,
|
dev_err(player->dev,
|
||||||
"%s: Failed to select freq synth clock",
|
"%s: Failed to select freq synth clock\n",
|
||||||
__func__);
|
__func__);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1105,7 +1082,7 @@ int uni_player_init(struct platform_device *pdev,
|
||||||
ret = regmap_field_write(player->valid_sel, player->id);
|
ret = regmap_field_write(player->valid_sel, player->id);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(player->dev,
|
dev_err(player->dev,
|
||||||
"%s: unable to connect to tdm bus", __func__);
|
"%s: unable to connect to tdm bus\n", __func__);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1113,8 +1090,10 @@ int uni_player_init(struct platform_device *pdev,
|
||||||
ret = devm_request_irq(&pdev->dev, player->irq,
|
ret = devm_request_irq(&pdev->dev, player->irq,
|
||||||
uni_player_irq_handler, IRQF_SHARED,
|
uni_player_irq_handler, IRQF_SHARED,
|
||||||
dev_name(&pdev->dev), player);
|
dev_name(&pdev->dev), player);
|
||||||
if (ret < 0)
|
if (ret < 0) {
|
||||||
|
dev_err(player->dev, "unable to request IRQ %d\n", player->irq);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
mutex_init(&player->ctrl_lock);
|
mutex_init(&player->ctrl_lock);
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,6 @@
|
||||||
* License terms: GNU General Public License (GPL), version 2
|
* License terms: GNU General Public License (GPL), version 2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/clk.h>
|
|
||||||
#include <linux/delay.h>
|
|
||||||
#include <linux/io.h>
|
|
||||||
|
|
||||||
#include <sound/soc.h>
|
#include <sound/soc.h>
|
||||||
|
|
||||||
#include "uniperif.h"
|
#include "uniperif.h"
|
||||||
|
@ -52,7 +48,7 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)
|
||||||
|
|
||||||
if (reader->state == UNIPERIF_STATE_STOPPED) {
|
if (reader->state == UNIPERIF_STATE_STOPPED) {
|
||||||
/* Unexpected IRQ: do nothing */
|
/* Unexpected IRQ: do nothing */
|
||||||
dev_warn(reader->dev, "unexpected IRQ ");
|
dev_warn(reader->dev, "unexpected IRQ\n");
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +58,7 @@ static irqreturn_t uni_reader_irq_handler(int irq, void *dev_id)
|
||||||
|
|
||||||
/* Check for fifo overflow error */
|
/* Check for fifo overflow error */
|
||||||
if (unlikely(status & UNIPERIF_ITS_FIFO_ERROR_MASK(reader))) {
|
if (unlikely(status & UNIPERIF_ITS_FIFO_ERROR_MASK(reader))) {
|
||||||
dev_err(reader->dev, "FIFO error detected");
|
dev_err(reader->dev, "FIFO error detected\n");
|
||||||
|
|
||||||
snd_pcm_stream_lock(reader->substream);
|
snd_pcm_stream_lock(reader->substream);
|
||||||
snd_pcm_stop(reader->substream, SNDRV_PCM_STATE_XRUN);
|
snd_pcm_stop(reader->substream, SNDRV_PCM_STATE_XRUN);
|
||||||
|
@ -105,7 +101,7 @@ static int uni_reader_prepare_pcm(struct snd_pcm_runtime *runtime,
|
||||||
SET_UNIPERIF_I2S_FMT_DATA_SIZE_16(reader);
|
SET_UNIPERIF_I2S_FMT_DATA_SIZE_16(reader);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(reader->dev, "subframe format not supported");
|
dev_err(reader->dev, "subframe format not supported\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,14 +121,14 @@ static int uni_reader_prepare_pcm(struct snd_pcm_runtime *runtime,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
dev_err(reader->dev, "format not supported");
|
dev_err(reader->dev, "format not supported\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Number of channels must be even */
|
/* Number of channels must be even */
|
||||||
if ((runtime->channels % 2) || (runtime->channels < 2) ||
|
if ((runtime->channels % 2) || (runtime->channels < 2) ||
|
||||||
(runtime->channels > 10)) {
|
(runtime->channels > 10)) {
|
||||||
dev_err(reader->dev, "%s: invalid nb of channels", __func__);
|
dev_err(reader->dev, "%s: invalid nb of channels\n", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,11 +182,10 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,
|
||||||
struct uniperif *reader = priv->dai_data.uni;
|
struct uniperif *reader = priv->dai_data.uni;
|
||||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||||
int transfer_size, trigger_limit, ret;
|
int transfer_size, trigger_limit, ret;
|
||||||
int count = 10;
|
|
||||||
|
|
||||||
/* The reader should be stopped */
|
/* The reader should be stopped */
|
||||||
if (reader->state != UNIPERIF_STATE_STOPPED) {
|
if (reader->state != UNIPERIF_STATE_STOPPED) {
|
||||||
dev_err(reader->dev, "%s: invalid reader state %d", __func__,
|
dev_err(reader->dev, "%s: invalid reader state %d\n", __func__,
|
||||||
reader->state);
|
reader->state);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -219,7 +214,8 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,
|
||||||
if ((!trigger_limit % 2) ||
|
if ((!trigger_limit % 2) ||
|
||||||
(trigger_limit != 1 && transfer_size % 2) ||
|
(trigger_limit != 1 && transfer_size % 2) ||
|
||||||
(trigger_limit > UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK(reader))) {
|
(trigger_limit > UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK(reader))) {
|
||||||
dev_err(reader->dev, "invalid trigger limit %d", trigger_limit);
|
dev_err(reader->dev, "invalid trigger limit %d\n",
|
||||||
|
trigger_limit);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +242,7 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,
|
||||||
SET_UNIPERIF_I2S_FMT_PADDING_SONY_MODE(reader);
|
SET_UNIPERIF_I2S_FMT_PADDING_SONY_MODE(reader);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
dev_err(reader->dev, "format not supported");
|
dev_err(reader->dev, "format not supported\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,25 +283,14 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset uniperipheral reader */
|
/* Reset uniperipheral reader */
|
||||||
SET_UNIPERIF_SOFT_RST_SOFT_RST(reader);
|
return sti_uniperiph_reset(reader);
|
||||||
|
|
||||||
while (GET_UNIPERIF_SOFT_RST_SOFT_RST(reader)) {
|
|
||||||
udelay(5);
|
|
||||||
count--;
|
|
||||||
}
|
|
||||||
if (!count) {
|
|
||||||
dev_err(reader->dev, "Failed to reset uniperif");
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int uni_reader_start(struct uniperif *reader)
|
static int uni_reader_start(struct uniperif *reader)
|
||||||
{
|
{
|
||||||
/* The reader should be stopped */
|
/* The reader should be stopped */
|
||||||
if (reader->state != UNIPERIF_STATE_STOPPED) {
|
if (reader->state != UNIPERIF_STATE_STOPPED) {
|
||||||
dev_err(reader->dev, "%s: invalid reader state", __func__);
|
dev_err(reader->dev, "%s: invalid reader state\n", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +310,7 @@ static int uni_reader_stop(struct uniperif *reader)
|
||||||
{
|
{
|
||||||
/* The reader should not be in stopped state */
|
/* The reader should not be in stopped state */
|
||||||
if (reader->state == UNIPERIF_STATE_STOPPED) {
|
if (reader->state == UNIPERIF_STATE_STOPPED) {
|
||||||
dev_err(reader->dev, "%s: invalid reader state", __func__);
|
dev_err(reader->dev, "%s: invalid reader state\n", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,7 +408,7 @@ int uni_reader_init(struct platform_device *pdev,
|
||||||
uni_reader_irq_handler, IRQF_SHARED,
|
uni_reader_irq_handler, IRQF_SHARED,
|
||||||
dev_name(&pdev->dev), reader);
|
dev_name(&pdev->dev), reader);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&pdev->dev, "Failed to request IRQ");
|
dev_err(&pdev->dev, "Failed to request IRQ\n");
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,14 @@ config SND_SUN4I_CODEC
|
||||||
Select Y or M to add support for the Codec embedded in the Allwinner
|
Select Y or M to add support for the Codec embedded in the Allwinner
|
||||||
A10 and affiliated SoCs.
|
A10 and affiliated SoCs.
|
||||||
|
|
||||||
|
config SND_SUN8I_CODEC_ANALOG
|
||||||
|
tristate "Allwinner sun8i Codec Analog Controls Support"
|
||||||
|
depends on MACH_SUN8I || COMPILE_TEST
|
||||||
|
select REGMAP
|
||||||
|
help
|
||||||
|
Say Y or M if you want to add support for the analog controls for
|
||||||
|
the codec embedded in newer Allwinner SoCs.
|
||||||
|
|
||||||
config SND_SUN4I_I2S
|
config SND_SUN4I_I2S
|
||||||
tristate "Allwinner A10 I2S Support"
|
tristate "Allwinner A10 I2S Support"
|
||||||
select SND_SOC_GENERIC_DMAENGINE_PCM
|
select SND_SOC_GENERIC_DMAENGINE_PCM
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
obj-$(CONFIG_SND_SUN4I_CODEC) += sun4i-codec.o
|
obj-$(CONFIG_SND_SUN4I_CODEC) += sun4i-codec.o
|
||||||
obj-$(CONFIG_SND_SUN4I_I2S) += sun4i-i2s.o
|
obj-$(CONFIG_SND_SUN4I_I2S) += sun4i-i2s.o
|
||||||
obj-$(CONFIG_SND_SUN4I_SPDIF) += sun4i-spdif.o
|
obj-$(CONFIG_SND_SUN4I_SPDIF) += sun4i-spdif.o
|
||||||
|
obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -93,6 +93,9 @@ struct sun4i_i2s {
|
||||||
struct clk *mod_clk;
|
struct clk *mod_clk;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
|
|
||||||
|
unsigned int mclk_freq;
|
||||||
|
|
||||||
|
struct snd_dmaengine_dai_dma_data capture_dma_data;
|
||||||
struct snd_dmaengine_dai_dma_data playback_dma_data;
|
struct snd_dmaengine_dai_dma_data playback_dma_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -157,14 +160,24 @@ static int sun4i_i2s_get_mclk_div(struct sun4i_i2s *i2s,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sun4i_i2s_oversample_rates[] = { 128, 192, 256, 384, 512, 768 };
|
static int sun4i_i2s_oversample_rates[] = { 128, 192, 256, 384, 512, 768 };
|
||||||
|
static bool sun4i_i2s_oversample_is_valid(unsigned int oversample)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(sun4i_i2s_oversample_rates); i++)
|
||||||
|
if (sun4i_i2s_oversample_rates[i] == oversample)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static int sun4i_i2s_set_clk_rate(struct sun4i_i2s *i2s,
|
static int sun4i_i2s_set_clk_rate(struct sun4i_i2s *i2s,
|
||||||
unsigned int rate,
|
unsigned int rate,
|
||||||
unsigned int word_size)
|
unsigned int word_size)
|
||||||
{
|
{
|
||||||
unsigned int clk_rate;
|
unsigned int oversample_rate, clk_rate;
|
||||||
int bclk_div, mclk_div;
|
int bclk_div, mclk_div;
|
||||||
int ret, i;
|
int ret;
|
||||||
|
|
||||||
switch (rate) {
|
switch (rate) {
|
||||||
case 176400:
|
case 176400:
|
||||||
|
@ -196,21 +209,18 @@ static int sun4i_i2s_set_clk_rate(struct sun4i_i2s *i2s,
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* Always favor the highest oversampling rate */
|
oversample_rate = i2s->mclk_freq / rate;
|
||||||
for (i = (ARRAY_SIZE(sun4i_i2s_oversample_rates) - 1); i >= 0; i--) {
|
if (!sun4i_i2s_oversample_is_valid(oversample_rate))
|
||||||
unsigned int oversample_rate = sun4i_i2s_oversample_rates[i];
|
return -EINVAL;
|
||||||
|
|
||||||
bclk_div = sun4i_i2s_get_bclk_div(i2s, oversample_rate,
|
bclk_div = sun4i_i2s_get_bclk_div(i2s, oversample_rate,
|
||||||
word_size);
|
word_size);
|
||||||
|
if (bclk_div < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
mclk_div = sun4i_i2s_get_mclk_div(i2s, oversample_rate,
|
mclk_div = sun4i_i2s_get_mclk_div(i2s, oversample_rate,
|
||||||
clk_rate,
|
clk_rate, rate);
|
||||||
rate);
|
if (mclk_div < 0)
|
||||||
|
|
||||||
if ((bclk_div >= 0) && (mclk_div >= 0))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((bclk_div < 0) || (mclk_div < 0))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
regmap_write(i2s->regmap, SUN4I_I2S_CLK_DIV_REG,
|
regmap_write(i2s->regmap, SUN4I_I2S_CLK_DIV_REG,
|
||||||
|
@ -341,6 +351,27 @@ static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sun4i_i2s_start_capture(struct sun4i_i2s *i2s)
|
||||||
|
{
|
||||||
|
/* Flush RX FIFO */
|
||||||
|
regmap_update_bits(i2s->regmap, SUN4I_I2S_FIFO_CTRL_REG,
|
||||||
|
SUN4I_I2S_FIFO_CTRL_FLUSH_RX,
|
||||||
|
SUN4I_I2S_FIFO_CTRL_FLUSH_RX);
|
||||||
|
|
||||||
|
/* Clear RX counter */
|
||||||
|
regmap_write(i2s->regmap, SUN4I_I2S_RX_CNT_REG, 0);
|
||||||
|
|
||||||
|
/* Enable RX Block */
|
||||||
|
regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
|
||||||
|
SUN4I_I2S_CTRL_RX_EN,
|
||||||
|
SUN4I_I2S_CTRL_RX_EN);
|
||||||
|
|
||||||
|
/* Enable RX DRQ */
|
||||||
|
regmap_update_bits(i2s->regmap, SUN4I_I2S_DMA_INT_CTRL_REG,
|
||||||
|
SUN4I_I2S_DMA_INT_CTRL_RX_DRQ_EN,
|
||||||
|
SUN4I_I2S_DMA_INT_CTRL_RX_DRQ_EN);
|
||||||
|
}
|
||||||
|
|
||||||
static void sun4i_i2s_start_playback(struct sun4i_i2s *i2s)
|
static void sun4i_i2s_start_playback(struct sun4i_i2s *i2s)
|
||||||
{
|
{
|
||||||
/* Flush TX FIFO */
|
/* Flush TX FIFO */
|
||||||
|
@ -362,6 +393,18 @@ static void sun4i_i2s_start_playback(struct sun4i_i2s *i2s)
|
||||||
SUN4I_I2S_DMA_INT_CTRL_TX_DRQ_EN);
|
SUN4I_I2S_DMA_INT_CTRL_TX_DRQ_EN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sun4i_i2s_stop_capture(struct sun4i_i2s *i2s)
|
||||||
|
{
|
||||||
|
/* Disable RX Block */
|
||||||
|
regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
|
||||||
|
SUN4I_I2S_CTRL_RX_EN,
|
||||||
|
0);
|
||||||
|
|
||||||
|
/* Disable RX DRQ */
|
||||||
|
regmap_update_bits(i2s->regmap, SUN4I_I2S_DMA_INT_CTRL_REG,
|
||||||
|
SUN4I_I2S_DMA_INT_CTRL_RX_DRQ_EN,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
static void sun4i_i2s_stop_playback(struct sun4i_i2s *i2s)
|
static void sun4i_i2s_stop_playback(struct sun4i_i2s *i2s)
|
||||||
{
|
{
|
||||||
|
@ -388,7 +431,7 @@ static int sun4i_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
||||||
sun4i_i2s_start_playback(i2s);
|
sun4i_i2s_start_playback(i2s);
|
||||||
else
|
else
|
||||||
return -EINVAL;
|
sun4i_i2s_start_capture(i2s);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNDRV_PCM_TRIGGER_STOP:
|
case SNDRV_PCM_TRIGGER_STOP:
|
||||||
|
@ -397,7 +440,7 @@ static int sun4i_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
||||||
sun4i_i2s_stop_playback(i2s);
|
sun4i_i2s_stop_playback(i2s);
|
||||||
else
|
else
|
||||||
return -EINVAL;
|
sun4i_i2s_stop_capture(i2s);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -447,9 +490,23 @@ static void sun4i_i2s_shutdown(struct snd_pcm_substream *substream,
|
||||||
regmap_write(i2s->regmap, SUN4I_I2S_CTRL_REG, 0);
|
regmap_write(i2s->regmap, SUN4I_I2S_CTRL_REG, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sun4i_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id,
|
||||||
|
unsigned int freq, int dir)
|
||||||
|
{
|
||||||
|
struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
|
||||||
|
|
||||||
|
if (clk_id != 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
i2s->mclk_freq = freq;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct snd_soc_dai_ops sun4i_i2s_dai_ops = {
|
static const struct snd_soc_dai_ops sun4i_i2s_dai_ops = {
|
||||||
.hw_params = sun4i_i2s_hw_params,
|
.hw_params = sun4i_i2s_hw_params,
|
||||||
.set_fmt = sun4i_i2s_set_fmt,
|
.set_fmt = sun4i_i2s_set_fmt,
|
||||||
|
.set_sysclk = sun4i_i2s_set_sysclk,
|
||||||
.shutdown = sun4i_i2s_shutdown,
|
.shutdown = sun4i_i2s_shutdown,
|
||||||
.startup = sun4i_i2s_startup,
|
.startup = sun4i_i2s_startup,
|
||||||
.trigger = sun4i_i2s_trigger,
|
.trigger = sun4i_i2s_trigger,
|
||||||
|
@ -459,7 +516,9 @@ static int sun4i_i2s_dai_probe(struct snd_soc_dai *dai)
|
||||||
{
|
{
|
||||||
struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
|
struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
|
||||||
|
|
||||||
snd_soc_dai_init_dma_data(dai, &i2s->playback_dma_data, NULL);
|
snd_soc_dai_init_dma_data(dai,
|
||||||
|
&i2s->playback_dma_data,
|
||||||
|
&i2s->capture_dma_data);
|
||||||
|
|
||||||
snd_soc_dai_set_drvdata(dai, i2s);
|
snd_soc_dai_set_drvdata(dai, i2s);
|
||||||
|
|
||||||
|
@ -468,6 +527,13 @@ static int sun4i_i2s_dai_probe(struct snd_soc_dai *dai)
|
||||||
|
|
||||||
static struct snd_soc_dai_driver sun4i_i2s_dai = {
|
static struct snd_soc_dai_driver sun4i_i2s_dai = {
|
||||||
.probe = sun4i_i2s_dai_probe,
|
.probe = sun4i_i2s_dai_probe,
|
||||||
|
.capture = {
|
||||||
|
.stream_name = "Capture",
|
||||||
|
.channels_min = 2,
|
||||||
|
.channels_max = 2,
|
||||||
|
.rates = SNDRV_PCM_RATE_8000_192000,
|
||||||
|
.formats = SNDRV_PCM_FMTBIT_S16_LE,
|
||||||
|
},
|
||||||
.playback = {
|
.playback = {
|
||||||
.stream_name = "Playback",
|
.stream_name = "Playback",
|
||||||
.channels_min = 2,
|
.channels_min = 2,
|
||||||
|
@ -630,6 +696,9 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
|
||||||
i2s->playback_dma_data.addr = res->start + SUN4I_I2S_FIFO_TX_REG;
|
i2s->playback_dma_data.addr = res->start + SUN4I_I2S_FIFO_TX_REG;
|
||||||
i2s->playback_dma_data.maxburst = 4;
|
i2s->playback_dma_data.maxburst = 4;
|
||||||
|
|
||||||
|
i2s->capture_dma_data.addr = res->start + SUN4I_I2S_FIFO_RX_REG;
|
||||||
|
i2s->capture_dma_data.maxburst = 4;
|
||||||
|
|
||||||
pm_runtime_enable(&pdev->dev);
|
pm_runtime_enable(&pdev->dev);
|
||||||
if (!pm_runtime_enabled(&pdev->dev)) {
|
if (!pm_runtime_enabled(&pdev->dev)) {
|
||||||
ret = sun4i_i2s_runtime_resume(&pdev->dev);
|
ret = sun4i_i2s_runtime_resume(&pdev->dev);
|
||||||
|
|
665
sound/soc/sunxi/sun8i-codec-analog.c
Normal file
665
sound/soc/sunxi/sun8i-codec-analog.c
Normal file
|
@ -0,0 +1,665 @@
|
||||||
|
/*
|
||||||
|
* This driver supports the analog controls for the internal codec
|
||||||
|
* found in Allwinner's A31s, A23, A33 and H3 SoCs.
|
||||||
|
*
|
||||||
|
* Copyright 2016 Chen-Yu Tsai <wens@csie.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/io.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/of.h>
|
||||||
|
#include <linux/of_device.h>
|
||||||
|
#include <linux/platform_device.h>
|
||||||
|
#include <linux/regmap.h>
|
||||||
|
|
||||||
|
#include <sound/soc.h>
|
||||||
|
#include <sound/soc-dapm.h>
|
||||||
|
#include <sound/tlv.h>
|
||||||
|
|
||||||
|
/* Codec analog control register offsets and bit fields */
|
||||||
|
#define SUN8I_ADDA_HP_VOLC 0x00
|
||||||
|
#define SUN8I_ADDA_HP_VOLC_PA_CLK_GATE 7
|
||||||
|
#define SUN8I_ADDA_HP_VOLC_HP_VOL 0
|
||||||
|
#define SUN8I_ADDA_LOMIXSC 0x01
|
||||||
|
#define SUN8I_ADDA_LOMIXSC_MIC1 6
|
||||||
|
#define SUN8I_ADDA_LOMIXSC_MIC2 5
|
||||||
|
#define SUN8I_ADDA_LOMIXSC_PHONE 4
|
||||||
|
#define SUN8I_ADDA_LOMIXSC_PHONEN 3
|
||||||
|
#define SUN8I_ADDA_LOMIXSC_LINEINL 2
|
||||||
|
#define SUN8I_ADDA_LOMIXSC_DACL 1
|
||||||
|
#define SUN8I_ADDA_LOMIXSC_DACR 0
|
||||||
|
#define SUN8I_ADDA_ROMIXSC 0x02
|
||||||
|
#define SUN8I_ADDA_ROMIXSC_MIC1 6
|
||||||
|
#define SUN8I_ADDA_ROMIXSC_MIC2 5
|
||||||
|
#define SUN8I_ADDA_ROMIXSC_PHONE 4
|
||||||
|
#define SUN8I_ADDA_ROMIXSC_PHONEP 3
|
||||||
|
#define SUN8I_ADDA_ROMIXSC_LINEINR 2
|
||||||
|
#define SUN8I_ADDA_ROMIXSC_DACR 1
|
||||||
|
#define SUN8I_ADDA_ROMIXSC_DACL 0
|
||||||
|
#define SUN8I_ADDA_DAC_PA_SRC 0x03
|
||||||
|
#define SUN8I_ADDA_DAC_PA_SRC_DACAREN 7
|
||||||
|
#define SUN8I_ADDA_DAC_PA_SRC_DACALEN 6
|
||||||
|
#define SUN8I_ADDA_DAC_PA_SRC_RMIXEN 5
|
||||||
|
#define SUN8I_ADDA_DAC_PA_SRC_LMIXEN 4
|
||||||
|
#define SUN8I_ADDA_DAC_PA_SRC_RHPPAMUTE 3
|
||||||
|
#define SUN8I_ADDA_DAC_PA_SRC_LHPPAMUTE 2
|
||||||
|
#define SUN8I_ADDA_DAC_PA_SRC_RHPIS 1
|
||||||
|
#define SUN8I_ADDA_DAC_PA_SRC_LHPIS 0
|
||||||
|
#define SUN8I_ADDA_PHONEIN_GCTRL 0x04
|
||||||
|
#define SUN8I_ADDA_PHONEIN_GCTRL_PHONEPG 4
|
||||||
|
#define SUN8I_ADDA_PHONEIN_GCTRL_PHONENG 0
|
||||||
|
#define SUN8I_ADDA_LINEIN_GCTRL 0x05
|
||||||
|
#define SUN8I_ADDA_LINEIN_GCTRL_LINEING 4
|
||||||
|
#define SUN8I_ADDA_LINEIN_GCTRL_PHONEG 0
|
||||||
|
#define SUN8I_ADDA_MICIN_GCTRL 0x06
|
||||||
|
#define SUN8I_ADDA_MICIN_GCTRL_MIC1G 4
|
||||||
|
#define SUN8I_ADDA_MICIN_GCTRL_MIC2G 0
|
||||||
|
#define SUN8I_ADDA_PAEN_HP_CTRL 0x07
|
||||||
|
#define SUN8I_ADDA_PAEN_HP_CTRL_HPPAEN 7
|
||||||
|
#define SUN8I_ADDA_PAEN_HP_CTRL_LINEOUTEN 7 /* H3 specific */
|
||||||
|
#define SUN8I_ADDA_PAEN_HP_CTRL_HPCOM_FC 5
|
||||||
|
#define SUN8I_ADDA_PAEN_HP_CTRL_COMPTEN 4
|
||||||
|
#define SUN8I_ADDA_PAEN_HP_CTRL_PA_ANTI_POP_CTRL 2
|
||||||
|
#define SUN8I_ADDA_PAEN_HP_CTRL_LTRNMUTE 1
|
||||||
|
#define SUN8I_ADDA_PAEN_HP_CTRL_RTLNMUTE 0
|
||||||
|
#define SUN8I_ADDA_PHONEOUT_CTRL 0x08
|
||||||
|
#define SUN8I_ADDA_PHONEOUT_CTRL_PHONEOUTG 5
|
||||||
|
#define SUN8I_ADDA_PHONEOUT_CTRL_PHONEOUTEN 4
|
||||||
|
#define SUN8I_ADDA_PHONEOUT_CTRL_PHONEOUT_MIC1 3
|
||||||
|
#define SUN8I_ADDA_PHONEOUT_CTRL_PHONEOUT_MIC2 2
|
||||||
|
#define SUN8I_ADDA_PHONEOUT_CTRL_PHONEOUT_RMIX 1
|
||||||
|
#define SUN8I_ADDA_PHONEOUT_CTRL_PHONEOUT_LMIX 0
|
||||||
|
#define SUN8I_ADDA_PHONE_GAIN_CTRL 0x09
|
||||||
|
#define SUN8I_ADDA_PHONE_GAIN_CTRL_LINEOUT_VOL 3
|
||||||
|
#define SUN8I_ADDA_PHONE_GAIN_CTRL_PHONEPREG 0
|
||||||
|
#define SUN8I_ADDA_MIC2G_CTRL 0x0a
|
||||||
|
#define SUN8I_ADDA_MIC2G_CTRL_MIC2AMPEN 7
|
||||||
|
#define SUN8I_ADDA_MIC2G_CTRL_MIC2BOOST 4
|
||||||
|
#define SUN8I_ADDA_MIC2G_CTRL_LINEOUTLEN 3
|
||||||
|
#define SUN8I_ADDA_MIC2G_CTRL_LINEOUTREN 2
|
||||||
|
#define SUN8I_ADDA_MIC2G_CTRL_LINEOUTLSRC 1
|
||||||
|
#define SUN8I_ADDA_MIC2G_CTRL_LINEOUTRSRC 0
|
||||||
|
#define SUN8I_ADDA_MIC1G_MICBIAS_CTRL 0x0b
|
||||||
|
#define SUN8I_ADDA_MIC1G_MICBIAS_CTRL_HMICBIASEN 7
|
||||||
|
#define SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MMICBIASEN 6
|
||||||
|
#define SUN8I_ADDA_MIC1G_MICBIAS_CTRL_HMICBIAS_MODE 5
|
||||||
|
#define SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MIC1AMPEN 3
|
||||||
|
#define SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MIC1BOOST 0
|
||||||
|
#define SUN8I_ADDA_LADCMIXSC 0x0c
|
||||||
|
#define SUN8I_ADDA_LADCMIXSC_MIC1 6
|
||||||
|
#define SUN8I_ADDA_LADCMIXSC_MIC2 5
|
||||||
|
#define SUN8I_ADDA_LADCMIXSC_PHONE 4
|
||||||
|
#define SUN8I_ADDA_LADCMIXSC_PHONEN 3
|
||||||
|
#define SUN8I_ADDA_LADCMIXSC_LINEINL 2
|
||||||
|
#define SUN8I_ADDA_LADCMIXSC_OMIXRL 1
|
||||||
|
#define SUN8I_ADDA_LADCMIXSC_OMIXRR 0
|
||||||
|
#define SUN8I_ADDA_RADCMIXSC 0x0d
|
||||||
|
#define SUN8I_ADDA_RADCMIXSC_MIC1 6
|
||||||
|
#define SUN8I_ADDA_RADCMIXSC_MIC2 5
|
||||||
|
#define SUN8I_ADDA_RADCMIXSC_PHONE 4
|
||||||
|
#define SUN8I_ADDA_RADCMIXSC_PHONEP 3
|
||||||
|
#define SUN8I_ADDA_RADCMIXSC_LINEINR 2
|
||||||
|
#define SUN8I_ADDA_RADCMIXSC_OMIXR 1
|
||||||
|
#define SUN8I_ADDA_RADCMIXSC_OMIXL 0
|
||||||
|
#define SUN8I_ADDA_RES 0x0e
|
||||||
|
#define SUN8I_ADDA_RES_MMICBIAS_SEL 4
|
||||||
|
#define SUN8I_ADDA_RES_PA_ANTI_POP_CTRL 0
|
||||||
|
#define SUN8I_ADDA_ADC_AP_EN 0x0f
|
||||||
|
#define SUN8I_ADDA_ADC_AP_EN_ADCREN 7
|
||||||
|
#define SUN8I_ADDA_ADC_AP_EN_ADCLEN 6
|
||||||
|
#define SUN8I_ADDA_ADC_AP_EN_ADCG 0
|
||||||
|
|
||||||
|
/* Analog control register access bits */
|
||||||
|
#define ADDA_PR 0x0 /* PRCM base + 0x1c0 */
|
||||||
|
#define ADDA_PR_RESET BIT(28)
|
||||||
|
#define ADDA_PR_WRITE BIT(24)
|
||||||
|
#define ADDA_PR_ADDR_SHIFT 16
|
||||||
|
#define ADDA_PR_ADDR_MASK GENMASK(4, 0)
|
||||||
|
#define ADDA_PR_DATA_IN_SHIFT 8
|
||||||
|
#define ADDA_PR_DATA_IN_MASK GENMASK(7, 0)
|
||||||
|
#define ADDA_PR_DATA_OUT_SHIFT 0
|
||||||
|
#define ADDA_PR_DATA_OUT_MASK GENMASK(7, 0)
|
||||||
|
|
||||||
|
/* regmap access bits */
|
||||||
|
static int adda_reg_read(void *context, unsigned int reg, unsigned int *val)
|
||||||
|
{
|
||||||
|
void __iomem *base = (void __iomem *)context;
|
||||||
|
u32 tmp;
|
||||||
|
|
||||||
|
/* De-assert reset */
|
||||||
|
writel(readl(base) | ADDA_PR_RESET, base);
|
||||||
|
|
||||||
|
/* Clear write bit */
|
||||||
|
writel(readl(base) & ~ADDA_PR_WRITE, base);
|
||||||
|
|
||||||
|
/* Set register address */
|
||||||
|
tmp = readl(base);
|
||||||
|
tmp &= ~(ADDA_PR_ADDR_MASK << ADDA_PR_ADDR_SHIFT);
|
||||||
|
tmp |= (reg & ADDA_PR_ADDR_MASK) << ADDA_PR_ADDR_SHIFT;
|
||||||
|
writel(tmp, base);
|
||||||
|
|
||||||
|
/* Read back value */
|
||||||
|
*val = readl(base) & ADDA_PR_DATA_OUT_MASK;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int adda_reg_write(void *context, unsigned int reg, unsigned int val)
|
||||||
|
{
|
||||||
|
void __iomem *base = (void __iomem *)context;
|
||||||
|
u32 tmp;
|
||||||
|
|
||||||
|
/* De-assert reset */
|
||||||
|
writel(readl(base) | ADDA_PR_RESET, base);
|
||||||
|
|
||||||
|
/* Set register address */
|
||||||
|
tmp = readl(base);
|
||||||
|
tmp &= ~(ADDA_PR_ADDR_MASK << ADDA_PR_ADDR_SHIFT);
|
||||||
|
tmp |= (reg & ADDA_PR_ADDR_MASK) << ADDA_PR_ADDR_SHIFT;
|
||||||
|
writel(tmp, base);
|
||||||
|
|
||||||
|
/* Set data to write */
|
||||||
|
tmp = readl(base);
|
||||||
|
tmp &= ~(ADDA_PR_DATA_IN_MASK << ADDA_PR_DATA_IN_SHIFT);
|
||||||
|
tmp |= (val & ADDA_PR_DATA_IN_MASK) << ADDA_PR_DATA_IN_SHIFT;
|
||||||
|
writel(tmp, base);
|
||||||
|
|
||||||
|
/* Set write bit to signal a write */
|
||||||
|
writel(readl(base) | ADDA_PR_WRITE, base);
|
||||||
|
|
||||||
|
/* Clear write bit */
|
||||||
|
writel(readl(base) & ~ADDA_PR_WRITE, base);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct regmap_config adda_pr_regmap_cfg = {
|
||||||
|
.name = "adda-pr",
|
||||||
|
.reg_bits = 5,
|
||||||
|
.reg_stride = 1,
|
||||||
|
.val_bits = 8,
|
||||||
|
.reg_read = adda_reg_read,
|
||||||
|
.reg_write = adda_reg_write,
|
||||||
|
.fast_io = true,
|
||||||
|
.max_register = 24,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* mixer controls */
|
||||||
|
static const struct snd_kcontrol_new sun8i_codec_mixer_controls[] = {
|
||||||
|
SOC_DAPM_DOUBLE_R("DAC Playback Switch",
|
||||||
|
SUN8I_ADDA_LOMIXSC,
|
||||||
|
SUN8I_ADDA_ROMIXSC,
|
||||||
|
SUN8I_ADDA_LOMIXSC_DACL, 1, 0),
|
||||||
|
SOC_DAPM_DOUBLE_R("DAC Reversed Playback Switch",
|
||||||
|
SUN8I_ADDA_LOMIXSC,
|
||||||
|
SUN8I_ADDA_ROMIXSC,
|
||||||
|
SUN8I_ADDA_LOMIXSC_DACR, 1, 0),
|
||||||
|
SOC_DAPM_DOUBLE_R("Line In Playback Switch",
|
||||||
|
SUN8I_ADDA_LOMIXSC,
|
||||||
|
SUN8I_ADDA_ROMIXSC,
|
||||||
|
SUN8I_ADDA_LOMIXSC_LINEINL, 1, 0),
|
||||||
|
SOC_DAPM_DOUBLE_R("Mic1 Playback Switch",
|
||||||
|
SUN8I_ADDA_LOMIXSC,
|
||||||
|
SUN8I_ADDA_ROMIXSC,
|
||||||
|
SUN8I_ADDA_LOMIXSC_MIC1, 1, 0),
|
||||||
|
SOC_DAPM_DOUBLE_R("Mic2 Playback Switch",
|
||||||
|
SUN8I_ADDA_LOMIXSC,
|
||||||
|
SUN8I_ADDA_ROMIXSC,
|
||||||
|
SUN8I_ADDA_LOMIXSC_MIC2, 1, 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ADC mixer controls */
|
||||||
|
static const struct snd_kcontrol_new sun8i_codec_adc_mixer_controls[] = {
|
||||||
|
SOC_DAPM_DOUBLE_R("Mixer Capture Switch",
|
||||||
|
SUN8I_ADDA_LADCMIXSC,
|
||||||
|
SUN8I_ADDA_RADCMIXSC,
|
||||||
|
SUN8I_ADDA_LADCMIXSC_OMIXRL, 1, 0),
|
||||||
|
SOC_DAPM_DOUBLE_R("Mixer Reversed Capture Switch",
|
||||||
|
SUN8I_ADDA_LADCMIXSC,
|
||||||
|
SUN8I_ADDA_RADCMIXSC,
|
||||||
|
SUN8I_ADDA_LADCMIXSC_OMIXRR, 1, 0),
|
||||||
|
SOC_DAPM_DOUBLE_R("Line In Capture Switch",
|
||||||
|
SUN8I_ADDA_LADCMIXSC,
|
||||||
|
SUN8I_ADDA_RADCMIXSC,
|
||||||
|
SUN8I_ADDA_LADCMIXSC_LINEINL, 1, 0),
|
||||||
|
SOC_DAPM_DOUBLE_R("Mic1 Capture Switch",
|
||||||
|
SUN8I_ADDA_LADCMIXSC,
|
||||||
|
SUN8I_ADDA_RADCMIXSC,
|
||||||
|
SUN8I_ADDA_LADCMIXSC_MIC1, 1, 0),
|
||||||
|
SOC_DAPM_DOUBLE_R("Mic2 Capture Switch",
|
||||||
|
SUN8I_ADDA_LADCMIXSC,
|
||||||
|
SUN8I_ADDA_RADCMIXSC,
|
||||||
|
SUN8I_ADDA_LADCMIXSC_MIC2, 1, 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
/* volume / mute controls */
|
||||||
|
static const DECLARE_TLV_DB_SCALE(sun8i_codec_out_mixer_pregain_scale,
|
||||||
|
-450, 150, 0);
|
||||||
|
static const DECLARE_TLV_DB_RANGE(sun8i_codec_mic_gain_scale,
|
||||||
|
0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
|
||||||
|
1, 7, TLV_DB_SCALE_ITEM(2400, 300, 0),
|
||||||
|
);
|
||||||
|
|
||||||
|
static const struct snd_kcontrol_new sun8i_codec_common_controls[] = {
|
||||||
|
/* Mixer pre-gains */
|
||||||
|
SOC_SINGLE_TLV("Line In Playback Volume", SUN8I_ADDA_LINEIN_GCTRL,
|
||||||
|
SUN8I_ADDA_LINEIN_GCTRL_LINEING,
|
||||||
|
0x7, 0, sun8i_codec_out_mixer_pregain_scale),
|
||||||
|
SOC_SINGLE_TLV("Mic1 Playback Volume", SUN8I_ADDA_MICIN_GCTRL,
|
||||||
|
SUN8I_ADDA_MICIN_GCTRL_MIC1G,
|
||||||
|
0x7, 0, sun8i_codec_out_mixer_pregain_scale),
|
||||||
|
SOC_SINGLE_TLV("Mic2 Playback Volume",
|
||||||
|
SUN8I_ADDA_MICIN_GCTRL, SUN8I_ADDA_MICIN_GCTRL_MIC2G,
|
||||||
|
0x7, 0, sun8i_codec_out_mixer_pregain_scale),
|
||||||
|
|
||||||
|
/* Microphone Amp boost gains */
|
||||||
|
SOC_SINGLE_TLV("Mic1 Boost Volume", SUN8I_ADDA_MIC1G_MICBIAS_CTRL,
|
||||||
|
SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MIC1BOOST, 0x7, 0,
|
||||||
|
sun8i_codec_mic_gain_scale),
|
||||||
|
SOC_SINGLE_TLV("Mic2 Boost Volume", SUN8I_ADDA_MIC2G_CTRL,
|
||||||
|
SUN8I_ADDA_MIC2G_CTRL_MIC2BOOST, 0x7, 0,
|
||||||
|
sun8i_codec_mic_gain_scale),
|
||||||
|
|
||||||
|
/* ADC */
|
||||||
|
SOC_SINGLE_TLV("ADC Gain Capture Volume", SUN8I_ADDA_ADC_AP_EN,
|
||||||
|
SUN8I_ADDA_ADC_AP_EN_ADCG, 0x7, 0,
|
||||||
|
sun8i_codec_out_mixer_pregain_scale),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct snd_soc_dapm_widget sun8i_codec_common_widgets[] = {
|
||||||
|
/* ADC */
|
||||||
|
SND_SOC_DAPM_ADC("Left ADC", NULL, SUN8I_ADDA_ADC_AP_EN,
|
||||||
|
SUN8I_ADDA_ADC_AP_EN_ADCLEN, 0),
|
||||||
|
SND_SOC_DAPM_ADC("Right ADC", NULL, SUN8I_ADDA_ADC_AP_EN,
|
||||||
|
SUN8I_ADDA_ADC_AP_EN_ADCREN, 0),
|
||||||
|
|
||||||
|
/* DAC */
|
||||||
|
SND_SOC_DAPM_DAC("Left DAC", NULL, SUN8I_ADDA_DAC_PA_SRC,
|
||||||
|
SUN8I_ADDA_DAC_PA_SRC_DACALEN, 0),
|
||||||
|
SND_SOC_DAPM_DAC("Right DAC", NULL, SUN8I_ADDA_DAC_PA_SRC,
|
||||||
|
SUN8I_ADDA_DAC_PA_SRC_DACAREN, 0),
|
||||||
|
/*
|
||||||
|
* Due to this component and the codec belonging to separate DAPM
|
||||||
|
* contexts, we need to manually link the above widgets to their
|
||||||
|
* stream widgets at the card level.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Line In */
|
||||||
|
SND_SOC_DAPM_INPUT("LINEIN"),
|
||||||
|
|
||||||
|
/* Microphone inputs */
|
||||||
|
SND_SOC_DAPM_INPUT("MIC1"),
|
||||||
|
SND_SOC_DAPM_INPUT("MIC2"),
|
||||||
|
|
||||||
|
/* Microphone Bias */
|
||||||
|
SND_SOC_DAPM_SUPPLY("MBIAS", SUN8I_ADDA_MIC1G_MICBIAS_CTRL,
|
||||||
|
SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MMICBIASEN,
|
||||||
|
0, NULL, 0),
|
||||||
|
|
||||||
|
/* Mic input path */
|
||||||
|
SND_SOC_DAPM_PGA("Mic1 Amplifier", SUN8I_ADDA_MIC1G_MICBIAS_CTRL,
|
||||||
|
SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MIC1AMPEN, 0, NULL, 0),
|
||||||
|
SND_SOC_DAPM_PGA("Mic2 Amplifier", SUN8I_ADDA_MIC2G_CTRL,
|
||||||
|
SUN8I_ADDA_MIC2G_CTRL_MIC2AMPEN, 0, NULL, 0),
|
||||||
|
|
||||||
|
/* Mixers */
|
||||||
|
SND_SOC_DAPM_MIXER("Left Mixer", SUN8I_ADDA_DAC_PA_SRC,
|
||||||
|
SUN8I_ADDA_DAC_PA_SRC_LMIXEN, 0,
|
||||||
|
sun8i_codec_mixer_controls,
|
||||||
|
ARRAY_SIZE(sun8i_codec_mixer_controls)),
|
||||||
|
SND_SOC_DAPM_MIXER("Right Mixer", SUN8I_ADDA_DAC_PA_SRC,
|
||||||
|
SUN8I_ADDA_DAC_PA_SRC_RMIXEN, 0,
|
||||||
|
sun8i_codec_mixer_controls,
|
||||||
|
ARRAY_SIZE(sun8i_codec_mixer_controls)),
|
||||||
|
SND_SOC_DAPM_MIXER("Left ADC Mixer", SUN8I_ADDA_ADC_AP_EN,
|
||||||
|
SUN8I_ADDA_ADC_AP_EN_ADCLEN, 0,
|
||||||
|
sun8i_codec_adc_mixer_controls,
|
||||||
|
ARRAY_SIZE(sun8i_codec_adc_mixer_controls)),
|
||||||
|
SND_SOC_DAPM_MIXER("Right ADC Mixer", SUN8I_ADDA_ADC_AP_EN,
|
||||||
|
SUN8I_ADDA_ADC_AP_EN_ADCREN, 0,
|
||||||
|
sun8i_codec_adc_mixer_controls,
|
||||||
|
ARRAY_SIZE(sun8i_codec_adc_mixer_controls)),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct snd_soc_dapm_route sun8i_codec_common_routes[] = {
|
||||||
|
/* Microphone Routes */
|
||||||
|
{ "Mic1 Amplifier", NULL, "MIC1"},
|
||||||
|
{ "Mic2 Amplifier", NULL, "MIC2"},
|
||||||
|
|
||||||
|
/* Left Mixer Routes */
|
||||||
|
{ "Left Mixer", "DAC Playback Switch", "Left DAC" },
|
||||||
|
{ "Left Mixer", "DAC Reversed Playback Switch", "Right DAC" },
|
||||||
|
{ "Left Mixer", "Line In Playback Switch", "LINEIN" },
|
||||||
|
{ "Left Mixer", "Mic1 Playback Switch", "Mic1 Amplifier" },
|
||||||
|
{ "Left Mixer", "Mic2 Playback Switch", "Mic2 Amplifier" },
|
||||||
|
|
||||||
|
/* Right Mixer Routes */
|
||||||
|
{ "Right Mixer", "DAC Playback Switch", "Right DAC" },
|
||||||
|
{ "Right Mixer", "DAC Reversed Playback Switch", "Left DAC" },
|
||||||
|
{ "Right Mixer", "Line In Playback Switch", "LINEIN" },
|
||||||
|
{ "Right Mixer", "Mic1 Playback Switch", "Mic1 Amplifier" },
|
||||||
|
{ "Right Mixer", "Mic2 Playback Switch", "Mic2 Amplifier" },
|
||||||
|
|
||||||
|
/* Left ADC Mixer Routes */
|
||||||
|
{ "Left ADC Mixer", "Mixer Capture Switch", "Left Mixer" },
|
||||||
|
{ "Left ADC Mixer", "Mixer Reversed Capture Switch", "Right Mixer" },
|
||||||
|
{ "Left ADC Mixer", "Line In Capture Switch", "LINEIN" },
|
||||||
|
{ "Left ADC Mixer", "Mic1 Capture Switch", "Mic1 Amplifier" },
|
||||||
|
{ "Left ADC Mixer", "Mic2 Capture Switch", "Mic2 Amplifier" },
|
||||||
|
|
||||||
|
/* Right ADC Mixer Routes */
|
||||||
|
{ "Right ADC Mixer", "Mixer Capture Switch", "Right Mixer" },
|
||||||
|
{ "Right ADC Mixer", "Mixer Reversed Capture Switch", "Left Mixer" },
|
||||||
|
{ "Right ADC Mixer", "Line In Capture Switch", "LINEIN" },
|
||||||
|
{ "Right ADC Mixer", "Mic1 Capture Switch", "Mic1 Amplifier" },
|
||||||
|
{ "Right ADC Mixer", "Mic2 Capture Switch", "Mic2 Amplifier" },
|
||||||
|
|
||||||
|
/* ADC Routes */
|
||||||
|
{ "Left ADC", NULL, "Left ADC Mixer" },
|
||||||
|
{ "Right ADC", NULL, "Right ADC Mixer" },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* headphone specific controls, widgets, and routes */
|
||||||
|
static const DECLARE_TLV_DB_SCALE(sun8i_codec_hp_vol_scale, -6300, 100, 1);
|
||||||
|
static const struct snd_kcontrol_new sun8i_codec_headphone_controls[] = {
|
||||||
|
SOC_SINGLE_TLV("Headphone Playback Volume",
|
||||||
|
SUN8I_ADDA_HP_VOLC,
|
||||||
|
SUN8I_ADDA_HP_VOLC_HP_VOL, 0x3f, 0,
|
||||||
|
sun8i_codec_hp_vol_scale),
|
||||||
|
SOC_DOUBLE("Headphone Playback Switch",
|
||||||
|
SUN8I_ADDA_DAC_PA_SRC,
|
||||||
|
SUN8I_ADDA_DAC_PA_SRC_LHPPAMUTE,
|
||||||
|
SUN8I_ADDA_DAC_PA_SRC_RHPPAMUTE, 1, 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char * const sun8i_codec_hp_src_enum_text[] = {
|
||||||
|
"DAC", "Mixer",
|
||||||
|
};
|
||||||
|
|
||||||
|
static SOC_ENUM_DOUBLE_DECL(sun8i_codec_hp_src_enum,
|
||||||
|
SUN8I_ADDA_DAC_PA_SRC,
|
||||||
|
SUN8I_ADDA_DAC_PA_SRC_LHPIS,
|
||||||
|
SUN8I_ADDA_DAC_PA_SRC_RHPIS,
|
||||||
|
sun8i_codec_hp_src_enum_text);
|
||||||
|
|
||||||
|
static const struct snd_kcontrol_new sun8i_codec_hp_src[] = {
|
||||||
|
SOC_DAPM_ENUM("Headphone Source Playback Route",
|
||||||
|
sun8i_codec_hp_src_enum),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct snd_soc_dapm_widget sun8i_codec_headphone_widgets[] = {
|
||||||
|
SND_SOC_DAPM_MUX("Headphone Source Playback Route",
|
||||||
|
SND_SOC_NOPM, 0, 0, sun8i_codec_hp_src),
|
||||||
|
SND_SOC_DAPM_OUT_DRV("Headphone Amp", SUN8I_ADDA_PAEN_HP_CTRL,
|
||||||
|
SUN8I_ADDA_PAEN_HP_CTRL_HPPAEN, 0, NULL, 0),
|
||||||
|
SND_SOC_DAPM_SUPPLY("HPCOM Protection", SUN8I_ADDA_PAEN_HP_CTRL,
|
||||||
|
SUN8I_ADDA_PAEN_HP_CTRL_COMPTEN, 0, NULL, 0),
|
||||||
|
SND_SOC_DAPM_REG(snd_soc_dapm_supply, "HPCOM", SUN8I_ADDA_PAEN_HP_CTRL,
|
||||||
|
SUN8I_ADDA_PAEN_HP_CTRL_HPCOM_FC, 0x3, 0x3, 0),
|
||||||
|
SND_SOC_DAPM_OUTPUT("HP"),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct snd_soc_dapm_route sun8i_codec_headphone_routes[] = {
|
||||||
|
{ "Headphone Source Playback Route", "DAC", "Left DAC" },
|
||||||
|
{ "Headphone Source Playback Route", "DAC", "Right DAC" },
|
||||||
|
{ "Headphone Source Playback Route", "Mixer", "Left Mixer" },
|
||||||
|
{ "Headphone Source Playback Route", "Mixer", "Right Mixer" },
|
||||||
|
{ "Headphone Amp", NULL, "Headphone Source Playback Route" },
|
||||||
|
{ "HPCOM", NULL, "HPCOM Protection" },
|
||||||
|
{ "HP", NULL, "Headphone Amp" },
|
||||||
|
};
|
||||||
|
|
||||||
|
static int sun8i_codec_add_headphone(struct snd_soc_component *cmpnt)
|
||||||
|
{
|
||||||
|
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt);
|
||||||
|
struct device *dev = cmpnt->dev;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = snd_soc_add_component_controls(cmpnt,
|
||||||
|
sun8i_codec_headphone_controls,
|
||||||
|
ARRAY_SIZE(sun8i_codec_headphone_controls));
|
||||||
|
if (ret) {
|
||||||
|
dev_err(dev, "Failed to add Headphone controls: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = snd_soc_dapm_new_controls(dapm, sun8i_codec_headphone_widgets,
|
||||||
|
ARRAY_SIZE(sun8i_codec_headphone_widgets));
|
||||||
|
if (ret) {
|
||||||
|
dev_err(dev, "Failed to add Headphone DAPM widgets: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = snd_soc_dapm_add_routes(dapm, sun8i_codec_headphone_routes,
|
||||||
|
ARRAY_SIZE(sun8i_codec_headphone_routes));
|
||||||
|
if (ret) {
|
||||||
|
dev_err(dev, "Failed to add Headphone DAPM routes: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* hmic specific widget */
|
||||||
|
static const struct snd_soc_dapm_widget sun8i_codec_hmic_widgets[] = {
|
||||||
|
SND_SOC_DAPM_SUPPLY("HBIAS", SUN8I_ADDA_MIC1G_MICBIAS_CTRL,
|
||||||
|
SUN8I_ADDA_MIC1G_MICBIAS_CTRL_HMICBIASEN,
|
||||||
|
0, NULL, 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
static int sun8i_codec_add_hmic(struct snd_soc_component *cmpnt)
|
||||||
|
{
|
||||||
|
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt);
|
||||||
|
struct device *dev = cmpnt->dev;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = snd_soc_dapm_new_controls(dapm, sun8i_codec_hmic_widgets,
|
||||||
|
ARRAY_SIZE(sun8i_codec_hmic_widgets));
|
||||||
|
if (ret)
|
||||||
|
dev_err(dev, "Failed to add Mic3 DAPM widgets: %d\n", ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* line out specific controls, widgets and routes */
|
||||||
|
static const DECLARE_TLV_DB_RANGE(sun8i_codec_lineout_vol_scale,
|
||||||
|
0, 1, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
|
||||||
|
2, 31, TLV_DB_SCALE_ITEM(-4350, 150, 0),
|
||||||
|
);
|
||||||
|
static const struct snd_kcontrol_new sun8i_codec_lineout_controls[] = {
|
||||||
|
SOC_SINGLE_TLV("Line Out Playback Volume",
|
||||||
|
SUN8I_ADDA_PHONE_GAIN_CTRL,
|
||||||
|
SUN8I_ADDA_PHONE_GAIN_CTRL_LINEOUT_VOL, 0x1f, 0,
|
||||||
|
sun8i_codec_lineout_vol_scale),
|
||||||
|
SOC_DOUBLE("Line Out Playback Switch",
|
||||||
|
SUN8I_ADDA_MIC2G_CTRL,
|
||||||
|
SUN8I_ADDA_MIC2G_CTRL_LINEOUTLEN,
|
||||||
|
SUN8I_ADDA_MIC2G_CTRL_LINEOUTREN, 1, 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char * const sun8i_codec_lineout_src_enum_text[] = {
|
||||||
|
"Stereo", "Mono Differential",
|
||||||
|
};
|
||||||
|
|
||||||
|
static SOC_ENUM_DOUBLE_DECL(sun8i_codec_lineout_src_enum,
|
||||||
|
SUN8I_ADDA_MIC2G_CTRL,
|
||||||
|
SUN8I_ADDA_MIC2G_CTRL_LINEOUTLSRC,
|
||||||
|
SUN8I_ADDA_MIC2G_CTRL_LINEOUTRSRC,
|
||||||
|
sun8i_codec_lineout_src_enum_text);
|
||||||
|
|
||||||
|
static const struct snd_kcontrol_new sun8i_codec_lineout_src[] = {
|
||||||
|
SOC_DAPM_ENUM("Line Out Source Playback Route",
|
||||||
|
sun8i_codec_lineout_src_enum),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct snd_soc_dapm_widget sun8i_codec_lineout_widgets[] = {
|
||||||
|
SND_SOC_DAPM_MUX("Line Out Source Playback Route",
|
||||||
|
SND_SOC_NOPM, 0, 0, sun8i_codec_lineout_src),
|
||||||
|
/* It is unclear if this is a buffer or gate, model it as a supply */
|
||||||
|
SND_SOC_DAPM_SUPPLY("Line Out Enable", SUN8I_ADDA_PAEN_HP_CTRL,
|
||||||
|
SUN8I_ADDA_PAEN_HP_CTRL_LINEOUTEN, 0, NULL, 0),
|
||||||
|
SND_SOC_DAPM_OUTPUT("LINEOUT"),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct snd_soc_dapm_route sun8i_codec_lineout_routes[] = {
|
||||||
|
{ "Line Out Source Playback Route", "Stereo", "Left Mixer" },
|
||||||
|
{ "Line Out Source Playback Route", "Stereo", "Right Mixer" },
|
||||||
|
{ "Line Out Source Playback Route", "Mono Differential", "Left Mixer" },
|
||||||
|
{ "Line Out Source Playback Route", "Mono Differential", "Right Mixer" },
|
||||||
|
{ "LINEOUT", NULL, "Line Out Source Playback Route" },
|
||||||
|
{ "LINEOUT", NULL, "Line Out Enable", },
|
||||||
|
};
|
||||||
|
|
||||||
|
static int sun8i_codec_add_lineout(struct snd_soc_component *cmpnt)
|
||||||
|
{
|
||||||
|
struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt);
|
||||||
|
struct device *dev = cmpnt->dev;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = snd_soc_add_component_controls(cmpnt,
|
||||||
|
sun8i_codec_lineout_controls,
|
||||||
|
ARRAY_SIZE(sun8i_codec_lineout_controls));
|
||||||
|
if (ret) {
|
||||||
|
dev_err(dev, "Failed to add Line Out controls: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = snd_soc_dapm_new_controls(dapm, sun8i_codec_lineout_widgets,
|
||||||
|
ARRAY_SIZE(sun8i_codec_lineout_widgets));
|
||||||
|
if (ret) {
|
||||||
|
dev_err(dev, "Failed to add Line Out DAPM widgets: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = snd_soc_dapm_add_routes(dapm, sun8i_codec_lineout_routes,
|
||||||
|
ARRAY_SIZE(sun8i_codec_lineout_routes));
|
||||||
|
if (ret) {
|
||||||
|
dev_err(dev, "Failed to add Line Out DAPM routes: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sun8i_codec_analog_quirks {
|
||||||
|
bool has_headphone;
|
||||||
|
bool has_hmic;
|
||||||
|
bool has_lineout;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct sun8i_codec_analog_quirks sun8i_a23_quirks = {
|
||||||
|
.has_headphone = true,
|
||||||
|
.has_hmic = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct sun8i_codec_analog_quirks sun8i_h3_quirks = {
|
||||||
|
.has_lineout = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt)
|
||||||
|
{
|
||||||
|
struct device *dev = cmpnt->dev;
|
||||||
|
const struct sun8i_codec_analog_quirks *quirks;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This would never return NULL unless someone directly registers a
|
||||||
|
* platform device matching this driver's name, without specifying a
|
||||||
|
* device tree node.
|
||||||
|
*/
|
||||||
|
quirks = of_device_get_match_data(dev);
|
||||||
|
|
||||||
|
/* Add controls, widgets, and routes for individual features */
|
||||||
|
|
||||||
|
if (quirks->has_headphone) {
|
||||||
|
ret = sun8i_codec_add_headphone(cmpnt);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quirks->has_hmic) {
|
||||||
|
ret = sun8i_codec_add_hmic(cmpnt);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quirks->has_lineout) {
|
||||||
|
ret = sun8i_codec_add_lineout(cmpnt);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct snd_soc_component_driver sun8i_codec_analog_cmpnt_drv = {
|
||||||
|
.controls = sun8i_codec_common_controls,
|
||||||
|
.num_controls = ARRAY_SIZE(sun8i_codec_common_controls),
|
||||||
|
.dapm_widgets = sun8i_codec_common_widgets,
|
||||||
|
.num_dapm_widgets = ARRAY_SIZE(sun8i_codec_common_widgets),
|
||||||
|
.dapm_routes = sun8i_codec_common_routes,
|
||||||
|
.num_dapm_routes = ARRAY_SIZE(sun8i_codec_common_routes),
|
||||||
|
.probe = sun8i_codec_analog_cmpnt_probe,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct of_device_id sun8i_codec_analog_of_match[] = {
|
||||||
|
{
|
||||||
|
.compatible = "allwinner,sun8i-a23-codec-analog",
|
||||||
|
.data = &sun8i_a23_quirks,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.compatible = "allwinner,sun8i-h3-codec-analog",
|
||||||
|
.data = &sun8i_h3_quirks,
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(of, sun8i_codec_analog_of_match);
|
||||||
|
|
||||||
|
static int sun8i_codec_analog_probe(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
struct resource *res;
|
||||||
|
struct regmap *regmap;
|
||||||
|
void __iomem *base;
|
||||||
|
|
||||||
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
|
base = devm_ioremap_resource(&pdev->dev, res);
|
||||||
|
if (IS_ERR(base)) {
|
||||||
|
dev_err(&pdev->dev, "Failed to map the registers\n");
|
||||||
|
return PTR_ERR(base);
|
||||||
|
}
|
||||||
|
|
||||||
|
regmap = devm_regmap_init(&pdev->dev, NULL, base, &adda_pr_regmap_cfg);
|
||||||
|
if (IS_ERR(regmap)) {
|
||||||
|
dev_err(&pdev->dev, "Failed to create regmap\n");
|
||||||
|
return PTR_ERR(regmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
return devm_snd_soc_register_component(&pdev->dev,
|
||||||
|
&sun8i_codec_analog_cmpnt_drv,
|
||||||
|
NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct platform_driver sun8i_codec_analog_driver = {
|
||||||
|
.driver = {
|
||||||
|
.name = "sun8i-codec-analog",
|
||||||
|
.of_match_table = sun8i_codec_analog_of_match,
|
||||||
|
},
|
||||||
|
.probe = sun8i_codec_analog_probe,
|
||||||
|
};
|
||||||
|
module_platform_driver(sun8i_codec_analog_driver);
|
||||||
|
|
||||||
|
MODULE_DESCRIPTION("Allwinner internal codec analog controls driver");
|
||||||
|
MODULE_AUTHOR("Chen-Yu Tsai <wens@csie.org>");
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
|
MODULE_ALIAS("platform:sun8i-codec-analog");
|
|
@ -65,7 +65,7 @@ static int tegra_alc5632_asoc_hw_params(struct snd_pcm_substream *substream,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct snd_soc_ops tegra_alc5632_asoc_ops = {
|
static const struct snd_soc_ops tegra_alc5632_asoc_ops = {
|
||||||
.hw_params = tegra_alc5632_asoc_hw_params,
|
.hw_params = tegra_alc5632_asoc_hw_params,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ static int tegra_max98090_asoc_hw_params(struct snd_pcm_substream *substream,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct snd_soc_ops tegra_max98090_ops = {
|
static const struct snd_soc_ops tegra_max98090_ops = {
|
||||||
.hw_params = tegra_max98090_asoc_hw_params,
|
.hw_params = tegra_max98090_asoc_hw_params,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ static int tegra_rt5640_asoc_hw_params(struct snd_pcm_substream *substream,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct snd_soc_ops tegra_rt5640_ops = {
|
static const struct snd_soc_ops tegra_rt5640_ops = {
|
||||||
.hw_params = tegra_rt5640_asoc_hw_params,
|
.hw_params = tegra_rt5640_asoc_hw_params,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ static int tegra_rt5677_event_hp(struct snd_soc_dapm_widget *w,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct snd_soc_ops tegra_rt5677_ops = {
|
static const struct snd_soc_ops tegra_rt5677_ops = {
|
||||||
.hw_params = tegra_rt5677_asoc_hw_params,
|
.hw_params = tegra_rt5677_asoc_hw_params,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ static int tegra_sgtl5000_hw_params(struct snd_pcm_substream *substream,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct snd_soc_ops tegra_sgtl5000_ops = {
|
static const struct snd_soc_ops tegra_sgtl5000_ops = {
|
||||||
.hw_params = tegra_sgtl5000_hw_params,
|
.hw_params = tegra_sgtl5000_hw_params,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ static int tegra_wm8753_hw_params(struct snd_pcm_substream *substream,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct snd_soc_ops tegra_wm8753_ops = {
|
static const struct snd_soc_ops tegra_wm8753_ops = {
|
||||||
.hw_params = tegra_wm8753_hw_params,
|
.hw_params = tegra_wm8753_hw_params,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ static int tegra_wm8903_hw_params(struct snd_pcm_substream *substream,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct snd_soc_ops tegra_wm8903_ops = {
|
static const struct snd_soc_ops tegra_wm8903_ops = {
|
||||||
.hw_params = tegra_wm8903_hw_params,
|
.hw_params = tegra_wm8903_hw_params,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ static int trimslice_asoc_hw_params(struct snd_pcm_substream *substream,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct snd_soc_ops trimslice_asoc_ops = {
|
static const struct snd_soc_ops trimslice_asoc_ops = {
|
||||||
.hw_params = trimslice_asoc_hw_params,
|
.hw_params = trimslice_asoc_hw_params,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue