Lines Matching +full:mux +full:- +full:int +full:- +full:port

1 // SPDX-License-Identifier: GPL-2.0
11 * This includes SoCs which are sub- or super- sets of this particular line,
23 #include <linux/pinctrl/pinconf-generic.h>
35 #define DRIVER_NAME "pinctrl-rza1"
48 #define RZA1_ADDR(mem, reg, port) ((mem) + (reg) + ((port) * 4)) argument
58 * Use 16 higher bits [31:16] for pin mux function
70 /* Pin mux flags */
75 /* ----------------------------------------------------------------------------
80 * rza1_bidir_pin - describe a single pin that needs bidir flag applied.
88 * rza1_bidir_entry - describe a list of pins that needs bidir flag applied.
89 * Each struct rza1_bidir_entry describes a port.
92 const unsigned int npins;
97 * rza1_swio_pin - describe a single pin that needs swio flag applied.
101 u16 port: 4; member
107 * rza1_swio_entry - describe a list of pins that needs swio flag applied
110 const unsigned int npins;
115 * rza1_pinmux_conf - group together bidir and swio pinmux flag tables
122 /* ----------------------------------------------------------------------------
260 { .port = 2, .pin = 7, .func = 4, .input = 0 },
261 { .port = 2, .pin = 11, .func = 4, .input = 0 },
262 { .port = 3, .pin = 7, .func = 3, .input = 0 },
263 { .port = 3, .pin = 7, .func = 8, .input = 0 },
264 { .port = 4, .pin = 7, .func = 5, .input = 0 },
265 { .port = 4, .pin = 7, .func = 11, .input = 0 },
266 { .port = 4, .pin = 15, .func = 6, .input = 0 },
267 { .port = 5, .pin = 0, .func = 1, .input = 1 },
268 { .port = 5, .pin = 1, .func = 1, .input = 1 },
269 { .port = 5, .pin = 2, .func = 1, .input = 1 },
270 { .port = 5, .pin = 3, .func = 1, .input = 1 },
271 { .port = 5, .pin = 4, .func = 1, .input = 1 },
272 { .port = 5, .pin = 5, .func = 1, .input = 1 },
273 { .port = 5, .pin = 6, .func = 1, .input = 1 },
274 { .port = 5, .pin = 7, .func = 1, .input = 1 },
275 { .port = 7, .pin = 4, .func = 6, .input = 0 },
276 { .port = 7, .pin = 11, .func = 2, .input = 0 },
277 { .port = 8, .pin = 10, .func = 8, .input = 0 },
278 { .port = 10, .pin = 15, .func = 2, .input = 0 },
303 /* ----------------------------------------------------------------------------
403 { .port = 2, .pin = 8, .func = 2, .input = 0 },
404 { .port = 5, .pin = 6, .func = 3, .input = 0 },
405 { .port = 6, .pin = 6, .func = 3, .input = 0 },
406 { .port = 6, .pin = 10, .func = 3, .input = 0 },
407 { .port = 7, .pin = 10, .func = 2, .input = 0 },
408 { .port = 8, .pin = 2, .func = 3, .input = 0 },
431 /* ----------------------------------------------------------------------------
435 * struct rza1_mux_conf - describes a pin multiplexing operation
438 * @port: the port where pin sits on
446 u8 port; member
454 * struct rza1_port - describes a pin port
456 * This is mostly useful to lock register writes per-bank and not globally.
459 * @id: port number
461 * @pins: pins sitting on this port
465 unsigned int id;
471 * struct rza1_pinctrl - RZ pincontroller device
490 unsigned int nport;
500 /* ----------------------------------------------------------------------------
503 static inline bool rza1_pinmux_get_bidir(unsigned int port, in rza1_pinmux_get_bidir() argument
504 unsigned int pin, in rza1_pinmux_get_bidir()
505 unsigned int func, in rza1_pinmux_get_bidir()
508 const struct rza1_bidir_entry *entry = &table[port]; in rza1_pinmux_get_bidir()
510 unsigned int i; in rza1_pinmux_get_bidir()
512 for (i = 0; i < entry->npins; ++i) { in rza1_pinmux_get_bidir()
513 bidir_pin = &entry->pins[i]; in rza1_pinmux_get_bidir()
514 if (bidir_pin->pin == pin && bidir_pin->func == func) in rza1_pinmux_get_bidir()
521 static inline int rza1_pinmux_get_swio(unsigned int port, in rza1_pinmux_get_swio() argument
522 unsigned int pin, in rza1_pinmux_get_swio()
523 unsigned int func, in rza1_pinmux_get_swio()
527 unsigned int i; in rza1_pinmux_get_swio()
530 for (i = 0; i < table->npins; ++i) { in rza1_pinmux_get_swio()
531 swio_pin = &table->pins[i]; in rza1_pinmux_get_swio()
532 if (swio_pin->port == port && swio_pin->pin == pin && in rza1_pinmux_get_swio()
533 swio_pin->func == func) in rza1_pinmux_get_swio()
534 return swio_pin->input; in rza1_pinmux_get_swio()
537 return -ENOENT; in rza1_pinmux_get_swio()
541 * rza1_pinmux_get_flags() - return pinmux flags associated to a pin
543 static unsigned int rza1_pinmux_get_flags(unsigned int port, unsigned int pin, in rza1_pinmux_get_flags() argument
544 unsigned int func, in rza1_pinmux_get_flags()
548 const struct rza1_pinmux_conf *pmx_conf = rza1_pctl->data; in rza1_pinmux_get_flags()
549 const struct rza1_bidir_entry *bidir_entries = pmx_conf->bidir_entries; in rza1_pinmux_get_flags()
550 const struct rza1_swio_entry *swio_entries = pmx_conf->swio_entries; in rza1_pinmux_get_flags()
551 unsigned int pmx_flags = 0; in rza1_pinmux_get_flags()
552 int ret; in rza1_pinmux_get_flags()
554 if (rza1_pinmux_get_bidir(port, pin, func, bidir_entries)) in rza1_pinmux_get_flags()
557 ret = rza1_pinmux_get_swio(port, pin, func, swio_entries); in rza1_pinmux_get_flags()
566 /* ----------------------------------------------------------------------------
571 * rza1_set_bit() - un-locked set/clear a single bit in pin configuration
574 static inline void rza1_set_bit(struct rza1_port *port, unsigned int reg, in rza1_set_bit() argument
575 unsigned int bit, bool set) in rza1_set_bit()
577 void __iomem *mem = RZA1_ADDR(port->base, reg, port->id); in rza1_set_bit()
588 static inline unsigned int rza1_get_bit(struct rza1_port *port, in rza1_get_bit() argument
589 unsigned int reg, unsigned int bit) in rza1_get_bit()
591 void __iomem *mem = RZA1_ADDR(port->base, reg, port->id); in rza1_get_bit()
597 * rza1_pin_reset() - reset a pin to default initial state
599 * Reset pin state disabling input buffer and bi-directional control,
600 * and configure it as input port.
604 * @port: port where pin sits on
607 static void rza1_pin_reset(struct rza1_port *port, unsigned int pin) in rza1_pin_reset() argument
611 spin_lock_irqsave(&port->lock, irqflags); in rza1_pin_reset()
612 rza1_set_bit(port, RZA1_PIBC_REG, pin, 0); in rza1_pin_reset()
613 rza1_set_bit(port, RZA1_PBDC_REG, pin, 0); in rza1_pin_reset()
615 rza1_set_bit(port, RZA1_PM_REG, pin, 1); in rza1_pin_reset()
616 rza1_set_bit(port, RZA1_PMC_REG, pin, 0); in rza1_pin_reset()
617 rza1_set_bit(port, RZA1_PIPC_REG, pin, 0); in rza1_pin_reset()
618 spin_unlock_irqrestore(&port->lock, irqflags); in rza1_pin_reset()
622 * rza1_pin_set_direction() - set I/O direction on a pin in port mode
624 * When running in output port mode keep PBDC enabled to allow reading the
627 * @port: port where pin sits on
631 static inline void rza1_pin_set_direction(struct rza1_port *port, in rza1_pin_set_direction() argument
632 unsigned int pin, bool input) in rza1_pin_set_direction()
636 spin_lock_irqsave(&port->lock, irqflags); in rza1_pin_set_direction()
638 rza1_set_bit(port, RZA1_PIBC_REG, pin, 1); in rza1_pin_set_direction()
640 rza1_set_bit(port, RZA1_PM_REG, pin, 1); in rza1_pin_set_direction()
641 rza1_set_bit(port, RZA1_PBDC_REG, pin, 0); in rza1_pin_set_direction()
643 rza1_set_bit(port, RZA1_PM_REG, pin, 0); in rza1_pin_set_direction()
644 rza1_set_bit(port, RZA1_PBDC_REG, pin, 1); in rza1_pin_set_direction()
647 spin_unlock_irqrestore(&port->lock, irqflags); in rza1_pin_set_direction()
650 static inline void rza1_pin_set(struct rza1_port *port, unsigned int pin, in rza1_pin_set() argument
651 unsigned int value) in rza1_pin_set()
655 spin_lock_irqsave(&port->lock, irqflags); in rza1_pin_set()
656 rza1_set_bit(port, RZA1_P_REG, pin, !!value); in rza1_pin_set()
657 spin_unlock_irqrestore(&port->lock, irqflags); in rza1_pin_set()
660 static inline int rza1_pin_get(struct rza1_port *port, unsigned int pin) in rza1_pin_get() argument
662 return rza1_get_bit(port, RZA1_PPR_REG, pin); in rza1_pin_get()
666 * rza1_pin_mux_single() - configure pin multiplexing on a single pin
671 static int rza1_pin_mux_single(struct rza1_pinctrl *rza1_pctl, in rza1_pin_mux_single()
674 struct rza1_port *port = &rza1_pctl->ports[mux_conf->port]; in rza1_pin_mux_single() local
675 unsigned int pin = mux_conf->pin; in rza1_pin_mux_single()
676 u8 mux_func = mux_conf->mux_func; in rza1_pin_mux_single()
677 u8 mux_flags = mux_conf->mux_flags; in rza1_pin_mux_single()
680 rza1_pin_reset(port, pin); in rza1_pin_mux_single()
683 mux_flags_from_table = rza1_pinmux_get_flags(port->id, pin, mux_func, in rza1_pin_mux_single()
691 rza1_set_bit(port, RZA1_PBDC_REG, pin, 1); in rza1_pin_mux_single()
696 * Be careful here: the pin mux sub-nodes in device tree in rza1_pin_mux_single()
701 * ---------------------------------------------------- in rza1_pin_mux_single()
704 * PMC PFC PFCE PFCAE (mux_func - 1) in rza1_pin_mux_single()
713 * ---------------------------------------------------- in rza1_pin_mux_single()
715 mux_func -= 1; in rza1_pin_mux_single()
716 rza1_set_bit(port, RZA1_PFC_REG, pin, mux_func & MUX_FUNC_PFC_MASK); in rza1_pin_mux_single()
717 rza1_set_bit(port, RZA1_PFCE_REG, pin, mux_func & MUX_FUNC_PFCE_MASK); in rza1_pin_mux_single()
718 rza1_set_bit(port, RZA1_PFCEA_REG, pin, mux_func & MUX_FUNC_PFCEA_MASK); in rza1_pin_mux_single()
723 * to I/O direction specified by pin configuration -after- PMC has been in rza1_pin_mux_single()
727 rza1_set_bit(port, RZA1_PM_REG, pin, in rza1_pin_mux_single()
730 rza1_set_bit(port, RZA1_PIPC_REG, pin, 1); in rza1_pin_mux_single()
732 rza1_set_bit(port, RZA1_PMC_REG, pin, 1); in rza1_pin_mux_single()
737 /* ----------------------------------------------------------------------------
742 * rza1_gpio_request() - configure pin in port mode
744 * Configure a pin as gpio (port mode).
751 static int rza1_gpio_request(struct gpio_chip *chip, unsigned int gpio) in rza1_gpio_request()
753 struct rza1_port *port = gpiochip_get_data(chip); in rza1_gpio_request() local
754 int ret; in rza1_gpio_request()
760 rza1_pin_reset(port, gpio); in rza1_gpio_request()
766 * rza1_gpio_free() - reset a pin
769 * Reset pin to port mode, with input buffer disabled. This overwrites all
770 * port direction settings applied with set_direction
775 static void rza1_gpio_free(struct gpio_chip *chip, unsigned int gpio) in rza1_gpio_free()
777 struct rza1_port *port = gpiochip_get_data(chip); in rza1_gpio_free() local
779 rza1_pin_reset(port, gpio); in rza1_gpio_free()
783 static int rza1_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio) in rza1_gpio_get_direction()
785 struct rza1_port *port = gpiochip_get_data(chip); in rza1_gpio_get_direction() local
787 if (rza1_get_bit(port, RZA1_PM_REG, gpio)) in rza1_gpio_get_direction()
793 static int rza1_gpio_direction_input(struct gpio_chip *chip, in rza1_gpio_direction_input()
794 unsigned int gpio) in rza1_gpio_direction_input()
796 struct rza1_port *port = gpiochip_get_data(chip); in rza1_gpio_direction_input() local
798 rza1_pin_set_direction(port, gpio, true); in rza1_gpio_direction_input()
803 static int rza1_gpio_direction_output(struct gpio_chip *chip, in rza1_gpio_direction_output()
804 unsigned int gpio, in rza1_gpio_direction_output()
805 int value) in rza1_gpio_direction_output()
807 struct rza1_port *port = gpiochip_get_data(chip); in rza1_gpio_direction_output() local
810 rza1_pin_set(port, gpio, value); in rza1_gpio_direction_output()
811 rza1_pin_set_direction(port, gpio, false); in rza1_gpio_direction_output()
817 * rza1_gpio_get() - read a gpio pin value
820 * Requires bi-directional mode to work when reading the value of a pin
826 static int rza1_gpio_get(struct gpio_chip *chip, unsigned int gpio) in rza1_gpio_get()
828 struct rza1_port *port = gpiochip_get_data(chip); in rza1_gpio_get() local
830 return rza1_pin_get(port, gpio); in rza1_gpio_get()
833 static void rza1_gpio_set(struct gpio_chip *chip, unsigned int gpio, in rza1_gpio_set()
834 int value) in rza1_gpio_set()
836 struct rza1_port *port = gpiochip_get_data(chip); in rza1_gpio_set() local
838 rza1_pin_set(port, gpio, value); in rza1_gpio_set()
850 /* ----------------------------------------------------------------------------
855 * rza1_dt_node_pin_count() - Count number of pins in a dt node or in all its
856 * children sub-nodes
860 static int rza1_dt_node_pin_count(struct device_node *np) in rza1_dt_node_pin_count()
863 unsigned int npins; in rza1_dt_node_pin_count()
867 return of_pins->length / sizeof(u32); in rza1_dt_node_pin_count()
873 return -EINVAL; in rza1_dt_node_pin_count()
875 npins += of_pins->length / sizeof(u32); in rza1_dt_node_pin_count()
882 * rza1_parse_pinmux_node() - parse a pin mux sub-node
885 * @np: of pmx sub-node
886 * @mux_confs: array of pin mux configurations to fill with parsed info
887 * @grpins: array of pin ids to mux
889 static int rza1_parse_pinmux_node(struct rza1_pinctrl *rza1_pctl, in rza1_parse_pinmux_node()
892 unsigned int *grpins) in rza1_parse_pinmux_node()
894 struct pinctrl_dev *pctldev = rza1_pctl->pctl; in rza1_parse_pinmux_node()
897 unsigned int npin_configs; in rza1_parse_pinmux_node()
899 unsigned int npins; in rza1_parse_pinmux_node()
901 unsigned int i; in rza1_parse_pinmux_node()
902 int ret; in rza1_parse_pinmux_node()
906 dev_dbg(rza1_pctl->dev, "Missing %s property\n", prop_name); in rza1_parse_pinmux_node()
907 return -ENOENT; in rza1_parse_pinmux_node()
909 npins = of_pins->length / sizeof(u32); in rza1_parse_pinmux_node()
913 * this sub-node in rza1_parse_pinmux_node()
918 dev_err(rza1_pctl->dev, in rza1_parse_pinmux_node()
926 * very few pins (TIOC[0-4][A|B|C|D] require SWIO direction in rza1_parse_pinmux_node()
946 /* Collect pin positions and their mux settings. */ in rza1_parse_pinmux_node()
955 mux_conf->id = of_pinconf & MUX_PIN_ID_MASK; in rza1_parse_pinmux_node()
956 mux_conf->port = RZA1_PIN_ID_TO_PORT(mux_conf->id); in rza1_parse_pinmux_node()
957 mux_conf->pin = RZA1_PIN_ID_TO_PIN(mux_conf->id); in rza1_parse_pinmux_node()
958 mux_conf->mux_func = MUX_FUNC(of_pinconf); in rza1_parse_pinmux_node()
959 mux_conf->mux_flags = pinmux_flags; in rza1_parse_pinmux_node()
961 if (mux_conf->port >= RZA1_NPORTS || in rza1_parse_pinmux_node()
962 mux_conf->pin >= RZA1_PINS_PER_PORT) { in rza1_parse_pinmux_node()
963 dev_err(rza1_pctl->dev, in rza1_parse_pinmux_node()
964 "Wrong port %u pin %u for %s property\n", in rza1_parse_pinmux_node()
965 mux_conf->port, mux_conf->pin, prop_name); in rza1_parse_pinmux_node()
966 return -EINVAL; in rza1_parse_pinmux_node()
969 grpins[i] = mux_conf->id; in rza1_parse_pinmux_node()
976 * rza1_dt_node_to_map() - map a pin mux node to a function/group
978 * Parse and register a pin mux function.
985 static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev, in rza1_dt_node_to_map()
988 unsigned int *num_maps) in rza1_dt_node_to_map()
992 unsigned int *grpins, *grpin; in rza1_dt_node_to_map()
995 int ret, npins; in rza1_dt_node_to_map()
996 int gsel, fsel; in rza1_dt_node_to_map()
1000 dev_err(rza1_pctl->dev, "invalid pinmux node structure\n"); in rza1_dt_node_to_map()
1001 return -EINVAL; in rza1_dt_node_to_map()
1007 * except that functions carry an array of per-pin mux configuration in rza1_dt_node_to_map()
1010 mux_confs = devm_kcalloc(rza1_pctl->dev, npins, sizeof(*mux_confs), in rza1_dt_node_to_map()
1012 grpins = devm_kcalloc(rza1_pctl->dev, npins, sizeof(*grpins), in rza1_dt_node_to_map()
1014 fngrps = devm_kzalloc(rza1_pctl->dev, sizeof(*fngrps), GFP_KERNEL); in rza1_dt_node_to_map()
1017 return -ENOMEM; in rza1_dt_node_to_map()
1021 * If the node does not contain "pinmux" property (-ENOENT) in rza1_dt_node_to_map()
1022 * that property shall be specified in all its children sub-nodes. in rza1_dt_node_to_map()
1028 if (ret == -ENOENT) in rza1_dt_node_to_map()
1042 grpname = np->name; in rza1_dt_node_to_map()
1045 mutex_lock(&rza1_pctl->mutex); in rza1_dt_node_to_map()
1049 mutex_unlock(&rza1_pctl->mutex); in rza1_dt_node_to_map()
1060 dev_info(rza1_pctl->dev, "Parsed function and group %s with %d pins\n", in rza1_dt_node_to_map()
1063 /* Create map where to retrieve function and mux settings from */ in rza1_dt_node_to_map()
1067 ret = -ENOMEM; in rza1_dt_node_to_map()
1071 (*map)->type = PIN_MAP_TYPE_MUX_GROUP; in rza1_dt_node_to_map()
1072 (*map)->data.mux.group = np->name; in rza1_dt_node_to_map()
1073 (*map)->data.mux.function = np->name; in rza1_dt_node_to_map()
1075 mutex_unlock(&rza1_pctl->mutex); in rza1_dt_node_to_map()
1084 mutex_unlock(&rza1_pctl->mutex); in rza1_dt_node_to_map()
1086 dev_info(rza1_pctl->dev, "Unable to parse function and group %s\n", in rza1_dt_node_to_map()
1093 struct pinctrl_map *map, unsigned int num_maps) in rza1_dt_free_map()
1106 /* ----------------------------------------------------------------------------
1111 * rza1_set_mux() - retrieve pins from a group and apply their mux settings
1117 static int rza1_set_mux(struct pinctrl_dev *pctldev, unsigned int selector, in rza1_set_mux()
1118 unsigned int group) in rza1_set_mux()
1124 int i; in rza1_set_mux()
1128 return -EINVAL; in rza1_set_mux()
1132 return -EINVAL; in rza1_set_mux()
1134 mux_confs = (struct rza1_mux_conf *)func->data; in rza1_set_mux()
1135 for (i = 0; i < grp->grp.npins; ++i) { in rza1_set_mux()
1136 int ret; in rza1_set_mux()
1154 /* ----------------------------------------------------------------------------
1159 * rza1_parse_gpiochip() - parse and register a gpio chip and pin range
1161 * The gpio controller subnode shall provide a "gpio-ranges" list property as
1165 * @fwnode: gpio-controller firmware node
1169 static int rza1_parse_gpiochip(struct rza1_pinctrl *rza1_pctl, in rza1_parse_gpiochip()
1174 const char *list_name = "gpio-ranges"; in rza1_parse_gpiochip()
1176 unsigned int gpioport; in rza1_parse_gpiochip()
1178 int ret; in rza1_parse_gpiochip()
1182 dev_err(rza1_pctl->dev, "Unable to parse %s list property\n", in rza1_parse_gpiochip()
1188 * Find out on which port this gpio-chip maps to by inspecting the in rza1_parse_gpiochip()
1189 * second argument of the "gpio-ranges" property. in rza1_parse_gpiochip()
1194 dev_err(rza1_pctl->dev, in rza1_parse_gpiochip()
1196 return -EINVAL; in rza1_parse_gpiochip()
1200 chip->base = -1; in rza1_parse_gpiochip()
1201 chip->ngpio = args.args[2]; in rza1_parse_gpiochip()
1202 chip->label = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "%pfwP", fwnode); in rza1_parse_gpiochip()
1203 if (!chip->label) in rza1_parse_gpiochip()
1204 return -ENOMEM; in rza1_parse_gpiochip()
1206 chip->fwnode = fwnode; in rza1_parse_gpiochip()
1207 chip->parent = rza1_pctl->dev; in rza1_parse_gpiochip()
1209 range->id = gpioport; in rza1_parse_gpiochip()
1210 range->name = chip->label; in rza1_parse_gpiochip()
1211 range->pin_base = range->base = pinctrl_base; in rza1_parse_gpiochip()
1212 range->npins = args.args[2]; in rza1_parse_gpiochip()
1213 range->gc = chip; in rza1_parse_gpiochip()
1215 ret = devm_gpiochip_add_data(rza1_pctl->dev, chip, in rza1_parse_gpiochip()
1216 &rza1_pctl->ports[gpioport]); in rza1_parse_gpiochip()
1220 pinctrl_add_gpio_range(rza1_pctl->pctl, range); in rza1_parse_gpiochip()
1222 dev_dbg(rza1_pctl->dev, "Parsed gpiochip %s with %d pins\n", in rza1_parse_gpiochip()
1223 chip->label, chip->ngpio); in rza1_parse_gpiochip()
1229 * rza1_gpio_register() - parse DT to collect gpio-chips and gpio-ranges
1233 static int rza1_gpio_register(struct rza1_pinctrl *rza1_pctl) in rza1_gpio_register()
1238 unsigned int ngpiochips; in rza1_gpio_register()
1239 unsigned int i; in rza1_gpio_register()
1240 int ret; in rza1_gpio_register()
1242 ngpiochips = gpiochip_node_count(rza1_pctl->dev); in rza1_gpio_register()
1244 dev_dbg(rza1_pctl->dev, "No gpiochip registered\n"); in rza1_gpio_register()
1248 gpio_chips = devm_kcalloc(rza1_pctl->dev, ngpiochips, in rza1_gpio_register()
1250 gpio_ranges = devm_kcalloc(rza1_pctl->dev, ngpiochips, in rza1_gpio_register()
1253 return -ENOMEM; in rza1_gpio_register()
1256 for_each_gpiochip_node(rza1_pctl->dev, child) { in rza1_gpio_register()
1267 dev_info(rza1_pctl->dev, "Registered %u gpio controllers\n", i); in rza1_gpio_register()
1273 * rza1_pinctrl_register() - Enumerate pins, ports and gpiochips; register
1278 static int rza1_pinctrl_register(struct rza1_pinctrl *rza1_pctl) in rza1_pinctrl_register()
1282 unsigned int i; in rza1_pinctrl_register()
1283 int ret; in rza1_pinctrl_register()
1285 pins = devm_kcalloc(rza1_pctl->dev, RZA1_NPINS, sizeof(*pins), in rza1_pinctrl_register()
1287 ports = devm_kcalloc(rza1_pctl->dev, RZA1_NPORTS, sizeof(*ports), in rza1_pinctrl_register()
1290 return -ENOMEM; in rza1_pinctrl_register()
1292 rza1_pctl->pins = pins; in rza1_pinctrl_register()
1293 rza1_pctl->desc.pins = pins; in rza1_pinctrl_register()
1294 rza1_pctl->desc.npins = RZA1_NPINS; in rza1_pinctrl_register()
1295 rza1_pctl->ports = ports; in rza1_pinctrl_register()
1298 unsigned int pin = RZA1_PIN_ID_TO_PIN(i); in rza1_pinctrl_register()
1299 unsigned int port = RZA1_PIN_ID_TO_PORT(i); in rza1_pinctrl_register() local
1302 pins[i].name = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, in rza1_pinctrl_register()
1303 "P%u-%u", port, pin); in rza1_pinctrl_register()
1305 return -ENOMEM; in rza1_pinctrl_register()
1310 * they provide per-port lock and logical base address. in rza1_pinctrl_register()
1312 unsigned int port_id = RZA1_PIN_ID_TO_PORT(i); in rza1_pinctrl_register()
1315 ports[port_id].base = rza1_pctl->base; in rza1_pinctrl_register()
1321 ret = devm_pinctrl_register_and_init(rza1_pctl->dev, &rza1_pctl->desc, in rza1_pinctrl_register()
1322 rza1_pctl, &rza1_pctl->pctl); in rza1_pinctrl_register()
1324 dev_err(rza1_pctl->dev, in rza1_pinctrl_register()
1329 ret = pinctrl_enable(rza1_pctl->pctl); in rza1_pinctrl_register()
1331 dev_err(rza1_pctl->dev, in rza1_pinctrl_register()
1338 dev_err(rza1_pctl->dev, "RZ/A1 GPIO registration failed\n"); in rza1_pinctrl_register()
1345 static int rza1_pinctrl_probe(struct platform_device *pdev) in rza1_pinctrl_probe()
1348 int ret; in rza1_pinctrl_probe()
1350 rza1_pctl = devm_kzalloc(&pdev->dev, sizeof(*rza1_pctl), GFP_KERNEL); in rza1_pinctrl_probe()
1352 return -ENOMEM; in rza1_pinctrl_probe()
1354 rza1_pctl->dev = &pdev->dev; in rza1_pinctrl_probe()
1356 rza1_pctl->base = devm_platform_ioremap_resource(pdev, 0); in rza1_pinctrl_probe()
1357 if (IS_ERR(rza1_pctl->base)) in rza1_pinctrl_probe()
1358 return PTR_ERR(rza1_pctl->base); in rza1_pinctrl_probe()
1360 mutex_init(&rza1_pctl->mutex); in rza1_pinctrl_probe()
1364 rza1_pctl->desc.name = DRIVER_NAME; in rza1_pinctrl_probe()
1365 rza1_pctl->desc.pctlops = &rza1_pinctrl_ops; in rza1_pinctrl_probe()
1366 rza1_pctl->desc.pmxops = &rza1_pinmux_ops; in rza1_pinctrl_probe()
1367 rza1_pctl->desc.owner = THIS_MODULE; in rza1_pinctrl_probe()
1368 rza1_pctl->data = of_device_get_match_data(&pdev->dev); in rza1_pinctrl_probe()
1374 dev_info(&pdev->dev, in rza1_pinctrl_probe()
1383 .compatible = "renesas,r7s72100-ports",
1388 .compatible = "renesas,r7s72102-ports",
1402 static int __init rza1_pinctrl_init(void) in rza1_pinctrl_init()