1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * (C) Copyright 2016 - Beniamino Galvani <b.galvani@gmail.com>
6 #ifndef __PINCTRL_MESON_H__
7 #define __PINCTRL_MESON_H__
9 #include <linux/types.h>
11 struct meson_pmx_group {
13 const unsigned int *pins;
14 unsigned int num_pins;
20 struct meson_pmx_func {
22 const char * const *groups;
23 unsigned int num_groups;
26 struct meson_pinctrl_data {
28 struct meson_pmx_group *groups;
29 struct meson_pmx_func *funcs;
30 struct meson_bank *banks;
31 unsigned int pin_base;
32 unsigned int num_pins;
33 unsigned int num_groups;
34 unsigned int num_funcs;
35 unsigned int num_banks;
38 struct meson_pinctrl {
39 struct meson_pinctrl_data *data;
40 void __iomem *reg_mux;
41 void __iomem *reg_gpio;
45 * struct meson_reg_desc - a register descriptor
47 * @reg: register offset in the regmap
48 * @bit: bit index in register
50 * The structure describes the information needed to control pull,
51 * pull-enable, direction, etc. for a single pin
53 struct meson_reg_desc {
59 * enum meson_reg_type - type of registers encoded in @meson_reg_desc
74 * @first: first pin of the bank
75 * @last: last pin of the bank
76 * @regs: array of register descriptors
78 * A bank represents a set of pins controlled by a contiguous set of
79 * bits in the domain registers. The structure specifies which bits in
80 * the regmap control the different functionalities. Each member of
81 * the @regs array refers to the first pin of the bank.
87 struct meson_reg_desc regs[NUM_REG];
90 #define PIN(x, b) (b + x)
92 #define GROUP(grp, r, b) \
95 .pins = grp ## _pins, \
96 .num_pins = ARRAY_SIZE(grp ## _pins), \
101 #define GPIO_GROUP(gpio, b) \
104 .pins = (const unsigned int[]){ PIN(gpio, b) }, \
109 #define FUNCTION(fn) \
112 .groups = fn ## _groups, \
113 .num_groups = ARRAY_SIZE(fn ## _groups), \
116 #define BANK(n, f, l, per, peb, pr, pb, dr, db, or, ob, ir, ib) \
122 [REG_PULLEN] = { per, peb }, \
123 [REG_PULL] = { pr, pb }, \
124 [REG_DIR] = { dr, db }, \
125 [REG_OUT] = { or, ob }, \
126 [REG_IN] = { ir, ib }, \
130 #define MESON_PIN(x, b) PINCTRL_PIN(PIN(x, b), #x)
132 extern const struct pinctrl_ops meson_pinctrl_ops;
134 int meson_pinctrl_probe(struct udevice *dev);
136 #endif /* __PINCTRL_MESON_H__ */