* [PATCH] pinctrl: cs42l43: Add GPIO controlled mic/spk mute LEDs
@ 2026-11-10 14:20 Maciej Strozek
2026-11-11 11:01 ` Charles Keepax
2026-11-25 18:06 ` Linus Walleij
0 siblings, 2 replies; 7+ messages in thread
From: Maciej Strozek @ 2026-11-10 14:20 UTC (permalink / raw)
To: linusw
Cc: brgl, patches, linux-gpio, linux-sound, linux-kernel, Maciej Strozek
Add ability to use cs42l43's GPIOs to drive speaker and microphone mute
LEDs. The LEDs must be described using
01fa-global-mute-led-(spk|mic)-mute-gpio ACPI property, which tells
which of the 3 available cs42l43's GPIOs to use for the respective
function.
Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
---
drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 156 +++++++++++++++++++++++
1 file changed, 156 insertions(+)
diff --git a/drivers/pinctrl/cirrus/pinctrl-cs42l43.c b/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
index 8990fab0446cf..7e4e43783ef14 100644
--- a/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
+++ b/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
@@ -5,11 +5,15 @@
// Copyright (c) 2023 Cirrus Logic, Inc. and
// Cirrus Logic International Semiconductor Ltd.
+#include <linux/acpi.h>
#include <linux/array_size.h>
#include <linux/bits.h>
#include <linux/build_bug.h>
#include <linux/err.h>
+#include <linux/gpio/consumer.h>
#include <linux/gpio/driver.h>
+#include <linux/gpio/machine.h>
+#include <linux/leds.h>
#include <linux/mfd/cs42l43.h>
#include <linux/mfd/cs42l43-regs.h>
#include <linux/module.h>
@@ -29,9 +33,18 @@
#define CS42L43_NUM_GPIOS 3
+struct cs42l43_mute_led {
+ struct led_classdev cdev;
+ struct gpio_desc *gpio;
+ u32 gpio_num;
+};
+
struct cs42l43_pin {
struct gpio_chip gpio_chip;
+ struct cs42l43_mute_led spk_mute_led;
+ struct cs42l43_mute_led mic_mute_led;
+
struct device *dev;
struct regmap *regmap;
bool shutters_locked;
@@ -535,6 +548,143 @@ static void cs42l43_fwnode_put(void *data)
fwnode_handle_put(data);
}
+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
+static int cs42l43_find_mute_gpios(struct cs42l43_pin *priv, struct fwnode_handle *fwnode)
+{
+ struct cs42l43_mute_led *mic = &priv->mic_mute_led;
+ struct cs42l43_mute_led *spk = &priv->spk_mute_led;
+ int ret;
+
+ fwnode_for_each_child_node_scoped(fwnode, child_fwnode) {
+ struct fwnode_handle *ext_fwnode __free(fwnode_handle) =
+ fwnode_get_named_child_node(child_fwnode,
+ "mipi-sdca-function-expansion-subproperties");
+ bool mic_present, spk_present;
+
+ if (!ext_fwnode)
+ continue;
+
+ mic_present = fwnode_property_present(ext_fwnode,
+ "01fa-global-mute-led-mic-mute-gpio");
+ spk_present = fwnode_property_present(ext_fwnode,
+ "01fa-global-mute-led-spk-mute-gpio");
+ if (!mic_present && !spk_present)
+ continue;
+
+ if (mic_present) {
+ ret = fwnode_property_read_u32(ext_fwnode,
+ "01fa-global-mute-led-mic-mute-gpio",
+ &mic->gpio_num);
+ if (ret)
+ return dev_err_probe(priv->dev, ret,
+ "Invalid mic-mute LED GPIO property\n");
+ }
+
+ if (spk_present) {
+ ret = fwnode_property_read_u32(ext_fwnode,
+ "01fa-global-mute-led-spk-mute-gpio",
+ &spk->gpio_num);
+ if (ret)
+ return dev_err_probe(priv->dev, ret,
+ "Invalid spk-mute LED GPIO property\n");
+ }
+
+ return 0;
+ }
+
+ return 0;
+}
+
+static int cs42l43_mute_led_set(struct led_classdev *cdev, enum led_brightness value)
+{
+ struct cs42l43_mute_led *led = container_of(cdev, struct cs42l43_mute_led, cdev);
+
+ return gpiod_set_value_cansleep(led->gpio, value != LED_OFF);
+}
+
+static void cs42l43_mute_led_gpio_free(void *data)
+{
+ struct cs42l43_mute_led *led = data;
+
+ gpiochip_free_own_desc(led->gpio);
+}
+
+static int cs42l43_mute_led_register(struct cs42l43_pin *priv,
+ struct cs42l43_mute_led *led,
+ const char *function, const char *trigger)
+{
+ int ret;
+
+ led->gpio = gpiochip_request_own_desc(&priv->gpio_chip, led->gpio_num - 1,
+ trigger, GPIO_ACTIVE_HIGH,
+ GPIOD_OUT_LOW);
+ if (IS_ERR(led->gpio))
+ return dev_err_probe(priv->dev, PTR_ERR(led->gpio),
+ "Failed to request GPIO%u for %s LED\n",
+ led->gpio_num, trigger);
+
+ ret = devm_add_action_or_reset(priv->dev, cs42l43_mute_led_gpio_free, led);
+ if (ret)
+ return ret;
+
+ led->cdev.name = devm_kasprintf(priv->dev, GFP_KERNEL, "%s::%s",
+ dev_name(priv->dev), function);
+ if (!led->cdev.name)
+ return -ENOMEM;
+
+ led->cdev.default_trigger = trigger;
+ led->cdev.brightness_set_blocking = cs42l43_mute_led_set;
+ led->cdev.max_brightness = 1;
+
+ ret = devm_led_classdev_register(priv->dev, &led->cdev);
+ if (ret)
+ return dev_err_probe(priv->dev, ret, "Failed to register %s LED\n",
+ trigger);
+
+ dev_dbg(priv->dev, "%s LED uses codec GPIO%u\n", trigger, led->gpio_num);
+
+ return 0;
+}
+
+static int cs42l43_mute_leds_register(struct cs42l43_pin *priv,
+ struct fwnode_handle *fwnode)
+{
+ struct cs42l43_mute_led *mic = &priv->mic_mute_led;
+ struct cs42l43_mute_led *spk = &priv->spk_mute_led;
+ int ret;
+
+ if (!is_acpi_node(fwnode))
+ return 0;
+
+ ret = cs42l43_find_mute_gpios(priv, fwnode);
+ if (ret)
+ return ret;
+
+ if (mic->gpio_num > CS42L43_NUM_GPIOS ||
+ spk->gpio_num > CS42L43_NUM_GPIOS ||
+ (mic->gpio_num && mic->gpio_num == spk->gpio_num))
+ return dev_err_probe(priv->dev, -EINVAL,
+ "Invalid or shared mute LED GPIOs: mic=%u, spk=%u\n",
+ mic->gpio_num, spk->gpio_num);
+
+ if (mic->gpio_num) {
+ ret = cs42l43_mute_led_register(priv, mic, LED_FUNCTION_MICMUTE,
+ "audio-micmute");
+ if (ret)
+ return ret;
+ }
+
+ if (spk->gpio_num) {
+ ret = cs42l43_mute_led_register(priv, spk, LED_FUNCTION_MUTE,
+ "audio-mute");
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+#endif
+
static int cs42l43_pin_probe(struct platform_device *pdev)
{
struct cs42l43 *cs42l43 = dev_get_drvdata(pdev->dev.parent);
@@ -598,6 +748,12 @@ static int cs42l43_pin_probe(struct platform_device *pdev)
return dev_err_probe(priv->dev, ret,
"Failed to register gpiochip\n");
+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
+ ret = cs42l43_mute_leds_register(priv, dev_fwnode(cs42l43->dev));
+ if (ret)
+ return ret;
+#endif
+
return 0;
}
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] pinctrl: cs42l43: Add GPIO controlled mic/spk mute LEDs
2026-11-10 14:20 [PATCH] pinctrl: cs42l43: Add GPIO controlled mic/spk mute LEDs Maciej Strozek
@ 2026-11-11 11:01 ` Charles Keepax
2026-11-25 18:06 ` Linus Walleij
1 sibling, 0 replies; 7+ messages in thread
From: Charles Keepax @ 2026-11-11 11:01 UTC (permalink / raw)
To: Maciej Strozek
Cc: linusw, brgl, patches, linux-gpio, linux-sound, linux-kernel
On Tue, Nov 10, 2026 at 02:20:58PM +0000, Maciej Strozek wrote:
> Add ability to use cs42l43's GPIOs to drive speaker and microphone mute
> LEDs. The LEDs must be described using
> 01fa-global-mute-led-(spk|mic)-mute-gpio ACPI property, which tells
> which of the 3 available cs42l43's GPIOs to use for the respective
> function.
>
> Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
> ---
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Thanks,
Charles
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] pinctrl: cs42l43: Add GPIO controlled mic/spk mute LEDs
2026-11-10 14:20 [PATCH] pinctrl: cs42l43: Add GPIO controlled mic/spk mute LEDs Maciej Strozek
2026-11-11 11:01 ` Charles Keepax
@ 2026-11-25 18:06 ` Linus Walleij
2026-11-26 7:35 ` Mika Westerberg
1 sibling, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2026-11-25 18:06 UTC (permalink / raw)
To: Maciej Strozek, Andy Shevchenko, Mika Westerberg
Cc: brgl, patches, linux-gpio, linux-sound, linux-kernel
Top posting to loop in more people.
(Andy & Mika)
On Tue, Nov 10, 2026 at 3:21 PM Maciej Strozek
<mstrozek@opensource.cirrus.com> wrote:
> Add ability to use cs42l43's GPIOs to drive speaker and microphone mute
> LEDs. The LEDs must be described using
> 01fa-global-mute-led-(spk|mic)-mute-gpio ACPI property, which tells
> which of the 3 available cs42l43's GPIOs to use for the respective
> function.
>
> Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
ACPI property, so Andy and Mika need to decide if this is a reasonable
way to go about this issue.
> ---
> drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 156 +++++++++++++++++++++++
> 1 file changed, 156 insertions(+)
>
> diff --git a/drivers/pinctrl/cirrus/pinctrl-cs42l43.c b/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
> index 8990fab0446cf..7e4e43783ef14 100644
> --- a/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
> +++ b/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
> @@ -5,11 +5,15 @@
> // Copyright (c) 2023 Cirrus Logic, Inc. and
> // Cirrus Logic International Semiconductor Ltd.
>
> +#include <linux/acpi.h>
> #include <linux/array_size.h>
> #include <linux/bits.h>
> #include <linux/build_bug.h>
> #include <linux/err.h>
> +#include <linux/gpio/consumer.h>
> #include <linux/gpio/driver.h>
> +#include <linux/gpio/machine.h>
> +#include <linux/leds.h>
> #include <linux/mfd/cs42l43.h>
> #include <linux/mfd/cs42l43-regs.h>
> #include <linux/module.h>
> @@ -29,9 +33,18 @@
>
> #define CS42L43_NUM_GPIOS 3
>
> +struct cs42l43_mute_led {
> + struct led_classdev cdev;
> + struct gpio_desc *gpio;
> + u32 gpio_num;
> +};
> +
> struct cs42l43_pin {
> struct gpio_chip gpio_chip;
>
> + struct cs42l43_mute_led spk_mute_led;
> + struct cs42l43_mute_led mic_mute_led;
> +
> struct device *dev;
> struct regmap *regmap;
> bool shutters_locked;
> @@ -535,6 +548,143 @@ static void cs42l43_fwnode_put(void *data)
> fwnode_handle_put(data);
> }
>
> +#if IS_REACHABLE(CONFIG_LEDS_CLASS)
> +static int cs42l43_find_mute_gpios(struct cs42l43_pin *priv, struct fwnode_handle *fwnode)
> +{
> + struct cs42l43_mute_led *mic = &priv->mic_mute_led;
> + struct cs42l43_mute_led *spk = &priv->spk_mute_led;
> + int ret;
> +
> + fwnode_for_each_child_node_scoped(fwnode, child_fwnode) {
> + struct fwnode_handle *ext_fwnode __free(fwnode_handle) =
> + fwnode_get_named_child_node(child_fwnode,
> + "mipi-sdca-function-expansion-subproperties");
> + bool mic_present, spk_present;
> +
> + if (!ext_fwnode)
> + continue;
> +
> + mic_present = fwnode_property_present(ext_fwnode,
> + "01fa-global-mute-led-mic-mute-gpio");
> + spk_present = fwnode_property_present(ext_fwnode,
> + "01fa-global-mute-led-spk-mute-gpio");
> + if (!mic_present && !spk_present)
> + continue;
> +
> + if (mic_present) {
> + ret = fwnode_property_read_u32(ext_fwnode,
> + "01fa-global-mute-led-mic-mute-gpio",
> + &mic->gpio_num);
> + if (ret)
> + return dev_err_probe(priv->dev, ret,
> + "Invalid mic-mute LED GPIO property\n");
> + }
> +
> + if (spk_present) {
> + ret = fwnode_property_read_u32(ext_fwnode,
> + "01fa-global-mute-led-spk-mute-gpio",
> + &spk->gpio_num);
> + if (ret)
> + return dev_err_probe(priv->dev, ret,
> + "Invalid spk-mute LED GPIO property\n");
> + }
> +
> + return 0;
> + }
> +
> + return 0;
> +}
> +
> +static int cs42l43_mute_led_set(struct led_classdev *cdev, enum led_brightness value)
> +{
> + struct cs42l43_mute_led *led = container_of(cdev, struct cs42l43_mute_led, cdev);
> +
> + return gpiod_set_value_cansleep(led->gpio, value != LED_OFF);
> +}
> +
> +static void cs42l43_mute_led_gpio_free(void *data)
> +{
> + struct cs42l43_mute_led *led = data;
> +
> + gpiochip_free_own_desc(led->gpio);
> +}
> +
> +static int cs42l43_mute_led_register(struct cs42l43_pin *priv,
> + struct cs42l43_mute_led *led,
> + const char *function, const char *trigger)
> +{
> + int ret;
> +
> + led->gpio = gpiochip_request_own_desc(&priv->gpio_chip, led->gpio_num - 1,
> + trigger, GPIO_ACTIVE_HIGH,
> + GPIOD_OUT_LOW);
> + if (IS_ERR(led->gpio))
> + return dev_err_probe(priv->dev, PTR_ERR(led->gpio),
> + "Failed to request GPIO%u for %s LED\n",
> + led->gpio_num, trigger);
> +
> + ret = devm_add_action_or_reset(priv->dev, cs42l43_mute_led_gpio_free, led);
> + if (ret)
> + return ret;
> +
> + led->cdev.name = devm_kasprintf(priv->dev, GFP_KERNEL, "%s::%s",
> + dev_name(priv->dev), function);
> + if (!led->cdev.name)
> + return -ENOMEM;
> +
> + led->cdev.default_trigger = trigger;
> + led->cdev.brightness_set_blocking = cs42l43_mute_led_set;
> + led->cdev.max_brightness = 1;
> +
> + ret = devm_led_classdev_register(priv->dev, &led->cdev);
> + if (ret)
> + return dev_err_probe(priv->dev, ret, "Failed to register %s LED\n",
> + trigger);
> +
> + dev_dbg(priv->dev, "%s LED uses codec GPIO%u\n", trigger, led->gpio_num);
> +
> + return 0;
> +}
> +
> +static int cs42l43_mute_leds_register(struct cs42l43_pin *priv,
> + struct fwnode_handle *fwnode)
> +{
> + struct cs42l43_mute_led *mic = &priv->mic_mute_led;
> + struct cs42l43_mute_led *spk = &priv->spk_mute_led;
> + int ret;
> +
> + if (!is_acpi_node(fwnode))
> + return 0;
> +
> + ret = cs42l43_find_mute_gpios(priv, fwnode);
> + if (ret)
> + return ret;
> +
> + if (mic->gpio_num > CS42L43_NUM_GPIOS ||
> + spk->gpio_num > CS42L43_NUM_GPIOS ||
> + (mic->gpio_num && mic->gpio_num == spk->gpio_num))
> + return dev_err_probe(priv->dev, -EINVAL,
> + "Invalid or shared mute LED GPIOs: mic=%u, spk=%u\n",
> + mic->gpio_num, spk->gpio_num);
> +
> + if (mic->gpio_num) {
> + ret = cs42l43_mute_led_register(priv, mic, LED_FUNCTION_MICMUTE,
> + "audio-micmute");
> + if (ret)
> + return ret;
> + }
> +
> + if (spk->gpio_num) {
> + ret = cs42l43_mute_led_register(priv, spk, LED_FUNCTION_MUTE,
> + "audio-mute");
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
> +#endif
> +
> static int cs42l43_pin_probe(struct platform_device *pdev)
> {
> struct cs42l43 *cs42l43 = dev_get_drvdata(pdev->dev.parent);
> @@ -598,6 +748,12 @@ static int cs42l43_pin_probe(struct platform_device *pdev)
> return dev_err_probe(priv->dev, ret,
> "Failed to register gpiochip\n");
>
> +#if IS_REACHABLE(CONFIG_LEDS_CLASS)
> + ret = cs42l43_mute_leds_register(priv, dev_fwnode(cs42l43->dev));
> + if (ret)
> + return ret;
> +#endif
> +
> return 0;
> }
>
> --
> 2.47.3
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] pinctrl: cs42l43: Add GPIO controlled mic/spk mute LEDs
2026-11-25 18:06 ` Linus Walleij
@ 2026-11-26 7:35 ` Mika Westerberg
2026-11-26 9:08 ` Maciej Strozek
2026-11-26 14:09 ` Andy Shevchenko
0 siblings, 2 replies; 7+ messages in thread
From: Mika Westerberg @ 2026-11-26 7:35 UTC (permalink / raw)
To: Linus Walleij
Cc: Maciej Strozek, Andy Shevchenko, brgl, patches, linux-gpio,
linux-sound, linux-kernel
Hi,
On Wed, Nov 25, 2026 at 07:06:24PM +0100, Linus Walleij wrote:
> Top posting to loop in more people.
>
> (Andy & Mika)
>
> On Tue, Nov 10, 2026 at 3:21 PM Maciej Strozek
> <mstrozek@opensource.cirrus.com> wrote:
>
> > Add ability to use cs42l43's GPIOs to drive speaker and microphone mute
> > LEDs. The LEDs must be described using
> > 01fa-global-mute-led-(spk|mic)-mute-gpio ACPI property, which tells
> > which of the 3 available cs42l43's GPIOs to use for the respective
> > function.
> >
> > Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
>
> ACPI property, so Andy and Mika need to decide if this is a reasonable
> way to go about this issue.
I think the properties themselves are already "known" so that should be
okay (but let's see if Andy has any comments), there is though a tiny
observation below.
> > ---
> > drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 156 +++++++++++++++++++++++
> > 1 file changed, 156 insertions(+)
> >
> > diff --git a/drivers/pinctrl/cirrus/pinctrl-cs42l43.c b/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
> > index 8990fab0446cf..7e4e43783ef14 100644
> > --- a/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
> > +++ b/drivers/pinctrl/cirrus/pinctrl-cs42l43.c
> > @@ -5,11 +5,15 @@
> > // Copyright (c) 2023 Cirrus Logic, Inc. and
> > // Cirrus Logic International Semiconductor Ltd.
> >
> > +#include <linux/acpi.h>
> > #include <linux/array_size.h>
> > #include <linux/bits.h>
> > #include <linux/build_bug.h>
> > #include <linux/err.h>
> > +#include <linux/gpio/consumer.h>
> > #include <linux/gpio/driver.h>
> > +#include <linux/gpio/machine.h>
> > +#include <linux/leds.h>
> > #include <linux/mfd/cs42l43.h>
> > #include <linux/mfd/cs42l43-regs.h>
> > #include <linux/module.h>
> > @@ -29,9 +33,18 @@
> >
> > #define CS42L43_NUM_GPIOS 3
> >
> > +struct cs42l43_mute_led {
> > + struct led_classdev cdev;
> > + struct gpio_desc *gpio;
> > + u32 gpio_num;
> > +};
> > +
> > struct cs42l43_pin {
> > struct gpio_chip gpio_chip;
> >
> > + struct cs42l43_mute_led spk_mute_led;
> > + struct cs42l43_mute_led mic_mute_led;
> > +
> > struct device *dev;
> > struct regmap *regmap;
> > bool shutters_locked;
> > @@ -535,6 +548,143 @@ static void cs42l43_fwnode_put(void *data)
> > fwnode_handle_put(data);
> > }
> >
> > +#if IS_REACHABLE(CONFIG_LEDS_CLASS)
> > +static int cs42l43_find_mute_gpios(struct cs42l43_pin *priv, struct fwnode_handle *fwnode)
> > +{
> > + struct cs42l43_mute_led *mic = &priv->mic_mute_led;
> > + struct cs42l43_mute_led *spk = &priv->spk_mute_led;
> > + int ret;
> > +
> > + fwnode_for_each_child_node_scoped(fwnode, child_fwnode) {
> > + struct fwnode_handle *ext_fwnode __free(fwnode_handle) =
> > + fwnode_get_named_child_node(child_fwnode,
> > + "mipi-sdca-function-expansion-subproperties");
> > + bool mic_present, spk_present;
> > +
> > + if (!ext_fwnode)
> > + continue;
> > +
> > + mic_present = fwnode_property_present(ext_fwnode,
> > + "01fa-global-mute-led-mic-mute-gpio");
> > + spk_present = fwnode_property_present(ext_fwnode,
> > + "01fa-global-mute-led-spk-mute-gpio");
> > + if (!mic_present && !spk_present)
> > + continue;
> > +
> > + if (mic_present) {
> > + ret = fwnode_property_read_u32(ext_fwnode,
> > + "01fa-global-mute-led-mic-mute-gpio",
> > + &mic->gpio_num);
> > + if (ret)
> > + return dev_err_probe(priv->dev, ret,
> > + "Invalid mic-mute LED GPIO property\n");
> > + }
> > +
> > + if (spk_present) {
> > + ret = fwnode_property_read_u32(ext_fwnode,
> > + "01fa-global-mute-led-spk-mute-gpio",
> > + &spk->gpio_num);
> > + if (ret)
> > + return dev_err_probe(priv->dev, ret,
> > + "Invalid spk-mute LED GPIO property\n");
> > + }
> > +
> > + return 0;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +static int cs42l43_mute_led_set(struct led_classdev *cdev, enum led_brightness value)
> > +{
> > + struct cs42l43_mute_led *led = container_of(cdev, struct cs42l43_mute_led, cdev);
> > +
> > + return gpiod_set_value_cansleep(led->gpio, value != LED_OFF);
> > +}
> > +
> > +static void cs42l43_mute_led_gpio_free(void *data)
> > +{
> > + struct cs42l43_mute_led *led = data;
> > +
> > + gpiochip_free_own_desc(led->gpio);
> > +}
> > +
> > +static int cs42l43_mute_led_register(struct cs42l43_pin *priv,
> > + struct cs42l43_mute_led *led,
> > + const char *function, const char *trigger)
> > +{
> > + int ret;
> > +
> > + led->gpio = gpiochip_request_own_desc(&priv->gpio_chip, led->gpio_num - 1,
> > + trigger, GPIO_ACTIVE_HIGH,
> > + GPIOD_OUT_LOW);
> > + if (IS_ERR(led->gpio))
> > + return dev_err_probe(priv->dev, PTR_ERR(led->gpio),
> > + "Failed to request GPIO%u for %s LED\n",
> > + led->gpio_num, trigger);
> > +
> > + ret = devm_add_action_or_reset(priv->dev, cs42l43_mute_led_gpio_free, led);
> > + if (ret)
> > + return ret;
> > +
> > + led->cdev.name = devm_kasprintf(priv->dev, GFP_KERNEL, "%s::%s",
> > + dev_name(priv->dev), function);
> > + if (!led->cdev.name)
> > + return -ENOMEM;
> > +
> > + led->cdev.default_trigger = trigger;
> > + led->cdev.brightness_set_blocking = cs42l43_mute_led_set;
> > + led->cdev.max_brightness = 1;
> > +
> > + ret = devm_led_classdev_register(priv->dev, &led->cdev);
> > + if (ret)
> > + return dev_err_probe(priv->dev, ret, "Failed to register %s LED\n",
> > + trigger);
> > +
> > + dev_dbg(priv->dev, "%s LED uses codec GPIO%u\n", trigger, led->gpio_num);
> > +
> > + return 0;
> > +}
> > +
> > +static int cs42l43_mute_leds_register(struct cs42l43_pin *priv,
> > + struct fwnode_handle *fwnode)
> > +{
> > + struct cs42l43_mute_led *mic = &priv->mic_mute_led;
> > + struct cs42l43_mute_led *spk = &priv->spk_mute_led;
> > + int ret;
> > +
> > + if (!is_acpi_node(fwnode))
> > + return 0;
> > +
> > + ret = cs42l43_find_mute_gpios(priv, fwnode);
> > + if (ret)
> > + return ret;
> > +
> > + if (mic->gpio_num > CS42L43_NUM_GPIOS ||
> > + spk->gpio_num > CS42L43_NUM_GPIOS ||
> > + (mic->gpio_num && mic->gpio_num == spk->gpio_num))
> > + return dev_err_probe(priv->dev, -EINVAL,
> > + "Invalid or shared mute LED GPIOs: mic=%u, spk=%u\n",
> > + mic->gpio_num, spk->gpio_num);
> > +
> > + if (mic->gpio_num) {
> > + ret = cs42l43_mute_led_register(priv, mic, LED_FUNCTION_MICMUTE,
> > + "audio-micmute");
> > + if (ret)
> > + return ret;
> > + }
> > +
> > + if (spk->gpio_num) {
> > + ret = cs42l43_mute_led_register(priv, spk, LED_FUNCTION_MUTE,
> > + "audio-mute");
> > + if (ret)
> > + return ret;
> > + }
> > +
> > + return 0;
> > +}
> > +#endif
If you do this:
#else
static inline int cs42l43_mute_leds_register(struct cs42l43_pin *priv,
struct fwnode_handle *fwnode)
{
return 0;
}
#endif
> > +
> > static int cs42l43_pin_probe(struct platform_device *pdev)
> > {
> > struct cs42l43 *cs42l43 = dev_get_drvdata(pdev->dev.parent);
> > @@ -598,6 +748,12 @@ static int cs42l43_pin_probe(struct platform_device *pdev)
> > return dev_err_probe(priv->dev, ret,
> > "Failed to register gpiochip\n");
> >
> > +#if IS_REACHABLE(CONFIG_LEDS_CLASS)
> > + ret = cs42l43_mute_leds_register(priv, dev_fwnode(cs42l43->dev));
> > + if (ret)
> > + return ret;
> > +#endif
then this reads better:
ret = cs42l43_mute_leds_register(priv, dev_fwnode(cs42l43->dev));
if (ret)
return ret;
> > +
> > return 0;
> > }
> >
> > --
> > 2.47.3
> >
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] pinctrl: cs42l43: Add GPIO controlled mic/spk mute LEDs
2026-11-26 7:35 ` Mika Westerberg
@ 2026-11-26 9:08 ` Maciej Strozek
2026-11-26 14:09 ` Andy Shevchenko
1 sibling, 0 replies; 7+ messages in thread
From: Maciej Strozek @ 2026-11-26 9:08 UTC (permalink / raw)
To: Mika Westerberg, Linus Walleij
Cc: Andy Shevchenko, brgl, patches, linux-gpio, linux-sound, linux-kernel
W dniu czw, 26.11.2026 o godzinie 08∶35 +0100, użytkownik Mika
Westerberg napisał:
> >
> If you do this:
>
> #else
> static inline int cs42l43_mute_leds_register(struct cs42l43_pin
> *priv,
> struct fwnode_handle *fwnode)
> {
> return 0;
> }
> #endif
>
> > > +
> > > static int cs42l43_pin_probe(struct platform_device *pdev)
> > > {
> > > struct cs42l43 *cs42l43 = dev_get_drvdata(pdev-
> > > >dev.parent);
> > > @@ -598,6 +748,12 @@ static int cs42l43_pin_probe(struct
> > > platform_device *pdev)
> > > return dev_err_probe(priv->dev, ret,
> > > "Failed to register
> > > gpiochip\n");
> > >
> > > +#if IS_REACHABLE(CONFIG_LEDS_CLASS)
> > > + ret = cs42l43_mute_leds_register(priv,
> > > dev_fwnode(cs42l43->dev));
> > > + if (ret)
> > > + return ret;
> > > +#endif
>
> then this reads better:
>
> ret = cs42l43_mute_leds_register(priv, dev_fwnode(cs42l43->dev));
> if (ret)
> return ret;
>
> > > +
> > >
Yes, that looks nicer. Can send a v2 with that, but will wait if Andy
has any comments.
--
Regards,
Maciej
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] pinctrl: cs42l43: Add GPIO controlled mic/spk mute LEDs
2026-11-26 7:35 ` Mika Westerberg
2026-11-26 9:08 ` Maciej Strozek
@ 2026-11-26 14:09 ` Andy Shevchenko
2026-11-26 14:54 ` Maciej Strozek
1 sibling, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2026-11-26 14:09 UTC (permalink / raw)
To: Mika Westerberg
Cc: Linus Walleij, Maciej Strozek, Andy Shevchenko, brgl, patches,
linux-gpio, linux-sound, linux-kernel
On Thu, Nov 26, 2026 at 08:35:45AM +0100, Mika Westerberg wrote:
> On Wed, Nov 25, 2026 at 07:06:24PM +0100, Linus Walleij wrote:
> > On Tue, Nov 10, 2026 at 3:21 PM Maciej Strozek
> > <mstrozek@opensource.cirrus.com> wrote:
...
> > > Add ability to use cs42l43's GPIOs to drive speaker and microphone mute
> > > LEDs. The LEDs must be described using
> > > 01fa-global-mute-led-(spk|mic)-mute-gpio ACPI property, which tells
> > > which of the 3 available cs42l43's GPIOs to use for the respective
> > > function.
> > >
> > > Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
> >
> > ACPI property, so Andy and Mika need to decide if this is a reasonable
> > way to go about this issue.
>
> I think the properties themselves are already "known" so that should be
> okay (but let's see if Andy has any comments), there is though a tiny
> observation below.
Yeah, I think it's some kind of vendor/device specific MIPI properties.
Would be nice to know if they are specified somewhere or is it just a vendor
push.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] pinctrl: cs42l43: Add GPIO controlled mic/spk mute LEDs
2026-11-26 14:09 ` Andy Shevchenko
@ 2026-11-26 14:54 ` Maciej Strozek
0 siblings, 0 replies; 7+ messages in thread
From: Maciej Strozek @ 2026-11-26 14:54 UTC (permalink / raw)
To: Andy Shevchenko, Mika Westerberg
Cc: Linus Walleij, Andy Shevchenko, brgl, patches, linux-gpio,
linux-sound, linux-kernel
W dniu czw, 26.11.2026 o godzinie 16∶09 +0200, użytkownik Andy
Shevchenko napisał:
> On Thu, Nov 26, 2026 at 08:35:45AM +0100, Mika Westerberg wrote:
> > On Wed, Nov 25, 2026 at 07:06:24PM +0100, Linus Walleij wrote:
> > > On Tue, Nov 10, 2026 at 3:21 PM Maciej Strozek
> > > <mstrozek@opensource.cirrus.com> wrote:
>
> ...
>
> > > > Add ability to use cs42l43's GPIOs to drive speaker and
> > > > microphone mute
> > > > LEDs. The LEDs must be described using
> > > > 01fa-global-mute-led-(spk|mic)-mute-gpio ACPI property, which
> > > > tells
> > > > which of the 3 available cs42l43's GPIOs to use for the
> > > > respective
> > > > function.
> > > >
> > > > Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
> > >
> > > ACPI property, so Andy and Mika need to decide if this is a
> > > reasonable
> > > way to go about this issue.
> >
> > I think the properties themselves are already "known" so that
> > should be
> > okay (but let's see if Andy has any comments), there is though a
> > tiny
> > observation below.
>
> Yeah, I think it's some kind of vendor/device specific MIPI
> properties.
> Would be nice to know if they are specified somewhere or is it just a
> vendor
> push.
It's only for Cirrus devices (it starts with the '01fa' cirrus vendor
code)
--
Regards,
Maciej
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-26 14:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10 14:20 [PATCH] pinctrl: cs42l43: Add GPIO controlled mic/spk mute LEDs Maciej Strozek
2026-11-11 11:01 ` Charles Keepax
2026-11-25 18:06 ` Linus Walleij
2026-11-26 7:35 ` Mika Westerberg
2026-11-26 9:08 ` Maciej Strozek
2026-11-26 14:09 ` Andy Shevchenko
2026-11-26 14:54 ` Maciej Strozek
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®