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>
13 #include <linux/pinctrl/pinctrl.h>
14 #include <linux/pinctrl/pinconf.h>
15 #include <linux/pinctrl/pinmux.h>
16 #include <linux/pinctrl/consumer.h>
17 #include <linux/pinctrl/machine.h>
21 #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)
24 #define MFPR_FUNC_MASK 0x3
26 #define LTQ_PINCONF_PACK(param, arg) ((param) << 16 | (arg))
27 #define LTQ_PINCONF_UNPACK_PARAM(conf) ((conf) >> 16)
28 #define LTQ_PINCONF_UNPACK_ARG(conf) ((conf) & 0xffff)
30 enum ltq_pinconf_param
{
31 LTQ_PINCONF_PARAM_PULL
,
32 LTQ_PINCONF_PARAM_OPEN_DRAIN
,
33 LTQ_PINCONF_PARAM_DRIVE_CURRENT
,
34 LTQ_PINCONF_PARAM_SLEW_RATE
,
35 LTQ_PINCONF_PARAM_OUTPUT
,
38 struct ltq_cfg_param
{
40 enum ltq_pinconf_param param
;
45 const unsigned int pin
;
46 const unsigned short func
[LTQ_MAX_MUX
];
49 struct ltq_pin_group
{
58 const char * const *groups
;
59 const unsigned num_groups
;
62 struct ltq_pinmux_info
{
64 struct pinctrl_dev
*pctrl
;
66 /* we need to manage up to 5 pad controllers */
67 void __iomem
*membase
[5];
69 /* the descriptor for the subsystem */
70 struct pinctrl_desc
*desc
;
72 /* we expose our pads to the subsystem */
73 struct pinctrl_pin_desc
*pads
;
75 /* the number of pads. this varies between socs */
76 unsigned int num_pads
;
78 /* these are our multifunction pins */
79 const struct ltq_mfp_pin
*mfp
;
82 /* a number of multifunction pins can be grouped together */
83 const struct ltq_pin_group
*grps
;
84 unsigned int num_grps
;
86 /* a mapping between function string and id */
87 const struct ltq_pmx_func
*funcs
;
88 unsigned int num_funcs
;
90 /* the pinconf options that we are able to read from the DT */
91 const struct ltq_cfg_param
*params
;
92 unsigned int num_params
;
94 /* the pad controller can have a irq mapping */
96 unsigned int num_exin
;
98 /* we need 5 clocks max */
101 /* soc specific callback used to apply muxing */
102 int (*apply_mux
)(struct pinctrl_dev
*pctrldev
, int pin
, int mux
);
198 extern int ltq_pinctrl_register(struct platform_device
*pdev
,
199 struct ltq_pinmux_info
*info
);
200 extern int ltq_pinctrl_unregister(struct platform_device
*pdev
);
201 #endif /* __PINCTRL_LANTIQ_H */