Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Internal interface between the core pin control system and the |
| 3 | * pinmux portions |
| 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 | * License terms: GNU General Public License (GPL) version 2 |
| 12 | */ |
| 13 | #ifdef CONFIG_PINMUX |
| 14 | |
Tony Lindgren | b9130b7 | 2012-01-24 16:28:08 -0800 | [diff] [blame] | 15 | int pinmux_check_ops(struct pinctrl_dev *pctldev); |
Stephen Warren | 7ecdb16 | 2012-03-02 13:05:45 -0700 | [diff] [blame] | 16 | |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 17 | int pinmux_validate_map(const struct pinctrl_map *map, int i); |
Stephen Warren | 1e2082b | 2012-03-02 13:05:48 -0700 | [diff] [blame] | 18 | |
Linus Walleij | befe5bd | 2012-02-09 19:47:48 +0100 | [diff] [blame] | 19 | int pinmux_request_gpio(struct pinctrl_dev *pctldev, |
| 20 | struct pinctrl_gpio_range *range, |
| 21 | unsigned pin, unsigned gpio); |
| 22 | void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned pin, |
| 23 | struct pinctrl_gpio_range *range); |
| 24 | int pinmux_gpio_direction(struct pinctrl_dev *pctldev, |
| 25 | struct pinctrl_gpio_range *range, |
| 26 | unsigned pin, bool input); |
Stephen Warren | 7ecdb16 | 2012-03-02 13:05:45 -0700 | [diff] [blame] | 27 | |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 28 | int pinmux_map_to_setting(const struct pinctrl_map *map, |
Stephen Warren | 7ecdb16 | 2012-03-02 13:05:45 -0700 | [diff] [blame] | 29 | struct pinctrl_setting *setting); |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 30 | void pinmux_free_setting(const struct pinctrl_setting *setting); |
| 31 | int pinmux_enable_setting(const struct pinctrl_setting *setting); |
| 32 | void pinmux_disable_setting(const struct pinctrl_setting *setting); |
Stephen Warren | 7ecdb16 | 2012-03-02 13:05:45 -0700 | [diff] [blame] | 33 | |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 34 | #else |
| 35 | |
Tony Lindgren | b9130b7 | 2012-01-24 16:28:08 -0800 | [diff] [blame] | 36 | static inline int pinmux_check_ops(struct pinctrl_dev *pctldev) |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 37 | { |
| 38 | return 0; |
| 39 | } |
| 40 | |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 41 | static inline int pinmux_validate_map(const struct pinctrl_map *map, int i) |
Stephen Warren | 1e2082b | 2012-03-02 13:05:48 -0700 | [diff] [blame] | 42 | { |
| 43 | return 0; |
| 44 | } |
| 45 | |
Linus Walleij | befe5bd | 2012-02-09 19:47:48 +0100 | [diff] [blame] | 46 | static inline int pinmux_request_gpio(struct pinctrl_dev *pctldev, |
| 47 | struct pinctrl_gpio_range *range, |
| 48 | unsigned pin, unsigned gpio) |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 49 | { |
| 50 | return 0; |
| 51 | } |
| 52 | |
Linus Walleij | befe5bd | 2012-02-09 19:47:48 +0100 | [diff] [blame] | 53 | static inline void pinmux_free_gpio(struct pinctrl_dev *pctldev, |
| 54 | unsigned pin, |
| 55 | struct pinctrl_gpio_range *range) |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | static inline int pinmux_gpio_direction(struct pinctrl_dev *pctldev, |
| 60 | struct pinctrl_gpio_range *range, |
| 61 | unsigned pin, bool input) |
| 62 | { |
| 63 | return 0; |
| 64 | } |
| 65 | |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 66 | static inline int pinmux_map_to_setting(const struct pinctrl_map *map, |
Stephen Warren | 7ecdb16 | 2012-03-02 13:05:45 -0700 | [diff] [blame] | 67 | struct pinctrl_setting *setting) |
Linus Walleij | befe5bd | 2012-02-09 19:47:48 +0100 | [diff] [blame] | 68 | { |
| 69 | return 0; |
| 70 | } |
| 71 | |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 72 | static inline void pinmux_free_setting(const struct pinctrl_setting *setting) |
Linus Walleij | befe5bd | 2012-02-09 19:47:48 +0100 | [diff] [blame] | 73 | { |
| 74 | } |
| 75 | |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 76 | static inline int pinmux_enable_setting(const struct pinctrl_setting *setting) |
Linus Walleij | befe5bd | 2012-02-09 19:47:48 +0100 | [diff] [blame] | 77 | { |
Stephen Warren | 7ecdb16 | 2012-03-02 13:05:45 -0700 | [diff] [blame] | 78 | return 0; |
Linus Walleij | befe5bd | 2012-02-09 19:47:48 +0100 | [diff] [blame] | 79 | } |
| 80 | |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 81 | static inline void pinmux_disable_setting(const struct pinctrl_setting *setting) |
Linus Walleij | befe5bd | 2012-02-09 19:47:48 +0100 | [diff] [blame] | 82 | { |
| 83 | } |
| 84 | |
Stephen Warren | c736d73 | 2012-04-11 16:45:45 -0600 | [diff] [blame] | 85 | #endif |
| 86 | |
| 87 | #if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS) |
| 88 | |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 89 | void pinmux_show_map(struct seq_file *s, const struct pinctrl_map *map); |
Stephen Warren | c736d73 | 2012-04-11 16:45:45 -0600 | [diff] [blame] | 90 | void pinmux_show_setting(struct seq_file *s, |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 91 | const struct pinctrl_setting *setting); |
Stephen Warren | c736d73 | 2012-04-11 16:45:45 -0600 | [diff] [blame] | 92 | void pinmux_init_device_debugfs(struct dentry *devroot, |
| 93 | struct pinctrl_dev *pctldev); |
| 94 | |
| 95 | #else |
| 96 | |
Stephen Warren | 1e2082b | 2012-03-02 13:05:48 -0700 | [diff] [blame] | 97 | static inline void pinmux_show_map(struct seq_file *s, |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 98 | const struct pinctrl_map *map) |
Stephen Warren | 03665e0 | 2012-02-19 23:45:45 -0700 | [diff] [blame] | 99 | { |
| 100 | } |
| 101 | |
Stephen Warren | 1e2082b | 2012-03-02 13:05:48 -0700 | [diff] [blame] | 102 | static inline void pinmux_show_setting(struct seq_file *s, |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 103 | const struct pinctrl_setting *setting) |
Stephen Warren | 1e2082b | 2012-03-02 13:05:48 -0700 | [diff] [blame] | 104 | { |
| 105 | } |
| 106 | |
| 107 | static inline void pinmux_init_device_debugfs(struct dentry *devroot, |
| 108 | struct pinctrl_dev *pctldev) |
Linus Walleij | 2744e8a | 2011-05-02 20:50:54 +0200 | [diff] [blame] | 109 | { |
| 110 | } |
| 111 | |
| 112 | #endif |
Tony Lindgren | a76edc8 | 2016-12-27 09:20:01 -0800 | [diff] [blame] | 113 | |
| 114 | #ifdef CONFIG_GENERIC_PINMUX_FUNCTIONS |
| 115 | |
| 116 | /** |
| 117 | * struct function_desc - generic function descriptor |
| 118 | * @name: name of the function |
| 119 | * @group_names: array of pin group names |
| 120 | * @num_group_names: number of pin group names |
| 121 | * @data: pin controller driver specific data |
| 122 | */ |
| 123 | struct function_desc { |
| 124 | const char *name; |
| 125 | const char **group_names; |
| 126 | int num_group_names; |
| 127 | void *data; |
| 128 | }; |
| 129 | |
| 130 | int pinmux_generic_get_function_count(struct pinctrl_dev *pctldev); |
| 131 | |
| 132 | const char * |
| 133 | pinmux_generic_get_function_name(struct pinctrl_dev *pctldev, |
| 134 | unsigned int selector); |
| 135 | |
| 136 | int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev, |
| 137 | unsigned int selector, |
| 138 | const char * const **groups, |
| 139 | unsigned * const num_groups); |
| 140 | |
| 141 | struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev, |
| 142 | unsigned int selector); |
| 143 | |
| 144 | int pinmux_generic_add_function(struct pinctrl_dev *pctldev, |
| 145 | const char *name, |
| 146 | const char **groups, |
| 147 | unsigned const num_groups, |
| 148 | void *data); |
| 149 | |
| 150 | int pinmux_generic_remove_function(struct pinctrl_dev *pctldev, |
| 151 | unsigned int selector); |
| 152 | |
| 153 | static inline int |
| 154 | pinmux_generic_remove_last_function(struct pinctrl_dev *pctldev) |
| 155 | { |
| 156 | return pinmux_generic_remove_function(pctldev, |
| 157 | pctldev->num_functions - 1); |
| 158 | } |
| 159 | |
| 160 | void pinmux_generic_free_functions(struct pinctrl_dev *pctldev); |
| 161 | |
| 162 | #else |
| 163 | |
| 164 | static inline void pinmux_generic_free_functions(struct pinctrl_dev *pctldev) |
| 165 | { |
| 166 | } |
| 167 | |
| 168 | #endif /* CONFIG_GENERIC_PINMUX_FUNCTIONS */ |