GNU Linux-libre 4.14.332-gnu1
[releases.git] / drivers / pinctrl / pinconf.h
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
16 int pinconf_check_ops(struct pinctrl_dev *pctldev);
17 int pinconf_validate_map(const struct pinctrl_map *map, int i);
18 int pinconf_map_to_setting(const struct pinctrl_map *map,
19                           struct pinctrl_setting *setting);
20 void pinconf_free_setting(const struct pinctrl_setting *setting);
21 int pinconf_apply_setting(const struct pinctrl_setting *setting);
22
23 int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin,
24                        unsigned long *configs, size_t nconfigs);
25
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
35 #else
36
37 static inline int pinconf_check_ops(struct pinctrl_dev *pctldev)
38 {
39         return 0;
40 }
41
42 static inline int pinconf_validate_map(const struct pinctrl_map *map, int i)
43 {
44         return 0;
45 }
46
47 static inline int pinconf_map_to_setting(const struct pinctrl_map *map,
48                           struct pinctrl_setting *setting)
49 {
50         return 0;
51 }
52
53 static inline void pinconf_free_setting(const struct pinctrl_setting *setting)
54 {
55 }
56
57 static inline int pinconf_apply_setting(const struct pinctrl_setting *setting)
58 {
59         return 0;
60 }
61
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
68 #endif
69
70 #if defined(CONFIG_PINCONF) && defined(CONFIG_DEBUG_FS)
71
72 void pinconf_show_map(struct seq_file *s, const struct pinctrl_map *map);
73 void pinconf_show_setting(struct seq_file *s,
74                           const struct pinctrl_setting *setting);
75 void pinconf_init_device_debugfs(struct dentry *devroot,
76                                  struct pinctrl_dev *pctldev);
77
78 #else
79
80 static inline void pinconf_show_map(struct seq_file *s,
81                                     const struct pinctrl_map *map)
82 {
83 }
84
85 static inline void pinconf_show_setting(struct seq_file *s,
86                                         const struct pinctrl_setting *setting)
87 {
88 }
89
90 static inline void pinconf_init_device_debugfs(struct dentry *devroot,
91                                                struct pinctrl_dev *pctldev)
92 {
93 }
94
95 #endif
96
97 /*
98  * The following functions are available if the driver uses the generic
99  * pin config.
100  */
101
102 #if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_DEBUG_FS)
103
104 void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev,
105                                struct seq_file *s, const char *gname,
106                                unsigned pin);
107
108 void pinconf_generic_dump_config(struct pinctrl_dev *pctldev,
109                                  struct seq_file *s, unsigned long config);
110 #else
111
112 static inline void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev,
113                                              struct seq_file *s,
114                                              const char *gname, unsigned pin)
115 {
116         return;
117 }
118
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 }
125 #endif
126
127 #if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_OF)
128 int pinconf_generic_parse_dt_config(struct device_node *np,
129                                     struct pinctrl_dev *pctldev,
130                                     unsigned long **configs,
131                                     unsigned int *nconfigs);
132 #endif