1
2
3
4
5
6
7
8
9
10
11#ifndef __LINUX_PINCTRL_MACHINE_H
12#define __LINUX_PINCTRL_MACHINE_H
13
14#include <linux/bug.h>
15
16#include <linux/pinctrl/pinctrl-state.h>
17
18enum pinctrl_map_type {
19 PIN_MAP_TYPE_INVALID,
20 PIN_MAP_TYPE_DUMMY_STATE,
21 PIN_MAP_TYPE_MUX_GROUP,
22 PIN_MAP_TYPE_CONFIGS_PIN,
23 PIN_MAP_TYPE_CONFIGS_GROUP,
24};
25
26
27
28
29
30
31
32
33struct pinctrl_map_mux {
34 const char *group;
35 const char *function;
36};
37
38
39
40
41
42
43
44
45
46
47struct pinctrl_map_configs {
48 const char *group_or_pin;
49 unsigned long *configs;
50 unsigned num_configs;
51};
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67struct pinctrl_map {
68 const char *dev_name;
69 const char *name;
70 enum pinctrl_map_type type;
71 const char *ctrl_dev_name;
72 union {
73 struct pinctrl_map_mux mux;
74 struct pinctrl_map_configs configs;
75 } data;
76};
77
78
79
80#define PIN_MAP_DUMMY_STATE(dev, state) \
81 { \
82 .dev_name = dev, \
83 .name = state, \
84 .type = PIN_MAP_TYPE_DUMMY_STATE, \
85 }
86
87#define PIN_MAP_MUX_GROUP(dev, state, pinctrl, grp, func) \
88 { \
89 .dev_name = dev, \
90 .name = state, \
91 .type = PIN_MAP_TYPE_MUX_GROUP, \
92 .ctrl_dev_name = pinctrl, \
93 .data.mux = { \
94 .group = grp, \
95 .function = func, \
96 }, \
97 }
98
99#define PIN_MAP_MUX_GROUP_DEFAULT(dev, pinctrl, grp, func) \
100 PIN_MAP_MUX_GROUP(dev, PINCTRL_STATE_DEFAULT, pinctrl, grp, func)
101
102#define PIN_MAP_MUX_GROUP_HOG(dev, state, grp, func) \
103 PIN_MAP_MUX_GROUP(dev, state, dev, grp, func)
104
105#define PIN_MAP_MUX_GROUP_HOG_DEFAULT(dev, grp, func) \
106 PIN_MAP_MUX_GROUP(dev, PINCTRL_STATE_DEFAULT, dev, grp, func)
107
108#define PIN_MAP_CONFIGS_PIN(dev, state, pinctrl, pin, cfgs) \
109 { \
110 .dev_name = dev, \
111 .name = state, \
112 .type = PIN_MAP_TYPE_CONFIGS_PIN, \
113 .ctrl_dev_name = pinctrl, \
114 .data.configs = { \
115 .group_or_pin = pin, \
116 .configs = cfgs, \
117 .num_configs = ARRAY_SIZE(cfgs), \
118 }, \
119 }
120
121#define PIN_MAP_CONFIGS_PIN_DEFAULT(dev, pinctrl, pin, cfgs) \
122 PIN_MAP_CONFIGS_PIN(dev, PINCTRL_STATE_DEFAULT, pinctrl, pin, cfgs)
123
124#define PIN_MAP_CONFIGS_PIN_HOG(dev, state, pin, cfgs) \
125 PIN_MAP_CONFIGS_PIN(dev, state, dev, pin, cfgs)
126
127#define PIN_MAP_CONFIGS_PIN_HOG_DEFAULT(dev, pin, cfgs) \
128 PIN_MAP_CONFIGS_PIN(dev, PINCTRL_STATE_DEFAULT, dev, pin, cfgs)
129
130#define PIN_MAP_CONFIGS_GROUP(dev, state, pinctrl, grp, cfgs) \
131 { \
132 .dev_name = dev, \
133 .name = state, \
134 .type = PIN_MAP_TYPE_CONFIGS_GROUP, \
135 .ctrl_dev_name = pinctrl, \
136 .data.configs = { \
137 .group_or_pin = grp, \
138 .configs = cfgs, \
139 .num_configs = ARRAY_SIZE(cfgs), \
140 }, \
141 }
142
143#define PIN_MAP_CONFIGS_GROUP_DEFAULT(dev, pinctrl, grp, cfgs) \
144 PIN_MAP_CONFIGS_GROUP(dev, PINCTRL_STATE_DEFAULT, pinctrl, grp, cfgs)
145
146#define PIN_MAP_CONFIGS_GROUP_HOG(dev, state, grp, cfgs) \
147 PIN_MAP_CONFIGS_GROUP(dev, state, dev, grp, cfgs)
148
149#define PIN_MAP_CONFIGS_GROUP_HOG_DEFAULT(dev, grp, cfgs) \
150 PIN_MAP_CONFIGS_GROUP(dev, PINCTRL_STATE_DEFAULT, dev, grp, cfgs)
151
152#ifdef CONFIG_PINCTRL
153
154extern int pinctrl_register_mappings(const struct pinctrl_map *map,
155 unsigned num_maps);
156extern void pinctrl_unregister_mappings(const struct pinctrl_map *map);
157extern void pinctrl_provide_dummies(void);
158#else
159
160static inline int pinctrl_register_mappings(const struct pinctrl_map *map,
161 unsigned num_maps)
162{
163 return 0;
164}
165
166static inline void pinctrl_unregister_mappings(const struct pinctrl_map *map)
167{
168}
169
170static inline void pinctrl_provide_dummies(void)
171{
172}
173#endif
174#endif
175