blob: 621909b01debd79d4eb0923fa48e314d747cc237 [file] [log] [blame]
Thomas Gleixneraf873fc2019-05-28 09:57:21 -07001// SPDX-License-Identifier: GPL-2.0-only
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002/*
3 * Ingenic SoCs pinctrl driver
4 *
5 * Copyright (c) 2017 Paul Cercueil <paul@crapouillou.net>
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08006 * Copyright (c) 2019 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
Paul Boddiea0bb89e2020-02-28 19:19:30 +01007 * Copyright (c) 2017, 2019 Paul Boddie <paul@boddie.org.uk>
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02008 */
9
10#include <linux/compiler.h>
Linus Walleij28d6eeb2018-08-29 13:39:54 +020011#include <linux/gpio/driver.h>
Paul Cercueilb5c23aa2017-05-12 18:52:56 +020012#include <linux/interrupt.h>
13#include <linux/io.h>
14#include <linux/of_device.h>
Paul Cercueile72394e2018-08-21 18:42:32 +020015#include <linux/of_irq.h>
Paul Cercueilb5c23aa2017-05-12 18:52:56 +020016#include <linux/of_platform.h>
17#include <linux/pinctrl/pinctrl.h>
18#include <linux/pinctrl/pinmux.h>
19#include <linux/pinctrl/pinconf.h>
20#include <linux/pinctrl/pinconf-generic.h>
21#include <linux/platform_device.h>
22#include <linux/regmap.h>
23#include <linux/slab.h>
24
25#include "core.h"
26#include "pinconf.h"
27#include "pinmux.h"
28
Paul Cercueile72394e2018-08-21 18:42:32 +020029#define GPIO_PIN 0x00
30#define GPIO_MSK 0x20
31
Paul Cercueilb5c23aa2017-05-12 18:52:56 +020032#define JZ4740_GPIO_DATA 0x10
33#define JZ4740_GPIO_PULL_DIS 0x30
34#define JZ4740_GPIO_FUNC 0x40
35#define JZ4740_GPIO_SELECT 0x50
36#define JZ4740_GPIO_DIR 0x60
37#define JZ4740_GPIO_TRIG 0x70
38#define JZ4740_GPIO_FLAG 0x80
39
Zhou Yanjie0257595a2019-07-14 11:53:52 +080040#define JZ4760_GPIO_INT 0x10
41#define JZ4760_GPIO_PAT1 0x30
42#define JZ4760_GPIO_PAT0 0x40
43#define JZ4760_GPIO_FLAG 0x50
44#define JZ4760_GPIO_PEN 0x70
Paul Cercueilb5c23aa2017-05-12 18:52:56 +020045
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +080046#define X1830_GPIO_PEL 0x110
47#define X1830_GPIO_PEH 0x120
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +080048
Paul Cercueilb5c23aa2017-05-12 18:52:56 +020049#define REG_SET(x) ((x) + 0x4)
50#define REG_CLEAR(x) ((x) + 0x8)
51
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +080052#define REG_PZ_BASE(x) ((x) * 7)
53#define REG_PZ_GID2LD(x) ((x) * 7 + 0xf0)
54
55#define GPIO_PULL_DIS 0
56#define GPIO_PULL_UP 1
57#define GPIO_PULL_DOWN 2
58
Paul Cercueilb5c23aa2017-05-12 18:52:56 +020059#define PINS_PER_GPIO_CHIP 32
60
61enum jz_version {
62 ID_JZ4740,
Paul Cercueilf2a96762018-08-21 18:42:34 +020063 ID_JZ4725B,
Zhou Yanjie0257595a2019-07-14 11:53:52 +080064 ID_JZ4760,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +020065 ID_JZ4770,
66 ID_JZ4780,
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +080067 ID_X1000,
Zhou Yanjie5d215952019-07-14 11:53:56 +080068 ID_X1500,
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +080069 ID_X1830,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +020070};
71
72struct ingenic_chip_info {
73 unsigned int num_chips;
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +080074 unsigned int reg_offset;
Paul Cercueilbaf15642020-01-07 00:27:08 +010075 enum jz_version version;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +020076
77 const struct group_desc *groups;
78 unsigned int num_groups;
79
80 const struct function_desc *functions;
81 unsigned int num_functions;
82
83 const u32 *pull_ups, *pull_downs;
84};
85
86struct ingenic_pinctrl {
87 struct device *dev;
88 struct regmap *map;
89 struct pinctrl_dev *pctl;
90 struct pinctrl_pin_desc *pdesc;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +020091
92 const struct ingenic_chip_info *info;
93};
94
Paul Cercueile72394e2018-08-21 18:42:32 +020095struct ingenic_gpio_chip {
96 struct ingenic_pinctrl *jzpc;
97 struct gpio_chip gc;
98 struct irq_chip irq_chip;
99 unsigned int irq, reg_base;
100};
101
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200102static const u32 jz4740_pull_ups[4] = {
103 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
104};
105
106static const u32 jz4740_pull_downs[4] = {
107 0x00000000, 0x00000000, 0x00000000, 0x00000000,
108};
109
110static int jz4740_mmc_1bit_pins[] = { 0x69, 0x68, 0x6a, };
111static int jz4740_mmc_4bit_pins[] = { 0x6b, 0x6c, 0x6d, };
112static int jz4740_uart0_data_pins[] = { 0x7a, 0x79, };
113static int jz4740_uart0_hwflow_pins[] = { 0x7e, 0x7f, };
114static int jz4740_uart1_data_pins[] = { 0x7e, 0x7f, };
115static int jz4740_lcd_8bit_pins[] = {
116 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x52, 0x53, 0x54,
117};
118static int jz4740_lcd_16bit_pins[] = {
119 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x55,
120};
121static int jz4740_lcd_18bit_pins[] = { 0x50, 0x51, };
122static int jz4740_lcd_18bit_tft_pins[] = { 0x56, 0x57, 0x31, 0x32, };
123static int jz4740_nand_cs1_pins[] = { 0x39, };
124static int jz4740_nand_cs2_pins[] = { 0x3a, };
125static int jz4740_nand_cs3_pins[] = { 0x3b, };
126static int jz4740_nand_cs4_pins[] = { 0x3c, };
Paul Cercueilbcad94d2020-06-07 19:42:43 +0200127static int jz4740_nand_fre_fwe_pins[] = { 0x5c, 0x5d, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200128static int jz4740_pwm_pwm0_pins[] = { 0x77, };
129static int jz4740_pwm_pwm1_pins[] = { 0x78, };
130static int jz4740_pwm_pwm2_pins[] = { 0x79, };
131static int jz4740_pwm_pwm3_pins[] = { 0x7a, };
132static int jz4740_pwm_pwm4_pins[] = { 0x7b, };
133static int jz4740_pwm_pwm5_pins[] = { 0x7c, };
134static int jz4740_pwm_pwm6_pins[] = { 0x7e, };
135static int jz4740_pwm_pwm7_pins[] = { 0x7f, };
136
137static int jz4740_mmc_1bit_funcs[] = { 0, 0, 0, };
138static int jz4740_mmc_4bit_funcs[] = { 0, 0, 0, };
139static int jz4740_uart0_data_funcs[] = { 1, 1, };
140static int jz4740_uart0_hwflow_funcs[] = { 1, 1, };
141static int jz4740_uart1_data_funcs[] = { 2, 2, };
142static int jz4740_lcd_8bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
143static int jz4740_lcd_16bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, };
144static int jz4740_lcd_18bit_funcs[] = { 0, 0, };
145static int jz4740_lcd_18bit_tft_funcs[] = { 0, 0, 0, 0, };
146static int jz4740_nand_cs1_funcs[] = { 0, };
147static int jz4740_nand_cs2_funcs[] = { 0, };
148static int jz4740_nand_cs3_funcs[] = { 0, };
149static int jz4740_nand_cs4_funcs[] = { 0, };
Paul Cercueilbcad94d2020-06-07 19:42:43 +0200150static int jz4740_nand_fre_fwe_funcs[] = { 0, 0, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200151static int jz4740_pwm_pwm0_funcs[] = { 0, };
152static int jz4740_pwm_pwm1_funcs[] = { 0, };
153static int jz4740_pwm_pwm2_funcs[] = { 0, };
154static int jz4740_pwm_pwm3_funcs[] = { 0, };
155static int jz4740_pwm_pwm4_funcs[] = { 0, };
156static int jz4740_pwm_pwm5_funcs[] = { 0, };
157static int jz4740_pwm_pwm6_funcs[] = { 0, };
158static int jz4740_pwm_pwm7_funcs[] = { 0, };
159
160#define INGENIC_PIN_GROUP(name, id) \
161 { \
162 name, \
163 id##_pins, \
164 ARRAY_SIZE(id##_pins), \
165 id##_funcs, \
166 }
167
168static const struct group_desc jz4740_groups[] = {
169 INGENIC_PIN_GROUP("mmc-1bit", jz4740_mmc_1bit),
170 INGENIC_PIN_GROUP("mmc-4bit", jz4740_mmc_4bit),
171 INGENIC_PIN_GROUP("uart0-data", jz4740_uart0_data),
172 INGENIC_PIN_GROUP("uart0-hwflow", jz4740_uart0_hwflow),
173 INGENIC_PIN_GROUP("uart1-data", jz4740_uart1_data),
174 INGENIC_PIN_GROUP("lcd-8bit", jz4740_lcd_8bit),
175 INGENIC_PIN_GROUP("lcd-16bit", jz4740_lcd_16bit),
176 INGENIC_PIN_GROUP("lcd-18bit", jz4740_lcd_18bit),
177 INGENIC_PIN_GROUP("lcd-18bit-tft", jz4740_lcd_18bit_tft),
178 { "lcd-no-pins", },
179 INGENIC_PIN_GROUP("nand-cs1", jz4740_nand_cs1),
180 INGENIC_PIN_GROUP("nand-cs2", jz4740_nand_cs2),
181 INGENIC_PIN_GROUP("nand-cs3", jz4740_nand_cs3),
182 INGENIC_PIN_GROUP("nand-cs4", jz4740_nand_cs4),
Paul Cercueilbcad94d2020-06-07 19:42:43 +0200183 INGENIC_PIN_GROUP("nand-fre-fwe", jz4740_nand_fre_fwe),
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200184 INGENIC_PIN_GROUP("pwm0", jz4740_pwm_pwm0),
185 INGENIC_PIN_GROUP("pwm1", jz4740_pwm_pwm1),
186 INGENIC_PIN_GROUP("pwm2", jz4740_pwm_pwm2),
187 INGENIC_PIN_GROUP("pwm3", jz4740_pwm_pwm3),
188 INGENIC_PIN_GROUP("pwm4", jz4740_pwm_pwm4),
189 INGENIC_PIN_GROUP("pwm5", jz4740_pwm_pwm5),
190 INGENIC_PIN_GROUP("pwm6", jz4740_pwm_pwm6),
191 INGENIC_PIN_GROUP("pwm7", jz4740_pwm_pwm7),
192};
193
194static const char *jz4740_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
195static const char *jz4740_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
196static const char *jz4740_uart1_groups[] = { "uart1-data", };
197static const char *jz4740_lcd_groups[] = {
198 "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-18bit-tft", "lcd-no-pins",
199};
200static const char *jz4740_nand_groups[] = {
Paul Cercueilbcad94d2020-06-07 19:42:43 +0200201 "nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4", "nand-fre-fwe",
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200202};
203static const char *jz4740_pwm0_groups[] = { "pwm0", };
204static const char *jz4740_pwm1_groups[] = { "pwm1", };
205static const char *jz4740_pwm2_groups[] = { "pwm2", };
206static const char *jz4740_pwm3_groups[] = { "pwm3", };
207static const char *jz4740_pwm4_groups[] = { "pwm4", };
208static const char *jz4740_pwm5_groups[] = { "pwm5", };
209static const char *jz4740_pwm6_groups[] = { "pwm6", };
210static const char *jz4740_pwm7_groups[] = { "pwm7", };
211
212static const struct function_desc jz4740_functions[] = {
213 { "mmc", jz4740_mmc_groups, ARRAY_SIZE(jz4740_mmc_groups), },
214 { "uart0", jz4740_uart0_groups, ARRAY_SIZE(jz4740_uart0_groups), },
215 { "uart1", jz4740_uart1_groups, ARRAY_SIZE(jz4740_uart1_groups), },
216 { "lcd", jz4740_lcd_groups, ARRAY_SIZE(jz4740_lcd_groups), },
217 { "nand", jz4740_nand_groups, ARRAY_SIZE(jz4740_nand_groups), },
218 { "pwm0", jz4740_pwm0_groups, ARRAY_SIZE(jz4740_pwm0_groups), },
219 { "pwm1", jz4740_pwm1_groups, ARRAY_SIZE(jz4740_pwm1_groups), },
220 { "pwm2", jz4740_pwm2_groups, ARRAY_SIZE(jz4740_pwm2_groups), },
221 { "pwm3", jz4740_pwm3_groups, ARRAY_SIZE(jz4740_pwm3_groups), },
222 { "pwm4", jz4740_pwm4_groups, ARRAY_SIZE(jz4740_pwm4_groups), },
223 { "pwm5", jz4740_pwm5_groups, ARRAY_SIZE(jz4740_pwm5_groups), },
224 { "pwm6", jz4740_pwm6_groups, ARRAY_SIZE(jz4740_pwm6_groups), },
225 { "pwm7", jz4740_pwm7_groups, ARRAY_SIZE(jz4740_pwm7_groups), },
226};
227
228static const struct ingenic_chip_info jz4740_chip_info = {
229 .num_chips = 4,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +0800230 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +0100231 .version = ID_JZ4740,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200232 .groups = jz4740_groups,
233 .num_groups = ARRAY_SIZE(jz4740_groups),
234 .functions = jz4740_functions,
235 .num_functions = ARRAY_SIZE(jz4740_functions),
236 .pull_ups = jz4740_pull_ups,
237 .pull_downs = jz4740_pull_downs,
238};
239
Paul Cercueilf2a96762018-08-21 18:42:34 +0200240static int jz4725b_mmc0_1bit_pins[] = { 0x48, 0x49, 0x5c, };
241static int jz4725b_mmc0_4bit_pins[] = { 0x5d, 0x5b, 0x56, };
242static int jz4725b_mmc1_1bit_pins[] = { 0x7a, 0x7b, 0x7c, };
243static int jz4725b_mmc1_4bit_pins[] = { 0x7d, 0x7e, 0x7f, };
244static int jz4725b_uart_data_pins[] = { 0x4c, 0x4d, };
245static int jz4725b_nand_cs1_pins[] = { 0x55, };
246static int jz4725b_nand_cs2_pins[] = { 0x56, };
247static int jz4725b_nand_cs3_pins[] = { 0x57, };
248static int jz4725b_nand_cs4_pins[] = { 0x58, };
249static int jz4725b_nand_cle_ale_pins[] = { 0x48, 0x49 };
250static int jz4725b_nand_fre_fwe_pins[] = { 0x5c, 0x5d };
251static int jz4725b_pwm_pwm0_pins[] = { 0x4a, };
252static int jz4725b_pwm_pwm1_pins[] = { 0x4b, };
253static int jz4725b_pwm_pwm2_pins[] = { 0x4c, };
254static int jz4725b_pwm_pwm3_pins[] = { 0x4d, };
255static int jz4725b_pwm_pwm4_pins[] = { 0x4e, };
256static int jz4725b_pwm_pwm5_pins[] = { 0x4f, };
Paul Cercueila3240f02019-02-07 10:55:36 -0300257static int jz4725b_lcd_8bit_pins[] = {
258 0x72, 0x73, 0x74,
259 0x60, 0x61, 0x62, 0x63,
260 0x64, 0x65, 0x66, 0x67,
261};
262static int jz4725b_lcd_16bit_pins[] = {
263 0x68, 0x69, 0x6a, 0x6b,
264 0x6c, 0x6d, 0x6e, 0x6f,
265};
266static int jz4725b_lcd_18bit_pins[] = { 0x70, 0x71, };
267static int jz4725b_lcd_24bit_pins[] = { 0x76, 0x77, 0x78, 0x79, };
268static int jz4725b_lcd_special_pins[] = { 0x76, 0x77, 0x78, 0x79, };
269static int jz4725b_lcd_generic_pins[] = { 0x75, };
Paul Cercueilf2a96762018-08-21 18:42:34 +0200270
271static int jz4725b_mmc0_1bit_funcs[] = { 1, 1, 1, };
272static int jz4725b_mmc0_4bit_funcs[] = { 1, 0, 1, };
273static int jz4725b_mmc1_1bit_funcs[] = { 0, 0, 0, };
274static int jz4725b_mmc1_4bit_funcs[] = { 0, 0, 0, };
275static int jz4725b_uart_data_funcs[] = { 1, 1, };
276static int jz4725b_nand_cs1_funcs[] = { 0, };
277static int jz4725b_nand_cs2_funcs[] = { 0, };
278static int jz4725b_nand_cs3_funcs[] = { 0, };
279static int jz4725b_nand_cs4_funcs[] = { 0, };
280static int jz4725b_nand_cle_ale_funcs[] = { 0, 0, };
281static int jz4725b_nand_fre_fwe_funcs[] = { 0, 0, };
282static int jz4725b_pwm_pwm0_funcs[] = { 0, };
283static int jz4725b_pwm_pwm1_funcs[] = { 0, };
284static int jz4725b_pwm_pwm2_funcs[] = { 0, };
285static int jz4725b_pwm_pwm3_funcs[] = { 0, };
286static int jz4725b_pwm_pwm4_funcs[] = { 0, };
287static int jz4725b_pwm_pwm5_funcs[] = { 0, };
Paul Cercueila3240f02019-02-07 10:55:36 -0300288static int jz4725b_lcd_8bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
289static int jz4725b_lcd_16bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
290static int jz4725b_lcd_18bit_funcs[] = { 0, 0, };
291static int jz4725b_lcd_24bit_funcs[] = { 1, 1, 1, 1, };
292static int jz4725b_lcd_special_funcs[] = { 0, 0, 0, 0, };
293static int jz4725b_lcd_generic_funcs[] = { 0, };
Paul Cercueilf2a96762018-08-21 18:42:34 +0200294
295static const struct group_desc jz4725b_groups[] = {
296 INGENIC_PIN_GROUP("mmc0-1bit", jz4725b_mmc0_1bit),
297 INGENIC_PIN_GROUP("mmc0-4bit", jz4725b_mmc0_4bit),
298 INGENIC_PIN_GROUP("mmc1-1bit", jz4725b_mmc1_1bit),
299 INGENIC_PIN_GROUP("mmc1-4bit", jz4725b_mmc1_4bit),
300 INGENIC_PIN_GROUP("uart-data", jz4725b_uart_data),
301 INGENIC_PIN_GROUP("nand-cs1", jz4725b_nand_cs1),
302 INGENIC_PIN_GROUP("nand-cs2", jz4725b_nand_cs2),
303 INGENIC_PIN_GROUP("nand-cs3", jz4725b_nand_cs3),
304 INGENIC_PIN_GROUP("nand-cs4", jz4725b_nand_cs4),
305 INGENIC_PIN_GROUP("nand-cle-ale", jz4725b_nand_cle_ale),
306 INGENIC_PIN_GROUP("nand-fre-fwe", jz4725b_nand_fre_fwe),
307 INGENIC_PIN_GROUP("pwm0", jz4725b_pwm_pwm0),
308 INGENIC_PIN_GROUP("pwm1", jz4725b_pwm_pwm1),
309 INGENIC_PIN_GROUP("pwm2", jz4725b_pwm_pwm2),
310 INGENIC_PIN_GROUP("pwm3", jz4725b_pwm_pwm3),
311 INGENIC_PIN_GROUP("pwm4", jz4725b_pwm_pwm4),
312 INGENIC_PIN_GROUP("pwm5", jz4725b_pwm_pwm5),
Paul Cercueila3240f02019-02-07 10:55:36 -0300313 INGENIC_PIN_GROUP("lcd-8bit", jz4725b_lcd_8bit),
314 INGENIC_PIN_GROUP("lcd-16bit", jz4725b_lcd_16bit),
315 INGENIC_PIN_GROUP("lcd-18bit", jz4725b_lcd_18bit),
316 INGENIC_PIN_GROUP("lcd-24bit", jz4725b_lcd_24bit),
317 INGENIC_PIN_GROUP("lcd-special", jz4725b_lcd_special),
318 INGENIC_PIN_GROUP("lcd-generic", jz4725b_lcd_generic),
Paul Cercueilf2a96762018-08-21 18:42:34 +0200319};
320
321static const char *jz4725b_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", };
322static const char *jz4725b_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
323static const char *jz4725b_uart_groups[] = { "uart-data", };
324static const char *jz4725b_nand_groups[] = {
325 "nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4",
326 "nand-cle-ale", "nand-fre-fwe",
327};
328static const char *jz4725b_pwm0_groups[] = { "pwm0", };
329static const char *jz4725b_pwm1_groups[] = { "pwm1", };
330static const char *jz4725b_pwm2_groups[] = { "pwm2", };
331static const char *jz4725b_pwm3_groups[] = { "pwm3", };
332static const char *jz4725b_pwm4_groups[] = { "pwm4", };
333static const char *jz4725b_pwm5_groups[] = { "pwm5", };
Paul Cercueila3240f02019-02-07 10:55:36 -0300334static const char *jz4725b_lcd_groups[] = {
335 "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
336 "lcd-special", "lcd-generic",
337};
Paul Cercueilf2a96762018-08-21 18:42:34 +0200338
339static const struct function_desc jz4725b_functions[] = {
340 { "mmc0", jz4725b_mmc0_groups, ARRAY_SIZE(jz4725b_mmc0_groups), },
341 { "mmc1", jz4725b_mmc1_groups, ARRAY_SIZE(jz4725b_mmc1_groups), },
342 { "uart", jz4725b_uart_groups, ARRAY_SIZE(jz4725b_uart_groups), },
343 { "nand", jz4725b_nand_groups, ARRAY_SIZE(jz4725b_nand_groups), },
344 { "pwm0", jz4725b_pwm0_groups, ARRAY_SIZE(jz4725b_pwm0_groups), },
345 { "pwm1", jz4725b_pwm1_groups, ARRAY_SIZE(jz4725b_pwm1_groups), },
346 { "pwm2", jz4725b_pwm2_groups, ARRAY_SIZE(jz4725b_pwm2_groups), },
347 { "pwm3", jz4725b_pwm3_groups, ARRAY_SIZE(jz4725b_pwm3_groups), },
348 { "pwm4", jz4725b_pwm4_groups, ARRAY_SIZE(jz4725b_pwm4_groups), },
349 { "pwm5", jz4725b_pwm5_groups, ARRAY_SIZE(jz4725b_pwm5_groups), },
Paul Cercueila3240f02019-02-07 10:55:36 -0300350 { "lcd", jz4725b_lcd_groups, ARRAY_SIZE(jz4725b_lcd_groups), },
Paul Cercueilf2a96762018-08-21 18:42:34 +0200351};
352
353static const struct ingenic_chip_info jz4725b_chip_info = {
354 .num_chips = 4,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +0800355 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +0100356 .version = ID_JZ4725B,
Paul Cercueilf2a96762018-08-21 18:42:34 +0200357 .groups = jz4725b_groups,
358 .num_groups = ARRAY_SIZE(jz4725b_groups),
359 .functions = jz4725b_functions,
360 .num_functions = ARRAY_SIZE(jz4725b_functions),
361 .pull_ups = jz4740_pull_ups,
362 .pull_downs = jz4740_pull_downs,
363};
364
Zhou Yanjie0257595a2019-07-14 11:53:52 +0800365static const u32 jz4760_pull_ups[6] = {
366 0xffffffff, 0xfffcf3ff, 0xffffffff, 0xffffcfff, 0xfffffb7c, 0xfffff00f,
367};
368
369static const u32 jz4760_pull_downs[6] = {
370 0x00000000, 0x00030c00, 0x00000000, 0x00003000, 0x00000483, 0x00000ff0,
371};
372
373static int jz4760_uart0_data_pins[] = { 0xa0, 0xa3, };
374static int jz4760_uart0_hwflow_pins[] = { 0xa1, 0xa2, };
375static int jz4760_uart1_data_pins[] = { 0x7a, 0x7c, };
376static int jz4760_uart1_hwflow_pins[] = { 0x7b, 0x7d, };
377static int jz4760_uart2_data_pins[] = { 0x5c, 0x5e, };
378static int jz4760_uart2_hwflow_pins[] = { 0x5d, 0x5f, };
379static int jz4760_uart3_data_pins[] = { 0x6c, 0x85, };
380static int jz4760_uart3_hwflow_pins[] = { 0x88, 0x89, };
381static int jz4760_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, };
382static int jz4760_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, };
383static int jz4760_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
384static int jz4760_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
385static int jz4760_mmc0_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
386static int jz4760_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, };
387static int jz4760_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, };
388static int jz4760_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
389static int jz4760_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
390static int jz4760_mmc1_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
391static int jz4760_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, };
392static int jz4760_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, };
393static int jz4760_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
394static int jz4760_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
395static int jz4760_mmc2_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
396static int jz4760_nemc_8bit_data_pins[] = {
397 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
398};
399static int jz4760_nemc_16bit_data_pins[] = {
400 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
401};
402static int jz4760_nemc_cle_ale_pins[] = { 0x20, 0x21, };
403static int jz4760_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, };
404static int jz4760_nemc_rd_we_pins[] = { 0x10, 0x11, };
405static int jz4760_nemc_frd_fwe_pins[] = { 0x12, 0x13, };
406static int jz4760_nemc_wait_pins[] = { 0x1b, };
407static int jz4760_nemc_cs1_pins[] = { 0x15, };
408static int jz4760_nemc_cs2_pins[] = { 0x16, };
409static int jz4760_nemc_cs3_pins[] = { 0x17, };
410static int jz4760_nemc_cs4_pins[] = { 0x18, };
411static int jz4760_nemc_cs5_pins[] = { 0x19, };
412static int jz4760_nemc_cs6_pins[] = { 0x1a, };
413static int jz4760_i2c0_pins[] = { 0x7e, 0x7f, };
414static int jz4760_i2c1_pins[] = { 0x9e, 0x9f, };
415static int jz4760_cim_pins[] = {
416 0x26, 0x27, 0x28, 0x29,
417 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
418};
419static int jz4760_lcd_24bit_pins[] = {
420 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
421 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
422 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
423 0x58, 0x59, 0x5a, 0x5b,
424};
425static int jz4760_pwm_pwm0_pins[] = { 0x80, };
426static int jz4760_pwm_pwm1_pins[] = { 0x81, };
427static int jz4760_pwm_pwm2_pins[] = { 0x82, };
428static int jz4760_pwm_pwm3_pins[] = { 0x83, };
429static int jz4760_pwm_pwm4_pins[] = { 0x84, };
430static int jz4760_pwm_pwm5_pins[] = { 0x85, };
431static int jz4760_pwm_pwm6_pins[] = { 0x6a, };
432static int jz4760_pwm_pwm7_pins[] = { 0x6b, };
433
434static int jz4760_uart0_data_funcs[] = { 0, 0, };
435static int jz4760_uart0_hwflow_funcs[] = { 0, 0, };
436static int jz4760_uart1_data_funcs[] = { 0, 0, };
437static int jz4760_uart1_hwflow_funcs[] = { 0, 0, };
438static int jz4760_uart2_data_funcs[] = { 0, 0, };
439static int jz4760_uart2_hwflow_funcs[] = { 0, 0, };
440static int jz4760_uart3_data_funcs[] = { 0, 1, };
441static int jz4760_uart3_hwflow_funcs[] = { 0, 0, };
442static int jz4760_mmc0_1bit_a_funcs[] = { 1, 1, 0, };
443static int jz4760_mmc0_4bit_a_funcs[] = { 1, 1, 1, };
444static int jz4760_mmc0_1bit_e_funcs[] = { 0, 0, 0, };
445static int jz4760_mmc0_4bit_e_funcs[] = { 0, 0, 0, };
446static int jz4760_mmc0_8bit_e_funcs[] = { 0, 0, 0, 0, };
447static int jz4760_mmc1_1bit_d_funcs[] = { 0, 0, 0, };
448static int jz4760_mmc1_4bit_d_funcs[] = { 0, 0, 0, };
449static int jz4760_mmc1_1bit_e_funcs[] = { 1, 1, 1, };
450static int jz4760_mmc1_4bit_e_funcs[] = { 1, 1, 1, };
451static int jz4760_mmc1_8bit_e_funcs[] = { 1, 1, 1, 1, };
452static int jz4760_mmc2_1bit_b_funcs[] = { 0, 0, 0, };
453static int jz4760_mmc2_4bit_b_funcs[] = { 0, 0, 0, };
454static int jz4760_mmc2_1bit_e_funcs[] = { 2, 2, 2, };
455static int jz4760_mmc2_4bit_e_funcs[] = { 2, 2, 2, };
456static int jz4760_mmc2_8bit_e_funcs[] = { 2, 2, 2, 2, };
457static int jz4760_nemc_8bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
458static int jz4760_nemc_16bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
459static int jz4760_nemc_cle_ale_funcs[] = { 0, 0, };
460static int jz4760_nemc_addr_funcs[] = { 0, 0, 0, 0, };
461static int jz4760_nemc_rd_we_funcs[] = { 0, 0, };
462static int jz4760_nemc_frd_fwe_funcs[] = { 0, 0, };
463static int jz4760_nemc_wait_funcs[] = { 0, };
464static int jz4760_nemc_cs1_funcs[] = { 0, };
465static int jz4760_nemc_cs2_funcs[] = { 0, };
466static int jz4760_nemc_cs3_funcs[] = { 0, };
467static int jz4760_nemc_cs4_funcs[] = { 0, };
468static int jz4760_nemc_cs5_funcs[] = { 0, };
469static int jz4760_nemc_cs6_funcs[] = { 0, };
470static int jz4760_i2c0_funcs[] = { 0, 0, };
471static int jz4760_i2c1_funcs[] = { 0, 0, };
472static int jz4760_cim_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
473static int jz4760_lcd_24bit_funcs[] = {
474 0, 0, 0, 0, 0, 0, 0, 0,
475 0, 0, 0, 0, 0, 0, 0, 0,
476 0, 0, 0, 0, 0, 0, 0, 0,
477 0, 0, 0, 0,
478};
479static int jz4760_pwm_pwm0_funcs[] = { 0, };
480static int jz4760_pwm_pwm1_funcs[] = { 0, };
481static int jz4760_pwm_pwm2_funcs[] = { 0, };
482static int jz4760_pwm_pwm3_funcs[] = { 0, };
483static int jz4760_pwm_pwm4_funcs[] = { 0, };
484static int jz4760_pwm_pwm5_funcs[] = { 0, };
485static int jz4760_pwm_pwm6_funcs[] = { 0, };
486static int jz4760_pwm_pwm7_funcs[] = { 0, };
487
488static const struct group_desc jz4760_groups[] = {
489 INGENIC_PIN_GROUP("uart0-data", jz4760_uart0_data),
490 INGENIC_PIN_GROUP("uart0-hwflow", jz4760_uart0_hwflow),
491 INGENIC_PIN_GROUP("uart1-data", jz4760_uart1_data),
492 INGENIC_PIN_GROUP("uart1-hwflow", jz4760_uart1_hwflow),
493 INGENIC_PIN_GROUP("uart2-data", jz4760_uart2_data),
494 INGENIC_PIN_GROUP("uart2-hwflow", jz4760_uart2_hwflow),
495 INGENIC_PIN_GROUP("uart3-data", jz4760_uart3_data),
496 INGENIC_PIN_GROUP("uart3-hwflow", jz4760_uart3_hwflow),
497 INGENIC_PIN_GROUP("mmc0-1bit-a", jz4760_mmc0_1bit_a),
498 INGENIC_PIN_GROUP("mmc0-4bit-a", jz4760_mmc0_4bit_a),
499 INGENIC_PIN_GROUP("mmc0-1bit-e", jz4760_mmc0_1bit_e),
500 INGENIC_PIN_GROUP("mmc0-4bit-e", jz4760_mmc0_4bit_e),
501 INGENIC_PIN_GROUP("mmc0-8bit-e", jz4760_mmc0_8bit_e),
502 INGENIC_PIN_GROUP("mmc1-1bit-d", jz4760_mmc1_1bit_d),
503 INGENIC_PIN_GROUP("mmc1-4bit-d", jz4760_mmc1_4bit_d),
504 INGENIC_PIN_GROUP("mmc1-1bit-e", jz4760_mmc1_1bit_e),
505 INGENIC_PIN_GROUP("mmc1-4bit-e", jz4760_mmc1_4bit_e),
506 INGENIC_PIN_GROUP("mmc1-8bit-e", jz4760_mmc1_8bit_e),
507 INGENIC_PIN_GROUP("mmc2-1bit-b", jz4760_mmc2_1bit_b),
508 INGENIC_PIN_GROUP("mmc2-4bit-b", jz4760_mmc2_4bit_b),
509 INGENIC_PIN_GROUP("mmc2-1bit-e", jz4760_mmc2_1bit_e),
510 INGENIC_PIN_GROUP("mmc2-4bit-e", jz4760_mmc2_4bit_e),
511 INGENIC_PIN_GROUP("mmc2-8bit-e", jz4760_mmc2_8bit_e),
512 INGENIC_PIN_GROUP("nemc-8bit-data", jz4760_nemc_8bit_data),
513 INGENIC_PIN_GROUP("nemc-16bit-data", jz4760_nemc_16bit_data),
514 INGENIC_PIN_GROUP("nemc-cle-ale", jz4760_nemc_cle_ale),
515 INGENIC_PIN_GROUP("nemc-addr", jz4760_nemc_addr),
516 INGENIC_PIN_GROUP("nemc-rd-we", jz4760_nemc_rd_we),
517 INGENIC_PIN_GROUP("nemc-frd-fwe", jz4760_nemc_frd_fwe),
518 INGENIC_PIN_GROUP("nemc-wait", jz4760_nemc_wait),
519 INGENIC_PIN_GROUP("nemc-cs1", jz4760_nemc_cs1),
520 INGENIC_PIN_GROUP("nemc-cs2", jz4760_nemc_cs2),
521 INGENIC_PIN_GROUP("nemc-cs3", jz4760_nemc_cs3),
522 INGENIC_PIN_GROUP("nemc-cs4", jz4760_nemc_cs4),
523 INGENIC_PIN_GROUP("nemc-cs5", jz4760_nemc_cs5),
524 INGENIC_PIN_GROUP("nemc-cs6", jz4760_nemc_cs6),
525 INGENIC_PIN_GROUP("i2c0-data", jz4760_i2c0),
526 INGENIC_PIN_GROUP("i2c1-data", jz4760_i2c1),
527 INGENIC_PIN_GROUP("cim-data", jz4760_cim),
528 INGENIC_PIN_GROUP("lcd-24bit", jz4760_lcd_24bit),
529 { "lcd-no-pins", },
530 INGENIC_PIN_GROUP("pwm0", jz4760_pwm_pwm0),
531 INGENIC_PIN_GROUP("pwm1", jz4760_pwm_pwm1),
532 INGENIC_PIN_GROUP("pwm2", jz4760_pwm_pwm2),
533 INGENIC_PIN_GROUP("pwm3", jz4760_pwm_pwm3),
534 INGENIC_PIN_GROUP("pwm4", jz4760_pwm_pwm4),
535 INGENIC_PIN_GROUP("pwm5", jz4760_pwm_pwm5),
536 INGENIC_PIN_GROUP("pwm6", jz4760_pwm_pwm6),
537 INGENIC_PIN_GROUP("pwm7", jz4760_pwm_pwm7),
538};
539
540static const char *jz4760_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
541static const char *jz4760_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
542static const char *jz4760_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
543static const char *jz4760_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
544static const char *jz4760_mmc0_groups[] = {
545 "mmc0-1bit-a", "mmc0-4bit-a",
546 "mmc0-1bit-e", "mmc0-4bit-e", "mmc0-8bit-e",
547};
548static const char *jz4760_mmc1_groups[] = {
549 "mmc1-1bit-d", "mmc1-4bit-d",
550 "mmc1-1bit-e", "mmc1-4bit-e", "mmc1-8bit-e",
551};
552static const char *jz4760_mmc2_groups[] = {
553 "mmc2-1bit-b", "mmc2-4bit-b",
554 "mmc2-1bit-e", "mmc2-4bit-e", "mmc2-8bit-e",
555};
556static const char *jz4760_nemc_groups[] = {
557 "nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale",
558 "nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
559};
560static const char *jz4760_cs1_groups[] = { "nemc-cs1", };
561static const char *jz4760_cs2_groups[] = { "nemc-cs2", };
562static const char *jz4760_cs3_groups[] = { "nemc-cs3", };
563static const char *jz4760_cs4_groups[] = { "nemc-cs4", };
564static const char *jz4760_cs5_groups[] = { "nemc-cs5", };
565static const char *jz4760_cs6_groups[] = { "nemc-cs6", };
566static const char *jz4760_i2c0_groups[] = { "i2c0-data", };
567static const char *jz4760_i2c1_groups[] = { "i2c1-data", };
568static const char *jz4760_cim_groups[] = { "cim-data", };
569static const char *jz4760_lcd_groups[] = { "lcd-24bit", "lcd-no-pins", };
570static const char *jz4760_pwm0_groups[] = { "pwm0", };
571static const char *jz4760_pwm1_groups[] = { "pwm1", };
572static const char *jz4760_pwm2_groups[] = { "pwm2", };
573static const char *jz4760_pwm3_groups[] = { "pwm3", };
574static const char *jz4760_pwm4_groups[] = { "pwm4", };
575static const char *jz4760_pwm5_groups[] = { "pwm5", };
576static const char *jz4760_pwm6_groups[] = { "pwm6", };
577static const char *jz4760_pwm7_groups[] = { "pwm7", };
578
579static const struct function_desc jz4760_functions[] = {
580 { "uart0", jz4760_uart0_groups, ARRAY_SIZE(jz4760_uart0_groups), },
581 { "uart1", jz4760_uart1_groups, ARRAY_SIZE(jz4760_uart1_groups), },
582 { "uart2", jz4760_uart2_groups, ARRAY_SIZE(jz4760_uart2_groups), },
583 { "uart3", jz4760_uart3_groups, ARRAY_SIZE(jz4760_uart3_groups), },
584 { "mmc0", jz4760_mmc0_groups, ARRAY_SIZE(jz4760_mmc0_groups), },
585 { "mmc1", jz4760_mmc1_groups, ARRAY_SIZE(jz4760_mmc1_groups), },
586 { "mmc2", jz4760_mmc2_groups, ARRAY_SIZE(jz4760_mmc2_groups), },
587 { "nemc", jz4760_nemc_groups, ARRAY_SIZE(jz4760_nemc_groups), },
588 { "nemc-cs1", jz4760_cs1_groups, ARRAY_SIZE(jz4760_cs1_groups), },
589 { "nemc-cs2", jz4760_cs2_groups, ARRAY_SIZE(jz4760_cs2_groups), },
590 { "nemc-cs3", jz4760_cs3_groups, ARRAY_SIZE(jz4760_cs3_groups), },
591 { "nemc-cs4", jz4760_cs4_groups, ARRAY_SIZE(jz4760_cs4_groups), },
592 { "nemc-cs5", jz4760_cs5_groups, ARRAY_SIZE(jz4760_cs5_groups), },
593 { "nemc-cs6", jz4760_cs6_groups, ARRAY_SIZE(jz4760_cs6_groups), },
594 { "i2c0", jz4760_i2c0_groups, ARRAY_SIZE(jz4760_i2c0_groups), },
595 { "i2c1", jz4760_i2c1_groups, ARRAY_SIZE(jz4760_i2c1_groups), },
596 { "cim", jz4760_cim_groups, ARRAY_SIZE(jz4760_cim_groups), },
597 { "lcd", jz4760_lcd_groups, ARRAY_SIZE(jz4760_lcd_groups), },
598 { "pwm0", jz4760_pwm0_groups, ARRAY_SIZE(jz4760_pwm0_groups), },
599 { "pwm1", jz4760_pwm1_groups, ARRAY_SIZE(jz4760_pwm1_groups), },
600 { "pwm2", jz4760_pwm2_groups, ARRAY_SIZE(jz4760_pwm2_groups), },
601 { "pwm3", jz4760_pwm3_groups, ARRAY_SIZE(jz4760_pwm3_groups), },
602 { "pwm4", jz4760_pwm4_groups, ARRAY_SIZE(jz4760_pwm4_groups), },
603 { "pwm5", jz4760_pwm5_groups, ARRAY_SIZE(jz4760_pwm5_groups), },
604 { "pwm6", jz4760_pwm6_groups, ARRAY_SIZE(jz4760_pwm6_groups), },
605 { "pwm7", jz4760_pwm7_groups, ARRAY_SIZE(jz4760_pwm7_groups), },
606};
607
608static const struct ingenic_chip_info jz4760_chip_info = {
609 .num_chips = 6,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +0800610 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +0100611 .version = ID_JZ4760,
Zhou Yanjie0257595a2019-07-14 11:53:52 +0800612 .groups = jz4760_groups,
613 .num_groups = ARRAY_SIZE(jz4760_groups),
614 .functions = jz4760_functions,
615 .num_functions = ARRAY_SIZE(jz4760_functions),
616 .pull_ups = jz4760_pull_ups,
617 .pull_downs = jz4760_pull_downs,
618};
619
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200620static const u32 jz4770_pull_ups[6] = {
621 0x3fffffff, 0xfff0030c, 0xffffffff, 0xffff4fff, 0xfffffb7c, 0xffa7f00f,
622};
623
624static const u32 jz4770_pull_downs[6] = {
625 0x00000000, 0x000f0c03, 0x00000000, 0x0000b000, 0x00000483, 0x00580ff0,
626};
627
628static int jz4770_uart0_data_pins[] = { 0xa0, 0xa3, };
629static int jz4770_uart0_hwflow_pins[] = { 0xa1, 0xa2, };
630static int jz4770_uart1_data_pins[] = { 0x7a, 0x7c, };
631static int jz4770_uart1_hwflow_pins[] = { 0x7b, 0x7d, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800632static int jz4770_uart2_data_pins[] = { 0x5c, 0x5e, };
633static int jz4770_uart2_hwflow_pins[] = { 0x5d, 0x5f, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200634static int jz4770_uart3_data_pins[] = { 0x6c, 0x85, };
635static int jz4770_uart3_hwflow_pins[] = { 0x88, 0x89, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800636static int jz4770_ssi0_dt_a_pins[] = { 0x15, };
637static int jz4770_ssi0_dt_b_pins[] = { 0x35, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200638static int jz4770_ssi0_dt_d_pins[] = { 0x75, };
639static int jz4770_ssi0_dt_e_pins[] = { 0x91, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800640static int jz4770_ssi0_dr_a_pins[] = { 0x14, };
641static int jz4770_ssi0_dr_b_pins[] = { 0x34, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200642static int jz4770_ssi0_dr_d_pins[] = { 0x74, };
643static int jz4770_ssi0_dr_e_pins[] = { 0x8e, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800644static int jz4770_ssi0_clk_a_pins[] = { 0x12, };
645static int jz4770_ssi0_clk_b_pins[] = { 0x3c, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200646static int jz4770_ssi0_clk_d_pins[] = { 0x78, };
647static int jz4770_ssi0_clk_e_pins[] = { 0x8f, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800648static int jz4770_ssi0_gpc_b_pins[] = { 0x3e, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200649static int jz4770_ssi0_gpc_d_pins[] = { 0x76, };
650static int jz4770_ssi0_gpc_e_pins[] = { 0x93, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800651static int jz4770_ssi0_ce0_a_pins[] = { 0x13, };
652static int jz4770_ssi0_ce0_b_pins[] = { 0x3d, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200653static int jz4770_ssi0_ce0_d_pins[] = { 0x79, };
654static int jz4770_ssi0_ce0_e_pins[] = { 0x90, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800655static int jz4770_ssi0_ce1_b_pins[] = { 0x3f, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200656static int jz4770_ssi0_ce1_d_pins[] = { 0x77, };
657static int jz4770_ssi0_ce1_e_pins[] = { 0x92, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800658static int jz4770_ssi1_dt_b_pins[] = { 0x35, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200659static int jz4770_ssi1_dt_d_pins[] = { 0x75, };
660static int jz4770_ssi1_dt_e_pins[] = { 0x91, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800661static int jz4770_ssi1_dr_b_pins[] = { 0x34, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200662static int jz4770_ssi1_dr_d_pins[] = { 0x74, };
663static int jz4770_ssi1_dr_e_pins[] = { 0x8e, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800664static int jz4770_ssi1_clk_b_pins[] = { 0x3c, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200665static int jz4770_ssi1_clk_d_pins[] = { 0x78, };
666static int jz4770_ssi1_clk_e_pins[] = { 0x8f, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800667static int jz4770_ssi1_gpc_b_pins[] = { 0x3e, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200668static int jz4770_ssi1_gpc_d_pins[] = { 0x76, };
669static int jz4770_ssi1_gpc_e_pins[] = { 0x93, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800670static int jz4770_ssi1_ce0_b_pins[] = { 0x3d, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200671static int jz4770_ssi1_ce0_d_pins[] = { 0x79, };
672static int jz4770_ssi1_ce0_e_pins[] = { 0x90, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800673static int jz4770_ssi1_ce1_b_pins[] = { 0x3f, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200674static int jz4770_ssi1_ce1_d_pins[] = { 0x77, };
675static int jz4770_ssi1_ce1_e_pins[] = { 0x92, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200676static int jz4770_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800677static int jz4770_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200678static int jz4770_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800679static int jz4770_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
680static int jz4770_mmc0_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200681static int jz4770_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800682static int jz4770_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200683static int jz4770_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800684static int jz4770_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
685static int jz4770_mmc1_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800686static int jz4770_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, };
687static int jz4770_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, };
688static int jz4770_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
689static int jz4770_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
690static int jz4770_mmc2_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800691static int jz4770_nemc_8bit_data_pins[] = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200692 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
693};
Zhou Yanjieff656e42019-01-28 23:19:57 +0800694static int jz4770_nemc_16bit_data_pins[] = {
695 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
696};
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200697static int jz4770_nemc_cle_ale_pins[] = { 0x20, 0x21, };
698static int jz4770_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, };
699static int jz4770_nemc_rd_we_pins[] = { 0x10, 0x11, };
700static int jz4770_nemc_frd_fwe_pins[] = { 0x12, 0x13, };
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800701static int jz4770_nemc_wait_pins[] = { 0x1b, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200702static int jz4770_nemc_cs1_pins[] = { 0x15, };
703static int jz4770_nemc_cs2_pins[] = { 0x16, };
704static int jz4770_nemc_cs3_pins[] = { 0x17, };
705static int jz4770_nemc_cs4_pins[] = { 0x18, };
706static int jz4770_nemc_cs5_pins[] = { 0x19, };
707static int jz4770_nemc_cs6_pins[] = { 0x1a, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800708static int jz4770_i2c0_pins[] = { 0x7e, 0x7f, };
709static int jz4770_i2c1_pins[] = { 0x9e, 0x9f, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200710static int jz4770_i2c2_pins[] = { 0xb0, 0xb1, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800711static int jz4770_cim_8bit_pins[] = {
712 0x26, 0x27, 0x28, 0x29,
713 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200714};
Zhou Yanjieff656e42019-01-28 23:19:57 +0800715static int jz4770_cim_12bit_pins[] = {
716 0x32, 0x33, 0xb0, 0xb1,
717};
718static int jz4770_lcd_24bit_pins[] = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200719 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
720 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
721 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
Zhou Yanjieff656e42019-01-28 23:19:57 +0800722 0x58, 0x59, 0x5a, 0x5b,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200723};
724static int jz4770_pwm_pwm0_pins[] = { 0x80, };
725static int jz4770_pwm_pwm1_pins[] = { 0x81, };
726static int jz4770_pwm_pwm2_pins[] = { 0x82, };
727static int jz4770_pwm_pwm3_pins[] = { 0x83, };
728static int jz4770_pwm_pwm4_pins[] = { 0x84, };
729static int jz4770_pwm_pwm5_pins[] = { 0x85, };
730static int jz4770_pwm_pwm6_pins[] = { 0x6a, };
731static int jz4770_pwm_pwm7_pins[] = { 0x6b, };
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800732static int jz4770_mac_rmii_pins[] = {
733 0xa9, 0xab, 0xaa, 0xac, 0xa5, 0xa4, 0xad, 0xae, 0xa6, 0xa8,
734};
735static int jz4770_mac_mii_pins[] = { 0xa7, 0xaf, };
Paul Cercueilae75b532019-11-19 16:52:11 +0100736static int jz4770_otg_pins[] = { 0x8a, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200737
738static int jz4770_uart0_data_funcs[] = { 0, 0, };
739static int jz4770_uart0_hwflow_funcs[] = { 0, 0, };
740static int jz4770_uart1_data_funcs[] = { 0, 0, };
741static int jz4770_uart1_hwflow_funcs[] = { 0, 0, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800742static int jz4770_uart2_data_funcs[] = { 0, 0, };
743static int jz4770_uart2_hwflow_funcs[] = { 0, 0, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200744static int jz4770_uart3_data_funcs[] = { 0, 1, };
745static int jz4770_uart3_hwflow_funcs[] = { 0, 0, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800746static int jz4770_ssi0_dt_a_funcs[] = { 2, };
747static int jz4770_ssi0_dt_b_funcs[] = { 1, };
748static int jz4770_ssi0_dt_d_funcs[] = { 1, };
749static int jz4770_ssi0_dt_e_funcs[] = { 0, };
750static int jz4770_ssi0_dr_a_funcs[] = { 1, };
751static int jz4770_ssi0_dr_b_funcs[] = { 1, };
752static int jz4770_ssi0_dr_d_funcs[] = { 1, };
753static int jz4770_ssi0_dr_e_funcs[] = { 0, };
754static int jz4770_ssi0_clk_a_funcs[] = { 2, };
755static int jz4770_ssi0_clk_b_funcs[] = { 1, };
756static int jz4770_ssi0_clk_d_funcs[] = { 1, };
757static int jz4770_ssi0_clk_e_funcs[] = { 0, };
758static int jz4770_ssi0_gpc_b_funcs[] = { 1, };
759static int jz4770_ssi0_gpc_d_funcs[] = { 1, };
760static int jz4770_ssi0_gpc_e_funcs[] = { 0, };
761static int jz4770_ssi0_ce0_a_funcs[] = { 2, };
762static int jz4770_ssi0_ce0_b_funcs[] = { 1, };
763static int jz4770_ssi0_ce0_d_funcs[] = { 1, };
764static int jz4770_ssi0_ce0_e_funcs[] = { 0, };
765static int jz4770_ssi0_ce1_b_funcs[] = { 1, };
766static int jz4770_ssi0_ce1_d_funcs[] = { 1, };
767static int jz4770_ssi0_ce1_e_funcs[] = { 0, };
768static int jz4770_ssi1_dt_b_funcs[] = { 2, };
769static int jz4770_ssi1_dt_d_funcs[] = { 2, };
770static int jz4770_ssi1_dt_e_funcs[] = { 1, };
771static int jz4770_ssi1_dr_b_funcs[] = { 2, };
772static int jz4770_ssi1_dr_d_funcs[] = { 2, };
773static int jz4770_ssi1_dr_e_funcs[] = { 1, };
774static int jz4770_ssi1_clk_b_funcs[] = { 2, };
775static int jz4770_ssi1_clk_d_funcs[] = { 2, };
776static int jz4770_ssi1_clk_e_funcs[] = { 1, };
777static int jz4770_ssi1_gpc_b_funcs[] = { 2, };
778static int jz4770_ssi1_gpc_d_funcs[] = { 2, };
779static int jz4770_ssi1_gpc_e_funcs[] = { 1, };
780static int jz4770_ssi1_ce0_b_funcs[] = { 2, };
781static int jz4770_ssi1_ce0_d_funcs[] = { 2, };
782static int jz4770_ssi1_ce0_e_funcs[] = { 1, };
783static int jz4770_ssi1_ce1_b_funcs[] = { 2, };
784static int jz4770_ssi1_ce1_d_funcs[] = { 2, };
785static int jz4770_ssi1_ce1_e_funcs[] = { 1, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200786static int jz4770_mmc0_1bit_a_funcs[] = { 1, 1, 0, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800787static int jz4770_mmc0_4bit_a_funcs[] = { 1, 1, 1, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200788static int jz4770_mmc0_1bit_e_funcs[] = { 0, 0, 0, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800789static int jz4770_mmc0_4bit_e_funcs[] = { 0, 0, 0, };
790static int jz4770_mmc0_8bit_e_funcs[] = { 0, 0, 0, 0, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200791static int jz4770_mmc1_1bit_d_funcs[] = { 0, 0, 0, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800792static int jz4770_mmc1_4bit_d_funcs[] = { 0, 0, 0, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200793static int jz4770_mmc1_1bit_e_funcs[] = { 1, 1, 1, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800794static int jz4770_mmc1_4bit_e_funcs[] = { 1, 1, 1, };
795static int jz4770_mmc1_8bit_e_funcs[] = { 1, 1, 1, 1, };
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800796static int jz4770_mmc2_1bit_b_funcs[] = { 0, 0, 0, };
797static int jz4770_mmc2_4bit_b_funcs[] = { 0, 0, 0, };
798static int jz4770_mmc2_1bit_e_funcs[] = { 2, 2, 2, };
799static int jz4770_mmc2_4bit_e_funcs[] = { 2, 2, 2, };
800static int jz4770_mmc2_8bit_e_funcs[] = { 2, 2, 2, 2, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800801static int jz4770_nemc_8bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
802static int jz4770_nemc_16bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200803static int jz4770_nemc_cle_ale_funcs[] = { 0, 0, };
804static int jz4770_nemc_addr_funcs[] = { 0, 0, 0, 0, };
805static int jz4770_nemc_rd_we_funcs[] = { 0, 0, };
806static int jz4770_nemc_frd_fwe_funcs[] = { 0, 0, };
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800807static int jz4770_nemc_wait_funcs[] = { 0, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200808static int jz4770_nemc_cs1_funcs[] = { 0, };
809static int jz4770_nemc_cs2_funcs[] = { 0, };
810static int jz4770_nemc_cs3_funcs[] = { 0, };
811static int jz4770_nemc_cs4_funcs[] = { 0, };
812static int jz4770_nemc_cs5_funcs[] = { 0, };
813static int jz4770_nemc_cs6_funcs[] = { 0, };
814static int jz4770_i2c0_funcs[] = { 0, 0, };
815static int jz4770_i2c1_funcs[] = { 0, 0, };
816static int jz4770_i2c2_funcs[] = { 2, 2, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800817static int jz4770_cim_8bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
818static int jz4770_cim_12bit_funcs[] = { 0, 0, 0, 0, };
819static int jz4770_lcd_24bit_funcs[] = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200820 0, 0, 0, 0, 0, 0, 0, 0,
821 0, 0, 0, 0, 0, 0, 0, 0,
Zhou Yanjieff656e42019-01-28 23:19:57 +0800822 0, 0, 0, 0, 0, 0, 0, 0,
823 0, 0, 0, 0,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200824};
825static int jz4770_pwm_pwm0_funcs[] = { 0, };
826static int jz4770_pwm_pwm1_funcs[] = { 0, };
827static int jz4770_pwm_pwm2_funcs[] = { 0, };
828static int jz4770_pwm_pwm3_funcs[] = { 0, };
829static int jz4770_pwm_pwm4_funcs[] = { 0, };
830static int jz4770_pwm_pwm5_funcs[] = { 0, };
831static int jz4770_pwm_pwm6_funcs[] = { 0, };
832static int jz4770_pwm_pwm7_funcs[] = { 0, };
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800833static int jz4770_mac_rmii_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
834static int jz4770_mac_mii_funcs[] = { 0, 0, };
Paul Cercueilae75b532019-11-19 16:52:11 +0100835static int jz4770_otg_funcs[] = { 0, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200836
837static const struct group_desc jz4770_groups[] = {
838 INGENIC_PIN_GROUP("uart0-data", jz4770_uart0_data),
839 INGENIC_PIN_GROUP("uart0-hwflow", jz4770_uart0_hwflow),
840 INGENIC_PIN_GROUP("uart1-data", jz4770_uart1_data),
841 INGENIC_PIN_GROUP("uart1-hwflow", jz4770_uart1_hwflow),
842 INGENIC_PIN_GROUP("uart2-data", jz4770_uart2_data),
843 INGENIC_PIN_GROUP("uart2-hwflow", jz4770_uart2_hwflow),
844 INGENIC_PIN_GROUP("uart3-data", jz4770_uart3_data),
845 INGENIC_PIN_GROUP("uart3-hwflow", jz4770_uart3_hwflow),
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800846 INGENIC_PIN_GROUP("ssi0-dt-a", jz4770_ssi0_dt_a),
847 INGENIC_PIN_GROUP("ssi0-dt-b", jz4770_ssi0_dt_b),
848 INGENIC_PIN_GROUP("ssi0-dt-d", jz4770_ssi0_dt_d),
849 INGENIC_PIN_GROUP("ssi0-dt-e", jz4770_ssi0_dt_e),
850 INGENIC_PIN_GROUP("ssi0-dr-a", jz4770_ssi0_dr_a),
851 INGENIC_PIN_GROUP("ssi0-dr-b", jz4770_ssi0_dr_b),
852 INGENIC_PIN_GROUP("ssi0-dr-d", jz4770_ssi0_dr_d),
853 INGENIC_PIN_GROUP("ssi0-dr-e", jz4770_ssi0_dr_e),
854 INGENIC_PIN_GROUP("ssi0-clk-a", jz4770_ssi0_clk_a),
855 INGENIC_PIN_GROUP("ssi0-clk-b", jz4770_ssi0_clk_b),
856 INGENIC_PIN_GROUP("ssi0-clk-d", jz4770_ssi0_clk_d),
857 INGENIC_PIN_GROUP("ssi0-clk-e", jz4770_ssi0_clk_e),
858 INGENIC_PIN_GROUP("ssi0-gpc-b", jz4770_ssi0_gpc_b),
859 INGENIC_PIN_GROUP("ssi0-gpc-d", jz4770_ssi0_gpc_d),
860 INGENIC_PIN_GROUP("ssi0-gpc-e", jz4770_ssi0_gpc_e),
861 INGENIC_PIN_GROUP("ssi0-ce0-a", jz4770_ssi0_ce0_a),
862 INGENIC_PIN_GROUP("ssi0-ce0-b", jz4770_ssi0_ce0_b),
863 INGENIC_PIN_GROUP("ssi0-ce0-d", jz4770_ssi0_ce0_d),
864 INGENIC_PIN_GROUP("ssi0-ce0-e", jz4770_ssi0_ce0_e),
865 INGENIC_PIN_GROUP("ssi0-ce1-b", jz4770_ssi0_ce1_b),
866 INGENIC_PIN_GROUP("ssi0-ce1-d", jz4770_ssi0_ce1_d),
867 INGENIC_PIN_GROUP("ssi0-ce1-e", jz4770_ssi0_ce1_e),
868 INGENIC_PIN_GROUP("ssi1-dt-b", jz4770_ssi1_dt_b),
869 INGENIC_PIN_GROUP("ssi1-dt-d", jz4770_ssi1_dt_d),
870 INGENIC_PIN_GROUP("ssi1-dt-e", jz4770_ssi1_dt_e),
871 INGENIC_PIN_GROUP("ssi1-dr-b", jz4770_ssi1_dr_b),
872 INGENIC_PIN_GROUP("ssi1-dr-d", jz4770_ssi1_dr_d),
873 INGENIC_PIN_GROUP("ssi1-dr-e", jz4770_ssi1_dr_e),
874 INGENIC_PIN_GROUP("ssi1-clk-b", jz4770_ssi1_clk_b),
875 INGENIC_PIN_GROUP("ssi1-clk-d", jz4770_ssi1_clk_d),
876 INGENIC_PIN_GROUP("ssi1-clk-e", jz4770_ssi1_clk_e),
877 INGENIC_PIN_GROUP("ssi1-gpc-b", jz4770_ssi1_gpc_b),
878 INGENIC_PIN_GROUP("ssi1-gpc-d", jz4770_ssi1_gpc_d),
879 INGENIC_PIN_GROUP("ssi1-gpc-e", jz4770_ssi1_gpc_e),
880 INGENIC_PIN_GROUP("ssi1-ce0-b", jz4770_ssi1_ce0_b),
881 INGENIC_PIN_GROUP("ssi1-ce0-d", jz4770_ssi1_ce0_d),
882 INGENIC_PIN_GROUP("ssi1-ce0-e", jz4770_ssi1_ce0_e),
883 INGENIC_PIN_GROUP("ssi1-ce1-b", jz4770_ssi1_ce1_b),
884 INGENIC_PIN_GROUP("ssi1-ce1-d", jz4770_ssi1_ce1_d),
885 INGENIC_PIN_GROUP("ssi1-ce1-e", jz4770_ssi1_ce1_e),
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200886 INGENIC_PIN_GROUP("mmc0-1bit-a", jz4770_mmc0_1bit_a),
Zhou Yanjieff656e42019-01-28 23:19:57 +0800887 INGENIC_PIN_GROUP("mmc0-4bit-a", jz4770_mmc0_4bit_a),
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200888 INGENIC_PIN_GROUP("mmc0-1bit-e", jz4770_mmc0_1bit_e),
Zhou Yanjieff656e42019-01-28 23:19:57 +0800889 INGENIC_PIN_GROUP("mmc0-4bit-e", jz4770_mmc0_4bit_e),
890 INGENIC_PIN_GROUP("mmc0-8bit-e", jz4770_mmc0_8bit_e),
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200891 INGENIC_PIN_GROUP("mmc1-1bit-d", jz4770_mmc1_1bit_d),
Zhou Yanjieff656e42019-01-28 23:19:57 +0800892 INGENIC_PIN_GROUP("mmc1-4bit-d", jz4770_mmc1_4bit_d),
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200893 INGENIC_PIN_GROUP("mmc1-1bit-e", jz4770_mmc1_1bit_e),
Zhou Yanjieff656e42019-01-28 23:19:57 +0800894 INGENIC_PIN_GROUP("mmc1-4bit-e", jz4770_mmc1_4bit_e),
895 INGENIC_PIN_GROUP("mmc1-8bit-e", jz4770_mmc1_8bit_e),
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800896 INGENIC_PIN_GROUP("mmc2-1bit-b", jz4770_mmc2_1bit_b),
897 INGENIC_PIN_GROUP("mmc2-4bit-b", jz4770_mmc2_4bit_b),
898 INGENIC_PIN_GROUP("mmc2-1bit-e", jz4770_mmc2_1bit_e),
899 INGENIC_PIN_GROUP("mmc2-4bit-e", jz4770_mmc2_4bit_e),
900 INGENIC_PIN_GROUP("mmc2-8bit-e", jz4770_mmc2_8bit_e),
Zhou Yanjieff656e42019-01-28 23:19:57 +0800901 INGENIC_PIN_GROUP("nemc-8bit-data", jz4770_nemc_8bit_data),
902 INGENIC_PIN_GROUP("nemc-16bit-data", jz4770_nemc_16bit_data),
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200903 INGENIC_PIN_GROUP("nemc-cle-ale", jz4770_nemc_cle_ale),
904 INGENIC_PIN_GROUP("nemc-addr", jz4770_nemc_addr),
905 INGENIC_PIN_GROUP("nemc-rd-we", jz4770_nemc_rd_we),
906 INGENIC_PIN_GROUP("nemc-frd-fwe", jz4770_nemc_frd_fwe),
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800907 INGENIC_PIN_GROUP("nemc-wait", jz4770_nemc_wait),
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200908 INGENIC_PIN_GROUP("nemc-cs1", jz4770_nemc_cs1),
909 INGENIC_PIN_GROUP("nemc-cs2", jz4770_nemc_cs2),
910 INGENIC_PIN_GROUP("nemc-cs3", jz4770_nemc_cs3),
911 INGENIC_PIN_GROUP("nemc-cs4", jz4770_nemc_cs4),
912 INGENIC_PIN_GROUP("nemc-cs5", jz4770_nemc_cs5),
913 INGENIC_PIN_GROUP("nemc-cs6", jz4770_nemc_cs6),
914 INGENIC_PIN_GROUP("i2c0-data", jz4770_i2c0),
915 INGENIC_PIN_GROUP("i2c1-data", jz4770_i2c1),
916 INGENIC_PIN_GROUP("i2c2-data", jz4770_i2c2),
Zhou Yanjieff656e42019-01-28 23:19:57 +0800917 INGENIC_PIN_GROUP("cim-data-8bit", jz4770_cim_8bit),
918 INGENIC_PIN_GROUP("cim-data-12bit", jz4770_cim_12bit),
919 INGENIC_PIN_GROUP("lcd-24bit", jz4770_lcd_24bit),
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200920 { "lcd-no-pins", },
921 INGENIC_PIN_GROUP("pwm0", jz4770_pwm_pwm0),
922 INGENIC_PIN_GROUP("pwm1", jz4770_pwm_pwm1),
923 INGENIC_PIN_GROUP("pwm2", jz4770_pwm_pwm2),
924 INGENIC_PIN_GROUP("pwm3", jz4770_pwm_pwm3),
925 INGENIC_PIN_GROUP("pwm4", jz4770_pwm_pwm4),
926 INGENIC_PIN_GROUP("pwm5", jz4770_pwm_pwm5),
927 INGENIC_PIN_GROUP("pwm6", jz4770_pwm_pwm6),
928 INGENIC_PIN_GROUP("pwm7", jz4770_pwm_pwm7),
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800929 INGENIC_PIN_GROUP("mac-rmii", jz4770_mac_rmii),
930 INGENIC_PIN_GROUP("mac-mii", jz4770_mac_mii),
Paul Cercueilae75b532019-11-19 16:52:11 +0100931 INGENIC_PIN_GROUP("otg-vbus", jz4770_otg),
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200932};
933
934static const char *jz4770_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
935static const char *jz4770_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
936static const char *jz4770_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
937static const char *jz4770_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800938static const char *jz4770_ssi0_groups[] = {
939 "ssi0-dt-a", "ssi0-dt-b", "ssi0-dt-d", "ssi0-dt-e",
940 "ssi0-dr-a", "ssi0-dr-b", "ssi0-dr-d", "ssi0-dr-e",
941 "ssi0-clk-a", "ssi0-clk-b", "ssi0-clk-d", "ssi0-clk-e",
942 "ssi0-gpc-b", "ssi0-gpc-d", "ssi0-gpc-e",
943 "ssi0-ce0-a", "ssi0-ce0-b", "ssi0-ce0-d", "ssi0-ce0-e",
944 "ssi0-ce1-b", "ssi0-ce1-d", "ssi0-ce1-e",
945};
946static const char *jz4770_ssi1_groups[] = {
947 "ssi1-dt-b", "ssi1-dt-d", "ssi1-dt-e",
948 "ssi1-dr-b", "ssi1-dr-d", "ssi1-dr-e",
949 "ssi1-clk-b", "ssi1-clk-d", "ssi1-clk-e",
950 "ssi1-gpc-b", "ssi1-gpc-d", "ssi1-gpc-e",
951 "ssi1-ce0-b", "ssi1-ce0-d", "ssi1-ce0-e",
952 "ssi1-ce1-b", "ssi1-ce1-d", "ssi1-ce1-e",
953};
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200954static const char *jz4770_mmc0_groups[] = {
Zhou Yanjieff656e42019-01-28 23:19:57 +0800955 "mmc0-1bit-a", "mmc0-4bit-a",
956 "mmc0-1bit-e", "mmc0-4bit-e", "mmc0-8bit-e",
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200957};
958static const char *jz4770_mmc1_groups[] = {
Zhou Yanjieff656e42019-01-28 23:19:57 +0800959 "mmc1-1bit-d", "mmc1-4bit-d",
960 "mmc1-1bit-e", "mmc1-4bit-e", "mmc1-8bit-e",
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200961};
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800962static const char *jz4770_mmc2_groups[] = {
963 "mmc2-1bit-b", "mmc2-4bit-b",
964 "mmc2-1bit-e", "mmc2-4bit-e", "mmc2-8bit-e",
965};
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200966static const char *jz4770_nemc_groups[] = {
Zhou Yanjieff656e42019-01-28 23:19:57 +0800967 "nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale",
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800968 "nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200969};
970static const char *jz4770_cs1_groups[] = { "nemc-cs1", };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800971static const char *jz4770_cs2_groups[] = { "nemc-cs2", };
972static const char *jz4770_cs3_groups[] = { "nemc-cs3", };
973static const char *jz4770_cs4_groups[] = { "nemc-cs4", };
974static const char *jz4770_cs5_groups[] = { "nemc-cs5", };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200975static const char *jz4770_cs6_groups[] = { "nemc-cs6", };
976static const char *jz4770_i2c0_groups[] = { "i2c0-data", };
977static const char *jz4770_i2c1_groups[] = { "i2c1-data", };
978static const char *jz4770_i2c2_groups[] = { "i2c2-data", };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800979static const char *jz4770_cim_groups[] = { "cim-data-8bit", "cim-data-12bit", };
980static const char *jz4770_lcd_groups[] = { "lcd-24bit", "lcd-no-pins", };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200981static const char *jz4770_pwm0_groups[] = { "pwm0", };
982static const char *jz4770_pwm1_groups[] = { "pwm1", };
983static const char *jz4770_pwm2_groups[] = { "pwm2", };
984static const char *jz4770_pwm3_groups[] = { "pwm3", };
985static const char *jz4770_pwm4_groups[] = { "pwm4", };
986static const char *jz4770_pwm5_groups[] = { "pwm5", };
987static const char *jz4770_pwm6_groups[] = { "pwm6", };
988static const char *jz4770_pwm7_groups[] = { "pwm7", };
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800989static const char *jz4770_mac_groups[] = { "mac-rmii", "mac-mii", };
Paul Cercueilae75b532019-11-19 16:52:11 +0100990static const char *jz4770_otg_groups[] = { "otg-vbus", };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200991
992static const struct function_desc jz4770_functions[] = {
993 { "uart0", jz4770_uart0_groups, ARRAY_SIZE(jz4770_uart0_groups), },
994 { "uart1", jz4770_uart1_groups, ARRAY_SIZE(jz4770_uart1_groups), },
995 { "uart2", jz4770_uart2_groups, ARRAY_SIZE(jz4770_uart2_groups), },
996 { "uart3", jz4770_uart3_groups, ARRAY_SIZE(jz4770_uart3_groups), },
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800997 { "ssi0", jz4770_ssi0_groups, ARRAY_SIZE(jz4770_ssi0_groups), },
998 { "ssi1", jz4770_ssi1_groups, ARRAY_SIZE(jz4770_ssi1_groups), },
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200999 { "mmc0", jz4770_mmc0_groups, ARRAY_SIZE(jz4770_mmc0_groups), },
1000 { "mmc1", jz4770_mmc1_groups, ARRAY_SIZE(jz4770_mmc1_groups), },
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001001 { "mmc2", jz4770_mmc2_groups, ARRAY_SIZE(jz4770_mmc2_groups), },
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02001002 { "nemc", jz4770_nemc_groups, ARRAY_SIZE(jz4770_nemc_groups), },
1003 { "nemc-cs1", jz4770_cs1_groups, ARRAY_SIZE(jz4770_cs1_groups), },
Zhou Yanjieff656e42019-01-28 23:19:57 +08001004 { "nemc-cs2", jz4770_cs2_groups, ARRAY_SIZE(jz4770_cs2_groups), },
1005 { "nemc-cs3", jz4770_cs3_groups, ARRAY_SIZE(jz4770_cs3_groups), },
1006 { "nemc-cs4", jz4770_cs4_groups, ARRAY_SIZE(jz4770_cs4_groups), },
1007 { "nemc-cs5", jz4770_cs5_groups, ARRAY_SIZE(jz4770_cs5_groups), },
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02001008 { "nemc-cs6", jz4770_cs6_groups, ARRAY_SIZE(jz4770_cs6_groups), },
1009 { "i2c0", jz4770_i2c0_groups, ARRAY_SIZE(jz4770_i2c0_groups), },
1010 { "i2c1", jz4770_i2c1_groups, ARRAY_SIZE(jz4770_i2c1_groups), },
1011 { "i2c2", jz4770_i2c2_groups, ARRAY_SIZE(jz4770_i2c2_groups), },
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02001012 { "cim", jz4770_cim_groups, ARRAY_SIZE(jz4770_cim_groups), },
1013 { "lcd", jz4770_lcd_groups, ARRAY_SIZE(jz4770_lcd_groups), },
1014 { "pwm0", jz4770_pwm0_groups, ARRAY_SIZE(jz4770_pwm0_groups), },
1015 { "pwm1", jz4770_pwm1_groups, ARRAY_SIZE(jz4770_pwm1_groups), },
1016 { "pwm2", jz4770_pwm2_groups, ARRAY_SIZE(jz4770_pwm2_groups), },
1017 { "pwm3", jz4770_pwm3_groups, ARRAY_SIZE(jz4770_pwm3_groups), },
1018 { "pwm4", jz4770_pwm4_groups, ARRAY_SIZE(jz4770_pwm4_groups), },
1019 { "pwm5", jz4770_pwm5_groups, ARRAY_SIZE(jz4770_pwm5_groups), },
1020 { "pwm6", jz4770_pwm6_groups, ARRAY_SIZE(jz4770_pwm6_groups), },
1021 { "pwm7", jz4770_pwm7_groups, ARRAY_SIZE(jz4770_pwm7_groups), },
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001022 { "mac", jz4770_mac_groups, ARRAY_SIZE(jz4770_mac_groups), },
Paul Cercueilae75b532019-11-19 16:52:11 +01001023 { "otg", jz4770_otg_groups, ARRAY_SIZE(jz4770_otg_groups), },
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02001024};
1025
1026static const struct ingenic_chip_info jz4770_chip_info = {
1027 .num_chips = 6,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08001028 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +01001029 .version = ID_JZ4770,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02001030 .groups = jz4770_groups,
1031 .num_groups = ARRAY_SIZE(jz4770_groups),
1032 .functions = jz4770_functions,
1033 .num_functions = ARRAY_SIZE(jz4770_functions),
1034 .pull_ups = jz4770_pull_ups,
1035 .pull_downs = jz4770_pull_downs,
1036};
1037
周琰杰 (Zhou Yanjie)d9f5dc42020-09-13 14:58:35 +08001038static const u32 jz4780_pull_ups[6] = {
1039 0x3fffffff, 0xfff0f3fc, 0x0fffffff, 0xffff4fff, 0xfffffb7c, 0x7fa7f00f,
1040};
1041
1042static const u32 jz4780_pull_downs[6] = {
1043 0x00000000, 0x000f0c03, 0x00000000, 0x0000b000, 0x00000483, 0x00580ff0,
1044};
1045
Zhou Yanjieff656e42019-01-28 23:19:57 +08001046static int jz4780_uart2_data_pins[] = { 0x66, 0x67, };
1047static int jz4780_uart2_hwflow_pins[] = { 0x65, 0x64, };
1048static int jz4780_uart4_data_pins[] = { 0x54, 0x4a, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001049static int jz4780_ssi0_dt_a_19_pins[] = { 0x13, };
1050static int jz4780_ssi0_dt_a_21_pins[] = { 0x15, };
1051static int jz4780_ssi0_dt_a_28_pins[] = { 0x1c, };
1052static int jz4780_ssi0_dt_b_pins[] = { 0x3d, };
Paul Cercueilf83c2602020-10-10 21:25:09 +02001053static int jz4780_ssi0_dt_d_pins[] = { 0x79, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001054static int jz4780_ssi0_dr_a_20_pins[] = { 0x14, };
1055static int jz4780_ssi0_dr_a_27_pins[] = { 0x1b, };
1056static int jz4780_ssi0_dr_b_pins[] = { 0x34, };
Paul Cercueilf83c2602020-10-10 21:25:09 +02001057static int jz4780_ssi0_dr_d_pins[] = { 0x74, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001058static int jz4780_ssi0_clk_a_pins[] = { 0x12, };
1059static int jz4780_ssi0_clk_b_5_pins[] = { 0x25, };
1060static int jz4780_ssi0_clk_b_28_pins[] = { 0x3c, };
Paul Cercueilf83c2602020-10-10 21:25:09 +02001061static int jz4780_ssi0_clk_d_pins[] = { 0x78, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001062static int jz4780_ssi0_gpc_b_pins[] = { 0x3e, };
Paul Cercueilf83c2602020-10-10 21:25:09 +02001063static int jz4780_ssi0_gpc_d_pins[] = { 0x76, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001064static int jz4780_ssi0_ce0_a_23_pins[] = { 0x17, };
1065static int jz4780_ssi0_ce0_a_25_pins[] = { 0x19, };
1066static int jz4780_ssi0_ce0_b_pins[] = { 0x3f, };
Paul Cercueilf83c2602020-10-10 21:25:09 +02001067static int jz4780_ssi0_ce0_d_pins[] = { 0x77, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001068static int jz4780_ssi0_ce1_b_pins[] = { 0x35, };
Paul Cercueilf83c2602020-10-10 21:25:09 +02001069static int jz4780_ssi0_ce1_d_pins[] = { 0x75, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001070static int jz4780_ssi1_dt_b_pins[] = { 0x3d, };
Paul Cercueilf83c2602020-10-10 21:25:09 +02001071static int jz4780_ssi1_dt_d_pins[] = { 0x79, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001072static int jz4780_ssi1_dr_b_pins[] = { 0x34, };
Paul Cercueilf83c2602020-10-10 21:25:09 +02001073static int jz4780_ssi1_dr_d_pins[] = { 0x74, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001074static int jz4780_ssi1_clk_b_pins[] = { 0x3c, };
Paul Cercueilf83c2602020-10-10 21:25:09 +02001075static int jz4780_ssi1_clk_d_pins[] = { 0x78, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001076static int jz4780_ssi1_gpc_b_pins[] = { 0x3e, };
Paul Cercueilf83c2602020-10-10 21:25:09 +02001077static int jz4780_ssi1_gpc_d_pins[] = { 0x76, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001078static int jz4780_ssi1_ce0_b_pins[] = { 0x3f, };
Paul Cercueilf83c2602020-10-10 21:25:09 +02001079static int jz4780_ssi1_ce0_d_pins[] = { 0x77, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001080static int jz4780_ssi1_ce1_b_pins[] = { 0x35, };
Paul Cercueilf83c2602020-10-10 21:25:09 +02001081static int jz4780_ssi1_ce1_d_pins[] = { 0x75, };
Zhou Yanjieff656e42019-01-28 23:19:57 +08001082static int jz4780_mmc0_8bit_a_pins[] = { 0x04, 0x05, 0x06, 0x07, 0x18, };
1083static int jz4780_i2c3_pins[] = { 0x6a, 0x6b, };
1084static int jz4780_i2c4_e_pins[] = { 0x8c, 0x8d, };
1085static int jz4780_i2c4_f_pins[] = { 0xb9, 0xb8, };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001086static int jz4780_i2s_data_tx_pins[] = { 0x87, };
1087static int jz4780_i2s_data_rx_pins[] = { 0x86, };
1088static int jz4780_i2s_clk_txrx_pins[] = { 0x6c, 0x6d, };
1089static int jz4780_i2s_clk_rx_pins[] = { 0x88, 0x89, };
1090static int jz4780_i2s_sysclk_pins[] = { 0x85, };
Paul Boddiea0bb89e2020-02-28 19:19:30 +01001091static int jz4780_hdmi_ddc_pins[] = { 0xb9, 0xb8, };
Zhou Yanjieff656e42019-01-28 23:19:57 +08001092
1093static int jz4780_uart2_data_funcs[] = { 1, 1, };
1094static int jz4780_uart2_hwflow_funcs[] = { 1, 1, };
1095static int jz4780_uart4_data_funcs[] = { 2, 2, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001096static int jz4780_ssi0_dt_a_19_funcs[] = { 2, };
1097static int jz4780_ssi0_dt_a_21_funcs[] = { 2, };
1098static int jz4780_ssi0_dt_a_28_funcs[] = { 2, };
1099static int jz4780_ssi0_dt_b_funcs[] = { 1, };
1100static int jz4780_ssi0_dt_d_funcs[] = { 1, };
1101static int jz4780_ssi0_dr_a_20_funcs[] = { 2, };
1102static int jz4780_ssi0_dr_a_27_funcs[] = { 2, };
1103static int jz4780_ssi0_dr_b_funcs[] = { 1, };
1104static int jz4780_ssi0_dr_d_funcs[] = { 1, };
1105static int jz4780_ssi0_clk_a_funcs[] = { 2, };
1106static int jz4780_ssi0_clk_b_5_funcs[] = { 1, };
1107static int jz4780_ssi0_clk_b_28_funcs[] = { 1, };
1108static int jz4780_ssi0_clk_d_funcs[] = { 1, };
1109static int jz4780_ssi0_gpc_b_funcs[] = { 1, };
1110static int jz4780_ssi0_gpc_d_funcs[] = { 1, };
1111static int jz4780_ssi0_ce0_a_23_funcs[] = { 2, };
1112static int jz4780_ssi0_ce0_a_25_funcs[] = { 2, };
1113static int jz4780_ssi0_ce0_b_funcs[] = { 1, };
1114static int jz4780_ssi0_ce0_d_funcs[] = { 1, };
1115static int jz4780_ssi0_ce1_b_funcs[] = { 1, };
1116static int jz4780_ssi0_ce1_d_funcs[] = { 1, };
1117static int jz4780_ssi1_dt_b_funcs[] = { 2, };
1118static int jz4780_ssi1_dt_d_funcs[] = { 2, };
1119static int jz4780_ssi1_dr_b_funcs[] = { 2, };
1120static int jz4780_ssi1_dr_d_funcs[] = { 2, };
1121static int jz4780_ssi1_clk_b_funcs[] = { 2, };
1122static int jz4780_ssi1_clk_d_funcs[] = { 2, };
1123static int jz4780_ssi1_gpc_b_funcs[] = { 2, };
1124static int jz4780_ssi1_gpc_d_funcs[] = { 2, };
1125static int jz4780_ssi1_ce0_b_funcs[] = { 2, };
1126static int jz4780_ssi1_ce0_d_funcs[] = { 2, };
1127static int jz4780_ssi1_ce1_b_funcs[] = { 2, };
1128static int jz4780_ssi1_ce1_d_funcs[] = { 2, };
Zhou Yanjieff656e42019-01-28 23:19:57 +08001129static int jz4780_mmc0_8bit_a_funcs[] = { 1, 1, 1, 1, 1, };
1130static int jz4780_i2c3_funcs[] = { 1, 1, };
1131static int jz4780_i2c4_e_funcs[] = { 1, 1, };
1132static int jz4780_i2c4_f_funcs[] = { 1, 1, };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001133static int jz4780_i2s_data_tx_funcs[] = { 0, };
1134static int jz4780_i2s_data_rx_funcs[] = { 0, };
1135static int jz4780_i2s_clk_txrx_funcs[] = { 1, 0, };
1136static int jz4780_i2s_clk_rx_funcs[] = { 1, 1, };
1137static int jz4780_i2s_sysclk_funcs[] = { 2, };
Paul Boddiea0bb89e2020-02-28 19:19:30 +01001138static int jz4780_hdmi_ddc_funcs[] = { 0, 0, };
Zhou Yanjieff656e42019-01-28 23:19:57 +08001139
1140static const struct group_desc jz4780_groups[] = {
1141 INGENIC_PIN_GROUP("uart0-data", jz4770_uart0_data),
1142 INGENIC_PIN_GROUP("uart0-hwflow", jz4770_uart0_hwflow),
1143 INGENIC_PIN_GROUP("uart1-data", jz4770_uart1_data),
1144 INGENIC_PIN_GROUP("uart1-hwflow", jz4770_uart1_hwflow),
1145 INGENIC_PIN_GROUP("uart2-data", jz4780_uart2_data),
1146 INGENIC_PIN_GROUP("uart2-hwflow", jz4780_uart2_hwflow),
1147 INGENIC_PIN_GROUP("uart3-data", jz4770_uart3_data),
1148 INGENIC_PIN_GROUP("uart3-hwflow", jz4770_uart3_hwflow),
1149 INGENIC_PIN_GROUP("uart4-data", jz4780_uart4_data),
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001150 INGENIC_PIN_GROUP("ssi0-dt-a-19", jz4780_ssi0_dt_a_19),
1151 INGENIC_PIN_GROUP("ssi0-dt-a-21", jz4780_ssi0_dt_a_21),
1152 INGENIC_PIN_GROUP("ssi0-dt-a-28", jz4780_ssi0_dt_a_28),
1153 INGENIC_PIN_GROUP("ssi0-dt-b", jz4780_ssi0_dt_b),
1154 INGENIC_PIN_GROUP("ssi0-dt-d", jz4780_ssi0_dt_d),
1155 INGENIC_PIN_GROUP("ssi0-dt-e", jz4770_ssi0_dt_e),
1156 INGENIC_PIN_GROUP("ssi0-dr-a-20", jz4780_ssi0_dr_a_20),
1157 INGENIC_PIN_GROUP("ssi0-dr-a-27", jz4780_ssi0_dr_a_27),
1158 INGENIC_PIN_GROUP("ssi0-dr-b", jz4780_ssi0_dr_b),
1159 INGENIC_PIN_GROUP("ssi0-dr-d", jz4780_ssi0_dr_d),
1160 INGENIC_PIN_GROUP("ssi0-dr-e", jz4770_ssi0_dr_e),
1161 INGENIC_PIN_GROUP("ssi0-clk-a", jz4780_ssi0_clk_a),
1162 INGENIC_PIN_GROUP("ssi0-clk-b-5", jz4780_ssi0_clk_b_5),
1163 INGENIC_PIN_GROUP("ssi0-clk-b-28", jz4780_ssi0_clk_b_28),
1164 INGENIC_PIN_GROUP("ssi0-clk-d", jz4780_ssi0_clk_d),
1165 INGENIC_PIN_GROUP("ssi0-clk-e", jz4770_ssi0_clk_e),
1166 INGENIC_PIN_GROUP("ssi0-gpc-b", jz4780_ssi0_gpc_b),
1167 INGENIC_PIN_GROUP("ssi0-gpc-d", jz4780_ssi0_gpc_d),
1168 INGENIC_PIN_GROUP("ssi0-gpc-e", jz4770_ssi0_gpc_e),
1169 INGENIC_PIN_GROUP("ssi0-ce0-a-23", jz4780_ssi0_ce0_a_23),
1170 INGENIC_PIN_GROUP("ssi0-ce0-a-25", jz4780_ssi0_ce0_a_25),
1171 INGENIC_PIN_GROUP("ssi0-ce0-b", jz4780_ssi0_ce0_b),
1172 INGENIC_PIN_GROUP("ssi0-ce0-d", jz4780_ssi0_ce0_d),
1173 INGENIC_PIN_GROUP("ssi0-ce0-e", jz4770_ssi0_ce0_e),
1174 INGENIC_PIN_GROUP("ssi0-ce1-b", jz4780_ssi0_ce1_b),
1175 INGENIC_PIN_GROUP("ssi0-ce1-d", jz4780_ssi0_ce1_d),
1176 INGENIC_PIN_GROUP("ssi0-ce1-e", jz4770_ssi0_ce1_e),
1177 INGENIC_PIN_GROUP("ssi1-dt-b", jz4780_ssi1_dt_b),
1178 INGENIC_PIN_GROUP("ssi1-dt-d", jz4780_ssi1_dt_d),
1179 INGENIC_PIN_GROUP("ssi1-dt-e", jz4770_ssi1_dt_e),
1180 INGENIC_PIN_GROUP("ssi1-dr-b", jz4780_ssi1_dr_b),
1181 INGENIC_PIN_GROUP("ssi1-dr-d", jz4780_ssi1_dr_d),
1182 INGENIC_PIN_GROUP("ssi1-dr-e", jz4770_ssi1_dr_e),
1183 INGENIC_PIN_GROUP("ssi1-clk-b", jz4780_ssi1_clk_b),
1184 INGENIC_PIN_GROUP("ssi1-clk-d", jz4780_ssi1_clk_d),
1185 INGENIC_PIN_GROUP("ssi1-clk-e", jz4770_ssi1_clk_e),
1186 INGENIC_PIN_GROUP("ssi1-gpc-b", jz4780_ssi1_gpc_b),
1187 INGENIC_PIN_GROUP("ssi1-gpc-d", jz4780_ssi1_gpc_d),
1188 INGENIC_PIN_GROUP("ssi1-gpc-e", jz4770_ssi1_gpc_e),
1189 INGENIC_PIN_GROUP("ssi1-ce0-b", jz4780_ssi1_ce0_b),
1190 INGENIC_PIN_GROUP("ssi1-ce0-d", jz4780_ssi1_ce0_d),
1191 INGENIC_PIN_GROUP("ssi1-ce0-e", jz4770_ssi1_ce0_e),
1192 INGENIC_PIN_GROUP("ssi1-ce1-b", jz4780_ssi1_ce1_b),
1193 INGENIC_PIN_GROUP("ssi1-ce1-d", jz4780_ssi1_ce1_d),
1194 INGENIC_PIN_GROUP("ssi1-ce1-e", jz4770_ssi1_ce1_e),
Zhou Yanjieff656e42019-01-28 23:19:57 +08001195 INGENIC_PIN_GROUP("mmc0-1bit-a", jz4770_mmc0_1bit_a),
1196 INGENIC_PIN_GROUP("mmc0-4bit-a", jz4770_mmc0_4bit_a),
1197 INGENIC_PIN_GROUP("mmc0-8bit-a", jz4780_mmc0_8bit_a),
1198 INGENIC_PIN_GROUP("mmc0-1bit-e", jz4770_mmc0_1bit_e),
1199 INGENIC_PIN_GROUP("mmc0-4bit-e", jz4770_mmc0_4bit_e),
1200 INGENIC_PIN_GROUP("mmc1-1bit-d", jz4770_mmc1_1bit_d),
1201 INGENIC_PIN_GROUP("mmc1-4bit-d", jz4770_mmc1_4bit_d),
1202 INGENIC_PIN_GROUP("mmc1-1bit-e", jz4770_mmc1_1bit_e),
1203 INGENIC_PIN_GROUP("mmc1-4bit-e", jz4770_mmc1_4bit_e),
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001204 INGENIC_PIN_GROUP("mmc2-1bit-b", jz4770_mmc2_1bit_b),
1205 INGENIC_PIN_GROUP("mmc2-4bit-b", jz4770_mmc2_4bit_b),
1206 INGENIC_PIN_GROUP("mmc2-1bit-e", jz4770_mmc2_1bit_e),
1207 INGENIC_PIN_GROUP("mmc2-4bit-e", jz4770_mmc2_4bit_e),
Zhou Yanjieff656e42019-01-28 23:19:57 +08001208 INGENIC_PIN_GROUP("nemc-data", jz4770_nemc_8bit_data),
1209 INGENIC_PIN_GROUP("nemc-cle-ale", jz4770_nemc_cle_ale),
1210 INGENIC_PIN_GROUP("nemc-addr", jz4770_nemc_addr),
1211 INGENIC_PIN_GROUP("nemc-rd-we", jz4770_nemc_rd_we),
1212 INGENIC_PIN_GROUP("nemc-frd-fwe", jz4770_nemc_frd_fwe),
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001213 INGENIC_PIN_GROUP("nemc-wait", jz4770_nemc_wait),
Zhou Yanjieff656e42019-01-28 23:19:57 +08001214 INGENIC_PIN_GROUP("nemc-cs1", jz4770_nemc_cs1),
1215 INGENIC_PIN_GROUP("nemc-cs2", jz4770_nemc_cs2),
1216 INGENIC_PIN_GROUP("nemc-cs3", jz4770_nemc_cs3),
1217 INGENIC_PIN_GROUP("nemc-cs4", jz4770_nemc_cs4),
1218 INGENIC_PIN_GROUP("nemc-cs5", jz4770_nemc_cs5),
1219 INGENIC_PIN_GROUP("nemc-cs6", jz4770_nemc_cs6),
1220 INGENIC_PIN_GROUP("i2c0-data", jz4770_i2c0),
1221 INGENIC_PIN_GROUP("i2c1-data", jz4770_i2c1),
1222 INGENIC_PIN_GROUP("i2c2-data", jz4770_i2c2),
1223 INGENIC_PIN_GROUP("i2c3-data", jz4780_i2c3),
1224 INGENIC_PIN_GROUP("i2c4-data-e", jz4780_i2c4_e),
1225 INGENIC_PIN_GROUP("i2c4-data-f", jz4780_i2c4_f),
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001226 INGENIC_PIN_GROUP("i2s-data-tx", jz4780_i2s_data_tx),
1227 INGENIC_PIN_GROUP("i2s-data-rx", jz4780_i2s_data_rx),
1228 INGENIC_PIN_GROUP("i2s-clk-txrx", jz4780_i2s_clk_txrx),
1229 INGENIC_PIN_GROUP("i2s-clk-rx", jz4780_i2s_clk_rx),
1230 INGENIC_PIN_GROUP("i2s-sysclk", jz4780_i2s_sysclk),
Paul Boddiea0bb89e2020-02-28 19:19:30 +01001231 INGENIC_PIN_GROUP("hdmi-ddc", jz4780_hdmi_ddc),
Zhou Yanjieff656e42019-01-28 23:19:57 +08001232 INGENIC_PIN_GROUP("cim-data", jz4770_cim_8bit),
1233 INGENIC_PIN_GROUP("lcd-24bit", jz4770_lcd_24bit),
1234 { "lcd-no-pins", },
1235 INGENIC_PIN_GROUP("pwm0", jz4770_pwm_pwm0),
1236 INGENIC_PIN_GROUP("pwm1", jz4770_pwm_pwm1),
1237 INGENIC_PIN_GROUP("pwm2", jz4770_pwm_pwm2),
1238 INGENIC_PIN_GROUP("pwm3", jz4770_pwm_pwm3),
1239 INGENIC_PIN_GROUP("pwm4", jz4770_pwm_pwm4),
1240 INGENIC_PIN_GROUP("pwm5", jz4770_pwm_pwm5),
1241 INGENIC_PIN_GROUP("pwm6", jz4770_pwm_pwm6),
1242 INGENIC_PIN_GROUP("pwm7", jz4770_pwm_pwm7),
1243};
1244
1245static const char *jz4780_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
1246static const char *jz4780_uart4_groups[] = { "uart4-data", };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001247static const char *jz4780_ssi0_groups[] = {
1248 "ssi0-dt-a-19", "ssi0-dt-a-21", "ssi0-dt-a-28", "ssi0-dt-b", "ssi0-dt-d", "ssi0-dt-e",
1249 "ssi0-dr-a-20", "ssi0-dr-a-27", "ssi0-dr-b", "ssi0-dr-d", "ssi0-dr-e",
1250 "ssi0-clk-a", "ssi0-clk-b-5", "ssi0-clk-b-28", "ssi0-clk-d", "ssi0-clk-e",
1251 "ssi0-gpc-b", "ssi0-gpc-d", "ssi0-gpc-e",
1252 "ssi0-ce0-a-23", "ssi0-ce0-a-25", "ssi0-ce0-b", "ssi0-ce0-d", "ssi0-ce0-e",
1253 "ssi0-ce1-b", "ssi0-ce1-d", "ssi0-ce1-e",
1254};
1255static const char *jz4780_ssi1_groups[] = {
1256 "ssi1-dt-b", "ssi1-dt-d", "ssi1-dt-e",
1257 "ssi1-dr-b", "ssi1-dr-d", "ssi1-dr-e",
1258 "ssi1-clk-b", "ssi1-clk-d", "ssi1-clk-e",
1259 "ssi1-gpc-b", "ssi1-gpc-d", "ssi1-gpc-e",
1260 "ssi1-ce0-b", "ssi1-ce0-d", "ssi1-ce0-e",
1261 "ssi1-ce1-b", "ssi1-ce1-d", "ssi1-ce1-e",
1262};
Zhou Yanjieff656e42019-01-28 23:19:57 +08001263static const char *jz4780_mmc0_groups[] = {
1264 "mmc0-1bit-a", "mmc0-4bit-a", "mmc0-8bit-a",
1265 "mmc0-1bit-e", "mmc0-4bit-e",
1266};
1267static const char *jz4780_mmc1_groups[] = {
1268 "mmc1-1bit-d", "mmc1-4bit-d", "mmc1-1bit-e", "mmc1-4bit-e",
1269};
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001270static const char *jz4780_mmc2_groups[] = {
1271 "mmc2-1bit-b", "mmc2-4bit-b", "mmc2-1bit-e", "mmc2-4bit-e",
1272};
Zhou Yanjieff656e42019-01-28 23:19:57 +08001273static const char *jz4780_nemc_groups[] = {
1274 "nemc-data", "nemc-cle-ale", "nemc-addr",
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001275 "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
Zhou Yanjieff656e42019-01-28 23:19:57 +08001276};
1277static const char *jz4780_i2c3_groups[] = { "i2c3-data", };
1278static const char *jz4780_i2c4_groups[] = { "i2c4-data-e", "i2c4-data-f", };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001279static const char *jz4780_i2s_groups[] = {
1280 "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-clk-rx", "i2s-sysclk",
1281};
Zhou Yanjieff656e42019-01-28 23:19:57 +08001282static const char *jz4780_cim_groups[] = { "cim-data", };
Paul Boddiea0bb89e2020-02-28 19:19:30 +01001283static const char *jz4780_hdmi_ddc_groups[] = { "hdmi-ddc", };
Zhou Yanjieff656e42019-01-28 23:19:57 +08001284
1285static const struct function_desc jz4780_functions[] = {
1286 { "uart0", jz4770_uart0_groups, ARRAY_SIZE(jz4770_uart0_groups), },
1287 { "uart1", jz4770_uart1_groups, ARRAY_SIZE(jz4770_uart1_groups), },
1288 { "uart2", jz4780_uart2_groups, ARRAY_SIZE(jz4780_uart2_groups), },
1289 { "uart3", jz4770_uart3_groups, ARRAY_SIZE(jz4770_uart3_groups), },
1290 { "uart4", jz4780_uart4_groups, ARRAY_SIZE(jz4780_uart4_groups), },
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001291 { "ssi0", jz4780_ssi0_groups, ARRAY_SIZE(jz4780_ssi0_groups), },
1292 { "ssi1", jz4780_ssi1_groups, ARRAY_SIZE(jz4780_ssi1_groups), },
Zhou Yanjieff656e42019-01-28 23:19:57 +08001293 { "mmc0", jz4780_mmc0_groups, ARRAY_SIZE(jz4780_mmc0_groups), },
1294 { "mmc1", jz4780_mmc1_groups, ARRAY_SIZE(jz4780_mmc1_groups), },
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001295 { "mmc2", jz4780_mmc2_groups, ARRAY_SIZE(jz4780_mmc2_groups), },
Zhou Yanjieff656e42019-01-28 23:19:57 +08001296 { "nemc", jz4780_nemc_groups, ARRAY_SIZE(jz4780_nemc_groups), },
1297 { "nemc-cs1", jz4770_cs1_groups, ARRAY_SIZE(jz4770_cs1_groups), },
1298 { "nemc-cs2", jz4770_cs2_groups, ARRAY_SIZE(jz4770_cs2_groups), },
1299 { "nemc-cs3", jz4770_cs3_groups, ARRAY_SIZE(jz4770_cs3_groups), },
1300 { "nemc-cs4", jz4770_cs4_groups, ARRAY_SIZE(jz4770_cs4_groups), },
1301 { "nemc-cs5", jz4770_cs5_groups, ARRAY_SIZE(jz4770_cs5_groups), },
1302 { "nemc-cs6", jz4770_cs6_groups, ARRAY_SIZE(jz4770_cs6_groups), },
1303 { "i2c0", jz4770_i2c0_groups, ARRAY_SIZE(jz4770_i2c0_groups), },
1304 { "i2c1", jz4770_i2c1_groups, ARRAY_SIZE(jz4770_i2c1_groups), },
1305 { "i2c2", jz4770_i2c2_groups, ARRAY_SIZE(jz4770_i2c2_groups), },
1306 { "i2c3", jz4780_i2c3_groups, ARRAY_SIZE(jz4780_i2c3_groups), },
1307 { "i2c4", jz4780_i2c4_groups, ARRAY_SIZE(jz4780_i2c4_groups), },
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001308 { "i2s", jz4780_i2s_groups, ARRAY_SIZE(jz4780_i2s_groups), },
Zhou Yanjieff656e42019-01-28 23:19:57 +08001309 { "cim", jz4780_cim_groups, ARRAY_SIZE(jz4780_cim_groups), },
1310 { "lcd", jz4770_lcd_groups, ARRAY_SIZE(jz4770_lcd_groups), },
1311 { "pwm0", jz4770_pwm0_groups, ARRAY_SIZE(jz4770_pwm0_groups), },
1312 { "pwm1", jz4770_pwm1_groups, ARRAY_SIZE(jz4770_pwm1_groups), },
1313 { "pwm2", jz4770_pwm2_groups, ARRAY_SIZE(jz4770_pwm2_groups), },
1314 { "pwm3", jz4770_pwm3_groups, ARRAY_SIZE(jz4770_pwm3_groups), },
1315 { "pwm4", jz4770_pwm4_groups, ARRAY_SIZE(jz4770_pwm4_groups), },
1316 { "pwm5", jz4770_pwm5_groups, ARRAY_SIZE(jz4770_pwm5_groups), },
1317 { "pwm6", jz4770_pwm6_groups, ARRAY_SIZE(jz4770_pwm6_groups), },
1318 { "pwm7", jz4770_pwm7_groups, ARRAY_SIZE(jz4770_pwm7_groups), },
Paul Boddiea0bb89e2020-02-28 19:19:30 +01001319 { "hdmi-ddc", jz4780_hdmi_ddc_groups,
1320 ARRAY_SIZE(jz4780_hdmi_ddc_groups), },
Zhou Yanjieff656e42019-01-28 23:19:57 +08001321};
1322
1323static const struct ingenic_chip_info jz4780_chip_info = {
1324 .num_chips = 6,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08001325 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +01001326 .version = ID_JZ4780,
Zhou Yanjieff656e42019-01-28 23:19:57 +08001327 .groups = jz4780_groups,
1328 .num_groups = ARRAY_SIZE(jz4780_groups),
1329 .functions = jz4780_functions,
1330 .num_functions = ARRAY_SIZE(jz4780_functions),
周琰杰 (Zhou Yanjie)d9f5dc42020-09-13 14:58:35 +08001331 .pull_ups = jz4780_pull_ups,
1332 .pull_downs = jz4780_pull_downs,
Zhou Yanjieff656e42019-01-28 23:19:57 +08001333};
1334
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001335static const u32 x1000_pull_ups[4] = {
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001336 0xffffffff, 0xfdffffff, 0x0dffffff, 0x0000003f,
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001337};
1338
1339static const u32 x1000_pull_downs[4] = {
1340 0x00000000, 0x02000000, 0x02000000, 0x00000000,
1341};
1342
1343static int x1000_uart0_data_pins[] = { 0x4a, 0x4b, };
1344static int x1000_uart0_hwflow_pins[] = { 0x4c, 0x4d, };
1345static int x1000_uart1_data_a_pins[] = { 0x04, 0x05, };
1346static int x1000_uart1_data_d_pins[] = { 0x62, 0x63, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001347static int x1000_uart1_hwflow_pins[] = { 0x64, 0x65, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001348static int x1000_uart2_data_a_pins[] = { 0x02, 0x03, };
1349static int x1000_uart2_data_d_pins[] = { 0x65, 0x64, };
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001350static int x1000_sfc_pins[] = { 0x1d, 0x1c, 0x1e, 0x1f, 0x1a, 0x1b, };
1351static int x1000_ssi_dt_a_22_pins[] = { 0x16, };
1352static int x1000_ssi_dt_a_29_pins[] = { 0x1d, };
1353static int x1000_ssi_dt_d_pins[] = { 0x62, };
1354static int x1000_ssi_dr_a_23_pins[] = { 0x17, };
1355static int x1000_ssi_dr_a_28_pins[] = { 0x1c, };
1356static int x1000_ssi_dr_d_pins[] = { 0x63, };
1357static int x1000_ssi_clk_a_24_pins[] = { 0x18, };
1358static int x1000_ssi_clk_a_26_pins[] = { 0x1a, };
1359static int x1000_ssi_clk_d_pins[] = { 0x60, };
1360static int x1000_ssi_gpc_a_20_pins[] = { 0x14, };
1361static int x1000_ssi_gpc_a_31_pins[] = { 0x1f, };
1362static int x1000_ssi_ce0_a_25_pins[] = { 0x19, };
1363static int x1000_ssi_ce0_a_27_pins[] = { 0x1b, };
1364static int x1000_ssi_ce0_d_pins[] = { 0x61, };
1365static int x1000_ssi_ce1_a_21_pins[] = { 0x15, };
1366static int x1000_ssi_ce1_a_30_pins[] = { 0x1e, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001367static int x1000_mmc0_1bit_pins[] = { 0x18, 0x19, 0x17, };
1368static int x1000_mmc0_4bit_pins[] = { 0x16, 0x15, 0x14, };
1369static int x1000_mmc0_8bit_pins[] = { 0x13, 0x12, 0x11, 0x10, };
1370static int x1000_mmc1_1bit_pins[] = { 0x40, 0x41, 0x42, };
1371static int x1000_mmc1_4bit_pins[] = { 0x43, 0x44, 0x45, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001372static int x1000_emc_8bit_data_pins[] = {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001373 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1374};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001375static int x1000_emc_16bit_data_pins[] = {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001376 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1377};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001378static int x1000_emc_addr_pins[] = {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001379 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
1380 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
1381};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001382static int x1000_emc_rd_we_pins[] = { 0x30, 0x31, };
1383static int x1000_emc_wait_pins[] = { 0x34, };
1384static int x1000_emc_cs1_pins[] = { 0x32, };
1385static int x1000_emc_cs2_pins[] = { 0x33, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001386static int x1000_i2c0_pins[] = { 0x38, 0x37, };
1387static int x1000_i2c1_a_pins[] = { 0x01, 0x00, };
1388static int x1000_i2c1_c_pins[] = { 0x5b, 0x5a, };
1389static int x1000_i2c2_pins[] = { 0x61, 0x60, };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001390static int x1000_i2s_data_tx_pins[] = { 0x24, };
1391static int x1000_i2s_data_rx_pins[] = { 0x23, };
1392static int x1000_i2s_clk_txrx_pins[] = { 0x21, 0x22, };
1393static int x1000_i2s_sysclk_pins[] = { 0x20, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001394static int x1000_cim_pins[] = {
1395 0x08, 0x09, 0x0a, 0x0b,
1396 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c,
1397};
1398static int x1000_lcd_8bit_pins[] = {
1399 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1400 0x30, 0x31, 0x32, 0x33, 0x34,
1401};
1402static int x1000_lcd_16bit_pins[] = {
1403 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1404};
1405static int x1000_pwm_pwm0_pins[] = { 0x59, };
1406static int x1000_pwm_pwm1_pins[] = { 0x5a, };
1407static int x1000_pwm_pwm2_pins[] = { 0x5b, };
1408static int x1000_pwm_pwm3_pins[] = { 0x26, };
1409static int x1000_pwm_pwm4_pins[] = { 0x58, };
1410static int x1000_mac_pins[] = {
1411 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x26,
1412};
1413
1414static int x1000_uart0_data_funcs[] = { 0, 0, };
1415static int x1000_uart0_hwflow_funcs[] = { 0, 0, };
1416static int x1000_uart1_data_a_funcs[] = { 2, 2, };
1417static int x1000_uart1_data_d_funcs[] = { 1, 1, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001418static int x1000_uart1_hwflow_funcs[] = { 1, 1, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001419static int x1000_uart2_data_a_funcs[] = { 2, 2, };
1420static int x1000_uart2_data_d_funcs[] = { 0, 0, };
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001421static int x1000_sfc_funcs[] = { 1, 1, 1, 1, 1, 1, };
1422static int x1000_ssi_dt_a_22_funcs[] = { 2, };
1423static int x1000_ssi_dt_a_29_funcs[] = { 2, };
1424static int x1000_ssi_dt_d_funcs[] = { 0, };
1425static int x1000_ssi_dr_a_23_funcs[] = { 2, };
1426static int x1000_ssi_dr_a_28_funcs[] = { 2, };
1427static int x1000_ssi_dr_d_funcs[] = { 0, };
1428static int x1000_ssi_clk_a_24_funcs[] = { 2, };
1429static int x1000_ssi_clk_a_26_funcs[] = { 2, };
1430static int x1000_ssi_clk_d_funcs[] = { 0, };
1431static int x1000_ssi_gpc_a_20_funcs[] = { 2, };
1432static int x1000_ssi_gpc_a_31_funcs[] = { 2, };
1433static int x1000_ssi_ce0_a_25_funcs[] = { 2, };
1434static int x1000_ssi_ce0_a_27_funcs[] = { 2, };
1435static int x1000_ssi_ce0_d_funcs[] = { 0, };
1436static int x1000_ssi_ce1_a_21_funcs[] = { 2, };
1437static int x1000_ssi_ce1_a_30_funcs[] = { 2, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001438static int x1000_mmc0_1bit_funcs[] = { 1, 1, 1, };
1439static int x1000_mmc0_4bit_funcs[] = { 1, 1, 1, };
1440static int x1000_mmc0_8bit_funcs[] = { 1, 1, 1, 1, 1, };
1441static int x1000_mmc1_1bit_funcs[] = { 0, 0, 0, };
1442static int x1000_mmc1_4bit_funcs[] = { 0, 0, 0, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001443static int x1000_emc_8bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
1444static int x1000_emc_16bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
1445static int x1000_emc_addr_funcs[] = {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001446 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1447};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001448static int x1000_emc_rd_we_funcs[] = { 0, 0, };
1449static int x1000_emc_wait_funcs[] = { 0, };
1450static int x1000_emc_cs1_funcs[] = { 0, };
1451static int x1000_emc_cs2_funcs[] = { 0, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001452static int x1000_i2c0_funcs[] = { 0, 0, };
1453static int x1000_i2c1_a_funcs[] = { 2, 2, };
1454static int x1000_i2c1_c_funcs[] = { 0, 0, };
1455static int x1000_i2c2_funcs[] = { 1, 1, };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001456static int x1000_i2s_data_tx_funcs[] = { 1, };
1457static int x1000_i2s_data_rx_funcs[] = { 1, };
1458static int x1000_i2s_clk_txrx_funcs[] = { 1, 1, };
1459static int x1000_i2s_sysclk_funcs[] = { 1, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001460static int x1000_cim_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
1461static int x1000_lcd_8bit_funcs[] = {
1462 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1463};
1464static int x1000_lcd_16bit_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, };
1465static int x1000_pwm_pwm0_funcs[] = { 0, };
1466static int x1000_pwm_pwm1_funcs[] = { 1, };
1467static int x1000_pwm_pwm2_funcs[] = { 1, };
1468static int x1000_pwm_pwm3_funcs[] = { 2, };
1469static int x1000_pwm_pwm4_funcs[] = { 0, };
1470static int x1000_mac_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
1471
1472static const struct group_desc x1000_groups[] = {
1473 INGENIC_PIN_GROUP("uart0-data", x1000_uart0_data),
1474 INGENIC_PIN_GROUP("uart0-hwflow", x1000_uart0_hwflow),
1475 INGENIC_PIN_GROUP("uart1-data-a", x1000_uart1_data_a),
1476 INGENIC_PIN_GROUP("uart1-data-d", x1000_uart1_data_d),
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001477 INGENIC_PIN_GROUP("uart1-hwflow", x1000_uart1_hwflow),
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001478 INGENIC_PIN_GROUP("uart2-data-a", x1000_uart2_data_a),
1479 INGENIC_PIN_GROUP("uart2-data-d", x1000_uart2_data_d),
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001480 INGENIC_PIN_GROUP("sfc", x1000_sfc),
1481 INGENIC_PIN_GROUP("ssi-dt-a-22", x1000_ssi_dt_a_22),
1482 INGENIC_PIN_GROUP("ssi-dt-a-29", x1000_ssi_dt_a_29),
1483 INGENIC_PIN_GROUP("ssi-dt-d", x1000_ssi_dt_d),
1484 INGENIC_PIN_GROUP("ssi-dr-a-23", x1000_ssi_dr_a_23),
1485 INGENIC_PIN_GROUP("ssi-dr-a-28", x1000_ssi_dr_a_28),
1486 INGENIC_PIN_GROUP("ssi-dr-d", x1000_ssi_dr_d),
1487 INGENIC_PIN_GROUP("ssi-clk-a-24", x1000_ssi_clk_a_24),
1488 INGENIC_PIN_GROUP("ssi-clk-a-26", x1000_ssi_clk_a_26),
1489 INGENIC_PIN_GROUP("ssi-clk-d", x1000_ssi_clk_d),
1490 INGENIC_PIN_GROUP("ssi-gpc-a-20", x1000_ssi_gpc_a_20),
1491 INGENIC_PIN_GROUP("ssi-gpc-a-31", x1000_ssi_gpc_a_31),
1492 INGENIC_PIN_GROUP("ssi-ce0-a-25", x1000_ssi_ce0_a_25),
1493 INGENIC_PIN_GROUP("ssi-ce0-a-27", x1000_ssi_ce0_a_27),
1494 INGENIC_PIN_GROUP("ssi-ce0-d", x1000_ssi_ce0_d),
1495 INGENIC_PIN_GROUP("ssi-ce1-a-21", x1000_ssi_ce1_a_21),
1496 INGENIC_PIN_GROUP("ssi-ce1-a-30", x1000_ssi_ce1_a_30),
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001497 INGENIC_PIN_GROUP("mmc0-1bit", x1000_mmc0_1bit),
1498 INGENIC_PIN_GROUP("mmc0-4bit", x1000_mmc0_4bit),
1499 INGENIC_PIN_GROUP("mmc0-8bit", x1000_mmc0_8bit),
1500 INGENIC_PIN_GROUP("mmc1-1bit", x1000_mmc1_1bit),
1501 INGENIC_PIN_GROUP("mmc1-4bit", x1000_mmc1_4bit),
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001502 INGENIC_PIN_GROUP("emc-8bit-data", x1000_emc_8bit_data),
1503 INGENIC_PIN_GROUP("emc-16bit-data", x1000_emc_16bit_data),
1504 INGENIC_PIN_GROUP("emc-addr", x1000_emc_addr),
1505 INGENIC_PIN_GROUP("emc-rd-we", x1000_emc_rd_we),
1506 INGENIC_PIN_GROUP("emc-wait", x1000_emc_wait),
1507 INGENIC_PIN_GROUP("emc-cs1", x1000_emc_cs1),
1508 INGENIC_PIN_GROUP("emc-cs2", x1000_emc_cs2),
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001509 INGENIC_PIN_GROUP("i2c0-data", x1000_i2c0),
1510 INGENIC_PIN_GROUP("i2c1-data-a", x1000_i2c1_a),
1511 INGENIC_PIN_GROUP("i2c1-data-c", x1000_i2c1_c),
1512 INGENIC_PIN_GROUP("i2c2-data", x1000_i2c2),
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001513 INGENIC_PIN_GROUP("i2s-data-tx", x1000_i2s_data_tx),
1514 INGENIC_PIN_GROUP("i2s-data-rx", x1000_i2s_data_rx),
1515 INGENIC_PIN_GROUP("i2s-clk-txrx", x1000_i2s_clk_txrx),
1516 INGENIC_PIN_GROUP("i2s-sysclk", x1000_i2s_sysclk),
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001517 INGENIC_PIN_GROUP("cim-data", x1000_cim),
1518 INGENIC_PIN_GROUP("lcd-8bit", x1000_lcd_8bit),
1519 INGENIC_PIN_GROUP("lcd-16bit", x1000_lcd_16bit),
1520 { "lcd-no-pins", },
1521 INGENIC_PIN_GROUP("pwm0", x1000_pwm_pwm0),
1522 INGENIC_PIN_GROUP("pwm1", x1000_pwm_pwm1),
1523 INGENIC_PIN_GROUP("pwm2", x1000_pwm_pwm2),
1524 INGENIC_PIN_GROUP("pwm3", x1000_pwm_pwm3),
1525 INGENIC_PIN_GROUP("pwm4", x1000_pwm_pwm4),
1526 INGENIC_PIN_GROUP("mac", x1000_mac),
1527};
1528
1529static const char *x1000_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1530static const char *x1000_uart1_groups[] = {
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001531 "uart1-data-a", "uart1-data-d", "uart1-hwflow",
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001532};
1533static const char *x1000_uart2_groups[] = { "uart2-data-a", "uart2-data-d", };
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001534static const char *x1000_sfc_groups[] = { "sfc", };
1535static const char *x1000_ssi_groups[] = {
1536 "ssi-dt-a-22", "ssi-dt-a-29", "ssi-dt-d",
1537 "ssi-dr-a-23", "ssi-dr-a-28", "ssi-dr-d",
1538 "ssi-clk-a-24", "ssi-clk-a-26", "ssi-clk-d",
1539 "ssi-gpc-a-20", "ssi-gpc-a-31",
1540 "ssi-ce0-a-25", "ssi-ce0-a-27", "ssi-ce0-d",
1541 "ssi-ce1-a-21", "ssi-ce1-a-30",
1542};
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001543static const char *x1000_mmc0_groups[] = {
1544 "mmc0-1bit", "mmc0-4bit", "mmc0-8bit",
1545};
1546static const char *x1000_mmc1_groups[] = {
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001547 "mmc1-1bit", "mmc1-4bit",
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001548};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001549static const char *x1000_emc_groups[] = {
1550 "emc-8bit-data", "emc-16bit-data",
1551 "emc-addr", "emc-rd-we", "emc-wait",
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001552};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001553static const char *x1000_cs1_groups[] = { "emc-cs1", };
1554static const char *x1000_cs2_groups[] = { "emc-cs2", };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001555static const char *x1000_i2c0_groups[] = { "i2c0-data", };
1556static const char *x1000_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", };
1557static const char *x1000_i2c2_groups[] = { "i2c2-data", };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001558static const char *x1000_i2s_groups[] = {
1559 "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-sysclk",
1560};
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001561static const char *x1000_cim_groups[] = { "cim-data", };
1562static const char *x1000_lcd_groups[] = {
1563 "lcd-8bit", "lcd-16bit", "lcd-no-pins",
1564};
1565static const char *x1000_pwm0_groups[] = { "pwm0", };
1566static const char *x1000_pwm1_groups[] = { "pwm1", };
1567static const char *x1000_pwm2_groups[] = { "pwm2", };
1568static const char *x1000_pwm3_groups[] = { "pwm3", };
1569static const char *x1000_pwm4_groups[] = { "pwm4", };
1570static const char *x1000_mac_groups[] = { "mac", };
1571
1572static const struct function_desc x1000_functions[] = {
1573 { "uart0", x1000_uart0_groups, ARRAY_SIZE(x1000_uart0_groups), },
1574 { "uart1", x1000_uart1_groups, ARRAY_SIZE(x1000_uart1_groups), },
1575 { "uart2", x1000_uart2_groups, ARRAY_SIZE(x1000_uart2_groups), },
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001576 { "sfc", x1000_sfc_groups, ARRAY_SIZE(x1000_sfc_groups), },
1577 { "ssi", x1000_ssi_groups, ARRAY_SIZE(x1000_ssi_groups), },
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001578 { "mmc0", x1000_mmc0_groups, ARRAY_SIZE(x1000_mmc0_groups), },
1579 { "mmc1", x1000_mmc1_groups, ARRAY_SIZE(x1000_mmc1_groups), },
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001580 { "emc", x1000_emc_groups, ARRAY_SIZE(x1000_emc_groups), },
1581 { "emc-cs1", x1000_cs1_groups, ARRAY_SIZE(x1000_cs1_groups), },
1582 { "emc-cs2", x1000_cs2_groups, ARRAY_SIZE(x1000_cs2_groups), },
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001583 { "i2c0", x1000_i2c0_groups, ARRAY_SIZE(x1000_i2c0_groups), },
1584 { "i2c1", x1000_i2c1_groups, ARRAY_SIZE(x1000_i2c1_groups), },
1585 { "i2c2", x1000_i2c2_groups, ARRAY_SIZE(x1000_i2c2_groups), },
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001586 { "i2s", x1000_i2s_groups, ARRAY_SIZE(x1000_i2s_groups), },
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001587 { "cim", x1000_cim_groups, ARRAY_SIZE(x1000_cim_groups), },
1588 { "lcd", x1000_lcd_groups, ARRAY_SIZE(x1000_lcd_groups), },
1589 { "pwm0", x1000_pwm0_groups, ARRAY_SIZE(x1000_pwm0_groups), },
1590 { "pwm1", x1000_pwm1_groups, ARRAY_SIZE(x1000_pwm1_groups), },
1591 { "pwm2", x1000_pwm2_groups, ARRAY_SIZE(x1000_pwm2_groups), },
1592 { "pwm3", x1000_pwm3_groups, ARRAY_SIZE(x1000_pwm3_groups), },
1593 { "pwm4", x1000_pwm4_groups, ARRAY_SIZE(x1000_pwm4_groups), },
1594 { "mac", x1000_mac_groups, ARRAY_SIZE(x1000_mac_groups), },
1595};
1596
1597static const struct ingenic_chip_info x1000_chip_info = {
1598 .num_chips = 4,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08001599 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +01001600 .version = ID_X1000,
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001601 .groups = x1000_groups,
1602 .num_groups = ARRAY_SIZE(x1000_groups),
1603 .functions = x1000_functions,
1604 .num_functions = ARRAY_SIZE(x1000_functions),
1605 .pull_ups = x1000_pull_ups,
1606 .pull_downs = x1000_pull_downs,
1607};
1608
Zhou Yanjie5d215952019-07-14 11:53:56 +08001609static int x1500_uart0_data_pins[] = { 0x4a, 0x4b, };
1610static int x1500_uart0_hwflow_pins[] = { 0x4c, 0x4d, };
1611static int x1500_uart1_data_a_pins[] = { 0x04, 0x05, };
1612static int x1500_uart1_data_d_pins[] = { 0x62, 0x63, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001613static int x1500_uart1_hwflow_pins[] = { 0x64, 0x65, };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001614static int x1500_uart2_data_a_pins[] = { 0x02, 0x03, };
1615static int x1500_uart2_data_d_pins[] = { 0x65, 0x64, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001616static int x1500_mmc_1bit_pins[] = { 0x18, 0x19, 0x17, };
1617static int x1500_mmc_4bit_pins[] = { 0x16, 0x15, 0x14, };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001618static int x1500_i2c0_pins[] = { 0x38, 0x37, };
1619static int x1500_i2c1_a_pins[] = { 0x01, 0x00, };
1620static int x1500_i2c1_c_pins[] = { 0x5b, 0x5a, };
1621static int x1500_i2c2_pins[] = { 0x61, 0x60, };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001622static int x1500_i2s_data_tx_pins[] = { 0x24, };
1623static int x1500_i2s_data_rx_pins[] = { 0x23, };
1624static int x1500_i2s_clk_txrx_pins[] = { 0x21, 0x22, };
1625static int x1500_i2s_sysclk_pins[] = { 0x20, };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001626static int x1500_cim_pins[] = {
1627 0x08, 0x09, 0x0a, 0x0b,
1628 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c,
1629};
1630static int x1500_pwm_pwm0_pins[] = { 0x59, };
1631static int x1500_pwm_pwm1_pins[] = { 0x5a, };
1632static int x1500_pwm_pwm2_pins[] = { 0x5b, };
1633static int x1500_pwm_pwm3_pins[] = { 0x26, };
1634static int x1500_pwm_pwm4_pins[] = { 0x58, };
1635
1636static int x1500_uart0_data_funcs[] = { 0, 0, };
1637static int x1500_uart0_hwflow_funcs[] = { 0, 0, };
1638static int x1500_uart1_data_a_funcs[] = { 2, 2, };
1639static int x1500_uart1_data_d_funcs[] = { 1, 1, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001640static int x1500_uart1_hwflow_funcs[] = { 1, 1, };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001641static int x1500_uart2_data_a_funcs[] = { 2, 2, };
1642static int x1500_uart2_data_d_funcs[] = { 0, 0, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001643static int x1500_mmc_1bit_funcs[] = { 1, 1, 1, };
1644static int x1500_mmc_4bit_funcs[] = { 1, 1, 1, };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001645static int x1500_i2c0_funcs[] = { 0, 0, };
1646static int x1500_i2c1_a_funcs[] = { 2, 2, };
1647static int x1500_i2c1_c_funcs[] = { 0, 0, };
1648static int x1500_i2c2_funcs[] = { 1, 1, };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001649static int x1500_i2s_data_tx_funcs[] = { 1, };
1650static int x1500_i2s_data_rx_funcs[] = { 1, };
1651static int x1500_i2s_clk_txrx_funcs[] = { 1, 1, };
1652static int x1500_i2s_sysclk_funcs[] = { 1, };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001653static int x1500_cim_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
1654static int x1500_pwm_pwm0_funcs[] = { 0, };
1655static int x1500_pwm_pwm1_funcs[] = { 1, };
1656static int x1500_pwm_pwm2_funcs[] = { 1, };
1657static int x1500_pwm_pwm3_funcs[] = { 2, };
1658static int x1500_pwm_pwm4_funcs[] = { 0, };
1659
1660static const struct group_desc x1500_groups[] = {
1661 INGENIC_PIN_GROUP("uart0-data", x1500_uart0_data),
1662 INGENIC_PIN_GROUP("uart0-hwflow", x1500_uart0_hwflow),
1663 INGENIC_PIN_GROUP("uart1-data-a", x1500_uart1_data_a),
1664 INGENIC_PIN_GROUP("uart1-data-d", x1500_uart1_data_d),
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001665 INGENIC_PIN_GROUP("uart1-hwflow", x1500_uart1_hwflow),
Zhou Yanjie5d215952019-07-14 11:53:56 +08001666 INGENIC_PIN_GROUP("uart2-data-a", x1500_uart2_data_a),
1667 INGENIC_PIN_GROUP("uart2-data-d", x1500_uart2_data_d),
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001668 INGENIC_PIN_GROUP("sfc", x1000_sfc),
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001669 INGENIC_PIN_GROUP("mmc-1bit", x1500_mmc_1bit),
1670 INGENIC_PIN_GROUP("mmc-4bit", x1500_mmc_4bit),
Zhou Yanjie5d215952019-07-14 11:53:56 +08001671 INGENIC_PIN_GROUP("i2c0-data", x1500_i2c0),
1672 INGENIC_PIN_GROUP("i2c1-data-a", x1500_i2c1_a),
1673 INGENIC_PIN_GROUP("i2c1-data-c", x1500_i2c1_c),
1674 INGENIC_PIN_GROUP("i2c2-data", x1500_i2c2),
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001675 INGENIC_PIN_GROUP("i2s-data-tx", x1500_i2s_data_tx),
1676 INGENIC_PIN_GROUP("i2s-data-rx", x1500_i2s_data_rx),
1677 INGENIC_PIN_GROUP("i2s-clk-txrx", x1500_i2s_clk_txrx),
1678 INGENIC_PIN_GROUP("i2s-sysclk", x1500_i2s_sysclk),
Zhou Yanjie5d215952019-07-14 11:53:56 +08001679 INGENIC_PIN_GROUP("cim-data", x1500_cim),
1680 { "lcd-no-pins", },
1681 INGENIC_PIN_GROUP("pwm0", x1500_pwm_pwm0),
1682 INGENIC_PIN_GROUP("pwm1", x1500_pwm_pwm1),
1683 INGENIC_PIN_GROUP("pwm2", x1500_pwm_pwm2),
1684 INGENIC_PIN_GROUP("pwm3", x1500_pwm_pwm3),
1685 INGENIC_PIN_GROUP("pwm4", x1500_pwm_pwm4),
1686};
1687
1688static const char *x1500_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1689static const char *x1500_uart1_groups[] = {
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001690 "uart1-data-a", "uart1-data-d", "uart1-hwflow",
Zhou Yanjie5d215952019-07-14 11:53:56 +08001691};
1692static const char *x1500_uart2_groups[] = { "uart2-data-a", "uart2-data-d", };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001693static const char *x1500_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001694static const char *x1500_i2c0_groups[] = { "i2c0-data", };
1695static const char *x1500_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", };
1696static const char *x1500_i2c2_groups[] = { "i2c2-data", };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001697static const char *x1500_i2s_groups[] = {
1698 "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-sysclk",
1699};
Zhou Yanjie5d215952019-07-14 11:53:56 +08001700static const char *x1500_cim_groups[] = { "cim-data", };
1701static const char *x1500_lcd_groups[] = { "lcd-no-pins", };
1702static const char *x1500_pwm0_groups[] = { "pwm0", };
1703static const char *x1500_pwm1_groups[] = { "pwm1", };
1704static const char *x1500_pwm2_groups[] = { "pwm2", };
1705static const char *x1500_pwm3_groups[] = { "pwm3", };
1706static const char *x1500_pwm4_groups[] = { "pwm4", };
1707
1708static const struct function_desc x1500_functions[] = {
1709 { "uart0", x1500_uart0_groups, ARRAY_SIZE(x1500_uart0_groups), },
1710 { "uart1", x1500_uart1_groups, ARRAY_SIZE(x1500_uart1_groups), },
1711 { "uart2", x1500_uart2_groups, ARRAY_SIZE(x1500_uart2_groups), },
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001712 { "sfc", x1000_sfc_groups, ARRAY_SIZE(x1000_sfc_groups), },
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001713 { "mmc", x1500_mmc_groups, ARRAY_SIZE(x1500_mmc_groups), },
Zhou Yanjie5d215952019-07-14 11:53:56 +08001714 { "i2c0", x1500_i2c0_groups, ARRAY_SIZE(x1500_i2c0_groups), },
1715 { "i2c1", x1500_i2c1_groups, ARRAY_SIZE(x1500_i2c1_groups), },
1716 { "i2c2", x1500_i2c2_groups, ARRAY_SIZE(x1500_i2c2_groups), },
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001717 { "i2s", x1500_i2s_groups, ARRAY_SIZE(x1500_i2s_groups), },
Zhou Yanjie5d215952019-07-14 11:53:56 +08001718 { "cim", x1500_cim_groups, ARRAY_SIZE(x1500_cim_groups), },
1719 { "lcd", x1500_lcd_groups, ARRAY_SIZE(x1500_lcd_groups), },
1720 { "pwm0", x1500_pwm0_groups, ARRAY_SIZE(x1500_pwm0_groups), },
1721 { "pwm1", x1500_pwm1_groups, ARRAY_SIZE(x1500_pwm1_groups), },
1722 { "pwm2", x1500_pwm2_groups, ARRAY_SIZE(x1500_pwm2_groups), },
1723 { "pwm3", x1500_pwm3_groups, ARRAY_SIZE(x1500_pwm3_groups), },
1724 { "pwm4", x1500_pwm4_groups, ARRAY_SIZE(x1500_pwm4_groups), },
1725};
1726
1727static const struct ingenic_chip_info x1500_chip_info = {
1728 .num_chips = 4,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08001729 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +01001730 .version = ID_X1500,
Zhou Yanjie5d215952019-07-14 11:53:56 +08001731 .groups = x1500_groups,
1732 .num_groups = ARRAY_SIZE(x1500_groups),
1733 .functions = x1500_functions,
1734 .num_functions = ARRAY_SIZE(x1500_functions),
1735 .pull_ups = x1000_pull_ups,
1736 .pull_downs = x1000_pull_downs,
1737};
1738
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001739static const u32 x1830_pull_ups[4] = {
1740 0x5fdfffc0, 0xffffefff, 0x1ffffbff, 0x0fcff3fc,
1741};
1742
1743static const u32 x1830_pull_downs[4] = {
1744 0x5fdfffc0, 0xffffefff, 0x1ffffbff, 0x0fcff3fc,
1745};
1746
1747static int x1830_uart0_data_pins[] = { 0x33, 0x36, };
1748static int x1830_uart0_hwflow_pins[] = { 0x34, 0x35, };
1749static int x1830_uart1_data_pins[] = { 0x38, 0x37, };
1750static int x1830_sfc_pins[] = { 0x17, 0x18, 0x1a, 0x19, 0x1b, 0x1c, };
1751static int x1830_ssi0_dt_pins[] = { 0x4c, };
1752static int x1830_ssi0_dr_pins[] = { 0x4b, };
1753static int x1830_ssi0_clk_pins[] = { 0x4f, };
1754static int x1830_ssi0_gpc_pins[] = { 0x4d, };
1755static int x1830_ssi0_ce0_pins[] = { 0x50, };
1756static int x1830_ssi0_ce1_pins[] = { 0x4e, };
1757static int x1830_ssi1_dt_c_pins[] = { 0x53, };
1758static int x1830_ssi1_dr_c_pins[] = { 0x54, };
1759static int x1830_ssi1_clk_c_pins[] = { 0x57, };
1760static int x1830_ssi1_gpc_c_pins[] = { 0x55, };
1761static int x1830_ssi1_ce0_c_pins[] = { 0x58, };
1762static int x1830_ssi1_ce1_c_pins[] = { 0x56, };
1763static int x1830_ssi1_dt_d_pins[] = { 0x62, };
1764static int x1830_ssi1_dr_d_pins[] = { 0x63, };
1765static int x1830_ssi1_clk_d_pins[] = { 0x66, };
1766static int x1830_ssi1_gpc_d_pins[] = { 0x64, };
1767static int x1830_ssi1_ce0_d_pins[] = { 0x67, };
1768static int x1830_ssi1_ce1_d_pins[] = { 0x65, };
1769static int x1830_mmc0_1bit_pins[] = { 0x24, 0x25, 0x20, };
1770static int x1830_mmc0_4bit_pins[] = { 0x21, 0x22, 0x23, };
1771static int x1830_mmc1_1bit_pins[] = { 0x42, 0x43, 0x44, };
1772static int x1830_mmc1_4bit_pins[] = { 0x45, 0x46, 0x47, };
1773static int x1830_i2c0_pins[] = { 0x0c, 0x0d, };
1774static int x1830_i2c1_pins[] = { 0x39, 0x3a, };
1775static int x1830_i2c2_pins[] = { 0x5b, 0x5c, };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001776static int x1830_i2s_data_tx_pins[] = { 0x53, };
1777static int x1830_i2s_data_rx_pins[] = { 0x54, };
1778static int x1830_i2s_clk_txrx_pins[] = { 0x58, 0x52, };
1779static int x1830_i2s_clk_rx_pins[] = { 0x56, 0x55, };
1780static int x1830_i2s_sysclk_pins[] = { 0x57, };
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001781static int x1830_lcd_rgb_18bit_pins[] = {
1782 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
1783 0x68, 0x69, 0x6c, 0x6d, 0x6e, 0x6f,
1784 0x70, 0x71, 0x72, 0x73, 0x76, 0x77,
1785 0x78, 0x79, 0x7a, 0x7b,
1786};
1787static int x1830_lcd_slcd_8bit_pins[] = {
1788 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x6c, 0x6d,
1789 0x69, 0x72, 0x73, 0x7b, 0x7a,
1790};
1791static int x1830_lcd_slcd_16bit_pins[] = {
1792 0x6e, 0x6f, 0x70, 0x71, 0x76, 0x77, 0x78, 0x79,
1793};
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001794static int x1830_pwm_pwm0_b_pins[] = { 0x31, };
1795static int x1830_pwm_pwm0_c_pins[] = { 0x4b, };
1796static int x1830_pwm_pwm1_b_pins[] = { 0x32, };
1797static int x1830_pwm_pwm1_c_pins[] = { 0x4c, };
1798static int x1830_pwm_pwm2_c_8_pins[] = { 0x48, };
1799static int x1830_pwm_pwm2_c_13_pins[] = { 0x4d, };
1800static int x1830_pwm_pwm3_c_9_pins[] = { 0x49, };
1801static int x1830_pwm_pwm3_c_14_pins[] = { 0x4e, };
1802static int x1830_pwm_pwm4_c_15_pins[] = { 0x4f, };
1803static int x1830_pwm_pwm4_c_25_pins[] = { 0x59, };
1804static int x1830_pwm_pwm5_c_16_pins[] = { 0x50, };
1805static int x1830_pwm_pwm5_c_26_pins[] = { 0x5a, };
1806static int x1830_pwm_pwm6_c_17_pins[] = { 0x51, };
1807static int x1830_pwm_pwm6_c_27_pins[] = { 0x5b, };
1808static int x1830_pwm_pwm7_c_18_pins[] = { 0x52, };
1809static int x1830_pwm_pwm7_c_28_pins[] = { 0x5c, };
1810static int x1830_mac_pins[] = {
1811 0x29, 0x30, 0x2f, 0x28, 0x2e, 0x2d, 0x2a, 0x2b, 0x26, 0x27,
1812};
1813
1814static int x1830_uart0_data_funcs[] = { 0, 0, };
1815static int x1830_uart0_hwflow_funcs[] = { 0, 0, };
1816static int x1830_uart1_data_funcs[] = { 0, 0, };
1817static int x1830_sfc_funcs[] = { 1, 1, 1, 1, 1, 1, };
1818static int x1830_ssi0_dt_funcs[] = { 0, };
1819static int x1830_ssi0_dr_funcs[] = { 0, };
1820static int x1830_ssi0_clk_funcs[] = { 0, };
1821static int x1830_ssi0_gpc_funcs[] = { 0, };
1822static int x1830_ssi0_ce0_funcs[] = { 0, };
1823static int x1830_ssi0_ce1_funcs[] = { 0, };
1824static int x1830_ssi1_dt_c_funcs[] = { 1, };
1825static int x1830_ssi1_dr_c_funcs[] = { 1, };
1826static int x1830_ssi1_clk_c_funcs[] = { 1, };
1827static int x1830_ssi1_gpc_c_funcs[] = { 1, };
1828static int x1830_ssi1_ce0_c_funcs[] = { 1, };
1829static int x1830_ssi1_ce1_c_funcs[] = { 1, };
1830static int x1830_ssi1_dt_d_funcs[] = { 2, };
1831static int x1830_ssi1_dr_d_funcs[] = { 2, };
1832static int x1830_ssi1_clk_d_funcs[] = { 2, };
1833static int x1830_ssi1_gpc_d_funcs[] = { 2, };
1834static int x1830_ssi1_ce0_d_funcs[] = { 2, };
1835static int x1830_ssi1_ce1_d_funcs[] = { 2, };
1836static int x1830_mmc0_1bit_funcs[] = { 0, 0, 0, };
1837static int x1830_mmc0_4bit_funcs[] = { 0, 0, 0, };
1838static int x1830_mmc1_1bit_funcs[] = { 0, 0, 0, };
1839static int x1830_mmc1_4bit_funcs[] = { 0, 0, 0, };
1840static int x1830_i2c0_funcs[] = { 1, 1, };
1841static int x1830_i2c1_funcs[] = { 0, 0, };
1842static int x1830_i2c2_funcs[] = { 1, 1, };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001843static int x1830_i2s_data_tx_funcs[] = { 0, };
1844static int x1830_i2s_data_rx_funcs[] = { 0, };
1845static int x1830_i2s_clk_txrx_funcs[] = { 0, 0, };
1846static int x1830_i2s_clk_rx_funcs[] = { 0, 0, };
1847static int x1830_i2s_sysclk_funcs[] = { 0, };
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001848static int x1830_lcd_rgb_18bit_funcs[] = {
1849 0, 0, 0, 0, 0, 0,
1850 0, 0, 0, 0, 0, 0,
1851 0, 0, 0, 0, 0, 0,
1852 0, 0, 0, 0,
1853};
1854static int x1830_lcd_slcd_8bit_funcs[] = {
1855 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1856};
1857static int x1830_lcd_slcd_16bit_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, };
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001858static int x1830_pwm_pwm0_b_funcs[] = { 0, };
1859static int x1830_pwm_pwm0_c_funcs[] = { 1, };
1860static int x1830_pwm_pwm1_b_funcs[] = { 0, };
1861static int x1830_pwm_pwm1_c_funcs[] = { 1, };
1862static int x1830_pwm_pwm2_c_8_funcs[] = { 0, };
1863static int x1830_pwm_pwm2_c_13_funcs[] = { 1, };
1864static int x1830_pwm_pwm3_c_9_funcs[] = { 0, };
1865static int x1830_pwm_pwm3_c_14_funcs[] = { 1, };
1866static int x1830_pwm_pwm4_c_15_funcs[] = { 1, };
1867static int x1830_pwm_pwm4_c_25_funcs[] = { 0, };
1868static int x1830_pwm_pwm5_c_16_funcs[] = { 1, };
1869static int x1830_pwm_pwm5_c_26_funcs[] = { 0, };
1870static int x1830_pwm_pwm6_c_17_funcs[] = { 1, };
1871static int x1830_pwm_pwm6_c_27_funcs[] = { 0, };
1872static int x1830_pwm_pwm7_c_18_funcs[] = { 1, };
1873static int x1830_pwm_pwm7_c_28_funcs[] = { 0, };
1874static int x1830_mac_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
1875
1876static const struct group_desc x1830_groups[] = {
1877 INGENIC_PIN_GROUP("uart0-data", x1830_uart0_data),
1878 INGENIC_PIN_GROUP("uart0-hwflow", x1830_uart0_hwflow),
1879 INGENIC_PIN_GROUP("uart1-data", x1830_uart1_data),
1880 INGENIC_PIN_GROUP("sfc", x1830_sfc),
1881 INGENIC_PIN_GROUP("ssi0-dt", x1830_ssi0_dt),
1882 INGENIC_PIN_GROUP("ssi0-dr", x1830_ssi0_dr),
1883 INGENIC_PIN_GROUP("ssi0-clk", x1830_ssi0_clk),
1884 INGENIC_PIN_GROUP("ssi0-gpc", x1830_ssi0_gpc),
1885 INGENIC_PIN_GROUP("ssi0-ce0", x1830_ssi0_ce0),
1886 INGENIC_PIN_GROUP("ssi0-ce1", x1830_ssi0_ce1),
1887 INGENIC_PIN_GROUP("ssi1-dt-c", x1830_ssi1_dt_c),
1888 INGENIC_PIN_GROUP("ssi1-dr-c", x1830_ssi1_dr_c),
1889 INGENIC_PIN_GROUP("ssi1-clk-c", x1830_ssi1_clk_c),
1890 INGENIC_PIN_GROUP("ssi1-gpc-c", x1830_ssi1_gpc_c),
1891 INGENIC_PIN_GROUP("ssi1-ce0-c", x1830_ssi1_ce0_c),
1892 INGENIC_PIN_GROUP("ssi1-ce1-c", x1830_ssi1_ce1_c),
1893 INGENIC_PIN_GROUP("ssi1-dt-d", x1830_ssi1_dt_d),
1894 INGENIC_PIN_GROUP("ssi1-dr-d", x1830_ssi1_dr_d),
1895 INGENIC_PIN_GROUP("ssi1-clk-d", x1830_ssi1_clk_d),
1896 INGENIC_PIN_GROUP("ssi1-gpc-d", x1830_ssi1_gpc_d),
1897 INGENIC_PIN_GROUP("ssi1-ce0-d", x1830_ssi1_ce0_d),
1898 INGENIC_PIN_GROUP("ssi1-ce1-d", x1830_ssi1_ce1_d),
1899 INGENIC_PIN_GROUP("mmc0-1bit", x1830_mmc0_1bit),
1900 INGENIC_PIN_GROUP("mmc0-4bit", x1830_mmc0_4bit),
1901 INGENIC_PIN_GROUP("mmc1-1bit", x1830_mmc1_1bit),
1902 INGENIC_PIN_GROUP("mmc1-4bit", x1830_mmc1_4bit),
1903 INGENIC_PIN_GROUP("i2c0-data", x1830_i2c0),
1904 INGENIC_PIN_GROUP("i2c1-data", x1830_i2c1),
1905 INGENIC_PIN_GROUP("i2c2-data", x1830_i2c2),
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001906 INGENIC_PIN_GROUP("i2s-data-tx", x1830_i2s_data_tx),
1907 INGENIC_PIN_GROUP("i2s-data-rx", x1830_i2s_data_rx),
1908 INGENIC_PIN_GROUP("i2s-clk-txrx", x1830_i2s_clk_txrx),
1909 INGENIC_PIN_GROUP("i2s-clk-rx", x1830_i2s_clk_rx),
1910 INGENIC_PIN_GROUP("i2s-sysclk", x1830_i2s_sysclk),
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001911 INGENIC_PIN_GROUP("lcd-rgb-18bit", x1830_lcd_rgb_18bit),
1912 INGENIC_PIN_GROUP("lcd-slcd-8bit", x1830_lcd_slcd_8bit),
1913 INGENIC_PIN_GROUP("lcd-slcd-16bit", x1830_lcd_slcd_16bit),
1914 { "lcd-no-pins", },
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001915 INGENIC_PIN_GROUP("pwm0-b", x1830_pwm_pwm0_b),
1916 INGENIC_PIN_GROUP("pwm0-c", x1830_pwm_pwm0_c),
1917 INGENIC_PIN_GROUP("pwm1-b", x1830_pwm_pwm1_b),
1918 INGENIC_PIN_GROUP("pwm1-c", x1830_pwm_pwm1_c),
1919 INGENIC_PIN_GROUP("pwm2-c-8", x1830_pwm_pwm2_c_8),
1920 INGENIC_PIN_GROUP("pwm2-c-13", x1830_pwm_pwm2_c_13),
1921 INGENIC_PIN_GROUP("pwm3-c-9", x1830_pwm_pwm3_c_9),
1922 INGENIC_PIN_GROUP("pwm3-c-14", x1830_pwm_pwm3_c_14),
1923 INGENIC_PIN_GROUP("pwm4-c-15", x1830_pwm_pwm4_c_15),
1924 INGENIC_PIN_GROUP("pwm4-c-25", x1830_pwm_pwm4_c_25),
1925 INGENIC_PIN_GROUP("pwm5-c-16", x1830_pwm_pwm5_c_16),
1926 INGENIC_PIN_GROUP("pwm5-c-26", x1830_pwm_pwm5_c_26),
1927 INGENIC_PIN_GROUP("pwm6-c-17", x1830_pwm_pwm6_c_17),
1928 INGENIC_PIN_GROUP("pwm6-c-27", x1830_pwm_pwm6_c_27),
1929 INGENIC_PIN_GROUP("pwm7-c-18", x1830_pwm_pwm7_c_18),
1930 INGENIC_PIN_GROUP("pwm7-c-28", x1830_pwm_pwm7_c_28),
1931 INGENIC_PIN_GROUP("mac", x1830_mac),
1932};
1933
1934static const char *x1830_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1935static const char *x1830_uart1_groups[] = { "uart1-data", };
1936static const char *x1830_sfc_groups[] = { "sfc", };
1937static const char *x1830_ssi0_groups[] = {
1938 "ssi0-dt", "ssi0-dr", "ssi0-clk", "ssi0-gpc", "ssi0-ce0", "ssi0-ce1",
1939};
1940static const char *x1830_ssi1_groups[] = {
1941 "ssi1-dt-c", "ssi1-dt-d",
1942 "ssi1-dr-c", "ssi1-dr-d",
1943 "ssi1-clk-c", "ssi1-clk-d",
1944 "ssi1-gpc-c", "ssi1-gpc-d",
1945 "ssi1-ce0-c", "ssi1-ce0-d",
1946 "ssi1-ce1-c", "ssi1-ce1-d",
1947};
1948static const char *x1830_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", };
1949static const char *x1830_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
1950static const char *x1830_i2c0_groups[] = { "i2c0-data", };
1951static const char *x1830_i2c1_groups[] = { "i2c1-data", };
1952static const char *x1830_i2c2_groups[] = { "i2c2-data", };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001953static const char *x1830_i2s_groups[] = {
1954 "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-clk-rx", "i2s-sysclk",
1955};
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001956static const char *x1830_lcd_groups[] = {
1957 "lcd-rgb-18bit", "lcd-slcd-8bit", "lcd-slcd-16bit", "lcd-no-pins",
1958};
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001959static const char *x1830_pwm0_groups[] = { "pwm0-b", "pwm0-c", };
1960static const char *x1830_pwm1_groups[] = { "pwm1-b", "pwm1-c", };
1961static const char *x1830_pwm2_groups[] = { "pwm2-c-8", "pwm2-c-13", };
1962static const char *x1830_pwm3_groups[] = { "pwm3-c-9", "pwm3-c-14", };
1963static const char *x1830_pwm4_groups[] = { "pwm4-c-15", "pwm4-c-25", };
1964static const char *x1830_pwm5_groups[] = { "pwm5-c-16", "pwm5-c-26", };
1965static const char *x1830_pwm6_groups[] = { "pwm6-c-17", "pwm6-c-27", };
1966static const char *x1830_pwm7_groups[] = { "pwm7-c-18", "pwm7-c-28", };
1967static const char *x1830_mac_groups[] = { "mac", };
1968
1969static const struct function_desc x1830_functions[] = {
1970 { "uart0", x1830_uart0_groups, ARRAY_SIZE(x1830_uart0_groups), },
1971 { "uart1", x1830_uart1_groups, ARRAY_SIZE(x1830_uart1_groups), },
1972 { "sfc", x1830_sfc_groups, ARRAY_SIZE(x1830_sfc_groups), },
1973 { "ssi0", x1830_ssi0_groups, ARRAY_SIZE(x1830_ssi0_groups), },
1974 { "ssi1", x1830_ssi1_groups, ARRAY_SIZE(x1830_ssi1_groups), },
1975 { "mmc0", x1830_mmc0_groups, ARRAY_SIZE(x1830_mmc0_groups), },
1976 { "mmc1", x1830_mmc1_groups, ARRAY_SIZE(x1830_mmc1_groups), },
1977 { "i2c0", x1830_i2c0_groups, ARRAY_SIZE(x1830_i2c0_groups), },
1978 { "i2c1", x1830_i2c1_groups, ARRAY_SIZE(x1830_i2c1_groups), },
1979 { "i2c2", x1830_i2c2_groups, ARRAY_SIZE(x1830_i2c2_groups), },
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001980 { "i2s", x1830_i2s_groups, ARRAY_SIZE(x1830_i2s_groups), },
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001981 { "lcd", x1830_lcd_groups, ARRAY_SIZE(x1830_lcd_groups), },
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001982 { "pwm0", x1830_pwm0_groups, ARRAY_SIZE(x1830_pwm0_groups), },
1983 { "pwm1", x1830_pwm1_groups, ARRAY_SIZE(x1830_pwm1_groups), },
1984 { "pwm2", x1830_pwm2_groups, ARRAY_SIZE(x1830_pwm2_groups), },
1985 { "pwm3", x1830_pwm3_groups, ARRAY_SIZE(x1830_pwm3_groups), },
1986 { "pwm4", x1830_pwm4_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1987 { "pwm5", x1830_pwm5_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1988 { "pwm6", x1830_pwm6_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1989 { "pwm7", x1830_pwm7_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1990 { "mac", x1830_mac_groups, ARRAY_SIZE(x1830_mac_groups), },
1991};
1992
1993static const struct ingenic_chip_info x1830_chip_info = {
1994 .num_chips = 4,
1995 .reg_offset = 0x1000,
Paul Cercueilbaf15642020-01-07 00:27:08 +01001996 .version = ID_X1830,
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001997 .groups = x1830_groups,
1998 .num_groups = ARRAY_SIZE(x1830_groups),
1999 .functions = x1830_functions,
2000 .num_functions = ARRAY_SIZE(x1830_functions),
2001 .pull_ups = x1830_pull_ups,
2002 .pull_downs = x1830_pull_downs,
2003};
2004
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002005static u32 ingenic_gpio_read_reg(struct ingenic_gpio_chip *jzgc, u8 reg)
Paul Cercueile72394e2018-08-21 18:42:32 +02002006{
2007 unsigned int val;
2008
2009 regmap_read(jzgc->jzpc->map, jzgc->reg_base + reg, &val);
2010
2011 return (u32) val;
2012}
2013
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002014static void ingenic_gpio_set_bit(struct ingenic_gpio_chip *jzgc,
Paul Cercueile72394e2018-08-21 18:42:32 +02002015 u8 reg, u8 offset, bool set)
2016{
2017 if (set)
2018 reg = REG_SET(reg);
2019 else
2020 reg = REG_CLEAR(reg);
2021
2022 regmap_write(jzgc->jzpc->map, jzgc->reg_base + reg, BIT(offset));
2023}
2024
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002025static void ingenic_gpio_shadow_set_bit(struct ingenic_gpio_chip *jzgc,
2026 u8 reg, u8 offset, bool set)
2027{
2028 if (set)
2029 reg = REG_SET(reg);
2030 else
2031 reg = REG_CLEAR(reg);
2032
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002033 regmap_write(jzgc->jzpc->map, REG_PZ_BASE(
2034 jzgc->jzpc->info->reg_offset) + reg, BIT(offset));
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002035}
2036
2037static void ingenic_gpio_shadow_set_bit_load(struct ingenic_gpio_chip *jzgc)
2038{
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002039 regmap_write(jzgc->jzpc->map, REG_PZ_GID2LD(
2040 jzgc->jzpc->info->reg_offset),
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002041 jzgc->gc.base / PINS_PER_GPIO_CHIP);
2042}
2043
Paul Cercueile72394e2018-08-21 18:42:32 +02002044static inline bool ingenic_gpio_get_value(struct ingenic_gpio_chip *jzgc,
2045 u8 offset)
2046{
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002047 unsigned int val = ingenic_gpio_read_reg(jzgc, GPIO_PIN);
Paul Cercueile72394e2018-08-21 18:42:32 +02002048
2049 return !!(val & BIT(offset));
2050}
2051
2052static void ingenic_gpio_set_value(struct ingenic_gpio_chip *jzgc,
2053 u8 offset, int value)
2054{
Paul Cercueilbaf15642020-01-07 00:27:08 +01002055 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002056 ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_PAT0, offset, !!value);
Paul Cercueile72394e2018-08-21 18:42:32 +02002057 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002058 ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, offset, !!value);
Paul Cercueile72394e2018-08-21 18:42:32 +02002059}
2060
2061static void irq_set_type(struct ingenic_gpio_chip *jzgc,
2062 u8 offset, unsigned int type)
2063{
2064 u8 reg1, reg2;
Paul Cercueilf831f932020-01-07 00:27:10 +01002065 bool val1, val2;
2066
2067 switch (type) {
2068 case IRQ_TYPE_EDGE_RISING:
2069 val1 = val2 = true;
2070 break;
2071 case IRQ_TYPE_EDGE_FALLING:
2072 val1 = false;
2073 val2 = true;
2074 break;
2075 case IRQ_TYPE_LEVEL_HIGH:
2076 val1 = true;
2077 val2 = false;
2078 break;
2079 case IRQ_TYPE_LEVEL_LOW:
2080 default:
2081 val1 = val2 = false;
2082 break;
2083 }
Paul Cercueile72394e2018-08-21 18:42:32 +02002084
Paul Cercueilbaf15642020-01-07 00:27:08 +01002085 if (jzgc->jzpc->info->version >= ID_JZ4760) {
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002086 reg1 = JZ4760_GPIO_PAT1;
2087 reg2 = JZ4760_GPIO_PAT0;
Paul Cercueile72394e2018-08-21 18:42:32 +02002088 } else {
2089 reg1 = JZ4740_GPIO_TRIG;
2090 reg2 = JZ4740_GPIO_DIR;
2091 }
2092
Paul Cercueilf831f932020-01-07 00:27:10 +01002093 if (jzgc->jzpc->info->version >= ID_X1000) {
2094 ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, val1);
2095 ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, val2);
2096 ingenic_gpio_shadow_set_bit_load(jzgc);
2097 } else {
2098 ingenic_gpio_set_bit(jzgc, reg2, offset, val1);
2099 ingenic_gpio_set_bit(jzgc, reg1, offset, val2);
Paul Cercueile72394e2018-08-21 18:42:32 +02002100 }
2101}
2102
2103static void ingenic_gpio_irq_mask(struct irq_data *irqd)
2104{
2105 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2106 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2107
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002108 ingenic_gpio_set_bit(jzgc, GPIO_MSK, irqd->hwirq, true);
Paul Cercueile72394e2018-08-21 18:42:32 +02002109}
2110
2111static void ingenic_gpio_irq_unmask(struct irq_data *irqd)
2112{
2113 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2114 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2115
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002116 ingenic_gpio_set_bit(jzgc, GPIO_MSK, irqd->hwirq, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002117}
2118
2119static void ingenic_gpio_irq_enable(struct irq_data *irqd)
2120{
2121 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2122 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2123 int irq = irqd->hwirq;
2124
Paul Cercueilbaf15642020-01-07 00:27:08 +01002125 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002126 ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_INT, irq, true);
Paul Cercueile72394e2018-08-21 18:42:32 +02002127 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002128 ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, true);
Paul Cercueile72394e2018-08-21 18:42:32 +02002129
2130 ingenic_gpio_irq_unmask(irqd);
2131}
2132
2133static void ingenic_gpio_irq_disable(struct irq_data *irqd)
2134{
2135 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2136 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2137 int irq = irqd->hwirq;
2138
2139 ingenic_gpio_irq_mask(irqd);
2140
Paul Cercueilbaf15642020-01-07 00:27:08 +01002141 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002142 ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_INT, irq, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002143 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002144 ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002145}
2146
2147static void ingenic_gpio_irq_ack(struct irq_data *irqd)
2148{
2149 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2150 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2151 int irq = irqd->hwirq;
2152 bool high;
2153
2154 if (irqd_get_trigger_type(irqd) == IRQ_TYPE_EDGE_BOTH) {
2155 /*
2156 * Switch to an interrupt for the opposite edge to the one that
2157 * triggered the interrupt being ACKed.
2158 */
2159 high = ingenic_gpio_get_value(jzgc, irq);
2160 if (high)
Paul Cercueil1c953482020-06-22 23:45:47 +02002161 irq_set_type(jzgc, irq, IRQ_TYPE_LEVEL_LOW);
Paul Cercueile72394e2018-08-21 18:42:32 +02002162 else
Paul Cercueil1c953482020-06-22 23:45:47 +02002163 irq_set_type(jzgc, irq, IRQ_TYPE_LEVEL_HIGH);
Paul Cercueile72394e2018-08-21 18:42:32 +02002164 }
2165
Paul Cercueilbaf15642020-01-07 00:27:08 +01002166 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002167 ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_FLAG, irq, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002168 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002169 ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, irq, true);
Paul Cercueile72394e2018-08-21 18:42:32 +02002170}
2171
2172static int ingenic_gpio_irq_set_type(struct irq_data *irqd, unsigned int type)
2173{
2174 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2175 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2176
2177 switch (type) {
2178 case IRQ_TYPE_EDGE_BOTH:
2179 case IRQ_TYPE_EDGE_RISING:
2180 case IRQ_TYPE_EDGE_FALLING:
2181 irq_set_handler_locked(irqd, handle_edge_irq);
2182 break;
2183 case IRQ_TYPE_LEVEL_HIGH:
2184 case IRQ_TYPE_LEVEL_LOW:
2185 irq_set_handler_locked(irqd, handle_level_irq);
2186 break;
2187 default:
2188 irq_set_handler_locked(irqd, handle_bad_irq);
2189 }
2190
2191 if (type == IRQ_TYPE_EDGE_BOTH) {
2192 /*
2193 * The hardware does not support interrupts on both edges. The
2194 * best we can do is to set up a single-edge interrupt and then
2195 * switch to the opposing edge when ACKing the interrupt.
2196 */
2197 bool high = ingenic_gpio_get_value(jzgc, irqd->hwirq);
2198
Paul Cercueil1c953482020-06-22 23:45:47 +02002199 type = high ? IRQ_TYPE_LEVEL_LOW : IRQ_TYPE_LEVEL_HIGH;
Paul Cercueile72394e2018-08-21 18:42:32 +02002200 }
2201
2202 irq_set_type(jzgc, irqd->hwirq, type);
2203 return 0;
2204}
2205
2206static int ingenic_gpio_irq_set_wake(struct irq_data *irqd, unsigned int on)
2207{
2208 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2209 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2210
2211 return irq_set_irq_wake(jzgc->irq, on);
2212}
2213
2214static void ingenic_gpio_irq_handler(struct irq_desc *desc)
2215{
2216 struct gpio_chip *gc = irq_desc_get_handler_data(desc);
2217 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2218 struct irq_chip *irq_chip = irq_data_get_irq_chip(&desc->irq_data);
2219 unsigned long flag, i;
2220
2221 chained_irq_enter(irq_chip, desc);
2222
Paul Cercueilbaf15642020-01-07 00:27:08 +01002223 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002224 flag = ingenic_gpio_read_reg(jzgc, JZ4760_GPIO_FLAG);
Paul Cercueile72394e2018-08-21 18:42:32 +02002225 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002226 flag = ingenic_gpio_read_reg(jzgc, JZ4740_GPIO_FLAG);
Paul Cercueile72394e2018-08-21 18:42:32 +02002227
2228 for_each_set_bit(i, &flag, 32)
2229 generic_handle_irq(irq_linear_revmap(gc->irq.domain, i));
2230 chained_irq_exit(irq_chip, desc);
2231}
2232
2233static void ingenic_gpio_set(struct gpio_chip *gc,
2234 unsigned int offset, int value)
2235{
2236 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2237
2238 ingenic_gpio_set_value(jzgc, offset, value);
2239}
2240
2241static int ingenic_gpio_get(struct gpio_chip *gc, unsigned int offset)
2242{
2243 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2244
2245 return (int) ingenic_gpio_get_value(jzgc, offset);
2246}
2247
2248static int ingenic_gpio_direction_input(struct gpio_chip *gc,
2249 unsigned int offset)
2250{
2251 return pinctrl_gpio_direction_input(gc->base + offset);
2252}
2253
2254static int ingenic_gpio_direction_output(struct gpio_chip *gc,
2255 unsigned int offset, int value)
2256{
2257 ingenic_gpio_set(gc, offset, value);
2258 return pinctrl_gpio_direction_output(gc->base + offset);
2259}
2260
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002261static inline void ingenic_config_pin(struct ingenic_pinctrl *jzpc,
2262 unsigned int pin, u8 reg, bool set)
2263{
2264 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2265 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2266
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08002267 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002268 (set ? REG_SET(reg) : REG_CLEAR(reg)), BIT(idx));
2269}
2270
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002271static inline void ingenic_shadow_config_pin(struct ingenic_pinctrl *jzpc,
2272 unsigned int pin, u8 reg, bool set)
2273{
2274 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2275
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08002276 regmap_write(jzpc->map, REG_PZ_BASE(jzpc->info->reg_offset) +
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002277 (set ? REG_SET(reg) : REG_CLEAR(reg)), BIT(idx));
2278}
2279
2280static inline void ingenic_shadow_config_pin_load(struct ingenic_pinctrl *jzpc,
2281 unsigned int pin)
2282{
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002283 regmap_write(jzpc->map, REG_PZ_GID2LD(jzpc->info->reg_offset),
2284 pin / PINS_PER_GPIO_CHIP);
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002285}
2286
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002287static inline bool ingenic_get_pin_config(struct ingenic_pinctrl *jzpc,
2288 unsigned int pin, u8 reg)
2289{
2290 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2291 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2292 unsigned int val;
2293
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08002294 regmap_read(jzpc->map, offt * jzpc->info->reg_offset + reg, &val);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002295
2296 return val & BIT(idx);
2297}
2298
Paul Cercueilebd66512018-08-21 18:42:33 +02002299static int ingenic_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
2300{
2301 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2302 struct ingenic_pinctrl *jzpc = jzgc->jzpc;
2303 unsigned int pin = gc->base + offset;
2304
Matti Vaittinen3c827872020-02-14 15:57:12 +02002305 if (jzpc->info->version >= ID_JZ4760) {
Paul Cercueil84e7a942020-06-22 23:45:48 +02002306 if (ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_INT) ||
2307 ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_PAT1))
Matti Vaittinen3c827872020-02-14 15:57:12 +02002308 return GPIO_LINE_DIRECTION_IN;
2309 return GPIO_LINE_DIRECTION_OUT;
2310 }
Paul Cercueilebd66512018-08-21 18:42:33 +02002311
2312 if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_SELECT))
Matti Vaittinen3c827872020-02-14 15:57:12 +02002313 return GPIO_LINE_DIRECTION_IN;
Paul Cercueilebd66512018-08-21 18:42:33 +02002314
Matti Vaittinen3c827872020-02-14 15:57:12 +02002315 if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_DIR))
2316 return GPIO_LINE_DIRECTION_OUT;
2317
2318 return GPIO_LINE_DIRECTION_IN;
Paul Cercueilebd66512018-08-21 18:42:33 +02002319}
2320
Julia Lawall5bf7b842017-08-10 12:06:23 +02002321static const struct pinctrl_ops ingenic_pctlops = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002322 .get_groups_count = pinctrl_generic_get_group_count,
2323 .get_group_name = pinctrl_generic_get_group_name,
2324 .get_group_pins = pinctrl_generic_get_group_pins,
2325 .dt_node_to_map = pinconf_generic_dt_node_to_map_all,
2326 .dt_free_map = pinconf_generic_dt_free_map,
2327};
2328
Paul Cercueil9a0f1342020-05-03 18:45:49 +02002329static int ingenic_gpio_irq_request(struct irq_data *data)
2330{
2331 struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
2332 int ret;
2333
2334 ret = ingenic_gpio_direction_input(gpio_chip, data->hwirq);
2335 if (ret)
2336 return ret;
2337
2338 return gpiochip_reqres_irq(gpio_chip, data->hwirq);
2339}
2340
2341static void ingenic_gpio_irq_release(struct irq_data *data)
2342{
2343 struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
2344
2345 return gpiochip_relres_irq(gpio_chip, data->hwirq);
2346}
2347
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002348static int ingenic_pinmux_set_pin_fn(struct ingenic_pinctrl *jzpc,
2349 int pin, int func)
2350{
2351 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2352 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2353
2354 dev_dbg(jzpc->dev, "set pin P%c%u to function %u\n",
2355 'A' + offt, idx, func);
2356
Paul Cercueilbaf15642020-01-07 00:27:08 +01002357 if (jzpc->info->version >= ID_X1000) {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002358 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
2359 ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, false);
2360 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, func & 0x2);
2361 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, func & 0x1);
2362 ingenic_shadow_config_pin_load(jzpc, pin);
Paul Cercueilbaf15642020-01-07 00:27:08 +01002363 } else if (jzpc->info->version >= ID_JZ4760) {
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002364 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002365 ingenic_config_pin(jzpc, pin, GPIO_MSK, false);
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002366 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, func & 0x2);
2367 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, func & 0x1);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002368 } else {
2369 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, true);
2370 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_TRIG, func & 0x2);
2371 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, func > 0);
2372 }
2373
2374 return 0;
2375}
2376
2377static int ingenic_pinmux_set_mux(struct pinctrl_dev *pctldev,
2378 unsigned int selector, unsigned int group)
2379{
2380 struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2381 struct function_desc *func;
2382 struct group_desc *grp;
2383 unsigned int i;
2384
2385 func = pinmux_generic_get_function(pctldev, selector);
2386 if (!func)
2387 return -EINVAL;
2388
2389 grp = pinctrl_generic_get_group(pctldev, group);
2390 if (!grp)
2391 return -EINVAL;
2392
2393 dev_dbg(pctldev->dev, "enable function %s group %s\n",
2394 func->name, grp->name);
2395
2396 for (i = 0; i < grp->num_pins; i++) {
2397 int *pin_modes = grp->data;
2398
2399 ingenic_pinmux_set_pin_fn(jzpc, grp->pins[i], pin_modes[i]);
2400 }
2401
2402 return 0;
2403}
2404
2405static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
2406 struct pinctrl_gpio_range *range,
2407 unsigned int pin, bool input)
2408{
2409 struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2410 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2411 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2412
2413 dev_dbg(pctldev->dev, "set pin P%c%u to %sput\n",
2414 'A' + offt, idx, input ? "in" : "out");
2415
Paul Cercueilbaf15642020-01-07 00:27:08 +01002416 if (jzpc->info->version >= ID_X1000) {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002417 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
2418 ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, true);
2419 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, input);
2420 ingenic_shadow_config_pin_load(jzpc, pin);
Paul Cercueilbaf15642020-01-07 00:27:08 +01002421 } else if (jzpc->info->version >= ID_JZ4760) {
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002422 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002423 ingenic_config_pin(jzpc, pin, GPIO_MSK, true);
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002424 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, input);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002425 } else {
2426 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, false);
Paul Cercueil0084a782018-06-27 13:49:02 +02002427 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, !input);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002428 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, false);
2429 }
2430
2431 return 0;
2432}
2433
Julia Lawall5bf7b842017-08-10 12:06:23 +02002434static const struct pinmux_ops ingenic_pmxops = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002435 .get_functions_count = pinmux_generic_get_function_count,
2436 .get_function_name = pinmux_generic_get_function_name,
2437 .get_function_groups = pinmux_generic_get_function_groups,
2438 .set_mux = ingenic_pinmux_set_mux,
2439 .gpio_set_direction = ingenic_pinmux_gpio_set_direction,
2440};
2441
2442static int ingenic_pinconf_get(struct pinctrl_dev *pctldev,
2443 unsigned int pin, unsigned long *config)
2444{
2445 struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2446 enum pin_config_param param = pinconf_to_config_param(*config);
2447 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2448 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2449 bool pull;
2450
Paul Cercueilbaf15642020-01-07 00:27:08 +01002451 if (jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002452 pull = !ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_PEN);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002453 else
2454 pull = !ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_PULL_DIS);
2455
2456 switch (param) {
2457 case PIN_CONFIG_BIAS_DISABLE:
2458 if (pull)
2459 return -EINVAL;
2460 break;
2461
2462 case PIN_CONFIG_BIAS_PULL_UP:
2463 if (!pull || !(jzpc->info->pull_ups[offt] & BIT(idx)))
2464 return -EINVAL;
2465 break;
2466
2467 case PIN_CONFIG_BIAS_PULL_DOWN:
2468 if (!pull || !(jzpc->info->pull_downs[offt] & BIT(idx)))
2469 return -EINVAL;
2470 break;
2471
2472 default:
2473 return -ENOTSUPP;
2474 }
2475
2476 *config = pinconf_to_config_packed(param, 1);
2477 return 0;
2478}
2479
2480static void ingenic_set_bias(struct ingenic_pinctrl *jzpc,
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002481 unsigned int pin, unsigned int bias)
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002482{
Paul Cercueilbaf15642020-01-07 00:27:08 +01002483 if (jzpc->info->version >= ID_X1830) {
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002484 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2485 unsigned int half = PINS_PER_GPIO_CHIP / 2;
2486 unsigned int idxh = pin % half * 2;
2487 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2488
2489 if (idx < half) {
2490 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2491 REG_CLEAR(X1830_GPIO_PEL), 3 << idxh);
2492 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2493 REG_SET(X1830_GPIO_PEL), bias << idxh);
2494 } else {
2495 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2496 REG_CLEAR(X1830_GPIO_PEH), 3 << idxh);
2497 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2498 REG_SET(X1830_GPIO_PEH), bias << idxh);
2499 }
2500
Paul Cercueilbaf15642020-01-07 00:27:08 +01002501 } else if (jzpc->info->version >= ID_JZ4760) {
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002502 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PEN, !bias);
2503 } else {
2504 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_PULL_DIS, !bias);
2505 }
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002506}
2507
Paul Cercueil7009d042019-11-19 16:52:10 +01002508static void ingenic_set_output_level(struct ingenic_pinctrl *jzpc,
2509 unsigned int pin, bool high)
2510{
Paul Cercueilbaf15642020-01-07 00:27:08 +01002511 if (jzpc->info->version >= ID_JZ4760)
Paul Cercueil7009d042019-11-19 16:52:10 +01002512 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, high);
2513 else
2514 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DATA, high);
2515}
2516
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002517static int ingenic_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
2518 unsigned long *configs, unsigned int num_configs)
2519{
2520 struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2521 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2522 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
Paul Cercueil7009d042019-11-19 16:52:10 +01002523 unsigned int cfg, arg;
2524 int ret;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002525
2526 for (cfg = 0; cfg < num_configs; cfg++) {
2527 switch (pinconf_to_config_param(configs[cfg])) {
2528 case PIN_CONFIG_BIAS_DISABLE:
2529 case PIN_CONFIG_BIAS_PULL_UP:
2530 case PIN_CONFIG_BIAS_PULL_DOWN:
Paul Cercueil7009d042019-11-19 16:52:10 +01002531 case PIN_CONFIG_OUTPUT:
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002532 continue;
2533 default:
2534 return -ENOTSUPP;
2535 }
2536 }
2537
2538 for (cfg = 0; cfg < num_configs; cfg++) {
Paul Cercueil7009d042019-11-19 16:52:10 +01002539 arg = pinconf_to_config_argument(configs[cfg]);
2540
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002541 switch (pinconf_to_config_param(configs[cfg])) {
2542 case PIN_CONFIG_BIAS_DISABLE:
2543 dev_dbg(jzpc->dev, "disable pull-over for pin P%c%u\n",
2544 'A' + offt, idx);
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002545 ingenic_set_bias(jzpc, pin, GPIO_PULL_DIS);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002546 break;
2547
2548 case PIN_CONFIG_BIAS_PULL_UP:
2549 if (!(jzpc->info->pull_ups[offt] & BIT(idx)))
2550 return -EINVAL;
2551 dev_dbg(jzpc->dev, "set pull-up for pin P%c%u\n",
2552 'A' + offt, idx);
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002553 ingenic_set_bias(jzpc, pin, GPIO_PULL_UP);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002554 break;
2555
2556 case PIN_CONFIG_BIAS_PULL_DOWN:
2557 if (!(jzpc->info->pull_downs[offt] & BIT(idx)))
2558 return -EINVAL;
2559 dev_dbg(jzpc->dev, "set pull-down for pin P%c%u\n",
2560 'A' + offt, idx);
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002561 ingenic_set_bias(jzpc, pin, GPIO_PULL_DOWN);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002562 break;
2563
Paul Cercueil7009d042019-11-19 16:52:10 +01002564 case PIN_CONFIG_OUTPUT:
2565 ret = pinctrl_gpio_direction_output(pin);
2566 if (ret)
2567 return ret;
2568
2569 ingenic_set_output_level(jzpc, pin, arg);
2570 break;
2571
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002572 default:
Josh Poimboeufd6d43a92020-02-20 09:35:09 -06002573 /* unreachable */
2574 break;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002575 }
2576 }
2577
2578 return 0;
2579}
2580
2581static int ingenic_pinconf_group_get(struct pinctrl_dev *pctldev,
2582 unsigned int group, unsigned long *config)
2583{
2584 const unsigned int *pins;
2585 unsigned int i, npins, old = 0;
2586 int ret;
2587
2588 ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
2589 if (ret)
2590 return ret;
2591
2592 for (i = 0; i < npins; i++) {
2593 if (ingenic_pinconf_get(pctldev, pins[i], config))
2594 return -ENOTSUPP;
2595
2596 /* configs do not match between two pins */
2597 if (i && (old != *config))
2598 return -ENOTSUPP;
2599
2600 old = *config;
2601 }
2602
2603 return 0;
2604}
2605
2606static int ingenic_pinconf_group_set(struct pinctrl_dev *pctldev,
2607 unsigned int group, unsigned long *configs,
2608 unsigned int num_configs)
2609{
2610 const unsigned int *pins;
2611 unsigned int i, npins;
2612 int ret;
2613
2614 ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
2615 if (ret)
2616 return ret;
2617
2618 for (i = 0; i < npins; i++) {
2619 ret = ingenic_pinconf_set(pctldev,
2620 pins[i], configs, num_configs);
2621 if (ret)
2622 return ret;
2623 }
2624
2625 return 0;
2626}
2627
Julia Lawall5bf7b842017-08-10 12:06:23 +02002628static const struct pinconf_ops ingenic_confops = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002629 .is_generic = true,
2630 .pin_config_get = ingenic_pinconf_get,
2631 .pin_config_set = ingenic_pinconf_set,
2632 .pin_config_group_get = ingenic_pinconf_group_get,
2633 .pin_config_group_set = ingenic_pinconf_group_set,
2634};
2635
2636static const struct regmap_config ingenic_pinctrl_regmap_config = {
2637 .reg_bits = 32,
2638 .val_bits = 32,
2639 .reg_stride = 4,
2640};
2641
Paul Cercueile72394e2018-08-21 18:42:32 +02002642static const struct of_device_id ingenic_gpio_of_match[] __initconst = {
2643 { .compatible = "ingenic,jz4740-gpio", },
Paul Cercueilb5fc06a2020-06-12 14:06:09 +02002644 { .compatible = "ingenic,jz4725b-gpio", },
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002645 { .compatible = "ingenic,jz4760-gpio", },
Paul Cercueile72394e2018-08-21 18:42:32 +02002646 { .compatible = "ingenic,jz4770-gpio", },
2647 { .compatible = "ingenic,jz4780-gpio", },
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002648 { .compatible = "ingenic,x1000-gpio", },
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002649 { .compatible = "ingenic,x1830-gpio", },
Paul Cercueile72394e2018-08-21 18:42:32 +02002650 {},
2651};
2652
2653static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,
2654 struct device_node *node)
2655{
2656 struct ingenic_gpio_chip *jzgc;
2657 struct device *dev = jzpc->dev;
Linus Walleij142b8762019-10-01 15:32:09 +02002658 struct gpio_irq_chip *girq;
Paul Cercueile72394e2018-08-21 18:42:32 +02002659 unsigned int bank;
2660 int err;
2661
2662 err = of_property_read_u32(node, "reg", &bank);
2663 if (err) {
2664 dev_err(dev, "Cannot read \"reg\" property: %i\n", err);
2665 return err;
2666 }
2667
2668 jzgc = devm_kzalloc(dev, sizeof(*jzgc), GFP_KERNEL);
2669 if (!jzgc)
2670 return -ENOMEM;
2671
2672 jzgc->jzpc = jzpc;
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08002673 jzgc->reg_base = bank * jzpc->info->reg_offset;
Paul Cercueile72394e2018-08-21 18:42:32 +02002674
2675 jzgc->gc.label = devm_kasprintf(dev, GFP_KERNEL, "GPIO%c", 'A' + bank);
2676 if (!jzgc->gc.label)
2677 return -ENOMEM;
2678
2679 /* DO NOT EXPAND THIS: FOR BACKWARD GPIO NUMBERSPACE COMPATIBIBILITY
2680 * ONLY: WORK TO TRANSITION CONSUMERS TO USE THE GPIO DESCRIPTOR API IN
2681 * <linux/gpio/consumer.h> INSTEAD.
2682 */
2683 jzgc->gc.base = bank * 32;
2684
2685 jzgc->gc.ngpio = 32;
2686 jzgc->gc.parent = dev;
2687 jzgc->gc.of_node = node;
2688 jzgc->gc.owner = THIS_MODULE;
2689
2690 jzgc->gc.set = ingenic_gpio_set;
2691 jzgc->gc.get = ingenic_gpio_get;
2692 jzgc->gc.direction_input = ingenic_gpio_direction_input;
2693 jzgc->gc.direction_output = ingenic_gpio_direction_output;
Paul Cercueilebd66512018-08-21 18:42:33 +02002694 jzgc->gc.get_direction = ingenic_gpio_get_direction;
Thierry Redingd6471d62020-04-01 22:05:27 +02002695 jzgc->gc.request = gpiochip_generic_request;
2696 jzgc->gc.free = gpiochip_generic_free;
Paul Cercueile72394e2018-08-21 18:42:32 +02002697
Paul Cercueile72394e2018-08-21 18:42:32 +02002698 jzgc->irq = irq_of_parse_and_map(node, 0);
2699 if (!jzgc->irq)
2700 return -EINVAL;
2701
2702 jzgc->irq_chip.name = jzgc->gc.label;
2703 jzgc->irq_chip.irq_enable = ingenic_gpio_irq_enable;
2704 jzgc->irq_chip.irq_disable = ingenic_gpio_irq_disable;
2705 jzgc->irq_chip.irq_unmask = ingenic_gpio_irq_unmask;
2706 jzgc->irq_chip.irq_mask = ingenic_gpio_irq_mask;
2707 jzgc->irq_chip.irq_ack = ingenic_gpio_irq_ack;
2708 jzgc->irq_chip.irq_set_type = ingenic_gpio_irq_set_type;
2709 jzgc->irq_chip.irq_set_wake = ingenic_gpio_irq_set_wake;
Paul Cercueil9a0f1342020-05-03 18:45:49 +02002710 jzgc->irq_chip.irq_request_resources = ingenic_gpio_irq_request;
2711 jzgc->irq_chip.irq_release_resources = ingenic_gpio_irq_release;
Paul Cercueile72394e2018-08-21 18:42:32 +02002712 jzgc->irq_chip.flags = IRQCHIP_MASK_ON_SUSPEND;
2713
Linus Walleij142b8762019-10-01 15:32:09 +02002714 girq = &jzgc->gc.irq;
2715 girq->chip = &jzgc->irq_chip;
2716 girq->parent_handler = ingenic_gpio_irq_handler;
2717 girq->num_parents = 1;
2718 girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
2719 GFP_KERNEL);
2720 if (!girq->parents)
2721 return -ENOMEM;
2722 girq->parents[0] = jzgc->irq;
2723 girq->default_type = IRQ_TYPE_NONE;
2724 girq->handler = handle_level_irq;
2725
2726 err = devm_gpiochip_add_data(dev, &jzgc->gc, jzgc);
Paul Cercueile72394e2018-08-21 18:42:32 +02002727 if (err)
2728 return err;
2729
Paul Cercueile72394e2018-08-21 18:42:32 +02002730 return 0;
2731}
2732
Paul Cercueil4717b112018-08-21 18:42:31 +02002733static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002734{
2735 struct device *dev = &pdev->dev;
2736 struct ingenic_pinctrl *jzpc;
2737 struct pinctrl_desc *pctl_desc;
2738 void __iomem *base;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002739 const struct ingenic_chip_info *chip_info;
Paul Cercueile72394e2018-08-21 18:42:32 +02002740 struct device_node *node;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002741 unsigned int i;
2742 int err;
2743
2744 jzpc = devm_kzalloc(dev, sizeof(*jzpc), GFP_KERNEL);
2745 if (!jzpc)
2746 return -ENOMEM;
2747
Paul Cercueil94f7a2c2020-01-07 00:27:11 +01002748 base = devm_platform_ioremap_resource(pdev, 0);
Wei Yongjun119fcf42018-01-17 11:29:17 +00002749 if (IS_ERR(base))
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002750 return PTR_ERR(base);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002751
2752 jzpc->map = devm_regmap_init_mmio(dev, base,
2753 &ingenic_pinctrl_regmap_config);
2754 if (IS_ERR(jzpc->map)) {
2755 dev_err(dev, "Failed to create regmap\n");
2756 return PTR_ERR(jzpc->map);
2757 }
2758
2759 jzpc->dev = dev;
Paul Cercueilbaf15642020-01-07 00:27:08 +01002760 jzpc->info = chip_info = of_device_get_match_data(dev);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002761
2762 pctl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctl_desc), GFP_KERNEL);
2763 if (!pctl_desc)
2764 return -ENOMEM;
2765
2766 /* fill in pinctrl_desc structure */
2767 pctl_desc->name = dev_name(dev);
2768 pctl_desc->owner = THIS_MODULE;
2769 pctl_desc->pctlops = &ingenic_pctlops;
2770 pctl_desc->pmxops = &ingenic_pmxops;
2771 pctl_desc->confops = &ingenic_confops;
2772 pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP;
Kees Cooka86854d2018-06-12 14:07:58 -07002773 pctl_desc->pins = jzpc->pdesc = devm_kcalloc(&pdev->dev,
2774 pctl_desc->npins, sizeof(*jzpc->pdesc), GFP_KERNEL);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002775 if (!jzpc->pdesc)
2776 return -ENOMEM;
2777
2778 for (i = 0; i < pctl_desc->npins; i++) {
2779 jzpc->pdesc[i].number = i;
2780 jzpc->pdesc[i].name = kasprintf(GFP_KERNEL, "P%c%d",
2781 'A' + (i / PINS_PER_GPIO_CHIP),
2782 i % PINS_PER_GPIO_CHIP);
2783 }
2784
2785 jzpc->pctl = devm_pinctrl_register(dev, pctl_desc, jzpc);
Dan Carpentere7f4c4b2017-06-14 12:12:09 +03002786 if (IS_ERR(jzpc->pctl)) {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002787 dev_err(dev, "Failed to register pinctrl\n");
Dan Carpentere7f4c4b2017-06-14 12:12:09 +03002788 return PTR_ERR(jzpc->pctl);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002789 }
2790
2791 for (i = 0; i < chip_info->num_groups; i++) {
2792 const struct group_desc *group = &chip_info->groups[i];
2793
2794 err = pinctrl_generic_add_group(jzpc->pctl, group->name,
2795 group->pins, group->num_pins, group->data);
Paul Burton823dd712018-08-25 10:53:28 -07002796 if (err < 0) {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002797 dev_err(dev, "Failed to register group %s\n",
2798 group->name);
2799 return err;
2800 }
2801 }
2802
2803 for (i = 0; i < chip_info->num_functions; i++) {
2804 const struct function_desc *func = &chip_info->functions[i];
2805
2806 err = pinmux_generic_add_function(jzpc->pctl, func->name,
2807 func->group_names, func->num_group_names,
2808 func->data);
Paul Burton823dd712018-08-25 10:53:28 -07002809 if (err < 0) {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002810 dev_err(dev, "Failed to register function %s\n",
2811 func->name);
2812 return err;
2813 }
2814 }
2815
2816 dev_set_drvdata(dev, jzpc->map);
2817
Paul Cercueile72394e2018-08-21 18:42:32 +02002818 for_each_child_of_node(dev->of_node, node) {
2819 if (of_match_node(ingenic_gpio_of_match, node)) {
2820 err = ingenic_gpio_probe(jzpc, node);
2821 if (err)
2822 return err;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002823 }
2824 }
2825
2826 return 0;
2827}
2828
Paul Cercueilbaf15642020-01-07 00:27:08 +01002829static const struct of_device_id ingenic_pinctrl_of_match[] = {
2830 { .compatible = "ingenic,jz4740-pinctrl", .data = &jz4740_chip_info },
2831 { .compatible = "ingenic,jz4725b-pinctrl", .data = &jz4725b_chip_info },
2832 { .compatible = "ingenic,jz4760-pinctrl", .data = &jz4760_chip_info },
Paul Cercueil5ffdbb72020-01-07 00:27:09 +01002833 { .compatible = "ingenic,jz4760b-pinctrl", .data = &jz4760_chip_info },
Paul Cercueilbaf15642020-01-07 00:27:08 +01002834 { .compatible = "ingenic,jz4770-pinctrl", .data = &jz4770_chip_info },
2835 { .compatible = "ingenic,jz4780-pinctrl", .data = &jz4780_chip_info },
2836 { .compatible = "ingenic,x1000-pinctrl", .data = &x1000_chip_info },
Paul Cercueil5ffdbb72020-01-07 00:27:09 +01002837 { .compatible = "ingenic,x1000e-pinctrl", .data = &x1000_chip_info },
Paul Cercueilbaf15642020-01-07 00:27:08 +01002838 { .compatible = "ingenic,x1500-pinctrl", .data = &x1500_chip_info },
2839 { .compatible = "ingenic,x1830-pinctrl", .data = &x1830_chip_info },
2840 {},
2841};
2842
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002843static struct platform_driver ingenic_pinctrl_driver = {
2844 .driver = {
2845 .name = "pinctrl-ingenic",
Paul Cercueil5ec008b2020-01-07 00:27:07 +01002846 .of_match_table = ingenic_pinctrl_of_match,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002847 },
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002848};
2849
2850static int __init ingenic_pinctrl_drv_register(void)
2851{
Paul Cercueil4717b112018-08-21 18:42:31 +02002852 return platform_driver_probe(&ingenic_pinctrl_driver,
2853 ingenic_pinctrl_probe);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002854}
Paul Cercueil556a36a2018-08-21 18:42:30 +02002855subsys_initcall(ingenic_pinctrl_drv_register);