2 * linux/drivers/pinctrl/pinctrl-lantiq.h
3 * based on linux/drivers/pinctrl/pinctrl-pxa3xx.h
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * publishhed by the Free Software Foundation.
9 * Copyright (C) 2012 John Crispin <john@phrozen.org>
12 #ifndef __PINCTRL_LANTIQ_H
13 #define __PINCTRL_LANTIQ_H
15 #include <linux/clkdev.h>
16 #include <linux/pinctrl/pinctrl.h>
17 #include <linux/pinctrl/pinconf.h>
18 #include <linux/pinctrl/pinmux.h>
19 #include <linux/pinctrl/consumer.h>
20 #include <linux/pinctrl/machine.h>
24 #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)
27 #define MFPR_FUNC_MASK 0x3
29 #define LTQ_PINCONF_PACK(param, arg) ((param) << 16 | (arg))
30 #define LTQ_PINCONF_UNPACK_PARAM(conf) ((conf) >> 16)
31 #define LTQ_PINCONF_UNPACK_ARG(conf) ((conf) & 0xffff)
33 enum ltq_pinconf_param
{
34 LTQ_PINCONF_PARAM_PULL
,
35 LTQ_PINCONF_PARAM_OPEN_DRAIN
,
36 LTQ_PINCONF_PARAM_DRIVE_CURRENT
,
37 LTQ_PINCONF_PARAM_SLEW_RATE
,
38 LTQ_PINCONF_PARAM_OUTPUT
,
41 struct ltq_cfg_param
{
43 enum ltq_pinconf_param param
;
48 const unsigned int pin
;
49 const unsigned short func
[LTQ_MAX_MUX
];
52 struct ltq_pin_group
{
61 const char * const *groups
;
62 const unsigned num_groups
;
65 struct ltq_pinmux_info
{
67 struct pinctrl_dev
*pctrl
;
69 /* we need to manage up to 5 pad controllers */
70 void __iomem
*membase
[5];
72 /* the descriptor for the subsystem */
73 struct pinctrl_desc
*desc
;
75 /* we expose our pads to the subsystem */
76 struct pinctrl_pin_desc
*pads
;
78 /* the number of pads. this varies between socs */
79 unsigned int num_pads
;
81 /* these are our multifunction pins */
82 const struct ltq_mfp_pin
*mfp
;
85 /* a number of multifunction pins can be grouped together */
86 const struct ltq_pin_group
*grps
;
87 unsigned int num_grps
;
89 /* a mapping between function string and id */
90 const struct ltq_pmx_func
*funcs
;
91 unsigned int num_funcs
;
93 /* the pinconf options that we are able to read from the DT */
94 const struct ltq_cfg_param
*params
;
95 unsigned int num_params
;
97 /* the pad controller can have a irq mapping */
99 unsigned int num_exin
;
101 /* we need 5 clocks max */
104 /* soc specific callback used to apply muxing */
105 int (*apply_mux
)(struct pinctrl_dev
*pctrldev
, int pin
, int mux
);
201 extern int ltq_pinctrl_register(struct platform_device
*pdev
,
202 struct ltq_pinmux_info
*info
);
203 extern int ltq_pinctrl_unregister(struct platform_device
*pdev
);
204 #endif /* __PINCTRL_LANTIQ_H */