Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 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 "pinctrl.h" |
| 18 | |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 19 | #ifdef CONFIG_PINMUX |
| 20 | |
| 21 | struct pinctrl_dev; |
| 22 | |
| 23 | /** |
| 24 | * struct pinmux_ops - pinmux operations, to be implemented by pin controller |
| 25 | * drivers that support pinmuxing |
| 26 | * @request: called by the core to see if a certain pin can be made available |
| 27 | * available for muxing. This is called by the core to acquire the pins |
| 28 | * before selecting any actual mux setting across a function. The driver |
| 29 | * is allowed to answer "no" by returning a negative error code |
| 30 | * @free: the reverse function of the request() callback, frees a pin after |
| 31 | * being requested |
| 32 | * @list_functions: list the number of selectable named functions available |
| 33 | * in this pinmux driver, the core will begin on 0 and call this |
| 34 | * repeatedly as long as it returns >= 0 to enumerate mux settings |
| 35 | * @get_function_name: return the function name of the muxing selector, |
| 36 | * called by the core to figure out which mux setting it shall map a |
| 37 | * certain device to |
| 38 | * @get_function_groups: return an array of groups names (in turn |
| 39 | * referencing pins) connected to a certain function selector. The group |
| 40 | * name can be used with the generic @pinctrl_ops to retrieve the |
| 41 | * actual pins affected. The applicable groups will be returned in |
| 42 | * @groups and the number of groups in @num_groups |
| 43 | * @enable: enable a certain muxing function with a certain pin group. The |
| 44 | * driver does not need to figure out whether enabling this function |
| 45 | * conflicts some other use of the pins in that group, such collisions |
| 46 | * are handled by the pinmux subsystem. The @func_selector selects a |
| 47 | * certain function whereas @group_selector selects a certain set of pins |
| 48 | * to be used. On simple controllers the latter argument may be ignored |
| 49 | * @disable: disable a certain muxing selector with a certain pin group |
| 50 | * @gpio_request_enable: requests and enables GPIO on a certain pin. |
| 51 | * Implement this only if you can mux every pin individually as GPIO. The |
Chanho Park | 3c739ad | 2011-11-11 18:47:58 +0900 | [diff] [blame] | 52 | * affected GPIO range is passed along with an offset(pin number) into that |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 53 | * specific GPIO range - function selectors and pin groups are orthogonal |
Linus Walleij | 542e704 | 2011-11-14 10:06:22 +0100 | [diff] [blame] | 54 | * to this, the core will however make sure the pins do not collide. |
| 55 | * @gpio_disable_free: free up GPIO muxing on a certain pin, the reverse of |
| 56 | * @gpio_request_enable |
| 57 | * @gpio_set_direction: Since controllers may need different configurations |
| 58 | * depending on whether the GPIO is configured as input or output, |
| 59 | * a direction selector function may be implemented as a backing |
| 60 | * to the GPIO controllers that need pin muxing. |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 61 | */ |
| 62 | struct pinmux_ops { |
| 63 | int (*request) (struct pinctrl_dev *pctldev, unsigned offset); |
| 64 | int (*free) (struct pinctrl_dev *pctldev, unsigned offset); |
| 65 | int (*list_functions) (struct pinctrl_dev *pctldev, unsigned selector); |
| 66 | const char *(*get_function_name) (struct pinctrl_dev *pctldev, |
| 67 | unsigned selector); |
| 68 | int (*get_function_groups) (struct pinctrl_dev *pctldev, |
| 69 | unsigned selector, |
| 70 | const char * const **groups, |
| 71 | unsigned * const num_groups); |
| 72 | int (*enable) (struct pinctrl_dev *pctldev, unsigned func_selector, |
| 73 | unsigned group_selector); |
| 74 | void (*disable) (struct pinctrl_dev *pctldev, unsigned func_selector, |
| 75 | unsigned group_selector); |
| 76 | int (*gpio_request_enable) (struct pinctrl_dev *pctldev, |
| 77 | struct pinctrl_gpio_range *range, |
| 78 | unsigned offset); |
Stephen Warren | 3712a3c | 2011-10-21 12:25:53 -0600 | [diff] [blame] | 79 | void (*gpio_disable_free) (struct pinctrl_dev *pctldev, |
| 80 | struct pinctrl_gpio_range *range, |
| 81 | unsigned offset); |
Linus Walleij | 542e704 | 2011-11-14 10:06:22 +0100 | [diff] [blame] | 82 | int (*gpio_set_direction) (struct pinctrl_dev *pctldev, |
| 83 | struct pinctrl_gpio_range *range, |
| 84 | unsigned offset, |
| 85 | bool input); |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 86 | }; |
| 87 | |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 88 | #endif /* CONFIG_PINMUX */ |
| 89 | |
| 90 | #endif /* __LINUX_PINCTRL_PINMUX_H */ |