blob: d5ac8489ba3d97f65223ea31a4d550a4256b4f56 [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, };
638static int jz4770_ssi0_dt_d_pins[] = { 0x55, };
639static int jz4770_ssi0_dt_e_pins[] = { 0x71, };
640static int jz4770_ssi0_dr_a_pins[] = { 0x14, };
641static int jz4770_ssi0_dr_b_pins[] = { 0x34, };
642static int jz4770_ssi0_dr_d_pins[] = { 0x54, };
643static int jz4770_ssi0_dr_e_pins[] = { 0x6e, };
644static int jz4770_ssi0_clk_a_pins[] = { 0x12, };
645static int jz4770_ssi0_clk_b_pins[] = { 0x3c, };
646static int jz4770_ssi0_clk_d_pins[] = { 0x58, };
647static int jz4770_ssi0_clk_e_pins[] = { 0x6f, };
648static int jz4770_ssi0_gpc_b_pins[] = { 0x3e, };
649static int jz4770_ssi0_gpc_d_pins[] = { 0x56, };
650static int jz4770_ssi0_gpc_e_pins[] = { 0x73, };
651static int jz4770_ssi0_ce0_a_pins[] = { 0x13, };
652static int jz4770_ssi0_ce0_b_pins[] = { 0x3d, };
653static int jz4770_ssi0_ce0_d_pins[] = { 0x59, };
654static int jz4770_ssi0_ce0_e_pins[] = { 0x70, };
655static int jz4770_ssi0_ce1_b_pins[] = { 0x3f, };
656static int jz4770_ssi0_ce1_d_pins[] = { 0x57, };
657static int jz4770_ssi0_ce1_e_pins[] = { 0x72, };
658static int jz4770_ssi1_dt_b_pins[] = { 0x35, };
659static int jz4770_ssi1_dt_d_pins[] = { 0x55, };
660static int jz4770_ssi1_dt_e_pins[] = { 0x71, };
661static int jz4770_ssi1_dr_b_pins[] = { 0x34, };
662static int jz4770_ssi1_dr_d_pins[] = { 0x54, };
663static int jz4770_ssi1_dr_e_pins[] = { 0x6e, };
664static int jz4770_ssi1_clk_b_pins[] = { 0x3c, };
665static int jz4770_ssi1_clk_d_pins[] = { 0x58, };
666static int jz4770_ssi1_clk_e_pins[] = { 0x6f, };
667static int jz4770_ssi1_gpc_b_pins[] = { 0x3e, };
668static int jz4770_ssi1_gpc_d_pins[] = { 0x56, };
669static int jz4770_ssi1_gpc_e_pins[] = { 0x73, };
670static int jz4770_ssi1_ce0_b_pins[] = { 0x3d, };
671static int jz4770_ssi1_ce0_d_pins[] = { 0x59, };
672static int jz4770_ssi1_ce0_e_pins[] = { 0x70, };
673static int jz4770_ssi1_ce1_b_pins[] = { 0x3f, };
674static int jz4770_ssi1_ce1_d_pins[] = { 0x57, };
675static int jz4770_ssi1_ce1_e_pins[] = { 0x72, };
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, };
1053static int jz4780_ssi0_dt_d_pins[] = { 0x59, };
1054static 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, };
1057static int jz4780_ssi0_dr_d_pins[] = { 0x54, };
1058static 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, };
1061static int jz4780_ssi0_clk_d_pins[] = { 0x58, };
1062static int jz4780_ssi0_gpc_b_pins[] = { 0x3e, };
1063static int jz4780_ssi0_gpc_d_pins[] = { 0x56, };
1064static 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, };
1067static int jz4780_ssi0_ce0_d_pins[] = { 0x57, };
1068static int jz4780_ssi0_ce1_b_pins[] = { 0x35, };
1069static int jz4780_ssi0_ce1_d_pins[] = { 0x55, };
1070static int jz4780_ssi1_dt_b_pins[] = { 0x3d, };
1071static int jz4780_ssi1_dt_d_pins[] = { 0x59, };
1072static int jz4780_ssi1_dr_b_pins[] = { 0x34, };
1073static int jz4780_ssi1_dr_d_pins[] = { 0x54, };
1074static int jz4780_ssi1_clk_b_pins[] = { 0x3c, };
1075static int jz4780_ssi1_clk_d_pins[] = { 0x58, };
1076static int jz4780_ssi1_gpc_b_pins[] = { 0x3e, };
1077static int jz4780_ssi1_gpc_d_pins[] = { 0x56, };
1078static int jz4780_ssi1_ce0_b_pins[] = { 0x3f, };
1079static int jz4780_ssi1_ce0_d_pins[] = { 0x57, };
1080static int jz4780_ssi1_ce1_b_pins[] = { 0x35, };
1081static int jz4780_ssi1_ce1_d_pins[] = { 0x55, };
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, };
Paul Boddiea0bb89e2020-02-28 19:19:30 +01001086static int jz4780_hdmi_ddc_pins[] = { 0xb9, 0xb8, };
Zhou Yanjieff656e42019-01-28 23:19:57 +08001087
1088static int jz4780_uart2_data_funcs[] = { 1, 1, };
1089static int jz4780_uart2_hwflow_funcs[] = { 1, 1, };
1090static int jz4780_uart4_data_funcs[] = { 2, 2, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001091static int jz4780_ssi0_dt_a_19_funcs[] = { 2, };
1092static int jz4780_ssi0_dt_a_21_funcs[] = { 2, };
1093static int jz4780_ssi0_dt_a_28_funcs[] = { 2, };
1094static int jz4780_ssi0_dt_b_funcs[] = { 1, };
1095static int jz4780_ssi0_dt_d_funcs[] = { 1, };
1096static int jz4780_ssi0_dr_a_20_funcs[] = { 2, };
1097static int jz4780_ssi0_dr_a_27_funcs[] = { 2, };
1098static int jz4780_ssi0_dr_b_funcs[] = { 1, };
1099static int jz4780_ssi0_dr_d_funcs[] = { 1, };
1100static int jz4780_ssi0_clk_a_funcs[] = { 2, };
1101static int jz4780_ssi0_clk_b_5_funcs[] = { 1, };
1102static int jz4780_ssi0_clk_b_28_funcs[] = { 1, };
1103static int jz4780_ssi0_clk_d_funcs[] = { 1, };
1104static int jz4780_ssi0_gpc_b_funcs[] = { 1, };
1105static int jz4780_ssi0_gpc_d_funcs[] = { 1, };
1106static int jz4780_ssi0_ce0_a_23_funcs[] = { 2, };
1107static int jz4780_ssi0_ce0_a_25_funcs[] = { 2, };
1108static int jz4780_ssi0_ce0_b_funcs[] = { 1, };
1109static int jz4780_ssi0_ce0_d_funcs[] = { 1, };
1110static int jz4780_ssi0_ce1_b_funcs[] = { 1, };
1111static int jz4780_ssi0_ce1_d_funcs[] = { 1, };
1112static int jz4780_ssi1_dt_b_funcs[] = { 2, };
1113static int jz4780_ssi1_dt_d_funcs[] = { 2, };
1114static int jz4780_ssi1_dr_b_funcs[] = { 2, };
1115static int jz4780_ssi1_dr_d_funcs[] = { 2, };
1116static int jz4780_ssi1_clk_b_funcs[] = { 2, };
1117static int jz4780_ssi1_clk_d_funcs[] = { 2, };
1118static int jz4780_ssi1_gpc_b_funcs[] = { 2, };
1119static int jz4780_ssi1_gpc_d_funcs[] = { 2, };
1120static int jz4780_ssi1_ce0_b_funcs[] = { 2, };
1121static int jz4780_ssi1_ce0_d_funcs[] = { 2, };
1122static int jz4780_ssi1_ce1_b_funcs[] = { 2, };
1123static int jz4780_ssi1_ce1_d_funcs[] = { 2, };
Zhou Yanjieff656e42019-01-28 23:19:57 +08001124static int jz4780_mmc0_8bit_a_funcs[] = { 1, 1, 1, 1, 1, };
1125static int jz4780_i2c3_funcs[] = { 1, 1, };
1126static int jz4780_i2c4_e_funcs[] = { 1, 1, };
1127static int jz4780_i2c4_f_funcs[] = { 1, 1, };
Paul Boddiea0bb89e2020-02-28 19:19:30 +01001128static int jz4780_hdmi_ddc_funcs[] = { 0, 0, };
Zhou Yanjieff656e42019-01-28 23:19:57 +08001129
1130static const struct group_desc jz4780_groups[] = {
1131 INGENIC_PIN_GROUP("uart0-data", jz4770_uart0_data),
1132 INGENIC_PIN_GROUP("uart0-hwflow", jz4770_uart0_hwflow),
1133 INGENIC_PIN_GROUP("uart1-data", jz4770_uart1_data),
1134 INGENIC_PIN_GROUP("uart1-hwflow", jz4770_uart1_hwflow),
1135 INGENIC_PIN_GROUP("uart2-data", jz4780_uart2_data),
1136 INGENIC_PIN_GROUP("uart2-hwflow", jz4780_uart2_hwflow),
1137 INGENIC_PIN_GROUP("uart3-data", jz4770_uart3_data),
1138 INGENIC_PIN_GROUP("uart3-hwflow", jz4770_uart3_hwflow),
1139 INGENIC_PIN_GROUP("uart4-data", jz4780_uart4_data),
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001140 INGENIC_PIN_GROUP("ssi0-dt-a-19", jz4780_ssi0_dt_a_19),
1141 INGENIC_PIN_GROUP("ssi0-dt-a-21", jz4780_ssi0_dt_a_21),
1142 INGENIC_PIN_GROUP("ssi0-dt-a-28", jz4780_ssi0_dt_a_28),
1143 INGENIC_PIN_GROUP("ssi0-dt-b", jz4780_ssi0_dt_b),
1144 INGENIC_PIN_GROUP("ssi0-dt-d", jz4780_ssi0_dt_d),
1145 INGENIC_PIN_GROUP("ssi0-dt-e", jz4770_ssi0_dt_e),
1146 INGENIC_PIN_GROUP("ssi0-dr-a-20", jz4780_ssi0_dr_a_20),
1147 INGENIC_PIN_GROUP("ssi0-dr-a-27", jz4780_ssi0_dr_a_27),
1148 INGENIC_PIN_GROUP("ssi0-dr-b", jz4780_ssi0_dr_b),
1149 INGENIC_PIN_GROUP("ssi0-dr-d", jz4780_ssi0_dr_d),
1150 INGENIC_PIN_GROUP("ssi0-dr-e", jz4770_ssi0_dr_e),
1151 INGENIC_PIN_GROUP("ssi0-clk-a", jz4780_ssi0_clk_a),
1152 INGENIC_PIN_GROUP("ssi0-clk-b-5", jz4780_ssi0_clk_b_5),
1153 INGENIC_PIN_GROUP("ssi0-clk-b-28", jz4780_ssi0_clk_b_28),
1154 INGENIC_PIN_GROUP("ssi0-clk-d", jz4780_ssi0_clk_d),
1155 INGENIC_PIN_GROUP("ssi0-clk-e", jz4770_ssi0_clk_e),
1156 INGENIC_PIN_GROUP("ssi0-gpc-b", jz4780_ssi0_gpc_b),
1157 INGENIC_PIN_GROUP("ssi0-gpc-d", jz4780_ssi0_gpc_d),
1158 INGENIC_PIN_GROUP("ssi0-gpc-e", jz4770_ssi0_gpc_e),
1159 INGENIC_PIN_GROUP("ssi0-ce0-a-23", jz4780_ssi0_ce0_a_23),
1160 INGENIC_PIN_GROUP("ssi0-ce0-a-25", jz4780_ssi0_ce0_a_25),
1161 INGENIC_PIN_GROUP("ssi0-ce0-b", jz4780_ssi0_ce0_b),
1162 INGENIC_PIN_GROUP("ssi0-ce0-d", jz4780_ssi0_ce0_d),
1163 INGENIC_PIN_GROUP("ssi0-ce0-e", jz4770_ssi0_ce0_e),
1164 INGENIC_PIN_GROUP("ssi0-ce1-b", jz4780_ssi0_ce1_b),
1165 INGENIC_PIN_GROUP("ssi0-ce1-d", jz4780_ssi0_ce1_d),
1166 INGENIC_PIN_GROUP("ssi0-ce1-e", jz4770_ssi0_ce1_e),
1167 INGENIC_PIN_GROUP("ssi1-dt-b", jz4780_ssi1_dt_b),
1168 INGENIC_PIN_GROUP("ssi1-dt-d", jz4780_ssi1_dt_d),
1169 INGENIC_PIN_GROUP("ssi1-dt-e", jz4770_ssi1_dt_e),
1170 INGENIC_PIN_GROUP("ssi1-dr-b", jz4780_ssi1_dr_b),
1171 INGENIC_PIN_GROUP("ssi1-dr-d", jz4780_ssi1_dr_d),
1172 INGENIC_PIN_GROUP("ssi1-dr-e", jz4770_ssi1_dr_e),
1173 INGENIC_PIN_GROUP("ssi1-clk-b", jz4780_ssi1_clk_b),
1174 INGENIC_PIN_GROUP("ssi1-clk-d", jz4780_ssi1_clk_d),
1175 INGENIC_PIN_GROUP("ssi1-clk-e", jz4770_ssi1_clk_e),
1176 INGENIC_PIN_GROUP("ssi1-gpc-b", jz4780_ssi1_gpc_b),
1177 INGENIC_PIN_GROUP("ssi1-gpc-d", jz4780_ssi1_gpc_d),
1178 INGENIC_PIN_GROUP("ssi1-gpc-e", jz4770_ssi1_gpc_e),
1179 INGENIC_PIN_GROUP("ssi1-ce0-b", jz4780_ssi1_ce0_b),
1180 INGENIC_PIN_GROUP("ssi1-ce0-d", jz4780_ssi1_ce0_d),
1181 INGENIC_PIN_GROUP("ssi1-ce0-e", jz4770_ssi1_ce0_e),
1182 INGENIC_PIN_GROUP("ssi1-ce1-b", jz4780_ssi1_ce1_b),
1183 INGENIC_PIN_GROUP("ssi1-ce1-d", jz4780_ssi1_ce1_d),
1184 INGENIC_PIN_GROUP("ssi1-ce1-e", jz4770_ssi1_ce1_e),
Zhou Yanjieff656e42019-01-28 23:19:57 +08001185 INGENIC_PIN_GROUP("mmc0-1bit-a", jz4770_mmc0_1bit_a),
1186 INGENIC_PIN_GROUP("mmc0-4bit-a", jz4770_mmc0_4bit_a),
1187 INGENIC_PIN_GROUP("mmc0-8bit-a", jz4780_mmc0_8bit_a),
1188 INGENIC_PIN_GROUP("mmc0-1bit-e", jz4770_mmc0_1bit_e),
1189 INGENIC_PIN_GROUP("mmc0-4bit-e", jz4770_mmc0_4bit_e),
1190 INGENIC_PIN_GROUP("mmc1-1bit-d", jz4770_mmc1_1bit_d),
1191 INGENIC_PIN_GROUP("mmc1-4bit-d", jz4770_mmc1_4bit_d),
1192 INGENIC_PIN_GROUP("mmc1-1bit-e", jz4770_mmc1_1bit_e),
1193 INGENIC_PIN_GROUP("mmc1-4bit-e", jz4770_mmc1_4bit_e),
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001194 INGENIC_PIN_GROUP("mmc2-1bit-b", jz4770_mmc2_1bit_b),
1195 INGENIC_PIN_GROUP("mmc2-4bit-b", jz4770_mmc2_4bit_b),
1196 INGENIC_PIN_GROUP("mmc2-1bit-e", jz4770_mmc2_1bit_e),
1197 INGENIC_PIN_GROUP("mmc2-4bit-e", jz4770_mmc2_4bit_e),
Zhou Yanjieff656e42019-01-28 23:19:57 +08001198 INGENIC_PIN_GROUP("nemc-data", jz4770_nemc_8bit_data),
1199 INGENIC_PIN_GROUP("nemc-cle-ale", jz4770_nemc_cle_ale),
1200 INGENIC_PIN_GROUP("nemc-addr", jz4770_nemc_addr),
1201 INGENIC_PIN_GROUP("nemc-rd-we", jz4770_nemc_rd_we),
1202 INGENIC_PIN_GROUP("nemc-frd-fwe", jz4770_nemc_frd_fwe),
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001203 INGENIC_PIN_GROUP("nemc-wait", jz4770_nemc_wait),
Zhou Yanjieff656e42019-01-28 23:19:57 +08001204 INGENIC_PIN_GROUP("nemc-cs1", jz4770_nemc_cs1),
1205 INGENIC_PIN_GROUP("nemc-cs2", jz4770_nemc_cs2),
1206 INGENIC_PIN_GROUP("nemc-cs3", jz4770_nemc_cs3),
1207 INGENIC_PIN_GROUP("nemc-cs4", jz4770_nemc_cs4),
1208 INGENIC_PIN_GROUP("nemc-cs5", jz4770_nemc_cs5),
1209 INGENIC_PIN_GROUP("nemc-cs6", jz4770_nemc_cs6),
1210 INGENIC_PIN_GROUP("i2c0-data", jz4770_i2c0),
1211 INGENIC_PIN_GROUP("i2c1-data", jz4770_i2c1),
1212 INGENIC_PIN_GROUP("i2c2-data", jz4770_i2c2),
1213 INGENIC_PIN_GROUP("i2c3-data", jz4780_i2c3),
1214 INGENIC_PIN_GROUP("i2c4-data-e", jz4780_i2c4_e),
1215 INGENIC_PIN_GROUP("i2c4-data-f", jz4780_i2c4_f),
Paul Boddiea0bb89e2020-02-28 19:19:30 +01001216 INGENIC_PIN_GROUP("hdmi-ddc", jz4780_hdmi_ddc),
Zhou Yanjieff656e42019-01-28 23:19:57 +08001217 INGENIC_PIN_GROUP("cim-data", jz4770_cim_8bit),
1218 INGENIC_PIN_GROUP("lcd-24bit", jz4770_lcd_24bit),
1219 { "lcd-no-pins", },
1220 INGENIC_PIN_GROUP("pwm0", jz4770_pwm_pwm0),
1221 INGENIC_PIN_GROUP("pwm1", jz4770_pwm_pwm1),
1222 INGENIC_PIN_GROUP("pwm2", jz4770_pwm_pwm2),
1223 INGENIC_PIN_GROUP("pwm3", jz4770_pwm_pwm3),
1224 INGENIC_PIN_GROUP("pwm4", jz4770_pwm_pwm4),
1225 INGENIC_PIN_GROUP("pwm5", jz4770_pwm_pwm5),
1226 INGENIC_PIN_GROUP("pwm6", jz4770_pwm_pwm6),
1227 INGENIC_PIN_GROUP("pwm7", jz4770_pwm_pwm7),
1228};
1229
1230static const char *jz4780_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
1231static const char *jz4780_uart4_groups[] = { "uart4-data", };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001232static const char *jz4780_ssi0_groups[] = {
1233 "ssi0-dt-a-19", "ssi0-dt-a-21", "ssi0-dt-a-28", "ssi0-dt-b", "ssi0-dt-d", "ssi0-dt-e",
1234 "ssi0-dr-a-20", "ssi0-dr-a-27", "ssi0-dr-b", "ssi0-dr-d", "ssi0-dr-e",
1235 "ssi0-clk-a", "ssi0-clk-b-5", "ssi0-clk-b-28", "ssi0-clk-d", "ssi0-clk-e",
1236 "ssi0-gpc-b", "ssi0-gpc-d", "ssi0-gpc-e",
1237 "ssi0-ce0-a-23", "ssi0-ce0-a-25", "ssi0-ce0-b", "ssi0-ce0-d", "ssi0-ce0-e",
1238 "ssi0-ce1-b", "ssi0-ce1-d", "ssi0-ce1-e",
1239};
1240static const char *jz4780_ssi1_groups[] = {
1241 "ssi1-dt-b", "ssi1-dt-d", "ssi1-dt-e",
1242 "ssi1-dr-b", "ssi1-dr-d", "ssi1-dr-e",
1243 "ssi1-clk-b", "ssi1-clk-d", "ssi1-clk-e",
1244 "ssi1-gpc-b", "ssi1-gpc-d", "ssi1-gpc-e",
1245 "ssi1-ce0-b", "ssi1-ce0-d", "ssi1-ce0-e",
1246 "ssi1-ce1-b", "ssi1-ce1-d", "ssi1-ce1-e",
1247};
Zhou Yanjieff656e42019-01-28 23:19:57 +08001248static const char *jz4780_mmc0_groups[] = {
1249 "mmc0-1bit-a", "mmc0-4bit-a", "mmc0-8bit-a",
1250 "mmc0-1bit-e", "mmc0-4bit-e",
1251};
1252static const char *jz4780_mmc1_groups[] = {
1253 "mmc1-1bit-d", "mmc1-4bit-d", "mmc1-1bit-e", "mmc1-4bit-e",
1254};
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001255static const char *jz4780_mmc2_groups[] = {
1256 "mmc2-1bit-b", "mmc2-4bit-b", "mmc2-1bit-e", "mmc2-4bit-e",
1257};
Zhou Yanjieff656e42019-01-28 23:19:57 +08001258static const char *jz4780_nemc_groups[] = {
1259 "nemc-data", "nemc-cle-ale", "nemc-addr",
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001260 "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
Zhou Yanjieff656e42019-01-28 23:19:57 +08001261};
1262static const char *jz4780_i2c3_groups[] = { "i2c3-data", };
1263static const char *jz4780_i2c4_groups[] = { "i2c4-data-e", "i2c4-data-f", };
1264static const char *jz4780_cim_groups[] = { "cim-data", };
Paul Boddiea0bb89e2020-02-28 19:19:30 +01001265static const char *jz4780_hdmi_ddc_groups[] = { "hdmi-ddc", };
Zhou Yanjieff656e42019-01-28 23:19:57 +08001266
1267static const struct function_desc jz4780_functions[] = {
1268 { "uart0", jz4770_uart0_groups, ARRAY_SIZE(jz4770_uart0_groups), },
1269 { "uart1", jz4770_uart1_groups, ARRAY_SIZE(jz4770_uart1_groups), },
1270 { "uart2", jz4780_uart2_groups, ARRAY_SIZE(jz4780_uart2_groups), },
1271 { "uart3", jz4770_uart3_groups, ARRAY_SIZE(jz4770_uart3_groups), },
1272 { "uart4", jz4780_uart4_groups, ARRAY_SIZE(jz4780_uart4_groups), },
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001273 { "ssi0", jz4780_ssi0_groups, ARRAY_SIZE(jz4780_ssi0_groups), },
1274 { "ssi1", jz4780_ssi1_groups, ARRAY_SIZE(jz4780_ssi1_groups), },
Zhou Yanjieff656e42019-01-28 23:19:57 +08001275 { "mmc0", jz4780_mmc0_groups, ARRAY_SIZE(jz4780_mmc0_groups), },
1276 { "mmc1", jz4780_mmc1_groups, ARRAY_SIZE(jz4780_mmc1_groups), },
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001277 { "mmc2", jz4780_mmc2_groups, ARRAY_SIZE(jz4780_mmc2_groups), },
Zhou Yanjieff656e42019-01-28 23:19:57 +08001278 { "nemc", jz4780_nemc_groups, ARRAY_SIZE(jz4780_nemc_groups), },
1279 { "nemc-cs1", jz4770_cs1_groups, ARRAY_SIZE(jz4770_cs1_groups), },
1280 { "nemc-cs2", jz4770_cs2_groups, ARRAY_SIZE(jz4770_cs2_groups), },
1281 { "nemc-cs3", jz4770_cs3_groups, ARRAY_SIZE(jz4770_cs3_groups), },
1282 { "nemc-cs4", jz4770_cs4_groups, ARRAY_SIZE(jz4770_cs4_groups), },
1283 { "nemc-cs5", jz4770_cs5_groups, ARRAY_SIZE(jz4770_cs5_groups), },
1284 { "nemc-cs6", jz4770_cs6_groups, ARRAY_SIZE(jz4770_cs6_groups), },
1285 { "i2c0", jz4770_i2c0_groups, ARRAY_SIZE(jz4770_i2c0_groups), },
1286 { "i2c1", jz4770_i2c1_groups, ARRAY_SIZE(jz4770_i2c1_groups), },
1287 { "i2c2", jz4770_i2c2_groups, ARRAY_SIZE(jz4770_i2c2_groups), },
1288 { "i2c3", jz4780_i2c3_groups, ARRAY_SIZE(jz4780_i2c3_groups), },
1289 { "i2c4", jz4780_i2c4_groups, ARRAY_SIZE(jz4780_i2c4_groups), },
1290 { "cim", jz4780_cim_groups, ARRAY_SIZE(jz4780_cim_groups), },
1291 { "lcd", jz4770_lcd_groups, ARRAY_SIZE(jz4770_lcd_groups), },
1292 { "pwm0", jz4770_pwm0_groups, ARRAY_SIZE(jz4770_pwm0_groups), },
1293 { "pwm1", jz4770_pwm1_groups, ARRAY_SIZE(jz4770_pwm1_groups), },
1294 { "pwm2", jz4770_pwm2_groups, ARRAY_SIZE(jz4770_pwm2_groups), },
1295 { "pwm3", jz4770_pwm3_groups, ARRAY_SIZE(jz4770_pwm3_groups), },
1296 { "pwm4", jz4770_pwm4_groups, ARRAY_SIZE(jz4770_pwm4_groups), },
1297 { "pwm5", jz4770_pwm5_groups, ARRAY_SIZE(jz4770_pwm5_groups), },
1298 { "pwm6", jz4770_pwm6_groups, ARRAY_SIZE(jz4770_pwm6_groups), },
1299 { "pwm7", jz4770_pwm7_groups, ARRAY_SIZE(jz4770_pwm7_groups), },
Paul Boddiea0bb89e2020-02-28 19:19:30 +01001300 { "hdmi-ddc", jz4780_hdmi_ddc_groups,
1301 ARRAY_SIZE(jz4780_hdmi_ddc_groups), },
Zhou Yanjieff656e42019-01-28 23:19:57 +08001302};
1303
1304static const struct ingenic_chip_info jz4780_chip_info = {
1305 .num_chips = 6,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08001306 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +01001307 .version = ID_JZ4780,
Zhou Yanjieff656e42019-01-28 23:19:57 +08001308 .groups = jz4780_groups,
1309 .num_groups = ARRAY_SIZE(jz4780_groups),
1310 .functions = jz4780_functions,
1311 .num_functions = ARRAY_SIZE(jz4780_functions),
周琰杰 (Zhou Yanjie)d9f5dc42020-09-13 14:58:35 +08001312 .pull_ups = jz4780_pull_ups,
1313 .pull_downs = jz4780_pull_downs,
Zhou Yanjieff656e42019-01-28 23:19:57 +08001314};
1315
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001316static const u32 x1000_pull_ups[4] = {
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001317 0xffffffff, 0xfdffffff, 0x0dffffff, 0x0000003f,
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001318};
1319
1320static const u32 x1000_pull_downs[4] = {
1321 0x00000000, 0x02000000, 0x02000000, 0x00000000,
1322};
1323
1324static int x1000_uart0_data_pins[] = { 0x4a, 0x4b, };
1325static int x1000_uart0_hwflow_pins[] = { 0x4c, 0x4d, };
1326static int x1000_uart1_data_a_pins[] = { 0x04, 0x05, };
1327static int x1000_uart1_data_d_pins[] = { 0x62, 0x63, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001328static int x1000_uart1_hwflow_pins[] = { 0x64, 0x65, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001329static int x1000_uart2_data_a_pins[] = { 0x02, 0x03, };
1330static int x1000_uart2_data_d_pins[] = { 0x65, 0x64, };
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001331static int x1000_sfc_pins[] = { 0x1d, 0x1c, 0x1e, 0x1f, 0x1a, 0x1b, };
1332static int x1000_ssi_dt_a_22_pins[] = { 0x16, };
1333static int x1000_ssi_dt_a_29_pins[] = { 0x1d, };
1334static int x1000_ssi_dt_d_pins[] = { 0x62, };
1335static int x1000_ssi_dr_a_23_pins[] = { 0x17, };
1336static int x1000_ssi_dr_a_28_pins[] = { 0x1c, };
1337static int x1000_ssi_dr_d_pins[] = { 0x63, };
1338static int x1000_ssi_clk_a_24_pins[] = { 0x18, };
1339static int x1000_ssi_clk_a_26_pins[] = { 0x1a, };
1340static int x1000_ssi_clk_d_pins[] = { 0x60, };
1341static int x1000_ssi_gpc_a_20_pins[] = { 0x14, };
1342static int x1000_ssi_gpc_a_31_pins[] = { 0x1f, };
1343static int x1000_ssi_ce0_a_25_pins[] = { 0x19, };
1344static int x1000_ssi_ce0_a_27_pins[] = { 0x1b, };
1345static int x1000_ssi_ce0_d_pins[] = { 0x61, };
1346static int x1000_ssi_ce1_a_21_pins[] = { 0x15, };
1347static int x1000_ssi_ce1_a_30_pins[] = { 0x1e, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001348static int x1000_mmc0_1bit_pins[] = { 0x18, 0x19, 0x17, };
1349static int x1000_mmc0_4bit_pins[] = { 0x16, 0x15, 0x14, };
1350static int x1000_mmc0_8bit_pins[] = { 0x13, 0x12, 0x11, 0x10, };
1351static int x1000_mmc1_1bit_pins[] = { 0x40, 0x41, 0x42, };
1352static int x1000_mmc1_4bit_pins[] = { 0x43, 0x44, 0x45, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001353static int x1000_emc_8bit_data_pins[] = {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001354 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1355};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001356static int x1000_emc_16bit_data_pins[] = {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001357 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1358};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001359static int x1000_emc_addr_pins[] = {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001360 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
1361 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
1362};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001363static int x1000_emc_rd_we_pins[] = { 0x30, 0x31, };
1364static int x1000_emc_wait_pins[] = { 0x34, };
1365static int x1000_emc_cs1_pins[] = { 0x32, };
1366static int x1000_emc_cs2_pins[] = { 0x33, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001367static int x1000_i2c0_pins[] = { 0x38, 0x37, };
1368static int x1000_i2c1_a_pins[] = { 0x01, 0x00, };
1369static int x1000_i2c1_c_pins[] = { 0x5b, 0x5a, };
1370static int x1000_i2c2_pins[] = { 0x61, 0x60, };
1371static int x1000_cim_pins[] = {
1372 0x08, 0x09, 0x0a, 0x0b,
1373 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c,
1374};
1375static int x1000_lcd_8bit_pins[] = {
1376 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1377 0x30, 0x31, 0x32, 0x33, 0x34,
1378};
1379static int x1000_lcd_16bit_pins[] = {
1380 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1381};
1382static int x1000_pwm_pwm0_pins[] = { 0x59, };
1383static int x1000_pwm_pwm1_pins[] = { 0x5a, };
1384static int x1000_pwm_pwm2_pins[] = { 0x5b, };
1385static int x1000_pwm_pwm3_pins[] = { 0x26, };
1386static int x1000_pwm_pwm4_pins[] = { 0x58, };
1387static int x1000_mac_pins[] = {
1388 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x26,
1389};
1390
1391static int x1000_uart0_data_funcs[] = { 0, 0, };
1392static int x1000_uart0_hwflow_funcs[] = { 0, 0, };
1393static int x1000_uart1_data_a_funcs[] = { 2, 2, };
1394static int x1000_uart1_data_d_funcs[] = { 1, 1, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001395static int x1000_uart1_hwflow_funcs[] = { 1, 1, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001396static int x1000_uart2_data_a_funcs[] = { 2, 2, };
1397static int x1000_uart2_data_d_funcs[] = { 0, 0, };
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001398static int x1000_sfc_funcs[] = { 1, 1, 1, 1, 1, 1, };
1399static int x1000_ssi_dt_a_22_funcs[] = { 2, };
1400static int x1000_ssi_dt_a_29_funcs[] = { 2, };
1401static int x1000_ssi_dt_d_funcs[] = { 0, };
1402static int x1000_ssi_dr_a_23_funcs[] = { 2, };
1403static int x1000_ssi_dr_a_28_funcs[] = { 2, };
1404static int x1000_ssi_dr_d_funcs[] = { 0, };
1405static int x1000_ssi_clk_a_24_funcs[] = { 2, };
1406static int x1000_ssi_clk_a_26_funcs[] = { 2, };
1407static int x1000_ssi_clk_d_funcs[] = { 0, };
1408static int x1000_ssi_gpc_a_20_funcs[] = { 2, };
1409static int x1000_ssi_gpc_a_31_funcs[] = { 2, };
1410static int x1000_ssi_ce0_a_25_funcs[] = { 2, };
1411static int x1000_ssi_ce0_a_27_funcs[] = { 2, };
1412static int x1000_ssi_ce0_d_funcs[] = { 0, };
1413static int x1000_ssi_ce1_a_21_funcs[] = { 2, };
1414static int x1000_ssi_ce1_a_30_funcs[] = { 2, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001415static int x1000_mmc0_1bit_funcs[] = { 1, 1, 1, };
1416static int x1000_mmc0_4bit_funcs[] = { 1, 1, 1, };
1417static int x1000_mmc0_8bit_funcs[] = { 1, 1, 1, 1, 1, };
1418static int x1000_mmc1_1bit_funcs[] = { 0, 0, 0, };
1419static int x1000_mmc1_4bit_funcs[] = { 0, 0, 0, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001420static int x1000_emc_8bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
1421static int x1000_emc_16bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, };
1422static int x1000_emc_addr_funcs[] = {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001423 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1424};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001425static int x1000_emc_rd_we_funcs[] = { 0, 0, };
1426static int x1000_emc_wait_funcs[] = { 0, };
1427static int x1000_emc_cs1_funcs[] = { 0, };
1428static int x1000_emc_cs2_funcs[] = { 0, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001429static int x1000_i2c0_funcs[] = { 0, 0, };
1430static int x1000_i2c1_a_funcs[] = { 2, 2, };
1431static int x1000_i2c1_c_funcs[] = { 0, 0, };
1432static int x1000_i2c2_funcs[] = { 1, 1, };
1433static int x1000_cim_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
1434static int x1000_lcd_8bit_funcs[] = {
1435 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1436};
1437static int x1000_lcd_16bit_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, };
1438static int x1000_pwm_pwm0_funcs[] = { 0, };
1439static int x1000_pwm_pwm1_funcs[] = { 1, };
1440static int x1000_pwm_pwm2_funcs[] = { 1, };
1441static int x1000_pwm_pwm3_funcs[] = { 2, };
1442static int x1000_pwm_pwm4_funcs[] = { 0, };
1443static int x1000_mac_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
1444
1445static const struct group_desc x1000_groups[] = {
1446 INGENIC_PIN_GROUP("uart0-data", x1000_uart0_data),
1447 INGENIC_PIN_GROUP("uart0-hwflow", x1000_uart0_hwflow),
1448 INGENIC_PIN_GROUP("uart1-data-a", x1000_uart1_data_a),
1449 INGENIC_PIN_GROUP("uart1-data-d", x1000_uart1_data_d),
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001450 INGENIC_PIN_GROUP("uart1-hwflow", x1000_uart1_hwflow),
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001451 INGENIC_PIN_GROUP("uart2-data-a", x1000_uart2_data_a),
1452 INGENIC_PIN_GROUP("uart2-data-d", x1000_uart2_data_d),
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001453 INGENIC_PIN_GROUP("sfc", x1000_sfc),
1454 INGENIC_PIN_GROUP("ssi-dt-a-22", x1000_ssi_dt_a_22),
1455 INGENIC_PIN_GROUP("ssi-dt-a-29", x1000_ssi_dt_a_29),
1456 INGENIC_PIN_GROUP("ssi-dt-d", x1000_ssi_dt_d),
1457 INGENIC_PIN_GROUP("ssi-dr-a-23", x1000_ssi_dr_a_23),
1458 INGENIC_PIN_GROUP("ssi-dr-a-28", x1000_ssi_dr_a_28),
1459 INGENIC_PIN_GROUP("ssi-dr-d", x1000_ssi_dr_d),
1460 INGENIC_PIN_GROUP("ssi-clk-a-24", x1000_ssi_clk_a_24),
1461 INGENIC_PIN_GROUP("ssi-clk-a-26", x1000_ssi_clk_a_26),
1462 INGENIC_PIN_GROUP("ssi-clk-d", x1000_ssi_clk_d),
1463 INGENIC_PIN_GROUP("ssi-gpc-a-20", x1000_ssi_gpc_a_20),
1464 INGENIC_PIN_GROUP("ssi-gpc-a-31", x1000_ssi_gpc_a_31),
1465 INGENIC_PIN_GROUP("ssi-ce0-a-25", x1000_ssi_ce0_a_25),
1466 INGENIC_PIN_GROUP("ssi-ce0-a-27", x1000_ssi_ce0_a_27),
1467 INGENIC_PIN_GROUP("ssi-ce0-d", x1000_ssi_ce0_d),
1468 INGENIC_PIN_GROUP("ssi-ce1-a-21", x1000_ssi_ce1_a_21),
1469 INGENIC_PIN_GROUP("ssi-ce1-a-30", x1000_ssi_ce1_a_30),
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001470 INGENIC_PIN_GROUP("mmc0-1bit", x1000_mmc0_1bit),
1471 INGENIC_PIN_GROUP("mmc0-4bit", x1000_mmc0_4bit),
1472 INGENIC_PIN_GROUP("mmc0-8bit", x1000_mmc0_8bit),
1473 INGENIC_PIN_GROUP("mmc1-1bit", x1000_mmc1_1bit),
1474 INGENIC_PIN_GROUP("mmc1-4bit", x1000_mmc1_4bit),
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001475 INGENIC_PIN_GROUP("emc-8bit-data", x1000_emc_8bit_data),
1476 INGENIC_PIN_GROUP("emc-16bit-data", x1000_emc_16bit_data),
1477 INGENIC_PIN_GROUP("emc-addr", x1000_emc_addr),
1478 INGENIC_PIN_GROUP("emc-rd-we", x1000_emc_rd_we),
1479 INGENIC_PIN_GROUP("emc-wait", x1000_emc_wait),
1480 INGENIC_PIN_GROUP("emc-cs1", x1000_emc_cs1),
1481 INGENIC_PIN_GROUP("emc-cs2", x1000_emc_cs2),
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001482 INGENIC_PIN_GROUP("i2c0-data", x1000_i2c0),
1483 INGENIC_PIN_GROUP("i2c1-data-a", x1000_i2c1_a),
1484 INGENIC_PIN_GROUP("i2c1-data-c", x1000_i2c1_c),
1485 INGENIC_PIN_GROUP("i2c2-data", x1000_i2c2),
1486 INGENIC_PIN_GROUP("cim-data", x1000_cim),
1487 INGENIC_PIN_GROUP("lcd-8bit", x1000_lcd_8bit),
1488 INGENIC_PIN_GROUP("lcd-16bit", x1000_lcd_16bit),
1489 { "lcd-no-pins", },
1490 INGENIC_PIN_GROUP("pwm0", x1000_pwm_pwm0),
1491 INGENIC_PIN_GROUP("pwm1", x1000_pwm_pwm1),
1492 INGENIC_PIN_GROUP("pwm2", x1000_pwm_pwm2),
1493 INGENIC_PIN_GROUP("pwm3", x1000_pwm_pwm3),
1494 INGENIC_PIN_GROUP("pwm4", x1000_pwm_pwm4),
1495 INGENIC_PIN_GROUP("mac", x1000_mac),
1496};
1497
1498static const char *x1000_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1499static const char *x1000_uart1_groups[] = {
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001500 "uart1-data-a", "uart1-data-d", "uart1-hwflow",
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001501};
1502static const char *x1000_uart2_groups[] = { "uart2-data-a", "uart2-data-d", };
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001503static const char *x1000_sfc_groups[] = { "sfc", };
1504static const char *x1000_ssi_groups[] = {
1505 "ssi-dt-a-22", "ssi-dt-a-29", "ssi-dt-d",
1506 "ssi-dr-a-23", "ssi-dr-a-28", "ssi-dr-d",
1507 "ssi-clk-a-24", "ssi-clk-a-26", "ssi-clk-d",
1508 "ssi-gpc-a-20", "ssi-gpc-a-31",
1509 "ssi-ce0-a-25", "ssi-ce0-a-27", "ssi-ce0-d",
1510 "ssi-ce1-a-21", "ssi-ce1-a-30",
1511};
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001512static const char *x1000_mmc0_groups[] = {
1513 "mmc0-1bit", "mmc0-4bit", "mmc0-8bit",
1514};
1515static const char *x1000_mmc1_groups[] = {
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001516 "mmc1-1bit", "mmc1-4bit",
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001517};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001518static const char *x1000_emc_groups[] = {
1519 "emc-8bit-data", "emc-16bit-data",
1520 "emc-addr", "emc-rd-we", "emc-wait",
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001521};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001522static const char *x1000_cs1_groups[] = { "emc-cs1", };
1523static const char *x1000_cs2_groups[] = { "emc-cs2", };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001524static const char *x1000_i2c0_groups[] = { "i2c0-data", };
1525static const char *x1000_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", };
1526static const char *x1000_i2c2_groups[] = { "i2c2-data", };
1527static const char *x1000_cim_groups[] = { "cim-data", };
1528static const char *x1000_lcd_groups[] = {
1529 "lcd-8bit", "lcd-16bit", "lcd-no-pins",
1530};
1531static const char *x1000_pwm0_groups[] = { "pwm0", };
1532static const char *x1000_pwm1_groups[] = { "pwm1", };
1533static const char *x1000_pwm2_groups[] = { "pwm2", };
1534static const char *x1000_pwm3_groups[] = { "pwm3", };
1535static const char *x1000_pwm4_groups[] = { "pwm4", };
1536static const char *x1000_mac_groups[] = { "mac", };
1537
1538static const struct function_desc x1000_functions[] = {
1539 { "uart0", x1000_uart0_groups, ARRAY_SIZE(x1000_uart0_groups), },
1540 { "uart1", x1000_uart1_groups, ARRAY_SIZE(x1000_uart1_groups), },
1541 { "uart2", x1000_uart2_groups, ARRAY_SIZE(x1000_uart2_groups), },
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001542 { "sfc", x1000_sfc_groups, ARRAY_SIZE(x1000_sfc_groups), },
1543 { "ssi", x1000_ssi_groups, ARRAY_SIZE(x1000_ssi_groups), },
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001544 { "mmc0", x1000_mmc0_groups, ARRAY_SIZE(x1000_mmc0_groups), },
1545 { "mmc1", x1000_mmc1_groups, ARRAY_SIZE(x1000_mmc1_groups), },
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001546 { "emc", x1000_emc_groups, ARRAY_SIZE(x1000_emc_groups), },
1547 { "emc-cs1", x1000_cs1_groups, ARRAY_SIZE(x1000_cs1_groups), },
1548 { "emc-cs2", x1000_cs2_groups, ARRAY_SIZE(x1000_cs2_groups), },
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001549 { "i2c0", x1000_i2c0_groups, ARRAY_SIZE(x1000_i2c0_groups), },
1550 { "i2c1", x1000_i2c1_groups, ARRAY_SIZE(x1000_i2c1_groups), },
1551 { "i2c2", x1000_i2c2_groups, ARRAY_SIZE(x1000_i2c2_groups), },
1552 { "cim", x1000_cim_groups, ARRAY_SIZE(x1000_cim_groups), },
1553 { "lcd", x1000_lcd_groups, ARRAY_SIZE(x1000_lcd_groups), },
1554 { "pwm0", x1000_pwm0_groups, ARRAY_SIZE(x1000_pwm0_groups), },
1555 { "pwm1", x1000_pwm1_groups, ARRAY_SIZE(x1000_pwm1_groups), },
1556 { "pwm2", x1000_pwm2_groups, ARRAY_SIZE(x1000_pwm2_groups), },
1557 { "pwm3", x1000_pwm3_groups, ARRAY_SIZE(x1000_pwm3_groups), },
1558 { "pwm4", x1000_pwm4_groups, ARRAY_SIZE(x1000_pwm4_groups), },
1559 { "mac", x1000_mac_groups, ARRAY_SIZE(x1000_mac_groups), },
1560};
1561
1562static const struct ingenic_chip_info x1000_chip_info = {
1563 .num_chips = 4,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08001564 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +01001565 .version = ID_X1000,
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001566 .groups = x1000_groups,
1567 .num_groups = ARRAY_SIZE(x1000_groups),
1568 .functions = x1000_functions,
1569 .num_functions = ARRAY_SIZE(x1000_functions),
1570 .pull_ups = x1000_pull_ups,
1571 .pull_downs = x1000_pull_downs,
1572};
1573
Zhou Yanjie5d215952019-07-14 11:53:56 +08001574static int x1500_uart0_data_pins[] = { 0x4a, 0x4b, };
1575static int x1500_uart0_hwflow_pins[] = { 0x4c, 0x4d, };
1576static int x1500_uart1_data_a_pins[] = { 0x04, 0x05, };
1577static int x1500_uart1_data_d_pins[] = { 0x62, 0x63, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001578static int x1500_uart1_hwflow_pins[] = { 0x64, 0x65, };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001579static int x1500_uart2_data_a_pins[] = { 0x02, 0x03, };
1580static int x1500_uart2_data_d_pins[] = { 0x65, 0x64, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001581static int x1500_mmc_1bit_pins[] = { 0x18, 0x19, 0x17, };
1582static int x1500_mmc_4bit_pins[] = { 0x16, 0x15, 0x14, };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001583static int x1500_i2c0_pins[] = { 0x38, 0x37, };
1584static int x1500_i2c1_a_pins[] = { 0x01, 0x00, };
1585static int x1500_i2c1_c_pins[] = { 0x5b, 0x5a, };
1586static int x1500_i2c2_pins[] = { 0x61, 0x60, };
1587static int x1500_cim_pins[] = {
1588 0x08, 0x09, 0x0a, 0x0b,
1589 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c,
1590};
1591static int x1500_pwm_pwm0_pins[] = { 0x59, };
1592static int x1500_pwm_pwm1_pins[] = { 0x5a, };
1593static int x1500_pwm_pwm2_pins[] = { 0x5b, };
1594static int x1500_pwm_pwm3_pins[] = { 0x26, };
1595static int x1500_pwm_pwm4_pins[] = { 0x58, };
1596
1597static int x1500_uart0_data_funcs[] = { 0, 0, };
1598static int x1500_uart0_hwflow_funcs[] = { 0, 0, };
1599static int x1500_uart1_data_a_funcs[] = { 2, 2, };
1600static int x1500_uart1_data_d_funcs[] = { 1, 1, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001601static int x1500_uart1_hwflow_funcs[] = { 1, 1, };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001602static int x1500_uart2_data_a_funcs[] = { 2, 2, };
1603static int x1500_uart2_data_d_funcs[] = { 0, 0, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001604static int x1500_mmc_1bit_funcs[] = { 1, 1, 1, };
1605static int x1500_mmc_4bit_funcs[] = { 1, 1, 1, };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001606static int x1500_i2c0_funcs[] = { 0, 0, };
1607static int x1500_i2c1_a_funcs[] = { 2, 2, };
1608static int x1500_i2c1_c_funcs[] = { 0, 0, };
1609static int x1500_i2c2_funcs[] = { 1, 1, };
1610static int x1500_cim_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
1611static int x1500_pwm_pwm0_funcs[] = { 0, };
1612static int x1500_pwm_pwm1_funcs[] = { 1, };
1613static int x1500_pwm_pwm2_funcs[] = { 1, };
1614static int x1500_pwm_pwm3_funcs[] = { 2, };
1615static int x1500_pwm_pwm4_funcs[] = { 0, };
1616
1617static const struct group_desc x1500_groups[] = {
1618 INGENIC_PIN_GROUP("uart0-data", x1500_uart0_data),
1619 INGENIC_PIN_GROUP("uart0-hwflow", x1500_uart0_hwflow),
1620 INGENIC_PIN_GROUP("uart1-data-a", x1500_uart1_data_a),
1621 INGENIC_PIN_GROUP("uart1-data-d", x1500_uart1_data_d),
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001622 INGENIC_PIN_GROUP("uart1-hwflow", x1500_uart1_hwflow),
Zhou Yanjie5d215952019-07-14 11:53:56 +08001623 INGENIC_PIN_GROUP("uart2-data-a", x1500_uart2_data_a),
1624 INGENIC_PIN_GROUP("uart2-data-d", x1500_uart2_data_d),
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001625 INGENIC_PIN_GROUP("sfc", x1000_sfc),
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001626 INGENIC_PIN_GROUP("mmc-1bit", x1500_mmc_1bit),
1627 INGENIC_PIN_GROUP("mmc-4bit", x1500_mmc_4bit),
Zhou Yanjie5d215952019-07-14 11:53:56 +08001628 INGENIC_PIN_GROUP("i2c0-data", x1500_i2c0),
1629 INGENIC_PIN_GROUP("i2c1-data-a", x1500_i2c1_a),
1630 INGENIC_PIN_GROUP("i2c1-data-c", x1500_i2c1_c),
1631 INGENIC_PIN_GROUP("i2c2-data", x1500_i2c2),
1632 INGENIC_PIN_GROUP("cim-data", x1500_cim),
1633 { "lcd-no-pins", },
1634 INGENIC_PIN_GROUP("pwm0", x1500_pwm_pwm0),
1635 INGENIC_PIN_GROUP("pwm1", x1500_pwm_pwm1),
1636 INGENIC_PIN_GROUP("pwm2", x1500_pwm_pwm2),
1637 INGENIC_PIN_GROUP("pwm3", x1500_pwm_pwm3),
1638 INGENIC_PIN_GROUP("pwm4", x1500_pwm_pwm4),
1639};
1640
1641static const char *x1500_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1642static const char *x1500_uart1_groups[] = {
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001643 "uart1-data-a", "uart1-data-d", "uart1-hwflow",
Zhou Yanjie5d215952019-07-14 11:53:56 +08001644};
1645static const char *x1500_uart2_groups[] = { "uart2-data-a", "uart2-data-d", };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001646static const char *x1500_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001647static const char *x1500_i2c0_groups[] = { "i2c0-data", };
1648static const char *x1500_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", };
1649static const char *x1500_i2c2_groups[] = { "i2c2-data", };
1650static const char *x1500_cim_groups[] = { "cim-data", };
1651static const char *x1500_lcd_groups[] = { "lcd-no-pins", };
1652static const char *x1500_pwm0_groups[] = { "pwm0", };
1653static const char *x1500_pwm1_groups[] = { "pwm1", };
1654static const char *x1500_pwm2_groups[] = { "pwm2", };
1655static const char *x1500_pwm3_groups[] = { "pwm3", };
1656static const char *x1500_pwm4_groups[] = { "pwm4", };
1657
1658static const struct function_desc x1500_functions[] = {
1659 { "uart0", x1500_uart0_groups, ARRAY_SIZE(x1500_uart0_groups), },
1660 { "uart1", x1500_uart1_groups, ARRAY_SIZE(x1500_uart1_groups), },
1661 { "uart2", x1500_uart2_groups, ARRAY_SIZE(x1500_uart2_groups), },
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001662 { "sfc", x1000_sfc_groups, ARRAY_SIZE(x1000_sfc_groups), },
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001663 { "mmc", x1500_mmc_groups, ARRAY_SIZE(x1500_mmc_groups), },
Zhou Yanjie5d215952019-07-14 11:53:56 +08001664 { "i2c0", x1500_i2c0_groups, ARRAY_SIZE(x1500_i2c0_groups), },
1665 { "i2c1", x1500_i2c1_groups, ARRAY_SIZE(x1500_i2c1_groups), },
1666 { "i2c2", x1500_i2c2_groups, ARRAY_SIZE(x1500_i2c2_groups), },
1667 { "cim", x1500_cim_groups, ARRAY_SIZE(x1500_cim_groups), },
1668 { "lcd", x1500_lcd_groups, ARRAY_SIZE(x1500_lcd_groups), },
1669 { "pwm0", x1500_pwm0_groups, ARRAY_SIZE(x1500_pwm0_groups), },
1670 { "pwm1", x1500_pwm1_groups, ARRAY_SIZE(x1500_pwm1_groups), },
1671 { "pwm2", x1500_pwm2_groups, ARRAY_SIZE(x1500_pwm2_groups), },
1672 { "pwm3", x1500_pwm3_groups, ARRAY_SIZE(x1500_pwm3_groups), },
1673 { "pwm4", x1500_pwm4_groups, ARRAY_SIZE(x1500_pwm4_groups), },
1674};
1675
1676static const struct ingenic_chip_info x1500_chip_info = {
1677 .num_chips = 4,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08001678 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +01001679 .version = ID_X1500,
Zhou Yanjie5d215952019-07-14 11:53:56 +08001680 .groups = x1500_groups,
1681 .num_groups = ARRAY_SIZE(x1500_groups),
1682 .functions = x1500_functions,
1683 .num_functions = ARRAY_SIZE(x1500_functions),
1684 .pull_ups = x1000_pull_ups,
1685 .pull_downs = x1000_pull_downs,
1686};
1687
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001688static const u32 x1830_pull_ups[4] = {
1689 0x5fdfffc0, 0xffffefff, 0x1ffffbff, 0x0fcff3fc,
1690};
1691
1692static const u32 x1830_pull_downs[4] = {
1693 0x5fdfffc0, 0xffffefff, 0x1ffffbff, 0x0fcff3fc,
1694};
1695
1696static int x1830_uart0_data_pins[] = { 0x33, 0x36, };
1697static int x1830_uart0_hwflow_pins[] = { 0x34, 0x35, };
1698static int x1830_uart1_data_pins[] = { 0x38, 0x37, };
1699static int x1830_sfc_pins[] = { 0x17, 0x18, 0x1a, 0x19, 0x1b, 0x1c, };
1700static int x1830_ssi0_dt_pins[] = { 0x4c, };
1701static int x1830_ssi0_dr_pins[] = { 0x4b, };
1702static int x1830_ssi0_clk_pins[] = { 0x4f, };
1703static int x1830_ssi0_gpc_pins[] = { 0x4d, };
1704static int x1830_ssi0_ce0_pins[] = { 0x50, };
1705static int x1830_ssi0_ce1_pins[] = { 0x4e, };
1706static int x1830_ssi1_dt_c_pins[] = { 0x53, };
1707static int x1830_ssi1_dr_c_pins[] = { 0x54, };
1708static int x1830_ssi1_clk_c_pins[] = { 0x57, };
1709static int x1830_ssi1_gpc_c_pins[] = { 0x55, };
1710static int x1830_ssi1_ce0_c_pins[] = { 0x58, };
1711static int x1830_ssi1_ce1_c_pins[] = { 0x56, };
1712static int x1830_ssi1_dt_d_pins[] = { 0x62, };
1713static int x1830_ssi1_dr_d_pins[] = { 0x63, };
1714static int x1830_ssi1_clk_d_pins[] = { 0x66, };
1715static int x1830_ssi1_gpc_d_pins[] = { 0x64, };
1716static int x1830_ssi1_ce0_d_pins[] = { 0x67, };
1717static int x1830_ssi1_ce1_d_pins[] = { 0x65, };
1718static int x1830_mmc0_1bit_pins[] = { 0x24, 0x25, 0x20, };
1719static int x1830_mmc0_4bit_pins[] = { 0x21, 0x22, 0x23, };
1720static int x1830_mmc1_1bit_pins[] = { 0x42, 0x43, 0x44, };
1721static int x1830_mmc1_4bit_pins[] = { 0x45, 0x46, 0x47, };
1722static int x1830_i2c0_pins[] = { 0x0c, 0x0d, };
1723static int x1830_i2c1_pins[] = { 0x39, 0x3a, };
1724static int x1830_i2c2_pins[] = { 0x5b, 0x5c, };
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001725static int x1830_lcd_rgb_18bit_pins[] = {
1726 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
1727 0x68, 0x69, 0x6c, 0x6d, 0x6e, 0x6f,
1728 0x70, 0x71, 0x72, 0x73, 0x76, 0x77,
1729 0x78, 0x79, 0x7a, 0x7b,
1730};
1731static int x1830_lcd_slcd_8bit_pins[] = {
1732 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x6c, 0x6d,
1733 0x69, 0x72, 0x73, 0x7b, 0x7a,
1734};
1735static int x1830_lcd_slcd_16bit_pins[] = {
1736 0x6e, 0x6f, 0x70, 0x71, 0x76, 0x77, 0x78, 0x79,
1737};
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001738static int x1830_pwm_pwm0_b_pins[] = { 0x31, };
1739static int x1830_pwm_pwm0_c_pins[] = { 0x4b, };
1740static int x1830_pwm_pwm1_b_pins[] = { 0x32, };
1741static int x1830_pwm_pwm1_c_pins[] = { 0x4c, };
1742static int x1830_pwm_pwm2_c_8_pins[] = { 0x48, };
1743static int x1830_pwm_pwm2_c_13_pins[] = { 0x4d, };
1744static int x1830_pwm_pwm3_c_9_pins[] = { 0x49, };
1745static int x1830_pwm_pwm3_c_14_pins[] = { 0x4e, };
1746static int x1830_pwm_pwm4_c_15_pins[] = { 0x4f, };
1747static int x1830_pwm_pwm4_c_25_pins[] = { 0x59, };
1748static int x1830_pwm_pwm5_c_16_pins[] = { 0x50, };
1749static int x1830_pwm_pwm5_c_26_pins[] = { 0x5a, };
1750static int x1830_pwm_pwm6_c_17_pins[] = { 0x51, };
1751static int x1830_pwm_pwm6_c_27_pins[] = { 0x5b, };
1752static int x1830_pwm_pwm7_c_18_pins[] = { 0x52, };
1753static int x1830_pwm_pwm7_c_28_pins[] = { 0x5c, };
1754static int x1830_mac_pins[] = {
1755 0x29, 0x30, 0x2f, 0x28, 0x2e, 0x2d, 0x2a, 0x2b, 0x26, 0x27,
1756};
1757
1758static int x1830_uart0_data_funcs[] = { 0, 0, };
1759static int x1830_uart0_hwflow_funcs[] = { 0, 0, };
1760static int x1830_uart1_data_funcs[] = { 0, 0, };
1761static int x1830_sfc_funcs[] = { 1, 1, 1, 1, 1, 1, };
1762static int x1830_ssi0_dt_funcs[] = { 0, };
1763static int x1830_ssi0_dr_funcs[] = { 0, };
1764static int x1830_ssi0_clk_funcs[] = { 0, };
1765static int x1830_ssi0_gpc_funcs[] = { 0, };
1766static int x1830_ssi0_ce0_funcs[] = { 0, };
1767static int x1830_ssi0_ce1_funcs[] = { 0, };
1768static int x1830_ssi1_dt_c_funcs[] = { 1, };
1769static int x1830_ssi1_dr_c_funcs[] = { 1, };
1770static int x1830_ssi1_clk_c_funcs[] = { 1, };
1771static int x1830_ssi1_gpc_c_funcs[] = { 1, };
1772static int x1830_ssi1_ce0_c_funcs[] = { 1, };
1773static int x1830_ssi1_ce1_c_funcs[] = { 1, };
1774static int x1830_ssi1_dt_d_funcs[] = { 2, };
1775static int x1830_ssi1_dr_d_funcs[] = { 2, };
1776static int x1830_ssi1_clk_d_funcs[] = { 2, };
1777static int x1830_ssi1_gpc_d_funcs[] = { 2, };
1778static int x1830_ssi1_ce0_d_funcs[] = { 2, };
1779static int x1830_ssi1_ce1_d_funcs[] = { 2, };
1780static int x1830_mmc0_1bit_funcs[] = { 0, 0, 0, };
1781static int x1830_mmc0_4bit_funcs[] = { 0, 0, 0, };
1782static int x1830_mmc1_1bit_funcs[] = { 0, 0, 0, };
1783static int x1830_mmc1_4bit_funcs[] = { 0, 0, 0, };
1784static int x1830_i2c0_funcs[] = { 1, 1, };
1785static int x1830_i2c1_funcs[] = { 0, 0, };
1786static int x1830_i2c2_funcs[] = { 1, 1, };
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001787static int x1830_lcd_rgb_18bit_funcs[] = {
1788 0, 0, 0, 0, 0, 0,
1789 0, 0, 0, 0, 0, 0,
1790 0, 0, 0, 0, 0, 0,
1791 0, 0, 0, 0,
1792};
1793static int x1830_lcd_slcd_8bit_funcs[] = {
1794 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1795};
1796static int x1830_lcd_slcd_16bit_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, };
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001797static int x1830_pwm_pwm0_b_funcs[] = { 0, };
1798static int x1830_pwm_pwm0_c_funcs[] = { 1, };
1799static int x1830_pwm_pwm1_b_funcs[] = { 0, };
1800static int x1830_pwm_pwm1_c_funcs[] = { 1, };
1801static int x1830_pwm_pwm2_c_8_funcs[] = { 0, };
1802static int x1830_pwm_pwm2_c_13_funcs[] = { 1, };
1803static int x1830_pwm_pwm3_c_9_funcs[] = { 0, };
1804static int x1830_pwm_pwm3_c_14_funcs[] = { 1, };
1805static int x1830_pwm_pwm4_c_15_funcs[] = { 1, };
1806static int x1830_pwm_pwm4_c_25_funcs[] = { 0, };
1807static int x1830_pwm_pwm5_c_16_funcs[] = { 1, };
1808static int x1830_pwm_pwm5_c_26_funcs[] = { 0, };
1809static int x1830_pwm_pwm6_c_17_funcs[] = { 1, };
1810static int x1830_pwm_pwm6_c_27_funcs[] = { 0, };
1811static int x1830_pwm_pwm7_c_18_funcs[] = { 1, };
1812static int x1830_pwm_pwm7_c_28_funcs[] = { 0, };
1813static int x1830_mac_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
1814
1815static const struct group_desc x1830_groups[] = {
1816 INGENIC_PIN_GROUP("uart0-data", x1830_uart0_data),
1817 INGENIC_PIN_GROUP("uart0-hwflow", x1830_uart0_hwflow),
1818 INGENIC_PIN_GROUP("uart1-data", x1830_uart1_data),
1819 INGENIC_PIN_GROUP("sfc", x1830_sfc),
1820 INGENIC_PIN_GROUP("ssi0-dt", x1830_ssi0_dt),
1821 INGENIC_PIN_GROUP("ssi0-dr", x1830_ssi0_dr),
1822 INGENIC_PIN_GROUP("ssi0-clk", x1830_ssi0_clk),
1823 INGENIC_PIN_GROUP("ssi0-gpc", x1830_ssi0_gpc),
1824 INGENIC_PIN_GROUP("ssi0-ce0", x1830_ssi0_ce0),
1825 INGENIC_PIN_GROUP("ssi0-ce1", x1830_ssi0_ce1),
1826 INGENIC_PIN_GROUP("ssi1-dt-c", x1830_ssi1_dt_c),
1827 INGENIC_PIN_GROUP("ssi1-dr-c", x1830_ssi1_dr_c),
1828 INGENIC_PIN_GROUP("ssi1-clk-c", x1830_ssi1_clk_c),
1829 INGENIC_PIN_GROUP("ssi1-gpc-c", x1830_ssi1_gpc_c),
1830 INGENIC_PIN_GROUP("ssi1-ce0-c", x1830_ssi1_ce0_c),
1831 INGENIC_PIN_GROUP("ssi1-ce1-c", x1830_ssi1_ce1_c),
1832 INGENIC_PIN_GROUP("ssi1-dt-d", x1830_ssi1_dt_d),
1833 INGENIC_PIN_GROUP("ssi1-dr-d", x1830_ssi1_dr_d),
1834 INGENIC_PIN_GROUP("ssi1-clk-d", x1830_ssi1_clk_d),
1835 INGENIC_PIN_GROUP("ssi1-gpc-d", x1830_ssi1_gpc_d),
1836 INGENIC_PIN_GROUP("ssi1-ce0-d", x1830_ssi1_ce0_d),
1837 INGENIC_PIN_GROUP("ssi1-ce1-d", x1830_ssi1_ce1_d),
1838 INGENIC_PIN_GROUP("mmc0-1bit", x1830_mmc0_1bit),
1839 INGENIC_PIN_GROUP("mmc0-4bit", x1830_mmc0_4bit),
1840 INGENIC_PIN_GROUP("mmc1-1bit", x1830_mmc1_1bit),
1841 INGENIC_PIN_GROUP("mmc1-4bit", x1830_mmc1_4bit),
1842 INGENIC_PIN_GROUP("i2c0-data", x1830_i2c0),
1843 INGENIC_PIN_GROUP("i2c1-data", x1830_i2c1),
1844 INGENIC_PIN_GROUP("i2c2-data", x1830_i2c2),
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001845 INGENIC_PIN_GROUP("lcd-rgb-18bit", x1830_lcd_rgb_18bit),
1846 INGENIC_PIN_GROUP("lcd-slcd-8bit", x1830_lcd_slcd_8bit),
1847 INGENIC_PIN_GROUP("lcd-slcd-16bit", x1830_lcd_slcd_16bit),
1848 { "lcd-no-pins", },
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001849 INGENIC_PIN_GROUP("pwm0-b", x1830_pwm_pwm0_b),
1850 INGENIC_PIN_GROUP("pwm0-c", x1830_pwm_pwm0_c),
1851 INGENIC_PIN_GROUP("pwm1-b", x1830_pwm_pwm1_b),
1852 INGENIC_PIN_GROUP("pwm1-c", x1830_pwm_pwm1_c),
1853 INGENIC_PIN_GROUP("pwm2-c-8", x1830_pwm_pwm2_c_8),
1854 INGENIC_PIN_GROUP("pwm2-c-13", x1830_pwm_pwm2_c_13),
1855 INGENIC_PIN_GROUP("pwm3-c-9", x1830_pwm_pwm3_c_9),
1856 INGENIC_PIN_GROUP("pwm3-c-14", x1830_pwm_pwm3_c_14),
1857 INGENIC_PIN_GROUP("pwm4-c-15", x1830_pwm_pwm4_c_15),
1858 INGENIC_PIN_GROUP("pwm4-c-25", x1830_pwm_pwm4_c_25),
1859 INGENIC_PIN_GROUP("pwm5-c-16", x1830_pwm_pwm5_c_16),
1860 INGENIC_PIN_GROUP("pwm5-c-26", x1830_pwm_pwm5_c_26),
1861 INGENIC_PIN_GROUP("pwm6-c-17", x1830_pwm_pwm6_c_17),
1862 INGENIC_PIN_GROUP("pwm6-c-27", x1830_pwm_pwm6_c_27),
1863 INGENIC_PIN_GROUP("pwm7-c-18", x1830_pwm_pwm7_c_18),
1864 INGENIC_PIN_GROUP("pwm7-c-28", x1830_pwm_pwm7_c_28),
1865 INGENIC_PIN_GROUP("mac", x1830_mac),
1866};
1867
1868static const char *x1830_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1869static const char *x1830_uart1_groups[] = { "uart1-data", };
1870static const char *x1830_sfc_groups[] = { "sfc", };
1871static const char *x1830_ssi0_groups[] = {
1872 "ssi0-dt", "ssi0-dr", "ssi0-clk", "ssi0-gpc", "ssi0-ce0", "ssi0-ce1",
1873};
1874static const char *x1830_ssi1_groups[] = {
1875 "ssi1-dt-c", "ssi1-dt-d",
1876 "ssi1-dr-c", "ssi1-dr-d",
1877 "ssi1-clk-c", "ssi1-clk-d",
1878 "ssi1-gpc-c", "ssi1-gpc-d",
1879 "ssi1-ce0-c", "ssi1-ce0-d",
1880 "ssi1-ce1-c", "ssi1-ce1-d",
1881};
1882static const char *x1830_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", };
1883static const char *x1830_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
1884static const char *x1830_i2c0_groups[] = { "i2c0-data", };
1885static const char *x1830_i2c1_groups[] = { "i2c1-data", };
1886static const char *x1830_i2c2_groups[] = { "i2c2-data", };
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001887static const char *x1830_lcd_groups[] = {
1888 "lcd-rgb-18bit", "lcd-slcd-8bit", "lcd-slcd-16bit", "lcd-no-pins",
1889};
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001890static const char *x1830_pwm0_groups[] = { "pwm0-b", "pwm0-c", };
1891static const char *x1830_pwm1_groups[] = { "pwm1-b", "pwm1-c", };
1892static const char *x1830_pwm2_groups[] = { "pwm2-c-8", "pwm2-c-13", };
1893static const char *x1830_pwm3_groups[] = { "pwm3-c-9", "pwm3-c-14", };
1894static const char *x1830_pwm4_groups[] = { "pwm4-c-15", "pwm4-c-25", };
1895static const char *x1830_pwm5_groups[] = { "pwm5-c-16", "pwm5-c-26", };
1896static const char *x1830_pwm6_groups[] = { "pwm6-c-17", "pwm6-c-27", };
1897static const char *x1830_pwm7_groups[] = { "pwm7-c-18", "pwm7-c-28", };
1898static const char *x1830_mac_groups[] = { "mac", };
1899
1900static const struct function_desc x1830_functions[] = {
1901 { "uart0", x1830_uart0_groups, ARRAY_SIZE(x1830_uart0_groups), },
1902 { "uart1", x1830_uart1_groups, ARRAY_SIZE(x1830_uart1_groups), },
1903 { "sfc", x1830_sfc_groups, ARRAY_SIZE(x1830_sfc_groups), },
1904 { "ssi0", x1830_ssi0_groups, ARRAY_SIZE(x1830_ssi0_groups), },
1905 { "ssi1", x1830_ssi1_groups, ARRAY_SIZE(x1830_ssi1_groups), },
1906 { "mmc0", x1830_mmc0_groups, ARRAY_SIZE(x1830_mmc0_groups), },
1907 { "mmc1", x1830_mmc1_groups, ARRAY_SIZE(x1830_mmc1_groups), },
1908 { "i2c0", x1830_i2c0_groups, ARRAY_SIZE(x1830_i2c0_groups), },
1909 { "i2c1", x1830_i2c1_groups, ARRAY_SIZE(x1830_i2c1_groups), },
1910 { "i2c2", x1830_i2c2_groups, ARRAY_SIZE(x1830_i2c2_groups), },
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001911 { "lcd", x1830_lcd_groups, ARRAY_SIZE(x1830_lcd_groups), },
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001912 { "pwm0", x1830_pwm0_groups, ARRAY_SIZE(x1830_pwm0_groups), },
1913 { "pwm1", x1830_pwm1_groups, ARRAY_SIZE(x1830_pwm1_groups), },
1914 { "pwm2", x1830_pwm2_groups, ARRAY_SIZE(x1830_pwm2_groups), },
1915 { "pwm3", x1830_pwm3_groups, ARRAY_SIZE(x1830_pwm3_groups), },
1916 { "pwm4", x1830_pwm4_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1917 { "pwm5", x1830_pwm5_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1918 { "pwm6", x1830_pwm6_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1919 { "pwm7", x1830_pwm7_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1920 { "mac", x1830_mac_groups, ARRAY_SIZE(x1830_mac_groups), },
1921};
1922
1923static const struct ingenic_chip_info x1830_chip_info = {
1924 .num_chips = 4,
1925 .reg_offset = 0x1000,
Paul Cercueilbaf15642020-01-07 00:27:08 +01001926 .version = ID_X1830,
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001927 .groups = x1830_groups,
1928 .num_groups = ARRAY_SIZE(x1830_groups),
1929 .functions = x1830_functions,
1930 .num_functions = ARRAY_SIZE(x1830_functions),
1931 .pull_ups = x1830_pull_ups,
1932 .pull_downs = x1830_pull_downs,
1933};
1934
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001935static u32 ingenic_gpio_read_reg(struct ingenic_gpio_chip *jzgc, u8 reg)
Paul Cercueile72394e2018-08-21 18:42:32 +02001936{
1937 unsigned int val;
1938
1939 regmap_read(jzgc->jzpc->map, jzgc->reg_base + reg, &val);
1940
1941 return (u32) val;
1942}
1943
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001944static void ingenic_gpio_set_bit(struct ingenic_gpio_chip *jzgc,
Paul Cercueile72394e2018-08-21 18:42:32 +02001945 u8 reg, u8 offset, bool set)
1946{
1947 if (set)
1948 reg = REG_SET(reg);
1949 else
1950 reg = REG_CLEAR(reg);
1951
1952 regmap_write(jzgc->jzpc->map, jzgc->reg_base + reg, BIT(offset));
1953}
1954
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001955static void ingenic_gpio_shadow_set_bit(struct ingenic_gpio_chip *jzgc,
1956 u8 reg, u8 offset, bool set)
1957{
1958 if (set)
1959 reg = REG_SET(reg);
1960 else
1961 reg = REG_CLEAR(reg);
1962
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001963 regmap_write(jzgc->jzpc->map, REG_PZ_BASE(
1964 jzgc->jzpc->info->reg_offset) + reg, BIT(offset));
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001965}
1966
1967static void ingenic_gpio_shadow_set_bit_load(struct ingenic_gpio_chip *jzgc)
1968{
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001969 regmap_write(jzgc->jzpc->map, REG_PZ_GID2LD(
1970 jzgc->jzpc->info->reg_offset),
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001971 jzgc->gc.base / PINS_PER_GPIO_CHIP);
1972}
1973
Paul Cercueile72394e2018-08-21 18:42:32 +02001974static inline bool ingenic_gpio_get_value(struct ingenic_gpio_chip *jzgc,
1975 u8 offset)
1976{
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001977 unsigned int val = ingenic_gpio_read_reg(jzgc, GPIO_PIN);
Paul Cercueile72394e2018-08-21 18:42:32 +02001978
1979 return !!(val & BIT(offset));
1980}
1981
1982static void ingenic_gpio_set_value(struct ingenic_gpio_chip *jzgc,
1983 u8 offset, int value)
1984{
Paul Cercueilbaf15642020-01-07 00:27:08 +01001985 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08001986 ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_PAT0, offset, !!value);
Paul Cercueile72394e2018-08-21 18:42:32 +02001987 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001988 ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, offset, !!value);
Paul Cercueile72394e2018-08-21 18:42:32 +02001989}
1990
1991static void irq_set_type(struct ingenic_gpio_chip *jzgc,
1992 u8 offset, unsigned int type)
1993{
1994 u8 reg1, reg2;
Paul Cercueilf831f932020-01-07 00:27:10 +01001995 bool val1, val2;
1996
1997 switch (type) {
1998 case IRQ_TYPE_EDGE_RISING:
1999 val1 = val2 = true;
2000 break;
2001 case IRQ_TYPE_EDGE_FALLING:
2002 val1 = false;
2003 val2 = true;
2004 break;
2005 case IRQ_TYPE_LEVEL_HIGH:
2006 val1 = true;
2007 val2 = false;
2008 break;
2009 case IRQ_TYPE_LEVEL_LOW:
2010 default:
2011 val1 = val2 = false;
2012 break;
2013 }
Paul Cercueile72394e2018-08-21 18:42:32 +02002014
Paul Cercueilbaf15642020-01-07 00:27:08 +01002015 if (jzgc->jzpc->info->version >= ID_JZ4760) {
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002016 reg1 = JZ4760_GPIO_PAT1;
2017 reg2 = JZ4760_GPIO_PAT0;
Paul Cercueile72394e2018-08-21 18:42:32 +02002018 } else {
2019 reg1 = JZ4740_GPIO_TRIG;
2020 reg2 = JZ4740_GPIO_DIR;
2021 }
2022
Paul Cercueilf831f932020-01-07 00:27:10 +01002023 if (jzgc->jzpc->info->version >= ID_X1000) {
2024 ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, val1);
2025 ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, val2);
2026 ingenic_gpio_shadow_set_bit_load(jzgc);
2027 } else {
2028 ingenic_gpio_set_bit(jzgc, reg2, offset, val1);
2029 ingenic_gpio_set_bit(jzgc, reg1, offset, val2);
Paul Cercueile72394e2018-08-21 18:42:32 +02002030 }
2031}
2032
2033static void ingenic_gpio_irq_mask(struct irq_data *irqd)
2034{
2035 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2036 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2037
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002038 ingenic_gpio_set_bit(jzgc, GPIO_MSK, irqd->hwirq, true);
Paul Cercueile72394e2018-08-21 18:42:32 +02002039}
2040
2041static void ingenic_gpio_irq_unmask(struct irq_data *irqd)
2042{
2043 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2044 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2045
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002046 ingenic_gpio_set_bit(jzgc, GPIO_MSK, irqd->hwirq, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002047}
2048
2049static void ingenic_gpio_irq_enable(struct irq_data *irqd)
2050{
2051 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2052 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2053 int irq = irqd->hwirq;
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_INT, irq, true);
Paul Cercueile72394e2018-08-21 18:42:32 +02002057 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002058 ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, true);
Paul Cercueile72394e2018-08-21 18:42:32 +02002059
2060 ingenic_gpio_irq_unmask(irqd);
2061}
2062
2063static void ingenic_gpio_irq_disable(struct irq_data *irqd)
2064{
2065 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2066 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2067 int irq = irqd->hwirq;
2068
2069 ingenic_gpio_irq_mask(irqd);
2070
Paul Cercueilbaf15642020-01-07 00:27:08 +01002071 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002072 ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_INT, irq, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002073 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002074 ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002075}
2076
2077static void ingenic_gpio_irq_ack(struct irq_data *irqd)
2078{
2079 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2080 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2081 int irq = irqd->hwirq;
2082 bool high;
2083
2084 if (irqd_get_trigger_type(irqd) == IRQ_TYPE_EDGE_BOTH) {
2085 /*
2086 * Switch to an interrupt for the opposite edge to the one that
2087 * triggered the interrupt being ACKed.
2088 */
2089 high = ingenic_gpio_get_value(jzgc, irq);
2090 if (high)
Paul Cercueil1c953482020-06-22 23:45:47 +02002091 irq_set_type(jzgc, irq, IRQ_TYPE_LEVEL_LOW);
Paul Cercueile72394e2018-08-21 18:42:32 +02002092 else
Paul Cercueil1c953482020-06-22 23:45:47 +02002093 irq_set_type(jzgc, irq, IRQ_TYPE_LEVEL_HIGH);
Paul Cercueile72394e2018-08-21 18:42:32 +02002094 }
2095
Paul Cercueilbaf15642020-01-07 00:27:08 +01002096 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002097 ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_FLAG, irq, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002098 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002099 ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, irq, true);
Paul Cercueile72394e2018-08-21 18:42:32 +02002100}
2101
2102static int ingenic_gpio_irq_set_type(struct irq_data *irqd, unsigned int type)
2103{
2104 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2105 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2106
2107 switch (type) {
2108 case IRQ_TYPE_EDGE_BOTH:
2109 case IRQ_TYPE_EDGE_RISING:
2110 case IRQ_TYPE_EDGE_FALLING:
2111 irq_set_handler_locked(irqd, handle_edge_irq);
2112 break;
2113 case IRQ_TYPE_LEVEL_HIGH:
2114 case IRQ_TYPE_LEVEL_LOW:
2115 irq_set_handler_locked(irqd, handle_level_irq);
2116 break;
2117 default:
2118 irq_set_handler_locked(irqd, handle_bad_irq);
2119 }
2120
2121 if (type == IRQ_TYPE_EDGE_BOTH) {
2122 /*
2123 * The hardware does not support interrupts on both edges. The
2124 * best we can do is to set up a single-edge interrupt and then
2125 * switch to the opposing edge when ACKing the interrupt.
2126 */
2127 bool high = ingenic_gpio_get_value(jzgc, irqd->hwirq);
2128
Paul Cercueil1c953482020-06-22 23:45:47 +02002129 type = high ? IRQ_TYPE_LEVEL_LOW : IRQ_TYPE_LEVEL_HIGH;
Paul Cercueile72394e2018-08-21 18:42:32 +02002130 }
2131
2132 irq_set_type(jzgc, irqd->hwirq, type);
2133 return 0;
2134}
2135
2136static int ingenic_gpio_irq_set_wake(struct irq_data *irqd, unsigned int on)
2137{
2138 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
2139 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2140
2141 return irq_set_irq_wake(jzgc->irq, on);
2142}
2143
2144static void ingenic_gpio_irq_handler(struct irq_desc *desc)
2145{
2146 struct gpio_chip *gc = irq_desc_get_handler_data(desc);
2147 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2148 struct irq_chip *irq_chip = irq_data_get_irq_chip(&desc->irq_data);
2149 unsigned long flag, i;
2150
2151 chained_irq_enter(irq_chip, desc);
2152
Paul Cercueilbaf15642020-01-07 00:27:08 +01002153 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002154 flag = ingenic_gpio_read_reg(jzgc, JZ4760_GPIO_FLAG);
Paul Cercueile72394e2018-08-21 18:42:32 +02002155 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08002156 flag = ingenic_gpio_read_reg(jzgc, JZ4740_GPIO_FLAG);
Paul Cercueile72394e2018-08-21 18:42:32 +02002157
2158 for_each_set_bit(i, &flag, 32)
2159 generic_handle_irq(irq_linear_revmap(gc->irq.domain, i));
2160 chained_irq_exit(irq_chip, desc);
2161}
2162
2163static void ingenic_gpio_set(struct gpio_chip *gc,
2164 unsigned int offset, int value)
2165{
2166 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2167
2168 ingenic_gpio_set_value(jzgc, offset, value);
2169}
2170
2171static int ingenic_gpio_get(struct gpio_chip *gc, unsigned int offset)
2172{
2173 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2174
2175 return (int) ingenic_gpio_get_value(jzgc, offset);
2176}
2177
2178static int ingenic_gpio_direction_input(struct gpio_chip *gc,
2179 unsigned int offset)
2180{
2181 return pinctrl_gpio_direction_input(gc->base + offset);
2182}
2183
2184static int ingenic_gpio_direction_output(struct gpio_chip *gc,
2185 unsigned int offset, int value)
2186{
2187 ingenic_gpio_set(gc, offset, value);
2188 return pinctrl_gpio_direction_output(gc->base + offset);
2189}
2190
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002191static inline void ingenic_config_pin(struct ingenic_pinctrl *jzpc,
2192 unsigned int pin, u8 reg, bool set)
2193{
2194 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2195 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2196
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08002197 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002198 (set ? REG_SET(reg) : REG_CLEAR(reg)), BIT(idx));
2199}
2200
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002201static inline void ingenic_shadow_config_pin(struct ingenic_pinctrl *jzpc,
2202 unsigned int pin, u8 reg, bool set)
2203{
2204 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2205
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08002206 regmap_write(jzpc->map, REG_PZ_BASE(jzpc->info->reg_offset) +
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002207 (set ? REG_SET(reg) : REG_CLEAR(reg)), BIT(idx));
2208}
2209
2210static inline void ingenic_shadow_config_pin_load(struct ingenic_pinctrl *jzpc,
2211 unsigned int pin)
2212{
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002213 regmap_write(jzpc->map, REG_PZ_GID2LD(jzpc->info->reg_offset),
2214 pin / PINS_PER_GPIO_CHIP);
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002215}
2216
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002217static inline bool ingenic_get_pin_config(struct ingenic_pinctrl *jzpc,
2218 unsigned int pin, u8 reg)
2219{
2220 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2221 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2222 unsigned int val;
2223
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08002224 regmap_read(jzpc->map, offt * jzpc->info->reg_offset + reg, &val);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002225
2226 return val & BIT(idx);
2227}
2228
Paul Cercueilebd66512018-08-21 18:42:33 +02002229static int ingenic_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
2230{
2231 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
2232 struct ingenic_pinctrl *jzpc = jzgc->jzpc;
2233 unsigned int pin = gc->base + offset;
2234
Matti Vaittinen3c827872020-02-14 15:57:12 +02002235 if (jzpc->info->version >= ID_JZ4760) {
Paul Cercueil84e7a942020-06-22 23:45:48 +02002236 if (ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_INT) ||
2237 ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_PAT1))
Matti Vaittinen3c827872020-02-14 15:57:12 +02002238 return GPIO_LINE_DIRECTION_IN;
2239 return GPIO_LINE_DIRECTION_OUT;
2240 }
Paul Cercueilebd66512018-08-21 18:42:33 +02002241
2242 if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_SELECT))
Matti Vaittinen3c827872020-02-14 15:57:12 +02002243 return GPIO_LINE_DIRECTION_IN;
Paul Cercueilebd66512018-08-21 18:42:33 +02002244
Matti Vaittinen3c827872020-02-14 15:57:12 +02002245 if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_DIR))
2246 return GPIO_LINE_DIRECTION_OUT;
2247
2248 return GPIO_LINE_DIRECTION_IN;
Paul Cercueilebd66512018-08-21 18:42:33 +02002249}
2250
Julia Lawall5bf7b842017-08-10 12:06:23 +02002251static const struct pinctrl_ops ingenic_pctlops = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002252 .get_groups_count = pinctrl_generic_get_group_count,
2253 .get_group_name = pinctrl_generic_get_group_name,
2254 .get_group_pins = pinctrl_generic_get_group_pins,
2255 .dt_node_to_map = pinconf_generic_dt_node_to_map_all,
2256 .dt_free_map = pinconf_generic_dt_free_map,
2257};
2258
Paul Cercueil9a0f1342020-05-03 18:45:49 +02002259static int ingenic_gpio_irq_request(struct irq_data *data)
2260{
2261 struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
2262 int ret;
2263
2264 ret = ingenic_gpio_direction_input(gpio_chip, data->hwirq);
2265 if (ret)
2266 return ret;
2267
2268 return gpiochip_reqres_irq(gpio_chip, data->hwirq);
2269}
2270
2271static void ingenic_gpio_irq_release(struct irq_data *data)
2272{
2273 struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
2274
2275 return gpiochip_relres_irq(gpio_chip, data->hwirq);
2276}
2277
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002278static int ingenic_pinmux_set_pin_fn(struct ingenic_pinctrl *jzpc,
2279 int pin, int func)
2280{
2281 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2282 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2283
2284 dev_dbg(jzpc->dev, "set pin P%c%u to function %u\n",
2285 'A' + offt, idx, func);
2286
Paul Cercueilbaf15642020-01-07 00:27:08 +01002287 if (jzpc->info->version >= ID_X1000) {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002288 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
2289 ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, false);
2290 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, func & 0x2);
2291 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, func & 0x1);
2292 ingenic_shadow_config_pin_load(jzpc, pin);
Paul Cercueilbaf15642020-01-07 00:27:08 +01002293 } else if (jzpc->info->version >= ID_JZ4760) {
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002294 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002295 ingenic_config_pin(jzpc, pin, GPIO_MSK, false);
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002296 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, func & 0x2);
2297 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, func & 0x1);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002298 } else {
2299 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, true);
2300 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_TRIG, func & 0x2);
2301 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, func > 0);
2302 }
2303
2304 return 0;
2305}
2306
2307static int ingenic_pinmux_set_mux(struct pinctrl_dev *pctldev,
2308 unsigned int selector, unsigned int group)
2309{
2310 struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2311 struct function_desc *func;
2312 struct group_desc *grp;
2313 unsigned int i;
2314
2315 func = pinmux_generic_get_function(pctldev, selector);
2316 if (!func)
2317 return -EINVAL;
2318
2319 grp = pinctrl_generic_get_group(pctldev, group);
2320 if (!grp)
2321 return -EINVAL;
2322
2323 dev_dbg(pctldev->dev, "enable function %s group %s\n",
2324 func->name, grp->name);
2325
2326 for (i = 0; i < grp->num_pins; i++) {
2327 int *pin_modes = grp->data;
2328
2329 ingenic_pinmux_set_pin_fn(jzpc, grp->pins[i], pin_modes[i]);
2330 }
2331
2332 return 0;
2333}
2334
2335static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
2336 struct pinctrl_gpio_range *range,
2337 unsigned int pin, bool input)
2338{
2339 struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2340 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2341 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2342
2343 dev_dbg(pctldev->dev, "set pin P%c%u to %sput\n",
2344 'A' + offt, idx, input ? "in" : "out");
2345
Paul Cercueilbaf15642020-01-07 00:27:08 +01002346 if (jzpc->info->version >= ID_X1000) {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002347 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
2348 ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, true);
2349 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, input);
2350 ingenic_shadow_config_pin_load(jzpc, pin);
Paul Cercueilbaf15642020-01-07 00:27:08 +01002351 } else if (jzpc->info->version >= ID_JZ4760) {
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002352 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002353 ingenic_config_pin(jzpc, pin, GPIO_MSK, true);
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002354 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, input);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002355 } else {
2356 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, false);
Paul Cercueil0084a782018-06-27 13:49:02 +02002357 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, !input);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002358 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, false);
2359 }
2360
2361 return 0;
2362}
2363
Julia Lawall5bf7b842017-08-10 12:06:23 +02002364static const struct pinmux_ops ingenic_pmxops = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002365 .get_functions_count = pinmux_generic_get_function_count,
2366 .get_function_name = pinmux_generic_get_function_name,
2367 .get_function_groups = pinmux_generic_get_function_groups,
2368 .set_mux = ingenic_pinmux_set_mux,
2369 .gpio_set_direction = ingenic_pinmux_gpio_set_direction,
2370};
2371
2372static int ingenic_pinconf_get(struct pinctrl_dev *pctldev,
2373 unsigned int pin, unsigned long *config)
2374{
2375 struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2376 enum pin_config_param param = pinconf_to_config_param(*config);
2377 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2378 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2379 bool pull;
2380
Paul Cercueilbaf15642020-01-07 00:27:08 +01002381 if (jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002382 pull = !ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_PEN);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002383 else
2384 pull = !ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_PULL_DIS);
2385
2386 switch (param) {
2387 case PIN_CONFIG_BIAS_DISABLE:
2388 if (pull)
2389 return -EINVAL;
2390 break;
2391
2392 case PIN_CONFIG_BIAS_PULL_UP:
2393 if (!pull || !(jzpc->info->pull_ups[offt] & BIT(idx)))
2394 return -EINVAL;
2395 break;
2396
2397 case PIN_CONFIG_BIAS_PULL_DOWN:
2398 if (!pull || !(jzpc->info->pull_downs[offt] & BIT(idx)))
2399 return -EINVAL;
2400 break;
2401
2402 default:
2403 return -ENOTSUPP;
2404 }
2405
2406 *config = pinconf_to_config_packed(param, 1);
2407 return 0;
2408}
2409
2410static void ingenic_set_bias(struct ingenic_pinctrl *jzpc,
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002411 unsigned int pin, unsigned int bias)
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002412{
Paul Cercueilbaf15642020-01-07 00:27:08 +01002413 if (jzpc->info->version >= ID_X1830) {
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002414 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2415 unsigned int half = PINS_PER_GPIO_CHIP / 2;
2416 unsigned int idxh = pin % half * 2;
2417 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2418
2419 if (idx < half) {
2420 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2421 REG_CLEAR(X1830_GPIO_PEL), 3 << idxh);
2422 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2423 REG_SET(X1830_GPIO_PEL), bias << idxh);
2424 } else {
2425 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2426 REG_CLEAR(X1830_GPIO_PEH), 3 << idxh);
2427 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2428 REG_SET(X1830_GPIO_PEH), bias << idxh);
2429 }
2430
Paul Cercueilbaf15642020-01-07 00:27:08 +01002431 } else if (jzpc->info->version >= ID_JZ4760) {
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002432 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PEN, !bias);
2433 } else {
2434 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_PULL_DIS, !bias);
2435 }
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002436}
2437
Paul Cercueil7009d042019-11-19 16:52:10 +01002438static void ingenic_set_output_level(struct ingenic_pinctrl *jzpc,
2439 unsigned int pin, bool high)
2440{
Paul Cercueilbaf15642020-01-07 00:27:08 +01002441 if (jzpc->info->version >= ID_JZ4760)
Paul Cercueil7009d042019-11-19 16:52:10 +01002442 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, high);
2443 else
2444 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DATA, high);
2445}
2446
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002447static int ingenic_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
2448 unsigned long *configs, unsigned int num_configs)
2449{
2450 struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2451 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2452 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
Paul Cercueil7009d042019-11-19 16:52:10 +01002453 unsigned int cfg, arg;
2454 int ret;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002455
2456 for (cfg = 0; cfg < num_configs; cfg++) {
2457 switch (pinconf_to_config_param(configs[cfg])) {
2458 case PIN_CONFIG_BIAS_DISABLE:
2459 case PIN_CONFIG_BIAS_PULL_UP:
2460 case PIN_CONFIG_BIAS_PULL_DOWN:
Paul Cercueil7009d042019-11-19 16:52:10 +01002461 case PIN_CONFIG_OUTPUT:
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002462 continue;
2463 default:
2464 return -ENOTSUPP;
2465 }
2466 }
2467
2468 for (cfg = 0; cfg < num_configs; cfg++) {
Paul Cercueil7009d042019-11-19 16:52:10 +01002469 arg = pinconf_to_config_argument(configs[cfg]);
2470
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002471 switch (pinconf_to_config_param(configs[cfg])) {
2472 case PIN_CONFIG_BIAS_DISABLE:
2473 dev_dbg(jzpc->dev, "disable pull-over for pin P%c%u\n",
2474 'A' + offt, idx);
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002475 ingenic_set_bias(jzpc, pin, GPIO_PULL_DIS);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002476 break;
2477
2478 case PIN_CONFIG_BIAS_PULL_UP:
2479 if (!(jzpc->info->pull_ups[offt] & BIT(idx)))
2480 return -EINVAL;
2481 dev_dbg(jzpc->dev, "set pull-up for pin P%c%u\n",
2482 'A' + offt, idx);
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002483 ingenic_set_bias(jzpc, pin, GPIO_PULL_UP);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002484 break;
2485
2486 case PIN_CONFIG_BIAS_PULL_DOWN:
2487 if (!(jzpc->info->pull_downs[offt] & BIT(idx)))
2488 return -EINVAL;
2489 dev_dbg(jzpc->dev, "set pull-down for pin P%c%u\n",
2490 'A' + offt, idx);
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002491 ingenic_set_bias(jzpc, pin, GPIO_PULL_DOWN);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002492 break;
2493
Paul Cercueil7009d042019-11-19 16:52:10 +01002494 case PIN_CONFIG_OUTPUT:
2495 ret = pinctrl_gpio_direction_output(pin);
2496 if (ret)
2497 return ret;
2498
2499 ingenic_set_output_level(jzpc, pin, arg);
2500 break;
2501
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002502 default:
Josh Poimboeufd6d43a92020-02-20 09:35:09 -06002503 /* unreachable */
2504 break;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002505 }
2506 }
2507
2508 return 0;
2509}
2510
2511static int ingenic_pinconf_group_get(struct pinctrl_dev *pctldev,
2512 unsigned int group, unsigned long *config)
2513{
2514 const unsigned int *pins;
2515 unsigned int i, npins, old = 0;
2516 int ret;
2517
2518 ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
2519 if (ret)
2520 return ret;
2521
2522 for (i = 0; i < npins; i++) {
2523 if (ingenic_pinconf_get(pctldev, pins[i], config))
2524 return -ENOTSUPP;
2525
2526 /* configs do not match between two pins */
2527 if (i && (old != *config))
2528 return -ENOTSUPP;
2529
2530 old = *config;
2531 }
2532
2533 return 0;
2534}
2535
2536static int ingenic_pinconf_group_set(struct pinctrl_dev *pctldev,
2537 unsigned int group, unsigned long *configs,
2538 unsigned int num_configs)
2539{
2540 const unsigned int *pins;
2541 unsigned int i, npins;
2542 int ret;
2543
2544 ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
2545 if (ret)
2546 return ret;
2547
2548 for (i = 0; i < npins; i++) {
2549 ret = ingenic_pinconf_set(pctldev,
2550 pins[i], configs, num_configs);
2551 if (ret)
2552 return ret;
2553 }
2554
2555 return 0;
2556}
2557
Julia Lawall5bf7b842017-08-10 12:06:23 +02002558static const struct pinconf_ops ingenic_confops = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002559 .is_generic = true,
2560 .pin_config_get = ingenic_pinconf_get,
2561 .pin_config_set = ingenic_pinconf_set,
2562 .pin_config_group_get = ingenic_pinconf_group_get,
2563 .pin_config_group_set = ingenic_pinconf_group_set,
2564};
2565
2566static const struct regmap_config ingenic_pinctrl_regmap_config = {
2567 .reg_bits = 32,
2568 .val_bits = 32,
2569 .reg_stride = 4,
2570};
2571
Paul Cercueile72394e2018-08-21 18:42:32 +02002572static const struct of_device_id ingenic_gpio_of_match[] __initconst = {
2573 { .compatible = "ingenic,jz4740-gpio", },
Paul Cercueilb5fc06a2020-06-12 14:06:09 +02002574 { .compatible = "ingenic,jz4725b-gpio", },
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002575 { .compatible = "ingenic,jz4760-gpio", },
Paul Cercueile72394e2018-08-21 18:42:32 +02002576 { .compatible = "ingenic,jz4770-gpio", },
2577 { .compatible = "ingenic,jz4780-gpio", },
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002578 { .compatible = "ingenic,x1000-gpio", },
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002579 { .compatible = "ingenic,x1830-gpio", },
Paul Cercueile72394e2018-08-21 18:42:32 +02002580 {},
2581};
2582
2583static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,
2584 struct device_node *node)
2585{
2586 struct ingenic_gpio_chip *jzgc;
2587 struct device *dev = jzpc->dev;
Linus Walleij142b8762019-10-01 15:32:09 +02002588 struct gpio_irq_chip *girq;
Paul Cercueile72394e2018-08-21 18:42:32 +02002589 unsigned int bank;
2590 int err;
2591
2592 err = of_property_read_u32(node, "reg", &bank);
2593 if (err) {
2594 dev_err(dev, "Cannot read \"reg\" property: %i\n", err);
2595 return err;
2596 }
2597
2598 jzgc = devm_kzalloc(dev, sizeof(*jzgc), GFP_KERNEL);
2599 if (!jzgc)
2600 return -ENOMEM;
2601
2602 jzgc->jzpc = jzpc;
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08002603 jzgc->reg_base = bank * jzpc->info->reg_offset;
Paul Cercueile72394e2018-08-21 18:42:32 +02002604
2605 jzgc->gc.label = devm_kasprintf(dev, GFP_KERNEL, "GPIO%c", 'A' + bank);
2606 if (!jzgc->gc.label)
2607 return -ENOMEM;
2608
2609 /* DO NOT EXPAND THIS: FOR BACKWARD GPIO NUMBERSPACE COMPATIBIBILITY
2610 * ONLY: WORK TO TRANSITION CONSUMERS TO USE THE GPIO DESCRIPTOR API IN
2611 * <linux/gpio/consumer.h> INSTEAD.
2612 */
2613 jzgc->gc.base = bank * 32;
2614
2615 jzgc->gc.ngpio = 32;
2616 jzgc->gc.parent = dev;
2617 jzgc->gc.of_node = node;
2618 jzgc->gc.owner = THIS_MODULE;
2619
2620 jzgc->gc.set = ingenic_gpio_set;
2621 jzgc->gc.get = ingenic_gpio_get;
2622 jzgc->gc.direction_input = ingenic_gpio_direction_input;
2623 jzgc->gc.direction_output = ingenic_gpio_direction_output;
Paul Cercueilebd66512018-08-21 18:42:33 +02002624 jzgc->gc.get_direction = ingenic_gpio_get_direction;
Thierry Redingd6471d62020-04-01 22:05:27 +02002625 jzgc->gc.request = gpiochip_generic_request;
2626 jzgc->gc.free = gpiochip_generic_free;
Paul Cercueile72394e2018-08-21 18:42:32 +02002627
Paul Cercueile72394e2018-08-21 18:42:32 +02002628 jzgc->irq = irq_of_parse_and_map(node, 0);
2629 if (!jzgc->irq)
2630 return -EINVAL;
2631
2632 jzgc->irq_chip.name = jzgc->gc.label;
2633 jzgc->irq_chip.irq_enable = ingenic_gpio_irq_enable;
2634 jzgc->irq_chip.irq_disable = ingenic_gpio_irq_disable;
2635 jzgc->irq_chip.irq_unmask = ingenic_gpio_irq_unmask;
2636 jzgc->irq_chip.irq_mask = ingenic_gpio_irq_mask;
2637 jzgc->irq_chip.irq_ack = ingenic_gpio_irq_ack;
2638 jzgc->irq_chip.irq_set_type = ingenic_gpio_irq_set_type;
2639 jzgc->irq_chip.irq_set_wake = ingenic_gpio_irq_set_wake;
Paul Cercueil9a0f1342020-05-03 18:45:49 +02002640 jzgc->irq_chip.irq_request_resources = ingenic_gpio_irq_request;
2641 jzgc->irq_chip.irq_release_resources = ingenic_gpio_irq_release;
Paul Cercueile72394e2018-08-21 18:42:32 +02002642 jzgc->irq_chip.flags = IRQCHIP_MASK_ON_SUSPEND;
2643
Linus Walleij142b8762019-10-01 15:32:09 +02002644 girq = &jzgc->gc.irq;
2645 girq->chip = &jzgc->irq_chip;
2646 girq->parent_handler = ingenic_gpio_irq_handler;
2647 girq->num_parents = 1;
2648 girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
2649 GFP_KERNEL);
2650 if (!girq->parents)
2651 return -ENOMEM;
2652 girq->parents[0] = jzgc->irq;
2653 girq->default_type = IRQ_TYPE_NONE;
2654 girq->handler = handle_level_irq;
2655
2656 err = devm_gpiochip_add_data(dev, &jzgc->gc, jzgc);
Paul Cercueile72394e2018-08-21 18:42:32 +02002657 if (err)
2658 return err;
2659
Paul Cercueile72394e2018-08-21 18:42:32 +02002660 return 0;
2661}
2662
Paul Cercueil4717b112018-08-21 18:42:31 +02002663static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002664{
2665 struct device *dev = &pdev->dev;
2666 struct ingenic_pinctrl *jzpc;
2667 struct pinctrl_desc *pctl_desc;
2668 void __iomem *base;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002669 const struct ingenic_chip_info *chip_info;
Paul Cercueile72394e2018-08-21 18:42:32 +02002670 struct device_node *node;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002671 unsigned int i;
2672 int err;
2673
2674 jzpc = devm_kzalloc(dev, sizeof(*jzpc), GFP_KERNEL);
2675 if (!jzpc)
2676 return -ENOMEM;
2677
Paul Cercueil94f7a2c2020-01-07 00:27:11 +01002678 base = devm_platform_ioremap_resource(pdev, 0);
Wei Yongjun119fcf42018-01-17 11:29:17 +00002679 if (IS_ERR(base))
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002680 return PTR_ERR(base);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002681
2682 jzpc->map = devm_regmap_init_mmio(dev, base,
2683 &ingenic_pinctrl_regmap_config);
2684 if (IS_ERR(jzpc->map)) {
2685 dev_err(dev, "Failed to create regmap\n");
2686 return PTR_ERR(jzpc->map);
2687 }
2688
2689 jzpc->dev = dev;
Paul Cercueilbaf15642020-01-07 00:27:08 +01002690 jzpc->info = chip_info = of_device_get_match_data(dev);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002691
2692 pctl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctl_desc), GFP_KERNEL);
2693 if (!pctl_desc)
2694 return -ENOMEM;
2695
2696 /* fill in pinctrl_desc structure */
2697 pctl_desc->name = dev_name(dev);
2698 pctl_desc->owner = THIS_MODULE;
2699 pctl_desc->pctlops = &ingenic_pctlops;
2700 pctl_desc->pmxops = &ingenic_pmxops;
2701 pctl_desc->confops = &ingenic_confops;
2702 pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP;
Kees Cooka86854d2018-06-12 14:07:58 -07002703 pctl_desc->pins = jzpc->pdesc = devm_kcalloc(&pdev->dev,
2704 pctl_desc->npins, sizeof(*jzpc->pdesc), GFP_KERNEL);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002705 if (!jzpc->pdesc)
2706 return -ENOMEM;
2707
2708 for (i = 0; i < pctl_desc->npins; i++) {
2709 jzpc->pdesc[i].number = i;
2710 jzpc->pdesc[i].name = kasprintf(GFP_KERNEL, "P%c%d",
2711 'A' + (i / PINS_PER_GPIO_CHIP),
2712 i % PINS_PER_GPIO_CHIP);
2713 }
2714
2715 jzpc->pctl = devm_pinctrl_register(dev, pctl_desc, jzpc);
Dan Carpentere7f4c4b2017-06-14 12:12:09 +03002716 if (IS_ERR(jzpc->pctl)) {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002717 dev_err(dev, "Failed to register pinctrl\n");
Dan Carpentere7f4c4b2017-06-14 12:12:09 +03002718 return PTR_ERR(jzpc->pctl);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002719 }
2720
2721 for (i = 0; i < chip_info->num_groups; i++) {
2722 const struct group_desc *group = &chip_info->groups[i];
2723
2724 err = pinctrl_generic_add_group(jzpc->pctl, group->name,
2725 group->pins, group->num_pins, group->data);
Paul Burton823dd712018-08-25 10:53:28 -07002726 if (err < 0) {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002727 dev_err(dev, "Failed to register group %s\n",
2728 group->name);
2729 return err;
2730 }
2731 }
2732
2733 for (i = 0; i < chip_info->num_functions; i++) {
2734 const struct function_desc *func = &chip_info->functions[i];
2735
2736 err = pinmux_generic_add_function(jzpc->pctl, func->name,
2737 func->group_names, func->num_group_names,
2738 func->data);
Paul Burton823dd712018-08-25 10:53:28 -07002739 if (err < 0) {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002740 dev_err(dev, "Failed to register function %s\n",
2741 func->name);
2742 return err;
2743 }
2744 }
2745
2746 dev_set_drvdata(dev, jzpc->map);
2747
Paul Cercueile72394e2018-08-21 18:42:32 +02002748 for_each_child_of_node(dev->of_node, node) {
2749 if (of_match_node(ingenic_gpio_of_match, node)) {
2750 err = ingenic_gpio_probe(jzpc, node);
2751 if (err)
2752 return err;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002753 }
2754 }
2755
2756 return 0;
2757}
2758
Paul Cercueilbaf15642020-01-07 00:27:08 +01002759static const struct of_device_id ingenic_pinctrl_of_match[] = {
2760 { .compatible = "ingenic,jz4740-pinctrl", .data = &jz4740_chip_info },
2761 { .compatible = "ingenic,jz4725b-pinctrl", .data = &jz4725b_chip_info },
2762 { .compatible = "ingenic,jz4760-pinctrl", .data = &jz4760_chip_info },
Paul Cercueil5ffdbb72020-01-07 00:27:09 +01002763 { .compatible = "ingenic,jz4760b-pinctrl", .data = &jz4760_chip_info },
Paul Cercueilbaf15642020-01-07 00:27:08 +01002764 { .compatible = "ingenic,jz4770-pinctrl", .data = &jz4770_chip_info },
2765 { .compatible = "ingenic,jz4780-pinctrl", .data = &jz4780_chip_info },
2766 { .compatible = "ingenic,x1000-pinctrl", .data = &x1000_chip_info },
Paul Cercueil5ffdbb72020-01-07 00:27:09 +01002767 { .compatible = "ingenic,x1000e-pinctrl", .data = &x1000_chip_info },
Paul Cercueilbaf15642020-01-07 00:27:08 +01002768 { .compatible = "ingenic,x1500-pinctrl", .data = &x1500_chip_info },
2769 { .compatible = "ingenic,x1830-pinctrl", .data = &x1830_chip_info },
2770 {},
2771};
2772
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002773static struct platform_driver ingenic_pinctrl_driver = {
2774 .driver = {
2775 .name = "pinctrl-ingenic",
Paul Cercueil5ec008b2020-01-07 00:27:07 +01002776 .of_match_table = ingenic_pinctrl_of_match,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002777 },
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002778};
2779
2780static int __init ingenic_pinctrl_drv_register(void)
2781{
Paul Cercueil4717b112018-08-21 18:42:31 +02002782 return platform_driver_probe(&ingenic_pinctrl_driver,
2783 ingenic_pinctrl_probe);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002784}
Paul Cercueil556a36a2018-08-21 18:42:30 +02002785subsys_initcall(ingenic_pinctrl_drv_register);