xref: /linux/drivers/pinctrl/pinctrl-ingenic.c (revision d2c9a99135da931377240942d44f3dea104cedb8)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Ingenic SoCs pinctrl driver
4  *
5  * Copyright (c) 2017 Paul Cercueil <paul@crapouillou.net>
6  * Copyright (c) 2017, 2019, 2020, 2023 Paul Boddie <paul@boddie.org.uk>
7  * Copyright (c) 2019, 2020 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
8  */
9 
10 #include <linux/compiler.h>
11 #include <linux/gpio/driver.h>
12 #include <linux/interrupt.h>
13 #include <linux/io.h>
14 #include <linux/kernel.h>
15 #include <linux/of.h>
16 #include <linux/platform_device.h>
17 #include <linux/property.h>
18 #include <linux/regmap.h>
19 #include <linux/seq_file.h>
20 #include <linux/slab.h>
21 
22 #include <linux/pinctrl/consumer.h>
23 #include <linux/pinctrl/pinconf-generic.h>
24 #include <linux/pinctrl/pinconf.h>
25 #include <linux/pinctrl/pinctrl.h>
26 #include <linux/pinctrl/pinmux.h>
27 
28 #include "core.h"
29 #include "pinconf.h"
30 #include "pinmux.h"
31 
32 #define GPIO_PIN					0x00
33 #define GPIO_MSK					0x20
34 
35 #define JZ4730_GPIO_DATA			0x00
36 #define JZ4730_GPIO_GPDIR			0x04
37 #define JZ4730_GPIO_GPPUR			0x0c
38 #define JZ4730_GPIO_GPALR			0x10
39 #define JZ4730_GPIO_GPAUR			0x14
40 #define JZ4730_GPIO_GPIDLR			0x18
41 #define JZ4730_GPIO_GPIDUR			0x1c
42 #define JZ4730_GPIO_GPIER			0x20
43 #define JZ4730_GPIO_GPIMR			0x24
44 #define JZ4730_GPIO_GPFR			0x28
45 
46 #define JZ4740_GPIO_DATA			0x10
47 #define JZ4740_GPIO_PULL_DIS		0x30
48 #define JZ4740_GPIO_FUNC			0x40
49 #define JZ4740_GPIO_SELECT			0x50
50 #define JZ4740_GPIO_DIR				0x60
51 #define JZ4740_GPIO_TRIG			0x70
52 #define JZ4740_GPIO_FLAG			0x80
53 
54 #define JZ4770_GPIO_INT				0x10
55 #define JZ4770_GPIO_PAT1			0x30
56 #define JZ4770_GPIO_PAT0			0x40
57 #define JZ4770_GPIO_FLAG			0x50
58 #define JZ4770_GPIO_PEN				0x70
59 
60 #define X1600_GPIO_PU				0x80
61 
62 #define X1830_GPIO_PEL				0x110
63 #define X1830_GPIO_PEH				0x120
64 #define X1830_GPIO_SR				0x150
65 #define X1830_GPIO_SMT				0x160
66 
67 #define X2000_GPIO_EDG				0x70
68 #define X2000_GPIO_PEPU				0x80
69 #define X2000_GPIO_PEPD				0x90
70 #define X2000_GPIO_SR				0xd0
71 #define X2000_GPIO_SMT				0xe0
72 
73 #define REG_SET(x)					((x) + 0x4)
74 #define REG_CLEAR(x)				((x) + 0x8)
75 
76 #define REG_PZ_BASE(x)				((x) * 7)
77 #define REG_PZ_GID2LD(x)			((x) * 7 + 0xf0)
78 
79 #define GPIO_PULL_DIS				0
80 #define GPIO_PULL_UP				1
81 #define GPIO_PULL_DOWN				2
82 
83 #define PINS_PER_GPIO_CHIP			32
84 #define JZ4730_PINS_PER_PAIRED_REG	16
85 
86 #define INGENIC_PIN_GROUP_FUNCS(_name_, id, funcs)					\
87 	{										\
88 		.grp = PINCTRL_PINGROUP(_name_, id##_pins, ARRAY_SIZE(id##_pins)),	\
89 		.data = funcs,								\
90 	}
91 
92 #define INGENIC_PIN_GROUP(_name_, id, func)						\
93 	{										\
94 		.grp = PINCTRL_PINGROUP(_name_, id##_pins, ARRAY_SIZE(id##_pins)),	\
95 		.data = (void *)func,							\
96 	}
97 
98 #define INGENIC_PIN_FUNCTION(_name_, id)						\
99 	PINCTRL_PINFUNCTION(_name_, id##_groups, ARRAY_SIZE(id##_groups))
100 
101 enum jz_version {
102 	ID_JZ4730,
103 	ID_JZ4740,
104 	ID_JZ4725B,
105 	ID_JZ4750,
106 	ID_JZ4755,
107 	ID_JZ4760,
108 	ID_JZ4770,
109 	ID_JZ4775,
110 	ID_JZ4780,
111 	ID_X1000,
112 	ID_X1500,
113 	ID_X1600,
114 	ID_X1830,
115 	ID_X2000,
116 	ID_X2100,
117 };
118 
119 struct ingenic_chip_info {
120 	unsigned int num_chips;
121 	unsigned int reg_offset;
122 	enum jz_version version;
123 
124 	const struct group_desc *groups;
125 	unsigned int num_groups;
126 
127 	const struct pinfunction *functions;
128 	unsigned int num_functions;
129 
130 	const u32 *pull_ups, *pull_downs;
131 
132 	const struct regmap_access_table *access_table;
133 };
134 
135 struct ingenic_pinctrl {
136 	struct device *dev;
137 	struct regmap *map;
138 	struct pinctrl_dev *pctl;
139 	struct pinctrl_pin_desc *pdesc;
140 
141 	const struct ingenic_chip_info *info;
142 
143 	struct gpio_chip *gc;
144 };
145 
146 struct ingenic_gpio_chip {
147 	struct ingenic_pinctrl *jzpc;
148 	struct gpio_chip gc;
149 	unsigned int irq, reg_base;
150 };
151 
152 static const unsigned long enabled_socs =
153 	IS_ENABLED(CONFIG_MACH_JZ4730) << ID_JZ4730 |
154 	IS_ENABLED(CONFIG_MACH_JZ4740) << ID_JZ4740 |
155 	IS_ENABLED(CONFIG_MACH_JZ4725B) << ID_JZ4725B |
156 	IS_ENABLED(CONFIG_MACH_JZ4750) << ID_JZ4750 |
157 	IS_ENABLED(CONFIG_MACH_JZ4755) << ID_JZ4755 |
158 	IS_ENABLED(CONFIG_MACH_JZ4760) << ID_JZ4760 |
159 	IS_ENABLED(CONFIG_MACH_JZ4770) << ID_JZ4770 |
160 	IS_ENABLED(CONFIG_MACH_JZ4775) << ID_JZ4775 |
161 	IS_ENABLED(CONFIG_MACH_JZ4780) << ID_JZ4780 |
162 	IS_ENABLED(CONFIG_MACH_X1000) << ID_X1000 |
163 	IS_ENABLED(CONFIG_MACH_X1500) << ID_X1500 |
164 	IS_ENABLED(CONFIG_MACH_X1600) << ID_X1600 |
165 	IS_ENABLED(CONFIG_MACH_X1830) << ID_X1830 |
166 	IS_ENABLED(CONFIG_MACH_X2000) << ID_X2000 |
167 	IS_ENABLED(CONFIG_MACH_X2100) << ID_X2100;
168 
169 static bool
is_soc_or_above(const struct ingenic_pinctrl * jzpc,enum jz_version version)170 is_soc_or_above(const struct ingenic_pinctrl *jzpc, enum jz_version version)
171 {
172 	return (enabled_socs >> version) &&
173 		(!(enabled_socs & GENMASK(version - 1, 0))
174 		 || jzpc->info->version >= version);
175 }
176 
177 static const u32 jz4730_pull_ups[4] = {
178 	0x3fa3320f, 0xf200ffff, 0xffffffff, 0xffffffff,
179 };
180 
181 static const u32 jz4730_pull_downs[4] = {
182 	0x00000df0, 0x0dff0000, 0x00000000, 0x00000000,
183 };
184 
185 static int jz4730_mmc_1bit_pins[] = { 0x27, 0x26, 0x22, };
186 static int jz4730_mmc_4bit_pins[] = { 0x23, 0x24, 0x25, };
187 static int jz4730_uart0_data_pins[] = { 0x7e, 0x7f, };
188 static int jz4730_uart1_data_pins[] = { 0x18, 0x19, };
189 static int jz4730_uart2_data_pins[] = { 0x6f, 0x7d, };
190 static int jz4730_uart3_data_pins[] = { 0x10, 0x15, };
191 static int jz4730_uart3_hwflow_pins[] = { 0x11, 0x17, };
192 static int jz4730_lcd_8bit_pins[] = {
193 	0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
194 	0x3a, 0x39, 0x38,
195 };
196 static int jz4730_lcd_16bit_pins[] = {
197 	0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
198 };
199 static int jz4730_lcd_special_pins[] = { 0x3d, 0x3c, 0x3e, 0x3f, };
200 static int jz4730_lcd_generic_pins[] = { 0x3b, };
201 static int jz4730_nand_cs1_pins[] = { 0x53, };
202 static int jz4730_nand_cs2_pins[] = { 0x54, };
203 static int jz4730_nand_cs3_pins[] = { 0x55, };
204 static int jz4730_nand_cs4_pins[] = { 0x56, };
205 static int jz4730_nand_cs5_pins[] = { 0x57, };
206 static int jz4730_pwm_pwm0_pins[] = { 0x5e, };
207 static int jz4730_pwm_pwm1_pins[] = { 0x5f, };
208 
209 static int jz4730_mii_pins[] = { 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
210 				 0x77, 0x78, 0x19, 0x7a, 0x1b, 0x7c, };
211 
212 static int jz4730_i2s_mclk_pins[] = { 0x44, };
213 static int jz4730_i2s_acreset_pins[] = { 0x45, };
214 static int jz4730_i2s_data_pins[] = { 0x46, 0x47, };
215 static int jz4730_i2s_clock_pins[] = { 0x4d, 0x4e, };
216 
217 static u8 jz4730_lcd_8bit_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, };
218 
219 static const struct group_desc jz4730_groups[] = {
220 	INGENIC_PIN_GROUP("mmc-1bit", jz4730_mmc_1bit, 1),
221 	INGENIC_PIN_GROUP("mmc-4bit", jz4730_mmc_4bit, 1),
222 	INGENIC_PIN_GROUP("uart0-data", jz4730_uart0_data, 1),
223 	INGENIC_PIN_GROUP("uart1-data", jz4730_uart1_data, 1),
224 	INGENIC_PIN_GROUP("uart2-data", jz4730_uart2_data, 1),
225 	INGENIC_PIN_GROUP("uart3-data", jz4730_uart3_data, 1),
226 	INGENIC_PIN_GROUP("uart3-hwflow", jz4730_uart3_hwflow, 1),
227 	INGENIC_PIN_GROUP_FUNCS("lcd-8bit", jz4730_lcd_8bit, jz4730_lcd_8bit_funcs),
228 	INGENIC_PIN_GROUP("lcd-16bit", jz4730_lcd_16bit, 1),
229 	INGENIC_PIN_GROUP("lcd-special", jz4730_lcd_special, 1),
230 	INGENIC_PIN_GROUP("lcd-generic", jz4730_lcd_generic, 1),
231 	INGENIC_PIN_GROUP("nand-cs1", jz4730_nand_cs1, 1),
232 	INGENIC_PIN_GROUP("nand-cs2", jz4730_nand_cs2, 1),
233 	INGENIC_PIN_GROUP("nand-cs3", jz4730_nand_cs3, 1),
234 	INGENIC_PIN_GROUP("nand-cs4", jz4730_nand_cs4, 1),
235 	INGENIC_PIN_GROUP("nand-cs5", jz4730_nand_cs5, 1),
236 	INGENIC_PIN_GROUP("pwm0", jz4730_pwm_pwm0, 1),
237 	INGENIC_PIN_GROUP("pwm1", jz4730_pwm_pwm1, 1),
238 	INGENIC_PIN_GROUP("mii", jz4730_mii, 1),
239 	INGENIC_PIN_GROUP("i2s-mclk-out", jz4730_i2s_mclk, 1),
240 	INGENIC_PIN_GROUP("i2s-acreset", jz4730_i2s_acreset, 1),
241 	INGENIC_PIN_GROUP("i2s-data", jz4730_i2s_data, 1),
242 	INGENIC_PIN_GROUP("i2s-master", jz4730_i2s_clock, 1),
243 	INGENIC_PIN_GROUP("i2s-slave", jz4730_i2s_clock, 2),
244 };
245 
246 static const char *jz4730_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
247 static const char *jz4730_uart0_groups[] = { "uart0-data", };
248 static const char *jz4730_uart1_groups[] = { "uart1-data", };
249 static const char *jz4730_uart2_groups[] = { "uart2-data", };
250 static const char *jz4730_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
251 static const char *jz4730_lcd_groups[] = {
252 	"lcd-8bit", "lcd-16bit", "lcd-special", "lcd-generic",
253 };
254 static const char *jz4730_nand_groups[] = {
255 	"nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4", "nand-cs5",
256 };
257 static const char *jz4730_pwm0_groups[] = { "pwm0", };
258 static const char *jz4730_pwm1_groups[] = { "pwm1", };
259 static const char *jz4730_mii_groups[] = { "mii", };
260 static const char *jz4730_i2s_groups[] = { "i2s-data", "i2s-master", "i2s-slave", };
261 
262 static const struct pinfunction jz4730_functions[] = {
263 	INGENIC_PIN_FUNCTION("mmc", jz4730_mmc),
264 	INGENIC_PIN_FUNCTION("uart0", jz4730_uart0),
265 	INGENIC_PIN_FUNCTION("uart1", jz4730_uart1),
266 	INGENIC_PIN_FUNCTION("uart2", jz4730_uart2),
267 	INGENIC_PIN_FUNCTION("uart3", jz4730_uart3),
268 	INGENIC_PIN_FUNCTION("lcd", jz4730_lcd),
269 	INGENIC_PIN_FUNCTION("nand", jz4730_nand),
270 	INGENIC_PIN_FUNCTION("pwm0", jz4730_pwm0),
271 	INGENIC_PIN_FUNCTION("pwm1", jz4730_pwm1),
272 	INGENIC_PIN_FUNCTION("mii", jz4730_mii),
273 	INGENIC_PIN_FUNCTION("i2s", jz4730_i2s),
274 };
275 
276 static const struct ingenic_chip_info jz4730_chip_info = {
277 	.num_chips = 4,
278 	.reg_offset = 0x30,
279 	.version = ID_JZ4730,
280 	.groups = jz4730_groups,
281 	.num_groups = ARRAY_SIZE(jz4730_groups),
282 	.functions = jz4730_functions,
283 	.num_functions = ARRAY_SIZE(jz4730_functions),
284 	.pull_ups = jz4730_pull_ups,
285 	.pull_downs = jz4730_pull_downs,
286 };
287 
288 static const u32 jz4740_pull_ups[4] = {
289 	0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
290 };
291 
292 static const u32 jz4740_pull_downs[4] = {
293 	0x00000000, 0x00000000, 0x00000000, 0x00000000,
294 };
295 
296 static int jz4740_mmc_1bit_pins[] = { 0x69, 0x68, 0x6a, };
297 static int jz4740_mmc_4bit_pins[] = { 0x6b, 0x6c, 0x6d, };
298 static int jz4740_uart0_data_pins[] = { 0x7a, 0x79, };
299 static int jz4740_uart0_hwflow_pins[] = { 0x7e, 0x7f, };
300 static int jz4740_uart1_data_pins[] = { 0x7e, 0x7f, };
301 static int jz4740_lcd_8bit_pins[] = {
302 	0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
303 	0x52, 0x53, 0x54,
304 };
305 static int jz4740_lcd_16bit_pins[] = {
306 	0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
307 };
308 static int jz4740_lcd_18bit_pins[] = { 0x50, 0x51, };
309 static int jz4740_lcd_special_pins[] = { 0x31, 0x32, 0x56, 0x57, };
310 static int jz4740_lcd_generic_pins[] = { 0x55, };
311 static int jz4740_nand_cs1_pins[] = { 0x39, };
312 static int jz4740_nand_cs2_pins[] = { 0x3a, };
313 static int jz4740_nand_cs3_pins[] = { 0x3b, };
314 static int jz4740_nand_cs4_pins[] = { 0x3c, };
315 static int jz4740_nand_fre_fwe_pins[] = { 0x5c, 0x5d, };
316 static int jz4740_pwm_pwm0_pins[] = { 0x77, };
317 static int jz4740_pwm_pwm1_pins[] = { 0x78, };
318 static int jz4740_pwm_pwm2_pins[] = { 0x79, };
319 static int jz4740_pwm_pwm3_pins[] = { 0x7a, };
320 static int jz4740_pwm_pwm4_pins[] = { 0x7b, };
321 static int jz4740_pwm_pwm5_pins[] = { 0x7c, };
322 static int jz4740_pwm_pwm6_pins[] = { 0x7e, };
323 static int jz4740_pwm_pwm7_pins[] = { 0x7f, };
324 
325 static const struct group_desc jz4740_groups[] = {
326 	INGENIC_PIN_GROUP("mmc-1bit", jz4740_mmc_1bit, 0),
327 	INGENIC_PIN_GROUP("mmc-4bit", jz4740_mmc_4bit, 0),
328 	INGENIC_PIN_GROUP("uart0-data", jz4740_uart0_data, 1),
329 	INGENIC_PIN_GROUP("uart0-hwflow", jz4740_uart0_hwflow, 1),
330 	INGENIC_PIN_GROUP("uart1-data", jz4740_uart1_data, 2),
331 	INGENIC_PIN_GROUP("lcd-8bit", jz4740_lcd_8bit, 0),
332 	INGENIC_PIN_GROUP("lcd-16bit", jz4740_lcd_16bit, 0),
333 	INGENIC_PIN_GROUP("lcd-18bit", jz4740_lcd_18bit, 0),
334 	INGENIC_PIN_GROUP("lcd-special", jz4740_lcd_special, 0),
335 	INGENIC_PIN_GROUP("lcd-generic", jz4740_lcd_generic, 0),
336 	INGENIC_PIN_GROUP("nand-cs1", jz4740_nand_cs1, 0),
337 	INGENIC_PIN_GROUP("nand-cs2", jz4740_nand_cs2, 0),
338 	INGENIC_PIN_GROUP("nand-cs3", jz4740_nand_cs3, 0),
339 	INGENIC_PIN_GROUP("nand-cs4", jz4740_nand_cs4, 0),
340 	INGENIC_PIN_GROUP("nand-fre-fwe", jz4740_nand_fre_fwe, 0),
341 	INGENIC_PIN_GROUP("pwm0", jz4740_pwm_pwm0, 0),
342 	INGENIC_PIN_GROUP("pwm1", jz4740_pwm_pwm1, 0),
343 	INGENIC_PIN_GROUP("pwm2", jz4740_pwm_pwm2, 0),
344 	INGENIC_PIN_GROUP("pwm3", jz4740_pwm_pwm3, 0),
345 	INGENIC_PIN_GROUP("pwm4", jz4740_pwm_pwm4, 0),
346 	INGENIC_PIN_GROUP("pwm5", jz4740_pwm_pwm5, 0),
347 	INGENIC_PIN_GROUP("pwm6", jz4740_pwm_pwm6, 0),
348 	INGENIC_PIN_GROUP("pwm7", jz4740_pwm_pwm7, 0),
349 };
350 
351 static const char *jz4740_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
352 static const char *jz4740_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
353 static const char *jz4740_uart1_groups[] = { "uart1-data", };
354 static const char *jz4740_lcd_groups[] = {
355 	"lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-special", "lcd-generic",
356 };
357 static const char *jz4740_nand_groups[] = {
358 	"nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4", "nand-fre-fwe",
359 };
360 static const char *jz4740_pwm0_groups[] = { "pwm0", };
361 static const char *jz4740_pwm1_groups[] = { "pwm1", };
362 static const char *jz4740_pwm2_groups[] = { "pwm2", };
363 static const char *jz4740_pwm3_groups[] = { "pwm3", };
364 static const char *jz4740_pwm4_groups[] = { "pwm4", };
365 static const char *jz4740_pwm5_groups[] = { "pwm5", };
366 static const char *jz4740_pwm6_groups[] = { "pwm6", };
367 static const char *jz4740_pwm7_groups[] = { "pwm7", };
368 
369 static const struct pinfunction jz4740_functions[] = {
370 	INGENIC_PIN_FUNCTION("mmc", jz4740_mmc),
371 	INGENIC_PIN_FUNCTION("uart0", jz4740_uart0),
372 	INGENIC_PIN_FUNCTION("uart1", jz4740_uart1),
373 	INGENIC_PIN_FUNCTION("lcd", jz4740_lcd),
374 	INGENIC_PIN_FUNCTION("nand", jz4740_nand),
375 	INGENIC_PIN_FUNCTION("pwm0", jz4740_pwm0),
376 	INGENIC_PIN_FUNCTION("pwm1", jz4740_pwm1),
377 	INGENIC_PIN_FUNCTION("pwm2", jz4740_pwm2),
378 	INGENIC_PIN_FUNCTION("pwm3", jz4740_pwm3),
379 	INGENIC_PIN_FUNCTION("pwm4", jz4740_pwm4),
380 	INGENIC_PIN_FUNCTION("pwm5", jz4740_pwm5),
381 	INGENIC_PIN_FUNCTION("pwm6", jz4740_pwm6),
382 	INGENIC_PIN_FUNCTION("pwm7", jz4740_pwm7),
383 };
384 
385 static const struct ingenic_chip_info jz4740_chip_info = {
386 	.num_chips = 4,
387 	.reg_offset = 0x100,
388 	.version = ID_JZ4740,
389 	.groups = jz4740_groups,
390 	.num_groups = ARRAY_SIZE(jz4740_groups),
391 	.functions = jz4740_functions,
392 	.num_functions = ARRAY_SIZE(jz4740_functions),
393 	.pull_ups = jz4740_pull_ups,
394 	.pull_downs = jz4740_pull_downs,
395 };
396 
397 static int jz4725b_mmc0_1bit_pins[] = { 0x48, 0x49, 0x5c, };
398 static int jz4725b_mmc0_4bit_pins[] = { 0x5d, 0x5b, 0x56, };
399 static int jz4725b_mmc1_1bit_pins[] = { 0x7a, 0x7b, 0x7c, };
400 static int jz4725b_mmc1_4bit_pins[] = { 0x7d, 0x7e, 0x7f, };
401 static int jz4725b_uart_data_pins[] = { 0x4c, 0x4d, };
402 static int jz4725b_lcd_8bit_pins[] = {
403 	0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
404 	0x72, 0x73, 0x74,
405 };
406 static int jz4725b_lcd_16bit_pins[] = {
407 	0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
408 };
409 static int jz4725b_lcd_18bit_pins[] = { 0x70, 0x71, };
410 static int jz4725b_lcd_24bit_pins[] = { 0x76, 0x77, 0x78, 0x79, };
411 static int jz4725b_lcd_special_pins[] = { 0x76, 0x77, 0x78, 0x79, };
412 static int jz4725b_lcd_generic_pins[] = { 0x75, };
413 static int jz4725b_nand_cs1_pins[] = { 0x55, };
414 static int jz4725b_nand_cs2_pins[] = { 0x56, };
415 static int jz4725b_nand_cs3_pins[] = { 0x57, };
416 static int jz4725b_nand_cs4_pins[] = { 0x58, };
417 static int jz4725b_nand_cle_ale_pins[] = { 0x48, 0x49 };
418 static int jz4725b_nand_fre_fwe_pins[] = { 0x5c, 0x5d };
419 static int jz4725b_pwm_pwm0_pins[] = { 0x4a, };
420 static int jz4725b_pwm_pwm1_pins[] = { 0x4b, };
421 static int jz4725b_pwm_pwm2_pins[] = { 0x4c, };
422 static int jz4725b_pwm_pwm3_pins[] = { 0x4d, };
423 static int jz4725b_pwm_pwm4_pins[] = { 0x4e, };
424 static int jz4725b_pwm_pwm5_pins[] = { 0x4f, };
425 
426 static u8 jz4725b_mmc0_4bit_funcs[] = { 1, 0, 1, };
427 
428 static const struct group_desc jz4725b_groups[] = {
429 	INGENIC_PIN_GROUP("mmc0-1bit", jz4725b_mmc0_1bit, 1),
430 	INGENIC_PIN_GROUP_FUNCS("mmc0-4bit", jz4725b_mmc0_4bit,
431 				jz4725b_mmc0_4bit_funcs),
432 	INGENIC_PIN_GROUP("mmc1-1bit", jz4725b_mmc1_1bit, 0),
433 	INGENIC_PIN_GROUP("mmc1-4bit", jz4725b_mmc1_4bit, 0),
434 	INGENIC_PIN_GROUP("uart-data", jz4725b_uart_data, 1),
435 	INGENIC_PIN_GROUP("lcd-8bit", jz4725b_lcd_8bit, 0),
436 	INGENIC_PIN_GROUP("lcd-16bit", jz4725b_lcd_16bit, 0),
437 	INGENIC_PIN_GROUP("lcd-18bit", jz4725b_lcd_18bit, 0),
438 	INGENIC_PIN_GROUP("lcd-24bit", jz4725b_lcd_24bit, 1),
439 	INGENIC_PIN_GROUP("lcd-special", jz4725b_lcd_special, 0),
440 	INGENIC_PIN_GROUP("lcd-generic", jz4725b_lcd_generic, 0),
441 	INGENIC_PIN_GROUP("nand-cs1", jz4725b_nand_cs1, 0),
442 	INGENIC_PIN_GROUP("nand-cs2", jz4725b_nand_cs2, 0),
443 	INGENIC_PIN_GROUP("nand-cs3", jz4725b_nand_cs3, 0),
444 	INGENIC_PIN_GROUP("nand-cs4", jz4725b_nand_cs4, 0),
445 	INGENIC_PIN_GROUP("nand-cle-ale", jz4725b_nand_cle_ale, 0),
446 	INGENIC_PIN_GROUP("nand-fre-fwe", jz4725b_nand_fre_fwe, 0),
447 	INGENIC_PIN_GROUP("pwm0", jz4725b_pwm_pwm0, 0),
448 	INGENIC_PIN_GROUP("pwm1", jz4725b_pwm_pwm1, 0),
449 	INGENIC_PIN_GROUP("pwm2", jz4725b_pwm_pwm2, 0),
450 	INGENIC_PIN_GROUP("pwm3", jz4725b_pwm_pwm3, 0),
451 	INGENIC_PIN_GROUP("pwm4", jz4725b_pwm_pwm4, 0),
452 	INGENIC_PIN_GROUP("pwm5", jz4725b_pwm_pwm5, 0),
453 };
454 
455 static const char *jz4725b_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", };
456 static const char *jz4725b_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
457 static const char *jz4725b_uart_groups[] = { "uart-data", };
458 static const char *jz4725b_lcd_groups[] = {
459 	"lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
460 	"lcd-special", "lcd-generic",
461 };
462 static const char *jz4725b_nand_groups[] = {
463 	"nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4",
464 	"nand-cle-ale", "nand-fre-fwe",
465 };
466 static const char *jz4725b_pwm0_groups[] = { "pwm0", };
467 static const char *jz4725b_pwm1_groups[] = { "pwm1", };
468 static const char *jz4725b_pwm2_groups[] = { "pwm2", };
469 static const char *jz4725b_pwm3_groups[] = { "pwm3", };
470 static const char *jz4725b_pwm4_groups[] = { "pwm4", };
471 static const char *jz4725b_pwm5_groups[] = { "pwm5", };
472 
473 static const struct pinfunction jz4725b_functions[] = {
474 	INGENIC_PIN_FUNCTION("mmc0", jz4725b_mmc0),
475 	INGENIC_PIN_FUNCTION("mmc1", jz4725b_mmc1),
476 	INGENIC_PIN_FUNCTION("uart", jz4725b_uart),
477 	INGENIC_PIN_FUNCTION("nand", jz4725b_nand),
478 	INGENIC_PIN_FUNCTION("pwm0", jz4725b_pwm0),
479 	INGENIC_PIN_FUNCTION("pwm1", jz4725b_pwm1),
480 	INGENIC_PIN_FUNCTION("pwm2", jz4725b_pwm2),
481 	INGENIC_PIN_FUNCTION("pwm3", jz4725b_pwm3),
482 	INGENIC_PIN_FUNCTION("pwm4", jz4725b_pwm4),
483 	INGENIC_PIN_FUNCTION("pwm5", jz4725b_pwm5),
484 	INGENIC_PIN_FUNCTION("lcd", jz4725b_lcd),
485 };
486 
487 static const struct ingenic_chip_info jz4725b_chip_info = {
488 	.num_chips = 4,
489 	.reg_offset = 0x100,
490 	.version = ID_JZ4725B,
491 	.groups = jz4725b_groups,
492 	.num_groups = ARRAY_SIZE(jz4725b_groups),
493 	.functions = jz4725b_functions,
494 	.num_functions = ARRAY_SIZE(jz4725b_functions),
495 	.pull_ups = jz4740_pull_ups,
496 	.pull_downs = jz4740_pull_downs,
497 };
498 
499 static const u32 jz4750_pull_ups[6] = {
500 	0xffffffff, 0xffffffff, 0x3fffffff, 0x7fffffff, 0x1fff3fff, 0x00ffffff,
501 };
502 
503 static const u32 jz4750_pull_downs[6] = {
504 	0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
505 };
506 
507 static int jz4750_uart0_data_pins[] = { 0xa4, 0xa5, };
508 static int jz4750_uart0_hwflow_pins[] = { 0xa6, 0xa7, };
509 static int jz4750_uart1_data_pins[] = { 0x90, 0x91, };
510 static int jz4750_uart1_hwflow_pins[] = { 0x92, 0x93, };
511 static int jz4750_uart2_data_pins[] = { 0x9b, 0x9a, };
512 static int jz4750_uart3_data_pins[] = { 0xb0, 0xb1, };
513 static int jz4750_uart3_hwflow_pins[] = { 0xb2, 0xb3, };
514 static int jz4750_mmc0_1bit_pins[] = { 0xa8, 0xa9, 0xa0, };
515 static int jz4750_mmc0_4bit_pins[] = { 0xa1, 0xa2, 0xa3, };
516 static int jz4750_mmc0_8bit_pins[] = { 0xa4, 0xa5, 0xa6, 0xa7, };
517 static int jz4750_mmc1_1bit_pins[] = { 0xae, 0xaf, 0xaa, };
518 static int jz4750_mmc1_4bit_pins[] = { 0xab, 0xac, 0xad, };
519 static int jz4750_i2c_pins[] = { 0x8c, 0x8d, };
520 static int jz4750_cim_pins[] = {
521 	0x89, 0x8b, 0x8a, 0x88,
522 	0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
523 };
524 static int jz4750_lcd_8bit_pins[] = {
525 	0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
526 	0x72, 0x73, 0x74,
527 };
528 static int jz4750_lcd_16bit_pins[] = {
529 	0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
530 };
531 static int jz4750_lcd_18bit_pins[] = { 0x70, 0x71, };
532 static int jz4750_lcd_24bit_pins[] = { 0x76, 0x77, 0x78, 0x79, 0xb2, 0xb3, };
533 static int jz4750_lcd_special_pins[] = { 0x76, 0x77, 0x78, 0x79, };
534 static int jz4750_lcd_generic_pins[] = { 0x75, };
535 static int jz4750_nand_cs1_pins[] = { 0x55, };
536 static int jz4750_nand_cs2_pins[] = { 0x56, };
537 static int jz4750_nand_cs3_pins[] = { 0x57, };
538 static int jz4750_nand_cs4_pins[] = { 0x58, };
539 static int jz4750_nand_fre_fwe_pins[] = { 0x5c, 0x5d, };
540 static int jz4750_pwm_pwm0_pins[] = { 0x94, };
541 static int jz4750_pwm_pwm1_pins[] = { 0x95, };
542 static int jz4750_pwm_pwm2_pins[] = { 0x96, };
543 static int jz4750_pwm_pwm3_pins[] = { 0x97, };
544 static int jz4750_pwm_pwm4_pins[] = { 0x98, };
545 static int jz4750_pwm_pwm5_pins[] = { 0x99, };
546 
547 static const struct group_desc jz4750_groups[] = {
548 	INGENIC_PIN_GROUP("uart0-data", jz4750_uart0_data, 1),
549 	INGENIC_PIN_GROUP("uart0-hwflow", jz4750_uart0_hwflow, 1),
550 	INGENIC_PIN_GROUP("uart1-data", jz4750_uart1_data, 0),
551 	INGENIC_PIN_GROUP("uart1-hwflow", jz4750_uart1_hwflow, 0),
552 	INGENIC_PIN_GROUP("uart2-data", jz4750_uart2_data, 1),
553 	INGENIC_PIN_GROUP("uart3-data", jz4750_uart3_data, 0),
554 	INGENIC_PIN_GROUP("uart3-hwflow", jz4750_uart3_hwflow, 0),
555 	INGENIC_PIN_GROUP("mmc0-1bit", jz4750_mmc0_1bit, 0),
556 	INGENIC_PIN_GROUP("mmc0-4bit", jz4750_mmc0_4bit, 0),
557 	INGENIC_PIN_GROUP("mmc0-8bit", jz4750_mmc0_8bit, 0),
558 	INGENIC_PIN_GROUP("mmc1-1bit", jz4750_mmc1_1bit, 0),
559 	INGENIC_PIN_GROUP("mmc1-4bit", jz4750_mmc1_4bit, 0),
560 	INGENIC_PIN_GROUP("i2c-data", jz4750_i2c, 0),
561 	INGENIC_PIN_GROUP("cim-data", jz4750_cim, 0),
562 	INGENIC_PIN_GROUP("lcd-8bit", jz4750_lcd_8bit, 0),
563 	INGENIC_PIN_GROUP("lcd-16bit", jz4750_lcd_16bit, 0),
564 	INGENIC_PIN_GROUP("lcd-18bit", jz4750_lcd_18bit, 0),
565 	INGENIC_PIN_GROUP("lcd-24bit", jz4750_lcd_24bit, 1),
566 	INGENIC_PIN_GROUP("lcd-special", jz4750_lcd_special, 0),
567 	INGENIC_PIN_GROUP("lcd-generic", jz4750_lcd_generic, 0),
568 	INGENIC_PIN_GROUP("nand-cs1", jz4750_nand_cs1, 0),
569 	INGENIC_PIN_GROUP("nand-cs2", jz4750_nand_cs2, 0),
570 	INGENIC_PIN_GROUP("nand-cs3", jz4750_nand_cs3, 0),
571 	INGENIC_PIN_GROUP("nand-cs4", jz4750_nand_cs4, 0),
572 	INGENIC_PIN_GROUP("nand-fre-fwe", jz4750_nand_fre_fwe, 0),
573 	INGENIC_PIN_GROUP("pwm0", jz4750_pwm_pwm0, 0),
574 	INGENIC_PIN_GROUP("pwm1", jz4750_pwm_pwm1, 0),
575 	INGENIC_PIN_GROUP("pwm2", jz4750_pwm_pwm2, 0),
576 	INGENIC_PIN_GROUP("pwm3", jz4750_pwm_pwm3, 0),
577 	INGENIC_PIN_GROUP("pwm4", jz4750_pwm_pwm4, 0),
578 	INGENIC_PIN_GROUP("pwm5", jz4750_pwm_pwm5, 0),
579 };
580 
581 static const char *jz4750_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
582 static const char *jz4750_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
583 static const char *jz4750_uart2_groups[] = { "uart2-data", };
584 static const char *jz4750_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
585 static const char *jz4750_mmc0_groups[] = {
586 	"mmc0-1bit", "mmc0-4bit", "mmc0-8bit",
587 };
588 static const char *jz4750_mmc1_groups[] = { "mmc0-1bit", "mmc0-4bit", };
589 static const char *jz4750_i2c_groups[] = { "i2c-data", };
590 static const char *jz4750_cim_groups[] = { "cim-data", };
591 static const char *jz4750_lcd_groups[] = {
592 	"lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
593 	"lcd-special", "lcd-generic",
594 };
595 static const char *jz4750_nand_groups[] = {
596 	"nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4", "nand-fre-fwe",
597 };
598 static const char *jz4750_pwm0_groups[] = { "pwm0", };
599 static const char *jz4750_pwm1_groups[] = { "pwm1", };
600 static const char *jz4750_pwm2_groups[] = { "pwm2", };
601 static const char *jz4750_pwm3_groups[] = { "pwm3", };
602 static const char *jz4750_pwm4_groups[] = { "pwm4", };
603 static const char *jz4750_pwm5_groups[] = { "pwm5", };
604 
605 static const struct pinfunction jz4750_functions[] = {
606 	INGENIC_PIN_FUNCTION("uart0", jz4750_uart0),
607 	INGENIC_PIN_FUNCTION("uart1", jz4750_uart1),
608 	INGENIC_PIN_FUNCTION("uart2", jz4750_uart2),
609 	INGENIC_PIN_FUNCTION("uart3", jz4750_uart3),
610 	INGENIC_PIN_FUNCTION("mmc0", jz4750_mmc0),
611 	INGENIC_PIN_FUNCTION("mmc1", jz4750_mmc1),
612 	INGENIC_PIN_FUNCTION("i2c", jz4750_i2c),
613 	INGENIC_PIN_FUNCTION("cim", jz4750_cim),
614 	INGENIC_PIN_FUNCTION("lcd", jz4750_lcd),
615 	INGENIC_PIN_FUNCTION("nand", jz4750_nand),
616 	INGENIC_PIN_FUNCTION("pwm0", jz4750_pwm0),
617 	INGENIC_PIN_FUNCTION("pwm1", jz4750_pwm1),
618 	INGENIC_PIN_FUNCTION("pwm2", jz4750_pwm2),
619 	INGENIC_PIN_FUNCTION("pwm3", jz4750_pwm3),
620 	INGENIC_PIN_FUNCTION("pwm4", jz4750_pwm4),
621 	INGENIC_PIN_FUNCTION("pwm5", jz4750_pwm5),
622 };
623 
624 static const struct ingenic_chip_info jz4750_chip_info = {
625 	.num_chips = 6,
626 	.reg_offset = 0x100,
627 	.version = ID_JZ4750,
628 	.groups = jz4750_groups,
629 	.num_groups = ARRAY_SIZE(jz4750_groups),
630 	.functions = jz4750_functions,
631 	.num_functions = ARRAY_SIZE(jz4750_functions),
632 	.pull_ups = jz4750_pull_ups,
633 	.pull_downs = jz4750_pull_downs,
634 };
635 
636 static const u32 jz4755_pull_ups[6] = {
637 	0xffffffff, 0xffffffff, 0x0fffffff, 0xffffffff, 0x33dc3fff, 0x0000fc00,
638 };
639 
640 static const u32 jz4755_pull_downs[6] = {
641 	0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
642 };
643 
644 static int jz4755_uart0_data_pins[] = { 0x7c, 0x7d, };
645 static int jz4755_uart0_hwflow_pins[] = { 0x7e, 0x7f, };
646 static int jz4755_uart1_data_pins[] = { 0x97, 0x99, };
647 static int jz4755_uart2_data_pins[] = { 0x9f, };
648 static int jz4755_ssi_dt_b_pins[] = { 0x3b, };
649 static int jz4755_ssi_dt_f_pins[] = { 0xa1, };
650 static int jz4755_ssi_dr_b_pins[] = { 0x3c, };
651 static int jz4755_ssi_dr_f_pins[] = { 0xa2, };
652 static int jz4755_ssi_clk_b_pins[] = { 0x3a, };
653 static int jz4755_ssi_clk_f_pins[] = { 0xa0, };
654 static int jz4755_ssi_gpc_b_pins[] = { 0x3e, };
655 static int jz4755_ssi_gpc_f_pins[] = { 0xa4, };
656 static int jz4755_ssi_ce0_b_pins[] = { 0x3d, };
657 static int jz4755_ssi_ce0_f_pins[] = { 0xa3, };
658 static int jz4755_ssi_ce1_b_pins[] = { 0x3f, };
659 static int jz4755_ssi_ce1_f_pins[] = { 0xa5, };
660 static int jz4755_mmc0_1bit_pins[] = { 0x2f, 0x50, 0x5c, };
661 static int jz4755_mmc0_4bit_pins[] = { 0x5d, 0x5b, 0x51, };
662 static int jz4755_mmc1_1bit_pins[] = { 0x3a, 0x3d, 0x3c, };
663 static int jz4755_mmc1_4bit_pins[] = { 0x3b, 0x3e, 0x3f, };
664 static int jz4755_i2c_pins[] = { 0x8c, 0x8d, };
665 static int jz4755_cim_pins[] = {
666 	0x89, 0x8b, 0x8a, 0x88,
667 	0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
668 };
669 static int jz4755_lcd_8bit_pins[] = {
670 	0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
671 	0x72, 0x73, 0x74,
672 };
673 static int jz4755_lcd_16bit_pins[] = {
674 	0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
675 };
676 static int jz4755_lcd_18bit_pins[] = { 0x70, 0x71, };
677 static int jz4755_lcd_24bit_pins[] = { 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, };
678 static int jz4755_lcd_special_pins[] = { 0x76, 0x77, 0x78, 0x79, };
679 static int jz4755_lcd_generic_pins[] = { 0x75, };
680 static int jz4755_nand_cs1_pins[] = { 0x55, };
681 static int jz4755_nand_cs2_pins[] = { 0x56, };
682 static int jz4755_nand_cs3_pins[] = { 0x57, };
683 static int jz4755_nand_cs4_pins[] = { 0x58, };
684 static int jz4755_nand_fre_fwe_pins[] = { 0x5c, 0x5d, };
685 static int jz4755_pwm_pwm0_pins[] = { 0x94, };
686 static int jz4755_pwm_pwm1_pins[] = { 0xab, };
687 static int jz4755_pwm_pwm2_pins[] = { 0x96, };
688 static int jz4755_pwm_pwm3_pins[] = { 0x97, };
689 static int jz4755_pwm_pwm4_pins[] = { 0x98, };
690 static int jz4755_pwm_pwm5_pins[] = { 0x99, };
691 
692 static u8 jz4755_mmc0_1bit_funcs[] = { 2, 2, 1, };
693 static u8 jz4755_mmc0_4bit_funcs[] = { 1, 0, 1, };
694 static u8 jz4755_lcd_24bit_funcs[] = { 1, 1, 1, 1, 0, 0, };
695 
696 static const struct group_desc jz4755_groups[] = {
697 	INGENIC_PIN_GROUP("uart0-data", jz4755_uart0_data, 0),
698 	INGENIC_PIN_GROUP("uart0-hwflow", jz4755_uart0_hwflow, 0),
699 	INGENIC_PIN_GROUP("uart1-data", jz4755_uart1_data, 1),
700 	INGENIC_PIN_GROUP("uart2-data", jz4755_uart2_data, 1),
701 	INGENIC_PIN_GROUP("ssi-dt-b", jz4755_ssi_dt_b, 0),
702 	INGENIC_PIN_GROUP("ssi-dt-f", jz4755_ssi_dt_f, 0),
703 	INGENIC_PIN_GROUP("ssi-dr-b", jz4755_ssi_dr_b, 0),
704 	INGENIC_PIN_GROUP("ssi-dr-f", jz4755_ssi_dr_f, 0),
705 	INGENIC_PIN_GROUP("ssi-clk-b", jz4755_ssi_clk_b, 0),
706 	INGENIC_PIN_GROUP("ssi-clk-f", jz4755_ssi_clk_f, 0),
707 	INGENIC_PIN_GROUP("ssi-gpc-b", jz4755_ssi_gpc_b, 0),
708 	INGENIC_PIN_GROUP("ssi-gpc-f", jz4755_ssi_gpc_f, 0),
709 	INGENIC_PIN_GROUP("ssi-ce0-b", jz4755_ssi_ce0_b, 0),
710 	INGENIC_PIN_GROUP("ssi-ce0-f", jz4755_ssi_ce0_f, 0),
711 	INGENIC_PIN_GROUP("ssi-ce1-b", jz4755_ssi_ce1_b, 0),
712 	INGENIC_PIN_GROUP("ssi-ce1-f", jz4755_ssi_ce1_f, 0),
713 	INGENIC_PIN_GROUP_FUNCS("mmc0-1bit", jz4755_mmc0_1bit,
714 				jz4755_mmc0_1bit_funcs),
715 	INGENIC_PIN_GROUP_FUNCS("mmc0-4bit", jz4755_mmc0_4bit,
716 				jz4755_mmc0_4bit_funcs),
717 	INGENIC_PIN_GROUP("mmc1-1bit", jz4755_mmc1_1bit, 1),
718 	INGENIC_PIN_GROUP("mmc1-4bit", jz4755_mmc1_4bit, 1),
719 	INGENIC_PIN_GROUP("i2c-data", jz4755_i2c, 0),
720 	INGENIC_PIN_GROUP("cim-data", jz4755_cim, 0),
721 	INGENIC_PIN_GROUP("lcd-8bit", jz4755_lcd_8bit, 0),
722 	INGENIC_PIN_GROUP("lcd-16bit", jz4755_lcd_16bit, 0),
723 	INGENIC_PIN_GROUP("lcd-18bit", jz4755_lcd_18bit, 0),
724 	INGENIC_PIN_GROUP_FUNCS("lcd-24bit", jz4755_lcd_24bit,
725 				jz4755_lcd_24bit_funcs),
726 	INGENIC_PIN_GROUP("lcd-special", jz4755_lcd_special, 0),
727 	INGENIC_PIN_GROUP("lcd-generic", jz4755_lcd_generic, 0),
728 	INGENIC_PIN_GROUP("nand-cs1", jz4755_nand_cs1, 0),
729 	INGENIC_PIN_GROUP("nand-cs2", jz4755_nand_cs2, 0),
730 	INGENIC_PIN_GROUP("nand-cs3", jz4755_nand_cs3, 0),
731 	INGENIC_PIN_GROUP("nand-cs4", jz4755_nand_cs4, 0),
732 	INGENIC_PIN_GROUP("nand-fre-fwe", jz4755_nand_fre_fwe, 0),
733 	INGENIC_PIN_GROUP("pwm0", jz4755_pwm_pwm0, 0),
734 	INGENIC_PIN_GROUP("pwm1", jz4755_pwm_pwm1, 1),
735 	INGENIC_PIN_GROUP("pwm2", jz4755_pwm_pwm2, 0),
736 	INGENIC_PIN_GROUP("pwm3", jz4755_pwm_pwm3, 0),
737 	INGENIC_PIN_GROUP("pwm4", jz4755_pwm_pwm4, 0),
738 	INGENIC_PIN_GROUP("pwm5", jz4755_pwm_pwm5, 0),
739 };
740 
741 static const char *jz4755_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
742 static const char *jz4755_uart1_groups[] = { "uart1-data", };
743 static const char *jz4755_uart2_groups[] = { "uart2-data", };
744 static const char *jz4755_ssi_groups[] = {
745 	"ssi-dt-b", "ssi-dt-f",
746 	"ssi-dr-b", "ssi-dr-f",
747 	"ssi-clk-b", "ssi-clk-f",
748 	"ssi-gpc-b", "ssi-gpc-f",
749 	"ssi-ce0-b", "ssi-ce0-f",
750 	"ssi-ce1-b", "ssi-ce1-f",
751 };
752 static const char *jz4755_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", };
753 static const char *jz4755_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
754 static const char *jz4755_i2c_groups[] = { "i2c-data", };
755 static const char *jz4755_cim_groups[] = { "cim-data", };
756 static const char *jz4755_lcd_groups[] = {
757 	"lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
758 	"lcd-special", "lcd-generic",
759 };
760 static const char *jz4755_nand_groups[] = {
761 	"nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4", "nand-fre-fwe",
762 };
763 static const char *jz4755_pwm0_groups[] = { "pwm0", };
764 static const char *jz4755_pwm1_groups[] = { "pwm1", };
765 static const char *jz4755_pwm2_groups[] = { "pwm2", };
766 static const char *jz4755_pwm3_groups[] = { "pwm3", };
767 static const char *jz4755_pwm4_groups[] = { "pwm4", };
768 static const char *jz4755_pwm5_groups[] = { "pwm5", };
769 
770 static const struct pinfunction jz4755_functions[] = {
771 	INGENIC_PIN_FUNCTION("uart0", jz4755_uart0),
772 	INGENIC_PIN_FUNCTION("uart1", jz4755_uart1),
773 	INGENIC_PIN_FUNCTION("uart2", jz4755_uart2),
774 	INGENIC_PIN_FUNCTION("ssi", jz4755_ssi),
775 	INGENIC_PIN_FUNCTION("mmc0", jz4755_mmc0),
776 	INGENIC_PIN_FUNCTION("mmc1", jz4755_mmc1),
777 	INGENIC_PIN_FUNCTION("i2c", jz4755_i2c),
778 	INGENIC_PIN_FUNCTION("cim", jz4755_cim),
779 	INGENIC_PIN_FUNCTION("lcd", jz4755_lcd),
780 	INGENIC_PIN_FUNCTION("nand", jz4755_nand),
781 	INGENIC_PIN_FUNCTION("pwm0", jz4755_pwm0),
782 	INGENIC_PIN_FUNCTION("pwm1", jz4755_pwm1),
783 	INGENIC_PIN_FUNCTION("pwm2", jz4755_pwm2),
784 	INGENIC_PIN_FUNCTION("pwm3", jz4755_pwm3),
785 	INGENIC_PIN_FUNCTION("pwm4", jz4755_pwm4),
786 	INGENIC_PIN_FUNCTION("pwm5", jz4755_pwm5),
787 };
788 
789 static const struct ingenic_chip_info jz4755_chip_info = {
790 	.num_chips = 6,
791 	.reg_offset = 0x100,
792 	.version = ID_JZ4755,
793 	.groups = jz4755_groups,
794 	.num_groups = ARRAY_SIZE(jz4755_groups),
795 	.functions = jz4755_functions,
796 	.num_functions = ARRAY_SIZE(jz4755_functions),
797 	.pull_ups = jz4755_pull_ups,
798 	.pull_downs = jz4755_pull_downs,
799 };
800 
801 static const u32 jz4760_pull_ups[6] = {
802 	0xffffffff, 0xfffcf3ff, 0xffffffff, 0xffffcfff, 0xfffffb7c, 0x0000000f,
803 };
804 
805 static const u32 jz4760_pull_downs[6] = {
806 	0x00000000, 0x00030c00, 0x00000000, 0x00003000, 0x00000483, 0x00000ff0,
807 };
808 
809 static int jz4760_uart0_data_pins[] = { 0xa0, 0xa3, };
810 static int jz4760_uart0_hwflow_pins[] = { 0xa1, 0xa2, };
811 static int jz4760_uart1_data_pins[] = { 0x7a, 0x7c, };
812 static int jz4760_uart1_hwflow_pins[] = { 0x7b, 0x7d, };
813 static int jz4760_uart2_data_pins[] = { 0x5c, 0x5e, };
814 static int jz4760_uart2_hwflow_pins[] = { 0x5d, 0x5f, };
815 static int jz4760_uart3_data_pins[] = { 0x6c, 0x85, };
816 static int jz4760_uart3_hwflow_pins[] = { 0x88, 0x89, };
817 static int jz4760_ssi0_dt_a_pins[] = { 0x15, };
818 static int jz4760_ssi0_dt_b_pins[] = { 0x35, };
819 static int jz4760_ssi0_dt_d_pins[] = { 0x75, };
820 static int jz4760_ssi0_dt_e_pins[] = { 0x91, };
821 static int jz4760_ssi0_dr_a_pins[] = { 0x14, };
822 static int jz4760_ssi0_dr_b_pins[] = { 0x34, };
823 static int jz4760_ssi0_dr_d_pins[] = { 0x74, };
824 static int jz4760_ssi0_dr_e_pins[] = { 0x8e, };
825 static int jz4760_ssi0_clk_a_pins[] = { 0x12, };
826 static int jz4760_ssi0_clk_b_pins[] = { 0x3c, };
827 static int jz4760_ssi0_clk_d_pins[] = { 0x78, };
828 static int jz4760_ssi0_clk_e_pins[] = { 0x8f, };
829 static int jz4760_ssi0_gpc_b_pins[] = { 0x3e, };
830 static int jz4760_ssi0_gpc_d_pins[] = { 0x76, };
831 static int jz4760_ssi0_gpc_e_pins[] = { 0x93, };
832 static int jz4760_ssi0_ce0_a_pins[] = { 0x13, };
833 static int jz4760_ssi0_ce0_b_pins[] = { 0x3d, };
834 static int jz4760_ssi0_ce0_d_pins[] = { 0x79, };
835 static int jz4760_ssi0_ce0_e_pins[] = { 0x90, };
836 static int jz4760_ssi0_ce1_b_pins[] = { 0x3f, };
837 static int jz4760_ssi0_ce1_d_pins[] = { 0x77, };
838 static int jz4760_ssi0_ce1_e_pins[] = { 0x92, };
839 static int jz4760_ssi1_dt_b_9_pins[] = { 0x29, };
840 static int jz4760_ssi1_dt_b_21_pins[] = { 0x35, };
841 static int jz4760_ssi1_dt_d_12_pins[] = { 0x6c, };
842 static int jz4760_ssi1_dt_d_21_pins[] = { 0x75, };
843 static int jz4760_ssi1_dt_e_pins[] = { 0x91, };
844 static int jz4760_ssi1_dt_f_pins[] = { 0xa3, };
845 static int jz4760_ssi1_dr_b_6_pins[] = { 0x26, };
846 static int jz4760_ssi1_dr_b_20_pins[] = { 0x34, };
847 static int jz4760_ssi1_dr_d_13_pins[] = { 0x6d, };
848 static int jz4760_ssi1_dr_d_20_pins[] = { 0x74, };
849 static int jz4760_ssi1_dr_e_pins[] = { 0x8e, };
850 static int jz4760_ssi1_dr_f_pins[] = { 0xa0, };
851 static int jz4760_ssi1_clk_b_7_pins[] = { 0x27, };
852 static int jz4760_ssi1_clk_b_28_pins[] = { 0x3c, };
853 static int jz4760_ssi1_clk_d_pins[] = { 0x78, };
854 static int jz4760_ssi1_clk_e_7_pins[] = { 0x87, };
855 static int jz4760_ssi1_clk_e_15_pins[] = { 0x8f, };
856 static int jz4760_ssi1_clk_f_pins[] = { 0xa2, };
857 static int jz4760_ssi1_gpc_b_pins[] = { 0x3e, };
858 static int jz4760_ssi1_gpc_d_pins[] = { 0x76, };
859 static int jz4760_ssi1_gpc_e_pins[] = { 0x93, };
860 static int jz4760_ssi1_ce0_b_8_pins[] = { 0x28, };
861 static int jz4760_ssi1_ce0_b_29_pins[] = { 0x3d, };
862 static int jz4760_ssi1_ce0_d_pins[] = { 0x79, };
863 static int jz4760_ssi1_ce0_e_6_pins[] = { 0x86, };
864 static int jz4760_ssi1_ce0_e_16_pins[] = { 0x90, };
865 static int jz4760_ssi1_ce0_f_pins[] = { 0xa1, };
866 static int jz4760_ssi1_ce1_b_pins[] = { 0x3f, };
867 static int jz4760_ssi1_ce1_d_pins[] = { 0x77, };
868 static int jz4760_ssi1_ce1_e_pins[] = { 0x92, };
869 static int jz4760_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, };
870 static int jz4760_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, };
871 static int jz4760_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
872 static int jz4760_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
873 static int jz4760_mmc0_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
874 static int jz4760_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, };
875 static int jz4760_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, };
876 static int jz4760_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
877 static int jz4760_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
878 static int jz4760_mmc1_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
879 static int jz4760_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, };
880 static int jz4760_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, };
881 static int jz4760_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
882 static int jz4760_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
883 static int jz4760_mmc2_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
884 static int jz4760_nemc_8bit_data_pins[] = {
885 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
886 };
887 static int jz4760_nemc_16bit_data_pins[] = {
888 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
889 };
890 static int jz4760_nemc_cle_ale_pins[] = { 0x20, 0x21, };
891 static int jz4760_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, };
892 static int jz4760_nemc_rd_we_pins[] = { 0x10, 0x11, };
893 static int jz4760_nemc_frd_fwe_pins[] = { 0x12, 0x13, };
894 static int jz4760_nemc_wait_pins[] = { 0x1b, };
895 static int jz4760_nemc_cs1_pins[] = { 0x15, };
896 static int jz4760_nemc_cs2_pins[] = { 0x16, };
897 static int jz4760_nemc_cs3_pins[] = { 0x17, };
898 static int jz4760_nemc_cs4_pins[] = { 0x18, };
899 static int jz4760_nemc_cs5_pins[] = { 0x19, };
900 static int jz4760_nemc_cs6_pins[] = { 0x1a, };
901 static int jz4760_i2c0_pins[] = { 0x7e, 0x7f, };
902 static int jz4760_i2c1_pins[] = { 0x9e, 0x9f, };
903 static int jz4760_cim_pins[] = {
904 	0x26, 0x27, 0x28, 0x29,
905 	0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
906 };
907 static int jz4760_lcd_8bit_pins[] = {
908 	0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x4c,
909 	0x4d, 0x52, 0x53,
910 };
911 static int jz4760_lcd_16bit_pins[] = {
912 	0x4e, 0x4f, 0x50, 0x51, 0x56, 0x57, 0x58, 0x59,
913 };
914 static int jz4760_lcd_18bit_pins[] = {
915 	0x5a, 0x5b,
916 };
917 static int jz4760_lcd_24bit_pins[] = {
918 	0x40, 0x41, 0x4a, 0x4b, 0x54, 0x55,
919 };
920 static int jz4760_lcd_special_pins[] = { 0x54, 0x4a, 0x41, 0x40, };
921 static int jz4760_lcd_generic_pins[] = { 0x49, };
922 static int jz4760_pwm_pwm0_pins[] = { 0x80, };
923 static int jz4760_pwm_pwm1_pins[] = { 0x81, };
924 static int jz4760_pwm_pwm2_pins[] = { 0x82, };
925 static int jz4760_pwm_pwm3_pins[] = { 0x83, };
926 static int jz4760_pwm_pwm4_pins[] = { 0x84, };
927 static int jz4760_pwm_pwm5_pins[] = { 0x85, };
928 static int jz4760_pwm_pwm6_pins[] = { 0x6a, };
929 static int jz4760_pwm_pwm7_pins[] = { 0x6b, };
930 static int jz4760_otg_pins[] = { 0x8a, };
931 
932 static u8 jz4760_uart3_data_funcs[] = { 0, 1, };
933 static u8 jz4760_mmc0_1bit_a_funcs[] = { 1, 1, 0, };
934 
935 static const struct group_desc jz4760_groups[] = {
936 	INGENIC_PIN_GROUP("uart0-data", jz4760_uart0_data, 0),
937 	INGENIC_PIN_GROUP("uart0-hwflow", jz4760_uart0_hwflow, 0),
938 	INGENIC_PIN_GROUP("uart1-data", jz4760_uart1_data, 0),
939 	INGENIC_PIN_GROUP("uart1-hwflow", jz4760_uart1_hwflow, 0),
940 	INGENIC_PIN_GROUP("uart2-data", jz4760_uart2_data, 0),
941 	INGENIC_PIN_GROUP("uart2-hwflow", jz4760_uart2_hwflow, 0),
942 	INGENIC_PIN_GROUP_FUNCS("uart3-data", jz4760_uart3_data,
943 				jz4760_uart3_data_funcs),
944 	INGENIC_PIN_GROUP("uart3-hwflow", jz4760_uart3_hwflow, 0),
945 	INGENIC_PIN_GROUP("ssi0-dt-a", jz4760_ssi0_dt_a, 2),
946 	INGENIC_PIN_GROUP("ssi0-dt-b", jz4760_ssi0_dt_b, 1),
947 	INGENIC_PIN_GROUP("ssi0-dt-d", jz4760_ssi0_dt_d, 1),
948 	INGENIC_PIN_GROUP("ssi0-dt-e", jz4760_ssi0_dt_e, 0),
949 	INGENIC_PIN_GROUP("ssi0-dr-a", jz4760_ssi0_dr_a, 1),
950 	INGENIC_PIN_GROUP("ssi0-dr-b", jz4760_ssi0_dr_b, 1),
951 	INGENIC_PIN_GROUP("ssi0-dr-d", jz4760_ssi0_dr_d, 1),
952 	INGENIC_PIN_GROUP("ssi0-dr-e", jz4760_ssi0_dr_e, 0),
953 	INGENIC_PIN_GROUP("ssi0-clk-a", jz4760_ssi0_clk_a, 2),
954 	INGENIC_PIN_GROUP("ssi0-clk-b", jz4760_ssi0_clk_b, 1),
955 	INGENIC_PIN_GROUP("ssi0-clk-d", jz4760_ssi0_clk_d, 1),
956 	INGENIC_PIN_GROUP("ssi0-clk-e", jz4760_ssi0_clk_e, 0),
957 	INGENIC_PIN_GROUP("ssi0-gpc-b", jz4760_ssi0_gpc_b, 1),
958 	INGENIC_PIN_GROUP("ssi0-gpc-d", jz4760_ssi0_gpc_d, 1),
959 	INGENIC_PIN_GROUP("ssi0-gpc-e", jz4760_ssi0_gpc_e, 0),
960 	INGENIC_PIN_GROUP("ssi0-ce0-a", jz4760_ssi0_ce0_a, 2),
961 	INGENIC_PIN_GROUP("ssi0-ce0-b", jz4760_ssi0_ce0_b, 1),
962 	INGENIC_PIN_GROUP("ssi0-ce0-d", jz4760_ssi0_ce0_d, 1),
963 	INGENIC_PIN_GROUP("ssi0-ce0-e", jz4760_ssi0_ce0_e, 0),
964 	INGENIC_PIN_GROUP("ssi0-ce1-b", jz4760_ssi0_ce1_b, 1),
965 	INGENIC_PIN_GROUP("ssi0-ce1-d", jz4760_ssi0_ce1_d, 1),
966 	INGENIC_PIN_GROUP("ssi0-ce1-e", jz4760_ssi0_ce1_e, 0),
967 	INGENIC_PIN_GROUP("ssi1-dt-b-9", jz4760_ssi1_dt_b_9, 2),
968 	INGENIC_PIN_GROUP("ssi1-dt-b-21", jz4760_ssi1_dt_b_21, 2),
969 	INGENIC_PIN_GROUP("ssi1-dt-d-12", jz4760_ssi1_dt_d_12, 2),
970 	INGENIC_PIN_GROUP("ssi1-dt-d-21", jz4760_ssi1_dt_d_21, 2),
971 	INGENIC_PIN_GROUP("ssi1-dt-e", jz4760_ssi1_dt_e, 1),
972 	INGENIC_PIN_GROUP("ssi1-dt-f", jz4760_ssi1_dt_f, 2),
973 	INGENIC_PIN_GROUP("ssi1-dr-b-6", jz4760_ssi1_dr_b_6, 2),
974 	INGENIC_PIN_GROUP("ssi1-dr-b-20", jz4760_ssi1_dr_b_20, 2),
975 	INGENIC_PIN_GROUP("ssi1-dr-d-13", jz4760_ssi1_dr_d_13, 2),
976 	INGENIC_PIN_GROUP("ssi1-dr-d-20", jz4760_ssi1_dr_d_20, 2),
977 	INGENIC_PIN_GROUP("ssi1-dr-e", jz4760_ssi1_dr_e, 1),
978 	INGENIC_PIN_GROUP("ssi1-dr-f", jz4760_ssi1_dr_f, 2),
979 	INGENIC_PIN_GROUP("ssi1-clk-b-7", jz4760_ssi1_clk_b_7, 2),
980 	INGENIC_PIN_GROUP("ssi1-clk-b-28", jz4760_ssi1_clk_b_28, 2),
981 	INGENIC_PIN_GROUP("ssi1-clk-d", jz4760_ssi1_clk_d, 2),
982 	INGENIC_PIN_GROUP("ssi1-clk-e-7", jz4760_ssi1_clk_e_7, 2),
983 	INGENIC_PIN_GROUP("ssi1-clk-e-15", jz4760_ssi1_clk_e_15, 1),
984 	INGENIC_PIN_GROUP("ssi1-clk-f", jz4760_ssi1_clk_f, 2),
985 	INGENIC_PIN_GROUP("ssi1-gpc-b", jz4760_ssi1_gpc_b, 2),
986 	INGENIC_PIN_GROUP("ssi1-gpc-d", jz4760_ssi1_gpc_d, 2),
987 	INGENIC_PIN_GROUP("ssi1-gpc-e", jz4760_ssi1_gpc_e, 1),
988 	INGENIC_PIN_GROUP("ssi1-ce0-b-8", jz4760_ssi1_ce0_b_8, 2),
989 	INGENIC_PIN_GROUP("ssi1-ce0-b-29", jz4760_ssi1_ce0_b_29, 2),
990 	INGENIC_PIN_GROUP("ssi1-ce0-d", jz4760_ssi1_ce0_d, 2),
991 	INGENIC_PIN_GROUP("ssi1-ce0-e-6", jz4760_ssi1_ce0_e_6, 2),
992 	INGENIC_PIN_GROUP("ssi1-ce0-e-16", jz4760_ssi1_ce0_e_16, 1),
993 	INGENIC_PIN_GROUP("ssi1-ce0-f", jz4760_ssi1_ce0_f, 2),
994 	INGENIC_PIN_GROUP("ssi1-ce1-b", jz4760_ssi1_ce1_b, 2),
995 	INGENIC_PIN_GROUP("ssi1-ce1-d", jz4760_ssi1_ce1_d, 2),
996 	INGENIC_PIN_GROUP("ssi1-ce1-e", jz4760_ssi1_ce1_e, 1),
997 	INGENIC_PIN_GROUP_FUNCS("mmc0-1bit-a", jz4760_mmc0_1bit_a,
998 				jz4760_mmc0_1bit_a_funcs),
999 	INGENIC_PIN_GROUP("mmc0-4bit-a", jz4760_mmc0_4bit_a, 1),
1000 	INGENIC_PIN_GROUP("mmc0-1bit-e", jz4760_mmc0_1bit_e, 0),
1001 	INGENIC_PIN_GROUP("mmc0-4bit-e", jz4760_mmc0_4bit_e, 0),
1002 	INGENIC_PIN_GROUP("mmc0-8bit-e", jz4760_mmc0_8bit_e, 0),
1003 	INGENIC_PIN_GROUP("mmc1-1bit-d", jz4760_mmc1_1bit_d, 0),
1004 	INGENIC_PIN_GROUP("mmc1-4bit-d", jz4760_mmc1_4bit_d, 0),
1005 	INGENIC_PIN_GROUP("mmc1-1bit-e", jz4760_mmc1_1bit_e, 1),
1006 	INGENIC_PIN_GROUP("mmc1-4bit-e", jz4760_mmc1_4bit_e, 1),
1007 	INGENIC_PIN_GROUP("mmc1-8bit-e", jz4760_mmc1_8bit_e, 1),
1008 	INGENIC_PIN_GROUP("mmc2-1bit-b", jz4760_mmc2_1bit_b, 0),
1009 	INGENIC_PIN_GROUP("mmc2-4bit-b", jz4760_mmc2_4bit_b, 0),
1010 	INGENIC_PIN_GROUP("mmc2-1bit-e", jz4760_mmc2_1bit_e, 2),
1011 	INGENIC_PIN_GROUP("mmc2-4bit-e", jz4760_mmc2_4bit_e, 2),
1012 	INGENIC_PIN_GROUP("mmc2-8bit-e", jz4760_mmc2_8bit_e, 2),
1013 	INGENIC_PIN_GROUP("nemc-8bit-data", jz4760_nemc_8bit_data, 0),
1014 	INGENIC_PIN_GROUP("nemc-16bit-data", jz4760_nemc_16bit_data, 0),
1015 	INGENIC_PIN_GROUP("nemc-cle-ale", jz4760_nemc_cle_ale, 0),
1016 	INGENIC_PIN_GROUP("nemc-addr", jz4760_nemc_addr, 0),
1017 	INGENIC_PIN_GROUP("nemc-rd-we", jz4760_nemc_rd_we, 0),
1018 	INGENIC_PIN_GROUP("nemc-frd-fwe", jz4760_nemc_frd_fwe, 0),
1019 	INGENIC_PIN_GROUP("nemc-wait", jz4760_nemc_wait, 0),
1020 	INGENIC_PIN_GROUP("nemc-cs1", jz4760_nemc_cs1, 0),
1021 	INGENIC_PIN_GROUP("nemc-cs2", jz4760_nemc_cs2, 0),
1022 	INGENIC_PIN_GROUP("nemc-cs3", jz4760_nemc_cs3, 0),
1023 	INGENIC_PIN_GROUP("nemc-cs4", jz4760_nemc_cs4, 0),
1024 	INGENIC_PIN_GROUP("nemc-cs5", jz4760_nemc_cs5, 0),
1025 	INGENIC_PIN_GROUP("nemc-cs6", jz4760_nemc_cs6, 0),
1026 	INGENIC_PIN_GROUP("i2c0-data", jz4760_i2c0, 0),
1027 	INGENIC_PIN_GROUP("i2c1-data", jz4760_i2c1, 0),
1028 	INGENIC_PIN_GROUP("cim-data", jz4760_cim, 0),
1029 	INGENIC_PIN_GROUP("lcd-8bit", jz4760_lcd_8bit, 0),
1030 	INGENIC_PIN_GROUP("lcd-16bit", jz4760_lcd_16bit, 0),
1031 	INGENIC_PIN_GROUP("lcd-18bit", jz4760_lcd_18bit, 0),
1032 	INGENIC_PIN_GROUP("lcd-24bit", jz4760_lcd_24bit, 0),
1033 	INGENIC_PIN_GROUP("lcd-special", jz4760_lcd_special, 1),
1034 	INGENIC_PIN_GROUP("lcd-generic", jz4760_lcd_generic, 0),
1035 	INGENIC_PIN_GROUP("pwm0", jz4760_pwm_pwm0, 0),
1036 	INGENIC_PIN_GROUP("pwm1", jz4760_pwm_pwm1, 0),
1037 	INGENIC_PIN_GROUP("pwm2", jz4760_pwm_pwm2, 0),
1038 	INGENIC_PIN_GROUP("pwm3", jz4760_pwm_pwm3, 0),
1039 	INGENIC_PIN_GROUP("pwm4", jz4760_pwm_pwm4, 0),
1040 	INGENIC_PIN_GROUP("pwm5", jz4760_pwm_pwm5, 0),
1041 	INGENIC_PIN_GROUP("pwm6", jz4760_pwm_pwm6, 0),
1042 	INGENIC_PIN_GROUP("pwm7", jz4760_pwm_pwm7, 0),
1043 	INGENIC_PIN_GROUP("otg-vbus", jz4760_otg, 0),
1044 };
1045 
1046 static const char *jz4760_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1047 static const char *jz4760_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
1048 static const char *jz4760_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
1049 static const char *jz4760_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
1050 static const char *jz4760_ssi0_groups[] = {
1051 	"ssi0-dt-a", "ssi0-dt-b", "ssi0-dt-d", "ssi0-dt-e",
1052 	"ssi0-dr-a", "ssi0-dr-b", "ssi0-dr-d", "ssi0-dr-e",
1053 	"ssi0-clk-a", "ssi0-clk-b", "ssi0-clk-d", "ssi0-clk-e",
1054 	"ssi0-gpc-b", "ssi0-gpc-d", "ssi0-gpc-e",
1055 	"ssi0-ce0-a", "ssi0-ce0-b", "ssi0-ce0-d", "ssi0-ce0-e",
1056 	"ssi0-ce1-b", "ssi0-ce1-d", "ssi0-ce1-e",
1057 };
1058 static const char *jz4760_ssi1_groups[] = {
1059 	"ssi1-dt-b-9", "ssi1-dt-b-21", "ssi1-dt-d-12", "ssi1-dt-d-21", "ssi1-dt-e", "ssi1-dt-f",
1060 	"ssi1-dr-b-6", "ssi1-dr-b-20", "ssi1-dr-d-13", "ssi1-dr-d-20", "ssi1-dr-e", "ssi1-dr-f",
1061 	"ssi1-clk-b-7", "ssi1-clk-b-28", "ssi1-clk-d", "ssi1-clk-e-7", "ssi1-clk-e-15", "ssi1-clk-f",
1062 	"ssi1-gpc-b", "ssi1-gpc-d", "ssi1-gpc-e",
1063 	"ssi1-ce0-b-8", "ssi1-ce0-b-29", "ssi1-ce0-d", "ssi1-ce0-e-6", "ssi1-ce0-e-16", "ssi1-ce0-f",
1064 	"ssi1-ce1-b", "ssi1-ce1-d", "ssi1-ce1-e",
1065 };
1066 static const char *jz4760_mmc0_groups[] = {
1067 	"mmc0-1bit-a", "mmc0-4bit-a",
1068 	"mmc0-1bit-e", "mmc0-4bit-e", "mmc0-8bit-e",
1069 };
1070 static const char *jz4760_mmc1_groups[] = {
1071 	"mmc1-1bit-d", "mmc1-4bit-d",
1072 	"mmc1-1bit-e", "mmc1-4bit-e", "mmc1-8bit-e",
1073 };
1074 static const char *jz4760_mmc2_groups[] = {
1075 	"mmc2-1bit-b", "mmc2-4bit-b",
1076 	"mmc2-1bit-e", "mmc2-4bit-e", "mmc2-8bit-e",
1077 };
1078 static const char *jz4760_nemc_groups[] = {
1079 	"nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale",
1080 	"nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
1081 };
1082 static const char *jz4760_cs1_groups[] = { "nemc-cs1", };
1083 static const char *jz4760_cs2_groups[] = { "nemc-cs2", };
1084 static const char *jz4760_cs3_groups[] = { "nemc-cs3", };
1085 static const char *jz4760_cs4_groups[] = { "nemc-cs4", };
1086 static const char *jz4760_cs5_groups[] = { "nemc-cs5", };
1087 static const char *jz4760_cs6_groups[] = { "nemc-cs6", };
1088 static const char *jz4760_i2c0_groups[] = { "i2c0-data", };
1089 static const char *jz4760_i2c1_groups[] = { "i2c1-data", };
1090 static const char *jz4760_cim_groups[] = { "cim-data", };
1091 static const char *jz4760_lcd_groups[] = {
1092 	"lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
1093 	"lcd-special", "lcd-generic",
1094 };
1095 static const char *jz4760_pwm0_groups[] = { "pwm0", };
1096 static const char *jz4760_pwm1_groups[] = { "pwm1", };
1097 static const char *jz4760_pwm2_groups[] = { "pwm2", };
1098 static const char *jz4760_pwm3_groups[] = { "pwm3", };
1099 static const char *jz4760_pwm4_groups[] = { "pwm4", };
1100 static const char *jz4760_pwm5_groups[] = { "pwm5", };
1101 static const char *jz4760_pwm6_groups[] = { "pwm6", };
1102 static const char *jz4760_pwm7_groups[] = { "pwm7", };
1103 static const char *jz4760_otg_groups[] = { "otg-vbus", };
1104 
1105 static const struct pinfunction jz4760_functions[] = {
1106 	INGENIC_PIN_FUNCTION("uart0", jz4760_uart0),
1107 	INGENIC_PIN_FUNCTION("uart1", jz4760_uart1),
1108 	INGENIC_PIN_FUNCTION("uart2", jz4760_uart2),
1109 	INGENIC_PIN_FUNCTION("uart3", jz4760_uart3),
1110 	INGENIC_PIN_FUNCTION("ssi0", jz4760_ssi0),
1111 	INGENIC_PIN_FUNCTION("ssi1", jz4760_ssi1),
1112 	INGENIC_PIN_FUNCTION("mmc0", jz4760_mmc0),
1113 	INGENIC_PIN_FUNCTION("mmc1", jz4760_mmc1),
1114 	INGENIC_PIN_FUNCTION("mmc2", jz4760_mmc2),
1115 	INGENIC_PIN_FUNCTION("nemc", jz4760_nemc),
1116 	INGENIC_PIN_FUNCTION("nemc-cs1", jz4760_cs1),
1117 	INGENIC_PIN_FUNCTION("nemc-cs2", jz4760_cs2),
1118 	INGENIC_PIN_FUNCTION("nemc-cs3", jz4760_cs3),
1119 	INGENIC_PIN_FUNCTION("nemc-cs4", jz4760_cs4),
1120 	INGENIC_PIN_FUNCTION("nemc-cs5", jz4760_cs5),
1121 	INGENIC_PIN_FUNCTION("nemc-cs6", jz4760_cs6),
1122 	INGENIC_PIN_FUNCTION("i2c0", jz4760_i2c0),
1123 	INGENIC_PIN_FUNCTION("i2c1", jz4760_i2c1),
1124 	INGENIC_PIN_FUNCTION("cim", jz4760_cim),
1125 	INGENIC_PIN_FUNCTION("lcd", jz4760_lcd),
1126 	INGENIC_PIN_FUNCTION("pwm0", jz4760_pwm0),
1127 	INGENIC_PIN_FUNCTION("pwm1", jz4760_pwm1),
1128 	INGENIC_PIN_FUNCTION("pwm2", jz4760_pwm2),
1129 	INGENIC_PIN_FUNCTION("pwm3", jz4760_pwm3),
1130 	INGENIC_PIN_FUNCTION("pwm4", jz4760_pwm4),
1131 	INGENIC_PIN_FUNCTION("pwm5", jz4760_pwm5),
1132 	INGENIC_PIN_FUNCTION("pwm6", jz4760_pwm6),
1133 	INGENIC_PIN_FUNCTION("pwm7", jz4760_pwm7),
1134 	INGENIC_PIN_FUNCTION("otg", jz4760_otg),
1135 };
1136 
1137 static const struct ingenic_chip_info jz4760_chip_info = {
1138 	.num_chips = 6,
1139 	.reg_offset = 0x100,
1140 	.version = ID_JZ4760,
1141 	.groups = jz4760_groups,
1142 	.num_groups = ARRAY_SIZE(jz4760_groups),
1143 	.functions = jz4760_functions,
1144 	.num_functions = ARRAY_SIZE(jz4760_functions),
1145 	.pull_ups = jz4760_pull_ups,
1146 	.pull_downs = jz4760_pull_downs,
1147 };
1148 
1149 static const u32 jz4770_pull_ups[6] = {
1150 	0x3fffffff, 0xfff0f3fc, 0xffffffff, 0xffff4fff, 0xfffffb7c, 0x0024f00f,
1151 };
1152 
1153 static const u32 jz4770_pull_downs[6] = {
1154 	0x00000000, 0x000f0c03, 0x00000000, 0x0000b000, 0x00000483, 0x005b0ff0,
1155 };
1156 
1157 static int jz4770_uart0_data_pins[] = { 0xa0, 0xa3, };
1158 static int jz4770_uart0_hwflow_pins[] = { 0xa1, 0xa2, };
1159 static int jz4770_uart1_data_pins[] = { 0x7a, 0x7c, };
1160 static int jz4770_uart1_hwflow_pins[] = { 0x7b, 0x7d, };
1161 static int jz4770_uart2_data_pins[] = { 0x5c, 0x5e, };
1162 static int jz4770_uart2_hwflow_pins[] = { 0x5d, 0x5f, };
1163 static int jz4770_uart3_data_pins[] = { 0x6c, 0x85, };
1164 static int jz4770_uart3_hwflow_pins[] = { 0x88, 0x89, };
1165 static int jz4770_ssi0_dt_a_pins[] = { 0x15, };
1166 static int jz4770_ssi0_dt_b_pins[] = { 0x35, };
1167 static int jz4770_ssi0_dt_d_pins[] = { 0x75, };
1168 static int jz4770_ssi0_dt_e_pins[] = { 0x91, };
1169 static int jz4770_ssi0_dr_a_pins[] = { 0x14, };
1170 static int jz4770_ssi0_dr_b_pins[] = { 0x34, };
1171 static int jz4770_ssi0_dr_d_pins[] = { 0x74, };
1172 static int jz4770_ssi0_dr_e_pins[] = { 0x8e, };
1173 static int jz4770_ssi0_clk_a_pins[] = { 0x12, };
1174 static int jz4770_ssi0_clk_b_pins[] = { 0x3c, };
1175 static int jz4770_ssi0_clk_d_pins[] = { 0x78, };
1176 static int jz4770_ssi0_clk_e_pins[] = { 0x8f, };
1177 static int jz4770_ssi0_gpc_b_pins[] = { 0x3e, };
1178 static int jz4770_ssi0_gpc_d_pins[] = { 0x76, };
1179 static int jz4770_ssi0_gpc_e_pins[] = { 0x93, };
1180 static int jz4770_ssi0_ce0_a_pins[] = { 0x13, };
1181 static int jz4770_ssi0_ce0_b_pins[] = { 0x3d, };
1182 static int jz4770_ssi0_ce0_d_pins[] = { 0x79, };
1183 static int jz4770_ssi0_ce0_e_pins[] = { 0x90, };
1184 static int jz4770_ssi0_ce1_b_pins[] = { 0x3f, };
1185 static int jz4770_ssi0_ce1_d_pins[] = { 0x77, };
1186 static int jz4770_ssi0_ce1_e_pins[] = { 0x92, };
1187 static int jz4770_ssi1_dt_b_pins[] = { 0x35, };
1188 static int jz4770_ssi1_dt_d_pins[] = { 0x75, };
1189 static int jz4770_ssi1_dt_e_pins[] = { 0x91, };
1190 static int jz4770_ssi1_dr_b_pins[] = { 0x34, };
1191 static int jz4770_ssi1_dr_d_pins[] = { 0x74, };
1192 static int jz4770_ssi1_dr_e_pins[] = { 0x8e, };
1193 static int jz4770_ssi1_clk_b_pins[] = { 0x3c, };
1194 static int jz4770_ssi1_clk_d_pins[] = { 0x78, };
1195 static int jz4770_ssi1_clk_e_pins[] = { 0x8f, };
1196 static int jz4770_ssi1_gpc_b_pins[] = { 0x3e, };
1197 static int jz4770_ssi1_gpc_d_pins[] = { 0x76, };
1198 static int jz4770_ssi1_gpc_e_pins[] = { 0x93, };
1199 static int jz4770_ssi1_ce0_b_pins[] = { 0x3d, };
1200 static int jz4770_ssi1_ce0_d_pins[] = { 0x79, };
1201 static int jz4770_ssi1_ce0_e_pins[] = { 0x90, };
1202 static int jz4770_ssi1_ce1_b_pins[] = { 0x3f, };
1203 static int jz4770_ssi1_ce1_d_pins[] = { 0x77, };
1204 static int jz4770_ssi1_ce1_e_pins[] = { 0x92, };
1205 static int jz4770_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, };
1206 static int jz4770_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, };
1207 static int jz4770_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
1208 static int jz4770_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
1209 static int jz4770_mmc0_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
1210 static int jz4770_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, };
1211 static int jz4770_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, };
1212 static int jz4770_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
1213 static int jz4770_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
1214 static int jz4770_mmc1_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
1215 static int jz4770_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, };
1216 static int jz4770_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, };
1217 static int jz4770_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
1218 static int jz4770_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
1219 static int jz4770_mmc2_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
1220 static int jz4770_nemc_8bit_data_pins[] = {
1221 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1222 };
1223 static int jz4770_nemc_16bit_data_pins[] = {
1224 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1225 };
1226 static int jz4770_nemc_cle_ale_pins[] = { 0x20, 0x21, };
1227 static int jz4770_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, };
1228 static int jz4770_nemc_rd_we_pins[] = { 0x10, 0x11, };
1229 static int jz4770_nemc_frd_fwe_pins[] = { 0x12, 0x13, };
1230 static int jz4770_nemc_wait_pins[] = { 0x1b, };
1231 static int jz4770_nemc_cs1_pins[] = { 0x15, };
1232 static int jz4770_nemc_cs2_pins[] = { 0x16, };
1233 static int jz4770_nemc_cs3_pins[] = { 0x17, };
1234 static int jz4770_nemc_cs4_pins[] = { 0x18, };
1235 static int jz4770_nemc_cs5_pins[] = { 0x19, };
1236 static int jz4770_nemc_cs6_pins[] = { 0x1a, };
1237 static int jz4770_i2c0_pins[] = { 0x7e, 0x7f, };
1238 static int jz4770_i2c1_pins[] = { 0x9e, 0x9f, };
1239 static int jz4770_i2c2_pins[] = { 0xb0, 0xb1, };
1240 static int jz4770_cim_8bit_pins[] = {
1241 	0x26, 0x27, 0x28, 0x29,
1242 	0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
1243 };
1244 static int jz4770_cim_12bit_pins[] = {
1245 	0x32, 0x33, 0xb0, 0xb1,
1246 };
1247 static int jz4770_lcd_8bit_pins[] = {
1248 	0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x4c, 0x4d,
1249 	0x48, 0x52, 0x53,
1250 };
1251 static int jz4770_lcd_16bit_pins[] = {
1252 	0x4e, 0x4f, 0x50, 0x51, 0x56, 0x57, 0x58, 0x59,
1253 };
1254 static int jz4770_lcd_18bit_pins[] = {
1255 	0x5a, 0x5b,
1256 };
1257 static int jz4770_lcd_24bit_pins[] = {
1258 	0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
1259 	0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
1260 	0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
1261 	0x58, 0x59, 0x5a, 0x5b,
1262 };
1263 static int jz4770_lcd_special_pins[] = { 0x54, 0x4a, 0x41, 0x40, };
1264 static int jz4770_lcd_generic_pins[] = { 0x49, };
1265 static int jz4770_pwm_pwm0_pins[] = { 0x80, };
1266 static int jz4770_pwm_pwm1_pins[] = { 0x81, };
1267 static int jz4770_pwm_pwm2_pins[] = { 0x82, };
1268 static int jz4770_pwm_pwm3_pins[] = { 0x83, };
1269 static int jz4770_pwm_pwm4_pins[] = { 0x84, };
1270 static int jz4770_pwm_pwm5_pins[] = { 0x85, };
1271 static int jz4770_pwm_pwm6_pins[] = { 0x6a, };
1272 static int jz4770_pwm_pwm7_pins[] = { 0x6b, };
1273 static int jz4770_mac_rmii_pins[] = {
1274 	0xa9, 0xab, 0xaa, 0xac, 0xa5, 0xa4, 0xad, 0xae, 0xa6, 0xa8,
1275 };
1276 static int jz4770_mac_mii_pins[] = {
1277 	0x7b, 0x7a, 0x7d, 0x7c, 0xa7, 0x24, 0xaf,
1278 };
1279 
1280 static const struct group_desc jz4770_groups[] = {
1281 	INGENIC_PIN_GROUP("uart0-data", jz4770_uart0_data, 0),
1282 	INGENIC_PIN_GROUP("uart0-hwflow", jz4770_uart0_hwflow, 0),
1283 	INGENIC_PIN_GROUP("uart1-data", jz4770_uart1_data, 0),
1284 	INGENIC_PIN_GROUP("uart1-hwflow", jz4770_uart1_hwflow, 0),
1285 	INGENIC_PIN_GROUP("uart2-data", jz4770_uart2_data, 0),
1286 	INGENIC_PIN_GROUP("uart2-hwflow", jz4770_uart2_hwflow, 0),
1287 	INGENIC_PIN_GROUP_FUNCS("uart3-data", jz4770_uart3_data,
1288 				jz4760_uart3_data_funcs),
1289 	INGENIC_PIN_GROUP("uart3-hwflow", jz4770_uart3_hwflow, 0),
1290 	INGENIC_PIN_GROUP("ssi0-dt-a", jz4770_ssi0_dt_a, 2),
1291 	INGENIC_PIN_GROUP("ssi0-dt-b", jz4770_ssi0_dt_b, 1),
1292 	INGENIC_PIN_GROUP("ssi0-dt-d", jz4770_ssi0_dt_d, 1),
1293 	INGENIC_PIN_GROUP("ssi0-dt-e", jz4770_ssi0_dt_e, 0),
1294 	INGENIC_PIN_GROUP("ssi0-dr-a", jz4770_ssi0_dr_a, 1),
1295 	INGENIC_PIN_GROUP("ssi0-dr-b", jz4770_ssi0_dr_b, 1),
1296 	INGENIC_PIN_GROUP("ssi0-dr-d", jz4770_ssi0_dr_d, 1),
1297 	INGENIC_PIN_GROUP("ssi0-dr-e", jz4770_ssi0_dr_e, 0),
1298 	INGENIC_PIN_GROUP("ssi0-clk-a", jz4770_ssi0_clk_a, 2),
1299 	INGENIC_PIN_GROUP("ssi0-clk-b", jz4770_ssi0_clk_b, 1),
1300 	INGENIC_PIN_GROUP("ssi0-clk-d", jz4770_ssi0_clk_d, 1),
1301 	INGENIC_PIN_GROUP("ssi0-clk-e", jz4770_ssi0_clk_e, 0),
1302 	INGENIC_PIN_GROUP("ssi0-gpc-b", jz4770_ssi0_gpc_b, 1),
1303 	INGENIC_PIN_GROUP("ssi0-gpc-d", jz4770_ssi0_gpc_d, 1),
1304 	INGENIC_PIN_GROUP("ssi0-gpc-e", jz4770_ssi0_gpc_e, 0),
1305 	INGENIC_PIN_GROUP("ssi0-ce0-a", jz4770_ssi0_ce0_a, 2),
1306 	INGENIC_PIN_GROUP("ssi0-ce0-b", jz4770_ssi0_ce0_b, 1),
1307 	INGENIC_PIN_GROUP("ssi0-ce0-d", jz4770_ssi0_ce0_d, 1),
1308 	INGENIC_PIN_GROUP("ssi0-ce0-e", jz4770_ssi0_ce0_e, 0),
1309 	INGENIC_PIN_GROUP("ssi0-ce1-b", jz4770_ssi0_ce1_b, 1),
1310 	INGENIC_PIN_GROUP("ssi0-ce1-d", jz4770_ssi0_ce1_d, 1),
1311 	INGENIC_PIN_GROUP("ssi0-ce1-e", jz4770_ssi0_ce1_e, 0),
1312 	INGENIC_PIN_GROUP("ssi1-dt-b", jz4770_ssi1_dt_b, 2),
1313 	INGENIC_PIN_GROUP("ssi1-dt-d", jz4770_ssi1_dt_d, 2),
1314 	INGENIC_PIN_GROUP("ssi1-dt-e", jz4770_ssi1_dt_e, 1),
1315 	INGENIC_PIN_GROUP("ssi1-dr-b", jz4770_ssi1_dr_b, 2),
1316 	INGENIC_PIN_GROUP("ssi1-dr-d", jz4770_ssi1_dr_d, 2),
1317 	INGENIC_PIN_GROUP("ssi1-dr-e", jz4770_ssi1_dr_e, 1),
1318 	INGENIC_PIN_GROUP("ssi1-clk-b", jz4770_ssi1_clk_b, 2),
1319 	INGENIC_PIN_GROUP("ssi1-clk-d", jz4770_ssi1_clk_d, 2),
1320 	INGENIC_PIN_GROUP("ssi1-clk-e", jz4770_ssi1_clk_e, 1),
1321 	INGENIC_PIN_GROUP("ssi1-gpc-b", jz4770_ssi1_gpc_b, 2),
1322 	INGENIC_PIN_GROUP("ssi1-gpc-d", jz4770_ssi1_gpc_d, 2),
1323 	INGENIC_PIN_GROUP("ssi1-gpc-e", jz4770_ssi1_gpc_e, 1),
1324 	INGENIC_PIN_GROUP("ssi1-ce0-b", jz4770_ssi1_ce0_b, 2),
1325 	INGENIC_PIN_GROUP("ssi1-ce0-d", jz4770_ssi1_ce0_d, 2),
1326 	INGENIC_PIN_GROUP("ssi1-ce0-e", jz4770_ssi1_ce0_e, 1),
1327 	INGENIC_PIN_GROUP("ssi1-ce1-b", jz4770_ssi1_ce1_b, 2),
1328 	INGENIC_PIN_GROUP("ssi1-ce1-d", jz4770_ssi1_ce1_d, 2),
1329 	INGENIC_PIN_GROUP("ssi1-ce1-e", jz4770_ssi1_ce1_e, 1),
1330 	INGENIC_PIN_GROUP_FUNCS("mmc0-1bit-a", jz4770_mmc0_1bit_a,
1331 				jz4760_mmc0_1bit_a_funcs),
1332 	INGENIC_PIN_GROUP("mmc0-4bit-a", jz4770_mmc0_4bit_a, 1),
1333 	INGENIC_PIN_GROUP("mmc0-1bit-e", jz4770_mmc0_1bit_e, 0),
1334 	INGENIC_PIN_GROUP("mmc0-4bit-e", jz4770_mmc0_4bit_e, 0),
1335 	INGENIC_PIN_GROUP("mmc0-8bit-e", jz4770_mmc0_8bit_e, 0),
1336 	INGENIC_PIN_GROUP("mmc1-1bit-d", jz4770_mmc1_1bit_d, 0),
1337 	INGENIC_PIN_GROUP("mmc1-4bit-d", jz4770_mmc1_4bit_d, 0),
1338 	INGENIC_PIN_GROUP("mmc1-1bit-e", jz4770_mmc1_1bit_e, 1),
1339 	INGENIC_PIN_GROUP("mmc1-4bit-e", jz4770_mmc1_4bit_e, 1),
1340 	INGENIC_PIN_GROUP("mmc1-8bit-e", jz4770_mmc1_8bit_e, 1),
1341 	INGENIC_PIN_GROUP("mmc2-1bit-b", jz4770_mmc2_1bit_b, 0),
1342 	INGENIC_PIN_GROUP("mmc2-4bit-b", jz4770_mmc2_4bit_b, 0),
1343 	INGENIC_PIN_GROUP("mmc2-1bit-e", jz4770_mmc2_1bit_e, 2),
1344 	INGENIC_PIN_GROUP("mmc2-4bit-e", jz4770_mmc2_4bit_e, 2),
1345 	INGENIC_PIN_GROUP("mmc2-8bit-e", jz4770_mmc2_8bit_e, 2),
1346 	INGENIC_PIN_GROUP("nemc-8bit-data", jz4770_nemc_8bit_data, 0),
1347 	INGENIC_PIN_GROUP("nemc-16bit-data", jz4770_nemc_16bit_data, 0),
1348 	INGENIC_PIN_GROUP("nemc-cle-ale", jz4770_nemc_cle_ale, 0),
1349 	INGENIC_PIN_GROUP("nemc-addr", jz4770_nemc_addr, 0),
1350 	INGENIC_PIN_GROUP("nemc-rd-we", jz4770_nemc_rd_we, 0),
1351 	INGENIC_PIN_GROUP("nemc-frd-fwe", jz4770_nemc_frd_fwe, 0),
1352 	INGENIC_PIN_GROUP("nemc-wait", jz4770_nemc_wait, 0),
1353 	INGENIC_PIN_GROUP("nemc-cs1", jz4770_nemc_cs1, 0),
1354 	INGENIC_PIN_GROUP("nemc-cs2", jz4770_nemc_cs2, 0),
1355 	INGENIC_PIN_GROUP("nemc-cs3", jz4770_nemc_cs3, 0),
1356 	INGENIC_PIN_GROUP("nemc-cs4", jz4770_nemc_cs4, 0),
1357 	INGENIC_PIN_GROUP("nemc-cs5", jz4770_nemc_cs5, 0),
1358 	INGENIC_PIN_GROUP("nemc-cs6", jz4770_nemc_cs6, 0),
1359 	INGENIC_PIN_GROUP("i2c0-data", jz4770_i2c0, 0),
1360 	INGENIC_PIN_GROUP("i2c1-data", jz4770_i2c1, 0),
1361 	INGENIC_PIN_GROUP("i2c2-data", jz4770_i2c2, 2),
1362 	INGENIC_PIN_GROUP("cim-data-8bit", jz4770_cim_8bit, 0),
1363 	INGENIC_PIN_GROUP("cim-data-12bit", jz4770_cim_12bit, 0),
1364 	INGENIC_PIN_GROUP("lcd-8bit", jz4770_lcd_8bit, 0),
1365 	INGENIC_PIN_GROUP("lcd-16bit", jz4770_lcd_16bit, 0),
1366 	INGENIC_PIN_GROUP("lcd-18bit", jz4770_lcd_18bit, 0),
1367 	INGENIC_PIN_GROUP("lcd-24bit", jz4770_lcd_24bit, 0),
1368 	INGENIC_PIN_GROUP("lcd-special", jz4770_lcd_special, 1),
1369 	INGENIC_PIN_GROUP("lcd-generic", jz4770_lcd_generic, 0),
1370 	INGENIC_PIN_GROUP("pwm0", jz4770_pwm_pwm0, 0),
1371 	INGENIC_PIN_GROUP("pwm1", jz4770_pwm_pwm1, 0),
1372 	INGENIC_PIN_GROUP("pwm2", jz4770_pwm_pwm2, 0),
1373 	INGENIC_PIN_GROUP("pwm3", jz4770_pwm_pwm3, 0),
1374 	INGENIC_PIN_GROUP("pwm4", jz4770_pwm_pwm4, 0),
1375 	INGENIC_PIN_GROUP("pwm5", jz4770_pwm_pwm5, 0),
1376 	INGENIC_PIN_GROUP("pwm6", jz4770_pwm_pwm6, 0),
1377 	INGENIC_PIN_GROUP("pwm7", jz4770_pwm_pwm7, 0),
1378 	INGENIC_PIN_GROUP("mac-rmii", jz4770_mac_rmii, 0),
1379 	INGENIC_PIN_GROUP("mac-mii", jz4770_mac_mii, 0),
1380 	INGENIC_PIN_GROUP("otg-vbus", jz4760_otg, 0),
1381 };
1382 
1383 static const char *jz4770_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1384 static const char *jz4770_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
1385 static const char *jz4770_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
1386 static const char *jz4770_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
1387 static const char *jz4770_ssi0_groups[] = {
1388 	"ssi0-dt-a", "ssi0-dt-b", "ssi0-dt-d", "ssi0-dt-e",
1389 	"ssi0-dr-a", "ssi0-dr-b", "ssi0-dr-d", "ssi0-dr-e",
1390 	"ssi0-clk-a", "ssi0-clk-b", "ssi0-clk-d", "ssi0-clk-e",
1391 	"ssi0-gpc-b", "ssi0-gpc-d", "ssi0-gpc-e",
1392 	"ssi0-ce0-a", "ssi0-ce0-b", "ssi0-ce0-d", "ssi0-ce0-e",
1393 	"ssi0-ce1-b", "ssi0-ce1-d", "ssi0-ce1-e",
1394 };
1395 static const char *jz4770_ssi1_groups[] = {
1396 	"ssi1-dt-b", "ssi1-dt-d", "ssi1-dt-e",
1397 	"ssi1-dr-b", "ssi1-dr-d", "ssi1-dr-e",
1398 	"ssi1-clk-b", "ssi1-clk-d", "ssi1-clk-e",
1399 	"ssi1-gpc-b", "ssi1-gpc-d", "ssi1-gpc-e",
1400 	"ssi1-ce0-b", "ssi1-ce0-d", "ssi1-ce0-e",
1401 	"ssi1-ce1-b", "ssi1-ce1-d", "ssi1-ce1-e",
1402 };
1403 static const char *jz4770_mmc0_groups[] = {
1404 	"mmc0-1bit-a", "mmc0-4bit-a",
1405 	"mmc0-1bit-e", "mmc0-4bit-e", "mmc0-8bit-e",
1406 };
1407 static const char *jz4770_mmc1_groups[] = {
1408 	"mmc1-1bit-d", "mmc1-4bit-d",
1409 	"mmc1-1bit-e", "mmc1-4bit-e", "mmc1-8bit-e",
1410 };
1411 static const char *jz4770_mmc2_groups[] = {
1412 	"mmc2-1bit-b", "mmc2-4bit-b",
1413 	"mmc2-1bit-e", "mmc2-4bit-e", "mmc2-8bit-e",
1414 };
1415 static const char *jz4770_nemc_groups[] = {
1416 	"nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale",
1417 	"nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
1418 };
1419 static const char *jz4770_cs1_groups[] = { "nemc-cs1", };
1420 static const char *jz4770_cs2_groups[] = { "nemc-cs2", };
1421 static const char *jz4770_cs3_groups[] = { "nemc-cs3", };
1422 static const char *jz4770_cs4_groups[] = { "nemc-cs4", };
1423 static const char *jz4770_cs5_groups[] = { "nemc-cs5", };
1424 static const char *jz4770_cs6_groups[] = { "nemc-cs6", };
1425 static const char *jz4770_i2c0_groups[] = { "i2c0-data", };
1426 static const char *jz4770_i2c1_groups[] = { "i2c1-data", };
1427 static const char *jz4770_i2c2_groups[] = { "i2c2-data", };
1428 static const char *jz4770_cim_groups[] = { "cim-data-8bit", "cim-data-12bit", };
1429 static const char *jz4770_lcd_groups[] = {
1430 	"lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
1431 	"lcd-special", "lcd-generic",
1432 };
1433 static const char *jz4770_pwm0_groups[] = { "pwm0", };
1434 static const char *jz4770_pwm1_groups[] = { "pwm1", };
1435 static const char *jz4770_pwm2_groups[] = { "pwm2", };
1436 static const char *jz4770_pwm3_groups[] = { "pwm3", };
1437 static const char *jz4770_pwm4_groups[] = { "pwm4", };
1438 static const char *jz4770_pwm5_groups[] = { "pwm5", };
1439 static const char *jz4770_pwm6_groups[] = { "pwm6", };
1440 static const char *jz4770_pwm7_groups[] = { "pwm7", };
1441 static const char *jz4770_mac_groups[] = { "mac-rmii", "mac-mii", };
1442 
1443 static const struct pinfunction jz4770_functions[] = {
1444 	INGENIC_PIN_FUNCTION("uart0", jz4770_uart0),
1445 	INGENIC_PIN_FUNCTION("uart1", jz4770_uart1),
1446 	INGENIC_PIN_FUNCTION("uart2", jz4770_uart2),
1447 	INGENIC_PIN_FUNCTION("uart3", jz4770_uart3),
1448 	INGENIC_PIN_FUNCTION("ssi0", jz4770_ssi0),
1449 	INGENIC_PIN_FUNCTION("ssi1", jz4770_ssi1),
1450 	INGENIC_PIN_FUNCTION("mmc0", jz4770_mmc0),
1451 	INGENIC_PIN_FUNCTION("mmc1", jz4770_mmc1),
1452 	INGENIC_PIN_FUNCTION("mmc2", jz4770_mmc2),
1453 	INGENIC_PIN_FUNCTION("nemc", jz4770_nemc),
1454 	INGENIC_PIN_FUNCTION("nemc-cs1", jz4770_cs1),
1455 	INGENIC_PIN_FUNCTION("nemc-cs2", jz4770_cs2),
1456 	INGENIC_PIN_FUNCTION("nemc-cs3", jz4770_cs3),
1457 	INGENIC_PIN_FUNCTION("nemc-cs4", jz4770_cs4),
1458 	INGENIC_PIN_FUNCTION("nemc-cs5", jz4770_cs5),
1459 	INGENIC_PIN_FUNCTION("nemc-cs6", jz4770_cs6),
1460 	INGENIC_PIN_FUNCTION("i2c0", jz4770_i2c0),
1461 	INGENIC_PIN_FUNCTION("i2c1", jz4770_i2c1),
1462 	INGENIC_PIN_FUNCTION("i2c2", jz4770_i2c2),
1463 	INGENIC_PIN_FUNCTION("cim", jz4770_cim),
1464 	INGENIC_PIN_FUNCTION("lcd", jz4770_lcd),
1465 	INGENIC_PIN_FUNCTION("pwm0", jz4770_pwm0),
1466 	INGENIC_PIN_FUNCTION("pwm1", jz4770_pwm1),
1467 	INGENIC_PIN_FUNCTION("pwm2", jz4770_pwm2),
1468 	INGENIC_PIN_FUNCTION("pwm3", jz4770_pwm3),
1469 	INGENIC_PIN_FUNCTION("pwm4", jz4770_pwm4),
1470 	INGENIC_PIN_FUNCTION("pwm5", jz4770_pwm5),
1471 	INGENIC_PIN_FUNCTION("pwm6", jz4770_pwm6),
1472 	INGENIC_PIN_FUNCTION("pwm7", jz4770_pwm7),
1473 	INGENIC_PIN_FUNCTION("mac", jz4770_mac),
1474 	INGENIC_PIN_FUNCTION("otg", jz4760_otg),
1475 };
1476 
1477 static const struct ingenic_chip_info jz4770_chip_info = {
1478 	.num_chips = 6,
1479 	.reg_offset = 0x100,
1480 	.version = ID_JZ4770,
1481 	.groups = jz4770_groups,
1482 	.num_groups = ARRAY_SIZE(jz4770_groups),
1483 	.functions = jz4770_functions,
1484 	.num_functions = ARRAY_SIZE(jz4770_functions),
1485 	.pull_ups = jz4770_pull_ups,
1486 	.pull_downs = jz4770_pull_downs,
1487 };
1488 
1489 static const u32 jz4775_pull_ups[7] = {
1490 	0x28ff00ff, 0xf030f3fc, 0x0fffffff, 0xfffe4000, 0xf0f0000c, 0x0000f00f, 0x0000f3c0,
1491 };
1492 
1493 static const u32 jz4775_pull_downs[7] = {
1494 	0x00000000, 0x00030c03, 0x00000000, 0x00008000, 0x00000403, 0x00000ff0, 0x00030c00,
1495 };
1496 
1497 static int jz4775_uart0_data_pins[] = { 0xa0, 0xa3, };
1498 static int jz4775_uart0_hwflow_pins[] = { 0xa1, 0xa2, };
1499 static int jz4775_uart1_data_pins[] = { 0x7a, 0x7c, };
1500 static int jz4775_uart1_hwflow_pins[] = { 0x7b, 0x7d, };
1501 static int jz4775_uart2_data_c_pins[] = { 0x54, 0x4a, };
1502 static int jz4775_uart2_data_f_pins[] = { 0xa5, 0xa4, };
1503 static int jz4775_uart3_data_pins[] = { 0x1e, 0x1f, };
1504 static int jz4775_ssi_dt_a_pins[] = { 0x13, };
1505 static int jz4775_ssi_dt_d_pins[] = { 0x75, };
1506 static int jz4775_ssi_dr_a_pins[] = { 0x14, };
1507 static int jz4775_ssi_dr_d_pins[] = { 0x74, };
1508 static int jz4775_ssi_clk_a_pins[] = { 0x12, };
1509 static int jz4775_ssi_clk_d_pins[] = { 0x78, };
1510 static int jz4775_ssi_gpc_pins[] = { 0x76, };
1511 static int jz4775_ssi_ce0_a_pins[] = { 0x17, };
1512 static int jz4775_ssi_ce0_d_pins[] = { 0x79, };
1513 static int jz4775_ssi_ce1_pins[] = { 0x77, };
1514 static int jz4775_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, };
1515 static int jz4775_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, };
1516 static int jz4775_mmc0_8bit_a_pins[] = { 0x04, 0x05, 0x06, 0x07, };
1517 static int jz4775_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
1518 static int jz4775_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
1519 static int jz4775_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, };
1520 static int jz4775_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, };
1521 static int jz4775_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
1522 static int jz4775_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
1523 static int jz4775_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, };
1524 static int jz4775_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, };
1525 static int jz4775_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
1526 static int jz4775_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
1527 static int jz4775_nemc_8bit_data_pins[] = {
1528 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1529 };
1530 static int jz4775_nemc_16bit_data_pins[] = {
1531 	0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1,
1532 };
1533 static int jz4775_nemc_cle_ale_pins[] = { 0x20, 0x21, };
1534 static int jz4775_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, };
1535 static int jz4775_nemc_rd_we_pins[] = { 0x10, 0x11, };
1536 static int jz4775_nemc_frd_fwe_pins[] = { 0x12, 0x13, };
1537 static int jz4775_nemc_wait_pins[] = { 0x1b, };
1538 static int jz4775_nemc_cs1_pins[] = { 0x15, };
1539 static int jz4775_nemc_cs2_pins[] = { 0x16, };
1540 static int jz4775_nemc_cs3_pins[] = { 0x17, };
1541 static int jz4775_i2c0_pins[] = { 0x7e, 0x7f, };
1542 static int jz4775_i2c1_pins[] = { 0x9e, 0x9f, };
1543 static int jz4775_i2c2_pins[] = { 0x80, 0x83, };
1544 static int jz4775_i2s_data_tx_pins[] = { 0xa3, };
1545 static int jz4775_i2s_data_rx_pins[] = { 0xa2, };
1546 static int jz4775_i2s_clk_txrx_pins[] = { 0xa0, 0xa1, };
1547 static int jz4775_i2s_sysclk_pins[] = { 0x83, };
1548 static int jz4775_dmic_pins[] = { 0xaa, 0xab, };
1549 static int jz4775_cim_pins[] = {
1550 	0x26, 0x27, 0x28, 0x29,
1551 	0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
1552 };
1553 static int jz4775_lcd_8bit_pins[] = {
1554 	0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x4c, 0x4d,
1555 	0x48, 0x52, 0x53,
1556 };
1557 static int jz4775_lcd_16bit_pins[] = {
1558 	0x4e, 0x4f, 0x50, 0x51, 0x56, 0x57, 0x58, 0x59,
1559 };
1560 static int jz4775_lcd_18bit_pins[] = {
1561 	0x5a, 0x5b,
1562 };
1563 static int jz4775_lcd_24bit_pins[] = {
1564 	0x40, 0x41, 0x4a, 0x4b, 0x54, 0x55,
1565 };
1566 static int jz4775_lcd_special_pins[] = { 0x54, 0x4a, 0x41, 0x40, };
1567 static int jz4775_lcd_generic_pins[] = { 0x49, };
1568 static int jz4775_pwm_pwm0_pins[] = { 0x80, };
1569 static int jz4775_pwm_pwm1_pins[] = { 0x81, };
1570 static int jz4775_pwm_pwm2_pins[] = { 0x82, };
1571 static int jz4775_pwm_pwm3_pins[] = { 0x83, };
1572 static int jz4775_mac_rmii_pins[] = {
1573 	0xa9, 0xab, 0xaa, 0xac, 0xa5, 0xa4, 0xad, 0xae, 0xa6, 0xa8,
1574 };
1575 static int jz4775_mac_mii_pins[] = {
1576 	0x7b, 0x7a, 0x7d, 0x7c, 0xa7, 0x24, 0xaf,
1577 };
1578 static int jz4775_mac_rgmii_pins[] = {
1579 	0xa9, 0x7b, 0x7a, 0xab, 0xaa, 0xac, 0x7d, 0x7c, 0xa5, 0xa4,
1580 	0xad, 0xae, 0xa7, 0xa6,
1581 };
1582 static int jz4775_mac_gmii_pins[] = {
1583 	0x31, 0x30, 0x2f, 0x2e, 0x2d, 0x2c, 0x2b, 0x2a,
1584 	0xa8, 0x28, 0x24, 0xaf,
1585 };
1586 static int jz4775_otg_pins[] = { 0x8a, };
1587 
1588 static u8 jz4775_uart3_data_funcs[] = { 0, 1, };
1589 static u8 jz4775_mac_mii_funcs[] = { 1, 1, 1, 1, 0, 1, 0, };
1590 static u8 jz4775_mac_rgmii_funcs[] = {
1591 	0, 1, 1, 0, 0, 0, 1, 1, 0, 0,
1592 	0, 0, 0, 0,
1593 };
1594 static u8 jz4775_mac_gmii_funcs[] = {
1595 	1, 1, 1, 1, 1, 1, 1, 1,
1596 	0, 1, 1, 0,
1597 };
1598 
1599 static const struct group_desc jz4775_groups[] = {
1600 	INGENIC_PIN_GROUP("uart0-data", jz4775_uart0_data, 0),
1601 	INGENIC_PIN_GROUP("uart0-hwflow", jz4775_uart0_hwflow, 0),
1602 	INGENIC_PIN_GROUP("uart1-data", jz4775_uart1_data, 0),
1603 	INGENIC_PIN_GROUP("uart1-hwflow", jz4775_uart1_hwflow, 0),
1604 	INGENIC_PIN_GROUP("uart2-data-c", jz4775_uart2_data_c, 2),
1605 	INGENIC_PIN_GROUP("uart2-data-f", jz4775_uart2_data_f, 1),
1606 	INGENIC_PIN_GROUP_FUNCS("uart3-data", jz4775_uart3_data,
1607 				jz4775_uart3_data_funcs),
1608 	INGENIC_PIN_GROUP("ssi-dt-a", jz4775_ssi_dt_a, 2),
1609 	INGENIC_PIN_GROUP("ssi-dt-d", jz4775_ssi_dt_d, 1),
1610 	INGENIC_PIN_GROUP("ssi-dr-a", jz4775_ssi_dr_a, 2),
1611 	INGENIC_PIN_GROUP("ssi-dr-d", jz4775_ssi_dr_d, 1),
1612 	INGENIC_PIN_GROUP("ssi-clk-a", jz4775_ssi_clk_a, 2),
1613 	INGENIC_PIN_GROUP("ssi-clk-d", jz4775_ssi_clk_d, 1),
1614 	INGENIC_PIN_GROUP("ssi-gpc", jz4775_ssi_gpc, 1),
1615 	INGENIC_PIN_GROUP("ssi-ce0-a", jz4775_ssi_ce0_a, 2),
1616 	INGENIC_PIN_GROUP("ssi-ce0-d", jz4775_ssi_ce0_d, 1),
1617 	INGENIC_PIN_GROUP("ssi-ce1", jz4775_ssi_ce1, 1),
1618 	INGENIC_PIN_GROUP("mmc0-1bit-a", jz4775_mmc0_1bit_a, 1),
1619 	INGENIC_PIN_GROUP("mmc0-4bit-a", jz4775_mmc0_4bit_a, 1),
1620 	INGENIC_PIN_GROUP("mmc0-8bit-a", jz4775_mmc0_8bit_a, 1),
1621 	INGENIC_PIN_GROUP("mmc0-1bit-e", jz4775_mmc0_1bit_e, 0),
1622 	INGENIC_PIN_GROUP("mmc0-4bit-e", jz4775_mmc0_4bit_e, 0),
1623 	INGENIC_PIN_GROUP("mmc1-1bit-d", jz4775_mmc1_1bit_d, 0),
1624 	INGENIC_PIN_GROUP("mmc1-4bit-d", jz4775_mmc1_4bit_d, 0),
1625 	INGENIC_PIN_GROUP("mmc1-1bit-e", jz4775_mmc1_1bit_e, 1),
1626 	INGENIC_PIN_GROUP("mmc1-4bit-e", jz4775_mmc1_4bit_e, 1),
1627 	INGENIC_PIN_GROUP("mmc2-1bit-b", jz4775_mmc2_1bit_b, 0),
1628 	INGENIC_PIN_GROUP("mmc2-4bit-b", jz4775_mmc2_4bit_b, 0),
1629 	INGENIC_PIN_GROUP("mmc2-1bit-e", jz4775_mmc2_1bit_e, 2),
1630 	INGENIC_PIN_GROUP("mmc2-4bit-e", jz4775_mmc2_4bit_e, 2),
1631 	INGENIC_PIN_GROUP("nemc-8bit-data", jz4775_nemc_8bit_data, 0),
1632 	INGENIC_PIN_GROUP("nemc-16bit-data", jz4775_nemc_16bit_data, 1),
1633 	INGENIC_PIN_GROUP("nemc-cle-ale", jz4775_nemc_cle_ale, 0),
1634 	INGENIC_PIN_GROUP("nemc-addr", jz4775_nemc_addr, 0),
1635 	INGENIC_PIN_GROUP("nemc-rd-we", jz4775_nemc_rd_we, 0),
1636 	INGENIC_PIN_GROUP("nemc-frd-fwe", jz4775_nemc_frd_fwe, 0),
1637 	INGENIC_PIN_GROUP("nemc-wait", jz4775_nemc_wait, 0),
1638 	INGENIC_PIN_GROUP("nemc-cs1", jz4775_nemc_cs1, 0),
1639 	INGENIC_PIN_GROUP("nemc-cs2", jz4775_nemc_cs2, 0),
1640 	INGENIC_PIN_GROUP("nemc-cs3", jz4775_nemc_cs3, 0),
1641 	INGENIC_PIN_GROUP("i2c0-data", jz4775_i2c0, 0),
1642 	INGENIC_PIN_GROUP("i2c1-data", jz4775_i2c1, 0),
1643 	INGENIC_PIN_GROUP("i2c2-data", jz4775_i2c2, 1),
1644 	INGENIC_PIN_GROUP("i2s-data-tx", jz4775_i2s_data_tx, 1),
1645 	INGENIC_PIN_GROUP("i2s-data-rx", jz4775_i2s_data_rx, 1),
1646 	INGENIC_PIN_GROUP("i2s-clk-txrx", jz4775_i2s_clk_txrx, 1),
1647 	INGENIC_PIN_GROUP("i2s-sysclk", jz4775_i2s_sysclk, 2),
1648 	INGENIC_PIN_GROUP("dmic", jz4775_dmic, 1),
1649 	INGENIC_PIN_GROUP("cim-data", jz4775_cim, 0),
1650 	INGENIC_PIN_GROUP("lcd-8bit", jz4775_lcd_8bit, 0),
1651 	INGENIC_PIN_GROUP("lcd-16bit", jz4775_lcd_16bit, 0),
1652 	INGENIC_PIN_GROUP("lcd-18bit", jz4775_lcd_18bit, 0),
1653 	INGENIC_PIN_GROUP("lcd-24bit", jz4775_lcd_24bit, 0),
1654 	INGENIC_PIN_GROUP("lcd-generic", jz4775_lcd_generic, 0),
1655 	INGENIC_PIN_GROUP("lcd-special", jz4775_lcd_special, 1),
1656 	INGENIC_PIN_GROUP("pwm0", jz4775_pwm_pwm0, 0),
1657 	INGENIC_PIN_GROUP("pwm1", jz4775_pwm_pwm1, 0),
1658 	INGENIC_PIN_GROUP("pwm2", jz4775_pwm_pwm2, 0),
1659 	INGENIC_PIN_GROUP("pwm3", jz4775_pwm_pwm3, 0),
1660 	INGENIC_PIN_GROUP("mac-rmii", jz4775_mac_rmii, 0),
1661 	INGENIC_PIN_GROUP_FUNCS("mac-mii", jz4775_mac_mii,
1662 				jz4775_mac_mii_funcs),
1663 	INGENIC_PIN_GROUP_FUNCS("mac-rgmii", jz4775_mac_rgmii,
1664 				jz4775_mac_rgmii_funcs),
1665 	INGENIC_PIN_GROUP_FUNCS("mac-gmii", jz4775_mac_gmii,
1666 				jz4775_mac_gmii_funcs),
1667 	INGENIC_PIN_GROUP("otg-vbus", jz4775_otg, 0),
1668 };
1669 
1670 static const char *jz4775_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1671 static const char *jz4775_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
1672 static const char *jz4775_uart2_groups[] = { "uart2-data-c", "uart2-data-f", };
1673 static const char *jz4775_uart3_groups[] = { "uart3-data", };
1674 static const char *jz4775_ssi_groups[] = {
1675 	"ssi-dt-a", "ssi-dt-d",
1676 	"ssi-dr-a", "ssi-dr-d",
1677 	"ssi-clk-a", "ssi-clk-d",
1678 	"ssi-gpc",
1679 	"ssi-ce0-a", "ssi-ce0-d",
1680 	"ssi-ce1",
1681 };
1682 static const char *jz4775_mmc0_groups[] = {
1683 	"mmc0-1bit-a", "mmc0-4bit-a", "mmc0-8bit-a",
1684 	"mmc0-1bit-e", "mmc0-4bit-e",
1685 };
1686 static const char *jz4775_mmc1_groups[] = {
1687 	"mmc1-1bit-d", "mmc1-4bit-d",
1688 	"mmc1-1bit-e", "mmc1-4bit-e",
1689 };
1690 static const char *jz4775_mmc2_groups[] = {
1691 	"mmc2-1bit-b", "mmc2-4bit-b",
1692 	"mmc2-1bit-e", "mmc2-4bit-e",
1693 };
1694 static const char *jz4775_nemc_groups[] = {
1695 	"nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale",
1696 	"nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
1697 };
1698 static const char *jz4775_cs1_groups[] = { "nemc-cs1", };
1699 static const char *jz4775_cs2_groups[] = { "nemc-cs2", };
1700 static const char *jz4775_cs3_groups[] = { "nemc-cs3", };
1701 static const char *jz4775_i2c0_groups[] = { "i2c0-data", };
1702 static const char *jz4775_i2c1_groups[] = { "i2c1-data", };
1703 static const char *jz4775_i2c2_groups[] = { "i2c2-data", };
1704 static const char *jz4775_i2s_groups[] = {
1705 	"i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-sysclk",
1706 };
1707 static const char *jz4775_dmic_groups[] = { "dmic", };
1708 static const char *jz4775_cim_groups[] = { "cim-data", };
1709 static const char *jz4775_lcd_groups[] = {
1710 	"lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
1711 	"lcd-special", "lcd-generic",
1712 };
1713 static const char *jz4775_pwm0_groups[] = { "pwm0", };
1714 static const char *jz4775_pwm1_groups[] = { "pwm1", };
1715 static const char *jz4775_pwm2_groups[] = { "pwm2", };
1716 static const char *jz4775_pwm3_groups[] = { "pwm3", };
1717 static const char *jz4775_mac_groups[] = {
1718 	"mac-rmii", "mac-mii", "mac-rgmii", "mac-gmii",
1719 };
1720 static const char *jz4775_otg_groups[] = { "otg-vbus", };
1721 
1722 static const struct pinfunction jz4775_functions[] = {
1723 	INGENIC_PIN_FUNCTION("uart0", jz4775_uart0),
1724 	INGENIC_PIN_FUNCTION("uart1", jz4775_uart1),
1725 	INGENIC_PIN_FUNCTION("uart2", jz4775_uart2),
1726 	INGENIC_PIN_FUNCTION("uart3", jz4775_uart3),
1727 	INGENIC_PIN_FUNCTION("ssi", jz4775_ssi),
1728 	INGENIC_PIN_FUNCTION("mmc0", jz4775_mmc0),
1729 	INGENIC_PIN_FUNCTION("mmc1", jz4775_mmc1),
1730 	INGENIC_PIN_FUNCTION("mmc2", jz4775_mmc2),
1731 	INGENIC_PIN_FUNCTION("nemc", jz4775_nemc),
1732 	INGENIC_PIN_FUNCTION("nemc-cs1", jz4775_cs1),
1733 	INGENIC_PIN_FUNCTION("nemc-cs2", jz4775_cs2),
1734 	INGENIC_PIN_FUNCTION("nemc-cs3", jz4775_cs3),
1735 	INGENIC_PIN_FUNCTION("i2c0", jz4775_i2c0),
1736 	INGENIC_PIN_FUNCTION("i2c1", jz4775_i2c1),
1737 	INGENIC_PIN_FUNCTION("i2c2", jz4775_i2c2),
1738 	INGENIC_PIN_FUNCTION("i2s", jz4775_i2s),
1739 	INGENIC_PIN_FUNCTION("dmic", jz4775_dmic),
1740 	INGENIC_PIN_FUNCTION("cim", jz4775_cim),
1741 	INGENIC_PIN_FUNCTION("lcd", jz4775_lcd),
1742 	INGENIC_PIN_FUNCTION("pwm0", jz4775_pwm0),
1743 	INGENIC_PIN_FUNCTION("pwm1", jz4775_pwm1),
1744 	INGENIC_PIN_FUNCTION("pwm2", jz4775_pwm2),
1745 	INGENIC_PIN_FUNCTION("pwm3", jz4775_pwm3),
1746 	INGENIC_PIN_FUNCTION("mac", jz4775_mac),
1747 	INGENIC_PIN_FUNCTION("otg", jz4775_otg),
1748 };
1749 
1750 static const struct ingenic_chip_info jz4775_chip_info = {
1751 	.num_chips = 7,
1752 	.reg_offset = 0x100,
1753 	.version = ID_JZ4775,
1754 	.groups = jz4775_groups,
1755 	.num_groups = ARRAY_SIZE(jz4775_groups),
1756 	.functions = jz4775_functions,
1757 	.num_functions = ARRAY_SIZE(jz4775_functions),
1758 	.pull_ups = jz4775_pull_ups,
1759 	.pull_downs = jz4775_pull_downs,
1760 };
1761 
1762 static const u32 jz4780_pull_ups[6] = {
1763 	0x3fffffff, 0xfff0f3fc, 0x0fffffff, 0xffff4fff, 0xfffffb7c, 0x7fa7f00f,
1764 };
1765 
1766 static const u32 jz4780_pull_downs[6] = {
1767 	0x00000000, 0x000f0c03, 0x00000000, 0x0000b000, 0x00000483, 0x00580ff0,
1768 };
1769 
1770 static int jz4780_uart2_data_pins[] = { 0x66, 0x67, };
1771 static int jz4780_uart2_hwflow_pins[] = { 0x65, 0x64, };
1772 static int jz4780_uart4_data_pins[] = { 0x54, 0x4a, };
1773 static int jz4780_ssi0_dt_a_19_pins[] = { 0x13, };
1774 static int jz4780_ssi0_dt_a_21_pins[] = { 0x15, };
1775 static int jz4780_ssi0_dt_a_28_pins[] = { 0x1c, };
1776 static int jz4780_ssi0_dt_b_pins[] = { 0x3d, };
1777 static int jz4780_ssi0_dt_d_pins[] = { 0x79, };
1778 static int jz4780_ssi0_dr_a_20_pins[] = { 0x14, };
1779 static int jz4780_ssi0_dr_a_27_pins[] = { 0x1b, };
1780 static int jz4780_ssi0_dr_b_pins[] = { 0x34, };
1781 static int jz4780_ssi0_dr_d_pins[] = { 0x74, };
1782 static int jz4780_ssi0_clk_a_pins[] = { 0x12, };
1783 static int jz4780_ssi0_clk_b_5_pins[] = { 0x25, };
1784 static int jz4780_ssi0_clk_b_28_pins[] = { 0x3c, };
1785 static int jz4780_ssi0_clk_d_pins[] = { 0x78, };
1786 static int jz4780_ssi0_gpc_b_pins[] = { 0x3e, };
1787 static int jz4780_ssi0_gpc_d_pins[] = { 0x76, };
1788 static int jz4780_ssi0_ce0_a_23_pins[] = { 0x17, };
1789 static int jz4780_ssi0_ce0_a_25_pins[] = { 0x19, };
1790 static int jz4780_ssi0_ce0_b_pins[] = { 0x3f, };
1791 static int jz4780_ssi0_ce0_d_pins[] = { 0x77, };
1792 static int jz4780_ssi0_ce1_b_pins[] = { 0x35, };
1793 static int jz4780_ssi0_ce1_d_pins[] = { 0x75, };
1794 static int jz4780_ssi1_dt_b_pins[] = { 0x3d, };
1795 static int jz4780_ssi1_dt_d_pins[] = { 0x79, };
1796 static int jz4780_ssi1_dr_b_pins[] = { 0x34, };
1797 static int jz4780_ssi1_dr_d_pins[] = { 0x74, };
1798 static int jz4780_ssi1_clk_b_pins[] = { 0x3c, };
1799 static int jz4780_ssi1_clk_d_pins[] = { 0x78, };
1800 static int jz4780_ssi1_gpc_b_pins[] = { 0x3e, };
1801 static int jz4780_ssi1_gpc_d_pins[] = { 0x76, };
1802 static int jz4780_ssi1_ce0_b_pins[] = { 0x3f, };
1803 static int jz4780_ssi1_ce0_d_pins[] = { 0x77, };
1804 static int jz4780_ssi1_ce1_b_pins[] = { 0x35, };
1805 static int jz4780_ssi1_ce1_d_pins[] = { 0x75, };
1806 static int jz4780_mmc0_8bit_a_pins[] = { 0x04, 0x05, 0x06, 0x07, 0x18, };
1807 static int jz4780_i2c3_pins[] = { 0x6a, 0x6b, };
1808 static int jz4780_i2c4_e_pins[] = { 0x8c, 0x8d, };
1809 static int jz4780_i2c4_f_pins[] = { 0xb9, 0xb8, };
1810 static int jz4780_i2s_data_tx_pins[] = { 0x87, };
1811 static int jz4780_i2s_data_rx_pins[] = { 0x86, };
1812 static int jz4780_i2s_clk_txrx_pins[] = { 0x6c, 0x6d, };
1813 static int jz4780_i2s_clk_rx_pins[] = { 0x88, 0x89, };
1814 static int jz4780_i2s_sysclk_pins[] = { 0x85, };
1815 static int jz4780_dmic_pins[] = { 0x32, 0x33, };
1816 static int jz4780_hdmi_ddc_pins[] = { 0xb9, 0xb8, };
1817 
1818 static u8 jz4780_i2s_clk_txrx_funcs[] = { 1, 0, };
1819 
1820 static const struct group_desc jz4780_groups[] = {
1821 	INGENIC_PIN_GROUP("uart0-data", jz4770_uart0_data, 0),
1822 	INGENIC_PIN_GROUP("uart0-hwflow", jz4770_uart0_hwflow, 0),
1823 	INGENIC_PIN_GROUP("uart1-data", jz4770_uart1_data, 0),
1824 	INGENIC_PIN_GROUP("uart1-hwflow", jz4770_uart1_hwflow, 0),
1825 	INGENIC_PIN_GROUP("uart2-data", jz4780_uart2_data, 1),
1826 	INGENIC_PIN_GROUP("uart2-hwflow", jz4780_uart2_hwflow, 1),
1827 	INGENIC_PIN_GROUP_FUNCS("uart3-data", jz4770_uart3_data,
1828 				jz4760_uart3_data_funcs),
1829 	INGENIC_PIN_GROUP("uart3-hwflow", jz4770_uart3_hwflow, 0),
1830 	INGENIC_PIN_GROUP("uart4-data", jz4780_uart4_data, 2),
1831 	INGENIC_PIN_GROUP("ssi0-dt-a-19", jz4780_ssi0_dt_a_19, 2),
1832 	INGENIC_PIN_GROUP("ssi0-dt-a-21", jz4780_ssi0_dt_a_21, 2),
1833 	INGENIC_PIN_GROUP("ssi0-dt-a-28", jz4780_ssi0_dt_a_28, 2),
1834 	INGENIC_PIN_GROUP("ssi0-dt-b", jz4780_ssi0_dt_b, 1),
1835 	INGENIC_PIN_GROUP("ssi0-dt-d", jz4780_ssi0_dt_d, 1),
1836 	INGENIC_PIN_GROUP("ssi0-dt-e", jz4770_ssi0_dt_e, 0),
1837 	INGENIC_PIN_GROUP("ssi0-dr-a-20", jz4780_ssi0_dr_a_20, 2),
1838 	INGENIC_PIN_GROUP("ssi0-dr-a-27", jz4780_ssi0_dr_a_27, 2),
1839 	INGENIC_PIN_GROUP("ssi0-dr-b", jz4780_ssi0_dr_b, 1),
1840 	INGENIC_PIN_GROUP("ssi0-dr-d", jz4780_ssi0_dr_d, 1),
1841 	INGENIC_PIN_GROUP("ssi0-dr-e", jz4770_ssi0_dr_e, 0),
1842 	INGENIC_PIN_GROUP("ssi0-clk-a", jz4780_ssi0_clk_a, 2),
1843 	INGENIC_PIN_GROUP("ssi0-clk-b-5", jz4780_ssi0_clk_b_5, 1),
1844 	INGENIC_PIN_GROUP("ssi0-clk-b-28", jz4780_ssi0_clk_b_28, 1),
1845 	INGENIC_PIN_GROUP("ssi0-clk-d", jz4780_ssi0_clk_d, 1),
1846 	INGENIC_PIN_GROUP("ssi0-clk-e", jz4770_ssi0_clk_e, 0),
1847 	INGENIC_PIN_GROUP("ssi0-gpc-b", jz4780_ssi0_gpc_b, 1),
1848 	INGENIC_PIN_GROUP("ssi0-gpc-d", jz4780_ssi0_gpc_d, 1),
1849 	INGENIC_PIN_GROUP("ssi0-gpc-e", jz4770_ssi0_gpc_e, 0),
1850 	INGENIC_PIN_GROUP("ssi0-ce0-a-23", jz4780_ssi0_ce0_a_23, 2),
1851 	INGENIC_PIN_GROUP("ssi0-ce0-a-25", jz4780_ssi0_ce0_a_25, 2),
1852 	INGENIC_PIN_GROUP("ssi0-ce0-b", jz4780_ssi0_ce0_b, 1),
1853 	INGENIC_PIN_GROUP("ssi0-ce0-d", jz4780_ssi0_ce0_d, 1),
1854 	INGENIC_PIN_GROUP("ssi0-ce0-e", jz4770_ssi0_ce0_e, 0),
1855 	INGENIC_PIN_GROUP("ssi0-ce1-b", jz4780_ssi0_ce1_b, 1),
1856 	INGENIC_PIN_GROUP("ssi0-ce1-d", jz4780_ssi0_ce1_d, 1),
1857 	INGENIC_PIN_GROUP("ssi0-ce1-e", jz4770_ssi0_ce1_e, 0),
1858 	INGENIC_PIN_GROUP("ssi1-dt-b", jz4780_ssi1_dt_b, 2),
1859 	INGENIC_PIN_GROUP("ssi1-dt-d", jz4780_ssi1_dt_d, 2),
1860 	INGENIC_PIN_GROUP("ssi1-dt-e", jz4770_ssi1_dt_e, 1),
1861 	INGENIC_PIN_GROUP("ssi1-dr-b", jz4780_ssi1_dr_b, 2),
1862 	INGENIC_PIN_GROUP("ssi1-dr-d", jz4780_ssi1_dr_d, 2),
1863 	INGENIC_PIN_GROUP("ssi1-dr-e", jz4770_ssi1_dr_e, 1),
1864 	INGENIC_PIN_GROUP("ssi1-clk-b", jz4780_ssi1_clk_b, 2),
1865 	INGENIC_PIN_GROUP("ssi1-clk-d", jz4780_ssi1_clk_d, 2),
1866 	INGENIC_PIN_GROUP("ssi1-clk-e", jz4770_ssi1_clk_e, 1),
1867 	INGENIC_PIN_GROUP("ssi1-gpc-b", jz4780_ssi1_gpc_b, 2),
1868 	INGENIC_PIN_GROUP("ssi1-gpc-d", jz4780_ssi1_gpc_d, 2),
1869 	INGENIC_PIN_GROUP("ssi1-gpc-e", jz4770_ssi1_gpc_e, 1),
1870 	INGENIC_PIN_GROUP("ssi1-ce0-b", jz4780_ssi1_ce0_b, 2),
1871 	INGENIC_PIN_GROUP("ssi1-ce0-d", jz4780_ssi1_ce0_d, 2),
1872 	INGENIC_PIN_GROUP("ssi1-ce0-e", jz4770_ssi1_ce0_e, 1),
1873 	INGENIC_PIN_GROUP("ssi1-ce1-b", jz4780_ssi1_ce1_b, 2),
1874 	INGENIC_PIN_GROUP("ssi1-ce1-d", jz4780_ssi1_ce1_d, 2),
1875 	INGENIC_PIN_GROUP("ssi1-ce1-e", jz4770_ssi1_ce1_e, 1),
1876 	INGENIC_PIN_GROUP_FUNCS("mmc0-1bit-a", jz4770_mmc0_1bit_a,
1877 				jz4760_mmc0_1bit_a_funcs),
1878 	INGENIC_PIN_GROUP("mmc0-4bit-a", jz4770_mmc0_4bit_a, 1),
1879 	INGENIC_PIN_GROUP("mmc0-8bit-a", jz4780_mmc0_8bit_a, 1),
1880 	INGENIC_PIN_GROUP("mmc0-1bit-e", jz4770_mmc0_1bit_e, 0),
1881 	INGENIC_PIN_GROUP("mmc0-4bit-e", jz4770_mmc0_4bit_e, 0),
1882 	INGENIC_PIN_GROUP("mmc1-1bit-d", jz4770_mmc1_1bit_d, 0),
1883 	INGENIC_PIN_GROUP("mmc1-4bit-d", jz4770_mmc1_4bit_d, 0),
1884 	INGENIC_PIN_GROUP("mmc1-1bit-e", jz4770_mmc1_1bit_e, 1),
1885 	INGENIC_PIN_GROUP("mmc1-4bit-e", jz4770_mmc1_4bit_e, 1),
1886 	INGENIC_PIN_GROUP("mmc2-1bit-b", jz4770_mmc2_1bit_b, 0),
1887 	INGENIC_PIN_GROUP("mmc2-4bit-b", jz4770_mmc2_4bit_b, 0),
1888 	INGENIC_PIN_GROUP("mmc2-1bit-e", jz4770_mmc2_1bit_e, 2),
1889 	INGENIC_PIN_GROUP("mmc2-4bit-e", jz4770_mmc2_4bit_e, 2),
1890 	INGENIC_PIN_GROUP("nemc-data", jz4770_nemc_8bit_data, 0),
1891 	INGENIC_PIN_GROUP("nemc-cle-ale", jz4770_nemc_cle_ale, 0),
1892 	INGENIC_PIN_GROUP("nemc-addr", jz4770_nemc_addr, 0),
1893 	INGENIC_PIN_GROUP("nemc-rd-we", jz4770_nemc_rd_we, 0),
1894 	INGENIC_PIN_GROUP("nemc-frd-fwe", jz4770_nemc_frd_fwe, 0),
1895 	INGENIC_PIN_GROUP("nemc-wait", jz4770_nemc_wait, 0),
1896 	INGENIC_PIN_GROUP("nemc-cs1", jz4770_nemc_cs1, 0),
1897 	INGENIC_PIN_GROUP("nemc-cs2", jz4770_nemc_cs2, 0),
1898 	INGENIC_PIN_GROUP("nemc-cs3", jz4770_nemc_cs3, 0),
1899 	INGENIC_PIN_GROUP("nemc-cs4", jz4770_nemc_cs4, 0),
1900 	INGENIC_PIN_GROUP("nemc-cs5", jz4770_nemc_cs5, 0),
1901 	INGENIC_PIN_GROUP("nemc-cs6", jz4770_nemc_cs6, 0),
1902 	INGENIC_PIN_GROUP("i2c0-data", jz4770_i2c0, 0),
1903 	INGENIC_PIN_GROUP("i2c1-data", jz4770_i2c1, 0),
1904 	INGENIC_PIN_GROUP("i2c2-data", jz4770_i2c2, 2),
1905 	INGENIC_PIN_GROUP("i2c3-data", jz4780_i2c3, 1),
1906 	INGENIC_PIN_GROUP("i2c4-data-e", jz4780_i2c4_e, 1),
1907 	INGENIC_PIN_GROUP("i2c4-data-f", jz4780_i2c4_f, 1),
1908 	INGENIC_PIN_GROUP("i2s-data-tx", jz4780_i2s_data_tx, 0),
1909 	INGENIC_PIN_GROUP("i2s-data-rx", jz4780_i2s_data_rx, 0),
1910 	INGENIC_PIN_GROUP_FUNCS("i2s-clk-txrx", jz4780_i2s_clk_txrx,
1911 				jz4780_i2s_clk_txrx_funcs),
1912 	INGENIC_PIN_GROUP("i2s-clk-rx", jz4780_i2s_clk_rx, 1),
1913 	INGENIC_PIN_GROUP("i2s-sysclk", jz4780_i2s_sysclk, 2),
1914 	INGENIC_PIN_GROUP("dmic", jz4780_dmic, 1),
1915 	INGENIC_PIN_GROUP("hdmi-ddc", jz4780_hdmi_ddc, 0),
1916 	INGENIC_PIN_GROUP("cim-data", jz4770_cim_8bit, 0),
1917 	INGENIC_PIN_GROUP("cim-data-12bit", jz4770_cim_12bit, 0),
1918 	INGENIC_PIN_GROUP("lcd-8bit", jz4770_lcd_8bit, 0),
1919 	INGENIC_PIN_GROUP("lcd-16bit", jz4770_lcd_16bit, 0),
1920 	INGENIC_PIN_GROUP("lcd-18bit", jz4770_lcd_18bit, 0),
1921 	INGENIC_PIN_GROUP("lcd-24bit", jz4770_lcd_24bit, 0),
1922 	INGENIC_PIN_GROUP("lcd-special", jz4770_lcd_special, 1),
1923 	INGENIC_PIN_GROUP("lcd-generic", jz4770_lcd_generic, 0),
1924 	INGENIC_PIN_GROUP("pwm0", jz4770_pwm_pwm0, 0),
1925 	INGENIC_PIN_GROUP("pwm1", jz4770_pwm_pwm1, 0),
1926 	INGENIC_PIN_GROUP("pwm2", jz4770_pwm_pwm2, 0),
1927 	INGENIC_PIN_GROUP("pwm3", jz4770_pwm_pwm3, 0),
1928 	INGENIC_PIN_GROUP("pwm4", jz4770_pwm_pwm4, 0),
1929 	INGENIC_PIN_GROUP("pwm5", jz4770_pwm_pwm5, 0),
1930 	INGENIC_PIN_GROUP("pwm6", jz4770_pwm_pwm6, 0),
1931 	INGENIC_PIN_GROUP("pwm7", jz4770_pwm_pwm7, 0),
1932 };
1933 
1934 static const char *jz4780_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
1935 static const char *jz4780_uart4_groups[] = { "uart4-data", };
1936 static const char *jz4780_ssi0_groups[] = {
1937 	"ssi0-dt-a-19", "ssi0-dt-a-21", "ssi0-dt-a-28", "ssi0-dt-b", "ssi0-dt-d", "ssi0-dt-e",
1938 	"ssi0-dr-a-20", "ssi0-dr-a-27", "ssi0-dr-b", "ssi0-dr-d", "ssi0-dr-e",
1939 	"ssi0-clk-a", "ssi0-clk-b-5", "ssi0-clk-b-28", "ssi0-clk-d", "ssi0-clk-e",
1940 	"ssi0-gpc-b", "ssi0-gpc-d", "ssi0-gpc-e",
1941 	"ssi0-ce0-a-23", "ssi0-ce0-a-25", "ssi0-ce0-b", "ssi0-ce0-d", "ssi0-ce0-e",
1942 	"ssi0-ce1-b", "ssi0-ce1-d", "ssi0-ce1-e",
1943 };
1944 static const char *jz4780_ssi1_groups[] = {
1945 	"ssi1-dt-b", "ssi1-dt-d", "ssi1-dt-e",
1946 	"ssi1-dr-b", "ssi1-dr-d", "ssi1-dr-e",
1947 	"ssi1-clk-b", "ssi1-clk-d", "ssi1-clk-e",
1948 	"ssi1-gpc-b", "ssi1-gpc-d", "ssi1-gpc-e",
1949 	"ssi1-ce0-b", "ssi1-ce0-d", "ssi1-ce0-e",
1950 	"ssi1-ce1-b", "ssi1-ce1-d", "ssi1-ce1-e",
1951 };
1952 static const char *jz4780_mmc0_groups[] = {
1953 	"mmc0-1bit-a", "mmc0-4bit-a", "mmc0-8bit-a",
1954 	"mmc0-1bit-e", "mmc0-4bit-e",
1955 };
1956 static const char *jz4780_mmc1_groups[] = {
1957 	"mmc1-1bit-d", "mmc1-4bit-d", "mmc1-1bit-e", "mmc1-4bit-e",
1958 };
1959 static const char *jz4780_mmc2_groups[] = {
1960 	"mmc2-1bit-b", "mmc2-4bit-b", "mmc2-1bit-e", "mmc2-4bit-e",
1961 };
1962 static const char *jz4780_nemc_groups[] = {
1963 	"nemc-data", "nemc-cle-ale", "nemc-addr",
1964 	"nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
1965 };
1966 static const char *jz4780_i2c3_groups[] = { "i2c3-data", };
1967 static const char *jz4780_i2c4_groups[] = { "i2c4-data-e", "i2c4-data-f", };
1968 static const char *jz4780_i2s_groups[] = {
1969 	"i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-clk-rx", "i2s-sysclk",
1970 };
1971 static const char *jz4780_dmic_groups[] = { "dmic", };
1972 static const char *jz4780_cim_groups[] = { "cim-data", };
1973 static const char *jz4780_hdmi_ddc_groups[] = { "hdmi-ddc", };
1974 
1975 static const struct pinfunction jz4780_functions[] = {
1976 	INGENIC_PIN_FUNCTION("uart0", jz4770_uart0),
1977 	INGENIC_PIN_FUNCTION("uart1", jz4770_uart1),
1978 	INGENIC_PIN_FUNCTION("uart2", jz4780_uart2),
1979 	INGENIC_PIN_FUNCTION("uart3", jz4770_uart3),
1980 	INGENIC_PIN_FUNCTION("uart4", jz4780_uart4),
1981 	INGENIC_PIN_FUNCTION("ssi0", jz4780_ssi0),
1982 	INGENIC_PIN_FUNCTION("ssi1", jz4780_ssi1),
1983 	INGENIC_PIN_FUNCTION("mmc0", jz4780_mmc0),
1984 	INGENIC_PIN_FUNCTION("mmc1", jz4780_mmc1),
1985 	INGENIC_PIN_FUNCTION("mmc2", jz4780_mmc2),
1986 	INGENIC_PIN_FUNCTION("nemc", jz4780_nemc),
1987 	INGENIC_PIN_FUNCTION("nemc-cs1", jz4770_cs1),
1988 	INGENIC_PIN_FUNCTION("nemc-cs2", jz4770_cs2),
1989 	INGENIC_PIN_FUNCTION("nemc-cs3", jz4770_cs3),
1990 	INGENIC_PIN_FUNCTION("nemc-cs4", jz4770_cs4),
1991 	INGENIC_PIN_FUNCTION("nemc-cs5", jz4770_cs5),
1992 	INGENIC_PIN_FUNCTION("nemc-cs6", jz4770_cs6),
1993 	INGENIC_PIN_FUNCTION("i2c0", jz4770_i2c0),
1994 	INGENIC_PIN_FUNCTION("i2c1", jz4770_i2c1),
1995 	INGENIC_PIN_FUNCTION("i2c2", jz4770_i2c2),
1996 	INGENIC_PIN_FUNCTION("i2c3", jz4780_i2c3),
1997 	INGENIC_PIN_FUNCTION("i2c4", jz4780_i2c4),
1998 	INGENIC_PIN_FUNCTION("i2s", jz4780_i2s),
1999 	INGENIC_PIN_FUNCTION("dmic", jz4780_dmic),
2000 	INGENIC_PIN_FUNCTION("cim", jz4780_cim),
2001 	INGENIC_PIN_FUNCTION("lcd", jz4770_lcd),
2002 	INGENIC_PIN_FUNCTION("pwm0", jz4770_pwm0),
2003 	INGENIC_PIN_FUNCTION("pwm1", jz4770_pwm1),
2004 	INGENIC_PIN_FUNCTION("pwm2", jz4770_pwm2),
2005 	INGENIC_PIN_FUNCTION("pwm3", jz4770_pwm3),
2006 	INGENIC_PIN_FUNCTION("pwm4", jz4770_pwm4),
2007 	INGENIC_PIN_FUNCTION("pwm5", jz4770_pwm5),
2008 	INGENIC_PIN_FUNCTION("pwm6", jz4770_pwm6),
2009 	INGENIC_PIN_FUNCTION("pwm7", jz4770_pwm7),
2010 	INGENIC_PIN_FUNCTION("hdmi-ddc", jz4780_hdmi_ddc),
2011 };
2012 
2013 static const struct ingenic_chip_info jz4780_chip_info = {
2014 	.num_chips = 6,
2015 	.reg_offset = 0x100,
2016 	.version = ID_JZ4780,
2017 	.groups = jz4780_groups,
2018 	.num_groups = ARRAY_SIZE(jz4780_groups),
2019 	.functions = jz4780_functions,
2020 	.num_functions = ARRAY_SIZE(jz4780_functions),
2021 	.pull_ups = jz4780_pull_ups,
2022 	.pull_downs = jz4780_pull_downs,
2023 };
2024 
2025 static const u32 x1000_pull_ups[4] = {
2026 	0xffffffff, 0xfdffffff, 0x0dffffff, 0x0000003f,
2027 };
2028 
2029 static const u32 x1000_pull_downs[4] = {
2030 	0x00000000, 0x02000000, 0x02000000, 0x00000000,
2031 };
2032 
2033 static int x1000_uart0_data_pins[] = { 0x4a, 0x4b, };
2034 static int x1000_uart0_hwflow_pins[] = { 0x4c, 0x4d, };
2035 static int x1000_uart1_data_a_pins[] = { 0x04, 0x05, };
2036 static int x1000_uart1_data_d_pins[] = { 0x62, 0x63, };
2037 static int x1000_uart1_hwflow_pins[] = { 0x64, 0x65, };
2038 static int x1000_uart2_data_a_pins[] = { 0x02, 0x03, };
2039 static int x1000_uart2_data_d_pins[] = { 0x65, 0x64, };
2040 static int x1000_sfc_data_pins[] = { 0x1d, 0x1c, 0x1e, 0x1f, };
2041 static int x1000_sfc_clk_pins[] = { 0x1a, };
2042 static int x1000_sfc_ce_pins[] = { 0x1b, };
2043 static int x1000_ssi_dt_a_22_pins[] = { 0x16, };
2044 static int x1000_ssi_dt_a_29_pins[] = { 0x1d, };
2045 static int x1000_ssi_dt_d_pins[] = { 0x62, };
2046 static int x1000_ssi_dr_a_23_pins[] = { 0x17, };
2047 static int x1000_ssi_dr_a_28_pins[] = { 0x1c, };
2048 static int x1000_ssi_dr_d_pins[] = { 0x63, };
2049 static int x1000_ssi_clk_a_24_pins[] = { 0x18, };
2050 static int x1000_ssi_clk_a_26_pins[] = { 0x1a, };
2051 static int x1000_ssi_clk_d_pins[] = { 0x60, };
2052 static int x1000_ssi_gpc_a_20_pins[] = { 0x14, };
2053 static int x1000_ssi_gpc_a_31_pins[] = { 0x1f, };
2054 static int x1000_ssi_ce0_a_25_pins[] = { 0x19, };
2055 static int x1000_ssi_ce0_a_27_pins[] = { 0x1b, };
2056 static int x1000_ssi_ce0_d_pins[] = { 0x61, };
2057 static int x1000_ssi_ce1_a_21_pins[] = { 0x15, };
2058 static int x1000_ssi_ce1_a_30_pins[] = { 0x1e, };
2059 static int x1000_mmc0_1bit_pins[] = { 0x18, 0x19, 0x17, };
2060 static int x1000_mmc0_4bit_pins[] = { 0x16, 0x15, 0x14, };
2061 static int x1000_mmc0_8bit_pins[] = { 0x13, 0x12, 0x11, 0x10, };
2062 static int x1000_mmc1_1bit_pins[] = { 0x40, 0x41, 0x42, };
2063 static int x1000_mmc1_4bit_pins[] = { 0x43, 0x44, 0x45, };
2064 static int x1000_emc_8bit_data_pins[] = {
2065 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2066 };
2067 static int x1000_emc_16bit_data_pins[] = {
2068 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2069 };
2070 static int x1000_emc_addr_pins[] = {
2071 	0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
2072 	0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
2073 };
2074 static int x1000_emc_rd_we_pins[] = { 0x30, 0x31, };
2075 static int x1000_emc_wait_pins[] = { 0x34, };
2076 static int x1000_emc_cs1_pins[] = { 0x32, };
2077 static int x1000_emc_cs2_pins[] = { 0x33, };
2078 static int x1000_i2c0_pins[] = { 0x38, 0x37, };
2079 static int x1000_i2c1_a_pins[] = { 0x01, 0x00, };
2080 static int x1000_i2c1_c_pins[] = { 0x5b, 0x5a, };
2081 static int x1000_i2c2_pins[] = { 0x61, 0x60, };
2082 static int x1000_i2s_data_tx_pins[] = { 0x24, };
2083 static int x1000_i2s_data_rx_pins[] = { 0x23, };
2084 static int x1000_i2s_clk_txrx_pins[] = { 0x21, 0x22, };
2085 static int x1000_i2s_sysclk_pins[] = { 0x20, };
2086 static int x1000_dmic_if0_pins[] = { 0x35, 0x36, };
2087 static int x1000_dmic_if1_pins[] = { 0x25, };
2088 static int x1000_cim_pins[] = {
2089 	0x08, 0x09, 0x0a, 0x0b,
2090 	0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c,
2091 };
2092 static int x1000_lcd_8bit_pins[] = {
2093 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2094 	0x30, 0x31, 0x32, 0x33, 0x34,
2095 };
2096 static int x1000_lcd_16bit_pins[] = {
2097 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2098 };
2099 static int x1000_pwm_pwm0_pins[] = { 0x59, };
2100 static int x1000_pwm_pwm1_pins[] = { 0x5a, };
2101 static int x1000_pwm_pwm2_pins[] = { 0x5b, };
2102 static int x1000_pwm_pwm3_pins[] = { 0x26, };
2103 static int x1000_pwm_pwm4_pins[] = { 0x58, };
2104 static int x1000_mac_pins[] = {
2105 	0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x26,
2106 };
2107 
2108 static const struct group_desc x1000_groups[] = {
2109 	INGENIC_PIN_GROUP("uart0-data", x1000_uart0_data, 0),
2110 	INGENIC_PIN_GROUP("uart0-hwflow", x1000_uart0_hwflow, 0),
2111 	INGENIC_PIN_GROUP("uart1-data-a", x1000_uart1_data_a, 2),
2112 	INGENIC_PIN_GROUP("uart1-data-d", x1000_uart1_data_d, 1),
2113 	INGENIC_PIN_GROUP("uart1-hwflow", x1000_uart1_hwflow, 1),
2114 	INGENIC_PIN_GROUP("uart2-data-a", x1000_uart2_data_a, 2),
2115 	INGENIC_PIN_GROUP("uart2-data-d", x1000_uart2_data_d, 0),
2116 	INGENIC_PIN_GROUP("sfc-data", x1000_sfc_data, 1),
2117 	INGENIC_PIN_GROUP("sfc-clk", x1000_sfc_clk, 1),
2118 	INGENIC_PIN_GROUP("sfc-ce", x1000_sfc_ce, 1),
2119 	INGENIC_PIN_GROUP("ssi-dt-a-22", x1000_ssi_dt_a_22, 2),
2120 	INGENIC_PIN_GROUP("ssi-dt-a-29", x1000_ssi_dt_a_29, 2),
2121 	INGENIC_PIN_GROUP("ssi-dt-d", x1000_ssi_dt_d, 0),
2122 	INGENIC_PIN_GROUP("ssi-dr-a-23", x1000_ssi_dr_a_23, 2),
2123 	INGENIC_PIN_GROUP("ssi-dr-a-28", x1000_ssi_dr_a_28, 2),
2124 	INGENIC_PIN_GROUP("ssi-dr-d", x1000_ssi_dr_d, 0),
2125 	INGENIC_PIN_GROUP("ssi-clk-a-24", x1000_ssi_clk_a_24, 2),
2126 	INGENIC_PIN_GROUP("ssi-clk-a-26", x1000_ssi_clk_a_26, 2),
2127 	INGENIC_PIN_GROUP("ssi-clk-d", x1000_ssi_clk_d, 0),
2128 	INGENIC_PIN_GROUP("ssi-gpc-a-20", x1000_ssi_gpc_a_20, 2),
2129 	INGENIC_PIN_GROUP("ssi-gpc-a-31", x1000_ssi_gpc_a_31, 2),
2130 	INGENIC_PIN_GROUP("ssi-ce0-a-25", x1000_ssi_ce0_a_25, 2),
2131 	INGENIC_PIN_GROUP("ssi-ce0-a-27", x1000_ssi_ce0_a_27, 2),
2132 	INGENIC_PIN_GROUP("ssi-ce0-d", x1000_ssi_ce0_d, 0),
2133 	INGENIC_PIN_GROUP("ssi-ce1-a-21", x1000_ssi_ce1_a_21, 2),
2134 	INGENIC_PIN_GROUP("ssi-ce1-a-30", x1000_ssi_ce1_a_30, 2),
2135 	INGENIC_PIN_GROUP("mmc0-1bit", x1000_mmc0_1bit, 1),
2136 	INGENIC_PIN_GROUP("mmc0-4bit", x1000_mmc0_4bit, 1),
2137 	INGENIC_PIN_GROUP("mmc0-8bit", x1000_mmc0_8bit, 1),
2138 	INGENIC_PIN_GROUP("mmc1-1bit", x1000_mmc1_1bit, 0),
2139 	INGENIC_PIN_GROUP("mmc1-4bit", x1000_mmc1_4bit, 0),
2140 	INGENIC_PIN_GROUP("emc-8bit-data", x1000_emc_8bit_data, 0),
2141 	INGENIC_PIN_GROUP("emc-16bit-data", x1000_emc_16bit_data, 0),
2142 	INGENIC_PIN_GROUP("emc-addr", x1000_emc_addr, 0),
2143 	INGENIC_PIN_GROUP("emc-rd-we", x1000_emc_rd_we, 0),
2144 	INGENIC_PIN_GROUP("emc-wait", x1000_emc_wait, 0),
2145 	INGENIC_PIN_GROUP("emc-cs1", x1000_emc_cs1, 0),
2146 	INGENIC_PIN_GROUP("emc-cs2", x1000_emc_cs2, 0),
2147 	INGENIC_PIN_GROUP("i2c0-data", x1000_i2c0, 0),
2148 	INGENIC_PIN_GROUP("i2c1-data-a", x1000_i2c1_a, 2),
2149 	INGENIC_PIN_GROUP("i2c1-data-c", x1000_i2c1_c, 0),
2150 	INGENIC_PIN_GROUP("i2c2-data", x1000_i2c2, 1),
2151 	INGENIC_PIN_GROUP("i2s-data-tx", x1000_i2s_data_tx, 1),
2152 	INGENIC_PIN_GROUP("i2s-data-rx", x1000_i2s_data_rx, 1),
2153 	INGENIC_PIN_GROUP("i2s-clk-txrx", x1000_i2s_clk_txrx, 1),
2154 	INGENIC_PIN_GROUP("i2s-sysclk", x1000_i2s_sysclk, 1),
2155 	INGENIC_PIN_GROUP("dmic-if0", x1000_dmic_if0, 0),
2156 	INGENIC_PIN_GROUP("dmic-if1", x1000_dmic_if1, 1),
2157 	INGENIC_PIN_GROUP("cim-data", x1000_cim, 2),
2158 	INGENIC_PIN_GROUP("lcd-8bit", x1000_lcd_8bit, 1),
2159 	INGENIC_PIN_GROUP("lcd-16bit", x1000_lcd_16bit, 1),
2160 	INGENIC_PIN_GROUP("pwm0", x1000_pwm_pwm0, 0),
2161 	INGENIC_PIN_GROUP("pwm1", x1000_pwm_pwm1, 1),
2162 	INGENIC_PIN_GROUP("pwm2", x1000_pwm_pwm2, 1),
2163 	INGENIC_PIN_GROUP("pwm3", x1000_pwm_pwm3, 2),
2164 	INGENIC_PIN_GROUP("pwm4", x1000_pwm_pwm4, 0),
2165 	INGENIC_PIN_GROUP("mac", x1000_mac, 1),
2166 };
2167 
2168 static const char *x1000_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
2169 static const char *x1000_uart1_groups[] = {
2170 	"uart1-data-a", "uart1-data-d", "uart1-hwflow",
2171 };
2172 static const char *x1000_uart2_groups[] = { "uart2-data-a", "uart2-data-d", };
2173 static const char *x1000_sfc_groups[] = { "sfc-data", "sfc-clk", "sfc-ce", };
2174 static const char *x1000_ssi_groups[] = {
2175 	"ssi-dt-a-22", "ssi-dt-a-29", "ssi-dt-d",
2176 	"ssi-dr-a-23", "ssi-dr-a-28", "ssi-dr-d",
2177 	"ssi-clk-a-24", "ssi-clk-a-26", "ssi-clk-d",
2178 	"ssi-gpc-a-20", "ssi-gpc-a-31",
2179 	"ssi-ce0-a-25", "ssi-ce0-a-27", "ssi-ce0-d",
2180 	"ssi-ce1-a-21", "ssi-ce1-a-30",
2181 };
2182 static const char *x1000_mmc0_groups[] = {
2183 	"mmc0-1bit", "mmc0-4bit", "mmc0-8bit",
2184 };
2185 static const char *x1000_mmc1_groups[] = {
2186 	"mmc1-1bit", "mmc1-4bit",
2187 };
2188 static const char *x1000_emc_groups[] = {
2189 	"emc-8bit-data", "emc-16bit-data",
2190 	"emc-addr", "emc-rd-we", "emc-wait",
2191 };
2192 static const char *x1000_cs1_groups[] = { "emc-cs1", };
2193 static const char *x1000_cs2_groups[] = { "emc-cs2", };
2194 static const char *x1000_i2c0_groups[] = { "i2c0-data", };
2195 static const char *x1000_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", };
2196 static const char *x1000_i2c2_groups[] = { "i2c2-data", };
2197 static const char *x1000_i2s_groups[] = {
2198 	"i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-sysclk",
2199 };
2200 static const char *x1000_dmic_groups[] = { "dmic-if0", "dmic-if1", };
2201 static const char *x1000_cim_groups[] = { "cim-data", };
2202 static const char *x1000_lcd_groups[] = { "lcd-8bit", "lcd-16bit", };
2203 static const char *x1000_pwm0_groups[] = { "pwm0", };
2204 static const char *x1000_pwm1_groups[] = { "pwm1", };
2205 static const char *x1000_pwm2_groups[] = { "pwm2", };
2206 static const char *x1000_pwm3_groups[] = { "pwm3", };
2207 static const char *x1000_pwm4_groups[] = { "pwm4", };
2208 static const char *x1000_mac_groups[] = { "mac", };
2209 
2210 static const struct pinfunction x1000_functions[] = {
2211 	INGENIC_PIN_FUNCTION("uart0", x1000_uart0),
2212 	INGENIC_PIN_FUNCTION("uart1", x1000_uart1),
2213 	INGENIC_PIN_FUNCTION("uart2", x1000_uart2),
2214 	INGENIC_PIN_FUNCTION("sfc", x1000_sfc),
2215 	INGENIC_PIN_FUNCTION("ssi", x1000_ssi),
2216 	INGENIC_PIN_FUNCTION("mmc0", x1000_mmc0),
2217 	INGENIC_PIN_FUNCTION("mmc1", x1000_mmc1),
2218 	INGENIC_PIN_FUNCTION("emc", x1000_emc),
2219 	INGENIC_PIN_FUNCTION("emc-cs1", x1000_cs1),
2220 	INGENIC_PIN_FUNCTION("emc-cs2", x1000_cs2),
2221 	INGENIC_PIN_FUNCTION("i2c0", x1000_i2c0),
2222 	INGENIC_PIN_FUNCTION("i2c1", x1000_i2c1),
2223 	INGENIC_PIN_FUNCTION("i2c2", x1000_i2c2),
2224 	INGENIC_PIN_FUNCTION("i2s", x1000_i2s),
2225 	INGENIC_PIN_FUNCTION("dmic", x1000_dmic),
2226 	INGENIC_PIN_FUNCTION("cim", x1000_cim),
2227 	INGENIC_PIN_FUNCTION("lcd", x1000_lcd),
2228 	INGENIC_PIN_FUNCTION("pwm0", x1000_pwm0),
2229 	INGENIC_PIN_FUNCTION("pwm1", x1000_pwm1),
2230 	INGENIC_PIN_FUNCTION("pwm2", x1000_pwm2),
2231 	INGENIC_PIN_FUNCTION("pwm3", x1000_pwm3),
2232 	INGENIC_PIN_FUNCTION("pwm4", x1000_pwm4),
2233 	INGENIC_PIN_FUNCTION("mac", x1000_mac),
2234 };
2235 
2236 static const struct regmap_range x1000_access_ranges[] = {
2237 	regmap_reg_range(0x000, 0x400 - 4),
2238 	regmap_reg_range(0x700, 0x800 - 4),
2239 };
2240 
2241 /* shared with X1500 */
2242 static const struct regmap_access_table x1000_access_table = {
2243 	.yes_ranges = x1000_access_ranges,
2244 	.n_yes_ranges = ARRAY_SIZE(x1000_access_ranges),
2245 };
2246 
2247 static const struct ingenic_chip_info x1000_chip_info = {
2248 	.num_chips = 4,
2249 	.reg_offset = 0x100,
2250 	.version = ID_X1000,
2251 	.groups = x1000_groups,
2252 	.num_groups = ARRAY_SIZE(x1000_groups),
2253 	.functions = x1000_functions,
2254 	.num_functions = ARRAY_SIZE(x1000_functions),
2255 	.pull_ups = x1000_pull_ups,
2256 	.pull_downs = x1000_pull_downs,
2257 	.access_table = &x1000_access_table,
2258 };
2259 
2260 static int x1500_uart0_data_pins[] = { 0x4a, 0x4b, };
2261 static int x1500_uart0_hwflow_pins[] = { 0x4c, 0x4d, };
2262 static int x1500_uart1_data_a_pins[] = { 0x04, 0x05, };
2263 static int x1500_uart1_data_d_pins[] = { 0x62, 0x63, };
2264 static int x1500_uart1_hwflow_pins[] = { 0x64, 0x65, };
2265 static int x1500_uart2_data_a_pins[] = { 0x02, 0x03, };
2266 static int x1500_uart2_data_d_pins[] = { 0x65, 0x64, };
2267 static int x1500_mmc_1bit_pins[] = { 0x18, 0x19, 0x17, };
2268 static int x1500_mmc_4bit_pins[] = { 0x16, 0x15, 0x14, };
2269 static int x1500_i2c0_pins[] = { 0x38, 0x37, };
2270 static int x1500_i2c1_a_pins[] = { 0x01, 0x00, };
2271 static int x1500_i2c1_c_pins[] = { 0x5b, 0x5a, };
2272 static int x1500_i2c2_pins[] = { 0x61, 0x60, };
2273 static int x1500_i2s_data_tx_pins[] = { 0x24, };
2274 static int x1500_i2s_data_rx_pins[] = { 0x23, };
2275 static int x1500_i2s_clk_txrx_pins[] = { 0x21, 0x22, };
2276 static int x1500_i2s_sysclk_pins[] = { 0x20, };
2277 static int x1500_dmic_if0_pins[] = { 0x35, 0x36, };
2278 static int x1500_dmic_if1_pins[] = { 0x25, };
2279 static int x1500_cim_pins[] = {
2280 	0x08, 0x09, 0x0a, 0x0b,
2281 	0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c,
2282 };
2283 static int x1500_pwm_pwm0_pins[] = { 0x59, };
2284 static int x1500_pwm_pwm1_pins[] = { 0x5a, };
2285 static int x1500_pwm_pwm2_pins[] = { 0x5b, };
2286 static int x1500_pwm_pwm3_pins[] = { 0x26, };
2287 static int x1500_pwm_pwm4_pins[] = { 0x58, };
2288 
2289 static const struct group_desc x1500_groups[] = {
2290 	INGENIC_PIN_GROUP("uart0-data", x1500_uart0_data, 0),
2291 	INGENIC_PIN_GROUP("uart0-hwflow", x1500_uart0_hwflow, 0),
2292 	INGENIC_PIN_GROUP("uart1-data-a", x1500_uart1_data_a, 2),
2293 	INGENIC_PIN_GROUP("uart1-data-d", x1500_uart1_data_d, 1),
2294 	INGENIC_PIN_GROUP("uart1-hwflow", x1500_uart1_hwflow, 1),
2295 	INGENIC_PIN_GROUP("uart2-data-a", x1500_uart2_data_a, 2),
2296 	INGENIC_PIN_GROUP("uart2-data-d", x1500_uart2_data_d, 0),
2297 	INGENIC_PIN_GROUP("sfc-data", x1000_sfc_data, 1),
2298 	INGENIC_PIN_GROUP("sfc-clk", x1000_sfc_clk, 1),
2299 	INGENIC_PIN_GROUP("sfc-ce", x1000_sfc_ce, 1),
2300 	INGENIC_PIN_GROUP("mmc-1bit", x1500_mmc_1bit, 1),
2301 	INGENIC_PIN_GROUP("mmc-4bit", x1500_mmc_4bit, 1),
2302 	INGENIC_PIN_GROUP("i2c0-data", x1500_i2c0, 0),
2303 	INGENIC_PIN_GROUP("i2c1-data-a", x1500_i2c1_a, 2),
2304 	INGENIC_PIN_GROUP("i2c1-data-c", x1500_i2c1_c, 0),
2305 	INGENIC_PIN_GROUP("i2c2-data", x1500_i2c2, 1),
2306 	INGENIC_PIN_GROUP("i2s-data-tx", x1500_i2s_data_tx, 1),
2307 	INGENIC_PIN_GROUP("i2s-data-rx", x1500_i2s_data_rx, 1),
2308 	INGENIC_PIN_GROUP("i2s-clk-txrx", x1500_i2s_clk_txrx, 1),
2309 	INGENIC_PIN_GROUP("i2s-sysclk", x1500_i2s_sysclk, 1),
2310 	INGENIC_PIN_GROUP("dmic-if0", x1500_dmic_if0, 0),
2311 	INGENIC_PIN_GROUP("dmic-if1", x1500_dmic_if1, 1),
2312 	INGENIC_PIN_GROUP("cim-data", x1500_cim, 2),
2313 	INGENIC_PIN_GROUP("pwm0", x1500_pwm_pwm0, 0),
2314 	INGENIC_PIN_GROUP("pwm1", x1500_pwm_pwm1, 1),
2315 	INGENIC_PIN_GROUP("pwm2", x1500_pwm_pwm2, 1),
2316 	INGENIC_PIN_GROUP("pwm3", x1500_pwm_pwm3, 2),
2317 	INGENIC_PIN_GROUP("pwm4", x1500_pwm_pwm4, 0),
2318 };
2319 
2320 static const char *x1500_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
2321 static const char *x1500_uart1_groups[] = {
2322 	"uart1-data-a", "uart1-data-d", "uart1-hwflow",
2323 };
2324 static const char *x1500_uart2_groups[] = { "uart2-data-a", "uart2-data-d", };
2325 static const char *x1500_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
2326 static const char *x1500_i2c0_groups[] = { "i2c0-data", };
2327 static const char *x1500_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", };
2328 static const char *x1500_i2c2_groups[] = { "i2c2-data", };
2329 static const char *x1500_i2s_groups[] = {
2330 	"i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-sysclk",
2331 };
2332 static const char *x1500_dmic_groups[] = { "dmic-if0", "dmic-if1", };
2333 static const char *x1500_cim_groups[] = { "cim-data", };
2334 static const char *x1500_pwm0_groups[] = { "pwm0", };
2335 static const char *x1500_pwm1_groups[] = { "pwm1", };
2336 static const char *x1500_pwm2_groups[] = { "pwm2", };
2337 static const char *x1500_pwm3_groups[] = { "pwm3", };
2338 static const char *x1500_pwm4_groups[] = { "pwm4", };
2339 
2340 static const struct pinfunction x1500_functions[] = {
2341 	INGENIC_PIN_FUNCTION("uart0", x1500_uart0),
2342 	INGENIC_PIN_FUNCTION("uart1", x1500_uart1),
2343 	INGENIC_PIN_FUNCTION("uart2", x1500_uart2),
2344 	INGENIC_PIN_FUNCTION("sfc", x1000_sfc),
2345 	INGENIC_PIN_FUNCTION("mmc", x1500_mmc),
2346 	INGENIC_PIN_FUNCTION("i2c0", x1500_i2c0),
2347 	INGENIC_PIN_FUNCTION("i2c1", x1500_i2c1),
2348 	INGENIC_PIN_FUNCTION("i2c2", x1500_i2c2),
2349 	INGENIC_PIN_FUNCTION("i2s", x1500_i2s),
2350 	INGENIC_PIN_FUNCTION("dmic", x1500_dmic),
2351 	INGENIC_PIN_FUNCTION("cim", x1500_cim),
2352 	INGENIC_PIN_FUNCTION("pwm0", x1500_pwm0),
2353 	INGENIC_PIN_FUNCTION("pwm1", x1500_pwm1),
2354 	INGENIC_PIN_FUNCTION("pwm2", x1500_pwm2),
2355 	INGENIC_PIN_FUNCTION("pwm3", x1500_pwm3),
2356 	INGENIC_PIN_FUNCTION("pwm4", x1500_pwm4),
2357 };
2358 
2359 static const struct ingenic_chip_info x1500_chip_info = {
2360 	.num_chips = 4,
2361 	.reg_offset = 0x100,
2362 	.version = ID_X1500,
2363 	.groups = x1500_groups,
2364 	.num_groups = ARRAY_SIZE(x1500_groups),
2365 	.functions = x1500_functions,
2366 	.num_functions = ARRAY_SIZE(x1500_functions),
2367 	.pull_ups = x1000_pull_ups,
2368 	.pull_downs = x1000_pull_downs,
2369 	.access_table = &x1000_access_table,
2370 };
2371 
2372 static const u32 x1600_pull_ups[4] = {
2373 	0xffffffff, 0xdffbf7bf, 0x987e0000, 0x0000003f,
2374 };
2375 
2376 static const u32 x1600_pull_downs[4] = {
2377 	0x00000000, 0x00000000, 0x07000007, 0x00000000,
2378 };
2379 
2380 static int x1600_uart0_data_pins[] = { 0x27, 0x28, };
2381 static int x1600_uart0_hwflow_pins[] = { 0x29, 0x2a, };
2382 static int x1600_uart1_data_pins[] = { 0x23, 0x22, };
2383 static int x1600_uart1_hwflow_pins[] = { 0x25, 0x24, };
2384 static int x1600_uart2_data_a_pins[] = { 0x1f, 0x1e, };
2385 static int x1600_uart2_data_b_pins[] = { 0x21, 0x20, };
2386 static int x1600_uart3_data_b_pins[] = { 0x25, 0x24, };
2387 static int x1600_uart3_data_d_pins[] = { 0x65, 0x64, };
2388 static int x1600_sfc_pins[] = { 0x53, 0x54, 0x55, 0x56, 0x51, 0x52, 0x24, };
2389 static int x1600_ssi_dt_a_pins[] = { 0x1e, };
2390 static int x1600_ssi_dt_b_pins[] = { 0x2d, };
2391 static int x1600_ssi_dr_a_pins[] = { 0x1d, };
2392 static int x1600_ssi_dr_b_pins[] = { 0x2e, };
2393 static int x1600_ssi_clk_a_pins[] = { 0x1f, };
2394 static int x1600_ssi_clk_b_pins[] = { 0x2c, };
2395 static int x1600_ssi_ce0_a_pins[] = { 0x1c, };
2396 static int x1600_ssi_ce0_b_pins[] = { 0x31, };
2397 static int x1600_ssi_ce1_a_pins[] = { 0x22, };
2398 static int x1600_ssi_ce1_b_pins[] = { 0x30, };
2399 static int x1600_mmc0_1bit_b_pins[] = { 0x2c, 0x2d, 0x2e, };
2400 static int x1600_mmc0_4bit_b_pins[] = { 0x2f, 0x30, 0x31, };
2401 static int x1600_mmc0_1bit_c_pins[] = { 0x51, 0x53, 0x54, };
2402 static int x1600_mmc0_4bit_c_pins[] = { 0x56, 0x55, 0x52, };
2403 static int x1600_mmc1_1bit_pins[] = { 0x60, 0x61, 0x62, };
2404 static int x1600_mmc1_4bit_pins[] = { 0x63, 0x64, 0x65, };
2405 static int x1600_i2c0_a_pins[] = { 0x1d, 0x1c, };
2406 static int x1600_i2c0_b_pins[] = { 0x3f, 0x3e, };
2407 static int x1600_i2c1_b_15_pins[] = { 0x30, 0x2f, };
2408 static int x1600_i2c1_b_19_pins[] = { 0x34, 0x33, };
2409 static int x1600_i2s_data_tx_pins[] = { 0x39, };
2410 static int x1600_i2s_data_rx_pins[] = { 0x35, };
2411 static int x1600_i2s_clk_rx_pins[] = { 0x37, 0x38, };
2412 static int x1600_i2s_clk_tx_pins[] = { 0x3b, 0x3c, };
2413 static int x1600_i2s_sysclk_pins[] = { 0x36, 0x3a, };
2414 
2415 static int x1600_cim_pins[] = {
2416 	0x14, 0x16, 0x15, 0x18, 0x13,
2417 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2418 };
2419 
2420 static int x1600_slcd_8bit_pins[] = {
2421 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2422 	0x17, 0x19, 0x1a, 0x1b,
2423 };
2424 
2425 static int x1600_slcd_16bit_pins[] = {
2426 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2427 };
2428 
2429 static int x1600_lcd_16bit_pins[] = {
2430 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2431 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
2432 	0x18, 0x19, 0x1a, 0x1b,
2433 };
2434 
2435 static int x1600_lcd_18bit_pins[] = {
2436 	0x10, 0x11,
2437 };
2438 
2439 static int x1600_lcd_24bit_pins[] = {
2440 	0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
2441 };
2442 
2443 static int x1600_pwm_pwm0_pins[] = { 0x40, };
2444 static int x1600_pwm_pwm1_pins[] = { 0x41, };
2445 static int x1600_pwm_pwm2_pins[] = { 0x42, };
2446 static int x1600_pwm_pwm3_pins[] = { 0x58, };
2447 static int x1600_pwm_pwm4_pins[] = { 0x59, };
2448 static int x1600_pwm_pwm5_b_pins[] = { 0x33, };
2449 static int x1600_pwm_pwm5_c_pins[] = { 0x5a, };
2450 static int x1600_pwm_pwm6_b9_pins[] = { 0x29, };
2451 static int x1600_pwm_pwm6_b20_pins[] = { 0x34, };
2452 static int x1600_pwm_pwm7_b10_pins[] = { 0x2a, };
2453 static int x1600_pwm_pwm7_b21_pins[] = { 0x35, };
2454 
2455 static int x1600_mac_pins[] = {
2456 	0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c,
2457 };
2458 
2459 static int x1600_sfc_funcs[] = { 0, 0, 0, 0, 0, 0, 2, };
2460 
2461 static const struct group_desc x1600_groups[] = {
2462 	INGENIC_PIN_GROUP("uart0-data", x1600_uart0_data, 0),
2463 	INGENIC_PIN_GROUP("uart0-hwflow", x1600_uart0_hwflow, 0),
2464 	INGENIC_PIN_GROUP("uart1-data", x1600_uart1_data, 1),
2465 	INGENIC_PIN_GROUP("uart1-hwflow", x1600_uart1_hwflow, 1),
2466 	INGENIC_PIN_GROUP("uart2-data-a", x1600_uart2_data_a, 2),
2467 	INGENIC_PIN_GROUP("uart2-data-b", x1600_uart2_data_b, 1),
2468 	INGENIC_PIN_GROUP("uart3-data-b", x1600_uart3_data_b, 0),
2469 	INGENIC_PIN_GROUP("uart3-data-d", x1600_uart3_data_d, 2),
2470 	INGENIC_PIN_GROUP_FUNCS("sfc", x1600_sfc, x1600_sfc_funcs),
2471 	INGENIC_PIN_GROUP("ssi-dt-a", x1600_ssi_dt_a, 0),
2472 	INGENIC_PIN_GROUP("ssi-dt-b", x1600_ssi_dt_b, 1),
2473 	INGENIC_PIN_GROUP("ssi-dr-a", x1600_ssi_dr_a, 0),
2474 	INGENIC_PIN_GROUP("ssi-dr-b", x1600_ssi_dr_b, 1),
2475 	INGENIC_PIN_GROUP("ssi-clk-a", x1600_ssi_clk_a, 0),
2476 	INGENIC_PIN_GROUP("ssi-clk-b", x1600_ssi_clk_b, 1),
2477 	INGENIC_PIN_GROUP("ssi-ce0-a", x1600_ssi_ce0_a, 0),
2478 	INGENIC_PIN_GROUP("ssi-ce0-b", x1600_ssi_ce0_b, 1),
2479 	INGENIC_PIN_GROUP("ssi-ce1-a", x1600_ssi_ce1_a, 2),
2480 	INGENIC_PIN_GROUP("ssi-ce1-b", x1600_ssi_ce1_b, 1),
2481 	INGENIC_PIN_GROUP("mmc0-1bit-b", x1600_mmc0_1bit_b, 0),
2482 	INGENIC_PIN_GROUP("mmc0-4bit-b", x1600_mmc0_4bit_b, 0),
2483 	INGENIC_PIN_GROUP("mmc0-1bit-c", x1600_mmc0_1bit_c, 1),
2484 	INGENIC_PIN_GROUP("mmc0-4bit-c", x1600_mmc0_4bit_c, 1),
2485 	INGENIC_PIN_GROUP("mmc1-1bit", x1600_mmc1_1bit, 0),
2486 	INGENIC_PIN_GROUP("mmc1-4bit", x1600_mmc1_4bit, 0),
2487 	INGENIC_PIN_GROUP("i2c0-data-a", x1600_i2c0_a, 2),
2488 	INGENIC_PIN_GROUP("i2c0-data-b", x1600_i2c0_b, 0),
2489 	INGENIC_PIN_GROUP("i2c1-data-b-15", x1600_i2c1_b_15, 2),
2490 	INGENIC_PIN_GROUP("i2c1-data-b-19", x1600_i2c1_b_19, 0),
2491 	INGENIC_PIN_GROUP("i2s-data-tx", x1600_i2s_data_tx, 0),
2492 	INGENIC_PIN_GROUP("i2s-data-rx", x1600_i2s_data_rx, 0),
2493 	INGENIC_PIN_GROUP("i2s-clk-rx", x1600_i2s_clk_rx, 0),
2494 	INGENIC_PIN_GROUP("i2s-clk-tx", x1600_i2s_clk_tx, 0),
2495 	INGENIC_PIN_GROUP("i2s-sysclk", x1600_i2s_sysclk, 0),
2496 	INGENIC_PIN_GROUP("cim-data", x1600_cim, 2),
2497 	INGENIC_PIN_GROUP("slcd-8bit", x1600_slcd_8bit, 1),
2498 	INGENIC_PIN_GROUP("slcd-16bit", x1600_slcd_16bit, 1),
2499 	INGENIC_PIN_GROUP("lcd-16bit", x1600_lcd_16bit, 0),
2500 	INGENIC_PIN_GROUP("lcd-18bit", x1600_lcd_18bit, 0),
2501 	INGENIC_PIN_GROUP("lcd-24bit", x1600_lcd_24bit, 0),
2502 	INGENIC_PIN_GROUP("pwm0", x1600_pwm_pwm0, 0),
2503 	INGENIC_PIN_GROUP("pwm1", x1600_pwm_pwm1, 0),
2504 	INGENIC_PIN_GROUP("pwm2", x1600_pwm_pwm2, 0),
2505 	INGENIC_PIN_GROUP("pwm3", x1600_pwm_pwm3, 1),
2506 	INGENIC_PIN_GROUP("pwm4", x1600_pwm_pwm4, 1),
2507 	INGENIC_PIN_GROUP("pwm5-b", x1600_pwm_pwm5_b, 2),
2508 	INGENIC_PIN_GROUP("pwm5-c", x1600_pwm_pwm5_c, 1),
2509 	INGENIC_PIN_GROUP("pwm6-b9", x1600_pwm_pwm6_b9, 1),
2510 	INGENIC_PIN_GROUP("pwm6-b20", x1600_pwm_pwm6_b20, 2),
2511 	INGENIC_PIN_GROUP("pwm7-b10", x1600_pwm_pwm7_b10, 1),
2512 	INGENIC_PIN_GROUP("pwm7-b21", x1600_pwm_pwm7_b21, 2),
2513 	INGENIC_PIN_GROUP("mac", x1600_mac, 1),
2514 };
2515 
2516 static const char * const x1600_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
2517 static const char * const x1600_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
2518 static const char * const x1600_uart2_groups[] = { "uart2-data-a", "uart2-data-b", };
2519 static const char * const x1600_uart3_groups[] = { "uart3-data-b", "uart3-data-d", };
2520 
2521 static const char * const x1600_sfc_groups[] = { "sfc", };
2522 
2523 static const char * const x1600_ssi_groups[] = {
2524 	"ssi-dt-a", "ssi-dt-b",
2525 	"ssi-dr-a", "ssi-dr-b",
2526 	"ssi-clk-a", "ssi-clk-b",
2527 	"ssi-ce0-a", "ssi-ce0-b",
2528 	"ssi-ce1-a", "ssi-ce1-b",
2529 };
2530 
2531 static const char * const x1600_mmc0_groups[] = { "mmc0-1bit-b", "mmc0-4bit-b",
2532 	"mmc0-1bit-c", "mmc0-4bit-c",
2533 };
2534 
2535 static const char * const x1600_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
2536 
2537 static const char * const x1600_i2c0_groups[] = { "i2c0-data-a", "i2c0-data-b", };
2538 static const char * const x1600_i2c1_groups[] = { "i2c1-data-b-15", "i2c1-data-b-19", };
2539 
2540 static const char * const x1600_i2s_groups[] = {
2541 	"i2s-data-tx", "i2s-data-rx", "i2s-clk-rx", "i2s-clk-tx", "i2s-sysclk",
2542 };
2543 
2544 static const char * const x1600_cim_groups[] = { "cim-data", };
2545 
2546 static const char * const x1600_lcd_groups[] = { "slcd-8bit", "slcd-16bit",
2547 	"lcd-16bit", "lcd-18bit", "lcd-24bit", "lcd-no-pins",
2548 };
2549 
2550 static const char * const x1600_pwm0_groups[] = { "pwm0", };
2551 static const char * const x1600_pwm1_groups[] = { "pwm1", };
2552 static const char * const x1600_pwm2_groups[] = { "pwm2", };
2553 static const char * const x1600_pwm3_groups[] = { "pwm3", };
2554 static const char * const x1600_pwm4_groups[] = { "pwm4", };
2555 static const char * const x1600_pwm5_groups[] = { "pwm5-b", "pwm5-c", };
2556 static const char * const x1600_pwm6_groups[] = { "pwm6-b9", "pwm6-b20", };
2557 static const char * const x1600_pwm7_groups[] = { "pwm7-b10", "pwm7-b21", };
2558 
2559 static const char * const x1600_mac_groups[] = { "mac", };
2560 
2561 static const struct pinfunction x1600_functions[] = {
2562 	INGENIC_PIN_FUNCTION("uart0", x1600_uart0),
2563 	INGENIC_PIN_FUNCTION("uart1", x1600_uart1),
2564 	INGENIC_PIN_FUNCTION("uart2", x1600_uart2),
2565 	INGENIC_PIN_FUNCTION("uart3", x1600_uart3),
2566 	INGENIC_PIN_FUNCTION("sfc", x1600_sfc),
2567 	INGENIC_PIN_FUNCTION("ssi", x1600_ssi),
2568 	INGENIC_PIN_FUNCTION("mmc0", x1600_mmc0),
2569 	INGENIC_PIN_FUNCTION("mmc1", x1600_mmc1),
2570 	INGENIC_PIN_FUNCTION("i2c0", x1600_i2c0),
2571 	INGENIC_PIN_FUNCTION("i2c1", x1600_i2c1),
2572 	INGENIC_PIN_FUNCTION("i2s", x1600_i2s),
2573 	INGENIC_PIN_FUNCTION("cim", x1600_cim),
2574 	INGENIC_PIN_FUNCTION("lcd", x1600_lcd),
2575 	INGENIC_PIN_FUNCTION("pwm0", x1600_pwm0),
2576 	INGENIC_PIN_FUNCTION("pwm1", x1600_pwm1),
2577 	INGENIC_PIN_FUNCTION("pwm2", x1600_pwm2),
2578 	INGENIC_PIN_FUNCTION("pwm3", x1600_pwm3),
2579 	INGENIC_PIN_FUNCTION("pwm4", x1600_pwm4),
2580 	INGENIC_PIN_FUNCTION("pwm5", x1600_pwm5),
2581 	INGENIC_PIN_FUNCTION("pwm6", x1600_pwm6),
2582 	INGENIC_PIN_FUNCTION("pwm7", x1600_pwm7),
2583 	INGENIC_PIN_FUNCTION("mac", x1600_mac),
2584 };
2585 
2586 static const struct ingenic_chip_info x1600_chip_info = {
2587 	.num_chips = 4,
2588 	.reg_offset = 0x100,
2589 	.version = ID_X1600,
2590 	.groups = x1600_groups,
2591 	.num_groups = ARRAY_SIZE(x1600_groups),
2592 	.functions = x1600_functions,
2593 	.num_functions = ARRAY_SIZE(x1600_functions),
2594 	.pull_ups = x1600_pull_ups,
2595 	.pull_downs = x1600_pull_downs,
2596 	.access_table = &x1000_access_table,
2597 };
2598 
2599 static const u32 x1830_pull_ups[4] = {
2600 	0x5fdfffc0, 0xffffefff, 0x1ffffbff, 0x0fcff3fc,
2601 };
2602 
2603 static const u32 x1830_pull_downs[4] = {
2604 	0x5fdfffc0, 0xffffefff, 0x1ffffbff, 0x0fcff3fc,
2605 };
2606 
2607 static int x1830_uart0_data_pins[] = { 0x33, 0x36, };
2608 static int x1830_uart0_hwflow_pins[] = { 0x34, 0x35, };
2609 static int x1830_uart1_data_pins[] = { 0x38, 0x37, };
2610 static int x1830_sfc_data_pins[] = { 0x17, 0x18, 0x1a, 0x19, };
2611 static int x1830_sfc_clk_pins[] = { 0x1b, };
2612 static int x1830_sfc_ce_pins[] = { 0x1c, };
2613 static int x1830_ssi0_dt_pins[] = { 0x4c, };
2614 static int x1830_ssi0_dr_pins[] = { 0x4b, };
2615 static int x1830_ssi0_clk_pins[] = { 0x4f, };
2616 static int x1830_ssi0_gpc_pins[] = { 0x4d, };
2617 static int x1830_ssi0_ce0_pins[] = { 0x50, };
2618 static int x1830_ssi0_ce1_pins[] = { 0x4e, };
2619 static int x1830_ssi1_dt_c_pins[] = { 0x53, };
2620 static int x1830_ssi1_dt_d_pins[] = { 0x62, };
2621 static int x1830_ssi1_dr_c_pins[] = { 0x54, };
2622 static int x1830_ssi1_dr_d_pins[] = { 0x63, };
2623 static int x1830_ssi1_clk_c_pins[] = { 0x57, };
2624 static int x1830_ssi1_clk_d_pins[] = { 0x66, };
2625 static int x1830_ssi1_gpc_c_pins[] = { 0x55, };
2626 static int x1830_ssi1_gpc_d_pins[] = { 0x64, };
2627 static int x1830_ssi1_ce0_c_pins[] = { 0x58, };
2628 static int x1830_ssi1_ce0_d_pins[] = { 0x67, };
2629 static int x1830_ssi1_ce1_c_pins[] = { 0x56, };
2630 static int x1830_ssi1_ce1_d_pins[] = { 0x65, };
2631 static int x1830_mmc0_1bit_pins[] = { 0x24, 0x25, 0x20, };
2632 static int x1830_mmc0_4bit_pins[] = { 0x21, 0x22, 0x23, };
2633 static int x1830_mmc1_1bit_pins[] = { 0x42, 0x43, 0x44, };
2634 static int x1830_mmc1_4bit_pins[] = { 0x45, 0x46, 0x47, };
2635 static int x1830_i2c0_pins[] = { 0x0c, 0x0d, };
2636 static int x1830_i2c1_pins[] = { 0x39, 0x3a, };
2637 static int x1830_i2c2_pins[] = { 0x5b, 0x5c, };
2638 static int x1830_i2s_data_tx_pins[] = { 0x53, };
2639 static int x1830_i2s_data_rx_pins[] = { 0x54, };
2640 static int x1830_i2s_clk_txrx_pins[] = { 0x58, 0x52, };
2641 static int x1830_i2s_clk_rx_pins[] = { 0x56, 0x55, };
2642 static int x1830_i2s_sysclk_pins[] = { 0x57, };
2643 static int x1830_dmic_if0_pins[] = { 0x48, 0x59, };
2644 static int x1830_dmic_if1_pins[] = { 0x5a, };
2645 static int x1830_lcd_tft_8bit_pins[] = {
2646 	0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
2647 	0x68, 0x73, 0x72, 0x69,
2648 };
2649 static int x1830_lcd_tft_24bit_pins[] = {
2650 	0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71,
2651 	0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b,
2652 };
2653 static int x1830_lcd_slcd_8bit_pins[] = {
2654 	0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x6c, 0x6d,
2655 	0x69, 0x72, 0x73, 0x7b, 0x7a,
2656 };
2657 static int x1830_lcd_slcd_16bit_pins[] = {
2658 	0x6e, 0x6f, 0x70, 0x71, 0x76, 0x77, 0x78, 0x79,
2659 };
2660 static int x1830_pwm_pwm0_b_pins[] = { 0x31, };
2661 static int x1830_pwm_pwm0_c_pins[] = { 0x4b, };
2662 static int x1830_pwm_pwm1_b_pins[] = { 0x32, };
2663 static int x1830_pwm_pwm1_c_pins[] = { 0x4c, };
2664 static int x1830_pwm_pwm2_c_8_pins[] = { 0x48, };
2665 static int x1830_pwm_pwm2_c_13_pins[] = { 0x4d, };
2666 static int x1830_pwm_pwm3_c_9_pins[] = { 0x49, };
2667 static int x1830_pwm_pwm3_c_14_pins[] = { 0x4e, };
2668 static int x1830_pwm_pwm4_c_15_pins[] = { 0x4f, };
2669 static int x1830_pwm_pwm4_c_25_pins[] = { 0x59, };
2670 static int x1830_pwm_pwm5_c_16_pins[] = { 0x50, };
2671 static int x1830_pwm_pwm5_c_26_pins[] = { 0x5a, };
2672 static int x1830_pwm_pwm6_c_17_pins[] = { 0x51, };
2673 static int x1830_pwm_pwm6_c_27_pins[] = { 0x5b, };
2674 static int x1830_pwm_pwm7_c_18_pins[] = { 0x52, };
2675 static int x1830_pwm_pwm7_c_28_pins[] = { 0x5c, };
2676 static int x1830_mac_pins[] = {
2677 	0x29, 0x30, 0x2f, 0x28, 0x2e, 0x2d, 0x2a, 0x2b, 0x26, 0x27,
2678 };
2679 
2680 static const struct group_desc x1830_groups[] = {
2681 	INGENIC_PIN_GROUP("uart0-data", x1830_uart0_data, 0),
2682 	INGENIC_PIN_GROUP("uart0-hwflow", x1830_uart0_hwflow, 0),
2683 	INGENIC_PIN_GROUP("uart1-data", x1830_uart1_data, 0),
2684 	INGENIC_PIN_GROUP("sfc-data", x1830_sfc_data, 1),
2685 	INGENIC_PIN_GROUP("sfc-clk", x1830_sfc_clk, 1),
2686 	INGENIC_PIN_GROUP("sfc-ce", x1830_sfc_ce, 1),
2687 	INGENIC_PIN_GROUP("ssi0-dt", x1830_ssi0_dt, 0),
2688 	INGENIC_PIN_GROUP("ssi0-dr", x1830_ssi0_dr, 0),
2689 	INGENIC_PIN_GROUP("ssi0-clk", x1830_ssi0_clk, 0),
2690 	INGENIC_PIN_GROUP("ssi0-gpc", x1830_ssi0_gpc, 0),
2691 	INGENIC_PIN_GROUP("ssi0-ce0", x1830_ssi0_ce0, 0),
2692 	INGENIC_PIN_GROUP("ssi0-ce1", x1830_ssi0_ce1, 0),
2693 	INGENIC_PIN_GROUP("ssi1-dt-c", x1830_ssi1_dt_c, 1),
2694 	INGENIC_PIN_GROUP("ssi1-dr-c", x1830_ssi1_dr_c, 1),
2695 	INGENIC_PIN_GROUP("ssi1-clk-c", x1830_ssi1_clk_c, 1),
2696 	INGENIC_PIN_GROUP("ssi1-gpc-c", x1830_ssi1_gpc_c, 1),
2697 	INGENIC_PIN_GROUP("ssi1-ce0-c", x1830_ssi1_ce0_c, 1),
2698 	INGENIC_PIN_GROUP("ssi1-ce1-c", x1830_ssi1_ce1_c, 1),
2699 	INGENIC_PIN_GROUP("ssi1-dt-d", x1830_ssi1_dt_d, 2),
2700 	INGENIC_PIN_GROUP("ssi1-dr-d", x1830_ssi1_dr_d, 2),
2701 	INGENIC_PIN_GROUP("ssi1-clk-d", x1830_ssi1_clk_d, 2),
2702 	INGENIC_PIN_GROUP("ssi1-gpc-d", x1830_ssi1_gpc_d, 2),
2703 	INGENIC_PIN_GROUP("ssi1-ce0-d", x1830_ssi1_ce0_d, 2),
2704 	INGENIC_PIN_GROUP("ssi1-ce1-d", x1830_ssi1_ce1_d, 2),
2705 	INGENIC_PIN_GROUP("mmc0-1bit", x1830_mmc0_1bit, 0),
2706 	INGENIC_PIN_GROUP("mmc0-4bit", x1830_mmc0_4bit, 0),
2707 	INGENIC_PIN_GROUP("mmc1-1bit", x1830_mmc1_1bit, 0),
2708 	INGENIC_PIN_GROUP("mmc1-4bit", x1830_mmc1_4bit, 0),
2709 	INGENIC_PIN_GROUP("i2c0-data", x1830_i2c0, 1),
2710 	INGENIC_PIN_GROUP("i2c1-data", x1830_i2c1, 0),
2711 	INGENIC_PIN_GROUP("i2c2-data", x1830_i2c2, 1),
2712 	INGENIC_PIN_GROUP("i2s-data-tx", x1830_i2s_data_tx, 0),
2713 	INGENIC_PIN_GROUP("i2s-data-rx", x1830_i2s_data_rx, 0),
2714 	INGENIC_PIN_GROUP("i2s-clk-txrx", x1830_i2s_clk_txrx, 0),
2715 	INGENIC_PIN_GROUP("i2s-clk-rx", x1830_i2s_clk_rx, 0),
2716 	INGENIC_PIN_GROUP("i2s-sysclk", x1830_i2s_sysclk, 0),
2717 	INGENIC_PIN_GROUP("dmic-if0", x1830_dmic_if0, 2),
2718 	INGENIC_PIN_GROUP("dmic-if1", x1830_dmic_if1, 2),
2719 	INGENIC_PIN_GROUP("lcd-tft-8bit", x1830_lcd_tft_8bit, 0),
2720 	INGENIC_PIN_GROUP("lcd-tft-24bit", x1830_lcd_tft_24bit, 0),
2721 	INGENIC_PIN_GROUP("lcd-slcd-8bit", x1830_lcd_slcd_8bit, 1),
2722 	INGENIC_PIN_GROUP("lcd-slcd-16bit", x1830_lcd_slcd_16bit, 1),
2723 	INGENIC_PIN_GROUP("pwm0-b", x1830_pwm_pwm0_b, 0),
2724 	INGENIC_PIN_GROUP("pwm0-c", x1830_pwm_pwm0_c, 1),
2725 	INGENIC_PIN_GROUP("pwm1-b", x1830_pwm_pwm1_b, 0),
2726 	INGENIC_PIN_GROUP("pwm1-c", x1830_pwm_pwm1_c, 1),
2727 	INGENIC_PIN_GROUP("pwm2-c-8", x1830_pwm_pwm2_c_8, 0),
2728 	INGENIC_PIN_GROUP("pwm2-c-13", x1830_pwm_pwm2_c_13, 1),
2729 	INGENIC_PIN_GROUP("pwm3-c-9", x1830_pwm_pwm3_c_9, 0),
2730 	INGENIC_PIN_GROUP("pwm3-c-14", x1830_pwm_pwm3_c_14, 1),
2731 	INGENIC_PIN_GROUP("pwm4-c-15", x1830_pwm_pwm4_c_15, 1),
2732 	INGENIC_PIN_GROUP("pwm4-c-25", x1830_pwm_pwm4_c_25, 0),
2733 	INGENIC_PIN_GROUP("pwm5-c-16", x1830_pwm_pwm5_c_16, 1),
2734 	INGENIC_PIN_GROUP("pwm5-c-26", x1830_pwm_pwm5_c_26, 0),
2735 	INGENIC_PIN_GROUP("pwm6-c-17", x1830_pwm_pwm6_c_17, 1),
2736 	INGENIC_PIN_GROUP("pwm6-c-27", x1830_pwm_pwm6_c_27, 0),
2737 	INGENIC_PIN_GROUP("pwm7-c-18", x1830_pwm_pwm7_c_18, 1),
2738 	INGENIC_PIN_GROUP("pwm7-c-28", x1830_pwm_pwm7_c_28, 0),
2739 	INGENIC_PIN_GROUP("mac", x1830_mac, 0),
2740 };
2741 
2742 static const char *x1830_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
2743 static const char *x1830_uart1_groups[] = { "uart1-data", };
2744 static const char *x1830_sfc_groups[] = { "sfc-data", "sfc-clk", "sfc-ce", };
2745 static const char *x1830_ssi0_groups[] = {
2746 	"ssi0-dt", "ssi0-dr", "ssi0-clk", "ssi0-gpc", "ssi0-ce0", "ssi0-ce1",
2747 };
2748 static const char *x1830_ssi1_groups[] = {
2749 	"ssi1-dt-c", "ssi1-dt-d",
2750 	"ssi1-dr-c", "ssi1-dr-d",
2751 	"ssi1-clk-c", "ssi1-clk-d",
2752 	"ssi1-gpc-c", "ssi1-gpc-d",
2753 	"ssi1-ce0-c", "ssi1-ce0-d",
2754 	"ssi1-ce1-c", "ssi1-ce1-d",
2755 };
2756 static const char *x1830_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", };
2757 static const char *x1830_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
2758 static const char *x1830_i2c0_groups[] = { "i2c0-data", };
2759 static const char *x1830_i2c1_groups[] = { "i2c1-data", };
2760 static const char *x1830_i2c2_groups[] = { "i2c2-data", };
2761 static const char *x1830_i2s_groups[] = {
2762 	"i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-clk-rx", "i2s-sysclk",
2763 };
2764 static const char *x1830_dmic_groups[] = { "dmic-if0", "dmic-if1", };
2765 static const char *x1830_lcd_groups[] = {
2766 	"lcd-tft-8bit", "lcd-tft-24bit", "lcd-slcd-8bit", "lcd-slcd-16bit",
2767 };
2768 static const char *x1830_pwm0_groups[] = { "pwm0-b", "pwm0-c", };
2769 static const char *x1830_pwm1_groups[] = { "pwm1-b", "pwm1-c", };
2770 static const char *x1830_pwm2_groups[] = { "pwm2-c-8", "pwm2-c-13", };
2771 static const char *x1830_pwm3_groups[] = { "pwm3-c-9", "pwm3-c-14", };
2772 static const char *x1830_pwm4_groups[] = { "pwm4-c-15", "pwm4-c-25", };
2773 static const char *x1830_pwm5_groups[] = { "pwm5-c-16", "pwm5-c-26", };
2774 static const char *x1830_pwm6_groups[] = { "pwm6-c-17", "pwm6-c-27", };
2775 static const char *x1830_pwm7_groups[] = { "pwm7-c-18", "pwm7-c-28", };
2776 static const char *x1830_mac_groups[] = { "mac", };
2777 
2778 static const struct pinfunction x1830_functions[] = {
2779 	INGENIC_PIN_FUNCTION("uart0", x1830_uart0),
2780 	INGENIC_PIN_FUNCTION("uart1", x1830_uart1),
2781 	INGENIC_PIN_FUNCTION("sfc", x1830_sfc),
2782 	INGENIC_PIN_FUNCTION("ssi0", x1830_ssi0),
2783 	INGENIC_PIN_FUNCTION("ssi1", x1830_ssi1),
2784 	INGENIC_PIN_FUNCTION("mmc0", x1830_mmc0),
2785 	INGENIC_PIN_FUNCTION("mmc1", x1830_mmc1),
2786 	INGENIC_PIN_FUNCTION("i2c0", x1830_i2c0),
2787 	INGENIC_PIN_FUNCTION("i2c1", x1830_i2c1),
2788 	INGENIC_PIN_FUNCTION("i2c2", x1830_i2c2),
2789 	INGENIC_PIN_FUNCTION("i2s", x1830_i2s),
2790 	INGENIC_PIN_FUNCTION("dmic", x1830_dmic),
2791 	INGENIC_PIN_FUNCTION("lcd", x1830_lcd),
2792 	INGENIC_PIN_FUNCTION("pwm0", x1830_pwm0),
2793 	INGENIC_PIN_FUNCTION("pwm1", x1830_pwm1),
2794 	INGENIC_PIN_FUNCTION("pwm2", x1830_pwm2),
2795 	INGENIC_PIN_FUNCTION("pwm3", x1830_pwm3),
2796 	INGENIC_PIN_FUNCTION("pwm4", x1830_pwm4),
2797 	INGENIC_PIN_FUNCTION("pwm5", x1830_pwm5),
2798 	INGENIC_PIN_FUNCTION("pwm6", x1830_pwm6),
2799 	INGENIC_PIN_FUNCTION("pwm7", x1830_pwm7),
2800 	INGENIC_PIN_FUNCTION("mac", x1830_mac),
2801 };
2802 
2803 static const struct regmap_range x1830_access_ranges[] = {
2804 	regmap_reg_range(0x0000, 0x4000 - 4),
2805 	regmap_reg_range(0x7000, 0x8000 - 4),
2806 };
2807 
2808 static const struct regmap_access_table x1830_access_table = {
2809 	.yes_ranges = x1830_access_ranges,
2810 	.n_yes_ranges = ARRAY_SIZE(x1830_access_ranges),
2811 };
2812 
2813 static const struct ingenic_chip_info x1830_chip_info = {
2814 	.num_chips = 4,
2815 	.reg_offset = 0x1000,
2816 	.version = ID_X1830,
2817 	.groups = x1830_groups,
2818 	.num_groups = ARRAY_SIZE(x1830_groups),
2819 	.functions = x1830_functions,
2820 	.num_functions = ARRAY_SIZE(x1830_functions),
2821 	.pull_ups = x1830_pull_ups,
2822 	.pull_downs = x1830_pull_downs,
2823 	.access_table = &x1830_access_table,
2824 };
2825 
2826 static const u32 x2000_pull_ups[5] = {
2827 	0x0003ffff, 0xffffffff, 0x1ff0ffff, 0xc7fe3f3f, 0x8fff003f,
2828 };
2829 
2830 static const u32 x2000_pull_downs[5] = {
2831 	0x0003ffff, 0xffffffff, 0x1ff0ffff, 0x00000000, 0x8fff003f,
2832 };
2833 
2834 static int x2000_uart0_data_pins[] = { 0x77, 0x78, };
2835 static int x2000_uart0_hwflow_pins[] = { 0x79, 0x7a, };
2836 static int x2000_uart1_data_pins[] = { 0x57, 0x58, };
2837 static int x2000_uart1_hwflow_pins[] = { 0x55, 0x56, };
2838 static int x2000_uart2_data_pins[] = { 0x7e, 0x7f, };
2839 static int x2000_uart3_data_c_pins[] = { 0x59, 0x5a, };
2840 static int x2000_uart3_data_d_pins[] = { 0x62, 0x63, };
2841 static int x2000_uart3_hwflow_c_pins[] = { 0x5b, 0x5c, };
2842 static int x2000_uart3_hwflow_d_pins[] = { 0x60, 0x61, };
2843 static int x2000_uart4_data_a_pins[] = { 0x02, 0x03, };
2844 static int x2000_uart4_data_c_pins[] = { 0x4b, 0x4c, };
2845 static int x2000_uart4_hwflow_a_pins[] = { 0x00, 0x01, };
2846 static int x2000_uart4_hwflow_c_pins[] = { 0x49, 0x4a, };
2847 static int x2000_uart5_data_a_pins[] = { 0x04, 0x05, };
2848 static int x2000_uart5_data_c_pins[] = { 0x45, 0x46, };
2849 static int x2000_uart6_data_a_pins[] = { 0x06, 0x07, };
2850 static int x2000_uart6_data_c_pins[] = { 0x47, 0x48, };
2851 static int x2000_uart7_data_a_pins[] = { 0x08, 0x09, };
2852 static int x2000_uart7_data_c_pins[] = { 0x41, 0x42, };
2853 static int x2000_uart8_data_pins[] = { 0x3c, 0x3d, };
2854 static int x2000_uart9_data_pins[] = { 0x3e, 0x3f, };
2855 static int x2000_sfc_data_if0_d_pins[] = { 0x73, 0x74, 0x75, 0x76, };
2856 static int x2000_sfc_data_if0_e_pins[] = { 0x92, 0x93, 0x94, 0x95, };
2857 static int x2000_sfc_data_if1_pins[] = { 0x77, 0x78, 0x79, 0x7a, };
2858 static int x2000_sfc_clk_d_pins[] = { 0x71, };
2859 static int x2000_sfc_clk_e_pins[] = { 0x90, };
2860 static int x2000_sfc_ce_d_pins[] = { 0x72, };
2861 static int x2000_sfc_ce_e_pins[] = { 0x91, };
2862 static int x2000_ssi0_dt_b_pins[] = { 0x3e, };
2863 static int x2000_ssi0_dt_d_pins[] = { 0x69, };
2864 static int x2000_ssi0_dr_b_pins[] = { 0x3d, };
2865 static int x2000_ssi0_dr_d_pins[] = { 0x6a, };
2866 static int x2000_ssi0_clk_b_pins[] = { 0x3f, };
2867 static int x2000_ssi0_clk_d_pins[] = { 0x68, };
2868 static int x2000_ssi0_ce_b_pins[] = { 0x3c, };
2869 static int x2000_ssi0_ce_d_pins[] = { 0x6d, };
2870 static int x2000_ssi1_dt_c_pins[] = { 0x4b, };
2871 static int x2000_ssi1_dt_d_pins[] = { 0x72, };
2872 static int x2000_ssi1_dt_e_pins[] = { 0x91, };
2873 static int x2000_ssi1_dr_c_pins[] = { 0x4a, };
2874 static int x2000_ssi1_dr_d_pins[] = { 0x73, };
2875 static int x2000_ssi1_dr_e_pins[] = { 0x92, };
2876 static int x2000_ssi1_clk_c_pins[] = { 0x4c, };
2877 static int x2000_ssi1_clk_d_pins[] = { 0x71, };
2878 static int x2000_ssi1_clk_e_pins[] = { 0x90, };
2879 static int x2000_ssi1_ce_c_pins[] = { 0x49, };
2880 static int x2000_ssi1_ce_d_pins[] = { 0x76, };
2881 static int x2000_ssi1_ce_e_pins[] = { 0x95, };
2882 static int x2000_mmc0_1bit_pins[] = { 0x71, 0x72, 0x73, };
2883 static int x2000_mmc0_4bit_pins[] = { 0x74, 0x75, 0x75, };
2884 static int x2000_mmc0_8bit_pins[] = { 0x77, 0x78, 0x79, 0x7a, };
2885 static int x2000_mmc1_1bit_pins[] = { 0x68, 0x69, 0x6a, };
2886 static int x2000_mmc1_4bit_pins[] = { 0x6b, 0x6c, 0x6d, };
2887 static int x2000_mmc2_1bit_pins[] = { 0x80, 0x81, 0x82, };
2888 static int x2000_mmc2_4bit_pins[] = { 0x83, 0x84, 0x85, };
2889 static int x2000_emc_8bit_data_pins[] = {
2890 	0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2891 };
2892 static int x2000_emc_16bit_data_pins[] = {
2893 	0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
2894 };
2895 static int x2000_emc_addr_pins[] = {
2896 	0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
2897 	0x28, 0x29, 0x2a, 0x2b, 0x2c,
2898 };
2899 static int x2000_emc_rd_we_pins[] = { 0x2d, 0x2e, };
2900 static int x2000_emc_wait_pins[] = { 0x2f, };
2901 static int x2000_emc_cs1_pins[] = { 0x57, };
2902 static int x2000_emc_cs2_pins[] = { 0x58, };
2903 static int x2000_i2c0_pins[] = { 0x4e, 0x4d, };
2904 static int x2000_i2c1_c_pins[] = { 0x58, 0x57, };
2905 static int x2000_i2c1_d_pins[] = { 0x6c, 0x6b, };
2906 static int x2000_i2c2_b_pins[] = { 0x37, 0x36, };
2907 static int x2000_i2c2_d_pins[] = { 0x75, 0x74, };
2908 static int x2000_i2c2_e_pins[] = { 0x94, 0x93, };
2909 static int x2000_i2c3_a_pins[] = { 0x11, 0x10, };
2910 static int x2000_i2c3_d_pins[] = { 0x7f, 0x7e, };
2911 static int x2000_i2c4_c_pins[] = { 0x5a, 0x59, };
2912 static int x2000_i2c4_d_pins[] = { 0x61, 0x60, };
2913 static int x2000_i2c5_c_pins[] = { 0x5c, 0x5b, };
2914 static int x2000_i2c5_d_pins[] = { 0x65, 0x64, };
2915 static int x2000_i2s1_data_tx_pins[] = { 0x47, };
2916 static int x2000_i2s1_data_rx_pins[] = { 0x44, };
2917 static int x2000_i2s1_clk_tx_pins[] = { 0x45, 0x46, };
2918 static int x2000_i2s1_clk_rx_pins[] = { 0x42, 0x43, };
2919 static int x2000_i2s1_sysclk_tx_pins[] = { 0x48, };
2920 static int x2000_i2s1_sysclk_rx_pins[] = { 0x41, };
2921 static int x2000_i2s2_data_rx0_pins[] = { 0x0a, };
2922 static int x2000_i2s2_data_rx1_pins[] = { 0x0b, };
2923 static int x2000_i2s2_data_rx2_pins[] = { 0x0c, };
2924 static int x2000_i2s2_data_rx3_pins[] = { 0x0d, };
2925 static int x2000_i2s2_clk_rx_pins[] = { 0x11, 0x09, };
2926 static int x2000_i2s2_sysclk_rx_pins[] = { 0x07, };
2927 static int x2000_i2s3_data_tx0_pins[] = { 0x03, };
2928 static int x2000_i2s3_data_tx1_pins[] = { 0x04, };
2929 static int x2000_i2s3_data_tx2_pins[] = { 0x05, };
2930 static int x2000_i2s3_data_tx3_pins[] = { 0x06, };
2931 static int x2000_i2s3_clk_tx_pins[] = { 0x10, 0x02, };
2932 static int x2000_i2s3_sysclk_tx_pins[] = { 0x00, };
2933 static int x2000_dmic_if0_pins[] = { 0x54, 0x55, };
2934 static int x2000_dmic_if1_pins[] = { 0x56, };
2935 static int x2000_dmic_if2_pins[] = { 0x57, };
2936 static int x2000_dmic_if3_pins[] = { 0x58, };
2937 static int x2000_cim_8bit_pins[] = {
2938 	0x0e, 0x0c, 0x0d, 0x4f,
2939 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2940 };
2941 static int x2000_cim_12bit_pins[] = { 0x08, 0x09, 0x0a, 0x0b, };
2942 static int x2000_lcd_tft_8bit_pins[] = {
2943 	0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
2944 	0x38, 0x3a, 0x39, 0x3b,
2945 };
2946 static int x2000_lcd_tft_16bit_pins[] = {
2947 	0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
2948 };
2949 static int x2000_lcd_tft_18bit_pins[] = {
2950 	0x30, 0x31,
2951 };
2952 static int x2000_lcd_tft_24bit_pins[] = {
2953 	0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2954 };
2955 static int x2000_lcd_slcd_8bit_pins[] = {
2956 	0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
2957 	0x3a, 0x38, 0x3b, 0x30, 0x39,
2958 };
2959 static int x2000_pwm_pwm0_c_pins[] = { 0x40, };
2960 static int x2000_pwm_pwm0_d_pins[] = { 0x7e, };
2961 static int x2000_pwm_pwm1_c_pins[] = { 0x41, };
2962 static int x2000_pwm_pwm1_d_pins[] = { 0x7f, };
2963 static int x2000_pwm_pwm2_c_pins[] = { 0x42, };
2964 static int x2000_pwm_pwm2_e_pins[] = { 0x80, };
2965 static int x2000_pwm_pwm3_c_pins[] = { 0x43, };
2966 static int x2000_pwm_pwm3_e_pins[] = { 0x81, };
2967 static int x2000_pwm_pwm4_c_pins[] = { 0x44, };
2968 static int x2000_pwm_pwm4_e_pins[] = { 0x82, };
2969 static int x2000_pwm_pwm5_c_pins[] = { 0x45, };
2970 static int x2000_pwm_pwm5_e_pins[] = { 0x83, };
2971 static int x2000_pwm_pwm6_c_pins[] = { 0x46, };
2972 static int x2000_pwm_pwm6_e_pins[] = { 0x84, };
2973 static int x2000_pwm_pwm7_c_pins[] = { 0x47, };
2974 static int x2000_pwm_pwm7_e_pins[] = { 0x85, };
2975 static int x2000_pwm_pwm8_pins[] = { 0x48, };
2976 static int x2000_pwm_pwm9_pins[] = { 0x49, };
2977 static int x2000_pwm_pwm10_pins[] = { 0x4a, };
2978 static int x2000_pwm_pwm11_pins[] = { 0x4b, };
2979 static int x2000_pwm_pwm12_pins[] = { 0x4c, };
2980 static int x2000_pwm_pwm13_pins[] = { 0x4d, };
2981 static int x2000_pwm_pwm14_pins[] = { 0x4e, };
2982 static int x2000_pwm_pwm15_pins[] = { 0x4f, };
2983 static int x2000_mac0_rmii_pins[] = {
2984 	0x4b, 0x47, 0x46, 0x4a, 0x43, 0x42, 0x4c, 0x4d, 0x4e, 0x41,
2985 };
2986 static int x2000_mac0_rgmii_pins[] = {
2987 	0x4b, 0x49, 0x48, 0x47, 0x46, 0x4a, 0x45, 0x44, 0x43, 0x42,
2988 	0x4c, 0x4d, 0x4f, 0x4e, 0x41,
2989 };
2990 static int x2000_mac1_rmii_pins[] = {
2991 	0x32, 0x2d, 0x2c, 0x31, 0x29, 0x28, 0x33, 0x34, 0x35, 0x37,
2992 };
2993 static int x2000_mac1_rgmii_pins[] = {
2994 	0x32, 0x2f, 0x2e, 0x2d, 0x2c, 0x31, 0x2b, 0x2a, 0x29, 0x28,
2995 	0x33, 0x34, 0x36, 0x35, 0x37,
2996 };
2997 static int x2000_otg_pins[] = { 0x96, };
2998 
2999 static u8 x2000_cim_8bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, };
3000 
3001 static const struct group_desc x2000_groups[] = {
3002 	INGENIC_PIN_GROUP("uart0-data", x2000_uart0_data, 2),
3003 	INGENIC_PIN_GROUP("uart0-hwflow", x2000_uart0_hwflow, 2),
3004 	INGENIC_PIN_GROUP("uart1-data", x2000_uart1_data, 1),
3005 	INGENIC_PIN_GROUP("uart1-hwflow", x2000_uart1_hwflow, 1),
3006 	INGENIC_PIN_GROUP("uart2-data", x2000_uart2_data, 0),
3007 	INGENIC_PIN_GROUP("uart3-data-c", x2000_uart3_data_c, 0),
3008 	INGENIC_PIN_GROUP("uart3-data-d", x2000_uart3_data_d, 1),
3009 	INGENIC_PIN_GROUP("uart3-hwflow-c", x2000_uart3_hwflow_c, 0),
3010 	INGENIC_PIN_GROUP("uart3-hwflow-d", x2000_uart3_hwflow_d, 1),
3011 	INGENIC_PIN_GROUP("uart4-data-a", x2000_uart4_data_a, 1),
3012 	INGENIC_PIN_GROUP("uart4-data-c", x2000_uart4_data_c, 3),
3013 	INGENIC_PIN_GROUP("uart4-hwflow-a", x2000_uart4_hwflow_a, 1),
3014 	INGENIC_PIN_GROUP("uart4-hwflow-c", x2000_uart4_hwflow_c, 3),
3015 	INGENIC_PIN_GROUP("uart5-data-a", x2000_uart5_data_a, 1),
3016 	INGENIC_PIN_GROUP("uart5-data-c", x2000_uart5_data_c, 3),
3017 	INGENIC_PIN_GROUP("uart6-data-a", x2000_uart6_data_a, 1),
3018 	INGENIC_PIN_GROUP("uart6-data-c", x2000_uart6_data_c, 3),
3019 	INGENIC_PIN_GROUP("uart7-data-a", x2000_uart7_data_a, 1),
3020 	INGENIC_PIN_GROUP("uart7-data-c", x2000_uart7_data_c, 3),
3021 	INGENIC_PIN_GROUP("uart8-data", x2000_uart8_data, 3),
3022 	INGENIC_PIN_GROUP("uart9-data", x2000_uart9_data, 3),
3023 	INGENIC_PIN_GROUP("sfc-data-if0-d", x2000_sfc_data_if0_d, 1),
3024 	INGENIC_PIN_GROUP("sfc-data-if0-e", x2000_sfc_data_if0_e, 0),
3025 	INGENIC_PIN_GROUP("sfc-data-if1", x2000_sfc_data_if1, 1),
3026 	INGENIC_PIN_GROUP("sfc-clk-d", x2000_sfc_clk_d, 1),
3027 	INGENIC_PIN_GROUP("sfc-clk-e", x2000_sfc_clk_e, 0),
3028 	INGENIC_PIN_GROUP("sfc-ce-d", x2000_sfc_ce_d, 1),
3029 	INGENIC_PIN_GROUP("sfc-ce-e", x2000_sfc_ce_e, 0),
3030 	INGENIC_PIN_GROUP("ssi0-dt-b", x2000_ssi0_dt_b, 1),
3031 	INGENIC_PIN_GROUP("ssi0-dt-d", x2000_ssi0_dt_d, 1),
3032 	INGENIC_PIN_GROUP("ssi0-dr-b", x2000_ssi0_dr_b, 1),
3033 	INGENIC_PIN_GROUP("ssi0-dr-d", x2000_ssi0_dr_d, 1),
3034 	INGENIC_PIN_GROUP("ssi0-clk-b", x2000_ssi0_clk_b, 1),
3035 	INGENIC_PIN_GROUP("ssi0-clk-d", x2000_ssi0_clk_d, 1),
3036 	INGENIC_PIN_GROUP("ssi0-ce-b", x2000_ssi0_ce_b, 1),
3037 	INGENIC_PIN_GROUP("ssi0-ce-d", x2000_ssi0_ce_d, 1),
3038 	INGENIC_PIN_GROUP("ssi1-dt-c", x2000_ssi1_dt_c, 2),
3039 	INGENIC_PIN_GROUP("ssi1-dt-d", x2000_ssi1_dt_d, 2),
3040 	INGENIC_PIN_GROUP("ssi1-dt-e", x2000_ssi1_dt_e, 1),
3041 	INGENIC_PIN_GROUP("ssi1-dr-c", x2000_ssi1_dr_c, 2),
3042 	INGENIC_PIN_GROUP("ssi1-dr-d", x2000_ssi1_dr_d, 2),
3043 	INGENIC_PIN_GROUP("ssi1-dr-e", x2000_ssi1_dr_e, 1),
3044 	INGENIC_PIN_GROUP("ssi1-clk-c", x2000_ssi1_clk_c, 2),
3045 	INGENIC_PIN_GROUP("ssi1-clk-d", x2000_ssi1_clk_d, 2),
3046 	INGENIC_PIN_GROUP("ssi1-clk-e", x2000_ssi1_clk_e, 1),
3047 	INGENIC_PIN_GROUP("ssi1-ce-c", x2000_ssi1_ce_c, 2),
3048 	INGENIC_PIN_GROUP("ssi1-ce-d", x2000_ssi1_ce_d, 2),
3049 	INGENIC_PIN_GROUP("ssi1-ce-e", x2000_ssi1_ce_e, 1),
3050 	INGENIC_PIN_GROUP("mmc0-1bit", x2000_mmc0_1bit, 0),
3051 	INGENIC_PIN_GROUP("mmc0-4bit", x2000_mmc0_4bit, 0),
3052 	INGENIC_PIN_GROUP("mmc0-8bit", x2000_mmc0_8bit, 0),
3053 	INGENIC_PIN_GROUP("mmc1-1bit", x2000_mmc1_1bit, 0),
3054 	INGENIC_PIN_GROUP("mmc1-4bit", x2000_mmc1_4bit, 0),
3055 	INGENIC_PIN_GROUP("mmc2-1bit", x2000_mmc2_1bit, 0),
3056 	INGENIC_PIN_GROUP("mmc2-4bit", x2000_mmc2_4bit, 0),
3057 	INGENIC_PIN_GROUP("emc-8bit-data", x2000_emc_8bit_data, 0),
3058 	INGENIC_PIN_GROUP("emc-16bit-data", x2000_emc_16bit_data, 0),
3059 	INGENIC_PIN_GROUP("emc-addr", x2000_emc_addr, 0),
3060 	INGENIC_PIN_GROUP("emc-rd-we", x2000_emc_rd_we, 0),
3061 	INGENIC_PIN_GROUP("emc-wait", x2000_emc_wait, 0),
3062 	INGENIC_PIN_GROUP("emc-cs1", x2000_emc_cs1, 3),
3063 	INGENIC_PIN_GROUP("emc-cs2", x2000_emc_cs2, 3),
3064 	INGENIC_PIN_GROUP("i2c0-data", x2000_i2c0, 3),
3065 	INGENIC_PIN_GROUP("i2c1-data-c", x2000_i2c1_c, 2),
3066 	INGENIC_PIN_GROUP("i2c1-data-d", x2000_i2c1_d, 1),
3067 	INGENIC_PIN_GROUP("i2c2-data-b", x2000_i2c2_b, 2),
3068 	INGENIC_PIN_GROUP("i2c2-data-d", x2000_i2c2_d, 2),
3069 	INGENIC_PIN_GROUP("i2c2-data-e", x2000_i2c2_e, 1),
3070 	INGENIC_PIN_GROUP("i2c3-data-a", x2000_i2c3_a, 0),
3071 	INGENIC_PIN_GROUP("i2c3-data-d", x2000_i2c3_d, 1),
3072 	INGENIC_PIN_GROUP("i2c4-data-c", x2000_i2c4_c, 1),
3073 	INGENIC_PIN_GROUP("i2c4-data-d", x2000_i2c4_d, 2),
3074 	INGENIC_PIN_GROUP("i2c5-data-c", x2000_i2c5_c, 1),
3075 	INGENIC_PIN_GROUP("i2c5-data-d", x2000_i2c5_d, 1),
3076 	INGENIC_PIN_GROUP("i2s1-data-tx", x2000_i2s1_data_tx, 2),
3077 	INGENIC_PIN_GROUP("i2s1-data-rx", x2000_i2s1_data_rx, 2),
3078 	INGENIC_PIN_GROUP("i2s1-clk-tx", x2000_i2s1_clk_tx, 2),
3079 	INGENIC_PIN_GROUP("i2s1-clk-rx", x2000_i2s1_clk_rx, 2),
3080 	INGENIC_PIN_GROUP("i2s1-sysclk-tx", x2000_i2s1_sysclk_tx, 2),
3081 	INGENIC_PIN_GROUP("i2s1-sysclk-rx", x2000_i2s1_sysclk_rx, 2),
3082 	INGENIC_PIN_GROUP("i2s2-data-rx0", x2000_i2s2_data_rx0, 2),
3083 	INGENIC_PIN_GROUP("i2s2-data-rx1", x2000_i2s2_data_rx1, 2),
3084 	INGENIC_PIN_GROUP("i2s2-data-rx2", x2000_i2s2_data_rx2, 2),
3085 	INGENIC_PIN_GROUP("i2s2-data-rx3", x2000_i2s2_data_rx3, 2),
3086 	INGENIC_PIN_GROUP("i2s2-clk-rx", x2000_i2s2_clk_rx, 2),
3087 	INGENIC_PIN_GROUP("i2s2-sysclk-rx", x2000_i2s2_sysclk_rx, 2),
3088 	INGENIC_PIN_GROUP("i2s3-data-tx0", x2000_i2s3_data_tx0, 2),
3089 	INGENIC_PIN_GROUP("i2s3-data-tx1", x2000_i2s3_data_tx1, 2),
3090 	INGENIC_PIN_GROUP("i2s3-data-tx2", x2000_i2s3_data_tx2, 2),
3091 	INGENIC_PIN_GROUP("i2s3-data-tx3", x2000_i2s3_data_tx3, 2),
3092 	INGENIC_PIN_GROUP("i2s3-clk-tx", x2000_i2s3_clk_tx, 2),
3093 	INGENIC_PIN_GROUP("i2s3-sysclk-tx", x2000_i2s3_sysclk_tx, 2),
3094 	INGENIC_PIN_GROUP("dmic-if0", x2000_dmic_if0, 0),
3095 	INGENIC_PIN_GROUP("dmic-if1", x2000_dmic_if1, 0),
3096 	INGENIC_PIN_GROUP("dmic-if2", x2000_dmic_if2, 0),
3097 	INGENIC_PIN_GROUP("dmic-if3", x2000_dmic_if3, 0),
3098 	INGENIC_PIN_GROUP_FUNCS("cim-data-8bit", x2000_cim_8bit,
3099 				x2000_cim_8bit_funcs),
3100 	INGENIC_PIN_GROUP("cim-data-12bit", x2000_cim_12bit, 0),
3101 	INGENIC_PIN_GROUP("lcd-tft-8bit", x2000_lcd_tft_8bit, 1),
3102 	INGENIC_PIN_GROUP("lcd-tft-16bit", x2000_lcd_tft_16bit, 1),
3103 	INGENIC_PIN_GROUP("lcd-tft-18bit", x2000_lcd_tft_18bit, 1),
3104 	INGENIC_PIN_GROUP("lcd-tft-24bit", x2000_lcd_tft_24bit, 1),
3105 	INGENIC_PIN_GROUP("lcd-slcd-8bit", x2000_lcd_slcd_8bit, 2),
3106 	INGENIC_PIN_GROUP("lcd-slcd-16bit", x2000_lcd_tft_16bit, 2),
3107 	INGENIC_PIN_GROUP("pwm0-c", x2000_pwm_pwm0_c, 0),
3108 	INGENIC_PIN_GROUP("pwm0-d", x2000_pwm_pwm0_d, 2),
3109 	INGENIC_PIN_GROUP("pwm1-c", x2000_pwm_pwm1_c, 0),
3110 	INGENIC_PIN_GROUP("pwm1-d", x2000_pwm_pwm1_d, 2),
3111 	INGENIC_PIN_GROUP("pwm2-c", x2000_pwm_pwm2_c, 0),
3112 	INGENIC_PIN_GROUP("pwm2-e", x2000_pwm_pwm2_e, 1),
3113 	INGENIC_PIN_GROUP("pwm3-c", x2000_pwm_pwm3_c, 0),
3114 	INGENIC_PIN_GROUP("pwm3-e", x2000_pwm_pwm3_e, 1),
3115 	INGENIC_PIN_GROUP("pwm4-c", x2000_pwm_pwm4_c, 0),
3116 	INGENIC_PIN_GROUP("pwm4-e", x2000_pwm_pwm4_e, 1),
3117 	INGENIC_PIN_GROUP("pwm5-c", x2000_pwm_pwm5_c, 0),
3118 	INGENIC_PIN_GROUP("pwm5-e", x2000_pwm_pwm5_e, 1),
3119 	INGENIC_PIN_GROUP("pwm6-c", x2000_pwm_pwm6_c, 0),
3120 	INGENIC_PIN_GROUP("pwm6-e", x2000_pwm_pwm6_e, 1),
3121 	INGENIC_PIN_GROUP("pwm7-c", x2000_pwm_pwm7_c, 0),
3122 	INGENIC_PIN_GROUP("pwm7-e", x2000_pwm_pwm7_e, 1),
3123 	INGENIC_PIN_GROUP("pwm8", x2000_pwm_pwm8, 0),
3124 	INGENIC_PIN_GROUP("pwm9", x2000_pwm_pwm9, 0),
3125 	INGENIC_PIN_GROUP("pwm10", x2000_pwm_pwm10, 0),
3126 	INGENIC_PIN_GROUP("pwm11", x2000_pwm_pwm11, 0),
3127 	INGENIC_PIN_GROUP("pwm12", x2000_pwm_pwm12, 0),
3128 	INGENIC_PIN_GROUP("pwm13", x2000_pwm_pwm13, 0),
3129 	INGENIC_PIN_GROUP("pwm14", x2000_pwm_pwm14, 0),
3130 	INGENIC_PIN_GROUP("pwm15", x2000_pwm_pwm15, 0),
3131 	INGENIC_PIN_GROUP("mac0-rmii", x2000_mac0_rmii, 1),
3132 	INGENIC_PIN_GROUP("mac0-rgmii", x2000_mac0_rgmii, 1),
3133 	INGENIC_PIN_GROUP("mac1-rmii", x2000_mac1_rmii, 3),
3134 	INGENIC_PIN_GROUP("mac1-rgmii", x2000_mac1_rgmii, 3),
3135 	INGENIC_PIN_GROUP("otg-vbus", x2000_otg, 0),
3136 };
3137 
3138 static const char *x2000_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
3139 static const char *x2000_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
3140 static const char *x2000_uart2_groups[] = { "uart2-data", };
3141 static const char *x2000_uart3_groups[] = {
3142 	"uart3-data-c", "uart3-data-d", "uart3-hwflow-c", "uart3-hwflow-d",
3143 };
3144 static const char *x2000_uart4_groups[] = {
3145 	"uart4-data-a", "uart4-data-c", "uart4-hwflow-a", "uart4-hwflow-c",
3146 };
3147 static const char *x2000_uart5_groups[] = { "uart5-data-a", "uart5-data-c", };
3148 static const char *x2000_uart6_groups[] = { "uart6-data-a", "uart6-data-c", };
3149 static const char *x2000_uart7_groups[] = { "uart7-data-a", "uart7-data-c", };
3150 static const char *x2000_uart8_groups[] = { "uart8-data", };
3151 static const char *x2000_uart9_groups[] = { "uart9-data", };
3152 static const char *x2000_sfc_groups[] = {
3153 	"sfc-data-if0-d", "sfc-data-if0-e", "sfc-data-if1",
3154 	"sfc-clk-d", "sfc-clk-e", "sfc-ce-d", "sfc-ce-e",
3155 };
3156 static const char *x2000_ssi0_groups[] = {
3157 	"ssi0-dt-b", "ssi0-dt-d",
3158 	"ssi0-dr-b", "ssi0-dr-d",
3159 	"ssi0-clk-b", "ssi0-clk-d",
3160 	"ssi0-ce-b", "ssi0-ce-d",
3161 };
3162 static const char *x2000_ssi1_groups[] = {
3163 	"ssi1-dt-c", "ssi1-dt-d", "ssi1-dt-e",
3164 	"ssi1-dr-c", "ssi1-dr-d", "ssi1-dr-e",
3165 	"ssi1-clk-c", "ssi1-clk-d", "ssi1-clk-e",
3166 	"ssi1-ce-c", "ssi1-ce-d", "ssi1-ce-e",
3167 };
3168 static const char *x2000_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", "mmc0-8bit", };
3169 static const char *x2000_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
3170 static const char *x2000_mmc2_groups[] = { "mmc2-1bit", "mmc2-4bit", };
3171 static const char *x2000_emc_groups[] = {
3172 	"emc-8bit-data", "emc-16bit-data",
3173 	"emc-addr", "emc-rd-we", "emc-wait",
3174 };
3175 static const char *x2000_cs1_groups[] = { "emc-cs1", };
3176 static const char *x2000_cs2_groups[] = { "emc-cs2", };
3177 static const char *x2000_i2c0_groups[] = { "i2c0-data", };
3178 static const char *x2000_i2c1_groups[] = { "i2c1-data-c", "i2c1-data-d", };
3179 static const char *x2000_i2c2_groups[] = { "i2c2-data-b", "i2c2-data-d", };
3180 static const char *x2000_i2c3_groups[] = { "i2c3-data-a", "i2c3-data-d", };
3181 static const char *x2000_i2c4_groups[] = { "i2c4-data-c", "i2c4-data-d", };
3182 static const char *x2000_i2c5_groups[] = { "i2c5-data-c", "i2c5-data-d", };
3183 static const char *x2000_i2s1_groups[] = {
3184 	"i2s1-data-tx", "i2s1-data-rx",
3185 	"i2s1-clk-tx", "i2s1-clk-rx",
3186 	"i2s1-sysclk-tx", "i2s1-sysclk-rx",
3187 };
3188 static const char *x2000_i2s2_groups[] = {
3189 	"i2s2-data-rx0", "i2s2-data-rx1", "i2s2-data-rx2", "i2s2-data-rx3",
3190 	"i2s2-clk-rx", "i2s2-sysclk-rx",
3191 };
3192 static const char *x2000_i2s3_groups[] = {
3193 	"i2s3-data-tx0", "i2s3-data-tx1", "i2s3-data-tx2", "i2s3-data-tx3",
3194 	"i2s3-clk-tx", "i2s3-sysclk-tx",
3195 };
3196 static const char *x2000_dmic_groups[] = {
3197 	"dmic-if0", "dmic-if1", "dmic-if2", "dmic-if3",
3198 };
3199 static const char *x2000_cim_groups[] = { "cim-data-8bit", "cim-data-12bit", };
3200 static const char *x2000_lcd_groups[] = {
3201 	"lcd-tft-8bit", "lcd-tft-16bit", "lcd-tft-18bit", "lcd-tft-24bit",
3202 	"lcd-slcd-8bit", "lcd-slcd-16bit",
3203 };
3204 static const char *x2000_pwm0_groups[] = { "pwm0-c", "pwm0-d", };
3205 static const char *x2000_pwm1_groups[] = { "pwm1-c", "pwm1-d", };
3206 static const char *x2000_pwm2_groups[] = { "pwm2-c", "pwm2-e", };
3207 static const char *x2000_pwm3_groups[] = { "pwm3-c", "pwm3-r", };
3208 static const char *x2000_pwm4_groups[] = { "pwm4-c", "pwm4-e", };
3209 static const char *x2000_pwm5_groups[] = { "pwm5-c", "pwm5-e", };
3210 static const char *x2000_pwm6_groups[] = { "pwm6-c", "pwm6-e", };
3211 static const char *x2000_pwm7_groups[] = { "pwm7-c", "pwm7-e", };
3212 static const char *x2000_pwm8_groups[] = { "pwm8", };
3213 static const char *x2000_pwm9_groups[] = { "pwm9", };
3214 static const char *x2000_pwm10_groups[] = { "pwm10", };
3215 static const char *x2000_pwm11_groups[] = { "pwm11", };
3216 static const char *x2000_pwm12_groups[] = { "pwm12", };
3217 static const char *x2000_pwm13_groups[] = { "pwm13", };
3218 static const char *x2000_pwm14_groups[] = { "pwm14", };
3219 static const char *x2000_pwm15_groups[] = { "pwm15", };
3220 static const char *x2000_mac0_groups[] = { "mac0-rmii", "mac0-rgmii", };
3221 static const char *x2000_mac1_groups[] = { "mac1-rmii", "mac1-rgmii", };
3222 static const char *x2000_otg_groups[] = { "otg-vbus", };
3223 
3224 static const struct pinfunction x2000_functions[] = {
3225 	INGENIC_PIN_FUNCTION("uart0", x2000_uart0),
3226 	INGENIC_PIN_FUNCTION("uart1", x2000_uart1),
3227 	INGENIC_PIN_FUNCTION("uart2", x2000_uart2),
3228 	INGENIC_PIN_FUNCTION("uart3", x2000_uart3),
3229 	INGENIC_PIN_FUNCTION("uart4", x2000_uart4),
3230 	INGENIC_PIN_FUNCTION("uart5", x2000_uart5),
3231 	INGENIC_PIN_FUNCTION("uart6", x2000_uart6),
3232 	INGENIC_PIN_FUNCTION("uart7", x2000_uart7),
3233 	INGENIC_PIN_FUNCTION("uart8", x2000_uart8),
3234 	INGENIC_PIN_FUNCTION("uart9", x2000_uart9),
3235 	INGENIC_PIN_FUNCTION("sfc", x2000_sfc),
3236 	INGENIC_PIN_FUNCTION("ssi0", x2000_ssi0),
3237 	INGENIC_PIN_FUNCTION("ssi1", x2000_ssi1),
3238 	INGENIC_PIN_FUNCTION("mmc0", x2000_mmc0),
3239 	INGENIC_PIN_FUNCTION("mmc1", x2000_mmc1),
3240 	INGENIC_PIN_FUNCTION("mmc2", x2000_mmc2),
3241 	INGENIC_PIN_FUNCTION("emc", x2000_emc),
3242 	INGENIC_PIN_FUNCTION("emc-cs1", x2000_cs1),
3243 	INGENIC_PIN_FUNCTION("emc-cs2", x2000_cs2),
3244 	INGENIC_PIN_FUNCTION("i2c0", x2000_i2c0),
3245 	INGENIC_PIN_FUNCTION("i2c1", x2000_i2c1),
3246 	INGENIC_PIN_FUNCTION("i2c2", x2000_i2c2),
3247 	INGENIC_PIN_FUNCTION("i2c3", x2000_i2c3),
3248 	INGENIC_PIN_FUNCTION("i2c4", x2000_i2c4),
3249 	INGENIC_PIN_FUNCTION("i2c5", x2000_i2c5),
3250 	INGENIC_PIN_FUNCTION("i2s1", x2000_i2s1),
3251 	INGENIC_PIN_FUNCTION("i2s2", x2000_i2s2),
3252 	INGENIC_PIN_FUNCTION("i2s3", x2000_i2s3),
3253 	INGENIC_PIN_FUNCTION("dmic", x2000_dmic),
3254 	INGENIC_PIN_FUNCTION("cim", x2000_cim),
3255 	INGENIC_PIN_FUNCTION("lcd", x2000_lcd),
3256 	INGENIC_PIN_FUNCTION("pwm0", x2000_pwm0),
3257 	INGENIC_PIN_FUNCTION("pwm1", x2000_pwm1),
3258 	INGENIC_PIN_FUNCTION("pwm2", x2000_pwm2),
3259 	INGENIC_PIN_FUNCTION("pwm3", x2000_pwm3),
3260 	INGENIC_PIN_FUNCTION("pwm4", x2000_pwm4),
3261 	INGENIC_PIN_FUNCTION("pwm5", x2000_pwm5),
3262 	INGENIC_PIN_FUNCTION("pwm6", x2000_pwm6),
3263 	INGENIC_PIN_FUNCTION("pwm7", x2000_pwm7),
3264 	INGENIC_PIN_FUNCTION("pwm8", x2000_pwm8),
3265 	INGENIC_PIN_FUNCTION("pwm9", x2000_pwm9),
3266 	INGENIC_PIN_FUNCTION("pwm10", x2000_pwm10),
3267 	INGENIC_PIN_FUNCTION("pwm11", x2000_pwm11),
3268 	INGENIC_PIN_FUNCTION("pwm12", x2000_pwm12),
3269 	INGENIC_PIN_FUNCTION("pwm13", x2000_pwm13),
3270 	INGENIC_PIN_FUNCTION("pwm14", x2000_pwm14),
3271 	INGENIC_PIN_FUNCTION("pwm15", x2000_pwm15),
3272 	INGENIC_PIN_FUNCTION("mac0", x2000_mac0),
3273 	INGENIC_PIN_FUNCTION("mac1", x2000_mac1),
3274 	INGENIC_PIN_FUNCTION("otg", x2000_otg),
3275 };
3276 
3277 static const struct regmap_range x2000_access_ranges[] = {
3278 	regmap_reg_range(0x000, 0x500 - 4),
3279 	regmap_reg_range(0x700, 0x800 - 4),
3280 };
3281 
3282 /* shared with X2100 */
3283 static const struct regmap_access_table x2000_access_table = {
3284 	.yes_ranges = x2000_access_ranges,
3285 	.n_yes_ranges = ARRAY_SIZE(x2000_access_ranges),
3286 };
3287 
3288 static const struct ingenic_chip_info x2000_chip_info = {
3289 	.num_chips = 5,
3290 	.reg_offset = 0x100,
3291 	.version = ID_X2000,
3292 	.groups = x2000_groups,
3293 	.num_groups = ARRAY_SIZE(x2000_groups),
3294 	.functions = x2000_functions,
3295 	.num_functions = ARRAY_SIZE(x2000_functions),
3296 	.pull_ups = x2000_pull_ups,
3297 	.pull_downs = x2000_pull_downs,
3298 	.access_table = &x2000_access_table,
3299 };
3300 
3301 static const u32 x2100_pull_ups[5] = {
3302 	0x0003ffff, 0xffffffff, 0x1ff0ffff, 0xc7fe3f3f, 0x0fbf003f,
3303 };
3304 
3305 static const u32 x2100_pull_downs[5] = {
3306 	0x0003ffff, 0xffffffff, 0x1ff0ffff, 0x00000000, 0x0fbf003f,
3307 };
3308 
3309 static int x2100_mac_pins[] = {
3310 	0x4b, 0x47, 0x46, 0x4a, 0x43, 0x42, 0x4c, 0x4d, 0x4f, 0x41,
3311 };
3312 
3313 static const struct group_desc x2100_groups[] = {
3314 	INGENIC_PIN_GROUP("uart0-data", x2000_uart0_data, 2),
3315 	INGENIC_PIN_GROUP("uart0-hwflow", x2000_uart0_hwflow, 2),
3316 	INGENIC_PIN_GROUP("uart1-data", x2000_uart1_data, 1),
3317 	INGENIC_PIN_GROUP("uart1-hwflow", x2000_uart1_hwflow, 1),
3318 	INGENIC_PIN_GROUP("uart2-data", x2000_uart2_data, 0),
3319 	INGENIC_PIN_GROUP("uart3-data-c", x2000_uart3_data_c, 0),
3320 	INGENIC_PIN_GROUP("uart3-data-d", x2000_uart3_data_d, 1),
3321 	INGENIC_PIN_GROUP("uart3-hwflow-c", x2000_uart3_hwflow_c, 0),
3322 	INGENIC_PIN_GROUP("uart3-hwflow-d", x2000_uart3_hwflow_d, 1),
3323 	INGENIC_PIN_GROUP("uart4-data-a", x2000_uart4_data_a, 1),
3324 	INGENIC_PIN_GROUP("uart4-data-c", x2000_uart4_data_c, 3),
3325 	INGENIC_PIN_GROUP("uart4-hwflow-a", x2000_uart4_hwflow_a, 1),
3326 	INGENIC_PIN_GROUP("uart4-hwflow-c", x2000_uart4_hwflow_c, 3),
3327 	INGENIC_PIN_GROUP("uart5-data-a", x2000_uart5_data_a, 1),
3328 	INGENIC_PIN_GROUP("uart5-data-c", x2000_uart5_data_c, 3),
3329 	INGENIC_PIN_GROUP("uart6-data-a", x2000_uart6_data_a, 1),
3330 	INGENIC_PIN_GROUP("uart6-data-c", x2000_uart6_data_c, 3),
3331 	INGENIC_PIN_GROUP("uart7-data-a", x2000_uart7_data_a, 1),
3332 	INGENIC_PIN_GROUP("uart7-data-c", x2000_uart7_data_c, 3),
3333 	INGENIC_PIN_GROUP("uart8-data", x2000_uart8_data, 3),
3334 	INGENIC_PIN_GROUP("uart9-data", x2000_uart9_data, 3),
3335 	INGENIC_PIN_GROUP("sfc-data-if0-d", x2000_sfc_data_if0_d, 1),
3336 	INGENIC_PIN_GROUP("sfc-data-if0-e", x2000_sfc_data_if0_e, 0),
3337 	INGENIC_PIN_GROUP("sfc-data-if1", x2000_sfc_data_if1, 1),
3338 	INGENIC_PIN_GROUP("sfc-clk-d", x2000_sfc_clk_d, 1),
3339 	INGENIC_PIN_GROUP("sfc-clk-e", x2000_sfc_clk_e, 0),
3340 	INGENIC_PIN_GROUP("sfc-ce-d", x2000_sfc_ce_d, 1),
3341 	INGENIC_PIN_GROUP("sfc-ce-e", x2000_sfc_ce_e, 0),
3342 	INGENIC_PIN_GROUP("ssi0-dt-b", x2000_ssi0_dt_b, 1),
3343 	INGENIC_PIN_GROUP("ssi0-dt-d", x2000_ssi0_dt_d, 1),
3344 	INGENIC_PIN_GROUP("ssi0-dr-b", x2000_ssi0_dr_b, 1),
3345 	INGENIC_PIN_GROUP("ssi0-dr-d", x2000_ssi0_dr_d, 1),
3346 	INGENIC_PIN_GROUP("ssi0-clk-b", x2000_ssi0_clk_b, 1),
3347 	INGENIC_PIN_GROUP("ssi0-clk-d", x2000_ssi0_clk_d, 1),
3348 	INGENIC_PIN_GROUP("ssi0-ce-b", x2000_ssi0_ce_b, 1),
3349 	INGENIC_PIN_GROUP("ssi0-ce-d", x2000_ssi0_ce_d, 1),
3350 	INGENIC_PIN_GROUP("ssi1-dt-c", x2000_ssi1_dt_c, 2),
3351 	INGENIC_PIN_GROUP("ssi1-dt-d", x2000_ssi1_dt_d, 2),
3352 	INGENIC_PIN_GROUP("ssi1-dt-e", x2000_ssi1_dt_e, 1),
3353 	INGENIC_PIN_GROUP("ssi1-dr-c", x2000_ssi1_dr_c, 2),
3354 	INGENIC_PIN_GROUP("ssi1-dr-d", x2000_ssi1_dr_d, 2),
3355 	INGENIC_PIN_GROUP("ssi1-dr-e", x2000_ssi1_dr_e, 1),
3356 	INGENIC_PIN_GROUP("ssi1-clk-c", x2000_ssi1_clk_c, 2),
3357 	INGENIC_PIN_GROUP("ssi1-clk-d", x2000_ssi1_clk_d, 2),
3358 	INGENIC_PIN_GROUP("ssi1-clk-e", x2000_ssi1_clk_e, 1),
3359 	INGENIC_PIN_GROUP("ssi1-ce-c", x2000_ssi1_ce_c, 2),
3360 	INGENIC_PIN_GROUP("ssi1-ce-d", x2000_ssi1_ce_d, 2),
3361 	INGENIC_PIN_GROUP("ssi1-ce-e", x2000_ssi1_ce_e, 1),
3362 	INGENIC_PIN_GROUP("mmc0-1bit", x2000_mmc0_1bit, 0),
3363 	INGENIC_PIN_GROUP("mmc0-4bit", x2000_mmc0_4bit, 0),
3364 	INGENIC_PIN_GROUP("mmc0-8bit", x2000_mmc0_8bit, 0),
3365 	INGENIC_PIN_GROUP("mmc1-1bit", x2000_mmc1_1bit, 0),
3366 	INGENIC_PIN_GROUP("mmc1-4bit", x2000_mmc1_4bit, 0),
3367 	INGENIC_PIN_GROUP("mmc2-1bit", x2000_mmc2_1bit, 0),
3368 	INGENIC_PIN_GROUP("mmc2-4bit", x2000_mmc2_4bit, 0),
3369 	INGENIC_PIN_GROUP("emc-8bit-data", x2000_emc_8bit_data, 0),
3370 	INGENIC_PIN_GROUP("emc-16bit-data", x2000_emc_16bit_data, 0),
3371 	INGENIC_PIN_GROUP("emc-addr", x2000_emc_addr, 0),
3372 	INGENIC_PIN_GROUP("emc-rd-we", x2000_emc_rd_we, 0),
3373 	INGENIC_PIN_GROUP("emc-wait", x2000_emc_wait, 0),
3374 	INGENIC_PIN_GROUP("emc-cs1", x2000_emc_cs1, 3),
3375 	INGENIC_PIN_GROUP("emc-cs2", x2000_emc_cs2, 3),
3376 	INGENIC_PIN_GROUP("i2c0-data", x2000_i2c0, 3),
3377 	INGENIC_PIN_GROUP("i2c1-data-c", x2000_i2c1_c, 2),
3378 	INGENIC_PIN_GROUP("i2c1-data-d", x2000_i2c1_d, 1),
3379 	INGENIC_PIN_GROUP("i2c2-data-b", x2000_i2c2_b, 2),
3380 	INGENIC_PIN_GROUP("i2c2-data-d", x2000_i2c2_d, 2),
3381 	INGENIC_PIN_GROUP("i2c2-data-e", x2000_i2c2_e, 1),
3382 	INGENIC_PIN_GROUP("i2c3-data-a", x2000_i2c3_a, 0),
3383 	INGENIC_PIN_GROUP("i2c3-data-d", x2000_i2c3_d, 1),
3384 	INGENIC_PIN_GROUP("i2c4-data-c", x2000_i2c4_c, 1),
3385 	INGENIC_PIN_GROUP("i2c4-data-d", x2000_i2c4_d, 2),
3386 	INGENIC_PIN_GROUP("i2c5-data-c", x2000_i2c5_c, 1),
3387 	INGENIC_PIN_GROUP("i2c5-data-d", x2000_i2c5_d, 1),
3388 	INGENIC_PIN_GROUP("i2s1-data-tx", x2000_i2s1_data_tx, 2),
3389 	INGENIC_PIN_GROUP("i2s1-data-rx", x2000_i2s1_data_rx, 2),
3390 	INGENIC_PIN_GROUP("i2s1-clk-tx", x2000_i2s1_clk_tx, 2),
3391 	INGENIC_PIN_GROUP("i2s1-clk-rx", x2000_i2s1_clk_rx, 2),
3392 	INGENIC_PIN_GROUP("i2s1-sysclk-tx", x2000_i2s1_sysclk_tx, 2),
3393 	INGENIC_PIN_GROUP("i2s1-sysclk-rx", x2000_i2s1_sysclk_rx, 2),
3394 	INGENIC_PIN_GROUP("i2s2-data-rx0", x2000_i2s2_data_rx0, 2),
3395 	INGENIC_PIN_GROUP("i2s2-data-rx1", x2000_i2s2_data_rx1, 2),
3396 	INGENIC_PIN_GROUP("i2s2-data-rx2", x2000_i2s2_data_rx2, 2),
3397 	INGENIC_PIN_GROUP("i2s2-data-rx3", x2000_i2s2_data_rx3, 2),
3398 	INGENIC_PIN_GROUP("i2s2-clk-rx", x2000_i2s2_clk_rx, 2),
3399 	INGENIC_PIN_GROUP("i2s2-sysclk-rx", x2000_i2s2_sysclk_rx, 2),
3400 	INGENIC_PIN_GROUP("i2s3-data-tx0", x2000_i2s3_data_tx0, 2),
3401 	INGENIC_PIN_GROUP("i2s3-data-tx1", x2000_i2s3_data_tx1, 2),
3402 	INGENIC_PIN_GROUP("i2s3-data-tx2", x2000_i2s3_data_tx2, 2),
3403 	INGENIC_PIN_GROUP("i2s3-data-tx3", x2000_i2s3_data_tx3, 2),
3404 	INGENIC_PIN_GROUP("i2s3-clk-tx", x2000_i2s3_clk_tx, 2),
3405 	INGENIC_PIN_GROUP("i2s3-sysclk-tx", x2000_i2s3_sysclk_tx, 2),
3406 	INGENIC_PIN_GROUP("dmic-if0", x2000_dmic_if0, 0),
3407 	INGENIC_PIN_GROUP("dmic-if1", x2000_dmic_if1, 0),
3408 	INGENIC_PIN_GROUP("dmic-if2", x2000_dmic_if2, 0),
3409 	INGENIC_PIN_GROUP("dmic-if3", x2000_dmic_if3, 0),
3410 	INGENIC_PIN_GROUP_FUNCS("cim-data-8bit", x2000_cim_8bit,
3411 				x2000_cim_8bit_funcs),
3412 	INGENIC_PIN_GROUP("cim-data-12bit", x2000_cim_12bit, 0),
3413 	INGENIC_PIN_GROUP("lcd-tft-8bit", x2000_lcd_tft_8bit, 1),
3414 	INGENIC_PIN_GROUP("lcd-tft-16bit", x2000_lcd_tft_16bit, 1),
3415 	INGENIC_PIN_GROUP("lcd-tft-18bit", x2000_lcd_tft_18bit, 1),
3416 	INGENIC_PIN_GROUP("lcd-tft-24bit", x2000_lcd_tft_24bit, 1),
3417 	INGENIC_PIN_GROUP("lcd-slcd-8bit", x2000_lcd_slcd_8bit, 2),
3418 	INGENIC_PIN_GROUP("lcd-slcd-16bit", x2000_lcd_tft_16bit, 2),
3419 	INGENIC_PIN_GROUP("pwm0-c", x2000_pwm_pwm0_c, 0),
3420 	INGENIC_PIN_GROUP("pwm0-d", x2000_pwm_pwm0_d, 2),
3421 	INGENIC_PIN_GROUP("pwm1-c", x2000_pwm_pwm1_c, 0),
3422 	INGENIC_PIN_GROUP("pwm1-d", x2000_pwm_pwm1_d, 2),
3423 	INGENIC_PIN_GROUP("pwm2-c", x2000_pwm_pwm2_c, 0),
3424 	INGENIC_PIN_GROUP("pwm2-e", x2000_pwm_pwm2_e, 1),
3425 	INGENIC_PIN_GROUP("pwm3-c", x2000_pwm_pwm3_c, 0),
3426 	INGENIC_PIN_GROUP("pwm3-e", x2000_pwm_pwm3_e, 1),
3427 	INGENIC_PIN_GROUP("pwm4-c", x2000_pwm_pwm4_c, 0),
3428 	INGENIC_PIN_GROUP("pwm4-e", x2000_pwm_pwm4_e, 1),
3429 	INGENIC_PIN_GROUP("pwm5-c", x2000_pwm_pwm5_c, 0),
3430 	INGENIC_PIN_GROUP("pwm5-e", x2000_pwm_pwm5_e, 1),
3431 	INGENIC_PIN_GROUP("pwm6-c", x2000_pwm_pwm6_c, 0),
3432 	INGENIC_PIN_GROUP("pwm6-e", x2000_pwm_pwm6_e, 1),
3433 	INGENIC_PIN_GROUP("pwm7-c", x2000_pwm_pwm7_c, 0),
3434 	INGENIC_PIN_GROUP("pwm7-e", x2000_pwm_pwm7_e, 1),
3435 	INGENIC_PIN_GROUP("pwm8", x2000_pwm_pwm8, 0),
3436 	INGENIC_PIN_GROUP("pwm9", x2000_pwm_pwm9, 0),
3437 	INGENIC_PIN_GROUP("pwm10", x2000_pwm_pwm10, 0),
3438 	INGENIC_PIN_GROUP("pwm11", x2000_pwm_pwm11, 0),
3439 	INGENIC_PIN_GROUP("pwm12", x2000_pwm_pwm12, 0),
3440 	INGENIC_PIN_GROUP("pwm13", x2000_pwm_pwm13, 0),
3441 	INGENIC_PIN_GROUP("pwm14", x2000_pwm_pwm14, 0),
3442 	INGENIC_PIN_GROUP("pwm15", x2000_pwm_pwm15, 0),
3443 	INGENIC_PIN_GROUP("mac", x2100_mac, 1),
3444 };
3445 
3446 static const char *x2100_mac_groups[] = { "mac", };
3447 
3448 static const struct pinfunction x2100_functions[] = {
3449 	INGENIC_PIN_FUNCTION("uart0", x2000_uart0),
3450 	INGENIC_PIN_FUNCTION("uart1", x2000_uart1),
3451 	INGENIC_PIN_FUNCTION("uart2", x2000_uart2),
3452 	INGENIC_PIN_FUNCTION("uart3", x2000_uart3),
3453 	INGENIC_PIN_FUNCTION("uart4", x2000_uart4),
3454 	INGENIC_PIN_FUNCTION("uart5", x2000_uart5),
3455 	INGENIC_PIN_FUNCTION("uart6", x2000_uart6),
3456 	INGENIC_PIN_FUNCTION("uart7", x2000_uart7),
3457 	INGENIC_PIN_FUNCTION("uart8", x2000_uart8),
3458 	INGENIC_PIN_FUNCTION("uart9", x2000_uart9),
3459 	INGENIC_PIN_FUNCTION("sfc", x2000_sfc),
3460 	INGENIC_PIN_FUNCTION("ssi0", x2000_ssi0),
3461 	INGENIC_PIN_FUNCTION("ssi1", x2000_ssi1),
3462 	INGENIC_PIN_FUNCTION("mmc0", x2000_mmc0),
3463 	INGENIC_PIN_FUNCTION("mmc1", x2000_mmc1),
3464 	INGENIC_PIN_FUNCTION("mmc2", x2000_mmc2),
3465 	INGENIC_PIN_FUNCTION("emc", x2000_emc),
3466 	INGENIC_PIN_FUNCTION("emc-cs1", x2000_cs1),
3467 	INGENIC_PIN_FUNCTION("emc-cs2", x2000_cs2),
3468 	INGENIC_PIN_FUNCTION("i2c0", x2000_i2c0),
3469 	INGENIC_PIN_FUNCTION("i2c1", x2000_i2c1),
3470 	INGENIC_PIN_FUNCTION("i2c2", x2000_i2c2),
3471 	INGENIC_PIN_FUNCTION("i2c3", x2000_i2c3),
3472 	INGENIC_PIN_FUNCTION("i2c4", x2000_i2c4),
3473 	INGENIC_PIN_FUNCTION("i2c5", x2000_i2c5),
3474 	INGENIC_PIN_FUNCTION("i2s1", x2000_i2s1),
3475 	INGENIC_PIN_FUNCTION("i2s2", x2000_i2s2),
3476 	INGENIC_PIN_FUNCTION("i2s3", x2000_i2s3),
3477 	INGENIC_PIN_FUNCTION("dmic", x2000_dmic),
3478 	INGENIC_PIN_FUNCTION("cim", x2000_cim),
3479 	INGENIC_PIN_FUNCTION("lcd", x2000_lcd),
3480 	INGENIC_PIN_FUNCTION("pwm0", x2000_pwm0),
3481 	INGENIC_PIN_FUNCTION("pwm1", x2000_pwm1),
3482 	INGENIC_PIN_FUNCTION("pwm2", x2000_pwm2),
3483 	INGENIC_PIN_FUNCTION("pwm3", x2000_pwm3),
3484 	INGENIC_PIN_FUNCTION("pwm4", x2000_pwm4),
3485 	INGENIC_PIN_FUNCTION("pwm5", x2000_pwm5),
3486 	INGENIC_PIN_FUNCTION("pwm6", x2000_pwm6),
3487 	INGENIC_PIN_FUNCTION("pwm7", x2000_pwm7),
3488 	INGENIC_PIN_FUNCTION("pwm8", x2000_pwm8),
3489 	INGENIC_PIN_FUNCTION("pwm9", x2000_pwm9),
3490 	INGENIC_PIN_FUNCTION("pwm10", x2000_pwm10),
3491 	INGENIC_PIN_FUNCTION("pwm11", x2000_pwm11),
3492 	INGENIC_PIN_FUNCTION("pwm12", x2000_pwm12),
3493 	INGENIC_PIN_FUNCTION("pwm13", x2000_pwm13),
3494 	INGENIC_PIN_FUNCTION("pwm14", x2000_pwm14),
3495 	INGENIC_PIN_FUNCTION("pwm15", x2000_pwm15),
3496 	INGENIC_PIN_FUNCTION("mac", x2100_mac),
3497 };
3498 
3499 static const struct ingenic_chip_info x2100_chip_info = {
3500 	.num_chips = 5,
3501 	.reg_offset = 0x100,
3502 	.version = ID_X2100,
3503 	.groups = x2100_groups,
3504 	.num_groups = ARRAY_SIZE(x2100_groups),
3505 	.functions = x2100_functions,
3506 	.num_functions = ARRAY_SIZE(x2100_functions),
3507 	.pull_ups = x2100_pull_ups,
3508 	.pull_downs = x2100_pull_downs,
3509 	.access_table = &x2000_access_table,
3510 };
3511 
ingenic_gpio_read_reg(struct ingenic_gpio_chip * jzgc,u8 reg)3512 static u32 ingenic_gpio_read_reg(struct ingenic_gpio_chip *jzgc, u8 reg)
3513 {
3514 	unsigned int val;
3515 
3516 	regmap_read(jzgc->jzpc->map, jzgc->reg_base + reg, &val);
3517 
3518 	return (u32) val;
3519 }
3520 
ingenic_gpio_set_bit(struct ingenic_gpio_chip * jzgc,u8 reg,u8 offset,bool set)3521 static void ingenic_gpio_set_bit(struct ingenic_gpio_chip *jzgc,
3522 		u8 reg, u8 offset, bool set)
3523 {
3524 	if (!is_soc_or_above(jzgc->jzpc, ID_JZ4740)) {
3525 		regmap_update_bits(jzgc->jzpc->map, jzgc->reg_base + reg,
3526 				BIT(offset), set ? BIT(offset) : 0);
3527 		return;
3528 	}
3529 
3530 	if (set)
3531 		reg = REG_SET(reg);
3532 	else
3533 		reg = REG_CLEAR(reg);
3534 
3535 	regmap_write(jzgc->jzpc->map, jzgc->reg_base + reg, BIT(offset));
3536 }
3537 
ingenic_gpio_shadow_set_bit(struct ingenic_gpio_chip * jzgc,u8 reg,u8 offset,bool set)3538 static void ingenic_gpio_shadow_set_bit(struct ingenic_gpio_chip *jzgc,
3539 		u8 reg, u8 offset, bool set)
3540 {
3541 	if (set)
3542 		reg = REG_SET(reg);
3543 	else
3544 		reg = REG_CLEAR(reg);
3545 
3546 	regmap_write(jzgc->jzpc->map, REG_PZ_BASE(
3547 			jzgc->jzpc->info->reg_offset) + reg, BIT(offset));
3548 }
3549 
ingenic_gpio_shadow_set_bit_load(struct ingenic_gpio_chip * jzgc)3550 static void ingenic_gpio_shadow_set_bit_load(struct ingenic_gpio_chip *jzgc)
3551 {
3552 	regmap_write(jzgc->jzpc->map, REG_PZ_GID2LD(
3553 			jzgc->jzpc->info->reg_offset),
3554 			jzgc->gc.base / PINS_PER_GPIO_CHIP);
3555 }
3556 
jz4730_gpio_set_bits(struct ingenic_gpio_chip * jzgc,u8 reg_upper,u8 reg_lower,u8 offset,u8 value)3557 static void jz4730_gpio_set_bits(struct ingenic_gpio_chip *jzgc,
3558 		u8 reg_upper, u8 reg_lower, u8 offset, u8 value)
3559 {
3560 	/*
3561 	 * JZ4730 function and IRQ registers support two-bits-per-pin
3562 	 * definitions, split into two groups of 16.
3563 	 */
3564 	u8 reg = offset < JZ4730_PINS_PER_PAIRED_REG ? reg_lower : reg_upper;
3565 	unsigned int idx = offset % JZ4730_PINS_PER_PAIRED_REG;
3566 	unsigned int mask = GENMASK(1, 0) << idx * 2;
3567 
3568 	regmap_update_bits(jzgc->jzpc->map, jzgc->reg_base + reg, mask, value << (idx * 2));
3569 }
3570 
ingenic_gpio_get_value(struct ingenic_gpio_chip * jzgc,u8 offset)3571 static inline bool ingenic_gpio_get_value(struct ingenic_gpio_chip *jzgc,
3572 					  u8 offset)
3573 {
3574 	unsigned int val = ingenic_gpio_read_reg(jzgc, GPIO_PIN);
3575 
3576 	return !!(val & BIT(offset));
3577 }
3578 
ingenic_gpio_set_value(struct ingenic_gpio_chip * jzgc,u8 offset,int value)3579 static void ingenic_gpio_set_value(struct ingenic_gpio_chip *jzgc,
3580 				   u8 offset, int value)
3581 {
3582 	if (is_soc_or_above(jzgc->jzpc, ID_JZ4770))
3583 		ingenic_gpio_set_bit(jzgc, JZ4770_GPIO_PAT0, offset, !!value);
3584 	else if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
3585 		ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, offset, !!value);
3586 	else
3587 		ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_DATA, offset, !!value);
3588 }
3589 
irq_set_type(struct ingenic_gpio_chip * jzgc,u8 offset,unsigned int type)3590 static void irq_set_type(struct ingenic_gpio_chip *jzgc,
3591 		u8 offset, unsigned int type)
3592 {
3593 	u8 reg1, reg2;
3594 	bool val1, val2, val3;
3595 
3596 	switch (type) {
3597 	case IRQ_TYPE_EDGE_BOTH:
3598 		val1 = val2 = false;
3599 		val3 = true;
3600 		break;
3601 	case IRQ_TYPE_EDGE_RISING:
3602 		val1 = val2 = true;
3603 		val3 = false;
3604 		break;
3605 	case IRQ_TYPE_EDGE_FALLING:
3606 		val1 = val3 = false;
3607 		val2 = true;
3608 		break;
3609 	case IRQ_TYPE_LEVEL_HIGH:
3610 		val1 = true;
3611 		val2 = val3 = false;
3612 		break;
3613 	case IRQ_TYPE_LEVEL_LOW:
3614 	default:
3615 		val1 = val2 = val3 = false;
3616 		break;
3617 	}
3618 
3619 	if (is_soc_or_above(jzgc->jzpc, ID_JZ4770)) {
3620 		reg1 = JZ4770_GPIO_PAT1;
3621 		reg2 = JZ4770_GPIO_PAT0;
3622 	} else if (is_soc_or_above(jzgc->jzpc, ID_JZ4740)) {
3623 		reg1 = JZ4740_GPIO_TRIG;
3624 		reg2 = JZ4740_GPIO_DIR;
3625 	} else {
3626 		ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_GPDIR, offset, false);
3627 		jz4730_gpio_set_bits(jzgc, JZ4730_GPIO_GPIDUR,
3628 				JZ4730_GPIO_GPIDLR, offset, (val2 << 1) | val1);
3629 		return;
3630 	}
3631 
3632 	if (is_soc_or_above(jzgc->jzpc, ID_X2000)) {
3633 		ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, val1);
3634 		ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, val2);
3635 		ingenic_gpio_shadow_set_bit_load(jzgc);
3636 		ingenic_gpio_set_bit(jzgc, X2000_GPIO_EDG, offset, val3);
3637 	} else if (is_soc_or_above(jzgc->jzpc, ID_X1000)) {
3638 		ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, val1);
3639 		ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, val2);
3640 		ingenic_gpio_shadow_set_bit_load(jzgc);
3641 	} else {
3642 		ingenic_gpio_set_bit(jzgc, reg2, offset, val1);
3643 		ingenic_gpio_set_bit(jzgc, reg1, offset, val2);
3644 	}
3645 }
3646 
ingenic_gpio_irq_mask(struct irq_data * irqd)3647 static void ingenic_gpio_irq_mask(struct irq_data *irqd)
3648 {
3649 	struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
3650 	struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
3651 	irq_hw_number_t irq = irqd_to_hwirq(irqd);
3652 
3653 	if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
3654 		ingenic_gpio_set_bit(jzgc, GPIO_MSK, irq, true);
3655 	else
3656 		ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_GPIMR, irq, true);
3657 }
3658 
ingenic_gpio_irq_unmask(struct irq_data * irqd)3659 static void ingenic_gpio_irq_unmask(struct irq_data *irqd)
3660 {
3661 	struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
3662 	struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
3663 	irq_hw_number_t irq = irqd_to_hwirq(irqd);
3664 
3665 	if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
3666 		ingenic_gpio_set_bit(jzgc, GPIO_MSK, irq, false);
3667 	else
3668 		ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_GPIMR, irq, false);
3669 }
3670 
ingenic_gpio_irq_enable(struct irq_data * irqd)3671 static void ingenic_gpio_irq_enable(struct irq_data *irqd)
3672 {
3673 	struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
3674 	struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
3675 	irq_hw_number_t irq = irqd_to_hwirq(irqd);
3676 
3677 	gpiochip_enable_irq(gc, irq);
3678 
3679 	if (is_soc_or_above(jzgc->jzpc, ID_JZ4770))
3680 		ingenic_gpio_set_bit(jzgc, JZ4770_GPIO_INT, irq, true);
3681 	else if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
3682 		ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, true);
3683 	else
3684 		ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_GPIER, irq, true);
3685 
3686 	ingenic_gpio_irq_unmask(irqd);
3687 }
3688 
ingenic_gpio_irq_disable(struct irq_data * irqd)3689 static void ingenic_gpio_irq_disable(struct irq_data *irqd)
3690 {
3691 	struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
3692 	struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
3693 	irq_hw_number_t irq = irqd_to_hwirq(irqd);
3694 
3695 	ingenic_gpio_irq_mask(irqd);
3696 
3697 	if (is_soc_or_above(jzgc->jzpc, ID_JZ4770))
3698 		ingenic_gpio_set_bit(jzgc, JZ4770_GPIO_INT, irq, false);
3699 	else if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
3700 		ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, false);
3701 	else
3702 		ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_GPIER, irq, false);
3703 
3704 	gpiochip_disable_irq(gc, irq);
3705 }
3706 
ingenic_gpio_irq_ack(struct irq_data * irqd)3707 static void ingenic_gpio_irq_ack(struct irq_data *irqd)
3708 {
3709 	struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
3710 	struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
3711 	irq_hw_number_t irq = irqd_to_hwirq(irqd);
3712 	bool high;
3713 
3714 	if ((irqd_get_trigger_type(irqd) == IRQ_TYPE_EDGE_BOTH) &&
3715 	    !is_soc_or_above(jzgc->jzpc, ID_X2000)) {
3716 		/*
3717 		 * Switch to an interrupt for the opposite edge to the one that
3718 		 * triggered the interrupt being ACKed.
3719 		 */
3720 		high = ingenic_gpio_get_value(jzgc, irq);
3721 		if (high)
3722 			irq_set_type(jzgc, irq, IRQ_TYPE_LEVEL_LOW);
3723 		else
3724 			irq_set_type(jzgc, irq, IRQ_TYPE_LEVEL_HIGH);
3725 	}
3726 
3727 	if (is_soc_or_above(jzgc->jzpc, ID_JZ4770))
3728 		ingenic_gpio_set_bit(jzgc, JZ4770_GPIO_FLAG, irq, false);
3729 	else if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
3730 		ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, irq, true);
3731 	else
3732 		ingenic_gpio_set_bit(jzgc, JZ4730_GPIO_GPFR, irq, false);
3733 }
3734 
ingenic_gpio_irq_set_type(struct irq_data * irqd,unsigned int type)3735 static int ingenic_gpio_irq_set_type(struct irq_data *irqd, unsigned int type)
3736 {
3737 	struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
3738 	struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
3739 	irq_hw_number_t irq = irqd_to_hwirq(irqd);
3740 
3741 	switch (type) {
3742 	case IRQ_TYPE_EDGE_BOTH:
3743 	case IRQ_TYPE_EDGE_RISING:
3744 	case IRQ_TYPE_EDGE_FALLING:
3745 		irq_set_handler_locked(irqd, handle_edge_irq);
3746 		break;
3747 	case IRQ_TYPE_LEVEL_HIGH:
3748 	case IRQ_TYPE_LEVEL_LOW:
3749 		irq_set_handler_locked(irqd, handle_level_irq);
3750 		break;
3751 	default:
3752 		irq_set_handler_locked(irqd, handle_bad_irq);
3753 	}
3754 
3755 	if ((type == IRQ_TYPE_EDGE_BOTH) && !is_soc_or_above(jzgc->jzpc, ID_X2000)) {
3756 		/*
3757 		 * The hardware does not support interrupts on both edges. The
3758 		 * best we can do is to set up a single-edge interrupt and then
3759 		 * switch to the opposing edge when ACKing the interrupt.
3760 		 */
3761 		bool high = ingenic_gpio_get_value(jzgc, irq);
3762 
3763 		type = high ? IRQ_TYPE_LEVEL_LOW : IRQ_TYPE_LEVEL_HIGH;
3764 	}
3765 
3766 	irq_set_type(jzgc, irq, type);
3767 	return 0;
3768 }
3769 
ingenic_gpio_irq_set_wake(struct irq_data * irqd,unsigned int on)3770 static int ingenic_gpio_irq_set_wake(struct irq_data *irqd, unsigned int on)
3771 {
3772 	struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
3773 	struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
3774 
3775 	return irq_set_irq_wake(jzgc->irq, on);
3776 }
3777 
ingenic_gpio_irq_handler(struct irq_desc * desc)3778 static void ingenic_gpio_irq_handler(struct irq_desc *desc)
3779 {
3780 	struct gpio_chip *gc = irq_desc_get_handler_data(desc);
3781 	struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
3782 	struct irq_chip *irq_chip = irq_data_get_irq_chip(&desc->irq_data);
3783 	unsigned long flag, i;
3784 
3785 	chained_irq_enter(irq_chip, desc);
3786 
3787 	if (is_soc_or_above(jzgc->jzpc, ID_JZ4770))
3788 		flag = ingenic_gpio_read_reg(jzgc, JZ4770_GPIO_FLAG);
3789 	else if (is_soc_or_above(jzgc->jzpc, ID_JZ4740))
3790 		flag = ingenic_gpio_read_reg(jzgc, JZ4740_GPIO_FLAG);
3791 	else
3792 		flag = ingenic_gpio_read_reg(jzgc, JZ4730_GPIO_GPFR);
3793 
3794 	for_each_set_bit(i, &flag, 32)
3795 		generic_handle_domain_irq(gc->irq.domain, i);
3796 	chained_irq_exit(irq_chip, desc);
3797 }
3798 
ingenic_gpio_set(struct gpio_chip * gc,unsigned int offset,int value)3799 static int ingenic_gpio_set(struct gpio_chip *gc, unsigned int offset,
3800 			    int value)
3801 {
3802 	struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
3803 
3804 	ingenic_gpio_set_value(jzgc, offset, value);
3805 
3806 	return 0;
3807 }
3808 
ingenic_gpio_get(struct gpio_chip * gc,unsigned int offset)3809 static int ingenic_gpio_get(struct gpio_chip *gc, unsigned int offset)
3810 {
3811 	struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
3812 
3813 	return (int) ingenic_gpio_get_value(jzgc, offset);
3814 }
3815 
ingenic_gpio_direction_output(struct gpio_chip * gc,unsigned int offset,int value)3816 static int ingenic_gpio_direction_output(struct gpio_chip *gc,
3817 		unsigned int offset, int value)
3818 {
3819 	ingenic_gpio_set(gc, offset, value);
3820 	return pinctrl_gpio_direction_output(gc, offset);
3821 }
3822 
ingenic_config_pin(struct ingenic_pinctrl * jzpc,unsigned int pin,unsigned int reg,bool set)3823 static inline void ingenic_config_pin(struct ingenic_pinctrl *jzpc,
3824 		unsigned int pin, unsigned int reg, bool set)
3825 {
3826 	unsigned int idx = pin % PINS_PER_GPIO_CHIP;
3827 	unsigned int offt = pin / PINS_PER_GPIO_CHIP;
3828 
3829 	if (set) {
3830 		if (is_soc_or_above(jzpc, ID_JZ4740))
3831 			regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
3832 					REG_SET(reg), BIT(idx));
3833 		else
3834 			regmap_set_bits(jzpc->map, offt * jzpc->info->reg_offset +
3835 					reg, BIT(idx));
3836 	} else {
3837 		if (is_soc_or_above(jzpc, ID_JZ4740))
3838 			regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
3839 					REG_CLEAR(reg), BIT(idx));
3840 		else
3841 			regmap_clear_bits(jzpc->map, offt * jzpc->info->reg_offset +
3842 					reg, BIT(idx));
3843 	}
3844 }
3845 
ingenic_shadow_config_pin(struct ingenic_pinctrl * jzpc,unsigned int pin,u8 reg,bool set)3846 static inline void ingenic_shadow_config_pin(struct ingenic_pinctrl *jzpc,
3847 		unsigned int pin, u8 reg, bool set)
3848 {
3849 	unsigned int idx = pin % PINS_PER_GPIO_CHIP;
3850 
3851 	regmap_write(jzpc->map, REG_PZ_BASE(jzpc->info->reg_offset) +
3852 			(set ? REG_SET(reg) : REG_CLEAR(reg)), BIT(idx));
3853 }
3854 
ingenic_shadow_config_pin_load(struct ingenic_pinctrl * jzpc,unsigned int pin)3855 static inline void ingenic_shadow_config_pin_load(struct ingenic_pinctrl *jzpc,
3856 		unsigned int pin)
3857 {
3858 	regmap_write(jzpc->map, REG_PZ_GID2LD(jzpc->info->reg_offset),
3859 			pin / PINS_PER_GPIO_CHIP);
3860 }
3861 
jz4730_config_pin_function(struct ingenic_pinctrl * jzpc,unsigned int pin,u8 reg_upper,u8 reg_lower,u8 value)3862 static inline void jz4730_config_pin_function(struct ingenic_pinctrl *jzpc,
3863 		unsigned int pin, u8 reg_upper, u8 reg_lower, u8 value)
3864 {
3865 	/*
3866 	 * JZ4730 function and IRQ registers support two-bits-per-pin
3867 	 * definitions, split into two groups of 16.
3868 	 */
3869 	unsigned int idx = pin % JZ4730_PINS_PER_PAIRED_REG;
3870 	unsigned int mask = GENMASK(1, 0) << idx * 2;
3871 	unsigned int offt = pin / PINS_PER_GPIO_CHIP;
3872 	u8 reg = (pin % PINS_PER_GPIO_CHIP) < JZ4730_PINS_PER_PAIRED_REG ? reg_lower : reg_upper;
3873 
3874 	regmap_update_bits(jzpc->map, offt * jzpc->info->reg_offset + reg,
3875 			mask, value << (idx * 2));
3876 }
3877 
ingenic_get_pin_config(struct ingenic_pinctrl * jzpc,unsigned int pin,unsigned int reg)3878 static inline bool ingenic_get_pin_config(struct ingenic_pinctrl *jzpc,
3879 		unsigned int pin, unsigned int reg)
3880 {
3881 	unsigned int idx = pin % PINS_PER_GPIO_CHIP;
3882 	unsigned int offt = pin / PINS_PER_GPIO_CHIP;
3883 	unsigned int val;
3884 
3885 	regmap_read(jzpc->map, offt * jzpc->info->reg_offset + reg, &val);
3886 
3887 	return val & BIT(idx);
3888 }
3889 
ingenic_gpio_get_direction(struct gpio_chip * gc,unsigned int offset)3890 static int ingenic_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
3891 {
3892 	struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
3893 	struct ingenic_pinctrl *jzpc = jzgc->jzpc;
3894 	unsigned int pin = gc->base + offset;
3895 
3896 	if (is_soc_or_above(jzpc, ID_JZ4770)) {
3897 		if (ingenic_get_pin_config(jzpc, pin, JZ4770_GPIO_INT) ||
3898 		    ingenic_get_pin_config(jzpc, pin, JZ4770_GPIO_PAT1))
3899 			return GPIO_LINE_DIRECTION_IN;
3900 		return GPIO_LINE_DIRECTION_OUT;
3901 	} else if (!is_soc_or_above(jzpc, ID_JZ4740)) {
3902 		if (!ingenic_get_pin_config(jzpc, pin, JZ4730_GPIO_GPDIR))
3903 			return GPIO_LINE_DIRECTION_IN;
3904 		return GPIO_LINE_DIRECTION_OUT;
3905 	}
3906 
3907 	if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_SELECT))
3908 		return GPIO_LINE_DIRECTION_IN;
3909 
3910 	if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_DIR))
3911 		return GPIO_LINE_DIRECTION_OUT;
3912 
3913 	return GPIO_LINE_DIRECTION_IN;
3914 }
3915 
3916 static const struct pinctrl_ops ingenic_pctlops = {
3917 	.get_groups_count = pinctrl_generic_get_group_count,
3918 	.get_group_name = pinctrl_generic_get_group_name,
3919 	.get_group_pins = pinctrl_generic_get_group_pins,
3920 	.dt_node_to_map = pinconf_generic_dt_node_to_map_all,
3921 	.dt_free_map = pinconf_generic_dt_free_map,
3922 };
3923 
ingenic_gpio_irq_request(struct irq_data * data)3924 static int ingenic_gpio_irq_request(struct irq_data *data)
3925 {
3926 	struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
3927 	irq_hw_number_t irq = irqd_to_hwirq(data);
3928 	int ret;
3929 
3930 	ret = pinctrl_gpio_direction_input(gpio_chip, irq);
3931 	if (ret)
3932 		return ret;
3933 
3934 	return gpiochip_reqres_irq(gpio_chip, irq);
3935 }
3936 
ingenic_gpio_irq_release(struct irq_data * data)3937 static void ingenic_gpio_irq_release(struct irq_data *data)
3938 {
3939 	struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
3940 	irq_hw_number_t irq = irqd_to_hwirq(data);
3941 
3942 	return gpiochip_relres_irq(gpio_chip, irq);
3943 }
3944 
ingenic_gpio_irq_print_chip(struct irq_data * data,struct seq_file * p)3945 static void ingenic_gpio_irq_print_chip(struct irq_data *data, struct seq_file *p)
3946 {
3947 	struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
3948 
3949 	seq_puts(p, gpio_chip->label);
3950 }
3951 
3952 static const struct irq_chip ingenic_gpio_irqchip = {
3953 	.irq_enable		= ingenic_gpio_irq_enable,
3954 	.irq_disable		= ingenic_gpio_irq_disable,
3955 	.irq_unmask		= ingenic_gpio_irq_unmask,
3956 	.irq_mask		= ingenic_gpio_irq_mask,
3957 	.irq_ack		= ingenic_gpio_irq_ack,
3958 	.irq_set_type		= ingenic_gpio_irq_set_type,
3959 	.irq_set_wake		= ingenic_gpio_irq_set_wake,
3960 	.irq_request_resources	= ingenic_gpio_irq_request,
3961 	.irq_release_resources	= ingenic_gpio_irq_release,
3962 	.irq_print_chip		= ingenic_gpio_irq_print_chip,
3963 	.flags			= IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_IMMUTABLE,
3964 };
3965 
ingenic_pinmux_set_pin_fn(struct ingenic_pinctrl * jzpc,int pin,int func)3966 static int ingenic_pinmux_set_pin_fn(struct ingenic_pinctrl *jzpc,
3967 		int pin, int func)
3968 {
3969 	unsigned int idx = pin % PINS_PER_GPIO_CHIP;
3970 	unsigned int offt = pin / PINS_PER_GPIO_CHIP;
3971 
3972 	dev_dbg(jzpc->dev, "set pin P%c%u to function %u\n",
3973 			'A' + offt, idx, func);
3974 
3975 	if (is_soc_or_above(jzpc, ID_X1000)) {
3976 		ingenic_shadow_config_pin(jzpc, pin, JZ4770_GPIO_INT, false);
3977 		ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, false);
3978 		ingenic_shadow_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, func & 0x2);
3979 		ingenic_shadow_config_pin(jzpc, pin, JZ4770_GPIO_PAT0, func & 0x1);
3980 		ingenic_shadow_config_pin_load(jzpc, pin);
3981 	} else if (is_soc_or_above(jzpc, ID_JZ4770)) {
3982 		ingenic_config_pin(jzpc, pin, JZ4770_GPIO_INT, false);
3983 		ingenic_config_pin(jzpc, pin, GPIO_MSK, false);
3984 		ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, func & 0x2);
3985 		ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT0, func & 0x1);
3986 	} else if (is_soc_or_above(jzpc, ID_JZ4740)) {
3987 		ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, true);
3988 		ingenic_config_pin(jzpc, pin, JZ4740_GPIO_TRIG, func & 0x2);
3989 		ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, func & 0x1);
3990 	} else {
3991 		ingenic_config_pin(jzpc, pin, JZ4730_GPIO_GPIER, false);
3992 		jz4730_config_pin_function(jzpc, pin, JZ4730_GPIO_GPAUR, JZ4730_GPIO_GPALR, func);
3993 	}
3994 
3995 	return 0;
3996 }
3997 
ingenic_pinmux_set_mux(struct pinctrl_dev * pctldev,unsigned int selector,unsigned int group)3998 static int ingenic_pinmux_set_mux(struct pinctrl_dev *pctldev,
3999 		unsigned int selector, unsigned int group)
4000 {
4001 	struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
4002 	const struct function_desc *func;
4003 	struct group_desc *grp;
4004 	unsigned int i;
4005 	uintptr_t mode;
4006 	u8 *pin_modes;
4007 
4008 	func = pinmux_generic_get_function(pctldev, selector);
4009 	if (!func)
4010 		return -EINVAL;
4011 
4012 	grp = pinctrl_generic_get_group(pctldev, group);
4013 	if (!grp)
4014 		return -EINVAL;
4015 
4016 	dev_dbg(pctldev->dev, "enable function %s group %s\n",
4017 		func->func->name, grp->grp.name);
4018 
4019 	mode = (uintptr_t)grp->data;
4020 	if (mode <= 3) {
4021 		for (i = 0; i < grp->grp.npins; i++)
4022 			ingenic_pinmux_set_pin_fn(jzpc, grp->grp.pins[i], mode);
4023 	} else {
4024 		pin_modes = grp->data;
4025 
4026 		for (i = 0; i < grp->grp.npins; i++)
4027 			ingenic_pinmux_set_pin_fn(jzpc, grp->grp.pins[i], pin_modes[i]);
4028 	}
4029 
4030 	return 0;
4031 }
4032 
ingenic_pinmux_gpio_set_direction(struct pinctrl_dev * pctldev,struct pinctrl_gpio_range * range,unsigned int pin,bool input)4033 static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
4034 		struct pinctrl_gpio_range *range,
4035 		unsigned int pin, bool input)
4036 {
4037 	struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
4038 	unsigned int idx = pin % PINS_PER_GPIO_CHIP;
4039 	unsigned int offt = pin / PINS_PER_GPIO_CHIP;
4040 
4041 	dev_dbg(pctldev->dev, "set pin P%c%u to %sput\n",
4042 			'A' + offt, idx, input ? "in" : "out");
4043 
4044 	if (is_soc_or_above(jzpc, ID_X1000)) {
4045 		ingenic_shadow_config_pin(jzpc, pin, JZ4770_GPIO_INT, false);
4046 		ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, true);
4047 		ingenic_shadow_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, input);
4048 		ingenic_shadow_config_pin_load(jzpc, pin);
4049 	} else if (is_soc_or_above(jzpc, ID_JZ4770)) {
4050 		ingenic_config_pin(jzpc, pin, JZ4770_GPIO_INT, false);
4051 		ingenic_config_pin(jzpc, pin, GPIO_MSK, true);
4052 		ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT1, input);
4053 	} else if (is_soc_or_above(jzpc, ID_JZ4740)) {
4054 		ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, false);
4055 		ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, !input);
4056 		ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, false);
4057 	} else {
4058 		ingenic_config_pin(jzpc, pin, JZ4730_GPIO_GPIER, false);
4059 		ingenic_config_pin(jzpc, pin, JZ4730_GPIO_GPDIR, !input);
4060 		jz4730_config_pin_function(jzpc, pin, JZ4730_GPIO_GPAUR, JZ4730_GPIO_GPALR, 0);
4061 	}
4062 
4063 	return 0;
4064 }
4065 
4066 static const struct pinmux_ops ingenic_pmxops = {
4067 	.get_functions_count = pinmux_generic_get_function_count,
4068 	.get_function_name = pinmux_generic_get_function_name,
4069 	.get_function_groups = pinmux_generic_get_function_groups,
4070 	.set_mux = ingenic_pinmux_set_mux,
4071 	.gpio_set_direction = ingenic_pinmux_gpio_set_direction,
4072 };
4073 
ingenic_pinconf_get(struct pinctrl_dev * pctldev,unsigned int pin,unsigned long * config)4074 static int ingenic_pinconf_get(struct pinctrl_dev *pctldev,
4075 		unsigned int pin, unsigned long *config)
4076 {
4077 	struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
4078 	enum pin_config_param param = pinconf_to_config_param(*config);
4079 	unsigned int idx = pin % PINS_PER_GPIO_CHIP;
4080 	unsigned int offt = pin / PINS_PER_GPIO_CHIP;
4081 	unsigned int arg = 1;
4082 	unsigned int bias, reg;
4083 	bool pull, pullup, pulldown;
4084 
4085 	if (is_soc_or_above(jzpc, ID_X2000)) {
4086 		pullup = ingenic_get_pin_config(jzpc, pin, X2000_GPIO_PEPU) &&
4087 				!ingenic_get_pin_config(jzpc, pin, X2000_GPIO_PEPD) &&
4088 				(jzpc->info->pull_ups[offt] & BIT(idx));
4089 		pulldown = ingenic_get_pin_config(jzpc, pin, X2000_GPIO_PEPD) &&
4090 				!ingenic_get_pin_config(jzpc, pin, X2000_GPIO_PEPU) &&
4091 				(jzpc->info->pull_downs[offt] & BIT(idx));
4092 
4093 	} else if (is_soc_or_above(jzpc, ID_X1830)) {
4094 		unsigned int half = PINS_PER_GPIO_CHIP / 2;
4095 		unsigned int idxh = (pin % half) * 2;
4096 
4097 		if (idx < half)
4098 			regmap_read(jzpc->map, offt * jzpc->info->reg_offset +
4099 					X1830_GPIO_PEL, &bias);
4100 		else
4101 			regmap_read(jzpc->map, offt * jzpc->info->reg_offset +
4102 					X1830_GPIO_PEH, &bias);
4103 
4104 		bias = (bias >> idxh) & (GPIO_PULL_UP | GPIO_PULL_DOWN);
4105 
4106 		pullup = (bias == GPIO_PULL_UP) && (jzpc->info->pull_ups[offt] & BIT(idx));
4107 		pulldown = (bias == GPIO_PULL_DOWN) && (jzpc->info->pull_downs[offt] & BIT(idx));
4108 
4109 	} else {
4110 		if (is_soc_or_above(jzpc, ID_X1600))
4111 			pull = ingenic_get_pin_config(jzpc, pin, X1600_GPIO_PU);
4112 		else if (is_soc_or_above(jzpc, ID_JZ4770))
4113 			pull = !ingenic_get_pin_config(jzpc, pin, JZ4770_GPIO_PEN);
4114 		else if (is_soc_or_above(jzpc, ID_JZ4740))
4115 			pull = !ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_PULL_DIS);
4116 		else
4117 			pull = ingenic_get_pin_config(jzpc, pin, JZ4730_GPIO_GPPUR);
4118 
4119 		pullup = pull && (jzpc->info->pull_ups[offt] & BIT(idx));
4120 		pulldown = pull && (jzpc->info->pull_downs[offt] & BIT(idx));
4121 	}
4122 
4123 	switch (param) {
4124 	case PIN_CONFIG_BIAS_DISABLE:
4125 		if (pullup || pulldown)
4126 			return -EINVAL;
4127 
4128 		break;
4129 
4130 	case PIN_CONFIG_BIAS_PULL_UP:
4131 		if (!pullup)
4132 			return -EINVAL;
4133 
4134 		break;
4135 
4136 	case PIN_CONFIG_BIAS_PULL_DOWN:
4137 		if (!pulldown)
4138 			return -EINVAL;
4139 
4140 		break;
4141 
4142 	case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
4143 		if (is_soc_or_above(jzpc, ID_X2000))
4144 			reg = X2000_GPIO_SMT;
4145 		else if (is_soc_or_above(jzpc, ID_X1830))
4146 			reg = X1830_GPIO_SMT;
4147 		else
4148 			return -EINVAL;
4149 
4150 		arg = !!ingenic_get_pin_config(jzpc, pin, reg);
4151 		break;
4152 
4153 	case PIN_CONFIG_SLEW_RATE:
4154 		if (is_soc_or_above(jzpc, ID_X2000))
4155 			reg = X2000_GPIO_SR;
4156 		else if (is_soc_or_above(jzpc, ID_X1830))
4157 			reg = X1830_GPIO_SR;
4158 		else
4159 			return -EINVAL;
4160 
4161 		arg = !!ingenic_get_pin_config(jzpc, pin, reg);
4162 		break;
4163 
4164 	default:
4165 		return -ENOTSUPP;
4166 	}
4167 
4168 	*config = pinconf_to_config_packed(param, arg);
4169 	return 0;
4170 }
4171 
ingenic_set_bias(struct ingenic_pinctrl * jzpc,unsigned int pin,unsigned int bias)4172 static void ingenic_set_bias(struct ingenic_pinctrl *jzpc,
4173 		unsigned int pin, unsigned int bias)
4174 {
4175 	if (is_soc_or_above(jzpc, ID_X2000)) {
4176 		switch (bias) {
4177 		case GPIO_PULL_UP:
4178 			ingenic_config_pin(jzpc, pin, X2000_GPIO_PEPD, false);
4179 			ingenic_config_pin(jzpc, pin, X2000_GPIO_PEPU, true);
4180 			break;
4181 
4182 		case GPIO_PULL_DOWN:
4183 			ingenic_config_pin(jzpc, pin, X2000_GPIO_PEPU, false);
4184 			ingenic_config_pin(jzpc, pin, X2000_GPIO_PEPD, true);
4185 			break;
4186 
4187 		case GPIO_PULL_DIS:
4188 		default:
4189 			ingenic_config_pin(jzpc, pin, X2000_GPIO_PEPU, false);
4190 			ingenic_config_pin(jzpc, pin, X2000_GPIO_PEPD, false);
4191 		}
4192 
4193 	} else if (is_soc_or_above(jzpc, ID_X1830)) {
4194 		unsigned int idx = pin % PINS_PER_GPIO_CHIP;
4195 		unsigned int half = PINS_PER_GPIO_CHIP / 2;
4196 		unsigned int idxh = (pin % half) * 2;
4197 		unsigned int offt = pin / PINS_PER_GPIO_CHIP;
4198 
4199 		if (idx < half) {
4200 			regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
4201 					REG_CLEAR(X1830_GPIO_PEL), 3 << idxh);
4202 			regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
4203 					REG_SET(X1830_GPIO_PEL), bias << idxh);
4204 		} else {
4205 			regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
4206 					REG_CLEAR(X1830_GPIO_PEH), 3 << idxh);
4207 			regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
4208 					REG_SET(X1830_GPIO_PEH), bias << idxh);
4209 		}
4210 
4211 	} else if (is_soc_or_above(jzpc, ID_X1600)) {
4212 		ingenic_config_pin(jzpc, pin, X1600_GPIO_PU, bias);
4213 	} else if (is_soc_or_above(jzpc, ID_JZ4770)) {
4214 		ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PEN, !bias);
4215 	} else if (is_soc_or_above(jzpc, ID_JZ4740)) {
4216 		ingenic_config_pin(jzpc, pin, JZ4740_GPIO_PULL_DIS, !bias);
4217 	} else {
4218 		ingenic_config_pin(jzpc, pin, JZ4730_GPIO_GPPUR, bias);
4219 	}
4220 }
4221 
ingenic_set_schmitt_trigger(struct ingenic_pinctrl * jzpc,unsigned int pin,bool enable)4222 static void ingenic_set_schmitt_trigger(struct ingenic_pinctrl *jzpc,
4223 		unsigned int pin, bool enable)
4224 {
4225 	if (is_soc_or_above(jzpc, ID_X2000))
4226 		ingenic_config_pin(jzpc, pin, X2000_GPIO_SMT, enable);
4227 	else
4228 		ingenic_config_pin(jzpc, pin, X1830_GPIO_SMT, enable);
4229 }
4230 
ingenic_set_output_level(struct ingenic_pinctrl * jzpc,unsigned int pin,bool high)4231 static void ingenic_set_output_level(struct ingenic_pinctrl *jzpc,
4232 				     unsigned int pin, bool high)
4233 {
4234 	if (is_soc_or_above(jzpc, ID_JZ4770))
4235 		ingenic_config_pin(jzpc, pin, JZ4770_GPIO_PAT0, high);
4236 	else if (is_soc_or_above(jzpc, ID_JZ4740))
4237 		ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DATA, high);
4238 	else
4239 		ingenic_config_pin(jzpc, pin, JZ4730_GPIO_DATA, high);
4240 }
4241 
ingenic_set_slew_rate(struct ingenic_pinctrl * jzpc,unsigned int pin,unsigned int slew)4242 static void ingenic_set_slew_rate(struct ingenic_pinctrl *jzpc,
4243 		unsigned int pin, unsigned int slew)
4244 {
4245 	if (is_soc_or_above(jzpc, ID_X2000))
4246 		ingenic_config_pin(jzpc, pin, X2000_GPIO_SR, slew);
4247 	else
4248 		ingenic_config_pin(jzpc, pin, X1830_GPIO_SR, slew);
4249 }
4250 
ingenic_pinconf_set(struct pinctrl_dev * pctldev,unsigned int pin,unsigned long * configs,unsigned int num_configs)4251 static int ingenic_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
4252 		unsigned long *configs, unsigned int num_configs)
4253 {
4254 	struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
4255 	unsigned int idx = pin % PINS_PER_GPIO_CHIP;
4256 	unsigned int offt = pin / PINS_PER_GPIO_CHIP;
4257 	unsigned int cfg, arg;
4258 	int ret;
4259 
4260 	for (cfg = 0; cfg < num_configs; cfg++) {
4261 		switch (pinconf_to_config_param(configs[cfg])) {
4262 		case PIN_CONFIG_BIAS_DISABLE:
4263 		case PIN_CONFIG_BIAS_PULL_UP:
4264 		case PIN_CONFIG_BIAS_PULL_DOWN:
4265 		case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
4266 		case PIN_CONFIG_LEVEL:
4267 		case PIN_CONFIG_SLEW_RATE:
4268 			continue;
4269 		default:
4270 			return -ENOTSUPP;
4271 		}
4272 	}
4273 
4274 	for (cfg = 0; cfg < num_configs; cfg++) {
4275 		arg = pinconf_to_config_argument(configs[cfg]);
4276 
4277 		switch (pinconf_to_config_param(configs[cfg])) {
4278 		case PIN_CONFIG_BIAS_DISABLE:
4279 			dev_dbg(jzpc->dev, "disable pull-over for pin P%c%u\n",
4280 					'A' + offt, idx);
4281 			ingenic_set_bias(jzpc, pin, GPIO_PULL_DIS);
4282 			break;
4283 
4284 		case PIN_CONFIG_BIAS_PULL_UP:
4285 			if (!(jzpc->info->pull_ups[offt] & BIT(idx)))
4286 				return -EINVAL;
4287 			dev_dbg(jzpc->dev, "set pull-up for pin P%c%u\n",
4288 					'A' + offt, idx);
4289 			ingenic_set_bias(jzpc, pin, GPIO_PULL_UP);
4290 			break;
4291 
4292 		case PIN_CONFIG_BIAS_PULL_DOWN:
4293 			if (!(jzpc->info->pull_downs[offt] & BIT(idx)))
4294 				return -EINVAL;
4295 			dev_dbg(jzpc->dev, "set pull-down for pin P%c%u\n",
4296 					'A' + offt, idx);
4297 			ingenic_set_bias(jzpc, pin, GPIO_PULL_DOWN);
4298 			break;
4299 
4300 		case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
4301 			if (!is_soc_or_above(jzpc, ID_X1830))
4302 				return -EINVAL;
4303 
4304 			ingenic_set_schmitt_trigger(jzpc, pin, arg);
4305 			break;
4306 
4307 		case PIN_CONFIG_LEVEL:
4308 			ret = pinctrl_gpio_direction_output(jzpc->gc,
4309 							pin - jzpc->gc->base);
4310 			if (ret)
4311 				return ret;
4312 
4313 			ingenic_set_output_level(jzpc, pin, arg);
4314 			break;
4315 
4316 		case PIN_CONFIG_SLEW_RATE:
4317 			if (!is_soc_or_above(jzpc, ID_X1830))
4318 				return -EINVAL;
4319 
4320 			ingenic_set_slew_rate(jzpc, pin, arg);
4321 			break;
4322 
4323 		default:
4324 			/* unreachable */
4325 			break;
4326 		}
4327 	}
4328 
4329 	return 0;
4330 }
4331 
ingenic_pinconf_group_get(struct pinctrl_dev * pctldev,unsigned int group,unsigned long * config)4332 static int ingenic_pinconf_group_get(struct pinctrl_dev *pctldev,
4333 		unsigned int group, unsigned long *config)
4334 {
4335 	const unsigned int *pins;
4336 	unsigned int i, npins;
4337 	unsigned long old = 0;
4338 	int ret;
4339 
4340 	ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
4341 	if (ret)
4342 		return ret;
4343 
4344 	for (i = 0; i < npins; i++) {
4345 		if (ingenic_pinconf_get(pctldev, pins[i], config))
4346 			return -ENOTSUPP;
4347 
4348 		/* configs do not match between two pins */
4349 		if (i && (old != *config))
4350 			return -ENOTSUPP;
4351 
4352 		old = *config;
4353 	}
4354 
4355 	return 0;
4356 }
4357 
ingenic_pinconf_group_set(struct pinctrl_dev * pctldev,unsigned int group,unsigned long * configs,unsigned int num_configs)4358 static int ingenic_pinconf_group_set(struct pinctrl_dev *pctldev,
4359 		unsigned int group, unsigned long *configs,
4360 		unsigned int num_configs)
4361 {
4362 	const unsigned int *pins;
4363 	unsigned int i, npins;
4364 	int ret;
4365 
4366 	ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
4367 	if (ret)
4368 		return ret;
4369 
4370 	for (i = 0; i < npins; i++) {
4371 		ret = ingenic_pinconf_set(pctldev,
4372 				pins[i], configs, num_configs);
4373 		if (ret)
4374 			return ret;
4375 	}
4376 
4377 	return 0;
4378 }
4379 
4380 static const struct pinconf_ops ingenic_confops = {
4381 	.is_generic = true,
4382 	.pin_config_get = ingenic_pinconf_get,
4383 	.pin_config_set = ingenic_pinconf_set,
4384 	.pin_config_group_get = ingenic_pinconf_group_get,
4385 	.pin_config_group_set = ingenic_pinconf_group_set,
4386 };
4387 
4388 static const struct regmap_config ingenic_pinctrl_regmap_config = {
4389 	.reg_bits = 32,
4390 	.val_bits = 32,
4391 	.reg_stride = 4,
4392 };
4393 
4394 static const struct of_device_id ingenic_gpio_of_matches[] __initconst = {
4395 	{ .compatible = "ingenic,jz4730-gpio" },
4396 	{ .compatible = "ingenic,jz4740-gpio" },
4397 	{ .compatible = "ingenic,jz4725b-gpio" },
4398 	{ .compatible = "ingenic,jz4750-gpio" },
4399 	{ .compatible = "ingenic,jz4755-gpio" },
4400 	{ .compatible = "ingenic,jz4760-gpio" },
4401 	{ .compatible = "ingenic,jz4770-gpio" },
4402 	{ .compatible = "ingenic,jz4775-gpio" },
4403 	{ .compatible = "ingenic,jz4780-gpio" },
4404 	{ .compatible = "ingenic,x1000-gpio" },
4405 	{ .compatible = "ingenic,x1600-gpio" },
4406 	{ .compatible = "ingenic,x1830-gpio" },
4407 	{ .compatible = "ingenic,x2000-gpio" },
4408 	{ .compatible = "ingenic,x2100-gpio" },
4409 	{},
4410 };
4411 
ingenic_gpio_probe(struct ingenic_pinctrl * jzpc,struct fwnode_handle * fwnode)4412 static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,
4413 				     struct fwnode_handle *fwnode)
4414 {
4415 	struct ingenic_gpio_chip *jzgc;
4416 	struct device *dev = jzpc->dev;
4417 	struct gpio_irq_chip *girq;
4418 	unsigned int bank;
4419 	int err;
4420 
4421 	err = fwnode_property_read_u32(fwnode, "reg", &bank);
4422 	if (err) {
4423 		dev_err(dev, "Cannot read \"reg\" property: %i\n", err);
4424 		return err;
4425 	}
4426 
4427 	jzgc = devm_kzalloc(dev, sizeof(*jzgc), GFP_KERNEL);
4428 	if (!jzgc)
4429 		return -ENOMEM;
4430 
4431 	jzpc->gc = &jzgc->gc;
4432 
4433 	jzgc->jzpc = jzpc;
4434 	jzgc->reg_base = bank * jzpc->info->reg_offset;
4435 
4436 	jzgc->gc.label = devm_kasprintf(dev, GFP_KERNEL, "GPIO%c", 'A' + bank);
4437 	if (!jzgc->gc.label)
4438 		return -ENOMEM;
4439 
4440 	/* DO NOT EXPAND THIS: FOR BACKWARD GPIO NUMBERSPACE COMPATIBIBILITY
4441 	 * ONLY: WORK TO TRANSITION CONSUMERS TO USE THE GPIO DESCRIPTOR API IN
4442 	 * <linux/gpio/consumer.h> INSTEAD.
4443 	 */
4444 	jzgc->gc.base = bank * 32;
4445 
4446 	jzgc->gc.ngpio = 32;
4447 	jzgc->gc.parent = dev;
4448 	jzgc->gc.fwnode = fwnode;
4449 	jzgc->gc.owner = THIS_MODULE;
4450 
4451 	jzgc->gc.set = ingenic_gpio_set;
4452 	jzgc->gc.get = ingenic_gpio_get;
4453 	jzgc->gc.direction_input = pinctrl_gpio_direction_input;
4454 	jzgc->gc.direction_output = ingenic_gpio_direction_output;
4455 	jzgc->gc.get_direction = ingenic_gpio_get_direction;
4456 	jzgc->gc.request = gpiochip_generic_request;
4457 	jzgc->gc.free = gpiochip_generic_free;
4458 
4459 	err = fwnode_irq_get(fwnode, 0);
4460 	if (err < 0)
4461 		return err;
4462 	if (!err)
4463 		return -EINVAL;
4464 	jzgc->irq = err;
4465 
4466 	girq = &jzgc->gc.irq;
4467 	gpio_irq_chip_set_chip(girq, &ingenic_gpio_irqchip);
4468 	girq->parent_handler = ingenic_gpio_irq_handler;
4469 	girq->num_parents = 1;
4470 	girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
4471 				     GFP_KERNEL);
4472 	if (!girq->parents)
4473 		return -ENOMEM;
4474 
4475 	girq->parents[0] = jzgc->irq;
4476 	girq->default_type = IRQ_TYPE_NONE;
4477 	girq->handler = handle_level_irq;
4478 
4479 	err = devm_gpiochip_add_data(dev, &jzgc->gc, jzgc);
4480 	if (err)
4481 		return err;
4482 
4483 	return 0;
4484 }
4485 
ingenic_pinctrl_probe(struct platform_device * pdev)4486 static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
4487 {
4488 	struct device *dev = &pdev->dev;
4489 	struct ingenic_pinctrl *jzpc;
4490 	struct pinctrl_desc *pctl_desc;
4491 	void __iomem *base;
4492 	const struct ingenic_chip_info *chip_info;
4493 	struct regmap_config regmap_config;
4494 	struct fwnode_handle *fwnode;
4495 	unsigned int i;
4496 	int err;
4497 
4498 	chip_info = device_get_match_data(dev);
4499 	if (!chip_info) {
4500 		dev_err(dev, "Unsupported SoC\n");
4501 		return -EINVAL;
4502 	}
4503 
4504 	jzpc = devm_kzalloc(dev, sizeof(*jzpc), GFP_KERNEL);
4505 	if (!jzpc)
4506 		return -ENOMEM;
4507 
4508 	base = devm_platform_ioremap_resource(pdev, 0);
4509 	if (IS_ERR(base))
4510 		return PTR_ERR(base);
4511 
4512 	regmap_config = ingenic_pinctrl_regmap_config;
4513 	if (chip_info->access_table) {
4514 		regmap_config.rd_table = chip_info->access_table;
4515 		regmap_config.wr_table = chip_info->access_table;
4516 	} else {
4517 		regmap_config.max_register = chip_info->num_chips * chip_info->reg_offset - 4;
4518 	}
4519 
4520 	jzpc->map = devm_regmap_init_mmio(dev, base, &regmap_config);
4521 	if (IS_ERR(jzpc->map)) {
4522 		dev_err(dev, "Failed to create regmap\n");
4523 		return PTR_ERR(jzpc->map);
4524 	}
4525 
4526 	jzpc->dev = dev;
4527 	jzpc->info = chip_info;
4528 
4529 	pctl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctl_desc), GFP_KERNEL);
4530 	if (!pctl_desc)
4531 		return -ENOMEM;
4532 
4533 	/* fill in pinctrl_desc structure */
4534 	pctl_desc->name = dev_name(dev);
4535 	pctl_desc->owner = THIS_MODULE;
4536 	pctl_desc->pctlops = &ingenic_pctlops;
4537 	pctl_desc->pmxops = &ingenic_pmxops;
4538 	pctl_desc->confops = &ingenic_confops;
4539 	pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP;
4540 	pctl_desc->pins = jzpc->pdesc = devm_kcalloc(&pdev->dev,
4541 			pctl_desc->npins, sizeof(*jzpc->pdesc), GFP_KERNEL);
4542 	if (!jzpc->pdesc)
4543 		return -ENOMEM;
4544 
4545 	for (i = 0; i < pctl_desc->npins; i++) {
4546 		jzpc->pdesc[i].number = i;
4547 		jzpc->pdesc[i].name = kasprintf(GFP_KERNEL, "P%c%d",
4548 						'A' + (i / PINS_PER_GPIO_CHIP),
4549 						i % PINS_PER_GPIO_CHIP);
4550 	}
4551 
4552 	jzpc->pctl = devm_pinctrl_register(dev, pctl_desc, jzpc);
4553 	if (IS_ERR(jzpc->pctl)) {
4554 		dev_err(dev, "Failed to register pinctrl\n");
4555 		return PTR_ERR(jzpc->pctl);
4556 	}
4557 
4558 	for (i = 0; i < chip_info->num_groups; i++) {
4559 		const struct group_desc *group = &chip_info->groups[i];
4560 		const struct pingroup *grp = &group->grp;
4561 
4562 		err = pinctrl_generic_add_group(jzpc->pctl, grp->name, grp->pins, grp->npins,
4563 						group->data);
4564 		if (err < 0) {
4565 			dev_err(dev, "Failed to register group %s\n", grp->name);
4566 			return err;
4567 		}
4568 	}
4569 
4570 	for (i = 0; i < chip_info->num_functions; i++) {
4571 		const struct pinfunction *func = &chip_info->functions[i];
4572 
4573 		err = pinmux_generic_add_pinfunction(jzpc->pctl, func, NULL);
4574 		if (err < 0) {
4575 			dev_err(dev, "Failed to register function %s\n", func->name);
4576 			return err;
4577 		}
4578 	}
4579 
4580 	dev_set_drvdata(dev, jzpc->map);
4581 
4582 	device_for_each_child_node(dev, fwnode) {
4583 		if (of_match_node(ingenic_gpio_of_matches, to_of_node(fwnode))) {
4584 			err = ingenic_gpio_probe(jzpc, fwnode);
4585 			if (err) {
4586 				fwnode_handle_put(fwnode);
4587 				return err;
4588 			}
4589 		}
4590 	}
4591 
4592 	return 0;
4593 }
4594 
4595 #define IF_ENABLED(cfg, ptr)	PTR_IF(IS_ENABLED(cfg), (ptr))
4596 
4597 static const struct of_device_id ingenic_pinctrl_of_matches[] = {
4598 	{
4599 		.compatible = "ingenic,jz4730-pinctrl",
4600 		.data = IF_ENABLED(CONFIG_MACH_JZ4730, &jz4730_chip_info)
4601 	},
4602 	{
4603 		.compatible = "ingenic,jz4740-pinctrl",
4604 		.data = IF_ENABLED(CONFIG_MACH_JZ4740, &jz4740_chip_info)
4605 	},
4606 	{
4607 		.compatible = "ingenic,jz4725b-pinctrl",
4608 		.data = IF_ENABLED(CONFIG_MACH_JZ4725B, &jz4725b_chip_info)
4609 	},
4610 	{
4611 		.compatible = "ingenic,jz4750-pinctrl",
4612 		.data = IF_ENABLED(CONFIG_MACH_JZ4750, &jz4750_chip_info)
4613 	},
4614 	{
4615 		.compatible = "ingenic,jz4755-pinctrl",
4616 		.data = IF_ENABLED(CONFIG_MACH_JZ4755, &jz4755_chip_info)
4617 	},
4618 	{
4619 		.compatible = "ingenic,jz4760-pinctrl",
4620 		.data = IF_ENABLED(CONFIG_MACH_JZ4760, &jz4760_chip_info)
4621 	},
4622 	{
4623 		.compatible = "ingenic,jz4760b-pinctrl",
4624 		.data = IF_ENABLED(CONFIG_MACH_JZ4760, &jz4760_chip_info)
4625 	},
4626 	{
4627 		.compatible = "ingenic,jz4770-pinctrl",
4628 		.data = IF_ENABLED(CONFIG_MACH_JZ4770, &jz4770_chip_info)
4629 	},
4630 	{
4631 		.compatible = "ingenic,jz4775-pinctrl",
4632 		.data = IF_ENABLED(CONFIG_MACH_JZ4775, &jz4775_chip_info)
4633 	},
4634 	{
4635 		.compatible = "ingenic,jz4780-pinctrl",
4636 		.data = IF_ENABLED(CONFIG_MACH_JZ4780, &jz4780_chip_info)
4637 	},
4638 	{
4639 		.compatible = "ingenic,x1000-pinctrl",
4640 		.data = IF_ENABLED(CONFIG_MACH_X1000, &x1000_chip_info)
4641 	},
4642 	{
4643 		.compatible = "ingenic,x1000e-pinctrl",
4644 		.data = IF_ENABLED(CONFIG_MACH_X1000, &x1000_chip_info)
4645 	},
4646 	{
4647 		.compatible = "ingenic,x1500-pinctrl",
4648 		.data = IF_ENABLED(CONFIG_MACH_X1500, &x1500_chip_info)
4649 	},
4650 	{
4651 		.compatible = "ingenic,x1600-pinctrl",
4652 		.data = IF_ENABLED(CONFIG_MACH_X1600, &x1600_chip_info)
4653 	},
4654 	{
4655 		.compatible = "ingenic,x1830-pinctrl",
4656 		.data = IF_ENABLED(CONFIG_MACH_X1830, &x1830_chip_info)
4657 	},
4658 	{
4659 		.compatible = "ingenic,x2000-pinctrl",
4660 		.data = IF_ENABLED(CONFIG_MACH_X2000, &x2000_chip_info)
4661 	},
4662 	{
4663 		.compatible = "ingenic,x2000e-pinctrl",
4664 		.data = IF_ENABLED(CONFIG_MACH_X2000, &x2000_chip_info)
4665 	},
4666 	{
4667 		.compatible = "ingenic,x2100-pinctrl",
4668 		.data = IF_ENABLED(CONFIG_MACH_X2100, &x2100_chip_info)
4669 	},
4670 	{ /* sentinel */ },
4671 };
4672 
4673 static struct platform_driver ingenic_pinctrl_driver = {
4674 	.driver = {
4675 		.name = "pinctrl-ingenic",
4676 		.of_match_table = ingenic_pinctrl_of_matches,
4677 	},
4678 };
4679 
ingenic_pinctrl_drv_register(void)4680 static int __init ingenic_pinctrl_drv_register(void)
4681 {
4682 	return platform_driver_probe(&ingenic_pinctrl_driver,
4683 				     ingenic_pinctrl_probe);
4684 }
4685 subsys_initcall(ingenic_pinctrl_drv_register);
4686