From nobody Sun Dec 14 18:05:54 2025 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2086E32861E; Wed, 29 Oct 2025 09:39:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761730776; cv=none; b=OFkGuNv+AjUGcNWF8+IYko36mk030VN3xC4G64wwf73zUZUWPUBC+2hIomMZf31cr2DBOqcRW/ylSWGOejg2RZrxd3B3wcOBMcNRZaCeoNZIIN9NbboVbubNwfVeQSLi0vo6jblKCD6UWJWm37JTaVxo7tJ2B6bUsWkQvzTMVio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761730776; c=relaxed/simple; bh=HC7FJu5v0H5FaRqZVdMzzPzRo31MQLnxN2xyoGqCc1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tj4AV7kZQ+Ap/P3CGR7Ci/0x3uQnJm2nHb9OQVzg6MfjC8fCqpLLHD9Xh9Q7gCQGA4DveMM0UTGBHAZPRWajZCE3WDk+6W41ZYj6XEaxeyKpbo8fobrqZaKp+bMLgZJBHLQY4/gspKODfNtn/pSeSdzNM1u4sB55IWBXFkEqTWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=1ae/lHSH; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="1ae/lHSH" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 1128EC0BEBD; Wed, 29 Oct 2025 09:39:12 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 6132E606E8; Wed, 29 Oct 2025 09:39:32 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 26FEE117F19DA; Wed, 29 Oct 2025 10:39:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1761730771; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=cZfT+IVpVyyQl4hsGYvK1o0ggPzXojdpk+sM7Eh4XqU=; b=1ae/lHSHEXTTRI2/tUAd2klf50buGAdShgp9X2ukdZ4Qwi09jvTHALvm/yczHVYC7VFeTU ZZEXNKCvGZanyMZFQlHA76V8rlAHPYDHEAORNVH3aQR5f0w8PmcWhWJ6xj3SDuf8C7klXZ jvzTI47Ys/QZZA3hS/3AeUukktqfBZg2HrHOfzL5drV8YCDCeREl1EEPOpG2H8nx21FrUu JGuwWyJM+HevhcK169Giw/zujcA5K+Js9IGVm121dsZ3gxW+k2m5PFJkh7Yw8MX3MNNkeu 9gF2ApWgazg+00sIuQlecnp2VibVeFC9QRaix10Cpd5PtZ186IVDtw6uzXR1Ew== From: Herve Codina To: David Rhodes , Richard Fitzgerald , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Alexander Sverdlin , Nikita Shubin , Axel Lin , Brian Austin Cc: linux-sound@vger.kernel.org, patches@opensource.cirrus.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , stable@vger.kernel.org Subject: [PATCH v2 1/4] ASoC: cs4271: Fix cs4271 I2C and SPI drivers automatic module loading Date: Wed, 29 Oct 2025 10:39:17 +0100 Message-ID: <20251029093921.624088-2-herve.codina@bootlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251029093921.624088-1-herve.codina@bootlin.com> References: <20251029093921.624088-1-herve.codina@bootlin.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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" In commit c973b8a7dc50 ("ASoC: cs4271: Split SPI and I2C code into different modules") the driver was slit into a core, an SPI and an I2C part. However, the MODULE_DEVICE_TABLE(of, cs4271_dt_ids) was in the core part and so, module loading based on module.alias (based on DT compatible string matching) loads the core part but not the SPI or I2C parts. In order to have the I2C or the SPI module loaded automatically, move the MODULE_DEVICE_TABLE(of, ...) the core to I2C and SPI parts. Also move cs4271_dt_ids itself from the core part to I2C and SPI parts as both the call to MODULE_DEVICE_TABLE(of, ...) and the cs4271_dt_ids table itself need to be in the same file. Fixes: c973b8a7dc50 ("ASoC: cs4271: Split SPI and I2C code into different m= odules") Cc: stable@vger.kernel.org Signed-off-by: Herve Codina --- sound/soc/codecs/cs4271-i2c.c | 6 ++++++ sound/soc/codecs/cs4271-spi.c | 13 +++++++++++++ sound/soc/codecs/cs4271.c | 9 --------- sound/soc/codecs/cs4271.h | 1 - 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/cs4271-i2c.c b/sound/soc/codecs/cs4271-i2c.c index 1d210b969173..cefb8733fc61 100644 --- a/sound/soc/codecs/cs4271-i2c.c +++ b/sound/soc/codecs/cs4271-i2c.c @@ -28,6 +28,12 @@ static const struct i2c_device_id cs4271_i2c_id[] =3D { }; MODULE_DEVICE_TABLE(i2c, cs4271_i2c_id); =20 +static const struct of_device_id cs4271_dt_ids[] =3D { + { .compatible =3D "cirrus,cs4271", }, + { } +}; +MODULE_DEVICE_TABLE(of, cs4271_dt_ids); + static struct i2c_driver cs4271_i2c_driver =3D { .driver =3D { .name =3D "cs4271", diff --git a/sound/soc/codecs/cs4271-spi.c b/sound/soc/codecs/cs4271-spi.c index 4feb80436bd9..28dd7b8f3507 100644 --- a/sound/soc/codecs/cs4271-spi.c +++ b/sound/soc/codecs/cs4271-spi.c @@ -23,11 +23,24 @@ static int cs4271_spi_probe(struct spi_device *spi) return cs4271_probe(&spi->dev, devm_regmap_init_spi(spi, &config)); } =20 +static const struct spi_device_id cs4271_id_spi[] =3D { + { "cs4271", 0 }, + {} +}; +MODULE_DEVICE_TABLE(spi, cs4271_id_spi); + +static const struct of_device_id cs4271_dt_ids[] =3D { + { .compatible =3D "cirrus,cs4271", }, + { } +}; +MODULE_DEVICE_TABLE(of, cs4271_dt_ids); + static struct spi_driver cs4271_spi_driver =3D { .driver =3D { .name =3D "cs4271", .of_match_table =3D of_match_ptr(cs4271_dt_ids), }, + .id_table =3D cs4271_id_spi, .probe =3D cs4271_spi_probe, }; module_spi_driver(cs4271_spi_driver); diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c index 6a3cca3d26c7..ff9c6628224c 100644 --- a/sound/soc/codecs/cs4271.c +++ b/sound/soc/codecs/cs4271.c @@ -543,15 +543,6 @@ static int cs4271_soc_resume(struct snd_soc_component = *component) #define cs4271_soc_resume NULL #endif /* CONFIG_PM */ =20 -#ifdef CONFIG_OF -const struct of_device_id cs4271_dt_ids[] =3D { - { .compatible =3D "cirrus,cs4271", }, - { } -}; -MODULE_DEVICE_TABLE(of, cs4271_dt_ids); -EXPORT_SYMBOL_GPL(cs4271_dt_ids); -#endif - static int cs4271_component_probe(struct snd_soc_component *component) { struct cs4271_private *cs4271 =3D snd_soc_component_get_drvdata(component= ); diff --git a/sound/soc/codecs/cs4271.h b/sound/soc/codecs/cs4271.h index 290283a9149e..4965ce085875 100644 --- a/sound/soc/codecs/cs4271.h +++ b/sound/soc/codecs/cs4271.h @@ -4,7 +4,6 @@ =20 #include =20 -extern const struct of_device_id cs4271_dt_ids[]; extern const struct regmap_config cs4271_regmap_config; =20 int cs4271_probe(struct device *dev, struct regmap *regmap); --=20 2.51.0 From nobody Sun Dec 14 18:05:54 2025 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28A323314D3 for ; Wed, 29 Oct 2025 09:39:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761730779; cv=none; b=mInotNZaOD7xk2qTy6JtnTCR0Y/bjV4aj8ouJJx27drFkBsMhaWq11tO7Pv2O/17rOSKHLya2tNDfQIz8W7TYS5wn23G5fS2rE5bakkzhP8S+Bxd5Zb6D0+MDPQU1RrZ+ezgy4gLmhkApt2yNr08d589ht1wpQXd70gSW3zk5oQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761730779; c=relaxed/simple; bh=37IiwR/6S6dxfx7lj0RxvC3WsfBd/iSGcmPFwZTHdkY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bhIzCeIsOBCn/SET37+Hy7a9IqGmBddCHW8kYCkK5FBxNa42n/2Mit06crZRxB5k3oYAbKjWRV2s1nZDpNk5xl/SPInq+T4jiATr9OOEQ5xuY/7SYmq2I3VTlls+1CwV177xnTOAx/YarXUonVLT5LGFVGuhU5oJvLsuzqGwzdA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=HjhPfAve; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="HjhPfAve" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 4668AC0BEBC; Wed, 29 Oct 2025 09:39:15 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 99750606E8; Wed, 29 Oct 2025 09:39:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id CE804117F19D2; Wed, 29 Oct 2025 10:39:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1761730774; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=drk5eLb0e0St/3Rsft+R84KPgwf6up5pUeWOlxU8ev4=; b=HjhPfAve75wHUi/HamEnJwW4NYxmQErPBi1kEIEo6J3eTd45pTNoO79SbWWd6OhJlGSdiL lqf9x4vSJTirEHxaYebtzwgB2+kmSUQKLrGngfSmlMgaXR//IXzGpzCLbvWv1IxcKG6j/v U0DGa1wz/ph9iGWie2C1PNPDW5kMu7VjTTwuDz81T1kGyrIBRzo8MZitdWdkM8FiG1fQFZ U+xop2CMdP4jg29VIO1K+0Y3JF3NK8Ucdm0B+F7vunaBnRPSj39z8bP9vz/qE1z2d9zh/E PwCVeV4BRVb+l2HtEVmNycv1wc5501USF4uc1XlKDUI35V//eeSWJUqxs1DuRg== From: Herve Codina To: David Rhodes , Richard Fitzgerald , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Alexander Sverdlin , Nikita Shubin , Axel Lin , Brian Austin Cc: linux-sound@vger.kernel.org, patches@opensource.cirrus.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , stable@vger.kernel.org Subject: [PATCH v2 2/4] ASoC: cs4271: Disable regulators in component_probe() error path Date: Wed, 29 Oct 2025 10:39:18 +0100 Message-ID: <20251029093921.624088-3-herve.codina@bootlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251029093921.624088-1-herve.codina@bootlin.com> References: <20251029093921.624088-1-herve.codina@bootlin.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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The commit 9a397f473657 ("ASoC: cs4271: add regulator consumer support") has introduced regulators in the driver. Regulators are enabled at the beginning of component_probe() but they are not disabled on errors. This can lead to unbalanced enable/disable. Fix the error path to disable regulators on errors. Fixes: 9a397f473657 ("ASoC: cs4271: add regulator consumer support") Cc: stable@vger.kernel.org Signed-off-by: Herve Codina Reviewed-by: Alexander Sverdlin --- sound/soc/codecs/cs4271.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c index ff9c6628224c..a9d333e6c723 100644 --- a/sound/soc/codecs/cs4271.c +++ b/sound/soc/codecs/cs4271.c @@ -572,17 +572,17 @@ static int cs4271_component_probe(struct snd_soc_comp= onent *component) =20 ret =3D regcache_sync(cs4271->regmap); if (ret < 0) - return ret; + goto err_disable_regulators; =20 ret =3D regmap_update_bits(cs4271->regmap, CS4271_MODE2, CS4271_MODE2_PDN | CS4271_MODE2_CPEN, CS4271_MODE2_PDN | CS4271_MODE2_CPEN); if (ret < 0) - return ret; + goto err_disable_regulators; ret =3D regmap_update_bits(cs4271->regmap, CS4271_MODE2, CS4271_MODE2_PDN, 0); if (ret < 0) - return ret; + goto err_disable_regulators; /* Power-up sequence requires 85 uS */ udelay(85); =20 @@ -592,6 +592,10 @@ static int cs4271_component_probe(struct snd_soc_compo= nent *component) CS4271_MODE2_MUTECAEQUB); =20 return 0; + +err_disable_regulators: + regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies); + return ret; } =20 static void cs4271_component_remove(struct snd_soc_component *component) --=20 2.51.0 From nobody Sun Dec 14 18:05:54 2025 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E90473321A6; Wed, 29 Oct 2025 09:39:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761730781; cv=none; b=epeak2rK1M3/8kUZ7ASbmrjGX74zH3JoNR2c4dopiFgydtgkfGLfrBCxmuGKIcVRqNb7UjQrUKCY+lLU732ALbzpHHZerkMwqnhKss291wsxGIKBNJb091z/LkTYaXmdXNIswyDBgMR2U5bhbFjlTD/ViCfXVARAjQKxfnPfiik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761730781; c=relaxed/simple; bh=IVDScBKmFFaCLSQrllzQaCmJgM4AfNhIPlPvVyFW2yM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c9jP+kTZAhvzJB0wT0EflXS1iULvhEnr42KJnvhrEU2uA9O3eIy1BTfosK/QTsMgIjV432gFuUpyIa7PytHKFxKisB1OQotf7nBlsoB0Pxh4lJ8jIq5ClObN+WsUY1vKcreDuJKsUsLcz20DqHqSct8eaTCvuv4KL4RnQQG80tA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=AnPzfyrn; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="AnPzfyrn" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 4AC551A1730; Wed, 29 Oct 2025 09:39:38 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 215C0606E8; Wed, 29 Oct 2025 09:39:38 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1C514117F19DC; Wed, 29 Oct 2025 10:39:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1761730777; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=LcbzbbFlItjrhGLz15qb3R8NFa0q0DWjO/2UGxU62ww=; b=AnPzfyrnVBgV0R7LaWb+IPN73q/msOqJwyeCtr9uhqnaIBMYxeF4Cd+y3cVxrH0t9IeScX 2GakTgMLe+zy0QFWuBjNyNV6ZZzOmSdpz8x7TXo/xfxuse+y0JITlMRb9w4LAPK2CYjFuh YrIITgAKsjDV3ks9h5xI8vqm4YiHDqfpKNQ/UDb4XkFlea9aRNcsdMWFoZLaMYFzfKaOIe 30PO3JYx47S0duhEDAvRVEsUOoNb+YeotSL01Pq6yAE8wF7hso6uBprArw2W1xuExB5zeP 6L0WmMaRKiVUkrLh+t63Dywb7IWrrv0+gZTIuvXZ8YkVrda7TaDqqk9AUBSKxA== From: Herve Codina To: David Rhodes , Richard Fitzgerald , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Alexander Sverdlin , Nikita Shubin , Axel Lin , Brian Austin Cc: linux-sound@vger.kernel.org, patches@opensource.cirrus.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina , Krzysztof Kozlowski Subject: [PATCH v2 3/4] ASoC: dt-bindings: cirrus,cs4271: Document mclk clock Date: Wed, 29 Oct 2025 10:39:19 +0100 Message-ID: <20251029093921.624088-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251029093921.624088-1-herve.codina@bootlin.com> References: <20251029093921.624088-1-herve.codina@bootlin.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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The Cirrus CS4271 codec can use an external clock as an input Master Clock. When no crystal is used, the CS4271 component considers its MCLK pin as an input pin and expects the external clock connected to provide the Master Clock. This clock is not documented in the binding. Add the missing clock. Signed-off-by: Herve Codina Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/sound/cirrus,cs4271.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/cirrus,cs4271.yaml b/D= ocumentation/devicetree/bindings/sound/cirrus,cs4271.yaml index 68fbf5cc208f..d286eb169915 100644 --- a/Documentation/devicetree/bindings/sound/cirrus,cs4271.yaml +++ b/Documentation/devicetree/bindings/sound/cirrus,cs4271.yaml @@ -25,6 +25,16 @@ properties: reg: maxItems: 1 =20 + clocks: + items: + - description: + Master clock connected to the MCLK pin if MCLK is an input (i.e.= no + crystal used). + + clock-names: + items: + - const: mclk + spi-cpha: true =20 spi-cpol: true --=20 2.51.0 From nobody Sun Dec 14 18:05:54 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D48BE3328FF for ; Wed, 29 Oct 2025 09:39:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761730783; cv=none; b=tscAh1aTd857XzPySTxJk1HT4iIYWpOJAVv4wqD8VtqevUDi+1vDGdpL/pD4uXrpQPCAsRSTPm2nb0MvwsqvxKuH15HPRJ7R/qZXRrI57iyfeg3Ct+qwegpEf6iqu8QQ4jHW8OYRc3X5JOTZG1hAXaBRT+W7p51Iru86xa4yOws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761730783; c=relaxed/simple; bh=9Jrp+ehv1bHsY53MY3h58OEcHjCmI5PtpCsDcMmBsMo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yj3YFidBt/dhj64ks2iwt0nxvdSeEAVRxmO7I+bZcqRDhd1ldgEM9wqBR7eWfcOm6rmpIgzKfYQide/X1HRSyYb9nk+6rQUQ6HGo2yPuDgGM1s/wXQAvyv163//1ZTdef/SBHAgA0W1NvBhF7fX9Bd9NNdk2FaTFTU3OPHkQUfE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=McJClldz; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="McJClldz" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 8BFCA4E413C6; Wed, 29 Oct 2025 09:39:40 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 60D4B606E8; Wed, 29 Oct 2025 09:39:40 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id BE099117F19E1; Wed, 29 Oct 2025 10:39:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1761730779; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=cag2UQaMgFonyUk6auPnw8wxwz30sT+vgy2pDfTh9FE=; b=McJClldzrIeRFKB4lV5B+LrsznjEJVBrhnFiYKfRM/oF0P+2JHq4H5AU1C3vQRIZKH/+m0 zdpgbyD5+rxfmQLC7ag4iUh/+wi+MH8hUgvlx2evyb546mf6kP28pTmknpX0C3OX9y10eA OfykYcrXqc97WrBipy16emLqhOS3jmqh/Ds6N63k02x7KzcS8euA44ZTfZ64OPXf+XU7E3 iVFebs5g2Ap6JWxY8KkVFHX9B3v0E4Zwa4pr+Kj+Qj9OCcvrDAUM1YzkPkYlrN1Bp3A6vL NgdmGyXHACqDjhn+czoywIA5c8R6NR5TRoktWagR9ifEtxddB8hfW+1FW79C+Q== From: Herve Codina To: David Rhodes , Richard Fitzgerald , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Alexander Sverdlin , Nikita Shubin , Axel Lin , Brian Austin Cc: linux-sound@vger.kernel.org, patches@opensource.cirrus.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Herve Codina Subject: [PATCH v2 4/4] ASoC: cs4271: Add support for the external mclk Date: Wed, 29 Oct 2025 10:39:20 +0100 Message-ID: <20251029093921.624088-5-herve.codina@bootlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251029093921.624088-1-herve.codina@bootlin.com> References: <20251029093921.624088-1-herve.codina@bootlin.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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The mclk (master clock) of the cs4271 codec can be an input clock. In this case the connected clock needs to be enabled outside of any audio stream. Indeed, this clock is needed for i2c communication. Add support of this clock and enable it before the first i2c transfer. Signed-off-by: Herve Codina Reviewed-by: Alexander Sverdlin --- sound/soc/codecs/cs4271.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c index a9d333e6c723..b8a50b9001e1 100644 --- a/sound/soc/codecs/cs4271.c +++ b/sound/soc/codecs/cs4271.c @@ -10,6 +10,7 @@ * DAPM support not implemented. */ =20 +#include #include #include #include @@ -163,6 +164,7 @@ struct cs4271_private { /* enable soft reset workaround */ bool enable_soft_reset; struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; + struct clk *clk; }; =20 static const struct snd_soc_dapm_widget cs4271_dapm_widgets[] =3D { @@ -505,6 +507,7 @@ static int cs4271_soc_suspend(struct snd_soc_component = *component) return ret; =20 regcache_mark_dirty(cs4271->regmap); + clk_disable_unprepare(cs4271->clk); regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies); =20 return 0; @@ -522,6 +525,12 @@ static int cs4271_soc_resume(struct snd_soc_component = *component) return ret; } =20 + ret =3D clk_prepare_enable(cs4271->clk); + if (ret) { + dev_err(component->dev, "Failed to enable clk: %d\n", ret); + return ret; + } + /* Do a proper reset after power up */ cs4271_reset(component); =20 @@ -567,22 +576,29 @@ static int cs4271_component_probe(struct snd_soc_comp= onent *component) cs4271->enable_soft_reset =3D cs4271plat->enable_soft_reset; } =20 + ret =3D clk_prepare_enable(cs4271->clk); + if (ret) { + dev_err(component->dev, "Failed to enable clk: %d\n", ret); + goto err_disable_regulators; + } + /* Reset codec */ cs4271_reset(component); =20 ret =3D regcache_sync(cs4271->regmap); if (ret < 0) - goto err_disable_regulators; + goto err_disable_clk; =20 ret =3D regmap_update_bits(cs4271->regmap, CS4271_MODE2, CS4271_MODE2_PDN | CS4271_MODE2_CPEN, CS4271_MODE2_PDN | CS4271_MODE2_CPEN); if (ret < 0) - goto err_disable_regulators; + goto err_disable_clk; ret =3D regmap_update_bits(cs4271->regmap, CS4271_MODE2, CS4271_MODE2_PDN, 0); if (ret < 0) - goto err_disable_regulators; + goto err_disable_clk; + /* Power-up sequence requires 85 uS */ udelay(85); =20 @@ -593,6 +609,8 @@ static int cs4271_component_probe(struct snd_soc_compon= ent *component) =20 return 0; =20 +err_disable_clk: + clk_disable_unprepare(cs4271->clk); err_disable_regulators: regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies); return ret; @@ -607,6 +625,7 @@ static void cs4271_component_remove(struct snd_soc_comp= onent *component) =20 regcache_mark_dirty(cs4271->regmap); regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies); + clk_disable_unprepare(cs4271->clk); }; =20 static const struct snd_soc_component_driver soc_component_dev_cs4271 =3D { @@ -641,6 +660,10 @@ static int cs4271_common_probe(struct device *dev, "error retrieving RESET GPIO\n"); gpiod_set_consumer_name(cs4271->reset, "CS4271 Reset"); =20 + cs4271->clk =3D devm_clk_get_optional(dev, "mclk"); + if (IS_ERR(cs4271->clk)) + return dev_err_probe(dev, PTR_ERR(cs4271->clk), "Failed to get mclk\n"); + for (i =3D 0; i < ARRAY_SIZE(supply_names); i++) cs4271->supplies[i].supply =3D supply_names[i]; =20 --=20 2.51.0