1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0+
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Bitmain BM1880 SoC Pinctrl driver
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Copyright (c) 2019 Linaro Ltd.
6*4882a593Smuzhiyun * Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
7*4882a593Smuzhiyun */
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun #include <linux/io.h>
10*4882a593Smuzhiyun #include <linux/of.h>
11*4882a593Smuzhiyun #include <linux/platform_device.h>
12*4882a593Smuzhiyun #include <linux/pinctrl/pinctrl.h>
13*4882a593Smuzhiyun #include <linux/pinctrl/pinmux.h>
14*4882a593Smuzhiyun #include <linux/pinctrl/pinconf-generic.h>
15*4882a593Smuzhiyun #include <linux/slab.h>
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun #include "core.h"
18*4882a593Smuzhiyun #include "pinctrl-utils.h"
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun #define BM1880_REG_MUX 0x20
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun /**
23*4882a593Smuzhiyun * struct bm1880_pinctrl - driver data
24*4882a593Smuzhiyun * @base: Pinctrl base address
25*4882a593Smuzhiyun * @pctrldev: Pinctrl device
26*4882a593Smuzhiyun * @groups: Pingroups
27*4882a593Smuzhiyun * @ngroups: Number of @groups
28*4882a593Smuzhiyun * @funcs: Pinmux functions
29*4882a593Smuzhiyun * @nfuncs: Number of @funcs
30*4882a593Smuzhiyun * @pinconf: Pinconf data
31*4882a593Smuzhiyun */
32*4882a593Smuzhiyun struct bm1880_pinctrl {
33*4882a593Smuzhiyun void __iomem *base;
34*4882a593Smuzhiyun struct pinctrl_dev *pctrldev;
35*4882a593Smuzhiyun const struct bm1880_pctrl_group *groups;
36*4882a593Smuzhiyun unsigned int ngroups;
37*4882a593Smuzhiyun const struct bm1880_pinmux_function *funcs;
38*4882a593Smuzhiyun unsigned int nfuncs;
39*4882a593Smuzhiyun const struct bm1880_pinconf_data *pinconf;
40*4882a593Smuzhiyun };
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun /**
43*4882a593Smuzhiyun * struct bm1880_pctrl_group - pinctrl group
44*4882a593Smuzhiyun * @name: Name of the group
45*4882a593Smuzhiyun * @pins: Array of pins belonging to this group
46*4882a593Smuzhiyun * @npins: Number of @pins
47*4882a593Smuzhiyun */
48*4882a593Smuzhiyun struct bm1880_pctrl_group {
49*4882a593Smuzhiyun const char *name;
50*4882a593Smuzhiyun const unsigned int *pins;
51*4882a593Smuzhiyun const unsigned int npins;
52*4882a593Smuzhiyun };
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun /**
55*4882a593Smuzhiyun * struct bm1880_pinmux_function - a pinmux function
56*4882a593Smuzhiyun * @name: Name of the pinmux function.
57*4882a593Smuzhiyun * @groups: List of pingroups for this function.
58*4882a593Smuzhiyun * @ngroups: Number of entries in @groups.
59*4882a593Smuzhiyun * @mux_val: Selector for this function
60*4882a593Smuzhiyun * @mux: Offset of function specific mux
61*4882a593Smuzhiyun * @mux_shift: Shift for function specific selector
62*4882a593Smuzhiyun */
63*4882a593Smuzhiyun struct bm1880_pinmux_function {
64*4882a593Smuzhiyun const char *name;
65*4882a593Smuzhiyun const char * const *groups;
66*4882a593Smuzhiyun unsigned int ngroups;
67*4882a593Smuzhiyun u32 mux_val;
68*4882a593Smuzhiyun u32 mux;
69*4882a593Smuzhiyun u8 mux_shift;
70*4882a593Smuzhiyun };
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun /**
73*4882a593Smuzhiyun * struct bm1880_pinconf_data - pinconf data
74*4882a593Smuzhiyun * @drv_bits: Drive strength bit width
75*4882a593Smuzhiyun */
76*4882a593Smuzhiyun struct bm1880_pinconf_data {
77*4882a593Smuzhiyun u32 drv_bits;
78*4882a593Smuzhiyun };
79*4882a593Smuzhiyun
80*4882a593Smuzhiyun static const struct pinctrl_pin_desc bm1880_pins[] = {
81*4882a593Smuzhiyun PINCTRL_PIN(0, "MIO0"),
82*4882a593Smuzhiyun PINCTRL_PIN(1, "MIO1"),
83*4882a593Smuzhiyun PINCTRL_PIN(2, "MIO2"),
84*4882a593Smuzhiyun PINCTRL_PIN(3, "MIO3"),
85*4882a593Smuzhiyun PINCTRL_PIN(4, "MIO4"),
86*4882a593Smuzhiyun PINCTRL_PIN(5, "MIO5"),
87*4882a593Smuzhiyun PINCTRL_PIN(6, "MIO6"),
88*4882a593Smuzhiyun PINCTRL_PIN(7, "MIO7"),
89*4882a593Smuzhiyun PINCTRL_PIN(8, "MIO8"),
90*4882a593Smuzhiyun PINCTRL_PIN(9, "MIO9"),
91*4882a593Smuzhiyun PINCTRL_PIN(10, "MIO10"),
92*4882a593Smuzhiyun PINCTRL_PIN(11, "MIO11"),
93*4882a593Smuzhiyun PINCTRL_PIN(12, "MIO12"),
94*4882a593Smuzhiyun PINCTRL_PIN(13, "MIO13"),
95*4882a593Smuzhiyun PINCTRL_PIN(14, "MIO14"),
96*4882a593Smuzhiyun PINCTRL_PIN(15, "MIO15"),
97*4882a593Smuzhiyun PINCTRL_PIN(16, "MIO16"),
98*4882a593Smuzhiyun PINCTRL_PIN(17, "MIO17"),
99*4882a593Smuzhiyun PINCTRL_PIN(18, "MIO18"),
100*4882a593Smuzhiyun PINCTRL_PIN(19, "MIO19"),
101*4882a593Smuzhiyun PINCTRL_PIN(20, "MIO20"),
102*4882a593Smuzhiyun PINCTRL_PIN(21, "MIO21"),
103*4882a593Smuzhiyun PINCTRL_PIN(22, "MIO22"),
104*4882a593Smuzhiyun PINCTRL_PIN(23, "MIO23"),
105*4882a593Smuzhiyun PINCTRL_PIN(24, "MIO24"),
106*4882a593Smuzhiyun PINCTRL_PIN(25, "MIO25"),
107*4882a593Smuzhiyun PINCTRL_PIN(26, "MIO26"),
108*4882a593Smuzhiyun PINCTRL_PIN(27, "MIO27"),
109*4882a593Smuzhiyun PINCTRL_PIN(28, "MIO28"),
110*4882a593Smuzhiyun PINCTRL_PIN(29, "MIO29"),
111*4882a593Smuzhiyun PINCTRL_PIN(30, "MIO30"),
112*4882a593Smuzhiyun PINCTRL_PIN(31, "MIO31"),
113*4882a593Smuzhiyun PINCTRL_PIN(32, "MIO32"),
114*4882a593Smuzhiyun PINCTRL_PIN(33, "MIO33"),
115*4882a593Smuzhiyun PINCTRL_PIN(34, "MIO34"),
116*4882a593Smuzhiyun PINCTRL_PIN(35, "MIO35"),
117*4882a593Smuzhiyun PINCTRL_PIN(36, "MIO36"),
118*4882a593Smuzhiyun PINCTRL_PIN(37, "MIO37"),
119*4882a593Smuzhiyun PINCTRL_PIN(38, "MIO38"),
120*4882a593Smuzhiyun PINCTRL_PIN(39, "MIO39"),
121*4882a593Smuzhiyun PINCTRL_PIN(40, "MIO40"),
122*4882a593Smuzhiyun PINCTRL_PIN(41, "MIO41"),
123*4882a593Smuzhiyun PINCTRL_PIN(42, "MIO42"),
124*4882a593Smuzhiyun PINCTRL_PIN(43, "MIO43"),
125*4882a593Smuzhiyun PINCTRL_PIN(44, "MIO44"),
126*4882a593Smuzhiyun PINCTRL_PIN(45, "MIO45"),
127*4882a593Smuzhiyun PINCTRL_PIN(46, "MIO46"),
128*4882a593Smuzhiyun PINCTRL_PIN(47, "MIO47"),
129*4882a593Smuzhiyun PINCTRL_PIN(48, "MIO48"),
130*4882a593Smuzhiyun PINCTRL_PIN(49, "MIO49"),
131*4882a593Smuzhiyun PINCTRL_PIN(50, "MIO50"),
132*4882a593Smuzhiyun PINCTRL_PIN(51, "MIO51"),
133*4882a593Smuzhiyun PINCTRL_PIN(52, "MIO52"),
134*4882a593Smuzhiyun PINCTRL_PIN(53, "MIO53"),
135*4882a593Smuzhiyun PINCTRL_PIN(54, "MIO54"),
136*4882a593Smuzhiyun PINCTRL_PIN(55, "MIO55"),
137*4882a593Smuzhiyun PINCTRL_PIN(56, "MIO56"),
138*4882a593Smuzhiyun PINCTRL_PIN(57, "MIO57"),
139*4882a593Smuzhiyun PINCTRL_PIN(58, "MIO58"),
140*4882a593Smuzhiyun PINCTRL_PIN(59, "MIO59"),
141*4882a593Smuzhiyun PINCTRL_PIN(60, "MIO60"),
142*4882a593Smuzhiyun PINCTRL_PIN(61, "MIO61"),
143*4882a593Smuzhiyun PINCTRL_PIN(62, "MIO62"),
144*4882a593Smuzhiyun PINCTRL_PIN(63, "MIO63"),
145*4882a593Smuzhiyun PINCTRL_PIN(64, "MIO64"),
146*4882a593Smuzhiyun PINCTRL_PIN(65, "MIO65"),
147*4882a593Smuzhiyun PINCTRL_PIN(66, "MIO66"),
148*4882a593Smuzhiyun PINCTRL_PIN(67, "MIO67"),
149*4882a593Smuzhiyun PINCTRL_PIN(68, "MIO68"),
150*4882a593Smuzhiyun PINCTRL_PIN(69, "MIO69"),
151*4882a593Smuzhiyun PINCTRL_PIN(70, "MIO70"),
152*4882a593Smuzhiyun PINCTRL_PIN(71, "MIO71"),
153*4882a593Smuzhiyun PINCTRL_PIN(72, "MIO72"),
154*4882a593Smuzhiyun PINCTRL_PIN(73, "MIO73"),
155*4882a593Smuzhiyun PINCTRL_PIN(74, "MIO74"),
156*4882a593Smuzhiyun PINCTRL_PIN(75, "MIO75"),
157*4882a593Smuzhiyun PINCTRL_PIN(76, "MIO76"),
158*4882a593Smuzhiyun PINCTRL_PIN(77, "MIO77"),
159*4882a593Smuzhiyun PINCTRL_PIN(78, "MIO78"),
160*4882a593Smuzhiyun PINCTRL_PIN(79, "MIO79"),
161*4882a593Smuzhiyun PINCTRL_PIN(80, "MIO80"),
162*4882a593Smuzhiyun PINCTRL_PIN(81, "MIO81"),
163*4882a593Smuzhiyun PINCTRL_PIN(82, "MIO82"),
164*4882a593Smuzhiyun PINCTRL_PIN(83, "MIO83"),
165*4882a593Smuzhiyun PINCTRL_PIN(84, "MIO84"),
166*4882a593Smuzhiyun PINCTRL_PIN(85, "MIO85"),
167*4882a593Smuzhiyun PINCTRL_PIN(86, "MIO86"),
168*4882a593Smuzhiyun PINCTRL_PIN(87, "MIO87"),
169*4882a593Smuzhiyun PINCTRL_PIN(88, "MIO88"),
170*4882a593Smuzhiyun PINCTRL_PIN(89, "MIO89"),
171*4882a593Smuzhiyun PINCTRL_PIN(90, "MIO90"),
172*4882a593Smuzhiyun PINCTRL_PIN(91, "MIO91"),
173*4882a593Smuzhiyun PINCTRL_PIN(92, "MIO92"),
174*4882a593Smuzhiyun PINCTRL_PIN(93, "MIO93"),
175*4882a593Smuzhiyun PINCTRL_PIN(94, "MIO94"),
176*4882a593Smuzhiyun PINCTRL_PIN(95, "MIO95"),
177*4882a593Smuzhiyun PINCTRL_PIN(96, "MIO96"),
178*4882a593Smuzhiyun PINCTRL_PIN(97, "MIO97"),
179*4882a593Smuzhiyun PINCTRL_PIN(98, "MIO98"),
180*4882a593Smuzhiyun PINCTRL_PIN(99, "MIO99"),
181*4882a593Smuzhiyun PINCTRL_PIN(100, "MIO100"),
182*4882a593Smuzhiyun PINCTRL_PIN(101, "MIO101"),
183*4882a593Smuzhiyun PINCTRL_PIN(102, "MIO102"),
184*4882a593Smuzhiyun PINCTRL_PIN(103, "MIO103"),
185*4882a593Smuzhiyun PINCTRL_PIN(104, "MIO104"),
186*4882a593Smuzhiyun PINCTRL_PIN(105, "MIO105"),
187*4882a593Smuzhiyun PINCTRL_PIN(106, "MIO106"),
188*4882a593Smuzhiyun PINCTRL_PIN(107, "MIO107"),
189*4882a593Smuzhiyun PINCTRL_PIN(108, "MIO108"),
190*4882a593Smuzhiyun PINCTRL_PIN(109, "MIO109"),
191*4882a593Smuzhiyun PINCTRL_PIN(110, "MIO110"),
192*4882a593Smuzhiyun PINCTRL_PIN(111, "MIO111"),
193*4882a593Smuzhiyun };
194*4882a593Smuzhiyun
195*4882a593Smuzhiyun enum bm1880_pinmux_functions {
196*4882a593Smuzhiyun F_nand, F_spi, F_emmc, F_sdio, F_eth0, F_pwm0, F_pwm1, F_pwm2,
197*4882a593Smuzhiyun F_pwm3, F_pwm4, F_pwm5, F_pwm6, F_pwm7, F_pwm8, F_pwm9, F_pwm10,
198*4882a593Smuzhiyun F_pwm11, F_pwm12, F_pwm13, F_pwm14, F_pwm15, F_pwm16, F_pwm17,
199*4882a593Smuzhiyun F_pwm18, F_pwm19, F_pwm20, F_pwm21, F_pwm22, F_pwm23, F_pwm24,
200*4882a593Smuzhiyun F_pwm25, F_pwm26, F_pwm27, F_pwm28, F_pwm29, F_pwm30, F_pwm31,
201*4882a593Smuzhiyun F_pwm32, F_pwm33, F_pwm34, F_pwm35, F_pwm36, F_pwm37, F_i2c0, F_i2c1,
202*4882a593Smuzhiyun F_i2c2, F_i2c3, F_i2c4, F_uart0, F_uart1, F_uart2, F_uart3, F_uart4,
203*4882a593Smuzhiyun F_uart5, F_uart6, F_uart7, F_uart8, F_uart9, F_uart10, F_uart11,
204*4882a593Smuzhiyun F_uart12, F_uart13, F_uart14, F_uart15, F_gpio0, F_gpio1, F_gpio2,
205*4882a593Smuzhiyun F_gpio3, F_gpio4, F_gpio5, F_gpio6, F_gpio7, F_gpio8, F_gpio9, F_gpio10,
206*4882a593Smuzhiyun F_gpio11, F_gpio12, F_gpio13, F_gpio14, F_gpio15, F_gpio16, F_gpio17,
207*4882a593Smuzhiyun F_gpio18, F_gpio19, F_gpio20, F_gpio21, F_gpio22, F_gpio23, F_gpio24,
208*4882a593Smuzhiyun F_gpio25, F_gpio26, F_gpio27, F_gpio28, F_gpio29, F_gpio30, F_gpio31,
209*4882a593Smuzhiyun F_gpio32, F_gpio33, F_gpio34, F_gpio35, F_gpio36, F_gpio37, F_gpio38,
210*4882a593Smuzhiyun F_gpio39, F_gpio40, F_gpio41, F_gpio42, F_gpio43, F_gpio44, F_gpio45,
211*4882a593Smuzhiyun F_gpio46, F_gpio47, F_gpio48, F_gpio49, F_gpio50, F_gpio51, F_gpio52,
212*4882a593Smuzhiyun F_gpio53, F_gpio54, F_gpio55, F_gpio56, F_gpio57, F_gpio58, F_gpio59,
213*4882a593Smuzhiyun F_gpio60, F_gpio61, F_gpio62, F_gpio63, F_gpio64, F_gpio65, F_gpio66,
214*4882a593Smuzhiyun F_gpio67, F_eth1, F_i2s0, F_i2s0_mclkin, F_i2s1, F_i2s1_mclkin, F_spi0,
215*4882a593Smuzhiyun F_max
216*4882a593Smuzhiyun };
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun static const unsigned int nand_pins[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
219*4882a593Smuzhiyun 10, 11, 12, 13, 14, 15, 16 };
220*4882a593Smuzhiyun static const unsigned int spi_pins[] = { 0, 1, 8, 10, 11, 12, 13 };
221*4882a593Smuzhiyun static const unsigned int emmc_pins[] = { 2, 3, 4, 5, 6, 7, 9, 14, 15, 16 };
222*4882a593Smuzhiyun static const unsigned int sdio_pins[] = { 17, 18, 19, 20, 21, 22, 23, 24,
223*4882a593Smuzhiyun 25, 26 };
224*4882a593Smuzhiyun static const unsigned int eth0_pins[] = { 27, 28, 29, 30, 31, 32, 33, 34, 35,
225*4882a593Smuzhiyun 36, 37, 38, 39, 40, 41, 42 };
226*4882a593Smuzhiyun static const unsigned int pwm0_pins[] = { 29 };
227*4882a593Smuzhiyun static const unsigned int pwm1_pins[] = { 30 };
228*4882a593Smuzhiyun static const unsigned int pwm2_pins[] = { 34 };
229*4882a593Smuzhiyun static const unsigned int pwm3_pins[] = { 35 };
230*4882a593Smuzhiyun static const unsigned int pwm4_pins[] = { 43 };
231*4882a593Smuzhiyun static const unsigned int pwm5_pins[] = { 44 };
232*4882a593Smuzhiyun static const unsigned int pwm6_pins[] = { 45 };
233*4882a593Smuzhiyun static const unsigned int pwm7_pins[] = { 46 };
234*4882a593Smuzhiyun static const unsigned int pwm8_pins[] = { 47 };
235*4882a593Smuzhiyun static const unsigned int pwm9_pins[] = { 48 };
236*4882a593Smuzhiyun static const unsigned int pwm10_pins[] = { 49 };
237*4882a593Smuzhiyun static const unsigned int pwm11_pins[] = { 50 };
238*4882a593Smuzhiyun static const unsigned int pwm12_pins[] = { 51 };
239*4882a593Smuzhiyun static const unsigned int pwm13_pins[] = { 52 };
240*4882a593Smuzhiyun static const unsigned int pwm14_pins[] = { 53 };
241*4882a593Smuzhiyun static const unsigned int pwm15_pins[] = { 54 };
242*4882a593Smuzhiyun static const unsigned int pwm16_pins[] = { 55 };
243*4882a593Smuzhiyun static const unsigned int pwm17_pins[] = { 56 };
244*4882a593Smuzhiyun static const unsigned int pwm18_pins[] = { 57 };
245*4882a593Smuzhiyun static const unsigned int pwm19_pins[] = { 58 };
246*4882a593Smuzhiyun static const unsigned int pwm20_pins[] = { 59 };
247*4882a593Smuzhiyun static const unsigned int pwm21_pins[] = { 60 };
248*4882a593Smuzhiyun static const unsigned int pwm22_pins[] = { 61 };
249*4882a593Smuzhiyun static const unsigned int pwm23_pins[] = { 62 };
250*4882a593Smuzhiyun static const unsigned int pwm24_pins[] = { 97 };
251*4882a593Smuzhiyun static const unsigned int pwm25_pins[] = { 98 };
252*4882a593Smuzhiyun static const unsigned int pwm26_pins[] = { 99 };
253*4882a593Smuzhiyun static const unsigned int pwm27_pins[] = { 100 };
254*4882a593Smuzhiyun static const unsigned int pwm28_pins[] = { 101 };
255*4882a593Smuzhiyun static const unsigned int pwm29_pins[] = { 102 };
256*4882a593Smuzhiyun static const unsigned int pwm30_pins[] = { 103 };
257*4882a593Smuzhiyun static const unsigned int pwm31_pins[] = { 104 };
258*4882a593Smuzhiyun static const unsigned int pwm32_pins[] = { 105 };
259*4882a593Smuzhiyun static const unsigned int pwm33_pins[] = { 106 };
260*4882a593Smuzhiyun static const unsigned int pwm34_pins[] = { 107 };
261*4882a593Smuzhiyun static const unsigned int pwm35_pins[] = { 108 };
262*4882a593Smuzhiyun static const unsigned int pwm36_pins[] = { 109 };
263*4882a593Smuzhiyun static const unsigned int pwm37_pins[] = { 110 };
264*4882a593Smuzhiyun static const unsigned int i2c0_pins[] = { 63, 64 };
265*4882a593Smuzhiyun static const unsigned int i2c1_pins[] = { 65, 66 };
266*4882a593Smuzhiyun static const unsigned int i2c2_pins[] = { 67, 68 };
267*4882a593Smuzhiyun static const unsigned int i2c3_pins[] = { 69, 70 };
268*4882a593Smuzhiyun static const unsigned int i2c4_pins[] = { 71, 72 };
269*4882a593Smuzhiyun static const unsigned int uart0_pins[] = { 73, 74 };
270*4882a593Smuzhiyun static const unsigned int uart1_pins[] = { 75, 76 };
271*4882a593Smuzhiyun static const unsigned int uart2_pins[] = { 77, 78 };
272*4882a593Smuzhiyun static const unsigned int uart3_pins[] = { 79, 80 };
273*4882a593Smuzhiyun static const unsigned int uart4_pins[] = { 81, 82 };
274*4882a593Smuzhiyun static const unsigned int uart5_pins[] = { 83, 84 };
275*4882a593Smuzhiyun static const unsigned int uart6_pins[] = { 85, 86 };
276*4882a593Smuzhiyun static const unsigned int uart7_pins[] = { 87, 88 };
277*4882a593Smuzhiyun static const unsigned int uart8_pins[] = { 89, 90 };
278*4882a593Smuzhiyun static const unsigned int uart9_pins[] = { 91, 92 };
279*4882a593Smuzhiyun static const unsigned int uart10_pins[] = { 93, 94 };
280*4882a593Smuzhiyun static const unsigned int uart11_pins[] = { 95, 96 };
281*4882a593Smuzhiyun static const unsigned int uart12_pins[] = { 73, 74, 75, 76 };
282*4882a593Smuzhiyun static const unsigned int uart13_pins[] = { 77, 78, 83, 84 };
283*4882a593Smuzhiyun static const unsigned int uart14_pins[] = { 79, 80, 85, 86 };
284*4882a593Smuzhiyun static const unsigned int uart15_pins[] = { 81, 82, 87, 88 };
285*4882a593Smuzhiyun static const unsigned int gpio0_pins[] = { 97 };
286*4882a593Smuzhiyun static const unsigned int gpio1_pins[] = { 98 };
287*4882a593Smuzhiyun static const unsigned int gpio2_pins[] = { 99 };
288*4882a593Smuzhiyun static const unsigned int gpio3_pins[] = { 100 };
289*4882a593Smuzhiyun static const unsigned int gpio4_pins[] = { 101 };
290*4882a593Smuzhiyun static const unsigned int gpio5_pins[] = { 102 };
291*4882a593Smuzhiyun static const unsigned int gpio6_pins[] = { 103 };
292*4882a593Smuzhiyun static const unsigned int gpio7_pins[] = { 104 };
293*4882a593Smuzhiyun static const unsigned int gpio8_pins[] = { 105 };
294*4882a593Smuzhiyun static const unsigned int gpio9_pins[] = { 106 };
295*4882a593Smuzhiyun static const unsigned int gpio10_pins[] = { 107 };
296*4882a593Smuzhiyun static const unsigned int gpio11_pins[] = { 108 };
297*4882a593Smuzhiyun static const unsigned int gpio12_pins[] = { 109 };
298*4882a593Smuzhiyun static const unsigned int gpio13_pins[] = { 110 };
299*4882a593Smuzhiyun static const unsigned int gpio14_pins[] = { 43 };
300*4882a593Smuzhiyun static const unsigned int gpio15_pins[] = { 44 };
301*4882a593Smuzhiyun static const unsigned int gpio16_pins[] = { 45 };
302*4882a593Smuzhiyun static const unsigned int gpio17_pins[] = { 46 };
303*4882a593Smuzhiyun static const unsigned int gpio18_pins[] = { 47 };
304*4882a593Smuzhiyun static const unsigned int gpio19_pins[] = { 48 };
305*4882a593Smuzhiyun static const unsigned int gpio20_pins[] = { 49 };
306*4882a593Smuzhiyun static const unsigned int gpio21_pins[] = { 50 };
307*4882a593Smuzhiyun static const unsigned int gpio22_pins[] = { 51 };
308*4882a593Smuzhiyun static const unsigned int gpio23_pins[] = { 52 };
309*4882a593Smuzhiyun static const unsigned int gpio24_pins[] = { 53 };
310*4882a593Smuzhiyun static const unsigned int gpio25_pins[] = { 54 };
311*4882a593Smuzhiyun static const unsigned int gpio26_pins[] = { 55 };
312*4882a593Smuzhiyun static const unsigned int gpio27_pins[] = { 56 };
313*4882a593Smuzhiyun static const unsigned int gpio28_pins[] = { 57 };
314*4882a593Smuzhiyun static const unsigned int gpio29_pins[] = { 58 };
315*4882a593Smuzhiyun static const unsigned int gpio30_pins[] = { 59 };
316*4882a593Smuzhiyun static const unsigned int gpio31_pins[] = { 60 };
317*4882a593Smuzhiyun static const unsigned int gpio32_pins[] = { 61 };
318*4882a593Smuzhiyun static const unsigned int gpio33_pins[] = { 62 };
319*4882a593Smuzhiyun static const unsigned int gpio34_pins[] = { 63 };
320*4882a593Smuzhiyun static const unsigned int gpio35_pins[] = { 64 };
321*4882a593Smuzhiyun static const unsigned int gpio36_pins[] = { 65 };
322*4882a593Smuzhiyun static const unsigned int gpio37_pins[] = { 66 };
323*4882a593Smuzhiyun static const unsigned int gpio38_pins[] = { 67 };
324*4882a593Smuzhiyun static const unsigned int gpio39_pins[] = { 68 };
325*4882a593Smuzhiyun static const unsigned int gpio40_pins[] = { 69 };
326*4882a593Smuzhiyun static const unsigned int gpio41_pins[] = { 70 };
327*4882a593Smuzhiyun static const unsigned int gpio42_pins[] = { 71 };
328*4882a593Smuzhiyun static const unsigned int gpio43_pins[] = { 72 };
329*4882a593Smuzhiyun static const unsigned int gpio44_pins[] = { 73 };
330*4882a593Smuzhiyun static const unsigned int gpio45_pins[] = { 74 };
331*4882a593Smuzhiyun static const unsigned int gpio46_pins[] = { 75 };
332*4882a593Smuzhiyun static const unsigned int gpio47_pins[] = { 76 };
333*4882a593Smuzhiyun static const unsigned int gpio48_pins[] = { 77 };
334*4882a593Smuzhiyun static const unsigned int gpio49_pins[] = { 78 };
335*4882a593Smuzhiyun static const unsigned int gpio50_pins[] = { 79 };
336*4882a593Smuzhiyun static const unsigned int gpio51_pins[] = { 80 };
337*4882a593Smuzhiyun static const unsigned int gpio52_pins[] = { 81 };
338*4882a593Smuzhiyun static const unsigned int gpio53_pins[] = { 82 };
339*4882a593Smuzhiyun static const unsigned int gpio54_pins[] = { 83 };
340*4882a593Smuzhiyun static const unsigned int gpio55_pins[] = { 84 };
341*4882a593Smuzhiyun static const unsigned int gpio56_pins[] = { 85 };
342*4882a593Smuzhiyun static const unsigned int gpio57_pins[] = { 86 };
343*4882a593Smuzhiyun static const unsigned int gpio58_pins[] = { 87 };
344*4882a593Smuzhiyun static const unsigned int gpio59_pins[] = { 88 };
345*4882a593Smuzhiyun static const unsigned int gpio60_pins[] = { 89 };
346*4882a593Smuzhiyun static const unsigned int gpio61_pins[] = { 90 };
347*4882a593Smuzhiyun static const unsigned int gpio62_pins[] = { 91 };
348*4882a593Smuzhiyun static const unsigned int gpio63_pins[] = { 92 };
349*4882a593Smuzhiyun static const unsigned int gpio64_pins[] = { 93 };
350*4882a593Smuzhiyun static const unsigned int gpio65_pins[] = { 94 };
351*4882a593Smuzhiyun static const unsigned int gpio66_pins[] = { 95 };
352*4882a593Smuzhiyun static const unsigned int gpio67_pins[] = { 96 };
353*4882a593Smuzhiyun static const unsigned int eth1_pins[] = { 43, 44, 45, 46, 47, 48, 49, 50, 51,
354*4882a593Smuzhiyun 52, 53, 54, 55, 56, 57, 58 };
355*4882a593Smuzhiyun static const unsigned int i2s0_pins[] = { 87, 88, 89, 90, 91 };
356*4882a593Smuzhiyun static const unsigned int i2s0_mclkin_pins[] = { 97 };
357*4882a593Smuzhiyun static const unsigned int i2s1_pins[] = { 92, 93, 94, 95, 96 };
358*4882a593Smuzhiyun static const unsigned int i2s1_mclkin_pins[] = { 98 };
359*4882a593Smuzhiyun static const unsigned int spi0_pins[] = { 59, 60, 61, 62 };
360*4882a593Smuzhiyun
361*4882a593Smuzhiyun #define BM1880_PINCTRL_GRP(nm) \
362*4882a593Smuzhiyun { \
363*4882a593Smuzhiyun .name = #nm "_grp", \
364*4882a593Smuzhiyun .pins = nm ## _pins, \
365*4882a593Smuzhiyun .npins = ARRAY_SIZE(nm ## _pins), \
366*4882a593Smuzhiyun }
367*4882a593Smuzhiyun
368*4882a593Smuzhiyun static const struct bm1880_pctrl_group bm1880_pctrl_groups[] = {
369*4882a593Smuzhiyun BM1880_PINCTRL_GRP(nand),
370*4882a593Smuzhiyun BM1880_PINCTRL_GRP(spi),
371*4882a593Smuzhiyun BM1880_PINCTRL_GRP(emmc),
372*4882a593Smuzhiyun BM1880_PINCTRL_GRP(sdio),
373*4882a593Smuzhiyun BM1880_PINCTRL_GRP(eth0),
374*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm0),
375*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm1),
376*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm2),
377*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm3),
378*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm4),
379*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm5),
380*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm6),
381*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm7),
382*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm8),
383*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm9),
384*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm10),
385*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm11),
386*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm12),
387*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm13),
388*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm14),
389*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm15),
390*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm16),
391*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm17),
392*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm18),
393*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm19),
394*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm20),
395*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm21),
396*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm22),
397*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm23),
398*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm24),
399*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm25),
400*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm26),
401*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm27),
402*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm28),
403*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm29),
404*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm30),
405*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm31),
406*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm32),
407*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm33),
408*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm34),
409*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm35),
410*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm36),
411*4882a593Smuzhiyun BM1880_PINCTRL_GRP(pwm37),
412*4882a593Smuzhiyun BM1880_PINCTRL_GRP(i2c0),
413*4882a593Smuzhiyun BM1880_PINCTRL_GRP(i2c1),
414*4882a593Smuzhiyun BM1880_PINCTRL_GRP(i2c2),
415*4882a593Smuzhiyun BM1880_PINCTRL_GRP(i2c3),
416*4882a593Smuzhiyun BM1880_PINCTRL_GRP(i2c4),
417*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart0),
418*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart1),
419*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart2),
420*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart3),
421*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart4),
422*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart5),
423*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart6),
424*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart7),
425*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart8),
426*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart9),
427*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart10),
428*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart11),
429*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart12),
430*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart13),
431*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart14),
432*4882a593Smuzhiyun BM1880_PINCTRL_GRP(uart15),
433*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio0),
434*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio1),
435*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio2),
436*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio3),
437*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio4),
438*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio5),
439*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio6),
440*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio7),
441*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio8),
442*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio9),
443*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio10),
444*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio11),
445*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio12),
446*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio13),
447*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio14),
448*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio15),
449*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio16),
450*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio17),
451*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio18),
452*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio19),
453*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio20),
454*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio21),
455*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio22),
456*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio23),
457*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio24),
458*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio25),
459*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio26),
460*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio27),
461*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio28),
462*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio29),
463*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio30),
464*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio31),
465*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio32),
466*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio33),
467*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio34),
468*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio35),
469*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio36),
470*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio37),
471*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio38),
472*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio39),
473*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio40),
474*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio41),
475*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio42),
476*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio43),
477*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio44),
478*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio45),
479*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio46),
480*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio47),
481*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio48),
482*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio49),
483*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio50),
484*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio51),
485*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio52),
486*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio53),
487*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio54),
488*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio55),
489*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio56),
490*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio57),
491*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio58),
492*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio59),
493*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio60),
494*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio61),
495*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio62),
496*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio63),
497*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio64),
498*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio65),
499*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio66),
500*4882a593Smuzhiyun BM1880_PINCTRL_GRP(gpio67),
501*4882a593Smuzhiyun BM1880_PINCTRL_GRP(eth1),
502*4882a593Smuzhiyun BM1880_PINCTRL_GRP(i2s0),
503*4882a593Smuzhiyun BM1880_PINCTRL_GRP(i2s0_mclkin),
504*4882a593Smuzhiyun BM1880_PINCTRL_GRP(i2s1),
505*4882a593Smuzhiyun BM1880_PINCTRL_GRP(i2s1_mclkin),
506*4882a593Smuzhiyun BM1880_PINCTRL_GRP(spi0),
507*4882a593Smuzhiyun };
508*4882a593Smuzhiyun
509*4882a593Smuzhiyun static const char * const nand_group[] = { "nand_grp" };
510*4882a593Smuzhiyun static const char * const spi_group[] = { "spi_grp" };
511*4882a593Smuzhiyun static const char * const emmc_group[] = { "emmc_grp" };
512*4882a593Smuzhiyun static const char * const sdio_group[] = { "sdio_grp" };
513*4882a593Smuzhiyun static const char * const eth0_group[] = { "eth0_grp" };
514*4882a593Smuzhiyun static const char * const pwm0_group[] = { "pwm0_grp" };
515*4882a593Smuzhiyun static const char * const pwm1_group[] = { "pwm1_grp" };
516*4882a593Smuzhiyun static const char * const pwm2_group[] = { "pwm2_grp" };
517*4882a593Smuzhiyun static const char * const pwm3_group[] = { "pwm3_grp" };
518*4882a593Smuzhiyun static const char * const pwm4_group[] = { "pwm4_grp" };
519*4882a593Smuzhiyun static const char * const pwm5_group[] = { "pwm5_grp" };
520*4882a593Smuzhiyun static const char * const pwm6_group[] = { "pwm6_grp" };
521*4882a593Smuzhiyun static const char * const pwm7_group[] = { "pwm7_grp" };
522*4882a593Smuzhiyun static const char * const pwm8_group[] = { "pwm8_grp" };
523*4882a593Smuzhiyun static const char * const pwm9_group[] = { "pwm9_grp" };
524*4882a593Smuzhiyun static const char * const pwm10_group[] = { "pwm10_grp" };
525*4882a593Smuzhiyun static const char * const pwm11_group[] = { "pwm11_grp" };
526*4882a593Smuzhiyun static const char * const pwm12_group[] = { "pwm12_grp" };
527*4882a593Smuzhiyun static const char * const pwm13_group[] = { "pwm13_grp" };
528*4882a593Smuzhiyun static const char * const pwm14_group[] = { "pwm14_grp" };
529*4882a593Smuzhiyun static const char * const pwm15_group[] = { "pwm15_grp" };
530*4882a593Smuzhiyun static const char * const pwm16_group[] = { "pwm16_grp" };
531*4882a593Smuzhiyun static const char * const pwm17_group[] = { "pwm17_grp" };
532*4882a593Smuzhiyun static const char * const pwm18_group[] = { "pwm18_grp" };
533*4882a593Smuzhiyun static const char * const pwm19_group[] = { "pwm19_grp" };
534*4882a593Smuzhiyun static const char * const pwm20_group[] = { "pwm20_grp" };
535*4882a593Smuzhiyun static const char * const pwm21_group[] = { "pwm21_grp" };
536*4882a593Smuzhiyun static const char * const pwm22_group[] = { "pwm22_grp" };
537*4882a593Smuzhiyun static const char * const pwm23_group[] = { "pwm23_grp" };
538*4882a593Smuzhiyun static const char * const pwm24_group[] = { "pwm24_grp" };
539*4882a593Smuzhiyun static const char * const pwm25_group[] = { "pwm25_grp" };
540*4882a593Smuzhiyun static const char * const pwm26_group[] = { "pwm26_grp" };
541*4882a593Smuzhiyun static const char * const pwm27_group[] = { "pwm27_grp" };
542*4882a593Smuzhiyun static const char * const pwm28_group[] = { "pwm28_grp" };
543*4882a593Smuzhiyun static const char * const pwm29_group[] = { "pwm29_grp" };
544*4882a593Smuzhiyun static const char * const pwm30_group[] = { "pwm30_grp" };
545*4882a593Smuzhiyun static const char * const pwm31_group[] = { "pwm31_grp" };
546*4882a593Smuzhiyun static const char * const pwm32_group[] = { "pwm32_grp" };
547*4882a593Smuzhiyun static const char * const pwm33_group[] = { "pwm33_grp" };
548*4882a593Smuzhiyun static const char * const pwm34_group[] = { "pwm34_grp" };
549*4882a593Smuzhiyun static const char * const pwm35_group[] = { "pwm35_grp" };
550*4882a593Smuzhiyun static const char * const pwm36_group[] = { "pwm36_grp" };
551*4882a593Smuzhiyun static const char * const pwm37_group[] = { "pwm37_grp" };
552*4882a593Smuzhiyun static const char * const i2c0_group[] = { "i2c0_grp" };
553*4882a593Smuzhiyun static const char * const i2c1_group[] = { "i2c1_grp" };
554*4882a593Smuzhiyun static const char * const i2c2_group[] = { "i2c2_grp" };
555*4882a593Smuzhiyun static const char * const i2c3_group[] = { "i2c3_grp" };
556*4882a593Smuzhiyun static const char * const i2c4_group[] = { "i2c4_grp" };
557*4882a593Smuzhiyun static const char * const uart0_group[] = { "uart0_grp" };
558*4882a593Smuzhiyun static const char * const uart1_group[] = { "uart1_grp" };
559*4882a593Smuzhiyun static const char * const uart2_group[] = { "uart2_grp" };
560*4882a593Smuzhiyun static const char * const uart3_group[] = { "uart3_grp" };
561*4882a593Smuzhiyun static const char * const uart4_group[] = { "uart4_grp" };
562*4882a593Smuzhiyun static const char * const uart5_group[] = { "uart5_grp" };
563*4882a593Smuzhiyun static const char * const uart6_group[] = { "uart6_grp" };
564*4882a593Smuzhiyun static const char * const uart7_group[] = { "uart7_grp" };
565*4882a593Smuzhiyun static const char * const uart8_group[] = { "uart8_grp" };
566*4882a593Smuzhiyun static const char * const uart9_group[] = { "uart9_grp" };
567*4882a593Smuzhiyun static const char * const uart10_group[] = { "uart10_grp" };
568*4882a593Smuzhiyun static const char * const uart11_group[] = { "uart11_grp" };
569*4882a593Smuzhiyun static const char * const uart12_group[] = { "uart12_grp" };
570*4882a593Smuzhiyun static const char * const uart13_group[] = { "uart13_grp" };
571*4882a593Smuzhiyun static const char * const uart14_group[] = { "uart14_grp" };
572*4882a593Smuzhiyun static const char * const uart15_group[] = { "uart15_grp" };
573*4882a593Smuzhiyun static const char * const gpio0_group[] = { "gpio0_grp" };
574*4882a593Smuzhiyun static const char * const gpio1_group[] = { "gpio1_grp" };
575*4882a593Smuzhiyun static const char * const gpio2_group[] = { "gpio2_grp" };
576*4882a593Smuzhiyun static const char * const gpio3_group[] = { "gpio3_grp" };
577*4882a593Smuzhiyun static const char * const gpio4_group[] = { "gpio4_grp" };
578*4882a593Smuzhiyun static const char * const gpio5_group[] = { "gpio5_grp" };
579*4882a593Smuzhiyun static const char * const gpio6_group[] = { "gpio6_grp" };
580*4882a593Smuzhiyun static const char * const gpio7_group[] = { "gpio7_grp" };
581*4882a593Smuzhiyun static const char * const gpio8_group[] = { "gpio8_grp" };
582*4882a593Smuzhiyun static const char * const gpio9_group[] = { "gpio9_grp" };
583*4882a593Smuzhiyun static const char * const gpio10_group[] = { "gpio10_grp" };
584*4882a593Smuzhiyun static const char * const gpio11_group[] = { "gpio11_grp" };
585*4882a593Smuzhiyun static const char * const gpio12_group[] = { "gpio12_grp" };
586*4882a593Smuzhiyun static const char * const gpio13_group[] = { "gpio13_grp" };
587*4882a593Smuzhiyun static const char * const gpio14_group[] = { "gpio14_grp" };
588*4882a593Smuzhiyun static const char * const gpio15_group[] = { "gpio15_grp" };
589*4882a593Smuzhiyun static const char * const gpio16_group[] = { "gpio16_grp" };
590*4882a593Smuzhiyun static const char * const gpio17_group[] = { "gpio17_grp" };
591*4882a593Smuzhiyun static const char * const gpio18_group[] = { "gpio18_grp" };
592*4882a593Smuzhiyun static const char * const gpio19_group[] = { "gpio19_grp" };
593*4882a593Smuzhiyun static const char * const gpio20_group[] = { "gpio20_grp" };
594*4882a593Smuzhiyun static const char * const gpio21_group[] = { "gpio21_grp" };
595*4882a593Smuzhiyun static const char * const gpio22_group[] = { "gpio22_grp" };
596*4882a593Smuzhiyun static const char * const gpio23_group[] = { "gpio23_grp" };
597*4882a593Smuzhiyun static const char * const gpio24_group[] = { "gpio24_grp" };
598*4882a593Smuzhiyun static const char * const gpio25_group[] = { "gpio25_grp" };
599*4882a593Smuzhiyun static const char * const gpio26_group[] = { "gpio26_grp" };
600*4882a593Smuzhiyun static const char * const gpio27_group[] = { "gpio27_grp" };
601*4882a593Smuzhiyun static const char * const gpio28_group[] = { "gpio28_grp" };
602*4882a593Smuzhiyun static const char * const gpio29_group[] = { "gpio29_grp" };
603*4882a593Smuzhiyun static const char * const gpio30_group[] = { "gpio30_grp" };
604*4882a593Smuzhiyun static const char * const gpio31_group[] = { "gpio31_grp" };
605*4882a593Smuzhiyun static const char * const gpio32_group[] = { "gpio32_grp" };
606*4882a593Smuzhiyun static const char * const gpio33_group[] = { "gpio33_grp" };
607*4882a593Smuzhiyun static const char * const gpio34_group[] = { "gpio34_grp" };
608*4882a593Smuzhiyun static const char * const gpio35_group[] = { "gpio35_grp" };
609*4882a593Smuzhiyun static const char * const gpio36_group[] = { "gpio36_grp" };
610*4882a593Smuzhiyun static const char * const gpio37_group[] = { "gpio37_grp" };
611*4882a593Smuzhiyun static const char * const gpio38_group[] = { "gpio38_grp" };
612*4882a593Smuzhiyun static const char * const gpio39_group[] = { "gpio39_grp" };
613*4882a593Smuzhiyun static const char * const gpio40_group[] = { "gpio40_grp" };
614*4882a593Smuzhiyun static const char * const gpio41_group[] = { "gpio41_grp" };
615*4882a593Smuzhiyun static const char * const gpio42_group[] = { "gpio42_grp" };
616*4882a593Smuzhiyun static const char * const gpio43_group[] = { "gpio43_grp" };
617*4882a593Smuzhiyun static const char * const gpio44_group[] = { "gpio44_grp" };
618*4882a593Smuzhiyun static const char * const gpio45_group[] = { "gpio45_grp" };
619*4882a593Smuzhiyun static const char * const gpio46_group[] = { "gpio46_grp" };
620*4882a593Smuzhiyun static const char * const gpio47_group[] = { "gpio47_grp" };
621*4882a593Smuzhiyun static const char * const gpio48_group[] = { "gpio48_grp" };
622*4882a593Smuzhiyun static const char * const gpio49_group[] = { "gpio49_grp" };
623*4882a593Smuzhiyun static const char * const gpio50_group[] = { "gpio50_grp" };
624*4882a593Smuzhiyun static const char * const gpio51_group[] = { "gpio51_grp" };
625*4882a593Smuzhiyun static const char * const gpio52_group[] = { "gpio52_grp" };
626*4882a593Smuzhiyun static const char * const gpio53_group[] = { "gpio53_grp" };
627*4882a593Smuzhiyun static const char * const gpio54_group[] = { "gpio54_grp" };
628*4882a593Smuzhiyun static const char * const gpio55_group[] = { "gpio55_grp" };
629*4882a593Smuzhiyun static const char * const gpio56_group[] = { "gpio56_grp" };
630*4882a593Smuzhiyun static const char * const gpio57_group[] = { "gpio57_grp" };
631*4882a593Smuzhiyun static const char * const gpio58_group[] = { "gpio58_grp" };
632*4882a593Smuzhiyun static const char * const gpio59_group[] = { "gpio59_grp" };
633*4882a593Smuzhiyun static const char * const gpio60_group[] = { "gpio60_grp" };
634*4882a593Smuzhiyun static const char * const gpio61_group[] = { "gpio61_grp" };
635*4882a593Smuzhiyun static const char * const gpio62_group[] = { "gpio62_grp" };
636*4882a593Smuzhiyun static const char * const gpio63_group[] = { "gpio63_grp" };
637*4882a593Smuzhiyun static const char * const gpio64_group[] = { "gpio64_grp" };
638*4882a593Smuzhiyun static const char * const gpio65_group[] = { "gpio65_grp" };
639*4882a593Smuzhiyun static const char * const gpio66_group[] = { "gpio66_grp" };
640*4882a593Smuzhiyun static const char * const gpio67_group[] = { "gpio67_grp" };
641*4882a593Smuzhiyun static const char * const eth1_group[] = { "eth1_grp" };
642*4882a593Smuzhiyun static const char * const i2s0_group[] = { "i2s0_grp" };
643*4882a593Smuzhiyun static const char * const i2s0_mclkin_group[] = { "i2s0_mclkin_grp" };
644*4882a593Smuzhiyun static const char * const i2s1_group[] = { "i2s1_grp" };
645*4882a593Smuzhiyun static const char * const i2s1_mclkin_group[] = { "i2s1_mclkin_grp" };
646*4882a593Smuzhiyun static const char * const spi0_group[] = { "spi0_grp" };
647*4882a593Smuzhiyun
648*4882a593Smuzhiyun #define BM1880_PINMUX_FUNCTION(fname, mval) \
649*4882a593Smuzhiyun [F_##fname] = { \
650*4882a593Smuzhiyun .name = #fname, \
651*4882a593Smuzhiyun .groups = fname##_group, \
652*4882a593Smuzhiyun .ngroups = ARRAY_SIZE(fname##_group), \
653*4882a593Smuzhiyun .mux_val = mval, \
654*4882a593Smuzhiyun }
655*4882a593Smuzhiyun
656*4882a593Smuzhiyun static const struct bm1880_pinmux_function bm1880_pmux_functions[] = {
657*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(nand, 2),
658*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(spi, 0),
659*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(emmc, 1),
660*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(sdio, 0),
661*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(eth0, 0),
662*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm0, 2),
663*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm1, 2),
664*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm2, 2),
665*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm3, 2),
666*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm4, 2),
667*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm5, 2),
668*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm6, 2),
669*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm7, 2),
670*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm8, 2),
671*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm9, 2),
672*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm10, 2),
673*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm11, 2),
674*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm12, 2),
675*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm13, 2),
676*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm14, 2),
677*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm15, 2),
678*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm16, 2),
679*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm17, 2),
680*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm18, 2),
681*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm19, 2),
682*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm20, 2),
683*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm21, 2),
684*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm22, 2),
685*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm23, 2),
686*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm24, 2),
687*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm25, 2),
688*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm26, 2),
689*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm27, 2),
690*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm28, 2),
691*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm29, 2),
692*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm30, 2),
693*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm31, 2),
694*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm32, 2),
695*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm33, 2),
696*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm34, 2),
697*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm35, 2),
698*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm36, 2),
699*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(pwm37, 2),
700*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(i2c0, 1),
701*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(i2c1, 1),
702*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(i2c2, 1),
703*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(i2c3, 1),
704*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(i2c4, 1),
705*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart0, 3),
706*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart1, 3),
707*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart2, 3),
708*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart3, 3),
709*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart4, 1),
710*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart5, 1),
711*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart6, 1),
712*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart7, 1),
713*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart8, 1),
714*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart9, 1),
715*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart10, 1),
716*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart11, 1),
717*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart12, 3),
718*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart13, 3),
719*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart14, 3),
720*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(uart15, 3),
721*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio0, 0),
722*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio1, 0),
723*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio2, 0),
724*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio3, 0),
725*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio4, 0),
726*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio5, 0),
727*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio6, 0),
728*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio7, 0),
729*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio8, 0),
730*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio9, 0),
731*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio10, 0),
732*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio11, 0),
733*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio12, 1),
734*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio13, 1),
735*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio14, 0),
736*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio15, 0),
737*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio16, 0),
738*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio17, 0),
739*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio18, 0),
740*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio19, 0),
741*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio20, 0),
742*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio21, 0),
743*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio22, 0),
744*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio23, 0),
745*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio24, 0),
746*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio25, 0),
747*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio26, 0),
748*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio27, 0),
749*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio28, 0),
750*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio29, 0),
751*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio30, 0),
752*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio31, 0),
753*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio32, 0),
754*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio33, 0),
755*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio34, 0),
756*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio35, 0),
757*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio36, 0),
758*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio37, 0),
759*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio38, 0),
760*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio39, 0),
761*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio40, 0),
762*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio41, 0),
763*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio42, 0),
764*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio43, 0),
765*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio44, 0),
766*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio45, 0),
767*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio46, 0),
768*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio47, 0),
769*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio48, 0),
770*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio49, 0),
771*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio50, 0),
772*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio51, 0),
773*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio52, 0),
774*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio53, 0),
775*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio54, 0),
776*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio55, 0),
777*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio56, 0),
778*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio57, 0),
779*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio58, 0),
780*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio59, 0),
781*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio60, 0),
782*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio61, 0),
783*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio62, 0),
784*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio63, 0),
785*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio64, 0),
786*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio65, 0),
787*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio66, 0),
788*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(gpio67, 0),
789*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(eth1, 1),
790*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(i2s0, 2),
791*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(i2s0_mclkin, 1),
792*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(i2s1, 2),
793*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(i2s1_mclkin, 1),
794*4882a593Smuzhiyun BM1880_PINMUX_FUNCTION(spi0, 1),
795*4882a593Smuzhiyun };
796*4882a593Smuzhiyun
797*4882a593Smuzhiyun #define BM1880_PINCONF_DAT(_width) \
798*4882a593Smuzhiyun { \
799*4882a593Smuzhiyun .drv_bits = _width, \
800*4882a593Smuzhiyun }
801*4882a593Smuzhiyun
802*4882a593Smuzhiyun static const struct bm1880_pinconf_data bm1880_pinconf[] = {
803*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
804*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
805*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
806*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
807*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
808*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
809*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
810*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
811*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
812*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
813*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
814*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
815*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
816*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
817*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
818*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
819*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
820*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
821*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
822*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
823*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
824*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
825*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
826*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
827*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
828*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
829*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
830*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
831*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
832*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
833*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
834*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
835*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
836*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
837*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
838*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
839*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
840*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
841*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
842*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
843*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
844*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
845*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
846*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
847*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
848*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
849*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
850*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
851*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
852*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
853*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
854*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
855*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
856*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
857*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
858*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
859*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
860*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
861*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
862*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x03),
863*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
864*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
865*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
866*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
867*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
868*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
869*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
870*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
871*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
872*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
873*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
874*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
875*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
876*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
877*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
878*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
879*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
880*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
881*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
882*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
883*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
884*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
885*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
886*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
887*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
888*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
889*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
890*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
891*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
892*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
893*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
894*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
895*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
896*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
897*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
898*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
899*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
900*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
901*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
902*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
903*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
904*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
905*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
906*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
907*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
908*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
909*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
910*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
911*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
912*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
913*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
914*4882a593Smuzhiyun BM1880_PINCONF_DAT(0x02),
915*4882a593Smuzhiyun };
916*4882a593Smuzhiyun
bm1880_pctrl_get_groups_count(struct pinctrl_dev * pctldev)917*4882a593Smuzhiyun static int bm1880_pctrl_get_groups_count(struct pinctrl_dev *pctldev)
918*4882a593Smuzhiyun {
919*4882a593Smuzhiyun struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
920*4882a593Smuzhiyun
921*4882a593Smuzhiyun return pctrl->ngroups;
922*4882a593Smuzhiyun }
923*4882a593Smuzhiyun
bm1880_pctrl_get_group_name(struct pinctrl_dev * pctldev,unsigned int selector)924*4882a593Smuzhiyun static const char *bm1880_pctrl_get_group_name(struct pinctrl_dev *pctldev,
925*4882a593Smuzhiyun unsigned int selector)
926*4882a593Smuzhiyun {
927*4882a593Smuzhiyun struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
928*4882a593Smuzhiyun
929*4882a593Smuzhiyun return pctrl->groups[selector].name;
930*4882a593Smuzhiyun }
931*4882a593Smuzhiyun
bm1880_pctrl_get_group_pins(struct pinctrl_dev * pctldev,unsigned int selector,const unsigned int ** pins,unsigned int * num_pins)932*4882a593Smuzhiyun static int bm1880_pctrl_get_group_pins(struct pinctrl_dev *pctldev,
933*4882a593Smuzhiyun unsigned int selector,
934*4882a593Smuzhiyun const unsigned int **pins,
935*4882a593Smuzhiyun unsigned int *num_pins)
936*4882a593Smuzhiyun {
937*4882a593Smuzhiyun struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
938*4882a593Smuzhiyun
939*4882a593Smuzhiyun *pins = pctrl->groups[selector].pins;
940*4882a593Smuzhiyun *num_pins = pctrl->groups[selector].npins;
941*4882a593Smuzhiyun
942*4882a593Smuzhiyun return 0;
943*4882a593Smuzhiyun }
944*4882a593Smuzhiyun
945*4882a593Smuzhiyun static const struct pinctrl_ops bm1880_pctrl_ops = {
946*4882a593Smuzhiyun .get_groups_count = bm1880_pctrl_get_groups_count,
947*4882a593Smuzhiyun .get_group_name = bm1880_pctrl_get_group_name,
948*4882a593Smuzhiyun .get_group_pins = bm1880_pctrl_get_group_pins,
949*4882a593Smuzhiyun .dt_node_to_map = pinconf_generic_dt_node_to_map_all,
950*4882a593Smuzhiyun .dt_free_map = pinctrl_utils_free_map,
951*4882a593Smuzhiyun };
952*4882a593Smuzhiyun
953*4882a593Smuzhiyun /* pinmux */
bm1880_pmux_get_functions_count(struct pinctrl_dev * pctldev)954*4882a593Smuzhiyun static int bm1880_pmux_get_functions_count(struct pinctrl_dev *pctldev)
955*4882a593Smuzhiyun {
956*4882a593Smuzhiyun struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
957*4882a593Smuzhiyun
958*4882a593Smuzhiyun return pctrl->nfuncs;
959*4882a593Smuzhiyun }
960*4882a593Smuzhiyun
bm1880_pmux_get_function_name(struct pinctrl_dev * pctldev,unsigned int selector)961*4882a593Smuzhiyun static const char *bm1880_pmux_get_function_name(struct pinctrl_dev *pctldev,
962*4882a593Smuzhiyun unsigned int selector)
963*4882a593Smuzhiyun {
964*4882a593Smuzhiyun struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
965*4882a593Smuzhiyun
966*4882a593Smuzhiyun return pctrl->funcs[selector].name;
967*4882a593Smuzhiyun }
968*4882a593Smuzhiyun
bm1880_pmux_get_function_groups(struct pinctrl_dev * pctldev,unsigned int selector,const char * const ** groups,unsigned * const num_groups)969*4882a593Smuzhiyun static int bm1880_pmux_get_function_groups(struct pinctrl_dev *pctldev,
970*4882a593Smuzhiyun unsigned int selector,
971*4882a593Smuzhiyun const char * const **groups,
972*4882a593Smuzhiyun unsigned * const num_groups)
973*4882a593Smuzhiyun {
974*4882a593Smuzhiyun struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
975*4882a593Smuzhiyun
976*4882a593Smuzhiyun *groups = pctrl->funcs[selector].groups;
977*4882a593Smuzhiyun *num_groups = pctrl->funcs[selector].ngroups;
978*4882a593Smuzhiyun return 0;
979*4882a593Smuzhiyun }
980*4882a593Smuzhiyun
bm1880_pinmux_set_mux(struct pinctrl_dev * pctldev,unsigned int function,unsigned int group)981*4882a593Smuzhiyun static int bm1880_pinmux_set_mux(struct pinctrl_dev *pctldev,
982*4882a593Smuzhiyun unsigned int function,
983*4882a593Smuzhiyun unsigned int group)
984*4882a593Smuzhiyun {
985*4882a593Smuzhiyun struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
986*4882a593Smuzhiyun const struct bm1880_pctrl_group *pgrp = &pctrl->groups[group];
987*4882a593Smuzhiyun const struct bm1880_pinmux_function *func = &pctrl->funcs[function];
988*4882a593Smuzhiyun int i;
989*4882a593Smuzhiyun
990*4882a593Smuzhiyun for (i = 0; i < pgrp->npins; i++) {
991*4882a593Smuzhiyun unsigned int pin = pgrp->pins[i];
992*4882a593Smuzhiyun u32 offset = (pin >> 1) << 2;
993*4882a593Smuzhiyun u32 mux_offset = ((!((pin + 1) & 1) << 4) + 4);
994*4882a593Smuzhiyun u32 regval = readl_relaxed(pctrl->base + BM1880_REG_MUX +
995*4882a593Smuzhiyun offset);
996*4882a593Smuzhiyun
997*4882a593Smuzhiyun regval &= ~(0x03 << mux_offset);
998*4882a593Smuzhiyun regval |= func->mux_val << mux_offset;
999*4882a593Smuzhiyun
1000*4882a593Smuzhiyun writel_relaxed(regval, pctrl->base + BM1880_REG_MUX + offset);
1001*4882a593Smuzhiyun }
1002*4882a593Smuzhiyun
1003*4882a593Smuzhiyun return 0;
1004*4882a593Smuzhiyun }
1005*4882a593Smuzhiyun
1006*4882a593Smuzhiyun #define BM1880_PINCONF(pin, idx) ((!((pin + 1) & 1) << 4) + idx)
1007*4882a593Smuzhiyun #define BM1880_PINCONF_PULLCTRL(pin) BM1880_PINCONF(pin, 0)
1008*4882a593Smuzhiyun #define BM1880_PINCONF_PULLUP(pin) BM1880_PINCONF(pin, 1)
1009*4882a593Smuzhiyun #define BM1880_PINCONF_PULLDOWN(pin) BM1880_PINCONF(pin, 2)
1010*4882a593Smuzhiyun #define BM1880_PINCONF_DRV(pin) BM1880_PINCONF(pin, 6)
1011*4882a593Smuzhiyun #define BM1880_PINCONF_SCHMITT(pin) BM1880_PINCONF(pin, 9)
1012*4882a593Smuzhiyun #define BM1880_PINCONF_SLEW(pin) BM1880_PINCONF(pin, 10)
1013*4882a593Smuzhiyun
bm1880_pinconf_drv_set(unsigned int mA,u32 width,u32 * regval,u32 bit_offset)1014*4882a593Smuzhiyun static int bm1880_pinconf_drv_set(unsigned int mA, u32 width,
1015*4882a593Smuzhiyun u32 *regval, u32 bit_offset)
1016*4882a593Smuzhiyun {
1017*4882a593Smuzhiyun u32 _regval;
1018*4882a593Smuzhiyun
1019*4882a593Smuzhiyun _regval = *regval;
1020*4882a593Smuzhiyun
1021*4882a593Smuzhiyun /*
1022*4882a593Smuzhiyun * There are two sets of drive strength bit width exposed by the
1023*4882a593Smuzhiyun * SoC at 4mA step, hence we need to handle them separately.
1024*4882a593Smuzhiyun */
1025*4882a593Smuzhiyun if (width == 0x03) {
1026*4882a593Smuzhiyun switch (mA) {
1027*4882a593Smuzhiyun case 4:
1028*4882a593Smuzhiyun _regval &= ~(width << bit_offset);
1029*4882a593Smuzhiyun _regval |= (0 << bit_offset);
1030*4882a593Smuzhiyun break;
1031*4882a593Smuzhiyun case 8:
1032*4882a593Smuzhiyun _regval &= ~(width << bit_offset);
1033*4882a593Smuzhiyun _regval |= (1 << bit_offset);
1034*4882a593Smuzhiyun break;
1035*4882a593Smuzhiyun case 12:
1036*4882a593Smuzhiyun _regval &= ~(width << bit_offset);
1037*4882a593Smuzhiyun _regval |= (2 << bit_offset);
1038*4882a593Smuzhiyun break;
1039*4882a593Smuzhiyun case 16:
1040*4882a593Smuzhiyun _regval &= ~(width << bit_offset);
1041*4882a593Smuzhiyun _regval |= (3 << bit_offset);
1042*4882a593Smuzhiyun break;
1043*4882a593Smuzhiyun case 20:
1044*4882a593Smuzhiyun _regval &= ~(width << bit_offset);
1045*4882a593Smuzhiyun _regval |= (4 << bit_offset);
1046*4882a593Smuzhiyun break;
1047*4882a593Smuzhiyun case 24:
1048*4882a593Smuzhiyun _regval &= ~(width << bit_offset);
1049*4882a593Smuzhiyun _regval |= (5 << bit_offset);
1050*4882a593Smuzhiyun break;
1051*4882a593Smuzhiyun case 28:
1052*4882a593Smuzhiyun _regval &= ~(width << bit_offset);
1053*4882a593Smuzhiyun _regval |= (6 << bit_offset);
1054*4882a593Smuzhiyun break;
1055*4882a593Smuzhiyun case 32:
1056*4882a593Smuzhiyun _regval &= ~(width << bit_offset);
1057*4882a593Smuzhiyun _regval |= (7 << bit_offset);
1058*4882a593Smuzhiyun break;
1059*4882a593Smuzhiyun default:
1060*4882a593Smuzhiyun return -EINVAL;
1061*4882a593Smuzhiyun }
1062*4882a593Smuzhiyun } else {
1063*4882a593Smuzhiyun switch (mA) {
1064*4882a593Smuzhiyun case 4:
1065*4882a593Smuzhiyun _regval &= ~(width << bit_offset);
1066*4882a593Smuzhiyun _regval |= (0 << bit_offset);
1067*4882a593Smuzhiyun break;
1068*4882a593Smuzhiyun case 8:
1069*4882a593Smuzhiyun _regval &= ~(width << bit_offset);
1070*4882a593Smuzhiyun _regval |= (1 << bit_offset);
1071*4882a593Smuzhiyun break;
1072*4882a593Smuzhiyun case 12:
1073*4882a593Smuzhiyun _regval &= ~(width << bit_offset);
1074*4882a593Smuzhiyun _regval |= (2 << bit_offset);
1075*4882a593Smuzhiyun break;
1076*4882a593Smuzhiyun case 16:
1077*4882a593Smuzhiyun _regval &= ~(width << bit_offset);
1078*4882a593Smuzhiyun _regval |= (3 << bit_offset);
1079*4882a593Smuzhiyun break;
1080*4882a593Smuzhiyun default:
1081*4882a593Smuzhiyun return -EINVAL;
1082*4882a593Smuzhiyun }
1083*4882a593Smuzhiyun }
1084*4882a593Smuzhiyun
1085*4882a593Smuzhiyun *regval = _regval;
1086*4882a593Smuzhiyun
1087*4882a593Smuzhiyun return 0;
1088*4882a593Smuzhiyun }
1089*4882a593Smuzhiyun
bm1880_pinconf_drv_get(u32 width,u32 drv)1090*4882a593Smuzhiyun static int bm1880_pinconf_drv_get(u32 width, u32 drv)
1091*4882a593Smuzhiyun {
1092*4882a593Smuzhiyun int ret = -ENOTSUPP;
1093*4882a593Smuzhiyun
1094*4882a593Smuzhiyun /*
1095*4882a593Smuzhiyun * There are two sets of drive strength bit width exposed by the
1096*4882a593Smuzhiyun * SoC at 4mA step, hence we need to handle them separately.
1097*4882a593Smuzhiyun */
1098*4882a593Smuzhiyun if (width == 0x03) {
1099*4882a593Smuzhiyun switch (drv) {
1100*4882a593Smuzhiyun case 0:
1101*4882a593Smuzhiyun ret = 4;
1102*4882a593Smuzhiyun break;
1103*4882a593Smuzhiyun case 1:
1104*4882a593Smuzhiyun ret = 8;
1105*4882a593Smuzhiyun break;
1106*4882a593Smuzhiyun case 2:
1107*4882a593Smuzhiyun ret = 12;
1108*4882a593Smuzhiyun break;
1109*4882a593Smuzhiyun case 3:
1110*4882a593Smuzhiyun ret = 16;
1111*4882a593Smuzhiyun break;
1112*4882a593Smuzhiyun case 4:
1113*4882a593Smuzhiyun ret = 20;
1114*4882a593Smuzhiyun break;
1115*4882a593Smuzhiyun case 5:
1116*4882a593Smuzhiyun ret = 24;
1117*4882a593Smuzhiyun break;
1118*4882a593Smuzhiyun case 6:
1119*4882a593Smuzhiyun ret = 28;
1120*4882a593Smuzhiyun break;
1121*4882a593Smuzhiyun case 7:
1122*4882a593Smuzhiyun ret = 32;
1123*4882a593Smuzhiyun break;
1124*4882a593Smuzhiyun default:
1125*4882a593Smuzhiyun break;
1126*4882a593Smuzhiyun }
1127*4882a593Smuzhiyun } else {
1128*4882a593Smuzhiyun switch (drv) {
1129*4882a593Smuzhiyun case 0:
1130*4882a593Smuzhiyun ret = 4;
1131*4882a593Smuzhiyun break;
1132*4882a593Smuzhiyun case 1:
1133*4882a593Smuzhiyun ret = 8;
1134*4882a593Smuzhiyun break;
1135*4882a593Smuzhiyun case 2:
1136*4882a593Smuzhiyun ret = 12;
1137*4882a593Smuzhiyun break;
1138*4882a593Smuzhiyun case 3:
1139*4882a593Smuzhiyun ret = 16;
1140*4882a593Smuzhiyun break;
1141*4882a593Smuzhiyun default:
1142*4882a593Smuzhiyun break;
1143*4882a593Smuzhiyun }
1144*4882a593Smuzhiyun }
1145*4882a593Smuzhiyun
1146*4882a593Smuzhiyun return ret;
1147*4882a593Smuzhiyun }
1148*4882a593Smuzhiyun
bm1880_pinconf_cfg_get(struct pinctrl_dev * pctldev,unsigned int pin,unsigned long * config)1149*4882a593Smuzhiyun static int bm1880_pinconf_cfg_get(struct pinctrl_dev *pctldev,
1150*4882a593Smuzhiyun unsigned int pin,
1151*4882a593Smuzhiyun unsigned long *config)
1152*4882a593Smuzhiyun {
1153*4882a593Smuzhiyun struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
1154*4882a593Smuzhiyun unsigned int param = pinconf_to_config_param(*config);
1155*4882a593Smuzhiyun unsigned int arg = 0;
1156*4882a593Smuzhiyun u32 regval, offset, bit_offset;
1157*4882a593Smuzhiyun int ret;
1158*4882a593Smuzhiyun
1159*4882a593Smuzhiyun offset = (pin >> 1) << 2;
1160*4882a593Smuzhiyun regval = readl_relaxed(pctrl->base + BM1880_REG_MUX + offset);
1161*4882a593Smuzhiyun
1162*4882a593Smuzhiyun switch (param) {
1163*4882a593Smuzhiyun case PIN_CONFIG_BIAS_PULL_UP:
1164*4882a593Smuzhiyun bit_offset = BM1880_PINCONF_PULLUP(pin);
1165*4882a593Smuzhiyun arg = !!(regval & BIT(bit_offset));
1166*4882a593Smuzhiyun break;
1167*4882a593Smuzhiyun case PIN_CONFIG_BIAS_PULL_DOWN:
1168*4882a593Smuzhiyun bit_offset = BM1880_PINCONF_PULLDOWN(pin);
1169*4882a593Smuzhiyun arg = !!(regval & BIT(bit_offset));
1170*4882a593Smuzhiyun break;
1171*4882a593Smuzhiyun case PIN_CONFIG_BIAS_DISABLE:
1172*4882a593Smuzhiyun bit_offset = BM1880_PINCONF_PULLCTRL(pin);
1173*4882a593Smuzhiyun arg = !!(regval & BIT(bit_offset));
1174*4882a593Smuzhiyun break;
1175*4882a593Smuzhiyun case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
1176*4882a593Smuzhiyun bit_offset = BM1880_PINCONF_SCHMITT(pin);
1177*4882a593Smuzhiyun arg = !!(regval & BIT(bit_offset));
1178*4882a593Smuzhiyun break;
1179*4882a593Smuzhiyun case PIN_CONFIG_SLEW_RATE:
1180*4882a593Smuzhiyun bit_offset = BM1880_PINCONF_SLEW(pin);
1181*4882a593Smuzhiyun arg = !!(regval & BIT(bit_offset));
1182*4882a593Smuzhiyun break;
1183*4882a593Smuzhiyun case PIN_CONFIG_DRIVE_STRENGTH:
1184*4882a593Smuzhiyun bit_offset = BM1880_PINCONF_DRV(pin);
1185*4882a593Smuzhiyun ret = bm1880_pinconf_drv_get(pctrl->pinconf[pin].drv_bits,
1186*4882a593Smuzhiyun !!(regval & BIT(bit_offset)));
1187*4882a593Smuzhiyun if (ret < 0)
1188*4882a593Smuzhiyun return ret;
1189*4882a593Smuzhiyun
1190*4882a593Smuzhiyun arg = ret;
1191*4882a593Smuzhiyun break;
1192*4882a593Smuzhiyun default:
1193*4882a593Smuzhiyun return -ENOTSUPP;
1194*4882a593Smuzhiyun }
1195*4882a593Smuzhiyun
1196*4882a593Smuzhiyun *config = pinconf_to_config_packed(param, arg);
1197*4882a593Smuzhiyun
1198*4882a593Smuzhiyun return 0;
1199*4882a593Smuzhiyun }
1200*4882a593Smuzhiyun
bm1880_pinconf_cfg_set(struct pinctrl_dev * pctldev,unsigned int pin,unsigned long * configs,unsigned int num_configs)1201*4882a593Smuzhiyun static int bm1880_pinconf_cfg_set(struct pinctrl_dev *pctldev,
1202*4882a593Smuzhiyun unsigned int pin,
1203*4882a593Smuzhiyun unsigned long *configs,
1204*4882a593Smuzhiyun unsigned int num_configs)
1205*4882a593Smuzhiyun {
1206*4882a593Smuzhiyun struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
1207*4882a593Smuzhiyun u32 regval, offset, bit_offset;
1208*4882a593Smuzhiyun int i, ret;
1209*4882a593Smuzhiyun
1210*4882a593Smuzhiyun offset = (pin >> 1) << 2;
1211*4882a593Smuzhiyun regval = readl_relaxed(pctrl->base + BM1880_REG_MUX + offset);
1212*4882a593Smuzhiyun
1213*4882a593Smuzhiyun for (i = 0; i < num_configs; i++) {
1214*4882a593Smuzhiyun unsigned int param = pinconf_to_config_param(configs[i]);
1215*4882a593Smuzhiyun unsigned int arg = pinconf_to_config_argument(configs[i]);
1216*4882a593Smuzhiyun
1217*4882a593Smuzhiyun switch (param) {
1218*4882a593Smuzhiyun case PIN_CONFIG_BIAS_PULL_UP:
1219*4882a593Smuzhiyun bit_offset = BM1880_PINCONF_PULLUP(pin);
1220*4882a593Smuzhiyun regval |= BIT(bit_offset);
1221*4882a593Smuzhiyun break;
1222*4882a593Smuzhiyun case PIN_CONFIG_BIAS_PULL_DOWN:
1223*4882a593Smuzhiyun bit_offset = BM1880_PINCONF_PULLDOWN(pin);
1224*4882a593Smuzhiyun regval |= BIT(bit_offset);
1225*4882a593Smuzhiyun break;
1226*4882a593Smuzhiyun case PIN_CONFIG_BIAS_DISABLE:
1227*4882a593Smuzhiyun bit_offset = BM1880_PINCONF_PULLCTRL(pin);
1228*4882a593Smuzhiyun regval |= BIT(bit_offset);
1229*4882a593Smuzhiyun break;
1230*4882a593Smuzhiyun case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
1231*4882a593Smuzhiyun bit_offset = BM1880_PINCONF_SCHMITT(pin);
1232*4882a593Smuzhiyun if (arg)
1233*4882a593Smuzhiyun regval |= BIT(bit_offset);
1234*4882a593Smuzhiyun else
1235*4882a593Smuzhiyun regval &= ~BIT(bit_offset);
1236*4882a593Smuzhiyun break;
1237*4882a593Smuzhiyun case PIN_CONFIG_SLEW_RATE:
1238*4882a593Smuzhiyun bit_offset = BM1880_PINCONF_SLEW(pin);
1239*4882a593Smuzhiyun if (arg)
1240*4882a593Smuzhiyun regval |= BIT(bit_offset);
1241*4882a593Smuzhiyun else
1242*4882a593Smuzhiyun regval &= ~BIT(bit_offset);
1243*4882a593Smuzhiyun break;
1244*4882a593Smuzhiyun case PIN_CONFIG_DRIVE_STRENGTH:
1245*4882a593Smuzhiyun bit_offset = BM1880_PINCONF_DRV(pin);
1246*4882a593Smuzhiyun ret = bm1880_pinconf_drv_set(arg,
1247*4882a593Smuzhiyun pctrl->pinconf[pin].drv_bits,
1248*4882a593Smuzhiyun ®val, bit_offset);
1249*4882a593Smuzhiyun if (ret < 0)
1250*4882a593Smuzhiyun return ret;
1251*4882a593Smuzhiyun
1252*4882a593Smuzhiyun break;
1253*4882a593Smuzhiyun default:
1254*4882a593Smuzhiyun dev_warn(pctldev->dev,
1255*4882a593Smuzhiyun "unsupported configuration parameter '%u'\n",
1256*4882a593Smuzhiyun param);
1257*4882a593Smuzhiyun continue;
1258*4882a593Smuzhiyun }
1259*4882a593Smuzhiyun
1260*4882a593Smuzhiyun writel_relaxed(regval, pctrl->base + BM1880_REG_MUX + offset);
1261*4882a593Smuzhiyun }
1262*4882a593Smuzhiyun
1263*4882a593Smuzhiyun return 0;
1264*4882a593Smuzhiyun }
1265*4882a593Smuzhiyun
bm1880_pinconf_group_set(struct pinctrl_dev * pctldev,unsigned int selector,unsigned long * configs,unsigned int num_configs)1266*4882a593Smuzhiyun static int bm1880_pinconf_group_set(struct pinctrl_dev *pctldev,
1267*4882a593Smuzhiyun unsigned int selector,
1268*4882a593Smuzhiyun unsigned long *configs,
1269*4882a593Smuzhiyun unsigned int num_configs)
1270*4882a593Smuzhiyun {
1271*4882a593Smuzhiyun int i, ret;
1272*4882a593Smuzhiyun struct bm1880_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
1273*4882a593Smuzhiyun const struct bm1880_pctrl_group *pgrp = &pctrl->groups[selector];
1274*4882a593Smuzhiyun
1275*4882a593Smuzhiyun for (i = 0; i < pgrp->npins; i++) {
1276*4882a593Smuzhiyun ret = bm1880_pinconf_cfg_set(pctldev, pgrp->pins[i], configs,
1277*4882a593Smuzhiyun num_configs);
1278*4882a593Smuzhiyun if (ret)
1279*4882a593Smuzhiyun return ret;
1280*4882a593Smuzhiyun }
1281*4882a593Smuzhiyun
1282*4882a593Smuzhiyun return 0;
1283*4882a593Smuzhiyun }
1284*4882a593Smuzhiyun
1285*4882a593Smuzhiyun static const struct pinconf_ops bm1880_pinconf_ops = {
1286*4882a593Smuzhiyun .is_generic = true,
1287*4882a593Smuzhiyun .pin_config_get = bm1880_pinconf_cfg_get,
1288*4882a593Smuzhiyun .pin_config_set = bm1880_pinconf_cfg_set,
1289*4882a593Smuzhiyun .pin_config_group_set = bm1880_pinconf_group_set,
1290*4882a593Smuzhiyun };
1291*4882a593Smuzhiyun
1292*4882a593Smuzhiyun static const struct pinmux_ops bm1880_pinmux_ops = {
1293*4882a593Smuzhiyun .get_functions_count = bm1880_pmux_get_functions_count,
1294*4882a593Smuzhiyun .get_function_name = bm1880_pmux_get_function_name,
1295*4882a593Smuzhiyun .get_function_groups = bm1880_pmux_get_function_groups,
1296*4882a593Smuzhiyun .set_mux = bm1880_pinmux_set_mux,
1297*4882a593Smuzhiyun };
1298*4882a593Smuzhiyun
1299*4882a593Smuzhiyun static struct pinctrl_desc bm1880_desc = {
1300*4882a593Smuzhiyun .name = "bm1880_pinctrl",
1301*4882a593Smuzhiyun .pins = bm1880_pins,
1302*4882a593Smuzhiyun .npins = ARRAY_SIZE(bm1880_pins),
1303*4882a593Smuzhiyun .pctlops = &bm1880_pctrl_ops,
1304*4882a593Smuzhiyun .pmxops = &bm1880_pinmux_ops,
1305*4882a593Smuzhiyun .confops = &bm1880_pinconf_ops,
1306*4882a593Smuzhiyun .owner = THIS_MODULE,
1307*4882a593Smuzhiyun };
1308*4882a593Smuzhiyun
bm1880_pinctrl_probe(struct platform_device * pdev)1309*4882a593Smuzhiyun static int bm1880_pinctrl_probe(struct platform_device *pdev)
1310*4882a593Smuzhiyun
1311*4882a593Smuzhiyun {
1312*4882a593Smuzhiyun struct bm1880_pinctrl *pctrl;
1313*4882a593Smuzhiyun
1314*4882a593Smuzhiyun pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
1315*4882a593Smuzhiyun if (!pctrl)
1316*4882a593Smuzhiyun return -ENOMEM;
1317*4882a593Smuzhiyun
1318*4882a593Smuzhiyun pctrl->base = devm_platform_ioremap_resource(pdev, 0);
1319*4882a593Smuzhiyun if (IS_ERR(pctrl->base))
1320*4882a593Smuzhiyun return PTR_ERR(pctrl->base);
1321*4882a593Smuzhiyun
1322*4882a593Smuzhiyun pctrl->groups = bm1880_pctrl_groups;
1323*4882a593Smuzhiyun pctrl->ngroups = ARRAY_SIZE(bm1880_pctrl_groups);
1324*4882a593Smuzhiyun pctrl->funcs = bm1880_pmux_functions;
1325*4882a593Smuzhiyun pctrl->nfuncs = ARRAY_SIZE(bm1880_pmux_functions);
1326*4882a593Smuzhiyun pctrl->pinconf = bm1880_pinconf;
1327*4882a593Smuzhiyun
1328*4882a593Smuzhiyun pctrl->pctrldev = devm_pinctrl_register(&pdev->dev, &bm1880_desc,
1329*4882a593Smuzhiyun pctrl);
1330*4882a593Smuzhiyun if (IS_ERR(pctrl->pctrldev))
1331*4882a593Smuzhiyun return PTR_ERR(pctrl->pctrldev);
1332*4882a593Smuzhiyun
1333*4882a593Smuzhiyun platform_set_drvdata(pdev, pctrl);
1334*4882a593Smuzhiyun
1335*4882a593Smuzhiyun dev_info(&pdev->dev, "BM1880 pinctrl driver initialized\n");
1336*4882a593Smuzhiyun
1337*4882a593Smuzhiyun return 0;
1338*4882a593Smuzhiyun }
1339*4882a593Smuzhiyun
1340*4882a593Smuzhiyun static const struct of_device_id bm1880_pinctrl_of_match[] = {
1341*4882a593Smuzhiyun { .compatible = "bitmain,bm1880-pinctrl" },
1342*4882a593Smuzhiyun { }
1343*4882a593Smuzhiyun };
1344*4882a593Smuzhiyun
1345*4882a593Smuzhiyun static struct platform_driver bm1880_pinctrl_driver = {
1346*4882a593Smuzhiyun .driver = {
1347*4882a593Smuzhiyun .name = "pinctrl-bm1880",
1348*4882a593Smuzhiyun .of_match_table = of_match_ptr(bm1880_pinctrl_of_match),
1349*4882a593Smuzhiyun },
1350*4882a593Smuzhiyun .probe = bm1880_pinctrl_probe,
1351*4882a593Smuzhiyun };
1352*4882a593Smuzhiyun
bm1880_pinctrl_init(void)1353*4882a593Smuzhiyun static int __init bm1880_pinctrl_init(void)
1354*4882a593Smuzhiyun {
1355*4882a593Smuzhiyun return platform_driver_register(&bm1880_pinctrl_driver);
1356*4882a593Smuzhiyun }
1357*4882a593Smuzhiyun arch_initcall(bm1880_pinctrl_init);
1358