* [PATCH 1/2] pinctrl: apple: Use unsigned int instead of unsigned
2026-01-11 20:29 [PATCH 0/2] pinctrl: apple: Fixup and RFC GPIO mode patch Linus Walleij
@ 2026-01-11 20:29 ` Linus Walleij
2026-01-11 22:17 ` Sven Peter
2026-01-11 20:29 ` [PATCH 2/2] RFC: pinctrl: apple: Implement GPIO func check callback Linus Walleij
2026-01-12 9:42 ` [PATCH 0/2] pinctrl: apple: Fixup and RFC GPIO mode patch Bartosz Golaszewski
2 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2026-01-11 20:29 UTC (permalink / raw)
To: Sven Peter, Janne Grunau, Neal Gompa, Bartosz Golaszewski
Cc: asahi, linux-arm-kernel, linux-gpio, Linus Walleij
It is discouraged to use the ambiguous "unsigned" type, use
explicit unsigned int in the driver.
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
drivers/pinctrl/pinctrl-apple-gpio.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index e1a7bc8cf765..a4161d59ab9f 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -102,9 +102,9 @@ static u32 apple_gpio_get_reg(struct apple_gpio_pinctrl *pctl,
static int apple_gpio_dt_node_to_map(struct pinctrl_dev *pctldev,
struct device_node *node,
struct pinctrl_map **map,
- unsigned *num_maps)
+ unsigned int *num_maps)
{
- unsigned reserved_maps;
+ unsigned int reserved_maps;
struct apple_gpio_pinctrl *pctl;
u32 pinfunc, pin, func;
int num_pins, i, ret;
@@ -170,8 +170,8 @@ static const struct pinctrl_ops apple_gpio_pinctrl_ops = {
/* Pin multiplexer functions */
-static int apple_gpio_pinmux_set(struct pinctrl_dev *pctldev, unsigned func,
- unsigned group)
+static int apple_gpio_pinmux_set(struct pinctrl_dev *pctldev, unsigned int func,
+ unsigned int group)
{
struct apple_gpio_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
@@ -202,7 +202,7 @@ static int apple_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
return GPIO_LINE_DIRECTION_IN;
}
-static int apple_gpio_get(struct gpio_chip *chip, unsigned offset)
+static int apple_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
struct apple_gpio_pinctrl *pctl = gpiochip_get_data(chip);
unsigned int reg = apple_gpio_get_reg(pctl, offset);
--
2.52.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] RFC: pinctrl: apple: Implement GPIO func check callback
2026-01-11 20:29 [PATCH 0/2] pinctrl: apple: Fixup and RFC GPIO mode patch Linus Walleij
2026-01-11 20:29 ` [PATCH 1/2] pinctrl: apple: Use unsigned int instead of unsigned Linus Walleij
@ 2026-01-11 20:29 ` Linus Walleij
2026-01-11 22:25 ` Sven Peter
2026-01-12 9:42 ` [PATCH 0/2] pinctrl: apple: Fixup and RFC GPIO mode patch Bartosz Golaszewski
2 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2026-01-11 20:29 UTC (permalink / raw)
To: Sven Peter, Janne Grunau, Neal Gompa, Bartosz Golaszewski
Cc: asahi, linux-arm-kernel, linux-gpio, Linus Walleij
This function will check if the indicated function enumerator
i.e. the value set into bits 5 and 6 of the pin configuration
register, is zero and thus corresponds to the GPIO mode of the
pin.
This may be necessary to know since the pin controller is
flagged as "strict": once you set a pin *explicitly* to GPIO
mode using function 0, the core is unaware that this is
actually the GPIO mode, and clients may be denied to
retrieve the pin as a GPIO.
Currently none of the in-kernel device trees sets any pin to
GPIO mode, but this may happen any day.
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
drivers/pinctrl/pinctrl-apple-gpio.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index a4161d59ab9f..fd20d0e49f48 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -170,6 +170,13 @@ static const struct pinctrl_ops apple_gpio_pinctrl_ops = {
/* Pin multiplexer functions */
+static int apple_gpio_pinmux_func_is_gpio(struct pinctrl_dev *pctldev,
+ unsigned int selector)
+{
+ /* Function selector 0 is always the GPIO mode */
+ return (selector == 0);
+}
+
static int apple_gpio_pinmux_set(struct pinctrl_dev *pctldev, unsigned int func,
unsigned int group)
{
@@ -186,6 +193,7 @@ static const struct pinmux_ops apple_gpio_pinmux_ops = {
.get_functions_count = pinmux_generic_get_function_count,
.get_function_name = pinmux_generic_get_function_name,
.get_function_groups = pinmux_generic_get_function_groups,
+ .function_is_gpio = apple_gpio_pinmux_func_is_gpio,
.set_mux = apple_gpio_pinmux_set,
.strict = true,
};
--
2.52.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 2/2] RFC: pinctrl: apple: Implement GPIO func check callback
2026-01-11 20:29 ` [PATCH 2/2] RFC: pinctrl: apple: Implement GPIO func check callback Linus Walleij
@ 2026-01-11 22:25 ` Sven Peter
0 siblings, 0 replies; 6+ messages in thread
From: Sven Peter @ 2026-01-11 22:25 UTC (permalink / raw)
To: Linus Walleij, Janne Grunau, Neal Gompa, Bartosz Golaszewski
Cc: asahi, linux-arm-kernel, linux-gpio
On 11.01.26 21:29, Linus Walleij wrote:
> This function will check if the indicated function enumerator
> i.e. the value set into bits 5 and 6 of the pin configuration
> register, is zero and thus corresponds to the GPIO mode of the
> pin.
>
> This may be necessary to know since the pin controller is
> flagged as "strict": once you set a pin *explicitly* to GPIO
> mode using function 0, the core is unaware that this is
> actually the GPIO mode, and clients may be denied to
> retrieve the pin as a GPIO.
>
> Currently none of the in-kernel device trees sets any pin to
> GPIO mode, but this may happen any day.
>
> Signed-off-by: Linus Walleij <linusw@kernel.org>
> ---
Just took a quick look: When we use them as GPIO we always set those two
bits to zero and all "special" functions (like i2c or spi) always start
at 1. As far as I can tell we can still read the pin value even when bit
5/6 aren't zero (and e.g. observe i2c traffic that way) but we can't
drive them anymore.
Since we don't have any documentation for this hardware that's probably
as good as it'll get:
Reviewed-by: Sven Peter <sven@kernel.org>
Sven
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] pinctrl: apple: Fixup and RFC GPIO mode patch
2026-01-11 20:29 [PATCH 0/2] pinctrl: apple: Fixup and RFC GPIO mode patch Linus Walleij
2026-01-11 20:29 ` [PATCH 1/2] pinctrl: apple: Use unsigned int instead of unsigned Linus Walleij
2026-01-11 20:29 ` [PATCH 2/2] RFC: pinctrl: apple: Implement GPIO func check callback Linus Walleij
@ 2026-01-12 9:42 ` Bartosz Golaszewski
2 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2026-01-12 9:42 UTC (permalink / raw)
To: Linus Walleij
Cc: asahi, linux-arm-kernel, linux-gpio, Sven Peter, Janne Grunau,
Neal Gompa, Bartosz Golaszewski
On Sun, 11 Jan 2026 21:29:20 +0100, Linus Walleij <linusw@kernel.org> said:
> This fixes some uses of the "unsigned" type to "unsigned int"
> then propose to implement the .function_is_gpio() callback.
>
> The Apple pin control maintainers can comment on this: I
> am not sure that "mode 0" is GPIO on this hardware but I
> find it likely.
>
> Toggling a pin between a certain function mode and GPIO
> mode happens on any sufficiently advanced system sooner or
> later and this callback was implemented because Qualcomm
> ran into it, so let's add it to the Apple driver before
> the users turn up.
>
> Signed-off-by: Linus Walleij <linusw@kernel.org>
> ---
> Linus Walleij (2):
> pinctrl: apple: Use unsigned int instead of unsigned
> RFC: pinctrl: apple: Implement GPIO func check callback
>
> drivers/pinctrl/pinctrl-apple-gpio.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
> ---
> base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
> change-id: 20260111-apple-req-gpio-func-3010ca45a118
>
> Best regards,
> --
> Linus Walleij <linusw@kernel.org>
>
>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 6+ messages in thread