ASoC: meson: tdmout: add sm1 support

On the sm1, the TDMOUT number of input is extended and the
the gain enable bit moved to accommodate this extension

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20190905120120.31752-9-jbrunet@baylibre.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Jerome Brunet 2019-09-05 14:01:20 +02:00 committed by Mark Brown
parent 5ac825c3d8
commit 329299d665
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 84 additions and 19 deletions

View File

@ -24,6 +24,7 @@
#define TDMOUT_CTRL1 0x04
#define TDMOUT_CTRL1_TYPE_MASK GENMASK(6, 4)
#define TDMOUT_CTRL1_TYPE(x) ((x) << 4)
#define SM1_TDMOUT_CTRL1_GAIN_EN 7
#define TDMOUT_CTRL1_MSB_POS_MASK GENMASK(12, 8)
#define TDMOUT_CTRL1_MSB_POS(x) ((x) << 8)
#define TDMOUT_CTRL1_SEL_SHIFT 24
@ -51,25 +52,6 @@ static const struct regmap_config axg_tdmout_regmap_cfg = {
.max_register = TDMOUT_MASK_VAL,
};
static const struct snd_kcontrol_new axg_tdmout_controls[] = {
SOC_DOUBLE("Lane 0 Volume", TDMOUT_GAIN0, 0, 8, 255, 0),
SOC_DOUBLE("Lane 1 Volume", TDMOUT_GAIN0, 16, 24, 255, 0),
SOC_DOUBLE("Lane 2 Volume", TDMOUT_GAIN1, 0, 8, 255, 0),
SOC_DOUBLE("Lane 3 Volume", TDMOUT_GAIN1, 16, 24, 255, 0),
SOC_SINGLE("Gain Enable Switch", TDMOUT_CTRL1,
TDMOUT_CTRL1_GAIN_EN, 1, 0),
};
static const char * const tdmout_sel_texts[] = {
"IN 0", "IN 1", "IN 2",
};
static SOC_ENUM_SINGLE_DECL(axg_tdmout_sel_enum, TDMOUT_CTRL1,
TDMOUT_CTRL1_SEL_SHIFT, tdmout_sel_texts);
static const struct snd_kcontrol_new axg_tdmout_in_mux =
SOC_DAPM_ENUM("Input Source", axg_tdmout_sel_enum);
static struct snd_soc_dai *
axg_tdmout_get_be(struct snd_soc_dapm_widget *w)
{
@ -197,6 +179,25 @@ static int axg_tdmout_prepare(struct regmap *map,
return axg_tdm_formatter_set_channel_masks(map, ts, TDMOUT_MASK0);
}
static const struct snd_kcontrol_new axg_tdmout_controls[] = {
SOC_DOUBLE("Lane 0 Volume", TDMOUT_GAIN0, 0, 8, 255, 0),
SOC_DOUBLE("Lane 1 Volume", TDMOUT_GAIN0, 16, 24, 255, 0),
SOC_DOUBLE("Lane 2 Volume", TDMOUT_GAIN1, 0, 8, 255, 0),
SOC_DOUBLE("Lane 3 Volume", TDMOUT_GAIN1, 16, 24, 255, 0),
SOC_SINGLE("Gain Enable Switch", TDMOUT_CTRL1,
TDMOUT_CTRL1_GAIN_EN, 1, 0),
};
static const char * const axg_tdmout_sel_texts[] = {
"IN 0", "IN 1", "IN 2",
};
static SOC_ENUM_SINGLE_DECL(axg_tdmout_sel_enum, TDMOUT_CTRL1,
TDMOUT_CTRL1_SEL_SHIFT, axg_tdmout_sel_texts);
static const struct snd_kcontrol_new axg_tdmout_in_mux =
SOC_DAPM_ENUM("Input Source", axg_tdmout_sel_enum);
static const struct snd_soc_dapm_widget axg_tdmout_dapm_widgets[] = {
SND_SOC_DAPM_AIF_IN("IN 0", NULL, 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_IN("IN 1", NULL, 0, SND_SOC_NOPM, 0, 0),
@ -252,6 +253,67 @@ static const struct axg_tdm_formatter_driver g12a_tdmout_drv = {
},
};
static const struct snd_kcontrol_new sm1_tdmout_controls[] = {
SOC_DOUBLE("Lane 0 Volume", TDMOUT_GAIN0, 0, 8, 255, 0),
SOC_DOUBLE("Lane 1 Volume", TDMOUT_GAIN0, 16, 24, 255, 0),
SOC_DOUBLE("Lane 2 Volume", TDMOUT_GAIN1, 0, 8, 255, 0),
SOC_DOUBLE("Lane 3 Volume", TDMOUT_GAIN1, 16, 24, 255, 0),
SOC_SINGLE("Gain Enable Switch", TDMOUT_CTRL1,
SM1_TDMOUT_CTRL1_GAIN_EN, 1, 0),
};
static const char * const sm1_tdmout_sel_texts[] = {
"IN 0", "IN 1", "IN 2", "IN 3", "IN 4",
};
static SOC_ENUM_SINGLE_DECL(sm1_tdmout_sel_enum, TDMOUT_CTRL1,
TDMOUT_CTRL1_SEL_SHIFT, sm1_tdmout_sel_texts);
static const struct snd_kcontrol_new sm1_tdmout_in_mux =
SOC_DAPM_ENUM("Input Source", sm1_tdmout_sel_enum);
static const struct snd_soc_dapm_widget sm1_tdmout_dapm_widgets[] = {
SND_SOC_DAPM_AIF_IN("IN 0", NULL, 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_IN("IN 1", NULL, 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_IN("IN 2", NULL, 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_IN("IN 3", NULL, 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_IN("IN 4", NULL, 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_MUX("SRC SEL", SND_SOC_NOPM, 0, 0, &sm1_tdmout_in_mux),
SND_SOC_DAPM_PGA_E("ENC", SND_SOC_NOPM, 0, 0, NULL, 0,
axg_tdm_formatter_event,
(SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD)),
SND_SOC_DAPM_AIF_OUT("OUT", NULL, 0, SND_SOC_NOPM, 0, 0),
};
static const struct snd_soc_dapm_route sm1_tdmout_dapm_routes[] = {
{ "SRC SEL", "IN 0", "IN 0" },
{ "SRC SEL", "IN 1", "IN 1" },
{ "SRC SEL", "IN 2", "IN 2" },
{ "SRC SEL", "IN 3", "IN 3" },
{ "SRC SEL", "IN 4", "IN 4" },
{ "ENC", NULL, "SRC SEL" },
{ "OUT", NULL, "ENC" },
};
static const struct snd_soc_component_driver sm1_tdmout_component_drv = {
.controls = sm1_tdmout_controls,
.num_controls = ARRAY_SIZE(sm1_tdmout_controls),
.dapm_widgets = sm1_tdmout_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(sm1_tdmout_dapm_widgets),
.dapm_routes = sm1_tdmout_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(sm1_tdmout_dapm_routes),
};
static const struct axg_tdm_formatter_driver sm1_tdmout_drv = {
.component_drv = &sm1_tdmout_component_drv,
.regmap_cfg = &axg_tdmout_regmap_cfg,
.ops = &axg_tdmout_ops,
.quirks = &(const struct axg_tdm_formatter_hw) {
.invert_sclk = true,
.skew_offset = 2,
},
};
static const struct of_device_id axg_tdmout_of_match[] = {
{
.compatible = "amlogic,axg-tdmout",
@ -259,6 +321,9 @@ static const struct of_device_id axg_tdmout_of_match[] = {
}, {
.compatible = "amlogic,g12a-tdmout",
.data = &g12a_tdmout_drv,
}, {
.compatible = "amlogic,sm1-tdmout",
.data = &sm1_tdmout_drv,
}, {}
};
MODULE_DEVICE_TABLE(of, axg_tdmout_of_match);