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