Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Internal interface between the core pin control system and the |
| 3 | * pin config 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 | |
| 14 | #ifdef CONFIG_PINCONF |
| 15 | |
Tony Lindgren | b9130b7 | 2012-01-24 16:28:08 -0800 | [diff] [blame] | 16 | int pinconf_check_ops(struct pinctrl_dev *pctldev); |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 17 | int pinconf_validate_map(const struct pinctrl_map *map, int i); |
| 18 | int pinconf_map_to_setting(const struct pinctrl_map *map, |
Stephen Warren | 1e2082b | 2012-03-02 13:05:48 -0700 | [diff] [blame] | 19 | struct pinctrl_setting *setting); |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 20 | void pinconf_free_setting(const struct pinctrl_setting *setting); |
| 21 | int pinconf_apply_setting(const struct pinctrl_setting *setting); |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 22 | |
Mika Westerberg | 15381bc | 2017-01-23 15:34:33 +0300 | [diff] [blame] | 23 | int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin, |
| 24 | unsigned long *configs, size_t nconfigs); |
| 25 | |
Linus Walleij | 394349f | 2011-11-24 18:27:15 +0100 | [diff] [blame] | 26 | /* |
| 27 | * You will only be interested in these if you're using PINCONF |
| 28 | * so don't supply any stubs for these. |
| 29 | */ |
| 30 | int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin, |
| 31 | unsigned long *config); |
| 32 | int pin_config_group_get(const char *dev_name, const char *pin_group, |
| 33 | unsigned long *config); |
| 34 | |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 35 | #else |
| 36 | |
Tony Lindgren | b9130b7 | 2012-01-24 16:28:08 -0800 | [diff] [blame] | 37 | static inline int pinconf_check_ops(struct pinctrl_dev *pctldev) |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +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 pinconf_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 | |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 47 | static inline int pinconf_map_to_setting(const struct pinctrl_map *map, |
Stephen Warren | 1e2082b | 2012-03-02 13:05:48 -0700 | [diff] [blame] | 48 | struct pinctrl_setting *setting) |
| 49 | { |
| 50 | return 0; |
| 51 | } |
| 52 | |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 53 | static inline void pinconf_free_setting(const struct pinctrl_setting *setting) |
Stephen Warren | 1e2082b | 2012-03-02 13:05:48 -0700 | [diff] [blame] | 54 | { |
| 55 | } |
| 56 | |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 57 | static inline int pinconf_apply_setting(const struct pinctrl_setting *setting) |
Stephen Warren | 1e2082b | 2012-03-02 13:05:48 -0700 | [diff] [blame] | 58 | { |
| 59 | return 0; |
| 60 | } |
| 61 | |
Mika Westerberg | 15381bc | 2017-01-23 15:34:33 +0300 | [diff] [blame] | 62 | static inline int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin, |
| 63 | unsigned long *configs, size_t nconfigs) |
| 64 | { |
| 65 | return -ENOTSUPP; |
| 66 | } |
| 67 | |
Stephen Warren | c736d73 | 2012-04-11 16:45:45 -0600 | [diff] [blame] | 68 | #endif |
| 69 | |
Viresh Kumar | 96593af | 2012-04-16 14:22:34 +0530 | [diff] [blame] | 70 | #if defined(CONFIG_PINCONF) && defined(CONFIG_DEBUG_FS) |
Stephen Warren | c736d73 | 2012-04-11 16:45:45 -0600 | [diff] [blame] | 71 | |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 72 | void pinconf_show_map(struct seq_file *s, const struct pinctrl_map *map); |
Stephen Warren | c736d73 | 2012-04-11 16:45:45 -0600 | [diff] [blame] | 73 | void pinconf_show_setting(struct seq_file *s, |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 74 | const struct pinctrl_setting *setting); |
Stephen Warren | c736d73 | 2012-04-11 16:45:45 -0600 | [diff] [blame] | 75 | void pinconf_init_device_debugfs(struct dentry *devroot, |
| 76 | struct pinctrl_dev *pctldev); |
| 77 | |
| 78 | #else |
| 79 | |
Stephen Warren | 1e2082b | 2012-03-02 13:05:48 -0700 | [diff] [blame] | 80 | static inline void pinconf_show_map(struct seq_file *s, |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 81 | const struct pinctrl_map *map) |
Stephen Warren | 1e2082b | 2012-03-02 13:05:48 -0700 | [diff] [blame] | 82 | { |
| 83 | } |
| 84 | |
| 85 | static inline void pinconf_show_setting(struct seq_file *s, |
Masahiro Yamada | 3f713b7 | 2017-08-04 11:22:31 +0900 | [diff] [blame] | 86 | const struct pinctrl_setting *setting) |
Stephen Warren | 1e2082b | 2012-03-02 13:05:48 -0700 | [diff] [blame] | 87 | { |
| 88 | } |
| 89 | |
Linus Walleij | ae6b4d8 | 2011-10-19 18:14:33 +0200 | [diff] [blame] | 90 | static inline void pinconf_init_device_debugfs(struct dentry *devroot, |
| 91 | struct pinctrl_dev *pctldev) |
| 92 | { |
| 93 | } |
| 94 | |
| 95 | #endif |
Linus Walleij | 394349f | 2011-11-24 18:27:15 +0100 | [diff] [blame] | 96 | |
| 97 | /* |
| 98 | * The following functions are available if the driver uses the generic |
| 99 | * pin config. |
| 100 | */ |
| 101 | |
Sachin Kamat | bf4d7be | 2013-03-13 17:13:46 +0530 | [diff] [blame] | 102 | #if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_DEBUG_FS) |
Linus Walleij | 394349f | 2011-11-24 18:27:15 +0100 | [diff] [blame] | 103 | |
Soren Brinkmann | dd4d01f | 2015-01-09 07:43:46 -0800 | [diff] [blame] | 104 | void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev, |
| 105 | struct seq_file *s, const char *gname, |
| 106 | unsigned pin); |
Linus Walleij | 394349f | 2011-11-24 18:27:15 +0100 | [diff] [blame] | 107 | |
Haojian Zhuang | 9cfd172 | 2013-02-17 19:42:53 +0800 | [diff] [blame] | 108 | void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, |
| 109 | struct seq_file *s, unsigned long config); |
Linus Walleij | 394349f | 2011-11-24 18:27:15 +0100 | [diff] [blame] | 110 | #else |
| 111 | |
Soren Brinkmann | dd4d01f | 2015-01-09 07:43:46 -0800 | [diff] [blame] | 112 | static inline void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev, |
| 113 | struct seq_file *s, |
| 114 | const char *gname, unsigned pin) |
Linus Walleij | 394349f | 2011-11-24 18:27:15 +0100 | [diff] [blame] | 115 | { |
| 116 | return; |
| 117 | } |
| 118 | |
Haojian Zhuang | 9cfd172 | 2013-02-17 19:42:53 +0800 | [diff] [blame] | 119 | static inline void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, |
| 120 | struct seq_file *s, |
| 121 | unsigned long config) |
| 122 | { |
| 123 | return; |
| 124 | } |
Linus Walleij | 394349f | 2011-11-24 18:27:15 +0100 | [diff] [blame] | 125 | #endif |
Heiko Stübner | 7db9af4 | 2013-06-10 21:40:29 +0200 | [diff] [blame] | 126 | |
| 127 | #if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_OF) |
| 128 | int pinconf_generic_parse_dt_config(struct device_node *np, |
Soren Brinkmann | dd4d01f | 2015-01-09 07:43:46 -0800 | [diff] [blame] | 129 | struct pinctrl_dev *pctldev, |
Heiko Stübner | 7db9af4 | 2013-06-10 21:40:29 +0200 | [diff] [blame] | 130 | unsigned long **configs, |
| 131 | unsigned int *nconfigs); |
| 132 | #endif |