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