Commit 0d3f01dc authored by Jerome Brunet's avatar Jerome Brunet Committed by Mark Brown

ASoC: meson: axg-tdm-formatters: fix sclk inversion

After carefully checking, it appears that both tdmout and tdmin require the
rising edge of the sclk they get to be synchronized with the frame sync
event (which should be a rising edge of lrclk).

TDMIN was improperly set before this patch. Remove the sclk_invert quirk
which is no longer needed and fix the sclk phase.

Fixes: 1a11d88f ("ASoC: meson: add tdm formatter base driver")
Signed-off-by: default avatarJerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20200729154456.1983396-4-jbrunet@baylibre.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 80a25439
...@@ -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 {
......
...@@ -228,7 +228,6 @@ static const struct axg_tdm_formatter_driver axg_tdmin_drv = { ...@@ -228,7 +228,6 @@ 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,
}, },
}; };
...@@ -238,7 +237,6 @@ static const struct axg_tdm_formatter_driver g12a_tdmin_drv = { ...@@ -238,7 +237,6 @@ static const struct axg_tdm_formatter_driver g12a_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 = 3, .skew_offset = 3,
}, },
}; };
......
...@@ -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