1
2
3
4
5
6
7
8
9
10
11
12
13
14#include <linux/gpio.h>
15#include <linux/pinctrl/pinctrl.h>
16#include <linux/regmap.h>
17#include <linux/types.h>
18
19
20
21
22
23
24
25
26
27
28
29
30struct meson_pmx_group {
31 const char *name;
32 const unsigned int *pins;
33 unsigned int num_pins;
34 bool is_gpio;
35 unsigned int reg;
36 unsigned int bit;
37};
38
39
40
41
42
43
44
45
46struct meson_pmx_func {
47 const char *name;
48 const char * const *groups;
49 unsigned int num_groups;
50};
51
52
53
54
55
56
57
58
59
60
61struct meson_reg_desc {
62 unsigned int reg;
63 unsigned int bit;
64};
65
66
67
68
69enum meson_reg_type {
70 REG_PULLEN,
71 REG_PULL,
72 REG_DIR,
73 REG_OUT,
74 REG_IN,
75 NUM_REG,
76};
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92struct meson_bank {
93 const char *name;
94 unsigned int first;
95 unsigned int last;
96 int irq_first;
97 int irq_last;
98 struct meson_reg_desc regs[NUM_REG];
99};
100
101struct meson_pinctrl_data {
102 const char *name;
103 const struct pinctrl_pin_desc *pins;
104 struct meson_pmx_group *groups;
105 struct meson_pmx_func *funcs;
106 unsigned int pin_base;
107 unsigned int num_pins;
108 unsigned int num_groups;
109 unsigned int num_funcs;
110 struct meson_bank *banks;
111 unsigned int num_banks;
112};
113
114struct meson_pinctrl {
115 struct device *dev;
116 struct pinctrl_dev *pcdev;
117 struct pinctrl_desc desc;
118 struct meson_pinctrl_data *data;
119 struct regmap *reg_mux;
120 struct regmap *reg_pullen;
121 struct regmap *reg_pull;
122 struct regmap *reg_gpio;
123 struct gpio_chip chip;
124 struct device_node *of_node;
125};
126
127#define PIN(x, b) (b + x)
128
129#define GROUP(grp, r, b) \
130 { \
131 .name = #grp, \
132 .pins = grp ## _pins, \
133 .num_pins = ARRAY_SIZE(grp ## _pins), \
134 .reg = r, \
135 .bit = b, \
136 }
137
138#define GPIO_GROUP(gpio, b) \
139 { \
140 .name = #gpio, \
141 .pins = (const unsigned int[]){ PIN(gpio, b) }, \
142 .num_pins = 1, \
143 .is_gpio = true, \
144 }
145
146#define FUNCTION(fn) \
147 { \
148 .name = #fn, \
149 .groups = fn ## _groups, \
150 .num_groups = ARRAY_SIZE(fn ## _groups), \
151 }
152
153#define BANK(n, f, l, fi, li, per, peb, pr, pb, dr, db, or, ob, ir, ib) \
154 { \
155 .name = n, \
156 .first = f, \
157 .last = l, \
158 .irq_first = fi, \
159 .irq_last = li, \
160 .regs = { \
161 [REG_PULLEN] = { per, peb }, \
162 [REG_PULL] = { pr, pb }, \
163 [REG_DIR] = { dr, db }, \
164 [REG_OUT] = { or, ob }, \
165 [REG_IN] = { ir, ib }, \
166 }, \
167 }
168
169#define MESON_PIN(x, b) PINCTRL_PIN(PIN(x, b), #x)
170
171extern struct meson_pinctrl_data meson8_cbus_pinctrl_data;
172extern struct meson_pinctrl_data meson8_aobus_pinctrl_data;
173extern struct meson_pinctrl_data meson8b_cbus_pinctrl_data;
174extern struct meson_pinctrl_data meson8b_aobus_pinctrl_data;
175extern struct meson_pinctrl_data meson_gxbb_periphs_pinctrl_data;
176extern struct meson_pinctrl_data meson_gxbb_aobus_pinctrl_data;
177extern struct meson_pinctrl_data meson_gxl_periphs_pinctrl_data;
178extern struct meson_pinctrl_data meson_gxl_aobus_pinctrl_data;
179