1 /* SPDX-License-Identifier: GPL-2.0-only */
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>
11 */
12
13 #include <linux/errno.h>
14
15 struct dentry;
16 struct device_node;
17 struct seq_file;
18
19 struct pinctrl_dev;
20 struct pinctrl_map;
21 struct pinctrl_setting;
22
23 #ifdef CONFIG_PINCONF
24
25 int pinconf_check_ops(struct pinctrl_dev *pctldev);
26 int pinconf_validate_map(const struct pinctrl_map *map, int i);
27 int pinconf_map_to_setting(const struct pinctrl_map *map,
28 struct pinctrl_setting *setting);
29 void pinconf_free_setting(const struct pinctrl_setting *setting);
30 int pinconf_apply_setting(const struct pinctrl_setting *setting);
31
32 int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin,
33 unsigned long *configs, size_t nconfigs);
34
35 /*
36 * You will only be interested in these if you're using PINCONF
37 * so don't supply any stubs for these.
38 */
39 int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
40 unsigned long *config);
41 int pin_config_group_get(const char *dev_name, const char *pin_group,
42 unsigned long *config);
43
44 #else
45
pinconf_check_ops(struct pinctrl_dev * pctldev)46 static inline int pinconf_check_ops(struct pinctrl_dev *pctldev)
47 {
48 return 0;
49 }
50
pinconf_validate_map(const struct pinctrl_map * map,int i)51 static inline int pinconf_validate_map(const struct pinctrl_map *map, int i)
52 {
53 return 0;
54 }
55
pinconf_map_to_setting(const struct pinctrl_map * map,struct pinctrl_setting * setting)56 static inline int pinconf_map_to_setting(const struct pinctrl_map *map,
57 struct pinctrl_setting *setting)
58 {
59 return 0;
60 }
61
pinconf_free_setting(const struct pinctrl_setting * setting)62 static inline void pinconf_free_setting(const struct pinctrl_setting *setting)
63 {
64 }
65
pinconf_apply_setting(const struct pinctrl_setting * setting)66 static inline int pinconf_apply_setting(const struct pinctrl_setting *setting)
67 {
68 return 0;
69 }
70
pinconf_set_config(struct pinctrl_dev * pctldev,unsigned pin,unsigned long * configs,size_t nconfigs)71 static inline int pinconf_set_config(struct pinctrl_dev *pctldev, unsigned pin,
72 unsigned long *configs, size_t nconfigs)
73 {
74 return -ENOTSUPP;
75 }
76
77 #endif
78
79 #if defined(CONFIG_PINCONF) && defined(CONFIG_DEBUG_FS)
80
81 void pinconf_show_map(struct seq_file *s, const struct pinctrl_map *map);
82 void pinconf_show_setting(struct seq_file *s,
83 const struct pinctrl_setting *setting);
84 void pinconf_init_device_debugfs(struct dentry *devroot,
85 struct pinctrl_dev *pctldev);
86
87 #else
88
pinconf_show_map(struct seq_file * s,const struct pinctrl_map * map)89 static inline void pinconf_show_map(struct seq_file *s,
90 const struct pinctrl_map *map)
91 {
92 }
93
pinconf_show_setting(struct seq_file * s,const struct pinctrl_setting * setting)94 static inline void pinconf_show_setting(struct seq_file *s,
95 const struct pinctrl_setting *setting)
96 {
97 }
98
pinconf_init_device_debugfs(struct dentry * devroot,struct pinctrl_dev * pctldev)99 static inline void pinconf_init_device_debugfs(struct dentry *devroot,
100 struct pinctrl_dev *pctldev)
101 {
102 }
103
104 #endif
105
106 /*
107 * The following functions are available if the driver uses the generic
108 * pin config.
109 */
110
111 #if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_DEBUG_FS)
112
113 void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev,
114 struct seq_file *s, const char *gname,
115 unsigned pin);
116
117 void pinconf_generic_dump_config(struct pinctrl_dev *pctldev,
118 struct seq_file *s, unsigned long config);
119 #else
120
pinconf_generic_dump_pins(struct pinctrl_dev * pctldev,struct seq_file * s,const char * gname,unsigned pin)121 static inline void pinconf_generic_dump_pins(struct pinctrl_dev *pctldev,
122 struct seq_file *s,
123 const char *gname, unsigned pin)
124 {
125 return;
126 }
127
pinconf_generic_dump_config(struct pinctrl_dev * pctldev,struct seq_file * s,unsigned long config)128 static inline void pinconf_generic_dump_config(struct pinctrl_dev *pctldev,
129 struct seq_file *s,
130 unsigned long config)
131 {
132 return;
133 }
134 #endif
135
136 #if defined(CONFIG_GENERIC_PINCONF) && defined(CONFIG_OF)
137 int pinconf_generic_parse_dt_config(struct device_node *np,
138 struct pinctrl_dev *pctldev,
139 unsigned long **configs,
140 unsigned int *nconfigs);
141 #endif
142