2 * (C) Copyright 2016 - Beniamino Galvani <b.galvani@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0+
7 #ifndef __PINCTRL_MESON_H__
8 #define __PINCTRL_MESON_H__
10 #include <linux/types.h>
12 struct meson_pmx_group {
14 const unsigned int *pins;
15 unsigned int num_pins;
21 struct meson_pmx_func {
23 const char * const *groups;
24 unsigned int num_groups;
27 struct meson_pinctrl_data {
29 struct meson_pmx_group *groups;
30 struct meson_pmx_func *funcs;
31 struct meson_bank *banks;
32 unsigned int pin_base;
33 unsigned int num_pins;
34 unsigned int num_groups;
35 unsigned int num_funcs;
36 unsigned int num_banks;
39 struct meson_pinctrl {
40 struct meson_pinctrl_data *data;
41 void __iomem *reg_mux;
42 void __iomem *reg_gpio;
46 * struct meson_reg_desc - a register descriptor
48 * @reg: register offset in the regmap
49 * @bit: bit index in register
51 * The structure describes the information needed to control pull,
52 * pull-enable, direction, etc. for a single pin
54 struct meson_reg_desc {
60 * enum meson_reg_type - type of registers encoded in @meson_reg_desc
75 * @first: first pin of the bank
76 * @last: last pin of the bank
77 * @regs: array of register descriptors
79 * A bank represents a set of pins controlled by a contiguous set of
80 * bits in the domain registers. The structure specifies which bits in
81 * the regmap control the different functionalities. Each member of
82 * the @regs array refers to the first pin of the bank.
88 struct meson_reg_desc regs[NUM_REG];
91 #define PIN(x, b) (b + x)
93 #define GROUP(grp, r, b) \
96 .pins = grp ## _pins, \
97 .num_pins = ARRAY_SIZE(grp ## _pins), \
102 #define GPIO_GROUP(gpio, b) \
105 .pins = (const unsigned int[]){ PIN(gpio, b) }, \
110 #define FUNCTION(fn) \
113 .groups = fn ## _groups, \
114 .num_groups = ARRAY_SIZE(fn ## _groups), \
117 #define BANK(n, f, l, per, peb, pr, pb, dr, db, or, ob, ir, ib) \
123 [REG_PULLEN] = { per, peb }, \
124 [REG_PULL] = { pr, pb }, \
125 [REG_DIR] = { dr, db }, \
126 [REG_OUT] = { or, ob }, \
127 [REG_IN] = { ir, ib }, \
131 #define MESON_PIN(x, b) PINCTRL_PIN(PIN(x, b), #x)
133 extern const struct pinctrl_ops meson_pinctrl_ops;
135 int meson_pinctrl_probe(struct udevice *dev);
137 #endif /* __PINCTRL_MESON_H__ */