1
2
3
4
5
6
7
8
9
10
11
12#ifndef __LINUX_PINCTRL_PINCTRL_H
13#define __LINUX_PINCTRL_PINCTRL_H
14
15#ifdef CONFIG_PINCTRL
16
17#include <linux/radix-tree.h>
18#include <linux/list.h>
19#include <linux/seq_file.h>
20#include <linux/pinctrl/pinctrl-state.h>
21
22struct device;
23struct pinctrl_dev;
24struct pinctrl_map;
25struct pinmux_ops;
26struct pinconf_ops;
27struct pin_config_item;
28struct gpio_chip;
29struct device_node;
30
31
32
33
34
35
36
37
38struct pinctrl_pin_desc {
39 unsigned number;
40 const char *name;
41 void *drv_data;
42};
43
44
45#define PINCTRL_PIN(a, b) { .number = a, .name = b }
46#define PINCTRL_PIN_ANON(a) { .number = a }
47
48
49
50
51
52
53
54
55
56
57
58
59
60struct pinctrl_gpio_range {
61 struct list_head node;
62 const char *name;
63 unsigned int id;
64 unsigned int base;
65 unsigned int pin_base;
66 unsigned const *pins;
67 unsigned int npins;
68 struct gpio_chip *gc;
69};
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90struct pinctrl_ops {
91 int (*get_groups_count) (struct pinctrl_dev *pctldev);
92 const char *(*get_group_name) (struct pinctrl_dev *pctldev,
93 unsigned selector);
94 int (*get_group_pins) (struct pinctrl_dev *pctldev,
95 unsigned selector,
96 const unsigned **pins,
97 unsigned *num_pins);
98 void (*pin_dbg_show) (struct pinctrl_dev *pctldev, struct seq_file *s,
99 unsigned offset);
100 int (*dt_node_to_map) (struct pinctrl_dev *pctldev,
101 struct device_node *np_config,
102 struct pinctrl_map **map, unsigned *num_maps);
103 void (*dt_free_map) (struct pinctrl_dev *pctldev,
104 struct pinctrl_map *map, unsigned num_maps);
105};
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128struct pinctrl_desc {
129 const char *name;
130 const struct pinctrl_pin_desc *pins;
131 unsigned int npins;
132 const struct pinctrl_ops *pctlops;
133 const struct pinmux_ops *pmxops;
134 const struct pinconf_ops *confops;
135 struct module *owner;
136#ifdef CONFIG_GENERIC_PINCONF
137 unsigned int num_custom_params;
138 const struct pinconf_generic_params *custom_params;
139 const struct pin_config_item *custom_conf_items;
140#endif
141};
142
143
144extern struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
145 struct device *dev, void *driver_data);
146extern void pinctrl_unregister(struct pinctrl_dev *pctldev);
147extern bool pin_is_valid(struct pinctrl_dev *pctldev, int pin);
148extern void pinctrl_add_gpio_range(struct pinctrl_dev *pctldev,
149 struct pinctrl_gpio_range *range);
150extern void pinctrl_add_gpio_ranges(struct pinctrl_dev *pctldev,
151 struct pinctrl_gpio_range *ranges,
152 unsigned nranges);
153extern void pinctrl_remove_gpio_range(struct pinctrl_dev *pctldev,
154 struct pinctrl_gpio_range *range);
155
156extern struct pinctrl_dev *pinctrl_find_and_add_gpio_range(const char *devname,
157 struct pinctrl_gpio_range *range);
158extern struct pinctrl_gpio_range *
159pinctrl_find_gpio_range_from_pin(struct pinctrl_dev *pctldev,
160 unsigned int pin);
161extern int pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
162 const char *pin_group, const unsigned **pins,
163 unsigned *num_pins);
164
165#ifdef CONFIG_OF
166extern struct pinctrl_dev *of_pinctrl_get(struct device_node *np);
167#else
168static inline
169struct pinctrl_dev *of_pinctrl_get(struct device_node *np)
170{
171 return NULL;
172}
173#endif
174
175extern const char *pinctrl_dev_get_name(struct pinctrl_dev *pctldev);
176extern const char *pinctrl_dev_get_devname(struct pinctrl_dev *pctldev);
177extern void *pinctrl_dev_get_drvdata(struct pinctrl_dev *pctldev);
178#else
179
180struct pinctrl_dev;
181
182
183static inline bool pin_is_valid(struct pinctrl_dev *pctldev, int pin)
184{
185 return pin >= 0;
186}
187
188#endif
189
190#endif
191