From: Adam Skladowski <a39.skl@gmail.com>
Cc: phone-devel@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht,
Adam Skladowski <a39.skl@gmail.com>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
Banajit Goswami <bgoswami@quicinc.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org,
linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Vladimir Lypak <vladimir.lypak@gmail.com>
Subject: [PATCH 4/4] ASoC: qcom: apq8016_sbc: Add support for msm8953/msm8976 SoC
Date: Mon, 22 Jul 2024 11:51:08 +0200 [thread overview]
Message-ID: <20240722095147.3372-5-a39.skl@gmail.com> (raw)
In-Reply-To: <20240722095147.3372-1-a39.skl@gmail.com>
From: Vladimir Lypak <vladimir.lypak@gmail.com>
Introduce support for audio card on MSM8953/MSM8976 platform.
Main difference between those two is Q6AFE CLK API supported by firmware
which influence way we enable digital codec clock.
Either inside machine driver or outside via q6afe-clocks driver.
Signed-off-by: Vladimir Lypak <vladimir.lypak@gmail.com>
[Adam: Add MSM8976, rename functions, add mclk setting,add msg]
Co-developed-by: Adam Skladowski <a39.skl@gmail.com>
Signed-off-by: Adam Skladowski <a39.skl@gmail.com>
---
sound/soc/qcom/apq8016_sbc.c | 66 ++++++++++++++++++++++++++++++++++--
1 file changed, 64 insertions(+), 2 deletions(-)
diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c
index 8971f4f5d339..51efefefe0a1 100644
--- a/sound/soc/qcom/apq8016_sbc.c
+++ b/sound/soc/qcom/apq8016_sbc.c
@@ -22,6 +22,11 @@
#define MI2S_COUNT (MI2S_QUINARY + 1)
+enum afe_clk_api {
+ Q6AFE_CLK_V1,
+ Q6AFE_CLK_V2
+};
+
struct apq8016_sbc_data {
struct snd_soc_card card;
void __iomem *mic_iomux;
@@ -29,6 +34,8 @@ struct apq8016_sbc_data {
void __iomem *quin_iomux;
struct snd_soc_jack jack;
bool jack_setup;
+ enum afe_clk_api q6afe_clk_ver;
+ bool dig_cdc_mclk_en;
int mi2s_clk_count[MI2S_COUNT];
};
@@ -192,6 +199,28 @@ static int qdsp6_dai_get_lpass_id(struct snd_soc_dai *cpu_dai)
}
}
+static int qdsp6_get_clk_id(struct apq8016_sbc_data *data, int mi2s_id)
+{
+ if (data->q6afe_clk_ver == Q6AFE_CLK_V2) {
+ switch (mi2s_id) {
+ case MI2S_PRIMARY:
+ return Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT;
+ case MI2S_SECONDARY:
+ return Q6AFE_LPASS_CLK_ID_SEC_MI2S_IBIT;
+ case MI2S_TERTIARY:
+ return Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT;
+ case MI2S_QUATERNARY:
+ return Q6AFE_LPASS_CLK_ID_QUAD_MI2S_IBIT;
+ case MI2S_QUINARY:
+ return Q6AFE_LPASS_CLK_ID_QUI_MI2S_IBIT;
+ default:
+ break;
+ }
+ }
+ /* If AFE CLK isn't V2 return V1 */
+ return LPAIF_BIT_CLK;
+}
+
static int msm8916_qdsp6_dai_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
@@ -214,8 +243,16 @@ static int msm8916_qdsp6_startup(struct snd_pcm_substream *substream)
if (++data->mi2s_clk_count[mi2s] > 1)
return 0;
+ /*
+ * On newer legacy SoC (MSM8976) lpass codec clocks are not available in gcc region
+ * so we have to request clock from machine driver using V1 API)
+ */
+ if (data->q6afe_clk_ver == Q6AFE_CLK_V1 && data->dig_cdc_mclk_en == true)
+ ret = snd_soc_dai_set_sysclk(cpu_dai, LPAIF_DIG_CLK, DEFAULT_MCLK_RATE, 0);
+ if (ret)
+ dev_err(card->dev, "Failed to enable LPAIF dig clk: %d\n", ret);
- ret = snd_soc_dai_set_sysclk(cpu_dai, LPAIF_BIT_CLK, MI2S_BCLK_RATE, 0);
+ ret = snd_soc_dai_set_sysclk(cpu_dai, qdsp6_get_clk_id(data, mi2s), MI2S_BCLK_RATE, 0);
if (ret)
dev_err(card->dev, "Failed to enable LPAIF bit clk: %d\n", ret);
return ret;
@@ -236,9 +273,15 @@ static void msm8916_qdsp6_shutdown(struct snd_pcm_substream *substream)
if (--data->mi2s_clk_count[mi2s] > 0)
return;
- ret = snd_soc_dai_set_sysclk(cpu_dai, LPAIF_BIT_CLK, 0, 0);
+ ret = snd_soc_dai_set_sysclk(cpu_dai, qdsp6_get_clk_id(data, mi2s), 0, 0);
if (ret)
dev_err(card->dev, "Failed to disable LPAIF bit clk: %d\n", ret);
+
+ if (data->q6afe_clk_ver == Q6AFE_CLK_V1 && data->dig_cdc_mclk_en == true)
+ ret = snd_soc_dai_set_sysclk(cpu_dai, LPAIF_DIG_CLK, 0, 0);
+ if (ret)
+ dev_err(card->dev, "Failed to disable LPAIF dig clk: %d\n", ret);
+
}
static const struct snd_soc_ops msm8916_qdsp6_be_ops = {
@@ -279,6 +322,23 @@ static void msm8916_qdsp6_add_ops(struct snd_soc_card *card)
}
}
+static void msm8953_qdsp6_add_ops(struct snd_soc_card *card)
+{
+ struct apq8016_sbc_data *pdata = snd_soc_card_get_drvdata(card);
+
+ pdata->q6afe_clk_ver = Q6AFE_CLK_V2;
+ msm8916_qdsp6_add_ops(card);
+}
+
+static void msm8976_qdsp6_add_ops(struct snd_soc_card *card)
+{
+ struct apq8016_sbc_data *pdata = snd_soc_card_get_drvdata(card);
+
+ pdata->q6afe_clk_ver = Q6AFE_CLK_V1;
+ pdata->dig_cdc_mclk_en = true;
+ msm8916_qdsp6_add_ops(card);
+}
+
static const struct snd_kcontrol_new apq8016_sbc_snd_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone Jack"),
SOC_DAPM_PIN_SWITCH("Mic Jack"),
@@ -343,6 +403,8 @@ static int apq8016_sbc_platform_probe(struct platform_device *pdev)
static const struct of_device_id apq8016_sbc_device_id[] __maybe_unused = {
{ .compatible = "qcom,apq8016-sbc-sndcard", .data = apq8016_sbc_add_ops },
{ .compatible = "qcom,msm8916-qdsp6-sndcard", .data = msm8916_qdsp6_add_ops },
+ { .compatible = "qcom,msm8953-qdsp6-sndcard", .data = msm8953_qdsp6_add_ops },
+ { .compatible = "qcom,msm8976-qdsp6-sndcard", .data = msm8976_qdsp6_add_ops },
{},
};
MODULE_DEVICE_TABLE(of, apq8016_sbc_device_id);
--
2.45.2
next prev parent reply other threads:[~2024-07-22 9:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-22 9:51 [PATCH 0/4] MSM8953/MSM8976 ASoC support Adam Skladowski
2024-07-22 9:51 ` [PATCH 1/4] ASoC: qcom: apq8016_sbc.c: Add Quinary support Adam Skladowski
2024-07-22 12:00 ` Dmitry Baryshkov
2024-07-22 9:51 ` [PATCH 2/4] ASoC: msm8916-wcd-analog: add cajon and cajon v2 support Adam Skladowski
2024-07-22 9:51 ` [PATCH 3/4] ASoC: dt-bindings: qcom,sm8250: Add msm8953/msm8976-qdsp6-sndcard Adam Skladowski
2024-07-23 8:19 ` Krzysztof Kozlowski
2024-07-23 8:36 ` Krzysztof Kozlowski
2024-07-22 9:51 ` Adam Skladowski [this message]
2024-07-22 15:06 ` [PATCH 4/4] ASoC: qcom: apq8016_sbc: Add support for msm8953/msm8976 SoC kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240722095147.3372-5-a39.skl@gmail.com \
--to=a39.skl@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=bgoswami@quicinc.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=phone-devel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.com \
--cc=vladimir.lypak@gmail.com \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).