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 | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 6 | * Copyright (c) 2019 Zhou Yanjie <zhouyanjie@zoho.com> |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/compiler.h> |
Linus Walleij | 28d6eeb | 2018-08-29 13:39:54 +0200 | [diff] [blame] | 10 | #include <linux/gpio/driver.h> |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 11 | #include <linux/interrupt.h> |
| 12 | #include <linux/io.h> |
| 13 | #include <linux/of_device.h> |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 14 | #include <linux/of_irq.h> |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 15 | #include <linux/of_platform.h> |
| 16 | #include <linux/pinctrl/pinctrl.h> |
| 17 | #include <linux/pinctrl/pinmux.h> |
| 18 | #include <linux/pinctrl/pinconf.h> |
| 19 | #include <linux/pinctrl/pinconf-generic.h> |
| 20 | #include <linux/platform_device.h> |
| 21 | #include <linux/regmap.h> |
| 22 | #include <linux/slab.h> |
| 23 | |
| 24 | #include "core.h" |
| 25 | #include "pinconf.h" |
| 26 | #include "pinmux.h" |
| 27 | |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 28 | #define GPIO_PIN 0x00 |
| 29 | #define GPIO_MSK 0x20 |
| 30 | |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 31 | #define JZ4740_GPIO_DATA 0x10 |
| 32 | #define JZ4740_GPIO_PULL_DIS 0x30 |
| 33 | #define JZ4740_GPIO_FUNC 0x40 |
| 34 | #define JZ4740_GPIO_SELECT 0x50 |
| 35 | #define JZ4740_GPIO_DIR 0x60 |
| 36 | #define JZ4740_GPIO_TRIG 0x70 |
| 37 | #define JZ4740_GPIO_FLAG 0x80 |
| 38 | |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 39 | #define JZ4760_GPIO_INT 0x10 |
| 40 | #define JZ4760_GPIO_PAT1 0x30 |
| 41 | #define JZ4760_GPIO_PAT0 0x40 |
| 42 | #define JZ4760_GPIO_FLAG 0x50 |
| 43 | #define JZ4760_GPIO_PEN 0x70 |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 44 | |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 45 | #define X1000_GPIO_PZ_BASE 0x700 |
| 46 | #define X1000_GPIO_PZ_GID2LD 0x7f0 |
| 47 | |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 48 | #define REG_SET(x) ((x) + 0x4) |
| 49 | #define REG_CLEAR(x) ((x) + 0x8) |
| 50 | |
| 51 | #define PINS_PER_GPIO_CHIP 32 |
| 52 | |
| 53 | enum jz_version { |
| 54 | ID_JZ4740, |
Paul Cercueil | f2a9676 | 2018-08-21 18:42:34 +0200 | [diff] [blame] | 55 | ID_JZ4725B, |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 56 | ID_JZ4760, |
| 57 | ID_JZ4760B, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 58 | ID_JZ4770, |
| 59 | ID_JZ4780, |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 60 | ID_X1000, |
| 61 | ID_X1000E, |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 62 | ID_X1500, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | struct ingenic_chip_info { |
| 66 | unsigned int num_chips; |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 67 | unsigned int reg_offset; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 68 | |
| 69 | const struct group_desc *groups; |
| 70 | unsigned int num_groups; |
| 71 | |
| 72 | const struct function_desc *functions; |
| 73 | unsigned int num_functions; |
| 74 | |
| 75 | const u32 *pull_ups, *pull_downs; |
| 76 | }; |
| 77 | |
| 78 | struct ingenic_pinctrl { |
| 79 | struct device *dev; |
| 80 | struct regmap *map; |
| 81 | struct pinctrl_dev *pctl; |
| 82 | struct pinctrl_pin_desc *pdesc; |
| 83 | enum jz_version version; |
| 84 | |
| 85 | const struct ingenic_chip_info *info; |
| 86 | }; |
| 87 | |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 88 | struct ingenic_gpio_chip { |
| 89 | struct ingenic_pinctrl *jzpc; |
| 90 | struct gpio_chip gc; |
| 91 | struct irq_chip irq_chip; |
| 92 | unsigned int irq, reg_base; |
| 93 | }; |
| 94 | |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 95 | static const u32 jz4740_pull_ups[4] = { |
| 96 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 97 | }; |
| 98 | |
| 99 | static const u32 jz4740_pull_downs[4] = { |
| 100 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, |
| 101 | }; |
| 102 | |
| 103 | static int jz4740_mmc_1bit_pins[] = { 0x69, 0x68, 0x6a, }; |
| 104 | static int jz4740_mmc_4bit_pins[] = { 0x6b, 0x6c, 0x6d, }; |
| 105 | static int jz4740_uart0_data_pins[] = { 0x7a, 0x79, }; |
| 106 | static int jz4740_uart0_hwflow_pins[] = { 0x7e, 0x7f, }; |
| 107 | static int jz4740_uart1_data_pins[] = { 0x7e, 0x7f, }; |
| 108 | static int jz4740_lcd_8bit_pins[] = { |
| 109 | 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x52, 0x53, 0x54, |
| 110 | }; |
| 111 | static int jz4740_lcd_16bit_pins[] = { |
| 112 | 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x55, |
| 113 | }; |
| 114 | static int jz4740_lcd_18bit_pins[] = { 0x50, 0x51, }; |
| 115 | static int jz4740_lcd_18bit_tft_pins[] = { 0x56, 0x57, 0x31, 0x32, }; |
| 116 | static int jz4740_nand_cs1_pins[] = { 0x39, }; |
| 117 | static int jz4740_nand_cs2_pins[] = { 0x3a, }; |
| 118 | static int jz4740_nand_cs3_pins[] = { 0x3b, }; |
| 119 | static int jz4740_nand_cs4_pins[] = { 0x3c, }; |
| 120 | static int jz4740_pwm_pwm0_pins[] = { 0x77, }; |
| 121 | static int jz4740_pwm_pwm1_pins[] = { 0x78, }; |
| 122 | static int jz4740_pwm_pwm2_pins[] = { 0x79, }; |
| 123 | static int jz4740_pwm_pwm3_pins[] = { 0x7a, }; |
| 124 | static int jz4740_pwm_pwm4_pins[] = { 0x7b, }; |
| 125 | static int jz4740_pwm_pwm5_pins[] = { 0x7c, }; |
| 126 | static int jz4740_pwm_pwm6_pins[] = { 0x7e, }; |
| 127 | static int jz4740_pwm_pwm7_pins[] = { 0x7f, }; |
| 128 | |
| 129 | static int jz4740_mmc_1bit_funcs[] = { 0, 0, 0, }; |
| 130 | static int jz4740_mmc_4bit_funcs[] = { 0, 0, 0, }; |
| 131 | static int jz4740_uart0_data_funcs[] = { 1, 1, }; |
| 132 | static int jz4740_uart0_hwflow_funcs[] = { 1, 1, }; |
| 133 | static int jz4740_uart1_data_funcs[] = { 2, 2, }; |
| 134 | static int jz4740_lcd_8bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; |
| 135 | static int jz4740_lcd_16bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, }; |
| 136 | static int jz4740_lcd_18bit_funcs[] = { 0, 0, }; |
| 137 | static int jz4740_lcd_18bit_tft_funcs[] = { 0, 0, 0, 0, }; |
| 138 | static int jz4740_nand_cs1_funcs[] = { 0, }; |
| 139 | static int jz4740_nand_cs2_funcs[] = { 0, }; |
| 140 | static int jz4740_nand_cs3_funcs[] = { 0, }; |
| 141 | static int jz4740_nand_cs4_funcs[] = { 0, }; |
| 142 | static int jz4740_pwm_pwm0_funcs[] = { 0, }; |
| 143 | static int jz4740_pwm_pwm1_funcs[] = { 0, }; |
| 144 | static int jz4740_pwm_pwm2_funcs[] = { 0, }; |
| 145 | static int jz4740_pwm_pwm3_funcs[] = { 0, }; |
| 146 | static int jz4740_pwm_pwm4_funcs[] = { 0, }; |
| 147 | static int jz4740_pwm_pwm5_funcs[] = { 0, }; |
| 148 | static int jz4740_pwm_pwm6_funcs[] = { 0, }; |
| 149 | static int jz4740_pwm_pwm7_funcs[] = { 0, }; |
| 150 | |
| 151 | #define INGENIC_PIN_GROUP(name, id) \ |
| 152 | { \ |
| 153 | name, \ |
| 154 | id##_pins, \ |
| 155 | ARRAY_SIZE(id##_pins), \ |
| 156 | id##_funcs, \ |
| 157 | } |
| 158 | |
| 159 | static const struct group_desc jz4740_groups[] = { |
| 160 | INGENIC_PIN_GROUP("mmc-1bit", jz4740_mmc_1bit), |
| 161 | INGENIC_PIN_GROUP("mmc-4bit", jz4740_mmc_4bit), |
| 162 | INGENIC_PIN_GROUP("uart0-data", jz4740_uart0_data), |
| 163 | INGENIC_PIN_GROUP("uart0-hwflow", jz4740_uart0_hwflow), |
| 164 | INGENIC_PIN_GROUP("uart1-data", jz4740_uart1_data), |
| 165 | INGENIC_PIN_GROUP("lcd-8bit", jz4740_lcd_8bit), |
| 166 | INGENIC_PIN_GROUP("lcd-16bit", jz4740_lcd_16bit), |
| 167 | INGENIC_PIN_GROUP("lcd-18bit", jz4740_lcd_18bit), |
| 168 | INGENIC_PIN_GROUP("lcd-18bit-tft", jz4740_lcd_18bit_tft), |
| 169 | { "lcd-no-pins", }, |
| 170 | INGENIC_PIN_GROUP("nand-cs1", jz4740_nand_cs1), |
| 171 | INGENIC_PIN_GROUP("nand-cs2", jz4740_nand_cs2), |
| 172 | INGENIC_PIN_GROUP("nand-cs3", jz4740_nand_cs3), |
| 173 | INGENIC_PIN_GROUP("nand-cs4", jz4740_nand_cs4), |
| 174 | INGENIC_PIN_GROUP("pwm0", jz4740_pwm_pwm0), |
| 175 | INGENIC_PIN_GROUP("pwm1", jz4740_pwm_pwm1), |
| 176 | INGENIC_PIN_GROUP("pwm2", jz4740_pwm_pwm2), |
| 177 | INGENIC_PIN_GROUP("pwm3", jz4740_pwm_pwm3), |
| 178 | INGENIC_PIN_GROUP("pwm4", jz4740_pwm_pwm4), |
| 179 | INGENIC_PIN_GROUP("pwm5", jz4740_pwm_pwm5), |
| 180 | INGENIC_PIN_GROUP("pwm6", jz4740_pwm_pwm6), |
| 181 | INGENIC_PIN_GROUP("pwm7", jz4740_pwm_pwm7), |
| 182 | }; |
| 183 | |
| 184 | static const char *jz4740_mmc_groups[] = { "mmc-1bit", "mmc-4bit", }; |
| 185 | static const char *jz4740_uart0_groups[] = { "uart0-data", "uart0-hwflow", }; |
| 186 | static const char *jz4740_uart1_groups[] = { "uart1-data", }; |
| 187 | static const char *jz4740_lcd_groups[] = { |
| 188 | "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-18bit-tft", "lcd-no-pins", |
| 189 | }; |
| 190 | static const char *jz4740_nand_groups[] = { |
| 191 | "nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4", |
| 192 | }; |
| 193 | static const char *jz4740_pwm0_groups[] = { "pwm0", }; |
| 194 | static const char *jz4740_pwm1_groups[] = { "pwm1", }; |
| 195 | static const char *jz4740_pwm2_groups[] = { "pwm2", }; |
| 196 | static const char *jz4740_pwm3_groups[] = { "pwm3", }; |
| 197 | static const char *jz4740_pwm4_groups[] = { "pwm4", }; |
| 198 | static const char *jz4740_pwm5_groups[] = { "pwm5", }; |
| 199 | static const char *jz4740_pwm6_groups[] = { "pwm6", }; |
| 200 | static const char *jz4740_pwm7_groups[] = { "pwm7", }; |
| 201 | |
| 202 | static const struct function_desc jz4740_functions[] = { |
| 203 | { "mmc", jz4740_mmc_groups, ARRAY_SIZE(jz4740_mmc_groups), }, |
| 204 | { "uart0", jz4740_uart0_groups, ARRAY_SIZE(jz4740_uart0_groups), }, |
| 205 | { "uart1", jz4740_uart1_groups, ARRAY_SIZE(jz4740_uart1_groups), }, |
| 206 | { "lcd", jz4740_lcd_groups, ARRAY_SIZE(jz4740_lcd_groups), }, |
| 207 | { "nand", jz4740_nand_groups, ARRAY_SIZE(jz4740_nand_groups), }, |
| 208 | { "pwm0", jz4740_pwm0_groups, ARRAY_SIZE(jz4740_pwm0_groups), }, |
| 209 | { "pwm1", jz4740_pwm1_groups, ARRAY_SIZE(jz4740_pwm1_groups), }, |
| 210 | { "pwm2", jz4740_pwm2_groups, ARRAY_SIZE(jz4740_pwm2_groups), }, |
| 211 | { "pwm3", jz4740_pwm3_groups, ARRAY_SIZE(jz4740_pwm3_groups), }, |
| 212 | { "pwm4", jz4740_pwm4_groups, ARRAY_SIZE(jz4740_pwm4_groups), }, |
| 213 | { "pwm5", jz4740_pwm5_groups, ARRAY_SIZE(jz4740_pwm5_groups), }, |
| 214 | { "pwm6", jz4740_pwm6_groups, ARRAY_SIZE(jz4740_pwm6_groups), }, |
| 215 | { "pwm7", jz4740_pwm7_groups, ARRAY_SIZE(jz4740_pwm7_groups), }, |
| 216 | }; |
| 217 | |
| 218 | static const struct ingenic_chip_info jz4740_chip_info = { |
| 219 | .num_chips = 4, |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 220 | .reg_offset = 0x100, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 221 | .groups = jz4740_groups, |
| 222 | .num_groups = ARRAY_SIZE(jz4740_groups), |
| 223 | .functions = jz4740_functions, |
| 224 | .num_functions = ARRAY_SIZE(jz4740_functions), |
| 225 | .pull_ups = jz4740_pull_ups, |
| 226 | .pull_downs = jz4740_pull_downs, |
| 227 | }; |
| 228 | |
Paul Cercueil | f2a9676 | 2018-08-21 18:42:34 +0200 | [diff] [blame] | 229 | static int jz4725b_mmc0_1bit_pins[] = { 0x48, 0x49, 0x5c, }; |
| 230 | static int jz4725b_mmc0_4bit_pins[] = { 0x5d, 0x5b, 0x56, }; |
| 231 | static int jz4725b_mmc1_1bit_pins[] = { 0x7a, 0x7b, 0x7c, }; |
| 232 | static int jz4725b_mmc1_4bit_pins[] = { 0x7d, 0x7e, 0x7f, }; |
| 233 | static int jz4725b_uart_data_pins[] = { 0x4c, 0x4d, }; |
| 234 | static int jz4725b_nand_cs1_pins[] = { 0x55, }; |
| 235 | static int jz4725b_nand_cs2_pins[] = { 0x56, }; |
| 236 | static int jz4725b_nand_cs3_pins[] = { 0x57, }; |
| 237 | static int jz4725b_nand_cs4_pins[] = { 0x58, }; |
| 238 | static int jz4725b_nand_cle_ale_pins[] = { 0x48, 0x49 }; |
| 239 | static int jz4725b_nand_fre_fwe_pins[] = { 0x5c, 0x5d }; |
| 240 | static int jz4725b_pwm_pwm0_pins[] = { 0x4a, }; |
| 241 | static int jz4725b_pwm_pwm1_pins[] = { 0x4b, }; |
| 242 | static int jz4725b_pwm_pwm2_pins[] = { 0x4c, }; |
| 243 | static int jz4725b_pwm_pwm3_pins[] = { 0x4d, }; |
| 244 | static int jz4725b_pwm_pwm4_pins[] = { 0x4e, }; |
| 245 | static int jz4725b_pwm_pwm5_pins[] = { 0x4f, }; |
Paul Cercueil | a3240f0 | 2019-02-07 10:55:36 -0300 | [diff] [blame] | 246 | static int jz4725b_lcd_8bit_pins[] = { |
| 247 | 0x72, 0x73, 0x74, |
| 248 | 0x60, 0x61, 0x62, 0x63, |
| 249 | 0x64, 0x65, 0x66, 0x67, |
| 250 | }; |
| 251 | static int jz4725b_lcd_16bit_pins[] = { |
| 252 | 0x68, 0x69, 0x6a, 0x6b, |
| 253 | 0x6c, 0x6d, 0x6e, 0x6f, |
| 254 | }; |
| 255 | static int jz4725b_lcd_18bit_pins[] = { 0x70, 0x71, }; |
| 256 | static int jz4725b_lcd_24bit_pins[] = { 0x76, 0x77, 0x78, 0x79, }; |
| 257 | static int jz4725b_lcd_special_pins[] = { 0x76, 0x77, 0x78, 0x79, }; |
| 258 | static int jz4725b_lcd_generic_pins[] = { 0x75, }; |
Paul Cercueil | f2a9676 | 2018-08-21 18:42:34 +0200 | [diff] [blame] | 259 | |
| 260 | static int jz4725b_mmc0_1bit_funcs[] = { 1, 1, 1, }; |
| 261 | static int jz4725b_mmc0_4bit_funcs[] = { 1, 0, 1, }; |
| 262 | static int jz4725b_mmc1_1bit_funcs[] = { 0, 0, 0, }; |
| 263 | static int jz4725b_mmc1_4bit_funcs[] = { 0, 0, 0, }; |
| 264 | static int jz4725b_uart_data_funcs[] = { 1, 1, }; |
| 265 | static int jz4725b_nand_cs1_funcs[] = { 0, }; |
| 266 | static int jz4725b_nand_cs2_funcs[] = { 0, }; |
| 267 | static int jz4725b_nand_cs3_funcs[] = { 0, }; |
| 268 | static int jz4725b_nand_cs4_funcs[] = { 0, }; |
| 269 | static int jz4725b_nand_cle_ale_funcs[] = { 0, 0, }; |
| 270 | static int jz4725b_nand_fre_fwe_funcs[] = { 0, 0, }; |
| 271 | static int jz4725b_pwm_pwm0_funcs[] = { 0, }; |
| 272 | static int jz4725b_pwm_pwm1_funcs[] = { 0, }; |
| 273 | static int jz4725b_pwm_pwm2_funcs[] = { 0, }; |
| 274 | static int jz4725b_pwm_pwm3_funcs[] = { 0, }; |
| 275 | static int jz4725b_pwm_pwm4_funcs[] = { 0, }; |
| 276 | static int jz4725b_pwm_pwm5_funcs[] = { 0, }; |
Paul Cercueil | a3240f0 | 2019-02-07 10:55:36 -0300 | [diff] [blame] | 277 | static int jz4725b_lcd_8bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; |
| 278 | static int jz4725b_lcd_16bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, }; |
| 279 | static int jz4725b_lcd_18bit_funcs[] = { 0, 0, }; |
| 280 | static int jz4725b_lcd_24bit_funcs[] = { 1, 1, 1, 1, }; |
| 281 | static int jz4725b_lcd_special_funcs[] = { 0, 0, 0, 0, }; |
| 282 | static int jz4725b_lcd_generic_funcs[] = { 0, }; |
Paul Cercueil | f2a9676 | 2018-08-21 18:42:34 +0200 | [diff] [blame] | 283 | |
| 284 | static const struct group_desc jz4725b_groups[] = { |
| 285 | INGENIC_PIN_GROUP("mmc0-1bit", jz4725b_mmc0_1bit), |
| 286 | INGENIC_PIN_GROUP("mmc0-4bit", jz4725b_mmc0_4bit), |
| 287 | INGENIC_PIN_GROUP("mmc1-1bit", jz4725b_mmc1_1bit), |
| 288 | INGENIC_PIN_GROUP("mmc1-4bit", jz4725b_mmc1_4bit), |
| 289 | INGENIC_PIN_GROUP("uart-data", jz4725b_uart_data), |
| 290 | INGENIC_PIN_GROUP("nand-cs1", jz4725b_nand_cs1), |
| 291 | INGENIC_PIN_GROUP("nand-cs2", jz4725b_nand_cs2), |
| 292 | INGENIC_PIN_GROUP("nand-cs3", jz4725b_nand_cs3), |
| 293 | INGENIC_PIN_GROUP("nand-cs4", jz4725b_nand_cs4), |
| 294 | INGENIC_PIN_GROUP("nand-cle-ale", jz4725b_nand_cle_ale), |
| 295 | INGENIC_PIN_GROUP("nand-fre-fwe", jz4725b_nand_fre_fwe), |
| 296 | INGENIC_PIN_GROUP("pwm0", jz4725b_pwm_pwm0), |
| 297 | INGENIC_PIN_GROUP("pwm1", jz4725b_pwm_pwm1), |
| 298 | INGENIC_PIN_GROUP("pwm2", jz4725b_pwm_pwm2), |
| 299 | INGENIC_PIN_GROUP("pwm3", jz4725b_pwm_pwm3), |
| 300 | INGENIC_PIN_GROUP("pwm4", jz4725b_pwm_pwm4), |
| 301 | INGENIC_PIN_GROUP("pwm5", jz4725b_pwm_pwm5), |
Paul Cercueil | a3240f0 | 2019-02-07 10:55:36 -0300 | [diff] [blame] | 302 | INGENIC_PIN_GROUP("lcd-8bit", jz4725b_lcd_8bit), |
| 303 | INGENIC_PIN_GROUP("lcd-16bit", jz4725b_lcd_16bit), |
| 304 | INGENIC_PIN_GROUP("lcd-18bit", jz4725b_lcd_18bit), |
| 305 | INGENIC_PIN_GROUP("lcd-24bit", jz4725b_lcd_24bit), |
| 306 | INGENIC_PIN_GROUP("lcd-special", jz4725b_lcd_special), |
| 307 | INGENIC_PIN_GROUP("lcd-generic", jz4725b_lcd_generic), |
Paul Cercueil | f2a9676 | 2018-08-21 18:42:34 +0200 | [diff] [blame] | 308 | }; |
| 309 | |
| 310 | static const char *jz4725b_mmc0_groups[] = { "mmc0-1bit", "mmc0-4bit", }; |
| 311 | static const char *jz4725b_mmc1_groups[] = { "mmc1-1bit", "mmc1-4bit", }; |
| 312 | static const char *jz4725b_uart_groups[] = { "uart-data", }; |
| 313 | static const char *jz4725b_nand_groups[] = { |
| 314 | "nand-cs1", "nand-cs2", "nand-cs3", "nand-cs4", |
| 315 | "nand-cle-ale", "nand-fre-fwe", |
| 316 | }; |
| 317 | static const char *jz4725b_pwm0_groups[] = { "pwm0", }; |
| 318 | static const char *jz4725b_pwm1_groups[] = { "pwm1", }; |
| 319 | static const char *jz4725b_pwm2_groups[] = { "pwm2", }; |
| 320 | static const char *jz4725b_pwm3_groups[] = { "pwm3", }; |
| 321 | static const char *jz4725b_pwm4_groups[] = { "pwm4", }; |
| 322 | static const char *jz4725b_pwm5_groups[] = { "pwm5", }; |
Paul Cercueil | a3240f0 | 2019-02-07 10:55:36 -0300 | [diff] [blame] | 323 | static const char *jz4725b_lcd_groups[] = { |
| 324 | "lcd-8bit", "lcd-16bit", "lcd-18bit", "lcd-24bit", |
| 325 | "lcd-special", "lcd-generic", |
| 326 | }; |
Paul Cercueil | f2a9676 | 2018-08-21 18:42:34 +0200 | [diff] [blame] | 327 | |
| 328 | static const struct function_desc jz4725b_functions[] = { |
| 329 | { "mmc0", jz4725b_mmc0_groups, ARRAY_SIZE(jz4725b_mmc0_groups), }, |
| 330 | { "mmc1", jz4725b_mmc1_groups, ARRAY_SIZE(jz4725b_mmc1_groups), }, |
| 331 | { "uart", jz4725b_uart_groups, ARRAY_SIZE(jz4725b_uart_groups), }, |
| 332 | { "nand", jz4725b_nand_groups, ARRAY_SIZE(jz4725b_nand_groups), }, |
| 333 | { "pwm0", jz4725b_pwm0_groups, ARRAY_SIZE(jz4725b_pwm0_groups), }, |
| 334 | { "pwm1", jz4725b_pwm1_groups, ARRAY_SIZE(jz4725b_pwm1_groups), }, |
| 335 | { "pwm2", jz4725b_pwm2_groups, ARRAY_SIZE(jz4725b_pwm2_groups), }, |
| 336 | { "pwm3", jz4725b_pwm3_groups, ARRAY_SIZE(jz4725b_pwm3_groups), }, |
| 337 | { "pwm4", jz4725b_pwm4_groups, ARRAY_SIZE(jz4725b_pwm4_groups), }, |
| 338 | { "pwm5", jz4725b_pwm5_groups, ARRAY_SIZE(jz4725b_pwm5_groups), }, |
Paul Cercueil | a3240f0 | 2019-02-07 10:55:36 -0300 | [diff] [blame] | 339 | { "lcd", jz4725b_lcd_groups, ARRAY_SIZE(jz4725b_lcd_groups), }, |
Paul Cercueil | f2a9676 | 2018-08-21 18:42:34 +0200 | [diff] [blame] | 340 | }; |
| 341 | |
| 342 | static const struct ingenic_chip_info jz4725b_chip_info = { |
| 343 | .num_chips = 4, |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 344 | .reg_offset = 0x100, |
Paul Cercueil | f2a9676 | 2018-08-21 18:42:34 +0200 | [diff] [blame] | 345 | .groups = jz4725b_groups, |
| 346 | .num_groups = ARRAY_SIZE(jz4725b_groups), |
| 347 | .functions = jz4725b_functions, |
| 348 | .num_functions = ARRAY_SIZE(jz4725b_functions), |
| 349 | .pull_ups = jz4740_pull_ups, |
| 350 | .pull_downs = jz4740_pull_downs, |
| 351 | }; |
| 352 | |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 353 | static const u32 jz4760_pull_ups[6] = { |
| 354 | 0xffffffff, 0xfffcf3ff, 0xffffffff, 0xffffcfff, 0xfffffb7c, 0xfffff00f, |
| 355 | }; |
| 356 | |
| 357 | static const u32 jz4760_pull_downs[6] = { |
| 358 | 0x00000000, 0x00030c00, 0x00000000, 0x00003000, 0x00000483, 0x00000ff0, |
| 359 | }; |
| 360 | |
| 361 | static int jz4760_uart0_data_pins[] = { 0xa0, 0xa3, }; |
| 362 | static int jz4760_uart0_hwflow_pins[] = { 0xa1, 0xa2, }; |
| 363 | static int jz4760_uart1_data_pins[] = { 0x7a, 0x7c, }; |
| 364 | static int jz4760_uart1_hwflow_pins[] = { 0x7b, 0x7d, }; |
| 365 | static int jz4760_uart2_data_pins[] = { 0x5c, 0x5e, }; |
| 366 | static int jz4760_uart2_hwflow_pins[] = { 0x5d, 0x5f, }; |
| 367 | static int jz4760_uart3_data_pins[] = { 0x6c, 0x85, }; |
| 368 | static int jz4760_uart3_hwflow_pins[] = { 0x88, 0x89, }; |
| 369 | static int jz4760_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, }; |
| 370 | static int jz4760_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, }; |
| 371 | static int jz4760_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, }; |
| 372 | static int jz4760_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, }; |
| 373 | static int jz4760_mmc0_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, }; |
| 374 | static int jz4760_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, }; |
| 375 | static int jz4760_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, }; |
| 376 | static int jz4760_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, }; |
| 377 | static int jz4760_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, }; |
| 378 | static int jz4760_mmc1_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, }; |
| 379 | static int jz4760_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, }; |
| 380 | static int jz4760_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, }; |
| 381 | static int jz4760_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, }; |
| 382 | static int jz4760_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, }; |
| 383 | static int jz4760_mmc2_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, }; |
| 384 | static int jz4760_nemc_8bit_data_pins[] = { |
| 385 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 386 | }; |
| 387 | static int jz4760_nemc_16bit_data_pins[] = { |
| 388 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 389 | }; |
| 390 | static int jz4760_nemc_cle_ale_pins[] = { 0x20, 0x21, }; |
| 391 | static int jz4760_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, }; |
| 392 | static int jz4760_nemc_rd_we_pins[] = { 0x10, 0x11, }; |
| 393 | static int jz4760_nemc_frd_fwe_pins[] = { 0x12, 0x13, }; |
| 394 | static int jz4760_nemc_wait_pins[] = { 0x1b, }; |
| 395 | static int jz4760_nemc_cs1_pins[] = { 0x15, }; |
| 396 | static int jz4760_nemc_cs2_pins[] = { 0x16, }; |
| 397 | static int jz4760_nemc_cs3_pins[] = { 0x17, }; |
| 398 | static int jz4760_nemc_cs4_pins[] = { 0x18, }; |
| 399 | static int jz4760_nemc_cs5_pins[] = { 0x19, }; |
| 400 | static int jz4760_nemc_cs6_pins[] = { 0x1a, }; |
| 401 | static int jz4760_i2c0_pins[] = { 0x7e, 0x7f, }; |
| 402 | static int jz4760_i2c1_pins[] = { 0x9e, 0x9f, }; |
| 403 | static int jz4760_cim_pins[] = { |
| 404 | 0x26, 0x27, 0x28, 0x29, |
| 405 | 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, |
| 406 | }; |
| 407 | static int jz4760_lcd_24bit_pins[] = { |
| 408 | 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, |
| 409 | 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, |
| 410 | 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, |
| 411 | 0x58, 0x59, 0x5a, 0x5b, |
| 412 | }; |
| 413 | static int jz4760_pwm_pwm0_pins[] = { 0x80, }; |
| 414 | static int jz4760_pwm_pwm1_pins[] = { 0x81, }; |
| 415 | static int jz4760_pwm_pwm2_pins[] = { 0x82, }; |
| 416 | static int jz4760_pwm_pwm3_pins[] = { 0x83, }; |
| 417 | static int jz4760_pwm_pwm4_pins[] = { 0x84, }; |
| 418 | static int jz4760_pwm_pwm5_pins[] = { 0x85, }; |
| 419 | static int jz4760_pwm_pwm6_pins[] = { 0x6a, }; |
| 420 | static int jz4760_pwm_pwm7_pins[] = { 0x6b, }; |
| 421 | |
| 422 | static int jz4760_uart0_data_funcs[] = { 0, 0, }; |
| 423 | static int jz4760_uart0_hwflow_funcs[] = { 0, 0, }; |
| 424 | static int jz4760_uart1_data_funcs[] = { 0, 0, }; |
| 425 | static int jz4760_uart1_hwflow_funcs[] = { 0, 0, }; |
| 426 | static int jz4760_uart2_data_funcs[] = { 0, 0, }; |
| 427 | static int jz4760_uart2_hwflow_funcs[] = { 0, 0, }; |
| 428 | static int jz4760_uart3_data_funcs[] = { 0, 1, }; |
| 429 | static int jz4760_uart3_hwflow_funcs[] = { 0, 0, }; |
| 430 | static int jz4760_mmc0_1bit_a_funcs[] = { 1, 1, 0, }; |
| 431 | static int jz4760_mmc0_4bit_a_funcs[] = { 1, 1, 1, }; |
| 432 | static int jz4760_mmc0_1bit_e_funcs[] = { 0, 0, 0, }; |
| 433 | static int jz4760_mmc0_4bit_e_funcs[] = { 0, 0, 0, }; |
| 434 | static int jz4760_mmc0_8bit_e_funcs[] = { 0, 0, 0, 0, }; |
| 435 | static int jz4760_mmc1_1bit_d_funcs[] = { 0, 0, 0, }; |
| 436 | static int jz4760_mmc1_4bit_d_funcs[] = { 0, 0, 0, }; |
| 437 | static int jz4760_mmc1_1bit_e_funcs[] = { 1, 1, 1, }; |
| 438 | static int jz4760_mmc1_4bit_e_funcs[] = { 1, 1, 1, }; |
| 439 | static int jz4760_mmc1_8bit_e_funcs[] = { 1, 1, 1, 1, }; |
| 440 | static int jz4760_mmc2_1bit_b_funcs[] = { 0, 0, 0, }; |
| 441 | static int jz4760_mmc2_4bit_b_funcs[] = { 0, 0, 0, }; |
| 442 | static int jz4760_mmc2_1bit_e_funcs[] = { 2, 2, 2, }; |
| 443 | static int jz4760_mmc2_4bit_e_funcs[] = { 2, 2, 2, }; |
| 444 | static int jz4760_mmc2_8bit_e_funcs[] = { 2, 2, 2, 2, }; |
| 445 | static int jz4760_nemc_8bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, }; |
| 446 | static int jz4760_nemc_16bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, }; |
| 447 | static int jz4760_nemc_cle_ale_funcs[] = { 0, 0, }; |
| 448 | static int jz4760_nemc_addr_funcs[] = { 0, 0, 0, 0, }; |
| 449 | static int jz4760_nemc_rd_we_funcs[] = { 0, 0, }; |
| 450 | static int jz4760_nemc_frd_fwe_funcs[] = { 0, 0, }; |
| 451 | static int jz4760_nemc_wait_funcs[] = { 0, }; |
| 452 | static int jz4760_nemc_cs1_funcs[] = { 0, }; |
| 453 | static int jz4760_nemc_cs2_funcs[] = { 0, }; |
| 454 | static int jz4760_nemc_cs3_funcs[] = { 0, }; |
| 455 | static int jz4760_nemc_cs4_funcs[] = { 0, }; |
| 456 | static int jz4760_nemc_cs5_funcs[] = { 0, }; |
| 457 | static int jz4760_nemc_cs6_funcs[] = { 0, }; |
| 458 | static int jz4760_i2c0_funcs[] = { 0, 0, }; |
| 459 | static int jz4760_i2c1_funcs[] = { 0, 0, }; |
| 460 | static int jz4760_cim_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; |
| 461 | static int jz4760_lcd_24bit_funcs[] = { |
| 462 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 463 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 464 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 465 | 0, 0, 0, 0, |
| 466 | }; |
| 467 | static int jz4760_pwm_pwm0_funcs[] = { 0, }; |
| 468 | static int jz4760_pwm_pwm1_funcs[] = { 0, }; |
| 469 | static int jz4760_pwm_pwm2_funcs[] = { 0, }; |
| 470 | static int jz4760_pwm_pwm3_funcs[] = { 0, }; |
| 471 | static int jz4760_pwm_pwm4_funcs[] = { 0, }; |
| 472 | static int jz4760_pwm_pwm5_funcs[] = { 0, }; |
| 473 | static int jz4760_pwm_pwm6_funcs[] = { 0, }; |
| 474 | static int jz4760_pwm_pwm7_funcs[] = { 0, }; |
| 475 | |
| 476 | static const struct group_desc jz4760_groups[] = { |
| 477 | INGENIC_PIN_GROUP("uart0-data", jz4760_uart0_data), |
| 478 | INGENIC_PIN_GROUP("uart0-hwflow", jz4760_uart0_hwflow), |
| 479 | INGENIC_PIN_GROUP("uart1-data", jz4760_uart1_data), |
| 480 | INGENIC_PIN_GROUP("uart1-hwflow", jz4760_uart1_hwflow), |
| 481 | INGENIC_PIN_GROUP("uart2-data", jz4760_uart2_data), |
| 482 | INGENIC_PIN_GROUP("uart2-hwflow", jz4760_uart2_hwflow), |
| 483 | INGENIC_PIN_GROUP("uart3-data", jz4760_uart3_data), |
| 484 | INGENIC_PIN_GROUP("uart3-hwflow", jz4760_uart3_hwflow), |
| 485 | INGENIC_PIN_GROUP("mmc0-1bit-a", jz4760_mmc0_1bit_a), |
| 486 | INGENIC_PIN_GROUP("mmc0-4bit-a", jz4760_mmc0_4bit_a), |
| 487 | INGENIC_PIN_GROUP("mmc0-1bit-e", jz4760_mmc0_1bit_e), |
| 488 | INGENIC_PIN_GROUP("mmc0-4bit-e", jz4760_mmc0_4bit_e), |
| 489 | INGENIC_PIN_GROUP("mmc0-8bit-e", jz4760_mmc0_8bit_e), |
| 490 | INGENIC_PIN_GROUP("mmc1-1bit-d", jz4760_mmc1_1bit_d), |
| 491 | INGENIC_PIN_GROUP("mmc1-4bit-d", jz4760_mmc1_4bit_d), |
| 492 | INGENIC_PIN_GROUP("mmc1-1bit-e", jz4760_mmc1_1bit_e), |
| 493 | INGENIC_PIN_GROUP("mmc1-4bit-e", jz4760_mmc1_4bit_e), |
| 494 | INGENIC_PIN_GROUP("mmc1-8bit-e", jz4760_mmc1_8bit_e), |
| 495 | INGENIC_PIN_GROUP("mmc2-1bit-b", jz4760_mmc2_1bit_b), |
| 496 | INGENIC_PIN_GROUP("mmc2-4bit-b", jz4760_mmc2_4bit_b), |
| 497 | INGENIC_PIN_GROUP("mmc2-1bit-e", jz4760_mmc2_1bit_e), |
| 498 | INGENIC_PIN_GROUP("mmc2-4bit-e", jz4760_mmc2_4bit_e), |
| 499 | INGENIC_PIN_GROUP("mmc2-8bit-e", jz4760_mmc2_8bit_e), |
| 500 | INGENIC_PIN_GROUP("nemc-8bit-data", jz4760_nemc_8bit_data), |
| 501 | INGENIC_PIN_GROUP("nemc-16bit-data", jz4760_nemc_16bit_data), |
| 502 | INGENIC_PIN_GROUP("nemc-cle-ale", jz4760_nemc_cle_ale), |
| 503 | INGENIC_PIN_GROUP("nemc-addr", jz4760_nemc_addr), |
| 504 | INGENIC_PIN_GROUP("nemc-rd-we", jz4760_nemc_rd_we), |
| 505 | INGENIC_PIN_GROUP("nemc-frd-fwe", jz4760_nemc_frd_fwe), |
| 506 | INGENIC_PIN_GROUP("nemc-wait", jz4760_nemc_wait), |
| 507 | INGENIC_PIN_GROUP("nemc-cs1", jz4760_nemc_cs1), |
| 508 | INGENIC_PIN_GROUP("nemc-cs2", jz4760_nemc_cs2), |
| 509 | INGENIC_PIN_GROUP("nemc-cs3", jz4760_nemc_cs3), |
| 510 | INGENIC_PIN_GROUP("nemc-cs4", jz4760_nemc_cs4), |
| 511 | INGENIC_PIN_GROUP("nemc-cs5", jz4760_nemc_cs5), |
| 512 | INGENIC_PIN_GROUP("nemc-cs6", jz4760_nemc_cs6), |
| 513 | INGENIC_PIN_GROUP("i2c0-data", jz4760_i2c0), |
| 514 | INGENIC_PIN_GROUP("i2c1-data", jz4760_i2c1), |
| 515 | INGENIC_PIN_GROUP("cim-data", jz4760_cim), |
| 516 | INGENIC_PIN_GROUP("lcd-24bit", jz4760_lcd_24bit), |
| 517 | { "lcd-no-pins", }, |
| 518 | INGENIC_PIN_GROUP("pwm0", jz4760_pwm_pwm0), |
| 519 | INGENIC_PIN_GROUP("pwm1", jz4760_pwm_pwm1), |
| 520 | INGENIC_PIN_GROUP("pwm2", jz4760_pwm_pwm2), |
| 521 | INGENIC_PIN_GROUP("pwm3", jz4760_pwm_pwm3), |
| 522 | INGENIC_PIN_GROUP("pwm4", jz4760_pwm_pwm4), |
| 523 | INGENIC_PIN_GROUP("pwm5", jz4760_pwm_pwm5), |
| 524 | INGENIC_PIN_GROUP("pwm6", jz4760_pwm_pwm6), |
| 525 | INGENIC_PIN_GROUP("pwm7", jz4760_pwm_pwm7), |
| 526 | }; |
| 527 | |
| 528 | static const char *jz4760_uart0_groups[] = { "uart0-data", "uart0-hwflow", }; |
| 529 | static const char *jz4760_uart1_groups[] = { "uart1-data", "uart1-hwflow", }; |
| 530 | static const char *jz4760_uart2_groups[] = { "uart2-data", "uart2-hwflow", }; |
| 531 | static const char *jz4760_uart3_groups[] = { "uart3-data", "uart3-hwflow", }; |
| 532 | static const char *jz4760_mmc0_groups[] = { |
| 533 | "mmc0-1bit-a", "mmc0-4bit-a", |
| 534 | "mmc0-1bit-e", "mmc0-4bit-e", "mmc0-8bit-e", |
| 535 | }; |
| 536 | static const char *jz4760_mmc1_groups[] = { |
| 537 | "mmc1-1bit-d", "mmc1-4bit-d", |
| 538 | "mmc1-1bit-e", "mmc1-4bit-e", "mmc1-8bit-e", |
| 539 | }; |
| 540 | static const char *jz4760_mmc2_groups[] = { |
| 541 | "mmc2-1bit-b", "mmc2-4bit-b", |
| 542 | "mmc2-1bit-e", "mmc2-4bit-e", "mmc2-8bit-e", |
| 543 | }; |
| 544 | static const char *jz4760_nemc_groups[] = { |
| 545 | "nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale", |
| 546 | "nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait", |
| 547 | }; |
| 548 | static const char *jz4760_cs1_groups[] = { "nemc-cs1", }; |
| 549 | static const char *jz4760_cs2_groups[] = { "nemc-cs2", }; |
| 550 | static const char *jz4760_cs3_groups[] = { "nemc-cs3", }; |
| 551 | static const char *jz4760_cs4_groups[] = { "nemc-cs4", }; |
| 552 | static const char *jz4760_cs5_groups[] = { "nemc-cs5", }; |
| 553 | static const char *jz4760_cs6_groups[] = { "nemc-cs6", }; |
| 554 | static const char *jz4760_i2c0_groups[] = { "i2c0-data", }; |
| 555 | static const char *jz4760_i2c1_groups[] = { "i2c1-data", }; |
| 556 | static const char *jz4760_cim_groups[] = { "cim-data", }; |
| 557 | static const char *jz4760_lcd_groups[] = { "lcd-24bit", "lcd-no-pins", }; |
| 558 | static const char *jz4760_pwm0_groups[] = { "pwm0", }; |
| 559 | static const char *jz4760_pwm1_groups[] = { "pwm1", }; |
| 560 | static const char *jz4760_pwm2_groups[] = { "pwm2", }; |
| 561 | static const char *jz4760_pwm3_groups[] = { "pwm3", }; |
| 562 | static const char *jz4760_pwm4_groups[] = { "pwm4", }; |
| 563 | static const char *jz4760_pwm5_groups[] = { "pwm5", }; |
| 564 | static const char *jz4760_pwm6_groups[] = { "pwm6", }; |
| 565 | static const char *jz4760_pwm7_groups[] = { "pwm7", }; |
| 566 | |
| 567 | static const struct function_desc jz4760_functions[] = { |
| 568 | { "uart0", jz4760_uart0_groups, ARRAY_SIZE(jz4760_uart0_groups), }, |
| 569 | { "uart1", jz4760_uart1_groups, ARRAY_SIZE(jz4760_uart1_groups), }, |
| 570 | { "uart2", jz4760_uart2_groups, ARRAY_SIZE(jz4760_uart2_groups), }, |
| 571 | { "uart3", jz4760_uart3_groups, ARRAY_SIZE(jz4760_uart3_groups), }, |
| 572 | { "mmc0", jz4760_mmc0_groups, ARRAY_SIZE(jz4760_mmc0_groups), }, |
| 573 | { "mmc1", jz4760_mmc1_groups, ARRAY_SIZE(jz4760_mmc1_groups), }, |
| 574 | { "mmc2", jz4760_mmc2_groups, ARRAY_SIZE(jz4760_mmc2_groups), }, |
| 575 | { "nemc", jz4760_nemc_groups, ARRAY_SIZE(jz4760_nemc_groups), }, |
| 576 | { "nemc-cs1", jz4760_cs1_groups, ARRAY_SIZE(jz4760_cs1_groups), }, |
| 577 | { "nemc-cs2", jz4760_cs2_groups, ARRAY_SIZE(jz4760_cs2_groups), }, |
| 578 | { "nemc-cs3", jz4760_cs3_groups, ARRAY_SIZE(jz4760_cs3_groups), }, |
| 579 | { "nemc-cs4", jz4760_cs4_groups, ARRAY_SIZE(jz4760_cs4_groups), }, |
| 580 | { "nemc-cs5", jz4760_cs5_groups, ARRAY_SIZE(jz4760_cs5_groups), }, |
| 581 | { "nemc-cs6", jz4760_cs6_groups, ARRAY_SIZE(jz4760_cs6_groups), }, |
| 582 | { "i2c0", jz4760_i2c0_groups, ARRAY_SIZE(jz4760_i2c0_groups), }, |
| 583 | { "i2c1", jz4760_i2c1_groups, ARRAY_SIZE(jz4760_i2c1_groups), }, |
| 584 | { "cim", jz4760_cim_groups, ARRAY_SIZE(jz4760_cim_groups), }, |
| 585 | { "lcd", jz4760_lcd_groups, ARRAY_SIZE(jz4760_lcd_groups), }, |
| 586 | { "pwm0", jz4760_pwm0_groups, ARRAY_SIZE(jz4760_pwm0_groups), }, |
| 587 | { "pwm1", jz4760_pwm1_groups, ARRAY_SIZE(jz4760_pwm1_groups), }, |
| 588 | { "pwm2", jz4760_pwm2_groups, ARRAY_SIZE(jz4760_pwm2_groups), }, |
| 589 | { "pwm3", jz4760_pwm3_groups, ARRAY_SIZE(jz4760_pwm3_groups), }, |
| 590 | { "pwm4", jz4760_pwm4_groups, ARRAY_SIZE(jz4760_pwm4_groups), }, |
| 591 | { "pwm5", jz4760_pwm5_groups, ARRAY_SIZE(jz4760_pwm5_groups), }, |
| 592 | { "pwm6", jz4760_pwm6_groups, ARRAY_SIZE(jz4760_pwm6_groups), }, |
| 593 | { "pwm7", jz4760_pwm7_groups, ARRAY_SIZE(jz4760_pwm7_groups), }, |
| 594 | }; |
| 595 | |
| 596 | static const struct ingenic_chip_info jz4760_chip_info = { |
| 597 | .num_chips = 6, |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 598 | .reg_offset = 0x100, |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 599 | .groups = jz4760_groups, |
| 600 | .num_groups = ARRAY_SIZE(jz4760_groups), |
| 601 | .functions = jz4760_functions, |
| 602 | .num_functions = ARRAY_SIZE(jz4760_functions), |
| 603 | .pull_ups = jz4760_pull_ups, |
| 604 | .pull_downs = jz4760_pull_downs, |
| 605 | }; |
| 606 | |
| 607 | static const struct ingenic_chip_info jz4760b_chip_info = { |
| 608 | .num_chips = 6, |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 609 | .reg_offset = 0x100, |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 610 | .groups = jz4760_groups, |
| 611 | .num_groups = ARRAY_SIZE(jz4760_groups), |
| 612 | .functions = jz4760_functions, |
| 613 | .num_functions = ARRAY_SIZE(jz4760_functions), |
| 614 | .pull_ups = jz4760_pull_ups, |
| 615 | .pull_downs = jz4760_pull_downs, |
| 616 | }; |
| 617 | |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 618 | static const u32 jz4770_pull_ups[6] = { |
| 619 | 0x3fffffff, 0xfff0030c, 0xffffffff, 0xffff4fff, 0xfffffb7c, 0xffa7f00f, |
| 620 | }; |
| 621 | |
| 622 | static const u32 jz4770_pull_downs[6] = { |
| 623 | 0x00000000, 0x000f0c03, 0x00000000, 0x0000b000, 0x00000483, 0x00580ff0, |
| 624 | }; |
| 625 | |
| 626 | static int jz4770_uart0_data_pins[] = { 0xa0, 0xa3, }; |
| 627 | static int jz4770_uart0_hwflow_pins[] = { 0xa1, 0xa2, }; |
| 628 | static int jz4770_uart1_data_pins[] = { 0x7a, 0x7c, }; |
| 629 | static int jz4770_uart1_hwflow_pins[] = { 0x7b, 0x7d, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 630 | static int jz4770_uart2_data_pins[] = { 0x5c, 0x5e, }; |
| 631 | static int jz4770_uart2_hwflow_pins[] = { 0x5d, 0x5f, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 632 | static int jz4770_uart3_data_pins[] = { 0x6c, 0x85, }; |
| 633 | static int jz4770_uart3_hwflow_pins[] = { 0x88, 0x89, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 634 | static int jz4770_mmc0_1bit_a_pins[] = { 0x12, 0x13, 0x14, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 635 | static int jz4770_mmc0_4bit_a_pins[] = { 0x15, 0x16, 0x17, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 636 | static int jz4770_mmc0_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 637 | static int jz4770_mmc0_4bit_e_pins[] = { 0x95, 0x96, 0x97, }; |
| 638 | static int jz4770_mmc0_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 639 | static int jz4770_mmc1_1bit_d_pins[] = { 0x78, 0x79, 0x74, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 640 | static int jz4770_mmc1_4bit_d_pins[] = { 0x75, 0x76, 0x77, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 641 | static int jz4770_mmc1_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 642 | static int jz4770_mmc1_4bit_e_pins[] = { 0x95, 0x96, 0x97, }; |
| 643 | static int jz4770_mmc1_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, }; |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 644 | static int jz4770_mmc2_1bit_b_pins[] = { 0x3c, 0x3d, 0x34, }; |
| 645 | static int jz4770_mmc2_4bit_b_pins[] = { 0x35, 0x3e, 0x3f, }; |
| 646 | static int jz4770_mmc2_1bit_e_pins[] = { 0x9c, 0x9d, 0x94, }; |
| 647 | static int jz4770_mmc2_4bit_e_pins[] = { 0x95, 0x96, 0x97, }; |
| 648 | static int jz4770_mmc2_8bit_e_pins[] = { 0x98, 0x99, 0x9a, 0x9b, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 649 | static int jz4770_nemc_8bit_data_pins[] = { |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 650 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 651 | }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 652 | static int jz4770_nemc_16bit_data_pins[] = { |
| 653 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 654 | }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 655 | static int jz4770_nemc_cle_ale_pins[] = { 0x20, 0x21, }; |
| 656 | static int jz4770_nemc_addr_pins[] = { 0x22, 0x23, 0x24, 0x25, }; |
| 657 | static int jz4770_nemc_rd_we_pins[] = { 0x10, 0x11, }; |
| 658 | static int jz4770_nemc_frd_fwe_pins[] = { 0x12, 0x13, }; |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 659 | static int jz4770_nemc_wait_pins[] = { 0x1b, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 660 | static int jz4770_nemc_cs1_pins[] = { 0x15, }; |
| 661 | static int jz4770_nemc_cs2_pins[] = { 0x16, }; |
| 662 | static int jz4770_nemc_cs3_pins[] = { 0x17, }; |
| 663 | static int jz4770_nemc_cs4_pins[] = { 0x18, }; |
| 664 | static int jz4770_nemc_cs5_pins[] = { 0x19, }; |
| 665 | static int jz4770_nemc_cs6_pins[] = { 0x1a, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 666 | static int jz4770_i2c0_pins[] = { 0x7e, 0x7f, }; |
| 667 | static int jz4770_i2c1_pins[] = { 0x9e, 0x9f, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 668 | static int jz4770_i2c2_pins[] = { 0xb0, 0xb1, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 669 | static int jz4770_cim_8bit_pins[] = { |
| 670 | 0x26, 0x27, 0x28, 0x29, |
| 671 | 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 672 | }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 673 | static int jz4770_cim_12bit_pins[] = { |
| 674 | 0x32, 0x33, 0xb0, 0xb1, |
| 675 | }; |
| 676 | static int jz4770_lcd_24bit_pins[] = { |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 677 | 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, |
| 678 | 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, |
| 679 | 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 680 | 0x58, 0x59, 0x5a, 0x5b, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 681 | }; |
| 682 | static int jz4770_pwm_pwm0_pins[] = { 0x80, }; |
| 683 | static int jz4770_pwm_pwm1_pins[] = { 0x81, }; |
| 684 | static int jz4770_pwm_pwm2_pins[] = { 0x82, }; |
| 685 | static int jz4770_pwm_pwm3_pins[] = { 0x83, }; |
| 686 | static int jz4770_pwm_pwm4_pins[] = { 0x84, }; |
| 687 | static int jz4770_pwm_pwm5_pins[] = { 0x85, }; |
| 688 | static int jz4770_pwm_pwm6_pins[] = { 0x6a, }; |
| 689 | static int jz4770_pwm_pwm7_pins[] = { 0x6b, }; |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 690 | static int jz4770_mac_rmii_pins[] = { |
| 691 | 0xa9, 0xab, 0xaa, 0xac, 0xa5, 0xa4, 0xad, 0xae, 0xa6, 0xa8, |
| 692 | }; |
| 693 | static int jz4770_mac_mii_pins[] = { 0xa7, 0xaf, }; |
Paul Cercueil | ae75b53 | 2019-11-19 16:52:11 +0100 | [diff] [blame] | 694 | static int jz4770_otg_pins[] = { 0x8a, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 695 | |
| 696 | static int jz4770_uart0_data_funcs[] = { 0, 0, }; |
| 697 | static int jz4770_uart0_hwflow_funcs[] = { 0, 0, }; |
| 698 | static int jz4770_uart1_data_funcs[] = { 0, 0, }; |
| 699 | static int jz4770_uart1_hwflow_funcs[] = { 0, 0, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 700 | static int jz4770_uart2_data_funcs[] = { 0, 0, }; |
| 701 | static int jz4770_uart2_hwflow_funcs[] = { 0, 0, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 702 | static int jz4770_uart3_data_funcs[] = { 0, 1, }; |
| 703 | static int jz4770_uart3_hwflow_funcs[] = { 0, 0, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 704 | static int jz4770_mmc0_1bit_a_funcs[] = { 1, 1, 0, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 705 | static int jz4770_mmc0_4bit_a_funcs[] = { 1, 1, 1, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 706 | static int jz4770_mmc0_1bit_e_funcs[] = { 0, 0, 0, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 707 | static int jz4770_mmc0_4bit_e_funcs[] = { 0, 0, 0, }; |
| 708 | static int jz4770_mmc0_8bit_e_funcs[] = { 0, 0, 0, 0, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 709 | static int jz4770_mmc1_1bit_d_funcs[] = { 0, 0, 0, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 710 | static int jz4770_mmc1_4bit_d_funcs[] = { 0, 0, 0, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 711 | static int jz4770_mmc1_1bit_e_funcs[] = { 1, 1, 1, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 712 | static int jz4770_mmc1_4bit_e_funcs[] = { 1, 1, 1, }; |
| 713 | static int jz4770_mmc1_8bit_e_funcs[] = { 1, 1, 1, 1, }; |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 714 | static int jz4770_mmc2_1bit_b_funcs[] = { 0, 0, 0, }; |
| 715 | static int jz4770_mmc2_4bit_b_funcs[] = { 0, 0, 0, }; |
| 716 | static int jz4770_mmc2_1bit_e_funcs[] = { 2, 2, 2, }; |
| 717 | static int jz4770_mmc2_4bit_e_funcs[] = { 2, 2, 2, }; |
| 718 | static int jz4770_mmc2_8bit_e_funcs[] = { 2, 2, 2, 2, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 719 | static int jz4770_nemc_8bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, }; |
| 720 | 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] | 721 | static int jz4770_nemc_cle_ale_funcs[] = { 0, 0, }; |
| 722 | static int jz4770_nemc_addr_funcs[] = { 0, 0, 0, 0, }; |
| 723 | static int jz4770_nemc_rd_we_funcs[] = { 0, 0, }; |
| 724 | static int jz4770_nemc_frd_fwe_funcs[] = { 0, 0, }; |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 725 | static int jz4770_nemc_wait_funcs[] = { 0, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 726 | static int jz4770_nemc_cs1_funcs[] = { 0, }; |
| 727 | static int jz4770_nemc_cs2_funcs[] = { 0, }; |
| 728 | static int jz4770_nemc_cs3_funcs[] = { 0, }; |
| 729 | static int jz4770_nemc_cs4_funcs[] = { 0, }; |
| 730 | static int jz4770_nemc_cs5_funcs[] = { 0, }; |
| 731 | static int jz4770_nemc_cs6_funcs[] = { 0, }; |
| 732 | static int jz4770_i2c0_funcs[] = { 0, 0, }; |
| 733 | static int jz4770_i2c1_funcs[] = { 0, 0, }; |
| 734 | static int jz4770_i2c2_funcs[] = { 2, 2, }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 735 | static int jz4770_cim_8bit_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; |
| 736 | static int jz4770_cim_12bit_funcs[] = { 0, 0, 0, 0, }; |
| 737 | static int jz4770_lcd_24bit_funcs[] = { |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 738 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 739 | 0, 0, 0, 0, 0, 0, 0, 0, |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 740 | 0, 0, 0, 0, 0, 0, 0, 0, |
| 741 | 0, 0, 0, 0, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 742 | }; |
| 743 | static int jz4770_pwm_pwm0_funcs[] = { 0, }; |
| 744 | static int jz4770_pwm_pwm1_funcs[] = { 0, }; |
| 745 | static int jz4770_pwm_pwm2_funcs[] = { 0, }; |
| 746 | static int jz4770_pwm_pwm3_funcs[] = { 0, }; |
| 747 | static int jz4770_pwm_pwm4_funcs[] = { 0, }; |
| 748 | static int jz4770_pwm_pwm5_funcs[] = { 0, }; |
| 749 | static int jz4770_pwm_pwm6_funcs[] = { 0, }; |
| 750 | static int jz4770_pwm_pwm7_funcs[] = { 0, }; |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 751 | static int jz4770_mac_rmii_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; |
| 752 | static int jz4770_mac_mii_funcs[] = { 0, 0, }; |
Paul Cercueil | ae75b53 | 2019-11-19 16:52:11 +0100 | [diff] [blame] | 753 | static int jz4770_otg_funcs[] = { 0, }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 754 | |
| 755 | static const struct group_desc jz4770_groups[] = { |
| 756 | INGENIC_PIN_GROUP("uart0-data", jz4770_uart0_data), |
| 757 | INGENIC_PIN_GROUP("uart0-hwflow", jz4770_uart0_hwflow), |
| 758 | INGENIC_PIN_GROUP("uart1-data", jz4770_uart1_data), |
| 759 | INGENIC_PIN_GROUP("uart1-hwflow", jz4770_uart1_hwflow), |
| 760 | INGENIC_PIN_GROUP("uart2-data", jz4770_uart2_data), |
| 761 | INGENIC_PIN_GROUP("uart2-hwflow", jz4770_uart2_hwflow), |
| 762 | INGENIC_PIN_GROUP("uart3-data", jz4770_uart3_data), |
| 763 | INGENIC_PIN_GROUP("uart3-hwflow", jz4770_uart3_hwflow), |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 764 | INGENIC_PIN_GROUP("mmc0-1bit-a", jz4770_mmc0_1bit_a), |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 765 | INGENIC_PIN_GROUP("mmc0-4bit-a", jz4770_mmc0_4bit_a), |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 766 | INGENIC_PIN_GROUP("mmc0-1bit-e", jz4770_mmc0_1bit_e), |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 767 | INGENIC_PIN_GROUP("mmc0-4bit-e", jz4770_mmc0_4bit_e), |
| 768 | INGENIC_PIN_GROUP("mmc0-8bit-e", jz4770_mmc0_8bit_e), |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 769 | INGENIC_PIN_GROUP("mmc1-1bit-d", jz4770_mmc1_1bit_d), |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 770 | INGENIC_PIN_GROUP("mmc1-4bit-d", jz4770_mmc1_4bit_d), |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 771 | INGENIC_PIN_GROUP("mmc1-1bit-e", jz4770_mmc1_1bit_e), |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 772 | INGENIC_PIN_GROUP("mmc1-4bit-e", jz4770_mmc1_4bit_e), |
| 773 | INGENIC_PIN_GROUP("mmc1-8bit-e", jz4770_mmc1_8bit_e), |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 774 | INGENIC_PIN_GROUP("mmc2-1bit-b", jz4770_mmc2_1bit_b), |
| 775 | INGENIC_PIN_GROUP("mmc2-4bit-b", jz4770_mmc2_4bit_b), |
| 776 | INGENIC_PIN_GROUP("mmc2-1bit-e", jz4770_mmc2_1bit_e), |
| 777 | INGENIC_PIN_GROUP("mmc2-4bit-e", jz4770_mmc2_4bit_e), |
| 778 | INGENIC_PIN_GROUP("mmc2-8bit-e", jz4770_mmc2_8bit_e), |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 779 | INGENIC_PIN_GROUP("nemc-8bit-data", jz4770_nemc_8bit_data), |
| 780 | INGENIC_PIN_GROUP("nemc-16bit-data", jz4770_nemc_16bit_data), |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 781 | INGENIC_PIN_GROUP("nemc-cle-ale", jz4770_nemc_cle_ale), |
| 782 | INGENIC_PIN_GROUP("nemc-addr", jz4770_nemc_addr), |
| 783 | INGENIC_PIN_GROUP("nemc-rd-we", jz4770_nemc_rd_we), |
| 784 | INGENIC_PIN_GROUP("nemc-frd-fwe", jz4770_nemc_frd_fwe), |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 785 | INGENIC_PIN_GROUP("nemc-wait", jz4770_nemc_wait), |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 786 | INGENIC_PIN_GROUP("nemc-cs1", jz4770_nemc_cs1), |
| 787 | INGENIC_PIN_GROUP("nemc-cs2", jz4770_nemc_cs2), |
| 788 | INGENIC_PIN_GROUP("nemc-cs3", jz4770_nemc_cs3), |
| 789 | INGENIC_PIN_GROUP("nemc-cs4", jz4770_nemc_cs4), |
| 790 | INGENIC_PIN_GROUP("nemc-cs5", jz4770_nemc_cs5), |
| 791 | INGENIC_PIN_GROUP("nemc-cs6", jz4770_nemc_cs6), |
| 792 | INGENIC_PIN_GROUP("i2c0-data", jz4770_i2c0), |
| 793 | INGENIC_PIN_GROUP("i2c1-data", jz4770_i2c1), |
| 794 | INGENIC_PIN_GROUP("i2c2-data", jz4770_i2c2), |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 795 | INGENIC_PIN_GROUP("cim-data-8bit", jz4770_cim_8bit), |
| 796 | INGENIC_PIN_GROUP("cim-data-12bit", jz4770_cim_12bit), |
| 797 | INGENIC_PIN_GROUP("lcd-24bit", jz4770_lcd_24bit), |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 798 | { "lcd-no-pins", }, |
| 799 | INGENIC_PIN_GROUP("pwm0", jz4770_pwm_pwm0), |
| 800 | INGENIC_PIN_GROUP("pwm1", jz4770_pwm_pwm1), |
| 801 | INGENIC_PIN_GROUP("pwm2", jz4770_pwm_pwm2), |
| 802 | INGENIC_PIN_GROUP("pwm3", jz4770_pwm_pwm3), |
| 803 | INGENIC_PIN_GROUP("pwm4", jz4770_pwm_pwm4), |
| 804 | INGENIC_PIN_GROUP("pwm5", jz4770_pwm_pwm5), |
| 805 | INGENIC_PIN_GROUP("pwm6", jz4770_pwm_pwm6), |
| 806 | INGENIC_PIN_GROUP("pwm7", jz4770_pwm_pwm7), |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 807 | INGENIC_PIN_GROUP("mac-rmii", jz4770_mac_rmii), |
| 808 | INGENIC_PIN_GROUP("mac-mii", jz4770_mac_mii), |
Paul Cercueil | ae75b53 | 2019-11-19 16:52:11 +0100 | [diff] [blame] | 809 | INGENIC_PIN_GROUP("otg-vbus", jz4770_otg), |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 810 | }; |
| 811 | |
| 812 | static const char *jz4770_uart0_groups[] = { "uart0-data", "uart0-hwflow", }; |
| 813 | static const char *jz4770_uart1_groups[] = { "uart1-data", "uart1-hwflow", }; |
| 814 | static const char *jz4770_uart2_groups[] = { "uart2-data", "uart2-hwflow", }; |
| 815 | static const char *jz4770_uart3_groups[] = { "uart3-data", "uart3-hwflow", }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 816 | static const char *jz4770_mmc0_groups[] = { |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 817 | "mmc0-1bit-a", "mmc0-4bit-a", |
| 818 | "mmc0-1bit-e", "mmc0-4bit-e", "mmc0-8bit-e", |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 819 | }; |
| 820 | static const char *jz4770_mmc1_groups[] = { |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 821 | "mmc1-1bit-d", "mmc1-4bit-d", |
| 822 | "mmc1-1bit-e", "mmc1-4bit-e", "mmc1-8bit-e", |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 823 | }; |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 824 | static const char *jz4770_mmc2_groups[] = { |
| 825 | "mmc2-1bit-b", "mmc2-4bit-b", |
| 826 | "mmc2-1bit-e", "mmc2-4bit-e", "mmc2-8bit-e", |
| 827 | }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 828 | static const char *jz4770_nemc_groups[] = { |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 829 | "nemc-8bit-data", "nemc-16bit-data", "nemc-cle-ale", |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 830 | "nemc-addr", "nemc-rd-we", "nemc-frd-fwe", "nemc-wait", |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 831 | }; |
| 832 | static const char *jz4770_cs1_groups[] = { "nemc-cs1", }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 833 | static const char *jz4770_cs2_groups[] = { "nemc-cs2", }; |
| 834 | static const char *jz4770_cs3_groups[] = { "nemc-cs3", }; |
| 835 | static const char *jz4770_cs4_groups[] = { "nemc-cs4", }; |
| 836 | static const char *jz4770_cs5_groups[] = { "nemc-cs5", }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 837 | static const char *jz4770_cs6_groups[] = { "nemc-cs6", }; |
| 838 | static const char *jz4770_i2c0_groups[] = { "i2c0-data", }; |
| 839 | static const char *jz4770_i2c1_groups[] = { "i2c1-data", }; |
| 840 | static const char *jz4770_i2c2_groups[] = { "i2c2-data", }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 841 | static const char *jz4770_cim_groups[] = { "cim-data-8bit", "cim-data-12bit", }; |
| 842 | static const char *jz4770_lcd_groups[] = { "lcd-24bit", "lcd-no-pins", }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 843 | static const char *jz4770_pwm0_groups[] = { "pwm0", }; |
| 844 | static const char *jz4770_pwm1_groups[] = { "pwm1", }; |
| 845 | static const char *jz4770_pwm2_groups[] = { "pwm2", }; |
| 846 | static const char *jz4770_pwm3_groups[] = { "pwm3", }; |
| 847 | static const char *jz4770_pwm4_groups[] = { "pwm4", }; |
| 848 | static const char *jz4770_pwm5_groups[] = { "pwm5", }; |
| 849 | static const char *jz4770_pwm6_groups[] = { "pwm6", }; |
| 850 | static const char *jz4770_pwm7_groups[] = { "pwm7", }; |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 851 | static const char *jz4770_mac_groups[] = { "mac-rmii", "mac-mii", }; |
Paul Cercueil | ae75b53 | 2019-11-19 16:52:11 +0100 | [diff] [blame] | 852 | static const char *jz4770_otg_groups[] = { "otg-vbus", }; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 853 | |
| 854 | static const struct function_desc jz4770_functions[] = { |
| 855 | { "uart0", jz4770_uart0_groups, ARRAY_SIZE(jz4770_uart0_groups), }, |
| 856 | { "uart1", jz4770_uart1_groups, ARRAY_SIZE(jz4770_uart1_groups), }, |
| 857 | { "uart2", jz4770_uart2_groups, ARRAY_SIZE(jz4770_uart2_groups), }, |
| 858 | { "uart3", jz4770_uart3_groups, ARRAY_SIZE(jz4770_uart3_groups), }, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 859 | { "mmc0", jz4770_mmc0_groups, ARRAY_SIZE(jz4770_mmc0_groups), }, |
| 860 | { "mmc1", jz4770_mmc1_groups, ARRAY_SIZE(jz4770_mmc1_groups), }, |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 861 | { "mmc2", jz4770_mmc2_groups, ARRAY_SIZE(jz4770_mmc2_groups), }, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 862 | { "nemc", jz4770_nemc_groups, ARRAY_SIZE(jz4770_nemc_groups), }, |
| 863 | { "nemc-cs1", jz4770_cs1_groups, ARRAY_SIZE(jz4770_cs1_groups), }, |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 864 | { "nemc-cs2", jz4770_cs2_groups, ARRAY_SIZE(jz4770_cs2_groups), }, |
| 865 | { "nemc-cs3", jz4770_cs3_groups, ARRAY_SIZE(jz4770_cs3_groups), }, |
| 866 | { "nemc-cs4", jz4770_cs4_groups, ARRAY_SIZE(jz4770_cs4_groups), }, |
| 867 | { "nemc-cs5", jz4770_cs5_groups, ARRAY_SIZE(jz4770_cs5_groups), }, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 868 | { "nemc-cs6", jz4770_cs6_groups, ARRAY_SIZE(jz4770_cs6_groups), }, |
| 869 | { "i2c0", jz4770_i2c0_groups, ARRAY_SIZE(jz4770_i2c0_groups), }, |
| 870 | { "i2c1", jz4770_i2c1_groups, ARRAY_SIZE(jz4770_i2c1_groups), }, |
| 871 | { "i2c2", jz4770_i2c2_groups, ARRAY_SIZE(jz4770_i2c2_groups), }, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 872 | { "cim", jz4770_cim_groups, ARRAY_SIZE(jz4770_cim_groups), }, |
| 873 | { "lcd", jz4770_lcd_groups, ARRAY_SIZE(jz4770_lcd_groups), }, |
| 874 | { "pwm0", jz4770_pwm0_groups, ARRAY_SIZE(jz4770_pwm0_groups), }, |
| 875 | { "pwm1", jz4770_pwm1_groups, ARRAY_SIZE(jz4770_pwm1_groups), }, |
| 876 | { "pwm2", jz4770_pwm2_groups, ARRAY_SIZE(jz4770_pwm2_groups), }, |
| 877 | { "pwm3", jz4770_pwm3_groups, ARRAY_SIZE(jz4770_pwm3_groups), }, |
| 878 | { "pwm4", jz4770_pwm4_groups, ARRAY_SIZE(jz4770_pwm4_groups), }, |
| 879 | { "pwm5", jz4770_pwm5_groups, ARRAY_SIZE(jz4770_pwm5_groups), }, |
| 880 | { "pwm6", jz4770_pwm6_groups, ARRAY_SIZE(jz4770_pwm6_groups), }, |
| 881 | { "pwm7", jz4770_pwm7_groups, ARRAY_SIZE(jz4770_pwm7_groups), }, |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 882 | { "mac", jz4770_mac_groups, ARRAY_SIZE(jz4770_mac_groups), }, |
Paul Cercueil | ae75b53 | 2019-11-19 16:52:11 +0100 | [diff] [blame] | 883 | { "otg", jz4770_otg_groups, ARRAY_SIZE(jz4770_otg_groups), }, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 884 | }; |
| 885 | |
| 886 | static const struct ingenic_chip_info jz4770_chip_info = { |
| 887 | .num_chips = 6, |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 888 | .reg_offset = 0x100, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 889 | .groups = jz4770_groups, |
| 890 | .num_groups = ARRAY_SIZE(jz4770_groups), |
| 891 | .functions = jz4770_functions, |
| 892 | .num_functions = ARRAY_SIZE(jz4770_functions), |
| 893 | .pull_ups = jz4770_pull_ups, |
| 894 | .pull_downs = jz4770_pull_downs, |
| 895 | }; |
| 896 | |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 897 | static int jz4780_uart2_data_pins[] = { 0x66, 0x67, }; |
| 898 | static int jz4780_uart2_hwflow_pins[] = { 0x65, 0x64, }; |
| 899 | static int jz4780_uart4_data_pins[] = { 0x54, 0x4a, }; |
| 900 | static int jz4780_mmc0_8bit_a_pins[] = { 0x04, 0x05, 0x06, 0x07, 0x18, }; |
| 901 | static int jz4780_i2c3_pins[] = { 0x6a, 0x6b, }; |
| 902 | static int jz4780_i2c4_e_pins[] = { 0x8c, 0x8d, }; |
| 903 | static int jz4780_i2c4_f_pins[] = { 0xb9, 0xb8, }; |
| 904 | |
| 905 | static int jz4780_uart2_data_funcs[] = { 1, 1, }; |
| 906 | static int jz4780_uart2_hwflow_funcs[] = { 1, 1, }; |
| 907 | static int jz4780_uart4_data_funcs[] = { 2, 2, }; |
| 908 | static int jz4780_mmc0_8bit_a_funcs[] = { 1, 1, 1, 1, 1, }; |
| 909 | static int jz4780_i2c3_funcs[] = { 1, 1, }; |
| 910 | static int jz4780_i2c4_e_funcs[] = { 1, 1, }; |
| 911 | static int jz4780_i2c4_f_funcs[] = { 1, 1, }; |
| 912 | |
| 913 | static const struct group_desc jz4780_groups[] = { |
| 914 | INGENIC_PIN_GROUP("uart0-data", jz4770_uart0_data), |
| 915 | INGENIC_PIN_GROUP("uart0-hwflow", jz4770_uart0_hwflow), |
| 916 | INGENIC_PIN_GROUP("uart1-data", jz4770_uart1_data), |
| 917 | INGENIC_PIN_GROUP("uart1-hwflow", jz4770_uart1_hwflow), |
| 918 | INGENIC_PIN_GROUP("uart2-data", jz4780_uart2_data), |
| 919 | INGENIC_PIN_GROUP("uart2-hwflow", jz4780_uart2_hwflow), |
| 920 | INGENIC_PIN_GROUP("uart3-data", jz4770_uart3_data), |
| 921 | INGENIC_PIN_GROUP("uart3-hwflow", jz4770_uart3_hwflow), |
| 922 | INGENIC_PIN_GROUP("uart4-data", jz4780_uart4_data), |
| 923 | INGENIC_PIN_GROUP("mmc0-1bit-a", jz4770_mmc0_1bit_a), |
| 924 | INGENIC_PIN_GROUP("mmc0-4bit-a", jz4770_mmc0_4bit_a), |
| 925 | INGENIC_PIN_GROUP("mmc0-8bit-a", jz4780_mmc0_8bit_a), |
| 926 | INGENIC_PIN_GROUP("mmc0-1bit-e", jz4770_mmc0_1bit_e), |
| 927 | INGENIC_PIN_GROUP("mmc0-4bit-e", jz4770_mmc0_4bit_e), |
| 928 | INGENIC_PIN_GROUP("mmc1-1bit-d", jz4770_mmc1_1bit_d), |
| 929 | INGENIC_PIN_GROUP("mmc1-4bit-d", jz4770_mmc1_4bit_d), |
| 930 | INGENIC_PIN_GROUP("mmc1-1bit-e", jz4770_mmc1_1bit_e), |
| 931 | INGENIC_PIN_GROUP("mmc1-4bit-e", jz4770_mmc1_4bit_e), |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 932 | INGENIC_PIN_GROUP("mmc2-1bit-b", jz4770_mmc2_1bit_b), |
| 933 | INGENIC_PIN_GROUP("mmc2-4bit-b", jz4770_mmc2_4bit_b), |
| 934 | INGENIC_PIN_GROUP("mmc2-1bit-e", jz4770_mmc2_1bit_e), |
| 935 | INGENIC_PIN_GROUP("mmc2-4bit-e", jz4770_mmc2_4bit_e), |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 936 | INGENIC_PIN_GROUP("nemc-data", jz4770_nemc_8bit_data), |
| 937 | INGENIC_PIN_GROUP("nemc-cle-ale", jz4770_nemc_cle_ale), |
| 938 | INGENIC_PIN_GROUP("nemc-addr", jz4770_nemc_addr), |
| 939 | INGENIC_PIN_GROUP("nemc-rd-we", jz4770_nemc_rd_we), |
| 940 | INGENIC_PIN_GROUP("nemc-frd-fwe", jz4770_nemc_frd_fwe), |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 941 | INGENIC_PIN_GROUP("nemc-wait", jz4770_nemc_wait), |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 942 | INGENIC_PIN_GROUP("nemc-cs1", jz4770_nemc_cs1), |
| 943 | INGENIC_PIN_GROUP("nemc-cs2", jz4770_nemc_cs2), |
| 944 | INGENIC_PIN_GROUP("nemc-cs3", jz4770_nemc_cs3), |
| 945 | INGENIC_PIN_GROUP("nemc-cs4", jz4770_nemc_cs4), |
| 946 | INGENIC_PIN_GROUP("nemc-cs5", jz4770_nemc_cs5), |
| 947 | INGENIC_PIN_GROUP("nemc-cs6", jz4770_nemc_cs6), |
| 948 | INGENIC_PIN_GROUP("i2c0-data", jz4770_i2c0), |
| 949 | INGENIC_PIN_GROUP("i2c1-data", jz4770_i2c1), |
| 950 | INGENIC_PIN_GROUP("i2c2-data", jz4770_i2c2), |
| 951 | INGENIC_PIN_GROUP("i2c3-data", jz4780_i2c3), |
| 952 | INGENIC_PIN_GROUP("i2c4-data-e", jz4780_i2c4_e), |
| 953 | INGENIC_PIN_GROUP("i2c4-data-f", jz4780_i2c4_f), |
| 954 | INGENIC_PIN_GROUP("cim-data", jz4770_cim_8bit), |
| 955 | INGENIC_PIN_GROUP("lcd-24bit", jz4770_lcd_24bit), |
| 956 | { "lcd-no-pins", }, |
| 957 | INGENIC_PIN_GROUP("pwm0", jz4770_pwm_pwm0), |
| 958 | INGENIC_PIN_GROUP("pwm1", jz4770_pwm_pwm1), |
| 959 | INGENIC_PIN_GROUP("pwm2", jz4770_pwm_pwm2), |
| 960 | INGENIC_PIN_GROUP("pwm3", jz4770_pwm_pwm3), |
| 961 | INGENIC_PIN_GROUP("pwm4", jz4770_pwm_pwm4), |
| 962 | INGENIC_PIN_GROUP("pwm5", jz4770_pwm_pwm5), |
| 963 | INGENIC_PIN_GROUP("pwm6", jz4770_pwm_pwm6), |
| 964 | INGENIC_PIN_GROUP("pwm7", jz4770_pwm_pwm7), |
| 965 | }; |
| 966 | |
| 967 | static const char *jz4780_uart2_groups[] = { "uart2-data", "uart2-hwflow", }; |
| 968 | static const char *jz4780_uart4_groups[] = { "uart4-data", }; |
| 969 | static const char *jz4780_mmc0_groups[] = { |
| 970 | "mmc0-1bit-a", "mmc0-4bit-a", "mmc0-8bit-a", |
| 971 | "mmc0-1bit-e", "mmc0-4bit-e", |
| 972 | }; |
| 973 | static const char *jz4780_mmc1_groups[] = { |
| 974 | "mmc1-1bit-d", "mmc1-4bit-d", "mmc1-1bit-e", "mmc1-4bit-e", |
| 975 | }; |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 976 | static const char *jz4780_mmc2_groups[] = { |
| 977 | "mmc2-1bit-b", "mmc2-4bit-b", "mmc2-1bit-e", "mmc2-4bit-e", |
| 978 | }; |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 979 | static const char *jz4780_nemc_groups[] = { |
| 980 | "nemc-data", "nemc-cle-ale", "nemc-addr", |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 981 | "nemc-rd-we", "nemc-frd-fwe", "nemc-wait", |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 982 | }; |
| 983 | static const char *jz4780_i2c3_groups[] = { "i2c3-data", }; |
| 984 | static const char *jz4780_i2c4_groups[] = { "i2c4-data-e", "i2c4-data-f", }; |
| 985 | static const char *jz4780_cim_groups[] = { "cim-data", }; |
| 986 | |
| 987 | static const struct function_desc jz4780_functions[] = { |
| 988 | { "uart0", jz4770_uart0_groups, ARRAY_SIZE(jz4770_uart0_groups), }, |
| 989 | { "uart1", jz4770_uart1_groups, ARRAY_SIZE(jz4770_uart1_groups), }, |
| 990 | { "uart2", jz4780_uart2_groups, ARRAY_SIZE(jz4780_uart2_groups), }, |
| 991 | { "uart3", jz4770_uart3_groups, ARRAY_SIZE(jz4770_uart3_groups), }, |
| 992 | { "uart4", jz4780_uart4_groups, ARRAY_SIZE(jz4780_uart4_groups), }, |
| 993 | { "mmc0", jz4780_mmc0_groups, ARRAY_SIZE(jz4780_mmc0_groups), }, |
| 994 | { "mmc1", jz4780_mmc1_groups, ARRAY_SIZE(jz4780_mmc1_groups), }, |
Zhou Yanjie | 5de1a73 | 2019-01-28 23:19:58 +0800 | [diff] [blame] | 995 | { "mmc2", jz4780_mmc2_groups, ARRAY_SIZE(jz4780_mmc2_groups), }, |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 996 | { "nemc", jz4780_nemc_groups, ARRAY_SIZE(jz4780_nemc_groups), }, |
| 997 | { "nemc-cs1", jz4770_cs1_groups, ARRAY_SIZE(jz4770_cs1_groups), }, |
| 998 | { "nemc-cs2", jz4770_cs2_groups, ARRAY_SIZE(jz4770_cs2_groups), }, |
| 999 | { "nemc-cs3", jz4770_cs3_groups, ARRAY_SIZE(jz4770_cs3_groups), }, |
| 1000 | { "nemc-cs4", jz4770_cs4_groups, ARRAY_SIZE(jz4770_cs4_groups), }, |
| 1001 | { "nemc-cs5", jz4770_cs5_groups, ARRAY_SIZE(jz4770_cs5_groups), }, |
| 1002 | { "nemc-cs6", jz4770_cs6_groups, ARRAY_SIZE(jz4770_cs6_groups), }, |
| 1003 | { "i2c0", jz4770_i2c0_groups, ARRAY_SIZE(jz4770_i2c0_groups), }, |
| 1004 | { "i2c1", jz4770_i2c1_groups, ARRAY_SIZE(jz4770_i2c1_groups), }, |
| 1005 | { "i2c2", jz4770_i2c2_groups, ARRAY_SIZE(jz4770_i2c2_groups), }, |
| 1006 | { "i2c3", jz4780_i2c3_groups, ARRAY_SIZE(jz4780_i2c3_groups), }, |
| 1007 | { "i2c4", jz4780_i2c4_groups, ARRAY_SIZE(jz4780_i2c4_groups), }, |
| 1008 | { "cim", jz4780_cim_groups, ARRAY_SIZE(jz4780_cim_groups), }, |
| 1009 | { "lcd", jz4770_lcd_groups, ARRAY_SIZE(jz4770_lcd_groups), }, |
| 1010 | { "pwm0", jz4770_pwm0_groups, ARRAY_SIZE(jz4770_pwm0_groups), }, |
| 1011 | { "pwm1", jz4770_pwm1_groups, ARRAY_SIZE(jz4770_pwm1_groups), }, |
| 1012 | { "pwm2", jz4770_pwm2_groups, ARRAY_SIZE(jz4770_pwm2_groups), }, |
| 1013 | { "pwm3", jz4770_pwm3_groups, ARRAY_SIZE(jz4770_pwm3_groups), }, |
| 1014 | { "pwm4", jz4770_pwm4_groups, ARRAY_SIZE(jz4770_pwm4_groups), }, |
| 1015 | { "pwm5", jz4770_pwm5_groups, ARRAY_SIZE(jz4770_pwm5_groups), }, |
| 1016 | { "pwm6", jz4770_pwm6_groups, ARRAY_SIZE(jz4770_pwm6_groups), }, |
| 1017 | { "pwm7", jz4770_pwm7_groups, ARRAY_SIZE(jz4770_pwm7_groups), }, |
| 1018 | }; |
| 1019 | |
| 1020 | static const struct ingenic_chip_info jz4780_chip_info = { |
| 1021 | .num_chips = 6, |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 1022 | .reg_offset = 0x100, |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 1023 | .groups = jz4780_groups, |
| 1024 | .num_groups = ARRAY_SIZE(jz4780_groups), |
| 1025 | .functions = jz4780_functions, |
| 1026 | .num_functions = ARRAY_SIZE(jz4780_functions), |
| 1027 | .pull_ups = jz4770_pull_ups, |
| 1028 | .pull_downs = jz4770_pull_downs, |
| 1029 | }; |
| 1030 | |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1031 | static const u32 x1000_pull_ups[4] = { |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1032 | 0xffffffff, 0xfdffffff, 0x0dffffff, 0x0000003f, |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1033 | }; |
| 1034 | |
| 1035 | static const u32 x1000_pull_downs[4] = { |
| 1036 | 0x00000000, 0x02000000, 0x02000000, 0x00000000, |
| 1037 | }; |
| 1038 | |
| 1039 | static int x1000_uart0_data_pins[] = { 0x4a, 0x4b, }; |
| 1040 | static int x1000_uart0_hwflow_pins[] = { 0x4c, 0x4d, }; |
| 1041 | static int x1000_uart1_data_a_pins[] = { 0x04, 0x05, }; |
| 1042 | static int x1000_uart1_data_d_pins[] = { 0x62, 0x63, }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1043 | static int x1000_uart1_hwflow_pins[] = { 0x64, 0x65, }; |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1044 | static int x1000_uart2_data_a_pins[] = { 0x02, 0x03, }; |
| 1045 | static int x1000_uart2_data_d_pins[] = { 0x65, 0x64, }; |
周琰杰 (Zhou Yanjie) | 3b31e9b | 2019-12-16 00:21:01 +0800 | [diff] [blame] | 1046 | static int x1000_sfc_pins[] = { 0x1d, 0x1c, 0x1e, 0x1f, 0x1a, 0x1b, }; |
| 1047 | static int x1000_ssi_dt_a_22_pins[] = { 0x16, }; |
| 1048 | static int x1000_ssi_dt_a_29_pins[] = { 0x1d, }; |
| 1049 | static int x1000_ssi_dt_d_pins[] = { 0x62, }; |
| 1050 | static int x1000_ssi_dr_a_23_pins[] = { 0x17, }; |
| 1051 | static int x1000_ssi_dr_a_28_pins[] = { 0x1c, }; |
| 1052 | static int x1000_ssi_dr_d_pins[] = { 0x63, }; |
| 1053 | static int x1000_ssi_clk_a_24_pins[] = { 0x18, }; |
| 1054 | static int x1000_ssi_clk_a_26_pins[] = { 0x1a, }; |
| 1055 | static int x1000_ssi_clk_d_pins[] = { 0x60, }; |
| 1056 | static int x1000_ssi_gpc_a_20_pins[] = { 0x14, }; |
| 1057 | static int x1000_ssi_gpc_a_31_pins[] = { 0x1f, }; |
| 1058 | static int x1000_ssi_ce0_a_25_pins[] = { 0x19, }; |
| 1059 | static int x1000_ssi_ce0_a_27_pins[] = { 0x1b, }; |
| 1060 | static int x1000_ssi_ce0_d_pins[] = { 0x61, }; |
| 1061 | static int x1000_ssi_ce1_a_21_pins[] = { 0x15, }; |
| 1062 | static int x1000_ssi_ce1_a_30_pins[] = { 0x1e, }; |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1063 | static int x1000_mmc0_1bit_pins[] = { 0x18, 0x19, 0x17, }; |
| 1064 | static int x1000_mmc0_4bit_pins[] = { 0x16, 0x15, 0x14, }; |
| 1065 | static int x1000_mmc0_8bit_pins[] = { 0x13, 0x12, 0x11, 0x10, }; |
| 1066 | static int x1000_mmc1_1bit_pins[] = { 0x40, 0x41, 0x42, }; |
| 1067 | static int x1000_mmc1_4bit_pins[] = { 0x43, 0x44, 0x45, }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1068 | static int x1000_emc_8bit_data_pins[] = { |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1069 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 1070 | }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1071 | static int x1000_emc_16bit_data_pins[] = { |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1072 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 1073 | }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1074 | static int x1000_emc_addr_pins[] = { |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1075 | 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, |
| 1076 | 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, |
| 1077 | }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1078 | static int x1000_emc_rd_we_pins[] = { 0x30, 0x31, }; |
| 1079 | static int x1000_emc_wait_pins[] = { 0x34, }; |
| 1080 | static int x1000_emc_cs1_pins[] = { 0x32, }; |
| 1081 | static int x1000_emc_cs2_pins[] = { 0x33, }; |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1082 | static int x1000_i2c0_pins[] = { 0x38, 0x37, }; |
| 1083 | static int x1000_i2c1_a_pins[] = { 0x01, 0x00, }; |
| 1084 | static int x1000_i2c1_c_pins[] = { 0x5b, 0x5a, }; |
| 1085 | static int x1000_i2c2_pins[] = { 0x61, 0x60, }; |
| 1086 | static int x1000_cim_pins[] = { |
| 1087 | 0x08, 0x09, 0x0a, 0x0b, |
| 1088 | 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c, |
| 1089 | }; |
| 1090 | static int x1000_lcd_8bit_pins[] = { |
| 1091 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 1092 | 0x30, 0x31, 0x32, 0x33, 0x34, |
| 1093 | }; |
| 1094 | static int x1000_lcd_16bit_pins[] = { |
| 1095 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 1096 | }; |
| 1097 | static int x1000_pwm_pwm0_pins[] = { 0x59, }; |
| 1098 | static int x1000_pwm_pwm1_pins[] = { 0x5a, }; |
| 1099 | static int x1000_pwm_pwm2_pins[] = { 0x5b, }; |
| 1100 | static int x1000_pwm_pwm3_pins[] = { 0x26, }; |
| 1101 | static int x1000_pwm_pwm4_pins[] = { 0x58, }; |
| 1102 | static int x1000_mac_pins[] = { |
| 1103 | 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x26, |
| 1104 | }; |
| 1105 | |
| 1106 | static int x1000_uart0_data_funcs[] = { 0, 0, }; |
| 1107 | static int x1000_uart0_hwflow_funcs[] = { 0, 0, }; |
| 1108 | static int x1000_uart1_data_a_funcs[] = { 2, 2, }; |
| 1109 | static int x1000_uart1_data_d_funcs[] = { 1, 1, }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1110 | static int x1000_uart1_hwflow_funcs[] = { 1, 1, }; |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1111 | static int x1000_uart2_data_a_funcs[] = { 2, 2, }; |
| 1112 | static int x1000_uart2_data_d_funcs[] = { 0, 0, }; |
周琰杰 (Zhou Yanjie) | 3b31e9b | 2019-12-16 00:21:01 +0800 | [diff] [blame] | 1113 | static int x1000_sfc_funcs[] = { 1, 1, 1, 1, 1, 1, }; |
| 1114 | static int x1000_ssi_dt_a_22_funcs[] = { 2, }; |
| 1115 | static int x1000_ssi_dt_a_29_funcs[] = { 2, }; |
| 1116 | static int x1000_ssi_dt_d_funcs[] = { 0, }; |
| 1117 | static int x1000_ssi_dr_a_23_funcs[] = { 2, }; |
| 1118 | static int x1000_ssi_dr_a_28_funcs[] = { 2, }; |
| 1119 | static int x1000_ssi_dr_d_funcs[] = { 0, }; |
| 1120 | static int x1000_ssi_clk_a_24_funcs[] = { 2, }; |
| 1121 | static int x1000_ssi_clk_a_26_funcs[] = { 2, }; |
| 1122 | static int x1000_ssi_clk_d_funcs[] = { 0, }; |
| 1123 | static int x1000_ssi_gpc_a_20_funcs[] = { 2, }; |
| 1124 | static int x1000_ssi_gpc_a_31_funcs[] = { 2, }; |
| 1125 | static int x1000_ssi_ce0_a_25_funcs[] = { 2, }; |
| 1126 | static int x1000_ssi_ce0_a_27_funcs[] = { 2, }; |
| 1127 | static int x1000_ssi_ce0_d_funcs[] = { 0, }; |
| 1128 | static int x1000_ssi_ce1_a_21_funcs[] = { 2, }; |
| 1129 | static int x1000_ssi_ce1_a_30_funcs[] = { 2, }; |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1130 | static int x1000_mmc0_1bit_funcs[] = { 1, 1, 1, }; |
| 1131 | static int x1000_mmc0_4bit_funcs[] = { 1, 1, 1, }; |
| 1132 | static int x1000_mmc0_8bit_funcs[] = { 1, 1, 1, 1, 1, }; |
| 1133 | static int x1000_mmc1_1bit_funcs[] = { 0, 0, 0, }; |
| 1134 | static int x1000_mmc1_4bit_funcs[] = { 0, 0, 0, }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1135 | static int x1000_emc_8bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, }; |
| 1136 | static int x1000_emc_16bit_data_funcs[] = { 0, 0, 0, 0, 0, 0, 0, 0, }; |
| 1137 | static int x1000_emc_addr_funcs[] = { |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1138 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1139 | }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1140 | static int x1000_emc_rd_we_funcs[] = { 0, 0, }; |
| 1141 | static int x1000_emc_wait_funcs[] = { 0, }; |
| 1142 | static int x1000_emc_cs1_funcs[] = { 0, }; |
| 1143 | static int x1000_emc_cs2_funcs[] = { 0, }; |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1144 | static int x1000_i2c0_funcs[] = { 0, 0, }; |
| 1145 | static int x1000_i2c1_a_funcs[] = { 2, 2, }; |
| 1146 | static int x1000_i2c1_c_funcs[] = { 0, 0, }; |
| 1147 | static int x1000_i2c2_funcs[] = { 1, 1, }; |
| 1148 | static int x1000_cim_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; |
| 1149 | static int x1000_lcd_8bit_funcs[] = { |
| 1150 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 1151 | }; |
| 1152 | static int x1000_lcd_16bit_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, }; |
| 1153 | static int x1000_pwm_pwm0_funcs[] = { 0, }; |
| 1154 | static int x1000_pwm_pwm1_funcs[] = { 1, }; |
| 1155 | static int x1000_pwm_pwm2_funcs[] = { 1, }; |
| 1156 | static int x1000_pwm_pwm3_funcs[] = { 2, }; |
| 1157 | static int x1000_pwm_pwm4_funcs[] = { 0, }; |
| 1158 | static int x1000_mac_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; |
| 1159 | |
| 1160 | static const struct group_desc x1000_groups[] = { |
| 1161 | INGENIC_PIN_GROUP("uart0-data", x1000_uart0_data), |
| 1162 | INGENIC_PIN_GROUP("uart0-hwflow", x1000_uart0_hwflow), |
| 1163 | INGENIC_PIN_GROUP("uart1-data-a", x1000_uart1_data_a), |
| 1164 | INGENIC_PIN_GROUP("uart1-data-d", x1000_uart1_data_d), |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1165 | INGENIC_PIN_GROUP("uart1-hwflow", x1000_uart1_hwflow), |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1166 | INGENIC_PIN_GROUP("uart2-data-a", x1000_uart2_data_a), |
| 1167 | INGENIC_PIN_GROUP("uart2-data-d", x1000_uart2_data_d), |
周琰杰 (Zhou Yanjie) | 3b31e9b | 2019-12-16 00:21:01 +0800 | [diff] [blame] | 1168 | INGENIC_PIN_GROUP("sfc", x1000_sfc), |
| 1169 | INGENIC_PIN_GROUP("ssi-dt-a-22", x1000_ssi_dt_a_22), |
| 1170 | INGENIC_PIN_GROUP("ssi-dt-a-29", x1000_ssi_dt_a_29), |
| 1171 | INGENIC_PIN_GROUP("ssi-dt-d", x1000_ssi_dt_d), |
| 1172 | INGENIC_PIN_GROUP("ssi-dr-a-23", x1000_ssi_dr_a_23), |
| 1173 | INGENIC_PIN_GROUP("ssi-dr-a-28", x1000_ssi_dr_a_28), |
| 1174 | INGENIC_PIN_GROUP("ssi-dr-d", x1000_ssi_dr_d), |
| 1175 | INGENIC_PIN_GROUP("ssi-clk-a-24", x1000_ssi_clk_a_24), |
| 1176 | INGENIC_PIN_GROUP("ssi-clk-a-26", x1000_ssi_clk_a_26), |
| 1177 | INGENIC_PIN_GROUP("ssi-clk-d", x1000_ssi_clk_d), |
| 1178 | INGENIC_PIN_GROUP("ssi-gpc-a-20", x1000_ssi_gpc_a_20), |
| 1179 | INGENIC_PIN_GROUP("ssi-gpc-a-31", x1000_ssi_gpc_a_31), |
| 1180 | INGENIC_PIN_GROUP("ssi-ce0-a-25", x1000_ssi_ce0_a_25), |
| 1181 | INGENIC_PIN_GROUP("ssi-ce0-a-27", x1000_ssi_ce0_a_27), |
| 1182 | INGENIC_PIN_GROUP("ssi-ce0-d", x1000_ssi_ce0_d), |
| 1183 | INGENIC_PIN_GROUP("ssi-ce1-a-21", x1000_ssi_ce1_a_21), |
| 1184 | INGENIC_PIN_GROUP("ssi-ce1-a-30", x1000_ssi_ce1_a_30), |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1185 | INGENIC_PIN_GROUP("mmc0-1bit", x1000_mmc0_1bit), |
| 1186 | INGENIC_PIN_GROUP("mmc0-4bit", x1000_mmc0_4bit), |
| 1187 | INGENIC_PIN_GROUP("mmc0-8bit", x1000_mmc0_8bit), |
| 1188 | INGENIC_PIN_GROUP("mmc1-1bit", x1000_mmc1_1bit), |
| 1189 | INGENIC_PIN_GROUP("mmc1-4bit", x1000_mmc1_4bit), |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1190 | INGENIC_PIN_GROUP("emc-8bit-data", x1000_emc_8bit_data), |
| 1191 | INGENIC_PIN_GROUP("emc-16bit-data", x1000_emc_16bit_data), |
| 1192 | INGENIC_PIN_GROUP("emc-addr", x1000_emc_addr), |
| 1193 | INGENIC_PIN_GROUP("emc-rd-we", x1000_emc_rd_we), |
| 1194 | INGENIC_PIN_GROUP("emc-wait", x1000_emc_wait), |
| 1195 | INGENIC_PIN_GROUP("emc-cs1", x1000_emc_cs1), |
| 1196 | INGENIC_PIN_GROUP("emc-cs2", x1000_emc_cs2), |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1197 | INGENIC_PIN_GROUP("i2c0-data", x1000_i2c0), |
| 1198 | INGENIC_PIN_GROUP("i2c1-data-a", x1000_i2c1_a), |
| 1199 | INGENIC_PIN_GROUP("i2c1-data-c", x1000_i2c1_c), |
| 1200 | INGENIC_PIN_GROUP("i2c2-data", x1000_i2c2), |
| 1201 | INGENIC_PIN_GROUP("cim-data", x1000_cim), |
| 1202 | INGENIC_PIN_GROUP("lcd-8bit", x1000_lcd_8bit), |
| 1203 | INGENIC_PIN_GROUP("lcd-16bit", x1000_lcd_16bit), |
| 1204 | { "lcd-no-pins", }, |
| 1205 | INGENIC_PIN_GROUP("pwm0", x1000_pwm_pwm0), |
| 1206 | INGENIC_PIN_GROUP("pwm1", x1000_pwm_pwm1), |
| 1207 | INGENIC_PIN_GROUP("pwm2", x1000_pwm_pwm2), |
| 1208 | INGENIC_PIN_GROUP("pwm3", x1000_pwm_pwm3), |
| 1209 | INGENIC_PIN_GROUP("pwm4", x1000_pwm_pwm4), |
| 1210 | INGENIC_PIN_GROUP("mac", x1000_mac), |
| 1211 | }; |
| 1212 | |
| 1213 | static const char *x1000_uart0_groups[] = { "uart0-data", "uart0-hwflow", }; |
| 1214 | static const char *x1000_uart1_groups[] = { |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1215 | "uart1-data-a", "uart1-data-d", "uart1-hwflow", |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1216 | }; |
| 1217 | static const char *x1000_uart2_groups[] = { "uart2-data-a", "uart2-data-d", }; |
周琰杰 (Zhou Yanjie) | 3b31e9b | 2019-12-16 00:21:01 +0800 | [diff] [blame] | 1218 | static const char *x1000_sfc_groups[] = { "sfc", }; |
| 1219 | static const char *x1000_ssi_groups[] = { |
| 1220 | "ssi-dt-a-22", "ssi-dt-a-29", "ssi-dt-d", |
| 1221 | "ssi-dr-a-23", "ssi-dr-a-28", "ssi-dr-d", |
| 1222 | "ssi-clk-a-24", "ssi-clk-a-26", "ssi-clk-d", |
| 1223 | "ssi-gpc-a-20", "ssi-gpc-a-31", |
| 1224 | "ssi-ce0-a-25", "ssi-ce0-a-27", "ssi-ce0-d", |
| 1225 | "ssi-ce1-a-21", "ssi-ce1-a-30", |
| 1226 | }; |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1227 | static const char *x1000_mmc0_groups[] = { |
| 1228 | "mmc0-1bit", "mmc0-4bit", "mmc0-8bit", |
| 1229 | }; |
| 1230 | static const char *x1000_mmc1_groups[] = { |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1231 | "mmc1-1bit", "mmc1-4bit", |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1232 | }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1233 | static const char *x1000_emc_groups[] = { |
| 1234 | "emc-8bit-data", "emc-16bit-data", |
| 1235 | "emc-addr", "emc-rd-we", "emc-wait", |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1236 | }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1237 | static const char *x1000_cs1_groups[] = { "emc-cs1", }; |
| 1238 | static const char *x1000_cs2_groups[] = { "emc-cs2", }; |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1239 | static const char *x1000_i2c0_groups[] = { "i2c0-data", }; |
| 1240 | static const char *x1000_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", }; |
| 1241 | static const char *x1000_i2c2_groups[] = { "i2c2-data", }; |
| 1242 | static const char *x1000_cim_groups[] = { "cim-data", }; |
| 1243 | static const char *x1000_lcd_groups[] = { |
| 1244 | "lcd-8bit", "lcd-16bit", "lcd-no-pins", |
| 1245 | }; |
| 1246 | static const char *x1000_pwm0_groups[] = { "pwm0", }; |
| 1247 | static const char *x1000_pwm1_groups[] = { "pwm1", }; |
| 1248 | static const char *x1000_pwm2_groups[] = { "pwm2", }; |
| 1249 | static const char *x1000_pwm3_groups[] = { "pwm3", }; |
| 1250 | static const char *x1000_pwm4_groups[] = { "pwm4", }; |
| 1251 | static const char *x1000_mac_groups[] = { "mac", }; |
| 1252 | |
| 1253 | static const struct function_desc x1000_functions[] = { |
| 1254 | { "uart0", x1000_uart0_groups, ARRAY_SIZE(x1000_uart0_groups), }, |
| 1255 | { "uart1", x1000_uart1_groups, ARRAY_SIZE(x1000_uart1_groups), }, |
| 1256 | { "uart2", x1000_uart2_groups, ARRAY_SIZE(x1000_uart2_groups), }, |
周琰杰 (Zhou Yanjie) | 3b31e9b | 2019-12-16 00:21:01 +0800 | [diff] [blame] | 1257 | { "sfc", x1000_sfc_groups, ARRAY_SIZE(x1000_sfc_groups), }, |
| 1258 | { "ssi", x1000_ssi_groups, ARRAY_SIZE(x1000_ssi_groups), }, |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1259 | { "mmc0", x1000_mmc0_groups, ARRAY_SIZE(x1000_mmc0_groups), }, |
| 1260 | { "mmc1", x1000_mmc1_groups, ARRAY_SIZE(x1000_mmc1_groups), }, |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1261 | { "emc", x1000_emc_groups, ARRAY_SIZE(x1000_emc_groups), }, |
| 1262 | { "emc-cs1", x1000_cs1_groups, ARRAY_SIZE(x1000_cs1_groups), }, |
| 1263 | { "emc-cs2", x1000_cs2_groups, ARRAY_SIZE(x1000_cs2_groups), }, |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1264 | { "i2c0", x1000_i2c0_groups, ARRAY_SIZE(x1000_i2c0_groups), }, |
| 1265 | { "i2c1", x1000_i2c1_groups, ARRAY_SIZE(x1000_i2c1_groups), }, |
| 1266 | { "i2c2", x1000_i2c2_groups, ARRAY_SIZE(x1000_i2c2_groups), }, |
| 1267 | { "cim", x1000_cim_groups, ARRAY_SIZE(x1000_cim_groups), }, |
| 1268 | { "lcd", x1000_lcd_groups, ARRAY_SIZE(x1000_lcd_groups), }, |
| 1269 | { "pwm0", x1000_pwm0_groups, ARRAY_SIZE(x1000_pwm0_groups), }, |
| 1270 | { "pwm1", x1000_pwm1_groups, ARRAY_SIZE(x1000_pwm1_groups), }, |
| 1271 | { "pwm2", x1000_pwm2_groups, ARRAY_SIZE(x1000_pwm2_groups), }, |
| 1272 | { "pwm3", x1000_pwm3_groups, ARRAY_SIZE(x1000_pwm3_groups), }, |
| 1273 | { "pwm4", x1000_pwm4_groups, ARRAY_SIZE(x1000_pwm4_groups), }, |
| 1274 | { "mac", x1000_mac_groups, ARRAY_SIZE(x1000_mac_groups), }, |
| 1275 | }; |
| 1276 | |
| 1277 | static const struct ingenic_chip_info x1000_chip_info = { |
| 1278 | .num_chips = 4, |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 1279 | .reg_offset = 0x100, |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1280 | .groups = x1000_groups, |
| 1281 | .num_groups = ARRAY_SIZE(x1000_groups), |
| 1282 | .functions = x1000_functions, |
| 1283 | .num_functions = ARRAY_SIZE(x1000_functions), |
| 1284 | .pull_ups = x1000_pull_ups, |
| 1285 | .pull_downs = x1000_pull_downs, |
| 1286 | }; |
| 1287 | |
| 1288 | static const struct ingenic_chip_info x1000e_chip_info = { |
| 1289 | .num_chips = 4, |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 1290 | .reg_offset = 0x100, |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1291 | .groups = x1000_groups, |
| 1292 | .num_groups = ARRAY_SIZE(x1000_groups), |
| 1293 | .functions = x1000_functions, |
| 1294 | .num_functions = ARRAY_SIZE(x1000_functions), |
| 1295 | .pull_ups = x1000_pull_ups, |
| 1296 | .pull_downs = x1000_pull_downs, |
| 1297 | }; |
| 1298 | |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 1299 | static int x1500_uart0_data_pins[] = { 0x4a, 0x4b, }; |
| 1300 | static int x1500_uart0_hwflow_pins[] = { 0x4c, 0x4d, }; |
| 1301 | static int x1500_uart1_data_a_pins[] = { 0x04, 0x05, }; |
| 1302 | static int x1500_uart1_data_d_pins[] = { 0x62, 0x63, }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1303 | static int x1500_uart1_hwflow_pins[] = { 0x64, 0x65, }; |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 1304 | static int x1500_uart2_data_a_pins[] = { 0x02, 0x03, }; |
| 1305 | static int x1500_uart2_data_d_pins[] = { 0x65, 0x64, }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1306 | static int x1500_mmc_1bit_pins[] = { 0x18, 0x19, 0x17, }; |
| 1307 | static int x1500_mmc_4bit_pins[] = { 0x16, 0x15, 0x14, }; |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 1308 | static int x1500_i2c0_pins[] = { 0x38, 0x37, }; |
| 1309 | static int x1500_i2c1_a_pins[] = { 0x01, 0x00, }; |
| 1310 | static int x1500_i2c1_c_pins[] = { 0x5b, 0x5a, }; |
| 1311 | static int x1500_i2c2_pins[] = { 0x61, 0x60, }; |
| 1312 | static int x1500_cim_pins[] = { |
| 1313 | 0x08, 0x09, 0x0a, 0x0b, |
| 1314 | 0x13, 0x12, 0x11, 0x10, 0x0f, 0x0e, 0x0d, 0x0c, |
| 1315 | }; |
| 1316 | static int x1500_pwm_pwm0_pins[] = { 0x59, }; |
| 1317 | static int x1500_pwm_pwm1_pins[] = { 0x5a, }; |
| 1318 | static int x1500_pwm_pwm2_pins[] = { 0x5b, }; |
| 1319 | static int x1500_pwm_pwm3_pins[] = { 0x26, }; |
| 1320 | static int x1500_pwm_pwm4_pins[] = { 0x58, }; |
| 1321 | |
| 1322 | static int x1500_uart0_data_funcs[] = { 0, 0, }; |
| 1323 | static int x1500_uart0_hwflow_funcs[] = { 0, 0, }; |
| 1324 | static int x1500_uart1_data_a_funcs[] = { 2, 2, }; |
| 1325 | static int x1500_uart1_data_d_funcs[] = { 1, 1, }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1326 | static int x1500_uart1_hwflow_funcs[] = { 1, 1, }; |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 1327 | static int x1500_uart2_data_a_funcs[] = { 2, 2, }; |
| 1328 | static int x1500_uart2_data_d_funcs[] = { 0, 0, }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1329 | static int x1500_mmc_1bit_funcs[] = { 1, 1, 1, }; |
| 1330 | static int x1500_mmc_4bit_funcs[] = { 1, 1, 1, }; |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 1331 | static int x1500_i2c0_funcs[] = { 0, 0, }; |
| 1332 | static int x1500_i2c1_a_funcs[] = { 2, 2, }; |
| 1333 | static int x1500_i2c1_c_funcs[] = { 0, 0, }; |
| 1334 | static int x1500_i2c2_funcs[] = { 1, 1, }; |
| 1335 | static int x1500_cim_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, }; |
| 1336 | static int x1500_pwm_pwm0_funcs[] = { 0, }; |
| 1337 | static int x1500_pwm_pwm1_funcs[] = { 1, }; |
| 1338 | static int x1500_pwm_pwm2_funcs[] = { 1, }; |
| 1339 | static int x1500_pwm_pwm3_funcs[] = { 2, }; |
| 1340 | static int x1500_pwm_pwm4_funcs[] = { 0, }; |
| 1341 | |
| 1342 | static const struct group_desc x1500_groups[] = { |
| 1343 | INGENIC_PIN_GROUP("uart0-data", x1500_uart0_data), |
| 1344 | INGENIC_PIN_GROUP("uart0-hwflow", x1500_uart0_hwflow), |
| 1345 | INGENIC_PIN_GROUP("uart1-data-a", x1500_uart1_data_a), |
| 1346 | INGENIC_PIN_GROUP("uart1-data-d", x1500_uart1_data_d), |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1347 | INGENIC_PIN_GROUP("uart1-hwflow", x1500_uart1_hwflow), |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 1348 | INGENIC_PIN_GROUP("uart2-data-a", x1500_uart2_data_a), |
| 1349 | INGENIC_PIN_GROUP("uart2-data-d", x1500_uart2_data_d), |
周琰杰 (Zhou Yanjie) | 3b31e9b | 2019-12-16 00:21:01 +0800 | [diff] [blame] | 1350 | INGENIC_PIN_GROUP("sfc", x1000_sfc), |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1351 | INGENIC_PIN_GROUP("mmc-1bit", x1500_mmc_1bit), |
| 1352 | INGENIC_PIN_GROUP("mmc-4bit", x1500_mmc_4bit), |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 1353 | INGENIC_PIN_GROUP("i2c0-data", x1500_i2c0), |
| 1354 | INGENIC_PIN_GROUP("i2c1-data-a", x1500_i2c1_a), |
| 1355 | INGENIC_PIN_GROUP("i2c1-data-c", x1500_i2c1_c), |
| 1356 | INGENIC_PIN_GROUP("i2c2-data", x1500_i2c2), |
| 1357 | INGENIC_PIN_GROUP("cim-data", x1500_cim), |
| 1358 | { "lcd-no-pins", }, |
| 1359 | INGENIC_PIN_GROUP("pwm0", x1500_pwm_pwm0), |
| 1360 | INGENIC_PIN_GROUP("pwm1", x1500_pwm_pwm1), |
| 1361 | INGENIC_PIN_GROUP("pwm2", x1500_pwm_pwm2), |
| 1362 | INGENIC_PIN_GROUP("pwm3", x1500_pwm_pwm3), |
| 1363 | INGENIC_PIN_GROUP("pwm4", x1500_pwm_pwm4), |
| 1364 | }; |
| 1365 | |
| 1366 | static const char *x1500_uart0_groups[] = { "uart0-data", "uart0-hwflow", }; |
| 1367 | static const char *x1500_uart1_groups[] = { |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1368 | "uart1-data-a", "uart1-data-d", "uart1-hwflow", |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 1369 | }; |
| 1370 | static const char *x1500_uart2_groups[] = { "uart2-data-a", "uart2-data-d", }; |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1371 | static const char *x1500_mmc_groups[] = { "mmc-1bit", "mmc-4bit", }; |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 1372 | static const char *x1500_i2c0_groups[] = { "i2c0-data", }; |
| 1373 | static const char *x1500_i2c1_groups[] = { "i2c1-data-a", "i2c1-data-c", }; |
| 1374 | static const char *x1500_i2c2_groups[] = { "i2c2-data", }; |
| 1375 | static const char *x1500_cim_groups[] = { "cim-data", }; |
| 1376 | static const char *x1500_lcd_groups[] = { "lcd-no-pins", }; |
| 1377 | static const char *x1500_pwm0_groups[] = { "pwm0", }; |
| 1378 | static const char *x1500_pwm1_groups[] = { "pwm1", }; |
| 1379 | static const char *x1500_pwm2_groups[] = { "pwm2", }; |
| 1380 | static const char *x1500_pwm3_groups[] = { "pwm3", }; |
| 1381 | static const char *x1500_pwm4_groups[] = { "pwm4", }; |
| 1382 | |
| 1383 | static const struct function_desc x1500_functions[] = { |
| 1384 | { "uart0", x1500_uart0_groups, ARRAY_SIZE(x1500_uart0_groups), }, |
| 1385 | { "uart1", x1500_uart1_groups, ARRAY_SIZE(x1500_uart1_groups), }, |
| 1386 | { "uart2", x1500_uart2_groups, ARRAY_SIZE(x1500_uart2_groups), }, |
周琰杰 (Zhou Yanjie) | 3b31e9b | 2019-12-16 00:21:01 +0800 | [diff] [blame] | 1387 | { "sfc", x1000_sfc_groups, ARRAY_SIZE(x1000_sfc_groups), }, |
周琰杰 (Zhou Yanjie) | b4a9372 | 2019-12-16 00:21:00 +0800 | [diff] [blame] | 1388 | { "mmc", x1500_mmc_groups, ARRAY_SIZE(x1500_mmc_groups), }, |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 1389 | { "i2c0", x1500_i2c0_groups, ARRAY_SIZE(x1500_i2c0_groups), }, |
| 1390 | { "i2c1", x1500_i2c1_groups, ARRAY_SIZE(x1500_i2c1_groups), }, |
| 1391 | { "i2c2", x1500_i2c2_groups, ARRAY_SIZE(x1500_i2c2_groups), }, |
| 1392 | { "cim", x1500_cim_groups, ARRAY_SIZE(x1500_cim_groups), }, |
| 1393 | { "lcd", x1500_lcd_groups, ARRAY_SIZE(x1500_lcd_groups), }, |
| 1394 | { "pwm0", x1500_pwm0_groups, ARRAY_SIZE(x1500_pwm0_groups), }, |
| 1395 | { "pwm1", x1500_pwm1_groups, ARRAY_SIZE(x1500_pwm1_groups), }, |
| 1396 | { "pwm2", x1500_pwm2_groups, ARRAY_SIZE(x1500_pwm2_groups), }, |
| 1397 | { "pwm3", x1500_pwm3_groups, ARRAY_SIZE(x1500_pwm3_groups), }, |
| 1398 | { "pwm4", x1500_pwm4_groups, ARRAY_SIZE(x1500_pwm4_groups), }, |
| 1399 | }; |
| 1400 | |
| 1401 | static const struct ingenic_chip_info x1500_chip_info = { |
| 1402 | .num_chips = 4, |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 1403 | .reg_offset = 0x100, |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 1404 | .groups = x1500_groups, |
| 1405 | .num_groups = ARRAY_SIZE(x1500_groups), |
| 1406 | .functions = x1500_functions, |
| 1407 | .num_functions = ARRAY_SIZE(x1500_functions), |
| 1408 | .pull_ups = x1000_pull_ups, |
| 1409 | .pull_downs = x1000_pull_downs, |
| 1410 | }; |
| 1411 | |
Zhou Yanjie | b71c184 | 2019-01-28 23:19:59 +0800 | [diff] [blame] | 1412 | 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] | 1413 | { |
| 1414 | unsigned int val; |
| 1415 | |
| 1416 | regmap_read(jzgc->jzpc->map, jzgc->reg_base + reg, &val); |
| 1417 | |
| 1418 | return (u32) val; |
| 1419 | } |
| 1420 | |
Zhou Yanjie | b71c184 | 2019-01-28 23:19:59 +0800 | [diff] [blame] | 1421 | static void ingenic_gpio_set_bit(struct ingenic_gpio_chip *jzgc, |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1422 | u8 reg, u8 offset, bool set) |
| 1423 | { |
| 1424 | if (set) |
| 1425 | reg = REG_SET(reg); |
| 1426 | else |
| 1427 | reg = REG_CLEAR(reg); |
| 1428 | |
| 1429 | regmap_write(jzgc->jzpc->map, jzgc->reg_base + reg, BIT(offset)); |
| 1430 | } |
| 1431 | |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1432 | static void ingenic_gpio_shadow_set_bit(struct ingenic_gpio_chip *jzgc, |
| 1433 | u8 reg, u8 offset, bool set) |
| 1434 | { |
| 1435 | if (set) |
| 1436 | reg = REG_SET(reg); |
| 1437 | else |
| 1438 | reg = REG_CLEAR(reg); |
| 1439 | |
| 1440 | regmap_write(jzgc->jzpc->map, X1000_GPIO_PZ_BASE + reg, BIT(offset)); |
| 1441 | } |
| 1442 | |
| 1443 | static void ingenic_gpio_shadow_set_bit_load(struct ingenic_gpio_chip *jzgc) |
| 1444 | { |
| 1445 | regmap_write(jzgc->jzpc->map, X1000_GPIO_PZ_GID2LD, |
| 1446 | jzgc->gc.base / PINS_PER_GPIO_CHIP); |
| 1447 | } |
| 1448 | |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1449 | static inline bool ingenic_gpio_get_value(struct ingenic_gpio_chip *jzgc, |
| 1450 | u8 offset) |
| 1451 | { |
Zhou Yanjie | b71c184 | 2019-01-28 23:19:59 +0800 | [diff] [blame] | 1452 | unsigned int val = ingenic_gpio_read_reg(jzgc, GPIO_PIN); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1453 | |
| 1454 | return !!(val & BIT(offset)); |
| 1455 | } |
| 1456 | |
| 1457 | static void ingenic_gpio_set_value(struct ingenic_gpio_chip *jzgc, |
| 1458 | u8 offset, int value) |
| 1459 | { |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 1460 | if (jzgc->jzpc->version >= ID_JZ4760) |
| 1461 | ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_PAT0, offset, !!value); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1462 | else |
Zhou Yanjie | b71c184 | 2019-01-28 23:19:59 +0800 | [diff] [blame] | 1463 | ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, offset, !!value); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1464 | } |
| 1465 | |
| 1466 | static void irq_set_type(struct ingenic_gpio_chip *jzgc, |
| 1467 | u8 offset, unsigned int type) |
| 1468 | { |
| 1469 | u8 reg1, reg2; |
| 1470 | |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 1471 | if (jzgc->jzpc->version >= ID_JZ4760) { |
| 1472 | reg1 = JZ4760_GPIO_PAT1; |
| 1473 | reg2 = JZ4760_GPIO_PAT0; |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1474 | } else { |
| 1475 | reg1 = JZ4740_GPIO_TRIG; |
| 1476 | reg2 = JZ4740_GPIO_DIR; |
| 1477 | } |
| 1478 | |
| 1479 | switch (type) { |
| 1480 | case IRQ_TYPE_EDGE_RISING: |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1481 | if (jzgc->jzpc->version >= ID_X1000) { |
| 1482 | ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, true); |
| 1483 | ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, true); |
| 1484 | ingenic_gpio_shadow_set_bit_load(jzgc); |
| 1485 | } else { |
| 1486 | ingenic_gpio_set_bit(jzgc, reg2, offset, true); |
| 1487 | ingenic_gpio_set_bit(jzgc, reg1, offset, true); |
| 1488 | } |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1489 | break; |
| 1490 | case IRQ_TYPE_EDGE_FALLING: |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1491 | if (jzgc->jzpc->version >= ID_X1000) { |
| 1492 | ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, false); |
| 1493 | ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, true); |
| 1494 | ingenic_gpio_shadow_set_bit_load(jzgc); |
| 1495 | } else { |
| 1496 | ingenic_gpio_set_bit(jzgc, reg2, offset, false); |
| 1497 | ingenic_gpio_set_bit(jzgc, reg1, offset, true); |
| 1498 | } |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1499 | break; |
| 1500 | case IRQ_TYPE_LEVEL_HIGH: |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1501 | if (jzgc->jzpc->version >= ID_X1000) { |
| 1502 | ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, true); |
| 1503 | ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, false); |
| 1504 | ingenic_gpio_shadow_set_bit_load(jzgc); |
| 1505 | } else { |
| 1506 | ingenic_gpio_set_bit(jzgc, reg2, offset, true); |
| 1507 | ingenic_gpio_set_bit(jzgc, reg1, offset, false); |
| 1508 | } |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1509 | break; |
| 1510 | case IRQ_TYPE_LEVEL_LOW: |
| 1511 | default: |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1512 | if (jzgc->jzpc->version >= ID_X1000) { |
| 1513 | ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, false); |
| 1514 | ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, false); |
| 1515 | ingenic_gpio_shadow_set_bit_load(jzgc); |
| 1516 | } else { |
| 1517 | ingenic_gpio_set_bit(jzgc, reg2, offset, false); |
| 1518 | ingenic_gpio_set_bit(jzgc, reg1, offset, false); |
| 1519 | } |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1520 | break; |
| 1521 | } |
| 1522 | } |
| 1523 | |
| 1524 | static void ingenic_gpio_irq_mask(struct irq_data *irqd) |
| 1525 | { |
| 1526 | struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); |
| 1527 | struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc); |
| 1528 | |
Zhou Yanjie | b71c184 | 2019-01-28 23:19:59 +0800 | [diff] [blame] | 1529 | ingenic_gpio_set_bit(jzgc, GPIO_MSK, irqd->hwirq, true); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1530 | } |
| 1531 | |
| 1532 | static void ingenic_gpio_irq_unmask(struct irq_data *irqd) |
| 1533 | { |
| 1534 | struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); |
| 1535 | struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc); |
| 1536 | |
Zhou Yanjie | b71c184 | 2019-01-28 23:19:59 +0800 | [diff] [blame] | 1537 | ingenic_gpio_set_bit(jzgc, GPIO_MSK, irqd->hwirq, false); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1538 | } |
| 1539 | |
| 1540 | static void ingenic_gpio_irq_enable(struct irq_data *irqd) |
| 1541 | { |
| 1542 | struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); |
| 1543 | struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc); |
| 1544 | int irq = irqd->hwirq; |
| 1545 | |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 1546 | if (jzgc->jzpc->version >= ID_JZ4760) |
| 1547 | ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_INT, irq, true); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1548 | else |
Zhou Yanjie | b71c184 | 2019-01-28 23:19:59 +0800 | [diff] [blame] | 1549 | ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, true); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1550 | |
| 1551 | ingenic_gpio_irq_unmask(irqd); |
| 1552 | } |
| 1553 | |
| 1554 | static void ingenic_gpio_irq_disable(struct irq_data *irqd) |
| 1555 | { |
| 1556 | struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); |
| 1557 | struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc); |
| 1558 | int irq = irqd->hwirq; |
| 1559 | |
| 1560 | ingenic_gpio_irq_mask(irqd); |
| 1561 | |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 1562 | if (jzgc->jzpc->version >= ID_JZ4760) |
| 1563 | ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_INT, irq, false); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1564 | else |
Zhou Yanjie | b71c184 | 2019-01-28 23:19:59 +0800 | [diff] [blame] | 1565 | ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, false); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1566 | } |
| 1567 | |
| 1568 | static void ingenic_gpio_irq_ack(struct irq_data *irqd) |
| 1569 | { |
| 1570 | struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); |
| 1571 | struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc); |
| 1572 | int irq = irqd->hwirq; |
| 1573 | bool high; |
| 1574 | |
| 1575 | if (irqd_get_trigger_type(irqd) == IRQ_TYPE_EDGE_BOTH) { |
| 1576 | /* |
| 1577 | * Switch to an interrupt for the opposite edge to the one that |
| 1578 | * triggered the interrupt being ACKed. |
| 1579 | */ |
| 1580 | high = ingenic_gpio_get_value(jzgc, irq); |
| 1581 | if (high) |
| 1582 | irq_set_type(jzgc, irq, IRQ_TYPE_EDGE_FALLING); |
| 1583 | else |
| 1584 | irq_set_type(jzgc, irq, IRQ_TYPE_EDGE_RISING); |
| 1585 | } |
| 1586 | |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 1587 | if (jzgc->jzpc->version >= ID_JZ4760) |
| 1588 | ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_FLAG, irq, false); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1589 | else |
Zhou Yanjie | b71c184 | 2019-01-28 23:19:59 +0800 | [diff] [blame] | 1590 | ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, irq, true); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1591 | } |
| 1592 | |
| 1593 | static int ingenic_gpio_irq_set_type(struct irq_data *irqd, unsigned int type) |
| 1594 | { |
| 1595 | struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); |
| 1596 | struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc); |
| 1597 | |
| 1598 | switch (type) { |
| 1599 | case IRQ_TYPE_EDGE_BOTH: |
| 1600 | case IRQ_TYPE_EDGE_RISING: |
| 1601 | case IRQ_TYPE_EDGE_FALLING: |
| 1602 | irq_set_handler_locked(irqd, handle_edge_irq); |
| 1603 | break; |
| 1604 | case IRQ_TYPE_LEVEL_HIGH: |
| 1605 | case IRQ_TYPE_LEVEL_LOW: |
| 1606 | irq_set_handler_locked(irqd, handle_level_irq); |
| 1607 | break; |
| 1608 | default: |
| 1609 | irq_set_handler_locked(irqd, handle_bad_irq); |
| 1610 | } |
| 1611 | |
| 1612 | if (type == IRQ_TYPE_EDGE_BOTH) { |
| 1613 | /* |
| 1614 | * The hardware does not support interrupts on both edges. The |
| 1615 | * best we can do is to set up a single-edge interrupt and then |
| 1616 | * switch to the opposing edge when ACKing the interrupt. |
| 1617 | */ |
| 1618 | bool high = ingenic_gpio_get_value(jzgc, irqd->hwirq); |
| 1619 | |
| 1620 | type = high ? IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING; |
| 1621 | } |
| 1622 | |
| 1623 | irq_set_type(jzgc, irqd->hwirq, type); |
| 1624 | return 0; |
| 1625 | } |
| 1626 | |
| 1627 | static int ingenic_gpio_irq_set_wake(struct irq_data *irqd, unsigned int on) |
| 1628 | { |
| 1629 | struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); |
| 1630 | struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc); |
| 1631 | |
| 1632 | return irq_set_irq_wake(jzgc->irq, on); |
| 1633 | } |
| 1634 | |
| 1635 | static void ingenic_gpio_irq_handler(struct irq_desc *desc) |
| 1636 | { |
| 1637 | struct gpio_chip *gc = irq_desc_get_handler_data(desc); |
| 1638 | struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc); |
| 1639 | struct irq_chip *irq_chip = irq_data_get_irq_chip(&desc->irq_data); |
| 1640 | unsigned long flag, i; |
| 1641 | |
| 1642 | chained_irq_enter(irq_chip, desc); |
| 1643 | |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 1644 | if (jzgc->jzpc->version >= ID_JZ4760) |
| 1645 | flag = ingenic_gpio_read_reg(jzgc, JZ4760_GPIO_FLAG); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1646 | else |
Zhou Yanjie | b71c184 | 2019-01-28 23:19:59 +0800 | [diff] [blame] | 1647 | flag = ingenic_gpio_read_reg(jzgc, JZ4740_GPIO_FLAG); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1648 | |
| 1649 | for_each_set_bit(i, &flag, 32) |
| 1650 | generic_handle_irq(irq_linear_revmap(gc->irq.domain, i)); |
| 1651 | chained_irq_exit(irq_chip, desc); |
| 1652 | } |
| 1653 | |
| 1654 | static void ingenic_gpio_set(struct gpio_chip *gc, |
| 1655 | unsigned int offset, int value) |
| 1656 | { |
| 1657 | struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc); |
| 1658 | |
| 1659 | ingenic_gpio_set_value(jzgc, offset, value); |
| 1660 | } |
| 1661 | |
| 1662 | static int ingenic_gpio_get(struct gpio_chip *gc, unsigned int offset) |
| 1663 | { |
| 1664 | struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc); |
| 1665 | |
| 1666 | return (int) ingenic_gpio_get_value(jzgc, offset); |
| 1667 | } |
| 1668 | |
| 1669 | static int ingenic_gpio_direction_input(struct gpio_chip *gc, |
| 1670 | unsigned int offset) |
| 1671 | { |
| 1672 | return pinctrl_gpio_direction_input(gc->base + offset); |
| 1673 | } |
| 1674 | |
| 1675 | static int ingenic_gpio_direction_output(struct gpio_chip *gc, |
| 1676 | unsigned int offset, int value) |
| 1677 | { |
| 1678 | ingenic_gpio_set(gc, offset, value); |
| 1679 | return pinctrl_gpio_direction_output(gc->base + offset); |
| 1680 | } |
| 1681 | |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1682 | static inline void ingenic_config_pin(struct ingenic_pinctrl *jzpc, |
| 1683 | unsigned int pin, u8 reg, bool set) |
| 1684 | { |
| 1685 | unsigned int idx = pin % PINS_PER_GPIO_CHIP; |
| 1686 | unsigned int offt = pin / PINS_PER_GPIO_CHIP; |
| 1687 | |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 1688 | regmap_write(jzpc->map, offt * jzpc->info->reg_offset + |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1689 | (set ? REG_SET(reg) : REG_CLEAR(reg)), BIT(idx)); |
| 1690 | } |
| 1691 | |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1692 | static inline void ingenic_shadow_config_pin(struct ingenic_pinctrl *jzpc, |
| 1693 | unsigned int pin, u8 reg, bool set) |
| 1694 | { |
| 1695 | unsigned int idx = pin % PINS_PER_GPIO_CHIP; |
| 1696 | |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 1697 | regmap_write(jzpc->map, REG_PZ_BASE(jzpc->info->reg_offset) + |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1698 | (set ? REG_SET(reg) : REG_CLEAR(reg)), BIT(idx)); |
| 1699 | } |
| 1700 | |
| 1701 | static inline void ingenic_shadow_config_pin_load(struct ingenic_pinctrl *jzpc, |
| 1702 | unsigned int pin) |
| 1703 | { |
| 1704 | regmap_write(jzpc->map, X1000_GPIO_PZ_GID2LD, pin / PINS_PER_GPIO_CHIP); |
| 1705 | } |
| 1706 | |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1707 | static inline bool ingenic_get_pin_config(struct ingenic_pinctrl *jzpc, |
| 1708 | unsigned int pin, u8 reg) |
| 1709 | { |
| 1710 | unsigned int idx = pin % PINS_PER_GPIO_CHIP; |
| 1711 | unsigned int offt = pin / PINS_PER_GPIO_CHIP; |
| 1712 | unsigned int val; |
| 1713 | |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 1714 | regmap_read(jzpc->map, offt * jzpc->info->reg_offset + reg, &val); |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1715 | |
| 1716 | return val & BIT(idx); |
| 1717 | } |
| 1718 | |
Paul Cercueil | ebd6651 | 2018-08-21 18:42:33 +0200 | [diff] [blame] | 1719 | static int ingenic_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) |
| 1720 | { |
| 1721 | struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc); |
| 1722 | struct ingenic_pinctrl *jzpc = jzgc->jzpc; |
| 1723 | unsigned int pin = gc->base + offset; |
| 1724 | |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 1725 | if (jzpc->version >= ID_JZ4760) |
| 1726 | return ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_PAT1); |
Paul Cercueil | ebd6651 | 2018-08-21 18:42:33 +0200 | [diff] [blame] | 1727 | |
| 1728 | if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_SELECT)) |
| 1729 | return true; |
| 1730 | |
| 1731 | return !ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_DIR); |
| 1732 | } |
| 1733 | |
Julia Lawall | 5bf7b84 | 2017-08-10 12:06:23 +0200 | [diff] [blame] | 1734 | static const struct pinctrl_ops ingenic_pctlops = { |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1735 | .get_groups_count = pinctrl_generic_get_group_count, |
| 1736 | .get_group_name = pinctrl_generic_get_group_name, |
| 1737 | .get_group_pins = pinctrl_generic_get_group_pins, |
| 1738 | .dt_node_to_map = pinconf_generic_dt_node_to_map_all, |
| 1739 | .dt_free_map = pinconf_generic_dt_free_map, |
| 1740 | }; |
| 1741 | |
| 1742 | static int ingenic_pinmux_set_pin_fn(struct ingenic_pinctrl *jzpc, |
| 1743 | int pin, int func) |
| 1744 | { |
| 1745 | unsigned int idx = pin % PINS_PER_GPIO_CHIP; |
| 1746 | unsigned int offt = pin / PINS_PER_GPIO_CHIP; |
| 1747 | |
| 1748 | dev_dbg(jzpc->dev, "set pin P%c%u to function %u\n", |
| 1749 | 'A' + offt, idx, func); |
| 1750 | |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1751 | if (jzpc->version >= ID_X1000) { |
| 1752 | ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_INT, false); |
| 1753 | ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, false); |
| 1754 | ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, func & 0x2); |
| 1755 | ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, func & 0x1); |
| 1756 | ingenic_shadow_config_pin_load(jzpc, pin); |
| 1757 | } else if (jzpc->version >= ID_JZ4760) { |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 1758 | ingenic_config_pin(jzpc, pin, JZ4760_GPIO_INT, false); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1759 | ingenic_config_pin(jzpc, pin, GPIO_MSK, false); |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 1760 | ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, func & 0x2); |
| 1761 | ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, func & 0x1); |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1762 | } else { |
| 1763 | ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, true); |
| 1764 | ingenic_config_pin(jzpc, pin, JZ4740_GPIO_TRIG, func & 0x2); |
| 1765 | ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, func > 0); |
| 1766 | } |
| 1767 | |
| 1768 | return 0; |
| 1769 | } |
| 1770 | |
| 1771 | static int ingenic_pinmux_set_mux(struct pinctrl_dev *pctldev, |
| 1772 | unsigned int selector, unsigned int group) |
| 1773 | { |
| 1774 | struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev); |
| 1775 | struct function_desc *func; |
| 1776 | struct group_desc *grp; |
| 1777 | unsigned int i; |
| 1778 | |
| 1779 | func = pinmux_generic_get_function(pctldev, selector); |
| 1780 | if (!func) |
| 1781 | return -EINVAL; |
| 1782 | |
| 1783 | grp = pinctrl_generic_get_group(pctldev, group); |
| 1784 | if (!grp) |
| 1785 | return -EINVAL; |
| 1786 | |
| 1787 | dev_dbg(pctldev->dev, "enable function %s group %s\n", |
| 1788 | func->name, grp->name); |
| 1789 | |
| 1790 | for (i = 0; i < grp->num_pins; i++) { |
| 1791 | int *pin_modes = grp->data; |
| 1792 | |
| 1793 | ingenic_pinmux_set_pin_fn(jzpc, grp->pins[i], pin_modes[i]); |
| 1794 | } |
| 1795 | |
| 1796 | return 0; |
| 1797 | } |
| 1798 | |
| 1799 | static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev, |
| 1800 | struct pinctrl_gpio_range *range, |
| 1801 | unsigned int pin, bool input) |
| 1802 | { |
| 1803 | struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev); |
| 1804 | unsigned int idx = pin % PINS_PER_GPIO_CHIP; |
| 1805 | unsigned int offt = pin / PINS_PER_GPIO_CHIP; |
| 1806 | |
| 1807 | dev_dbg(pctldev->dev, "set pin P%c%u to %sput\n", |
| 1808 | 'A' + offt, idx, input ? "in" : "out"); |
| 1809 | |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 1810 | if (jzpc->version >= ID_X1000) { |
| 1811 | ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_INT, false); |
| 1812 | ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, true); |
| 1813 | ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, input); |
| 1814 | ingenic_shadow_config_pin_load(jzpc, pin); |
| 1815 | } else if (jzpc->version >= ID_JZ4760) { |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 1816 | ingenic_config_pin(jzpc, pin, JZ4760_GPIO_INT, false); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 1817 | ingenic_config_pin(jzpc, pin, GPIO_MSK, true); |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 1818 | ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, input); |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1819 | } else { |
| 1820 | ingenic_config_pin(jzpc, pin, JZ4740_GPIO_SELECT, false); |
Paul Cercueil | 0084a78 | 2018-06-27 13:49:02 +0200 | [diff] [blame] | 1821 | ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DIR, !input); |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1822 | ingenic_config_pin(jzpc, pin, JZ4740_GPIO_FUNC, false); |
| 1823 | } |
| 1824 | |
| 1825 | return 0; |
| 1826 | } |
| 1827 | |
Julia Lawall | 5bf7b84 | 2017-08-10 12:06:23 +0200 | [diff] [blame] | 1828 | static const struct pinmux_ops ingenic_pmxops = { |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1829 | .get_functions_count = pinmux_generic_get_function_count, |
| 1830 | .get_function_name = pinmux_generic_get_function_name, |
| 1831 | .get_function_groups = pinmux_generic_get_function_groups, |
| 1832 | .set_mux = ingenic_pinmux_set_mux, |
| 1833 | .gpio_set_direction = ingenic_pinmux_gpio_set_direction, |
| 1834 | }; |
| 1835 | |
| 1836 | static int ingenic_pinconf_get(struct pinctrl_dev *pctldev, |
| 1837 | unsigned int pin, unsigned long *config) |
| 1838 | { |
| 1839 | struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev); |
| 1840 | enum pin_config_param param = pinconf_to_config_param(*config); |
| 1841 | unsigned int idx = pin % PINS_PER_GPIO_CHIP; |
| 1842 | unsigned int offt = pin / PINS_PER_GPIO_CHIP; |
| 1843 | bool pull; |
| 1844 | |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 1845 | if (jzpc->version >= ID_JZ4760) |
| 1846 | pull = !ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_PEN); |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1847 | else |
| 1848 | pull = !ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_PULL_DIS); |
| 1849 | |
| 1850 | switch (param) { |
| 1851 | case PIN_CONFIG_BIAS_DISABLE: |
| 1852 | if (pull) |
| 1853 | return -EINVAL; |
| 1854 | break; |
| 1855 | |
| 1856 | case PIN_CONFIG_BIAS_PULL_UP: |
| 1857 | if (!pull || !(jzpc->info->pull_ups[offt] & BIT(idx))) |
| 1858 | return -EINVAL; |
| 1859 | break; |
| 1860 | |
| 1861 | case PIN_CONFIG_BIAS_PULL_DOWN: |
| 1862 | if (!pull || !(jzpc->info->pull_downs[offt] & BIT(idx))) |
| 1863 | return -EINVAL; |
| 1864 | break; |
| 1865 | |
| 1866 | default: |
| 1867 | return -ENOTSUPP; |
| 1868 | } |
| 1869 | |
| 1870 | *config = pinconf_to_config_packed(param, 1); |
| 1871 | return 0; |
| 1872 | } |
| 1873 | |
| 1874 | static void ingenic_set_bias(struct ingenic_pinctrl *jzpc, |
| 1875 | unsigned int pin, bool enabled) |
| 1876 | { |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 1877 | if (jzpc->version >= ID_JZ4760) |
| 1878 | ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PEN, !enabled); |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1879 | else |
| 1880 | ingenic_config_pin(jzpc, pin, JZ4740_GPIO_PULL_DIS, !enabled); |
| 1881 | } |
| 1882 | |
Paul Cercueil | 7009d04 | 2019-11-19 16:52:10 +0100 | [diff] [blame] | 1883 | static void ingenic_set_output_level(struct ingenic_pinctrl *jzpc, |
| 1884 | unsigned int pin, bool high) |
| 1885 | { |
Paul Cercueil | 9e65527 | 2019-12-10 17:44:46 +0100 | [diff] [blame] | 1886 | if (jzpc->version >= ID_JZ4760) |
Paul Cercueil | 7009d04 | 2019-11-19 16:52:10 +0100 | [diff] [blame] | 1887 | ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, high); |
| 1888 | else |
| 1889 | ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DATA, high); |
| 1890 | } |
| 1891 | |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1892 | static int ingenic_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, |
| 1893 | unsigned long *configs, unsigned int num_configs) |
| 1894 | { |
| 1895 | struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev); |
| 1896 | unsigned int idx = pin % PINS_PER_GPIO_CHIP; |
| 1897 | unsigned int offt = pin / PINS_PER_GPIO_CHIP; |
Paul Cercueil | 7009d04 | 2019-11-19 16:52:10 +0100 | [diff] [blame] | 1898 | unsigned int cfg, arg; |
| 1899 | int ret; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1900 | |
| 1901 | for (cfg = 0; cfg < num_configs; cfg++) { |
| 1902 | switch (pinconf_to_config_param(configs[cfg])) { |
| 1903 | case PIN_CONFIG_BIAS_DISABLE: |
| 1904 | case PIN_CONFIG_BIAS_PULL_UP: |
| 1905 | case PIN_CONFIG_BIAS_PULL_DOWN: |
Paul Cercueil | 7009d04 | 2019-11-19 16:52:10 +0100 | [diff] [blame] | 1906 | case PIN_CONFIG_OUTPUT: |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1907 | continue; |
| 1908 | default: |
| 1909 | return -ENOTSUPP; |
| 1910 | } |
| 1911 | } |
| 1912 | |
| 1913 | for (cfg = 0; cfg < num_configs; cfg++) { |
Paul Cercueil | 7009d04 | 2019-11-19 16:52:10 +0100 | [diff] [blame] | 1914 | arg = pinconf_to_config_argument(configs[cfg]); |
| 1915 | |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1916 | switch (pinconf_to_config_param(configs[cfg])) { |
| 1917 | case PIN_CONFIG_BIAS_DISABLE: |
| 1918 | dev_dbg(jzpc->dev, "disable pull-over for pin P%c%u\n", |
| 1919 | 'A' + offt, idx); |
| 1920 | ingenic_set_bias(jzpc, pin, false); |
| 1921 | break; |
| 1922 | |
| 1923 | case PIN_CONFIG_BIAS_PULL_UP: |
| 1924 | if (!(jzpc->info->pull_ups[offt] & BIT(idx))) |
| 1925 | return -EINVAL; |
| 1926 | dev_dbg(jzpc->dev, "set pull-up for pin P%c%u\n", |
| 1927 | 'A' + offt, idx); |
| 1928 | ingenic_set_bias(jzpc, pin, true); |
| 1929 | break; |
| 1930 | |
| 1931 | case PIN_CONFIG_BIAS_PULL_DOWN: |
| 1932 | if (!(jzpc->info->pull_downs[offt] & BIT(idx))) |
| 1933 | return -EINVAL; |
| 1934 | dev_dbg(jzpc->dev, "set pull-down for pin P%c%u\n", |
| 1935 | 'A' + offt, idx); |
| 1936 | ingenic_set_bias(jzpc, pin, true); |
| 1937 | break; |
| 1938 | |
Paul Cercueil | 7009d04 | 2019-11-19 16:52:10 +0100 | [diff] [blame] | 1939 | case PIN_CONFIG_OUTPUT: |
| 1940 | ret = pinctrl_gpio_direction_output(pin); |
| 1941 | if (ret) |
| 1942 | return ret; |
| 1943 | |
| 1944 | ingenic_set_output_level(jzpc, pin, arg); |
| 1945 | break; |
| 1946 | |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 1947 | default: |
| 1948 | unreachable(); |
| 1949 | } |
| 1950 | } |
| 1951 | |
| 1952 | return 0; |
| 1953 | } |
| 1954 | |
| 1955 | static int ingenic_pinconf_group_get(struct pinctrl_dev *pctldev, |
| 1956 | unsigned int group, unsigned long *config) |
| 1957 | { |
| 1958 | const unsigned int *pins; |
| 1959 | unsigned int i, npins, old = 0; |
| 1960 | int ret; |
| 1961 | |
| 1962 | ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins); |
| 1963 | if (ret) |
| 1964 | return ret; |
| 1965 | |
| 1966 | for (i = 0; i < npins; i++) { |
| 1967 | if (ingenic_pinconf_get(pctldev, pins[i], config)) |
| 1968 | return -ENOTSUPP; |
| 1969 | |
| 1970 | /* configs do not match between two pins */ |
| 1971 | if (i && (old != *config)) |
| 1972 | return -ENOTSUPP; |
| 1973 | |
| 1974 | old = *config; |
| 1975 | } |
| 1976 | |
| 1977 | return 0; |
| 1978 | } |
| 1979 | |
| 1980 | static int ingenic_pinconf_group_set(struct pinctrl_dev *pctldev, |
| 1981 | unsigned int group, unsigned long *configs, |
| 1982 | unsigned int num_configs) |
| 1983 | { |
| 1984 | const unsigned int *pins; |
| 1985 | unsigned int i, npins; |
| 1986 | int ret; |
| 1987 | |
| 1988 | ret = pinctrl_generic_get_group_pins(pctldev, group, &pins, &npins); |
| 1989 | if (ret) |
| 1990 | return ret; |
| 1991 | |
| 1992 | for (i = 0; i < npins; i++) { |
| 1993 | ret = ingenic_pinconf_set(pctldev, |
| 1994 | pins[i], configs, num_configs); |
| 1995 | if (ret) |
| 1996 | return ret; |
| 1997 | } |
| 1998 | |
| 1999 | return 0; |
| 2000 | } |
| 2001 | |
Julia Lawall | 5bf7b84 | 2017-08-10 12:06:23 +0200 | [diff] [blame] | 2002 | static const struct pinconf_ops ingenic_confops = { |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2003 | .is_generic = true, |
| 2004 | .pin_config_get = ingenic_pinconf_get, |
| 2005 | .pin_config_set = ingenic_pinconf_set, |
| 2006 | .pin_config_group_get = ingenic_pinconf_group_get, |
| 2007 | .pin_config_group_set = ingenic_pinconf_group_set, |
| 2008 | }; |
| 2009 | |
| 2010 | static const struct regmap_config ingenic_pinctrl_regmap_config = { |
| 2011 | .reg_bits = 32, |
| 2012 | .val_bits = 32, |
| 2013 | .reg_stride = 4, |
| 2014 | }; |
| 2015 | |
| 2016 | static const struct of_device_id ingenic_pinctrl_of_match[] = { |
| 2017 | { .compatible = "ingenic,jz4740-pinctrl", .data = (void *) ID_JZ4740 }, |
Paul Cercueil | f2a9676 | 2018-08-21 18:42:34 +0200 | [diff] [blame] | 2018 | { .compatible = "ingenic,jz4725b-pinctrl", .data = (void *)ID_JZ4725B }, |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 2019 | { .compatible = "ingenic,jz4760-pinctrl", .data = (void *) ID_JZ4760 }, |
| 2020 | { .compatible = "ingenic,jz4760b-pinctrl", .data = (void *) ID_JZ4760B }, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2021 | { .compatible = "ingenic,jz4770-pinctrl", .data = (void *) ID_JZ4770 }, |
| 2022 | { .compatible = "ingenic,jz4780-pinctrl", .data = (void *) ID_JZ4780 }, |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 2023 | { .compatible = "ingenic,x1000-pinctrl", .data = (void *) ID_X1000 }, |
| 2024 | { .compatible = "ingenic,x1000e-pinctrl", .data = (void *) ID_X1000E }, |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 2025 | { .compatible = "ingenic,x1500-pinctrl", .data = (void *) ID_X1500 }, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2026 | {}, |
| 2027 | }; |
| 2028 | |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 2029 | static const struct of_device_id ingenic_gpio_of_match[] __initconst = { |
| 2030 | { .compatible = "ingenic,jz4740-gpio", }, |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 2031 | { .compatible = "ingenic,jz4760-gpio", }, |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 2032 | { .compatible = "ingenic,jz4770-gpio", }, |
| 2033 | { .compatible = "ingenic,jz4780-gpio", }, |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 2034 | { .compatible = "ingenic,x1000-gpio", }, |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 2035 | {}, |
| 2036 | }; |
| 2037 | |
| 2038 | static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc, |
| 2039 | struct device_node *node) |
| 2040 | { |
| 2041 | struct ingenic_gpio_chip *jzgc; |
| 2042 | struct device *dev = jzpc->dev; |
Linus Walleij | 142b876 | 2019-10-01 15:32:09 +0200 | [diff] [blame] | 2043 | struct gpio_irq_chip *girq; |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 2044 | unsigned int bank; |
| 2045 | int err; |
| 2046 | |
| 2047 | err = of_property_read_u32(node, "reg", &bank); |
| 2048 | if (err) { |
| 2049 | dev_err(dev, "Cannot read \"reg\" property: %i\n", err); |
| 2050 | return err; |
| 2051 | } |
| 2052 | |
| 2053 | jzgc = devm_kzalloc(dev, sizeof(*jzgc), GFP_KERNEL); |
| 2054 | if (!jzgc) |
| 2055 | return -ENOMEM; |
| 2056 | |
| 2057 | jzgc->jzpc = jzpc; |
周琰杰 (Zhou Yanjie) | f742e5e | 2019-12-16 00:21:02 +0800 | [diff] [blame^] | 2058 | jzgc->reg_base = bank * jzpc->info->reg_offset; |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 2059 | |
| 2060 | jzgc->gc.label = devm_kasprintf(dev, GFP_KERNEL, "GPIO%c", 'A' + bank); |
| 2061 | if (!jzgc->gc.label) |
| 2062 | return -ENOMEM; |
| 2063 | |
| 2064 | /* DO NOT EXPAND THIS: FOR BACKWARD GPIO NUMBERSPACE COMPATIBIBILITY |
| 2065 | * ONLY: WORK TO TRANSITION CONSUMERS TO USE THE GPIO DESCRIPTOR API IN |
| 2066 | * <linux/gpio/consumer.h> INSTEAD. |
| 2067 | */ |
| 2068 | jzgc->gc.base = bank * 32; |
| 2069 | |
| 2070 | jzgc->gc.ngpio = 32; |
| 2071 | jzgc->gc.parent = dev; |
| 2072 | jzgc->gc.of_node = node; |
| 2073 | jzgc->gc.owner = THIS_MODULE; |
| 2074 | |
| 2075 | jzgc->gc.set = ingenic_gpio_set; |
| 2076 | jzgc->gc.get = ingenic_gpio_get; |
| 2077 | jzgc->gc.direction_input = ingenic_gpio_direction_input; |
| 2078 | jzgc->gc.direction_output = ingenic_gpio_direction_output; |
Paul Cercueil | ebd6651 | 2018-08-21 18:42:33 +0200 | [diff] [blame] | 2079 | jzgc->gc.get_direction = ingenic_gpio_get_direction; |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 2080 | |
| 2081 | if (of_property_read_bool(node, "gpio-ranges")) { |
| 2082 | jzgc->gc.request = gpiochip_generic_request; |
| 2083 | jzgc->gc.free = gpiochip_generic_free; |
| 2084 | } |
| 2085 | |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 2086 | jzgc->irq = irq_of_parse_and_map(node, 0); |
| 2087 | if (!jzgc->irq) |
| 2088 | return -EINVAL; |
| 2089 | |
| 2090 | jzgc->irq_chip.name = jzgc->gc.label; |
| 2091 | jzgc->irq_chip.irq_enable = ingenic_gpio_irq_enable; |
| 2092 | jzgc->irq_chip.irq_disable = ingenic_gpio_irq_disable; |
| 2093 | jzgc->irq_chip.irq_unmask = ingenic_gpio_irq_unmask; |
| 2094 | jzgc->irq_chip.irq_mask = ingenic_gpio_irq_mask; |
| 2095 | jzgc->irq_chip.irq_ack = ingenic_gpio_irq_ack; |
| 2096 | jzgc->irq_chip.irq_set_type = ingenic_gpio_irq_set_type; |
| 2097 | jzgc->irq_chip.irq_set_wake = ingenic_gpio_irq_set_wake; |
| 2098 | jzgc->irq_chip.flags = IRQCHIP_MASK_ON_SUSPEND; |
| 2099 | |
Linus Walleij | 142b876 | 2019-10-01 15:32:09 +0200 | [diff] [blame] | 2100 | girq = &jzgc->gc.irq; |
| 2101 | girq->chip = &jzgc->irq_chip; |
| 2102 | girq->parent_handler = ingenic_gpio_irq_handler; |
| 2103 | girq->num_parents = 1; |
| 2104 | girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents), |
| 2105 | GFP_KERNEL); |
| 2106 | if (!girq->parents) |
| 2107 | return -ENOMEM; |
| 2108 | girq->parents[0] = jzgc->irq; |
| 2109 | girq->default_type = IRQ_TYPE_NONE; |
| 2110 | girq->handler = handle_level_irq; |
| 2111 | |
| 2112 | err = devm_gpiochip_add_data(dev, &jzgc->gc, jzgc); |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 2113 | if (err) |
| 2114 | return err; |
| 2115 | |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 2116 | return 0; |
| 2117 | } |
| 2118 | |
Paul Cercueil | 4717b11 | 2018-08-21 18:42:31 +0200 | [diff] [blame] | 2119 | static int __init ingenic_pinctrl_probe(struct platform_device *pdev) |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2120 | { |
| 2121 | struct device *dev = &pdev->dev; |
| 2122 | struct ingenic_pinctrl *jzpc; |
| 2123 | struct pinctrl_desc *pctl_desc; |
| 2124 | void __iomem *base; |
| 2125 | const struct platform_device_id *id = platform_get_device_id(pdev); |
| 2126 | const struct of_device_id *of_id = of_match_device( |
| 2127 | ingenic_pinctrl_of_match, dev); |
| 2128 | const struct ingenic_chip_info *chip_info; |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 2129 | struct device_node *node; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2130 | unsigned int i; |
| 2131 | int err; |
| 2132 | |
| 2133 | jzpc = devm_kzalloc(dev, sizeof(*jzpc), GFP_KERNEL); |
| 2134 | if (!jzpc) |
| 2135 | return -ENOMEM; |
| 2136 | |
| 2137 | base = devm_ioremap_resource(dev, |
| 2138 | platform_get_resource(pdev, IORESOURCE_MEM, 0)); |
Wei Yongjun | 119fcf4 | 2018-01-17 11:29:17 +0000 | [diff] [blame] | 2139 | if (IS_ERR(base)) |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2140 | return PTR_ERR(base); |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2141 | |
| 2142 | jzpc->map = devm_regmap_init_mmio(dev, base, |
| 2143 | &ingenic_pinctrl_regmap_config); |
| 2144 | if (IS_ERR(jzpc->map)) { |
| 2145 | dev_err(dev, "Failed to create regmap\n"); |
| 2146 | return PTR_ERR(jzpc->map); |
| 2147 | } |
| 2148 | |
| 2149 | jzpc->dev = dev; |
| 2150 | |
| 2151 | if (of_id) |
| 2152 | jzpc->version = (enum jz_version)of_id->data; |
| 2153 | else |
| 2154 | jzpc->version = (enum jz_version)id->driver_data; |
| 2155 | |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 2156 | if (jzpc->version >= ID_X1500) |
| 2157 | chip_info = &x1500_chip_info; |
| 2158 | else if (jzpc->version >= ID_X1000E) |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 2159 | chip_info = &x1000e_chip_info; |
| 2160 | else if (jzpc->version >= ID_X1000) |
| 2161 | chip_info = &x1000_chip_info; |
| 2162 | else if (jzpc->version >= ID_JZ4780) |
Zhou Yanjie | ff656e4 | 2019-01-28 23:19:57 +0800 | [diff] [blame] | 2163 | chip_info = &jz4780_chip_info; |
| 2164 | else if (jzpc->version >= ID_JZ4770) |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2165 | chip_info = &jz4770_chip_info; |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 2166 | else if (jzpc->version >= ID_JZ4760B) |
| 2167 | chip_info = &jz4760b_chip_info; |
| 2168 | else if (jzpc->version >= ID_JZ4760) |
| 2169 | chip_info = &jz4760_chip_info; |
Paul Cercueil | f2a9676 | 2018-08-21 18:42:34 +0200 | [diff] [blame] | 2170 | else if (jzpc->version >= ID_JZ4725B) |
| 2171 | chip_info = &jz4725b_chip_info; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2172 | else |
| 2173 | chip_info = &jz4740_chip_info; |
| 2174 | jzpc->info = chip_info; |
| 2175 | |
| 2176 | pctl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctl_desc), GFP_KERNEL); |
| 2177 | if (!pctl_desc) |
| 2178 | return -ENOMEM; |
| 2179 | |
| 2180 | /* fill in pinctrl_desc structure */ |
| 2181 | pctl_desc->name = dev_name(dev); |
| 2182 | pctl_desc->owner = THIS_MODULE; |
| 2183 | pctl_desc->pctlops = &ingenic_pctlops; |
| 2184 | pctl_desc->pmxops = &ingenic_pmxops; |
| 2185 | pctl_desc->confops = &ingenic_confops; |
| 2186 | pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP; |
Kees Cook | a86854d | 2018-06-12 14:07:58 -0700 | [diff] [blame] | 2187 | pctl_desc->pins = jzpc->pdesc = devm_kcalloc(&pdev->dev, |
| 2188 | pctl_desc->npins, sizeof(*jzpc->pdesc), GFP_KERNEL); |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2189 | if (!jzpc->pdesc) |
| 2190 | return -ENOMEM; |
| 2191 | |
| 2192 | for (i = 0; i < pctl_desc->npins; i++) { |
| 2193 | jzpc->pdesc[i].number = i; |
| 2194 | jzpc->pdesc[i].name = kasprintf(GFP_KERNEL, "P%c%d", |
| 2195 | 'A' + (i / PINS_PER_GPIO_CHIP), |
| 2196 | i % PINS_PER_GPIO_CHIP); |
| 2197 | } |
| 2198 | |
| 2199 | jzpc->pctl = devm_pinctrl_register(dev, pctl_desc, jzpc); |
Dan Carpenter | e7f4c4b | 2017-06-14 12:12:09 +0300 | [diff] [blame] | 2200 | if (IS_ERR(jzpc->pctl)) { |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2201 | dev_err(dev, "Failed to register pinctrl\n"); |
Dan Carpenter | e7f4c4b | 2017-06-14 12:12:09 +0300 | [diff] [blame] | 2202 | return PTR_ERR(jzpc->pctl); |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2203 | } |
| 2204 | |
| 2205 | for (i = 0; i < chip_info->num_groups; i++) { |
| 2206 | const struct group_desc *group = &chip_info->groups[i]; |
| 2207 | |
| 2208 | err = pinctrl_generic_add_group(jzpc->pctl, group->name, |
| 2209 | group->pins, group->num_pins, group->data); |
Paul Burton | 823dd71 | 2018-08-25 10:53:28 -0700 | [diff] [blame] | 2210 | if (err < 0) { |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2211 | dev_err(dev, "Failed to register group %s\n", |
| 2212 | group->name); |
| 2213 | return err; |
| 2214 | } |
| 2215 | } |
| 2216 | |
| 2217 | for (i = 0; i < chip_info->num_functions; i++) { |
| 2218 | const struct function_desc *func = &chip_info->functions[i]; |
| 2219 | |
| 2220 | err = pinmux_generic_add_function(jzpc->pctl, func->name, |
| 2221 | func->group_names, func->num_group_names, |
| 2222 | func->data); |
Paul Burton | 823dd71 | 2018-08-25 10:53:28 -0700 | [diff] [blame] | 2223 | if (err < 0) { |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2224 | dev_err(dev, "Failed to register function %s\n", |
| 2225 | func->name); |
| 2226 | return err; |
| 2227 | } |
| 2228 | } |
| 2229 | |
| 2230 | dev_set_drvdata(dev, jzpc->map); |
| 2231 | |
Paul Cercueil | e72394e | 2018-08-21 18:42:32 +0200 | [diff] [blame] | 2232 | for_each_child_of_node(dev->of_node, node) { |
| 2233 | if (of_match_node(ingenic_gpio_of_match, node)) { |
| 2234 | err = ingenic_gpio_probe(jzpc, node); |
| 2235 | if (err) |
| 2236 | return err; |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2237 | } |
| 2238 | } |
| 2239 | |
| 2240 | return 0; |
| 2241 | } |
| 2242 | |
| 2243 | static const struct platform_device_id ingenic_pinctrl_ids[] = { |
| 2244 | { "jz4740-pinctrl", ID_JZ4740 }, |
Paul Cercueil | f2a9676 | 2018-08-21 18:42:34 +0200 | [diff] [blame] | 2245 | { "jz4725b-pinctrl", ID_JZ4725B }, |
Zhou Yanjie | 0257595a | 2019-07-14 11:53:52 +0800 | [diff] [blame] | 2246 | { "jz4760-pinctrl", ID_JZ4760 }, |
| 2247 | { "jz4760b-pinctrl", ID_JZ4760B }, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2248 | { "jz4770-pinctrl", ID_JZ4770 }, |
| 2249 | { "jz4780-pinctrl", ID_JZ4780 }, |
Zhou Yanjie | fe1ad5e | 2019-07-14 11:53:54 +0800 | [diff] [blame] | 2250 | { "x1000-pinctrl", ID_X1000 }, |
| 2251 | { "x1000e-pinctrl", ID_X1000E }, |
Zhou Yanjie | 5d21595 | 2019-07-14 11:53:56 +0800 | [diff] [blame] | 2252 | { "x1500-pinctrl", ID_X1500 }, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2253 | {}, |
| 2254 | }; |
| 2255 | |
| 2256 | static struct platform_driver ingenic_pinctrl_driver = { |
| 2257 | .driver = { |
| 2258 | .name = "pinctrl-ingenic", |
| 2259 | .of_match_table = of_match_ptr(ingenic_pinctrl_of_match), |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2260 | }, |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2261 | .id_table = ingenic_pinctrl_ids, |
| 2262 | }; |
| 2263 | |
| 2264 | static int __init ingenic_pinctrl_drv_register(void) |
| 2265 | { |
Paul Cercueil | 4717b11 | 2018-08-21 18:42:31 +0200 | [diff] [blame] | 2266 | return platform_driver_probe(&ingenic_pinctrl_driver, |
| 2267 | ingenic_pinctrl_probe); |
Paul Cercueil | b5c23aa | 2017-05-12 18:52:56 +0200 | [diff] [blame] | 2268 | } |
Paul Cercueil | 556a36a | 2018-08-21 18:42:30 +0200 | [diff] [blame] | 2269 | subsys_initcall(ingenic_pinctrl_drv_register); |