Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: add NXP S32 SoC family support

Add the pinctrl driver for NXP S32 SoC family. This driver is mainly based
on NXP's downstream implementation on nxp-auto-linux repo[1].

[1] https://github.com/nxp-auto-linux/linux/tree/bsp35.0-5.15.73-rt/drivers/pinctrl/freescale

Signed-off-by: Matthew Nunez <matthew.nunez@nxp.com>
Signed-off-by: Phu Luu An <phu.luuan@nxp.com>
Signed-off-by: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com>
Signed-off-by: Ghennadi Procopciuc <Ghennadi.Procopciuc@oss.nxp.com>
Signed-off-by: Andrei Stefanescu <andrei.stefanescu@nxp.com>
Signed-off-by: Radu Pirea <radu-nicolae.pirea@nxp.com>
Signed-off-by: Chester Lin <clin@suse.com>
Link: https://lore.kernel.org/r/20230220023320.3499-3-clin@suse.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Chester Lin and committed by
Linus Walleij
fd84aaa8 2545625b

+1814
+1
drivers/pinctrl/Kconfig
··· 535 535 source "drivers/pinctrl/mvebu/Kconfig" 536 536 source "drivers/pinctrl/nomadik/Kconfig" 537 537 source "drivers/pinctrl/nuvoton/Kconfig" 538 + source "drivers/pinctrl/nxp/Kconfig" 538 539 source "drivers/pinctrl/pxa/Kconfig" 539 540 source "drivers/pinctrl/qcom/Kconfig" 540 541 source "drivers/pinctrl/ralink/Kconfig"
+1
drivers/pinctrl/Makefile
··· 64 64 obj-y += mvebu/ 65 65 obj-y += nomadik/ 66 66 obj-y += nuvoton/ 67 + obj-y += nxp/ 67 68 obj-$(CONFIG_PINCTRL_PXA) += pxa/ 68 69 obj-$(CONFIG_ARCH_QCOM) += qcom/ 69 70 obj-$(CONFIG_PINCTRL_RALINK) += ralink/
+15
drivers/pinctrl/nxp/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + config PINCTRL_S32CC 3 + bool 4 + depends on ARCH_S32 && OF 5 + select GENERIC_PINCTRL_GROUPS 6 + select GENERIC_PINMUX_FUNCTIONS 7 + select GENERIC_PINCONF 8 + select REGMAP_MMIO 9 + 10 + config PINCTRL_S32G2 11 + depends on ARCH_S32 && OF 12 + bool "NXP S32G2 pinctrl driver" 13 + select PINCTRL_S32CC 14 + help 15 + Say Y here to enable the pinctrl driver for NXP S32G2 family SoCs
+4
drivers/pinctrl/nxp/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # NXP pin control 3 + obj-$(CONFIG_PINCTRL_S32CC) += pinctrl-s32cc.o 4 + obj-$(CONFIG_PINCTRL_S32G2) += pinctrl-s32g2.o
+75
drivers/pinctrl/nxp/pinctrl-s32.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-or-later 2 + * 3 + * S32 pinmux core definitions 4 + * 5 + * Copyright 2016-2020, 2022 NXP 6 + * Copyright (C) 2022 SUSE LLC 7 + * Copyright 2015-2016 Freescale Semiconductor, Inc. 8 + * Copyright (C) 2012 Linaro Ltd. 9 + */ 10 + 11 + #ifndef __DRIVERS_PINCTRL_S32_H 12 + #define __DRIVERS_PINCTRL_S32_H 13 + 14 + struct platform_device; 15 + 16 + /** 17 + * struct s32_pin_group - describes an S32 pin group 18 + * @name: the name of this specific pin group 19 + * @npins: the number of pins in this group array, i.e. the number of 20 + * elements in pin_ids and pin_sss so we can iterate over that array 21 + * @pin_ids: an array of pin IDs in this group 22 + * @pin_sss: an array of source signal select configs paired with pin_ids 23 + */ 24 + struct s32_pin_group { 25 + const char *name; 26 + unsigned int npins; 27 + unsigned int *pin_ids; 28 + unsigned int *pin_sss; 29 + }; 30 + 31 + /** 32 + * struct s32_pmx_func - describes S32 pinmux functions 33 + * @name: the name of this specific function 34 + * @groups: corresponding pin groups 35 + * @num_groups: the number of groups 36 + */ 37 + struct s32_pmx_func { 38 + const char *name; 39 + const char **groups; 40 + unsigned int num_groups; 41 + }; 42 + 43 + /** 44 + * struct s32_pin_range - pin ID range for each memory region. 45 + * @start: start pin ID 46 + * @end: end pin ID 47 + */ 48 + struct s32_pin_range { 49 + unsigned int start; 50 + unsigned int end; 51 + }; 52 + 53 + struct s32_pinctrl_soc_info { 54 + struct device *dev; 55 + const struct pinctrl_pin_desc *pins; 56 + unsigned int npins; 57 + struct s32_pin_group *groups; 58 + unsigned int ngroups; 59 + struct s32_pmx_func *functions; 60 + unsigned int nfunctions; 61 + unsigned int grp_index; 62 + const struct s32_pin_range *mem_pin_ranges; 63 + unsigned int mem_regions; 64 + }; 65 + 66 + #define S32_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin) 67 + #define S32_PIN_RANGE(_start, _end) { .start = _start, .end = _end } 68 + 69 + int s32_pinctrl_probe(struct platform_device *pdev, 70 + struct s32_pinctrl_soc_info *info); 71 + #ifdef CONFIG_PM_SLEEP 72 + int __maybe_unused s32_pinctrl_resume(struct device *dev); 73 + int __maybe_unused s32_pinctrl_suspend(struct device *dev); 74 + #endif 75 + #endif /* __DRIVERS_PINCTRL_S32_H */
+945
drivers/pinctrl/nxp/pinctrl-s32cc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Core driver for the S32 CC (Common Chassis) pin controller 4 + * 5 + * Copyright 2017-2022 NXP 6 + * Copyright (C) 2022 SUSE LLC 7 + * Copyright 2015-2016 Freescale Semiconductor, Inc. 8 + */ 9 + 10 + #include <linux/bitops.h> 11 + #include <linux/err.h> 12 + #include <linux/gpio/driver.h> 13 + #include <linux/init.h> 14 + #include <linux/io.h> 15 + #include <linux/module.h> 16 + #include <linux/of.h> 17 + #include <linux/of_device.h> 18 + #include <linux/pinctrl/machine.h> 19 + #include <linux/pinctrl/pinconf.h> 20 + #include <linux/pinctrl/pinctrl.h> 21 + #include <linux/pinctrl/pinmux.h> 22 + #include <linux/regmap.h> 23 + #include <linux/seq_file.h> 24 + #include <linux/slab.h> 25 + 26 + #include "../core.h" 27 + #include "../pinconf.h" 28 + #include "../pinctrl-utils.h" 29 + #include "pinctrl-s32.h" 30 + 31 + #define S32_PIN_ID_MASK GENMASK(31, 4) 32 + 33 + #define S32_MSCR_SSS_MASK GENMASK(2, 0) 34 + #define S32_MSCR_PUS BIT(12) 35 + #define S32_MSCR_PUE BIT(13) 36 + #define S32_MSCR_SRE(X) (((X) & GENMASK(3, 0)) << 14) 37 + #define S32_MSCR_IBE BIT(19) 38 + #define S32_MSCR_ODE BIT(20) 39 + #define S32_MSCR_OBE BIT(21) 40 + 41 + static struct regmap_config s32_regmap_config = { 42 + .reg_bits = 32, 43 + .val_bits = 32, 44 + .reg_stride = 4, 45 + }; 46 + 47 + static u32 get_pin_no(u32 pinmux) 48 + { 49 + return (pinmux & S32_PIN_ID_MASK) >> __ffs(S32_PIN_ID_MASK); 50 + } 51 + 52 + static u32 get_pin_func(u32 pinmux) 53 + { 54 + return pinmux & GENMASK(3, 0); 55 + } 56 + 57 + struct s32_pinctrl_mem_region { 58 + struct regmap *map; 59 + const struct s32_pin_range *pin_range; 60 + char name[8]; 61 + }; 62 + 63 + /* 64 + * Holds pin configuration for GPIO's. 65 + * @pin_id: Pin ID for this GPIO 66 + * @config: Pin settings 67 + * @list: Linked list entry for each gpio pin 68 + */ 69 + struct gpio_pin_config { 70 + unsigned int pin_id; 71 + unsigned int config; 72 + struct list_head list; 73 + }; 74 + 75 + /* 76 + * Pad config save/restore for power suspend/resume. 77 + */ 78 + struct s32_pinctrl_context { 79 + unsigned int *pads; 80 + }; 81 + 82 + /* 83 + * @dev: a pointer back to containing device 84 + * @pctl: a pointer to the pinctrl device structure 85 + * @regions: reserved memory regions with start/end pin 86 + * @info: structure containing information about the pin 87 + * @gpio_configs: Saved configurations for GPIO pins 88 + * @gpiop_configs_lock: lock for the `gpio_configs` list 89 + * @s32_pinctrl_context: Configuration saved over system sleep 90 + */ 91 + struct s32_pinctrl { 92 + struct device *dev; 93 + struct pinctrl_dev *pctl; 94 + struct s32_pinctrl_mem_region *regions; 95 + struct s32_pinctrl_soc_info *info; 96 + struct list_head gpio_configs; 97 + spinlock_t gpio_configs_lock; 98 + #ifdef CONFIG_PM_SLEEP 99 + struct s32_pinctrl_context saved_context; 100 + #endif 101 + }; 102 + 103 + static struct s32_pinctrl_mem_region * 104 + s32_get_region(struct pinctrl_dev *pctldev, unsigned int pin) 105 + { 106 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 107 + const struct s32_pin_range *pin_range; 108 + unsigned int mem_regions = ipctl->info->mem_regions; 109 + unsigned int i; 110 + 111 + for (i = 0; i < mem_regions; ++i) { 112 + pin_range = ipctl->regions[i].pin_range; 113 + if (pin >= pin_range->start && pin <= pin_range->end) 114 + return &ipctl->regions[i]; 115 + } 116 + 117 + return NULL; 118 + } 119 + 120 + static inline int s32_check_pin(struct pinctrl_dev *pctldev, 121 + unsigned int pin) 122 + { 123 + return s32_get_region(pctldev, pin) ? 0 : -EINVAL; 124 + } 125 + 126 + static inline int s32_regmap_read(struct pinctrl_dev *pctldev, 127 + unsigned int pin, unsigned int *val) 128 + { 129 + struct s32_pinctrl_mem_region *region; 130 + unsigned int offset; 131 + 132 + region = s32_get_region(pctldev, pin); 133 + if (!region) 134 + return -EINVAL; 135 + 136 + offset = (pin - region->pin_range->start) * 137 + regmap_get_reg_stride(region->map); 138 + 139 + return regmap_read(region->map, offset, val); 140 + } 141 + 142 + static inline int s32_regmap_write(struct pinctrl_dev *pctldev, 143 + unsigned int pin, 144 + unsigned int val) 145 + { 146 + struct s32_pinctrl_mem_region *region; 147 + unsigned int offset; 148 + 149 + region = s32_get_region(pctldev, pin); 150 + if (!region) 151 + return -EINVAL; 152 + 153 + offset = (pin - region->pin_range->start) * 154 + regmap_get_reg_stride(region->map); 155 + 156 + return regmap_write(region->map, offset, val); 157 + 158 + } 159 + 160 + static inline int s32_regmap_update(struct pinctrl_dev *pctldev, unsigned int pin, 161 + unsigned int mask, unsigned int val) 162 + { 163 + struct s32_pinctrl_mem_region *region; 164 + unsigned int offset; 165 + 166 + region = s32_get_region(pctldev, pin); 167 + if (!region) 168 + return -EINVAL; 169 + 170 + offset = (pin - region->pin_range->start) * 171 + regmap_get_reg_stride(region->map); 172 + 173 + return regmap_update_bits(region->map, offset, mask, val); 174 + } 175 + 176 + static int s32_get_groups_count(struct pinctrl_dev *pctldev) 177 + { 178 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 179 + const struct s32_pinctrl_soc_info *info = ipctl->info; 180 + 181 + return info->ngroups; 182 + } 183 + 184 + static const char *s32_get_group_name(struct pinctrl_dev *pctldev, 185 + unsigned int selector) 186 + { 187 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 188 + const struct s32_pinctrl_soc_info *info = ipctl->info; 189 + 190 + return info->groups[selector].name; 191 + } 192 + 193 + static int s32_get_group_pins(struct pinctrl_dev *pctldev, 194 + unsigned int selector, const unsigned int **pins, 195 + unsigned int *npins) 196 + { 197 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 198 + const struct s32_pinctrl_soc_info *info = ipctl->info; 199 + 200 + *pins = info->groups[selector].pin_ids; 201 + *npins = info->groups[selector].npins; 202 + 203 + return 0; 204 + } 205 + 206 + static void s32_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, 207 + unsigned int offset) 208 + { 209 + seq_printf(s, "%s", dev_name(pctldev->dev)); 210 + } 211 + 212 + static int s32_dt_group_node_to_map(struct pinctrl_dev *pctldev, 213 + struct device_node *np, 214 + struct pinctrl_map **map, 215 + unsigned int *reserved_maps, 216 + unsigned int *num_maps, 217 + const char *func_name) 218 + { 219 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 220 + struct device *dev = ipctl->dev; 221 + unsigned long *cfgs = NULL; 222 + unsigned int n_cfgs, reserve = 1; 223 + int n_pins, ret; 224 + 225 + n_pins = of_property_count_elems_of_size(np, "pinmux", sizeof(u32)); 226 + if (n_pins < 0) { 227 + dev_warn(dev, "Unable to find 'pinmux' property in node %s.\n", 228 + np->name); 229 + } else if (!n_pins) { 230 + return -EINVAL; 231 + } 232 + 233 + ret = pinconf_generic_parse_dt_config(np, pctldev, &cfgs, &n_cfgs); 234 + if (ret) { 235 + dev_err(dev, "%pOF: could not parse node property\n", np); 236 + return ret; 237 + } 238 + 239 + if (n_cfgs) 240 + reserve++; 241 + 242 + ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps, num_maps, 243 + reserve); 244 + if (ret < 0) 245 + goto free_cfgs; 246 + 247 + ret = pinctrl_utils_add_map_mux(pctldev, map, reserved_maps, num_maps, 248 + np->name, func_name); 249 + if (ret < 0) 250 + goto free_cfgs; 251 + 252 + if (n_cfgs) { 253 + ret = pinctrl_utils_add_map_configs(pctldev, map, reserved_maps, 254 + num_maps, np->name, cfgs, n_cfgs, 255 + PIN_MAP_TYPE_CONFIGS_GROUP); 256 + if (ret < 0) 257 + goto free_cfgs; 258 + } 259 + 260 + free_cfgs: 261 + kfree(cfgs); 262 + return ret; 263 + } 264 + 265 + static int s32_dt_node_to_map(struct pinctrl_dev *pctldev, 266 + struct device_node *np_config, 267 + struct pinctrl_map **map, 268 + unsigned int *num_maps) 269 + { 270 + unsigned int reserved_maps; 271 + struct device_node *np; 272 + int ret = 0; 273 + 274 + reserved_maps = 0; 275 + *map = NULL; 276 + *num_maps = 0; 277 + 278 + for_each_available_child_of_node(np_config, np) { 279 + ret = s32_dt_group_node_to_map(pctldev, np, map, 280 + &reserved_maps, num_maps, 281 + np_config->name); 282 + if (ret < 0) 283 + break; 284 + } 285 + 286 + if (ret) 287 + pinctrl_utils_free_map(pctldev, *map, *num_maps); 288 + 289 + return ret; 290 + 291 + } 292 + 293 + static const struct pinctrl_ops s32_pctrl_ops = { 294 + .get_groups_count = s32_get_groups_count, 295 + .get_group_name = s32_get_group_name, 296 + .get_group_pins = s32_get_group_pins, 297 + .pin_dbg_show = s32_pin_dbg_show, 298 + .dt_node_to_map = s32_dt_node_to_map, 299 + .dt_free_map = pinctrl_utils_free_map, 300 + }; 301 + 302 + static int s32_pmx_set(struct pinctrl_dev *pctldev, unsigned int selector, 303 + unsigned int group) 304 + { 305 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 306 + const struct s32_pinctrl_soc_info *info = ipctl->info; 307 + int i, ret; 308 + struct s32_pin_group *grp; 309 + 310 + /* 311 + * Configure the mux mode for each pin in the group for a specific 312 + * function. 313 + */ 314 + grp = &info->groups[group]; 315 + 316 + dev_dbg(ipctl->dev, "set mux for function %s group %s\n", 317 + info->functions[selector].name, grp->name); 318 + 319 + /* Check beforehand so we don't have a partial config. */ 320 + for (i = 0; i < grp->npins; ++i) { 321 + if (s32_check_pin(pctldev, grp->pin_ids[i]) != 0) { 322 + dev_err(info->dev, "invalid pin: %d in group: %d\n", 323 + grp->pin_ids[i], group); 324 + return -EINVAL; 325 + } 326 + } 327 + 328 + for (i = 0, ret = 0; i < grp->npins && !ret; ++i) { 329 + ret = s32_regmap_update(pctldev, grp->pin_ids[i], 330 + S32_MSCR_SSS_MASK, grp->pin_sss[i]); 331 + } 332 + 333 + return ret; 334 + } 335 + 336 + static int s32_pmx_get_funcs_count(struct pinctrl_dev *pctldev) 337 + { 338 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 339 + const struct s32_pinctrl_soc_info *info = ipctl->info; 340 + 341 + return info->nfunctions; 342 + } 343 + 344 + static const char *s32_pmx_get_func_name(struct pinctrl_dev *pctldev, 345 + unsigned int selector) 346 + { 347 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 348 + const struct s32_pinctrl_soc_info *info = ipctl->info; 349 + 350 + return info->functions[selector].name; 351 + } 352 + 353 + static int s32_pmx_get_groups(struct pinctrl_dev *pctldev, 354 + unsigned int selector, 355 + const char * const **groups, 356 + unsigned int * const num_groups) 357 + { 358 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 359 + const struct s32_pinctrl_soc_info *info = ipctl->info; 360 + 361 + *groups = info->functions[selector].groups; 362 + *num_groups = info->functions[selector].num_groups; 363 + 364 + return 0; 365 + } 366 + 367 + static int s32_pmx_gpio_request_enable(struct pinctrl_dev *pctldev, 368 + struct pinctrl_gpio_range *range, 369 + unsigned int offset) 370 + { 371 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 372 + struct gpio_pin_config *gpio_pin; 373 + unsigned int config; 374 + unsigned long flags; 375 + int ret; 376 + 377 + ret = s32_regmap_read(pctldev, offset, &config); 378 + if (ret != 0) 379 + return -EINVAL; 380 + 381 + /* Save current configuration */ 382 + gpio_pin = kmalloc(sizeof(*gpio_pin), GFP_KERNEL); 383 + if (!gpio_pin) 384 + return -ENOMEM; 385 + 386 + gpio_pin->pin_id = offset; 387 + gpio_pin->config = config; 388 + 389 + spin_lock_irqsave(&ipctl->gpio_configs_lock, flags); 390 + list_add(&(gpio_pin->list), &(ipctl->gpio_configs)); 391 + spin_unlock_irqrestore(&ipctl->gpio_configs_lock, flags); 392 + 393 + /* GPIO pin means SSS = 0 */ 394 + config &= ~S32_MSCR_SSS_MASK; 395 + 396 + return s32_regmap_write(pctldev, offset, config); 397 + } 398 + 399 + static void s32_pmx_gpio_disable_free(struct pinctrl_dev *pctldev, 400 + struct pinctrl_gpio_range *range, 401 + unsigned int offset) 402 + { 403 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 404 + struct list_head *pos, *tmp; 405 + struct gpio_pin_config *gpio_pin; 406 + unsigned long flags; 407 + int ret; 408 + 409 + spin_lock_irqsave(&ipctl->gpio_configs_lock, flags); 410 + 411 + list_for_each_safe(pos, tmp, &ipctl->gpio_configs) { 412 + gpio_pin = list_entry(pos, struct gpio_pin_config, list); 413 + 414 + if (gpio_pin->pin_id == offset) { 415 + ret = s32_regmap_write(pctldev, gpio_pin->pin_id, 416 + gpio_pin->config); 417 + if (ret != 0) 418 + goto unlock; 419 + 420 + list_del(pos); 421 + kfree(gpio_pin); 422 + break; 423 + } 424 + } 425 + 426 + unlock: 427 + spin_unlock_irqrestore(&ipctl->gpio_configs_lock, flags); 428 + } 429 + 430 + static int s32_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, 431 + struct pinctrl_gpio_range *range, 432 + unsigned int offset, 433 + bool input) 434 + { 435 + unsigned int config; 436 + unsigned int mask = S32_MSCR_IBE | S32_MSCR_OBE; 437 + 438 + if (input) { 439 + /* Disable output buffer and enable input buffer */ 440 + config = S32_MSCR_IBE; 441 + } else { 442 + /* Disable input buffer and enable output buffer */ 443 + config = S32_MSCR_OBE; 444 + } 445 + 446 + return s32_regmap_update(pctldev, offset, mask, config); 447 + } 448 + 449 + static const struct pinmux_ops s32_pmx_ops = { 450 + .get_functions_count = s32_pmx_get_funcs_count, 451 + .get_function_name = s32_pmx_get_func_name, 452 + .get_function_groups = s32_pmx_get_groups, 453 + .set_mux = s32_pmx_set, 454 + .gpio_request_enable = s32_pmx_gpio_request_enable, 455 + .gpio_disable_free = s32_pmx_gpio_disable_free, 456 + .gpio_set_direction = s32_pmx_gpio_set_direction, 457 + }; 458 + 459 + /* Set the reserved elements as -1 */ 460 + static const int support_slew[] = {208, -1, -1, -1, 166, 150, 133, 83}; 461 + 462 + static int s32_get_slew_regval(int arg) 463 + { 464 + int i; 465 + /* Translate a real slew rate (MHz) to a register value */ 466 + for (i = 0; i < ARRAY_SIZE(support_slew); i++) { 467 + if (arg == support_slew[i]) 468 + return i; 469 + } 470 + 471 + return -EINVAL; 472 + } 473 + 474 + static int s32_get_pin_conf(enum pin_config_param param, u32 arg, 475 + unsigned int *mask, unsigned int *config) 476 + { 477 + int ret; 478 + 479 + switch (param) { 480 + /* All pins are persistent over suspend */ 481 + case PIN_CONFIG_PERSIST_STATE: 482 + return 0; 483 + case PIN_CONFIG_DRIVE_OPEN_DRAIN: 484 + *config |= S32_MSCR_ODE; 485 + *mask |= S32_MSCR_ODE; 486 + break; 487 + case PIN_CONFIG_OUTPUT_ENABLE: 488 + if (arg) 489 + *config |= S32_MSCR_OBE; 490 + else 491 + *config &= ~S32_MSCR_OBE; 492 + *mask |= S32_MSCR_OBE; 493 + break; 494 + case PIN_CONFIG_INPUT_ENABLE: 495 + if (arg) 496 + *config |= S32_MSCR_IBE; 497 + else 498 + *config &= ~S32_MSCR_IBE; 499 + *mask |= S32_MSCR_IBE; 500 + break; 501 + case PIN_CONFIG_SLEW_RATE: 502 + ret = s32_get_slew_regval(arg); 503 + if (ret < 0) 504 + return ret; 505 + *config |= S32_MSCR_SRE((u32)ret); 506 + *mask |= S32_MSCR_SRE(~0); 507 + break; 508 + case PIN_CONFIG_BIAS_PULL_UP: 509 + if (arg) 510 + *config |= S32_MSCR_PUS; 511 + else 512 + *config &= ~S32_MSCR_PUS; 513 + fallthrough; 514 + case PIN_CONFIG_BIAS_PULL_DOWN: 515 + if (arg) 516 + *config |= S32_MSCR_PUE; 517 + else 518 + *config &= ~S32_MSCR_PUE; 519 + *mask |= S32_MSCR_PUE | S32_MSCR_PUS; 520 + break; 521 + case PIN_CONFIG_BIAS_HIGH_IMPEDANCE: 522 + *config &= ~(S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE); 523 + *mask |= S32_MSCR_ODE | S32_MSCR_OBE | S32_MSCR_IBE; 524 + fallthrough; 525 + case PIN_CONFIG_BIAS_DISABLE: 526 + *config &= ~(S32_MSCR_PUS | S32_MSCR_PUE); 527 + *mask |= S32_MSCR_PUS | S32_MSCR_PUE; 528 + break; 529 + default: 530 + return -EOPNOTSUPP; 531 + } 532 + 533 + return 0; 534 + } 535 + 536 + static int s32_pinconf_mscr_update(struct pinctrl_dev *pctldev, 537 + unsigned int pin_id, 538 + unsigned long *configs, 539 + unsigned int num_configs) 540 + { 541 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 542 + unsigned int config = 0, mask = 0; 543 + int i, ret; 544 + 545 + if (s32_check_pin(pctldev, pin_id) != 0) 546 + return -EINVAL; 547 + 548 + dev_dbg(ipctl->dev, "pinconf set pin %s with %d configs\n", 549 + pin_get_name(pctldev, pin_id), num_configs); 550 + 551 + for (i = 0; i < num_configs; i++) { 552 + ret = s32_get_pin_conf(pinconf_to_config_param(configs[i]), 553 + pinconf_to_config_argument(configs[i]), 554 + &mask, &config); 555 + if (ret) 556 + return ret; 557 + } 558 + 559 + if (!config && !mask) 560 + return 0; 561 + 562 + ret = s32_regmap_update(pctldev, pin_id, mask, config); 563 + 564 + dev_dbg(ipctl->dev, "update: pin %d cfg 0x%x\n", pin_id, config); 565 + 566 + return ret; 567 + } 568 + 569 + static int s32_pinconf_get(struct pinctrl_dev *pctldev, 570 + unsigned int pin_id, 571 + unsigned long *config) 572 + { 573 + return s32_regmap_read(pctldev, pin_id, (unsigned int *)config); 574 + } 575 + 576 + static int s32_pinconf_set(struct pinctrl_dev *pctldev, 577 + unsigned int pin_id, unsigned long *configs, 578 + unsigned int num_configs) 579 + { 580 + return s32_pinconf_mscr_update(pctldev, pin_id, configs, 581 + num_configs); 582 + } 583 + 584 + static int s32_pconf_group_set(struct pinctrl_dev *pctldev, unsigned int selector, 585 + unsigned long *configs, unsigned int num_configs) 586 + { 587 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 588 + const struct s32_pinctrl_soc_info *info = ipctl->info; 589 + struct s32_pin_group *grp; 590 + int i, ret; 591 + 592 + grp = &info->groups[selector]; 593 + for (i = 0; i < grp->npins; i++) { 594 + ret = s32_pinconf_mscr_update(pctldev, grp->pin_ids[i], 595 + configs, num_configs); 596 + if (ret) 597 + return ret; 598 + } 599 + 600 + return 0; 601 + } 602 + 603 + static void s32_pinconf_dbg_show(struct pinctrl_dev *pctldev, 604 + struct seq_file *s, unsigned int pin_id) 605 + { 606 + unsigned int config; 607 + int ret = s32_regmap_read(pctldev, pin_id, &config); 608 + 609 + if (!ret) 610 + seq_printf(s, "0x%x", config); 611 + } 612 + 613 + static void s32_pinconf_group_dbg_show(struct pinctrl_dev *pctldev, 614 + struct seq_file *s, unsigned int selector) 615 + { 616 + struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev); 617 + const struct s32_pinctrl_soc_info *info = ipctl->info; 618 + struct s32_pin_group *grp; 619 + unsigned int config; 620 + const char *name; 621 + int i, ret; 622 + 623 + seq_puts(s, "\n"); 624 + grp = &info->groups[selector]; 625 + for (i = 0; i < grp->npins; i++) { 626 + name = pin_get_name(pctldev, grp->pin_ids[i]); 627 + ret = s32_regmap_read(pctldev, grp->pin_ids[i], &config); 628 + if (ret) 629 + return; 630 + seq_printf(s, "%s: 0x%x\n", name, config); 631 + } 632 + } 633 + 634 + static const struct pinconf_ops s32_pinconf_ops = { 635 + .pin_config_get = s32_pinconf_get, 636 + .pin_config_set = s32_pinconf_set, 637 + .pin_config_group_set = s32_pconf_group_set, 638 + .pin_config_dbg_show = s32_pinconf_dbg_show, 639 + .pin_config_group_dbg_show = s32_pinconf_group_dbg_show, 640 + }; 641 + 642 + #ifdef CONFIG_PM_SLEEP 643 + static bool s32_pinctrl_should_save(struct s32_pinctrl *ipctl, 644 + unsigned int pin) 645 + { 646 + const struct pin_desc *pd = pin_desc_get(ipctl->pctl, pin); 647 + 648 + if (!pd) 649 + return false; 650 + 651 + /* 652 + * Only restore the pin if it is actually in use by the kernel (or 653 + * by userspace). 654 + */ 655 + if (pd->mux_owner || pd->gpio_owner) 656 + return true; 657 + 658 + return false; 659 + } 660 + 661 + int __maybe_unused s32_pinctrl_suspend(struct device *dev) 662 + { 663 + struct platform_device *pdev = to_platform_device(dev); 664 + struct s32_pinctrl *ipctl = platform_get_drvdata(pdev); 665 + const struct pinctrl_pin_desc *pin; 666 + const struct s32_pinctrl_soc_info *info = ipctl->info; 667 + struct s32_pinctrl_context *saved_context = &ipctl->saved_context; 668 + int i; 669 + int ret; 670 + unsigned int config; 671 + 672 + for (i = 0; i < info->npins; i++) { 673 + pin = &info->pins[i]; 674 + 675 + if (!s32_pinctrl_should_save(ipctl, pin->number)) 676 + continue; 677 + 678 + ret = s32_regmap_read(ipctl->pctl, pin->number, &config); 679 + if (ret) 680 + return -EINVAL; 681 + 682 + saved_context->pads[i] = config; 683 + } 684 + 685 + return 0; 686 + } 687 + 688 + int __maybe_unused s32_pinctrl_resume(struct device *dev) 689 + { 690 + struct platform_device *pdev = to_platform_device(dev); 691 + struct s32_pinctrl *ipctl = platform_get_drvdata(pdev); 692 + const struct s32_pinctrl_soc_info *info = ipctl->info; 693 + const struct pinctrl_pin_desc *pin; 694 + struct s32_pinctrl_context *saved_context = &ipctl->saved_context; 695 + int ret, i; 696 + 697 + for (i = 0; i < info->npins; i++) { 698 + pin = &info->pins[i]; 699 + 700 + if (!s32_pinctrl_should_save(ipctl, pin->number)) 701 + continue; 702 + 703 + ret = s32_regmap_write(ipctl->pctl, pin->number, 704 + saved_context->pads[i]); 705 + if (ret) 706 + return ret; 707 + } 708 + 709 + return 0; 710 + } 711 + #endif 712 + 713 + static void s32_pinctrl_parse_groups(struct device_node *np, 714 + struct s32_pin_group *grp, 715 + struct s32_pinctrl_soc_info *info) 716 + { 717 + const __be32 *p; 718 + struct device *dev; 719 + struct property *prop; 720 + int i, npins; 721 + u32 pinmux; 722 + 723 + dev = info->dev; 724 + 725 + dev_dbg(dev, "group: %s\n", np->name); 726 + 727 + /* Initialise group */ 728 + grp->name = np->name; 729 + 730 + npins = of_property_count_elems_of_size(np, "pinmux", sizeof(u32)); 731 + 732 + if (npins < 0) { 733 + dev_err(dev, "Failed to read 'pinmux' property in node %s.\n", 734 + np->name); 735 + return; 736 + } 737 + if (!npins) { 738 + dev_err(dev, "The group %s has no pins.\n", np->name); 739 + return; 740 + } 741 + 742 + grp->npins = npins; 743 + 744 + grp->pin_ids = devm_kcalloc(info->dev, grp->npins, 745 + sizeof(unsigned int), GFP_KERNEL); 746 + grp->pin_sss = devm_kcalloc(info->dev, grp->npins, 747 + sizeof(unsigned int), GFP_KERNEL); 748 + 749 + if (!grp->pin_ids || !grp->pin_sss) { 750 + dev_err(dev, "Failed to allocate memory for the group %s.\n", 751 + np->name); 752 + return; 753 + } 754 + 755 + i = 0; 756 + of_property_for_each_u32(np, "pinmux", prop, p, pinmux) { 757 + grp->pin_ids[i] = get_pin_no(pinmux); 758 + grp->pin_sss[i] = get_pin_func(pinmux); 759 + 760 + dev_dbg(info->dev, "pin-id: 0x%x, sss: 0x%x", 761 + grp->pin_ids[i], grp->pin_sss[i]); 762 + i++; 763 + } 764 + } 765 + 766 + static void s32_pinctrl_parse_functions(struct device_node *np, 767 + struct s32_pinctrl_soc_info *info, 768 + u32 index) 769 + { 770 + struct device_node *child; 771 + struct s32_pmx_func *func; 772 + struct s32_pin_group *grp; 773 + u32 i = 0; 774 + 775 + dev_dbg(info->dev, "parse function(%d): %s\n", index, np->name); 776 + 777 + func = &info->functions[index]; 778 + 779 + /* Initialise function */ 780 + func->name = np->name; 781 + func->num_groups = of_get_child_count(np); 782 + if (func->num_groups == 0) { 783 + dev_err(info->dev, "no groups defined in %s\n", np->full_name); 784 + return; 785 + } 786 + func->groups = devm_kzalloc(info->dev, 787 + func->num_groups * sizeof(char *), GFP_KERNEL); 788 + 789 + for_each_child_of_node(np, child) { 790 + func->groups[i] = child->name; 791 + grp = &info->groups[info->grp_index++]; 792 + s32_pinctrl_parse_groups(child, grp, info); 793 + i++; 794 + } 795 + } 796 + 797 + static int s32_pinctrl_probe_dt(struct platform_device *pdev, 798 + struct s32_pinctrl *ipctl) 799 + { 800 + struct s32_pinctrl_soc_info *info = ipctl->info; 801 + struct device_node *np = pdev->dev.of_node; 802 + struct device_node *child; 803 + struct resource *res; 804 + struct regmap *map; 805 + void __iomem *base; 806 + int mem_regions = info->mem_regions; 807 + u32 nfuncs = 0; 808 + u32 i = 0; 809 + 810 + if (!np) 811 + return -ENODEV; 812 + 813 + if (mem_regions == 0) { 814 + dev_err(&pdev->dev, "mem_regions is 0\n"); 815 + return -EINVAL; 816 + } 817 + 818 + ipctl->regions = devm_kzalloc(&pdev->dev, 819 + mem_regions * sizeof(*(ipctl->regions)), 820 + GFP_KERNEL); 821 + if (!ipctl->regions) 822 + return -ENOMEM; 823 + 824 + for (i = 0; i < mem_regions; ++i) { 825 + base = devm_platform_get_and_ioremap_resource(pdev, i, &res); 826 + if (IS_ERR(base)) 827 + return PTR_ERR(base); 828 + 829 + snprintf(ipctl->regions[i].name, 830 + sizeof(ipctl->regions[i].name), "map%u", i); 831 + 832 + s32_regmap_config.name = ipctl->regions[i].name; 833 + s32_regmap_config.max_register = resource_size(res) - 834 + s32_regmap_config.reg_stride; 835 + 836 + map = devm_regmap_init_mmio(&pdev->dev, base, 837 + &s32_regmap_config); 838 + if (IS_ERR(map)) { 839 + dev_err(&pdev->dev, "Failed to init regmap[%u]\n", i); 840 + return PTR_ERR(map); 841 + } 842 + 843 + ipctl->regions[i].map = map; 844 + ipctl->regions[i].pin_range = &info->mem_pin_ranges[i]; 845 + } 846 + 847 + nfuncs = of_get_child_count(np); 848 + if (nfuncs <= 0) { 849 + dev_err(&pdev->dev, "no functions defined\n"); 850 + return -EINVAL; 851 + } 852 + 853 + info->nfunctions = nfuncs; 854 + info->functions = devm_kzalloc(&pdev->dev, 855 + nfuncs * sizeof(struct s32_pmx_func), 856 + GFP_KERNEL); 857 + if (!info->functions) 858 + return -ENOMEM; 859 + 860 + info->ngroups = 0; 861 + for_each_child_of_node(np, child) 862 + info->ngroups += of_get_child_count(child); 863 + info->groups = devm_kzalloc(&pdev->dev, 864 + info->ngroups * sizeof(struct s32_pin_group), 865 + GFP_KERNEL); 866 + if (!info->groups) 867 + return -ENOMEM; 868 + 869 + i = 0; 870 + for_each_child_of_node(np, child) 871 + s32_pinctrl_parse_functions(child, info, i++); 872 + 873 + return 0; 874 + } 875 + 876 + int s32_pinctrl_probe(struct platform_device *pdev, 877 + struct s32_pinctrl_soc_info *info) 878 + { 879 + struct s32_pinctrl *ipctl; 880 + int ret; 881 + struct pinctrl_desc *s32_pinctrl_desc; 882 + #ifdef CONFIG_PM_SLEEP 883 + struct s32_pinctrl_context *saved_context; 884 + #endif 885 + 886 + if (!info || !info->pins || !info->npins) { 887 + dev_err(&pdev->dev, "wrong pinctrl info\n"); 888 + return -EINVAL; 889 + } 890 + 891 + info->dev = &pdev->dev; 892 + 893 + /* Create state holders etc for this driver */ 894 + ipctl = devm_kzalloc(&pdev->dev, sizeof(*ipctl), GFP_KERNEL); 895 + if (!ipctl) 896 + return -ENOMEM; 897 + 898 + ipctl->info = info; 899 + ipctl->dev = info->dev; 900 + platform_set_drvdata(pdev, ipctl); 901 + 902 + INIT_LIST_HEAD(&ipctl->gpio_configs); 903 + spin_lock_init(&ipctl->gpio_configs_lock); 904 + 905 + s32_pinctrl_desc = 906 + devm_kmalloc(&pdev->dev, sizeof(*s32_pinctrl_desc), GFP_KERNEL); 907 + if (!s32_pinctrl_desc) 908 + return -ENOMEM; 909 + 910 + s32_pinctrl_desc->name = dev_name(&pdev->dev); 911 + s32_pinctrl_desc->pins = info->pins; 912 + s32_pinctrl_desc->npins = info->npins; 913 + s32_pinctrl_desc->pctlops = &s32_pctrl_ops; 914 + s32_pinctrl_desc->pmxops = &s32_pmx_ops; 915 + s32_pinctrl_desc->confops = &s32_pinconf_ops; 916 + s32_pinctrl_desc->owner = THIS_MODULE; 917 + 918 + ret = s32_pinctrl_probe_dt(pdev, ipctl); 919 + if (ret) { 920 + dev_err(&pdev->dev, "fail to probe dt properties\n"); 921 + return ret; 922 + } 923 + 924 + ipctl->pctl = devm_pinctrl_register(&pdev->dev, s32_pinctrl_desc, 925 + ipctl); 926 + 927 + if (IS_ERR(ipctl->pctl)) { 928 + dev_err(&pdev->dev, "could not register s32 pinctrl driver\n"); 929 + return PTR_ERR(ipctl->pctl); 930 + } 931 + 932 + #ifdef CONFIG_PM_SLEEP 933 + saved_context = &ipctl->saved_context; 934 + saved_context->pads = 935 + devm_kcalloc(&pdev->dev, info->npins, 936 + sizeof(*saved_context->pads), 937 + GFP_KERNEL); 938 + if (!saved_context->pads) 939 + return -ENOMEM; 940 + #endif 941 + 942 + dev_info(&pdev->dev, "initialized s32 pinctrl driver\n"); 943 + 944 + return 0; 945 + }
+773
drivers/pinctrl/nxp/pinctrl-s32g2.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * NXP S32G pinctrl driver 4 + * 5 + * Copyright 2015-2016 Freescale Semiconductor, Inc. 6 + * Copyright 2017-2018, 2020-2022 NXP 7 + * Copyright (C) 2022 SUSE LLC 8 + */ 9 + 10 + #include <linux/err.h> 11 + #include <linux/init.h> 12 + #include <linux/io.h> 13 + #include <linux/module.h> 14 + #include <linux/of.h> 15 + #include <linux/of_device.h> 16 + #include <linux/pinctrl/pinctrl.h> 17 + 18 + #include "pinctrl-s32.h" 19 + 20 + enum s32_pins { 21 + S32G_MSCR_PA_00 = 0, 22 + S32G_MSCR_PA_01 = 1, 23 + S32G_MSCR_PA_02 = 2, 24 + S32G_MSCR_PA_03 = 3, 25 + S32G_MSCR_PA_04 = 4, 26 + S32G_MSCR_PA_05 = 5, 27 + S32G_MSCR_PA_06 = 6, 28 + S32G_MSCR_PA_07 = 7, 29 + S32G_MSCR_PA_08 = 8, 30 + S32G_MSCR_PA_09 = 9, 31 + S32G_MSCR_PA_10 = 10, 32 + S32G_MSCR_PA_11 = 11, 33 + S32G_MSCR_PA_12 = 12, 34 + S32G_MSCR_PA_13 = 13, 35 + S32G_MSCR_PA_14 = 14, 36 + S32G_MSCR_PA_15 = 15, 37 + S32G_MSCR_PB_00 = 16, 38 + S32G_MSCR_PB_01 = 17, 39 + S32G_MSCR_PB_02 = 18, 40 + S32G_MSCR_PB_03 = 19, 41 + S32G_MSCR_PB_04 = 20, 42 + S32G_MSCR_PB_05 = 21, 43 + S32G_MSCR_PB_06 = 22, 44 + S32G_MSCR_PB_07 = 23, 45 + S32G_MSCR_PB_08 = 24, 46 + S32G_MSCR_PB_09 = 25, 47 + S32G_MSCR_PB_10 = 26, 48 + S32G_MSCR_PB_11 = 27, 49 + S32G_MSCR_PB_12 = 28, 50 + S32G_MSCR_PB_13 = 29, 51 + S32G_MSCR_PB_14 = 30, 52 + S32G_MSCR_PB_15 = 31, 53 + S32G_MSCR_PC_00 = 32, 54 + S32G_MSCR_PC_01 = 33, 55 + S32G_MSCR_PC_02 = 34, 56 + S32G_MSCR_PC_03 = 35, 57 + S32G_MSCR_PC_04 = 36, 58 + S32G_MSCR_PC_05 = 37, 59 + S32G_MSCR_PC_06 = 38, 60 + S32G_MSCR_PC_07 = 39, 61 + S32G_MSCR_PC_08 = 40, 62 + S32G_MSCR_PC_09 = 41, 63 + S32G_MSCR_PC_10 = 42, 64 + S32G_MSCR_PC_11 = 43, 65 + S32G_MSCR_PC_12 = 44, 66 + S32G_MSCR_PC_13 = 45, 67 + S32G_MSCR_PC_14 = 46, 68 + S32G_MSCR_PC_15 = 47, 69 + S32G_MSCR_PD_00 = 48, 70 + S32G_MSCR_PD_01 = 49, 71 + S32G_MSCR_PD_02 = 50, 72 + S32G_MSCR_PD_03 = 51, 73 + S32G_MSCR_PD_04 = 52, 74 + S32G_MSCR_PD_05 = 53, 75 + S32G_MSCR_PD_06 = 54, 76 + S32G_MSCR_PD_07 = 55, 77 + S32G_MSCR_PD_08 = 56, 78 + S32G_MSCR_PD_09 = 57, 79 + S32G_MSCR_PD_10 = 58, 80 + S32G_MSCR_PD_11 = 59, 81 + S32G_MSCR_PD_12 = 60, 82 + S32G_MSCR_PD_13 = 61, 83 + S32G_MSCR_PD_14 = 62, 84 + S32G_MSCR_PD_15 = 63, 85 + S32G_MSCR_PE_00 = 64, 86 + S32G_MSCR_PE_01 = 65, 87 + S32G_MSCR_PE_02 = 66, 88 + S32G_MSCR_PE_03 = 67, 89 + S32G_MSCR_PE_04 = 68, 90 + S32G_MSCR_PE_05 = 69, 91 + S32G_MSCR_PE_06 = 70, 92 + S32G_MSCR_PE_07 = 71, 93 + S32G_MSCR_PE_08 = 72, 94 + S32G_MSCR_PE_09 = 73, 95 + S32G_MSCR_PE_10 = 74, 96 + S32G_MSCR_PE_11 = 75, 97 + S32G_MSCR_PE_12 = 76, 98 + S32G_MSCR_PE_13 = 77, 99 + S32G_MSCR_PE_14 = 78, 100 + S32G_MSCR_PE_15 = 79, 101 + S32G_MSCR_PF_00 = 80, 102 + S32G_MSCR_PF_01 = 81, 103 + S32G_MSCR_PF_02 = 82, 104 + S32G_MSCR_PF_03 = 83, 105 + S32G_MSCR_PF_04 = 84, 106 + S32G_MSCR_PF_05 = 85, 107 + S32G_MSCR_PF_06 = 86, 108 + S32G_MSCR_PF_07 = 87, 109 + S32G_MSCR_PF_08 = 88, 110 + S32G_MSCR_PF_09 = 89, 111 + S32G_MSCR_PF_10 = 90, 112 + S32G_MSCR_PF_11 = 91, 113 + S32G_MSCR_PF_12 = 92, 114 + S32G_MSCR_PF_13 = 93, 115 + S32G_MSCR_PF_14 = 94, 116 + S32G_MSCR_PF_15 = 95, 117 + S32G_MSCR_PG_00 = 96, 118 + S32G_MSCR_PG_01 = 97, 119 + S32G_MSCR_PG_02 = 98, 120 + S32G_MSCR_PG_03 = 99, 121 + S32G_MSCR_PG_04 = 100, 122 + S32G_MSCR_PG_05 = 101, 123 + S32G_MSCR_PH_00 = 112, 124 + S32G_MSCR_PH_01 = 113, 125 + S32G_MSCR_PH_02 = 114, 126 + S32G_MSCR_PH_03 = 115, 127 + S32G_MSCR_PH_04 = 116, 128 + S32G_MSCR_PH_05 = 117, 129 + S32G_MSCR_PH_06 = 118, 130 + S32G_MSCR_PH_07 = 119, 131 + S32G_MSCR_PH_08 = 120, 132 + S32G_MSCR_PH_09 = 121, 133 + S32G_MSCR_PH_10 = 122, 134 + S32G_MSCR_PJ_00 = 144, 135 + S32G_MSCR_PJ_01 = 145, 136 + S32G_MSCR_PJ_02 = 146, 137 + S32G_MSCR_PJ_03 = 147, 138 + S32G_MSCR_PJ_04 = 148, 139 + S32G_MSCR_PJ_05 = 149, 140 + S32G_MSCR_PJ_06 = 150, 141 + S32G_MSCR_PJ_07 = 151, 142 + S32G_MSCR_PJ_08 = 152, 143 + S32G_MSCR_PJ_09 = 153, 144 + S32G_MSCR_PJ_10 = 154, 145 + S32G_MSCR_PJ_11 = 155, 146 + S32G_MSCR_PJ_12 = 156, 147 + S32G_MSCR_PJ_13 = 157, 148 + S32G_MSCR_PJ_14 = 158, 149 + S32G_MSCR_PJ_15 = 159, 150 + S32G_MSCR_PK_00 = 160, 151 + S32G_MSCR_PK_01 = 161, 152 + S32G_MSCR_PK_02 = 162, 153 + S32G_MSCR_PK_03 = 163, 154 + S32G_MSCR_PK_04 = 164, 155 + S32G_MSCR_PK_05 = 165, 156 + S32G_MSCR_PK_06 = 166, 157 + S32G_MSCR_PK_07 = 167, 158 + S32G_MSCR_PK_08 = 168, 159 + S32G_MSCR_PK_09 = 169, 160 + S32G_MSCR_PK_10 = 170, 161 + S32G_MSCR_PK_11 = 171, 162 + S32G_MSCR_PK_12 = 172, 163 + S32G_MSCR_PK_13 = 173, 164 + S32G_MSCR_PK_14 = 174, 165 + S32G_MSCR_PK_15 = 175, 166 + S32G_MSCR_PL_00 = 176, 167 + S32G_MSCR_PL_01 = 177, 168 + S32G_MSCR_PL_02 = 178, 169 + S32G_MSCR_PL_03 = 179, 170 + S32G_MSCR_PL_04 = 180, 171 + S32G_MSCR_PL_05 = 181, 172 + S32G_MSCR_PL_06 = 182, 173 + S32G_MSCR_PL_07 = 183, 174 + S32G_MSCR_PL_08 = 184, 175 + S32G_MSCR_PL_09 = 185, 176 + S32G_MSCR_PL_10 = 186, 177 + S32G_MSCR_PL_11 = 187, 178 + S32G_MSCR_PL_12 = 188, 179 + S32G_MSCR_PL_13 = 189, 180 + S32G_MSCR_PL_14 = 190, 181 + 182 + S32G_IMCR_QSPI_A_DATA0 = 540, 183 + S32G_IMCR_QSPI_A_DATA1 = 541, 184 + S32G_IMCR_QSPI_A_DATA2 = 542, 185 + S32G_IMCR_QSPI_A_DATA3 = 543, 186 + S32G_IMCR_QSPI_A_DATA4 = 544, 187 + S32G_IMCR_QSPI_A_DATA5 = 545, 188 + S32G_IMCR_QSPI_A_DATA6 = 546, 189 + S32G_IMCR_QSPI_A_DATA7 = 547, 190 + S32G_IMCR_QSPI_DQS_A = 548, 191 + S32G_IMCR_QSPI_B_DATA0 = 552, 192 + S32G_IMCR_QSPI_B_DATA1 = 554, 193 + S32G_IMCR_QSPI_B_DATA2 = 551, 194 + S32G_IMCR_QSPI_B_DATA3 = 553, 195 + S32G_IMCR_QSPI_B_DATA4 = 557, 196 + S32G_IMCR_QSPI_B_DATA5 = 550, 197 + S32G_IMCR_QSPI_B_DATA6 = 556, 198 + S32G_IMCR_QSPI_B_DATA7 = 555, 199 + S32G_IMCR_QSPI_DQS_B = 558, 200 + S32G_IMCR_BOOT_BOOTMOD0 = 560, 201 + S32G_IMCR_BOOT_BOOTMOD1 = 561, 202 + S32G_IMCR_I2C0_SCL = 566, 203 + S32G_IMCR_I2C0_SDA = 565, 204 + S32G_IMCR_LIN0_RX = 512, 205 + S32G_IMCR_USDHC_CMD = 515, 206 + S32G_IMCR_USDHC_DAT0 = 516, 207 + S32G_IMCR_USDHC_DAT1 = 517, 208 + S32G_IMCR_USDHC_DAT2 = 520, 209 + S32G_IMCR_USDHC_DAT3 = 521, 210 + S32G_IMCR_USDHC_DAT4 = 522, 211 + S32G_IMCR_USDHC_DAT5 = 523, 212 + S32G_IMCR_USDHC_DAT6 = 519, 213 + S32G_IMCR_USDHC_DAT7 = 518, 214 + S32G_IMCR_USDHC_DQS = 524, 215 + S32G_IMCR_CAN0_RXD = 513, 216 + S32G_IMCR_CAN1_RXD = 631, 217 + S32G_IMCR_CAN2_RXD = 632, 218 + S32G_IMCR_CAN3_RXD = 633, 219 + /* GMAC0 */ 220 + S32G_IMCR_Ethernet_MDIO = 527, 221 + S32G_IMCR_Ethernet_CRS = 526, 222 + S32G_IMCR_Ethernet_COL = 525, 223 + S32G_IMCR_Ethernet_RX_D0 = 531, 224 + S32G_IMCR_Ethernet_RX_D1 = 532, 225 + S32G_IMCR_Ethernet_RX_D2 = 533, 226 + S32G_IMCR_Ethernet_RX_D3 = 534, 227 + S32G_IMCR_Ethernet_RX_ER = 528, 228 + S32G_IMCR_Ethernet_RX_CLK = 529, 229 + S32G_IMCR_Ethernet_RX_DV = 530, 230 + S32G_IMCR_Ethernet_TX_CLK = 538, 231 + S32G_IMCR_Ethernet_REF_CLK = 535, 232 + /* PFE EMAC 0 MII */ 233 + /* PFE EMAC 1 MII */ 234 + S32G_IMCR_PFE_EMAC_1_MDIO = 857, 235 + S32G_IMCR_PFE_EMAC_1_CRS = 856, 236 + S32G_IMCR_PFE_EMAC_1_COL = 855, 237 + S32G_IMCR_PFE_EMAC_1_RX_D0 = 861, 238 + S32G_IMCR_PFE_EMAC_1_RX_D1 = 862, 239 + S32G_IMCR_PFE_EMAC_1_RX_D2 = 863, 240 + S32G_IMCR_PFE_EMAC_1_RX_D3 = 864, 241 + S32G_IMCR_PFE_EMAC_1_RX_ER = 860, 242 + S32G_IMCR_PFE_EMAC_1_RX_CLK = 859, 243 + S32G_IMCR_PFE_EMAC_1_RX_DV = 865, 244 + S32G_IMCR_PFE_EMAC_1_TX_CLK = 866, 245 + S32G_IMCR_PFE_EMAC_1_REF_CLK = 858, 246 + /* PFE EMAC 2 MII */ 247 + S32G_IMCR_PFE_EMAC_2_MDIO = 877, 248 + S32G_IMCR_PFE_EMAC_2_CRS = 876, 249 + S32G_IMCR_PFE_EMAC_2_COL = 875, 250 + S32G_IMCR_PFE_EMAC_2_RX_D0 = 881, 251 + S32G_IMCR_PFE_EMAC_2_RX_D1 = 882, 252 + S32G_IMCR_PFE_EMAC_2_RX_D2 = 883, 253 + S32G_IMCR_PFE_EMAC_2_RX_D3 = 884, 254 + S32G_IMCR_PFE_EMAC_2_RX_ER = 880, 255 + S32G_IMCR_PFE_EMAC_2_RX_CLK = 879, 256 + S32G_IMCR_PFE_EMAC_2_RX_DV = 885, 257 + S32G_IMCR_PFE_EMAC_2_TX_CLK = 886, 258 + S32G_IMCR_PFE_EMAC_2_REF_CLK = 878, 259 + 260 + S32G_IMCR_FlexRay0_A_RX = 785, 261 + S32G_IMCR_FlexRay0_B_RX = 786, 262 + S32G_IMCR_FlexTimer0_CH0 = 655, 263 + S32G_IMCR_FlexTimer1_CH0 = 665, 264 + S32G_IMCR_FlexTimer0_CH1 = 656, 265 + S32G_IMCR_FlexTimer1_CH1 = 666, 266 + S32G_IMCR_FlexTimer0_CH2 = 657, 267 + S32G_IMCR_FlexTimer1_CH2 = 667, 268 + S32G_IMCR_FlexTimer0_CH3 = 658, 269 + S32G_IMCR_FlexTimer1_CH3 = 668, 270 + S32G_IMCR_FlexTimer0_CH4 = 659, 271 + S32G_IMCR_FlexTimer1_CH4 = 669, 272 + S32G_IMCR_FlexTimer0_CH5 = 660, 273 + S32G_IMCR_FlexTimer1_CH5 = 670, 274 + S32G_IMCR_FlexTimer0_EXTCLK = 661, 275 + S32G_IMCR_FlexTimer1_EXTCLK = 671, 276 + S32G_IMCR_I2C1_SCL = 717, 277 + S32G_IMCR_I2C1_SDA = 718, 278 + S32G_IMCR_I2C2_SCL = 719, 279 + S32G_IMCR_I2C2_SDA = 720, 280 + S32G_IMCR_I2C3_SCL = 721, 281 + S32G_IMCR_I2C3_SDA = 722, 282 + S32G_IMCR_I2C4_SCL = 723, 283 + S32G_IMCR_I2C4_SDA = 724, 284 + S32G_IMCR_LIN1_RX = 736, 285 + S32G_IMCR_LIN2_RX = 737, 286 + S32G_IMCR_DSPI0_PCS0 = 980, 287 + S32G_IMCR_DSPI0_SCK = 981, 288 + S32G_IMCR_DSPI0_SIN = 982, 289 + S32G_IMCR_DSPI1_PCS0 = 985, 290 + S32G_IMCR_DSPI1_SCK = 986, 291 + S32G_IMCR_DSPI1_SIN = 987, 292 + S32G_IMCR_DSPI2_PCS0 = 990, 293 + S32G_IMCR_DSPI2_SCK = 991, 294 + S32G_IMCR_DSPI2_SIN = 992, 295 + S32G_IMCR_DSPI3_PCS0 = 995, 296 + S32G_IMCR_DSPI3_SCK = 996, 297 + S32G_IMCR_DSPI3_SIN = 997, 298 + S32G_IMCR_DSPI4_PCS0 = 1000, 299 + S32G_IMCR_DSPI4_SCK = 1001, 300 + S32G_IMCR_DSPI4_SIN = 1002, 301 + S32G_IMCR_DSPI5_PCS0 = 1005, 302 + S32G_IMCR_DSPI5_SCK = 1006, 303 + S32G_IMCR_DSPI5_SIN = 1007, 304 + S32G_IMCR_LLCE_CAN0_RXD = 745, 305 + S32G_IMCR_LLCE_CAN1_RXD = 746, 306 + S32G_IMCR_LLCE_CAN2_RXD = 747, 307 + S32G_IMCR_LLCE_CAN3_RXD = 748, 308 + S32G_IMCR_LLCE_CAN4_RXD = 749, 309 + S32G_IMCR_LLCE_CAN5_RXD = 750, 310 + S32G_IMCR_LLCE_CAN6_RXD = 751, 311 + S32G_IMCR_LLCE_CAN7_RXD = 752, 312 + S32G_IMCR_LLCE_CAN8_RXD = 753, 313 + S32G_IMCR_LLCE_CAN9_RXD = 754, 314 + S32G_IMCR_LLCE_CAN10_RXD = 755, 315 + S32G_IMCR_LLCE_CAN11_RXD = 756, 316 + S32G_IMCR_LLCE_CAN12_RXD = 757, 317 + S32G_IMCR_LLCE_CAN13_RXD = 758, 318 + S32G_IMCR_LLCE_CAN14_RXD = 759, 319 + S32G_IMCR_LLCE_CAN15_RXD = 760, 320 + S32G_IMCR_USB_CLK = 895, 321 + S32G_IMCR_USB_DATA0 = 896, 322 + S32G_IMCR_USB_DATA1 = 897, 323 + S32G_IMCR_USB_DATA2 = 898, 324 + S32G_IMCR_USB_DATA3 = 899, 325 + S32G_IMCR_USB_DATA4 = 900, 326 + S32G_IMCR_USB_DATA5 = 901, 327 + S32G_IMCR_USB_DATA6 = 902, 328 + S32G_IMCR_USB_DATA7 = 903, 329 + S32G_IMCR_USB_DIR = 904, 330 + S32G_IMCR_USB_NXT = 905, 331 + 332 + S32G_IMCR_SIUL_EIRQ0 = 910, 333 + S32G_IMCR_SIUL_EIRQ1 = 911, 334 + S32G_IMCR_SIUL_EIRQ2 = 912, 335 + S32G_IMCR_SIUL_EIRQ3 = 913, 336 + S32G_IMCR_SIUL_EIRQ4 = 914, 337 + S32G_IMCR_SIUL_EIRQ5 = 915, 338 + S32G_IMCR_SIUL_EIRQ6 = 916, 339 + S32G_IMCR_SIUL_EIRQ7 = 917, 340 + S32G_IMCR_SIUL_EIRQ8 = 918, 341 + S32G_IMCR_SIUL_EIRQ9 = 919, 342 + S32G_IMCR_SIUL_EIRQ10 = 920, 343 + S32G_IMCR_SIUL_EIRQ11 = 921, 344 + S32G_IMCR_SIUL_EIRQ12 = 922, 345 + S32G_IMCR_SIUL_EIRQ13 = 923, 346 + S32G_IMCR_SIUL_EIRQ14 = 924, 347 + S32G_IMCR_SIUL_EIRQ15 = 925, 348 + S32G_IMCR_SIUL_EIRQ16 = 926, 349 + S32G_IMCR_SIUL_EIRQ17 = 927, 350 + S32G_IMCR_SIUL_EIRQ18 = 928, 351 + S32G_IMCR_SIUL_EIRQ19 = 929, 352 + S32G_IMCR_SIUL_EIRQ20 = 930, 353 + S32G_IMCR_SIUL_EIRQ21 = 931, 354 + S32G_IMCR_SIUL_EIRQ22 = 932, 355 + S32G_IMCR_SIUL_EIRQ23 = 933, 356 + S32G_IMCR_SIUL_EIRQ24 = 934, 357 + S32G_IMCR_SIUL_EIRQ25 = 935, 358 + S32G_IMCR_SIUL_EIRQ26 = 936, 359 + S32G_IMCR_SIUL_EIRQ27 = 937, 360 + S32G_IMCR_SIUL_EIRQ28 = 938, 361 + S32G_IMCR_SIUL_EIRQ29 = 939, 362 + S32G_IMCR_SIUL_EIRQ30 = 940, 363 + S32G_IMCR_SIUL_EIRQ31 = 941, 364 + }; 365 + 366 + /* Pad names for the pinmux subsystem */ 367 + static const struct pinctrl_pin_desc s32_pinctrl_pads_siul2[] = { 368 + 369 + /* SIUL2_0 pins. */ 370 + 371 + S32_PINCTRL_PIN(S32G_MSCR_PA_00), 372 + S32_PINCTRL_PIN(S32G_MSCR_PA_01), 373 + S32_PINCTRL_PIN(S32G_MSCR_PA_02), 374 + S32_PINCTRL_PIN(S32G_MSCR_PA_03), 375 + S32_PINCTRL_PIN(S32G_MSCR_PA_04), 376 + S32_PINCTRL_PIN(S32G_MSCR_PA_05), 377 + S32_PINCTRL_PIN(S32G_MSCR_PA_06), 378 + S32_PINCTRL_PIN(S32G_MSCR_PA_07), 379 + S32_PINCTRL_PIN(S32G_MSCR_PA_08), 380 + S32_PINCTRL_PIN(S32G_MSCR_PA_09), 381 + S32_PINCTRL_PIN(S32G_MSCR_PA_10), 382 + S32_PINCTRL_PIN(S32G_MSCR_PA_11), 383 + S32_PINCTRL_PIN(S32G_MSCR_PA_12), 384 + S32_PINCTRL_PIN(S32G_MSCR_PA_13), 385 + S32_PINCTRL_PIN(S32G_MSCR_PA_14), 386 + S32_PINCTRL_PIN(S32G_MSCR_PA_15), 387 + S32_PINCTRL_PIN(S32G_MSCR_PB_00), 388 + S32_PINCTRL_PIN(S32G_MSCR_PB_01), 389 + S32_PINCTRL_PIN(S32G_MSCR_PB_02), 390 + S32_PINCTRL_PIN(S32G_MSCR_PB_03), 391 + S32_PINCTRL_PIN(S32G_MSCR_PB_04), 392 + S32_PINCTRL_PIN(S32G_MSCR_PB_05), 393 + S32_PINCTRL_PIN(S32G_MSCR_PB_06), 394 + S32_PINCTRL_PIN(S32G_MSCR_PB_07), 395 + S32_PINCTRL_PIN(S32G_MSCR_PB_08), 396 + S32_PINCTRL_PIN(S32G_MSCR_PB_09), 397 + S32_PINCTRL_PIN(S32G_MSCR_PB_10), 398 + S32_PINCTRL_PIN(S32G_MSCR_PB_11), 399 + S32_PINCTRL_PIN(S32G_MSCR_PB_12), 400 + S32_PINCTRL_PIN(S32G_MSCR_PB_13), 401 + S32_PINCTRL_PIN(S32G_MSCR_PB_14), 402 + S32_PINCTRL_PIN(S32G_MSCR_PB_15), 403 + S32_PINCTRL_PIN(S32G_MSCR_PC_00), 404 + S32_PINCTRL_PIN(S32G_MSCR_PC_01), 405 + S32_PINCTRL_PIN(S32G_MSCR_PC_02), 406 + S32_PINCTRL_PIN(S32G_MSCR_PC_03), 407 + S32_PINCTRL_PIN(S32G_MSCR_PC_04), 408 + S32_PINCTRL_PIN(S32G_MSCR_PC_05), 409 + S32_PINCTRL_PIN(S32G_MSCR_PC_06), 410 + S32_PINCTRL_PIN(S32G_MSCR_PC_07), 411 + S32_PINCTRL_PIN(S32G_MSCR_PC_08), 412 + S32_PINCTRL_PIN(S32G_MSCR_PC_09), 413 + S32_PINCTRL_PIN(S32G_MSCR_PC_10), 414 + S32_PINCTRL_PIN(S32G_MSCR_PC_11), 415 + S32_PINCTRL_PIN(S32G_MSCR_PC_12), 416 + S32_PINCTRL_PIN(S32G_MSCR_PC_13), 417 + S32_PINCTRL_PIN(S32G_MSCR_PC_14), 418 + S32_PINCTRL_PIN(S32G_MSCR_PC_15), 419 + S32_PINCTRL_PIN(S32G_MSCR_PD_00), 420 + S32_PINCTRL_PIN(S32G_MSCR_PD_01), 421 + S32_PINCTRL_PIN(S32G_MSCR_PD_02), 422 + S32_PINCTRL_PIN(S32G_MSCR_PD_03), 423 + S32_PINCTRL_PIN(S32G_MSCR_PD_04), 424 + S32_PINCTRL_PIN(S32G_MSCR_PD_05), 425 + S32_PINCTRL_PIN(S32G_MSCR_PD_06), 426 + S32_PINCTRL_PIN(S32G_MSCR_PD_07), 427 + S32_PINCTRL_PIN(S32G_MSCR_PD_08), 428 + S32_PINCTRL_PIN(S32G_MSCR_PD_09), 429 + S32_PINCTRL_PIN(S32G_MSCR_PD_10), 430 + S32_PINCTRL_PIN(S32G_MSCR_PD_11), 431 + S32_PINCTRL_PIN(S32G_MSCR_PD_12), 432 + S32_PINCTRL_PIN(S32G_MSCR_PD_13), 433 + S32_PINCTRL_PIN(S32G_MSCR_PD_14), 434 + S32_PINCTRL_PIN(S32G_MSCR_PD_15), 435 + S32_PINCTRL_PIN(S32G_MSCR_PE_00), 436 + S32_PINCTRL_PIN(S32G_MSCR_PE_01), 437 + S32_PINCTRL_PIN(S32G_MSCR_PE_02), 438 + S32_PINCTRL_PIN(S32G_MSCR_PE_03), 439 + S32_PINCTRL_PIN(S32G_MSCR_PE_04), 440 + S32_PINCTRL_PIN(S32G_MSCR_PE_05), 441 + S32_PINCTRL_PIN(S32G_MSCR_PE_06), 442 + S32_PINCTRL_PIN(S32G_MSCR_PE_07), 443 + S32_PINCTRL_PIN(S32G_MSCR_PE_08), 444 + S32_PINCTRL_PIN(S32G_MSCR_PE_09), 445 + S32_PINCTRL_PIN(S32G_MSCR_PE_10), 446 + S32_PINCTRL_PIN(S32G_MSCR_PE_11), 447 + S32_PINCTRL_PIN(S32G_MSCR_PE_12), 448 + S32_PINCTRL_PIN(S32G_MSCR_PE_13), 449 + S32_PINCTRL_PIN(S32G_MSCR_PE_14), 450 + S32_PINCTRL_PIN(S32G_MSCR_PE_15), 451 + S32_PINCTRL_PIN(S32G_MSCR_PF_00), 452 + S32_PINCTRL_PIN(S32G_MSCR_PF_01), 453 + S32_PINCTRL_PIN(S32G_MSCR_PF_02), 454 + S32_PINCTRL_PIN(S32G_MSCR_PF_03), 455 + S32_PINCTRL_PIN(S32G_MSCR_PF_04), 456 + S32_PINCTRL_PIN(S32G_MSCR_PF_05), 457 + S32_PINCTRL_PIN(S32G_MSCR_PF_06), 458 + S32_PINCTRL_PIN(S32G_MSCR_PF_07), 459 + S32_PINCTRL_PIN(S32G_MSCR_PF_08), 460 + S32_PINCTRL_PIN(S32G_MSCR_PF_09), 461 + S32_PINCTRL_PIN(S32G_MSCR_PF_10), 462 + S32_PINCTRL_PIN(S32G_MSCR_PF_11), 463 + S32_PINCTRL_PIN(S32G_MSCR_PF_12), 464 + S32_PINCTRL_PIN(S32G_MSCR_PF_13), 465 + S32_PINCTRL_PIN(S32G_MSCR_PF_14), 466 + S32_PINCTRL_PIN(S32G_MSCR_PF_15), 467 + S32_PINCTRL_PIN(S32G_MSCR_PG_00), 468 + S32_PINCTRL_PIN(S32G_MSCR_PG_01), 469 + S32_PINCTRL_PIN(S32G_MSCR_PG_02), 470 + S32_PINCTRL_PIN(S32G_MSCR_PG_03), 471 + S32_PINCTRL_PIN(S32G_MSCR_PG_04), 472 + S32_PINCTRL_PIN(S32G_MSCR_PG_05), 473 + 474 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_A_DATA0), 475 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_A_DATA1), 476 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_A_DATA2), 477 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_A_DATA3), 478 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_A_DATA4), 479 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_A_DATA5), 480 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_A_DATA6), 481 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_A_DATA7), 482 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_DQS_A), 483 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_B_DATA0), 484 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_B_DATA1), 485 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_B_DATA2), 486 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_B_DATA3), 487 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_B_DATA4), 488 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_B_DATA5), 489 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_B_DATA6), 490 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_B_DATA7), 491 + S32_PINCTRL_PIN(S32G_IMCR_QSPI_DQS_B), 492 + S32_PINCTRL_PIN(S32G_IMCR_I2C0_SCL), 493 + S32_PINCTRL_PIN(S32G_IMCR_I2C0_SDA), 494 + S32_PINCTRL_PIN(S32G_IMCR_LIN0_RX), 495 + S32_PINCTRL_PIN(S32G_IMCR_USDHC_CMD), 496 + S32_PINCTRL_PIN(S32G_IMCR_USDHC_DAT0), 497 + S32_PINCTRL_PIN(S32G_IMCR_USDHC_DAT1), 498 + S32_PINCTRL_PIN(S32G_IMCR_USDHC_DAT2), 499 + S32_PINCTRL_PIN(S32G_IMCR_USDHC_DAT3), 500 + S32_PINCTRL_PIN(S32G_IMCR_USDHC_DAT4), 501 + S32_PINCTRL_PIN(S32G_IMCR_USDHC_DAT5), 502 + S32_PINCTRL_PIN(S32G_IMCR_USDHC_DAT6), 503 + S32_PINCTRL_PIN(S32G_IMCR_USDHC_DAT7), 504 + S32_PINCTRL_PIN(S32G_IMCR_USDHC_DQS), 505 + S32_PINCTRL_PIN(S32G_IMCR_CAN0_RXD), 506 + /* GMAC0 */ 507 + S32_PINCTRL_PIN(S32G_IMCR_Ethernet_MDIO), 508 + S32_PINCTRL_PIN(S32G_IMCR_Ethernet_CRS), 509 + S32_PINCTRL_PIN(S32G_IMCR_Ethernet_COL), 510 + S32_PINCTRL_PIN(S32G_IMCR_Ethernet_RX_D0), 511 + S32_PINCTRL_PIN(S32G_IMCR_Ethernet_RX_D1), 512 + S32_PINCTRL_PIN(S32G_IMCR_Ethernet_RX_D2), 513 + S32_PINCTRL_PIN(S32G_IMCR_Ethernet_RX_D3), 514 + S32_PINCTRL_PIN(S32G_IMCR_Ethernet_RX_ER), 515 + S32_PINCTRL_PIN(S32G_IMCR_Ethernet_RX_CLK), 516 + S32_PINCTRL_PIN(S32G_IMCR_Ethernet_RX_DV), 517 + S32_PINCTRL_PIN(S32G_IMCR_Ethernet_TX_CLK), 518 + S32_PINCTRL_PIN(S32G_IMCR_Ethernet_REF_CLK), 519 + 520 + /* SIUL2_1 pins. */ 521 + 522 + S32_PINCTRL_PIN(S32G_MSCR_PH_00), 523 + S32_PINCTRL_PIN(S32G_MSCR_PH_01), 524 + S32_PINCTRL_PIN(S32G_MSCR_PH_02), 525 + S32_PINCTRL_PIN(S32G_MSCR_PH_03), 526 + S32_PINCTRL_PIN(S32G_MSCR_PH_04), 527 + S32_PINCTRL_PIN(S32G_MSCR_PH_05), 528 + S32_PINCTRL_PIN(S32G_MSCR_PH_06), 529 + S32_PINCTRL_PIN(S32G_MSCR_PH_07), 530 + S32_PINCTRL_PIN(S32G_MSCR_PH_08), 531 + S32_PINCTRL_PIN(S32G_MSCR_PH_09), 532 + S32_PINCTRL_PIN(S32G_MSCR_PH_10), 533 + S32_PINCTRL_PIN(S32G_MSCR_PJ_00), 534 + S32_PINCTRL_PIN(S32G_MSCR_PJ_01), 535 + S32_PINCTRL_PIN(S32G_MSCR_PJ_02), 536 + S32_PINCTRL_PIN(S32G_MSCR_PJ_03), 537 + S32_PINCTRL_PIN(S32G_MSCR_PJ_04), 538 + S32_PINCTRL_PIN(S32G_MSCR_PJ_05), 539 + S32_PINCTRL_PIN(S32G_MSCR_PJ_06), 540 + S32_PINCTRL_PIN(S32G_MSCR_PJ_07), 541 + S32_PINCTRL_PIN(S32G_MSCR_PJ_08), 542 + S32_PINCTRL_PIN(S32G_MSCR_PJ_09), 543 + S32_PINCTRL_PIN(S32G_MSCR_PJ_10), 544 + S32_PINCTRL_PIN(S32G_MSCR_PJ_11), 545 + S32_PINCTRL_PIN(S32G_MSCR_PJ_12), 546 + S32_PINCTRL_PIN(S32G_MSCR_PJ_13), 547 + S32_PINCTRL_PIN(S32G_MSCR_PJ_14), 548 + S32_PINCTRL_PIN(S32G_MSCR_PJ_15), 549 + S32_PINCTRL_PIN(S32G_MSCR_PK_00), 550 + S32_PINCTRL_PIN(S32G_MSCR_PK_01), 551 + S32_PINCTRL_PIN(S32G_MSCR_PK_02), 552 + S32_PINCTRL_PIN(S32G_MSCR_PK_03), 553 + S32_PINCTRL_PIN(S32G_MSCR_PK_04), 554 + S32_PINCTRL_PIN(S32G_MSCR_PK_05), 555 + S32_PINCTRL_PIN(S32G_MSCR_PK_06), 556 + S32_PINCTRL_PIN(S32G_MSCR_PK_07), 557 + S32_PINCTRL_PIN(S32G_MSCR_PK_08), 558 + S32_PINCTRL_PIN(S32G_MSCR_PK_09), 559 + S32_PINCTRL_PIN(S32G_MSCR_PK_10), 560 + S32_PINCTRL_PIN(S32G_MSCR_PK_11), 561 + S32_PINCTRL_PIN(S32G_MSCR_PK_12), 562 + S32_PINCTRL_PIN(S32G_MSCR_PK_13), 563 + S32_PINCTRL_PIN(S32G_MSCR_PK_14), 564 + S32_PINCTRL_PIN(S32G_MSCR_PK_15), 565 + S32_PINCTRL_PIN(S32G_MSCR_PL_00), 566 + S32_PINCTRL_PIN(S32G_MSCR_PL_01), 567 + S32_PINCTRL_PIN(S32G_MSCR_PL_02), 568 + S32_PINCTRL_PIN(S32G_MSCR_PL_03), 569 + S32_PINCTRL_PIN(S32G_MSCR_PL_04), 570 + S32_PINCTRL_PIN(S32G_MSCR_PL_05), 571 + S32_PINCTRL_PIN(S32G_MSCR_PL_06), 572 + S32_PINCTRL_PIN(S32G_MSCR_PL_07), 573 + S32_PINCTRL_PIN(S32G_MSCR_PL_08), 574 + S32_PINCTRL_PIN(S32G_MSCR_PL_09), 575 + S32_PINCTRL_PIN(S32G_MSCR_PL_10), 576 + S32_PINCTRL_PIN(S32G_MSCR_PL_11), 577 + S32_PINCTRL_PIN(S32G_MSCR_PL_12), 578 + S32_PINCTRL_PIN(S32G_MSCR_PL_13), 579 + S32_PINCTRL_PIN(S32G_MSCR_PL_14), 580 + 581 + S32_PINCTRL_PIN(S32G_IMCR_FlexRay0_A_RX), 582 + S32_PINCTRL_PIN(S32G_IMCR_FlexRay0_B_RX), 583 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer0_CH0), 584 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer1_CH0), 585 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer0_CH1), 586 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer1_CH1), 587 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer0_CH2), 588 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer1_CH2), 589 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer0_CH3), 590 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer1_CH3), 591 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer0_CH4), 592 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer1_CH4), 593 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer0_CH5), 594 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer1_CH5), 595 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer0_EXTCLK), 596 + S32_PINCTRL_PIN(S32G_IMCR_FlexTimer1_EXTCLK), 597 + S32_PINCTRL_PIN(S32G_IMCR_I2C1_SCL), 598 + S32_PINCTRL_PIN(S32G_IMCR_I2C1_SDA), 599 + S32_PINCTRL_PIN(S32G_IMCR_I2C2_SCL), 600 + S32_PINCTRL_PIN(S32G_IMCR_I2C2_SDA), 601 + S32_PINCTRL_PIN(S32G_IMCR_I2C3_SCL), 602 + S32_PINCTRL_PIN(S32G_IMCR_I2C3_SDA), 603 + S32_PINCTRL_PIN(S32G_IMCR_I2C4_SCL), 604 + S32_PINCTRL_PIN(S32G_IMCR_I2C4_SDA), 605 + S32_PINCTRL_PIN(S32G_IMCR_LIN1_RX), 606 + S32_PINCTRL_PIN(S32G_IMCR_LIN2_RX), 607 + S32_PINCTRL_PIN(S32G_IMCR_DSPI0_PCS0), 608 + S32_PINCTRL_PIN(S32G_IMCR_DSPI0_SCK), 609 + S32_PINCTRL_PIN(S32G_IMCR_DSPI0_SIN), 610 + S32_PINCTRL_PIN(S32G_IMCR_DSPI1_PCS0), 611 + S32_PINCTRL_PIN(S32G_IMCR_DSPI1_SCK), 612 + S32_PINCTRL_PIN(S32G_IMCR_DSPI1_SIN), 613 + S32_PINCTRL_PIN(S32G_IMCR_DSPI2_PCS0), 614 + S32_PINCTRL_PIN(S32G_IMCR_DSPI2_SCK), 615 + S32_PINCTRL_PIN(S32G_IMCR_DSPI2_SIN), 616 + S32_PINCTRL_PIN(S32G_IMCR_DSPI3_PCS0), 617 + S32_PINCTRL_PIN(S32G_IMCR_DSPI3_SCK), 618 + S32_PINCTRL_PIN(S32G_IMCR_DSPI3_SIN), 619 + S32_PINCTRL_PIN(S32G_IMCR_DSPI4_PCS0), 620 + S32_PINCTRL_PIN(S32G_IMCR_DSPI4_SCK), 621 + S32_PINCTRL_PIN(S32G_IMCR_DSPI4_SIN), 622 + S32_PINCTRL_PIN(S32G_IMCR_DSPI5_PCS0), 623 + S32_PINCTRL_PIN(S32G_IMCR_DSPI5_SCK), 624 + S32_PINCTRL_PIN(S32G_IMCR_DSPI5_SIN), 625 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN0_RXD), 626 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN1_RXD), 627 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN2_RXD), 628 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN3_RXD), 629 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN4_RXD), 630 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN5_RXD), 631 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN6_RXD), 632 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN7_RXD), 633 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN8_RXD), 634 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN9_RXD), 635 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN10_RXD), 636 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN11_RXD), 637 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN12_RXD), 638 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN13_RXD), 639 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN14_RXD), 640 + S32_PINCTRL_PIN(S32G_IMCR_LLCE_CAN15_RXD), 641 + S32_PINCTRL_PIN(S32G_IMCR_CAN1_RXD), 642 + S32_PINCTRL_PIN(S32G_IMCR_CAN2_RXD), 643 + S32_PINCTRL_PIN(S32G_IMCR_CAN3_RXD), 644 + S32_PINCTRL_PIN(S32G_IMCR_USB_CLK), 645 + S32_PINCTRL_PIN(S32G_IMCR_USB_DATA0), 646 + S32_PINCTRL_PIN(S32G_IMCR_USB_DATA1), 647 + S32_PINCTRL_PIN(S32G_IMCR_USB_DATA2), 648 + S32_PINCTRL_PIN(S32G_IMCR_USB_DATA3), 649 + S32_PINCTRL_PIN(S32G_IMCR_USB_DATA4), 650 + S32_PINCTRL_PIN(S32G_IMCR_USB_DATA5), 651 + S32_PINCTRL_PIN(S32G_IMCR_USB_DATA6), 652 + S32_PINCTRL_PIN(S32G_IMCR_USB_DATA7), 653 + S32_PINCTRL_PIN(S32G_IMCR_USB_DIR), 654 + S32_PINCTRL_PIN(S32G_IMCR_USB_NXT), 655 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_1_MDIO), 656 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_1_CRS), 657 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_1_COL), 658 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_1_RX_D0), 659 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_1_RX_D1), 660 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_1_RX_D2), 661 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_1_RX_D3), 662 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_1_RX_ER), 663 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_1_RX_CLK), 664 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_1_RX_DV), 665 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_1_TX_CLK), 666 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_1_REF_CLK), 667 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_2_MDIO), 668 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_2_CRS), 669 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_2_COL), 670 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_2_RX_D0), 671 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_2_RX_D1), 672 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_2_RX_D2), 673 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_2_RX_D3), 674 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_2_RX_ER), 675 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_2_RX_CLK), 676 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_2_RX_DV), 677 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_2_TX_CLK), 678 + S32_PINCTRL_PIN(S32G_IMCR_PFE_EMAC_2_REF_CLK), 679 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ0), 680 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ1), 681 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ2), 682 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ3), 683 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ4), 684 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ5), 685 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ6), 686 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ7), 687 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ8), 688 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ9), 689 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ10), 690 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ11), 691 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ12), 692 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ13), 693 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ14), 694 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ15), 695 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ16), 696 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ17), 697 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ18), 698 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ19), 699 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ20), 700 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ21), 701 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ22), 702 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ23), 703 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ24), 704 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ25), 705 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ26), 706 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ27), 707 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ28), 708 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ29), 709 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ30), 710 + S32_PINCTRL_PIN(S32G_IMCR_SIUL_EIRQ31), 711 + }; 712 + 713 + static const struct s32_pin_range s32_pin_ranges_siul2[] = { 714 + /* MSCR pin ID ranges */ 715 + S32_PIN_RANGE(0, 101), 716 + S32_PIN_RANGE(112, 122), 717 + S32_PIN_RANGE(144, 190), 718 + /* IMCR pin ID ranges */ 719 + S32_PIN_RANGE(512, 595), 720 + S32_PIN_RANGE(631, 909), 721 + S32_PIN_RANGE(942, 1007), 722 + }; 723 + 724 + static struct s32_pinctrl_soc_info s32_pinctrl_info = { 725 + .pins = s32_pinctrl_pads_siul2, 726 + .npins = ARRAY_SIZE(s32_pinctrl_pads_siul2), 727 + .mem_pin_ranges = s32_pin_ranges_siul2, 728 + .mem_regions = ARRAY_SIZE(s32_pin_ranges_siul2), 729 + }; 730 + 731 + static const struct of_device_id s32_pinctrl_of_match[] = { 732 + { 733 + 734 + .compatible = "nxp,s32g2-siul2-pinctrl", 735 + .data = (void *) &s32_pinctrl_info, 736 + }, 737 + { /* sentinel */ } 738 + }; 739 + MODULE_DEVICE_TABLE(of, s32_pinctrl_of_match); 740 + 741 + static int s32g_pinctrl_probe(struct platform_device *pdev) 742 + { 743 + const struct of_device_id *of_id = 744 + of_match_device(s32_pinctrl_of_match, &pdev->dev); 745 + 746 + if (!of_id) 747 + return -ENODEV; 748 + 749 + return s32_pinctrl_probe 750 + (pdev, (struct s32_pinctrl_soc_info *) of_id->data); 751 + } 752 + 753 + static const struct dev_pm_ops s32g_pinctrl_pm_ops = { 754 + SET_LATE_SYSTEM_SLEEP_PM_OPS(s32_pinctrl_suspend, 755 + s32_pinctrl_resume) 756 + }; 757 + 758 + static struct platform_driver s32g_pinctrl_driver = { 759 + .driver = { 760 + .name = "s32g-siul2-pinctrl", 761 + .owner = THIS_MODULE, 762 + .of_match_table = s32_pinctrl_of_match, 763 + .pm = &s32g_pinctrl_pm_ops, 764 + .suppress_bind_attrs = true, 765 + }, 766 + .probe = s32g_pinctrl_probe, 767 + }; 768 + 769 + builtin_platform_driver(s32g_pinctrl_driver); 770 + 771 + MODULE_AUTHOR("Matthew Nunez <matthew.nunez@nxp.com>"); 772 + MODULE_DESCRIPTION("NXP S32G pinctrl driver"); 773 + MODULE_LICENSE("GPL");