xref: /linux/drivers/pinctrl/freescale/pinctrl-imx7ulp.c (revision 060f03e95454a0f4a1deff3e5f912e461ae0f0c5)
1c2b39decSFabio Estevam // SPDX-License-Identifier: GPL-2.0
2c2b39decSFabio Estevam //
3c2b39decSFabio Estevam // Copyright (C) 2016 Freescale Semiconductor, Inc.
4c2b39decSFabio Estevam // Copyright (C) 2017 NXP
5c2b39decSFabio Estevam //
6c2b39decSFabio Estevam // Author: Dong Aisheng <aisheng.dong@nxp.com>
7b026402bSDong Aisheng 
8b026402bSDong Aisheng #include <linux/err.h>
9b026402bSDong Aisheng #include <linux/init.h>
10b026402bSDong Aisheng #include <linux/io.h>
11*060f03e9SRob Herring #include <linux/mod_devicetable.h>
12*060f03e9SRob Herring #include <linux/platform_device.h>
13b026402bSDong Aisheng #include <linux/pinctrl/pinctrl.h>
14b026402bSDong Aisheng 
15b026402bSDong Aisheng #include "pinctrl-imx.h"
16b026402bSDong Aisheng 
17b026402bSDong Aisheng enum imx7ulp_pads {
18b026402bSDong Aisheng 	IMX7ULP_PAD_PTC0 = 0,
19b026402bSDong Aisheng 	IMX7ULP_PAD_PTC1,
20b026402bSDong Aisheng 	IMX7ULP_PAD_PTC2,
21b026402bSDong Aisheng 	IMX7ULP_PAD_PTC3,
22b026402bSDong Aisheng 	IMX7ULP_PAD_PTC4,
23b026402bSDong Aisheng 	IMX7ULP_PAD_PTC5,
24b026402bSDong Aisheng 	IMX7ULP_PAD_PTC6,
25b026402bSDong Aisheng 	IMX7ULP_PAD_PTC7,
26b026402bSDong Aisheng 	IMX7ULP_PAD_PTC8,
27b026402bSDong Aisheng 	IMX7ULP_PAD_PTC9,
28b026402bSDong Aisheng 	IMX7ULP_PAD_PTC10,
29b026402bSDong Aisheng 	IMX7ULP_PAD_PTC11,
30b026402bSDong Aisheng 	IMX7ULP_PAD_PTC12,
31b026402bSDong Aisheng 	IMX7ULP_PAD_PTC13,
32b026402bSDong Aisheng 	IMX7ULP_PAD_PTC14,
33b026402bSDong Aisheng 	IMX7ULP_PAD_PTC15,
34b026402bSDong Aisheng 	IMX7ULP_PAD_PTC16,
35b026402bSDong Aisheng 	IMX7ULP_PAD_PTC17,
36b026402bSDong Aisheng 	IMX7ULP_PAD_PTC18,
37b026402bSDong Aisheng 	IMX7ULP_PAD_PTC19,
38b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE0,
39b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE1,
40b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE2,
41b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE3,
42b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE4,
43b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE5,
44b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE6,
45b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE7,
46b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE8,
47b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE9,
48b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE10,
49b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE11,
50b026402bSDong Aisheng 	IMX7ULP_PAD_PTD0,
51b026402bSDong Aisheng 	IMX7ULP_PAD_PTD1,
52b026402bSDong Aisheng 	IMX7ULP_PAD_PTD2,
53b026402bSDong Aisheng 	IMX7ULP_PAD_PTD3,
54b026402bSDong Aisheng 	IMX7ULP_PAD_PTD4,
55b026402bSDong Aisheng 	IMX7ULP_PAD_PTD5,
56b026402bSDong Aisheng 	IMX7ULP_PAD_PTD6,
57b026402bSDong Aisheng 	IMX7ULP_PAD_PTD7,
58b026402bSDong Aisheng 	IMX7ULP_PAD_PTD8,
59b026402bSDong Aisheng 	IMX7ULP_PAD_PTD9,
60b026402bSDong Aisheng 	IMX7ULP_PAD_PTD10,
61b026402bSDong Aisheng 	IMX7ULP_PAD_PTD11,
62b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE12,
63b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE13,
64b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE14,
65b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE15,
66b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE16,
67b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE17,
68b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE18,
69b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE19,
70b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE20,
71b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE21,
72b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE22,
73b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE23,
74b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE24,
75b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE25,
76b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE26,
77b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE27,
78b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE28,
79b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE29,
80b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE30,
81b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE31,
82b026402bSDong Aisheng 	IMX7ULP_PAD_PTE0,
83b026402bSDong Aisheng 	IMX7ULP_PAD_PTE1,
84b026402bSDong Aisheng 	IMX7ULP_PAD_PTE2,
85b026402bSDong Aisheng 	IMX7ULP_PAD_PTE3,
86b026402bSDong Aisheng 	IMX7ULP_PAD_PTE4,
87b026402bSDong Aisheng 	IMX7ULP_PAD_PTE5,
88b026402bSDong Aisheng 	IMX7ULP_PAD_PTE6,
89b026402bSDong Aisheng 	IMX7ULP_PAD_PTE7,
90b026402bSDong Aisheng 	IMX7ULP_PAD_PTE8,
91b026402bSDong Aisheng 	IMX7ULP_PAD_PTE9,
92b026402bSDong Aisheng 	IMX7ULP_PAD_PTE10,
93b026402bSDong Aisheng 	IMX7ULP_PAD_PTE11,
94b026402bSDong Aisheng 	IMX7ULP_PAD_PTE12,
95b026402bSDong Aisheng 	IMX7ULP_PAD_PTE13,
96b026402bSDong Aisheng 	IMX7ULP_PAD_PTE14,
97b026402bSDong Aisheng 	IMX7ULP_PAD_PTE15,
98b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE32,
99b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE33,
100b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE34,
101b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE35,
102b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE36,
103b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE37,
104b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE38,
105b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE39,
106b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE40,
107b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE41,
108b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE42,
109b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE43,
110b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE44,
111b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE45,
112b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE46,
113b026402bSDong Aisheng 	IMX7ULP_PAD_RESERVE47,
114b026402bSDong Aisheng 	IMX7ULP_PAD_PTF0,
115b026402bSDong Aisheng 	IMX7ULP_PAD_PTF1,
116b026402bSDong Aisheng 	IMX7ULP_PAD_PTF2,
117b026402bSDong Aisheng 	IMX7ULP_PAD_PTF3,
118b026402bSDong Aisheng 	IMX7ULP_PAD_PTF4,
119b026402bSDong Aisheng 	IMX7ULP_PAD_PTF5,
120b026402bSDong Aisheng 	IMX7ULP_PAD_PTF6,
121b026402bSDong Aisheng 	IMX7ULP_PAD_PTF7,
122b026402bSDong Aisheng 	IMX7ULP_PAD_PTF8,
123b026402bSDong Aisheng 	IMX7ULP_PAD_PTF9,
124b026402bSDong Aisheng 	IMX7ULP_PAD_PTF10,
125b026402bSDong Aisheng 	IMX7ULP_PAD_PTF11,
126b026402bSDong Aisheng 	IMX7ULP_PAD_PTF12,
127b026402bSDong Aisheng 	IMX7ULP_PAD_PTF13,
128b026402bSDong Aisheng 	IMX7ULP_PAD_PTF14,
129b026402bSDong Aisheng 	IMX7ULP_PAD_PTF15,
130b026402bSDong Aisheng 	IMX7ULP_PAD_PTF16,
131b026402bSDong Aisheng 	IMX7ULP_PAD_PTF17,
132b026402bSDong Aisheng 	IMX7ULP_PAD_PTF18,
133b026402bSDong Aisheng 	IMX7ULP_PAD_PTF19,
134b026402bSDong Aisheng };
135b026402bSDong Aisheng 
136b026402bSDong Aisheng /* Pad names for the pinmux subsystem */
137b026402bSDong Aisheng static const struct pinctrl_pin_desc imx7ulp_pinctrl_pads[] = {
138b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC0),
139b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC1),
140b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC2),
141b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC3),
142b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC4),
143b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC5),
144b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC6),
145b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC7),
146b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC8),
147b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC9),
148b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC10),
149b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC11),
150b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC12),
151b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC13),
152b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC14),
153b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC15),
154b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC16),
155b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC17),
156b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC18),
157b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTC19),
158b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE0),
159b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE1),
160b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE2),
161b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE3),
162b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE4),
163b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE5),
164b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE6),
165b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE7),
166b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE8),
167b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE9),
168b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE10),
169b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE11),
170b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTD0),
171b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTD1),
172b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTD2),
173b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTD3),
174b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTD4),
175b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTD5),
176b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTD6),
177b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTD7),
178b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTD8),
179b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTD9),
180b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTD10),
181b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTD11),
182b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE12),
183b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE13),
184b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE14),
185b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE15),
186b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE16),
187b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE17),
188b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE18),
189b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE19),
190b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE20),
191b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE21),
192b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE22),
193b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE23),
194b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE24),
195b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE25),
196b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE26),
197b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE27),
198b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE28),
199b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE29),
200b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE30),
201b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE31),
202b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE0),
203b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE1),
204b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE2),
205b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE3),
206b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE4),
207b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE5),
208b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE6),
209b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE7),
210b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE8),
211b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE9),
212b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE10),
213b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE11),
214b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE12),
215b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE13),
216b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE14),
217b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTE15),
218b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE32),
219b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE33),
220b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE34),
221b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE35),
222b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE36),
223b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE37),
224b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE38),
225b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE39),
226b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE40),
227b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE41),
228b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE42),
229b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE43),
230b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE44),
231b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE45),
232b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE46),
233b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_RESERVE47),
234b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF0),
235b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF1),
236b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF2),
237b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF3),
238b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF4),
239b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF5),
240b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF6),
241b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF7),
242b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF8),
243b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF9),
244b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF10),
245b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF11),
246b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF12),
247b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF13),
248b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF14),
249b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF15),
250b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF16),
251b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF17),
252b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF18),
253b026402bSDong Aisheng 	IMX_PINCTRL_PIN(IMX7ULP_PAD_PTF19),
254b026402bSDong Aisheng };
255b026402bSDong Aisheng 
25626d1f438SDong Aisheng #define BM_OBE_ENABLED		BIT(17)
25726d1f438SDong Aisheng #define BM_IBE_ENABLED		BIT(16)
258b026402bSDong Aisheng #define BM_MUX_MODE		0xf00
259b026402bSDong Aisheng #define BP_MUX_MODE		8
260b026402bSDong Aisheng 
26126d1f438SDong Aisheng static int imx7ulp_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
26226d1f438SDong Aisheng 					  struct pinctrl_gpio_range *range,
26326d1f438SDong Aisheng 					  unsigned offset, bool input)
26426d1f438SDong Aisheng {
26526d1f438SDong Aisheng 	struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
26626d1f438SDong Aisheng 	const struct imx_pin_reg *pin_reg;
26726d1f438SDong Aisheng 	u32 reg;
26826d1f438SDong Aisheng 
269f5843492SStefan Agner 	pin_reg = &ipctl->pin_regs[offset];
27026d1f438SDong Aisheng 	if (pin_reg->mux_reg == -1)
27126d1f438SDong Aisheng 		return -EINVAL;
27226d1f438SDong Aisheng 
27326d1f438SDong Aisheng 	reg = readl(ipctl->base + pin_reg->mux_reg);
27426d1f438SDong Aisheng 	if (input)
27526d1f438SDong Aisheng 		reg = (reg & ~BM_OBE_ENABLED) | BM_IBE_ENABLED;
27626d1f438SDong Aisheng 	else
27726d1f438SDong Aisheng 		reg = (reg & ~BM_IBE_ENABLED) | BM_OBE_ENABLED;
27826d1f438SDong Aisheng 	writel(reg, ipctl->base + pin_reg->mux_reg);
27926d1f438SDong Aisheng 
28026d1f438SDong Aisheng 	return 0;
28126d1f438SDong Aisheng }
28226d1f438SDong Aisheng 
2837c017687SStefan Agner static const struct imx_pinctrl_soc_info imx7ulp_pinctrl_info = {
284b026402bSDong Aisheng 	.pins = imx7ulp_pinctrl_pads,
285b026402bSDong Aisheng 	.npins = ARRAY_SIZE(imx7ulp_pinctrl_pads),
286b026402bSDong Aisheng 	.flags = ZERO_OFFSET_VALID | SHARE_MUX_CONF_REG,
28726d1f438SDong Aisheng 	.gpio_set_direction = imx7ulp_pmx_gpio_set_direction,
288b026402bSDong Aisheng 	.mux_mask = BM_MUX_MODE,
289b026402bSDong Aisheng 	.mux_shift = BP_MUX_MODE,
290b026402bSDong Aisheng };
291b026402bSDong Aisheng 
292b026402bSDong Aisheng static const struct of_device_id imx7ulp_pinctrl_of_match[] = {
293b026402bSDong Aisheng 	{ .compatible = "fsl,imx7ulp-iomuxc1", },
294b026402bSDong Aisheng 	{ /* sentinel */ }
295b026402bSDong Aisheng };
296b026402bSDong Aisheng 
297b026402bSDong Aisheng static int imx7ulp_pinctrl_probe(struct platform_device *pdev)
298b026402bSDong Aisheng {
299b026402bSDong Aisheng 	return imx_pinctrl_probe(pdev, &imx7ulp_pinctrl_info);
300b026402bSDong Aisheng }
301b026402bSDong Aisheng 
302b026402bSDong Aisheng static struct platform_driver imx7ulp_pinctrl_driver = {
303b026402bSDong Aisheng 	.driver = {
304b026402bSDong Aisheng 		.name = "imx7ulp-pinctrl",
305f6b6db2dSFabio Estevam 		.of_match_table = imx7ulp_pinctrl_of_match,
306b026402bSDong Aisheng 		.suppress_bind_attrs = true,
307b026402bSDong Aisheng 	},
308b026402bSDong Aisheng 	.probe = imx7ulp_pinctrl_probe,
309b026402bSDong Aisheng };
310b026402bSDong Aisheng 
311b026402bSDong Aisheng static int __init imx7ulp_pinctrl_init(void)
312b026402bSDong Aisheng {
313b026402bSDong Aisheng 	return platform_driver_register(&imx7ulp_pinctrl_driver);
314b026402bSDong Aisheng }
315b026402bSDong Aisheng arch_initcall(imx7ulp_pinctrl_init);
316