[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220908161154.648557-9-nfraprado@collabora.com>
Date: Thu, 8 Sep 2022 12:11:52 -0400
From: Nícolas F. R. A. Prado
<nfraprado@...labora.com>
To: Mark Brown <broonie@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>
Cc: kernel@...labora.com,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>,
Nícolas F. R. A. Prado
<nfraprado@...labora.com>, Chunxu Li <chunxu.li@...iatek.com>,
Dan Carpenter <dan.carpenter@...cle.com>,
Jaroslav Kysela <perex@...ex.cz>,
Jiaxin Yu <jiaxin.yu@...iatek.com>,
Liam Girdwood <lgirdwood@...il.com>,
Takashi Iwai <tiwai@...e.com>, alsa-devel@...a-project.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-mediatek@...ts.infradead.org
Subject: [PATCH 08/10] ASoC: mediatek: mt8186: Allow setting shared clocks from machine driver
Add a new function to configure the shared clock between two i2s ports,
and export it. This will allow the clock sharing to be set from the
machine driver instead of the devicetree.
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@...labora.com>
---
sound/soc/mediatek/mt8186/mt8186-afe-common.h | 3 +++
sound/soc/mediatek/mt8186/mt8186-dai-i2s.c | 26 +++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/sound/soc/mediatek/mt8186/mt8186-afe-common.h b/sound/soc/mediatek/mt8186/mt8186-afe-common.h
index b8f03e1b7e49..d59258520995 100644
--- a/sound/soc/mediatek/mt8186/mt8186-afe-common.h
+++ b/sound/soc/mediatek/mt8186/mt8186-afe-common.h
@@ -189,6 +189,9 @@ unsigned int mt8186_rate_transform(struct device *dev,
unsigned int mt8186_tdm_relatch_rate_transform(struct device *dev,
unsigned int rate);
+int mt8186_dai_i2s_set_share(struct mtk_base_afe *afe, const char *main_i2s_name,
+ const char *secondary_i2s_name);
+
int mt8186_dai_set_priv(struct mtk_base_afe *afe, int id,
int priv_size, const void *priv_data);
diff --git a/sound/soc/mediatek/mt8186/mt8186-dai-i2s.c b/sound/soc/mediatek/mt8186/mt8186-dai-i2s.c
index e553a555d168..7e8cad682c83 100644
--- a/sound/soc/mediatek/mt8186/mt8186-dai-i2s.c
+++ b/sound/soc/mediatek/mt8186/mt8186-dai-i2s.c
@@ -1184,6 +1184,32 @@ static int mt8186_dai_i2s_get_share(struct mtk_base_afe *afe)
return 0;
}
+/**
+ * mt8186_dai_i2s_set_share() - Set up I2S ports to share a single clock.
+ * @afe: Pointer to &struct mtk_base_afe
+ * @main_i2s_name: The name of the I2S port that will provide the clock
+ * @secondary_i2s_name: The name of the I2S port that will use this clock
+ */
+int mt8186_dai_i2s_set_share(struct mtk_base_afe *afe, const char *main_i2s_name,
+ const char *secondary_i2s_name)
+{
+ struct mtk_afe_i2s_priv *secondary_i2s_priv;
+ int main_i2s_id;
+
+ secondary_i2s_priv = get_i2s_priv_by_name(afe, secondary_i2s_name);
+ if (!secondary_i2s_priv)
+ return -EINVAL;
+
+ main_i2s_id = get_i2s_id_by_name(afe, main_i2s_name);
+ if (main_i2s_id < 0)
+ return main_i2s_id;
+
+ secondary_i2s_priv->share_i2s_id = main_i2s_id;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(mt8186_dai_i2s_set_share);
+
static int mt8186_dai_i2s_set_priv(struct mtk_base_afe *afe)
{
int i;
--
2.37.3
Powered by blists - more mailing lists