mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pinctrl: qcom: spmi-gpio: implement .get_direction()
@ 2026-03-04 17:41 Neil Armstrong
  2026-03-05  8:37 ` Bartosz Golaszewski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Neil Armstrong @ 2026-03-04 17:41 UTC (permalink / raw)
  To: Bjorn Andersson, Linus Walleij, Bartosz Golaszewski,
	Ivan T. Ivanov, Rob Herring, Fenglin Wu
  Cc: linux-arm-msm, linux-gpio, linux-kernel, Neil Armstrong

GPIO controller driver should typically implement the .get_direction()
callback as GPIOLIB internals may try to use it to determine the state
of a pin. Since introduction of shared proxy, it prints a warning splat
when using a shared spmi gpio.

The implementation is not easy because the controller supports enabling
the input and output logic at the same time, so we aligns on the
behaviour of the .get() operation and return -EINVAL in other
situations.

Fixes: eadff3024472 ("pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver")
Fixes: d7b5f5cc5eb4 ("pinctrl: qcom: spmi-gpio: Add support for GPIO LV/MV subtype")
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
index 83f940fe30b2..d02d42513ebb 100644
--- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
+++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
@@ -723,6 +723,21 @@ static const struct pinconf_ops pmic_gpio_pinconf_ops = {
 	.pin_config_group_dbg_show	= pmic_gpio_config_dbg_show,
 };
 
+static int pmic_gpio_get_direction(struct gpio_chip *chip, unsigned pin)
+{
+	struct pmic_gpio_state *state = gpiochip_get_data(chip);
+	struct pmic_gpio_pad *pad;
+
+	pad = state->ctrl->desc->pins[pin].drv_data;
+
+	if (!pad->is_enabled || pad->analog_pass ||
+	    (!pad->input_enabled && !pad->output_enabled))
+		return -EINVAL;
+
+	/* Make sure the state is aligned on what pmic_gpio_get() returns */
+	return pad->input_enabled ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
+}
+
 static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned pin)
 {
 	struct pmic_gpio_state *state = gpiochip_get_data(chip);
@@ -801,6 +816,7 @@ static void pmic_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
 }
 
 static const struct gpio_chip pmic_gpio_gpio_template = {
+	.get_direction		= pmic_gpio_get_direction,
 	.direction_input	= pmic_gpio_direction_input,
 	.direction_output	= pmic_gpio_direction_output,
 	.get			= pmic_gpio_get,

---
base-commit: 11439c4635edd669ae435eec308f4ab8a0804808
change-id: 20260304-topic-sm8x50-spmi-gpio-get-direction-23f7409554ca

Best regards,
-- 
Neil Armstrong <neil.armstrong@linaro.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pinctrl: qcom: spmi-gpio: implement .get_direction()
  2026-03-04 17:41 [PATCH] pinctrl: qcom: spmi-gpio: implement .get_direction() Neil Armstrong
@ 2026-03-05  8:37 ` Bartosz Golaszewski
  2026-03-05  9:54 ` Konrad Dybcio
  2026-03-10  9:22 ` Linus Walleij
  2 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2026-03-05  8:37 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: linux-arm-msm, linux-gpio, linux-kernel, Bjorn Andersson,
	Linus Walleij, Bartosz Golaszewski, Ivan T. Ivanov, Rob Herring,
	Fenglin Wu

On Wed, 4 Mar 2026 18:41:08 +0100, Neil Armstrong
<neil.armstrong@linaro.org> said:
> GPIO controller driver should typically implement the .get_direction()
> callback as GPIOLIB internals may try to use it to determine the state
> of a pin. Since introduction of shared proxy, it prints a warning splat
> when using a shared spmi gpio.
>
> The implementation is not easy because the controller supports enabling
> the input and output logic at the same time, so we aligns on the
> behaviour of the .get() operation and return -EINVAL in other
> situations.
>
> Fixes: eadff3024472 ("pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver")
> Fixes: d7b5f5cc5eb4 ("pinctrl: qcom: spmi-gpio: Add support for GPIO LV/MV subtype")
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---

Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pinctrl: qcom: spmi-gpio: implement .get_direction()
  2026-03-04 17:41 [PATCH] pinctrl: qcom: spmi-gpio: implement .get_direction() Neil Armstrong
  2026-03-05  8:37 ` Bartosz Golaszewski
@ 2026-03-05  9:54 ` Konrad Dybcio
  2026-03-10  9:22 ` Linus Walleij
  2 siblings, 0 replies; 4+ messages in thread
From: Konrad Dybcio @ 2026-03-05  9:54 UTC (permalink / raw)
  To: Neil Armstrong, Bjorn Andersson, Linus Walleij,
	Bartosz Golaszewski, Ivan T. Ivanov, Rob Herring, Fenglin Wu
  Cc: linux-arm-msm, linux-gpio, linux-kernel

On 3/4/26 6:41 PM, Neil Armstrong wrote:
> GPIO controller driver should typically implement the .get_direction()
> callback as GPIOLIB internals may try to use it to determine the state
> of a pin. Since introduction of shared proxy, it prints a warning splat
> when using a shared spmi gpio.
> 
> The implementation is not easy because the controller supports enabling
> the input and output logic at the same time, so we aligns on the
> behaviour of the .get() operation and return -EINVAL in other
> situations.
> 
> Fixes: eadff3024472 ("pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver")
> Fixes: d7b5f5cc5eb4 ("pinctrl: qcom: spmi-gpio: Add support for GPIO LV/MV subtype")
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] pinctrl: qcom: spmi-gpio: implement .get_direction()
  2026-03-04 17:41 [PATCH] pinctrl: qcom: spmi-gpio: implement .get_direction() Neil Armstrong
  2026-03-05  8:37 ` Bartosz Golaszewski
  2026-03-05  9:54 ` Konrad Dybcio
@ 2026-03-10  9:22 ` Linus Walleij
  2 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2026-03-10  9:22 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Bjorn Andersson, Bartosz Golaszewski, Ivan T. Ivanov,
	Rob Herring, Fenglin Wu, linux-arm-msm, linux-gpio, linux-kernel

On Wed, Mar 4, 2026 at 6:41 PM Neil Armstrong <neil.armstrong@linaro.org> wrote:

> GPIO controller driver should typically implement the .get_direction()
> callback as GPIOLIB internals may try to use it to determine the state
> of a pin. Since introduction of shared proxy, it prints a warning splat
> when using a shared spmi gpio.
>
> The implementation is not easy because the controller supports enabling
> the input and output logic at the same time, so we aligns on the
> behaviour of the .get() operation and return -EINVAL in other
> situations.
>
> Fixes: eadff3024472 ("pinctrl: Qualcomm SPMI PMIC GPIO pin controller driver")
> Fixes: d7b5f5cc5eb4 ("pinctrl: qcom: spmi-gpio: Add support for GPIO LV/MV subtype")
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>

Patch applied for fixes.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-10  9:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-04 17:41 [PATCH] pinctrl: qcom: spmi-gpio: implement .get_direction() Neil Armstrong
2026-03-05  8:37 ` Bartosz Golaszewski
2026-03-05  9:54 ` Konrad Dybcio
2026-03-10  9:22 ` Linus Walleij

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®