From patchwork Wed Mar 19 07:04:47 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: 14022177 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 8C6EEC35FFA for ; Wed, 19 Mar 2025 07:15:38 +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=WLjfJ+FcgY4WcY/FsWji7z11mIGsdXmpAMqojphW8WU=; b=l8FmD5yhWRNWAa/R3LlTVBCsfW HCb6W6bhRjb8VXOjXQgFP9Vu0hVy1c+fnmjnA9LZh7eVcjpDfWsDlUlZizBrG4+hKbmLu0CzBCXXa Xo7vjVxXhxkLPaeFYHJdLNry5eCSNJnJfE8Shc+ywy4t50fbgqT8Xqzx68HjhGN0TRTj+7ike8MEu iPCD+MGduhj+zVFmoqW4NPIWZFXO+cZaFKuefG1Uv7Dy/9wxY7VpLK8RFGVKLl0T1rnRIv7JiWb2k A/8ko60iQxZCiVHe6Z7CLSPxmbjJ38cFkGUI+AmOVChu61ns3jHAN+pm5wZhb/2OBdQ4Qg7artLJp 7x4MUHiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tuneD-00000008Ccf-3aOY; Wed, 19 Mar 2025 07:15:29 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tunVi-00000008BFU-2kDB; Wed, 19 Mar 2025 07:06:45 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 325D45C5A33; Wed, 19 Mar 2025 07:04:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 4BD30C4CEF2; Wed, 19 Mar 2025 07:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742368000; bh=DuSfZotDalhZy/pmrz/AmbhOcgcLNj8GcPM7THaEcNw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=R+v8ep400mKZXmR9VC0xdMBOOttoqBThGrvt/L1ldf4DUg6N4qgZ1f8joXZWd+uF0 KUywIZK+aQOXIfooiAACeW71nItMRBZel8PmosIU8/V6bMtVj+rrd8rrUuZhjxAIlj 3kVgUYf/l1xgjMdQyRNe95p4mN0fc46khxcbQjGWYSanqML1SGD5Db00durGWoZvQW gmJ+WEVIQjQIPoEKauzh4WnbPxKrFS4gZEcmCUkaYr4t//tA/IM1c3yID6JYN+6zj6 muy4HyqG+FuJ5EGSsCMOF60Pd5aky+2HlxiYHxyuMgd00TnUhk3+Vv3TVxZhrA/U01 LbcZ3wfiw0oAQ== 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 3F1BBC35FFC; Wed, 19 Mar 2025 07:06:40 +0000 (UTC) From: jiebing chen via B4 Relay Date: Wed, 19 Mar 2025 15:04:47 +0800 Subject: [PATCH v4 4/6] ASoC: meson: g12a-toacodec: Add s4 tocodec driver MIME-Version: 1.0 Message-Id: <20250319-audio_drvier-v4-4-686867fad719@amlogic.com> References: <20250319-audio_drvier-v4-0-686867fad719@amlogic.com> In-Reply-To: <20250319-audio_drvier-v4-0-686867fad719@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=1742367998; l=4024; i=jiebing.chen@amlogic.com; s=20250110; h=from:subject:message-id; bh=eyHcdpkfMqVY347i0/Y7l/fGm8VvnCZTc/KsX9aimF4=; b=A36VuBHcvnSfvBeYfUCeLDwCHRTvhRfcikwciTn1IV/brEWs4kxcydgpq9xlEyfjS/XNBvSt1 t3nR/Wo3v+WCf5Gq7pzx+WvToYMAfaP5jzMhrtjf3g6riD7MnX8Exdu 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250319_000642_828944_BCE3CB54 X-CRM114-Status: GOOD ( 11.40 ) 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 | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/sound/soc/meson/g12a-toacodec.c b/sound/soc/meson/g12a-toacodec.c index 531bb8707a3ec4c47814d6a0676d5c62c705da75..88f9adabb3b5d7d8881fa110f1d0d51e9ac9c60e 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,19 @@ static const struct snd_soc_dapm_widget sm1_toacodec_widgets[] = { &g12a_toacodec_out_enable), }; +/* + * FIXME: + * On this soc, tocodec need enable mclk and bclk control + * just enable it when dapm power widget power on. + */ + +static const struct snd_soc_dapm_widget s4_toacodec_widgets[] = { + SND_SOC_DAPM_MUX("SRC", TOACODEC_CTRL0, CTRL0_BCLK_ENABLE_SHIFT, 0, + &sm1_toacodec_mux), + SND_SOC_DAPM_SWITCH("OUT EN", TOACODEC_CTRL0, CTRL0_MCLK_ENABLE_SHIFT, 0, + &g12a_toacodec_out_enable), +}; + static int g12a_toacodec_input_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -236,6 +256,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 +282,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 = g12a_toacodec_routes, + .num_dapm_routes = ARRAY_SIZE(g12a_toacodec_routes), + .endianness = 1, +}; + static const struct regmap_config g12a_toacodec_regmap_cfg = { .reg_bits = 32, .val_bits = 32, @@ -278,6 +313,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 +329,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);