1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/drivers/pinctrl/pinctrl-lantiq.h
4 * based on linux/drivers/pinctrl/pinctrl-pxa3xx.h
6 * Copyright (C) 2012 John Crispin <john@phrozen.org>
9 #ifndef __PINCTRL_LANTIQ_H
10 #define __PINCTRL_LANTIQ_H
12 #include <linux/clkdev.h>
14 #include <linux/pinctrl/consumer.h>
15 #include <linux/pinctrl/machine.h>
16 #include <linux/pinctrl/pinconf.h>
17 #include <linux/pinctrl/pinctrl.h>
18 #include <linux/pinctrl/pinmux.h>
22 #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)
25 #define MFPR_FUNC_MASK 0x3
27 #define LTQ_PINCONF_PACK(param, arg) ((param) << 16 | (arg))
28 #define LTQ_PINCONF_UNPACK_PARAM(conf) ((conf) >> 16)
29 #define LTQ_PINCONF_UNPACK_ARG(conf) ((conf) & 0xffff)
31 enum ltq_pinconf_param {
32 LTQ_PINCONF_PARAM_PULL,
33 LTQ_PINCONF_PARAM_OPEN_DRAIN,
34 LTQ_PINCONF_PARAM_DRIVE_CURRENT,
35 LTQ_PINCONF_PARAM_SLEW_RATE,
36 LTQ_PINCONF_PARAM_OUTPUT,
39 struct ltq_cfg_param {
41 enum ltq_pinconf_param param;
46 const unsigned int pin;
47 const unsigned short func[LTQ_MAX_MUX];
50 struct ltq_pin_group {
59 const char * const *groups;
60 const unsigned num_groups;
63 struct ltq_pinmux_info {
65 struct pinctrl_dev *pctrl;
67 /* we need to manage up to 5 pad controllers */
68 void __iomem *membase[5];
70 /* the descriptor for the subsystem */
71 struct pinctrl_desc *desc;
73 /* we expose our pads to the subsystem */
74 struct pinctrl_pin_desc *pads;
76 /* the number of pads. this varies between socs */
77 unsigned int num_pads;
79 /* these are our multifunction pins */
80 const struct ltq_mfp_pin *mfp;
83 /* a number of multifunction pins can be grouped together */
84 const struct ltq_pin_group *grps;
85 unsigned int num_grps;
87 /* a mapping between function string and id */
88 const struct ltq_pmx_func *funcs;
89 unsigned int num_funcs;
91 /* the pinconf options that we are able to read from the DT */
92 const struct ltq_cfg_param *params;
93 unsigned int num_params;
95 /* the pad controller can have a irq mapping */
97 unsigned int num_exin;
99 /* we need 5 clocks max */
102 /* soc specific callback used to apply muxing */
103 int (*apply_mux)(struct pinctrl_dev *pctrldev, int pin, int mux);
199 extern int ltq_pinctrl_register(struct platform_device *pdev,
200 struct ltq_pinmux_info *info);
201 #endif /* __PINCTRL_LANTIQ_H */