1
2
3
4
5
6
7#ifndef __PINCTRL_MEDIATEK_H__
8#define __PINCTRL_MEDIATEK_H__
9
10#define MTK_RANGE(_a) { .range = (_a), .nranges = ARRAY_SIZE(_a), }
11#define MTK_PIN(_number, _name, _drv_n) { \
12 .number = _number, \
13 .name = _name, \
14 .drv_n = _drv_n, \
15 }
16
17#define PINCTRL_PIN_GROUP(name, id) \
18 { \
19 name, \
20 id##_pins, \
21 ARRAY_SIZE(id##_pins), \
22 id##_funcs, \
23 }
24
25#define PIN_FIELD_CALC(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, \
26 _x_bits, _sz_reg, _fixed) { \
27 .s_pin = _s_pin, \
28 .e_pin = _e_pin, \
29 .s_addr = _s_addr, \
30 .x_addrs = _x_addrs, \
31 .s_bit = _s_bit, \
32 .x_bits = _x_bits, \
33 .sz_reg = _sz_reg, \
34 .fixed = _fixed, \
35 }
36
37
38enum {
39 PINCTRL_PIN_REG_MODE,
40 PINCTRL_PIN_REG_DIR,
41 PINCTRL_PIN_REG_DI,
42 PINCTRL_PIN_REG_DO,
43 PINCTRL_PIN_REG_IES,
44 PINCTRL_PIN_REG_SMT,
45 PINCTRL_PIN_REG_PULLEN,
46 PINCTRL_PIN_REG_PULLSEL,
47 PINCTRL_PIN_REG_DRV,
48 PINCTRL_PIN_REG_MAX,
49};
50
51
52enum {
53 DRV_FIXED,
54 DRV_GRP0,
55 DRV_GRP1,
56 DRV_GRP2,
57 DRV_GRP3,
58 DRV_GRP4,
59};
60
61
62
63
64
65
66
67
68
69
70struct mtk_pin_field {
71 u32 offset;
72 u32 mask;
73 u8 bitpos;
74 u8 next;
75};
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92struct mtk_pin_field_calc {
93 u16 s_pin;
94 u16 e_pin;
95 u32 s_addr;
96 u8 x_addrs;
97 u8 s_bit;
98 u8 x_bits;
99 u8 sz_reg;
100 u8 fixed;
101};
102
103
104
105
106
107
108
109
110struct mtk_pin_reg_calc {
111 const struct mtk_pin_field_calc *range;
112 unsigned int nranges;
113};
114
115
116
117
118
119
120
121
122struct mtk_pin_desc {
123 unsigned int number;
124 const char *name;
125 u8 drv_n;
126};
127
128
129
130
131
132
133
134
135struct mtk_group_desc {
136 const char *name;
137 int *pins;
138 int num_pins;
139 void *data;
140};
141
142
143
144
145
146
147
148struct mtk_function_desc {
149 const char *name;
150 const char * const *group_names;
151 int num_group_names;
152};
153
154
155struct mtk_pinctrl_soc {
156 const char *name;
157 const struct mtk_pin_reg_calc *reg_cal;
158 const struct mtk_pin_desc *pins;
159 int npins;
160 const struct mtk_group_desc *grps;
161 int ngrps;
162 const struct mtk_function_desc *funcs;
163 int nfuncs;
164};
165
166
167
168
169
170
171
172struct mtk_pinctrl_priv {
173 void __iomem *base;
174 struct mtk_pinctrl_soc *soc;
175};
176
177extern const struct pinctrl_ops mtk_pinctrl_ops;
178
179
180void mtk_rmw(struct udevice *dev, u32 reg, u32 mask, u32 set);
181int mtk_pinctrl_common_probe(struct udevice *dev,
182 struct mtk_pinctrl_soc *soc);
183
184#endif
185