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