summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-abx500.h
blob: df8e0ff0c5d50dc93c8bd68c4ffce5910e809f3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#ifndef PINCTRL_PINCTRL_ABx5O0_H
#define PINCTRL_PINCTRL_ABx500_H

/* Package definitions */
#define PINCTRL_AB8500	0
#define PINCTRL_AB8540	1
#define PINCTRL_AB9540	2
#define PINCTRL_AB8505	3

/* pins alternate function */
enum abx500_pin_func {
	ABX500_DEFAULT,
	ABX500_ALT_A,
	ABX500_ALT_B,
	ABX500_ALT_C,
};

/**
 * struct abx500_function - ABx500 pinctrl mux function
 * @name: The name of the function, exported to pinctrl core.
 * @groups: An array of pin groups that may select this function.
 * @ngroups: The number of entries in @groups.
 */
struct abx500_function {
	const char *name;
	const char * const *groups;
	unsigned ngroups;
};

/**
 * struct abx500_pingroup - describes a ABx500 pin group
 * @name: the name of this specific pin group
 * @pins: an array of discrete physical pins used in this group, taken
 *	from the driver-local pin enumeration space
 * @num_pins: the number of pins in this group array, i.e. the number of
 *	elements in .pins so we can iterate over that array
 * @altsetting: the altsetting to apply to all pins in this group to
 *	configure them to be used by a function
 */
struct abx500_pingroup {
	const char *name;
	const unsigned int *pins;
	const unsigned npins;
	int altsetting;
};

#define ALTERNATE_FUNCTIONS(pin, sel_bit, alt1, alt2, alta, altb, altc)	\
{									\
	.pin_number = pin,						\
	.gpiosel_bit = sel_bit,						\
	.alt_bit1 = alt1,						\
	.alt_bit2 = alt2,						\
	.alta_val = alta,						\
	.altb_val = altb,						\
	.altc_val = altc,						\
}

#define UNUSED -1
/**
 * struct alternate_functions
 * @pin_number:		The pin number
 * @gpiosel_bit:	Control bit in GPIOSEL register,
 * @alt_bit1:		First AlternateFunction bit used to select the
 *			alternate function
 * @alt_bit2:		Second AlternateFunction bit used to select the
 *			alternate function
 *
 *			these 3 following fields are necessary due to none
 *			coherency on how to select the altA, altB and altC
 *			function between the ABx500 SOC family when using
 *			alternatfunc register.
 * @alta_val:		value to write in alternatfunc to select altA function
 * @altb_val:		value to write in alternatfunc to select altB function
 * @altc_val:		value to write in alternatfunc to select altC function
 */
struct alternate_functions {
	unsigned pin_number;
	s8 gpiosel_bit;
	s8 alt_bit1;
	s8 alt_bit2;
	u8 alta_val;
	u8 altb_val;
	u8 altc_val;
};

/**
 * struct pullud - specific pull up/down feature
 * @first_pin:		The pin number of the first pins which support
 *			specific pull up/down
 * @last_pin:		The pin number of the last pins
 */
struct pullud {
	unsigned first_pin;
	unsigned last_pin;
};

#define GPIO_IRQ_CLUSTER(a, b, c)	\
{					\
	.start = a,			\
	.end = b,			\
	.offset = c,			\
}

/**
 * struct abx500_gpio_irq_cluster - indicates GPIOs which are interrupt
 *			capable
 * @start:		The pin number of the first pin interrupt capable
 * @end:		The pin number of the last pin interrupt capable
 * @offset:		offset used to compute specific setting strategy of
 *			the interrupt line
 */

struct abx500_gpio_irq_cluster {
	int start;
	int end;
	int offset;
};

/**
 * struct abx500_pinrange - map pin numbers to GPIO offsets
 * @offset:		offset into the GPIO local numberspace, incidentally
 *			identical to the offset into the local pin numberspace
 * @npins:		number of pins to map from both offsets
 * @altfunc:		altfunc setting to be used to enable GPIO on a pin in
 *			this range (may vary)
 */
struct abx500_pinrange {
	unsigned int offset;
	unsigned int npins;
	int altfunc;
};

#define ABX500_PINRANGE(a, b, c) { .offset = a, .npins = b, .altfunc = c }

/**
 * struct abx500_pinctrl_soc_data - ABx500 pin controller per-SoC configuration
 * @gpio_ranges:	An array of GPIO ranges for this SoC
 * @gpio_num_ranges:	The number of GPIO ranges for this SoC
 * @pins:		An array describing all pins the pin controller affects.
 *			All pins which are also GPIOs must be listed first within the
 *			array, and be numbered identically to the GPIO controller's
 *			numbering.
 * @npins:		The number of entries in @pins.
 * @functions:		The functions supported on this SoC.
 * @nfunction:		The number of entries in @functions.
 * @groups:		An array describing all pin groups the pin SoC supports.
 * @ngroups:		The number of entries in @groups.
 * @alternate_functions: array describing pins which supports alternate and
 *			how to set it.
 * @pullud:		array describing pins which supports pull up/down
 *			specific registers.
 * @gpio_irq_cluster:	An array of GPIO interrupt capable for this SoC
 * @ngpio_irq_cluster:	The number of GPIO inetrrupt capable for this SoC
 * @irq_gpio_rising_offset: Interrupt offset used as base to compute specific
 *			setting strategy of the rising interrupt line
 * @irq_gpio_falling_offset: Interrupt offset used as base to compute specific
 *			setting strategy of the falling interrupt line
 * @irq_gpio_factor:	Factor used to compute specific setting strategy of
 *			the interrupt line
 */

struct abx500_pinctrl_soc_data {
	const struct abx500_pinrange *gpio_ranges;
	unsigned gpio_num_ranges;
	const struct pinctrl_pin_desc *pins;
	unsigned npins;
	const struct abx500_function *functions;
	unsigned nfunctions;
	const struct abx500_pingroup *groups;
	unsigned ngroups;
	struct alternate_functions *alternate_functions;
	struct pullud *pullud;
	struct abx500_gpio_irq_cluster *gpio_irq_cluster;
	unsigned ngpio_irq_cluster;
	int irq_gpio_rising_offset;
	int irq_gpio_falling_offset;
	int irq_gpio_factor;
};

#ifdef CONFIG_PINCTRL_AB8500

void abx500_pinctrl_ab8500_init(struct abx500_pinctrl_soc_data **soc);

#else

static inline void
abx500_pinctrl_ab8500_init(struct abx500_pinctrl_soc_data **soc)
{
}

#endif

#ifdef CONFIG_PINCTRL_AB8540

void abx500_pinctrl_ab8540_init(struct abx500_pinctrl_soc_data **soc);

#else

static inline void
abx500_pinctrl_ab8540_init(struct abx500_pinctrl_soc_data **soc)
{
}

#endif

#ifdef CONFIG_PINCTRL_AB9540

void abx500_pinctrl_ab9540_init(struct abx500_pinctrl_soc_data **soc);

#else

static inline void
abx500_pinctrl_ab9540_init(struct abx500_pinctrl_soc_data **soc)
{
}

#endif

#ifdef CONFIG_PINCTRL_AB8505

void abx500_pinctrl_ab8505_init(struct abx500_pinctrl_soc_data **soc);

#else

static inline void
abx500_pinctrl_ab8505_init(struct abx500_pinctrl_soc_data **soc)
{
}

#endif

#endif /* PINCTRL_PINCTRL_ABx500_H */
OpenPOWER on IntegriCloud