1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
4 * This file is created based on MT8196 Functional Specification
8 #include <device/mmio.h>
11 static const struct gpio_drv_info gpio_driving_info
[] = {
12 [0] = { 0x00, 0, 3, },
13 [1] = { 0x00, 3, 3, },
14 [2] = { 0x00, 12, 3, },
15 [3] = { 0x00, 12, 3, },
16 [4] = { 0x00, 15, 3, },
17 [5] = { 0x00, 0, 3, },
18 [6] = { 0x00, 3, 3, },
19 [7] = { 0x00, 6, 3, },
20 [8] = { 0x00, 9, 3, },
21 [9] = { 0x10, 9, 3, },
22 [10] = { 0x10, 6, 3, },
23 [11] = { 0x00, 24, 3, },
24 [12] = { 0x10, 15, 3, },
25 [13] = { 0x00, 9, 3, },
26 [14] = { 0x00, 0, 3, },
27 [15] = { 0x00, 0, 3, },
28 [16] = { 0x00, 9, 3, },
29 [17] = { 0x00, 9, 3, },
30 [18] = { 0x00, 3, 3, },
31 [19] = { 0x00, 6, 3, },
32 [20] = { 0x00, 9, 3, },
33 [21] = { 0x00, 0, 3, },
34 [22] = { 0x00, 3, 3, },
35 [23] = { 0x00, 6, 3, },
36 [24] = { 0x00, 9, 3, },
37 [25] = { 0x00, 12, 3, },
38 [26] = { 0x00, 15, 3, },
39 [27] = { 0x10, 3, 3, },
40 [28] = { 0x00, 18, 3, },
41 [29] = { 0x00, 21, 3, },
42 [30] = { 0x00, 24, 3, },
43 [31] = { 0x00, 27, 3, },
44 [32] = { 0x00, 21, 3, },
45 [33] = { 0x00, 21, 3, },
46 [34] = { 0x00, 21, 3, },
47 [35] = { 0x00, 21, 3, },
48 [36] = { 0x00, 21, 3, },
49 [37] = { 0x00, 27, 3, },
50 [38] = { 0x00, 18, 3, },
51 [39] = { 0x00, 27, 3, },
52 [40] = { 0x00, 6, 3, },
53 [41] = { 0x00, 12, 3, },
54 [42] = { 0x00, 9, 3, },
55 [43] = { 0x00, 15, 3, },
56 [44] = { 0x00, 18, 3, },
57 [45] = { 0x00, 21, 3, },
58 [46] = { 0x10, 0, 3, },
59 [47] = { 0x10, 9, 3, },
60 [48] = { 0x10, 3, 3, },
61 [49] = { 0x10, 12, 3, },
62 [50] = { 0x10, 6, 3, },
63 [51] = { 0x10, 15, 3, },
64 [52] = { 0x00, 21, 3, },
65 [53] = { 0x00, 24, 3, },
66 [54] = { 0x00, 6, 3, },
67 [55] = { 0x00, 3, 3, },
68 [56] = { 0x00, 15, 3, },
69 [57] = { 0x00, 18, 3, },
70 [58] = { 0x00, 9, 3, },
71 [59] = { 0x00, 12, 3, },
72 [60] = { 0x10, 24, 3, },
73 [61] = { 0x10, 0, 3, },
74 [62] = { 0x00, 27, 3, },
75 [63] = { 0x10, 12, 3, },
76 [64] = { 0x00, 0, 3, },
77 [65] = { 0x10, 3, 3, },
78 [66] = { 0x10, 27, 3, },
79 [67] = { 0x10, 21, 3, },
80 [68] = { 0x10, 21, 3, },
81 [69] = { 0x10, 21, 3, },
82 [70] = { 0x10, 18, 3, },
83 [71] = { 0x10, 18, 3, },
84 [72] = { 0x10, 21, 3, },
85 [73] = { 0x10, 18, 3, },
86 [74] = { 0x10, 18, 3, },
87 [75] = { 0x00, 6, 3, },
88 [76] = { 0x00, 9, 3, },
89 [77] = { 0x00, 12, 3, },
90 [78] = { 0x00, 15, 3, },
91 [79] = { 0x00, 0, 3, },
92 [80] = { 0x00, 3, 3, },
93 [81] = { 0x00, 18, 3, },
94 [82] = { 0x00, 21, 3, },
95 [83] = { 0x00, 27, 3, },
96 [84] = { 0x00, 24, 3, },
97 [85] = { 0x10, 0, 3, },
98 [86] = { 0x10, 3, 3, },
99 [87] = { 0x10, 9, 3, },
100 [88] = { 0x10, 6, 3, },
101 [89] = { 0x00, 12, 3, },
102 [90] = { 0x00, 12, 3, },
103 [91] = { 0x00, 15, 3, },
104 [92] = { 0x00, 15, 3, },
105 [93] = { 0x00, 15, 3, },
106 [94] = { 0x00, 12, 3, },
107 [95] = { 0x00, 0, 3, },
108 [96] = { 0x00, 6, 3, },
109 [97] = { 0x00, 3, 3, },
110 [98] = { 0x00, 9, 3, },
111 [99] = { 0x00, 18, 3, },
112 [100] = { 0x00, 27, 3, },
113 [101] = { 0x00, 21, 3, },
114 [102] = { 0x10, 0, 3, },
115 [103] = { 0x00, 12, 3, },
116 [104] = { 0x00, 24, 3, },
117 [105] = { 0x10, 3, 3, },
118 [106] = { 0x00, 0, 3, },
119 [107] = { 0x00, 3, 3, },
120 [108] = { 0x00, 9, 3, },
121 [109] = { 0x00, 6, 3, },
122 [110] = { 0x00, 12, 3, },
123 [111] = { 0x00, 15, 3, },
124 [112] = { 0x00, 21, 3, },
125 [113] = { 0x00, 18, 3, },
126 [114] = { 0x00, 24, 3, },
127 [115] = { 0x00, 27, 3, },
128 [116] = { 0x10, 3, 3, },
129 [117] = { 0x10, 0, 3, },
130 [118] = { 0x00, 18, 3, },
131 [119] = { 0x00, 21, 3, },
132 [120] = { 0x00, 27, 3, },
133 [121] = { 0x00, 24, 3, },
134 [122] = { 0x00, 9, 3, },
135 [123] = { 0x00, 12, 3, },
136 [124] = { 0x00, 15, 3, },
137 [125] = { 0x00, 0, 3, },
138 [126] = { 0x00, 3, 3, },
139 [127] = { 0x00, 6, 3, },
140 [128] = { 0x00, 9, 3, },
141 [129] = { 0x00, 12, 3, },
142 [130] = { 0x00, 15, 3, },
143 [131] = { 0x00, 27, 3, },
144 [132] = { 0x10, 3, 3, },
145 [133] = { 0x10, 0, 3, },
146 [134] = { 0x00, 18, 3, },
147 [135] = { 0x00, 24, 3, },
148 [136] = { 0x00, 21, 3, },
149 [137] = { 0x00, 6, 3, },
150 [138] = { 0x00, 9, 3, },
151 [139] = { 0x00, 12, 3, },
152 [140] = { 0x00, 15, 3, },
153 [141] = { 0x00, 18, 3, },
154 [142] = { 0x00, 21, 3, },
155 [143] = { 0x00, 24, 3, },
156 [144] = { 0x00, 27, 3, },
157 [145] = { 0x10, 0, 3, },
158 [146] = { 0x10, 0, 3, },
159 [147] = { 0x00, 0, 3, },
160 [148] = { 0x00, 3, 3, },
161 [149] = { 0x10, 3, 3, },
162 [150] = { 0x10, 3, 3, },
163 [151] = { 0x10, 3, 3, },
164 [152] = { 0x10, 3, 3, },
165 [153] = { 0x10, 12, 3, },
166 [154] = { 0x10, 9, 3, },
167 [155] = { 0x10, 6, 3, },
168 [156] = { 0x10, 6, 3, },
169 [157] = { 0x10, 0, 3, },
170 [158] = { 0x10, 0, 3, },
171 [159] = { 0x10, 0, 3, },
172 [160] = { 0x00, 3, 3, },
173 [161] = { 0x00, 6, 3, },
174 [162] = { 0x00, 6, 3, },
175 [163] = { 0x00, 6, 3, },
176 [164] = { 0x00, 18, 3, },
177 [165] = { 0x00, 24, 3, },
178 [166] = { 0x00, 21, 3, },
179 [167] = { 0x00, 27, 3, },
180 [168] = { 0x10, 0, 3, },
181 [169] = { 0x10, 3, 3, },
182 [170] = { 0x10, 9, 3, },
183 [171] = { 0x10, 6, 3, },
184 [172] = { 0x00, 9, 3, },
185 [173] = { 0x00, 9, 3, },
186 [174] = { 0x00, 27, 3, },
187 [175] = { 0x00, 27, 3, },
188 [176] = { 0x10, 0, 3, },
189 [177] = { 0x10, 3, 3, },
190 [178] = { 0x00, 24, 3, },
191 [179] = { 0x00, 24, 3, },
192 [180] = { 0x00, 0, 3, },
193 [181] = { 0x00, 3, 3, },
194 [182] = { 0x00, 6, 3, },
195 [183] = { 0x00, 9, 3, },
196 [184] = { 0x00, 12, 3, },
197 [185] = { 0x00, 15, 3, },
198 [186] = { 0x10, 12, 3, },
199 [187] = { 0x10, 12, 3, },
200 [188] = { 0x00, 12, 3, },
201 [189] = { 0x00, 27, 3, },
202 [190] = { 0x00, 15, 3, },
203 [191] = { 0x10, 0, 3, },
204 [192] = { 0x00, 0, 3, },
205 [193] = { 0x10, 15, 3, },
206 [194] = { 0x00, 18, 3, },
207 [195] = { 0x10, 3, 3, },
208 [196] = { 0x00, 3, 3, },
209 [197] = { 0x10, 18, 3, },
210 [198] = { 0x00, 21, 3, },
211 [199] = { 0x10, 6, 3, },
212 [200] = { 0x10, 27, 3, },
213 [201] = { 0x20, 6, 3, },
214 [202] = { 0x00, 24, 3, },
215 [203] = { 0x10, 9, 3, },
216 [204] = { 0x00, 6, 3, },
217 [205] = { 0x00, 9, 3, },
218 [206] = { 0x10, 24, 3, },
219 [207] = { 0x10, 21, 3, },
220 [208] = { 0x10, 21, 3, },
221 [209] = { 0x10, 21, 3, },
222 [210] = { 0x00, 0, 3, },
223 [211] = { 0x00, 3, 3, },
224 [212] = { 0x00, 6, 3, },
225 [213] = { 0x00, 9, 3, },
226 [214] = { 0x20, 0, 3, },
227 [215] = { 0x20, 3, 3, },
228 [216] = { 0x10, 6, 3, },
229 [217] = { 0x10, 6, 3, },
230 [218] = { 0x00, 15, 3, },
231 [219] = { 0x00, 12, 3, },
232 [220] = { 0x20, 3, 3, },
233 [221] = { 0x20, 6, 3, },
234 [222] = { 0x20, 12, 3, },
235 [223] = { 0x20, 9, 3, },
236 [224] = { 0x00, 18, 3, },
237 [225] = { 0x00, 21, 3, },
238 [226] = { 0x00, 24, 3, },
239 [227] = { 0x00, 27, 3, },
240 [228] = { 0x10, 0, 3, },
241 [229] = { 0x10, 3, 3, },
242 [230] = { 0x00, 0, 3, },
243 [231] = { 0x00, 0, 3, },
244 [232] = { 0x00, 0, 3, },
245 [233] = { 0x00, 3, 3, },
246 [234] = { 0x00, 3, 3, },
247 [235] = { 0x00, 3, 3, },
248 [236] = { 0x00, 3, 3, },
249 [237] = { 0x00, 6, 3, },
250 [238] = { 0x00, 6, 3, },
251 [239] = { 0x00, 6, 3, },
252 [240] = { 0x00, 6, 3, },
253 [241] = { 0x00, 9, 3, },
254 [242] = { 0x00, 9, 3, },
255 [243] = { 0x00, 9, 3, },
256 [244] = { 0x00, 9, 3, },
257 [245] = { 0x00, 12, 3, },
258 [246] = { 0x00, 15, 3, },
259 [247] = { 0x00, 15, 3, },
260 [248] = { 0x00, 12, 3, },
261 [249] = { 0x00, 12, 3, },
262 [250] = { 0x00, 12, 3, },
263 [251] = { 0x00, 9, 3, },
264 [252] = { 0x00, 12, 3, },
265 [253] = { 0x00, 12, 3, },
266 [254] = { 0x00, 12, 3, },
267 [255] = { 0x00, 12, 3, },
268 [256] = { 0x00, 15, 3, },
269 [257] = { 0x00, 15, 3, },
270 [258] = { 0x00, 15, 3, },
271 [259] = { 0x10, 9, 3, },
272 [260] = { 0x10, 12, 3, },
273 [261] = { 0x10, 15, 3, },
274 [262] = { 0x10, 18, 3, },
275 [263] = { 0x10, 21, 3, },
276 [264] = { 0x10, 24, 3, },
277 [265] = { 0x10, 27, 3, },
278 [266] = { 0x20, 0, 3, },
279 [267] = { 0x00, 24, 3, },
280 [268] = { 0x00, 27, 3, },
281 [269] = { 0x00, 18, 3, },
282 [270] = { 0x00, 21, 3, },
284 _Static_assert(ARRAY_SIZE(gpio_driving_info
) == GPIO_NUM
,
285 "gpio_driving_info array size not match");
287 static const struct gpio_drv_info gpio_driving_adv_info
[] = {
288 [46] = { 0x30, 0, 3, },
289 [47] = { 0x30, 9, 3, },
290 [48] = { 0x30, 3, 3, },
291 [49] = { 0x30, 12, 3, },
292 [50] = { 0x30, 6, 3, },
293 [51] = { 0x30, 15, 3, },
294 [52] = { 0x30, 0, 3, },
295 [53] = { 0x30, 3, 3, },
296 [75] = { 0x20, 0, 5, },
297 [76] = { 0x20, 5, 5, },
298 [77] = { 0x20, 10, 5, },
299 [78] = { 0x20, 15, 5, },
300 [99] = { 0x20, 0, 3, },
301 [100] = { 0x20, 9, 3, },
302 [101] = { 0x20, 3, 3, },
303 [102] = { 0x20, 12, 3, },
304 [104] = { 0x20, 6, 3, },
305 [105] = { 0x20, 15, 3, },
306 [123] = { 0x20, 0, 3, },
307 [124] = { 0x20, 3, 3, },
308 [164] = { 0x20, 0, 3, },
309 [165] = { 0x20, 6, 3, },
310 [166] = { 0x20, 3, 3, },
311 [167] = { 0x20, 9, 3, },
312 [168] = { 0x20, 12, 3, },
313 [170] = { 0x20, 15, 3, },
314 [176] = { 0x20, 0, 3, },
315 [177] = { 0x20, 3, 3, },
316 [188] = { 0x40, 0, 3, },
317 [189] = { 0x40, 15, 3, },
318 [190] = { 0x40, 3, 3, },
319 [191] = { 0x40, 18, 3, },
320 [194] = { 0x40, 6, 3, },
321 [195] = { 0x40, 21, 3, },
322 [198] = { 0x40, 9, 3, },
323 [199] = { 0x40, 24, 3, },
324 [200] = { 0x50, 0, 3, },
325 [201] = { 0x50, 9, 3, },
326 [202] = { 0x40, 12, 3, },
327 [203] = { 0x40, 27, 3, },
328 [214] = { 0x50, 3, 3, },
329 [215] = { 0x50, 6, 3, },
332 void *gpio_find_reg_addr(gpio_t gpio
)
336 switch (gpio
.base
& 0x0f) {
338 reg_addr
= (void *)IOCFG_RT_BASE
;
341 reg_addr
= (void *)IOCFG_RM1_BASE
;
344 reg_addr
= (void *)IOCFG_RM2_BASE
;
347 reg_addr
= (void *)IOCFG_RB_BASE
;
350 reg_addr
= (void *)IOCFG_BM1_BASE
;
353 reg_addr
= (void *)IOCFG_BM2_BASE
;
356 reg_addr
= (void *)IOCFG_BM3_BASE
;
359 reg_addr
= (void *)IOCFG_LT_BASE
;
362 reg_addr
= (void *)IOCFG_LM1_BASE
;
365 reg_addr
= (void *)IOCFG_LM2_BASE
;
368 reg_addr
= (void *)IOCFG_LB1_BASE
;
371 reg_addr
= (void *)IOCFG_LB2_BASE
;
374 reg_addr
= (void *)IOCFG_TM1_BASE
;
377 reg_addr
= (void *)IOCFG_TM2_BASE
;
380 reg_addr
= (void *)IOCFG_TM3_BASE
;
390 const struct gpio_drv_info
*get_gpio_driving_info(uint32_t raw_id
)
392 if (raw_id
>= ARRAY_SIZE(gpio_driving_info
))
394 return &gpio_driving_info
[raw_id
];
397 const struct gpio_drv_info
*get_gpio_driving_adv_info(uint32_t raw_id
)
399 if (raw_id
>= ARRAY_SIZE(gpio_driving_adv_info
))
401 return &gpio_driving_adv_info
[raw_id
];