mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-17 03:50:37 +00:00
The name of the pin function has no real meaning to pinctrl core and is there only for human readability of device properties. Some pins are muxed as GPIOs but for "strict" pinmuxers it's impossible to request them as GPIOs if they're bound to a devide - even if their function name explicitly says "gpio". Add a new field to struct pinfunction that allows to pass additional flags to pinctrl core. While we could go with a boolean "is_gpio" field, a flags field is more future-proof. If the PINFUNCTION_FLAG_GPIO is set for a given function, the pin muxed to it can be requested as GPIO even on strict pin controllers. Add a new callback to struct pinmux_ops - function_is_gpio() - that allows pinmux core to inspect a function and see if it's a GPIO one. Provide a generic implementation of this callback. Tested-by: Neil Armstrong <neil.armstrong@linaro.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
87 lines
3.9 KiB
C
87 lines
3.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Interface the pinmux subsystem
|
|
*
|
|
* Copyright (C) 2011 ST-Ericsson SA
|
|
* Written on behalf of Linaro for ST-Ericsson
|
|
* Based on bits of regulator core, gpio core and clk core
|
|
*
|
|
* Author: Linus Walleij <linus.walleij@linaro.org>
|
|
*/
|
|
#ifndef __LINUX_PINCTRL_PINMUX_H
|
|
#define __LINUX_PINCTRL_PINMUX_H
|
|
|
|
#include <linux/types.h>
|
|
|
|
struct pinctrl_dev;
|
|
struct pinctrl_gpio_range;
|
|
|
|
/**
|
|
* struct pinmux_ops - pinmux operations, to be implemented by pin controller
|
|
* drivers that support pinmuxing
|
|
* @request: called by the core to see if a certain pin can be made
|
|
* available for muxing. This is called by the core to acquire the pins
|
|
* before selecting any actual mux setting across a function. The driver
|
|
* is allowed to answer "no" by returning a negative error code
|
|
* @free: the reverse function of the request() callback, frees a pin after
|
|
* being requested
|
|
* @get_functions_count: returns number of selectable named functions available
|
|
* in this pinmux driver
|
|
* @get_function_name: return the function name of the muxing selector,
|
|
* called by the core to figure out which mux setting it shall map a
|
|
* certain device to
|
|
* @get_function_groups: return an array of groups names (in turn
|
|
* referencing pins) connected to a certain function selector. The group
|
|
* name can be used with the generic @pinctrl_ops to retrieve the
|
|
* actual pins affected. The applicable groups will be returned in
|
|
* @groups and the number of groups in @num_groups
|
|
* @set_mux: enable a certain muxing function with a certain pin group. The
|
|
* driver does not need to figure out whether enabling this function
|
|
* conflicts some other use of the pins in that group, such collisions
|
|
* are handled by the pinmux subsystem. The @func_selector selects a
|
|
* certain function whereas @group_selector selects a certain set of pins
|
|
* to be used. On simple controllers the latter argument may be ignored
|
|
* @gpio_request_enable: requests and enables GPIO on a certain pin.
|
|
* Implement this only if you can mux every pin individually as GPIO. The
|
|
* affected GPIO range is passed along with an offset(pin number) into that
|
|
* specific GPIO range - function selectors and pin groups are orthogonal
|
|
* to this, the core will however make sure the pins do not collide.
|
|
* @gpio_disable_free: free up GPIO muxing on a certain pin, the reverse of
|
|
* @gpio_request_enable
|
|
* @gpio_set_direction: Since controllers may need different configurations
|
|
* depending on whether the GPIO is configured as input or output,
|
|
* a direction selector function may be implemented as a backing
|
|
* to the GPIO controllers that need pin muxing.
|
|
* @strict: do not allow simultaneous use of the same pin for GPIO and another
|
|
* function. Check both gpio_owner and mux_owner strictly before approving
|
|
* the pin request.
|
|
*/
|
|
struct pinmux_ops {
|
|
int (*request) (struct pinctrl_dev *pctldev, unsigned int offset);
|
|
int (*free) (struct pinctrl_dev *pctldev, unsigned int offset);
|
|
int (*get_functions_count) (struct pinctrl_dev *pctldev);
|
|
const char *(*get_function_name) (struct pinctrl_dev *pctldev,
|
|
unsigned int selector);
|
|
int (*get_function_groups) (struct pinctrl_dev *pctldev,
|
|
unsigned int selector,
|
|
const char * const **groups,
|
|
unsigned int *num_groups);
|
|
bool (*function_is_gpio) (struct pinctrl_dev *pctldev,
|
|
unsigned int selector);
|
|
int (*set_mux) (struct pinctrl_dev *pctldev, unsigned int func_selector,
|
|
unsigned int group_selector);
|
|
int (*gpio_request_enable) (struct pinctrl_dev *pctldev,
|
|
struct pinctrl_gpio_range *range,
|
|
unsigned int offset);
|
|
void (*gpio_disable_free) (struct pinctrl_dev *pctldev,
|
|
struct pinctrl_gpio_range *range,
|
|
unsigned int offset);
|
|
int (*gpio_set_direction) (struct pinctrl_dev *pctldev,
|
|
struct pinctrl_gpio_range *range,
|
|
unsigned int offset,
|
|
bool input);
|
|
bool strict;
|
|
};
|
|
|
|
#endif /* __LINUX_PINCTRL_PINMUX_H */
|