Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux-2.6-block.git] / drivers / pinctrl / nomadik / pinctrl-nomadik.h
CommitLineData
e98ea774
LW
1#ifndef PINCTRL_PINCTRL_NOMADIK_H
2#define PINCTRL_PINCTRL_NOMADIK_H
3
e98ea774
LW
4/* Package definitions */
5#define PINCTRL_NMK_STN8815 0
6#define PINCTRL_NMK_DB8500 1
45a1b531 7#define PINCTRL_NMK_DB8540 2
e98ea774 8
8d993397
LW
9/* Alternate functions: function C is set in hw by setting both A and B */
10#define NMK_GPIO_ALT_GPIO 0
11#define NMK_GPIO_ALT_A 1
12#define NMK_GPIO_ALT_B 2
13#define NMK_GPIO_ALT_C (NMK_GPIO_ALT_A | NMK_GPIO_ALT_B)
14
15#define NMK_GPIO_ALT_CX_SHIFT 2
16#define NMK_GPIO_ALT_C1 ((1<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
17#define NMK_GPIO_ALT_C2 ((2<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
18#define NMK_GPIO_ALT_C3 ((3<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
19#define NMK_GPIO_ALT_C4 ((4<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
20
c22df08c
JNG
21#define PRCM_GPIOCR_ALTCX(pin_num,\
22 altc1_used, altc1_ri, altc1_cb,\
23 altc2_used, altc2_ri, altc2_cb,\
24 altc3_used, altc3_ri, altc3_cb,\
25 altc4_used, altc4_ri, altc4_cb)\
26{\
27 .pin = pin_num,\
28 .altcx[PRCM_IDX_GPIOCR_ALTC1] = {\
29 .used = altc1_used,\
30 .reg_index = altc1_ri,\
31 .control_bit = altc1_cb\
32 },\
33 .altcx[PRCM_IDX_GPIOCR_ALTC2] = {\
34 .used = altc2_used,\
35 .reg_index = altc2_ri,\
36 .control_bit = altc2_cb\
37 },\
38 .altcx[PRCM_IDX_GPIOCR_ALTC3] = {\
39 .used = altc3_used,\
40 .reg_index = altc3_ri,\
41 .control_bit = altc3_cb\
42 },\
43 .altcx[PRCM_IDX_GPIOCR_ALTC4] = {\
44 .used = altc4_used,\
45 .reg_index = altc4_ri,\
46 .control_bit = altc4_cb\
47 },\
48}
49
50/**
51 * enum prcm_gpiocr_reg_index
52 * Used to reference an PRCM GPIOCR register address.
53 */
54enum prcm_gpiocr_reg_index {
55 PRCM_IDX_GPIOCR1,
56 PRCM_IDX_GPIOCR2,
57 PRCM_IDX_GPIOCR3
58};
59/**
60 * enum prcm_gpiocr_altcx_index
61 * Used to reference an Other alternate-C function.
62 */
63enum prcm_gpiocr_altcx_index {
64 PRCM_IDX_GPIOCR_ALTC1,
65 PRCM_IDX_GPIOCR_ALTC2,
66 PRCM_IDX_GPIOCR_ALTC3,
67 PRCM_IDX_GPIOCR_ALTC4,
68 PRCM_IDX_GPIOCR_ALTC_MAX,
69};
70
71/**
72 * struct prcm_gpio_altcx - Other alternate-C function
73 * @used: other alternate-C function availability
74 * @reg_index: PRCM GPIOCR register index used to control the function
75 * @control_bit: PRCM GPIOCR bit used to control the function
76 */
77struct prcm_gpiocr_altcx {
78 bool used:1;
79 u8 reg_index:2;
80 u8 control_bit:5;
81} __packed;
82
83/**
84 * struct prcm_gpio_altcx_pin_desc - Other alternate-C pin
85 * @pin: The pin number
86 * @altcx: array of other alternate-C[1-4] functions
87 */
88struct prcm_gpiocr_altcx_pin_desc {
89 unsigned short pin;
90 struct prcm_gpiocr_altcx altcx[PRCM_IDX_GPIOCR_ALTC_MAX];
91};
92
dbfe8ca2
LW
93/**
94 * struct nmk_function - Nomadik pinctrl mux function
95 * @name: The name of the function, exported to pinctrl core.
96 * @groups: An array of pin groups that may select this function.
97 * @ngroups: The number of entries in @groups.
98 */
99struct nmk_function {
100 const char *name;
101 const char * const *groups;
102 unsigned ngroups;
103};
104
e98ea774
LW
105/**
106 * struct nmk_pingroup - describes a Nomadik pin group
107 * @name: the name of this specific pin group
108 * @pins: an array of discrete physical pins used in this group, taken
109 * from the driver-local pin enumeration space
110 * @num_pins: the number of pins in this group array, i.e. the number of
111 * elements in .pins so we can iterate over that array
112 * @altsetting: the altsetting to apply to all pins in this group to
113 * configure them to be used by a function
114 */
115struct nmk_pingroup {
116 const char *name;
117 const unsigned int *pins;
118 const unsigned npins;
dbfe8ca2 119 int altsetting;
e98ea774
LW
120};
121
122/**
123 * struct nmk_pinctrl_soc_data - Nomadik pin controller per-SoC configuration
e98ea774
LW
124 * @pins: An array describing all pins the pin controller affects.
125 * All pins which are also GPIOs must be listed first within the
126 * array, and be numbered identically to the GPIO controller's
127 * numbering.
dbfe8ca2
LW
128 * @npins: The number of entries in @pins.
129 * @functions: The functions supported on this SoC.
130 * @nfunction: The number of entries in @functions.
e98ea774
LW
131 * @groups: An array describing all pin groups the pin SoC supports.
132 * @ngroups: The number of entries in @groups.
c22df08c
JNG
133 * @altcx_pins: The pins that support Other alternate-C function on this SoC
134 * @npins_altcx: The number of Other alternate-C pins
135 * @prcm_gpiocr_registers: The array of PRCM GPIOCR registers on this SoC
e98ea774
LW
136 */
137struct nmk_pinctrl_soc_data {
e98ea774
LW
138 const struct pinctrl_pin_desc *pins;
139 unsigned npins;
dbfe8ca2
LW
140 const struct nmk_function *functions;
141 unsigned nfunctions;
e98ea774
LW
142 const struct nmk_pingroup *groups;
143 unsigned ngroups;
c22df08c
JNG
144 const struct prcm_gpiocr_altcx_pin_desc *altcx_pins;
145 unsigned npins_altcx;
146 const u16 *prcm_gpiocr_registers;
e98ea774
LW
147};
148
f79c5ed9
LW
149#ifdef CONFIG_PINCTRL_STN8815
150
151void nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc);
152
153#else
154
155static inline void
156nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc)
157{
158}
159
160#endif
161
e98ea774
LW
162#ifdef CONFIG_PINCTRL_DB8500
163
164void nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc);
165
166#else
167
168static inline void
169nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc)
170{
171}
172
173#endif
174
45a1b531
PC
175#ifdef CONFIG_PINCTRL_DB8540
176
177void nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc);
178
179#else
180
181static inline void
182nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc)
183{
184}
185
186#endif
187
e98ea774 188#endif /* PINCTRL_PINCTRL_NOMADIK_H */