1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef _PINCTRL_ROCKCHIP_H
19#define _PINCTRL_ROCKCHIP_H
20
21enum rockchip_pinctrl_type {
22 PX30,
23 RV1108,
24 RK2928,
25 RK3066B,
26 RK3128,
27 RK3188,
28 RK3288,
29 RK3308,
30 RK3368,
31 RK3399,
32 RK3568,
33};
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53struct rockchip_gpio_regs {
54 u32 port_dr;
55 u32 port_ddr;
56 u32 int_en;
57 u32 int_mask;
58 u32 int_type;
59 u32 int_polarity;
60 u32 int_bothedge;
61 u32 int_status;
62 u32 int_rawstatus;
63 u32 debounce;
64 u32 dbclk_div_en;
65 u32 dbclk_div_con;
66 u32 port_eoi;
67 u32 ext_port;
68 u32 version_id;
69};
70
71
72
73
74
75
76
77
78struct rockchip_iomux {
79 int type;
80 int offset;
81};
82
83
84
85
86enum rockchip_pin_drv_type {
87 DRV_TYPE_IO_DEFAULT = 0,
88 DRV_TYPE_IO_1V8_OR_3V0,
89 DRV_TYPE_IO_1V8_ONLY,
90 DRV_TYPE_IO_1V8_3V0_AUTO,
91 DRV_TYPE_IO_3V3_ONLY,
92 DRV_TYPE_MAX
93};
94
95
96
97
98enum rockchip_pin_pull_type {
99 PULL_TYPE_IO_DEFAULT = 0,
100 PULL_TYPE_IO_1V8_ONLY,
101 PULL_TYPE_MAX
102};
103
104
105
106
107
108
109
110
111
112
113struct rockchip_drv {
114 enum rockchip_pin_drv_type drv_type;
115 int offset;
116};
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147struct rockchip_pin_bank {
148 struct device *dev;
149 void __iomem *reg_base;
150 struct regmap *regmap_pull;
151 struct clk *clk;
152 struct clk *db_clk;
153 int irq;
154 u32 saved_masks;
155 u32 pin_base;
156 u8 nr_pins;
157 char *name;
158 u8 bank_num;
159 struct rockchip_iomux iomux[4];
160 struct rockchip_drv drv[4];
161 enum rockchip_pin_pull_type pull_type[4];
162 bool valid;
163 struct device_node *of_node;
164 struct rockchip_pinctrl *drvdata;
165 struct irq_domain *domain;
166 struct gpio_chip gpio_chip;
167 struct pinctrl_gpio_range grange;
168 raw_spinlock_t slock;
169 const struct rockchip_gpio_regs *gpio_regs;
170 u32 gpio_type;
171 u32 toggle_edge_mode;
172 u32 recalced_mask;
173 u32 route_mask;
174 struct list_head deferred_output;
175 struct mutex deferred_lock;
176};
177
178
179
180
181
182
183
184
185
186struct rockchip_mux_recalced_data {
187 u8 num;
188 u8 pin;
189 u32 reg;
190 u8 bit;
191 u8 mask;
192};
193
194enum rockchip_mux_route_location {
195 ROCKCHIP_ROUTE_SAME = 0,
196 ROCKCHIP_ROUTE_PMU,
197 ROCKCHIP_ROUTE_GRF,
198};
199
200
201
202
203
204
205
206
207
208
209struct rockchip_mux_route_data {
210 u8 bank_num;
211 u8 pin;
212 u8 func;
213 enum rockchip_mux_route_location route_location;
214 u32 route_offset;
215 u32 route_val;
216};
217
218struct rockchip_pin_ctrl {
219 struct rockchip_pin_bank *pin_banks;
220 u32 nr_banks;
221 u32 nr_pins;
222 char *label;
223 enum rockchip_pinctrl_type type;
224 int grf_mux_offset;
225 int pmu_mux_offset;
226 int grf_drv_offset;
227 int pmu_drv_offset;
228 struct rockchip_mux_recalced_data *iomux_recalced;
229 u32 niomux_recalced;
230 struct rockchip_mux_route_data *iomux_routes;
231 u32 niomux_routes;
232
233 void (*pull_calc_reg)(struct rockchip_pin_bank *bank,
234 int pin_num, struct regmap **regmap,
235 int *reg, u8 *bit);
236 void (*drv_calc_reg)(struct rockchip_pin_bank *bank,
237 int pin_num, struct regmap **regmap,
238 int *reg, u8 *bit);
239 int (*schmitt_calc_reg)(struct rockchip_pin_bank *bank,
240 int pin_num, struct regmap **regmap,
241 int *reg, u8 *bit);
242};
243
244struct rockchip_pin_config {
245 unsigned int func;
246 unsigned long *configs;
247 unsigned int nconfigs;
248};
249
250struct rockchip_pin_output_deferred {
251 struct list_head head;
252 unsigned int pin;
253 u32 arg;
254};
255
256
257
258
259
260
261
262
263struct rockchip_pin_group {
264 const char *name;
265 unsigned int npins;
266 unsigned int *pins;
267 struct rockchip_pin_config *data;
268};
269
270
271
272
273
274
275
276struct rockchip_pmx_func {
277 const char *name;
278 const char **groups;
279 u8 ngroups;
280};
281
282struct rockchip_pinctrl {
283 struct regmap *regmap_base;
284 int reg_size;
285 struct regmap *regmap_pull;
286 struct regmap *regmap_pmu;
287 struct device *dev;
288 struct rockchip_pin_ctrl *ctrl;
289 struct pinctrl_desc pctl;
290 struct pinctrl_dev *pctl_dev;
291 struct rockchip_pin_group *groups;
292 unsigned int ngroups;
293 struct rockchip_pmx_func *functions;
294 unsigned int nfunctions;
295};
296
297#endif
298