1
2
3
4
5
6
7
8
9#ifndef __PINCTRL_MVEBU_H__
10#define __PINCTRL_MVEBU_H__
11
12
13
14
15
16
17
18struct mvebu_mpp_ctrl_data {
19 union {
20 void __iomem *base;
21 struct {
22 struct regmap *map;
23 u32 offset;
24 } regmap;
25 };
26};
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47struct mvebu_mpp_ctrl {
48 const char *name;
49 u8 pid;
50 u8 npins;
51 unsigned *pins;
52 int (*mpp_get)(struct mvebu_mpp_ctrl_data *data, unsigned pid,
53 unsigned long *config);
54 int (*mpp_set)(struct mvebu_mpp_ctrl_data *data, unsigned pid,
55 unsigned long config);
56 int (*mpp_gpio_req)(struct mvebu_mpp_ctrl_data *data, unsigned pid);
57 int (*mpp_gpio_dir)(struct mvebu_mpp_ctrl_data *data, unsigned pid,
58 bool input);
59};
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84struct mvebu_mpp_ctrl_setting {
85 u8 val;
86 const char *name;
87 const char *subname;
88 u8 variant;
89 u8 flags;
90#define MVEBU_SETTING_GPO (1 << 0)
91#define MVEBU_SETTING_GPI (1 << 1)
92};
93
94
95
96
97
98
99
100
101
102struct mvebu_mpp_mode {
103 u8 pid;
104 struct mvebu_mpp_ctrl_setting *settings;
105};
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122struct mvebu_pinctrl_soc_info {
123 u8 variant;
124 const struct mvebu_mpp_ctrl *controls;
125 struct mvebu_mpp_ctrl_data *control_data;
126 int ncontrols;
127 struct mvebu_mpp_mode *modes;
128 int nmodes;
129 struct pinctrl_gpio_range *gpioranges;
130 int ngpioranges;
131};
132
133#define MPP_FUNC_CTRL(_idl, _idh, _name, _func) \
134 { \
135 .name = _name, \
136 .pid = _idl, \
137 .npins = _idh - _idl + 1, \
138 .pins = (unsigned[_idh - _idl + 1]) { }, \
139 .mpp_get = _func ## _get, \
140 .mpp_set = _func ## _set, \
141 .mpp_gpio_req = NULL, \
142 .mpp_gpio_dir = NULL, \
143 }
144
145#define MPP_FUNC_GPIO_CTRL(_idl, _idh, _name, _func) \
146 { \
147 .name = _name, \
148 .pid = _idl, \
149 .npins = _idh - _idl + 1, \
150 .pins = (unsigned[_idh - _idl + 1]) { }, \
151 .mpp_get = _func ## _get, \
152 .mpp_set = _func ## _set, \
153 .mpp_gpio_req = _func ## _gpio_req, \
154 .mpp_gpio_dir = _func ## _gpio_dir, \
155 }
156
157#define _MPP_VAR_FUNCTION(_val, _name, _subname, _mask) \
158 { \
159 .val = _val, \
160 .name = _name, \
161 .subname = _subname, \
162 .variant = _mask, \
163 .flags = 0, \
164 }
165
166#if defined(CONFIG_DEBUG_FS)
167#define MPP_VAR_FUNCTION(_val, _name, _subname, _mask) \
168 _MPP_VAR_FUNCTION(_val, _name, _subname, _mask)
169#else
170#define MPP_VAR_FUNCTION(_val, _name, _subname, _mask) \
171 _MPP_VAR_FUNCTION(_val, _name, NULL, _mask)
172#endif
173
174#define MPP_FUNCTION(_val, _name, _subname) \
175 MPP_VAR_FUNCTION(_val, _name, _subname, (u8)-1)
176
177#define MPP_MODE(_id, ...) \
178 { \
179 .pid = _id, \
180 .settings = (struct mvebu_mpp_ctrl_setting[]){ \
181 __VA_ARGS__, { } }, \
182 }
183
184#define MPP_GPIO_RANGE(_id, _pinbase, _gpiobase, _npins) \
185 { \
186 .name = "mvebu-gpio", \
187 .id = _id, \
188 .pin_base = _pinbase, \
189 .base = _gpiobase, \
190 .npins = _npins, \
191 }
192
193#define MVEBU_MPPS_PER_REG 8
194#define MVEBU_MPP_BITS 4
195#define MVEBU_MPP_MASK 0xf
196
197int mvebu_mmio_mpp_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
198 unsigned long *config);
199int mvebu_mmio_mpp_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
200 unsigned long config);
201int mvebu_regmap_mpp_ctrl_get(struct mvebu_mpp_ctrl_data *data, unsigned pid,
202 unsigned long *config);
203int mvebu_regmap_mpp_ctrl_set(struct mvebu_mpp_ctrl_data *data, unsigned pid,
204 unsigned long config);
205
206int mvebu_pinctrl_probe(struct platform_device *pdev);
207int mvebu_pinctrl_simple_mmio_probe(struct platform_device *pdev);
208int mvebu_pinctrl_simple_regmap_probe(struct platform_device *pdev,
209 struct device *syscon_dev, u32 offset);
210
211#endif
212