From patchwork Fri Feb 28 08:04:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jiebing chen via B4 Relay X-Patchwork-Id: 13995874 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D5BAC282C5 for ; Fri, 28 Feb 2025 08:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To: References:Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version: Subject:Date:From:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+J5a7MIkhelFw4Ym4oeDsuiKf/9JbQ8sKNFBz6ILK/Q=; b=xPXfZkR5kJYfp2d4SlHN90Qjst h+Ne4mCokzZ3RFJ+dd9iP88zAQSY9PKELYPzOmqH0patDo6fsqSKjlmi55YOMEZuOyQIefsi/jZl2 kkTeZFI9ln2FKRh7Y5vVqoKi18AI44WYeRKdxOFYD0q+Wjz8uxh/XHl161ukZLt3VAz2CnBhWfPqk Vn17BvynvBEmC543h4V6QMBSfJiposw0Z4sOHE42JpVlBiQjj+br+fB7V/nRz0OqC4hHNopOqFnMc 42JhsWtsf8R703Ima9mRBEXtpQpQKRK3SChhQvu/H8S5qqbLXTYVowTiW4uYdOFnak8Pbtywhjw8x P3HWYHJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tnvPQ-0000000A6XT-1jNq; Fri, 28 Feb 2025 08:07:48 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tnvMK-0000000A5Sq-2sAx; Fri, 28 Feb 2025 08:04:36 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 84D4261F5E; Fri, 28 Feb 2025 08:04:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 5F0C6C4CEE4; Fri, 28 Feb 2025 08:04:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740729875; bh=iBKf/MqVJS/RaohfLwY6/fVPPDai7O3DFGztOh4ZCQY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=s87Skr92oLvu1H/wEUIeA7CzEFsm5RWDh3BG0Ob3quhjFei5rxEs79dAHkkpX5LY3 qJjysqDG/e1uZVUlO+FWSA7c+ku5NZnzFPjq/B38DR+ulNlADu3G9cs9zsq6FjHyra BuQRfoV+cBPhO3gaKRK+zB57DtCBvKRPdGIjGR7gFDHy67D8hnV8ujJuYo9gIKaG6E CxLzurB1Zk1mN0JK2MGBnVSyhJDZUTXykHwtCMf402OafxLFj7CPHBC814RBzQmy52 8ji08bQ0tN+EbEWZzcmmJoQ8SUHLlv5DrTr2+Bi05SEaVgMxD9TnSLvIaXlV3rA6MQ SiwKNNAV1g3bQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5715EC282C5; Fri, 28 Feb 2025 08:04:35 +0000 (UTC) From: jiebing chen via B4 Relay Date: Fri, 28 Feb 2025 16:04:13 +0800 Subject: [PATCH v3 5/6] ASoC: meson: s4: Add s4 tocodec driver MIME-Version: 1.0 Message-Id: <20250228-audio_drvier-v3-5-dbfd30507e4c@amlogic.com> References: <20250228-audio_drvier-v3-0-dbfd30507e4c@amlogic.com> In-Reply-To: <20250228-audio_drvier-v3-0-dbfd30507e4c@amlogic.com> To: Jerome Brunet , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Neil Armstrong , Kevin Hilman , Martin Blumenstingl , Michael Turquette , Stephen Boyd Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, jian.xu@amlogic.com, shuai.li@amlogic.com, zhe.wang@amlogic.com, jiebing chen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1740729873; l=4499; i=jiebing.chen@amlogic.com; s=20250110; h=from:subject:message-id; bh=zvreiq77mtoUZZXMTxU9B9XQTVwpm3omZ1yAdi/Zb+k=; b=zuMV2pPva/jm6Re3wgtAZjAq9vq8UXNHNT3J9yfsa5m0aYBMjxXeS9EGuIm3X2P2DlJFjCQV9 FJCoCXpRWIYBM1xOpsITX2wDd5elHvMOLVwLLx3reg8WkemSo0OXrd9 X-Developer-Key: i=jiebing.chen@amlogic.com; a=ed25519; pk=6rFvvF45A84pLNRy03hfUHeROxHCnZ+1KAGw/DoqKic= X-Endpoint-Received: by B4 Relay for jiebing.chen@amlogic.com/20250110 with auth_id=316 X-Original-From: jiebing chen X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: jiebing.chen@amlogic.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: jiebing chen S4 tocodec support 8 lane to input, It need to enable bclk and mclk control bit when work Signed-off-by: jiebing chen --- sound/soc/meson/g12a-toacodec.c | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/sound/soc/meson/g12a-toacodec.c b/sound/soc/meson/g12a-toacodec.c index 531bb8707a3ec4c47814d6a0676d5c62c705da75..41eef9980059285275f0189a06469fc694775955 100644 --- a/sound/soc/meson/g12a-toacodec.c +++ b/sound/soc/meson/g12a-toacodec.c @@ -41,6 +41,9 @@ #define CTRL0_BCLK_SEL_LSB 4 #define CTRL0_MCLK_SEL GENMASK(2, 0) +#define CTRL0_BCLK_ENABLE_SHIFT 30 +#define CTRL0_MCLK_ENABLE_SHIFT 29 + #define TOACODEC_OUT_CHMAX 2 struct g12a_toacodec { @@ -129,6 +132,10 @@ static const struct snd_kcontrol_new g12a_toacodec_out_enable = SOC_DAPM_SINGLE_AUTODISABLE("Switch", TOACODEC_CTRL0, CTRL0_ENABLE_SHIFT, 1, 0); +static const struct snd_kcontrol_new s4_toacodec_clk_enable = + SOC_DAPM_DOUBLE("Switch", TOACODEC_CTRL0, + CTRL0_BCLK_ENABLE_SHIFT, CTRL0_MCLK_ENABLE_SHIFT, 1, 0); + static const struct snd_soc_dapm_widget g12a_toacodec_widgets[] = { SND_SOC_DAPM_MUX("SRC", SND_SOC_NOPM, 0, 0, &g12a_toacodec_mux), @@ -143,6 +150,15 @@ static const struct snd_soc_dapm_widget sm1_toacodec_widgets[] = { &g12a_toacodec_out_enable), }; +static const struct snd_soc_dapm_widget s4_toacodec_widgets[] = { + SND_SOC_DAPM_MUX("SRC", SND_SOC_NOPM, 0, 0, + &sm1_toacodec_mux), + SND_SOC_DAPM_SWITCH("OUT EN", SND_SOC_NOPM, 0, 0, + &g12a_toacodec_out_enable), + SND_SOC_DAPM_SWITCH("CLK EN", SND_SOC_NOPM, 0, 0, + &s4_toacodec_clk_enable), +}; + static int g12a_toacodec_input_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -228,6 +244,15 @@ static const struct snd_soc_dapm_route g12a_toacodec_routes[] = { { "OUT Capture", NULL, "OUT EN" }, }; +static const struct snd_soc_dapm_route s4_toacodec_routes[] = { + { "SRC", "I2S A", "IN A Playback" }, + { "SRC", "I2S B", "IN B Playback" }, + { "SRC", "I2S C", "IN C Playback" }, + { "OUT EN", "Switch", "SRC" }, + { "CLK EN", "Switch", "OUT EN" }, + { "OUT Capture", NULL, "CLK EN" }, +}; + static const struct snd_kcontrol_new g12a_toacodec_controls[] = { SOC_SINGLE("Lane Select", TOACODEC_CTRL0, CTRL0_LANE_SEL, 3, 0), }; @@ -236,6 +261,10 @@ static const struct snd_kcontrol_new sm1_toacodec_controls[] = { SOC_SINGLE("Lane Select", TOACODEC_CTRL0, CTRL0_LANE_SEL_SM1, 3, 0), }; +static const struct snd_kcontrol_new s4_toacodec_controls[] = { + SOC_SINGLE("Lane Select", TOACODEC_CTRL0, CTRL0_LANE_SEL_SM1, 7, 0), +}; + static const struct snd_soc_component_driver g12a_toacodec_component_drv = { .probe = g12a_toacodec_component_probe, .controls = g12a_toacodec_controls, @@ -258,6 +287,17 @@ static const struct snd_soc_component_driver sm1_toacodec_component_drv = { .endianness = 1, }; +static const struct snd_soc_component_driver s4_toacodec_component_drv = { + .probe = sm1_toacodec_component_probe, + .controls = s4_toacodec_controls, + .num_controls = ARRAY_SIZE(s4_toacodec_controls), + .dapm_widgets = s4_toacodec_widgets, + .num_dapm_widgets = ARRAY_SIZE(s4_toacodec_widgets), + .dapm_routes = s4_toacodec_routes, + .num_dapm_routes = ARRAY_SIZE(s4_toacodec_routes), + .endianness = 1, +}; + static const struct regmap_config g12a_toacodec_regmap_cfg = { .reg_bits = 32, .val_bits = 32, @@ -278,6 +318,13 @@ static const struct g12a_toacodec_match_data sm1_toacodec_match_data = { .field_bclk_sel = REG_FIELD(TOACODEC_CTRL0, 4, 6), }; +static const struct g12a_toacodec_match_data s4_toacodec_match_data = { + .component_drv = &s4_toacodec_component_drv, + .field_dat_sel = REG_FIELD(TOACODEC_CTRL0, 19, 20), + .field_lrclk_sel = REG_FIELD(TOACODEC_CTRL0, 12, 14), + .field_bclk_sel = REG_FIELD(TOACODEC_CTRL0, 4, 6), +}; + static const struct of_device_id g12a_toacodec_of_match[] = { { .compatible = "amlogic,g12a-toacodec", @@ -287,6 +334,10 @@ static const struct of_device_id g12a_toacodec_of_match[] = { .compatible = "amlogic,sm1-toacodec", .data = &sm1_toacodec_match_data, }, + { + .compatible = "amlogic,s4-toacodec", + .data = &s4_toacodec_match_data, + }, {} }; MODULE_DEVICE_TABLE(of, g12a_toacodec_of_match);