blob: bc12590e583604c96f643084072ddfac79824291 [file] [log] [blame]
Ryan Chen1efbd142021-11-02 10:17:52 +08001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) ASPEED Technology Inc.
4 */
5
Ryan Chen1efbd142021-11-02 10:17:52 +08006#include <errno.h>
7#include <asm/arch/pinctrl.h>
8#include <asm/arch/scu_ast2600.h>
9#include <asm/io.h>
10#include <dm.h>
11#include <dm/pinctrl.h>
12#include <linux/bitops.h>
13#include <linux/err.h>
14
15/*
16 * This driver works with very simple configuration that has the same name
17 * for group and function. This way it is compatible with the Linux Kernel
18 * driver.
19 */
20struct aspeed_sig_desc {
21 u32 offset;
22 u32 reg_set;
23 int clr;
24};
25
26struct aspeed_group_config {
27 char *group_name;
28 int ndescs;
29 struct aspeed_sig_desc *descs;
30};
31
32struct ast2600_pinctrl_priv {
33 struct ast2600_scu *scu;
34};
35
36static int ast2600_pinctrl_probe(struct udevice *dev)
37{
38 struct ast2600_pinctrl_priv *priv = dev_get_priv(dev);
39 struct udevice *clk_dev;
40 int ret = 0;
41
42 /* find SCU base address from clock device */
43 uclass_get_device_by_driver(UCLASS_CLK, DM_DRIVER_GET(aspeed_ast2600_scu), &clk_dev);
44
45 if (ret)
46 return ret;
47
48 priv->scu = dev_read_addr_ptr(clk_dev);
49 if (IS_ERR(priv->scu))
50 return PTR_ERR(priv->scu);
51
52 return 0;
53}
54
55static struct aspeed_sig_desc i2c1_link[] = {
56 { 0x418, GENMASK(9, 8), 1 },
57 { 0x4B8, GENMASK(9, 8), 0 },
58};
59
60static struct aspeed_sig_desc i2c2_link[] = {
61 { 0x418, GENMASK(11, 10), 1 },
62 { 0x4B8, GENMASK(11, 10), 0 },
63};
64
65static struct aspeed_sig_desc i2c3_link[] = {
66 { 0x418, GENMASK(13, 12), 1 },
67 { 0x4B8, GENMASK(13, 12), 0 },
68};
69
70static struct aspeed_sig_desc i2c4_link[] = {
71 { 0x418, GENMASK(15, 14), 1 },
72 { 0x4B8, GENMASK(15, 14), 0 },
73};
74
75static struct aspeed_sig_desc i2c5_link[] = {
76 { 0x418, GENMASK(17, 16), 0 },
77};
78
79static struct aspeed_sig_desc i2c6_link[] = {
80 { 0x418, GENMASK(19, 18), 0 },
81};
82
83static struct aspeed_sig_desc i2c7_link[] = {
84 { 0x418, GENMASK(21, 20), 0 },
85};
86
87static struct aspeed_sig_desc i2c8_link[] = {
88 { 0x418, GENMASK(23, 22), 0 },
89};
90
91static struct aspeed_sig_desc i2c9_link[] = {
92 { 0x418, GENMASK(25, 24), 0 },
93};
94
95static struct aspeed_sig_desc i2c10_link[] = {
96 { 0x418, GENMASK(27, 26), 0 },
97};
98
99static struct aspeed_sig_desc i2c11_link[] = {
100 { 0x410, GENMASK(1, 0), 1 },
101 { 0x4B0, GENMASK(1, 0), 0 },
102};
103
104static struct aspeed_sig_desc i2c12_link[] = {
105 { 0x410, GENMASK(3, 2), 1 },
106 { 0x4B0, GENMASK(3, 2), 0 },
107};
108
109static struct aspeed_sig_desc i2c13_link[] = {
110 { 0x410, GENMASK(5, 4), 1 },
111 { 0x4B0, GENMASK(5, 4), 0 },
112};
113
114static struct aspeed_sig_desc i2c14_link[] = {
115 { 0x410, GENMASK(7, 6), 1 },
116 { 0x4B0, GENMASK(7, 6), 0 },
117};
118
119static struct aspeed_sig_desc i2c15_link[] = {
120 { 0x414, GENMASK(29, 28), 1 },
121 { 0x4B4, GENMASK(29, 28), 0 },
122};
123
124static struct aspeed_sig_desc i2c16_link[] = {
125 { 0x414, GENMASK(31, 30), 1 },
126 { 0x4B4, GENMASK(31, 30), 0 },
127};
128
129static struct aspeed_sig_desc mac1_link[] = {
130 { 0x410, BIT(4), 0 },
131 { 0x470, BIT(4), 1 },
132};
133
134static struct aspeed_sig_desc mac2_link[] = {
135 { 0x410, BIT(5), 0 },
136 { 0x470, BIT(5), 1 },
137};
138
139static struct aspeed_sig_desc mac3_link[] = {
140 { 0x410, BIT(6), 0 },
141 { 0x470, BIT(6), 1 },
142};
143
144static struct aspeed_sig_desc mac4_link[] = {
145 { 0x410, BIT(7), 0 },
146 { 0x470, BIT(7), 1 },
147};
148
149static struct aspeed_sig_desc rgmii1[] = {
150 { 0x500, BIT(6), 0 },
151 { 0x400, GENMASK(11, 0), 0 },
152};
153
154static struct aspeed_sig_desc rgmii2[] = {
155 { 0x500, BIT(7), 0 },
156 { 0x400, GENMASK(23, 12), 0 },
157};
158
159static struct aspeed_sig_desc rgmii3[] = {
160 { 0x510, BIT(0), 0 },
161 { 0x410, GENMASK(27, 16), 0 },
162};
163
164static struct aspeed_sig_desc rgmii4[] = {
165 { 0x510, BIT(1), 0 },
166 { 0x410, GENMASK(31, 28), 1 },
167 { 0x4b0, GENMASK(31, 28), 0 },
168 { 0x474, GENMASK(7, 0), 1 },
169 { 0x414, GENMASK(7, 0), 1 },
170 { 0x4b4, GENMASK(7, 0), 0 },
171};
172
173static struct aspeed_sig_desc rmii1[] = {
174 { 0x504, BIT(6), 0 },
175 { 0x400, GENMASK(3, 0), 0 },
176 { 0x400, GENMASK(11, 6), 0 },
177};
178
179static struct aspeed_sig_desc rmii2[] = {
180 { 0x504, BIT(7), 0 },
181 { 0x400, GENMASK(15, 12), 0 },
182 { 0x400, GENMASK(23, 18), 0 },
183};
184
185static struct aspeed_sig_desc rmii3[] = {
186 { 0x514, BIT(0), 0 },
187 { 0x410, GENMASK(27, 22), 0 },
188 { 0x410, GENMASK(19, 16), 0 },
189};
190
191static struct aspeed_sig_desc rmii4[] = {
192 { 0x514, BIT(1), 0 },
193 { 0x410, GENMASK(7, 2), 1 },
194 { 0x410, GENMASK(31, 28), 1 },
195 { 0x414, GENMASK(7, 2), 1 },
196 { 0x4B0, GENMASK(31, 28), 0 },
197 { 0x4B4, GENMASK(7, 2), 0 },
198};
199
200static struct aspeed_sig_desc rmii1_rclk_oe[] = {
201 { 0x340, BIT(29), 0 },
202};
203
204static struct aspeed_sig_desc rmii2_rclk_oe[] = {
205 { 0x340, BIT(30), 0 },
206};
207
208static struct aspeed_sig_desc rmii3_rclk_oe[] = {
209 { 0x350, BIT(29), 0 },
210};
211
212static struct aspeed_sig_desc rmii4_rclk_oe[] = {
213 { 0x350, BIT(30), 0 },
214};
215
216static struct aspeed_sig_desc mdio1_link[] = {
217 { 0x430, BIT(17) | BIT(16), 0 },
218};
219
220static struct aspeed_sig_desc mdio2_link[] = {
221 { 0x470, BIT(13) | BIT(12), 1 },
222 { 0x410, BIT(13) | BIT(12), 0 },
223};
224
225static struct aspeed_sig_desc mdio3_link[] = {
226 { 0x470, BIT(1) | BIT(0), 1 },
227 { 0x410, BIT(1) | BIT(0), 0 },
228};
229
230static struct aspeed_sig_desc mdio4_link[] = {
231 { 0x470, BIT(3) | BIT(2), 1 },
232 { 0x410, BIT(3) | BIT(2), 0 },
233};
234
235static struct aspeed_sig_desc sdio2_link[] = {
236 { 0x414, GENMASK(23, 16), 1 },
237 { 0x4B4, GENMASK(23, 16), 0 },
238 { 0x450, BIT(1), 0 },
239};
240
241static struct aspeed_sig_desc sdio1_link[] = {
242 { 0x414, GENMASK(15, 8), 0 },
243};
244
245/* when sdio1 8bits, sdio2 can't use */
246static struct aspeed_sig_desc sdio1_8bit_link[] = {
247 { 0x414, GENMASK(15, 8), 0 },
248 { 0x4b4, GENMASK(21, 18), 0 },
249 { 0x450, BIT(3), 0 },
250 { 0x450, BIT(1), 1 },
251};
252
253static struct aspeed_sig_desc emmc_link[] = {
254 { 0x400, GENMASK(31, 24), 0 },
255};
256
257static struct aspeed_sig_desc emmcg8_link[] = {
258 { 0x400, GENMASK(31, 24), 0 },
259 { 0x404, GENMASK(3, 0), 0 },
260/* set SCU504 to clear the strap bits in SCU500 */
261 { 0x504, BIT(3), 0 },
262 { 0x504, BIT(5), 0 },
263};
264
265static struct aspeed_sig_desc fmcquad_link[] = {
266 { 0x438, GENMASK(5, 4), 0 },
267};
268
Ivan Mikhaylov5db5b682024-01-21 02:28:13 +0300269static struct aspeed_sig_desc siopbi_link[] = {
270 { 0x418, BIT(6), 0 },
271};
272
273static struct aspeed_sig_desc siopbo_link[] = {
274 { 0x418, BIT(5), 0 },
275};
276
Ryan Chen1efbd142021-11-02 10:17:52 +0800277static struct aspeed_sig_desc spi1_link[] = {
278 { 0x438, GENMASK(13, 11), 0 },
279};
280
281static struct aspeed_sig_desc spi1abr_link[] = {
282 { 0x438, BIT(9), 0 },
283};
284
285static struct aspeed_sig_desc spi1cs1_link[] = {
286 { 0x438, BIT(8), 0 },
287};
288
289static struct aspeed_sig_desc spi1wp_link[] = {
290 { 0x438, BIT(10), 0 },
291};
292
293static struct aspeed_sig_desc spi1quad_link[] = {
294 { 0x438, GENMASK(15, 14), 0 },
295};
296
297static struct aspeed_sig_desc spi2_link[] = {
298 { 0x434, GENMASK(29, 27) | BIT(24), 0 },
299};
300
301static struct aspeed_sig_desc spi2cs1_link[] = {
302 { 0x434, BIT(25), 0 },
303};
304
305static struct aspeed_sig_desc spi2cs2_link[] = {
306 { 0x434, BIT(26), 0 },
307};
308
309static struct aspeed_sig_desc spi2quad_link[] = {
310 { 0x434, GENMASK(31, 30), 0 },
311};
312
Ivan Mikhaylov5db5b682024-01-21 02:28:13 +0300313static struct aspeed_sig_desc thru0_link[] = {
314 { 0x4bc, GENMASK(25, 24), 0 },
315};
316
317static struct aspeed_sig_desc thru1_link[] = {
318 { 0x4bc, GENMASK(27, 26), 0 },
319};
320
321static struct aspeed_sig_desc thru2_link[] = {
322 { 0x4bc, GENMASK(29, 28), 0 },
323};
324
325static struct aspeed_sig_desc thru3_link[] = {
326 { 0x4bc, GENMASK(31, 30), 0 },
327};
328
Ryan Chen1efbd142021-11-02 10:17:52 +0800329static struct aspeed_sig_desc fsi1[] = {
330 { 0xd48, GENMASK(21, 20), 0 },
331};
332
333static struct aspeed_sig_desc fsi2[] = {
334 { 0xd48, GENMASK(23, 22), 0 },
335};
336
337static struct aspeed_sig_desc usb2ad_link[] = {
338 { 0x440, BIT(24), 0 },
339 { 0x440, BIT(25), 1 },
340};
341
342static struct aspeed_sig_desc usb2ah_link[] = {
343 { 0x440, BIT(24), 1 },
344 { 0x440, BIT(25), 0 },
345};
346
347static struct aspeed_sig_desc usb2bh_link[] = {
348 { 0x440, BIT(28), 1 },
349 { 0x440, BIT(29), 0 },
350};
351
352static struct aspeed_sig_desc pcie0rc_link[] = {
353 { 0x40, BIT(21), 0 },
354};
355
356static struct aspeed_sig_desc pcie1rc_link[] = {
357 { 0x40, BIT(19), 0 }, /* SSPRST# output enable */
358 { 0x500, BIT(24), 0 }, /* dedicate rc reset */
359};
360
Billy Tsai01013c82022-03-08 11:04:06 +0800361static struct aspeed_sig_desc pwm0[] = {
362 {0x41c, BIT(16), 0},
363};
364
365static struct aspeed_sig_desc pwm1[] = {
366 {0x41c, BIT(17), 0},
367};
368
369static struct aspeed_sig_desc pwm2[] = {
370 {0x41c, BIT(18), 0},
371};
372
373static struct aspeed_sig_desc pwm3[] = {
374 {0x41c, BIT(19), 0},
375};
376
377static struct aspeed_sig_desc pwm4[] = {
378 {0x41c, BIT(20), 0},
379};
380
381static struct aspeed_sig_desc pwm5[] = {
382 {0x41c, BIT(21), 0},
383};
384
385static struct aspeed_sig_desc pwm6[] = {
386 {0x41c, BIT(22), 0},
387};
388
389static struct aspeed_sig_desc pwm7[] = {
390 {0x41c, BIT(23), 0},
391};
392
393static struct aspeed_sig_desc pwm8g0[] = {
394 {0x4B4, BIT(8), 0},
395};
396
397static struct aspeed_sig_desc pwm8g1[] = {
398 {0x41c, BIT(24), 0},
399};
400
401static struct aspeed_sig_desc pwm9g0[] = {
402 {0x4B4, BIT(9), 0},
403};
404
405static struct aspeed_sig_desc pwm9g1[] = {
406 {0x41c, BIT(25), 0},
407};
408
409static struct aspeed_sig_desc pwm10g0[] = {
410 {0x4B4, BIT(10), 0},
411};
412
413static struct aspeed_sig_desc pwm10g1[] = {
414 {0x41c, BIT(26), 0},
415};
416
417static struct aspeed_sig_desc pwm11g0[] = {
418 {0x4B4, BIT(11), 0},
419};
420
421static struct aspeed_sig_desc pwm11g1[] = {
422 {0x41c, BIT(27), 0},
423};
424
425static struct aspeed_sig_desc pwm12g0[] = {
426 {0x4B4, BIT(12), 0},
427};
428
429static struct aspeed_sig_desc pwm12g1[] = {
430 {0x41c, BIT(28), 0},
431};
432
433static struct aspeed_sig_desc pwm13g0[] = {
434 {0x4B4, BIT(13), 0},
435};
436
437static struct aspeed_sig_desc pwm13g1[] = {
438 {0x41c, BIT(29), 0},
439};
440
441static struct aspeed_sig_desc pwm14g0[] = {
442 {0x4B4, BIT(14), 0},
443};
444
445static struct aspeed_sig_desc pwm14g1[] = {
446 {0x41c, BIT(30), 0},
447};
448
449static struct aspeed_sig_desc pwm15g0[] = {
450 {0x4B4, BIT(15), 0},
451};
452
453static struct aspeed_sig_desc pwm15g1[] = {
454 {0x41c, BIT(31), 0},
455};
456
Ryan Chen1efbd142021-11-02 10:17:52 +0800457static const struct aspeed_group_config ast2600_groups[] = {
458 { "MAC1LINK", ARRAY_SIZE(mac1_link), mac1_link },
459 { "MAC2LINK", ARRAY_SIZE(mac2_link), mac2_link },
460 { "MAC3LINK", ARRAY_SIZE(mac3_link), mac3_link },
461 { "MAC4LINK", ARRAY_SIZE(mac4_link), mac4_link },
462 { "RGMII1", ARRAY_SIZE(rgmii1), rgmii1 },
463 { "RGMII2", ARRAY_SIZE(rgmii2), rgmii2 },
464 { "RGMII3", ARRAY_SIZE(rgmii3), rgmii3 },
465 { "RGMII4", ARRAY_SIZE(rgmii4), rgmii4 },
466 { "RMII1", ARRAY_SIZE(rmii1), rmii1 },
467 { "RMII2", ARRAY_SIZE(rmii2), rmii2 },
468 { "RMII3", ARRAY_SIZE(rmii3), rmii3 },
469 { "RMII4", ARRAY_SIZE(rmii4), rmii4 },
470 { "RMII1RCLK", ARRAY_SIZE(rmii1_rclk_oe), rmii1_rclk_oe },
471 { "RMII2RCLK", ARRAY_SIZE(rmii2_rclk_oe), rmii2_rclk_oe },
472 { "RMII3RCLK", ARRAY_SIZE(rmii3_rclk_oe), rmii3_rclk_oe },
473 { "RMII4RCLK", ARRAY_SIZE(rmii4_rclk_oe), rmii4_rclk_oe },
474 { "MDIO1", ARRAY_SIZE(mdio1_link), mdio1_link },
475 { "MDIO2", ARRAY_SIZE(mdio2_link), mdio2_link },
476 { "MDIO3", ARRAY_SIZE(mdio3_link), mdio3_link },
477 { "MDIO4", ARRAY_SIZE(mdio4_link), mdio4_link },
478 { "SD1", ARRAY_SIZE(sdio1_link), sdio1_link },
479 { "SD1_8bits", ARRAY_SIZE(sdio1_8bit_link), sdio1_8bit_link },
480 { "SD2", ARRAY_SIZE(sdio2_link), sdio2_link },
481 { "EMMC", ARRAY_SIZE(emmc_link), emmc_link },
482 { "EMMCG8", ARRAY_SIZE(emmcg8_link), emmcg8_link },
483 { "FMCQUAD", ARRAY_SIZE(fmcquad_link), fmcquad_link },
Ivan Mikhaylov5db5b682024-01-21 02:28:13 +0300484 { "SIOPBI", ARRAY_SIZE(siopbi_link), siopbi_link },
485 { "SIOPBO", ARRAY_SIZE(siopbo_link), siopbo_link },
Ryan Chen1efbd142021-11-02 10:17:52 +0800486 { "SPI1", ARRAY_SIZE(spi1_link), spi1_link },
487 { "SPI1ABR", ARRAY_SIZE(spi1abr_link), spi1abr_link },
488 { "SPI1CS1", ARRAY_SIZE(spi1cs1_link), spi1cs1_link },
489 { "SPI1WP", ARRAY_SIZE(spi1wp_link), spi1wp_link },
490 { "SPI1QUAD", ARRAY_SIZE(spi1quad_link), spi1quad_link },
491 { "SPI2", ARRAY_SIZE(spi2_link), spi2_link },
492 { "SPI2CS1", ARRAY_SIZE(spi2cs1_link), spi2cs1_link },
493 { "SPI2CS2", ARRAY_SIZE(spi2cs2_link), spi2cs2_link },
494 { "SPI2QUAD", ARRAY_SIZE(spi2quad_link), spi2quad_link },
Ivan Mikhaylov5db5b682024-01-21 02:28:13 +0300495 { "THRU0", ARRAY_SIZE(thru0_link), thru0_link },
496 { "THRU1", ARRAY_SIZE(thru1_link), thru1_link },
497 { "THRU2", ARRAY_SIZE(thru2_link), thru2_link },
498 { "THRU3", ARRAY_SIZE(thru3_link), thru3_link },
Ryan Chen1efbd142021-11-02 10:17:52 +0800499 { "I2C1", ARRAY_SIZE(i2c1_link), i2c1_link },
500 { "I2C2", ARRAY_SIZE(i2c2_link), i2c2_link },
501 { "I2C3", ARRAY_SIZE(i2c3_link), i2c3_link },
502 { "I2C4", ARRAY_SIZE(i2c4_link), i2c4_link },
503 { "I2C5", ARRAY_SIZE(i2c5_link), i2c5_link },
504 { "I2C6", ARRAY_SIZE(i2c6_link), i2c6_link },
505 { "I2C7", ARRAY_SIZE(i2c7_link), i2c7_link },
506 { "I2C8", ARRAY_SIZE(i2c8_link), i2c8_link },
507 { "I2C9", ARRAY_SIZE(i2c9_link), i2c9_link },
508 { "I2C10", ARRAY_SIZE(i2c10_link), i2c10_link },
509 { "I2C11", ARRAY_SIZE(i2c11_link), i2c11_link },
510 { "I2C12", ARRAY_SIZE(i2c12_link), i2c12_link },
511 { "I2C13", ARRAY_SIZE(i2c13_link), i2c13_link },
512 { "I2C14", ARRAY_SIZE(i2c14_link), i2c14_link },
513 { "I2C15", ARRAY_SIZE(i2c15_link), i2c15_link },
514 { "I2C16", ARRAY_SIZE(i2c16_link), i2c16_link },
515 { "FSI1", ARRAY_SIZE(fsi1), fsi1 },
516 { "FSI2", ARRAY_SIZE(fsi2), fsi2 },
517 { "USB2AD", ARRAY_SIZE(usb2ad_link), usb2ad_link },
518 { "USB2AH", ARRAY_SIZE(usb2ah_link), usb2ah_link },
519 { "USB2BH", ARRAY_SIZE(usb2bh_link), usb2bh_link },
520 { "PCIE0RC", ARRAY_SIZE(pcie0rc_link), pcie0rc_link },
521 { "PCIE1RC", ARRAY_SIZE(pcie1rc_link), pcie1rc_link },
Billy Tsai01013c82022-03-08 11:04:06 +0800522 { "PWM0", ARRAY_SIZE(pwm0), pwm0 },
523 { "PWM1", ARRAY_SIZE(pwm1), pwm1 },
524 { "PWM2", ARRAY_SIZE(pwm2), pwm2 },
525 { "PWM3", ARRAY_SIZE(pwm3), pwm3 },
526 { "PWM4", ARRAY_SIZE(pwm4), pwm4 },
527 { "PWM5", ARRAY_SIZE(pwm5), pwm5 },
528 { "PWM6", ARRAY_SIZE(pwm6), pwm6 },
529 { "PWM7", ARRAY_SIZE(pwm7), pwm7 },
530 { "PWM8G0", ARRAY_SIZE(pwm8g0), pwm8g0 },
531 { "PWM8G1", ARRAY_SIZE(pwm8g1), pwm8g1 },
532 { "PWM9G0", ARRAY_SIZE(pwm9g0), pwm9g0 },
533 { "PWM9G1", ARRAY_SIZE(pwm9g1), pwm9g1 },
534 { "PWM10G0", ARRAY_SIZE(pwm10g0), pwm10g0 },
535 { "PWM10G1", ARRAY_SIZE(pwm10g1), pwm10g1 },
536 { "PWM11G0", ARRAY_SIZE(pwm11g0), pwm11g0 },
537 { "PWM11G1", ARRAY_SIZE(pwm11g1), pwm11g1 },
538 { "PWM12G0", ARRAY_SIZE(pwm12g0), pwm12g0 },
539 { "PWM12G1", ARRAY_SIZE(pwm12g1), pwm12g1 },
540 { "PWM13G0", ARRAY_SIZE(pwm13g0), pwm13g0 },
541 { "PWM13G1", ARRAY_SIZE(pwm13g1), pwm13g1 },
542 { "PWM14G0", ARRAY_SIZE(pwm14g0), pwm14g0 },
543 { "PWM14G1", ARRAY_SIZE(pwm14g1), pwm14g1 },
544 { "PWM15G0", ARRAY_SIZE(pwm15g0), pwm15g0 },
545 { "PWM15G1", ARRAY_SIZE(pwm15g1), pwm15g1 },
Ryan Chen1efbd142021-11-02 10:17:52 +0800546};
547
548static int ast2600_pinctrl_get_groups_count(struct udevice *dev)
549{
550 debug("PINCTRL: get_(functions/groups)_count\n");
551
552 return ARRAY_SIZE(ast2600_groups);
553}
554
555static const char *ast2600_pinctrl_get_group_name(struct udevice *dev,
556 unsigned selector)
557{
558 debug("PINCTRL: get_(function/group)_name %u\n", selector);
559
560 return ast2600_groups[selector].group_name;
561}
562
563static int ast2600_pinctrl_group_set(struct udevice *dev, unsigned selector, unsigned func_selector)
564{
565 struct ast2600_pinctrl_priv *priv = dev_get_priv(dev);
566 const struct aspeed_group_config *config;
567 const struct aspeed_sig_desc *descs;
568 u32 ctrl_reg = (u32)priv->scu;
569 u32 i;
570
571 debug("PINCTRL: group_set <%u, %u>\n", selector, func_selector);
572 if (selector >= ARRAY_SIZE(ast2600_groups))
573 return -EINVAL;
574
575 config = &ast2600_groups[selector];
576 for (i = 0; i < config->ndescs; i++) {
577 descs = &config->descs[i];
578 if (descs->clr)
579 clrbits_le32((u32)ctrl_reg + descs->offset, descs->reg_set);
580 else
581 setbits_le32((u32)ctrl_reg + descs->offset, descs->reg_set);
582 }
583
584 return 0;
585}
586
587static struct pinctrl_ops ast2600_pinctrl_ops = {
588 .set_state = pinctrl_generic_set_state,
589 .get_groups_count = ast2600_pinctrl_get_groups_count,
590 .get_group_name = ast2600_pinctrl_get_group_name,
591 .get_functions_count = ast2600_pinctrl_get_groups_count,
592 .get_function_name = ast2600_pinctrl_get_group_name,
593 .pinmux_group_set = ast2600_pinctrl_group_set,
594};
595
596static const struct udevice_id ast2600_pinctrl_ids[] = {
597 { .compatible = "aspeed,g6-pinctrl" },
598 { }
599};
600
601U_BOOT_DRIVER(pinctrl_aspeed) = {
602 .name = "aspeed_ast2600_pinctrl",
603 .id = UCLASS_PINCTRL,
604 .of_match = ast2600_pinctrl_ids,
605 .priv_auto = sizeof(struct ast2600_pinctrl_priv),
606 .ops = &ast2600_pinctrl_ops,
607 .probe = ast2600_pinctrl_probe,
608};