Skip to content

Commit 881238a

Browse files
committed
pinctrl: apple: Implement GPIO func check callback
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. Reviewed-by: Sven Peter <sven@kernel.org> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Signed-off-by: Linus Walleij <linusw@kernel.org>
1 parent 7b9a9ca commit 881238a

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/pinctrl/pinctrl-apple-gpio.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ static const struct pinctrl_ops apple_gpio_pinctrl_ops = {
170170

171171
/* Pin multiplexer functions */
172172

173+
static bool apple_gpio_pinmux_func_is_gpio(struct pinctrl_dev *pctldev,
174+
unsigned int selector)
175+
{
176+
/* Function selector 0 is always the GPIO mode */
177+
return (selector == 0);
178+
}
179+
173180
static int apple_gpio_pinmux_set(struct pinctrl_dev *pctldev, unsigned int func,
174181
unsigned int group)
175182
{
@@ -186,6 +193,7 @@ static const struct pinmux_ops apple_gpio_pinmux_ops = {
186193
.get_functions_count = pinmux_generic_get_function_count,
187194
.get_function_name = pinmux_generic_get_function_name,
188195
.get_function_groups = pinmux_generic_get_function_groups,
196+
.function_is_gpio = apple_gpio_pinmux_func_is_gpio,
189197
.set_mux = apple_gpio_pinmux_set,
190198
.strict = true,
191199
};

0 commit comments

Comments
 (0)