blob: 53a6a24bd05270291b690de275b072cba5cfb722 [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
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200137
Paul Cercueilbb42b592020-11-01 09:01:03 +0000138#define INGENIC_PIN_GROUP_FUNCS(name, id, funcs) \
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200139 { \
140 name, \
141 id##_pins, \
142 ARRAY_SIZE(id##_pins), \
Paul Cercueilbb42b592020-11-01 09:01:03 +0000143 funcs, \
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200144 }
145
Paul Cercueilbb42b592020-11-01 09:01:03 +0000146#define INGENIC_PIN_GROUP(name, id, func) \
147 INGENIC_PIN_GROUP_FUNCS(name, id, (void *)(func))
148
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200149static const struct group_desc jz4740_groups[] = {
Paul Cercueilbb42b592020-11-01 09:01:03 +0000150 INGENIC_PIN_GROUP("mmc-1bit", jz4740_mmc_1bit, 0),
151 INGENIC_PIN_GROUP("mmc-4bit", jz4740_mmc_4bit, 0),
152 INGENIC_PIN_GROUP("uart0-data", jz4740_uart0_data, 1),
153 INGENIC_PIN_GROUP("uart0-hwflow", jz4740_uart0_hwflow, 1),
154 INGENIC_PIN_GROUP("uart1-data", jz4740_uart1_data, 2),
155 INGENIC_PIN_GROUP("lcd-8bit", jz4740_lcd_8bit, 0),
156 INGENIC_PIN_GROUP("lcd-16bit", jz4740_lcd_16bit, 0),
157 INGENIC_PIN_GROUP("lcd-18bit", jz4740_lcd_18bit, 0),
158 INGENIC_PIN_GROUP("lcd-18bit-tft", jz4740_lcd_18bit_tft, 0),
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200159 { "lcd-no-pins", },
Paul Cercueilbb42b592020-11-01 09:01:03 +0000160 INGENIC_PIN_GROUP("nand-cs1", jz4740_nand_cs1, 0),
161 INGENIC_PIN_GROUP("nand-cs2", jz4740_nand_cs2, 0),
162 INGENIC_PIN_GROUP("nand-cs3", jz4740_nand_cs3, 0),
163 INGENIC_PIN_GROUP("nand-cs4", jz4740_nand_cs4, 0),
164 INGENIC_PIN_GROUP("nand-fre-fwe", jz4740_nand_fre_fwe, 0),
165 INGENIC_PIN_GROUP("pwm0", jz4740_pwm_pwm0, 0),
166 INGENIC_PIN_GROUP("pwm1", jz4740_pwm_pwm1, 0),
167 INGENIC_PIN_GROUP("pwm2", jz4740_pwm_pwm2, 0),
168 INGENIC_PIN_GROUP("pwm3", jz4740_pwm_pwm3, 0),
169 INGENIC_PIN_GROUP("pwm4", jz4740_pwm_pwm4, 0),
170 INGENIC_PIN_GROUP("pwm5", jz4740_pwm_pwm5, 0),
171 INGENIC_PIN_GROUP("pwm6", jz4740_pwm_pwm6, 0),
172 INGENIC_PIN_GROUP("pwm7", jz4740_pwm_pwm7, 0),
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200173};
174
175static const char *jz4740_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
176static const char *jz4740_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
177static const char *jz4740_uart1_groups[] = { "uart1-data", };
178static const char *jz4740_lcd_groups[] = {
179 "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-18bit-tft", "lcd-no-pins",
180};
181static const char *jz4740_nand_groups[] = {
Paul Cercueilbcad94d2020-06-07 19:42:43 +0200182 "nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4", "nand-fre-fwe",
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200183};
184static const char *jz4740_pwm0_groups[] = { "pwm0", };
185static const char *jz4740_pwm1_groups[] = { "pwm1", };
186static const char *jz4740_pwm2_groups[] = { "pwm2", };
187static const char *jz4740_pwm3_groups[] = { "pwm3", };
188static const char *jz4740_pwm4_groups[] = { "pwm4", };
189static const char *jz4740_pwm5_groups[] = { "pwm5", };
190static const char *jz4740_pwm6_groups[] = { "pwm6", };
191static const char *jz4740_pwm7_groups[] = { "pwm7", };
192
193static const struct function_desc jz4740_functions[] = {
194 { "mmc", jz4740_mmc_groups, ARRAY_SIZE(jz4740_mmc_groups), },
195 { "uart0", jz4740_uart0_groups, ARRAY_SIZE(jz4740_uart0_groups), },
196 { "uart1", jz4740_uart1_groups, ARRAY_SIZE(jz4740_uart1_groups), },
197 { "lcd", jz4740_lcd_groups, ARRAY_SIZE(jz4740_lcd_groups), },
198 { "nand", jz4740_nand_groups, ARRAY_SIZE(jz4740_nand_groups), },
199 { "pwm0", jz4740_pwm0_groups, ARRAY_SIZE(jz4740_pwm0_groups), },
200 { "pwm1", jz4740_pwm1_groups, ARRAY_SIZE(jz4740_pwm1_groups), },
201 { "pwm2", jz4740_pwm2_groups, ARRAY_SIZE(jz4740_pwm2_groups), },
202 { "pwm3", jz4740_pwm3_groups, ARRAY_SIZE(jz4740_pwm3_groups), },
203 { "pwm4", jz4740_pwm4_groups, ARRAY_SIZE(jz4740_pwm4_groups), },
204 { "pwm5", jz4740_pwm5_groups, ARRAY_SIZE(jz4740_pwm5_groups), },
205 { "pwm6", jz4740_pwm6_groups, ARRAY_SIZE(jz4740_pwm6_groups), },
206 { "pwm7", jz4740_pwm7_groups, ARRAY_SIZE(jz4740_pwm7_groups), },
207};
208
209static const struct ingenic_chip_info jz4740_chip_info = {
210 .num_chips = 4,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +0800211 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +0100212 .version = ID_JZ4740,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200213 .groups = jz4740_groups,
214 .num_groups = ARRAY_SIZE(jz4740_groups),
215 .functions = jz4740_functions,
216 .num_functions = ARRAY_SIZE(jz4740_functions),
217 .pull_ups = jz4740_pull_ups,
218 .pull_downs = jz4740_pull_downs,
219};
220
Paul Cercueilf2a96762018-08-21 18:42:34 +0200221static int jz4725b_mmc0_1bit_pins[] = { 0x48, 0x49, 0x5c, };
222static int jz4725b_mmc0_4bit_pins[] = { 0x5d, 0x5b, 0x56, };
223static int jz4725b_mmc1_1bit_pins[] = { 0x7a, 0x7b, 0x7c, };
224static int jz4725b_mmc1_4bit_pins[] = { 0x7d, 0x7e, 0x7f, };
225static int jz4725b_uart_data_pins[] = { 0x4c, 0x4d, };
226static int jz4725b_nand_cs1_pins[] = { 0x55, };
227static int jz4725b_nand_cs2_pins[] = { 0x56, };
228static int jz4725b_nand_cs3_pins[] = { 0x57, };
229static int jz4725b_nand_cs4_pins[] = { 0x58, };
230static int jz4725b_nand_cle_ale_pins[] = { 0x48, 0x49 };
231static int jz4725b_nand_fre_fwe_pins[] = { 0x5c, 0x5d };
232static int jz4725b_pwm_pwm0_pins[] = { 0x4a, };
233static int jz4725b_pwm_pwm1_pins[] = { 0x4b, };
234static int jz4725b_pwm_pwm2_pins[] = { 0x4c, };
235static int jz4725b_pwm_pwm3_pins[] = { 0x4d, };
236static int jz4725b_pwm_pwm4_pins[] = { 0x4e, };
237static int jz4725b_pwm_pwm5_pins[] = { 0x4f, };
Paul Cercueila3240f02019-02-07 10:55:36 -0300238static int jz4725b_lcd_8bit_pins[] = {
239 0x72, 0x73, 0x74,
240 0x60, 0x61, 0x62, 0x63,
241 0x64, 0x65, 0x66, 0x67,
242};
243static int jz4725b_lcd_16bit_pins[] = {
244 0x68, 0x69, 0x6a, 0x6b,
245 0x6c, 0x6d, 0x6e, 0x6f,
246};
247static int jz4725b_lcd_18bit_pins[] = { 0x70, 0x71, };
248static int jz4725b_lcd_24bit_pins[] = { 0x76, 0x77, 0x78, 0x79, };
249static int jz4725b_lcd_special_pins[] = { 0x76, 0x77, 0x78, 0x79, };
250static int jz4725b_lcd_generic_pins[] = { 0x75, };
Paul Cercueilf2a96762018-08-21 18:42:34 +0200251
Paul Cercueilbb42b592020-11-01 09:01:03 +0000252static u8 jz4725b_mmc0_4bit_funcs[] = { 1, 0, 1, };
Paul Cercueilf2a96762018-08-21 18:42:34 +0200253
254static const struct group_desc jz4725b_groups[] = {
Paul Cercueilbb42b592020-11-01 09:01:03 +0000255 INGENIC_PIN_GROUP("mmc0-1bit", jz4725b_mmc0_1bit, 1),
256 INGENIC_PIN_GROUP_FUNCS("mmc0-4bit", jz4725b_mmc0_4bit,
257 jz4725b_mmc0_4bit_funcs),
258 INGENIC_PIN_GROUP("mmc1-1bit", jz4725b_mmc1_1bit, 0),
259 INGENIC_PIN_GROUP("mmc1-4bit", jz4725b_mmc1_4bit, 0),
260 INGENIC_PIN_GROUP("uart-data", jz4725b_uart_data, 1),
261 INGENIC_PIN_GROUP("nand-cs1", jz4725b_nand_cs1, 0),
262 INGENIC_PIN_GROUP("nand-cs2", jz4725b_nand_cs2, 0),
263 INGENIC_PIN_GROUP("nand-cs3", jz4725b_nand_cs3, 0),
264 INGENIC_PIN_GROUP("nand-cs4", jz4725b_nand_cs4, 0),
265 INGENIC_PIN_GROUP("nand-cle-ale", jz4725b_nand_cle_ale, 0),
266 INGENIC_PIN_GROUP("nand-fre-fwe", jz4725b_nand_fre_fwe, 0),
267 INGENIC_PIN_GROUP("pwm0", jz4725b_pwm_pwm0, 0),
268 INGENIC_PIN_GROUP("pwm1", jz4725b_pwm_pwm1, 0),
269 INGENIC_PIN_GROUP("pwm2", jz4725b_pwm_pwm2, 0),
270 INGENIC_PIN_GROUP("pwm3", jz4725b_pwm_pwm3, 0),
271 INGENIC_PIN_GROUP("pwm4", jz4725b_pwm_pwm4, 0),
272 INGENIC_PIN_GROUP("pwm5", jz4725b_pwm_pwm5, 0),
273 INGENIC_PIN_GROUP("lcd-8bit", jz4725b_lcd_8bit, 0),
274 INGENIC_PIN_GROUP("lcd-16bit", jz4725b_lcd_16bit, 0),
275 INGENIC_PIN_GROUP("lcd-18bit", jz4725b_lcd_18bit, 0),
276 INGENIC_PIN_GROUP("lcd-24bit", jz4725b_lcd_24bit, 1),
277 INGENIC_PIN_GROUP("lcd-special", jz4725b_lcd_special, 0),
278 INGENIC_PIN_GROUP("lcd-generic", jz4725b_lcd_generic, 0),
Paul Cercueilf2a96762018-08-21 18:42:34 +0200279};
280
281static const char *jz4725b_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", };
282static const char *jz4725b_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
283static const char *jz4725b_uart_groups[] = { "uart-data", };
284static const char *jz4725b_nand_groups[] = {
285 "nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4",
286 "nand-cle-ale", "nand-fre-fwe",
287};
288static const char *jz4725b_pwm0_groups[] = { "pwm0", };
289static const char *jz4725b_pwm1_groups[] = { "pwm1", };
290static const char *jz4725b_pwm2_groups[] = { "pwm2", };
291static const char *jz4725b_pwm3_groups[] = { "pwm3", };
292static const char *jz4725b_pwm4_groups[] = { "pwm4", };
293static const char *jz4725b_pwm5_groups[] = { "pwm5", };
Paul Cercueila3240f02019-02-07 10:55:36 -0300294static const char *jz4725b_lcd_groups[] = {
295 "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit",
296 "lcd-special", "lcd-generic",
297};
Paul Cercueilf2a96762018-08-21 18:42:34 +0200298
299static const struct function_desc jz4725b_functions[] = {
300 { "mmc0", jz4725b_mmc0_groups, ARRAY_SIZE(jz4725b_mmc0_groups), },
301 { "mmc1", jz4725b_mmc1_groups, ARRAY_SIZE(jz4725b_mmc1_groups), },
302 { "uart", jz4725b_uart_groups, ARRAY_SIZE(jz4725b_uart_groups), },
303 { "nand", jz4725b_nand_groups, ARRAY_SIZE(jz4725b_nand_groups), },
304 { "pwm0", jz4725b_pwm0_groups, ARRAY_SIZE(jz4725b_pwm0_groups), },
305 { "pwm1", jz4725b_pwm1_groups, ARRAY_SIZE(jz4725b_pwm1_groups), },
306 { "pwm2", jz4725b_pwm2_groups, ARRAY_SIZE(jz4725b_pwm2_groups), },
307 { "pwm3", jz4725b_pwm3_groups, ARRAY_SIZE(jz4725b_pwm3_groups), },
308 { "pwm4", jz4725b_pwm4_groups, ARRAY_SIZE(jz4725b_pwm4_groups), },
309 { "pwm5", jz4725b_pwm5_groups, ARRAY_SIZE(jz4725b_pwm5_groups), },
Paul Cercueila3240f02019-02-07 10:55:36 -0300310 { "lcd", jz4725b_lcd_groups, ARRAY_SIZE(jz4725b_lcd_groups), },
Paul Cercueilf2a96762018-08-21 18:42:34 +0200311};
312
313static const struct ingenic_chip_info jz4725b_chip_info = {
314 .num_chips = 4,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +0800315 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +0100316 .version = ID_JZ4725B,
Paul Cercueilf2a96762018-08-21 18:42:34 +0200317 .groups = jz4725b_groups,
318 .num_groups = ARRAY_SIZE(jz4725b_groups),
319 .functions = jz4725b_functions,
320 .num_functions = ARRAY_SIZE(jz4725b_functions),
321 .pull_ups = jz4740_pull_ups,
322 .pull_downs = jz4740_pull_downs,
323};
324
Zhou Yanjie0257595a2019-07-14 11:53:52 +0800325static const u32 jz4760_pull_ups[6] = {
326 0xffffffff, 0xfffcf3ff, 0xffffffff, 0xffffcfff, 0xfffffb7c, 0xfffff00f,
327};
328
329static const u32 jz4760_pull_downs[6] = {
330 0x00000000, 0x00030c00, 0x00000000, 0x00003000, 0x00000483, 0x00000ff0,
331};
332
333static int jz4760_uart0_data_pins[] = { 0xa0, 0xa3, };
334static int jz4760_uart0_hwflow_pins[] = { 0xa1, 0xa2, };
335static int jz4760_uart1_data_pins[] = { 0x7a, 0x7c, };
336static int jz4760_uart1_hwflow_pins[] = { 0x7b, 0x7d, };
337static int jz4760_uart2_data_pins[] = { 0x5c, 0x5e, };
338static int jz4760_uart2_hwflow_pins[] = { 0x5d, 0x5f, };
339static int jz4760_uart3_data_pins[] = { 0x6c, 0x85, };
340static int jz4760_uart3_hwflow_pins[] = { 0x88, 0x89, };
341static int jz4760_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, };
342static int jz4760_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, };
343static int jz4760_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
344static int jz4760_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
345static int jz4760_mmc0_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
346static int jz4760_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, };
347static int jz4760_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, };
348static int jz4760_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
349static int jz4760_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
350static int jz4760_mmc1_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
351static int jz4760_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, };
352static int jz4760_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, };
353static int jz4760_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
354static int jz4760_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
355static int jz4760_mmc2_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
356static int jz4760_nemc_8bit_data_pins[] = {
357 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
358};
359static int jz4760_nemc_16bit_data_pins[] = {
360 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
361};
362static int jz4760_nemc_cle_ale_pins[] = { 0x20, 0x21, };
363static int jz4760_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, };
364static int jz4760_nemc_rd_we_pins[] = { 0x10, 0x11, };
365static int jz4760_nemc_frd_fwe_pins[] = { 0x12, 0x13, };
366static int jz4760_nemc_wait_pins[] = { 0x1b, };
367static int jz4760_nemc_cs1_pins[] = { 0x15, };
368static int jz4760_nemc_cs2_pins[] = { 0x16, };
369static int jz4760_nemc_cs3_pins[] = { 0x17, };
370static int jz4760_nemc_cs4_pins[] = { 0x18, };
371static int jz4760_nemc_cs5_pins[] = { 0x19, };
372static int jz4760_nemc_cs6_pins[] = { 0x1a, };
373static int jz4760_i2c0_pins[] = { 0x7e, 0x7f, };
374static int jz4760_i2c1_pins[] = { 0x9e, 0x9f, };
375static int jz4760_cim_pins[] = {
376 0x26, 0x27, 0x28, 0x29,
377 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
378};
379static int jz4760_lcd_24bit_pins[] = {
380 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
381 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
382 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
383 0x58, 0x59, 0x5a, 0x5b,
384};
385static int jz4760_pwm_pwm0_pins[] = { 0x80, };
386static int jz4760_pwm_pwm1_pins[] = { 0x81, };
387static int jz4760_pwm_pwm2_pins[] = { 0x82, };
388static int jz4760_pwm_pwm3_pins[] = { 0x83, };
389static int jz4760_pwm_pwm4_pins[] = { 0x84, };
390static int jz4760_pwm_pwm5_pins[] = { 0x85, };
391static int jz4760_pwm_pwm6_pins[] = { 0x6a, };
392static int jz4760_pwm_pwm7_pins[] = { 0x6b, };
393
Paul Cercueilbb42b592020-11-01 09:01:03 +0000394static u8 jz4760_uart3_data_funcs[] = { 0, 1, };
395static u8 jz4760_mmc0_1bit_a_funcs[] = { 1, 1, 0, };
Zhou Yanjie0257595a2019-07-14 11:53:52 +0800396
397static const struct group_desc jz4760_groups[] = {
Paul Cercueilbb42b592020-11-01 09:01:03 +0000398 INGENIC_PIN_GROUP("uart0-data", jz4760_uart0_data, 0),
399 INGENIC_PIN_GROUP("uart0-hwflow", jz4760_uart0_hwflow, 0),
400 INGENIC_PIN_GROUP("uart1-data", jz4760_uart1_data, 0),
401 INGENIC_PIN_GROUP("uart1-hwflow", jz4760_uart1_hwflow, 0),
402 INGENIC_PIN_GROUP("uart2-data", jz4760_uart2_data, 0),
403 INGENIC_PIN_GROUP("uart2-hwflow", jz4760_uart2_hwflow, 0),
404 INGENIC_PIN_GROUP_FUNCS("uart3-data", jz4760_uart3_data,
405 jz4760_uart3_data_funcs),
406 INGENIC_PIN_GROUP("uart3-hwflow", jz4760_uart3_hwflow, 0),
407 INGENIC_PIN_GROUP_FUNCS("mmc0-1bit-a", jz4760_mmc0_1bit_a,
408 jz4760_mmc0_1bit_a_funcs),
409 INGENIC_PIN_GROUP("mmc0-4bit-a", jz4760_mmc0_4bit_a, 1),
410 INGENIC_PIN_GROUP("mmc0-1bit-e", jz4760_mmc0_1bit_e, 0),
411 INGENIC_PIN_GROUP("mmc0-4bit-e", jz4760_mmc0_4bit_e, 0),
412 INGENIC_PIN_GROUP("mmc0-8bit-e", jz4760_mmc0_8bit_e, 0),
413 INGENIC_PIN_GROUP("mmc1-1bit-d", jz4760_mmc1_1bit_d, 0),
414 INGENIC_PIN_GROUP("mmc1-4bit-d", jz4760_mmc1_4bit_d, 0),
415 INGENIC_PIN_GROUP("mmc1-1bit-e", jz4760_mmc1_1bit_e, 1),
416 INGENIC_PIN_GROUP("mmc1-4bit-e", jz4760_mmc1_4bit_e, 1),
417 INGENIC_PIN_GROUP("mmc1-8bit-e", jz4760_mmc1_8bit_e, 1),
418 INGENIC_PIN_GROUP("mmc2-1bit-b", jz4760_mmc2_1bit_b, 0),
419 INGENIC_PIN_GROUP("mmc2-4bit-b", jz4760_mmc2_4bit_b, 0),
420 INGENIC_PIN_GROUP("mmc2-1bit-e", jz4760_mmc2_1bit_e, 2),
421 INGENIC_PIN_GROUP("mmc2-4bit-e", jz4760_mmc2_4bit_e, 2),
422 INGENIC_PIN_GROUP("mmc2-8bit-e", jz4760_mmc2_8bit_e, 2),
423 INGENIC_PIN_GROUP("nemc-8bit-data", jz4760_nemc_8bit_data, 0),
424 INGENIC_PIN_GROUP("nemc-16bit-data", jz4760_nemc_16bit_data, 0),
425 INGENIC_PIN_GROUP("nemc-cle-ale", jz4760_nemc_cle_ale, 0),
426 INGENIC_PIN_GROUP("nemc-addr", jz4760_nemc_addr, 0),
427 INGENIC_PIN_GROUP("nemc-rd-we", jz4760_nemc_rd_we, 0),
428 INGENIC_PIN_GROUP("nemc-frd-fwe", jz4760_nemc_frd_fwe, 0),
429 INGENIC_PIN_GROUP("nemc-wait", jz4760_nemc_wait, 0),
430 INGENIC_PIN_GROUP("nemc-cs1", jz4760_nemc_cs1, 0),
431 INGENIC_PIN_GROUP("nemc-cs2", jz4760_nemc_cs2, 0),
432 INGENIC_PIN_GROUP("nemc-cs3", jz4760_nemc_cs3, 0),
433 INGENIC_PIN_GROUP("nemc-cs4", jz4760_nemc_cs4, 0),
434 INGENIC_PIN_GROUP("nemc-cs5", jz4760_nemc_cs5, 0),
435 INGENIC_PIN_GROUP("nemc-cs6", jz4760_nemc_cs6, 0),
436 INGENIC_PIN_GROUP("i2c0-data", jz4760_i2c0, 0),
437 INGENIC_PIN_GROUP("i2c1-data", jz4760_i2c1, 0),
438 INGENIC_PIN_GROUP("cim-data", jz4760_cim, 0),
439 INGENIC_PIN_GROUP("lcd-24bit", jz4760_lcd_24bit, 0),
Zhou Yanjie0257595a2019-07-14 11:53:52 +0800440 { "lcd-no-pins", },
Paul Cercueilbb42b592020-11-01 09:01:03 +0000441 INGENIC_PIN_GROUP("pwm0", jz4760_pwm_pwm0, 0),
442 INGENIC_PIN_GROUP("pwm1", jz4760_pwm_pwm1, 0),
443 INGENIC_PIN_GROUP("pwm2", jz4760_pwm_pwm2, 0),
444 INGENIC_PIN_GROUP("pwm3", jz4760_pwm_pwm3, 0),
445 INGENIC_PIN_GROUP("pwm4", jz4760_pwm_pwm4, 0),
446 INGENIC_PIN_GROUP("pwm5", jz4760_pwm_pwm5, 0),
447 INGENIC_PIN_GROUP("pwm6", jz4760_pwm_pwm6, 0),
448 INGENIC_PIN_GROUP("pwm7", jz4760_pwm_pwm7, 0),
Zhou Yanjie0257595a2019-07-14 11:53:52 +0800449};
450
451static const char *jz4760_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
452static const char *jz4760_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
453static const char *jz4760_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
454static const char *jz4760_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
455static const char *jz4760_mmc0_groups[] = {
456 "mmc0-1bit-a", "mmc0-4bit-a",
457 "mmc0-1bit-e", "mmc0-4bit-e", "mmc0-8bit-e",
458};
459static const char *jz4760_mmc1_groups[] = {
460 "mmc1-1bit-d", "mmc1-4bit-d",
461 "mmc1-1bit-e", "mmc1-4bit-e", "mmc1-8bit-e",
462};
463static const char *jz4760_mmc2_groups[] = {
464 "mmc2-1bit-b", "mmc2-4bit-b",
465 "mmc2-1bit-e", "mmc2-4bit-e", "mmc2-8bit-e",
466};
467static const char *jz4760_nemc_groups[] = {
468 "nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale",
469 "nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
470};
471static const char *jz4760_cs1_groups[] = { "nemc-cs1", };
472static const char *jz4760_cs2_groups[] = { "nemc-cs2", };
473static const char *jz4760_cs3_groups[] = { "nemc-cs3", };
474static const char *jz4760_cs4_groups[] = { "nemc-cs4", };
475static const char *jz4760_cs5_groups[] = { "nemc-cs5", };
476static const char *jz4760_cs6_groups[] = { "nemc-cs6", };
477static const char *jz4760_i2c0_groups[] = { "i2c0-data", };
478static const char *jz4760_i2c1_groups[] = { "i2c1-data", };
479static const char *jz4760_cim_groups[] = { "cim-data", };
480static const char *jz4760_lcd_groups[] = { "lcd-24bit", "lcd-no-pins", };
481static const char *jz4760_pwm0_groups[] = { "pwm0", };
482static const char *jz4760_pwm1_groups[] = { "pwm1", };
483static const char *jz4760_pwm2_groups[] = { "pwm2", };
484static const char *jz4760_pwm3_groups[] = { "pwm3", };
485static const char *jz4760_pwm4_groups[] = { "pwm4", };
486static const char *jz4760_pwm5_groups[] = { "pwm5", };
487static const char *jz4760_pwm6_groups[] = { "pwm6", };
488static const char *jz4760_pwm7_groups[] = { "pwm7", };
489
490static const struct function_desc jz4760_functions[] = {
491 { "uart0", jz4760_uart0_groups, ARRAY_SIZE(jz4760_uart0_groups), },
492 { "uart1", jz4760_uart1_groups, ARRAY_SIZE(jz4760_uart1_groups), },
493 { "uart2", jz4760_uart2_groups, ARRAY_SIZE(jz4760_uart2_groups), },
494 { "uart3", jz4760_uart3_groups, ARRAY_SIZE(jz4760_uart3_groups), },
495 { "mmc0", jz4760_mmc0_groups, ARRAY_SIZE(jz4760_mmc0_groups), },
496 { "mmc1", jz4760_mmc1_groups, ARRAY_SIZE(jz4760_mmc1_groups), },
497 { "mmc2", jz4760_mmc2_groups, ARRAY_SIZE(jz4760_mmc2_groups), },
498 { "nemc", jz4760_nemc_groups, ARRAY_SIZE(jz4760_nemc_groups), },
499 { "nemc-cs1", jz4760_cs1_groups, ARRAY_SIZE(jz4760_cs1_groups), },
500 { "nemc-cs2", jz4760_cs2_groups, ARRAY_SIZE(jz4760_cs2_groups), },
501 { "nemc-cs3", jz4760_cs3_groups, ARRAY_SIZE(jz4760_cs3_groups), },
502 { "nemc-cs4", jz4760_cs4_groups, ARRAY_SIZE(jz4760_cs4_groups), },
503 { "nemc-cs5", jz4760_cs5_groups, ARRAY_SIZE(jz4760_cs5_groups), },
504 { "nemc-cs6", jz4760_cs6_groups, ARRAY_SIZE(jz4760_cs6_groups), },
505 { "i2c0", jz4760_i2c0_groups, ARRAY_SIZE(jz4760_i2c0_groups), },
506 { "i2c1", jz4760_i2c1_groups, ARRAY_SIZE(jz4760_i2c1_groups), },
507 { "cim", jz4760_cim_groups, ARRAY_SIZE(jz4760_cim_groups), },
508 { "lcd", jz4760_lcd_groups, ARRAY_SIZE(jz4760_lcd_groups), },
509 { "pwm0", jz4760_pwm0_groups, ARRAY_SIZE(jz4760_pwm0_groups), },
510 { "pwm1", jz4760_pwm1_groups, ARRAY_SIZE(jz4760_pwm1_groups), },
511 { "pwm2", jz4760_pwm2_groups, ARRAY_SIZE(jz4760_pwm2_groups), },
512 { "pwm3", jz4760_pwm3_groups, ARRAY_SIZE(jz4760_pwm3_groups), },
513 { "pwm4", jz4760_pwm4_groups, ARRAY_SIZE(jz4760_pwm4_groups), },
514 { "pwm5", jz4760_pwm5_groups, ARRAY_SIZE(jz4760_pwm5_groups), },
515 { "pwm6", jz4760_pwm6_groups, ARRAY_SIZE(jz4760_pwm6_groups), },
516 { "pwm7", jz4760_pwm7_groups, ARRAY_SIZE(jz4760_pwm7_groups), },
517};
518
519static const struct ingenic_chip_info jz4760_chip_info = {
520 .num_chips = 6,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +0800521 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +0100522 .version = ID_JZ4760,
Zhou Yanjie0257595a2019-07-14 11:53:52 +0800523 .groups = jz4760_groups,
524 .num_groups = ARRAY_SIZE(jz4760_groups),
525 .functions = jz4760_functions,
526 .num_functions = ARRAY_SIZE(jz4760_functions),
527 .pull_ups = jz4760_pull_ups,
528 .pull_downs = jz4760_pull_downs,
529};
530
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200531static const u32 jz4770_pull_ups[6] = {
532 0x3fffffff, 0xfff0030c, 0xffffffff, 0xffff4fff, 0xfffffb7c, 0xffa7f00f,
533};
534
535static const u32 jz4770_pull_downs[6] = {
536 0x00000000, 0x000f0c03, 0x00000000, 0x0000b000, 0x00000483, 0x00580ff0,
537};
538
539static int jz4770_uart0_data_pins[] = { 0xa0, 0xa3, };
540static int jz4770_uart0_hwflow_pins[] = { 0xa1, 0xa2, };
541static int jz4770_uart1_data_pins[] = { 0x7a, 0x7c, };
542static int jz4770_uart1_hwflow_pins[] = { 0x7b, 0x7d, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800543static int jz4770_uart2_data_pins[] = { 0x5c, 0x5e, };
544static int jz4770_uart2_hwflow_pins[] = { 0x5d, 0x5f, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200545static int jz4770_uart3_data_pins[] = { 0x6c, 0x85, };
546static int jz4770_uart3_hwflow_pins[] = { 0x88, 0x89, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800547static int jz4770_ssi0_dt_a_pins[] = { 0x15, };
548static int jz4770_ssi0_dt_b_pins[] = { 0x35, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200549static int jz4770_ssi0_dt_d_pins[] = { 0x75, };
550static int jz4770_ssi0_dt_e_pins[] = { 0x91, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800551static int jz4770_ssi0_dr_a_pins[] = { 0x14, };
552static int jz4770_ssi0_dr_b_pins[] = { 0x34, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200553static int jz4770_ssi0_dr_d_pins[] = { 0x74, };
554static int jz4770_ssi0_dr_e_pins[] = { 0x8e, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800555static int jz4770_ssi0_clk_a_pins[] = { 0x12, };
556static int jz4770_ssi0_clk_b_pins[] = { 0x3c, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200557static int jz4770_ssi0_clk_d_pins[] = { 0x78, };
558static int jz4770_ssi0_clk_e_pins[] = { 0x8f, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800559static int jz4770_ssi0_gpc_b_pins[] = { 0x3e, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200560static int jz4770_ssi0_gpc_d_pins[] = { 0x76, };
561static int jz4770_ssi0_gpc_e_pins[] = { 0x93, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800562static int jz4770_ssi0_ce0_a_pins[] = { 0x13, };
563static int jz4770_ssi0_ce0_b_pins[] = { 0x3d, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200564static int jz4770_ssi0_ce0_d_pins[] = { 0x79, };
565static int jz4770_ssi0_ce0_e_pins[] = { 0x90, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800566static int jz4770_ssi0_ce1_b_pins[] = { 0x3f, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200567static int jz4770_ssi0_ce1_d_pins[] = { 0x77, };
568static int jz4770_ssi0_ce1_e_pins[] = { 0x92, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800569static int jz4770_ssi1_dt_b_pins[] = { 0x35, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200570static int jz4770_ssi1_dt_d_pins[] = { 0x75, };
571static int jz4770_ssi1_dt_e_pins[] = { 0x91, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800572static int jz4770_ssi1_dr_b_pins[] = { 0x34, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200573static int jz4770_ssi1_dr_d_pins[] = { 0x74, };
574static int jz4770_ssi1_dr_e_pins[] = { 0x8e, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800575static int jz4770_ssi1_clk_b_pins[] = { 0x3c, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200576static int jz4770_ssi1_clk_d_pins[] = { 0x78, };
577static int jz4770_ssi1_clk_e_pins[] = { 0x8f, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800578static int jz4770_ssi1_gpc_b_pins[] = { 0x3e, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200579static int jz4770_ssi1_gpc_d_pins[] = { 0x76, };
580static int jz4770_ssi1_gpc_e_pins[] = { 0x93, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800581static int jz4770_ssi1_ce0_b_pins[] = { 0x3d, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200582static int jz4770_ssi1_ce0_d_pins[] = { 0x79, };
583static int jz4770_ssi1_ce0_e_pins[] = { 0x90, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800584static int jz4770_ssi1_ce1_b_pins[] = { 0x3f, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200585static int jz4770_ssi1_ce1_d_pins[] = { 0x77, };
586static int jz4770_ssi1_ce1_e_pins[] = { 0x92, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200587static int jz4770_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800588static int jz4770_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200589static int jz4770_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800590static int jz4770_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
591static int jz4770_mmc0_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200592static int jz4770_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800593static int jz4770_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200594static int jz4770_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800595static int jz4770_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
596static int jz4770_mmc1_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800597static int jz4770_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, };
598static int jz4770_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, };
599static int jz4770_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, };
600static int jz4770_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, };
601static int jz4770_mmc2_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800602static int jz4770_nemc_8bit_data_pins[] = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200603 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
604};
Zhou Yanjieff656e42019-01-28 23:19:57 +0800605static int jz4770_nemc_16bit_data_pins[] = {
606 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
607};
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200608static int jz4770_nemc_cle_ale_pins[] = { 0x20, 0x21, };
609static int jz4770_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, };
610static int jz4770_nemc_rd_we_pins[] = { 0x10, 0x11, };
611static int jz4770_nemc_frd_fwe_pins[] = { 0x12, 0x13, };
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800612static int jz4770_nemc_wait_pins[] = { 0x1b, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200613static int jz4770_nemc_cs1_pins[] = { 0x15, };
614static int jz4770_nemc_cs2_pins[] = { 0x16, };
615static int jz4770_nemc_cs3_pins[] = { 0x17, };
616static int jz4770_nemc_cs4_pins[] = { 0x18, };
617static int jz4770_nemc_cs5_pins[] = { 0x19, };
618static int jz4770_nemc_cs6_pins[] = { 0x1a, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800619static int jz4770_i2c0_pins[] = { 0x7e, 0x7f, };
620static int jz4770_i2c1_pins[] = { 0x9e, 0x9f, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200621static int jz4770_i2c2_pins[] = { 0xb0, 0xb1, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800622static int jz4770_cim_8bit_pins[] = {
623 0x26, 0x27, 0x28, 0x29,
624 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200625};
Zhou Yanjieff656e42019-01-28 23:19:57 +0800626static int jz4770_cim_12bit_pins[] = {
627 0x32, 0x33, 0xb0, 0xb1,
628};
Paul Cercueil016e0542020-11-01 09:01:04 +0000629static int jz4770_lcd_8bit_pins[] = {
630 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x4c, 0x4d,
631 0x48, 0x49, 0x52, 0x53,
632};
Zhou Yanjieff656e42019-01-28 23:19:57 +0800633static int jz4770_lcd_24bit_pins[] = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200634 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
635 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
636 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
Zhou Yanjieff656e42019-01-28 23:19:57 +0800637 0x58, 0x59, 0x5a, 0x5b,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200638};
639static int jz4770_pwm_pwm0_pins[] = { 0x80, };
640static int jz4770_pwm_pwm1_pins[] = { 0x81, };
641static int jz4770_pwm_pwm2_pins[] = { 0x82, };
642static int jz4770_pwm_pwm3_pins[] = { 0x83, };
643static int jz4770_pwm_pwm4_pins[] = { 0x84, };
644static int jz4770_pwm_pwm5_pins[] = { 0x85, };
645static int jz4770_pwm_pwm6_pins[] = { 0x6a, };
646static int jz4770_pwm_pwm7_pins[] = { 0x6b, };
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800647static int jz4770_mac_rmii_pins[] = {
648 0xa9, 0xab, 0xaa, 0xac, 0xa5, 0xa4, 0xad, 0xae, 0xa6, 0xa8,
649};
650static int jz4770_mac_mii_pins[] = { 0xa7, 0xaf, };
Paul Cercueilae75b532019-11-19 16:52:11 +0100651static int jz4770_otg_pins[] = { 0x8a, };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200652
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200653static const struct group_desc jz4770_groups[] = {
Paul Cercueilbb42b592020-11-01 09:01:03 +0000654 INGENIC_PIN_GROUP("uart0-data", jz4770_uart0_data, 0),
655 INGENIC_PIN_GROUP("uart0-hwflow", jz4770_uart0_hwflow, 0),
656 INGENIC_PIN_GROUP("uart1-data", jz4770_uart1_data, 0),
657 INGENIC_PIN_GROUP("uart1-hwflow", jz4770_uart1_hwflow, 0),
658 INGENIC_PIN_GROUP("uart2-data", jz4770_uart2_data, 0),
659 INGENIC_PIN_GROUP("uart2-hwflow", jz4770_uart2_hwflow, 0),
660 INGENIC_PIN_GROUP_FUNCS("uart3-data", jz4770_uart3_data,
661 jz4760_uart3_data_funcs),
662 INGENIC_PIN_GROUP("uart3-hwflow", jz4770_uart3_hwflow, 0),
663 INGENIC_PIN_GROUP("ssi0-dt-a", jz4770_ssi0_dt_a, 2),
664 INGENIC_PIN_GROUP("ssi0-dt-b", jz4770_ssi0_dt_b, 1),
665 INGENIC_PIN_GROUP("ssi0-dt-d", jz4770_ssi0_dt_d, 1),
666 INGENIC_PIN_GROUP("ssi0-dt-e", jz4770_ssi0_dt_e, 0),
667 INGENIC_PIN_GROUP("ssi0-dr-a", jz4770_ssi0_dr_a, 1),
668 INGENIC_PIN_GROUP("ssi0-dr-b", jz4770_ssi0_dr_b, 1),
669 INGENIC_PIN_GROUP("ssi0-dr-d", jz4770_ssi0_dr_d, 1),
670 INGENIC_PIN_GROUP("ssi0-dr-e", jz4770_ssi0_dr_e, 0),
671 INGENIC_PIN_GROUP("ssi0-clk-a", jz4770_ssi0_clk_a, 2),
672 INGENIC_PIN_GROUP("ssi0-clk-b", jz4770_ssi0_clk_b, 1),
673 INGENIC_PIN_GROUP("ssi0-clk-d", jz4770_ssi0_clk_d, 1),
674 INGENIC_PIN_GROUP("ssi0-clk-e", jz4770_ssi0_clk_e, 0),
675 INGENIC_PIN_GROUP("ssi0-gpc-b", jz4770_ssi0_gpc_b, 1),
676 INGENIC_PIN_GROUP("ssi0-gpc-d", jz4770_ssi0_gpc_d, 1),
677 INGENIC_PIN_GROUP("ssi0-gpc-e", jz4770_ssi0_gpc_e, 0),
678 INGENIC_PIN_GROUP("ssi0-ce0-a", jz4770_ssi0_ce0_a, 2),
679 INGENIC_PIN_GROUP("ssi0-ce0-b", jz4770_ssi0_ce0_b, 1),
680 INGENIC_PIN_GROUP("ssi0-ce0-d", jz4770_ssi0_ce0_d, 1),
681 INGENIC_PIN_GROUP("ssi0-ce0-e", jz4770_ssi0_ce0_e, 0),
682 INGENIC_PIN_GROUP("ssi0-ce1-b", jz4770_ssi0_ce1_b, 1),
683 INGENIC_PIN_GROUP("ssi0-ce1-d", jz4770_ssi0_ce1_d, 1),
684 INGENIC_PIN_GROUP("ssi0-ce1-e", jz4770_ssi0_ce1_e, 0),
685 INGENIC_PIN_GROUP("ssi1-dt-b", jz4770_ssi1_dt_b, 2),
686 INGENIC_PIN_GROUP("ssi1-dt-d", jz4770_ssi1_dt_d, 2),
687 INGENIC_PIN_GROUP("ssi1-dt-e", jz4770_ssi1_dt_e, 1),
688 INGENIC_PIN_GROUP("ssi1-dr-b", jz4770_ssi1_dr_b, 2),
689 INGENIC_PIN_GROUP("ssi1-dr-d", jz4770_ssi1_dr_d, 2),
690 INGENIC_PIN_GROUP("ssi1-dr-e", jz4770_ssi1_dr_e, 1),
691 INGENIC_PIN_GROUP("ssi1-clk-b", jz4770_ssi1_clk_b, 2),
692 INGENIC_PIN_GROUP("ssi1-clk-d", jz4770_ssi1_clk_d, 2),
693 INGENIC_PIN_GROUP("ssi1-clk-e", jz4770_ssi1_clk_e, 1),
694 INGENIC_PIN_GROUP("ssi1-gpc-b", jz4770_ssi1_gpc_b, 2),
695 INGENIC_PIN_GROUP("ssi1-gpc-d", jz4770_ssi1_gpc_d, 2),
696 INGENIC_PIN_GROUP("ssi1-gpc-e", jz4770_ssi1_gpc_e, 1),
697 INGENIC_PIN_GROUP("ssi1-ce0-b", jz4770_ssi1_ce0_b, 2),
698 INGENIC_PIN_GROUP("ssi1-ce0-d", jz4770_ssi1_ce0_d, 2),
699 INGENIC_PIN_GROUP("ssi1-ce0-e", jz4770_ssi1_ce0_e, 1),
700 INGENIC_PIN_GROUP("ssi1-ce1-b", jz4770_ssi1_ce1_b, 2),
701 INGENIC_PIN_GROUP("ssi1-ce1-d", jz4770_ssi1_ce1_d, 2),
702 INGENIC_PIN_GROUP("ssi1-ce1-e", jz4770_ssi1_ce1_e, 1),
703 INGENIC_PIN_GROUP_FUNCS("mmc0-1bit-a", jz4770_mmc0_1bit_a,
704 jz4760_mmc0_1bit_a_funcs),
705 INGENIC_PIN_GROUP("mmc0-4bit-a", jz4770_mmc0_4bit_a, 1),
706 INGENIC_PIN_GROUP("mmc0-1bit-e", jz4770_mmc0_1bit_e, 0),
707 INGENIC_PIN_GROUP("mmc0-4bit-e", jz4770_mmc0_4bit_e, 0),
708 INGENIC_PIN_GROUP("mmc0-8bit-e", jz4770_mmc0_8bit_e, 0),
709 INGENIC_PIN_GROUP("mmc1-1bit-d", jz4770_mmc1_1bit_d, 0),
710 INGENIC_PIN_GROUP("mmc1-4bit-d", jz4770_mmc1_4bit_d, 0),
711 INGENIC_PIN_GROUP("mmc1-1bit-e", jz4770_mmc1_1bit_e, 1),
712 INGENIC_PIN_GROUP("mmc1-4bit-e", jz4770_mmc1_4bit_e, 1),
713 INGENIC_PIN_GROUP("mmc1-8bit-e", jz4770_mmc1_8bit_e, 1),
714 INGENIC_PIN_GROUP("mmc2-1bit-b", jz4770_mmc2_1bit_b, 0),
715 INGENIC_PIN_GROUP("mmc2-4bit-b", jz4770_mmc2_4bit_b, 0),
716 INGENIC_PIN_GROUP("mmc2-1bit-e", jz4770_mmc2_1bit_e, 2),
717 INGENIC_PIN_GROUP("mmc2-4bit-e", jz4770_mmc2_4bit_e, 2),
718 INGENIC_PIN_GROUP("mmc2-8bit-e", jz4770_mmc2_8bit_e, 2),
719 INGENIC_PIN_GROUP("nemc-8bit-data", jz4770_nemc_8bit_data, 0),
720 INGENIC_PIN_GROUP("nemc-16bit-data", jz4770_nemc_16bit_data, 0),
721 INGENIC_PIN_GROUP("nemc-cle-ale", jz4770_nemc_cle_ale, 0),
722 INGENIC_PIN_GROUP("nemc-addr", jz4770_nemc_addr, 0),
723 INGENIC_PIN_GROUP("nemc-rd-we", jz4770_nemc_rd_we, 0),
724 INGENIC_PIN_GROUP("nemc-frd-fwe", jz4770_nemc_frd_fwe, 0),
725 INGENIC_PIN_GROUP("nemc-wait", jz4770_nemc_wait, 0),
726 INGENIC_PIN_GROUP("nemc-cs1", jz4770_nemc_cs1, 0),
727 INGENIC_PIN_GROUP("nemc-cs2", jz4770_nemc_cs2, 0),
728 INGENIC_PIN_GROUP("nemc-cs3", jz4770_nemc_cs3, 0),
729 INGENIC_PIN_GROUP("nemc-cs4", jz4770_nemc_cs4, 0),
730 INGENIC_PIN_GROUP("nemc-cs5", jz4770_nemc_cs5, 0),
731 INGENIC_PIN_GROUP("nemc-cs6", jz4770_nemc_cs6, 0),
732 INGENIC_PIN_GROUP("i2c0-data", jz4770_i2c0, 0),
733 INGENIC_PIN_GROUP("i2c1-data", jz4770_i2c1, 0),
734 INGENIC_PIN_GROUP("i2c2-data", jz4770_i2c2, 2),
735 INGENIC_PIN_GROUP("cim-data-8bit", jz4770_cim_8bit, 0),
736 INGENIC_PIN_GROUP("cim-data-12bit", jz4770_cim_12bit, 0),
Paul Cercueil016e0542020-11-01 09:01:04 +0000737 INGENIC_PIN_GROUP("lcd-8bit", jz4770_lcd_8bit, 0),
Paul Cercueilbb42b592020-11-01 09:01:03 +0000738 INGENIC_PIN_GROUP("lcd-24bit", jz4770_lcd_24bit, 0),
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200739 { "lcd-no-pins", },
Paul Cercueilbb42b592020-11-01 09:01:03 +0000740 INGENIC_PIN_GROUP("pwm0", jz4770_pwm_pwm0, 0),
741 INGENIC_PIN_GROUP("pwm1", jz4770_pwm_pwm1, 0),
742 INGENIC_PIN_GROUP("pwm2", jz4770_pwm_pwm2, 0),
743 INGENIC_PIN_GROUP("pwm3", jz4770_pwm_pwm3, 0),
744 INGENIC_PIN_GROUP("pwm4", jz4770_pwm_pwm4, 0),
745 INGENIC_PIN_GROUP("pwm5", jz4770_pwm_pwm5, 0),
746 INGENIC_PIN_GROUP("pwm6", jz4770_pwm_pwm6, 0),
747 INGENIC_PIN_GROUP("pwm7", jz4770_pwm_pwm7, 0),
748 INGENIC_PIN_GROUP("mac-rmii", jz4770_mac_rmii, 0),
749 INGENIC_PIN_GROUP("mac-mii", jz4770_mac_mii, 0),
750 INGENIC_PIN_GROUP("otg-vbus", jz4770_otg, 0),
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200751};
752
753static const char *jz4770_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
754static const char *jz4770_uart1_groups[] = { "uart1-data", "uart1-hwflow", };
755static const char *jz4770_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
756static const char *jz4770_uart3_groups[] = { "uart3-data", "uart3-hwflow", };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800757static const char *jz4770_ssi0_groups[] = {
758 "ssi0-dt-a", "ssi0-dt-b", "ssi0-dt-d", "ssi0-dt-e",
759 "ssi0-dr-a", "ssi0-dr-b", "ssi0-dr-d", "ssi0-dr-e",
760 "ssi0-clk-a", "ssi0-clk-b", "ssi0-clk-d", "ssi0-clk-e",
761 "ssi0-gpc-b", "ssi0-gpc-d", "ssi0-gpc-e",
762 "ssi0-ce0-a", "ssi0-ce0-b", "ssi0-ce0-d", "ssi0-ce0-e",
763 "ssi0-ce1-b", "ssi0-ce1-d", "ssi0-ce1-e",
764};
765static const char *jz4770_ssi1_groups[] = {
766 "ssi1-dt-b", "ssi1-dt-d", "ssi1-dt-e",
767 "ssi1-dr-b", "ssi1-dr-d", "ssi1-dr-e",
768 "ssi1-clk-b", "ssi1-clk-d", "ssi1-clk-e",
769 "ssi1-gpc-b", "ssi1-gpc-d", "ssi1-gpc-e",
770 "ssi1-ce0-b", "ssi1-ce0-d", "ssi1-ce0-e",
771 "ssi1-ce1-b", "ssi1-ce1-d", "ssi1-ce1-e",
772};
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200773static const char *jz4770_mmc0_groups[] = {
Zhou Yanjieff656e42019-01-28 23:19:57 +0800774 "mmc0-1bit-a", "mmc0-4bit-a",
775 "mmc0-1bit-e", "mmc0-4bit-e", "mmc0-8bit-e",
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200776};
777static const char *jz4770_mmc1_groups[] = {
Zhou Yanjieff656e42019-01-28 23:19:57 +0800778 "mmc1-1bit-d", "mmc1-4bit-d",
779 "mmc1-1bit-e", "mmc1-4bit-e", "mmc1-8bit-e",
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200780};
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800781static const char *jz4770_mmc2_groups[] = {
782 "mmc2-1bit-b", "mmc2-4bit-b",
783 "mmc2-1bit-e", "mmc2-4bit-e", "mmc2-8bit-e",
784};
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200785static const char *jz4770_nemc_groups[] = {
Zhou Yanjieff656e42019-01-28 23:19:57 +0800786 "nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale",
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800787 "nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200788};
789static const char *jz4770_cs1_groups[] = { "nemc-cs1", };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800790static const char *jz4770_cs2_groups[] = { "nemc-cs2", };
791static const char *jz4770_cs3_groups[] = { "nemc-cs3", };
792static const char *jz4770_cs4_groups[] = { "nemc-cs4", };
793static const char *jz4770_cs5_groups[] = { "nemc-cs5", };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200794static const char *jz4770_cs6_groups[] = { "nemc-cs6", };
795static const char *jz4770_i2c0_groups[] = { "i2c0-data", };
796static const char *jz4770_i2c1_groups[] = { "i2c1-data", };
797static const char *jz4770_i2c2_groups[] = { "i2c2-data", };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800798static const char *jz4770_cim_groups[] = { "cim-data-8bit", "cim-data-12bit", };
Paul Cercueil016e0542020-11-01 09:01:04 +0000799static const char *jz4770_lcd_groups[] = {
800 "lcd-8bit", "lcd-24bit", "lcd-no-pins",
801};
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200802static const char *jz4770_pwm0_groups[] = { "pwm0", };
803static const char *jz4770_pwm1_groups[] = { "pwm1", };
804static const char *jz4770_pwm2_groups[] = { "pwm2", };
805static const char *jz4770_pwm3_groups[] = { "pwm3", };
806static const char *jz4770_pwm4_groups[] = { "pwm4", };
807static const char *jz4770_pwm5_groups[] = { "pwm5", };
808static const char *jz4770_pwm6_groups[] = { "pwm6", };
809static const char *jz4770_pwm7_groups[] = { "pwm7", };
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800810static const char *jz4770_mac_groups[] = { "mac-rmii", "mac-mii", };
Paul Cercueilae75b532019-11-19 16:52:11 +0100811static const char *jz4770_otg_groups[] = { "otg-vbus", };
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200812
813static const struct function_desc jz4770_functions[] = {
814 { "uart0", jz4770_uart0_groups, ARRAY_SIZE(jz4770_uart0_groups), },
815 { "uart1", jz4770_uart1_groups, ARRAY_SIZE(jz4770_uart1_groups), },
816 { "uart2", jz4770_uart2_groups, ARRAY_SIZE(jz4770_uart2_groups), },
817 { "uart3", jz4770_uart3_groups, ARRAY_SIZE(jz4770_uart3_groups), },
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800818 { "ssi0", jz4770_ssi0_groups, ARRAY_SIZE(jz4770_ssi0_groups), },
819 { "ssi1", jz4770_ssi1_groups, ARRAY_SIZE(jz4770_ssi1_groups), },
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200820 { "mmc0", jz4770_mmc0_groups, ARRAY_SIZE(jz4770_mmc0_groups), },
821 { "mmc1", jz4770_mmc1_groups, ARRAY_SIZE(jz4770_mmc1_groups), },
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800822 { "mmc2", jz4770_mmc2_groups, ARRAY_SIZE(jz4770_mmc2_groups), },
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200823 { "nemc", jz4770_nemc_groups, ARRAY_SIZE(jz4770_nemc_groups), },
824 { "nemc-cs1", jz4770_cs1_groups, ARRAY_SIZE(jz4770_cs1_groups), },
Zhou Yanjieff656e42019-01-28 23:19:57 +0800825 { "nemc-cs2", jz4770_cs2_groups, ARRAY_SIZE(jz4770_cs2_groups), },
826 { "nemc-cs3", jz4770_cs3_groups, ARRAY_SIZE(jz4770_cs3_groups), },
827 { "nemc-cs4", jz4770_cs4_groups, ARRAY_SIZE(jz4770_cs4_groups), },
828 { "nemc-cs5", jz4770_cs5_groups, ARRAY_SIZE(jz4770_cs5_groups), },
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200829 { "nemc-cs6", jz4770_cs6_groups, ARRAY_SIZE(jz4770_cs6_groups), },
830 { "i2c0", jz4770_i2c0_groups, ARRAY_SIZE(jz4770_i2c0_groups), },
831 { "i2c1", jz4770_i2c1_groups, ARRAY_SIZE(jz4770_i2c1_groups), },
832 { "i2c2", jz4770_i2c2_groups, ARRAY_SIZE(jz4770_i2c2_groups), },
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200833 { "cim", jz4770_cim_groups, ARRAY_SIZE(jz4770_cim_groups), },
834 { "lcd", jz4770_lcd_groups, ARRAY_SIZE(jz4770_lcd_groups), },
835 { "pwm0", jz4770_pwm0_groups, ARRAY_SIZE(jz4770_pwm0_groups), },
836 { "pwm1", jz4770_pwm1_groups, ARRAY_SIZE(jz4770_pwm1_groups), },
837 { "pwm2", jz4770_pwm2_groups, ARRAY_SIZE(jz4770_pwm2_groups), },
838 { "pwm3", jz4770_pwm3_groups, ARRAY_SIZE(jz4770_pwm3_groups), },
839 { "pwm4", jz4770_pwm4_groups, ARRAY_SIZE(jz4770_pwm4_groups), },
840 { "pwm5", jz4770_pwm5_groups, ARRAY_SIZE(jz4770_pwm5_groups), },
841 { "pwm6", jz4770_pwm6_groups, ARRAY_SIZE(jz4770_pwm6_groups), },
842 { "pwm7", jz4770_pwm7_groups, ARRAY_SIZE(jz4770_pwm7_groups), },
Zhou Yanjie5de1a732019-01-28 23:19:58 +0800843 { "mac", jz4770_mac_groups, ARRAY_SIZE(jz4770_mac_groups), },
Paul Cercueilae75b532019-11-19 16:52:11 +0100844 { "otg", jz4770_otg_groups, ARRAY_SIZE(jz4770_otg_groups), },
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200845};
846
847static const struct ingenic_chip_info jz4770_chip_info = {
848 .num_chips = 6,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +0800849 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +0100850 .version = ID_JZ4770,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +0200851 .groups = jz4770_groups,
852 .num_groups = ARRAY_SIZE(jz4770_groups),
853 .functions = jz4770_functions,
854 .num_functions = ARRAY_SIZE(jz4770_functions),
855 .pull_ups = jz4770_pull_ups,
856 .pull_downs = jz4770_pull_downs,
857};
858
周琰杰 (Zhou Yanjie)d9f5dc42020-09-13 14:58:35 +0800859static const u32 jz4780_pull_ups[6] = {
860 0x3fffffff, 0xfff0f3fc, 0x0fffffff, 0xffff4fff, 0xfffffb7c, 0x7fa7f00f,
861};
862
863static const u32 jz4780_pull_downs[6] = {
864 0x00000000, 0x000f0c03, 0x00000000, 0x0000b000, 0x00000483, 0x00580ff0,
865};
866
Zhou Yanjieff656e42019-01-28 23:19:57 +0800867static int jz4780_uart2_data_pins[] = { 0x66, 0x67, };
868static int jz4780_uart2_hwflow_pins[] = { 0x65, 0x64, };
869static int jz4780_uart4_data_pins[] = { 0x54, 0x4a, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800870static int jz4780_ssi0_dt_a_19_pins[] = { 0x13, };
871static int jz4780_ssi0_dt_a_21_pins[] = { 0x15, };
872static int jz4780_ssi0_dt_a_28_pins[] = { 0x1c, };
873static int jz4780_ssi0_dt_b_pins[] = { 0x3d, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200874static int jz4780_ssi0_dt_d_pins[] = { 0x79, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800875static int jz4780_ssi0_dr_a_20_pins[] = { 0x14, };
876static int jz4780_ssi0_dr_a_27_pins[] = { 0x1b, };
877static int jz4780_ssi0_dr_b_pins[] = { 0x34, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200878static int jz4780_ssi0_dr_d_pins[] = { 0x74, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800879static int jz4780_ssi0_clk_a_pins[] = { 0x12, };
880static int jz4780_ssi0_clk_b_5_pins[] = { 0x25, };
881static int jz4780_ssi0_clk_b_28_pins[] = { 0x3c, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200882static int jz4780_ssi0_clk_d_pins[] = { 0x78, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800883static int jz4780_ssi0_gpc_b_pins[] = { 0x3e, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200884static int jz4780_ssi0_gpc_d_pins[] = { 0x76, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800885static int jz4780_ssi0_ce0_a_23_pins[] = { 0x17, };
886static int jz4780_ssi0_ce0_a_25_pins[] = { 0x19, };
887static int jz4780_ssi0_ce0_b_pins[] = { 0x3f, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200888static int jz4780_ssi0_ce0_d_pins[] = { 0x77, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800889static int jz4780_ssi0_ce1_b_pins[] = { 0x35, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200890static int jz4780_ssi0_ce1_d_pins[] = { 0x75, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800891static int jz4780_ssi1_dt_b_pins[] = { 0x3d, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200892static int jz4780_ssi1_dt_d_pins[] = { 0x79, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800893static int jz4780_ssi1_dr_b_pins[] = { 0x34, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200894static int jz4780_ssi1_dr_d_pins[] = { 0x74, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800895static int jz4780_ssi1_clk_b_pins[] = { 0x3c, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200896static int jz4780_ssi1_clk_d_pins[] = { 0x78, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800897static int jz4780_ssi1_gpc_b_pins[] = { 0x3e, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200898static int jz4780_ssi1_gpc_d_pins[] = { 0x76, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800899static int jz4780_ssi1_ce0_b_pins[] = { 0x3f, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200900static int jz4780_ssi1_ce0_d_pins[] = { 0x77, };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +0800901static int jz4780_ssi1_ce1_b_pins[] = { 0x35, };
Paul Cercueilf83c2602020-10-10 21:25:09 +0200902static int jz4780_ssi1_ce1_d_pins[] = { 0x75, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800903static int jz4780_mmc0_8bit_a_pins[] = { 0x04, 0x05, 0x06, 0x07, 0x18, };
904static int jz4780_i2c3_pins[] = { 0x6a, 0x6b, };
905static int jz4780_i2c4_e_pins[] = { 0x8c, 0x8d, };
906static int jz4780_i2c4_f_pins[] = { 0xb9, 0xb8, };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +0800907static int jz4780_i2s_data_tx_pins[] = { 0x87, };
908static int jz4780_i2s_data_rx_pins[] = { 0x86, };
909static int jz4780_i2s_clk_txrx_pins[] = { 0x6c, 0x6d, };
910static int jz4780_i2s_clk_rx_pins[] = { 0x88, 0x89, };
911static int jz4780_i2s_sysclk_pins[] = { 0x85, };
Paul Boddiea0bb89e2020-02-28 19:19:30 +0100912static int jz4780_hdmi_ddc_pins[] = { 0xb9, 0xb8, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800913
Paul Cercueilbb42b592020-11-01 09:01:03 +0000914static u8 jz4780_i2s_clk_txrx_funcs[] = { 1, 0, };
Zhou Yanjieff656e42019-01-28 23:19:57 +0800915
916static const struct group_desc jz4780_groups[] = {
Paul Cercueilbb42b592020-11-01 09:01:03 +0000917 INGENIC_PIN_GROUP("uart0-data", jz4770_uart0_data, 0),
918 INGENIC_PIN_GROUP("uart0-hwflow", jz4770_uart0_hwflow, 0),
919 INGENIC_PIN_GROUP("uart1-data", jz4770_uart1_data, 0),
920 INGENIC_PIN_GROUP("uart1-hwflow", jz4770_uart1_hwflow, 0),
921 INGENIC_PIN_GROUP("uart2-data", jz4780_uart2_data, 1),
922 INGENIC_PIN_GROUP("uart2-hwflow", jz4780_uart2_hwflow, 1),
923 INGENIC_PIN_GROUP_FUNCS("uart3-data", jz4770_uart3_data,
924 jz4760_uart3_data_funcs),
925 INGENIC_PIN_GROUP("uart3-hwflow", jz4770_uart3_hwflow, 0),
926 INGENIC_PIN_GROUP("uart4-data", jz4780_uart4_data, 2),
927 INGENIC_PIN_GROUP("ssi0-dt-a-19", jz4780_ssi0_dt_a_19, 2),
928 INGENIC_PIN_GROUP("ssi0-dt-a-21", jz4780_ssi0_dt_a_21, 2),
929 INGENIC_PIN_GROUP("ssi0-dt-a-28", jz4780_ssi0_dt_a_28, 2),
930 INGENIC_PIN_GROUP("ssi0-dt-b", jz4780_ssi0_dt_b, 1),
931 INGENIC_PIN_GROUP("ssi0-dt-d", jz4780_ssi0_dt_d, 1),
932 INGENIC_PIN_GROUP("ssi0-dt-e", jz4770_ssi0_dt_e, 0),
933 INGENIC_PIN_GROUP("ssi0-dr-a-20", jz4780_ssi0_dr_a_20, 2),
934 INGENIC_PIN_GROUP("ssi0-dr-a-27", jz4780_ssi0_dr_a_27, 2),
935 INGENIC_PIN_GROUP("ssi0-dr-b", jz4780_ssi0_dr_b, 1),
936 INGENIC_PIN_GROUP("ssi0-dr-d", jz4780_ssi0_dr_d, 1),
937 INGENIC_PIN_GROUP("ssi0-dr-e", jz4770_ssi0_dr_e, 0),
938 INGENIC_PIN_GROUP("ssi0-clk-a", jz4780_ssi0_clk_a, 2),
939 INGENIC_PIN_GROUP("ssi0-clk-b-5", jz4780_ssi0_clk_b_5, 1),
940 INGENIC_PIN_GROUP("ssi0-clk-b-28", jz4780_ssi0_clk_b_28, 1),
941 INGENIC_PIN_GROUP("ssi0-clk-d", jz4780_ssi0_clk_d, 1),
942 INGENIC_PIN_GROUP("ssi0-clk-e", jz4770_ssi0_clk_e, 0),
943 INGENIC_PIN_GROUP("ssi0-gpc-b", jz4780_ssi0_gpc_b, 1),
944 INGENIC_PIN_GROUP("ssi0-gpc-d", jz4780_ssi0_gpc_d, 1),
945 INGENIC_PIN_GROUP("ssi0-gpc-e", jz4770_ssi0_gpc_e, 0),
946 INGENIC_PIN_GROUP("ssi0-ce0-a-23", jz4780_ssi0_ce0_a_23, 2),
947 INGENIC_PIN_GROUP("ssi0-ce0-a-25", jz4780_ssi0_ce0_a_25, 2),
948 INGENIC_PIN_GROUP("ssi0-ce0-b", jz4780_ssi0_ce0_b, 1),
949 INGENIC_PIN_GROUP("ssi0-ce0-d", jz4780_ssi0_ce0_d, 1),
950 INGENIC_PIN_GROUP("ssi0-ce0-e", jz4770_ssi0_ce0_e, 0),
951 INGENIC_PIN_GROUP("ssi0-ce1-b", jz4780_ssi0_ce1_b, 1),
952 INGENIC_PIN_GROUP("ssi0-ce1-d", jz4780_ssi0_ce1_d, 1),
953 INGENIC_PIN_GROUP("ssi0-ce1-e", jz4770_ssi0_ce1_e, 0),
954 INGENIC_PIN_GROUP("ssi1-dt-b", jz4780_ssi1_dt_b, 2),
955 INGENIC_PIN_GROUP("ssi1-dt-d", jz4780_ssi1_dt_d, 2),
956 INGENIC_PIN_GROUP("ssi1-dt-e", jz4770_ssi1_dt_e, 1),
957 INGENIC_PIN_GROUP("ssi1-dr-b", jz4780_ssi1_dr_b, 2),
958 INGENIC_PIN_GROUP("ssi1-dr-d", jz4780_ssi1_dr_d, 2),
959 INGENIC_PIN_GROUP("ssi1-dr-e", jz4770_ssi1_dr_e, 1),
960 INGENIC_PIN_GROUP("ssi1-clk-b", jz4780_ssi1_clk_b, 2),
961 INGENIC_PIN_GROUP("ssi1-clk-d", jz4780_ssi1_clk_d, 2),
962 INGENIC_PIN_GROUP("ssi1-clk-e", jz4770_ssi1_clk_e, 1),
963 INGENIC_PIN_GROUP("ssi1-gpc-b", jz4780_ssi1_gpc_b, 2),
964 INGENIC_PIN_GROUP("ssi1-gpc-d", jz4780_ssi1_gpc_d, 2),
965 INGENIC_PIN_GROUP("ssi1-gpc-e", jz4770_ssi1_gpc_e, 1),
966 INGENIC_PIN_GROUP("ssi1-ce0-b", jz4780_ssi1_ce0_b, 2),
967 INGENIC_PIN_GROUP("ssi1-ce0-d", jz4780_ssi1_ce0_d, 2),
968 INGENIC_PIN_GROUP("ssi1-ce0-e", jz4770_ssi1_ce0_e, 1),
969 INGENIC_PIN_GROUP("ssi1-ce1-b", jz4780_ssi1_ce1_b, 2),
970 INGENIC_PIN_GROUP("ssi1-ce1-d", jz4780_ssi1_ce1_d, 2),
971 INGENIC_PIN_GROUP("ssi1-ce1-e", jz4770_ssi1_ce1_e, 1),
972 INGENIC_PIN_GROUP_FUNCS("mmc0-1bit-a", jz4770_mmc0_1bit_a,
973 jz4760_mmc0_1bit_a_funcs),
974 INGENIC_PIN_GROUP("mmc0-4bit-a", jz4770_mmc0_4bit_a, 1),
975 INGENIC_PIN_GROUP("mmc0-8bit-a", jz4780_mmc0_8bit_a, 1),
976 INGENIC_PIN_GROUP("mmc0-1bit-e", jz4770_mmc0_1bit_e, 0),
977 INGENIC_PIN_GROUP("mmc0-4bit-e", jz4770_mmc0_4bit_e, 0),
978 INGENIC_PIN_GROUP("mmc1-1bit-d", jz4770_mmc1_1bit_d, 0),
979 INGENIC_PIN_GROUP("mmc1-4bit-d", jz4770_mmc1_4bit_d, 0),
980 INGENIC_PIN_GROUP("mmc1-1bit-e", jz4770_mmc1_1bit_e, 1),
981 INGENIC_PIN_GROUP("mmc1-4bit-e", jz4770_mmc1_4bit_e, 1),
982 INGENIC_PIN_GROUP("mmc2-1bit-b", jz4770_mmc2_1bit_b, 0),
983 INGENIC_PIN_GROUP("mmc2-4bit-b", jz4770_mmc2_4bit_b, 0),
984 INGENIC_PIN_GROUP("mmc2-1bit-e", jz4770_mmc2_1bit_e, 2),
985 INGENIC_PIN_GROUP("mmc2-4bit-e", jz4770_mmc2_4bit_e, 2),
986 INGENIC_PIN_GROUP("nemc-data", jz4770_nemc_8bit_data, 0),
987 INGENIC_PIN_GROUP("nemc-cle-ale", jz4770_nemc_cle_ale, 0),
988 INGENIC_PIN_GROUP("nemc-addr", jz4770_nemc_addr, 0),
989 INGENIC_PIN_GROUP("nemc-rd-we", jz4770_nemc_rd_we, 0),
990 INGENIC_PIN_GROUP("nemc-frd-fwe", jz4770_nemc_frd_fwe, 0),
991 INGENIC_PIN_GROUP("nemc-wait", jz4770_nemc_wait, 0),
992 INGENIC_PIN_GROUP("nemc-cs1", jz4770_nemc_cs1, 0),
993 INGENIC_PIN_GROUP("nemc-cs2", jz4770_nemc_cs2, 0),
994 INGENIC_PIN_GROUP("nemc-cs3", jz4770_nemc_cs3, 0),
995 INGENIC_PIN_GROUP("nemc-cs4", jz4770_nemc_cs4, 0),
996 INGENIC_PIN_GROUP("nemc-cs5", jz4770_nemc_cs5, 0),
997 INGENIC_PIN_GROUP("nemc-cs6", jz4770_nemc_cs6, 0),
998 INGENIC_PIN_GROUP("i2c0-data", jz4770_i2c0, 0),
999 INGENIC_PIN_GROUP("i2c1-data", jz4770_i2c1, 0),
1000 INGENIC_PIN_GROUP("i2c2-data", jz4770_i2c2, 2),
1001 INGENIC_PIN_GROUP("i2c3-data", jz4780_i2c3, 1),
1002 INGENIC_PIN_GROUP("i2c4-data-e", jz4780_i2c4_e, 1),
1003 INGENIC_PIN_GROUP("i2c4-data-f", jz4780_i2c4_f, 1),
1004 INGENIC_PIN_GROUP("i2s-data-tx", jz4780_i2s_data_tx, 0),
1005 INGENIC_PIN_GROUP("i2s-data-rx", jz4780_i2s_data_rx, 0),
1006 INGENIC_PIN_GROUP_FUNCS("i2s-clk-txrx", jz4780_i2s_clk_txrx,
1007 jz4780_i2s_clk_txrx_funcs),
1008 INGENIC_PIN_GROUP("i2s-clk-rx", jz4780_i2s_clk_rx, 1),
1009 INGENIC_PIN_GROUP("i2s-sysclk", jz4780_i2s_sysclk, 2),
1010 INGENIC_PIN_GROUP("hdmi-ddc", jz4780_hdmi_ddc, 0),
1011 INGENIC_PIN_GROUP("cim-data", jz4770_cim_8bit, 0),
1012 INGENIC_PIN_GROUP("cim-data-12bit", jz4770_cim_12bit, 0),
1013 INGENIC_PIN_GROUP("lcd-24bit", jz4770_lcd_24bit, 0),
Zhou Yanjieff656e42019-01-28 23:19:57 +08001014 { "lcd-no-pins", },
Paul Cercueilbb42b592020-11-01 09:01:03 +00001015 INGENIC_PIN_GROUP("pwm0", jz4770_pwm_pwm0, 0),
1016 INGENIC_PIN_GROUP("pwm1", jz4770_pwm_pwm1, 0),
1017 INGENIC_PIN_GROUP("pwm2", jz4770_pwm_pwm2, 0),
1018 INGENIC_PIN_GROUP("pwm3", jz4770_pwm_pwm3, 0),
1019 INGENIC_PIN_GROUP("pwm4", jz4770_pwm_pwm4, 0),
1020 INGENIC_PIN_GROUP("pwm5", jz4770_pwm_pwm5, 0),
1021 INGENIC_PIN_GROUP("pwm6", jz4770_pwm_pwm6, 0),
1022 INGENIC_PIN_GROUP("pwm7", jz4770_pwm_pwm7, 0),
Zhou Yanjieff656e42019-01-28 23:19:57 +08001023};
1024
1025static const char *jz4780_uart2_groups[] = { "uart2-data", "uart2-hwflow", };
1026static const char *jz4780_uart4_groups[] = { "uart4-data", };
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001027static const char *jz4780_ssi0_groups[] = {
1028 "ssi0-dt-a-19", "ssi0-dt-a-21", "ssi0-dt-a-28", "ssi0-dt-b", "ssi0-dt-d", "ssi0-dt-e",
1029 "ssi0-dr-a-20", "ssi0-dr-a-27", "ssi0-dr-b", "ssi0-dr-d", "ssi0-dr-e",
1030 "ssi0-clk-a", "ssi0-clk-b-5", "ssi0-clk-b-28", "ssi0-clk-d", "ssi0-clk-e",
1031 "ssi0-gpc-b", "ssi0-gpc-d", "ssi0-gpc-e",
1032 "ssi0-ce0-a-23", "ssi0-ce0-a-25", "ssi0-ce0-b", "ssi0-ce0-d", "ssi0-ce0-e",
1033 "ssi0-ce1-b", "ssi0-ce1-d", "ssi0-ce1-e",
1034};
1035static const char *jz4780_ssi1_groups[] = {
1036 "ssi1-dt-b", "ssi1-dt-d", "ssi1-dt-e",
1037 "ssi1-dr-b", "ssi1-dr-d", "ssi1-dr-e",
1038 "ssi1-clk-b", "ssi1-clk-d", "ssi1-clk-e",
1039 "ssi1-gpc-b", "ssi1-gpc-d", "ssi1-gpc-e",
1040 "ssi1-ce0-b", "ssi1-ce0-d", "ssi1-ce0-e",
1041 "ssi1-ce1-b", "ssi1-ce1-d", "ssi1-ce1-e",
1042};
Zhou Yanjieff656e42019-01-28 23:19:57 +08001043static const char *jz4780_mmc0_groups[] = {
1044 "mmc0-1bit-a", "mmc0-4bit-a", "mmc0-8bit-a",
1045 "mmc0-1bit-e", "mmc0-4bit-e",
1046};
1047static const char *jz4780_mmc1_groups[] = {
1048 "mmc1-1bit-d", "mmc1-4bit-d", "mmc1-1bit-e", "mmc1-4bit-e",
1049};
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001050static const char *jz4780_mmc2_groups[] = {
1051 "mmc2-1bit-b", "mmc2-4bit-b", "mmc2-1bit-e", "mmc2-4bit-e",
1052};
Zhou Yanjieff656e42019-01-28 23:19:57 +08001053static const char *jz4780_nemc_groups[] = {
1054 "nemc-data", "nemc-cle-ale", "nemc-addr",
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001055 "nemc-rd-we", "nemc-frd-fwe", "nemc-wait",
Zhou Yanjieff656e42019-01-28 23:19:57 +08001056};
1057static const char *jz4780_i2c3_groups[] = { "i2c3-data", };
1058static const char *jz4780_i2c4_groups[] = { "i2c4-data-e", "i2c4-data-f", };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001059static const char *jz4780_i2s_groups[] = {
1060 "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-clk-rx", "i2s-sysclk",
1061};
Zhou Yanjieff656e42019-01-28 23:19:57 +08001062static const char *jz4780_cim_groups[] = { "cim-data", };
Paul Boddiea0bb89e2020-02-28 19:19:30 +01001063static const char *jz4780_hdmi_ddc_groups[] = { "hdmi-ddc", };
Zhou Yanjieff656e42019-01-28 23:19:57 +08001064
1065static const struct function_desc jz4780_functions[] = {
1066 { "uart0", jz4770_uart0_groups, ARRAY_SIZE(jz4770_uart0_groups), },
1067 { "uart1", jz4770_uart1_groups, ARRAY_SIZE(jz4770_uart1_groups), },
1068 { "uart2", jz4780_uart2_groups, ARRAY_SIZE(jz4780_uart2_groups), },
1069 { "uart3", jz4770_uart3_groups, ARRAY_SIZE(jz4770_uart3_groups), },
1070 { "uart4", jz4780_uart4_groups, ARRAY_SIZE(jz4780_uart4_groups), },
周琰杰 (Zhou Yanjie)d3ef8c62020-09-13 14:58:34 +08001071 { "ssi0", jz4780_ssi0_groups, ARRAY_SIZE(jz4780_ssi0_groups), },
1072 { "ssi1", jz4780_ssi1_groups, ARRAY_SIZE(jz4780_ssi1_groups), },
Zhou Yanjieff656e42019-01-28 23:19:57 +08001073 { "mmc0", jz4780_mmc0_groups, ARRAY_SIZE(jz4780_mmc0_groups), },
1074 { "mmc1", jz4780_mmc1_groups, ARRAY_SIZE(jz4780_mmc1_groups), },
Zhou Yanjie5de1a732019-01-28 23:19:58 +08001075 { "mmc2", jz4780_mmc2_groups, ARRAY_SIZE(jz4780_mmc2_groups), },
Zhou Yanjieff656e42019-01-28 23:19:57 +08001076 { "nemc", jz4780_nemc_groups, ARRAY_SIZE(jz4780_nemc_groups), },
1077 { "nemc-cs1", jz4770_cs1_groups, ARRAY_SIZE(jz4770_cs1_groups), },
1078 { "nemc-cs2", jz4770_cs2_groups, ARRAY_SIZE(jz4770_cs2_groups), },
1079 { "nemc-cs3", jz4770_cs3_groups, ARRAY_SIZE(jz4770_cs3_groups), },
1080 { "nemc-cs4", jz4770_cs4_groups, ARRAY_SIZE(jz4770_cs4_groups), },
1081 { "nemc-cs5", jz4770_cs5_groups, ARRAY_SIZE(jz4770_cs5_groups), },
1082 { "nemc-cs6", jz4770_cs6_groups, ARRAY_SIZE(jz4770_cs6_groups), },
1083 { "i2c0", jz4770_i2c0_groups, ARRAY_SIZE(jz4770_i2c0_groups), },
1084 { "i2c1", jz4770_i2c1_groups, ARRAY_SIZE(jz4770_i2c1_groups), },
1085 { "i2c2", jz4770_i2c2_groups, ARRAY_SIZE(jz4770_i2c2_groups), },
1086 { "i2c3", jz4780_i2c3_groups, ARRAY_SIZE(jz4780_i2c3_groups), },
1087 { "i2c4", jz4780_i2c4_groups, ARRAY_SIZE(jz4780_i2c4_groups), },
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001088 { "i2s", jz4780_i2s_groups, ARRAY_SIZE(jz4780_i2s_groups), },
Zhou Yanjieff656e42019-01-28 23:19:57 +08001089 { "cim", jz4780_cim_groups, ARRAY_SIZE(jz4780_cim_groups), },
1090 { "lcd", jz4770_lcd_groups, ARRAY_SIZE(jz4770_lcd_groups), },
1091 { "pwm0", jz4770_pwm0_groups, ARRAY_SIZE(jz4770_pwm0_groups), },
1092 { "pwm1", jz4770_pwm1_groups, ARRAY_SIZE(jz4770_pwm1_groups), },
1093 { "pwm2", jz4770_pwm2_groups, ARRAY_SIZE(jz4770_pwm2_groups), },
1094 { "pwm3", jz4770_pwm3_groups, ARRAY_SIZE(jz4770_pwm3_groups), },
1095 { "pwm4", jz4770_pwm4_groups, ARRAY_SIZE(jz4770_pwm4_groups), },
1096 { "pwm5", jz4770_pwm5_groups, ARRAY_SIZE(jz4770_pwm5_groups), },
1097 { "pwm6", jz4770_pwm6_groups, ARRAY_SIZE(jz4770_pwm6_groups), },
1098 { "pwm7", jz4770_pwm7_groups, ARRAY_SIZE(jz4770_pwm7_groups), },
Paul Boddiea0bb89e2020-02-28 19:19:30 +01001099 { "hdmi-ddc", jz4780_hdmi_ddc_groups,
1100 ARRAY_SIZE(jz4780_hdmi_ddc_groups), },
Zhou Yanjieff656e42019-01-28 23:19:57 +08001101};
1102
1103static const struct ingenic_chip_info jz4780_chip_info = {
1104 .num_chips = 6,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08001105 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +01001106 .version = ID_JZ4780,
Zhou Yanjieff656e42019-01-28 23:19:57 +08001107 .groups = jz4780_groups,
1108 .num_groups = ARRAY_SIZE(jz4780_groups),
1109 .functions = jz4780_functions,
1110 .num_functions = ARRAY_SIZE(jz4780_functions),
周琰杰 (Zhou Yanjie)d9f5dc42020-09-13 14:58:35 +08001111 .pull_ups = jz4780_pull_ups,
1112 .pull_downs = jz4780_pull_downs,
Zhou Yanjieff656e42019-01-28 23:19:57 +08001113};
1114
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001115static const u32 x1000_pull_ups[4] = {
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001116 0xffffffff, 0xfdffffff, 0x0dffffff, 0x0000003f,
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001117};
1118
1119static const u32 x1000_pull_downs[4] = {
1120 0x00000000, 0x02000000, 0x02000000, 0x00000000,
1121};
1122
1123static int x1000_uart0_data_pins[] = { 0x4a, 0x4b, };
1124static int x1000_uart0_hwflow_pins[] = { 0x4c, 0x4d, };
1125static int x1000_uart1_data_a_pins[] = { 0x04, 0x05, };
1126static int x1000_uart1_data_d_pins[] = { 0x62, 0x63, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001127static int x1000_uart1_hwflow_pins[] = { 0x64, 0x65, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001128static int x1000_uart2_data_a_pins[] = { 0x02, 0x03, };
1129static int x1000_uart2_data_d_pins[] = { 0x65, 0x64, };
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001130static int x1000_sfc_pins[] = { 0x1d, 0x1c, 0x1e, 0x1f, 0x1a, 0x1b, };
1131static int x1000_ssi_dt_a_22_pins[] = { 0x16, };
1132static int x1000_ssi_dt_a_29_pins[] = { 0x1d, };
1133static int x1000_ssi_dt_d_pins[] = { 0x62, };
1134static int x1000_ssi_dr_a_23_pins[] = { 0x17, };
1135static int x1000_ssi_dr_a_28_pins[] = { 0x1c, };
1136static int x1000_ssi_dr_d_pins[] = { 0x63, };
1137static int x1000_ssi_clk_a_24_pins[] = { 0x18, };
1138static int x1000_ssi_clk_a_26_pins[] = { 0x1a, };
1139static int x1000_ssi_clk_d_pins[] = { 0x60, };
1140static int x1000_ssi_gpc_a_20_pins[] = { 0x14, };
1141static int x1000_ssi_gpc_a_31_pins[] = { 0x1f, };
1142static int x1000_ssi_ce0_a_25_pins[] = { 0x19, };
1143static int x1000_ssi_ce0_a_27_pins[] = { 0x1b, };
1144static int x1000_ssi_ce0_d_pins[] = { 0x61, };
1145static int x1000_ssi_ce1_a_21_pins[] = { 0x15, };
1146static int x1000_ssi_ce1_a_30_pins[] = { 0x1e, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001147static int x1000_mmc0_1bit_pins[] = { 0x18, 0x19, 0x17, };
1148static int x1000_mmc0_4bit_pins[] = { 0x16, 0x15, 0x14, };
1149static int x1000_mmc0_8bit_pins[] = { 0x13, 0x12, 0x11, 0x10, };
1150static int x1000_mmc1_1bit_pins[] = { 0x40, 0x41, 0x42, };
1151static int x1000_mmc1_4bit_pins[] = { 0x43, 0x44, 0x45, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001152static int x1000_emc_8bit_data_pins[] = {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001153 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1154};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001155static int x1000_emc_16bit_data_pins[] = {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001156 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1157};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001158static int x1000_emc_addr_pins[] = {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001159 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
1160 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
1161};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001162static int x1000_emc_rd_we_pins[] = { 0x30, 0x31, };
1163static int x1000_emc_wait_pins[] = { 0x34, };
1164static int x1000_emc_cs1_pins[] = { 0x32, };
1165static int x1000_emc_cs2_pins[] = { 0x33, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001166static int x1000_i2c0_pins[] = { 0x38, 0x37, };
1167static int x1000_i2c1_a_pins[] = { 0x01, 0x00, };
1168static int x1000_i2c1_c_pins[] = { 0x5b, 0x5a, };
1169static int x1000_i2c2_pins[] = { 0x61, 0x60, };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001170static int x1000_i2s_data_tx_pins[] = { 0x24, };
1171static int x1000_i2s_data_rx_pins[] = { 0x23, };
1172static int x1000_i2s_clk_txrx_pins[] = { 0x21, 0x22, };
1173static int x1000_i2s_sysclk_pins[] = { 0x20, };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001174static int x1000_cim_pins[] = {
1175 0x08, 0x09, 0x0a, 0x0b,
1176 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c,
1177};
1178static int x1000_lcd_8bit_pins[] = {
1179 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1180 0x30, 0x31, 0x32, 0x33, 0x34,
1181};
1182static int x1000_lcd_16bit_pins[] = {
1183 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
1184};
1185static int x1000_pwm_pwm0_pins[] = { 0x59, };
1186static int x1000_pwm_pwm1_pins[] = { 0x5a, };
1187static int x1000_pwm_pwm2_pins[] = { 0x5b, };
1188static int x1000_pwm_pwm3_pins[] = { 0x26, };
1189static int x1000_pwm_pwm4_pins[] = { 0x58, };
1190static int x1000_mac_pins[] = {
1191 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x26,
1192};
1193
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001194static const struct group_desc x1000_groups[] = {
Paul Cercueilbb42b592020-11-01 09:01:03 +00001195 INGENIC_PIN_GROUP("uart0-data", x1000_uart0_data, 0),
1196 INGENIC_PIN_GROUP("uart0-hwflow", x1000_uart0_hwflow, 0),
1197 INGENIC_PIN_GROUP("uart1-data-a", x1000_uart1_data_a, 2),
1198 INGENIC_PIN_GROUP("uart1-data-d", x1000_uart1_data_d, 1),
1199 INGENIC_PIN_GROUP("uart1-hwflow", x1000_uart1_hwflow, 1),
1200 INGENIC_PIN_GROUP("uart2-data-a", x1000_uart2_data_a, 2),
1201 INGENIC_PIN_GROUP("uart2-data-d", x1000_uart2_data_d, 0),
1202 INGENIC_PIN_GROUP("sfc", x1000_sfc, 1),
1203 INGENIC_PIN_GROUP("ssi-dt-a-22", x1000_ssi_dt_a_22, 2),
1204 INGENIC_PIN_GROUP("ssi-dt-a-29", x1000_ssi_dt_a_29, 2),
1205 INGENIC_PIN_GROUP("ssi-dt-d", x1000_ssi_dt_d, 0),
1206 INGENIC_PIN_GROUP("ssi-dr-a-23", x1000_ssi_dr_a_23, 2),
1207 INGENIC_PIN_GROUP("ssi-dr-a-28", x1000_ssi_dr_a_28, 2),
1208 INGENIC_PIN_GROUP("ssi-dr-d", x1000_ssi_dr_d, 0),
1209 INGENIC_PIN_GROUP("ssi-clk-a-24", x1000_ssi_clk_a_24, 2),
1210 INGENIC_PIN_GROUP("ssi-clk-a-26", x1000_ssi_clk_a_26, 2),
1211 INGENIC_PIN_GROUP("ssi-clk-d", x1000_ssi_clk_d, 0),
1212 INGENIC_PIN_GROUP("ssi-gpc-a-20", x1000_ssi_gpc_a_20, 2),
1213 INGENIC_PIN_GROUP("ssi-gpc-a-31", x1000_ssi_gpc_a_31, 2),
1214 INGENIC_PIN_GROUP("ssi-ce0-a-25", x1000_ssi_ce0_a_25, 2),
1215 INGENIC_PIN_GROUP("ssi-ce0-a-27", x1000_ssi_ce0_a_27, 2),
1216 INGENIC_PIN_GROUP("ssi-ce0-d", x1000_ssi_ce0_d, 0),
1217 INGENIC_PIN_GROUP("ssi-ce1-a-21", x1000_ssi_ce1_a_21, 2),
1218 INGENIC_PIN_GROUP("ssi-ce1-a-30", x1000_ssi_ce1_a_30, 2),
1219 INGENIC_PIN_GROUP("mmc0-1bit", x1000_mmc0_1bit, 1),
1220 INGENIC_PIN_GROUP("mmc0-4bit", x1000_mmc0_4bit, 1),
1221 INGENIC_PIN_GROUP("mmc0-8bit", x1000_mmc0_8bit, 1),
1222 INGENIC_PIN_GROUP("mmc1-1bit", x1000_mmc1_1bit, 0),
1223 INGENIC_PIN_GROUP("mmc1-4bit", x1000_mmc1_4bit, 0),
1224 INGENIC_PIN_GROUP("emc-8bit-data", x1000_emc_8bit_data, 0),
1225 INGENIC_PIN_GROUP("emc-16bit-data", x1000_emc_16bit_data, 0),
1226 INGENIC_PIN_GROUP("emc-addr", x1000_emc_addr, 0),
1227 INGENIC_PIN_GROUP("emc-rd-we", x1000_emc_rd_we, 0),
1228 INGENIC_PIN_GROUP("emc-wait", x1000_emc_wait, 0),
1229 INGENIC_PIN_GROUP("emc-cs1", x1000_emc_cs1, 0),
1230 INGENIC_PIN_GROUP("emc-cs2", x1000_emc_cs2, 0),
1231 INGENIC_PIN_GROUP("i2c0-data", x1000_i2c0, 0),
1232 INGENIC_PIN_GROUP("i2c1-data-a", x1000_i2c1_a, 2),
1233 INGENIC_PIN_GROUP("i2c1-data-c", x1000_i2c1_c, 0),
1234 INGENIC_PIN_GROUP("i2c2-data", x1000_i2c2, 1),
1235 INGENIC_PIN_GROUP("i2s-data-tx", x1000_i2s_data_tx, 1),
1236 INGENIC_PIN_GROUP("i2s-data-rx", x1000_i2s_data_rx, 1),
1237 INGENIC_PIN_GROUP("i2s-clk-txrx", x1000_i2s_clk_txrx, 1),
1238 INGENIC_PIN_GROUP("i2s-sysclk", x1000_i2s_sysclk, 1),
1239 INGENIC_PIN_GROUP("cim-data", x1000_cim, 2),
1240 INGENIC_PIN_GROUP("lcd-8bit", x1000_lcd_8bit, 1),
1241 INGENIC_PIN_GROUP("lcd-16bit", x1000_lcd_16bit, 1),
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001242 { "lcd-no-pins", },
Paul Cercueilbb42b592020-11-01 09:01:03 +00001243 INGENIC_PIN_GROUP("pwm0", x1000_pwm_pwm0, 0),
1244 INGENIC_PIN_GROUP("pwm1", x1000_pwm_pwm1, 1),
1245 INGENIC_PIN_GROUP("pwm2", x1000_pwm_pwm2, 1),
1246 INGENIC_PIN_GROUP("pwm3", x1000_pwm_pwm3, 2),
1247 INGENIC_PIN_GROUP("pwm4", x1000_pwm_pwm4, 0),
1248 INGENIC_PIN_GROUP("mac", x1000_mac, 1),
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001249};
1250
1251static const char *x1000_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1252static const char *x1000_uart1_groups[] = {
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001253 "uart1-data-a", "uart1-data-d", "uart1-hwflow",
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001254};
1255static const char *x1000_uart2_groups[] = { "uart2-data-a", "uart2-data-d", };
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001256static const char *x1000_sfc_groups[] = { "sfc", };
1257static const char *x1000_ssi_groups[] = {
1258 "ssi-dt-a-22", "ssi-dt-a-29", "ssi-dt-d",
1259 "ssi-dr-a-23", "ssi-dr-a-28", "ssi-dr-d",
1260 "ssi-clk-a-24", "ssi-clk-a-26", "ssi-clk-d",
1261 "ssi-gpc-a-20", "ssi-gpc-a-31",
1262 "ssi-ce0-a-25", "ssi-ce0-a-27", "ssi-ce0-d",
1263 "ssi-ce1-a-21", "ssi-ce1-a-30",
1264};
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001265static const char *x1000_mmc0_groups[] = {
1266 "mmc0-1bit", "mmc0-4bit", "mmc0-8bit",
1267};
1268static const char *x1000_mmc1_groups[] = {
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001269 "mmc1-1bit", "mmc1-4bit",
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001270};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001271static const char *x1000_emc_groups[] = {
1272 "emc-8bit-data", "emc-16bit-data",
1273 "emc-addr", "emc-rd-we", "emc-wait",
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001274};
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001275static const char *x1000_cs1_groups[] = { "emc-cs1", };
1276static const char *x1000_cs2_groups[] = { "emc-cs2", };
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001277static const char *x1000_i2c0_groups[] = { "i2c0-data", };
1278static const char *x1000_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", };
1279static const char *x1000_i2c2_groups[] = { "i2c2-data", };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001280static const char *x1000_i2s_groups[] = {
1281 "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-sysclk",
1282};
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001283static const char *x1000_cim_groups[] = { "cim-data", };
1284static const char *x1000_lcd_groups[] = {
1285 "lcd-8bit", "lcd-16bit", "lcd-no-pins",
1286};
1287static const char *x1000_pwm0_groups[] = { "pwm0", };
1288static const char *x1000_pwm1_groups[] = { "pwm1", };
1289static const char *x1000_pwm2_groups[] = { "pwm2", };
1290static const char *x1000_pwm3_groups[] = { "pwm3", };
1291static const char *x1000_pwm4_groups[] = { "pwm4", };
1292static const char *x1000_mac_groups[] = { "mac", };
1293
1294static const struct function_desc x1000_functions[] = {
1295 { "uart0", x1000_uart0_groups, ARRAY_SIZE(x1000_uart0_groups), },
1296 { "uart1", x1000_uart1_groups, ARRAY_SIZE(x1000_uart1_groups), },
1297 { "uart2", x1000_uart2_groups, ARRAY_SIZE(x1000_uart2_groups), },
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001298 { "sfc", x1000_sfc_groups, ARRAY_SIZE(x1000_sfc_groups), },
1299 { "ssi", x1000_ssi_groups, ARRAY_SIZE(x1000_ssi_groups), },
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001300 { "mmc0", x1000_mmc0_groups, ARRAY_SIZE(x1000_mmc0_groups), },
1301 { "mmc1", x1000_mmc1_groups, ARRAY_SIZE(x1000_mmc1_groups), },
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001302 { "emc", x1000_emc_groups, ARRAY_SIZE(x1000_emc_groups), },
1303 { "emc-cs1", x1000_cs1_groups, ARRAY_SIZE(x1000_cs1_groups), },
1304 { "emc-cs2", x1000_cs2_groups, ARRAY_SIZE(x1000_cs2_groups), },
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001305 { "i2c0", x1000_i2c0_groups, ARRAY_SIZE(x1000_i2c0_groups), },
1306 { "i2c1", x1000_i2c1_groups, ARRAY_SIZE(x1000_i2c1_groups), },
1307 { "i2c2", x1000_i2c2_groups, ARRAY_SIZE(x1000_i2c2_groups), },
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001308 { "i2s", x1000_i2s_groups, ARRAY_SIZE(x1000_i2s_groups), },
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001309 { "cim", x1000_cim_groups, ARRAY_SIZE(x1000_cim_groups), },
1310 { "lcd", x1000_lcd_groups, ARRAY_SIZE(x1000_lcd_groups), },
1311 { "pwm0", x1000_pwm0_groups, ARRAY_SIZE(x1000_pwm0_groups), },
1312 { "pwm1", x1000_pwm1_groups, ARRAY_SIZE(x1000_pwm1_groups), },
1313 { "pwm2", x1000_pwm2_groups, ARRAY_SIZE(x1000_pwm2_groups), },
1314 { "pwm3", x1000_pwm3_groups, ARRAY_SIZE(x1000_pwm3_groups), },
1315 { "pwm4", x1000_pwm4_groups, ARRAY_SIZE(x1000_pwm4_groups), },
1316 { "mac", x1000_mac_groups, ARRAY_SIZE(x1000_mac_groups), },
1317};
1318
1319static const struct ingenic_chip_info x1000_chip_info = {
1320 .num_chips = 4,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08001321 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +01001322 .version = ID_X1000,
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001323 .groups = x1000_groups,
1324 .num_groups = ARRAY_SIZE(x1000_groups),
1325 .functions = x1000_functions,
1326 .num_functions = ARRAY_SIZE(x1000_functions),
1327 .pull_ups = x1000_pull_ups,
1328 .pull_downs = x1000_pull_downs,
1329};
1330
Zhou Yanjie5d215952019-07-14 11:53:56 +08001331static int x1500_uart0_data_pins[] = { 0x4a, 0x4b, };
1332static int x1500_uart0_hwflow_pins[] = { 0x4c, 0x4d, };
1333static int x1500_uart1_data_a_pins[] = { 0x04, 0x05, };
1334static int x1500_uart1_data_d_pins[] = { 0x62, 0x63, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001335static int x1500_uart1_hwflow_pins[] = { 0x64, 0x65, };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001336static int x1500_uart2_data_a_pins[] = { 0x02, 0x03, };
1337static int x1500_uart2_data_d_pins[] = { 0x65, 0x64, };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001338static int x1500_mmc_1bit_pins[] = { 0x18, 0x19, 0x17, };
1339static int x1500_mmc_4bit_pins[] = { 0x16, 0x15, 0x14, };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001340static int x1500_i2c0_pins[] = { 0x38, 0x37, };
1341static int x1500_i2c1_a_pins[] = { 0x01, 0x00, };
1342static int x1500_i2c1_c_pins[] = { 0x5b, 0x5a, };
1343static int x1500_i2c2_pins[] = { 0x61, 0x60, };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001344static int x1500_i2s_data_tx_pins[] = { 0x24, };
1345static int x1500_i2s_data_rx_pins[] = { 0x23, };
1346static int x1500_i2s_clk_txrx_pins[] = { 0x21, 0x22, };
1347static int x1500_i2s_sysclk_pins[] = { 0x20, };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001348static int x1500_cim_pins[] = {
1349 0x08, 0x09, 0x0a, 0x0b,
1350 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c,
1351};
1352static int x1500_pwm_pwm0_pins[] = { 0x59, };
1353static int x1500_pwm_pwm1_pins[] = { 0x5a, };
1354static int x1500_pwm_pwm2_pins[] = { 0x5b, };
1355static int x1500_pwm_pwm3_pins[] = { 0x26, };
1356static int x1500_pwm_pwm4_pins[] = { 0x58, };
1357
Zhou Yanjie5d215952019-07-14 11:53:56 +08001358static const struct group_desc x1500_groups[] = {
Paul Cercueilbb42b592020-11-01 09:01:03 +00001359 INGENIC_PIN_GROUP("uart0-data", x1500_uart0_data, 0),
1360 INGENIC_PIN_GROUP("uart0-hwflow", x1500_uart0_hwflow, 0),
1361 INGENIC_PIN_GROUP("uart1-data-a", x1500_uart1_data_a, 2),
1362 INGENIC_PIN_GROUP("uart1-data-d", x1500_uart1_data_d, 1),
1363 INGENIC_PIN_GROUP("uart1-hwflow", x1500_uart1_hwflow, 1),
1364 INGENIC_PIN_GROUP("uart2-data-a", x1500_uart2_data_a, 2),
1365 INGENIC_PIN_GROUP("uart2-data-d", x1500_uart2_data_d, 0),
1366 INGENIC_PIN_GROUP("sfc", x1000_sfc, 1),
1367 INGENIC_PIN_GROUP("mmc-1bit", x1500_mmc_1bit, 1),
1368 INGENIC_PIN_GROUP("mmc-4bit", x1500_mmc_4bit, 1),
1369 INGENIC_PIN_GROUP("i2c0-data", x1500_i2c0, 0),
1370 INGENIC_PIN_GROUP("i2c1-data-a", x1500_i2c1_a, 2),
1371 INGENIC_PIN_GROUP("i2c1-data-c", x1500_i2c1_c, 0),
1372 INGENIC_PIN_GROUP("i2c2-data", x1500_i2c2, 1),
1373 INGENIC_PIN_GROUP("i2s-data-tx", x1500_i2s_data_tx, 1),
1374 INGENIC_PIN_GROUP("i2s-data-rx", x1500_i2s_data_rx, 1),
1375 INGENIC_PIN_GROUP("i2s-clk-txrx", x1500_i2s_clk_txrx, 1),
1376 INGENIC_PIN_GROUP("i2s-sysclk", x1500_i2s_sysclk, 1),
1377 INGENIC_PIN_GROUP("cim-data", x1500_cim, 2),
Zhou Yanjie5d215952019-07-14 11:53:56 +08001378 { "lcd-no-pins", },
Paul Cercueilbb42b592020-11-01 09:01:03 +00001379 INGENIC_PIN_GROUP("pwm0", x1500_pwm_pwm0, 0),
1380 INGENIC_PIN_GROUP("pwm1", x1500_pwm_pwm1, 1),
1381 INGENIC_PIN_GROUP("pwm2", x1500_pwm_pwm2, 1),
1382 INGENIC_PIN_GROUP("pwm3", x1500_pwm_pwm3, 2),
1383 INGENIC_PIN_GROUP("pwm4", x1500_pwm_pwm4, 0),
Zhou Yanjie5d215952019-07-14 11:53:56 +08001384};
1385
1386static const char *x1500_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1387static const char *x1500_uart1_groups[] = {
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001388 "uart1-data-a", "uart1-data-d", "uart1-hwflow",
Zhou Yanjie5d215952019-07-14 11:53:56 +08001389};
1390static const char *x1500_uart2_groups[] = { "uart2-data-a", "uart2-data-d", };
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001391static const char *x1500_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
Zhou Yanjie5d215952019-07-14 11:53:56 +08001392static const char *x1500_i2c0_groups[] = { "i2c0-data", };
1393static const char *x1500_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", };
1394static const char *x1500_i2c2_groups[] = { "i2c2-data", };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001395static const char *x1500_i2s_groups[] = {
1396 "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-sysclk",
1397};
Zhou Yanjie5d215952019-07-14 11:53:56 +08001398static const char *x1500_cim_groups[] = { "cim-data", };
1399static const char *x1500_lcd_groups[] = { "lcd-no-pins", };
1400static const char *x1500_pwm0_groups[] = { "pwm0", };
1401static const char *x1500_pwm1_groups[] = { "pwm1", };
1402static const char *x1500_pwm2_groups[] = { "pwm2", };
1403static const char *x1500_pwm3_groups[] = { "pwm3", };
1404static const char *x1500_pwm4_groups[] = { "pwm4", };
1405
1406static const struct function_desc x1500_functions[] = {
1407 { "uart0", x1500_uart0_groups, ARRAY_SIZE(x1500_uart0_groups), },
1408 { "uart1", x1500_uart1_groups, ARRAY_SIZE(x1500_uart1_groups), },
1409 { "uart2", x1500_uart2_groups, ARRAY_SIZE(x1500_uart2_groups), },
周琰杰 (Zhou Yanjie)3b31e9b2019-12-16 00:21:01 +08001410 { "sfc", x1000_sfc_groups, ARRAY_SIZE(x1000_sfc_groups), },
周琰杰 (Zhou Yanjie)b4a93722019-12-16 00:21:00 +08001411 { "mmc", x1500_mmc_groups, ARRAY_SIZE(x1500_mmc_groups), },
Zhou Yanjie5d215952019-07-14 11:53:56 +08001412 { "i2c0", x1500_i2c0_groups, ARRAY_SIZE(x1500_i2c0_groups), },
1413 { "i2c1", x1500_i2c1_groups, ARRAY_SIZE(x1500_i2c1_groups), },
1414 { "i2c2", x1500_i2c2_groups, ARRAY_SIZE(x1500_i2c2_groups), },
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001415 { "i2s", x1500_i2s_groups, ARRAY_SIZE(x1500_i2s_groups), },
Zhou Yanjie5d215952019-07-14 11:53:56 +08001416 { "cim", x1500_cim_groups, ARRAY_SIZE(x1500_cim_groups), },
1417 { "lcd", x1500_lcd_groups, ARRAY_SIZE(x1500_lcd_groups), },
1418 { "pwm0", x1500_pwm0_groups, ARRAY_SIZE(x1500_pwm0_groups), },
1419 { "pwm1", x1500_pwm1_groups, ARRAY_SIZE(x1500_pwm1_groups), },
1420 { "pwm2", x1500_pwm2_groups, ARRAY_SIZE(x1500_pwm2_groups), },
1421 { "pwm3", x1500_pwm3_groups, ARRAY_SIZE(x1500_pwm3_groups), },
1422 { "pwm4", x1500_pwm4_groups, ARRAY_SIZE(x1500_pwm4_groups), },
1423};
1424
1425static const struct ingenic_chip_info x1500_chip_info = {
1426 .num_chips = 4,
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08001427 .reg_offset = 0x100,
Paul Cercueilbaf15642020-01-07 00:27:08 +01001428 .version = ID_X1500,
Zhou Yanjie5d215952019-07-14 11:53:56 +08001429 .groups = x1500_groups,
1430 .num_groups = ARRAY_SIZE(x1500_groups),
1431 .functions = x1500_functions,
1432 .num_functions = ARRAY_SIZE(x1500_functions),
1433 .pull_ups = x1000_pull_ups,
1434 .pull_downs = x1000_pull_downs,
1435};
1436
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001437static const u32 x1830_pull_ups[4] = {
1438 0x5fdfffc0, 0xffffefff, 0x1ffffbff, 0x0fcff3fc,
1439};
1440
1441static const u32 x1830_pull_downs[4] = {
1442 0x5fdfffc0, 0xffffefff, 0x1ffffbff, 0x0fcff3fc,
1443};
1444
1445static int x1830_uart0_data_pins[] = { 0x33, 0x36, };
1446static int x1830_uart0_hwflow_pins[] = { 0x34, 0x35, };
1447static int x1830_uart1_data_pins[] = { 0x38, 0x37, };
1448static int x1830_sfc_pins[] = { 0x17, 0x18, 0x1a, 0x19, 0x1b, 0x1c, };
1449static int x1830_ssi0_dt_pins[] = { 0x4c, };
1450static int x1830_ssi0_dr_pins[] = { 0x4b, };
1451static int x1830_ssi0_clk_pins[] = { 0x4f, };
1452static int x1830_ssi0_gpc_pins[] = { 0x4d, };
1453static int x1830_ssi0_ce0_pins[] = { 0x50, };
1454static int x1830_ssi0_ce1_pins[] = { 0x4e, };
1455static int x1830_ssi1_dt_c_pins[] = { 0x53, };
1456static int x1830_ssi1_dr_c_pins[] = { 0x54, };
1457static int x1830_ssi1_clk_c_pins[] = { 0x57, };
1458static int x1830_ssi1_gpc_c_pins[] = { 0x55, };
1459static int x1830_ssi1_ce0_c_pins[] = { 0x58, };
1460static int x1830_ssi1_ce1_c_pins[] = { 0x56, };
1461static int x1830_ssi1_dt_d_pins[] = { 0x62, };
1462static int x1830_ssi1_dr_d_pins[] = { 0x63, };
1463static int x1830_ssi1_clk_d_pins[] = { 0x66, };
1464static int x1830_ssi1_gpc_d_pins[] = { 0x64, };
1465static int x1830_ssi1_ce0_d_pins[] = { 0x67, };
1466static int x1830_ssi1_ce1_d_pins[] = { 0x65, };
1467static int x1830_mmc0_1bit_pins[] = { 0x24, 0x25, 0x20, };
1468static int x1830_mmc0_4bit_pins[] = { 0x21, 0x22, 0x23, };
1469static int x1830_mmc1_1bit_pins[] = { 0x42, 0x43, 0x44, };
1470static int x1830_mmc1_4bit_pins[] = { 0x45, 0x46, 0x47, };
1471static int x1830_i2c0_pins[] = { 0x0c, 0x0d, };
1472static int x1830_i2c1_pins[] = { 0x39, 0x3a, };
1473static int x1830_i2c2_pins[] = { 0x5b, 0x5c, };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001474static int x1830_i2s_data_tx_pins[] = { 0x53, };
1475static int x1830_i2s_data_rx_pins[] = { 0x54, };
1476static int x1830_i2s_clk_txrx_pins[] = { 0x58, 0x52, };
1477static int x1830_i2s_clk_rx_pins[] = { 0x56, 0x55, };
1478static int x1830_i2s_sysclk_pins[] = { 0x57, };
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001479static int x1830_lcd_rgb_18bit_pins[] = {
1480 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
1481 0x68, 0x69, 0x6c, 0x6d, 0x6e, 0x6f,
1482 0x70, 0x71, 0x72, 0x73, 0x76, 0x77,
1483 0x78, 0x79, 0x7a, 0x7b,
1484};
1485static int x1830_lcd_slcd_8bit_pins[] = {
1486 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x6c, 0x6d,
1487 0x69, 0x72, 0x73, 0x7b, 0x7a,
1488};
1489static int x1830_lcd_slcd_16bit_pins[] = {
1490 0x6e, 0x6f, 0x70, 0x71, 0x76, 0x77, 0x78, 0x79,
1491};
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001492static int x1830_pwm_pwm0_b_pins[] = { 0x31, };
1493static int x1830_pwm_pwm0_c_pins[] = { 0x4b, };
1494static int x1830_pwm_pwm1_b_pins[] = { 0x32, };
1495static int x1830_pwm_pwm1_c_pins[] = { 0x4c, };
1496static int x1830_pwm_pwm2_c_8_pins[] = { 0x48, };
1497static int x1830_pwm_pwm2_c_13_pins[] = { 0x4d, };
1498static int x1830_pwm_pwm3_c_9_pins[] = { 0x49, };
1499static int x1830_pwm_pwm3_c_14_pins[] = { 0x4e, };
1500static int x1830_pwm_pwm4_c_15_pins[] = { 0x4f, };
1501static int x1830_pwm_pwm4_c_25_pins[] = { 0x59, };
1502static int x1830_pwm_pwm5_c_16_pins[] = { 0x50, };
1503static int x1830_pwm_pwm5_c_26_pins[] = { 0x5a, };
1504static int x1830_pwm_pwm6_c_17_pins[] = { 0x51, };
1505static int x1830_pwm_pwm6_c_27_pins[] = { 0x5b, };
1506static int x1830_pwm_pwm7_c_18_pins[] = { 0x52, };
1507static int x1830_pwm_pwm7_c_28_pins[] = { 0x5c, };
1508static int x1830_mac_pins[] = {
1509 0x29, 0x30, 0x2f, 0x28, 0x2e, 0x2d, 0x2a, 0x2b, 0x26, 0x27,
1510};
1511
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001512static const struct group_desc x1830_groups[] = {
Paul Cercueilbb42b592020-11-01 09:01:03 +00001513 INGENIC_PIN_GROUP("uart0-data", x1830_uart0_data, 0),
1514 INGENIC_PIN_GROUP("uart0-hwflow", x1830_uart0_hwflow, 0),
1515 INGENIC_PIN_GROUP("uart1-data", x1830_uart1_data, 0),
1516 INGENIC_PIN_GROUP("sfc", x1830_sfc, 1),
1517 INGENIC_PIN_GROUP("ssi0-dt", x1830_ssi0_dt, 0),
1518 INGENIC_PIN_GROUP("ssi0-dr", x1830_ssi0_dr, 0),
1519 INGENIC_PIN_GROUP("ssi0-clk", x1830_ssi0_clk, 0),
1520 INGENIC_PIN_GROUP("ssi0-gpc", x1830_ssi0_gpc, 0),
1521 INGENIC_PIN_GROUP("ssi0-ce0", x1830_ssi0_ce0, 0),
1522 INGENIC_PIN_GROUP("ssi0-ce1", x1830_ssi0_ce1, 0),
1523 INGENIC_PIN_GROUP("ssi1-dt-c", x1830_ssi1_dt_c, 1),
1524 INGENIC_PIN_GROUP("ssi1-dr-c", x1830_ssi1_dr_c, 1),
1525 INGENIC_PIN_GROUP("ssi1-clk-c", x1830_ssi1_clk_c, 1),
1526 INGENIC_PIN_GROUP("ssi1-gpc-c", x1830_ssi1_gpc_c, 1),
1527 INGENIC_PIN_GROUP("ssi1-ce0-c", x1830_ssi1_ce0_c, 1),
1528 INGENIC_PIN_GROUP("ssi1-ce1-c", x1830_ssi1_ce1_c, 1),
1529 INGENIC_PIN_GROUP("ssi1-dt-d", x1830_ssi1_dt_d, 2),
1530 INGENIC_PIN_GROUP("ssi1-dr-d", x1830_ssi1_dr_d, 2),
1531 INGENIC_PIN_GROUP("ssi1-clk-d", x1830_ssi1_clk_d, 2),
1532 INGENIC_PIN_GROUP("ssi1-gpc-d", x1830_ssi1_gpc_d, 2),
1533 INGENIC_PIN_GROUP("ssi1-ce0-d", x1830_ssi1_ce0_d, 2),
1534 INGENIC_PIN_GROUP("ssi1-ce1-d", x1830_ssi1_ce1_d, 2),
1535 INGENIC_PIN_GROUP("mmc0-1bit", x1830_mmc0_1bit, 0),
1536 INGENIC_PIN_GROUP("mmc0-4bit", x1830_mmc0_4bit, 0),
1537 INGENIC_PIN_GROUP("mmc1-1bit", x1830_mmc1_1bit, 0),
1538 INGENIC_PIN_GROUP("mmc1-4bit", x1830_mmc1_4bit, 0),
1539 INGENIC_PIN_GROUP("i2c0-data", x1830_i2c0, 1),
1540 INGENIC_PIN_GROUP("i2c1-data", x1830_i2c1, 0),
1541 INGENIC_PIN_GROUP("i2c2-data", x1830_i2c2, 1),
1542 INGENIC_PIN_GROUP("i2s-data-tx", x1830_i2s_data_tx, 0),
1543 INGENIC_PIN_GROUP("i2s-data-rx", x1830_i2s_data_rx, 0),
1544 INGENIC_PIN_GROUP("i2s-clk-txrx", x1830_i2s_clk_txrx, 0),
1545 INGENIC_PIN_GROUP("i2s-clk-rx", x1830_i2s_clk_rx, 0),
1546 INGENIC_PIN_GROUP("i2s-sysclk", x1830_i2s_sysclk, 0),
1547 INGENIC_PIN_GROUP("lcd-rgb-18bit", x1830_lcd_rgb_18bit, 0),
1548 INGENIC_PIN_GROUP("lcd-slcd-8bit", x1830_lcd_slcd_8bit, 1),
1549 INGENIC_PIN_GROUP("lcd-slcd-16bit", x1830_lcd_slcd_16bit, 1),
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001550 { "lcd-no-pins", },
Paul Cercueilbb42b592020-11-01 09:01:03 +00001551 INGENIC_PIN_GROUP("pwm0-b", x1830_pwm_pwm0_b, 0),
1552 INGENIC_PIN_GROUP("pwm0-c", x1830_pwm_pwm0_c, 1),
1553 INGENIC_PIN_GROUP("pwm1-b", x1830_pwm_pwm1_b, 0),
1554 INGENIC_PIN_GROUP("pwm1-c", x1830_pwm_pwm1_c, 1),
1555 INGENIC_PIN_GROUP("pwm2-c-8", x1830_pwm_pwm2_c_8, 0),
1556 INGENIC_PIN_GROUP("pwm2-c-13", x1830_pwm_pwm2_c_13, 1),
1557 INGENIC_PIN_GROUP("pwm3-c-9", x1830_pwm_pwm3_c_9, 0),
1558 INGENIC_PIN_GROUP("pwm3-c-14", x1830_pwm_pwm3_c_14, 1),
1559 INGENIC_PIN_GROUP("pwm4-c-15", x1830_pwm_pwm4_c_15, 1),
1560 INGENIC_PIN_GROUP("pwm4-c-25", x1830_pwm_pwm4_c_25, 0),
1561 INGENIC_PIN_GROUP("pwm5-c-16", x1830_pwm_pwm5_c_16, 1),
1562 INGENIC_PIN_GROUP("pwm5-c-26", x1830_pwm_pwm5_c_26, 0),
1563 INGENIC_PIN_GROUP("pwm6-c-17", x1830_pwm_pwm6_c_17, 1),
1564 INGENIC_PIN_GROUP("pwm6-c-27", x1830_pwm_pwm6_c_27, 0),
1565 INGENIC_PIN_GROUP("pwm7-c-18", x1830_pwm_pwm7_c_18, 1),
1566 INGENIC_PIN_GROUP("pwm7-c-28", x1830_pwm_pwm7_c_28, 0),
1567 INGENIC_PIN_GROUP("mac", x1830_mac, 0),
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001568};
1569
1570static const char *x1830_uart0_groups[] = { "uart0-data", "uart0-hwflow", };
1571static const char *x1830_uart1_groups[] = { "uart1-data", };
1572static const char *x1830_sfc_groups[] = { "sfc", };
1573static const char *x1830_ssi0_groups[] = {
1574 "ssi0-dt", "ssi0-dr", "ssi0-clk", "ssi0-gpc", "ssi0-ce0", "ssi0-ce1",
1575};
1576static const char *x1830_ssi1_groups[] = {
1577 "ssi1-dt-c", "ssi1-dt-d",
1578 "ssi1-dr-c", "ssi1-dr-d",
1579 "ssi1-clk-c", "ssi1-clk-d",
1580 "ssi1-gpc-c", "ssi1-gpc-d",
1581 "ssi1-ce0-c", "ssi1-ce0-d",
1582 "ssi1-ce1-c", "ssi1-ce1-d",
1583};
1584static const char *x1830_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", };
1585static const char *x1830_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", };
1586static const char *x1830_i2c0_groups[] = { "i2c0-data", };
1587static const char *x1830_i2c1_groups[] = { "i2c1-data", };
1588static const char *x1830_i2c2_groups[] = { "i2c2-data", };
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001589static const char *x1830_i2s_groups[] = {
1590 "i2s-data-tx", "i2s-data-rx", "i2s-clk-txrx", "i2s-clk-rx", "i2s-sysclk",
1591};
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001592static const char *x1830_lcd_groups[] = {
1593 "lcd-rgb-18bit", "lcd-slcd-8bit", "lcd-slcd-16bit", "lcd-no-pins",
1594};
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001595static const char *x1830_pwm0_groups[] = { "pwm0-b", "pwm0-c", };
1596static const char *x1830_pwm1_groups[] = { "pwm1-b", "pwm1-c", };
1597static const char *x1830_pwm2_groups[] = { "pwm2-c-8", "pwm2-c-13", };
1598static const char *x1830_pwm3_groups[] = { "pwm3-c-9", "pwm3-c-14", };
1599static const char *x1830_pwm4_groups[] = { "pwm4-c-15", "pwm4-c-25", };
1600static const char *x1830_pwm5_groups[] = { "pwm5-c-16", "pwm5-c-26", };
1601static const char *x1830_pwm6_groups[] = { "pwm6-c-17", "pwm6-c-27", };
1602static const char *x1830_pwm7_groups[] = { "pwm7-c-18", "pwm7-c-28", };
1603static const char *x1830_mac_groups[] = { "mac", };
1604
1605static const struct function_desc x1830_functions[] = {
1606 { "uart0", x1830_uart0_groups, ARRAY_SIZE(x1830_uart0_groups), },
1607 { "uart1", x1830_uart1_groups, ARRAY_SIZE(x1830_uart1_groups), },
1608 { "sfc", x1830_sfc_groups, ARRAY_SIZE(x1830_sfc_groups), },
1609 { "ssi0", x1830_ssi0_groups, ARRAY_SIZE(x1830_ssi0_groups), },
1610 { "ssi1", x1830_ssi1_groups, ARRAY_SIZE(x1830_ssi1_groups), },
1611 { "mmc0", x1830_mmc0_groups, ARRAY_SIZE(x1830_mmc0_groups), },
1612 { "mmc1", x1830_mmc1_groups, ARRAY_SIZE(x1830_mmc1_groups), },
1613 { "i2c0", x1830_i2c0_groups, ARRAY_SIZE(x1830_i2c0_groups), },
1614 { "i2c1", x1830_i2c1_groups, ARRAY_SIZE(x1830_i2c1_groups), },
1615 { "i2c2", x1830_i2c2_groups, ARRAY_SIZE(x1830_i2c2_groups), },
周琰杰 (Zhou Yanjie)f4b5c342020-09-13 14:58:36 +08001616 { "i2s", x1830_i2s_groups, ARRAY_SIZE(x1830_i2s_groups), },
周琰杰 (Zhou Yanjie)b2954742020-02-16 19:17:08 +08001617 { "lcd", x1830_lcd_groups, ARRAY_SIZE(x1830_lcd_groups), },
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001618 { "pwm0", x1830_pwm0_groups, ARRAY_SIZE(x1830_pwm0_groups), },
1619 { "pwm1", x1830_pwm1_groups, ARRAY_SIZE(x1830_pwm1_groups), },
1620 { "pwm2", x1830_pwm2_groups, ARRAY_SIZE(x1830_pwm2_groups), },
1621 { "pwm3", x1830_pwm3_groups, ARRAY_SIZE(x1830_pwm3_groups), },
1622 { "pwm4", x1830_pwm4_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1623 { "pwm5", x1830_pwm5_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1624 { "pwm6", x1830_pwm6_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1625 { "pwm7", x1830_pwm7_groups, ARRAY_SIZE(x1830_pwm4_groups), },
1626 { "mac", x1830_mac_groups, ARRAY_SIZE(x1830_mac_groups), },
1627};
1628
1629static const struct ingenic_chip_info x1830_chip_info = {
1630 .num_chips = 4,
1631 .reg_offset = 0x1000,
Paul Cercueilbaf15642020-01-07 00:27:08 +01001632 .version = ID_X1830,
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001633 .groups = x1830_groups,
1634 .num_groups = ARRAY_SIZE(x1830_groups),
1635 .functions = x1830_functions,
1636 .num_functions = ARRAY_SIZE(x1830_functions),
1637 .pull_ups = x1830_pull_ups,
1638 .pull_downs = x1830_pull_downs,
1639};
1640
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001641static u32 ingenic_gpio_read_reg(struct ingenic_gpio_chip *jzgc, u8 reg)
Paul Cercueile72394e2018-08-21 18:42:32 +02001642{
1643 unsigned int val;
1644
1645 regmap_read(jzgc->jzpc->map, jzgc->reg_base + reg, &val);
1646
1647 return (u32) val;
1648}
1649
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001650static void ingenic_gpio_set_bit(struct ingenic_gpio_chip *jzgc,
Paul Cercueile72394e2018-08-21 18:42:32 +02001651 u8 reg, u8 offset, bool set)
1652{
1653 if (set)
1654 reg = REG_SET(reg);
1655 else
1656 reg = REG_CLEAR(reg);
1657
1658 regmap_write(jzgc->jzpc->map, jzgc->reg_base + reg, BIT(offset));
1659}
1660
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001661static void ingenic_gpio_shadow_set_bit(struct ingenic_gpio_chip *jzgc,
1662 u8 reg, u8 offset, bool set)
1663{
1664 if (set)
1665 reg = REG_SET(reg);
1666 else
1667 reg = REG_CLEAR(reg);
1668
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001669 regmap_write(jzgc->jzpc->map, REG_PZ_BASE(
1670 jzgc->jzpc->info->reg_offset) + reg, BIT(offset));
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001671}
1672
1673static void ingenic_gpio_shadow_set_bit_load(struct ingenic_gpio_chip *jzgc)
1674{
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001675 regmap_write(jzgc->jzpc->map, REG_PZ_GID2LD(
1676 jzgc->jzpc->info->reg_offset),
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001677 jzgc->gc.base / PINS_PER_GPIO_CHIP);
1678}
1679
Paul Cercueile72394e2018-08-21 18:42:32 +02001680static inline bool ingenic_gpio_get_value(struct ingenic_gpio_chip *jzgc,
1681 u8 offset)
1682{
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001683 unsigned int val = ingenic_gpio_read_reg(jzgc, GPIO_PIN);
Paul Cercueile72394e2018-08-21 18:42:32 +02001684
1685 return !!(val & BIT(offset));
1686}
1687
1688static void ingenic_gpio_set_value(struct ingenic_gpio_chip *jzgc,
1689 u8 offset, int value)
1690{
Paul Cercueilbaf15642020-01-07 00:27:08 +01001691 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08001692 ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_PAT0, offset, !!value);
Paul Cercueile72394e2018-08-21 18:42:32 +02001693 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001694 ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, offset, !!value);
Paul Cercueile72394e2018-08-21 18:42:32 +02001695}
1696
1697static void irq_set_type(struct ingenic_gpio_chip *jzgc,
1698 u8 offset, unsigned int type)
1699{
1700 u8 reg1, reg2;
Paul Cercueilf831f932020-01-07 00:27:10 +01001701 bool val1, val2;
1702
1703 switch (type) {
1704 case IRQ_TYPE_EDGE_RISING:
1705 val1 = val2 = true;
1706 break;
1707 case IRQ_TYPE_EDGE_FALLING:
1708 val1 = false;
1709 val2 = true;
1710 break;
1711 case IRQ_TYPE_LEVEL_HIGH:
1712 val1 = true;
1713 val2 = false;
1714 break;
1715 case IRQ_TYPE_LEVEL_LOW:
1716 default:
1717 val1 = val2 = false;
1718 break;
1719 }
Paul Cercueile72394e2018-08-21 18:42:32 +02001720
Paul Cercueilbaf15642020-01-07 00:27:08 +01001721 if (jzgc->jzpc->info->version >= ID_JZ4760) {
Zhou Yanjie0257595a2019-07-14 11:53:52 +08001722 reg1 = JZ4760_GPIO_PAT1;
1723 reg2 = JZ4760_GPIO_PAT0;
Paul Cercueile72394e2018-08-21 18:42:32 +02001724 } else {
1725 reg1 = JZ4740_GPIO_TRIG;
1726 reg2 = JZ4740_GPIO_DIR;
1727 }
1728
Paul Cercueilf831f932020-01-07 00:27:10 +01001729 if (jzgc->jzpc->info->version >= ID_X1000) {
1730 ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, val1);
1731 ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, val2);
1732 ingenic_gpio_shadow_set_bit_load(jzgc);
1733 } else {
1734 ingenic_gpio_set_bit(jzgc, reg2, offset, val1);
1735 ingenic_gpio_set_bit(jzgc, reg1, offset, val2);
Paul Cercueile72394e2018-08-21 18:42:32 +02001736 }
1737}
1738
1739static void ingenic_gpio_irq_mask(struct irq_data *irqd)
1740{
1741 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
1742 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
1743
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001744 ingenic_gpio_set_bit(jzgc, GPIO_MSK, irqd->hwirq, true);
Paul Cercueile72394e2018-08-21 18:42:32 +02001745}
1746
1747static void ingenic_gpio_irq_unmask(struct irq_data *irqd)
1748{
1749 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
1750 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
1751
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001752 ingenic_gpio_set_bit(jzgc, GPIO_MSK, irqd->hwirq, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02001753}
1754
1755static void ingenic_gpio_irq_enable(struct irq_data *irqd)
1756{
1757 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
1758 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
1759 int irq = irqd->hwirq;
1760
Paul Cercueilbaf15642020-01-07 00:27:08 +01001761 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08001762 ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_INT, irq, true);
Paul Cercueile72394e2018-08-21 18:42:32 +02001763 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001764 ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, true);
Paul Cercueile72394e2018-08-21 18:42:32 +02001765
1766 ingenic_gpio_irq_unmask(irqd);
1767}
1768
1769static void ingenic_gpio_irq_disable(struct irq_data *irqd)
1770{
1771 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
1772 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
1773 int irq = irqd->hwirq;
1774
1775 ingenic_gpio_irq_mask(irqd);
1776
Paul Cercueilbaf15642020-01-07 00:27:08 +01001777 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08001778 ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_INT, irq, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02001779 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001780 ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02001781}
1782
1783static void ingenic_gpio_irq_ack(struct irq_data *irqd)
1784{
1785 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
1786 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
1787 int irq = irqd->hwirq;
1788 bool high;
1789
1790 if (irqd_get_trigger_type(irqd) == IRQ_TYPE_EDGE_BOTH) {
1791 /*
1792 * Switch to an interrupt for the opposite edge to the one that
1793 * triggered the interrupt being ACKed.
1794 */
1795 high = ingenic_gpio_get_value(jzgc, irq);
1796 if (high)
Paul Cercueil1c953482020-06-22 23:45:47 +02001797 irq_set_type(jzgc, irq, IRQ_TYPE_LEVEL_LOW);
Paul Cercueile72394e2018-08-21 18:42:32 +02001798 else
Paul Cercueil1c953482020-06-22 23:45:47 +02001799 irq_set_type(jzgc, irq, IRQ_TYPE_LEVEL_HIGH);
Paul Cercueile72394e2018-08-21 18:42:32 +02001800 }
1801
Paul Cercueilbaf15642020-01-07 00:27:08 +01001802 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08001803 ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_FLAG, irq, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02001804 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001805 ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, irq, true);
Paul Cercueile72394e2018-08-21 18:42:32 +02001806}
1807
1808static int ingenic_gpio_irq_set_type(struct irq_data *irqd, unsigned int type)
1809{
1810 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
1811 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
1812
1813 switch (type) {
1814 case IRQ_TYPE_EDGE_BOTH:
1815 case IRQ_TYPE_EDGE_RISING:
1816 case IRQ_TYPE_EDGE_FALLING:
1817 irq_set_handler_locked(irqd, handle_edge_irq);
1818 break;
1819 case IRQ_TYPE_LEVEL_HIGH:
1820 case IRQ_TYPE_LEVEL_LOW:
1821 irq_set_handler_locked(irqd, handle_level_irq);
1822 break;
1823 default:
1824 irq_set_handler_locked(irqd, handle_bad_irq);
1825 }
1826
1827 if (type == IRQ_TYPE_EDGE_BOTH) {
1828 /*
1829 * The hardware does not support interrupts on both edges. The
1830 * best we can do is to set up a single-edge interrupt and then
1831 * switch to the opposing edge when ACKing the interrupt.
1832 */
1833 bool high = ingenic_gpio_get_value(jzgc, irqd->hwirq);
1834
Paul Cercueil1c953482020-06-22 23:45:47 +02001835 type = high ? IRQ_TYPE_LEVEL_LOW : IRQ_TYPE_LEVEL_HIGH;
Paul Cercueile72394e2018-08-21 18:42:32 +02001836 }
1837
1838 irq_set_type(jzgc, irqd->hwirq, type);
1839 return 0;
1840}
1841
1842static int ingenic_gpio_irq_set_wake(struct irq_data *irqd, unsigned int on)
1843{
1844 struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd);
1845 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
1846
1847 return irq_set_irq_wake(jzgc->irq, on);
1848}
1849
1850static void ingenic_gpio_irq_handler(struct irq_desc *desc)
1851{
1852 struct gpio_chip *gc = irq_desc_get_handler_data(desc);
1853 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
1854 struct irq_chip *irq_chip = irq_data_get_irq_chip(&desc->irq_data);
1855 unsigned long flag, i;
1856
1857 chained_irq_enter(irq_chip, desc);
1858
Paul Cercueilbaf15642020-01-07 00:27:08 +01001859 if (jzgc->jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08001860 flag = ingenic_gpio_read_reg(jzgc, JZ4760_GPIO_FLAG);
Paul Cercueile72394e2018-08-21 18:42:32 +02001861 else
Zhou Yanjieb71c1842019-01-28 23:19:59 +08001862 flag = ingenic_gpio_read_reg(jzgc, JZ4740_GPIO_FLAG);
Paul Cercueile72394e2018-08-21 18:42:32 +02001863
1864 for_each_set_bit(i, &flag, 32)
1865 generic_handle_irq(irq_linear_revmap(gc->irq.domain, i));
1866 chained_irq_exit(irq_chip, desc);
1867}
1868
1869static void ingenic_gpio_set(struct gpio_chip *gc,
1870 unsigned int offset, int value)
1871{
1872 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
1873
1874 ingenic_gpio_set_value(jzgc, offset, value);
1875}
1876
1877static int ingenic_gpio_get(struct gpio_chip *gc, unsigned int offset)
1878{
1879 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
1880
1881 return (int) ingenic_gpio_get_value(jzgc, offset);
1882}
1883
1884static int ingenic_gpio_direction_input(struct gpio_chip *gc,
1885 unsigned int offset)
1886{
1887 return pinctrl_gpio_direction_input(gc->base + offset);
1888}
1889
1890static int ingenic_gpio_direction_output(struct gpio_chip *gc,
1891 unsigned int offset, int value)
1892{
1893 ingenic_gpio_set(gc, offset, value);
1894 return pinctrl_gpio_direction_output(gc->base + offset);
1895}
1896
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02001897static inline void ingenic_config_pin(struct ingenic_pinctrl *jzpc,
1898 unsigned int pin, u8 reg, bool set)
1899{
1900 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
1901 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
1902
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08001903 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02001904 (set ? REG_SET(reg) : REG_CLEAR(reg)), BIT(idx));
1905}
1906
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001907static inline void ingenic_shadow_config_pin(struct ingenic_pinctrl *jzpc,
1908 unsigned int pin, u8 reg, bool set)
1909{
1910 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
1911
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08001912 regmap_write(jzpc->map, REG_PZ_BASE(jzpc->info->reg_offset) +
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001913 (set ? REG_SET(reg) : REG_CLEAR(reg)), BIT(idx));
1914}
1915
1916static inline void ingenic_shadow_config_pin_load(struct ingenic_pinctrl *jzpc,
1917 unsigned int pin)
1918{
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08001919 regmap_write(jzpc->map, REG_PZ_GID2LD(jzpc->info->reg_offset),
1920 pin / PINS_PER_GPIO_CHIP);
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001921}
1922
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02001923static inline bool ingenic_get_pin_config(struct ingenic_pinctrl *jzpc,
1924 unsigned int pin, u8 reg)
1925{
1926 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
1927 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
1928 unsigned int val;
1929
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08001930 regmap_read(jzpc->map, offt * jzpc->info->reg_offset + reg, &val);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02001931
1932 return val & BIT(idx);
1933}
1934
Paul Cercueilebd66512018-08-21 18:42:33 +02001935static int ingenic_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
1936{
1937 struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
1938 struct ingenic_pinctrl *jzpc = jzgc->jzpc;
1939 unsigned int pin = gc->base + offset;
1940
Matti Vaittinen3c827872020-02-14 15:57:12 +02001941 if (jzpc->info->version >= ID_JZ4760) {
Paul Cercueil84e7a942020-06-22 23:45:48 +02001942 if (ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_INT) ||
1943 ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_PAT1))
Matti Vaittinen3c827872020-02-14 15:57:12 +02001944 return GPIO_LINE_DIRECTION_IN;
1945 return GPIO_LINE_DIRECTION_OUT;
1946 }
Paul Cercueilebd66512018-08-21 18:42:33 +02001947
1948 if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_SELECT))
Matti Vaittinen3c827872020-02-14 15:57:12 +02001949 return GPIO_LINE_DIRECTION_IN;
Paul Cercueilebd66512018-08-21 18:42:33 +02001950
Matti Vaittinen3c827872020-02-14 15:57:12 +02001951 if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_DIR))
1952 return GPIO_LINE_DIRECTION_OUT;
1953
1954 return GPIO_LINE_DIRECTION_IN;
Paul Cercueilebd66512018-08-21 18:42:33 +02001955}
1956
Julia Lawall5bf7b842017-08-10 12:06:23 +02001957static const struct pinctrl_ops ingenic_pctlops = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02001958 .get_groups_count = pinctrl_generic_get_group_count,
1959 .get_group_name = pinctrl_generic_get_group_name,
1960 .get_group_pins = pinctrl_generic_get_group_pins,
1961 .dt_node_to_map = pinconf_generic_dt_node_to_map_all,
1962 .dt_free_map = pinconf_generic_dt_free_map,
1963};
1964
Paul Cercueil9a0f1342020-05-03 18:45:49 +02001965static int ingenic_gpio_irq_request(struct irq_data *data)
1966{
1967 struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
1968 int ret;
1969
1970 ret = ingenic_gpio_direction_input(gpio_chip, data->hwirq);
1971 if (ret)
1972 return ret;
1973
1974 return gpiochip_reqres_irq(gpio_chip, data->hwirq);
1975}
1976
1977static void ingenic_gpio_irq_release(struct irq_data *data)
1978{
1979 struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
1980
1981 return gpiochip_relres_irq(gpio_chip, data->hwirq);
1982}
1983
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02001984static int ingenic_pinmux_set_pin_fn(struct ingenic_pinctrl *jzpc,
1985 int pin, int func)
1986{
1987 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
1988 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
1989
1990 dev_dbg(jzpc->dev, "set pin P%c%u to function %u\n",
1991 'A' + offt, idx, func);
1992
Paul Cercueilbaf15642020-01-07 00:27:08 +01001993 if (jzpc->info->version >= ID_X1000) {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08001994 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
1995 ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, false);
1996 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, func & 0x2);
1997 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, func & 0x1);
1998 ingenic_shadow_config_pin_load(jzpc, pin);
Paul Cercueilbaf15642020-01-07 00:27:08 +01001999 } else if (jzpc->info->version >= ID_JZ4760) {
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002000 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002001 ingenic_config_pin(jzpc, pin, GPIO_MSK, false);
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002002 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, func & 0x2);
2003 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, func & 0x1);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002004 } else {
2005 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, true);
2006 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_TRIG, func & 0x2);
2007 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, func > 0);
2008 }
2009
2010 return 0;
2011}
2012
2013static int ingenic_pinmux_set_mux(struct pinctrl_dev *pctldev,
2014 unsigned int selector, unsigned int group)
2015{
2016 struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2017 struct function_desc *func;
2018 struct group_desc *grp;
2019 unsigned int i;
Paul Cercueilbb42b592020-11-01 09:01:03 +00002020 uintptr_t mode;
2021 u8 *pin_modes;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002022
2023 func = pinmux_generic_get_function(pctldev, selector);
2024 if (!func)
2025 return -EINVAL;
2026
2027 grp = pinctrl_generic_get_group(pctldev, group);
2028 if (!grp)
2029 return -EINVAL;
2030
2031 dev_dbg(pctldev->dev, "enable function %s group %s\n",
2032 func->name, grp->name);
2033
Paul Cercueilbb42b592020-11-01 09:01:03 +00002034 mode = (uintptr_t)grp->data;
2035 if (mode <= 3) {
2036 for (i = 0; i < grp->num_pins; i++)
2037 ingenic_pinmux_set_pin_fn(jzpc, grp->pins[i], mode);
2038 } else {
2039 pin_modes = grp->data;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002040
Paul Cercueilbb42b592020-11-01 09:01:03 +00002041 for (i = 0; i < grp->num_pins; i++)
2042 ingenic_pinmux_set_pin_fn(jzpc, grp->pins[i], pin_modes[i]);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002043 }
2044
2045 return 0;
2046}
2047
2048static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
2049 struct pinctrl_gpio_range *range,
2050 unsigned int pin, bool input)
2051{
2052 struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2053 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2054 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2055
2056 dev_dbg(pctldev->dev, "set pin P%c%u to %sput\n",
2057 'A' + offt, idx, input ? "in" : "out");
2058
Paul Cercueilbaf15642020-01-07 00:27:08 +01002059 if (jzpc->info->version >= ID_X1000) {
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002060 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
2061 ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, true);
2062 ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, input);
2063 ingenic_shadow_config_pin_load(jzpc, pin);
Paul Cercueilbaf15642020-01-07 00:27:08 +01002064 } else if (jzpc->info->version >= ID_JZ4760) {
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002065 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
Paul Cercueile72394e2018-08-21 18:42:32 +02002066 ingenic_config_pin(jzpc, pin, GPIO_MSK, true);
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002067 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, input);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002068 } else {
2069 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, false);
Paul Cercueil0084a782018-06-27 13:49:02 +02002070 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, !input);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002071 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, false);
2072 }
2073
2074 return 0;
2075}
2076
Julia Lawall5bf7b842017-08-10 12:06:23 +02002077static const struct pinmux_ops ingenic_pmxops = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002078 .get_functions_count = pinmux_generic_get_function_count,
2079 .get_function_name = pinmux_generic_get_function_name,
2080 .get_function_groups = pinmux_generic_get_function_groups,
2081 .set_mux = ingenic_pinmux_set_mux,
2082 .gpio_set_direction = ingenic_pinmux_gpio_set_direction,
2083};
2084
2085static int ingenic_pinconf_get(struct pinctrl_dev *pctldev,
2086 unsigned int pin, unsigned long *config)
2087{
2088 struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2089 enum pin_config_param param = pinconf_to_config_param(*config);
2090 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2091 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2092 bool pull;
2093
Paul Cercueilbaf15642020-01-07 00:27:08 +01002094 if (jzpc->info->version >= ID_JZ4760)
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002095 pull = !ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_PEN);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002096 else
2097 pull = !ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_PULL_DIS);
2098
2099 switch (param) {
2100 case PIN_CONFIG_BIAS_DISABLE:
2101 if (pull)
2102 return -EINVAL;
2103 break;
2104
2105 case PIN_CONFIG_BIAS_PULL_UP:
2106 if (!pull || !(jzpc->info->pull_ups[offt] & BIT(idx)))
2107 return -EINVAL;
2108 break;
2109
2110 case PIN_CONFIG_BIAS_PULL_DOWN:
2111 if (!pull || !(jzpc->info->pull_downs[offt] & BIT(idx)))
2112 return -EINVAL;
2113 break;
2114
2115 default:
2116 return -ENOTSUPP;
2117 }
2118
2119 *config = pinconf_to_config_packed(param, 1);
2120 return 0;
2121}
2122
2123static void ingenic_set_bias(struct ingenic_pinctrl *jzpc,
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002124 unsigned int pin, unsigned int bias)
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002125{
Paul Cercueilbaf15642020-01-07 00:27:08 +01002126 if (jzpc->info->version >= ID_X1830) {
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002127 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2128 unsigned int half = PINS_PER_GPIO_CHIP / 2;
2129 unsigned int idxh = pin % half * 2;
2130 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
2131
2132 if (idx < half) {
2133 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2134 REG_CLEAR(X1830_GPIO_PEL), 3 << idxh);
2135 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2136 REG_SET(X1830_GPIO_PEL), bias << idxh);
2137 } else {
2138 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2139 REG_CLEAR(X1830_GPIO_PEH), 3 << idxh);
2140 regmap_write(jzpc->map, offt * jzpc->info->reg_offset +
2141 REG_SET(X1830_GPIO_PEH), bias << idxh);
2142 }
2143
Paul Cercueilbaf15642020-01-07 00:27:08 +01002144 } else if (jzpc->info->version >= ID_JZ4760) {
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002145 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PEN, !bias);
2146 } else {
2147 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_PULL_DIS, !bias);
2148 }
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002149}
2150
Paul Cercueil7009d042019-11-19 16:52:10 +01002151static void ingenic_set_output_level(struct ingenic_pinctrl *jzpc,
2152 unsigned int pin, bool high)
2153{
Paul Cercueilbaf15642020-01-07 00:27:08 +01002154 if (jzpc->info->version >= ID_JZ4760)
Paul Cercueil7009d042019-11-19 16:52:10 +01002155 ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, high);
2156 else
2157 ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DATA, high);
2158}
2159
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002160static int ingenic_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
2161 unsigned long *configs, unsigned int num_configs)
2162{
2163 struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
2164 unsigned int idx = pin % PINS_PER_GPIO_CHIP;
2165 unsigned int offt = pin / PINS_PER_GPIO_CHIP;
Paul Cercueil7009d042019-11-19 16:52:10 +01002166 unsigned int cfg, arg;
2167 int ret;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002168
2169 for (cfg = 0; cfg < num_configs; cfg++) {
2170 switch (pinconf_to_config_param(configs[cfg])) {
2171 case PIN_CONFIG_BIAS_DISABLE:
2172 case PIN_CONFIG_BIAS_PULL_UP:
2173 case PIN_CONFIG_BIAS_PULL_DOWN:
Paul Cercueil7009d042019-11-19 16:52:10 +01002174 case PIN_CONFIG_OUTPUT:
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002175 continue;
2176 default:
2177 return -ENOTSUPP;
2178 }
2179 }
2180
2181 for (cfg = 0; cfg < num_configs; cfg++) {
Paul Cercueil7009d042019-11-19 16:52:10 +01002182 arg = pinconf_to_config_argument(configs[cfg]);
2183
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002184 switch (pinconf_to_config_param(configs[cfg])) {
2185 case PIN_CONFIG_BIAS_DISABLE:
2186 dev_dbg(jzpc->dev, "disable pull-over for pin P%c%u\n",
2187 'A' + offt, idx);
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002188 ingenic_set_bias(jzpc, pin, GPIO_PULL_DIS);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002189 break;
2190
2191 case PIN_CONFIG_BIAS_PULL_UP:
2192 if (!(jzpc->info->pull_ups[offt] & BIT(idx)))
2193 return -EINVAL;
2194 dev_dbg(jzpc->dev, "set pull-up for pin P%c%u\n",
2195 'A' + offt, idx);
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002196 ingenic_set_bias(jzpc, pin, GPIO_PULL_UP);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002197 break;
2198
2199 case PIN_CONFIG_BIAS_PULL_DOWN:
2200 if (!(jzpc->info->pull_downs[offt] & BIT(idx)))
2201 return -EINVAL;
2202 dev_dbg(jzpc->dev, "set pull-down for pin P%c%u\n",
2203 'A' + offt, idx);
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002204 ingenic_set_bias(jzpc, pin, GPIO_PULL_DOWN);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002205 break;
2206
Paul Cercueil7009d042019-11-19 16:52:10 +01002207 case PIN_CONFIG_OUTPUT:
2208 ret = pinctrl_gpio_direction_output(pin);
2209 if (ret)
2210 return ret;
2211
2212 ingenic_set_output_level(jzpc, pin, arg);
2213 break;
2214
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002215 default:
Josh Poimboeufd6d43a92020-02-20 09:35:09 -06002216 /* unreachable */
2217 break;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002218 }
2219 }
2220
2221 return 0;
2222}
2223
2224static int ingenic_pinconf_group_get(struct pinctrl_dev *pctldev,
2225 unsigned int group, unsigned long *config)
2226{
2227 const unsigned int *pins;
2228 unsigned int i, npins, old = 0;
2229 int ret;
2230
2231 ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
2232 if (ret)
2233 return ret;
2234
2235 for (i = 0; i < npins; i++) {
2236 if (ingenic_pinconf_get(pctldev, pins[i], config))
2237 return -ENOTSUPP;
2238
2239 /* configs do not match between two pins */
2240 if (i && (old != *config))
2241 return -ENOTSUPP;
2242
2243 old = *config;
2244 }
2245
2246 return 0;
2247}
2248
2249static int ingenic_pinconf_group_set(struct pinctrl_dev *pctldev,
2250 unsigned int group, unsigned long *configs,
2251 unsigned int num_configs)
2252{
2253 const unsigned int *pins;
2254 unsigned int i, npins;
2255 int ret;
2256
2257 ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins);
2258 if (ret)
2259 return ret;
2260
2261 for (i = 0; i < npins; i++) {
2262 ret = ingenic_pinconf_set(pctldev,
2263 pins[i], configs, num_configs);
2264 if (ret)
2265 return ret;
2266 }
2267
2268 return 0;
2269}
2270
Julia Lawall5bf7b842017-08-10 12:06:23 +02002271static const struct pinconf_ops ingenic_confops = {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002272 .is_generic = true,
2273 .pin_config_get = ingenic_pinconf_get,
2274 .pin_config_set = ingenic_pinconf_set,
2275 .pin_config_group_get = ingenic_pinconf_group_get,
2276 .pin_config_group_set = ingenic_pinconf_group_set,
2277};
2278
2279static const struct regmap_config ingenic_pinctrl_regmap_config = {
2280 .reg_bits = 32,
2281 .val_bits = 32,
2282 .reg_stride = 4,
2283};
2284
Paul Cercueile72394e2018-08-21 18:42:32 +02002285static const struct of_device_id ingenic_gpio_of_match[] __initconst = {
2286 { .compatible = "ingenic,jz4740-gpio", },
Paul Cercueilb5fc06a2020-06-12 14:06:09 +02002287 { .compatible = "ingenic,jz4725b-gpio", },
Zhou Yanjie0257595a2019-07-14 11:53:52 +08002288 { .compatible = "ingenic,jz4760-gpio", },
Paul Cercueile72394e2018-08-21 18:42:32 +02002289 { .compatible = "ingenic,jz4770-gpio", },
2290 { .compatible = "ingenic,jz4780-gpio", },
Zhou Yanjiefe1ad5e2019-07-14 11:53:54 +08002291 { .compatible = "ingenic,x1000-gpio", },
周琰杰 (Zhou Yanjie)d7da2a12019-12-16 00:21:04 +08002292 { .compatible = "ingenic,x1830-gpio", },
Paul Cercueile72394e2018-08-21 18:42:32 +02002293 {},
2294};
2295
2296static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,
2297 struct device_node *node)
2298{
2299 struct ingenic_gpio_chip *jzgc;
2300 struct device *dev = jzpc->dev;
Linus Walleij142b8762019-10-01 15:32:09 +02002301 struct gpio_irq_chip *girq;
Paul Cercueile72394e2018-08-21 18:42:32 +02002302 unsigned int bank;
2303 int err;
2304
2305 err = of_property_read_u32(node, "reg", &bank);
2306 if (err) {
2307 dev_err(dev, "Cannot read \"reg\" property: %i\n", err);
2308 return err;
2309 }
2310
2311 jzgc = devm_kzalloc(dev, sizeof(*jzgc), GFP_KERNEL);
2312 if (!jzgc)
2313 return -ENOMEM;
2314
2315 jzgc->jzpc = jzpc;
周琰杰 (Zhou Yanjie)f742e5e2019-12-16 00:21:02 +08002316 jzgc->reg_base = bank * jzpc->info->reg_offset;
Paul Cercueile72394e2018-08-21 18:42:32 +02002317
2318 jzgc->gc.label = devm_kasprintf(dev, GFP_KERNEL, "GPIO%c", 'A' + bank);
2319 if (!jzgc->gc.label)
2320 return -ENOMEM;
2321
2322 /* DO NOT EXPAND THIS: FOR BACKWARD GPIO NUMBERSPACE COMPATIBIBILITY
2323 * ONLY: WORK TO TRANSITION CONSUMERS TO USE THE GPIO DESCRIPTOR API IN
2324 * <linux/gpio/consumer.h> INSTEAD.
2325 */
2326 jzgc->gc.base = bank * 32;
2327
2328 jzgc->gc.ngpio = 32;
2329 jzgc->gc.parent = dev;
2330 jzgc->gc.of_node = node;
2331 jzgc->gc.owner = THIS_MODULE;
2332
2333 jzgc->gc.set = ingenic_gpio_set;
2334 jzgc->gc.get = ingenic_gpio_get;
2335 jzgc->gc.direction_input = ingenic_gpio_direction_input;
2336 jzgc->gc.direction_output = ingenic_gpio_direction_output;
Paul Cercueilebd66512018-08-21 18:42:33 +02002337 jzgc->gc.get_direction = ingenic_gpio_get_direction;
Thierry Redingd6471d62020-04-01 22:05:27 +02002338 jzgc->gc.request = gpiochip_generic_request;
2339 jzgc->gc.free = gpiochip_generic_free;
Paul Cercueile72394e2018-08-21 18:42:32 +02002340
Paul Cercueile72394e2018-08-21 18:42:32 +02002341 jzgc->irq = irq_of_parse_and_map(node, 0);
2342 if (!jzgc->irq)
2343 return -EINVAL;
2344
2345 jzgc->irq_chip.name = jzgc->gc.label;
2346 jzgc->irq_chip.irq_enable = ingenic_gpio_irq_enable;
2347 jzgc->irq_chip.irq_disable = ingenic_gpio_irq_disable;
2348 jzgc->irq_chip.irq_unmask = ingenic_gpio_irq_unmask;
2349 jzgc->irq_chip.irq_mask = ingenic_gpio_irq_mask;
2350 jzgc->irq_chip.irq_ack = ingenic_gpio_irq_ack;
2351 jzgc->irq_chip.irq_set_type = ingenic_gpio_irq_set_type;
2352 jzgc->irq_chip.irq_set_wake = ingenic_gpio_irq_set_wake;
Paul Cercueil9a0f1342020-05-03 18:45:49 +02002353 jzgc->irq_chip.irq_request_resources = ingenic_gpio_irq_request;
2354 jzgc->irq_chip.irq_release_resources = ingenic_gpio_irq_release;
Paul Cercueile72394e2018-08-21 18:42:32 +02002355 jzgc->irq_chip.flags = IRQCHIP_MASK_ON_SUSPEND;
2356
Linus Walleij142b8762019-10-01 15:32:09 +02002357 girq = &jzgc->gc.irq;
2358 girq->chip = &jzgc->irq_chip;
2359 girq->parent_handler = ingenic_gpio_irq_handler;
2360 girq->num_parents = 1;
2361 girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
2362 GFP_KERNEL);
2363 if (!girq->parents)
2364 return -ENOMEM;
2365 girq->parents[0] = jzgc->irq;
2366 girq->default_type = IRQ_TYPE_NONE;
2367 girq->handler = handle_level_irq;
2368
2369 err = devm_gpiochip_add_data(dev, &jzgc->gc, jzgc);
Paul Cercueile72394e2018-08-21 18:42:32 +02002370 if (err)
2371 return err;
2372
Paul Cercueile72394e2018-08-21 18:42:32 +02002373 return 0;
2374}
2375
Paul Cercueil4717b112018-08-21 18:42:31 +02002376static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002377{
2378 struct device *dev = &pdev->dev;
2379 struct ingenic_pinctrl *jzpc;
2380 struct pinctrl_desc *pctl_desc;
2381 void __iomem *base;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002382 const struct ingenic_chip_info *chip_info;
Paul Cercueile72394e2018-08-21 18:42:32 +02002383 struct device_node *node;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002384 unsigned int i;
2385 int err;
2386
2387 jzpc = devm_kzalloc(dev, sizeof(*jzpc), GFP_KERNEL);
2388 if (!jzpc)
2389 return -ENOMEM;
2390
Paul Cercueil94f7a2c2020-01-07 00:27:11 +01002391 base = devm_platform_ioremap_resource(pdev, 0);
Wei Yongjun119fcf42018-01-17 11:29:17 +00002392 if (IS_ERR(base))
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002393 return PTR_ERR(base);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002394
2395 jzpc->map = devm_regmap_init_mmio(dev, base,
2396 &ingenic_pinctrl_regmap_config);
2397 if (IS_ERR(jzpc->map)) {
2398 dev_err(dev, "Failed to create regmap\n");
2399 return PTR_ERR(jzpc->map);
2400 }
2401
2402 jzpc->dev = dev;
Paul Cercueilbaf15642020-01-07 00:27:08 +01002403 jzpc->info = chip_info = of_device_get_match_data(dev);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002404
2405 pctl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctl_desc), GFP_KERNEL);
2406 if (!pctl_desc)
2407 return -ENOMEM;
2408
2409 /* fill in pinctrl_desc structure */
2410 pctl_desc->name = dev_name(dev);
2411 pctl_desc->owner = THIS_MODULE;
2412 pctl_desc->pctlops = &ingenic_pctlops;
2413 pctl_desc->pmxops = &ingenic_pmxops;
2414 pctl_desc->confops = &ingenic_confops;
2415 pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP;
Kees Cooka86854d2018-06-12 14:07:58 -07002416 pctl_desc->pins = jzpc->pdesc = devm_kcalloc(&pdev->dev,
2417 pctl_desc->npins, sizeof(*jzpc->pdesc), GFP_KERNEL);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002418 if (!jzpc->pdesc)
2419 return -ENOMEM;
2420
2421 for (i = 0; i < pctl_desc->npins; i++) {
2422 jzpc->pdesc[i].number = i;
2423 jzpc->pdesc[i].name = kasprintf(GFP_KERNEL, "P%c%d",
2424 'A' + (i / PINS_PER_GPIO_CHIP),
2425 i % PINS_PER_GPIO_CHIP);
2426 }
2427
2428 jzpc->pctl = devm_pinctrl_register(dev, pctl_desc, jzpc);
Dan Carpentere7f4c4b2017-06-14 12:12:09 +03002429 if (IS_ERR(jzpc->pctl)) {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002430 dev_err(dev, "Failed to register pinctrl\n");
Dan Carpentere7f4c4b2017-06-14 12:12:09 +03002431 return PTR_ERR(jzpc->pctl);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002432 }
2433
2434 for (i = 0; i < chip_info->num_groups; i++) {
2435 const struct group_desc *group = &chip_info->groups[i];
2436
2437 err = pinctrl_generic_add_group(jzpc->pctl, group->name,
2438 group->pins, group->num_pins, group->data);
Paul Burton823dd712018-08-25 10:53:28 -07002439 if (err < 0) {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002440 dev_err(dev, "Failed to register group %s\n",
2441 group->name);
2442 return err;
2443 }
2444 }
2445
2446 for (i = 0; i < chip_info->num_functions; i++) {
2447 const struct function_desc *func = &chip_info->functions[i];
2448
2449 err = pinmux_generic_add_function(jzpc->pctl, func->name,
2450 func->group_names, func->num_group_names,
2451 func->data);
Paul Burton823dd712018-08-25 10:53:28 -07002452 if (err < 0) {
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002453 dev_err(dev, "Failed to register function %s\n",
2454 func->name);
2455 return err;
2456 }
2457 }
2458
2459 dev_set_drvdata(dev, jzpc->map);
2460
Paul Cercueile72394e2018-08-21 18:42:32 +02002461 for_each_child_of_node(dev->of_node, node) {
2462 if (of_match_node(ingenic_gpio_of_match, node)) {
2463 err = ingenic_gpio_probe(jzpc, node);
2464 if (err)
2465 return err;
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002466 }
2467 }
2468
2469 return 0;
2470}
2471
Paul Cercueilbaf15642020-01-07 00:27:08 +01002472static const struct of_device_id ingenic_pinctrl_of_match[] = {
2473 { .compatible = "ingenic,jz4740-pinctrl", .data = &jz4740_chip_info },
2474 { .compatible = "ingenic,jz4725b-pinctrl", .data = &jz4725b_chip_info },
2475 { .compatible = "ingenic,jz4760-pinctrl", .data = &jz4760_chip_info },
Paul Cercueil5ffdbb72020-01-07 00:27:09 +01002476 { .compatible = "ingenic,jz4760b-pinctrl", .data = &jz4760_chip_info },
Paul Cercueilbaf15642020-01-07 00:27:08 +01002477 { .compatible = "ingenic,jz4770-pinctrl", .data = &jz4770_chip_info },
2478 { .compatible = "ingenic,jz4780-pinctrl", .data = &jz4780_chip_info },
2479 { .compatible = "ingenic,x1000-pinctrl", .data = &x1000_chip_info },
Paul Cercueil5ffdbb72020-01-07 00:27:09 +01002480 { .compatible = "ingenic,x1000e-pinctrl", .data = &x1000_chip_info },
Paul Cercueilbaf15642020-01-07 00:27:08 +01002481 { .compatible = "ingenic,x1500-pinctrl", .data = &x1500_chip_info },
2482 { .compatible = "ingenic,x1830-pinctrl", .data = &x1830_chip_info },
2483 {},
2484};
2485
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002486static struct platform_driver ingenic_pinctrl_driver = {
2487 .driver = {
2488 .name = "pinctrl-ingenic",
Paul Cercueil5ec008b2020-01-07 00:27:07 +01002489 .of_match_table = ingenic_pinctrl_of_match,
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002490 },
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002491};
2492
2493static int __init ingenic_pinctrl_drv_register(void)
2494{
Paul Cercueil4717b112018-08-21 18:42:31 +02002495 return platform_driver_probe(&ingenic_pinctrl_driver,
2496 ingenic_pinctrl_probe);
Paul Cercueilb5c23aa2017-05-12 18:52:56 +02002497}
Paul Cercueil556a36a2018-08-21 18:42:30 +02002498subsys_initcall(ingenic_pinctrl_drv_register);