From nobody Sun Oct 5 16:15:49 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63FEB221DB4; Fri, 1 Aug 2025 09:18:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754039926; cv=none; b=BJHzWKthgZWtZ4xtV2StGarv9BIG1UQVHrhWAgq11Mq3YphJVU8NF68PILjPpKrUj+zfTzx+07ybJI9MH2tlZ72MVvWaulHLZPo1N31wwc+X38XaDQw9yGkJyzIkl2OnJr3mETjEPM6uTinjGVUGfngmLvjooDktENpMG9HedC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754039926; c=relaxed/simple; bh=QcoOAH1s06MPN/im803hG8+hLavbNrR9KDrB42elT/I=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RFTxUynQOucIVYbQbS2p0fy4UqP24MwqEaOtqV1PU6xxkW9TahFdi0g8dFJEiM44Yth1AeiGnJUi4E8i/FR+Pm2Eu8OXXfuOB5OoDeA3NIxGXuxxM0s0cRKDdU4FlKtmVD8Dg9wQllCRUx+0cdwKtusp05THLfPwQSc6BhlmO+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lsKDelXO; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lsKDelXO" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-45610582d07so12916575e9.0; Fri, 01 Aug 2025 02:18:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754039923; x=1754644723; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xtLunnP4TedJqPo1vsBP+WsJ5NT7Bmy4r8DnYlq+CEY=; b=lsKDelXONGBW+S9SglkMQu6Kv6drcpZyEYiWWawZAgySW+Xcs7uLwiqt7rj8FwAhD9 QSvQz2kTaL4/azZ2BzNpM7m39QdEOsJlMY1KXjp5+7mmjNmXozmmdRJcIRaTVp5TQ9r9 CwoGWkK6Yc1TTsfLiHFZ59w+uDgLujQYbRnbbiMf5g4fPCs/ff51UtQzeF4Pw2Jy5Ql7 PB66LJSgSHy+093aMslKN6F+iQWdfKC/Gqd0mp63oYaG9FJE0tlmU11+S1ju0R137p3C uvJdexVErzsuxoMLm9i8uLVbQjgO1w70VmkKX+yfuceNe7u5K+SpLJkLyTvoe1l4RWQE KM7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754039923; x=1754644723; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xtLunnP4TedJqPo1vsBP+WsJ5NT7Bmy4r8DnYlq+CEY=; b=u6GLo18851jTJEQqYw1ZpouPujx4iuTXdGTbsDeK41D0lcd+XtOz5aGmCynNQ2Yo+e +hFH0nOZoU3x9mAyaIZKXqU3W6Rl9CFbKAwxPQ5Hpr9leiJ8Ij5Qt+NRW8wAuuMSvnXr GIkgKhJrF+dfaauR3T32e3liJBc2kRLXUDQZWbmJ0QNJ4dI2ieA9wVXEslLVD07ayCis IS3vt5HRv3HsiwQOqeJB8OSwX/dNIknj2sQFL0sgRoFR323KL62H6/hNfxGXkKCyRRs4 wBnqo8FGTl0rWA1rgqYWRoHNhzj8vp/GRY7qnmbh1+3ATOk5whUCni069tUvTTk+X79j yq/g== X-Forwarded-Encrypted: i=1; AJvYcCVHuU7/B0l6FqEMEcUh/IwY3tjql3mMsGwedGI3hlciGzjxFDgXVnZcuuWJLOjWF9iR08q/lM47c4IR6Ac=@vger.kernel.org, AJvYcCVRuAZgh5MRMTgWKFpXbpZy1RjWzoFZKVAEuD75IyHMUiyj1fyps8qcFHhKD7uGZ5xgAHJKZjMEErFefI0=@vger.kernel.org X-Gm-Message-State: AOJu0YzutTRWxHKSHYUs/q51p5rAe7aXVFfMgOFwsqF0KwF5Moj+cVY/ UvaibwiJaolSVSYO6C7CzPV3jVTePIcZDG9eZFlm6XXsWYJVF1RiSWfn X-Gm-Gg: ASbGncsHorKwBshlj6LxV9ry+e4vtve3Dfk6zioYVubpKJoYwycHmnmaVDc0sbYER6U eNkqvk8J3pqgZ62uK2T4sxxY9dPxMhiEaaYVBBH3ov7AS6CexJXoFXykS6++r59hkNaG/Zqnvxy CNQcJUIspC/v1JUz6SejRF7RhgoKLcek/rjGH3BO5s1AQ3YsIwqCCm5dgBAA1O0vpW/IBwkOYCs oQNQemSBZQJYnPV+zX7XG4APOZvyYlSR1JcVLhAFQkC1q87cLwJLkJtXmLMdzvux1RT/uNyNrSU 0YF595J4GjytdvbqaTq3T/51d9OIYMZSOjaMcu/MdpBiArkDJifLVeMr5Fvv6uq73jQg5xBdtQ3 1RqxMfALLl6LqAhQcOy89/v6xy1VLI2/tnztZeV9Q4KuehzOpdeLHWEd69vbSsY9RnoabrTJpFM Ssdl7WEdHGjo5s X-Google-Smtp-Source: AGHT+IFi/skLLCRiAqQgbi5epGmUch5tPREIEOTjh2ICmnSbjfdG3rTwP7VXpgf+GU2FtdKGaxac6w== X-Received: by 2002:a05:600c:3e1b:b0:455:e858:cd04 with SMTP id 5b1f17b1804b1-45892bd217bmr88566565e9.25.1754039922271; Fri, 01 Aug 2025 02:18:42 -0700 (PDT) Received: from Ansuel-XPS24 (host-80-181-255-224.pool80181.interbusiness.it. [80.181.255.224]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-458953787a8sm95789065e9.14.2025.08.01.02.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Aug 2025 02:18:41 -0700 (PDT) From: Christian Marangi To: Jaroslav Kysela , Takashi Iwai , Matthias Brugger , AngeloGioacchino Del Regno , Liam Girdwood , Mark Brown , "Dr. David Alan Gilbert" , Christian Marangi , Chen-Yu Tsai , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Charles Keepax , Tang Bin , Kuninori Morimoto , =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , parkeryang , YR Yang , Zhang Yi , Fei Shao , Julien Massot , Alexandre Mergnat , linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [RFC RESEND PATCH 1/2] ASoC: mediatek: move some header to global include Date: Fri, 1 Aug 2025 11:18:08 +0200 Message-ID: <20250801091812.4866-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250801091812.4866-1-ansuelsmth@gmail.com> References: <20250801091812.4866-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In preparation for support of Airoha SoC sound system based on Mediatek AFE, move some header to global include to prevent having to use complex redirection for inclusion. Signed-off-by: Christian Marangi --- .../common =3D> include/sound/mediatek}/mtk-afe-fe-dai.h | 0 .../sound/mediatek}/mtk-afe-platform-driver.h | 0 sound/soc/mediatek/common/mtk-afe-fe-dai.c | 4 ++-- sound/soc/mediatek/common/mtk-afe-platform-driver.c | 2 +- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 4 ++-- sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 4 ++-- sound/soc/mediatek/mt7986/mt7986-afe-pcm.c | 4 ++-- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 4 ++-- sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 4 ++-- sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c | 2 +- sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c | 2 +- sound/soc/mediatek/mt8186/mt8186-afe-pcm.c | 4 ++-- sound/soc/mediatek/mt8186/mt8186-misc-control.c | 4 ++-- sound/soc/mediatek/mt8186/mt8186-mt6366-common.c | 2 +- sound/soc/mediatek/mt8186/mt8186-mt6366.c | 2 +- sound/soc/mediatek/mt8188/mt8188-afe-pcm.c | 4 ++-- sound/soc/mediatek/mt8188/mt8188-mt6359.c | 2 +- sound/soc/mediatek/mt8192/mt8192-afe-pcm.c | 4 ++-- sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c | 2 +- sound/soc/mediatek/mt8195/mt8195-afe-pcm.c | 4 ++-- sound/soc/mediatek/mt8195/mt8195-mt6359.c | 2 +- sound/soc/mediatek/mt8365/mt8365-afe-pcm.c | 4 ++-- 22 files changed, 32 insertions(+), 32 deletions(-) rename {sound/soc/mediatek/common =3D> include/sound/mediatek}/mtk-afe-fe-= dai.h (100%) rename {sound/soc/mediatek/common =3D> include/sound/mediatek}/mtk-afe-pla= tform-driver.h (100%) diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.h b/include/sound/med= iatek/mtk-afe-fe-dai.h similarity index 100% rename from sound/soc/mediatek/common/mtk-afe-fe-dai.h rename to include/sound/mediatek/mtk-afe-fe-dai.h diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.h b/include/= sound/mediatek/mtk-afe-platform-driver.h similarity index 100% rename from sound/soc/mediatek/common/mtk-afe-platform-driver.h rename to include/sound/mediatek/mtk-afe-platform-driver.h diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediate= k/common/mtk-afe-fe-dai.c index 3809068f5620..de58ee0afe27 100644 --- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c +++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c @@ -11,9 +11,9 @@ #include #include #include -#include "mtk-afe-platform-driver.h" +#include #include -#include "mtk-afe-fe-dai.h" +#include #include "mtk-base-afe.h" =20 #define AFE_BASE_END_OFFSET 8 diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/so= c/mediatek/common/mtk-afe-platform-driver.c index 6b6330583941..fc1681281ad5 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c @@ -10,7 +10,7 @@ #include #include =20 -#include "mtk-afe-platform-driver.h" +#include #include "mtk-base-afe.h" =20 int mtk_afe_combine_sub_dai(struct mtk_base_afe *afe) diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediate= k/mt2701/mt2701-afe-pcm.c index fcae38135d93..ce50eda77bd9 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -16,8 +16,8 @@ =20 #include "mt2701-afe-common.h" #include "mt2701-afe-clock-ctrl.h" -#include "../common/mtk-afe-platform-driver.h" -#include "../common/mtk-afe-fe-dai.h" +#include +#include =20 static const struct snd_pcm_hardware mt2701_afe_hardware =3D { .info =3D SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED diff --git a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c b/sound/soc/mediate= k/mt6797/mt6797-afe-pcm.c index f62a32f2f2b6..dd8583df7d0a 100644 --- a/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c +++ b/sound/soc/mediatek/mt6797/mt6797-afe-pcm.c @@ -16,8 +16,8 @@ #include "mt6797-afe-clk.h" #include "mt6797-interconnection.h" #include "mt6797-reg.h" -#include "../common/mtk-afe-platform-driver.h" -#include "../common/mtk-afe-fe-dai.h" +#include +#include =20 enum { MTK_AFE_RATE_8K =3D 0, diff --git a/sound/soc/mediatek/mt7986/mt7986-afe-pcm.c b/sound/soc/mediate= k/mt7986/mt7986-afe-pcm.c index 7a6ad9116e55..640c3a7bff2d 100644 --- a/sound/soc/mediatek/mt7986/mt7986-afe-pcm.c +++ b/sound/soc/mediatek/mt7986/mt7986-afe-pcm.c @@ -16,8 +16,8 @@ =20 #include "mt7986-afe-common.h" #include "mt7986-reg.h" -#include "../common/mtk-afe-platform-driver.h" -#include "../common/mtk-afe-fe-dai.h" +#include +#include =20 enum { MTK_AFE_RATE_8K =3D 0, diff --git a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c b/sound/soc/mediate= k/mt8173/mt8173-afe-pcm.c index 04ed0cfec174..6c58daa0a963 100644 --- a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +++ b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c @@ -18,8 +18,8 @@ #include #include "mt8173-afe-common.h" #include "../common/mtk-base-afe.h" -#include "../common/mtk-afe-platform-driver.h" -#include "../common/mtk-afe-fe-dai.h" +#include +#include =20 /*************************************************************************= **** * R E G I S T E R D E F I N I T I O N diff --git a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c b/sound/soc/mediate= k/mt8183/mt8183-afe-pcm.c index e8884354995c..9e1fa40bcb56 100644 --- a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c +++ b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c @@ -17,8 +17,8 @@ #include "mt8183-afe-clk.h" #include "mt8183-interconnection.h" #include "mt8183-reg.h" -#include "../common/mtk-afe-platform-driver.h" -#include "../common/mtk-afe-fe-dai.h" +#include +#include =20 enum { MTK_AFE_RATE_8K =3D 0, diff --git a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c b/sound/soc= /mediatek/mt8183/mt8183-da7219-max98357.c index 3388e076ccc9..faba30a58e9e 100644 --- a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +++ b/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c @@ -16,7 +16,7 @@ =20 #include "../../codecs/da7219.h" #include "../../codecs/rt1015.h" -#include "../common/mtk-afe-platform-driver.h" +#include #include "mt8183-afe-common.h" =20 #define DA7219_CODEC_DAI "da7219-hifi" diff --git a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c b/s= ound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c index 497a9043be7b..5d6bcaaebd8f 100644 --- a/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c +++ b/sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c @@ -15,7 +15,7 @@ =20 #include "../../codecs/rt1015.h" #include "../../codecs/ts3a227e.h" -#include "../common/mtk-afe-platform-driver.h" +#include #include "mt8183-afe-common.h" =20 #define RT1015_CODEC_DAI "rt1015-aif" diff --git a/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c b/sound/soc/mediate= k/mt8186/mt8186-afe-pcm.c index db7c93401bee..2ffb64d88c56 100644 --- a/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c +++ b/sound/soc/mediatek/mt8186/mt8186-afe-pcm.c @@ -14,8 +14,8 @@ #include #include =20 -#include "../common/mtk-afe-platform-driver.h" -#include "../common/mtk-afe-fe-dai.h" +#include +#include =20 #include "mt8186-afe-common.h" #include "mt8186-afe-clk.h" diff --git a/sound/soc/mediatek/mt8186/mt8186-misc-control.c b/sound/soc/me= diatek/mt8186/mt8186-misc-control.c index 2317de8c44c0..96ee69fdc8a6 100644 --- a/sound/soc/mediatek/mt8186/mt8186-misc-control.c +++ b/sound/soc/mediatek/mt8186/mt8186-misc-control.c @@ -11,8 +11,8 @@ #include #include =20 -#include "../common/mtk-afe-fe-dai.h" -#include "../common/mtk-afe-platform-driver.h" +#include +#include #include "mt8186-afe-common.h" =20 static const char * const mt8186_sgen_mode_str[] =3D { diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-common.c b/sound/soc/m= ediatek/mt8186/mt8186-mt6366-common.c index fa08eb0654d8..4155db56c59a 100644 --- a/sound/soc/mediatek/mt8186/mt8186-mt6366-common.c +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-common.c @@ -9,7 +9,7 @@ #include =20 #include "../../codecs/mt6358.h" -#include "../common/mtk-afe-platform-driver.h" +#include #include "mt8186-afe-common.h" #include "mt8186-mt6366-common.h" =20 diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366.c b/sound/soc/mediatek= /mt8186/mt8186-mt6366.c index 43546012cf61..9c47949864fc 100644 --- a/sound/soc/mediatek/mt8186/mt8186-mt6366.c +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366.c @@ -22,7 +22,7 @@ #include "../../codecs/da7219.h" #include "../../codecs/mt6358.h" #include "../../codecs/rt5682.h" -#include "../common/mtk-afe-platform-driver.h" +#include #include "../common/mtk-dsp-sof-common.h" #include "../common/mtk-soc-card.h" #include "../common/mtk-soundcard-driver.h" diff --git a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c b/sound/soc/mediate= k/mt8188/mt8188-afe-pcm.c index ac4fdf8ba78f..30bb0cd34953 100644 --- a/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c +++ b/sound/soc/mediatek/mt8188/mt8188-afe-pcm.c @@ -24,8 +24,8 @@ #include "mt8188-afe-common.h" #include "mt8188-afe-clk.h" #include "mt8188-reg.h" -#include "../common/mtk-afe-platform-driver.h" -#include "../common/mtk-afe-fe-dai.h" +#include +#include =20 #define MT8188_MEMIF_BUFFER_BYTES_ALIGN (0x40) #define MT8188_MEMIF_DL7_MAX_PERIOD_SIZE (0x3fff) diff --git a/sound/soc/mediatek/mt8188/mt8188-mt6359.c b/sound/soc/mediatek= /mt8188/mt8188-mt6359.c index a2a76b6df631..0801c26ef36d 100644 --- a/sound/soc/mediatek/mt8188/mt8188-mt6359.c +++ b/sound/soc/mediatek/mt8188/mt8188-mt6359.c @@ -19,7 +19,7 @@ #include "../../codecs/mt6359.h" #include "../../codecs/mt6359-accdet.h" #include "../../codecs/rt5682.h" -#include "../common/mtk-afe-platform-driver.h" +#include #include "../common/mtk-soundcard-driver.h" #include "../common/mtk-dsp-sof-common.h" #include "../common/mtk-soc-card.h" diff --git a/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c b/sound/soc/mediate= k/mt8192/mt8192-afe-pcm.c index fd6af74d7995..1498714ff6c0 100644 --- a/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c +++ b/sound/soc/mediatek/mt8192/mt8192-afe-pcm.c @@ -16,8 +16,8 @@ #include #include =20 -#include "../common/mtk-afe-fe-dai.h" -#include "../common/mtk-afe-platform-driver.h" +#include +#include =20 #include "mt8192-afe-common.h" #include "mt8192-afe-clk.h" diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/soun= d/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c index bf483a8fb34a..910ff56cc607 100644 --- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c @@ -19,7 +19,7 @@ #include "../../codecs/mt6359.h" #include "../../codecs/rt1015.h" #include "../../codecs/rt5682.h" -#include "../common/mtk-afe-platform-driver.h" +#include #include "../common/mtk-soc-card.h" #include "../common/mtk-soundcard-driver.h" #include "mt8192-afe-common.h" diff --git a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c b/sound/soc/mediate= k/mt8195/mt8195-afe-pcm.c index 5d025ad72263..a18fdfd9049c 100644 --- a/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c +++ b/sound/soc/mediatek/mt8195/mt8195-afe-pcm.c @@ -20,8 +20,8 @@ #include "mt8195-afe-common.h" #include "mt8195-afe-clk.h" #include "mt8195-reg.h" -#include "../common/mtk-afe-platform-driver.h" -#include "../common/mtk-afe-fe-dai.h" +#include +#include =20 #define MT8195_MEMIF_BUFFER_BYTES_ALIGN (0x40) #define MT8195_MEMIF_DL7_MAX_PERIOD_SIZE (0x3fff) diff --git a/sound/soc/mediatek/mt8195/mt8195-mt6359.c b/sound/soc/mediatek= /mt8195/mt8195-mt6359.c index e57391c213e7..9594689d935a 100644 --- a/sound/soc/mediatek/mt8195/mt8195-mt6359.c +++ b/sound/soc/mediatek/mt8195/mt8195-mt6359.c @@ -19,7 +19,7 @@ #include "../../codecs/mt6359.h" #include "../../codecs/rt1011.h" #include "../../codecs/rt5682.h" -#include "../common/mtk-afe-platform-driver.h" +#include #include "../common/mtk-dsp-sof-common.h" #include "../common/mtk-soc-card.h" #include "../common/mtk-soundcard-driver.h" diff --git a/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c b/sound/soc/mediate= k/mt8365/mt8365-afe-pcm.c index 10793bbe9275..ddedf55e0d8c 100644 --- a/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c +++ b/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c @@ -19,8 +19,8 @@ #include "mt8365-afe-clk.h" #include "mt8365-reg.h" #include "../common/mtk-base-afe.h" -#include "../common/mtk-afe-platform-driver.h" -#include "../common/mtk-afe-fe-dai.h" +#include +#include =20 #define AFE_BASE_END_OFFSET 8 =20 --=20 2.50.0 From nobody Sun Oct 5 16:15:49 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E13A9223DDD; Fri, 1 Aug 2025 09:18:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754039929; cv=none; b=tVxgd2JwyAIySZxDWjXya13vCmpysK7ftT2KfFzxX3HdWzMybVMPsEg3TgfUgalWD4H16geIbXYLsrUyazdfBsrmgOgb+LkJsYBshgDMsAiEk9JjDKX7QRe6bpwMaOGrvHnuv654U3uH5pWdatkFeDnh6bdW8ESy92qBmQv6Jn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754039929; c=relaxed/simple; bh=EZ9coIo9VdjSkRUbAibPRCDdd0sc/5sH13gzaeUrJX0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K+KxJk35P5fuvXSGeS0UZG2xF9y+SgMz5/uWEXgnpHusO6F0AiByGEofrCIHihUI8SE1YXBX0Ol0/J/cWVeZGhj+6WVZVNj3bHGOtav2QTMJ3R19N+QetWELx+Dn8LI0sLhCOVAzCZEUpDwNbNHJJMAPN53kC27+ZuPaizzgU74= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gl8Cf3aI; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gl8Cf3aI" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4589968e001so10991295e9.0; Fri, 01 Aug 2025 02:18:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754039925; x=1754644725; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ROhyw+t7FAuJ/neKZ5R3uau4fvGt/s6iE4pUlePNK0k=; b=gl8Cf3aIhvYASp21JvK62UMrCRYk0pM00so9cMAA5DeiFb+d7GNH2bSC81MOZf/d6f rMRS2kunV3pJOq96oqrBmNVwUMrbzk/B4Kn4HMpVUPBRFFUWBxKvIX3PhH4xBhgsJGRn SOO6OSWp4VcQQdxisfcqcVGKRxMjOVTQXORP1ktpCAGC5FsarUQxfW3zbhPtn+GIuRGc XM/0rJaC4Wqwyrwm0Qhbyya4pH6mbpMI3QCc5OMu8Hm94qDvWgyFr2nqeXp0CxKYL6xc BxfvwltJ2Ml+6jVqrbZ6a6YFypaBEvFxGC34r26iPdqH8iESABDDoE3gKW7cbnq/ZafL o0+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754039925; x=1754644725; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ROhyw+t7FAuJ/neKZ5R3uau4fvGt/s6iE4pUlePNK0k=; b=gTssBPBv6+TBPEy5v5jUIDnRrUitXz5nxfxOFbTXk8v5uMnef1oyPMFVtPkaMJ4SuR RrQFsDnWx9sHnYYFVwUljMbUAwy1nf/ykOl73/HJLyk8sDOH1eM6kgVzzCcaq0yibGon 326QtcG2GT5rB9Xr7Nwr9IJmrMMeBz9mrADvVSjpaO+gUVh8Jjt4Fo/W6+8d9zv7pbXX jYDifRu/dRbBo+S5iINsMiJxz/eh72Uk0PgjyH7J0VBkOJtNvbz6B18KDERdiocnp4AE kHkGn2L9B9CNDN3O21HWZy88++ByNoc7kzdCrts3wOmpw/Kgd+rwz/qYopTUKZx2iiQM lSCg== X-Forwarded-Encrypted: i=1; AJvYcCU1Rm9KfyH3S+Bc6BROZAb3+Le0pWMn0oNTaSbgNg9VjYXsdiJrSh2Bc+GNWIVzhoV7YHBofzNpsdbX2Aw=@vger.kernel.org, AJvYcCVh6iZcehABxkiq57qXvQb23gUMhgkTPQJCA3V6fYnhfQdU/equEelf4R9mXPW6AKVH2IRIKmAc06eZAdc=@vger.kernel.org X-Gm-Message-State: AOJu0YzNHLoCPXCpaP3utiuFhrvy0syDcgGfwxpXhNkJt9OooklV0WH7 caZhLSNQfPsN753czHbkV50dV2LfXOcICf6tGYmJgX3WdTdHxPgwkt0Y X-Gm-Gg: ASbGncvp0eHPUyhvya6GhR7xcg/6SdPChWbo3VkbSivwQEaev8W6O0Wky9cT5fsrF/E +4YsXHx3mIbBZ3bpGZ2j+0v+f2fuPPOAn3qbCAfG16Dhu6r+r2VywcMtoBMfhwbPsFpnarvbrSM SJ622WcOTHMcj8GZcIpQ6zyfGwFCPh1ussM/c+i71pJDr2Z4qbuB4uYn/QtpUSVl52icTO0KBr0 7WmCbxQg5TWrHZrS3DWzeW+5BVi0lFcxX8UUUTvqcPen70RP9vhZIffXrjEShcJwcfqY0/SQZIR XO/4D3ezpJCSgJ28nWeCrgv58CzKVrV/SPbS/LXBAerLaVV/ZX66iqpPjnelTpY8AGb5T25XIEe 5cqSrJ5hfuKwOYSGhX4dHWZ9XnVuJpEbQqU6F6cix8SRGPV0lEQY2eXscpvwanleI3dl0gAXPNu VIEefQ7kmJq5/t X-Google-Smtp-Source: AGHT+IF0EPte8HqaVBIYXtF1RnC8Y0lOpWJbe9LERhVuYpNScsmKQadfRHJvlxBAdqbO8bu+1FMb/A== X-Received: by 2002:a05:600c:138e:b0:456:1824:4808 with SMTP id 5b1f17b1804b1-45892bdf9admr85140375e9.32.1754039924825; Fri, 01 Aug 2025 02:18:44 -0700 (PDT) Received: from Ansuel-XPS24 (host-80-181-255-224.pool80181.interbusiness.it. [80.181.255.224]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-458953787a8sm95789065e9.14.2025.08.01.02.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Aug 2025 02:18:44 -0700 (PDT) From: Christian Marangi To: Jaroslav Kysela , Takashi Iwai , Matthias Brugger , AngeloGioacchino Del Regno , Liam Girdwood , Mark Brown , "Dr. David Alan Gilbert" , Christian Marangi , Chen-Yu Tsai , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Charles Keepax , Tang Bin , Kuninori Morimoto , =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?= , parkeryang , YR Yang , Zhang Yi , Fei Shao , Julien Massot , Alexandre Mergnat , linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [RFC RESEND PATCH 2/2] ASoC: airoha: Add AFE driver for Airoha AN7581 Date: Fri, 1 Aug 2025 11:18:09 +0200 Message-ID: <20250801091812.4866-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250801091812.4866-1-ansuelsmth@gmail.com> References: <20250801091812.4866-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for the Sound system present on Airoha AN7581 SoC. This is based on the mediatek AFE drivers. Signed-off-by: Christian Marangi --- sound/soc/Makefile | 1 + sound/soc/airoha/Kconfig | 10 + sound/soc/airoha/Makefile | 2 + sound/soc/airoha/an7581/Makefile | 7 + sound/soc/airoha/an7581/an7581-afe-common.h | 35 ++ sound/soc/airoha/an7581/an7581-afe-pcm.c | 455 ++++++++++++++++++++ sound/soc/airoha/an7581/an7581-reg.h | 29 ++ 7 files changed, 539 insertions(+) create mode 100644 sound/soc/airoha/Kconfig create mode 100644 sound/soc/airoha/Makefile create mode 100644 sound/soc/airoha/an7581/Makefile create mode 100644 sound/soc/airoha/an7581/an7581-afe-common.h create mode 100644 sound/soc/airoha/an7581/an7581-afe-pcm.c create mode 100644 sound/soc/airoha/an7581/an7581-reg.h diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 462322c38aa4..a6a9f5e84bad 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -46,6 +46,7 @@ obj-$(CONFIG_SND_SOC) +=3D codecs/ obj-$(CONFIG_SND_SOC) +=3D generic/ obj-$(CONFIG_SND_SOC) +=3D apple/ obj-$(CONFIG_SND_SOC) +=3D adi/ +obj-$(CONFIG_SND_SOC) +=3D airoha/ obj-$(CONFIG_SND_SOC) +=3D amd/ obj-$(CONFIG_SND_SOC) +=3D atmel/ obj-$(CONFIG_SND_SOC) +=3D au1x/ diff --git a/sound/soc/airoha/Kconfig b/sound/soc/airoha/Kconfig new file mode 100644 index 000000000000..01e84daba8fa --- /dev/null +++ b/sound/soc/airoha/Kconfig @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0-only +config SND_SOC_AN7581 + tristate "ASoC support for Airoha AN7581 chip" + depends on ARCH_AIROHA + select SND_SOC_MEDIATEK + help + This adds ASoC driver for Airoha AN7581 boards + that can be used with other codecs. + Select Y if you have such device. + If unsure select "N". diff --git a/sound/soc/airoha/Makefile b/sound/soc/airoha/Makefile new file mode 100644 index 000000000000..fef7fed384a9 --- /dev/null +++ b/sound/soc/airoha/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_SND_SOC_AN7581) +=3D an7581/ diff --git a/sound/soc/airoha/an7581/Makefile b/sound/soc/airoha/an7581/Mak= efile new file mode 100644 index 000000000000..bf475e14096a --- /dev/null +++ b/sound/soc/airoha/an7581/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 + +# platform driver +snd-soc-an7581-afe-y :=3D \ + an7581-afe-pcm.o + +obj-$(CONFIG_SND_SOC_AN7581) +=3D snd-soc-an7581-afe.o diff --git a/sound/soc/airoha/an7581/an7581-afe-common.h b/sound/soc/airoha= /an7581/an7581-afe-common.h new file mode 100644 index 000000000000..d2528735b75f --- /dev/null +++ b/sound/soc/airoha/an7581/an7581-afe-common.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * an7581-afe-common.h -- Airoha AN7581 audio driver definitions + */ + +#ifndef _AN_7581_AFE_COMMON_H_ +#define _AN_7581_AFE_COMMON_H_ + +#include +#include +#include +#include "../common/mtk-base-afe.h" + +enum { + AN7581_MEMIF_DL1, + AN7581_MEMIF_UL1, + AN7581_MEMIF_NUM, + AN7581_DAI_NUM =3D AN7581_MEMIF_NUM, +}; + +enum { + AN7581_IRQ_0, + AN7581_IRQ_1, + AN7581_IRQ_NUM, +}; + +struct an7581_afe_private { + /* dai */ + void *dai_priv[AN7581_DAI_NUM]; +}; + +unsigned int an7581_afe_rate_transform(struct device *dev, + unsigned int rate); + +#endif diff --git a/sound/soc/airoha/an7581/an7581-afe-pcm.c b/sound/soc/airoha/an= 7581/an7581-afe-pcm.c new file mode 100644 index 000000000000..456d402ba0ed --- /dev/null +++ b/sound/soc/airoha/an7581/an7581-afe-pcm.c @@ -0,0 +1,455 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Airoha ALSA SoC AFE platform driver for AN7581 + * + */ + +#include +#include +#include +#include +#include +#include + +#include "an7581-afe-common.h" +#include "an7581-reg.h" +#include +#include + +enum { + ARH_AFE_RATE_7K =3D 16, + ARH_AFE_RATE_8K =3D 0, + ARH_AFE_RATE_11K =3D 17, + ARH_AFE_RATE_12K =3D 1, + ARH_AFE_RATE_14K =3D 18, + ARH_AFE_RATE_16K =3D 2, + ARH_AFE_RATE_22K =3D 19, + ARH_AFE_RATE_24K =3D 3, + ARH_AFE_RATE_29K =3D 20, + ARH_AFE_RATE_32K =3D 4, + ARH_AFE_RATE_44K =3D 21, + ARH_AFE_RATE_48K =3D 5, + ARH_AFE_RATE_88K =3D 22, + ARH_AFE_RATE_96K =3D 6, + ARH_AFE_RATE_176K =3D 23, + ARH_AFE_RATE_192K =3D 7, + ARH_AFE_RATE_352K =3D 24, + ARH_AFE_RATE_384K =3D 8, +}; + +unsigned int an7581_afe_rate_transform(struct device *dev, unsigned int ra= te) +{ + switch (rate) { + case 7350: + return ARH_AFE_RATE_7K; + case 8000: + return ARH_AFE_RATE_8K; + case 11025: + return ARH_AFE_RATE_11K; + case 12000: + return ARH_AFE_RATE_12K; + case 14700: + return ARH_AFE_RATE_14K; + case 16000: + return ARH_AFE_RATE_16K; + case 22050: + return ARH_AFE_RATE_22K; + case 24000: + return ARH_AFE_RATE_24K; + case 29400: + return ARH_AFE_RATE_29K; + case 32000: + return ARH_AFE_RATE_32K; + case 44100: + return ARH_AFE_RATE_44K; + case 48000: + return ARH_AFE_RATE_48K; + case 88200: + return ARH_AFE_RATE_88K; + case 96000: + return ARH_AFE_RATE_96K; + case 176400: + return ARH_AFE_RATE_176K; + case 192000: + return ARH_AFE_RATE_192K; + case 352800: + return ARH_AFE_RATE_352K; + case 384000: + return ARH_AFE_RATE_384K; + default: + dev_warn(dev, "%s(), rate %u invalid, using %d!!!\n", + __func__, rate, ARH_AFE_RATE_48K); + return ARH_AFE_RATE_48K; + } +} + +static const int an7581_memif_specified_irqs[AN7581_MEMIF_NUM] =3D { + [AN7581_MEMIF_DL1] =3D AN7581_IRQ_0, + [AN7581_MEMIF_UL1] =3D AN7581_IRQ_1, +}; + +static const struct snd_pcm_hardware an7581_afe_hardware =3D { + .info =3D SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_MMAP_VALID, + .formats =3D SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + .period_bytes_min =3D 512, + .period_bytes_max =3D 128 * 1024, + .periods_min =3D 2, + .periods_max =3D 256, + .buffer_bytes_max =3D 256 * 1024, + .fifo_size =3D 0, +}; + +static int an7581_memif_fs(struct snd_pcm_substream *substream, + unsigned int rate) +{ + struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); + struct snd_soc_component *component =3D snd_soc_rtdcom_lookup(rtd, AFE_PC= M_NAME); + struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(component); + + return an7581_afe_rate_transform(afe->dev, rate); +} + +static int an7581_irq_fs(struct snd_pcm_substream *substream, + unsigned int rate) +{ + struct snd_soc_pcm_runtime *rtd =3D snd_soc_substream_to_rtd(substream); + struct snd_soc_component *component =3D snd_soc_rtdcom_lookup(rtd, AFE_PC= M_NAME); + struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(component); + + return an7581_afe_rate_transform(afe->dev, rate); +} + +#define ARH_PCM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ + SNDRV_PCM_FMTBIT_S32_LE) + +static struct snd_soc_dai_driver an7581_memif_dai_driver[] =3D { + /* FE DAIs: memory intefaces to CPU */ + { + .name =3D "DL1", + .id =3D AN7581_MEMIF_DL1, + .playback =3D { + .stream_name =3D "DL1", + .channels_min =3D 1, + .channels_max =3D 8, + .rates =3D SNDRV_PCM_RATE_8000_192000, + .formats =3D ARH_PCM_FORMATS, + }, + .ops =3D &mtk_afe_fe_ops, + }, + { + .name =3D "UL1", + .id =3D AN7581_MEMIF_UL1, + .capture =3D { + .stream_name =3D "UL1", + .channels_min =3D 1, + .channels_max =3D 2, + .rates =3D SNDRV_PCM_RATE_8000_192000, + .formats =3D ARH_PCM_FORMATS, + }, + .ops =3D &mtk_afe_fe_ops, + }, +}; +static const struct snd_soc_component_driver an7581_afe_pcm_dai_component = =3D { + .name =3D "an7581-afe-pcm-dai", +}; + +static const struct mtk_base_memif_data memif_data[AN7581_MEMIF_NUM] =3D { + [AN7581_MEMIF_DL1] =3D { + .name =3D "DL1", + .id =3D AN7581_MEMIF_DL1, + .reg_ofs_base =3D AFE_DL1_BASE, + .reg_ofs_cur =3D AFE_DL1_CUR, + .reg_ofs_end =3D AFE_DL1_END, + .fs_reg =3D -1, + .fs_shift =3D -1, + .fs_maskbit =3D -1, + .mono_reg =3D -1, + .mono_shift =3D -1, + .hd_reg =3D -1, + .hd_shift =3D -1, + .enable_reg =3D AFE_DAC_CON0, + .enable_shift =3D 17, + .msb_reg =3D -1, + .msb_shift =3D -1, + .agent_disable_reg =3D -1, + .agent_disable_shift =3D -1, + }, + [AN7581_MEMIF_UL1] =3D { + .name =3D "UL1", + .id =3D AN7581_MEMIF_UL1, + .reg_ofs_base =3D AFE_UL1_BASE, + .reg_ofs_cur =3D AFE_UL1_CUR, + .reg_ofs_end =3D AFE_UL1_END, + .fs_reg =3D -1, + .fs_shift =3D -1, + .fs_maskbit =3D -1, + .mono_reg =3D -1, + .mono_shift =3D -1, + .hd_reg =3D -1, + .hd_shift =3D -1, + .enable_reg =3D AFE_DAC_CON0, + .enable_shift =3D 1, + .msb_reg =3D -1, + .msb_shift =3D -1, + .agent_disable_reg =3D -1, + .agent_disable_shift =3D -1, + }, +}; + +static const struct mtk_base_irq_data irq_data[AN7581_IRQ_NUM] =3D { + [AN7581_IRQ_0] =3D { + .id =3D AN7581_IRQ_0, + .irq_cnt_reg =3D -1, + .irq_cnt_shift =3D -1, + .irq_cnt_maskbit =3D -1, + .irq_en_reg =3D AFE_IRQ1_CON0, + .irq_en_shift =3D 4, + .irq_fs_reg =3D -1, + .irq_fs_shift =3D -1, + .irq_fs_maskbit =3D -1, + .irq_clr_reg =3D AFE_IRQ1_CON0, + .irq_clr_shift =3D 0, + }, + [AN7581_IRQ_1] =3D { + .id =3D AN7581_IRQ_1, + .irq_cnt_reg =3D -1, + .irq_cnt_shift =3D -1, + .irq_cnt_maskbit =3D -1, + .irq_en_reg =3D AFE_IRQ0_CON0, + .irq_en_shift =3D 4, + .irq_fs_reg =3D -1, + .irq_fs_shift =3D -1, + .irq_fs_maskbit =3D -1, + .irq_clr_reg =3D AFE_IRQ0_CON0, + .irq_clr_shift =3D 1, + }, +}; + +static const struct regmap_config an7581_afe_regmap_config =3D { + .reg_bits =3D 32, + .reg_stride =3D 4, + .val_bits =3D 32, + .max_register =3D AFE_MAX_REGISTER, + .num_reg_defaults_raw =3D ((AFE_MAX_REGISTER / 4) + 1), +}; + +static irqreturn_t an7581_afe_irq_handler(int irq_id, void *dev) +{ + struct mtk_base_afe *afe =3D dev; + struct mtk_base_afe_irq *irq; + u32 status; + u32 reg; + int i; + + regmap_read(afe->regmap, AFE_IRQ_STS, &status); + + if (status & AFE_IRQ_STS_RECORD) + reg =3D AFE_IRQ0_CON0; + else + reg =3D AFE_IRQ1_CON0; + + regmap_set_bits(afe->regmap, reg, BIT(2)); + regmap_clear_bits(afe->regmap, reg, BIT(2)); + + regmap_set_bits(afe->regmap, reg, BIT(3)); + regmap_clear_bits(afe->regmap, reg, BIT(3)); + + for (i =3D 0; i < AN7581_MEMIF_NUM; i++) { + struct mtk_base_afe_memif *memif =3D &afe->memif[i]; + + if (!memif->substream) + continue; + + if (memif->irq_usage < 0) + continue; + + irq =3D &afe->irqs[memif->irq_usage]; + + if (status & (1 << irq->irq_data->irq_clr_shift)) + snd_pcm_period_elapsed(memif->substream); + } + + return IRQ_HANDLED; +} + +static int an7581_afe_runtime_suspend(struct device *dev) +{ + return 0; +} + +static int an7581_afe_runtime_resume(struct device *dev) +{ + return 0; +} + +static int an7581_dai_memif_register(struct mtk_base_afe *afe) +{ + struct mtk_base_afe_dai *dai; + + dai =3D devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); + if (!dai) + return -ENOMEM; + + list_add(&dai->list, &afe->sub_dais); + + dai->dai_drivers =3D an7581_memif_dai_driver; + dai->num_dai_drivers =3D ARRAY_SIZE(an7581_memif_dai_driver); + + return 0; +} + +typedef int (*dai_register_cb)(struct mtk_base_afe *); +static const dai_register_cb dai_register_cbs[] =3D { + an7581_dai_memif_register, +}; + +static int an7581_afe_pcm_dev_probe(struct platform_device *pdev) +{ + struct mtk_base_afe *afe; + struct an7581_afe_private *afe_priv; + struct device *dev; + int i, irq_id, ret; + + afe =3D devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL); + if (!afe) + return -ENOMEM; + platform_set_drvdata(pdev, afe); + + afe->platform_priv =3D devm_kzalloc(&pdev->dev, sizeof(*afe_priv), + GFP_KERNEL); + if (!afe->platform_priv) + return -ENOMEM; + + afe_priv =3D afe->platform_priv; + afe->dev =3D &pdev->dev; + dev =3D afe->dev; + + afe->base_addr =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(afe->base_addr)) + return PTR_ERR(afe->base_addr); + + ret =3D devm_pm_runtime_enable(dev); + if (ret) + return ret; + + pm_runtime_get_sync(&pdev->dev); + + afe->regmap =3D devm_regmap_init_mmio(&pdev->dev, afe->base_addr, + &an7581_afe_regmap_config); + + pm_runtime_put_sync(&pdev->dev); + if (IS_ERR(afe->regmap)) + return PTR_ERR(afe->regmap); + + + mutex_init(&afe->irq_alloc_lock); + + /* irq initialize */ + afe->irqs_size =3D AN7581_IRQ_NUM; + afe->irqs =3D devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs), + GFP_KERNEL); + if (!afe->irqs) + return -ENOMEM; + + for (i =3D 0; i < afe->irqs_size; i++) + afe->irqs[i].irq_data =3D &irq_data[i]; + + /* request irq */ + irq_id =3D platform_get_irq(pdev, 0); + if (irq_id < 0) + return irq_id; + + ret =3D devm_request_irq(dev, irq_id, an7581_afe_irq_handler, + IRQF_TRIGGER_NONE, "asys-isr", (void *)afe); + if (ret) + return dev_err_probe(dev, ret, "Failed to request irq for asys-isr\n"); + + /* init memif */ + afe->memif_size =3D AN7581_MEMIF_NUM; + afe->memif =3D devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif), + GFP_KERNEL); + if (!afe->memif) + return -ENOMEM; + + for (i =3D 0; i < afe->memif_size; i++) { + int sel_irq =3D an7581_memif_specified_irqs[i]; + + afe->memif[i].data =3D &memif_data[i]; + afe->memif[i].irq_usage =3D sel_irq; + afe->memif[i].const_irq =3D 1; + afe->irqs[sel_irq].irq_occupyed =3D true; + } + + /* init sub_dais */ + INIT_LIST_HEAD(&afe->sub_dais); + + for (i =3D 0; i < ARRAY_SIZE(dai_register_cbs); i++) { + ret =3D dai_register_cbs[i](afe); + if (ret) + return dev_err_probe(dev, ret, "DAI register failed, i: %d\n", i); + } + + /* init dai_driver and component_driver */ + ret =3D mtk_afe_combine_sub_dai(afe); + if (ret) + return dev_err_probe(dev, ret, "mtk_afe_combine_sub_dai fail\n"); + + afe->mtk_afe_hardware =3D &an7581_afe_hardware; + afe->memif_fs =3D an7581_memif_fs; + afe->irq_fs =3D an7581_irq_fs; + + afe->runtime_resume =3D an7581_afe_runtime_resume; + afe->runtime_suspend =3D an7581_afe_runtime_suspend; + + /* register component */ + ret =3D devm_snd_soc_register_component(&pdev->dev, + &mtk_afe_pcm_platform, + NULL, 0); + if (ret) + return dev_err_probe(dev, ret, "Cannot register AFE component\n"); + + ret =3D devm_snd_soc_register_component(afe->dev, + &an7581_afe_pcm_dai_component, + afe->dai_drivers, + afe->num_dai_drivers); + if (ret) + return dev_err_probe(dev, ret, "Cannot register PCM DAI component\n"); + + return 0; +} + +static void an7581_afe_pcm_dev_remove(struct platform_device *pdev) +{ + pm_runtime_disable(&pdev->dev); + if (!pm_runtime_status_suspended(&pdev->dev)) + an7581_afe_runtime_suspend(&pdev->dev); +} + +static const struct of_device_id an7581_afe_pcm_dt_match[] =3D { + { .compatible =3D "airoha,an7581-afe" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, an7581_afe_pcm_dt_match); + +static const struct dev_pm_ops an7581_afe_pm_ops =3D { + RUNTIME_PM_OPS(an7581_afe_runtime_suspend, + an7581_afe_runtime_resume, NULL) +}; + +static struct platform_driver an7581_afe_pcm_driver =3D { + .driver =3D { + .name =3D "an7581-audio", + .of_match_table =3D an7581_afe_pcm_dt_match, + .pm =3D pm_ptr(&an7581_afe_pm_ops), + }, + .probe =3D an7581_afe_pcm_dev_probe, + .remove =3D an7581_afe_pcm_dev_remove, +}; +module_platform_driver(an7581_afe_pcm_driver); + +MODULE_DESCRIPTION("Airoha SoC AFE platform driver for ALSA AN7581"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/airoha/an7581/an7581-reg.h b/sound/soc/airoha/an7581= /an7581-reg.h new file mode 100644 index 000000000000..2b14a66afa68 --- /dev/null +++ b/sound/soc/airoha/an7581/an7581-reg.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * an7581-reg.h -- Airoha AN7581 audio driver reg definition + */ + +#ifndef _AN7581_REG_H_ +#define _AN7581_REG_H_ + +#define AFE_DAC_CON0 0x0 + +#define AFE_DL1_BASE 0xa8 +#define AFE_DL1_END 0xac +#define AFE_DL1_CUR 0xb0 + +#define AFE_UL1_BASE 0xc4 +#define AFE_UL1_END 0xc8 +#define AFE_UL1_CUR 0xcc + +#define AFE_IRQ0_CON0 0xe4 + +#define AFE_IRQ_STS 0xf8 +#define AFE_IRQ_STS_PLAY BIT(1) +#define AFE_IRQ_STS_RECORD BIT(0) + +#define AFE_IRQ1_CON0 0x100 + +#define AFE_MAX_REGISTER AFE_IRQ1_CON0 + +#endif --=20 2.50.0