1 // SPDX-License-Identifier: GPL-2.0+
3 * OWL SoC's Pinctrl definitions
5 * Copyright (c) 2014 Actions Semi Inc.
6 * Author: David Liu <liuwei@actions-semi.com>
8 * Copyright (c) 2018 Linaro Ltd.
9 * Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
12 #ifndef __PINCTRL_OWL_H__
13 #define __PINCTRL_OWL_H__
15 #define OWL_PINCONF_SLEW_SLOW 0
16 #define OWL_PINCONF_SLEW_FAST 1
18 #define MUX_PG(group_name, reg, shift, width) \
20 .name = #group_name, \
21 .pads = group_name##_pads, \
22 .npads = ARRAY_SIZE(group_name##_pads), \
23 .funcs = group_name##_funcs, \
24 .nfuncs = ARRAY_SIZE(group_name##_funcs), \
25 .mfpctl_reg = MFCTL##reg, \
26 .mfpctl_shift = shift, \
27 .mfpctl_width = width, \
36 #define DRV_PG(group_name, reg, shift, width) \
38 .name = #group_name, \
39 .pads = group_name##_pads, \
40 .npads = ARRAY_SIZE(group_name##_pads), \
44 .drv_reg = PAD_DRV##reg, \
52 #define SR_PG(group_name, reg, shift, width) \
54 .name = #group_name, \
55 .pads = group_name##_pads, \
56 .npads = ARRAY_SIZE(group_name##_pads), \
63 .sr_reg = PAD_SR##reg, \
68 #define FUNCTION(fname) \
71 .groups = fname##_groups, \
72 .ngroups = ARRAY_SIZE(fname##_groups), \
75 /* PAD PULL UP/DOWN CONFIGURES */
76 #define PULLCTL_CONF(pull_reg, pull_sft, pull_wdt) \
78 .reg = PAD_PULLCTL##pull_reg, \
83 #define PAD_PULLCTL_CONF(pad_name, pull_reg, pull_sft, pull_wdt) \
84 struct owl_pullctl pad_name##_pullctl_conf \
85 = PULLCTL_CONF(pull_reg, pull_sft, pull_wdt)
87 #define ST_CONF(st_reg, st_sft, st_wdt) \
89 .reg = PAD_ST##st_reg, \
94 #define PAD_ST_CONF(pad_name, st_reg, st_sft, st_wdt) \
95 struct owl_st pad_name##_st_conf \
96 = ST_CONF(st_reg, st_sft, st_wdt)
98 #define PAD_INFO(name) \
105 #define PAD_INFO_ST(name) \
109 .st = &name##_st_conf, \
112 #define PAD_INFO_PULLCTL(name) \
115 .pullctl = &name##_pullctl_conf, \
119 #define PAD_INFO_PULLCTL_ST(name) \
122 .pullctl = &name##_pullctl_conf, \
123 .st = &name##_st_conf, \
126 #define OWL_GPIO_PORT_A 0
127 #define OWL_GPIO_PORT_B 1
128 #define OWL_GPIO_PORT_C 2
129 #define OWL_GPIO_PORT_D 3
130 #define OWL_GPIO_PORT_E 4
131 #define OWL_GPIO_PORT_F 5
133 #define OWL_GPIO_PORT(port, base, count, _outen, _inen, _dat, _intc_ctl,\
134 _intc_pd, _intc_msk, _intc_type, _share) \
135 [OWL_GPIO_PORT_##port] = { \
141 .intc_ctl = _intc_ctl, \
142 .intc_pd = _intc_pd, \
143 .intc_msk = _intc_msk, \
144 .intc_type = _intc_type, \
145 .shared_ctl_offset = _share, \
148 enum owl_pinconf_drv {
152 OWL_PINCONF_DRV_12MA,
155 /* GPIO CTRL Bit Definition */
156 #define OWL_GPIO_CTLR_PENDING 0
157 #define OWL_GPIO_CTLR_ENABLE 1
158 #define OWL_GPIO_CTLR_SAMPLE_CLK_24M 2
160 /* GPIO TYPE Bit Definition */
161 #define OWL_GPIO_INT_LEVEL_HIGH 0
162 #define OWL_GPIO_INT_LEVEL_LOW 1
163 #define OWL_GPIO_INT_EDGE_RISING 2
164 #define OWL_GPIO_INT_EDGE_FALLING 3
165 #define OWL_GPIO_INT_MASK 3
168 * struct owl_pullctl - Actions pad pull control register
169 * @reg: offset to the pull control register
170 * @shift: shift value of the register
171 * @width: width of the register
180 * struct owl_st - Actions pad schmitt trigger enable register
181 * @reg: offset to the schmitt trigger enable register
182 * @shift: shift value of the register
183 * @width: width of the register
192 * struct owl_pingroup - Actions pingroup definition
193 * @name: name of the pin group
194 * @pads: list of pins assigned to this pingroup
195 * @npads: size of @pads array
196 * @funcs: list of pinmux functions for this pingroup
197 * @nfuncs: size of @funcs array
198 * @mfpctl_reg: multiplexing control register offset
199 * @mfpctl_shift: multiplexing control register bit mask
200 * @mfpctl_width: multiplexing control register width
201 * @drv_reg: drive control register offset
202 * @drv_shift: drive control register bit mask
203 * @drv_width: driver control register width
204 * @sr_reg: slew rate control register offset
205 * @sr_shift: slew rate control register bit mask
206 * @sr_width: slew rate control register width
208 struct owl_pingroup {
216 unsigned int mfpctl_shift;
217 unsigned int mfpctl_width;
220 unsigned int drv_shift;
221 unsigned int drv_width;
224 unsigned int sr_shift;
225 unsigned int sr_width;
229 * struct owl_padinfo - Actions pinctrl pad info
230 * @pad: pad name of the SoC
231 * @pullctl: pull control register info
232 * @st: schmitt trigger register info
236 struct owl_pullctl *pullctl;
241 * struct owl_pinmux_func - Actions pinctrl mux functions
242 * @name: name of the pinmux function.
243 * @groups: array of pin groups that may select this function.
244 * @ngroups: number of entries in @groups.
246 struct owl_pinmux_func {
248 const char * const *groups;
249 unsigned int ngroups;
253 * struct owl_gpio_port - Actions GPIO port info
254 * @offset: offset of the GPIO port.
255 * @pins: number of pins belongs to the GPIO port.
256 * @outen: offset of the output enable register.
257 * @inen: offset of the input enable register.
258 * @dat: offset of the data register.
259 * @intc_ctl: offset of the interrupt control register.
260 * @intc_pd: offset of the interrupt pending register.
261 * @intc_msk: offset of the interrupt mask register.
262 * @intc_type: offset of the interrupt type register.
264 struct owl_gpio_port {
270 unsigned int intc_ctl;
271 unsigned int intc_pd;
272 unsigned int intc_msk;
273 unsigned int intc_type;
274 u8 shared_ctl_offset;
278 * struct owl_pinctrl_soc_data - Actions pin controller driver configuration
279 * @pins: array describing all pins of the pin controller.
280 * @npins: number of entries in @pins.
281 * @functions: array describing all mux functions of this SoC.
282 * @nfunction: number of entries in @functions.
283 * @groups: array describing all pin groups of this SoC.
284 * @ngroups: number of entries in @groups.
285 * @padinfo: array describing the pad info of this SoC.
286 * @ngpios: number of pingroups the driver should expose as GPIOs.
287 * @ports: array describing all GPIO ports of this SoC.
288 * @nports: number of GPIO ports in this SoC.
290 struct owl_pinctrl_soc_data {
291 const struct pinctrl_pin_desc *pins;
293 const struct owl_pinmux_func *functions;
294 unsigned int nfunctions;
295 const struct owl_pingroup *groups;
296 unsigned int ngroups;
297 const struct owl_padinfo *padinfo;
299 const struct owl_gpio_port *ports;
301 int (*padctl_val2arg)(const struct owl_padinfo *padinfo,
304 int (*padctl_arg2val)(const struct owl_padinfo *info,
309 int owl_pinctrl_probe(struct platform_device *pdev,
310 struct owl_pinctrl_soc_data *soc_data);
312 #endif /* __PINCTRL_OWL_H__ */