Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Interface the pinmux subsystem
0004  *
0005  * Copyright (C) 2011 ST-Ericsson SA
0006  * Written on behalf of Linaro for ST-Ericsson
0007  * Based on bits of regulator core, gpio core and clk core
0008  *
0009  * Author: Linus Walleij <linus.walleij@linaro.org>
0010  */
0011 #ifndef __LINUX_PINCTRL_PINMUX_H
0012 #define __LINUX_PINCTRL_PINMUX_H
0013 
0014 #include <linux/list.h>
0015 #include <linux/seq_file.h>
0016 #include <linux/pinctrl/pinctrl.h>
0017 
0018 struct pinctrl_dev;
0019 
0020 /**
0021  * struct pinmux_ops - pinmux operations, to be implemented by pin controller
0022  * drivers that support pinmuxing
0023  * @request: called by the core to see if a certain pin can be made
0024  *  available for muxing. This is called by the core to acquire the pins
0025  *  before selecting any actual mux setting across a function. The driver
0026  *  is allowed to answer "no" by returning a negative error code
0027  * @free: the reverse function of the request() callback, frees a pin after
0028  *  being requested
0029  * @get_functions_count: returns number of selectable named functions available
0030  *  in this pinmux driver
0031  * @get_function_name: return the function name of the muxing selector,
0032  *  called by the core to figure out which mux setting it shall map a
0033  *  certain device to
0034  * @get_function_groups: return an array of groups names (in turn
0035  *  referencing pins) connected to a certain function selector. The group
0036  *  name can be used with the generic @pinctrl_ops to retrieve the
0037  *  actual pins affected. The applicable groups will be returned in
0038  *  @groups and the number of groups in @num_groups
0039  * @set_mux: enable a certain muxing function with a certain pin group. The
0040  *  driver does not need to figure out whether enabling this function
0041  *  conflicts some other use of the pins in that group, such collisions
0042  *  are handled by the pinmux subsystem. The @func_selector selects a
0043  *  certain function whereas @group_selector selects a certain set of pins
0044  *  to be used. On simple controllers the latter argument may be ignored
0045  * @gpio_request_enable: requests and enables GPIO on a certain pin.
0046  *  Implement this only if you can mux every pin individually as GPIO. The
0047  *  affected GPIO range is passed along with an offset(pin number) into that
0048  *  specific GPIO range - function selectors and pin groups are orthogonal
0049  *  to this, the core will however make sure the pins do not collide.
0050  * @gpio_disable_free: free up GPIO muxing on a certain pin, the reverse of
0051  *  @gpio_request_enable
0052  * @gpio_set_direction: Since controllers may need different configurations
0053  *  depending on whether the GPIO is configured as input or output,
0054  *  a direction selector function may be implemented as a backing
0055  *  to the GPIO controllers that need pin muxing.
0056  * @strict: do not allow simultaneous use of the same pin for GPIO and another
0057  *  function. Check both gpio_owner and mux_owner strictly before approving
0058  *  the pin request.
0059  */
0060 struct pinmux_ops {
0061     int (*request) (struct pinctrl_dev *pctldev, unsigned offset);
0062     int (*free) (struct pinctrl_dev *pctldev, unsigned offset);
0063     int (*get_functions_count) (struct pinctrl_dev *pctldev);
0064     const char *(*get_function_name) (struct pinctrl_dev *pctldev,
0065                       unsigned selector);
0066     int (*get_function_groups) (struct pinctrl_dev *pctldev,
0067                   unsigned selector,
0068                   const char * const **groups,
0069                   unsigned *num_groups);
0070     int (*set_mux) (struct pinctrl_dev *pctldev, unsigned func_selector,
0071             unsigned group_selector);
0072     int (*gpio_request_enable) (struct pinctrl_dev *pctldev,
0073                     struct pinctrl_gpio_range *range,
0074                     unsigned offset);
0075     void (*gpio_disable_free) (struct pinctrl_dev *pctldev,
0076                    struct pinctrl_gpio_range *range,
0077                    unsigned offset);
0078     int (*gpio_set_direction) (struct pinctrl_dev *pctldev,
0079                    struct pinctrl_gpio_range *range,
0080                    unsigned offset,
0081                    bool input);
0082     bool strict;
0083 };
0084 
0085 #endif /* __LINUX_PINCTRL_PINMUX_H */