Thread (11 messages) 11 messages, 3 authors, 2024-11-13

Re: [PATCH v5 3/5] pinctrl: meson: add interface of of_xlate

From: Neil Armstrong <neil.armstrong@linaro.org>
Date: 2024-11-12 13:28:37
Also in: linux-amlogic, linux-devicetree, linux-gpio, lkml

On 12/11/2024 11:26, Xianwei Zhao via B4 Relay wrote:
quoted hunk ↗ jump to hunk
From: Xianwei Zhao <xianwei.zhao@amlogic.com>

Amlogic pinctrl software framework use system API of_gpio_simple_xlate
which only support linear one-to-one correspondence to translate gpiospec
to the GPIO number and flags before. It can not meet the non-linear needs.
Add the interface satisfies the underlying driver to implement the
transformation to meet the needs of various scenarios.

Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
---
  drivers/pinctrl/meson/pinctrl-meson.c | 4 ++++
  drivers/pinctrl/meson/pinctrl-meson.h | 4 ++++
  2 files changed, 8 insertions(+)
diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index 253a0cc57e39..fc0c0bef38c0 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -620,6 +620,10 @@ static int meson_gpiolib_register(struct meson_pinctrl *pc)
  	pc->chip.base = -1;
  	pc->chip.ngpio = pc->data->num_pins;
  	pc->chip.can_sleep = false;
+	if (pc->data->of_xlate) {
+		pc->chip.of_gpio_n_cells = pc->data->of_gpio_n_cells;
+		pc->chip.of_xlate = pc->data->of_xlate;
+	}
  
  	ret = gpiochip_add_data(&pc->chip, pc);
  	if (ret) {
diff --git a/drivers/pinctrl/meson/pinctrl-meson.h b/drivers/pinctrl/meson/pinctrl-meson.h
index 7883ea31a001..cbb3f22552b9 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.h
+++ b/drivers/pinctrl/meson/pinctrl-meson.h
@@ -120,6 +120,10 @@ struct meson_pinctrl_data {
  	const struct pinmux_ops *pmx_ops;
  	const void *pmx_data;
  	int (*parse_dt)(struct meson_pinctrl *pc);
+	int (*of_xlate)(struct gpio_chip *gc,
+			const struct of_phandle_args *gpiospec,
+			u32 *flags);
+	int of_gpio_n_cells;
  };
  
  struct meson_pinctrl {
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help