From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Peng Fan <peng.fan@nxp.com>, Linus Walleij <linusw@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Peter Ujfalusi <peter.ujfalusi@gmail.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org
Subject: [PATCH 1/2] ASoC: codecs: twl4030: fix external mute GPIO lookup
Date: Thu, 22 Oct 2026 13:29:46 -0700 [thread overview]
Message-ID: <20261022-twl4030-extmute-v1-1-3d2dbe260df9@gmail.com> (raw)
In-Reply-To: <20261022-twl4030-extmute-v1-0-3d2dbe260df9@gmail.com>
The twl4030-codec platform device instantiated by the twl4030-audio MFD
core does not have its own of_node or fwnode assigned; its device tree
properties reside in the "codec" child node of the parent MFD device
node.
Because of this, devm_gpiod_get_optional() called on the codec device
never locates the external mute GPIO. Furthermore, previous board param
handling only marked external mute active when the legacy
"ti,hs_extmute_gpio" property was present, ignoring the standard
"ti,hs_extmute-gpios" property when "ti,hs_extmute" was absent, and set
hs_extmute even if GPIO acquisition subsequently failed.
Switch to fwnode APIs to parse board properties directly inside
twl4030_get_board_params(), fold the helper function into it, and
acquire the GPIO descriptor directly from the "codec" child firmware
node using devm_fwnode_gpiod_get_optional() with the "ti,hs_extmute"
connection ID, removing the redundant legacy property check.
Fixes: 178c169a30b0 ("ASoC: codec: twl4030: Convert to GPIO descriptors")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
sound/soc/codecs/twl4030.c | 108 +++++++++++++++++++++++----------------------
1 file changed, 55 insertions(+), 53 deletions(-)
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 7117af5a1a56..9541c8a5a24e 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -6,6 +6,7 @@
*/
#include <linux/delay.h>
+#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/init.h>
@@ -13,9 +14,9 @@
#include <linux/mfd/twl4030-audio.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
-#include <linux/of.h>
#include <linux/pm.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/initval.h>
@@ -198,41 +199,53 @@ static void twl4030_codec_enable(struct snd_soc_component *component, int enable
udelay(10);
}
-static void
-twl4030_get_board_param_values(struct twl4030_board_params *board_params,
- struct device_node *node)
+static struct twl4030_board_params *twl4030_get_board_params(struct device *dev)
{
- of_property_read_u32(node, "ti,digimic_delay", &board_params->digimic_delay);
- of_property_read_u32(node, "ti,ramp_delay_value", &board_params->ramp_delay_value);
- of_property_read_u32(node, "ti,offset_cncl_path", &board_params->offset_cncl_path);
- board_params->hs_extmute = of_property_read_bool(node, "ti,hs_extmute");
+ struct twl4030_board_params *params;
+ int error;
- if (of_property_present(node, "ti,hs_extmute_gpio"))
- board_params->hs_extmute = 1;
-}
+ struct fwnode_handle *codec_node __free(fwnode_handle) =
+ device_get_named_child_node(dev->parent, "codec");
+ if (!codec_node)
+ return NULL;
-static struct twl4030_board_params*
-twl4030_get_board_params(struct device *dev)
-{
- struct twl4030_board_params *board_params = NULL;
- struct device_node *twl4030_codec_node = NULL;
-
- twl4030_codec_node = of_get_child_by_name(dev->parent->of_node,
- "codec");
-
- if (twl4030_codec_node) {
- board_params = devm_kzalloc(dev,
- sizeof(struct twl4030_board_params),
- GFP_KERNEL);
- if (!board_params) {
- of_node_put(twl4030_codec_node);
- return ERR_PTR(-ENOMEM);
- }
- twl4030_get_board_param_values(board_params, twl4030_codec_node);
- of_node_put(twl4030_codec_node);
+ params = devm_kzalloc(dev, sizeof(*params), GFP_KERNEL);
+ if (!params)
+ return ERR_PTR(-ENOMEM);
+
+ fwnode_property_read_u32(codec_node, "ti,digimic_delay",
+ ¶ms->digimic_delay);
+ fwnode_property_read_u32(codec_node, "ti,ramp_delay_value",
+ ¶ms->ramp_delay_value);
+ fwnode_property_read_u32(codec_node, "ti,offset_cncl_path",
+ ¶ms->offset_cncl_path);
+
+ /*
+ * Headset external mute can be controlled either via TWL4030's
+ * dedicated GPIO6/EXTMUTE pin (enabled by the boolean "ti,hs_extmute"
+ * property) or via a separate GPIO line ("ti,hs_extmute-gpios" or
+ * legacy "ti,hs_extmute_gpio"), which implies external mute is active.
+ */
+ params->hs_extmute = fwnode_property_read_bool(codec_node, "ti,hs_extmute");
+
+ /*
+ * This will attempt to parse "ti,hs_extmute-gpios" or
+ * "ti,hs_extmute_gpio".
+ */
+ params->hs_extmute_gpio = devm_fwnode_gpiod_get_optional(dev, codec_node,
+ "ti,hs_extmute",
+ GPIOD_OUT_LOW,
+ "hs_extmute");
+ error = PTR_ERR_OR_ZERO(params->hs_extmute_gpio);
+ if (error) {
+ dev_err_probe(dev, error, "Failed to get hs_extmute GPIO\n");
+ return ERR_PTR(error);
}
- return board_params;
+ if (params->hs_extmute_gpio)
+ params->hs_extmute = 1;
+
+ return params;
}
static int twl4030_get_hw_params(struct device *dev,
@@ -244,30 +257,19 @@ static int twl4030_get_hw_params(struct device *dev,
if (IS_ERR(board_params))
return PTR_ERR(board_params);
- if (board_params && board_params->hs_extmute) {
- board_params->hs_extmute_gpio = devm_gpiod_get_optional(dev,
- "ti,hs_extmute",
- GPIOD_OUT_LOW);
- if (IS_ERR(board_params->hs_extmute_gpio))
- return dev_err_probe(dev,
- PTR_ERR(board_params->hs_extmute_gpio),
- "Failed to get hs_extmute GPIO\n");
-
- if (board_params->hs_extmute_gpio) {
- gpiod_set_consumer_name(board_params->hs_extmute_gpio, "hs_extmute");
- } else {
- u8 pin_mux;
+ if (board_params && board_params->hs_extmute &&
+ !board_params->hs_extmute_gpio) {
+ u8 pin_mux;
- dev_info(dev, "use TWL4030 GPIO6\n");
+ dev_info(dev, "use TWL4030 GPIO6\n");
- /* Set TWL4030 GPIO6 as EXTMUTE signal */
- twl_i2c_read_u8(TWL4030_MODULE_INTBR, &pin_mux,
- TWL4030_PMBR1_REG);
- pin_mux &= ~TWL4030_GPIO6_PWM0_MUTE(0x03);
- pin_mux |= TWL4030_GPIO6_PWM0_MUTE(0x02);
- twl_i2c_write_u8(TWL4030_MODULE_INTBR, pin_mux,
- TWL4030_PMBR1_REG);
- }
+ /* Set TWL4030 GPIO6 as EXTMUTE signal */
+ twl_i2c_read_u8(TWL4030_MODULE_INTBR, &pin_mux,
+ TWL4030_PMBR1_REG);
+ pin_mux &= ~TWL4030_GPIO6_PWM0_MUTE(0x03);
+ pin_mux |= TWL4030_GPIO6_PWM0_MUTE(0x02);
+ twl_i2c_write_u8(TWL4030_MODULE_INTBR, pin_mux,
+ TWL4030_PMBR1_REG);
}
twl4030->board_params = board_params;
--
2.56.0.257.gf7497c7d27-goog
next prev parent reply other threads:[~2026-10-22 20:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 20:29 [PATCH 0/2] ASoC: codecs: twl4030: external mute GPIO lookup fix and binding update Dmitry Torokhov
2026-10-22 20:29 ` Dmitry Torokhov [this message]
2026-10-22 20:29 ` [PATCH 2/2] dt-bindings: mfd: twl4030-audio: document preferred name for external mute Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261022-twl4030-extmute-v1-1-3d2dbe260df9@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linusw@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@gmail.com \
--cc=robh@kernel.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®