Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Interface the pinmux subsystem
4 *
5 * Copyright (C) 2011 ST-Ericsson SA
6 * Written on behalf of Linaro for ST-Ericsson
7 * Based on bits of regulator core, gpio core and clk core
8 *
9 * Author: Linus Walleij <linus.walleij@linaro.org>
10 */
11#ifndef __LINUX_PINCTRL_PINMUX_H
12#define __LINUX_PINCTRL_PINMUX_H
13
14#include <linux/types.h>
15
16struct pinctrl_dev;
17struct pinctrl_gpio_range;
18
19/**
20 * struct pinmux_ops - pinmux operations, to be implemented by pin controller
21 * drivers that support pinmuxing
22 * @request: called by the core to see if a certain pin can be made
23 * available for muxing. This is called by the core to acquire the pins
24 * before selecting any actual mux setting across a function. The driver
25 * is allowed to answer "no" by returning a negative error code
26 * @free: the reverse function of the request() callback, frees a pin after
27 * being requested
28 * @get_functions_count: returns number of selectable named functions available
29 * in this pinmux driver
30 * @get_function_name: return the function name of the muxing selector,
31 * called by the core to figure out which mux setting it shall map a
32 * certain device to
33 * @get_function_groups: return an array of groups names (in turn
34 * referencing pins) connected to a certain function selector. The group
35 * name can be used with the generic @pinctrl_ops to retrieve the
36 * actual pins affected. The applicable groups will be returned in
37 * @groups and the number of groups in @num_groups
38 * @function_is_gpio: determine if the indicated function selector passed
39 * corresponds to the GPIO function which is used by the accelerated GPIO
40 * functions @gpio_request_enable, @gpio_disable_free and
41 * @gpio_set_direction. When the pin control core can properly determine
42 * if a function is a GPIO function, it is easier to use the @strict mode
43 * on the pin controller. Since a single function is passed, this is
44 * only useful on pin controllers that use a specific function for GPIO,
45 * and that usually presupposes that a one-group-per-pin approach is
46 * used, so that a single function can be set on a single pin to turn
47 * it to GPIO mode.
48 * @set_mux: enable a certain muxing function with a certain pin group. The
49 * driver does not need to figure out whether enabling this function
50 * conflicts some other use of the pins in that group, such collisions
51 * are handled by the pinmux subsystem. The @func_selector selects a
52 * certain function whereas @group_selector selects a certain set of pins
53 * to be used. On simple controllers the latter argument may be ignored
54 * @gpio_request_enable: requests and enables GPIO on a certain pin.
55 * Implement this only if you can mux every pin individually as GPIO. The
56 * affected GPIO range is passed along with an offset(pin number) into that
57 * specific GPIO range - function selectors and pin groups are orthogonal
58 * to this, the core will however make sure the pins do not collide.
59 * @gpio_disable_free: free up GPIO muxing on a certain pin, the reverse of
60 * @gpio_request_enable
61 * @gpio_set_direction: Since controllers may need different configurations
62 * depending on whether the GPIO is configured as input or output,
63 * a direction selector function may be implemented as a backing
64 * to the GPIO controllers that need pin muxing.
65 * @strict: do not allow simultaneous use of the same pin for GPIO and another
66 * function. Check both gpio_owner and mux_owner strictly before approving
67 * the pin request.
68 */
69struct pinmux_ops {
70 int (*request) (struct pinctrl_dev *pctldev, unsigned int offset);
71 int (*free) (struct pinctrl_dev *pctldev, unsigned int offset);
72 int (*get_functions_count) (struct pinctrl_dev *pctldev);
73 const char *(*get_function_name) (struct pinctrl_dev *pctldev,
74 unsigned int selector);
75 int (*get_function_groups) (struct pinctrl_dev *pctldev,
76 unsigned int selector,
77 const char * const **groups,
78 unsigned int *num_groups);
79 bool (*function_is_gpio) (struct pinctrl_dev *pctldev,
80 unsigned int selector);
81 int (*set_mux) (struct pinctrl_dev *pctldev, unsigned int func_selector,
82 unsigned int group_selector);
83 int (*gpio_request_enable) (struct pinctrl_dev *pctldev,
84 struct pinctrl_gpio_range *range,
85 unsigned int offset);
86 void (*gpio_disable_free) (struct pinctrl_dev *pctldev,
87 struct pinctrl_gpio_range *range,
88 unsigned int offset);
89 int (*gpio_set_direction) (struct pinctrl_dev *pctldev,
90 struct pinctrl_gpio_range *range,
91 unsigned int offset,
92 bool input);
93 bool strict;
94};
95
96#endif /* __LINUX_PINCTRL_PINMUX_H */