All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 6.5 01/34] ASoC: mediatek: mt8188-mt6359: support dynamic pinctrl
@ 2023-11-07 15:47 ` Sasha Levin
  0 siblings, 0 replies; 39+ messages in thread
From: Sasha Levin @ 2023-11-07 15:47 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Trevor Wu, AngeloGioacchino Del Regno, Mark Brown, Sasha Levin,
	lgirdwood, perex, tiwai, matthias.bgg, amergnat, ckeepax, robh,
	dan.carpenter, kuninori.morimoto.gx, xiazhengqiao, linux-sound,
	linux-arm-kernel, linux-mediatek

From: Trevor Wu <trevor.wu@mediatek.com>

[ Upstream commit d601bb78f06b9e3cbb52e6b87b88add9920a11b6 ]

To avoid power leakage, it is recommended to replace the default pinctrl
state with dynamic pinctrl since certain audio pinmux functions can
remain in a HIGH state even when audio is disabled. Linking pinctrl with
DAPM using SND_SOC_DAPM_PINCTRL will ensure that audio pins remain in
GPIO mode by default and only switch to an audio function when necessary.

Signed-off-by: Trevor Wu <trevor.wu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20230825024935.10878-2-trevor.wu@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/soc/mediatek/mt8188/mt8188-mt6359.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
index ac69c23e0da1c..7048ff52ab86a 100644
--- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c
+++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c
@@ -246,6 +246,11 @@ static const struct snd_soc_dapm_widget mt8188_mt6359_widgets[] = {
 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
 	SND_SOC_DAPM_SINK("HDMI"),
 	SND_SOC_DAPM_SINK("DP"),
+
+	/* dynamic pinctrl */
+	SND_SOC_DAPM_PINCTRL("ETDM_SPK_PIN", "aud_etdm_spk_on", "aud_etdm_spk_off"),
+	SND_SOC_DAPM_PINCTRL("ETDM_HP_PIN", "aud_etdm_hp_on", "aud_etdm_hp_off"),
+	SND_SOC_DAPM_PINCTRL("MTKAIF_PIN", "aud_mtkaif_on", "aud_mtkaif_off"),
 };
 
 static const struct snd_kcontrol_new mt8188_mt6359_controls[] = {
@@ -267,6 +272,7 @@ static int mt8188_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)
 		snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
 	struct snd_soc_component *cmpnt_codec =
 		asoc_rtd_to_codec(rtd, 0)->component;
+	struct snd_soc_dapm_widget *pin_w = NULL, *w;
 	struct mtk_base_afe *afe;
 	struct mt8188_afe_private *afe_priv;
 	struct mtkaif_param *param;
@@ -306,6 +312,18 @@ static int mt8188_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)
 		return 0;
 	}
 
+	for_each_card_widgets(rtd->card, w) {
+		if (!strcmp(w->name, "MTKAIF_PIN")) {
+			pin_w = w;
+			break;
+		}
+	}
+
+	if (pin_w)
+		dapm_pinctrl_event(pin_w, NULL, SND_SOC_DAPM_PRE_PMU);
+	else
+		dev_dbg(afe->dev, "%s(), no pinmux widget, please check if default on\n", __func__);
+
 	pm_runtime_get_sync(afe->dev);
 	mt6359_mtkaif_calibration_enable(cmpnt_codec);
 
@@ -403,6 +421,9 @@ static int mt8188_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)
 	for (i = 0; i < MT8188_MTKAIF_MISO_NUM; i++)
 		param->mtkaif_phase_cycle[i] = mtkaif_phase_cycle[i];
 
+	if (pin_w)
+		dapm_pinctrl_event(pin_w, NULL, SND_SOC_DAPM_POST_PMD);
+
 	dev_dbg(afe->dev, "%s(), end, calibration ok %d\n",
 		__func__, param->mtkaif_calibration_ok);
 
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2023-11-07 16:32 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-07 15:47 [PATCH AUTOSEL 6.5 01/34] ASoC: mediatek: mt8188-mt6359: support dynamic pinctrl Sasha Levin
2023-11-07 15:47 ` Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 02/34] ASoC: soc-card: Add storage for PCI SSID Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 03/34] ASoC: SOF: Pass PCI SSID to machine driver Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 04/34] crypto: pcrypt - Fix hungtask for PADATA_RESET Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 05/34] ALSA: scarlett2: Move USB IDs out from device_info struct Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 06/34] ASoC: SOF: ipc4: handle EXCEPTION_CAUGHT notification from firmware Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 07/34] RDMA/hfi1: Use FIELD_GET() to extract Link Width Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 08/34] scsi: hisi_sas: Set debugfs_dir pointer to NULL after removing debugfs Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 09/34] scsi: ibmvfc: Remove BUG_ON in the case of an empty event pool Sasha Levin
2023-11-07 15:47   ` Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 10/34] fs/jfs: Add check for negative db_l2nbperpage Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 11/34] fs/jfs: Add validity check for db_maxag and db_agpref Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 12/34] jfs: fix array-index-out-of-bounds in dbFindLeaf Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 13/34] jfs: fix array-index-out-of-bounds in diAlloc Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 14/34] HID: lenovo: Detect quirk-free fw on cptkbd and stop applying workaround Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 15/34] ARM: 9320/1: fix stack depot IRQ stack filter Sasha Levin
2023-11-07 15:47   ` Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 16/34] ALSA: hda: Fix possible null-ptr-deref when assigning a stream Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 17/34] gpiolib: of: Add quirk for mt2701-cs42448 ASoC sound Sasha Levin
2023-11-07 15:47   ` Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 18/34] PCI: tegra194: Use FIELD_GET()/FIELD_PREP() with Link Width fields Sasha Levin
2023-11-07 15:47 ` [PATCH AUTOSEL 6.5 19/34] PCI: mvebu: Use FIELD_PREP() with Link Width Sasha Levin
2023-11-07 15:47   ` Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 20/34] atm: iphase: Do PCI error checks on own line Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 21/34] PCI: Do error check on own line to split long "if" conditions Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 22/34] scsi: libfc: Fix potential NULL pointer dereference in fc_lport_ptp_setup() Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 23/34] PCI: Use FIELD_GET() to extract Link Width Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 24/34] PCI: Extract ATS disabling to a helper function Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 25/34] PCI: Disable ATS for specific Intel IPU E2000 devices Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 26/34] PCI: dwc: Add dw_pcie_link_set_max_link_width() Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 27/34] PCI: dwc: Add missing PCI_EXP_LNKCAP_MLW handling Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 28/34] misc: pci_endpoint_test: Add Device ID for R-Car S4-8 PCIe controller Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 29/34] PCI: Use FIELD_GET() in Sapphire RX 5600 XT Pulse quirk Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 30/34] ASoC: Intel: soc-acpi-cht: Add Lenovo Yoga Tab 3 Pro YT3-X90 quirk Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 31/34] crypto: hisilicon/qm - prevent soft lockup in receive loop Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 32/34] HID: Add quirk for Dell Pro Wireless Keyboard and Mouse KM5221W Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 33/34] exfat: support handle zero-size directory Sasha Levin
2023-11-07 15:48 ` [PATCH AUTOSEL 6.5 34/34] mfd: intel-lpss: Add Intel Lunar Lake-M PCI IDs Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.