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