STRUCT PINMUX_OPS(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿ’… struct pinmux_ops(9) ๐Ÿ’…

okay bestie, this page is from the Kernel API Manual, and it's all about struct pinmux_ops โ€” the pinmux operations struct, to be implemented by pin controller drivers that support pinmuxing โœจ no cap.


๐Ÿ’– NAME ๐Ÿ’–

struct pinmux_ops โ€” pinmux operations, to be implemented by pin controller drivers that support pinmuxing ๐ŸŽ€


โœจ SYNOPSIS โœจ

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);
    void (*release_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;
};

๐ŸŽ€ Members ๐ŸŽ€

  • request โ€” the core calls this to see if a certain pin can be made available for muxing. It's how the core acquires 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; it frees a pin after being requested ๐Ÿซถ
  • get_functions_count โ€” returns the number of selectable named functions available in this pinmux driver ๐Ÿ”ข
  • get_function_name โ€” returns the function name of the muxing selector. The core calls it to figure out which mux setting it shall map a certain device to ๐ŸŽฏ
  • get_function_groups โ€” returns 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 ๐Ÿงš
  • function_is_gpio โ€” determines if the indicated function selector passed corresponds to the GPIO function which is used by the accelerated GPIO functions gpio_request_enable, gpio_disable_free and gpio_set_direction. When the pin control core can properly determine if a function is a GPIO function, it is easier to use the strict mode on the pin controller. Since a single function is passed, this is only useful on pin controllers that use a specific function for GPIO, and that usually presupposes that a one-group-per-pin approach is used, so that a single function can be set on a single pin to turn it to GPIO mode ๐Ÿ‘‘
  • set_mux โ€” enables 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 ๐Ÿ”ฅ
  • release_mux โ€” releases software resources acquired by set_mux.
๐Ÿšจ bestie warning: this callback must not change hardware state to avoid glitches when switching mux ๐Ÿ’€
  • 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 ๐Ÿ”’

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

  • Kernel file ./include/linux/pinctrl/pinmux.h ๐Ÿ“

that's the whole page, bestie! it comes from ./include/linux/pinctrl, dated October 2026, for struct pinmux_ops(9) โ€” mwah, slay, periodt ๐Ÿ’…๐Ÿ’–

๐Ÿ“ฆ where this page comes from