47a6b5b72f907ade381e1b01de57c82cbf0365c1
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / pinctrl / spear / pinctrl-spear.h
1 /*
2  * Driver header file for the ST Microelectronics SPEAr pinmux
3  *
4  * Copyright (C) 2012 ST Microelectronics
5  * Viresh Kumar <viresh.kumar@st.com>
6  *
7  * This file is licensed under the terms of the GNU General Public
8  * License version 2. This program is licensed "as is" without any
9  * warranty of any kind, whether express or implied.
10  */
11
12 #ifndef __PINMUX_SPEAR_H__
13 #define __PINMUX_SPEAR_H__
14
15 #include <linux/pinctrl/pinctrl.h>
16 #include <linux/types.h>
17
18 struct platform_device;
19 struct device;
20
21 /**
22  * struct spear_pmx_mode - SPEAr pmx mode
23  * @name: name of pmx mode
24  * @mode: mode id
25  * @reg: register for configuring this mode
26  * @mask: mask of this mode in reg
27  * @val: val to be configured at reg after doing (val & mask)
28  */
29 struct spear_pmx_mode {
30         const char *const name;
31         u16 mode;
32         u16 reg;
33         u16 mask;
34         u32 val;
35 };
36
37 /**
38  * struct spear_muxreg - SPEAr mux reg configuration
39  * @reg: register offset
40  * @mask: mask bits
41  * @val: val to be written on mask bits
42  */
43 struct spear_muxreg {
44         u16 reg;
45         u32 mask;
46         u32 val;
47 };
48
49 /**
50  * struct spear_modemux - SPEAr mode mux configuration
51  * @modes: mode ids supported by this group of muxregs
52  * @nmuxregs: number of muxreg configurations to be done for modes
53  * @muxregs: array of muxreg configurations to be done for modes
54  */
55 struct spear_modemux {
56         u16 modes;
57         u8 nmuxregs;
58         struct spear_muxreg *muxregs;
59 };
60
61 /**
62  * struct spear_pingroup - SPEAr pin group configurations
63  * @name: name of pin group
64  * @pins: array containing pin numbers
65  * @npins: size of pins array
66  * @modemuxs: array of modemux configurations for this pin group
67  * @nmodemuxs: size of array modemuxs
68  *
69  * A representation of a group of pins in the SPEAr pin controller. Each group
70  * allows some parameter or parameters to be configured.
71  */
72 struct spear_pingroup {
73         const char *name;
74         const unsigned *pins;
75         unsigned npins;
76         struct spear_modemux *modemuxs;
77         unsigned nmodemuxs;
78 };
79
80 /**
81  * struct spear_function - SPEAr pinctrl mux function
82  * @name: The name of the function, exported to pinctrl core.
83  * @groups: An array of pin groups that may select this function.
84  * @ngroups: The number of entries in @groups.
85  */
86 struct spear_function {
87         const char *name;
88         const char *const *groups;
89         unsigned ngroups;
90 };
91
92 /**
93  * struct spear_pinctrl_machdata - SPEAr pin controller machine driver
94  *      configuration
95  * @pins: An array describing all pins the pin controller affects.
96  *      All pins which are also GPIOs must be listed first within the *array,
97  *      and be numbered identically to the GPIO controller's *numbering.
98  * @npins: The numbmer of entries in @pins.
99  * @functions: An array describing all mux functions the SoC supports.
100  * @nfunctions: The numbmer of entries in @functions.
101  * @groups: An array describing all pin groups the pin SoC supports.
102  * @ngroups: The numbmer of entries in @groups.
103  *
104  * @modes_supported: Does SoC support modes
105  * @mode: mode configured from probe
106  * @pmx_modes: array of modes supported by SoC
107  * @npmx_modes: number of entries in pmx_modes.
108  */
109 struct spear_pinctrl_machdata {
110         const struct pinctrl_pin_desc *pins;
111         unsigned npins;
112         struct spear_function **functions;
113         unsigned nfunctions;
114         struct spear_pingroup **groups;
115         unsigned ngroups;
116
117         bool modes_supported;
118         u16 mode;
119         struct spear_pmx_mode **pmx_modes;
120         unsigned npmx_modes;
121 };
122
123 /**
124  * struct spear_pmx - SPEAr pinctrl mux
125  * @dev: pointer to struct dev of platform_device registered
126  * @pctl: pointer to struct pinctrl_dev
127  * @machdata: pointer to SoC or machine specific structure
128  * @vbase: virtual base address of pinmux controller
129  */
130 struct spear_pmx {
131         struct device *dev;
132         struct pinctrl_dev *pctl;
133         struct spear_pinctrl_machdata *machdata;
134         void __iomem *vbase;
135 };
136
137 /* exported routines */
138 void __devinit pmx_init_addr(struct spear_pinctrl_machdata *machdata, u16 reg);
139 int __devinit spear_pinctrl_probe(struct platform_device *pdev,
140                 struct spear_pinctrl_machdata *machdata);
141 int __devexit spear_pinctrl_remove(struct platform_device *pdev);
142 #endif /* __PINMUX_SPEAR_H__ */