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