Commit 20196e0e authored by Mark Brown's avatar Mark Brown

Merge series "ASoC: meson: tdm fixes" from Jerome Brunet <jbrunet@baylibre.com>:

This patcheset is collection of fixes for the TDM input and output the
axg audio architecture. Its fixes:
 - slave mode format setting
 - g12 and sm1 skew offset
 - tdm clock inversion
 - standard daifmt props names which don't require a specific prefix

Jerome Brunet (4):
  ASoC: meson: axg-tdm-interface: fix link fmt setup
  ASoC: meson: axg-tdmin: fix g12a skew
  ASoC: meson: axg-tdm-formatters: fix sclk inversion
  ASoC: meson: cards: remove DT_PREFIX for standard daifmt properties

 sound/soc/meson/axg-tdm-formatter.c | 11 ++++++-----
 sound/soc/meson/axg-tdm-formatter.h |  1 -
 sound/soc/meson/axg-tdm-interface.c | 26 +++++++++++++++++---------
 sound/soc/meson/axg-tdmin.c         | 16 +++++++++++++++-
 sound/soc/meson/axg-tdmout.c        |  3 ---
 sound/soc/meson/meson-card-utils.c  |  2 +-
 6 files changed, 39 insertions(+), 20 deletions(-)

--
2.25.4
parents 5c74c9d3 0d3f01dc
...@@ -70,7 +70,7 @@ EXPORT_SYMBOL_GPL(axg_tdm_formatter_set_channel_masks); ...@@ -70,7 +70,7 @@ EXPORT_SYMBOL_GPL(axg_tdm_formatter_set_channel_masks);
static int axg_tdm_formatter_enable(struct axg_tdm_formatter *formatter) static int axg_tdm_formatter_enable(struct axg_tdm_formatter *formatter)
{ {
struct axg_tdm_stream *ts = formatter->stream; struct axg_tdm_stream *ts = formatter->stream;
bool invert = formatter->drv->quirks->invert_sclk; bool invert;
int ret; int ret;
/* Do nothing if the formatter is already enabled */ /* Do nothing if the formatter is already enabled */
...@@ -96,11 +96,12 @@ static int axg_tdm_formatter_enable(struct axg_tdm_formatter *formatter) ...@@ -96,11 +96,12 @@ static int axg_tdm_formatter_enable(struct axg_tdm_formatter *formatter)
return ret; return ret;
/* /*
* If sclk is inverted, invert it back and provide the inversion * If sclk is inverted, it means the bit should latched on the
* required by the formatter * rising edge which is what our HW expects. If not, we need to
* invert it before the formatter.
*/ */
invert ^= axg_tdm_sclk_invert(ts->iface->fmt); invert = axg_tdm_sclk_invert(ts->iface->fmt);
ret = clk_set_phase(formatter->sclk, invert ? 180 : 0); ret = clk_set_phase(formatter->sclk, invert ? 0 : 180);
if (ret) if (ret)
return ret; return ret;
......
...@@ -16,7 +16,6 @@ struct snd_kcontrol; ...@@ -16,7 +16,6 @@ struct snd_kcontrol;
struct axg_tdm_formatter_hw { struct axg_tdm_formatter_hw {
unsigned int skew_offset; unsigned int skew_offset;
bool invert_sclk;
}; };
struct axg_tdm_formatter_ops { struct axg_tdm_formatter_ops {
......
...@@ -119,17 +119,24 @@ static int axg_tdm_iface_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -119,17 +119,24 @@ static int axg_tdm_iface_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai); struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai);
/* These modes are not supported */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
if (fmt & (SND_SOC_DAIFMT_CBS_CFM | SND_SOC_DAIFMT_CBM_CFS)) { case SND_SOC_DAIFMT_CBS_CFS:
dev_err(dai->dev, "only CBS_CFS and CBM_CFM are supported\n"); if (!iface->mclk) {
return -EINVAL;
}
/* If the TDM interface is the clock master, it requires mclk */
if (!iface->mclk && (fmt & SND_SOC_DAIFMT_CBS_CFS)) {
dev_err(dai->dev, "cpu clock master: mclk missing\n"); dev_err(dai->dev, "cpu clock master: mclk missing\n");
return -ENODEV; return -ENODEV;
} }
break;
case SND_SOC_DAIFMT_CBM_CFM:
break;
case SND_SOC_DAIFMT_CBS_CFM:
case SND_SOC_DAIFMT_CBM_CFS:
dev_err(dai->dev, "only CBS_CFS and CBM_CFM are supported\n");
/* Fall-through */
default:
return -EINVAL;
}
iface->fmt = fmt; iface->fmt = fmt;
return 0; return 0;
...@@ -319,7 +326,8 @@ static int axg_tdm_iface_hw_params(struct snd_pcm_substream *substream, ...@@ -319,7 +326,8 @@ static int axg_tdm_iface_hw_params(struct snd_pcm_substream *substream,
if (ret) if (ret)
return ret; return ret;
if (iface->fmt & SND_SOC_DAIFMT_CBS_CFS) { if ((iface->fmt & SND_SOC_DAIFMT_MASTER_MASK) ==
SND_SOC_DAIFMT_CBS_CFS) {
ret = axg_tdm_iface_set_sclk(dai, params); ret = axg_tdm_iface_set_sclk(dai, params);
if (ret) if (ret)
return ret; return ret;
......
...@@ -228,15 +228,29 @@ static const struct axg_tdm_formatter_driver axg_tdmin_drv = { ...@@ -228,15 +228,29 @@ static const struct axg_tdm_formatter_driver axg_tdmin_drv = {
.regmap_cfg = &axg_tdmin_regmap_cfg, .regmap_cfg = &axg_tdmin_regmap_cfg,
.ops = &axg_tdmin_ops, .ops = &axg_tdmin_ops,
.quirks = &(const struct axg_tdm_formatter_hw) { .quirks = &(const struct axg_tdm_formatter_hw) {
.invert_sclk = false,
.skew_offset = 2, .skew_offset = 2,
}, },
}; };
static const struct axg_tdm_formatter_driver g12a_tdmin_drv = {
.component_drv = &axg_tdmin_component_drv,
.regmap_cfg = &axg_tdmin_regmap_cfg,
.ops = &axg_tdmin_ops,
.quirks = &(const struct axg_tdm_formatter_hw) {
.skew_offset = 3,
},
};
static const struct of_device_id axg_tdmin_of_match[] = { static const struct of_device_id axg_tdmin_of_match[] = {
{ {
.compatible = "amlogic,axg-tdmin", .compatible = "amlogic,axg-tdmin",
.data = &axg_tdmin_drv, .data = &axg_tdmin_drv,
}, {
.compatible = "amlogic,g12a-tdmin",
.data = &g12a_tdmin_drv,
}, {
.compatible = "amlogic,sm1-tdmin",
.data = &g12a_tdmin_drv,
}, {} }, {}
}; };
MODULE_DEVICE_TABLE(of, axg_tdmin_of_match); MODULE_DEVICE_TABLE(of, axg_tdmin_of_match);
......
...@@ -238,7 +238,6 @@ static const struct axg_tdm_formatter_driver axg_tdmout_drv = { ...@@ -238,7 +238,6 @@ static const struct axg_tdm_formatter_driver axg_tdmout_drv = {
.regmap_cfg = &axg_tdmout_regmap_cfg, .regmap_cfg = &axg_tdmout_regmap_cfg,
.ops = &axg_tdmout_ops, .ops = &axg_tdmout_ops,
.quirks = &(const struct axg_tdm_formatter_hw) { .quirks = &(const struct axg_tdm_formatter_hw) {
.invert_sclk = true,
.skew_offset = 1, .skew_offset = 1,
}, },
}; };
...@@ -248,7 +247,6 @@ static const struct axg_tdm_formatter_driver g12a_tdmout_drv = { ...@@ -248,7 +247,6 @@ static const struct axg_tdm_formatter_driver g12a_tdmout_drv = {
.regmap_cfg = &axg_tdmout_regmap_cfg, .regmap_cfg = &axg_tdmout_regmap_cfg,
.ops = &axg_tdmout_ops, .ops = &axg_tdmout_ops,
.quirks = &(const struct axg_tdm_formatter_hw) { .quirks = &(const struct axg_tdm_formatter_hw) {
.invert_sclk = true,
.skew_offset = 2, .skew_offset = 2,
}, },
}; };
...@@ -309,7 +307,6 @@ static const struct axg_tdm_formatter_driver sm1_tdmout_drv = { ...@@ -309,7 +307,6 @@ static const struct axg_tdm_formatter_driver sm1_tdmout_drv = {
.regmap_cfg = &axg_tdmout_regmap_cfg, .regmap_cfg = &axg_tdmout_regmap_cfg,
.ops = &axg_tdmout_ops, .ops = &axg_tdmout_ops,
.quirks = &(const struct axg_tdm_formatter_hw) { .quirks = &(const struct axg_tdm_formatter_hw) {
.invert_sclk = true,
.skew_offset = 2, .skew_offset = 2,
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment