1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Ingenic SoCs pinctrl driver
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Copyright (c) 2017 Paul Cercueil <paul@crapouillou.net>
6*4882a593Smuzhiyun * Copyright (c) 2019 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
7*4882a593Smuzhiyun * Copyright (c) 2017, 2019 Paul Boddie <paul@boddie.org.uk>
8*4882a593Smuzhiyun */
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun #include <linux/compiler.h>
11*4882a593Smuzhiyun #include <linux/gpio/driver.h>
12*4882a593Smuzhiyun #include <linux/interrupt.h>
13*4882a593Smuzhiyun #include <linux/io.h>
14*4882a593Smuzhiyun #include <linux/of_device.h>
15*4882a593Smuzhiyun #include <linux/of_irq.h>
16*4882a593Smuzhiyun #include <linux/of_platform.h>
17*4882a593Smuzhiyun #include <linux/pinctrl/pinctrl.h>
18*4882a593Smuzhiyun #include <linux/pinctrl/pinmux.h>
19*4882a593Smuzhiyun #include <linux/pinctrl/pinconf.h>
20*4882a593Smuzhiyun #include <linux/pinctrl/pinconf-generic.h>
21*4882a593Smuzhiyun #include <linux/platform_device.h>
22*4882a593Smuzhiyun #include <linux/regmap.h>
23*4882a593Smuzhiyun #include <linux/slab.h>
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun #include "core.h"
26*4882a593Smuzhiyun #include "pinconf.h"
27*4882a593Smuzhiyun #include "pinmux.h"
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun #define GPIO_PIN 0x00
30*4882a593Smuzhiyun #define GPIO_MSK 0x20
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun #define JZ4740_GPIO_DATA 0x10
33*4882a593Smuzhiyun #define JZ4740_GPIO_PULL_DIS 0x30
34*4882a593Smuzhiyun #define JZ4740_GPIO_FUNC 0x40
35*4882a593Smuzhiyun #define JZ4740_GPIO_SELECT 0x50
36*4882a593Smuzhiyun #define JZ4740_GPIO_DIR 0x60
37*4882a593Smuzhiyun #define JZ4740_GPIO_TRIG 0x70
38*4882a593Smuzhiyun #define JZ4740_GPIO_FLAG 0x80
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun #define JZ4760_GPIO_INT 0x10
41*4882a593Smuzhiyun #define JZ4760_GPIO_PAT1 0x30
42*4882a593Smuzhiyun #define JZ4760_GPIO_PAT0 0x40
43*4882a593Smuzhiyun #define JZ4760_GPIO_FLAG 0x50
44*4882a593Smuzhiyun #define JZ4760_GPIO_PEN 0x70
45*4882a593Smuzhiyun
46*4882a593Smuzhiyun #define X1830_GPIO_PEL 0x110
47*4882a593Smuzhiyun #define X1830_GPIO_PEH 0x120
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun #define REG_SET(x) ((x) + 0x4)
50*4882a593Smuzhiyun #define REG_CLEAR(x) ((x) + 0x8)
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun #define REG_PZ_BASE(x) ((x) * 7)
53*4882a593Smuzhiyun #define REG_PZ_GID2LD(x) ((x) * 7 + 0xf0)
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun #define GPIO_PULL_DIS 0
56*4882a593Smuzhiyun #define GPIO_PULL_UP 1
57*4882a593Smuzhiyun #define GPIO_PULL_DOWN 2
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun #define PINS_PER_GPIO_CHIP 32
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun enum jz_version {
62*4882a593Smuzhiyun ID_JZ4740,
63*4882a593Smuzhiyun ID_JZ4725B,
64*4882a593Smuzhiyun ID_JZ4760,
65*4882a593Smuzhiyun ID_JZ4770,
66*4882a593Smuzhiyun ID_JZ4780,
67*4882a593Smuzhiyun ID_X1000,
68*4882a593Smuzhiyun ID_X1500,
69*4882a593Smuzhiyun ID_X1830,
70*4882a593Smuzhiyun };
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun struct ingenic_chip_info {
73*4882a593Smuzhiyun unsigned int num_chips;
74*4882a593Smuzhiyun unsigned int reg_offset;
75*4882a593Smuzhiyun enum jz_version version;
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun const struct group_desc *groups;
78*4882a593Smuzhiyun unsigned int num_groups;
79*4882a593Smuzhiyun
80*4882a593Smuzhiyun const struct function_desc *functions;
81*4882a593Smuzhiyun unsigned int num_functions;
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun const u32 *pull_ups, *pull_downs;
84*4882a593Smuzhiyun };
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun struct ingenic_pinctrl {
87*4882a593Smuzhiyun struct device *dev;
88*4882a593Smuzhiyun struct regmap *map;
89*4882a593Smuzhiyun struct pinctrl_dev *pctl;
90*4882a593Smuzhiyun struct pinctrl_pin_desc *pdesc;
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun const struct ingenic_chip_info *info;
93*4882a593Smuzhiyun };
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun struct ingenic_gpio_chip {
96*4882a593Smuzhiyun struct ingenic_pinctrl *jzpc;
97*4882a593Smuzhiyun struct gpio_chip gc;
98*4882a593Smuzhiyun struct irq_chip irq_chip;
99*4882a593Smuzhiyun unsigned int irq, reg_base;
100*4882a593Smuzhiyun };
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun static const u32 jz4740_pull_ups[4] = {
103*4882a593Smuzhiyun 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
104*4882a593Smuzhiyun };
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun static const u32 jz4740_pull_downs[4] = {
107*4882a593Smuzhiyun 0x00000000, 0x00000000, 0x00000000, 0x00000000,
108*4882a593Smuzhiyun };
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun static int jz4740_mmc_1bit_pins[] = { 0x69, 0x68, 0x6a, };
111*4882a593Smuzhiyun static int jz4740_mmc_4bit_pins[] = { 0x6b, 0x6c, 0x6d, };
112*4882a593Smuzhiyun static int jz4740_uart0_data_pins[] = { 0x7a, 0x79, };
113*4882a593Smuzhiyun static int jz4740_uart0_hwflow_pins[] = { 0x7e, 0x7f, };
114*4882a593Smuzhiyun static int jz4740_uart1_data_pins[] = { 0x7e, 0x7f, };
115*4882a593Smuzhiyun static int jz4740_lcd_8bit_pins[] = {
116*4882a593Smuzhiyun 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x52, 0x53, 0x54,
117*4882a593Smuzhiyun };
118*4882a593Smuzhiyun static int jz4740_lcd_16bit_pins[] = {
119*4882a593Smuzhiyun 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x55,
120*4882a593Smuzhiyun };
121*4882a593Smuzhiyun static int jz4740_lcd_18bit_pins[] = { 0x50, 0x51, };
122*4882a593Smuzhiyun static int jz4740_lcd_18bit_tft_pins[] = { 0x56, 0x57, 0x31, 0x32, };
123*4882a593Smuzhiyun static int jz4740_nand_cs1_pins[] = { 0x39, };
124*4882a593Smuzhiyun static int jz4740_nand_cs2_pins[] = { 0x3a, };
125*4882a593Smuzhiyun static int jz4740_nand_cs3_pins[] = { 0x3b, };
126*4882a593Smuzhiyun static int jz4740_nand_cs4_pins[] = { 0x3c, };
127*4882a593Smuzhiyun static int jz4740_nand_fre_fwe_pins[] = { 0x5c, 0x5d, };
128*4882a593Smuzhiyun static int jz4740_pwm_pwm0_pins[] = { 0x77, };
129*4882a593Smuzhiyun static int jz4740_pwm_pwm1_pins[] = { 0x78, };
130*4882a593Smuzhiyun static int jz4740_pwm_pwm2_pins[] = { 0x79, };
131*4882a593Smuzhiyun static int jz4740_pwm_pwm3_pins[] = { 0x7a, };
132*4882a593Smuzhiyun static int jz4740_pwm_pwm4_pins[] = { 0x7b, };
133*4882a593Smuzhiyun static int jz4740_pwm_pwm5_pins[] = { 0x7c, };
134*4882a593Smuzhiyun static int jz4740_pwm_pwm6_pins[] = { 0x7e, };
135*4882a593Smuzhiyun static int jz4740_pwm_pwm7_pins[] = { 0x7f, };
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun static int jz4740_mmc_1bit_funcs[] = { 0, 0, 0, };
138*4882a593Smuzhiyun static int jz4740_mmc_4bit_funcs[] = { 0, 0, 0, };
139*4882a593Smuzhiyun static int jz4740_uart0_data_funcs[] = { 1, 1, };
140*4882a593Smuzhiyun static int jz4740_uart0_hwflow_funcs[] = { 1, 1, };
141*4882a593Smuzhiyun static int jz4740_uart1_data_funcs[] = { 2, 2, };
142*4882a593Smuzhiyun static int jz4740_lcd_8bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
143*4882a593Smuzhiyun static int jz4740_lcd_16bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, };
144*4882a593Smuzhiyun static int jz4740_lcd_18bit_funcs[] = { 0, 0, };
145*4882a593Smuzhiyun static int jz4740_lcd_18bit_tft_funcs[] = { 0, 0, 0, 0, };
146*4882a593Smuzhiyun static int jz4740_nand_cs1_funcs[] = { 0, };
147*4882a593Smuzhiyun static int jz4740_nand_cs2_funcs[] = { 0, };
148*4882a593Smuzhiyun static int jz4740_nand_cs3_funcs[] = { 0, };
149*4882a593Smuzhiyun static int jz4740_nand_cs4_funcs[] = { 0, };
150*4882a593Smuzhiyun static int jz4740_nand_fre_fwe_funcs[] = { 0, 0, };
151*4882a593Smuzhiyun static int jz4740_pwm_pwm0_funcs[] = { 0, };
152*4882a593Smuzhiyun static int jz4740_pwm_pwm1_funcs[] = { 0, };
153*4882a593Smuzhiyun static int jz4740_pwm_pwm2_funcs[] = { 0, };
154*4882a593Smuzhiyun static int jz4740_pwm_pwm3_funcs[] = { 0, };
155*4882a593Smuzhiyun static int jz4740_pwm_pwm4_funcs[] = { 0, };
156*4882a593Smuzhiyun static int jz4740_pwm_pwm5_funcs[] = { 0, };
157*4882a593Smuzhiyun static int jz4740_pwm_pwm6_funcs[] = { 0, };
158*4882a593Smuzhiyun static int jz4740_pwm_pwm7_funcs[] = { 0, };
159*4882a593Smuzhiyun
160*4882a593Smuzhiyun #define INGENIC_PIN_GROUP(name, id) \
161*4882a593Smuzhiyun { \
162*4882a593Smuzhiyun name, \
163*4882a593Smuzhiyun id##_pins, \
164*4882a593Smuzhiyun ARRAY_SIZE(id##_pins), \
165*4882a593Smuzhiyun id##_funcs, \
166*4882a593Smuzhiyun }
167*4882a593Smuzhiyun
168*4882a593Smuzhiyun static const struct group_desc jz4740_groups[] = {
169*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc-1bit", jz4740_mmc_1bit),
170*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc-4bit", jz4740_mmc_4bit),
171*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-data", jz4740_uart0_data),
172*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-hwflow", jz4740_uart0_hwflow),
173*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-data", jz4740_uart1_data),
174*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-8bit", jz4740_lcd_8bit),
175*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-16bit", jz4740_lcd_16bit),
176*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-18bit", jz4740_lcd_18bit),
177*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-18bit-tft", jz4740_lcd_18bit_tft),
178*4882a593Smuzhiyun { "lcd-no-pins", },
179*4882a593Smuzhiyun INGENIC_PIN_GROUP("nand-cs1", jz4740_nand_cs1),
180*4882a593Smuzhiyun INGENIC_PIN_GROUP("nand-cs2", jz4740_nand_cs2),
181*4882a593Smuzhiyun INGENIC_PIN_GROUP("nand-cs3", jz4740_nand_cs3),
182*4882a593Smuzhiyun INGENIC_PIN_GROUP("nand-cs4", jz4740_nand_cs4),
183*4882a593Smuzhiyun INGENIC_PIN_GROUP("nand-fre-fwe", jz4740_nand_fre_fwe),
184*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm0", jz4740_pwm_pwm0),
185*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm1", jz4740_pwm_pwm1),
186*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm2", jz4740_pwm_pwm2),
187*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm3", jz4740_pwm_pwm3),
188*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm4", jz4740_pwm_pwm4),
189*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm5", jz4740_pwm_pwm5),
190*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm6", jz4740_pwm_pwm6),
191*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm7", jz4740_pwm_pwm7),
192*4882a593Smuzhiyun };
193*4882a593Smuzhiyun
194*4882a593Smuzhiyun static const char *jz4740_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
195*4882a593Smuzhiyun static const char *jz4740_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
196*4882a593Smuzhiyun static const char *jz4740_uart1_groups[] = { "uart1-data", };
197*4882a593Smuzhiyun static const char *jz4740_lcd_groups[] = {
198*4882a593Smuzhiyun "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-18bit-tft", "lcd-no-pins",
199*4882a593Smuzhiyun };
200*4882a593Smuzhiyun static const char *jz4740_nand_groups[] = {
201*4882a593Smuzhiyun "nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4", "nand-fre-fwe",
202*4882a593Smuzhiyun };
203*4882a593Smuzhiyun static const char *jz4740_pwm0_groups[] = { "pwm0", };
204*4882a593Smuzhiyun static const char *jz4740_pwm1_groups[] = { "pwm1", };
205*4882a593Smuzhiyun static const char *jz4740_pwm2_groups[] = { "pwm2", };
206*4882a593Smuzhiyun static const char *jz4740_pwm3_groups[] = { "pwm3", };
207*4882a593Smuzhiyun static const char *jz4740_pwm4_groups[] = { "pwm4", };
208*4882a593Smuzhiyun static const char *jz4740_pwm5_groups[] = { "pwm5", };
209*4882a593Smuzhiyun static const char *jz4740_pwm6_groups[] = { "pwm6", };
210*4882a593Smuzhiyun static const char *jz4740_pwm7_groups[] = { "pwm7", };
211*4882a593Smuzhiyun
212*4882a593Smuzhiyun static const struct function_desc jz4740_functions[] = {
213*4882a593Smuzhiyun { "mmc", jz4740_mmc_groups, ARRAY_SIZE(jz4740_mmc_groups), },
214*4882a593Smuzhiyun { "uart0", jz4740_uart0_groups, ARRAY_SIZE(jz4740_uart0_groups), },
215*4882a593Smuzhiyun { "uart1", jz4740_uart1_groups, ARRAY_SIZE(jz4740_uart1_groups), },
216*4882a593Smuzhiyun { "lcd", jz4740_lcd_groups, ARRAY_SIZE(jz4740_lcd_groups), },
217*4882a593Smuzhiyun { "nand", jz4740_nand_groups, ARRAY_SIZE(jz4740_nand_groups), },
218*4882a593Smuzhiyun { "pwm0", jz4740_pwm0_groups, ARRAY_SIZE(jz4740_pwm0_groups), },
219*4882a593Smuzhiyun { "pwm1", jz4740_pwm1_groups, ARRAY_SIZE(jz4740_pwm1_groups), },
220*4882a593Smuzhiyun { "pwm2", jz4740_pwm2_groups, ARRAY_SIZE(jz4740_pwm2_groups), },
221*4882a593Smuzhiyun { "pwm3", jz4740_pwm3_groups, ARRAY_SIZE(jz4740_pwm3_groups), },
222*4882a593Smuzhiyun { "pwm4", jz4740_pwm4_groups, ARRAY_SIZE(jz4740_pwm4_groups), },
223*4882a593Smuzhiyun { "pwm5", jz4740_pwm5_groups, ARRAY_SIZE(jz4740_pwm5_groups), },
224*4882a593Smuzhiyun { "pwm6", jz4740_pwm6_groups, ARRAY_SIZE(jz4740_pwm6_groups), },
225*4882a593Smuzhiyun { "pwm7", jz4740_pwm7_groups, ARRAY_SIZE(jz4740_pwm7_groups), },
226*4882a593Smuzhiyun };
227*4882a593Smuzhiyun
228*4882a593Smuzhiyun static const struct ingenic_chip_info jz4740_chip_info = {
229*4882a593Smuzhiyun .num_chips = 4,
230*4882a593Smuzhiyun .reg_offset = 0x100,
231*4882a593Smuzhiyun .version = ID_JZ4740,
232*4882a593Smuzhiyun .groups = jz4740_groups,
233*4882a593Smuzhiyun .num_groups = ARRAY_SIZE(jz4740_groups),
234*4882a593Smuzhiyun .functions = jz4740_functions,
235*4882a593Smuzhiyun .num_functions = ARRAY_SIZE(jz4740_functions),
236*4882a593Smuzhiyun .pull_ups = jz4740_pull_ups,
237*4882a593Smuzhiyun .pull_downs = jz4740_pull_downs,
238*4882a593Smuzhiyun };
239*4882a593Smuzhiyun
240*4882a593Smuzhiyun static int jz4725b_mmc0_1bit_pins[] = { 0x48, 0x49, 0x5c, };
241*4882a593Smuzhiyun static int jz4725b_mmc0_4bit_pins[] = { 0x5d, 0x5b, 0x56, };
242*4882a593Smuzhiyun static int jz4725b_mmc1_1bit_pins[] = { 0x7a, 0x7b, 0x7c, };
243*4882a593Smuzhiyun static int jz4725b_mmc1_4bit_pins[] = { 0x7d, 0x7e, 0x7f, };
244*4882a593Smuzhiyun static int jz4725b_uart_data_pins[] = { 0x4c, 0x4d, };
245*4882a593Smuzhiyun static int jz4725b_nand_cs1_pins[] = { 0x55, };
246*4882a593Smuzhiyun static int jz4725b_nand_cs2_pins[] = { 0x56, };
247*4882a593Smuzhiyun static int jz4725b_nand_cs3_pins[] = { 0x57, };
248*4882a593Smuzhiyun static int jz4725b_nand_cs4_pins[] = { 0x58, };
249*4882a593Smuzhiyun static int jz4725b_nand_cle_ale_pins[] = { 0x48, 0x49 };
250*4882a593Smuzhiyun static int jz4725b_nand_fre_fwe_pins[] = { 0x5c, 0x5d };
251*4882a593Smuzhiyun static int jz4725b_pwm_pwm0_pins[] = { 0x4a, };
252*4882a593Smuzhiyun static int jz4725b_pwm_pwm1_pins[] = { 0x4b, };
253*4882a593Smuzhiyun static int jz4725b_pwm_pwm2_pins[] = { 0x4c, };
254*4882a593Smuzhiyun static int jz4725b_pwm_pwm3_pins[] = { 0x4d, };
255*4882a593Smuzhiyun static int jz4725b_pwm_pwm4_pins[] = { 0x4e, };
256*4882a593Smuzhiyun static int jz4725b_pwm_pwm5_pins[] = { 0x4f, };
257*4882a593Smuzhiyun static int jz4725b_lcd_8bit_pins[] = {
258*4882a593Smuzhiyun 0x72, 0x73, 0x74,
259*4882a593Smuzhiyun 0x60, 0x61, 0x62, 0x63,
260*4882a593Smuzhiyun 0x64, 0x65, 0x66, 0x67,
261*4882a593Smuzhiyun };
262*4882a593Smuzhiyun static int jz4725b_lcd_16bit_pins[] = {
263*4882a593Smuzhiyun 0x68, 0x69, 0x6a, 0x6b,
264*4882a593Smuzhiyun 0x6c, 0x6d, 0x6e, 0x6f,
265*4882a593Smuzhiyun };
266*4882a593Smuzhiyun static int jz4725b_lcd_18bit_pins[] = { 0x70, 0x71, };
267*4882a593Smuzhiyun static int jz4725b_lcd_24bit_pins[] = { 0x76, 0x77, 0x78, 0x79, };
268*4882a593Smuzhiyun static int jz4725b_lcd_special_pins[] = { 0x76, 0x77, 0x78, 0x79, };
269*4882a593Smuzhiyun static int jz4725b_lcd_generic_pins[] = { 0x75, };
270*4882a593Smuzhiyun
271*4882a593Smuzhiyun static int jz4725b_mmc0_1bit_funcs[] = { 1, 1, 1, };
272*4882a593Smuzhiyun static int jz4725b_mmc0_4bit_funcs[] = { 1, 0, 1, };
273*4882a593Smuzhiyun static int jz4725b_mmc1_1bit_funcs[] = { 0, 0, 0, };
274*4882a593Smuzhiyun static int jz4725b_mmc1_4bit_funcs[] = { 0, 0, 0, };
275*4882a593Smuzhiyun static int jz4725b_uart_data_funcs[] = { 1, 1, };
276*4882a593Smuzhiyun static int jz4725b_nand_cs1_funcs[] = { 0, };
277*4882a593Smuzhiyun static int jz4725b_nand_cs2_funcs[] = { 0, };
278*4882a593Smuzhiyun static int jz4725b_nand_cs3_funcs[] = { 0, };
279*4882a593Smuzhiyun static int jz4725b_nand_cs4_funcs[] = { 0, };
280*4882a593Smuzhiyun static int jz4725b_nand_cle_ale_funcs[] = { 0, 0, };
281*4882a593Smuzhiyun static int jz4725b_nand_fre_fwe_funcs[] = { 0, 0, };
282*4882a593Smuzhiyun static int jz4725b_pwm_pwm0_funcs[] = { 0, };
283*4882a593Smuzhiyun static int jz4725b_pwm_pwm1_funcs[] = { 0, };
284*4882a593Smuzhiyun static int jz4725b_pwm_pwm2_funcs[] = { 0, };
285*4882a593Smuzhiyun static int jz4725b_pwm_pwm3_funcs[] = { 0, };
286*4882a593Smuzhiyun static int jz4725b_pwm_pwm4_funcs[] = { 0, };
287*4882a593Smuzhiyun static int jz4725b_pwm_pwm5_funcs[] = { 0, };
288*4882a593Smuzhiyun static int jz4725b_lcd_8bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
289*4882a593Smuzhiyun static int jz4725b_lcd_16bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
290*4882a593Smuzhiyun static int jz4725b_lcd_18bit_funcs[] = { 0, 0, };
291*4882a593Smuzhiyun static int jz4725b_lcd_24bit_funcs[] = { 1, 1, 1, 1, };
292*4882a593Smuzhiyun static int jz4725b_lcd_special_funcs[] = { 0, 0, 0, 0, };
293*4882a593Smuzhiyun static int jz4725b_lcd_generic_funcs[] = { 0, };
294*4882a593Smuzhiyun
295*4882a593Smuzhiyun static const struct group_desc jz4725b_groups[] = {
296*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-1bit", jz4725b_mmc0_1bit),
297*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-4bit", jz4725b_mmc0_4bit),
298*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-1bit", jz4725b_mmc1_1bit),
299*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-4bit", jz4725b_mmc1_4bit),
300*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart-data", jz4725b_uart_data),
301*4882a593Smuzhiyun INGENIC_PIN_GROUP("nand-cs1", jz4725b_nand_cs1),
302*4882a593Smuzhiyun INGENIC_PIN_GROUP("nand-cs2", jz4725b_nand_cs2),
303*4882a593Smuzhiyun INGENIC_PIN_GROUP("nand-cs3", jz4725b_nand_cs3),
304*4882a593Smuzhiyun INGENIC_PIN_GROUP("nand-cs4", jz4725b_nand_cs4),
305*4882a593Smuzhiyun INGENIC_PIN_GROUP("nand-cle-ale", jz4725b_nand_cle_ale),
306*4882a593Smuzhiyun INGENIC_PIN_GROUP("nand-fre-fwe", jz4725b_nand_fre_fwe),
307*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm0", jz4725b_pwm_pwm0),
308*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm1", jz4725b_pwm_pwm1),
309*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm2", jz4725b_pwm_pwm2),
310*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm3", jz4725b_pwm_pwm3),
311*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm4", jz4725b_pwm_pwm4),
312*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm5", jz4725b_pwm_pwm5),
313*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-8bit", jz4725b_lcd_8bit),
314*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-16bit", jz4725b_lcd_16bit),
315*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-18bit", jz4725b_lcd_18bit),
316*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-24bit", jz4725b_lcd_24bit),
317*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-special", jz4725b_lcd_special),
318*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-generic", jz4725b_lcd_generic),
319*4882a593Smuzhiyun };
320*4882a593Smuzhiyun
321*4882a593Smuzhiyun static const char *jz4725b_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", };
322*4882a593Smuzhiyun static const char *jz4725b_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
323*4882a593Smuzhiyun static const char *jz4725b_uart_groups[] = { "uart-data", };
324*4882a593Smuzhiyun static const char *jz4725b_nand_groups[] = {
325*4882a593Smuzhiyun "nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4",
326*4882a593Smuzhiyun "nand-cle-ale", "nand-fre-fwe",
327*4882a593Smuzhiyun };
328*4882a593Smuzhiyun static const char *jz4725b_pwm0_groups[] = { "pwm0", };
329*4882a593Smuzhiyun static const char *jz4725b_pwm1_groups[] = { "pwm1", };
330*4882a593Smuzhiyun static const char *jz4725b_pwm2_groups[] = { "pwm2", };
331*4882a593Smuzhiyun static const char *jz4725b_pwm3_groups[] = { "pwm3", };
332*4882a593Smuzhiyun static const char *jz4725b_pwm4_groups[] = { "pwm4", };
333*4882a593Smuzhiyun static const char *jz4725b_pwm5_groups[] = { "pwm5", };
334*4882a593Smuzhiyun static const char *jz4725b_lcd_groups[] = {
335*4882a593Smuzhiyun "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
336*4882a593Smuzhiyun "lcd-special", "lcd-generic",
337*4882a593Smuzhiyun };
338*4882a593Smuzhiyun
339*4882a593Smuzhiyun static const struct function_desc jz4725b_functions[] = {
340*4882a593Smuzhiyun { "mmc0", jz4725b_mmc0_groups, ARRAY_SIZE(jz4725b_mmc0_groups), },
341*4882a593Smuzhiyun { "mmc1", jz4725b_mmc1_groups, ARRAY_SIZE(jz4725b_mmc1_groups), },
342*4882a593Smuzhiyun { "uart", jz4725b_uart_groups, ARRAY_SIZE(jz4725b_uart_groups), },
343*4882a593Smuzhiyun { "nand", jz4725b_nand_groups, ARRAY_SIZE(jz4725b_nand_groups), },
344*4882a593Smuzhiyun { "pwm0", jz4725b_pwm0_groups, ARRAY_SIZE(jz4725b_pwm0_groups), },
345*4882a593Smuzhiyun { "pwm1", jz4725b_pwm1_groups, ARRAY_SIZE(jz4725b_pwm1_groups), },
346*4882a593Smuzhiyun { "pwm2", jz4725b_pwm2_groups, ARRAY_SIZE(jz4725b_pwm2_groups), },
347*4882a593Smuzhiyun { "pwm3", jz4725b_pwm3_groups, ARRAY_SIZE(jz4725b_pwm3_groups), },
348*4882a593Smuzhiyun { "pwm4", jz4725b_pwm4_groups, ARRAY_SIZE(jz4725b_pwm4_groups), },
349*4882a593Smuzhiyun { "pwm5", jz4725b_pwm5_groups, ARRAY_SIZE(jz4725b_pwm5_groups), },
350*4882a593Smuzhiyun { "lcd", jz4725b_lcd_groups, ARRAY_SIZE(jz4725b_lcd_groups), },
351*4882a593Smuzhiyun };
352*4882a593Smuzhiyun
353*4882a593Smuzhiyun static const struct ingenic_chip_info jz4725b_chip_info = {
354*4882a593Smuzhiyun .num_chips = 4,
355*4882a593Smuzhiyun .reg_offset = 0x100,
356*4882a593Smuzhiyun .version = ID_JZ4725B,
357*4882a593Smuzhiyun .groups = jz4725b_groups,
358*4882a593Smuzhiyun .num_groups = ARRAY_SIZE(jz4725b_groups),
359*4882a593Smuzhiyun .functions = jz4725b_functions,
360*4882a593Smuzhiyun .num_functions = ARRAY_SIZE(jz4725b_functions),
361*4882a593Smuzhiyun .pull_ups = jz4740_pull_ups,
362*4882a593Smuzhiyun .pull_downs = jz4740_pull_downs,
363*4882a593Smuzhiyun };
364*4882a593Smuzhiyun
365*4882a593Smuzhiyun static const u32 jz4760_pull_ups[6] = {
366*4882a593Smuzhiyun 0xffffffff, 0xfffcf3ff, 0xffffffff, 0xffffcfff, 0xfffffb7c, 0x0000000f,
367*4882a593Smuzhiyun };
368*4882a593Smuzhiyun
369*4882a593Smuzhiyun static const u32 jz4760_pull_downs[6] = {
370*4882a593Smuzhiyun 0x00000000, 0x00030c00, 0x00000000, 0x00003000, 0x00000483, 0x00000ff0,
371*4882a593Smuzhiyun };
372*4882a593Smuzhiyun
373*4882a593Smuzhiyun static int jz4760_uart0_data_pins[] = { 0xa0, 0xa3, };
374*4882a593Smuzhiyun static int jz4760_uart0_hwflow_pins[] = { 0xa1, 0xa2, };
375*4882a593Smuzhiyun static int jz4760_uart1_data_pins[] = { 0x7a, 0x7c, };
376*4882a593Smuzhiyun static int jz4760_uart1_hwflow_pins[] = { 0x7b, 0x7d, };
377*4882a593Smuzhiyun static int jz4760_uart2_data_pins[] = { 0x5c, 0x5e, };
378*4882a593Smuzhiyun static int jz4760_uart2_hwflow_pins[] = { 0x5d, 0x5f, };
379*4882a593Smuzhiyun static int jz4760_uart3_data_pins[] = { 0x6c, 0x85, };
380*4882a593Smuzhiyun static int jz4760_uart3_hwflow_pins[] = { 0x88, 0x89, };
381*4882a593Smuzhiyun static int jz4760_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, };
382*4882a593Smuzhiyun static int jz4760_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, };
383*4882a593Smuzhiyun static int jz4760_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
384*4882a593Smuzhiyun static int jz4760_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
385*4882a593Smuzhiyun static int jz4760_mmc0_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
386*4882a593Smuzhiyun static int jz4760_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, };
387*4882a593Smuzhiyun static int jz4760_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, };
388*4882a593Smuzhiyun static int jz4760_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
389*4882a593Smuzhiyun static int jz4760_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
390*4882a593Smuzhiyun static int jz4760_mmc1_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
391*4882a593Smuzhiyun static int jz4760_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, };
392*4882a593Smuzhiyun static int jz4760_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, };
393*4882a593Smuzhiyun static int jz4760_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
394*4882a593Smuzhiyun static int jz4760_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
395*4882a593Smuzhiyun static int jz4760_mmc2_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
396*4882a593Smuzhiyun static int jz4760_nemc_8bit_data_pins[] = {
397*4882a593Smuzhiyun 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
398*4882a593Smuzhiyun };
399*4882a593Smuzhiyun static int jz4760_nemc_16bit_data_pins[] = {
400*4882a593Smuzhiyun 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
401*4882a593Smuzhiyun };
402*4882a593Smuzhiyun static int jz4760_nemc_cle_ale_pins[] = { 0x20, 0x21, };
403*4882a593Smuzhiyun static int jz4760_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, };
404*4882a593Smuzhiyun static int jz4760_nemc_rd_we_pins[] = { 0x10, 0x11, };
405*4882a593Smuzhiyun static int jz4760_nemc_frd_fwe_pins[] = { 0x12, 0x13, };
406*4882a593Smuzhiyun static int jz4760_nemc_wait_pins[] = { 0x1b, };
407*4882a593Smuzhiyun static int jz4760_nemc_cs1_pins[] = { 0x15, };
408*4882a593Smuzhiyun static int jz4760_nemc_cs2_pins[] = { 0x16, };
409*4882a593Smuzhiyun static int jz4760_nemc_cs3_pins[] = { 0x17, };
410*4882a593Smuzhiyun static int jz4760_nemc_cs4_pins[] = { 0x18, };
411*4882a593Smuzhiyun static int jz4760_nemc_cs5_pins[] = { 0x19, };
412*4882a593Smuzhiyun static int jz4760_nemc_cs6_pins[] = { 0x1a, };
413*4882a593Smuzhiyun static int jz4760_i2c0_pins[] = { 0x7e, 0x7f, };
414*4882a593Smuzhiyun static int jz4760_i2c1_pins[] = { 0x9e, 0x9f, };
415*4882a593Smuzhiyun static int jz4760_cim_pins[] = {
416*4882a593Smuzhiyun 0x26, 0x27, 0x28, 0x29,
417*4882a593Smuzhiyun 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
418*4882a593Smuzhiyun };
419*4882a593Smuzhiyun static int jz4760_lcd_24bit_pins[] = {
420*4882a593Smuzhiyun 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
421*4882a593Smuzhiyun 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
422*4882a593Smuzhiyun 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
423*4882a593Smuzhiyun 0x58, 0x59, 0x5a, 0x5b,
424*4882a593Smuzhiyun };
425*4882a593Smuzhiyun static int jz4760_pwm_pwm0_pins[] = { 0x80, };
426*4882a593Smuzhiyun static int jz4760_pwm_pwm1_pins[] = { 0x81, };
427*4882a593Smuzhiyun static int jz4760_pwm_pwm2_pins[] = { 0x82, };
428*4882a593Smuzhiyun static int jz4760_pwm_pwm3_pins[] = { 0x83, };
429*4882a593Smuzhiyun static int jz4760_pwm_pwm4_pins[] = { 0x84, };
430*4882a593Smuzhiyun static int jz4760_pwm_pwm5_pins[] = { 0x85, };
431*4882a593Smuzhiyun static int jz4760_pwm_pwm6_pins[] = { 0x6a, };
432*4882a593Smuzhiyun static int jz4760_pwm_pwm7_pins[] = { 0x6b, };
433*4882a593Smuzhiyun
434*4882a593Smuzhiyun static int jz4760_uart0_data_funcs[] = { 0, 0, };
435*4882a593Smuzhiyun static int jz4760_uart0_hwflow_funcs[] = { 0, 0, };
436*4882a593Smuzhiyun static int jz4760_uart1_data_funcs[] = { 0, 0, };
437*4882a593Smuzhiyun static int jz4760_uart1_hwflow_funcs[] = { 0, 0, };
438*4882a593Smuzhiyun static int jz4760_uart2_data_funcs[] = { 0, 0, };
439*4882a593Smuzhiyun static int jz4760_uart2_hwflow_funcs[] = { 0, 0, };
440*4882a593Smuzhiyun static int jz4760_uart3_data_funcs[] = { 0, 1, };
441*4882a593Smuzhiyun static int jz4760_uart3_hwflow_funcs[] = { 0, 0, };
442*4882a593Smuzhiyun static int jz4760_mmc0_1bit_a_funcs[] = { 1, 1, 0, };
443*4882a593Smuzhiyun static int jz4760_mmc0_4bit_a_funcs[] = { 1, 1, 1, };
444*4882a593Smuzhiyun static int jz4760_mmc0_1bit_e_funcs[] = { 0, 0, 0, };
445*4882a593Smuzhiyun static int jz4760_mmc0_4bit_e_funcs[] = { 0, 0, 0, };
446*4882a593Smuzhiyun static int jz4760_mmc0_8bit_e_funcs[] = { 0, 0, 0, 0, };
447*4882a593Smuzhiyun static int jz4760_mmc1_1bit_d_funcs[] = { 0, 0, 0, };
448*4882a593Smuzhiyun static int jz4760_mmc1_4bit_d_funcs[] = { 0, 0, 0, };
449*4882a593Smuzhiyun static int jz4760_mmc1_1bit_e_funcs[] = { 1, 1, 1, };
450*4882a593Smuzhiyun static int jz4760_mmc1_4bit_e_funcs[] = { 1, 1, 1, };
451*4882a593Smuzhiyun static int jz4760_mmc1_8bit_e_funcs[] = { 1, 1, 1, 1, };
452*4882a593Smuzhiyun static int jz4760_mmc2_1bit_b_funcs[] = { 0, 0, 0, };
453*4882a593Smuzhiyun static int jz4760_mmc2_4bit_b_funcs[] = { 0, 0, 0, };
454*4882a593Smuzhiyun static int jz4760_mmc2_1bit_e_funcs[] = { 2, 2, 2, };
455*4882a593Smuzhiyun static int jz4760_mmc2_4bit_e_funcs[] = { 2, 2, 2, };
456*4882a593Smuzhiyun static int jz4760_mmc2_8bit_e_funcs[] = { 2, 2, 2, 2, };
457*4882a593Smuzhiyun static int jz4760_nemc_8bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
458*4882a593Smuzhiyun static int jz4760_nemc_16bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
459*4882a593Smuzhiyun static int jz4760_nemc_cle_ale_funcs[] = { 0, 0, };
460*4882a593Smuzhiyun static int jz4760_nemc_addr_funcs[] = { 0, 0, 0, 0, };
461*4882a593Smuzhiyun static int jz4760_nemc_rd_we_funcs[] = { 0, 0, };
462*4882a593Smuzhiyun static int jz4760_nemc_frd_fwe_funcs[] = { 0, 0, };
463*4882a593Smuzhiyun static int jz4760_nemc_wait_funcs[] = { 0, };
464*4882a593Smuzhiyun static int jz4760_nemc_cs1_funcs[] = { 0, };
465*4882a593Smuzhiyun static int jz4760_nemc_cs2_funcs[] = { 0, };
466*4882a593Smuzhiyun static int jz4760_nemc_cs3_funcs[] = { 0, };
467*4882a593Smuzhiyun static int jz4760_nemc_cs4_funcs[] = { 0, };
468*4882a593Smuzhiyun static int jz4760_nemc_cs5_funcs[] = { 0, };
469*4882a593Smuzhiyun static int jz4760_nemc_cs6_funcs[] = { 0, };
470*4882a593Smuzhiyun static int jz4760_i2c0_funcs[] = { 0, 0, };
471*4882a593Smuzhiyun static int jz4760_i2c1_funcs[] = { 0, 0, };
472*4882a593Smuzhiyun static int jz4760_cim_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
473*4882a593Smuzhiyun static int jz4760_lcd_24bit_funcs[] = {
474*4882a593Smuzhiyun 0, 0, 0, 0, 0, 0, 0, 0,
475*4882a593Smuzhiyun 0, 0, 0, 0, 0, 0, 0, 0,
476*4882a593Smuzhiyun 0, 0, 0, 0, 0, 0, 0, 0,
477*4882a593Smuzhiyun 0, 0, 0, 0,
478*4882a593Smuzhiyun };
479*4882a593Smuzhiyun static int jz4760_pwm_pwm0_funcs[] = { 0, };
480*4882a593Smuzhiyun static int jz4760_pwm_pwm1_funcs[] = { 0, };
481*4882a593Smuzhiyun static int jz4760_pwm_pwm2_funcs[] = { 0, };
482*4882a593Smuzhiyun static int jz4760_pwm_pwm3_funcs[] = { 0, };
483*4882a593Smuzhiyun static int jz4760_pwm_pwm4_funcs[] = { 0, };
484*4882a593Smuzhiyun static int jz4760_pwm_pwm5_funcs[] = { 0, };
485*4882a593Smuzhiyun static int jz4760_pwm_pwm6_funcs[] = { 0, };
486*4882a593Smuzhiyun static int jz4760_pwm_pwm7_funcs[] = { 0, };
487*4882a593Smuzhiyun
488*4882a593Smuzhiyun static const struct group_desc jz4760_groups[] = {
489*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-data", jz4760_uart0_data),
490*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-hwflow", jz4760_uart0_hwflow),
491*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-data", jz4760_uart1_data),
492*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-hwflow", jz4760_uart1_hwflow),
493*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart2-data", jz4760_uart2_data),
494*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart2-hwflow", jz4760_uart2_hwflow),
495*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart3-data", jz4760_uart3_data),
496*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart3-hwflow", jz4760_uart3_hwflow),
497*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-1bit-a", jz4760_mmc0_1bit_a),
498*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-4bit-a", jz4760_mmc0_4bit_a),
499*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-1bit-e", jz4760_mmc0_1bit_e),
500*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-4bit-e", jz4760_mmc0_4bit_e),
501*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-8bit-e", jz4760_mmc0_8bit_e),
502*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-1bit-d", jz4760_mmc1_1bit_d),
503*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-4bit-d", jz4760_mmc1_4bit_d),
504*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-1bit-e", jz4760_mmc1_1bit_e),
505*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-4bit-e", jz4760_mmc1_4bit_e),
506*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-8bit-e", jz4760_mmc1_8bit_e),
507*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-1bit-b", jz4760_mmc2_1bit_b),
508*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-4bit-b", jz4760_mmc2_4bit_b),
509*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-1bit-e", jz4760_mmc2_1bit_e),
510*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-4bit-e", jz4760_mmc2_4bit_e),
511*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-8bit-e", jz4760_mmc2_8bit_e),
512*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-8bit-data", jz4760_nemc_8bit_data),
513*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-16bit-data", jz4760_nemc_16bit_data),
514*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cle-ale", jz4760_nemc_cle_ale),
515*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-addr", jz4760_nemc_addr),
516*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-rd-we", jz4760_nemc_rd_we),
517*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-frd-fwe", jz4760_nemc_frd_fwe),
518*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-wait", jz4760_nemc_wait),
519*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs1", jz4760_nemc_cs1),
520*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs2", jz4760_nemc_cs2),
521*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs3", jz4760_nemc_cs3),
522*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs4", jz4760_nemc_cs4),
523*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs5", jz4760_nemc_cs5),
524*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs6", jz4760_nemc_cs6),
525*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c0-data", jz4760_i2c0),
526*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c1-data", jz4760_i2c1),
527*4882a593Smuzhiyun INGENIC_PIN_GROUP("cim-data", jz4760_cim),
528*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-24bit", jz4760_lcd_24bit),
529*4882a593Smuzhiyun { "lcd-no-pins", },
530*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm0", jz4760_pwm_pwm0),
531*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm1", jz4760_pwm_pwm1),
532*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm2", jz4760_pwm_pwm2),
533*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm3", jz4760_pwm_pwm3),
534*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm4", jz4760_pwm_pwm4),
535*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm5", jz4760_pwm_pwm5),
536*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm6", jz4760_pwm_pwm6),
537*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm7", jz4760_pwm_pwm7),
538*4882a593Smuzhiyun };
539*4882a593Smuzhiyun
540*4882a593Smuzhiyun static const char *jz4760_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
541*4882a593Smuzhiyun static const char *jz4760_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
542*4882a593Smuzhiyun static const char *jz4760_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
543*4882a593Smuzhiyun static const char *jz4760_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
544*4882a593Smuzhiyun static const char *jz4760_mmc0_groups[] = {
545*4882a593Smuzhiyun "mmc0-1bit-a", "mmc0-4bit-a",
546*4882a593Smuzhiyun "mmc0-1bit-e", "mmc0-4bit-e", "mmc0-8bit-e",
547*4882a593Smuzhiyun };
548*4882a593Smuzhiyun static const char *jz4760_mmc1_groups[] = {
549*4882a593Smuzhiyun "mmc1-1bit-d", "mmc1-4bit-d",
550*4882a593Smuzhiyun "mmc1-1bit-e", "mmc1-4bit-e", "mmc1-8bit-e",
551*4882a593Smuzhiyun };
552*4882a593Smuzhiyun static const char *jz4760_mmc2_groups[] = {
553*4882a593Smuzhiyun "mmc2-1bit-b", "mmc2-4bit-b",
554*4882a593Smuzhiyun "mmc2-1bit-e", "mmc2-4bit-e", "mmc2-8bit-e",
555*4882a593Smuzhiyun };
556*4882a593Smuzhiyun static const char *jz4760_nemc_groups[] = {
557*4882a593Smuzhiyun "nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale",
558*4882a593Smuzhiyun "nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
559*4882a593Smuzhiyun };
560*4882a593Smuzhiyun static const char *jz4760_cs1_groups[] = { "nemc-cs1", };
561*4882a593Smuzhiyun static const char *jz4760_cs2_groups[] = { "nemc-cs2", };
562*4882a593Smuzhiyun static const char *jz4760_cs3_groups[] = { "nemc-cs3", };
563*4882a593Smuzhiyun static const char *jz4760_cs4_groups[] = { "nemc-cs4", };
564*4882a593Smuzhiyun static const char *jz4760_cs5_groups[] = { "nemc-cs5", };
565*4882a593Smuzhiyun static const char *jz4760_cs6_groups[] = { "nemc-cs6", };
566*4882a593Smuzhiyun static const char *jz4760_i2c0_groups[] = { "i2c0-data", };
567*4882a593Smuzhiyun static const char *jz4760_i2c1_groups[] = { "i2c1-data", };
568*4882a593Smuzhiyun static const char *jz4760_cim_groups[] = { "cim-data", };
569*4882a593Smuzhiyun static const char *jz4760_lcd_groups[] = { "lcd-24bit", "lcd-no-pins", };
570*4882a593Smuzhiyun static const char *jz4760_pwm0_groups[] = { "pwm0", };
571*4882a593Smuzhiyun static const char *jz4760_pwm1_groups[] = { "pwm1", };
572*4882a593Smuzhiyun static const char *jz4760_pwm2_groups[] = { "pwm2", };
573*4882a593Smuzhiyun static const char *jz4760_pwm3_groups[] = { "pwm3", };
574*4882a593Smuzhiyun static const char *jz4760_pwm4_groups[] = { "pwm4", };
575*4882a593Smuzhiyun static const char *jz4760_pwm5_groups[] = { "pwm5", };
576*4882a593Smuzhiyun static const char *jz4760_pwm6_groups[] = { "pwm6", };
577*4882a593Smuzhiyun static const char *jz4760_pwm7_groups[] = { "pwm7", };
578*4882a593Smuzhiyun
579*4882a593Smuzhiyun static const struct function_desc jz4760_functions[] = {
580*4882a593Smuzhiyun { "uart0", jz4760_uart0_groups, ARRAY_SIZE(jz4760_uart0_groups), },
581*4882a593Smuzhiyun { "uart1", jz4760_uart1_groups, ARRAY_SIZE(jz4760_uart1_groups), },
582*4882a593Smuzhiyun { "uart2", jz4760_uart2_groups, ARRAY_SIZE(jz4760_uart2_groups), },
583*4882a593Smuzhiyun { "uart3", jz4760_uart3_groups, ARRAY_SIZE(jz4760_uart3_groups), },
584*4882a593Smuzhiyun { "mmc0", jz4760_mmc0_groups, ARRAY_SIZE(jz4760_mmc0_groups), },
585*4882a593Smuzhiyun { "mmc1", jz4760_mmc1_groups, ARRAY_SIZE(jz4760_mmc1_groups), },
586*4882a593Smuzhiyun { "mmc2", jz4760_mmc2_groups, ARRAY_SIZE(jz4760_mmc2_groups), },
587*4882a593Smuzhiyun { "nemc", jz4760_nemc_groups, ARRAY_SIZE(jz4760_nemc_groups), },
588*4882a593Smuzhiyun { "nemc-cs1", jz4760_cs1_groups, ARRAY_SIZE(jz4760_cs1_groups), },
589*4882a593Smuzhiyun { "nemc-cs2", jz4760_cs2_groups, ARRAY_SIZE(jz4760_cs2_groups), },
590*4882a593Smuzhiyun { "nemc-cs3", jz4760_cs3_groups, ARRAY_SIZE(jz4760_cs3_groups), },
591*4882a593Smuzhiyun { "nemc-cs4", jz4760_cs4_groups, ARRAY_SIZE(jz4760_cs4_groups), },
592*4882a593Smuzhiyun { "nemc-cs5", jz4760_cs5_groups, ARRAY_SIZE(jz4760_cs5_groups), },
593*4882a593Smuzhiyun { "nemc-cs6", jz4760_cs6_groups, ARRAY_SIZE(jz4760_cs6_groups), },
594*4882a593Smuzhiyun { "i2c0", jz4760_i2c0_groups, ARRAY_SIZE(jz4760_i2c0_groups), },
595*4882a593Smuzhiyun { "i2c1", jz4760_i2c1_groups, ARRAY_SIZE(jz4760_i2c1_groups), },
596*4882a593Smuzhiyun { "cim", jz4760_cim_groups, ARRAY_SIZE(jz4760_cim_groups), },
597*4882a593Smuzhiyun { "lcd", jz4760_lcd_groups, ARRAY_SIZE(jz4760_lcd_groups), },
598*4882a593Smuzhiyun { "pwm0", jz4760_pwm0_groups, ARRAY_SIZE(jz4760_pwm0_groups), },
599*4882a593Smuzhiyun { "pwm1", jz4760_pwm1_groups, ARRAY_SIZE(jz4760_pwm1_groups), },
600*4882a593Smuzhiyun { "pwm2", jz4760_pwm2_groups, ARRAY_SIZE(jz4760_pwm2_groups), },
601*4882a593Smuzhiyun { "pwm3", jz4760_pwm3_groups, ARRAY_SIZE(jz4760_pwm3_groups), },
602*4882a593Smuzhiyun { "pwm4", jz4760_pwm4_groups, ARRAY_SIZE(jz4760_pwm4_groups), },
603*4882a593Smuzhiyun { "pwm5", jz4760_pwm5_groups, ARRAY_SIZE(jz4760_pwm5_groups), },
604*4882a593Smuzhiyun { "pwm6", jz4760_pwm6_groups, ARRAY_SIZE(jz4760_pwm6_groups), },
605*4882a593Smuzhiyun { "pwm7", jz4760_pwm7_groups, ARRAY_SIZE(jz4760_pwm7_groups), },
606*4882a593Smuzhiyun };
607*4882a593Smuzhiyun
608*4882a593Smuzhiyun static const struct ingenic_chip_info jz4760_chip_info = {
609*4882a593Smuzhiyun .num_chips = 6,
610*4882a593Smuzhiyun .reg_offset = 0x100,
611*4882a593Smuzhiyun .version = ID_JZ4760,
612*4882a593Smuzhiyun .groups = jz4760_groups,
613*4882a593Smuzhiyun .num_groups = ARRAY_SIZE(jz4760_groups),
614*4882a593Smuzhiyun .functions = jz4760_functions,
615*4882a593Smuzhiyun .num_functions = ARRAY_SIZE(jz4760_functions),
616*4882a593Smuzhiyun .pull_ups = jz4760_pull_ups,
617*4882a593Smuzhiyun .pull_downs = jz4760_pull_downs,
618*4882a593Smuzhiyun };
619*4882a593Smuzhiyun
620*4882a593Smuzhiyun static const u32 jz4770_pull_ups[6] = {
621*4882a593Smuzhiyun 0x3fffffff, 0xfff0f3fc, 0xffffffff, 0xffff4fff, 0xfffffb7c, 0x0024f00f,
622*4882a593Smuzhiyun };
623*4882a593Smuzhiyun
624*4882a593Smuzhiyun static const u32 jz4770_pull_downs[6] = {
625*4882a593Smuzhiyun 0x00000000, 0x000f0c03, 0x00000000, 0x0000b000, 0x00000483, 0x005b0ff0,
626*4882a593Smuzhiyun };
627*4882a593Smuzhiyun
628*4882a593Smuzhiyun static int jz4770_uart0_data_pins[] = { 0xa0, 0xa3, };
629*4882a593Smuzhiyun static int jz4770_uart0_hwflow_pins[] = { 0xa1, 0xa2, };
630*4882a593Smuzhiyun static int jz4770_uart1_data_pins[] = { 0x7a, 0x7c, };
631*4882a593Smuzhiyun static int jz4770_uart1_hwflow_pins[] = { 0x7b, 0x7d, };
632*4882a593Smuzhiyun static int jz4770_uart2_data_pins[] = { 0x5c, 0x5e, };
633*4882a593Smuzhiyun static int jz4770_uart2_hwflow_pins[] = { 0x5d, 0x5f, };
634*4882a593Smuzhiyun static int jz4770_uart3_data_pins[] = { 0x6c, 0x85, };
635*4882a593Smuzhiyun static int jz4770_uart3_hwflow_pins[] = { 0x88, 0x89, };
636*4882a593Smuzhiyun static int jz4770_ssi0_dt_a_pins[] = { 0x15, };
637*4882a593Smuzhiyun static int jz4770_ssi0_dt_b_pins[] = { 0x35, };
638*4882a593Smuzhiyun static int jz4770_ssi0_dt_d_pins[] = { 0x75, };
639*4882a593Smuzhiyun static int jz4770_ssi0_dt_e_pins[] = { 0x91, };
640*4882a593Smuzhiyun static int jz4770_ssi0_dr_a_pins[] = { 0x14, };
641*4882a593Smuzhiyun static int jz4770_ssi0_dr_b_pins[] = { 0x34, };
642*4882a593Smuzhiyun static int jz4770_ssi0_dr_d_pins[] = { 0x74, };
643*4882a593Smuzhiyun static int jz4770_ssi0_dr_e_pins[] = { 0x8e, };
644*4882a593Smuzhiyun static int jz4770_ssi0_clk_a_pins[] = { 0x12, };
645*4882a593Smuzhiyun static int jz4770_ssi0_clk_b_pins[] = { 0x3c, };
646*4882a593Smuzhiyun static int jz4770_ssi0_clk_d_pins[] = { 0x78, };
647*4882a593Smuzhiyun static int jz4770_ssi0_clk_e_pins[] = { 0x8f, };
648*4882a593Smuzhiyun static int jz4770_ssi0_gpc_b_pins[] = { 0x3e, };
649*4882a593Smuzhiyun static int jz4770_ssi0_gpc_d_pins[] = { 0x76, };
650*4882a593Smuzhiyun static int jz4770_ssi0_gpc_e_pins[] = { 0x93, };
651*4882a593Smuzhiyun static int jz4770_ssi0_ce0_a_pins[] = { 0x13, };
652*4882a593Smuzhiyun static int jz4770_ssi0_ce0_b_pins[] = { 0x3d, };
653*4882a593Smuzhiyun static int jz4770_ssi0_ce0_d_pins[] = { 0x79, };
654*4882a593Smuzhiyun static int jz4770_ssi0_ce0_e_pins[] = { 0x90, };
655*4882a593Smuzhiyun static int jz4770_ssi0_ce1_b_pins[] = { 0x3f, };
656*4882a593Smuzhiyun static int jz4770_ssi0_ce1_d_pins[] = { 0x77, };
657*4882a593Smuzhiyun static int jz4770_ssi0_ce1_e_pins[] = { 0x92, };
658*4882a593Smuzhiyun static int jz4770_ssi1_dt_b_pins[] = { 0x35, };
659*4882a593Smuzhiyun static int jz4770_ssi1_dt_d_pins[] = { 0x75, };
660*4882a593Smuzhiyun static int jz4770_ssi1_dt_e_pins[] = { 0x91, };
661*4882a593Smuzhiyun static int jz4770_ssi1_dr_b_pins[] = { 0x34, };
662*4882a593Smuzhiyun static int jz4770_ssi1_dr_d_pins[] = { 0x74, };
663*4882a593Smuzhiyun static int jz4770_ssi1_dr_e_pins[] = { 0x8e, };
664*4882a593Smuzhiyun static int jz4770_ssi1_clk_b_pins[] = { 0x3c, };
665*4882a593Smuzhiyun static int jz4770_ssi1_clk_d_pins[] = { 0x78, };
666*4882a593Smuzhiyun static int jz4770_ssi1_clk_e_pins[] = { 0x8f, };
667*4882a593Smuzhiyun static int jz4770_ssi1_gpc_b_pins[] = { 0x3e, };
668*4882a593Smuzhiyun static int jz4770_ssi1_gpc_d_pins[] = { 0x76, };
669*4882a593Smuzhiyun static int jz4770_ssi1_gpc_e_pins[] = { 0x93, };
670*4882a593Smuzhiyun static int jz4770_ssi1_ce0_b_pins[] = { 0x3d, };
671*4882a593Smuzhiyun static int jz4770_ssi1_ce0_d_pins[] = { 0x79, };
672*4882a593Smuzhiyun static int jz4770_ssi1_ce0_e_pins[] = { 0x90, };
673*4882a593Smuzhiyun static int jz4770_ssi1_ce1_b_pins[] = { 0x3f, };
674*4882a593Smuzhiyun static int jz4770_ssi1_ce1_d_pins[] = { 0x77, };
675*4882a593Smuzhiyun static int jz4770_ssi1_ce1_e_pins[] = { 0x92, };
676*4882a593Smuzhiyun static int jz4770_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, };
677*4882a593Smuzhiyun static int jz4770_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, };
678*4882a593Smuzhiyun static int jz4770_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
679*4882a593Smuzhiyun static int jz4770_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
680*4882a593Smuzhiyun static int jz4770_mmc0_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
681*4882a593Smuzhiyun static int jz4770_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, };
682*4882a593Smuzhiyun static int jz4770_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, };
683*4882a593Smuzhiyun static int jz4770_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
684*4882a593Smuzhiyun static int jz4770_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
685*4882a593Smuzhiyun static int jz4770_mmc1_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
686*4882a593Smuzhiyun static int jz4770_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, };
687*4882a593Smuzhiyun static int jz4770_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, };
688*4882a593Smuzhiyun static int jz4770_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
689*4882a593Smuzhiyun static int jz4770_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
690*4882a593Smuzhiyun static int jz4770_mmc2_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
691*4882a593Smuzhiyun static int jz4770_nemc_8bit_data_pins[] = {
692*4882a593Smuzhiyun 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
693*4882a593Smuzhiyun };
694*4882a593Smuzhiyun static int jz4770_nemc_16bit_data_pins[] = {
695*4882a593Smuzhiyun 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
696*4882a593Smuzhiyun };
697*4882a593Smuzhiyun static int jz4770_nemc_cle_ale_pins[] = { 0x20, 0x21, };
698*4882a593Smuzhiyun static int jz4770_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, };
699*4882a593Smuzhiyun static int jz4770_nemc_rd_we_pins[] = { 0x10, 0x11, };
700*4882a593Smuzhiyun static int jz4770_nemc_frd_fwe_pins[] = { 0x12, 0x13, };
701*4882a593Smuzhiyun static int jz4770_nemc_wait_pins[] = { 0x1b, };
702*4882a593Smuzhiyun static int jz4770_nemc_cs1_pins[] = { 0x15, };
703*4882a593Smuzhiyun static int jz4770_nemc_cs2_pins[] = { 0x16, };
704*4882a593Smuzhiyun static int jz4770_nemc_cs3_pins[] = { 0x17, };
705*4882a593Smuzhiyun static int jz4770_nemc_cs4_pins[] = { 0x18, };
706*4882a593Smuzhiyun static int jz4770_nemc_cs5_pins[] = { 0x19, };
707*4882a593Smuzhiyun static int jz4770_nemc_cs6_pins[] = { 0x1a, };
708*4882a593Smuzhiyun static int jz4770_i2c0_pins[] = { 0x7e, 0x7f, };
709*4882a593Smuzhiyun static int jz4770_i2c1_pins[] = { 0x9e, 0x9f, };
710*4882a593Smuzhiyun static int jz4770_i2c2_pins[] = { 0xb0, 0xb1, };
711*4882a593Smuzhiyun static int jz4770_cim_8bit_pins[] = {
712*4882a593Smuzhiyun 0x26, 0x27, 0x28, 0x29,
713*4882a593Smuzhiyun 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
714*4882a593Smuzhiyun };
715*4882a593Smuzhiyun static int jz4770_cim_12bit_pins[] = {
716*4882a593Smuzhiyun 0x32, 0x33, 0xb0, 0xb1,
717*4882a593Smuzhiyun };
718*4882a593Smuzhiyun static int jz4770_lcd_24bit_pins[] = {
719*4882a593Smuzhiyun 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
720*4882a593Smuzhiyun 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
721*4882a593Smuzhiyun 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
722*4882a593Smuzhiyun 0x58, 0x59, 0x5a, 0x5b,
723*4882a593Smuzhiyun };
724*4882a593Smuzhiyun static int jz4770_pwm_pwm0_pins[] = { 0x80, };
725*4882a593Smuzhiyun static int jz4770_pwm_pwm1_pins[] = { 0x81, };
726*4882a593Smuzhiyun static int jz4770_pwm_pwm2_pins[] = { 0x82, };
727*4882a593Smuzhiyun static int jz4770_pwm_pwm3_pins[] = { 0x83, };
728*4882a593Smuzhiyun static int jz4770_pwm_pwm4_pins[] = { 0x84, };
729*4882a593Smuzhiyun static int jz4770_pwm_pwm5_pins[] = { 0x85, };
730*4882a593Smuzhiyun static int jz4770_pwm_pwm6_pins[] = { 0x6a, };
731*4882a593Smuzhiyun static int jz4770_pwm_pwm7_pins[] = { 0x6b, };
732*4882a593Smuzhiyun static int jz4770_mac_rmii_pins[] = {
733*4882a593Smuzhiyun 0xa9, 0xab, 0xaa, 0xac, 0xa5, 0xa4, 0xad, 0xae, 0xa6, 0xa8,
734*4882a593Smuzhiyun };
735*4882a593Smuzhiyun static int jz4770_mac_mii_pins[] = { 0xa7, 0xaf, };
736*4882a593Smuzhiyun static int jz4770_otg_pins[] = { 0x8a, };
737*4882a593Smuzhiyun
738*4882a593Smuzhiyun static int jz4770_uart0_data_funcs[] = { 0, 0, };
739*4882a593Smuzhiyun static int jz4770_uart0_hwflow_funcs[] = { 0, 0, };
740*4882a593Smuzhiyun static int jz4770_uart1_data_funcs[] = { 0, 0, };
741*4882a593Smuzhiyun static int jz4770_uart1_hwflow_funcs[] = { 0, 0, };
742*4882a593Smuzhiyun static int jz4770_uart2_data_funcs[] = { 0, 0, };
743*4882a593Smuzhiyun static int jz4770_uart2_hwflow_funcs[] = { 0, 0, };
744*4882a593Smuzhiyun static int jz4770_uart3_data_funcs[] = { 0, 1, };
745*4882a593Smuzhiyun static int jz4770_uart3_hwflow_funcs[] = { 0, 0, };
746*4882a593Smuzhiyun static int jz4770_ssi0_dt_a_funcs[] = { 2, };
747*4882a593Smuzhiyun static int jz4770_ssi0_dt_b_funcs[] = { 1, };
748*4882a593Smuzhiyun static int jz4770_ssi0_dt_d_funcs[] = { 1, };
749*4882a593Smuzhiyun static int jz4770_ssi0_dt_e_funcs[] = { 0, };
750*4882a593Smuzhiyun static int jz4770_ssi0_dr_a_funcs[] = { 1, };
751*4882a593Smuzhiyun static int jz4770_ssi0_dr_b_funcs[] = { 1, };
752*4882a593Smuzhiyun static int jz4770_ssi0_dr_d_funcs[] = { 1, };
753*4882a593Smuzhiyun static int jz4770_ssi0_dr_e_funcs[] = { 0, };
754*4882a593Smuzhiyun static int jz4770_ssi0_clk_a_funcs[] = { 2, };
755*4882a593Smuzhiyun static int jz4770_ssi0_clk_b_funcs[] = { 1, };
756*4882a593Smuzhiyun static int jz4770_ssi0_clk_d_funcs[] = { 1, };
757*4882a593Smuzhiyun static int jz4770_ssi0_clk_e_funcs[] = { 0, };
758*4882a593Smuzhiyun static int jz4770_ssi0_gpc_b_funcs[] = { 1, };
759*4882a593Smuzhiyun static int jz4770_ssi0_gpc_d_funcs[] = { 1, };
760*4882a593Smuzhiyun static int jz4770_ssi0_gpc_e_funcs[] = { 0, };
761*4882a593Smuzhiyun static int jz4770_ssi0_ce0_a_funcs[] = { 2, };
762*4882a593Smuzhiyun static int jz4770_ssi0_ce0_b_funcs[] = { 1, };
763*4882a593Smuzhiyun static int jz4770_ssi0_ce0_d_funcs[] = { 1, };
764*4882a593Smuzhiyun static int jz4770_ssi0_ce0_e_funcs[] = { 0, };
765*4882a593Smuzhiyun static int jz4770_ssi0_ce1_b_funcs[] = { 1, };
766*4882a593Smuzhiyun static int jz4770_ssi0_ce1_d_funcs[] = { 1, };
767*4882a593Smuzhiyun static int jz4770_ssi0_ce1_e_funcs[] = { 0, };
768*4882a593Smuzhiyun static int jz4770_ssi1_dt_b_funcs[] = { 2, };
769*4882a593Smuzhiyun static int jz4770_ssi1_dt_d_funcs[] = { 2, };
770*4882a593Smuzhiyun static int jz4770_ssi1_dt_e_funcs[] = { 1, };
771*4882a593Smuzhiyun static int jz4770_ssi1_dr_b_funcs[] = { 2, };
772*4882a593Smuzhiyun static int jz4770_ssi1_dr_d_funcs[] = { 2, };
773*4882a593Smuzhiyun static int jz4770_ssi1_dr_e_funcs[] = { 1, };
774*4882a593Smuzhiyun static int jz4770_ssi1_clk_b_funcs[] = { 2, };
775*4882a593Smuzhiyun static int jz4770_ssi1_clk_d_funcs[] = { 2, };
776*4882a593Smuzhiyun static int jz4770_ssi1_clk_e_funcs[] = { 1, };
777*4882a593Smuzhiyun static int jz4770_ssi1_gpc_b_funcs[] = { 2, };
778*4882a593Smuzhiyun static int jz4770_ssi1_gpc_d_funcs[] = { 2, };
779*4882a593Smuzhiyun static int jz4770_ssi1_gpc_e_funcs[] = { 1, };
780*4882a593Smuzhiyun static int jz4770_ssi1_ce0_b_funcs[] = { 2, };
781*4882a593Smuzhiyun static int jz4770_ssi1_ce0_d_funcs[] = { 2, };
782*4882a593Smuzhiyun static int jz4770_ssi1_ce0_e_funcs[] = { 1, };
783*4882a593Smuzhiyun static int jz4770_ssi1_ce1_b_funcs[] = { 2, };
784*4882a593Smuzhiyun static int jz4770_ssi1_ce1_d_funcs[] = { 2, };
785*4882a593Smuzhiyun static int jz4770_ssi1_ce1_e_funcs[] = { 1, };
786*4882a593Smuzhiyun static int jz4770_mmc0_1bit_a_funcs[] = { 1, 1, 0, };
787*4882a593Smuzhiyun static int jz4770_mmc0_4bit_a_funcs[] = { 1, 1, 1, };
788*4882a593Smuzhiyun static int jz4770_mmc0_1bit_e_funcs[] = { 0, 0, 0, };
789*4882a593Smuzhiyun static int jz4770_mmc0_4bit_e_funcs[] = { 0, 0, 0, };
790*4882a593Smuzhiyun static int jz4770_mmc0_8bit_e_funcs[] = { 0, 0, 0, 0, };
791*4882a593Smuzhiyun static int jz4770_mmc1_1bit_d_funcs[] = { 0, 0, 0, };
792*4882a593Smuzhiyun static int jz4770_mmc1_4bit_d_funcs[] = { 0, 0, 0, };
793*4882a593Smuzhiyun static int jz4770_mmc1_1bit_e_funcs[] = { 1, 1, 1, };
794*4882a593Smuzhiyun static int jz4770_mmc1_4bit_e_funcs[] = { 1, 1, 1, };
795*4882a593Smuzhiyun static int jz4770_mmc1_8bit_e_funcs[] = { 1, 1, 1, 1, };
796*4882a593Smuzhiyun static int jz4770_mmc2_1bit_b_funcs[] = { 0, 0, 0, };
797*4882a593Smuzhiyun static int jz4770_mmc2_4bit_b_funcs[] = { 0, 0, 0, };
798*4882a593Smuzhiyun static int jz4770_mmc2_1bit_e_funcs[] = { 2, 2, 2, };
799*4882a593Smuzhiyun static int jz4770_mmc2_4bit_e_funcs[] = { 2, 2, 2, };
800*4882a593Smuzhiyun static int jz4770_mmc2_8bit_e_funcs[] = { 2, 2, 2, 2, };
801*4882a593Smuzhiyun static int jz4770_nemc_8bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
802*4882a593Smuzhiyun static int jz4770_nemc_16bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
803*4882a593Smuzhiyun static int jz4770_nemc_cle_ale_funcs[] = { 0, 0, };
804*4882a593Smuzhiyun static int jz4770_nemc_addr_funcs[] = { 0, 0, 0, 0, };
805*4882a593Smuzhiyun static int jz4770_nemc_rd_we_funcs[] = { 0, 0, };
806*4882a593Smuzhiyun static int jz4770_nemc_frd_fwe_funcs[] = { 0, 0, };
807*4882a593Smuzhiyun static int jz4770_nemc_wait_funcs[] = { 0, };
808*4882a593Smuzhiyun static int jz4770_nemc_cs1_funcs[] = { 0, };
809*4882a593Smuzhiyun static int jz4770_nemc_cs2_funcs[] = { 0, };
810*4882a593Smuzhiyun static int jz4770_nemc_cs3_funcs[] = { 0, };
811*4882a593Smuzhiyun static int jz4770_nemc_cs4_funcs[] = { 0, };
812*4882a593Smuzhiyun static int jz4770_nemc_cs5_funcs[] = { 0, };
813*4882a593Smuzhiyun static int jz4770_nemc_cs6_funcs[] = { 0, };
814*4882a593Smuzhiyun static int jz4770_i2c0_funcs[] = { 0, 0, };
815*4882a593Smuzhiyun static int jz4770_i2c1_funcs[] = { 0, 0, };
816*4882a593Smuzhiyun static int jz4770_i2c2_funcs[] = { 2, 2, };
817*4882a593Smuzhiyun static int jz4770_cim_8bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
818*4882a593Smuzhiyun static int jz4770_cim_12bit_funcs[] = { 0, 0, 0, 0, };
819*4882a593Smuzhiyun static int jz4770_lcd_24bit_funcs[] = {
820*4882a593Smuzhiyun 0, 0, 0, 0, 0, 0, 0, 0,
821*4882a593Smuzhiyun 0, 0, 0, 0, 0, 0, 0, 0,
822*4882a593Smuzhiyun 0, 0, 0, 0, 0, 0, 0, 0,
823*4882a593Smuzhiyun 0, 0, 0, 0,
824*4882a593Smuzhiyun };
825*4882a593Smuzhiyun static int jz4770_pwm_pwm0_funcs[] = { 0, };
826*4882a593Smuzhiyun static int jz4770_pwm_pwm1_funcs[] = { 0, };
827*4882a593Smuzhiyun static int jz4770_pwm_pwm2_funcs[] = { 0, };
828*4882a593Smuzhiyun static int jz4770_pwm_pwm3_funcs[] = { 0, };
829*4882a593Smuzhiyun static int jz4770_pwm_pwm4_funcs[] = { 0, };
830*4882a593Smuzhiyun static int jz4770_pwm_pwm5_funcs[] = { 0, };
831*4882a593Smuzhiyun static int jz4770_pwm_pwm6_funcs[] = { 0, };
832*4882a593Smuzhiyun static int jz4770_pwm_pwm7_funcs[] = { 0, };
833*4882a593Smuzhiyun static int jz4770_mac_rmii_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
834*4882a593Smuzhiyun static int jz4770_mac_mii_funcs[] = { 0, 0, };
835*4882a593Smuzhiyun static int jz4770_otg_funcs[] = { 0, };
836*4882a593Smuzhiyun
837*4882a593Smuzhiyun static const struct group_desc jz4770_groups[] = {
838*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-data", jz4770_uart0_data),
839*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-hwflow", jz4770_uart0_hwflow),
840*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-data", jz4770_uart1_data),
841*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-hwflow", jz4770_uart1_hwflow),
842*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart2-data", jz4770_uart2_data),
843*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart2-hwflow", jz4770_uart2_hwflow),
844*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart3-data", jz4770_uart3_data),
845*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart3-hwflow", jz4770_uart3_hwflow),
846*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dt-a", jz4770_ssi0_dt_a),
847*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dt-b", jz4770_ssi0_dt_b),
848*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dt-d", jz4770_ssi0_dt_d),
849*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dt-e", jz4770_ssi0_dt_e),
850*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dr-a", jz4770_ssi0_dr_a),
851*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dr-b", jz4770_ssi0_dr_b),
852*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dr-d", jz4770_ssi0_dr_d),
853*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dr-e", jz4770_ssi0_dr_e),
854*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-clk-a", jz4770_ssi0_clk_a),
855*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-clk-b", jz4770_ssi0_clk_b),
856*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-clk-d", jz4770_ssi0_clk_d),
857*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-clk-e", jz4770_ssi0_clk_e),
858*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-gpc-b", jz4770_ssi0_gpc_b),
859*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-gpc-d", jz4770_ssi0_gpc_d),
860*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-gpc-e", jz4770_ssi0_gpc_e),
861*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce0-a", jz4770_ssi0_ce0_a),
862*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce0-b", jz4770_ssi0_ce0_b),
863*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce0-d", jz4770_ssi0_ce0_d),
864*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce0-e", jz4770_ssi0_ce0_e),
865*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce1-b", jz4770_ssi0_ce1_b),
866*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce1-d", jz4770_ssi0_ce1_d),
867*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce1-e", jz4770_ssi0_ce1_e),
868*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dt-b", jz4770_ssi1_dt_b),
869*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dt-d", jz4770_ssi1_dt_d),
870*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dt-e", jz4770_ssi1_dt_e),
871*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dr-b", jz4770_ssi1_dr_b),
872*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dr-d", jz4770_ssi1_dr_d),
873*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dr-e", jz4770_ssi1_dr_e),
874*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-clk-b", jz4770_ssi1_clk_b),
875*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-clk-d", jz4770_ssi1_clk_d),
876*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-clk-e", jz4770_ssi1_clk_e),
877*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-gpc-b", jz4770_ssi1_gpc_b),
878*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-gpc-d", jz4770_ssi1_gpc_d),
879*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-gpc-e", jz4770_ssi1_gpc_e),
880*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce0-b", jz4770_ssi1_ce0_b),
881*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce0-d", jz4770_ssi1_ce0_d),
882*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce0-e", jz4770_ssi1_ce0_e),
883*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce1-b", jz4770_ssi1_ce1_b),
884*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce1-d", jz4770_ssi1_ce1_d),
885*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce1-e", jz4770_ssi1_ce1_e),
886*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-1bit-a", jz4770_mmc0_1bit_a),
887*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-4bit-a", jz4770_mmc0_4bit_a),
888*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-1bit-e", jz4770_mmc0_1bit_e),
889*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-4bit-e", jz4770_mmc0_4bit_e),
890*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-8bit-e", jz4770_mmc0_8bit_e),
891*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-1bit-d", jz4770_mmc1_1bit_d),
892*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-4bit-d", jz4770_mmc1_4bit_d),
893*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-1bit-e", jz4770_mmc1_1bit_e),
894*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-4bit-e", jz4770_mmc1_4bit_e),
895*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-8bit-e", jz4770_mmc1_8bit_e),
896*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-1bit-b", jz4770_mmc2_1bit_b),
897*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-4bit-b", jz4770_mmc2_4bit_b),
898*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-1bit-e", jz4770_mmc2_1bit_e),
899*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-4bit-e", jz4770_mmc2_4bit_e),
900*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-8bit-e", jz4770_mmc2_8bit_e),
901*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-8bit-data", jz4770_nemc_8bit_data),
902*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-16bit-data", jz4770_nemc_16bit_data),
903*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cle-ale", jz4770_nemc_cle_ale),
904*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-addr", jz4770_nemc_addr),
905*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-rd-we", jz4770_nemc_rd_we),
906*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-frd-fwe", jz4770_nemc_frd_fwe),
907*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-wait", jz4770_nemc_wait),
908*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs1", jz4770_nemc_cs1),
909*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs2", jz4770_nemc_cs2),
910*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs3", jz4770_nemc_cs3),
911*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs4", jz4770_nemc_cs4),
912*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs5", jz4770_nemc_cs5),
913*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs6", jz4770_nemc_cs6),
914*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c0-data", jz4770_i2c0),
915*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c1-data", jz4770_i2c1),
916*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c2-data", jz4770_i2c2),
917*4882a593Smuzhiyun INGENIC_PIN_GROUP("cim-data-8bit", jz4770_cim_8bit),
918*4882a593Smuzhiyun INGENIC_PIN_GROUP("cim-data-12bit", jz4770_cim_12bit),
919*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-24bit", jz4770_lcd_24bit),
920*4882a593Smuzhiyun { "lcd-no-pins", },
921*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm0", jz4770_pwm_pwm0),
922*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm1", jz4770_pwm_pwm1),
923*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm2", jz4770_pwm_pwm2),
924*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm3", jz4770_pwm_pwm3),
925*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm4", jz4770_pwm_pwm4),
926*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm5", jz4770_pwm_pwm5),
927*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm6", jz4770_pwm_pwm6),
928*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm7", jz4770_pwm_pwm7),
929*4882a593Smuzhiyun INGENIC_PIN_GROUP("mac-rmii", jz4770_mac_rmii),
930*4882a593Smuzhiyun INGENIC_PIN_GROUP("mac-mii", jz4770_mac_mii),
931*4882a593Smuzhiyun INGENIC_PIN_GROUP("otg-vbus", jz4770_otg),
932*4882a593Smuzhiyun };
933*4882a593Smuzhiyun
934*4882a593Smuzhiyun static const char *jz4770_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
935*4882a593Smuzhiyun static const char *jz4770_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
936*4882a593Smuzhiyun static const char *jz4770_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
937*4882a593Smuzhiyun static const char *jz4770_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
938*4882a593Smuzhiyun static const char *jz4770_ssi0_groups[] = {
939*4882a593Smuzhiyun "ssi0-dt-a", "ssi0-dt-b", "ssi0-dt-d", "ssi0-dt-e",
940*4882a593Smuzhiyun "ssi0-dr-a", "ssi0-dr-b", "ssi0-dr-d", "ssi0-dr-e",
941*4882a593Smuzhiyun "ssi0-clk-a", "ssi0-clk-b", "ssi0-clk-d", "ssi0-clk-e",
942*4882a593Smuzhiyun "ssi0-gpc-b", "ssi0-gpc-d", "ssi0-gpc-e",
943*4882a593Smuzhiyun "ssi0-ce0-a", "ssi0-ce0-b", "ssi0-ce0-d", "ssi0-ce0-e",
944*4882a593Smuzhiyun "ssi0-ce1-b", "ssi0-ce1-d", "ssi0-ce1-e",
945*4882a593Smuzhiyun };
946*4882a593Smuzhiyun static const char *jz4770_ssi1_groups[] = {
947*4882a593Smuzhiyun "ssi1-dt-b", "ssi1-dt-d", "ssi1-dt-e",
948*4882a593Smuzhiyun "ssi1-dr-b", "ssi1-dr-d", "ssi1-dr-e",
949*4882a593Smuzhiyun "ssi1-clk-b", "ssi1-clk-d", "ssi1-clk-e",
950*4882a593Smuzhiyun "ssi1-gpc-b", "ssi1-gpc-d", "ssi1-gpc-e",
951*4882a593Smuzhiyun "ssi1-ce0-b", "ssi1-ce0-d", "ssi1-ce0-e",
952*4882a593Smuzhiyun "ssi1-ce1-b", "ssi1-ce1-d", "ssi1-ce1-e",
953*4882a593Smuzhiyun };
954*4882a593Smuzhiyun static const char *jz4770_mmc0_groups[] = {
955*4882a593Smuzhiyun "mmc0-1bit-a", "mmc0-4bit-a",
956*4882a593Smuzhiyun "mmc0-1bit-e", "mmc0-4bit-e", "mmc0-8bit-e",
957*4882a593Smuzhiyun };
958*4882a593Smuzhiyun static const char *jz4770_mmc1_groups[] = {
959*4882a593Smuzhiyun "mmc1-1bit-d", "mmc1-4bit-d",
960*4882a593Smuzhiyun "mmc1-1bit-e", "mmc1-4bit-e", "mmc1-8bit-e",
961*4882a593Smuzhiyun };
962*4882a593Smuzhiyun static const char *jz4770_mmc2_groups[] = {
963*4882a593Smuzhiyun "mmc2-1bit-b", "mmc2-4bit-b",
964*4882a593Smuzhiyun "mmc2-1bit-e", "mmc2-4bit-e", "mmc2-8bit-e",
965*4882a593Smuzhiyun };
966*4882a593Smuzhiyun static const char *jz4770_nemc_groups[] = {
967*4882a593Smuzhiyun "nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale",
968*4882a593Smuzhiyun "nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
969*4882a593Smuzhiyun };
970*4882a593Smuzhiyun static const char *jz4770_cs1_groups[] = { "nemc-cs1", };
971*4882a593Smuzhiyun static const char *jz4770_cs2_groups[] = { "nemc-cs2", };
972*4882a593Smuzhiyun static const char *jz4770_cs3_groups[] = { "nemc-cs3", };
973*4882a593Smuzhiyun static const char *jz4770_cs4_groups[] = { "nemc-cs4", };
974*4882a593Smuzhiyun static const char *jz4770_cs5_groups[] = { "nemc-cs5", };
975*4882a593Smuzhiyun static const char *jz4770_cs6_groups[] = { "nemc-cs6", };
976*4882a593Smuzhiyun static const char *jz4770_i2c0_groups[] = { "i2c0-data", };
977*4882a593Smuzhiyun static const char *jz4770_i2c1_groups[] = { "i2c1-data", };
978*4882a593Smuzhiyun static const char *jz4770_i2c2_groups[] = { "i2c2-data", };
979*4882a593Smuzhiyun static const char *jz4770_cim_groups[] = { "cim-data-8bit", "cim-data-12bit", };
980*4882a593Smuzhiyun static const char *jz4770_lcd_groups[] = { "lcd-24bit", "lcd-no-pins", };
981*4882a593Smuzhiyun static const char *jz4770_pwm0_groups[] = { "pwm0", };
982*4882a593Smuzhiyun static const char *jz4770_pwm1_groups[] = { "pwm1", };
983*4882a593Smuzhiyun static const char *jz4770_pwm2_groups[] = { "pwm2", };
984*4882a593Smuzhiyun static const char *jz4770_pwm3_groups[] = { "pwm3", };
985*4882a593Smuzhiyun static const char *jz4770_pwm4_groups[] = { "pwm4", };
986*4882a593Smuzhiyun static const char *jz4770_pwm5_groups[] = { "pwm5", };
987*4882a593Smuzhiyun static const char *jz4770_pwm6_groups[] = { "pwm6", };
988*4882a593Smuzhiyun static const char *jz4770_pwm7_groups[] = { "pwm7", };
989*4882a593Smuzhiyun static const char *jz4770_mac_groups[] = { "mac-rmii", "mac-mii", };
990*4882a593Smuzhiyun static const char *jz4770_otg_groups[] = { "otg-vbus", };
991*4882a593Smuzhiyun
992*4882a593Smuzhiyun static const struct function_desc jz4770_functions[] = {
993*4882a593Smuzhiyun { "uart0", jz4770_uart0_groups, ARRAY_SIZE(jz4770_uart0_groups), },
994*4882a593Smuzhiyun { "uart1", jz4770_uart1_groups, ARRAY_SIZE(jz4770_uart1_groups), },
995*4882a593Smuzhiyun { "uart2", jz4770_uart2_groups, ARRAY_SIZE(jz4770_uart2_groups), },
996*4882a593Smuzhiyun { "uart3", jz4770_uart3_groups, ARRAY_SIZE(jz4770_uart3_groups), },
997*4882a593Smuzhiyun { "ssi0", jz4770_ssi0_groups, ARRAY_SIZE(jz4770_ssi0_groups), },
998*4882a593Smuzhiyun { "ssi1", jz4770_ssi1_groups, ARRAY_SIZE(jz4770_ssi1_groups), },
999*4882a593Smuzhiyun { "mmc0", jz4770_mmc0_groups, ARRAY_SIZE(jz4770_mmc0_groups), },
1000*4882a593Smuzhiyun { "mmc1", jz4770_mmc1_groups, ARRAY_SIZE(jz4770_mmc1_groups), },
1001*4882a593Smuzhiyun { "mmc2", jz4770_mmc2_groups, ARRAY_SIZE(jz4770_mmc2_groups), },
1002*4882a593Smuzhiyun { "nemc", jz4770_nemc_groups, ARRAY_SIZE(jz4770_nemc_groups), },
1003*4882a593Smuzhiyun { "nemc-cs1", jz4770_cs1_groups, ARRAY_SIZE(jz4770_cs1_groups), },
1004*4882a593Smuzhiyun { "nemc-cs2", jz4770_cs2_groups, ARRAY_SIZE(jz4770_cs2_groups), },
1005*4882a593Smuzhiyun { "nemc-cs3", jz4770_cs3_groups, ARRAY_SIZE(jz4770_cs3_groups), },
1006*4882a593Smuzhiyun { "nemc-cs4", jz4770_cs4_groups, ARRAY_SIZE(jz4770_cs4_groups), },
1007*4882a593Smuzhiyun { "nemc-cs5", jz4770_cs5_groups, ARRAY_SIZE(jz4770_cs5_groups), },
1008*4882a593Smuzhiyun { "nemc-cs6", jz4770_cs6_groups, ARRAY_SIZE(jz4770_cs6_groups), },
1009*4882a593Smuzhiyun { "i2c0", jz4770_i2c0_groups, ARRAY_SIZE(jz4770_i2c0_groups), },
1010*4882a593Smuzhiyun { "i2c1", jz4770_i2c1_groups, ARRAY_SIZE(jz4770_i2c1_groups), },
1011*4882a593Smuzhiyun { "i2c2", jz4770_i2c2_groups, ARRAY_SIZE(jz4770_i2c2_groups), },
1012*4882a593Smuzhiyun { "cim", jz4770_cim_groups, ARRAY_SIZE(jz4770_cim_groups), },
1013*4882a593Smuzhiyun { "lcd", jz4770_lcd_groups, ARRAY_SIZE(jz4770_lcd_groups), },
1014*4882a593Smuzhiyun { "pwm0", jz4770_pwm0_groups, ARRAY_SIZE(jz4770_pwm0_groups), },
1015*4882a593Smuzhiyun { "pwm1", jz4770_pwm1_groups, ARRAY_SIZE(jz4770_pwm1_groups), },
1016*4882a593Smuzhiyun { "pwm2", jz4770_pwm2_groups, ARRAY_SIZE(jz4770_pwm2_groups), },
1017*4882a593Smuzhiyun { "pwm3", jz4770_pwm3_groups, ARRAY_SIZE(jz4770_pwm3_groups), },
1018*4882a593Smuzhiyun { "pwm4", jz4770_pwm4_groups, ARRAY_SIZE(jz4770_pwm4_groups), },
1019*4882a593Smuzhiyun { "pwm5", jz4770_pwm5_groups, ARRAY_SIZE(jz4770_pwm5_groups), },
1020*4882a593Smuzhiyun { "pwm6", jz4770_pwm6_groups, ARRAY_SIZE(jz4770_pwm6_groups), },
1021*4882a593Smuzhiyun { "pwm7", jz4770_pwm7_groups, ARRAY_SIZE(jz4770_pwm7_groups), },
1022*4882a593Smuzhiyun { "mac", jz4770_mac_groups, ARRAY_SIZE(jz4770_mac_groups), },
1023*4882a593Smuzhiyun { "otg", jz4770_otg_groups, ARRAY_SIZE(jz4770_otg_groups), },
1024*4882a593Smuzhiyun };
1025*4882a593Smuzhiyun
1026*4882a593Smuzhiyun static const struct ingenic_chip_info jz4770_chip_info = {
1027*4882a593Smuzhiyun .num_chips = 6,
1028*4882a593Smuzhiyun .reg_offset = 0x100,
1029*4882a593Smuzhiyun .version = ID_JZ4770,
1030*4882a593Smuzhiyun .groups = jz4770_groups,
1031*4882a593Smuzhiyun .num_groups = ARRAY_SIZE(jz4770_groups),
1032*4882a593Smuzhiyun .functions = jz4770_functions,
1033*4882a593Smuzhiyun .num_functions = ARRAY_SIZE(jz4770_functions),
1034*4882a593Smuzhiyun .pull_ups = jz4770_pull_ups,
1035*4882a593Smuzhiyun .pull_downs = jz4770_pull_downs,
1036*4882a593Smuzhiyun };
1037*4882a593Smuzhiyun
1038*4882a593Smuzhiyun static const u32 jz4780_pull_ups[6] = {
1039*4882a593Smuzhiyun 0x3fffffff, 0xfff0f3fc, 0x0fffffff, 0xffff4fff, 0xfffffb7c, 0x7fa7f00f,
1040*4882a593Smuzhiyun };
1041*4882a593Smuzhiyun
1042*4882a593Smuzhiyun static const u32 jz4780_pull_downs[6] = {
1043*4882a593Smuzhiyun 0x00000000, 0x000f0c03, 0x00000000, 0x0000b000, 0x00000483, 0x00580ff0,
1044*4882a593Smuzhiyun };
1045*4882a593Smuzhiyun
1046*4882a593Smuzhiyun static int jz4780_uart2_data_pins[] = { 0x66, 0x67, };
1047*4882a593Smuzhiyun static int jz4780_uart2_hwflow_pins[] = { 0x65, 0x64, };
1048*4882a593Smuzhiyun static int jz4780_uart4_data_pins[] = { 0x54, 0x4a, };
1049*4882a593Smuzhiyun static int jz4780_ssi0_dt_a_19_pins[] = { 0x13, };
1050*4882a593Smuzhiyun static int jz4780_ssi0_dt_a_21_pins[] = { 0x15, };
1051*4882a593Smuzhiyun static int jz4780_ssi0_dt_a_28_pins[] = { 0x1c, };
1052*4882a593Smuzhiyun static int jz4780_ssi0_dt_b_pins[] = { 0x3d, };
1053*4882a593Smuzhiyun static int jz4780_ssi0_dt_d_pins[] = { 0x79, };
1054*4882a593Smuzhiyun static int jz4780_ssi0_dr_a_20_pins[] = { 0x14, };
1055*4882a593Smuzhiyun static int jz4780_ssi0_dr_a_27_pins[] = { 0x1b, };
1056*4882a593Smuzhiyun static int jz4780_ssi0_dr_b_pins[] = { 0x34, };
1057*4882a593Smuzhiyun static int jz4780_ssi0_dr_d_pins[] = { 0x74, };
1058*4882a593Smuzhiyun static int jz4780_ssi0_clk_a_pins[] = { 0x12, };
1059*4882a593Smuzhiyun static int jz4780_ssi0_clk_b_5_pins[] = { 0x25, };
1060*4882a593Smuzhiyun static int jz4780_ssi0_clk_b_28_pins[] = { 0x3c, };
1061*4882a593Smuzhiyun static int jz4780_ssi0_clk_d_pins[] = { 0x78, };
1062*4882a593Smuzhiyun static int jz4780_ssi0_gpc_b_pins[] = { 0x3e, };
1063*4882a593Smuzhiyun static int jz4780_ssi0_gpc_d_pins[] = { 0x76, };
1064*4882a593Smuzhiyun static int jz4780_ssi0_ce0_a_23_pins[] = { 0x17, };
1065*4882a593Smuzhiyun static int jz4780_ssi0_ce0_a_25_pins[] = { 0x19, };
1066*4882a593Smuzhiyun static int jz4780_ssi0_ce0_b_pins[] = { 0x3f, };
1067*4882a593Smuzhiyun static int jz4780_ssi0_ce0_d_pins[] = { 0x77, };
1068*4882a593Smuzhiyun static int jz4780_ssi0_ce1_b_pins[] = { 0x35, };
1069*4882a593Smuzhiyun static int jz4780_ssi0_ce1_d_pins[] = { 0x75, };
1070*4882a593Smuzhiyun static int jz4780_ssi1_dt_b_pins[] = { 0x3d, };
1071*4882a593Smuzhiyun static int jz4780_ssi1_dt_d_pins[] = { 0x79, };
1072*4882a593Smuzhiyun static int jz4780_ssi1_dr_b_pins[] = { 0x34, };
1073*4882a593Smuzhiyun static int jz4780_ssi1_dr_d_pins[] = { 0x74, };
1074*4882a593Smuzhiyun static int jz4780_ssi1_clk_b_pins[] = { 0x3c, };
1075*4882a593Smuzhiyun static int jz4780_ssi1_clk_d_pins[] = { 0x78, };
1076*4882a593Smuzhiyun static int jz4780_ssi1_gpc_b_pins[] = { 0x3e, };
1077*4882a593Smuzhiyun static int jz4780_ssi1_gpc_d_pins[] = { 0x76, };
1078*4882a593Smuzhiyun static int jz4780_ssi1_ce0_b_pins[] = { 0x3f, };
1079*4882a593Smuzhiyun static int jz4780_ssi1_ce0_d_pins[] = { 0x77, };
1080*4882a593Smuzhiyun static int jz4780_ssi1_ce1_b_pins[] = { 0x35, };
1081*4882a593Smuzhiyun static int jz4780_ssi1_ce1_d_pins[] = { 0x75, };
1082*4882a593Smuzhiyun static int jz4780_mmc0_8bit_a_pins[] = { 0x04, 0x05, 0x06, 0x07, 0x18, };
1083*4882a593Smuzhiyun static int jz4780_i2c3_pins[] = { 0x6a, 0x6b, };
1084*4882a593Smuzhiyun static int jz4780_i2c4_e_pins[] = { 0x8c, 0x8d, };
1085*4882a593Smuzhiyun static int jz4780_i2c4_f_pins[] = { 0xb9, 0xb8, };
1086*4882a593Smuzhiyun static int jz4780_i2s_data_tx_pins[] = { 0x87, };
1087*4882a593Smuzhiyun static int jz4780_i2s_data_rx_pins[] = { 0x86, };
1088*4882a593Smuzhiyun static int jz4780_i2s_clk_txrx_pins[] = { 0x6c, 0x6d, };
1089*4882a593Smuzhiyun static int jz4780_i2s_clk_rx_pins[] = { 0x88, 0x89, };
1090*4882a593Smuzhiyun static int jz4780_i2s_sysclk_pins[] = { 0x85, };
1091*4882a593Smuzhiyun static int jz4780_hdmi_ddc_pins[] = { 0xb9, 0xb8, };
1092*4882a593Smuzhiyun
1093*4882a593Smuzhiyun static int jz4780_uart2_data_funcs[] = { 1, 1, };
1094*4882a593Smuzhiyun static int jz4780_uart2_hwflow_funcs[] = { 1, 1, };
1095*4882a593Smuzhiyun static int jz4780_uart4_data_funcs[] = { 2, 2, };
1096*4882a593Smuzhiyun static int jz4780_ssi0_dt_a_19_funcs[] = { 2, };
1097*4882a593Smuzhiyun static int jz4780_ssi0_dt_a_21_funcs[] = { 2, };
1098*4882a593Smuzhiyun static int jz4780_ssi0_dt_a_28_funcs[] = { 2, };
1099*4882a593Smuzhiyun static int jz4780_ssi0_dt_b_funcs[] = { 1, };
1100*4882a593Smuzhiyun static int jz4780_ssi0_dt_d_funcs[] = { 1, };
1101*4882a593Smuzhiyun static int jz4780_ssi0_dr_a_20_funcs[] = { 2, };
1102*4882a593Smuzhiyun static int jz4780_ssi0_dr_a_27_funcs[] = { 2, };
1103*4882a593Smuzhiyun static int jz4780_ssi0_dr_b_funcs[] = { 1, };
1104*4882a593Smuzhiyun static int jz4780_ssi0_dr_d_funcs[] = { 1, };
1105*4882a593Smuzhiyun static int jz4780_ssi0_clk_a_funcs[] = { 2, };
1106*4882a593Smuzhiyun static int jz4780_ssi0_clk_b_5_funcs[] = { 1, };
1107*4882a593Smuzhiyun static int jz4780_ssi0_clk_b_28_funcs[] = { 1, };
1108*4882a593Smuzhiyun static int jz4780_ssi0_clk_d_funcs[] = { 1, };
1109*4882a593Smuzhiyun static int jz4780_ssi0_gpc_b_funcs[] = { 1, };
1110*4882a593Smuzhiyun static int jz4780_ssi0_gpc_d_funcs[] = { 1, };
1111*4882a593Smuzhiyun static int jz4780_ssi0_ce0_a_23_funcs[] = { 2, };
1112*4882a593Smuzhiyun static int jz4780_ssi0_ce0_a_25_funcs[] = { 2, };
1113*4882a593Smuzhiyun static int jz4780_ssi0_ce0_b_funcs[] = { 1, };
1114*4882a593Smuzhiyun static int jz4780_ssi0_ce0_d_funcs[] = { 1, };
1115*4882a593Smuzhiyun static int jz4780_ssi0_ce1_b_funcs[] = { 1, };
1116*4882a593Smuzhiyun static int jz4780_ssi0_ce1_d_funcs[] = { 1, };
1117*4882a593Smuzhiyun static int jz4780_ssi1_dt_b_funcs[] = { 2, };
1118*4882a593Smuzhiyun static int jz4780_ssi1_dt_d_funcs[] = { 2, };
1119*4882a593Smuzhiyun static int jz4780_ssi1_dr_b_funcs[] = { 2, };
1120*4882a593Smuzhiyun static int jz4780_ssi1_dr_d_funcs[] = { 2, };
1121*4882a593Smuzhiyun static int jz4780_ssi1_clk_b_funcs[] = { 2, };
1122*4882a593Smuzhiyun static int jz4780_ssi1_clk_d_funcs[] = { 2, };
1123*4882a593Smuzhiyun static int jz4780_ssi1_gpc_b_funcs[] = { 2, };
1124*4882a593Smuzhiyun static int jz4780_ssi1_gpc_d_funcs[] = { 2, };
1125*4882a593Smuzhiyun static int jz4780_ssi1_ce0_b_funcs[] = { 2, };
1126*4882a593Smuzhiyun static int jz4780_ssi1_ce0_d_funcs[] = { 2, };
1127*4882a593Smuzhiyun static int jz4780_ssi1_ce1_b_funcs[] = { 2, };
1128*4882a593Smuzhiyun static int jz4780_ssi1_ce1_d_funcs[] = { 2, };
1129*4882a593Smuzhiyun static int jz4780_mmc0_8bit_a_funcs[] = { 1, 1, 1, 1, 1, };
1130*4882a593Smuzhiyun static int jz4780_i2c3_funcs[] = { 1, 1, };
1131*4882a593Smuzhiyun static int jz4780_i2c4_e_funcs[] = { 1, 1, };
1132*4882a593Smuzhiyun static int jz4780_i2c4_f_funcs[] = { 1, 1, };
1133*4882a593Smuzhiyun static int jz4780_i2s_data_tx_funcs[] = { 0, };
1134*4882a593Smuzhiyun static int jz4780_i2s_data_rx_funcs[] = { 0, };
1135*4882a593Smuzhiyun static int jz4780_i2s_clk_txrx_funcs[] = { 1, 0, };
1136*4882a593Smuzhiyun static int jz4780_i2s_clk_rx_funcs[] = { 1, 1, };
1137*4882a593Smuzhiyun static int jz4780_i2s_sysclk_funcs[] = { 2, };
1138*4882a593Smuzhiyun static int jz4780_hdmi_ddc_funcs[] = { 0, 0, };
1139*4882a593Smuzhiyun
1140*4882a593Smuzhiyun static const struct group_desc jz4780_groups[] = {
1141*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-data", jz4770_uart0_data),
1142*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-hwflow", jz4770_uart0_hwflow),
1143*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-data", jz4770_uart1_data),
1144*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-hwflow", jz4770_uart1_hwflow),
1145*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart2-data", jz4780_uart2_data),
1146*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart2-hwflow", jz4780_uart2_hwflow),
1147*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart3-data", jz4770_uart3_data),
1148*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart3-hwflow", jz4770_uart3_hwflow),
1149*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart4-data", jz4780_uart4_data),
1150*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dt-a-19", jz4780_ssi0_dt_a_19),
1151*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dt-a-21", jz4780_ssi0_dt_a_21),
1152*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dt-a-28", jz4780_ssi0_dt_a_28),
1153*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dt-b", jz4780_ssi0_dt_b),
1154*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dt-d", jz4780_ssi0_dt_d),
1155*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dt-e", jz4770_ssi0_dt_e),
1156*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dr-a-20", jz4780_ssi0_dr_a_20),
1157*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dr-a-27", jz4780_ssi0_dr_a_27),
1158*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dr-b", jz4780_ssi0_dr_b),
1159*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dr-d", jz4780_ssi0_dr_d),
1160*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dr-e", jz4770_ssi0_dr_e),
1161*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-clk-a", jz4780_ssi0_clk_a),
1162*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-clk-b-5", jz4780_ssi0_clk_b_5),
1163*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-clk-b-28", jz4780_ssi0_clk_b_28),
1164*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-clk-d", jz4780_ssi0_clk_d),
1165*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-clk-e", jz4770_ssi0_clk_e),
1166*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-gpc-b", jz4780_ssi0_gpc_b),
1167*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-gpc-d", jz4780_ssi0_gpc_d),
1168*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-gpc-e", jz4770_ssi0_gpc_e),
1169*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce0-a-23", jz4780_ssi0_ce0_a_23),
1170*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce0-a-25", jz4780_ssi0_ce0_a_25),
1171*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce0-b", jz4780_ssi0_ce0_b),
1172*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce0-d", jz4780_ssi0_ce0_d),
1173*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce0-e", jz4770_ssi0_ce0_e),
1174*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce1-b", jz4780_ssi0_ce1_b),
1175*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce1-d", jz4780_ssi0_ce1_d),
1176*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce1-e", jz4770_ssi0_ce1_e),
1177*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dt-b", jz4780_ssi1_dt_b),
1178*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dt-d", jz4780_ssi1_dt_d),
1179*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dt-e", jz4770_ssi1_dt_e),
1180*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dr-b", jz4780_ssi1_dr_b),
1181*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dr-d", jz4780_ssi1_dr_d),
1182*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dr-e", jz4770_ssi1_dr_e),
1183*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-clk-b", jz4780_ssi1_clk_b),
1184*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-clk-d", jz4780_ssi1_clk_d),
1185*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-clk-e", jz4770_ssi1_clk_e),
1186*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-gpc-b", jz4780_ssi1_gpc_b),
1187*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-gpc-d", jz4780_ssi1_gpc_d),
1188*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-gpc-e", jz4770_ssi1_gpc_e),
1189*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce0-b", jz4780_ssi1_ce0_b),
1190*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce0-d", jz4780_ssi1_ce0_d),
1191*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce0-e", jz4770_ssi1_ce0_e),
1192*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce1-b", jz4780_ssi1_ce1_b),
1193*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce1-d", jz4780_ssi1_ce1_d),
1194*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce1-e", jz4770_ssi1_ce1_e),
1195*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-1bit-a", jz4770_mmc0_1bit_a),
1196*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-4bit-a", jz4770_mmc0_4bit_a),
1197*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-8bit-a", jz4780_mmc0_8bit_a),
1198*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-1bit-e", jz4770_mmc0_1bit_e),
1199*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-4bit-e", jz4770_mmc0_4bit_e),
1200*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-1bit-d", jz4770_mmc1_1bit_d),
1201*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-4bit-d", jz4770_mmc1_4bit_d),
1202*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-1bit-e", jz4770_mmc1_1bit_e),
1203*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-4bit-e", jz4770_mmc1_4bit_e),
1204*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-1bit-b", jz4770_mmc2_1bit_b),
1205*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-4bit-b", jz4770_mmc2_4bit_b),
1206*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-1bit-e", jz4770_mmc2_1bit_e),
1207*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc2-4bit-e", jz4770_mmc2_4bit_e),
1208*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-data", jz4770_nemc_8bit_data),
1209*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cle-ale", jz4770_nemc_cle_ale),
1210*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-addr", jz4770_nemc_addr),
1211*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-rd-we", jz4770_nemc_rd_we),
1212*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-frd-fwe", jz4770_nemc_frd_fwe),
1213*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-wait", jz4770_nemc_wait),
1214*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs1", jz4770_nemc_cs1),
1215*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs2", jz4770_nemc_cs2),
1216*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs3", jz4770_nemc_cs3),
1217*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs4", jz4770_nemc_cs4),
1218*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs5", jz4770_nemc_cs5),
1219*4882a593Smuzhiyun INGENIC_PIN_GROUP("nemc-cs6", jz4770_nemc_cs6),
1220*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c0-data", jz4770_i2c0),
1221*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c1-data", jz4770_i2c1),
1222*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c2-data", jz4770_i2c2),
1223*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c3-data", jz4780_i2c3),
1224*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c4-data-e", jz4780_i2c4_e),
1225*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c4-data-f", jz4780_i2c4_f),
1226*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-data-tx", jz4780_i2s_data_tx),
1227*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-data-rx", jz4780_i2s_data_rx),
1228*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-clk-txrx", jz4780_i2s_clk_txrx),
1229*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-clk-rx", jz4780_i2s_clk_rx),
1230*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-sysclk", jz4780_i2s_sysclk),
1231*4882a593Smuzhiyun INGENIC_PIN_GROUP("hdmi-ddc", jz4780_hdmi_ddc),
1232*4882a593Smuzhiyun INGENIC_PIN_GROUP("cim-data", jz4770_cim_8bit),
1233*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-24bit", jz4770_lcd_24bit),
1234*4882a593Smuzhiyun { "lcd-no-pins", },
1235*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm0", jz4770_pwm_pwm0),
1236*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm1", jz4770_pwm_pwm1),
1237*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm2", jz4770_pwm_pwm2),
1238*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm3", jz4770_pwm_pwm3),
1239*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm4", jz4770_pwm_pwm4),
1240*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm5", jz4770_pwm_pwm5),
1241*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm6", jz4770_pwm_pwm6),
1242*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm7", jz4770_pwm_pwm7),
1243*4882a593Smuzhiyun };
1244*4882a593Smuzhiyun
1245*4882a593Smuzhiyun static const char *jz4780_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
1246*4882a593Smuzhiyun static const char *jz4780_uart4_groups[] = { "uart4-data", };
1247*4882a593Smuzhiyun static const char *jz4780_ssi0_groups[] = {
1248*4882a593Smuzhiyun "ssi0-dt-a-19", "ssi0-dt-a-21", "ssi0-dt-a-28", "ssi0-dt-b", "ssi0-dt-d", "ssi0-dt-e",
1249*4882a593Smuzhiyun "ssi0-dr-a-20", "ssi0-dr-a-27", "ssi0-dr-b", "ssi0-dr-d", "ssi0-dr-e",
1250*4882a593Smuzhiyun "ssi0-clk-a", "ssi0-clk-b-5", "ssi0-clk-b-28", "ssi0-clk-d", "ssi0-clk-e",
1251*4882a593Smuzhiyun "ssi0-gpc-b", "ssi0-gpc-d", "ssi0-gpc-e",
1252*4882a593Smuzhiyun "ssi0-ce0-a-23", "ssi0-ce0-a-25", "ssi0-ce0-b", "ssi0-ce0-d", "ssi0-ce0-e",
1253*4882a593Smuzhiyun "ssi0-ce1-b", "ssi0-ce1-d", "ssi0-ce1-e",
1254*4882a593Smuzhiyun };
1255*4882a593Smuzhiyun static const char *jz4780_ssi1_groups[] = {
1256*4882a593Smuzhiyun "ssi1-dt-b", "ssi1-dt-d", "ssi1-dt-e",
1257*4882a593Smuzhiyun "ssi1-dr-b", "ssi1-dr-d", "ssi1-dr-e",
1258*4882a593Smuzhiyun "ssi1-clk-b", "ssi1-clk-d", "ssi1-clk-e",
1259*4882a593Smuzhiyun "ssi1-gpc-b", "ssi1-gpc-d", "ssi1-gpc-e",
1260*4882a593Smuzhiyun "ssi1-ce0-b", "ssi1-ce0-d", "ssi1-ce0-e",
1261*4882a593Smuzhiyun "ssi1-ce1-b", "ssi1-ce1-d", "ssi1-ce1-e",
1262*4882a593Smuzhiyun };
1263*4882a593Smuzhiyun static const char *jz4780_mmc0_groups[] = {
1264*4882a593Smuzhiyun "mmc0-1bit-a", "mmc0-4bit-a", "mmc0-8bit-a",
1265*4882a593Smuzhiyun "mmc0-1bit-e", "mmc0-4bit-e",
1266*4882a593Smuzhiyun };
1267*4882a593Smuzhiyun static const char *jz4780_mmc1_groups[] = {
1268*4882a593Smuzhiyun "mmc1-1bit-d", "mmc1-4bit-d", "mmc1-1bit-e", "mmc1-4bit-e",
1269*4882a593Smuzhiyun };
1270*4882a593Smuzhiyun static const char *jz4780_mmc2_groups[] = {
1271*4882a593Smuzhiyun "mmc2-1bit-b", "mmc2-4bit-b", "mmc2-1bit-e", "mmc2-4bit-e",
1272*4882a593Smuzhiyun };
1273*4882a593Smuzhiyun static const char *jz4780_nemc_groups[] = {
1274*4882a593Smuzhiyun "nemc-data", "nemc-cle-ale", "nemc-addr",
1275*4882a593Smuzhiyun "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
1276*4882a593Smuzhiyun };
1277*4882a593Smuzhiyun static const char *jz4780_i2c3_groups[] = { "i2c3-data", };
1278*4882a593Smuzhiyun static const char *jz4780_i2c4_groups[] = { "i2c4-data-e", "i2c4-data-f", };
1279*4882a593Smuzhiyun static const char *jz4780_i2s_groups[] = {
1280*4882a593Smuzhiyun "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-clk-rx", "i2s-sysclk",
1281*4882a593Smuzhiyun };
1282*4882a593Smuzhiyun static const char *jz4780_cim_groups[] = { "cim-data", };
1283*4882a593Smuzhiyun static const char *jz4780_hdmi_ddc_groups[] = { "hdmi-ddc", };
1284*4882a593Smuzhiyun
1285*4882a593Smuzhiyun static const struct function_desc jz4780_functions[] = {
1286*4882a593Smuzhiyun { "uart0", jz4770_uart0_groups, ARRAY_SIZE(jz4770_uart0_groups), },
1287*4882a593Smuzhiyun { "uart1", jz4770_uart1_groups, ARRAY_SIZE(jz4770_uart1_groups), },
1288*4882a593Smuzhiyun { "uart2", jz4780_uart2_groups, ARRAY_SIZE(jz4780_uart2_groups), },
1289*4882a593Smuzhiyun { "uart3", jz4770_uart3_groups, ARRAY_SIZE(jz4770_uart3_groups), },
1290*4882a593Smuzhiyun { "uart4", jz4780_uart4_groups, ARRAY_SIZE(jz4780_uart4_groups), },
1291*4882a593Smuzhiyun { "ssi0", jz4780_ssi0_groups, ARRAY_SIZE(jz4780_ssi0_groups), },
1292*4882a593Smuzhiyun { "ssi1", jz4780_ssi1_groups, ARRAY_SIZE(jz4780_ssi1_groups), },
1293*4882a593Smuzhiyun { "mmc0", jz4780_mmc0_groups, ARRAY_SIZE(jz4780_mmc0_groups), },
1294*4882a593Smuzhiyun { "mmc1", jz4780_mmc1_groups, ARRAY_SIZE(jz4780_mmc1_groups), },
1295*4882a593Smuzhiyun { "mmc2", jz4780_mmc2_groups, ARRAY_SIZE(jz4780_mmc2_groups), },
1296*4882a593Smuzhiyun { "nemc", jz4780_nemc_groups, ARRAY_SIZE(jz4780_nemc_groups), },
1297*4882a593Smuzhiyun { "nemc-cs1", jz4770_cs1_groups, ARRAY_SIZE(jz4770_cs1_groups), },
1298*4882a593Smuzhiyun { "nemc-cs2", jz4770_cs2_groups, ARRAY_SIZE(jz4770_cs2_groups), },
1299*4882a593Smuzhiyun { "nemc-cs3", jz4770_cs3_groups, ARRAY_SIZE(jz4770_cs3_groups), },
1300*4882a593Smuzhiyun { "nemc-cs4", jz4770_cs4_groups, ARRAY_SIZE(jz4770_cs4_groups), },
1301*4882a593Smuzhiyun { "nemc-cs5", jz4770_cs5_groups, ARRAY_SIZE(jz4770_cs5_groups), },
1302*4882a593Smuzhiyun { "nemc-cs6", jz4770_cs6_groups, ARRAY_SIZE(jz4770_cs6_groups), },
1303*4882a593Smuzhiyun { "i2c0", jz4770_i2c0_groups, ARRAY_SIZE(jz4770_i2c0_groups), },
1304*4882a593Smuzhiyun { "i2c1", jz4770_i2c1_groups, ARRAY_SIZE(jz4770_i2c1_groups), },
1305*4882a593Smuzhiyun { "i2c2", jz4770_i2c2_groups, ARRAY_SIZE(jz4770_i2c2_groups), },
1306*4882a593Smuzhiyun { "i2c3", jz4780_i2c3_groups, ARRAY_SIZE(jz4780_i2c3_groups), },
1307*4882a593Smuzhiyun { "i2c4", jz4780_i2c4_groups, ARRAY_SIZE(jz4780_i2c4_groups), },
1308*4882a593Smuzhiyun { "i2s", jz4780_i2s_groups, ARRAY_SIZE(jz4780_i2s_groups), },
1309*4882a593Smuzhiyun { "cim", jz4780_cim_groups, ARRAY_SIZE(jz4780_cim_groups), },
1310*4882a593Smuzhiyun { "lcd", jz4770_lcd_groups, ARRAY_SIZE(jz4770_lcd_groups), },
1311*4882a593Smuzhiyun { "pwm0", jz4770_pwm0_groups, ARRAY_SIZE(jz4770_pwm0_groups), },
1312*4882a593Smuzhiyun { "pwm1", jz4770_pwm1_groups, ARRAY_SIZE(jz4770_pwm1_groups), },
1313*4882a593Smuzhiyun { "pwm2", jz4770_pwm2_groups, ARRAY_SIZE(jz4770_pwm2_groups), },
1314*4882a593Smuzhiyun { "pwm3", jz4770_pwm3_groups, ARRAY_SIZE(jz4770_pwm3_groups), },
1315*4882a593Smuzhiyun { "pwm4", jz4770_pwm4_groups, ARRAY_SIZE(jz4770_pwm4_groups), },
1316*4882a593Smuzhiyun { "pwm5", jz4770_pwm5_groups, ARRAY_SIZE(jz4770_pwm5_groups), },
1317*4882a593Smuzhiyun { "pwm6", jz4770_pwm6_groups, ARRAY_SIZE(jz4770_pwm6_groups), },
1318*4882a593Smuzhiyun { "pwm7", jz4770_pwm7_groups, ARRAY_SIZE(jz4770_pwm7_groups), },
1319*4882a593Smuzhiyun { "hdmi-ddc", jz4780_hdmi_ddc_groups,
1320*4882a593Smuzhiyun ARRAY_SIZE(jz4780_hdmi_ddc_groups), },
1321*4882a593Smuzhiyun };
1322*4882a593Smuzhiyun
1323*4882a593Smuzhiyun static const struct ingenic_chip_info jz4780_chip_info = {
1324*4882a593Smuzhiyun .num_chips = 6,
1325*4882a593Smuzhiyun .reg_offset = 0x100,
1326*4882a593Smuzhiyun .version = ID_JZ4780,
1327*4882a593Smuzhiyun .groups = jz4780_groups,
1328*4882a593Smuzhiyun .num_groups = ARRAY_SIZE(jz4780_groups),
1329*4882a593Smuzhiyun .functions = jz4780_functions,
1330*4882a593Smuzhiyun .num_functions = ARRAY_SIZE(jz4780_functions),
1331*4882a593Smuzhiyun .pull_ups = jz4780_pull_ups,
1332*4882a593Smuzhiyun .pull_downs = jz4780_pull_downs,
1333*4882a593Smuzhiyun };
1334*4882a593Smuzhiyun
1335*4882a593Smuzhiyun static const u32 x1000_pull_ups[4] = {
1336*4882a593Smuzhiyun 0xffffffff, 0xfdffffff, 0x0dffffff, 0x0000003f,
1337*4882a593Smuzhiyun };
1338*4882a593Smuzhiyun
1339*4882a593Smuzhiyun static const u32 x1000_pull_downs[4] = {
1340*4882a593Smuzhiyun 0x00000000, 0x02000000, 0x02000000, 0x00000000,
1341*4882a593Smuzhiyun };
1342*4882a593Smuzhiyun
1343*4882a593Smuzhiyun static int x1000_uart0_data_pins[] = { 0x4a, 0x4b, };
1344*4882a593Smuzhiyun static int x1000_uart0_hwflow_pins[] = { 0x4c, 0x4d, };
1345*4882a593Smuzhiyun static int x1000_uart1_data_a_pins[] = { 0x04, 0x05, };
1346*4882a593Smuzhiyun static int x1000_uart1_data_d_pins[] = { 0x62, 0x63, };
1347*4882a593Smuzhiyun static int x1000_uart1_hwflow_pins[] = { 0x64, 0x65, };
1348*4882a593Smuzhiyun static int x1000_uart2_data_a_pins[] = { 0x02, 0x03, };
1349*4882a593Smuzhiyun static int x1000_uart2_data_d_pins[] = { 0x65, 0x64, };
1350*4882a593Smuzhiyun static int x1000_sfc_pins[] = { 0x1d, 0x1c, 0x1e, 0x1f, 0x1a, 0x1b, };
1351*4882a593Smuzhiyun static int x1000_ssi_dt_a_22_pins[] = { 0x16, };
1352*4882a593Smuzhiyun static int x1000_ssi_dt_a_29_pins[] = { 0x1d, };
1353*4882a593Smuzhiyun static int x1000_ssi_dt_d_pins[] = { 0x62, };
1354*4882a593Smuzhiyun static int x1000_ssi_dr_a_23_pins[] = { 0x17, };
1355*4882a593Smuzhiyun static int x1000_ssi_dr_a_28_pins[] = { 0x1c, };
1356*4882a593Smuzhiyun static int x1000_ssi_dr_d_pins[] = { 0x63, };
1357*4882a593Smuzhiyun static int x1000_ssi_clk_a_24_pins[] = { 0x18, };
1358*4882a593Smuzhiyun static int x1000_ssi_clk_a_26_pins[] = { 0x1a, };
1359*4882a593Smuzhiyun static int x1000_ssi_clk_d_pins[] = { 0x60, };
1360*4882a593Smuzhiyun static int x1000_ssi_gpc_a_20_pins[] = { 0x14, };
1361*4882a593Smuzhiyun static int x1000_ssi_gpc_a_31_pins[] = { 0x1f, };
1362*4882a593Smuzhiyun static int x1000_ssi_ce0_a_25_pins[] = { 0x19, };
1363*4882a593Smuzhiyun static int x1000_ssi_ce0_a_27_pins[] = { 0x1b, };
1364*4882a593Smuzhiyun static int x1000_ssi_ce0_d_pins[] = { 0x61, };
1365*4882a593Smuzhiyun static int x1000_ssi_ce1_a_21_pins[] = { 0x15, };
1366*4882a593Smuzhiyun static int x1000_ssi_ce1_a_30_pins[] = { 0x1e, };
1367*4882a593Smuzhiyun static int x1000_mmc0_1bit_pins[] = { 0x18, 0x19, 0x17, };
1368*4882a593Smuzhiyun static int x1000_mmc0_4bit_pins[] = { 0x16, 0x15, 0x14, };
1369*4882a593Smuzhiyun static int x1000_mmc0_8bit_pins[] = { 0x13, 0x12, 0x11, 0x10, };
1370*4882a593Smuzhiyun static int x1000_mmc1_1bit_pins[] = { 0x40, 0x41, 0x42, };
1371*4882a593Smuzhiyun static int x1000_mmc1_4bit_pins[] = { 0x43, 0x44, 0x45, };
1372*4882a593Smuzhiyun static int x1000_emc_8bit_data_pins[] = {
1373*4882a593Smuzhiyun 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1374*4882a593Smuzhiyun };
1375*4882a593Smuzhiyun static int x1000_emc_16bit_data_pins[] = {
1376*4882a593Smuzhiyun 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1377*4882a593Smuzhiyun };
1378*4882a593Smuzhiyun static int x1000_emc_addr_pins[] = {
1379*4882a593Smuzhiyun 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
1380*4882a593Smuzhiyun 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
1381*4882a593Smuzhiyun };
1382*4882a593Smuzhiyun static int x1000_emc_rd_we_pins[] = { 0x30, 0x31, };
1383*4882a593Smuzhiyun static int x1000_emc_wait_pins[] = { 0x34, };
1384*4882a593Smuzhiyun static int x1000_emc_cs1_pins[] = { 0x32, };
1385*4882a593Smuzhiyun static int x1000_emc_cs2_pins[] = { 0x33, };
1386*4882a593Smuzhiyun static int x1000_i2c0_pins[] = { 0x38, 0x37, };
1387*4882a593Smuzhiyun static int x1000_i2c1_a_pins[] = { 0x01, 0x00, };
1388*4882a593Smuzhiyun static int x1000_i2c1_c_pins[] = { 0x5b, 0x5a, };
1389*4882a593Smuzhiyun static int x1000_i2c2_pins[] = { 0x61, 0x60, };
1390*4882a593Smuzhiyun static int x1000_i2s_data_tx_pins[] = { 0x24, };
1391*4882a593Smuzhiyun static int x1000_i2s_data_rx_pins[] = { 0x23, };
1392*4882a593Smuzhiyun static int x1000_i2s_clk_txrx_pins[] = { 0x21, 0x22, };
1393*4882a593Smuzhiyun static int x1000_i2s_sysclk_pins[] = { 0x20, };
1394*4882a593Smuzhiyun static int x1000_cim_pins[] = {
1395*4882a593Smuzhiyun 0x08, 0x09, 0x0a, 0x0b,
1396*4882a593Smuzhiyun 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c,
1397*4882a593Smuzhiyun };
1398*4882a593Smuzhiyun static int x1000_lcd_8bit_pins[] = {
1399*4882a593Smuzhiyun 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1400*4882a593Smuzhiyun 0x30, 0x31, 0x32, 0x33, 0x34,
1401*4882a593Smuzhiyun };
1402*4882a593Smuzhiyun static int x1000_lcd_16bit_pins[] = {
1403*4882a593Smuzhiyun 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1404*4882a593Smuzhiyun };
1405*4882a593Smuzhiyun static int x1000_pwm_pwm0_pins[] = { 0x59, };
1406*4882a593Smuzhiyun static int x1000_pwm_pwm1_pins[] = { 0x5a, };
1407*4882a593Smuzhiyun static int x1000_pwm_pwm2_pins[] = { 0x5b, };
1408*4882a593Smuzhiyun static int x1000_pwm_pwm3_pins[] = { 0x26, };
1409*4882a593Smuzhiyun static int x1000_pwm_pwm4_pins[] = { 0x58, };
1410*4882a593Smuzhiyun static int x1000_mac_pins[] = {
1411*4882a593Smuzhiyun 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x26,
1412*4882a593Smuzhiyun };
1413*4882a593Smuzhiyun
1414*4882a593Smuzhiyun static int x1000_uart0_data_funcs[] = { 0, 0, };
1415*4882a593Smuzhiyun static int x1000_uart0_hwflow_funcs[] = { 0, 0, };
1416*4882a593Smuzhiyun static int x1000_uart1_data_a_funcs[] = { 2, 2, };
1417*4882a593Smuzhiyun static int x1000_uart1_data_d_funcs[] = { 1, 1, };
1418*4882a593Smuzhiyun static int x1000_uart1_hwflow_funcs[] = { 1, 1, };
1419*4882a593Smuzhiyun static int x1000_uart2_data_a_funcs[] = { 2, 2, };
1420*4882a593Smuzhiyun static int x1000_uart2_data_d_funcs[] = { 0, 0, };
1421*4882a593Smuzhiyun static int x1000_sfc_funcs[] = { 1, 1, 1, 1, 1, 1, };
1422*4882a593Smuzhiyun static int x1000_ssi_dt_a_22_funcs[] = { 2, };
1423*4882a593Smuzhiyun static int x1000_ssi_dt_a_29_funcs[] = { 2, };
1424*4882a593Smuzhiyun static int x1000_ssi_dt_d_funcs[] = { 0, };
1425*4882a593Smuzhiyun static int x1000_ssi_dr_a_23_funcs[] = { 2, };
1426*4882a593Smuzhiyun static int x1000_ssi_dr_a_28_funcs[] = { 2, };
1427*4882a593Smuzhiyun static int x1000_ssi_dr_d_funcs[] = { 0, };
1428*4882a593Smuzhiyun static int x1000_ssi_clk_a_24_funcs[] = { 2, };
1429*4882a593Smuzhiyun static int x1000_ssi_clk_a_26_funcs[] = { 2, };
1430*4882a593Smuzhiyun static int x1000_ssi_clk_d_funcs[] = { 0, };
1431*4882a593Smuzhiyun static int x1000_ssi_gpc_a_20_funcs[] = { 2, };
1432*4882a593Smuzhiyun static int x1000_ssi_gpc_a_31_funcs[] = { 2, };
1433*4882a593Smuzhiyun static int x1000_ssi_ce0_a_25_funcs[] = { 2, };
1434*4882a593Smuzhiyun static int x1000_ssi_ce0_a_27_funcs[] = { 2, };
1435*4882a593Smuzhiyun static int x1000_ssi_ce0_d_funcs[] = { 0, };
1436*4882a593Smuzhiyun static int x1000_ssi_ce1_a_21_funcs[] = { 2, };
1437*4882a593Smuzhiyun static int x1000_ssi_ce1_a_30_funcs[] = { 2, };
1438*4882a593Smuzhiyun static int x1000_mmc0_1bit_funcs[] = { 1, 1, 1, };
1439*4882a593Smuzhiyun static int x1000_mmc0_4bit_funcs[] = { 1, 1, 1, };
1440*4882a593Smuzhiyun static int x1000_mmc0_8bit_funcs[] = { 1, 1, 1, 1, 1, };
1441*4882a593Smuzhiyun static int x1000_mmc1_1bit_funcs[] = { 0, 0, 0, };
1442*4882a593Smuzhiyun static int x1000_mmc1_4bit_funcs[] = { 0, 0, 0, };
1443*4882a593Smuzhiyun static int x1000_emc_8bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
1444*4882a593Smuzhiyun static int x1000_emc_16bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
1445*4882a593Smuzhiyun static int x1000_emc_addr_funcs[] = {
1446*4882a593Smuzhiyun 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1447*4882a593Smuzhiyun };
1448*4882a593Smuzhiyun static int x1000_emc_rd_we_funcs[] = { 0, 0, };
1449*4882a593Smuzhiyun static int x1000_emc_wait_funcs[] = { 0, };
1450*4882a593Smuzhiyun static int x1000_emc_cs1_funcs[] = { 0, };
1451*4882a593Smuzhiyun static int x1000_emc_cs2_funcs[] = { 0, };
1452*4882a593Smuzhiyun static int x1000_i2c0_funcs[] = { 0, 0, };
1453*4882a593Smuzhiyun static int x1000_i2c1_a_funcs[] = { 2, 2, };
1454*4882a593Smuzhiyun static int x1000_i2c1_c_funcs[] = { 0, 0, };
1455*4882a593Smuzhiyun static int x1000_i2c2_funcs[] = { 1, 1, };
1456*4882a593Smuzhiyun static int x1000_i2s_data_tx_funcs[] = { 1, };
1457*4882a593Smuzhiyun static int x1000_i2s_data_rx_funcs[] = { 1, };
1458*4882a593Smuzhiyun static int x1000_i2s_clk_txrx_funcs[] = { 1, 1, };
1459*4882a593Smuzhiyun static int x1000_i2s_sysclk_funcs[] = { 1, };
1460*4882a593Smuzhiyun static int x1000_cim_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
1461*4882a593Smuzhiyun static int x1000_lcd_8bit_funcs[] = {
1462*4882a593Smuzhiyun 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1463*4882a593Smuzhiyun };
1464*4882a593Smuzhiyun static int x1000_lcd_16bit_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, };
1465*4882a593Smuzhiyun static int x1000_pwm_pwm0_funcs[] = { 0, };
1466*4882a593Smuzhiyun static int x1000_pwm_pwm1_funcs[] = { 1, };
1467*4882a593Smuzhiyun static int x1000_pwm_pwm2_funcs[] = { 1, };
1468*4882a593Smuzhiyun static int x1000_pwm_pwm3_funcs[] = { 2, };
1469*4882a593Smuzhiyun static int x1000_pwm_pwm4_funcs[] = { 0, };
1470*4882a593Smuzhiyun static int x1000_mac_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
1471*4882a593Smuzhiyun
1472*4882a593Smuzhiyun static const struct group_desc x1000_groups[] = {
1473*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-data", x1000_uart0_data),
1474*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-hwflow", x1000_uart0_hwflow),
1475*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-data-a", x1000_uart1_data_a),
1476*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-data-d", x1000_uart1_data_d),
1477*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-hwflow", x1000_uart1_hwflow),
1478*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart2-data-a", x1000_uart2_data_a),
1479*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart2-data-d", x1000_uart2_data_d),
1480*4882a593Smuzhiyun INGENIC_PIN_GROUP("sfc", x1000_sfc),
1481*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-dt-a-22", x1000_ssi_dt_a_22),
1482*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-dt-a-29", x1000_ssi_dt_a_29),
1483*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-dt-d", x1000_ssi_dt_d),
1484*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-dr-a-23", x1000_ssi_dr_a_23),
1485*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-dr-a-28", x1000_ssi_dr_a_28),
1486*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-dr-d", x1000_ssi_dr_d),
1487*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-clk-a-24", x1000_ssi_clk_a_24),
1488*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-clk-a-26", x1000_ssi_clk_a_26),
1489*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-clk-d", x1000_ssi_clk_d),
1490*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-gpc-a-20", x1000_ssi_gpc_a_20),
1491*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-gpc-a-31", x1000_ssi_gpc_a_31),
1492*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-ce0-a-25", x1000_ssi_ce0_a_25),
1493*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-ce0-a-27", x1000_ssi_ce0_a_27),
1494*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-ce0-d", x1000_ssi_ce0_d),
1495*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-ce1-a-21", x1000_ssi_ce1_a_21),
1496*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi-ce1-a-30", x1000_ssi_ce1_a_30),
1497*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-1bit", x1000_mmc0_1bit),
1498*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-4bit", x1000_mmc0_4bit),
1499*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-8bit", x1000_mmc0_8bit),
1500*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-1bit", x1000_mmc1_1bit),
1501*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-4bit", x1000_mmc1_4bit),
1502*4882a593Smuzhiyun INGENIC_PIN_GROUP("emc-8bit-data", x1000_emc_8bit_data),
1503*4882a593Smuzhiyun INGENIC_PIN_GROUP("emc-16bit-data", x1000_emc_16bit_data),
1504*4882a593Smuzhiyun INGENIC_PIN_GROUP("emc-addr", x1000_emc_addr),
1505*4882a593Smuzhiyun INGENIC_PIN_GROUP("emc-rd-we", x1000_emc_rd_we),
1506*4882a593Smuzhiyun INGENIC_PIN_GROUP("emc-wait", x1000_emc_wait),
1507*4882a593Smuzhiyun INGENIC_PIN_GROUP("emc-cs1", x1000_emc_cs1),
1508*4882a593Smuzhiyun INGENIC_PIN_GROUP("emc-cs2", x1000_emc_cs2),
1509*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c0-data", x1000_i2c0),
1510*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c1-data-a", x1000_i2c1_a),
1511*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c1-data-c", x1000_i2c1_c),
1512*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c2-data", x1000_i2c2),
1513*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-data-tx", x1000_i2s_data_tx),
1514*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-data-rx", x1000_i2s_data_rx),
1515*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-clk-txrx", x1000_i2s_clk_txrx),
1516*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-sysclk", x1000_i2s_sysclk),
1517*4882a593Smuzhiyun INGENIC_PIN_GROUP("cim-data", x1000_cim),
1518*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-8bit", x1000_lcd_8bit),
1519*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-16bit", x1000_lcd_16bit),
1520*4882a593Smuzhiyun { "lcd-no-pins", },
1521*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm0", x1000_pwm_pwm0),
1522*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm1", x1000_pwm_pwm1),
1523*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm2", x1000_pwm_pwm2),
1524*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm3", x1000_pwm_pwm3),
1525*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm4", x1000_pwm_pwm4),
1526*4882a593Smuzhiyun INGENIC_PIN_GROUP("mac", x1000_mac),
1527*4882a593Smuzhiyun };
1528*4882a593Smuzhiyun
1529*4882a593Smuzhiyun static const char *x1000_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1530*4882a593Smuzhiyun static const char *x1000_uart1_groups[] = {
1531*4882a593Smuzhiyun "uart1-data-a", "uart1-data-d", "uart1-hwflow",
1532*4882a593Smuzhiyun };
1533*4882a593Smuzhiyun static const char *x1000_uart2_groups[] = { "uart2-data-a", "uart2-data-d", };
1534*4882a593Smuzhiyun static const char *x1000_sfc_groups[] = { "sfc", };
1535*4882a593Smuzhiyun static const char *x1000_ssi_groups[] = {
1536*4882a593Smuzhiyun "ssi-dt-a-22", "ssi-dt-a-29", "ssi-dt-d",
1537*4882a593Smuzhiyun "ssi-dr-a-23", "ssi-dr-a-28", "ssi-dr-d",
1538*4882a593Smuzhiyun "ssi-clk-a-24", "ssi-clk-a-26", "ssi-clk-d",
1539*4882a593Smuzhiyun "ssi-gpc-a-20", "ssi-gpc-a-31",
1540*4882a593Smuzhiyun "ssi-ce0-a-25", "ssi-ce0-a-27", "ssi-ce0-d",
1541*4882a593Smuzhiyun "ssi-ce1-a-21", "ssi-ce1-a-30",
1542*4882a593Smuzhiyun };
1543*4882a593Smuzhiyun static const char *x1000_mmc0_groups[] = {
1544*4882a593Smuzhiyun "mmc0-1bit", "mmc0-4bit", "mmc0-8bit",
1545*4882a593Smuzhiyun };
1546*4882a593Smuzhiyun static const char *x1000_mmc1_groups[] = {
1547*4882a593Smuzhiyun "mmc1-1bit", "mmc1-4bit",
1548*4882a593Smuzhiyun };
1549*4882a593Smuzhiyun static const char *x1000_emc_groups[] = {
1550*4882a593Smuzhiyun "emc-8bit-data", "emc-16bit-data",
1551*4882a593Smuzhiyun "emc-addr", "emc-rd-we", "emc-wait",
1552*4882a593Smuzhiyun };
1553*4882a593Smuzhiyun static const char *x1000_cs1_groups[] = { "emc-cs1", };
1554*4882a593Smuzhiyun static const char *x1000_cs2_groups[] = { "emc-cs2", };
1555*4882a593Smuzhiyun static const char *x1000_i2c0_groups[] = { "i2c0-data", };
1556*4882a593Smuzhiyun static const char *x1000_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", };
1557*4882a593Smuzhiyun static const char *x1000_i2c2_groups[] = { "i2c2-data", };
1558*4882a593Smuzhiyun static const char *x1000_i2s_groups[] = {
1559*4882a593Smuzhiyun "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-sysclk",
1560*4882a593Smuzhiyun };
1561*4882a593Smuzhiyun static const char *x1000_cim_groups[] = { "cim-data", };
1562*4882a593Smuzhiyun static const char *x1000_lcd_groups[] = {
1563*4882a593Smuzhiyun "lcd-8bit", "lcd-16bit", "lcd-no-pins",
1564*4882a593Smuzhiyun };
1565*4882a593Smuzhiyun static const char *x1000_pwm0_groups[] = { "pwm0", };
1566*4882a593Smuzhiyun static const char *x1000_pwm1_groups[] = { "pwm1", };
1567*4882a593Smuzhiyun static const char *x1000_pwm2_groups[] = { "pwm2", };
1568*4882a593Smuzhiyun static const char *x1000_pwm3_groups[] = { "pwm3", };
1569*4882a593Smuzhiyun static const char *x1000_pwm4_groups[] = { "pwm4", };
1570*4882a593Smuzhiyun static const char *x1000_mac_groups[] = { "mac", };
1571*4882a593Smuzhiyun
1572*4882a593Smuzhiyun static const struct function_desc x1000_functions[] = {
1573*4882a593Smuzhiyun { "uart0", x1000_uart0_groups, ARRAY_SIZE(x1000_uart0_groups), },
1574*4882a593Smuzhiyun { "uart1", x1000_uart1_groups, ARRAY_SIZE(x1000_uart1_groups), },
1575*4882a593Smuzhiyun { "uart2", x1000_uart2_groups, ARRAY_SIZE(x1000_uart2_groups), },
1576*4882a593Smuzhiyun { "sfc", x1000_sfc_groups, ARRAY_SIZE(x1000_sfc_groups), },
1577*4882a593Smuzhiyun { "ssi", x1000_ssi_groups, ARRAY_SIZE(x1000_ssi_groups), },
1578*4882a593Smuzhiyun { "mmc0", x1000_mmc0_groups, ARRAY_SIZE(x1000_mmc0_groups), },
1579*4882a593Smuzhiyun { "mmc1", x1000_mmc1_groups, ARRAY_SIZE(x1000_mmc1_groups), },
1580*4882a593Smuzhiyun { "emc", x1000_emc_groups, ARRAY_SIZE(x1000_emc_groups), },
1581*4882a593Smuzhiyun { "emc-cs1", x1000_cs1_groups, ARRAY_SIZE(x1000_cs1_groups), },
1582*4882a593Smuzhiyun { "emc-cs2", x1000_cs2_groups, ARRAY_SIZE(x1000_cs2_groups), },
1583*4882a593Smuzhiyun { "i2c0", x1000_i2c0_groups, ARRAY_SIZE(x1000_i2c0_groups), },
1584*4882a593Smuzhiyun { "i2c1", x1000_i2c1_groups, ARRAY_SIZE(x1000_i2c1_groups), },
1585*4882a593Smuzhiyun { "i2c2", x1000_i2c2_groups, ARRAY_SIZE(x1000_i2c2_groups), },
1586*4882a593Smuzhiyun { "i2s", x1000_i2s_groups, ARRAY_SIZE(x1000_i2s_groups), },
1587*4882a593Smuzhiyun { "cim", x1000_cim_groups, ARRAY_SIZE(x1000_cim_groups), },
1588*4882a593Smuzhiyun { "lcd", x1000_lcd_groups, ARRAY_SIZE(x1000_lcd_groups), },
1589*4882a593Smuzhiyun { "pwm0", x1000_pwm0_groups, ARRAY_SIZE(x1000_pwm0_groups), },
1590*4882a593Smuzhiyun { "pwm1", x1000_pwm1_groups, ARRAY_SIZE(x1000_pwm1_groups), },
1591*4882a593Smuzhiyun { "pwm2", x1000_pwm2_groups, ARRAY_SIZE(x1000_pwm2_groups), },
1592*4882a593Smuzhiyun { "pwm3", x1000_pwm3_groups, ARRAY_SIZE(x1000_pwm3_groups), },
1593*4882a593Smuzhiyun { "pwm4", x1000_pwm4_groups, ARRAY_SIZE(x1000_pwm4_groups), },
1594*4882a593Smuzhiyun { "mac", x1000_mac_groups, ARRAY_SIZE(x1000_mac_groups), },
1595*4882a593Smuzhiyun };
1596*4882a593Smuzhiyun
1597*4882a593Smuzhiyun static const struct ingenic_chip_info x1000_chip_info = {
1598*4882a593Smuzhiyun .num_chips = 4,
1599*4882a593Smuzhiyun .reg_offset = 0x100,
1600*4882a593Smuzhiyun .version = ID_X1000,
1601*4882a593Smuzhiyun .groups = x1000_groups,
1602*4882a593Smuzhiyun .num_groups = ARRAY_SIZE(x1000_groups),
1603*4882a593Smuzhiyun .functions = x1000_functions,
1604*4882a593Smuzhiyun .num_functions = ARRAY_SIZE(x1000_functions),
1605*4882a593Smuzhiyun .pull_ups = x1000_pull_ups,
1606*4882a593Smuzhiyun .pull_downs = x1000_pull_downs,
1607*4882a593Smuzhiyun };
1608*4882a593Smuzhiyun
1609*4882a593Smuzhiyun static int x1500_uart0_data_pins[] = { 0x4a, 0x4b, };
1610*4882a593Smuzhiyun static int x1500_uart0_hwflow_pins[] = { 0x4c, 0x4d, };
1611*4882a593Smuzhiyun static int x1500_uart1_data_a_pins[] = { 0x04, 0x05, };
1612*4882a593Smuzhiyun static int x1500_uart1_data_d_pins[] = { 0x62, 0x63, };
1613*4882a593Smuzhiyun static int x1500_uart1_hwflow_pins[] = { 0x64, 0x65, };
1614*4882a593Smuzhiyun static int x1500_uart2_data_a_pins[] = { 0x02, 0x03, };
1615*4882a593Smuzhiyun static int x1500_uart2_data_d_pins[] = { 0x65, 0x64, };
1616*4882a593Smuzhiyun static int x1500_mmc_1bit_pins[] = { 0x18, 0x19, 0x17, };
1617*4882a593Smuzhiyun static int x1500_mmc_4bit_pins[] = { 0x16, 0x15, 0x14, };
1618*4882a593Smuzhiyun static int x1500_i2c0_pins[] = { 0x38, 0x37, };
1619*4882a593Smuzhiyun static int x1500_i2c1_a_pins[] = { 0x01, 0x00, };
1620*4882a593Smuzhiyun static int x1500_i2c1_c_pins[] = { 0x5b, 0x5a, };
1621*4882a593Smuzhiyun static int x1500_i2c2_pins[] = { 0x61, 0x60, };
1622*4882a593Smuzhiyun static int x1500_i2s_data_tx_pins[] = { 0x24, };
1623*4882a593Smuzhiyun static int x1500_i2s_data_rx_pins[] = { 0x23, };
1624*4882a593Smuzhiyun static int x1500_i2s_clk_txrx_pins[] = { 0x21, 0x22, };
1625*4882a593Smuzhiyun static int x1500_i2s_sysclk_pins[] = { 0x20, };
1626*4882a593Smuzhiyun static int x1500_cim_pins[] = {
1627*4882a593Smuzhiyun 0x08, 0x09, 0x0a, 0x0b,
1628*4882a593Smuzhiyun 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c,
1629*4882a593Smuzhiyun };
1630*4882a593Smuzhiyun static int x1500_pwm_pwm0_pins[] = { 0x59, };
1631*4882a593Smuzhiyun static int x1500_pwm_pwm1_pins[] = { 0x5a, };
1632*4882a593Smuzhiyun static int x1500_pwm_pwm2_pins[] = { 0x5b, };
1633*4882a593Smuzhiyun static int x1500_pwm_pwm3_pins[] = { 0x26, };
1634*4882a593Smuzhiyun static int x1500_pwm_pwm4_pins[] = { 0x58, };
1635*4882a593Smuzhiyun
1636*4882a593Smuzhiyun static int x1500_uart0_data_funcs[] = { 0, 0, };
1637*4882a593Smuzhiyun static int x1500_uart0_hwflow_funcs[] = { 0, 0, };
1638*4882a593Smuzhiyun static int x1500_uart1_data_a_funcs[] = { 2, 2, };
1639*4882a593Smuzhiyun static int x1500_uart1_data_d_funcs[] = { 1, 1, };
1640*4882a593Smuzhiyun static int x1500_uart1_hwflow_funcs[] = { 1, 1, };
1641*4882a593Smuzhiyun static int x1500_uart2_data_a_funcs[] = { 2, 2, };
1642*4882a593Smuzhiyun static int x1500_uart2_data_d_funcs[] = { 0, 0, };
1643*4882a593Smuzhiyun static int x1500_mmc_1bit_funcs[] = { 1, 1, 1, };
1644*4882a593Smuzhiyun static int x1500_mmc_4bit_funcs[] = { 1, 1, 1, };
1645*4882a593Smuzhiyun static int x1500_i2c0_funcs[] = { 0, 0, };
1646*4882a593Smuzhiyun static int x1500_i2c1_a_funcs[] = { 2, 2, };
1647*4882a593Smuzhiyun static int x1500_i2c1_c_funcs[] = { 0, 0, };
1648*4882a593Smuzhiyun static int x1500_i2c2_funcs[] = { 1, 1, };
1649*4882a593Smuzhiyun static int x1500_i2s_data_tx_funcs[] = { 1, };
1650*4882a593Smuzhiyun static int x1500_i2s_data_rx_funcs[] = { 1, };
1651*4882a593Smuzhiyun static int x1500_i2s_clk_txrx_funcs[] = { 1, 1, };
1652*4882a593Smuzhiyun static int x1500_i2s_sysclk_funcs[] = { 1, };
1653*4882a593Smuzhiyun static int x1500_cim_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
1654*4882a593Smuzhiyun static int x1500_pwm_pwm0_funcs[] = { 0, };
1655*4882a593Smuzhiyun static int x1500_pwm_pwm1_funcs[] = { 1, };
1656*4882a593Smuzhiyun static int x1500_pwm_pwm2_funcs[] = { 1, };
1657*4882a593Smuzhiyun static int x1500_pwm_pwm3_funcs[] = { 2, };
1658*4882a593Smuzhiyun static int x1500_pwm_pwm4_funcs[] = { 0, };
1659*4882a593Smuzhiyun
1660*4882a593Smuzhiyun static const struct group_desc x1500_groups[] = {
1661*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-data", x1500_uart0_data),
1662*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-hwflow", x1500_uart0_hwflow),
1663*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-data-a", x1500_uart1_data_a),
1664*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-data-d", x1500_uart1_data_d),
1665*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-hwflow", x1500_uart1_hwflow),
1666*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart2-data-a", x1500_uart2_data_a),
1667*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart2-data-d", x1500_uart2_data_d),
1668*4882a593Smuzhiyun INGENIC_PIN_GROUP("sfc", x1000_sfc),
1669*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc-1bit", x1500_mmc_1bit),
1670*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc-4bit", x1500_mmc_4bit),
1671*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c0-data", x1500_i2c0),
1672*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c1-data-a", x1500_i2c1_a),
1673*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c1-data-c", x1500_i2c1_c),
1674*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c2-data", x1500_i2c2),
1675*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-data-tx", x1500_i2s_data_tx),
1676*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-data-rx", x1500_i2s_data_rx),
1677*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-clk-txrx", x1500_i2s_clk_txrx),
1678*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-sysclk", x1500_i2s_sysclk),
1679*4882a593Smuzhiyun INGENIC_PIN_GROUP("cim-data", x1500_cim),
1680*4882a593Smuzhiyun { "lcd-no-pins", },
1681*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm0", x1500_pwm_pwm0),
1682*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm1", x1500_pwm_pwm1),
1683*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm2", x1500_pwm_pwm2),
1684*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm3", x1500_pwm_pwm3),
1685*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm4", x1500_pwm_pwm4),
1686*4882a593Smuzhiyun };
1687*4882a593Smuzhiyun
1688*4882a593Smuzhiyun static const char *x1500_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1689*4882a593Smuzhiyun static const char *x1500_uart1_groups[] = {
1690*4882a593Smuzhiyun "uart1-data-a", "uart1-data-d", "uart1-hwflow",
1691*4882a593Smuzhiyun };
1692*4882a593Smuzhiyun static const char *x1500_uart2_groups[] = { "uart2-data-a", "uart2-data-d", };
1693*4882a593Smuzhiyun static const char *x1500_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
1694*4882a593Smuzhiyun static const char *x1500_i2c0_groups[] = { "i2c0-data", };
1695*4882a593Smuzhiyun static const char *x1500_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", };
1696*4882a593Smuzhiyun static const char *x1500_i2c2_groups[] = { "i2c2-data", };
1697*4882a593Smuzhiyun static const char *x1500_i2s_groups[] = {
1698*4882a593Smuzhiyun "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-sysclk",
1699*4882a593Smuzhiyun };
1700*4882a593Smuzhiyun static const char *x1500_cim_groups[] = { "cim-data", };
1701*4882a593Smuzhiyun static const char *x1500_lcd_groups[] = { "lcd-no-pins", };
1702*4882a593Smuzhiyun static const char *x1500_pwm0_groups[] = { "pwm0", };
1703*4882a593Smuzhiyun static const char *x1500_pwm1_groups[] = { "pwm1", };
1704*4882a593Smuzhiyun static const char *x1500_pwm2_groups[] = { "pwm2", };
1705*4882a593Smuzhiyun static const char *x1500_pwm3_groups[] = { "pwm3", };
1706*4882a593Smuzhiyun static const char *x1500_pwm4_groups[] = { "pwm4", };
1707*4882a593Smuzhiyun
1708*4882a593Smuzhiyun static const struct function_desc x1500_functions[] = {
1709*4882a593Smuzhiyun { "uart0", x1500_uart0_groups, ARRAY_SIZE(x1500_uart0_groups), },
1710*4882a593Smuzhiyun { "uart1", x1500_uart1_groups, ARRAY_SIZE(x1500_uart1_groups), },
1711*4882a593Smuzhiyun { "uart2", x1500_uart2_groups, ARRAY_SIZE(x1500_uart2_groups), },
1712*4882a593Smuzhiyun { "sfc", x1000_sfc_groups, ARRAY_SIZE(x1000_sfc_groups), },
1713*4882a593Smuzhiyun { "mmc", x1500_mmc_groups, ARRAY_SIZE(x1500_mmc_groups), },
1714*4882a593Smuzhiyun { "i2c0", x1500_i2c0_groups, ARRAY_SIZE(x1500_i2c0_groups), },
1715*4882a593Smuzhiyun { "i2c1", x1500_i2c1_groups, ARRAY_SIZE(x1500_i2c1_groups), },
1716*4882a593Smuzhiyun { "i2c2", x1500_i2c2_groups, ARRAY_SIZE(x1500_i2c2_groups), },
1717*4882a593Smuzhiyun { "i2s", x1500_i2s_groups, ARRAY_SIZE(x1500_i2s_groups), },
1718*4882a593Smuzhiyun { "cim", x1500_cim_groups, ARRAY_SIZE(x1500_cim_groups), },
1719*4882a593Smuzhiyun { "lcd", x1500_lcd_groups, ARRAY_SIZE(x1500_lcd_groups), },
1720*4882a593Smuzhiyun { "pwm0", x1500_pwm0_groups, ARRAY_SIZE(x1500_pwm0_groups), },
1721*4882a593Smuzhiyun { "pwm1", x1500_pwm1_groups, ARRAY_SIZE(x1500_pwm1_groups), },
1722*4882a593Smuzhiyun { "pwm2", x1500_pwm2_groups, ARRAY_SIZE(x1500_pwm2_groups), },
1723*4882a593Smuzhiyun { "pwm3", x1500_pwm3_groups, ARRAY_SIZE(x1500_pwm3_groups), },
1724*4882a593Smuzhiyun { "pwm4", x1500_pwm4_groups, ARRAY_SIZE(x1500_pwm4_groups), },
1725*4882a593Smuzhiyun };
1726*4882a593Smuzhiyun
1727*4882a593Smuzhiyun static const struct ingenic_chip_info x1500_chip_info = {
1728*4882a593Smuzhiyun .num_chips = 4,
1729*4882a593Smuzhiyun .reg_offset = 0x100,
1730*4882a593Smuzhiyun .version = ID_X1500,
1731*4882a593Smuzhiyun .groups = x1500_groups,
1732*4882a593Smuzhiyun .num_groups = ARRAY_SIZE(x1500_groups),
1733*4882a593Smuzhiyun .functions = x1500_functions,
1734*4882a593Smuzhiyun .num_functions = ARRAY_SIZE(x1500_functions),
1735*4882a593Smuzhiyun .pull_ups = x1000_pull_ups,
1736*4882a593Smuzhiyun .pull_downs = x1000_pull_downs,
1737*4882a593Smuzhiyun };
1738*4882a593Smuzhiyun
1739*4882a593Smuzhiyun static const u32 x1830_pull_ups[4] = {
1740*4882a593Smuzhiyun 0x5fdfffc0, 0xffffefff, 0x1ffffbff, 0x0fcff3fc,
1741*4882a593Smuzhiyun };
1742*4882a593Smuzhiyun
1743*4882a593Smuzhiyun static const u32 x1830_pull_downs[4] = {
1744*4882a593Smuzhiyun 0x5fdfffc0, 0xffffefff, 0x1ffffbff, 0x0fcff3fc,
1745*4882a593Smuzhiyun };
1746*4882a593Smuzhiyun
1747*4882a593Smuzhiyun static int x1830_uart0_data_pins[] = { 0x33, 0x36, };
1748*4882a593Smuzhiyun static int x1830_uart0_hwflow_pins[] = { 0x34, 0x35, };
1749*4882a593Smuzhiyun static int x1830_uart1_data_pins[] = { 0x38, 0x37, };
1750*4882a593Smuzhiyun static int x1830_sfc_pins[] = { 0x17, 0x18, 0x1a, 0x19, 0x1b, 0x1c, };
1751*4882a593Smuzhiyun static int x1830_ssi0_dt_pins[] = { 0x4c, };
1752*4882a593Smuzhiyun static int x1830_ssi0_dr_pins[] = { 0x4b, };
1753*4882a593Smuzhiyun static int x1830_ssi0_clk_pins[] = { 0x4f, };
1754*4882a593Smuzhiyun static int x1830_ssi0_gpc_pins[] = { 0x4d, };
1755*4882a593Smuzhiyun static int x1830_ssi0_ce0_pins[] = { 0x50, };
1756*4882a593Smuzhiyun static int x1830_ssi0_ce1_pins[] = { 0x4e, };
1757*4882a593Smuzhiyun static int x1830_ssi1_dt_c_pins[] = { 0x53, };
1758*4882a593Smuzhiyun static int x1830_ssi1_dr_c_pins[] = { 0x54, };
1759*4882a593Smuzhiyun static int x1830_ssi1_clk_c_pins[] = { 0x57, };
1760*4882a593Smuzhiyun static int x1830_ssi1_gpc_c_pins[] = { 0x55, };
1761*4882a593Smuzhiyun static int x1830_ssi1_ce0_c_pins[] = { 0x58, };
1762*4882a593Smuzhiyun static int x1830_ssi1_ce1_c_pins[] = { 0x56, };
1763*4882a593Smuzhiyun static int x1830_ssi1_dt_d_pins[] = { 0x62, };
1764*4882a593Smuzhiyun static int x1830_ssi1_dr_d_pins[] = { 0x63, };
1765*4882a593Smuzhiyun static int x1830_ssi1_clk_d_pins[] = { 0x66, };
1766*4882a593Smuzhiyun static int x1830_ssi1_gpc_d_pins[] = { 0x64, };
1767*4882a593Smuzhiyun static int x1830_ssi1_ce0_d_pins[] = { 0x67, };
1768*4882a593Smuzhiyun static int x1830_ssi1_ce1_d_pins[] = { 0x65, };
1769*4882a593Smuzhiyun static int x1830_mmc0_1bit_pins[] = { 0x24, 0x25, 0x20, };
1770*4882a593Smuzhiyun static int x1830_mmc0_4bit_pins[] = { 0x21, 0x22, 0x23, };
1771*4882a593Smuzhiyun static int x1830_mmc1_1bit_pins[] = { 0x42, 0x43, 0x44, };
1772*4882a593Smuzhiyun static int x1830_mmc1_4bit_pins[] = { 0x45, 0x46, 0x47, };
1773*4882a593Smuzhiyun static int x1830_i2c0_pins[] = { 0x0c, 0x0d, };
1774*4882a593Smuzhiyun static int x1830_i2c1_pins[] = { 0x39, 0x3a, };
1775*4882a593Smuzhiyun static int x1830_i2c2_pins[] = { 0x5b, 0x5c, };
1776*4882a593Smuzhiyun static int x1830_i2s_data_tx_pins[] = { 0x53, };
1777*4882a593Smuzhiyun static int x1830_i2s_data_rx_pins[] = { 0x54, };
1778*4882a593Smuzhiyun static int x1830_i2s_clk_txrx_pins[] = { 0x58, 0x52, };
1779*4882a593Smuzhiyun static int x1830_i2s_clk_rx_pins[] = { 0x56, 0x55, };
1780*4882a593Smuzhiyun static int x1830_i2s_sysclk_pins[] = { 0x57, };
1781*4882a593Smuzhiyun static int x1830_lcd_rgb_18bit_pins[] = {
1782*4882a593Smuzhiyun 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
1783*4882a593Smuzhiyun 0x68, 0x69, 0x6c, 0x6d, 0x6e, 0x6f,
1784*4882a593Smuzhiyun 0x70, 0x71, 0x72, 0x73, 0x76, 0x77,
1785*4882a593Smuzhiyun 0x78, 0x79, 0x7a, 0x7b,
1786*4882a593Smuzhiyun };
1787*4882a593Smuzhiyun static int x1830_lcd_slcd_8bit_pins[] = {
1788*4882a593Smuzhiyun 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x6c, 0x6d,
1789*4882a593Smuzhiyun 0x69, 0x72, 0x73, 0x7b, 0x7a,
1790*4882a593Smuzhiyun };
1791*4882a593Smuzhiyun static int x1830_lcd_slcd_16bit_pins[] = {
1792*4882a593Smuzhiyun 0x6e, 0x6f, 0x70, 0x71, 0x76, 0x77, 0x78, 0x79,
1793*4882a593Smuzhiyun };
1794*4882a593Smuzhiyun static int x1830_pwm_pwm0_b_pins[] = { 0x31, };
1795*4882a593Smuzhiyun static int x1830_pwm_pwm0_c_pins[] = { 0x4b, };
1796*4882a593Smuzhiyun static int x1830_pwm_pwm1_b_pins[] = { 0x32, };
1797*4882a593Smuzhiyun static int x1830_pwm_pwm1_c_pins[] = { 0x4c, };
1798*4882a593Smuzhiyun static int x1830_pwm_pwm2_c_8_pins[] = { 0x48, };
1799*4882a593Smuzhiyun static int x1830_pwm_pwm2_c_13_pins[] = { 0x4d, };
1800*4882a593Smuzhiyun static int x1830_pwm_pwm3_c_9_pins[] = { 0x49, };
1801*4882a593Smuzhiyun static int x1830_pwm_pwm3_c_14_pins[] = { 0x4e, };
1802*4882a593Smuzhiyun static int x1830_pwm_pwm4_c_15_pins[] = { 0x4f, };
1803*4882a593Smuzhiyun static int x1830_pwm_pwm4_c_25_pins[] = { 0x59, };
1804*4882a593Smuzhiyun static int x1830_pwm_pwm5_c_16_pins[] = { 0x50, };
1805*4882a593Smuzhiyun static int x1830_pwm_pwm5_c_26_pins[] = { 0x5a, };
1806*4882a593Smuzhiyun static int x1830_pwm_pwm6_c_17_pins[] = { 0x51, };
1807*4882a593Smuzhiyun static int x1830_pwm_pwm6_c_27_pins[] = { 0x5b, };
1808*4882a593Smuzhiyun static int x1830_pwm_pwm7_c_18_pins[] = { 0x52, };
1809*4882a593Smuzhiyun static int x1830_pwm_pwm7_c_28_pins[] = { 0x5c, };
1810*4882a593Smuzhiyun static int x1830_mac_pins[] = {
1811*4882a593Smuzhiyun 0x29, 0x30, 0x2f, 0x28, 0x2e, 0x2d, 0x2a, 0x2b, 0x26, 0x27,
1812*4882a593Smuzhiyun };
1813*4882a593Smuzhiyun
1814*4882a593Smuzhiyun static int x1830_uart0_data_funcs[] = { 0, 0, };
1815*4882a593Smuzhiyun static int x1830_uart0_hwflow_funcs[] = { 0, 0, };
1816*4882a593Smuzhiyun static int x1830_uart1_data_funcs[] = { 0, 0, };
1817*4882a593Smuzhiyun static int x1830_sfc_funcs[] = { 1, 1, 1, 1, 1, 1, };
1818*4882a593Smuzhiyun static int x1830_ssi0_dt_funcs[] = { 0, };
1819*4882a593Smuzhiyun static int x1830_ssi0_dr_funcs[] = { 0, };
1820*4882a593Smuzhiyun static int x1830_ssi0_clk_funcs[] = { 0, };
1821*4882a593Smuzhiyun static int x1830_ssi0_gpc_funcs[] = { 0, };
1822*4882a593Smuzhiyun static int x1830_ssi0_ce0_funcs[] = { 0, };
1823*4882a593Smuzhiyun static int x1830_ssi0_ce1_funcs[] = { 0, };
1824*4882a593Smuzhiyun static int x1830_ssi1_dt_c_funcs[] = { 1, };
1825*4882a593Smuzhiyun static int x1830_ssi1_dr_c_funcs[] = { 1, };
1826*4882a593Smuzhiyun static int x1830_ssi1_clk_c_funcs[] = { 1, };
1827*4882a593Smuzhiyun static int x1830_ssi1_gpc_c_funcs[] = { 1, };
1828*4882a593Smuzhiyun static int x1830_ssi1_ce0_c_funcs[] = { 1, };
1829*4882a593Smuzhiyun static int x1830_ssi1_ce1_c_funcs[] = { 1, };
1830*4882a593Smuzhiyun static int x1830_ssi1_dt_d_funcs[] = { 2, };
1831*4882a593Smuzhiyun static int x1830_ssi1_dr_d_funcs[] = { 2, };
1832*4882a593Smuzhiyun static int x1830_ssi1_clk_d_funcs[] = { 2, };
1833*4882a593Smuzhiyun static int x1830_ssi1_gpc_d_funcs[] = { 2, };
1834*4882a593Smuzhiyun static int x1830_ssi1_ce0_d_funcs[] = { 2, };
1835*4882a593Smuzhiyun static int x1830_ssi1_ce1_d_funcs[] = { 2, };
1836*4882a593Smuzhiyun static int x1830_mmc0_1bit_funcs[] = { 0, 0, 0, };
1837*4882a593Smuzhiyun static int x1830_mmc0_4bit_funcs[] = { 0, 0, 0, };
1838*4882a593Smuzhiyun static int x1830_mmc1_1bit_funcs[] = { 0, 0, 0, };
1839*4882a593Smuzhiyun static int x1830_mmc1_4bit_funcs[] = { 0, 0, 0, };
1840*4882a593Smuzhiyun static int x1830_i2c0_funcs[] = { 1, 1, };
1841*4882a593Smuzhiyun static int x1830_i2c1_funcs[] = { 0, 0, };
1842*4882a593Smuzhiyun static int x1830_i2c2_funcs[] = { 1, 1, };
1843*4882a593Smuzhiyun static int x1830_i2s_data_tx_funcs[] = { 0, };
1844*4882a593Smuzhiyun static int x1830_i2s_data_rx_funcs[] = { 0, };
1845*4882a593Smuzhiyun static int x1830_i2s_clk_txrx_funcs[] = { 0, 0, };
1846*4882a593Smuzhiyun static int x1830_i2s_clk_rx_funcs[] = { 0, 0, };
1847*4882a593Smuzhiyun static int x1830_i2s_sysclk_funcs[] = { 0, };
1848*4882a593Smuzhiyun static int x1830_lcd_rgb_18bit_funcs[] = {
1849*4882a593Smuzhiyun 0, 0, 0, 0, 0, 0,
1850*4882a593Smuzhiyun 0, 0, 0, 0, 0, 0,
1851*4882a593Smuzhiyun 0, 0, 0, 0, 0, 0,
1852*4882a593Smuzhiyun 0, 0, 0, 0,
1853*4882a593Smuzhiyun };
1854*4882a593Smuzhiyun static int x1830_lcd_slcd_8bit_funcs[] = {
1855*4882a593Smuzhiyun 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1856*4882a593Smuzhiyun };
1857*4882a593Smuzhiyun static int x1830_lcd_slcd_16bit_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, };
1858*4882a593Smuzhiyun static int x1830_pwm_pwm0_b_funcs[] = { 0, };
1859*4882a593Smuzhiyun static int x1830_pwm_pwm0_c_funcs[] = { 1, };
1860*4882a593Smuzhiyun static int x1830_pwm_pwm1_b_funcs[] = { 0, };
1861*4882a593Smuzhiyun static int x1830_pwm_pwm1_c_funcs[] = { 1, };
1862*4882a593Smuzhiyun static int x1830_pwm_pwm2_c_8_funcs[] = { 0, };
1863*4882a593Smuzhiyun static int x1830_pwm_pwm2_c_13_funcs[] = { 1, };
1864*4882a593Smuzhiyun static int x1830_pwm_pwm3_c_9_funcs[] = { 0, };
1865*4882a593Smuzhiyun static int x1830_pwm_pwm3_c_14_funcs[] = { 1, };
1866*4882a593Smuzhiyun static int x1830_pwm_pwm4_c_15_funcs[] = { 1, };
1867*4882a593Smuzhiyun static int x1830_pwm_pwm4_c_25_funcs[] = { 0, };
1868*4882a593Smuzhiyun static int x1830_pwm_pwm5_c_16_funcs[] = { 1, };
1869*4882a593Smuzhiyun static int x1830_pwm_pwm5_c_26_funcs[] = { 0, };
1870*4882a593Smuzhiyun static int x1830_pwm_pwm6_c_17_funcs[] = { 1, };
1871*4882a593Smuzhiyun static int x1830_pwm_pwm6_c_27_funcs[] = { 0, };
1872*4882a593Smuzhiyun static int x1830_pwm_pwm7_c_18_funcs[] = { 1, };
1873*4882a593Smuzhiyun static int x1830_pwm_pwm7_c_28_funcs[] = { 0, };
1874*4882a593Smuzhiyun static int x1830_mac_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
1875*4882a593Smuzhiyun
1876*4882a593Smuzhiyun static const struct group_desc x1830_groups[] = {
1877*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-data", x1830_uart0_data),
1878*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart0-hwflow", x1830_uart0_hwflow),
1879*4882a593Smuzhiyun INGENIC_PIN_GROUP("uart1-data", x1830_uart1_data),
1880*4882a593Smuzhiyun INGENIC_PIN_GROUP("sfc", x1830_sfc),
1881*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dt", x1830_ssi0_dt),
1882*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-dr", x1830_ssi0_dr),
1883*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-clk", x1830_ssi0_clk),
1884*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-gpc", x1830_ssi0_gpc),
1885*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce0", x1830_ssi0_ce0),
1886*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi0-ce1", x1830_ssi0_ce1),
1887*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dt-c", x1830_ssi1_dt_c),
1888*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dr-c", x1830_ssi1_dr_c),
1889*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-clk-c", x1830_ssi1_clk_c),
1890*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-gpc-c", x1830_ssi1_gpc_c),
1891*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce0-c", x1830_ssi1_ce0_c),
1892*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce1-c", x1830_ssi1_ce1_c),
1893*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dt-d", x1830_ssi1_dt_d),
1894*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-dr-d", x1830_ssi1_dr_d),
1895*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-clk-d", x1830_ssi1_clk_d),
1896*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-gpc-d", x1830_ssi1_gpc_d),
1897*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce0-d", x1830_ssi1_ce0_d),
1898*4882a593Smuzhiyun INGENIC_PIN_GROUP("ssi1-ce1-d", x1830_ssi1_ce1_d),
1899*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-1bit", x1830_mmc0_1bit),
1900*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc0-4bit", x1830_mmc0_4bit),
1901*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-1bit", x1830_mmc1_1bit),
1902*4882a593Smuzhiyun INGENIC_PIN_GROUP("mmc1-4bit", x1830_mmc1_4bit),
1903*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c0-data", x1830_i2c0),
1904*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c1-data", x1830_i2c1),
1905*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2c2-data", x1830_i2c2),
1906*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-data-tx", x1830_i2s_data_tx),
1907*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-data-rx", x1830_i2s_data_rx),
1908*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-clk-txrx", x1830_i2s_clk_txrx),
1909*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-clk-rx", x1830_i2s_clk_rx),
1910*4882a593Smuzhiyun INGENIC_PIN_GROUP("i2s-sysclk", x1830_i2s_sysclk),
1911*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-rgb-18bit", x1830_lcd_rgb_18bit),
1912*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-slcd-8bit", x1830_lcd_slcd_8bit),
1913*4882a593Smuzhiyun INGENIC_PIN_GROUP("lcd-slcd-16bit", x1830_lcd_slcd_16bit),
1914*4882a593Smuzhiyun { "lcd-no-pins", },
1915*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm0-b", x1830_pwm_pwm0_b),
1916*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm0-c", x1830_pwm_pwm0_c),
1917*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm1-b", x1830_pwm_pwm1_b),
1918*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm1-c", x1830_pwm_pwm1_c),
1919*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm2-c-8", x1830_pwm_pwm2_c_8),
1920*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm2-c-13", x1830_pwm_pwm2_c_13),
1921*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm3-c-9", x1830_pwm_pwm3_c_9),
1922*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm3-c-14", x1830_pwm_pwm3_c_14),
1923*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm4-c-15", x1830_pwm_pwm4_c_15),
1924*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm4-c-25", x1830_pwm_pwm4_c_25),
1925*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm5-c-16", x1830_pwm_pwm5_c_16),
1926*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm5-c-26", x1830_pwm_pwm5_c_26),
1927*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm6-c-17", x1830_pwm_pwm6_c_17),
1928*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm6-c-27", x1830_pwm_pwm6_c_27),
1929*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm7-c-18", x1830_pwm_pwm7_c_18),
1930*4882a593Smuzhiyun INGENIC_PIN_GROUP("pwm7-c-28", x1830_pwm_pwm7_c_28),
1931*4882a593Smuzhiyun INGENIC_PIN_GROUP("mac", x1830_mac),
1932*4882a593Smuzhiyun };
1933*4882a593Smuzhiyun
1934*4882a593Smuzhiyun static const char *x1830_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1935*4882a593Smuzhiyun static const char *x1830_uart1_groups[] = { "uart1-data", };
1936*4882a593Smuzhiyun static const char *x1830_sfc_groups[] = { "sfc", };
1937*4882a593Smuzhiyun static const char *x1830_ssi0_groups[] = {
1938*4882a593Smuzhiyun "ssi0-dt", "ssi0-dr", "ssi0-clk", "ssi0-gpc", "ssi0-ce0", "ssi0-ce1",
1939*4882a593Smuzhiyun };
1940*4882a593Smuzhiyun static const char *x1830_ssi1_groups[] = {
1941*4882a593Smuzhiyun "ssi1-dt-c", "ssi1-dt-d",
1942*4882a593Smuzhiyun "ssi1-dr-c", "ssi1-dr-d",
1943*4882a593Smuzhiyun "ssi1-clk-c", "ssi1-clk-d",
1944*4882a593Smuzhiyun "ssi1-gpc-c", "ssi1-gpc-d",
1945*4882a593Smuzhiyun "ssi1-ce0-c", "ssi1-ce0-d",
1946*4882a593Smuzhiyun "ssi1-ce1-c", "ssi1-ce1-d",
1947*4882a593Smuzhiyun };
1948*4882a593Smuzhiyun static const char *x1830_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", };
1949*4882a593Smuzhiyun static const char *x1830_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
1950*4882a593Smuzhiyun static const char *x1830_i2c0_groups[] = { "i2c0-data", };
1951*4882a593Smuzhiyun static const char *x1830_i2c1_groups[] = { "i2c1-data", };
1952*4882a593Smuzhiyun static const char *x1830_i2c2_groups[] = { "i2c2-data", };
1953*4882a593Smuzhiyun static const char *x1830_i2s_groups[] = {
1954*4882a593Smuzhiyun "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-clk-rx", "i2s-sysclk",
1955*4882a593Smuzhiyun };
1956*4882a593Smuzhiyun static const char *x1830_lcd_groups[] = {
1957*4882a593Smuzhiyun "lcd-rgb-18bit", "lcd-slcd-8bit", "lcd-slcd-16bit", "lcd-no-pins",
1958*4882a593Smuzhiyun };
1959*4882a593Smuzhiyun static const char *x1830_pwm0_groups[] = { "pwm0-b", "pwm0-c", };
1960*4882a593Smuzhiyun static const char *x1830_pwm1_groups[] = { "pwm1-b", "pwm1-c", };
1961*4882a593Smuzhiyun static const char *x1830_pwm2_groups[] = { "pwm2-c-8", "pwm2-c-13", };
1962*4882a593Smuzhiyun static const char *x1830_pwm3_groups[] = { "pwm3-c-9", "pwm3-c-14", };
1963*4882a593Smuzhiyun static const char *x1830_pwm4_groups[] = { "pwm4-c-15", "pwm4-c-25", };
1964*4882a593Smuzhiyun static const char *x1830_pwm5_groups[] = { "pwm5-c-16", "pwm5-c-26", };
1965*4882a593Smuzhiyun static const char *x1830_pwm6_groups[] = { "pwm6-c-17", "pwm6-c-27", };
1966*4882a593Smuzhiyun static const char *x1830_pwm7_groups[] = { "pwm7-c-18", "pwm7-c-28", };
1967*4882a593Smuzhiyun static const char *x1830_mac_groups[] = { "mac", };
1968*4882a593Smuzhiyun
1969*4882a593Smuzhiyun static const struct function_desc x1830_functions[] = {
1970*4882a593Smuzhiyun { "uart0", x1830_uart0_groups, ARRAY_SIZE(x1830_uart0_groups), },
1971*4882a593Smuzhiyun { "uart1", x1830_uart1_groups, ARRAY_SIZE(x1830_uart1_groups), },
1972*4882a593Smuzhiyun { "sfc", x1830_sfc_groups, ARRAY_SIZE(x1830_sfc_groups), },
1973*4882a593Smuzhiyun { "ssi0", x1830_ssi0_groups, ARRAY_SIZE(x1830_ssi0_groups), },
1974*4882a593Smuzhiyun { "ssi1", x1830_ssi1_groups, ARRAY_SIZE(x1830_ssi1_groups), },
1975*4882a593Smuzhiyun { "mmc0", x1830_mmc0_groups, ARRAY_SIZE(x1830_mmc0_groups), },
1976*4882a593Smuzhiyun { "mmc1", x1830_mmc1_groups, ARRAY_SIZE(x1830_mmc1_groups), },
1977*4882a593Smuzhiyun { "i2c0", x1830_i2c0_groups, ARRAY_SIZE(x1830_i2c0_groups), },
1978*4882a593Smuzhiyun { "i2c1", x1830_i2c1_groups, ARRAY_SIZE(x1830_i2c1_groups), },
1979*4882a593Smuzhiyun { "i2c2", x1830_i2c2_groups, ARRAY_SIZE(x1830_i2c2_groups), },
1980*4882a593Smuzhiyun { "i2s", x1830_i2s_groups, ARRAY_SIZE(x1830_i2s_groups), },
1981*4882a593Smuzhiyun { "lcd", x1830_lcd_groups, ARRAY_SIZE(x1830_lcd_groups), },
1982*4882a593Smuzhiyun { "pwm0", x1830_pwm0_groups, ARRAY_SIZE(x1830_pwm0_groups), },
1983*4882a593Smuzhiyun { "pwm1", x1830_pwm1_groups, ARRAY_SIZE(x1830_pwm1_groups), },
1984*4882a593Smuzhiyun { "pwm2", x1830_pwm2_groups, ARRAY_SIZE(x1830_pwm2_groups), },
1985*4882a593Smuzhiyun { "pwm3", x1830_pwm3_groups, ARRAY_SIZE(x1830_pwm3_groups), },
1986*4882a593Smuzhiyun { "pwm4", x1830_pwm4_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1987*4882a593Smuzhiyun { "pwm5", x1830_pwm5_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1988*4882a593Smuzhiyun { "pwm6", x1830_pwm6_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1989*4882a593Smuzhiyun { "pwm7", x1830_pwm7_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1990*4882a593Smuzhiyun { "mac", x1830_mac_groups, ARRAY_SIZE(x1830_mac_groups), },
1991*4882a593Smuzhiyun };
1992*4882a593Smuzhiyun
1993*4882a593Smuzhiyun static const struct ingenic_chip_info x1830_chip_info = {
1994*4882a593Smuzhiyun .num_chips = 4,
1995*4882a593Smuzhiyun .reg_offset = 0x1000,
1996*4882a593Smuzhiyun .version = ID_X1830,
1997*4882a593Smuzhiyun .groups = x1830_groups,
1998*4882a593Smuzhiyun .num_groups = ARRAY_SIZE(x1830_groups),
1999*4882a593Smuzhiyun .functions = x1830_functions,
2000*4882a593Smuzhiyun .num_functions = ARRAY_SIZE(x1830_functions),
2001*4882a593Smuzhiyun .pull_ups = x1830_pull_ups,
2002*4882a593Smuzhiyun .pull_downs = x1830_pull_downs,
2003*4882a593Smuzhiyun };
2004*4882a593Smuzhiyun
ingenic_gpio_read_reg(struct ingenic_gpio_chip * jzgc,u8 reg)2005*4882a593Smuzhiyun static u32 ingenic_gpio_read_reg(struct ingenic_gpio_chip *jzgc, u8 reg)
2006*4882a593Smuzhiyun {
2007*4882a593Smuzhiyun unsigned int val;
2008*4882a593Smuzhiyun
2009*4882a593Smuzhiyun regmap_read(jzgc->jzpc->map, jzgc->reg_base + reg, &val);
2010*4882a593Smuzhiyun
2011*4882a593Smuzhiyun return (u32) val;
2012*4882a593Smuzhiyun }
2013*4882a593Smuzhiyun
ingenic_gpio_set_bit(struct ingenic_gpio_chip * jzgc,u8 reg,u8 offset,bool set)2014*4882a593Smuzhiyun static void ingenic_gpio_set_bit(struct ingenic_gpio_chip *jzgc,
2015*4882a593Smuzhiyun u8 reg, u8 offset, bool set)
2016*4882a593Smuzhiyun {
2017*4882a593Smuzhiyun if (set)
2018*4882a593Smuzhiyun reg = REG_SET(reg);
2019*4882a593Smuzhiyun else
2020*4882a593Smuzhiyun reg = REG_CLEAR(reg);
2021*4882a593Smuzhiyun
2022*4882a593Smuzhiyun regmap_write(jzgc->jzpc->map, jzgc->reg_base + reg, BIT(offset));
2023*4882a593Smuzhiyun }
2024*4882a593Smuzhiyun
ingenic_gpio_shadow_set_bit(struct ingenic_gpio_chip * jzgc,u8 reg,u8 offset,bool set)2025*4882a593Smuzhiyun static void ingenic_gpio_shadow_set_bit(struct ingenic_gpio_chip *jzgc,
2026*4882a593Smuzhiyun u8 reg, u8 offset, bool set)
2027*4882a593Smuzhiyun {
2028*4882a593Smuzhiyun if (set)
2029*4882a593Smuzhiyun reg = REG_SET(reg);
2030*4882a593Smuzhiyun else
2031*4882a593Smuzhiyun reg = REG_CLEAR(reg);
2032*4882a593Smuzhiyun
2033*4882a593Smuzhiyun regmap_write(jzgc->jzpc->map, REG_PZ_BASE(
2034*4882a593Smuzhiyun jzgc->jzpc->info->reg_offset) + reg, BIT(offset));
2035*4882a593Smuzhiyun }
2036*4882a593Smuzhiyun
ingenic_gpio_shadow_set_bit_load(struct ingenic_gpio_chip * jzgc)2037*4882a593Smuzhiyun static void ingenic_gpio_shadow_set_bit_load(struct ingenic_gpio_chip *jzgc)
2038*4882a593Smuzhiyun {
2039*4882a593Smuzhiyun regmap_write(jzgc->jzpc->map, REG_PZ_GID2LD(
2040*4882a593Smuzhiyun jzgc->jzpc->info->reg_offset),
2041*4882a593Smuzhiyun jzgc->gc.base / PINS_PER_GPIO_CHIP);
2042*4882a593Smuzhiyun }
2043*4882a593Smuzhiyun
ingenic_gpio_get_value(struct ingenic_gpio_chip * jzgc,u8 offset)2044*4882a593Smuzhiyun static inline bool ingenic_gpio_get_value(struct ingenic_gpio_chip *jzgc,
2045*4882a593Smuzhiyun u8 offset)
2046*4882a593Smuzhiyun {
2047*4882a593Smuzhiyun unsigned int val = ingenic_gpio_read_reg(jzgc, GPIO_PIN);
2048*4882a593Smuzhiyun
2049*4882a593Smuzhiyun return !!(val & BIT(offset));
2050*4882a593Smuzhiyun }
2051*4882a593Smuzhiyun
ingenic_gpio_set_value(struct ingenic_gpio_chip * jzgc,u8 offset,int value)2052*4882a593Smuzhiyun static void ingenic_gpio_set_value(struct ingenic_gpio_chip *jzgc,
2053*4882a593Smuzhiyun u8 offset, int value)
2054*4882a593Smuzhiyun {
2055*4882a593Smuzhiyun if (jzgc->jzpc->info->version >= ID_JZ4770)
2056*4882a593Smuzhiyun ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_PAT0, offset, !!value);
2057*4882a593Smuzhiyun else
2058*4882a593Smuzhiyun ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, offset, !!value);
2059*4882a593Smuzhiyun }
2060*4882a593Smuzhiyun
irq_set_type(struct ingenic_gpio_chip * jzgc,u8 offset,unsigned int type)2061*4882a593Smuzhiyun static void irq_set_type(struct ingenic_gpio_chip *jzgc,
2062*4882a593Smuzhiyun u8 offset, unsigned int type)
2063*4882a593Smuzhiyun {
2064*4882a593Smuzhiyun u8 reg1, reg2;
2065*4882a593Smuzhiyun bool val1, val2;
2066*4882a593Smuzhiyun
2067*4882a593Smuzhiyun switch (type) {
2068*4882a593Smuzhiyun case IRQ_TYPE_EDGE_RISING:
2069*4882a593Smuzhiyun val1 = val2 = true;
2070*4882a593Smuzhiyun break;
2071*4882a593Smuzhiyun case IRQ_TYPE_EDGE_FALLING:
2072*4882a593Smuzhiyun val1 = false;
2073*4882a593Smuzhiyun val2 = true;
2074*4882a593Smuzhiyun break;
2075*4882a593Smuzhiyun case IRQ_TYPE_LEVEL_HIGH:
2076*4882a593Smuzhiyun val1 = true;
2077*4882a593Smuzhiyun val2 = false;
2078*4882a593Smuzhiyun break;
2079*4882a593Smuzhiyun case IRQ_TYPE_LEVEL_LOW:
2080*4882a593Smuzhiyun default:
2081*4882a593Smuzhiyun val1 = val2 = false;
2082*4882a593Smuzhiyun break;
2083*4882a593Smuzhiyun }
2084*4882a593Smuzhiyun
2085*4882a593Smuzhiyun if (jzgc->jzpc->info->version >= ID_JZ4770) {
2086*4882a593Smuzhiyun reg1 = JZ4760_GPIO_PAT1;
2087*4882a593Smuzhiyun reg2 = JZ4760_GPIO_PAT0;
2088*4882a593Smuzhiyun } else {
2089*4882a593Smuzhiyun reg1 = JZ4740_GPIO_TRIG;
2090*4882a593Smuzhiyun reg2 = JZ4740_GPIO_DIR;
2091*4882a593Smuzhiyun }
2092*4882a593Smuzhiyun
2093*4882a593Smuzhiyun if (jzgc->jzpc->info->version >= ID_X1000) {
2094*4882a593Smuzhiyun ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, val1);
2095*4882a593Smuzhiyun ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, val2);
2096*4882a593Smuzhiyun ingenic_gpio_shadow_set_bit_load(jzgc);
2097*4882a593Smuzhiyun } else {
2098*4882a593Smuzhiyun ingenic_gpio_set_bit(jzgc, reg2, offset, val1);
2099*4882a593Smuzhiyun ingenic_gpio_set_bit(jzgc, reg1, offset, val2);
2100*4882a593Smuzhiyun }
2101*4882a593Smuzhiyun }
2102*4882a593Smuzhiyun
ingenic_gpio_irq_mask(struct irq_data * irqd)2103*4882a593Smuzhiyun static void ingenic_gpio_irq_mask(struct irq_data *irqd)
2104*4882a593Smuzhiyun {
2105*4882a593Smuzhiyun struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2106*4882a593Smuzhiyun struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2107*4882a593Smuzhiyun
2108*4882a593Smuzhiyun ingenic_gpio_set_bit(jzgc, GPIO_MSK, irqd->hwirq, true);
2109*4882a593Smuzhiyun }
2110*4882a593Smuzhiyun
ingenic_gpio_irq_unmask(struct irq_data * irqd)2111*4882a593Smuzhiyun static void ingenic_gpio_irq_unmask(struct irq_data *irqd)
2112*4882a593Smuzhiyun {
2113*4882a593Smuzhiyun struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2114*4882a593Smuzhiyun struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2115*4882a593Smuzhiyun
2116*4882a593Smuzhiyun ingenic_gpio_set_bit(jzgc, GPIO_MSK, irqd->hwirq, false);
2117*4882a593Smuzhiyun }
2118*4882a593Smuzhiyun
ingenic_gpio_irq_enable(struct irq_data * irqd)2119*4882a593Smuzhiyun static void ingenic_gpio_irq_enable(struct irq_data *irqd)
2120*4882a593Smuzhiyun {
2121*4882a593Smuzhiyun struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2122*4882a593Smuzhiyun struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2123*4882a593Smuzhiyun int irq = irqd->hwirq;
2124*4882a593Smuzhiyun
2125*4882a593Smuzhiyun if (jzgc->jzpc->info->version >= ID_JZ4770)
2126*4882a593Smuzhiyun ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_INT, irq, true);
2127*4882a593Smuzhiyun else
2128*4882a593Smuzhiyun ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, true);
2129*4882a593Smuzhiyun
2130*4882a593Smuzhiyun ingenic_gpio_irq_unmask(irqd);
2131*4882a593Smuzhiyun }
2132*4882a593Smuzhiyun
ingenic_gpio_irq_disable(struct irq_data * irqd)2133*4882a593Smuzhiyun static void ingenic_gpio_irq_disable(struct irq_data *irqd)
2134*4882a593Smuzhiyun {
2135*4882a593Smuzhiyun struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2136*4882a593Smuzhiyun struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2137*4882a593Smuzhiyun int irq = irqd->hwirq;
2138*4882a593Smuzhiyun
2139*4882a593Smuzhiyun ingenic_gpio_irq_mask(irqd);
2140*4882a593Smuzhiyun
2141*4882a593Smuzhiyun if (jzgc->jzpc->info->version >= ID_JZ4770)
2142*4882a593Smuzhiyun ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_INT, irq, false);
2143*4882a593Smuzhiyun else
2144*4882a593Smuzhiyun ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, false);
2145*4882a593Smuzhiyun }
2146*4882a593Smuzhiyun
ingenic_gpio_irq_ack(struct irq_data * irqd)2147*4882a593Smuzhiyun static void ingenic_gpio_irq_ack(struct irq_data *irqd)
2148*4882a593Smuzhiyun {
2149*4882a593Smuzhiyun struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2150*4882a593Smuzhiyun struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2151*4882a593Smuzhiyun int irq = irqd->hwirq;
2152*4882a593Smuzhiyun bool high;
2153*4882a593Smuzhiyun
2154*4882a593Smuzhiyun if (irqd_get_trigger_type(irqd) == IRQ_TYPE_EDGE_BOTH) {
2155*4882a593Smuzhiyun /*
2156*4882a593Smuzhiyun * Switch to an interrupt for the opposite edge to the one that
2157*4882a593Smuzhiyun * triggered the interrupt being ACKed.
2158*4882a593Smuzhiyun */
2159*4882a593Smuzhiyun high = ingenic_gpio_get_value(jzgc, irq);
2160*4882a593Smuzhiyun if (high)
2161*4882a593Smuzhiyun irq_set_type(jzgc, irq, IRQ_TYPE_LEVEL_LOW);
2162*4882a593Smuzhiyun else
2163*4882a593Smuzhiyun irq_set_type(jzgc, irq, IRQ_TYPE_LEVEL_HIGH);
2164*4882a593Smuzhiyun }
2165*4882a593Smuzhiyun
2166*4882a593Smuzhiyun if (jzgc->jzpc->info->version >= ID_JZ4770)
2167*4882a593Smuzhiyun ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_FLAG, irq, false);
2168*4882a593Smuzhiyun else
2169*4882a593Smuzhiyun ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, irq, true);
2170*4882a593Smuzhiyun }
2171*4882a593Smuzhiyun
ingenic_gpio_irq_set_type(struct irq_data * irqd,unsigned int type)2172*4882a593Smuzhiyun static int ingenic_gpio_irq_set_type(struct irq_data *irqd, unsigned int type)
2173*4882a593Smuzhiyun {
2174*4882a593Smuzhiyun struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2175*4882a593Smuzhiyun struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2176*4882a593Smuzhiyun
2177*4882a593Smuzhiyun switch (type) {
2178*4882a593Smuzhiyun case IRQ_TYPE_EDGE_BOTH:
2179*4882a593Smuzhiyun case IRQ_TYPE_EDGE_RISING:
2180*4882a593Smuzhiyun case IRQ_TYPE_EDGE_FALLING:
2181*4882a593Smuzhiyun irq_set_handler_locked(irqd, handle_edge_irq);
2182*4882a593Smuzhiyun break;
2183*4882a593Smuzhiyun case IRQ_TYPE_LEVEL_HIGH:
2184*4882a593Smuzhiyun case IRQ_TYPE_LEVEL_LOW:
2185*4882a593Smuzhiyun irq_set_handler_locked(irqd, handle_level_irq);
2186*4882a593Smuzhiyun break;
2187*4882a593Smuzhiyun default:
2188*4882a593Smuzhiyun irq_set_handler_locked(irqd, handle_bad_irq);
2189*4882a593Smuzhiyun }
2190*4882a593Smuzhiyun
2191*4882a593Smuzhiyun if (type == IRQ_TYPE_EDGE_BOTH) {
2192*4882a593Smuzhiyun /*
2193*4882a593Smuzhiyun * The hardware does not support interrupts on both edges. The
2194*4882a593Smuzhiyun * best we can do is to set up a single-edge interrupt and then
2195*4882a593Smuzhiyun * switch to the opposing edge when ACKing the interrupt.
2196*4882a593Smuzhiyun */
2197*4882a593Smuzhiyun bool high = ingenic_gpio_get_value(jzgc, irqd->hwirq);
2198*4882a593Smuzhiyun
2199*4882a593Smuzhiyun type = high ? IRQ_TYPE_LEVEL_LOW : IRQ_TYPE_LEVEL_HIGH;
2200*4882a593Smuzhiyun }
2201*4882a593Smuzhiyun
2202*4882a593Smuzhiyun irq_set_type(jzgc, irqd->hwirq, type);
2203*4882a593Smuzhiyun return 0;
2204*4882a593Smuzhiyun }
2205*4882a593Smuzhiyun
ingenic_gpio_irq_set_wake(struct irq_data * irqd,unsigned int on)2206*4882a593Smuzhiyun static int ingenic_gpio_irq_set_wake(struct irq_data *irqd, unsigned int on)
2207*4882a593Smuzhiyun {
2208*4882a593Smuzhiyun struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2209*4882a593Smuzhiyun struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2210*4882a593Smuzhiyun
2211*4882a593Smuzhiyun return irq_set_irq_wake(jzgc->irq, on);
2212*4882a593Smuzhiyun }
2213*4882a593Smuzhiyun
ingenic_gpio_irq_handler(struct irq_desc * desc)2214*4882a593Smuzhiyun static void ingenic_gpio_irq_handler(struct irq_desc *desc)
2215*4882a593Smuzhiyun {
2216*4882a593Smuzhiyun struct gpio_chip *gc = irq_desc_get_handler_data(desc);
2217*4882a593Smuzhiyun struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2218*4882a593Smuzhiyun struct irq_chip *irq_chip = irq_data_get_irq_chip(&desc->irq_data);
2219*4882a593Smuzhiyun unsigned long flag, i;
2220*4882a593Smuzhiyun
2221*4882a593Smuzhiyun chained_irq_enter(irq_chip, desc);
2222*4882a593Smuzhiyun
2223*4882a593Smuzhiyun if (jzgc->jzpc->info->version >= ID_JZ4770)
2224*4882a593Smuzhiyun flag = ingenic_gpio_read_reg(jzgc, JZ4760_GPIO_FLAG);
2225*4882a593Smuzhiyun else
2226*4882a593Smuzhiyun flag = ingenic_gpio_read_reg(jzgc, JZ4740_GPIO_FLAG);
2227*4882a593Smuzhiyun
2228*4882a593Smuzhiyun for_each_set_bit(i, &flag, 32)
2229*4882a593Smuzhiyun generic_handle_irq(irq_linear_revmap(gc->irq.domain, i));
2230*4882a593Smuzhiyun chained_irq_exit(irq_chip, desc);
2231*4882a593Smuzhiyun }
2232*4882a593Smuzhiyun
ingenic_gpio_set(struct gpio_chip * gc,unsigned int offset,int value)2233*4882a593Smuzhiyun static void ingenic_gpio_set(struct gpio_chip *gc,
2234*4882a593Smuzhiyun unsigned int offset, int value)
2235*4882a593Smuzhiyun {
2236*4882a593Smuzhiyun struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2237*4882a593Smuzhiyun
2238*4882a593Smuzhiyun ingenic_gpio_set_value(jzgc, offset, value);
2239*4882a593Smuzhiyun }
2240*4882a593Smuzhiyun
ingenic_gpio_get(struct gpio_chip * gc,unsigned int offset)2241*4882a593Smuzhiyun static int ingenic_gpio_get(struct gpio_chip *gc, unsigned int offset)
2242*4882a593Smuzhiyun {
2243*4882a593Smuzhiyun struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2244*4882a593Smuzhiyun
2245*4882a593Smuzhiyun return (int) ingenic_gpio_get_value(jzgc, offset);
2246*4882a593Smuzhiyun }
2247*4882a593Smuzhiyun
ingenic_gpio_direction_input(struct gpio_chip * gc,unsigned int offset)2248*4882a593Smuzhiyun static int ingenic_gpio_direction_input(struct gpio_chip *gc,
2249*4882a593Smuzhiyun unsigned int offset)
2250*4882a593Smuzhiyun {
2251*4882a593Smuzhiyun return pinctrl_gpio_direction_input(gc->base + offset);
2252*4882a593Smuzhiyun }
2253*4882a593Smuzhiyun
ingenic_gpio_direction_output(struct gpio_chip * gc,unsigned int offset,int value)2254*4882a593Smuzhiyun static int ingenic_gpio_direction_output(struct gpio_chip *gc,
2255*4882a593Smuzhiyun unsigned int offset, int value)
2256*4882a593Smuzhiyun {
2257*4882a593Smuzhiyun ingenic_gpio_set(gc, offset, value);
2258*4882a593Smuzhiyun return pinctrl_gpio_direction_output(gc->base + offset);
2259*4882a593Smuzhiyun }
2260*4882a593Smuzhiyun
ingenic_config_pin(struct ingenic_pinctrl * jzpc,unsigned int pin,u8 reg,bool set)2261*4882a593Smuzhiyun static inline void ingenic_config_pin(struct ingenic_pinctrl *jzpc,
2262*4882a593Smuzhiyun unsigned int pin, u8 reg, bool set)
2263*4882a593Smuzhiyun {
2264*4882a593Smuzhiyun unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2265*4882a593Smuzhiyun unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2266*4882a593Smuzhiyun
2267*4882a593Smuzhiyun regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2268*4882a593Smuzhiyun (set ? REG_SET(reg) : REG_CLEAR(reg)), BIT(idx));
2269*4882a593Smuzhiyun }
2270*4882a593Smuzhiyun
ingenic_shadow_config_pin(struct ingenic_pinctrl * jzpc,unsigned int pin,u8 reg,bool set)2271*4882a593Smuzhiyun static inline void ingenic_shadow_config_pin(struct ingenic_pinctrl *jzpc,
2272*4882a593Smuzhiyun unsigned int pin, u8 reg, bool set)
2273*4882a593Smuzhiyun {
2274*4882a593Smuzhiyun unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2275*4882a593Smuzhiyun
2276*4882a593Smuzhiyun regmap_write(jzpc->map, REG_PZ_BASE(jzpc->info->reg_offset) +
2277*4882a593Smuzhiyun (set ? REG_SET(reg) : REG_CLEAR(reg)), BIT(idx));
2278*4882a593Smuzhiyun }
2279*4882a593Smuzhiyun
ingenic_shadow_config_pin_load(struct ingenic_pinctrl * jzpc,unsigned int pin)2280*4882a593Smuzhiyun static inline void ingenic_shadow_config_pin_load(struct ingenic_pinctrl *jzpc,
2281*4882a593Smuzhiyun unsigned int pin)
2282*4882a593Smuzhiyun {
2283*4882a593Smuzhiyun regmap_write(jzpc->map, REG_PZ_GID2LD(jzpc->info->reg_offset),
2284*4882a593Smuzhiyun pin / PINS_PER_GPIO_CHIP);
2285*4882a593Smuzhiyun }
2286*4882a593Smuzhiyun
ingenic_get_pin_config(struct ingenic_pinctrl * jzpc,unsigned int pin,u8 reg)2287*4882a593Smuzhiyun static inline bool ingenic_get_pin_config(struct ingenic_pinctrl *jzpc,
2288*4882a593Smuzhiyun unsigned int pin, u8 reg)
2289*4882a593Smuzhiyun {
2290*4882a593Smuzhiyun unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2291*4882a593Smuzhiyun unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2292*4882a593Smuzhiyun unsigned int val;
2293*4882a593Smuzhiyun
2294*4882a593Smuzhiyun regmap_read(jzpc->map, offt * jzpc->info->reg_offset + reg, &val);
2295*4882a593Smuzhiyun
2296*4882a593Smuzhiyun return val & BIT(idx);
2297*4882a593Smuzhiyun }
2298*4882a593Smuzhiyun
ingenic_gpio_get_direction(struct gpio_chip * gc,unsigned int offset)2299*4882a593Smuzhiyun static int ingenic_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
2300*4882a593Smuzhiyun {
2301*4882a593Smuzhiyun struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2302*4882a593Smuzhiyun struct ingenic_pinctrl *jzpc = jzgc->jzpc;
2303*4882a593Smuzhiyun unsigned int pin = gc->base + offset;
2304*4882a593Smuzhiyun
2305*4882a593Smuzhiyun if (jzpc->info->version >= ID_JZ4770) {
2306*4882a593Smuzhiyun if (ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_INT) ||
2307*4882a593Smuzhiyun ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_PAT1))
2308*4882a593Smuzhiyun return GPIO_LINE_DIRECTION_IN;
2309*4882a593Smuzhiyun return GPIO_LINE_DIRECTION_OUT;
2310*4882a593Smuzhiyun }
2311*4882a593Smuzhiyun
2312*4882a593Smuzhiyun if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_SELECT))
2313*4882a593Smuzhiyun return GPIO_LINE_DIRECTION_IN;
2314*4882a593Smuzhiyun
2315*4882a593Smuzhiyun if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_DIR))
2316*4882a593Smuzhiyun return GPIO_LINE_DIRECTION_OUT;
2317*4882a593Smuzhiyun
2318*4882a593Smuzhiyun return GPIO_LINE_DIRECTION_IN;
2319*4882a593Smuzhiyun }
2320*4882a593Smuzhiyun
2321*4882a593Smuzhiyun static const struct pinctrl_ops ingenic_pctlops = {
2322*4882a593Smuzhiyun .get_groups_count = pinctrl_generic_get_group_count,
2323*4882a593Smuzhiyun .get_group_name = pinctrl_generic_get_group_name,
2324*4882a593Smuzhiyun .get_group_pins = pinctrl_generic_get_group_pins,
2325*4882a593Smuzhiyun .dt_node_to_map = pinconf_generic_dt_node_to_map_all,
2326*4882a593Smuzhiyun .dt_free_map = pinconf_generic_dt_free_map,
2327*4882a593Smuzhiyun };
2328*4882a593Smuzhiyun
ingenic_gpio_irq_request(struct irq_data * data)2329*4882a593Smuzhiyun static int ingenic_gpio_irq_request(struct irq_data *data)
2330*4882a593Smuzhiyun {
2331*4882a593Smuzhiyun struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
2332*4882a593Smuzhiyun int ret;
2333*4882a593Smuzhiyun
2334*4882a593Smuzhiyun ret = ingenic_gpio_direction_input(gpio_chip, data->hwirq);
2335*4882a593Smuzhiyun if (ret)
2336*4882a593Smuzhiyun return ret;
2337*4882a593Smuzhiyun
2338*4882a593Smuzhiyun return gpiochip_reqres_irq(gpio_chip, data->hwirq);
2339*4882a593Smuzhiyun }
2340*4882a593Smuzhiyun
ingenic_gpio_irq_release(struct irq_data * data)2341*4882a593Smuzhiyun static void ingenic_gpio_irq_release(struct irq_data *data)
2342*4882a593Smuzhiyun {
2343*4882a593Smuzhiyun struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
2344*4882a593Smuzhiyun
2345*4882a593Smuzhiyun return gpiochip_relres_irq(gpio_chip, data->hwirq);
2346*4882a593Smuzhiyun }
2347*4882a593Smuzhiyun
ingenic_pinmux_set_pin_fn(struct ingenic_pinctrl * jzpc,int pin,int func)2348*4882a593Smuzhiyun static int ingenic_pinmux_set_pin_fn(struct ingenic_pinctrl *jzpc,
2349*4882a593Smuzhiyun int pin, int func)
2350*4882a593Smuzhiyun {
2351*4882a593Smuzhiyun unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2352*4882a593Smuzhiyun unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2353*4882a593Smuzhiyun
2354*4882a593Smuzhiyun dev_dbg(jzpc->dev, "set pin P%c%u to function %u\n",
2355*4882a593Smuzhiyun 'A' + offt, idx, func);
2356*4882a593Smuzhiyun
2357*4882a593Smuzhiyun if (jzpc->info->version >= ID_X1000) {
2358*4882a593Smuzhiyun ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
2359*4882a593Smuzhiyun ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, false);
2360*4882a593Smuzhiyun ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, func & 0x2);
2361*4882a593Smuzhiyun ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, func & 0x1);
2362*4882a593Smuzhiyun ingenic_shadow_config_pin_load(jzpc, pin);
2363*4882a593Smuzhiyun } else if (jzpc->info->version >= ID_JZ4770) {
2364*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
2365*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, GPIO_MSK, false);
2366*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, func & 0x2);
2367*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, func & 0x1);
2368*4882a593Smuzhiyun } else {
2369*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, true);
2370*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4740_GPIO_TRIG, func & 0x2);
2371*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, func & 0x1);
2372*4882a593Smuzhiyun }
2373*4882a593Smuzhiyun
2374*4882a593Smuzhiyun return 0;
2375*4882a593Smuzhiyun }
2376*4882a593Smuzhiyun
ingenic_pinmux_set_mux(struct pinctrl_dev * pctldev,unsigned int selector,unsigned int group)2377*4882a593Smuzhiyun static int ingenic_pinmux_set_mux(struct pinctrl_dev *pctldev,
2378*4882a593Smuzhiyun unsigned int selector, unsigned int group)
2379*4882a593Smuzhiyun {
2380*4882a593Smuzhiyun struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2381*4882a593Smuzhiyun struct function_desc *func;
2382*4882a593Smuzhiyun struct group_desc *grp;
2383*4882a593Smuzhiyun unsigned int i;
2384*4882a593Smuzhiyun
2385*4882a593Smuzhiyun func = pinmux_generic_get_function(pctldev, selector);
2386*4882a593Smuzhiyun if (!func)
2387*4882a593Smuzhiyun return -EINVAL;
2388*4882a593Smuzhiyun
2389*4882a593Smuzhiyun grp = pinctrl_generic_get_group(pctldev, group);
2390*4882a593Smuzhiyun if (!grp)
2391*4882a593Smuzhiyun return -EINVAL;
2392*4882a593Smuzhiyun
2393*4882a593Smuzhiyun dev_dbg(pctldev->dev, "enable function %s group %s\n",
2394*4882a593Smuzhiyun func->name, grp->name);
2395*4882a593Smuzhiyun
2396*4882a593Smuzhiyun for (i = 0; i < grp->num_pins; i++) {
2397*4882a593Smuzhiyun int *pin_modes = grp->data;
2398*4882a593Smuzhiyun
2399*4882a593Smuzhiyun ingenic_pinmux_set_pin_fn(jzpc, grp->pins[i], pin_modes[i]);
2400*4882a593Smuzhiyun }
2401*4882a593Smuzhiyun
2402*4882a593Smuzhiyun return 0;
2403*4882a593Smuzhiyun }
2404*4882a593Smuzhiyun
ingenic_pinmux_gpio_set_direction(struct pinctrl_dev * pctldev,struct pinctrl_gpio_range * range,unsigned int pin,bool input)2405*4882a593Smuzhiyun static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
2406*4882a593Smuzhiyun struct pinctrl_gpio_range *range,
2407*4882a593Smuzhiyun unsigned int pin, bool input)
2408*4882a593Smuzhiyun {
2409*4882a593Smuzhiyun struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2410*4882a593Smuzhiyun unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2411*4882a593Smuzhiyun unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2412*4882a593Smuzhiyun
2413*4882a593Smuzhiyun dev_dbg(pctldev->dev, "set pin P%c%u to %sput\n",
2414*4882a593Smuzhiyun 'A' + offt, idx, input ? "in" : "out");
2415*4882a593Smuzhiyun
2416*4882a593Smuzhiyun if (jzpc->info->version >= ID_X1000) {
2417*4882a593Smuzhiyun ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
2418*4882a593Smuzhiyun ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, true);
2419*4882a593Smuzhiyun ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, input);
2420*4882a593Smuzhiyun ingenic_shadow_config_pin_load(jzpc, pin);
2421*4882a593Smuzhiyun } else if (jzpc->info->version >= ID_JZ4770) {
2422*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
2423*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, GPIO_MSK, true);
2424*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, input);
2425*4882a593Smuzhiyun } else {
2426*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, false);
2427*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, !input);
2428*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, false);
2429*4882a593Smuzhiyun }
2430*4882a593Smuzhiyun
2431*4882a593Smuzhiyun return 0;
2432*4882a593Smuzhiyun }
2433*4882a593Smuzhiyun
2434*4882a593Smuzhiyun static const struct pinmux_ops ingenic_pmxops = {
2435*4882a593Smuzhiyun .get_functions_count = pinmux_generic_get_function_count,
2436*4882a593Smuzhiyun .get_function_name = pinmux_generic_get_function_name,
2437*4882a593Smuzhiyun .get_function_groups = pinmux_generic_get_function_groups,
2438*4882a593Smuzhiyun .set_mux = ingenic_pinmux_set_mux,
2439*4882a593Smuzhiyun .gpio_set_direction = ingenic_pinmux_gpio_set_direction,
2440*4882a593Smuzhiyun };
2441*4882a593Smuzhiyun
ingenic_pinconf_get(struct pinctrl_dev * pctldev,unsigned int pin,unsigned long * config)2442*4882a593Smuzhiyun static int ingenic_pinconf_get(struct pinctrl_dev *pctldev,
2443*4882a593Smuzhiyun unsigned int pin, unsigned long *config)
2444*4882a593Smuzhiyun {
2445*4882a593Smuzhiyun struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2446*4882a593Smuzhiyun enum pin_config_param param = pinconf_to_config_param(*config);
2447*4882a593Smuzhiyun unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2448*4882a593Smuzhiyun unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2449*4882a593Smuzhiyun bool pull;
2450*4882a593Smuzhiyun
2451*4882a593Smuzhiyun if (jzpc->info->version >= ID_JZ4770)
2452*4882a593Smuzhiyun pull = !ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_PEN);
2453*4882a593Smuzhiyun else
2454*4882a593Smuzhiyun pull = !ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_PULL_DIS);
2455*4882a593Smuzhiyun
2456*4882a593Smuzhiyun switch (param) {
2457*4882a593Smuzhiyun case PIN_CONFIG_BIAS_DISABLE:
2458*4882a593Smuzhiyun if (pull)
2459*4882a593Smuzhiyun return -EINVAL;
2460*4882a593Smuzhiyun break;
2461*4882a593Smuzhiyun
2462*4882a593Smuzhiyun case PIN_CONFIG_BIAS_PULL_UP:
2463*4882a593Smuzhiyun if (!pull || !(jzpc->info->pull_ups[offt] & BIT(idx)))
2464*4882a593Smuzhiyun return -EINVAL;
2465*4882a593Smuzhiyun break;
2466*4882a593Smuzhiyun
2467*4882a593Smuzhiyun case PIN_CONFIG_BIAS_PULL_DOWN:
2468*4882a593Smuzhiyun if (!pull || !(jzpc->info->pull_downs[offt] & BIT(idx)))
2469*4882a593Smuzhiyun return -EINVAL;
2470*4882a593Smuzhiyun break;
2471*4882a593Smuzhiyun
2472*4882a593Smuzhiyun default:
2473*4882a593Smuzhiyun return -ENOTSUPP;
2474*4882a593Smuzhiyun }
2475*4882a593Smuzhiyun
2476*4882a593Smuzhiyun *config = pinconf_to_config_packed(param, 1);
2477*4882a593Smuzhiyun return 0;
2478*4882a593Smuzhiyun }
2479*4882a593Smuzhiyun
ingenic_set_bias(struct ingenic_pinctrl * jzpc,unsigned int pin,unsigned int bias)2480*4882a593Smuzhiyun static void ingenic_set_bias(struct ingenic_pinctrl *jzpc,
2481*4882a593Smuzhiyun unsigned int pin, unsigned int bias)
2482*4882a593Smuzhiyun {
2483*4882a593Smuzhiyun if (jzpc->info->version >= ID_X1830) {
2484*4882a593Smuzhiyun unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2485*4882a593Smuzhiyun unsigned int half = PINS_PER_GPIO_CHIP / 2;
2486*4882a593Smuzhiyun unsigned int idxh = pin % half * 2;
2487*4882a593Smuzhiyun unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2488*4882a593Smuzhiyun
2489*4882a593Smuzhiyun if (idx < half) {
2490*4882a593Smuzhiyun regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2491*4882a593Smuzhiyun REG_CLEAR(X1830_GPIO_PEL), 3 << idxh);
2492*4882a593Smuzhiyun regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2493*4882a593Smuzhiyun REG_SET(X1830_GPIO_PEL), bias << idxh);
2494*4882a593Smuzhiyun } else {
2495*4882a593Smuzhiyun regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2496*4882a593Smuzhiyun REG_CLEAR(X1830_GPIO_PEH), 3 << idxh);
2497*4882a593Smuzhiyun regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2498*4882a593Smuzhiyun REG_SET(X1830_GPIO_PEH), bias << idxh);
2499*4882a593Smuzhiyun }
2500*4882a593Smuzhiyun
2501*4882a593Smuzhiyun } else if (jzpc->info->version >= ID_JZ4770) {
2502*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PEN, !bias);
2503*4882a593Smuzhiyun } else {
2504*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4740_GPIO_PULL_DIS, !bias);
2505*4882a593Smuzhiyun }
2506*4882a593Smuzhiyun }
2507*4882a593Smuzhiyun
ingenic_set_output_level(struct ingenic_pinctrl * jzpc,unsigned int pin,bool high)2508*4882a593Smuzhiyun static void ingenic_set_output_level(struct ingenic_pinctrl *jzpc,
2509*4882a593Smuzhiyun unsigned int pin, bool high)
2510*4882a593Smuzhiyun {
2511*4882a593Smuzhiyun if (jzpc->info->version >= ID_JZ4770)
2512*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, high);
2513*4882a593Smuzhiyun else
2514*4882a593Smuzhiyun ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DATA, high);
2515*4882a593Smuzhiyun }
2516*4882a593Smuzhiyun
ingenic_pinconf_set(struct pinctrl_dev * pctldev,unsigned int pin,unsigned long * configs,unsigned int num_configs)2517*4882a593Smuzhiyun static int ingenic_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
2518*4882a593Smuzhiyun unsigned long *configs, unsigned int num_configs)
2519*4882a593Smuzhiyun {
2520*4882a593Smuzhiyun struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2521*4882a593Smuzhiyun unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2522*4882a593Smuzhiyun unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2523*4882a593Smuzhiyun unsigned int cfg, arg;
2524*4882a593Smuzhiyun int ret;
2525*4882a593Smuzhiyun
2526*4882a593Smuzhiyun for (cfg = 0; cfg < num_configs; cfg++) {
2527*4882a593Smuzhiyun switch (pinconf_to_config_param(configs[cfg])) {
2528*4882a593Smuzhiyun case PIN_CONFIG_BIAS_DISABLE:
2529*4882a593Smuzhiyun case PIN_CONFIG_BIAS_PULL_UP:
2530*4882a593Smuzhiyun case PIN_CONFIG_BIAS_PULL_DOWN:
2531*4882a593Smuzhiyun case PIN_CONFIG_OUTPUT:
2532*4882a593Smuzhiyun continue;
2533*4882a593Smuzhiyun default:
2534*4882a593Smuzhiyun return -ENOTSUPP;
2535*4882a593Smuzhiyun }
2536*4882a593Smuzhiyun }
2537*4882a593Smuzhiyun
2538*4882a593Smuzhiyun for (cfg = 0; cfg < num_configs; cfg++) {
2539*4882a593Smuzhiyun arg = pinconf_to_config_argument(configs[cfg]);
2540*4882a593Smuzhiyun
2541*4882a593Smuzhiyun switch (pinconf_to_config_param(configs[cfg])) {
2542*4882a593Smuzhiyun case PIN_CONFIG_BIAS_DISABLE:
2543*4882a593Smuzhiyun dev_dbg(jzpc->dev, "disable pull-over for pin P%c%u\n",
2544*4882a593Smuzhiyun 'A' + offt, idx);
2545*4882a593Smuzhiyun ingenic_set_bias(jzpc, pin, GPIO_PULL_DIS);
2546*4882a593Smuzhiyun break;
2547*4882a593Smuzhiyun
2548*4882a593Smuzhiyun case PIN_CONFIG_BIAS_PULL_UP:
2549*4882a593Smuzhiyun if (!(jzpc->info->pull_ups[offt] & BIT(idx)))
2550*4882a593Smuzhiyun return -EINVAL;
2551*4882a593Smuzhiyun dev_dbg(jzpc->dev, "set pull-up for pin P%c%u\n",
2552*4882a593Smuzhiyun 'A' + offt, idx);
2553*4882a593Smuzhiyun ingenic_set_bias(jzpc, pin, GPIO_PULL_UP);
2554*4882a593Smuzhiyun break;
2555*4882a593Smuzhiyun
2556*4882a593Smuzhiyun case PIN_CONFIG_BIAS_PULL_DOWN:
2557*4882a593Smuzhiyun if (!(jzpc->info->pull_downs[offt] & BIT(idx)))
2558*4882a593Smuzhiyun return -EINVAL;
2559*4882a593Smuzhiyun dev_dbg(jzpc->dev, "set pull-down for pin P%c%u\n",
2560*4882a593Smuzhiyun 'A' + offt, idx);
2561*4882a593Smuzhiyun ingenic_set_bias(jzpc, pin, GPIO_PULL_DOWN);
2562*4882a593Smuzhiyun break;
2563*4882a593Smuzhiyun
2564*4882a593Smuzhiyun case PIN_CONFIG_OUTPUT:
2565*4882a593Smuzhiyun ret = pinctrl_gpio_direction_output(pin);
2566*4882a593Smuzhiyun if (ret)
2567*4882a593Smuzhiyun return ret;
2568*4882a593Smuzhiyun
2569*4882a593Smuzhiyun ingenic_set_output_level(jzpc, pin, arg);
2570*4882a593Smuzhiyun break;
2571*4882a593Smuzhiyun
2572*4882a593Smuzhiyun default:
2573*4882a593Smuzhiyun /* unreachable */
2574*4882a593Smuzhiyun break;
2575*4882a593Smuzhiyun }
2576*4882a593Smuzhiyun }
2577*4882a593Smuzhiyun
2578*4882a593Smuzhiyun return 0;
2579*4882a593Smuzhiyun }
2580*4882a593Smuzhiyun
ingenic_pinconf_group_get(struct pinctrl_dev * pctldev,unsigned int group,unsigned long * config)2581*4882a593Smuzhiyun static int ingenic_pinconf_group_get(struct pinctrl_dev *pctldev,
2582*4882a593Smuzhiyun unsigned int group, unsigned long *config)
2583*4882a593Smuzhiyun {
2584*4882a593Smuzhiyun const unsigned int *pins;
2585*4882a593Smuzhiyun unsigned int i, npins, old = 0;
2586*4882a593Smuzhiyun int ret;
2587*4882a593Smuzhiyun
2588*4882a593Smuzhiyun ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
2589*4882a593Smuzhiyun if (ret)
2590*4882a593Smuzhiyun return ret;
2591*4882a593Smuzhiyun
2592*4882a593Smuzhiyun for (i = 0; i < npins; i++) {
2593*4882a593Smuzhiyun if (ingenic_pinconf_get(pctldev, pins[i], config))
2594*4882a593Smuzhiyun return -ENOTSUPP;
2595*4882a593Smuzhiyun
2596*4882a593Smuzhiyun /* configs do not match between two pins */
2597*4882a593Smuzhiyun if (i && (old != *config))
2598*4882a593Smuzhiyun return -ENOTSUPP;
2599*4882a593Smuzhiyun
2600*4882a593Smuzhiyun old = *config;
2601*4882a593Smuzhiyun }
2602*4882a593Smuzhiyun
2603*4882a593Smuzhiyun return 0;
2604*4882a593Smuzhiyun }
2605*4882a593Smuzhiyun
ingenic_pinconf_group_set(struct pinctrl_dev * pctldev,unsigned int group,unsigned long * configs,unsigned int num_configs)2606*4882a593Smuzhiyun static int ingenic_pinconf_group_set(struct pinctrl_dev *pctldev,
2607*4882a593Smuzhiyun unsigned int group, unsigned long *configs,
2608*4882a593Smuzhiyun unsigned int num_configs)
2609*4882a593Smuzhiyun {
2610*4882a593Smuzhiyun const unsigned int *pins;
2611*4882a593Smuzhiyun unsigned int i, npins;
2612*4882a593Smuzhiyun int ret;
2613*4882a593Smuzhiyun
2614*4882a593Smuzhiyun ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
2615*4882a593Smuzhiyun if (ret)
2616*4882a593Smuzhiyun return ret;
2617*4882a593Smuzhiyun
2618*4882a593Smuzhiyun for (i = 0; i < npins; i++) {
2619*4882a593Smuzhiyun ret = ingenic_pinconf_set(pctldev,
2620*4882a593Smuzhiyun pins[i], configs, num_configs);
2621*4882a593Smuzhiyun if (ret)
2622*4882a593Smuzhiyun return ret;
2623*4882a593Smuzhiyun }
2624*4882a593Smuzhiyun
2625*4882a593Smuzhiyun return 0;
2626*4882a593Smuzhiyun }
2627*4882a593Smuzhiyun
2628*4882a593Smuzhiyun static const struct pinconf_ops ingenic_confops = {
2629*4882a593Smuzhiyun .is_generic = true,
2630*4882a593Smuzhiyun .pin_config_get = ingenic_pinconf_get,
2631*4882a593Smuzhiyun .pin_config_set = ingenic_pinconf_set,
2632*4882a593Smuzhiyun .pin_config_group_get = ingenic_pinconf_group_get,
2633*4882a593Smuzhiyun .pin_config_group_set = ingenic_pinconf_group_set,
2634*4882a593Smuzhiyun };
2635*4882a593Smuzhiyun
2636*4882a593Smuzhiyun static const struct regmap_config ingenic_pinctrl_regmap_config = {
2637*4882a593Smuzhiyun .reg_bits = 32,
2638*4882a593Smuzhiyun .val_bits = 32,
2639*4882a593Smuzhiyun .reg_stride = 4,
2640*4882a593Smuzhiyun };
2641*4882a593Smuzhiyun
2642*4882a593Smuzhiyun static const struct of_device_id ingenic_gpio_of_match[] __initconst = {
2643*4882a593Smuzhiyun { .compatible = "ingenic,jz4740-gpio", },
2644*4882a593Smuzhiyun { .compatible = "ingenic,jz4725b-gpio", },
2645*4882a593Smuzhiyun { .compatible = "ingenic,jz4760-gpio", },
2646*4882a593Smuzhiyun { .compatible = "ingenic,jz4770-gpio", },
2647*4882a593Smuzhiyun { .compatible = "ingenic,jz4780-gpio", },
2648*4882a593Smuzhiyun { .compatible = "ingenic,x1000-gpio", },
2649*4882a593Smuzhiyun { .compatible = "ingenic,x1830-gpio", },
2650*4882a593Smuzhiyun {},
2651*4882a593Smuzhiyun };
2652*4882a593Smuzhiyun
ingenic_gpio_probe(struct ingenic_pinctrl * jzpc,struct device_node * node)2653*4882a593Smuzhiyun static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,
2654*4882a593Smuzhiyun struct device_node *node)
2655*4882a593Smuzhiyun {
2656*4882a593Smuzhiyun struct ingenic_gpio_chip *jzgc;
2657*4882a593Smuzhiyun struct device *dev = jzpc->dev;
2658*4882a593Smuzhiyun struct gpio_irq_chip *girq;
2659*4882a593Smuzhiyun unsigned int bank;
2660*4882a593Smuzhiyun int err;
2661*4882a593Smuzhiyun
2662*4882a593Smuzhiyun err = of_property_read_u32(node, "reg", &bank);
2663*4882a593Smuzhiyun if (err) {
2664*4882a593Smuzhiyun dev_err(dev, "Cannot read \"reg\" property: %i\n", err);
2665*4882a593Smuzhiyun return err;
2666*4882a593Smuzhiyun }
2667*4882a593Smuzhiyun
2668*4882a593Smuzhiyun jzgc = devm_kzalloc(dev, sizeof(*jzgc), GFP_KERNEL);
2669*4882a593Smuzhiyun if (!jzgc)
2670*4882a593Smuzhiyun return -ENOMEM;
2671*4882a593Smuzhiyun
2672*4882a593Smuzhiyun jzgc->jzpc = jzpc;
2673*4882a593Smuzhiyun jzgc->reg_base = bank * jzpc->info->reg_offset;
2674*4882a593Smuzhiyun
2675*4882a593Smuzhiyun jzgc->gc.label = devm_kasprintf(dev, GFP_KERNEL, "GPIO%c", 'A' + bank);
2676*4882a593Smuzhiyun if (!jzgc->gc.label)
2677*4882a593Smuzhiyun return -ENOMEM;
2678*4882a593Smuzhiyun
2679*4882a593Smuzhiyun /* DO NOT EXPAND THIS: FOR BACKWARD GPIO NUMBERSPACE COMPATIBIBILITY
2680*4882a593Smuzhiyun * ONLY: WORK TO TRANSITION CONSUMERS TO USE THE GPIO DESCRIPTOR API IN
2681*4882a593Smuzhiyun * <linux/gpio/consumer.h> INSTEAD.
2682*4882a593Smuzhiyun */
2683*4882a593Smuzhiyun jzgc->gc.base = bank * 32;
2684*4882a593Smuzhiyun
2685*4882a593Smuzhiyun jzgc->gc.ngpio = 32;
2686*4882a593Smuzhiyun jzgc->gc.parent = dev;
2687*4882a593Smuzhiyun jzgc->gc.of_node = node;
2688*4882a593Smuzhiyun jzgc->gc.owner = THIS_MODULE;
2689*4882a593Smuzhiyun
2690*4882a593Smuzhiyun jzgc->gc.set = ingenic_gpio_set;
2691*4882a593Smuzhiyun jzgc->gc.get = ingenic_gpio_get;
2692*4882a593Smuzhiyun jzgc->gc.direction_input = ingenic_gpio_direction_input;
2693*4882a593Smuzhiyun jzgc->gc.direction_output = ingenic_gpio_direction_output;
2694*4882a593Smuzhiyun jzgc->gc.get_direction = ingenic_gpio_get_direction;
2695*4882a593Smuzhiyun jzgc->gc.request = gpiochip_generic_request;
2696*4882a593Smuzhiyun jzgc->gc.free = gpiochip_generic_free;
2697*4882a593Smuzhiyun
2698*4882a593Smuzhiyun jzgc->irq = irq_of_parse_and_map(node, 0);
2699*4882a593Smuzhiyun if (!jzgc->irq)
2700*4882a593Smuzhiyun return -EINVAL;
2701*4882a593Smuzhiyun
2702*4882a593Smuzhiyun jzgc->irq_chip.name = jzgc->gc.label;
2703*4882a593Smuzhiyun jzgc->irq_chip.irq_enable = ingenic_gpio_irq_enable;
2704*4882a593Smuzhiyun jzgc->irq_chip.irq_disable = ingenic_gpio_irq_disable;
2705*4882a593Smuzhiyun jzgc->irq_chip.irq_unmask = ingenic_gpio_irq_unmask;
2706*4882a593Smuzhiyun jzgc->irq_chip.irq_mask = ingenic_gpio_irq_mask;
2707*4882a593Smuzhiyun jzgc->irq_chip.irq_ack = ingenic_gpio_irq_ack;
2708*4882a593Smuzhiyun jzgc->irq_chip.irq_set_type = ingenic_gpio_irq_set_type;
2709*4882a593Smuzhiyun jzgc->irq_chip.irq_set_wake = ingenic_gpio_irq_set_wake;
2710*4882a593Smuzhiyun jzgc->irq_chip.irq_request_resources = ingenic_gpio_irq_request;
2711*4882a593Smuzhiyun jzgc->irq_chip.irq_release_resources = ingenic_gpio_irq_release;
2712*4882a593Smuzhiyun jzgc->irq_chip.flags = IRQCHIP_MASK_ON_SUSPEND;
2713*4882a593Smuzhiyun
2714*4882a593Smuzhiyun girq = &jzgc->gc.irq;
2715*4882a593Smuzhiyun girq->chip = &jzgc->irq_chip;
2716*4882a593Smuzhiyun girq->parent_handler = ingenic_gpio_irq_handler;
2717*4882a593Smuzhiyun girq->num_parents = 1;
2718*4882a593Smuzhiyun girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
2719*4882a593Smuzhiyun GFP_KERNEL);
2720*4882a593Smuzhiyun if (!girq->parents)
2721*4882a593Smuzhiyun return -ENOMEM;
2722*4882a593Smuzhiyun girq->parents[0] = jzgc->irq;
2723*4882a593Smuzhiyun girq->default_type = IRQ_TYPE_NONE;
2724*4882a593Smuzhiyun girq->handler = handle_level_irq;
2725*4882a593Smuzhiyun
2726*4882a593Smuzhiyun err = devm_gpiochip_add_data(dev, &jzgc->gc, jzgc);
2727*4882a593Smuzhiyun if (err)
2728*4882a593Smuzhiyun return err;
2729*4882a593Smuzhiyun
2730*4882a593Smuzhiyun return 0;
2731*4882a593Smuzhiyun }
2732*4882a593Smuzhiyun
ingenic_pinctrl_probe(struct platform_device * pdev)2733*4882a593Smuzhiyun static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
2734*4882a593Smuzhiyun {
2735*4882a593Smuzhiyun struct device *dev = &pdev->dev;
2736*4882a593Smuzhiyun struct ingenic_pinctrl *jzpc;
2737*4882a593Smuzhiyun struct pinctrl_desc *pctl_desc;
2738*4882a593Smuzhiyun void __iomem *base;
2739*4882a593Smuzhiyun const struct ingenic_chip_info *chip_info;
2740*4882a593Smuzhiyun struct device_node *node;
2741*4882a593Smuzhiyun unsigned int i;
2742*4882a593Smuzhiyun int err;
2743*4882a593Smuzhiyun
2744*4882a593Smuzhiyun jzpc = devm_kzalloc(dev, sizeof(*jzpc), GFP_KERNEL);
2745*4882a593Smuzhiyun if (!jzpc)
2746*4882a593Smuzhiyun return -ENOMEM;
2747*4882a593Smuzhiyun
2748*4882a593Smuzhiyun base = devm_platform_ioremap_resource(pdev, 0);
2749*4882a593Smuzhiyun if (IS_ERR(base))
2750*4882a593Smuzhiyun return PTR_ERR(base);
2751*4882a593Smuzhiyun
2752*4882a593Smuzhiyun jzpc->map = devm_regmap_init_mmio(dev, base,
2753*4882a593Smuzhiyun &ingenic_pinctrl_regmap_config);
2754*4882a593Smuzhiyun if (IS_ERR(jzpc->map)) {
2755*4882a593Smuzhiyun dev_err(dev, "Failed to create regmap\n");
2756*4882a593Smuzhiyun return PTR_ERR(jzpc->map);
2757*4882a593Smuzhiyun }
2758*4882a593Smuzhiyun
2759*4882a593Smuzhiyun jzpc->dev = dev;
2760*4882a593Smuzhiyun jzpc->info = chip_info = of_device_get_match_data(dev);
2761*4882a593Smuzhiyun
2762*4882a593Smuzhiyun pctl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctl_desc), GFP_KERNEL);
2763*4882a593Smuzhiyun if (!pctl_desc)
2764*4882a593Smuzhiyun return -ENOMEM;
2765*4882a593Smuzhiyun
2766*4882a593Smuzhiyun /* fill in pinctrl_desc structure */
2767*4882a593Smuzhiyun pctl_desc->name = dev_name(dev);
2768*4882a593Smuzhiyun pctl_desc->owner = THIS_MODULE;
2769*4882a593Smuzhiyun pctl_desc->pctlops = &ingenic_pctlops;
2770*4882a593Smuzhiyun pctl_desc->pmxops = &ingenic_pmxops;
2771*4882a593Smuzhiyun pctl_desc->confops = &ingenic_confops;
2772*4882a593Smuzhiyun pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP;
2773*4882a593Smuzhiyun pctl_desc->pins = jzpc->pdesc = devm_kcalloc(&pdev->dev,
2774*4882a593Smuzhiyun pctl_desc->npins, sizeof(*jzpc->pdesc), GFP_KERNEL);
2775*4882a593Smuzhiyun if (!jzpc->pdesc)
2776*4882a593Smuzhiyun return -ENOMEM;
2777*4882a593Smuzhiyun
2778*4882a593Smuzhiyun for (i = 0; i < pctl_desc->npins; i++) {
2779*4882a593Smuzhiyun jzpc->pdesc[i].number = i;
2780*4882a593Smuzhiyun jzpc->pdesc[i].name = kasprintf(GFP_KERNEL, "P%c%d",
2781*4882a593Smuzhiyun 'A' + (i / PINS_PER_GPIO_CHIP),
2782*4882a593Smuzhiyun i % PINS_PER_GPIO_CHIP);
2783*4882a593Smuzhiyun }
2784*4882a593Smuzhiyun
2785*4882a593Smuzhiyun jzpc->pctl = devm_pinctrl_register(dev, pctl_desc, jzpc);
2786*4882a593Smuzhiyun if (IS_ERR(jzpc->pctl)) {
2787*4882a593Smuzhiyun dev_err(dev, "Failed to register pinctrl\n");
2788*4882a593Smuzhiyun return PTR_ERR(jzpc->pctl);
2789*4882a593Smuzhiyun }
2790*4882a593Smuzhiyun
2791*4882a593Smuzhiyun for (i = 0; i < chip_info->num_groups; i++) {
2792*4882a593Smuzhiyun const struct group_desc *group = &chip_info->groups[i];
2793*4882a593Smuzhiyun
2794*4882a593Smuzhiyun err = pinctrl_generic_add_group(jzpc->pctl, group->name,
2795*4882a593Smuzhiyun group->pins, group->num_pins, group->data);
2796*4882a593Smuzhiyun if (err < 0) {
2797*4882a593Smuzhiyun dev_err(dev, "Failed to register group %s\n",
2798*4882a593Smuzhiyun group->name);
2799*4882a593Smuzhiyun return err;
2800*4882a593Smuzhiyun }
2801*4882a593Smuzhiyun }
2802*4882a593Smuzhiyun
2803*4882a593Smuzhiyun for (i = 0; i < chip_info->num_functions; i++) {
2804*4882a593Smuzhiyun const struct function_desc *func = &chip_info->functions[i];
2805*4882a593Smuzhiyun
2806*4882a593Smuzhiyun err = pinmux_generic_add_function(jzpc->pctl, func->name,
2807*4882a593Smuzhiyun func->group_names, func->num_group_names,
2808*4882a593Smuzhiyun func->data);
2809*4882a593Smuzhiyun if (err < 0) {
2810*4882a593Smuzhiyun dev_err(dev, "Failed to register function %s\n",
2811*4882a593Smuzhiyun func->name);
2812*4882a593Smuzhiyun return err;
2813*4882a593Smuzhiyun }
2814*4882a593Smuzhiyun }
2815*4882a593Smuzhiyun
2816*4882a593Smuzhiyun dev_set_drvdata(dev, jzpc->map);
2817*4882a593Smuzhiyun
2818*4882a593Smuzhiyun for_each_child_of_node(dev->of_node, node) {
2819*4882a593Smuzhiyun if (of_match_node(ingenic_gpio_of_match, node)) {
2820*4882a593Smuzhiyun err = ingenic_gpio_probe(jzpc, node);
2821*4882a593Smuzhiyun if (err)
2822*4882a593Smuzhiyun return err;
2823*4882a593Smuzhiyun }
2824*4882a593Smuzhiyun }
2825*4882a593Smuzhiyun
2826*4882a593Smuzhiyun return 0;
2827*4882a593Smuzhiyun }
2828*4882a593Smuzhiyun
2829*4882a593Smuzhiyun static const struct of_device_id ingenic_pinctrl_of_match[] = {
2830*4882a593Smuzhiyun { .compatible = "ingenic,jz4740-pinctrl", .data = &jz4740_chip_info },
2831*4882a593Smuzhiyun { .compatible = "ingenic,jz4725b-pinctrl", .data = &jz4725b_chip_info },
2832*4882a593Smuzhiyun { .compatible = "ingenic,jz4760-pinctrl", .data = &jz4760_chip_info },
2833*4882a593Smuzhiyun { .compatible = "ingenic,jz4760b-pinctrl", .data = &jz4760_chip_info },
2834*4882a593Smuzhiyun { .compatible = "ingenic,jz4770-pinctrl", .data = &jz4770_chip_info },
2835*4882a593Smuzhiyun { .compatible = "ingenic,jz4780-pinctrl", .data = &jz4780_chip_info },
2836*4882a593Smuzhiyun { .compatible = "ingenic,x1000-pinctrl", .data = &x1000_chip_info },
2837*4882a593Smuzhiyun { .compatible = "ingenic,x1000e-pinctrl", .data = &x1000_chip_info },
2838*4882a593Smuzhiyun { .compatible = "ingenic,x1500-pinctrl", .data = &x1500_chip_info },
2839*4882a593Smuzhiyun { .compatible = "ingenic,x1830-pinctrl", .data = &x1830_chip_info },
2840*4882a593Smuzhiyun {},
2841*4882a593Smuzhiyun };
2842*4882a593Smuzhiyun
2843*4882a593Smuzhiyun static struct platform_driver ingenic_pinctrl_driver = {
2844*4882a593Smuzhiyun .driver = {
2845*4882a593Smuzhiyun .name = "pinctrl-ingenic",
2846*4882a593Smuzhiyun .of_match_table = ingenic_pinctrl_of_match,
2847*4882a593Smuzhiyun },
2848*4882a593Smuzhiyun };
2849*4882a593Smuzhiyun
ingenic_pinctrl_drv_register(void)2850*4882a593Smuzhiyun static int __init ingenic_pinctrl_drv_register(void)
2851*4882a593Smuzhiyun {
2852*4882a593Smuzhiyun return platform_driver_probe(&ingenic_pinctrl_driver,
2853*4882a593Smuzhiyun ingenic_pinctrl_probe);
2854*4882a593Smuzhiyun }
2855*4882a593Smuzhiyun subsys_initcall(ingenic_pinctrl_drv_register);
2856