blob: bcd4191e10ea8ced278c469799d521e4a82dee65 [file] [log] [blame]
Linus Walleije98ea772012-04-26 23:57:25 +02001#ifndef PINCTRL_PINCTRL_NOMADIK_H
2#define PINCTRL_PINCTRL_NOMADIK_H
3
Linus Walleijbb16bd92012-10-10 14:27:58 +02004#include <linux/platform_data/pinctrl-nomadik.h>
Linus Walleije98ea772012-04-26 23:57:25 +02005
6/* Package definitions */
7#define PINCTRL_NMK_STN8815 0
8#define PINCTRL_NMK_DB8500 1
Patrice Chotard45a1b532012-07-20 15:45:22 +02009#define PINCTRL_NMK_DB8540 2
Linus Walleije98ea772012-04-26 23:57:25 +020010
Jean-Nicolas Grauxc22df082012-09-27 15:38:50 +020011#define PRCM_GPIOCR_ALTCX(pin_num,\
12 altc1_used, altc1_ri, altc1_cb,\
13 altc2_used, altc2_ri, altc2_cb,\
14 altc3_used, altc3_ri, altc3_cb,\
15 altc4_used, altc4_ri, altc4_cb)\
16{\
17 .pin = pin_num,\
18 .altcx[PRCM_IDX_GPIOCR_ALTC1] = {\
19 .used = altc1_used,\
20 .reg_index = altc1_ri,\
21 .control_bit = altc1_cb\
22 },\
23 .altcx[PRCM_IDX_GPIOCR_ALTC2] = {\
24 .used = altc2_used,\
25 .reg_index = altc2_ri,\
26 .control_bit = altc2_cb\
27 },\
28 .altcx[PRCM_IDX_GPIOCR_ALTC3] = {\
29 .used = altc3_used,\
30 .reg_index = altc3_ri,\
31 .control_bit = altc3_cb\
32 },\
33 .altcx[PRCM_IDX_GPIOCR_ALTC4] = {\
34 .used = altc4_used,\
35 .reg_index = altc4_ri,\
36 .control_bit = altc4_cb\
37 },\
38}
39
40/**
41 * enum prcm_gpiocr_reg_index
42 * Used to reference an PRCM GPIOCR register address.
43 */
44enum prcm_gpiocr_reg_index {
45 PRCM_IDX_GPIOCR1,
46 PRCM_IDX_GPIOCR2,
47 PRCM_IDX_GPIOCR3
48};
49/**
50 * enum prcm_gpiocr_altcx_index
51 * Used to reference an Other alternate-C function.
52 */
53enum prcm_gpiocr_altcx_index {
54 PRCM_IDX_GPIOCR_ALTC1,
55 PRCM_IDX_GPIOCR_ALTC2,
56 PRCM_IDX_GPIOCR_ALTC3,
57 PRCM_IDX_GPIOCR_ALTC4,
58 PRCM_IDX_GPIOCR_ALTC_MAX,
59};
60
61/**
62 * struct prcm_gpio_altcx - Other alternate-C function
63 * @used: other alternate-C function availability
64 * @reg_index: PRCM GPIOCR register index used to control the function
65 * @control_bit: PRCM GPIOCR bit used to control the function
66 */
67struct prcm_gpiocr_altcx {
68 bool used:1;
69 u8 reg_index:2;
70 u8 control_bit:5;
71} __packed;
72
73/**
74 * struct prcm_gpio_altcx_pin_desc - Other alternate-C pin
75 * @pin: The pin number
76 * @altcx: array of other alternate-C[1-4] functions
77 */
78struct prcm_gpiocr_altcx_pin_desc {
79 unsigned short pin;
80 struct prcm_gpiocr_altcx altcx[PRCM_IDX_GPIOCR_ALTC_MAX];
81};
82
Linus Walleije98ea772012-04-26 23:57:25 +020083/**
Linus Walleijdbfe8ca2012-05-02 22:56:47 +020084 * struct nmk_function - Nomadik pinctrl mux function
85 * @name: The name of the function, exported to pinctrl core.
86 * @groups: An array of pin groups that may select this function.
87 * @ngroups: The number of entries in @groups.
88 */
89struct nmk_function {
90 const char *name;
91 const char * const *groups;
92 unsigned ngroups;
93};
94
95/**
Linus Walleije98ea772012-04-26 23:57:25 +020096 * struct nmk_pingroup - describes a Nomadik pin group
97 * @name: the name of this specific pin group
98 * @pins: an array of discrete physical pins used in this group, taken
99 * from the driver-local pin enumeration space
100 * @num_pins: the number of pins in this group array, i.e. the number of
101 * elements in .pins so we can iterate over that array
102 * @altsetting: the altsetting to apply to all pins in this group to
103 * configure them to be used by a function
104 */
105struct nmk_pingroup {
106 const char *name;
107 const unsigned int *pins;
108 const unsigned npins;
Linus Walleijdbfe8ca2012-05-02 22:56:47 +0200109 int altsetting;
Linus Walleije98ea772012-04-26 23:57:25 +0200110};
111
112/**
113 * struct nmk_pinctrl_soc_data - Nomadik pin controller per-SoC configuration
114 * @gpio_ranges: An array of GPIO ranges for this SoC
115 * @gpio_num_ranges: The number of GPIO ranges for this SoC
116 * @pins: An array describing all pins the pin controller affects.
117 * All pins which are also GPIOs must be listed first within the
118 * array, and be numbered identically to the GPIO controller's
119 * numbering.
Linus Walleijdbfe8ca2012-05-02 22:56:47 +0200120 * @npins: The number of entries in @pins.
121 * @functions: The functions supported on this SoC.
122 * @nfunction: The number of entries in @functions.
Linus Walleije98ea772012-04-26 23:57:25 +0200123 * @groups: An array describing all pin groups the pin SoC supports.
124 * @ngroups: The number of entries in @groups.
Jean-Nicolas Grauxc22df082012-09-27 15:38:50 +0200125 * @altcx_pins: The pins that support Other alternate-C function on this SoC
126 * @npins_altcx: The number of Other alternate-C pins
127 * @prcm_gpiocr_registers: The array of PRCM GPIOCR registers on this SoC
Linus Walleije98ea772012-04-26 23:57:25 +0200128 */
129struct nmk_pinctrl_soc_data {
130 struct pinctrl_gpio_range *gpio_ranges;
131 unsigned gpio_num_ranges;
132 const struct pinctrl_pin_desc *pins;
133 unsigned npins;
Linus Walleijdbfe8ca2012-05-02 22:56:47 +0200134 const struct nmk_function *functions;
135 unsigned nfunctions;
Linus Walleije98ea772012-04-26 23:57:25 +0200136 const struct nmk_pingroup *groups;
137 unsigned ngroups;
Jean-Nicolas Grauxc22df082012-09-27 15:38:50 +0200138 const struct prcm_gpiocr_altcx_pin_desc *altcx_pins;
139 unsigned npins_altcx;
140 const u16 *prcm_gpiocr_registers;
Linus Walleije98ea772012-04-26 23:57:25 +0200141};
142
Linus Walleijf79c5ed2012-08-10 00:43:28 +0200143#ifdef CONFIG_PINCTRL_STN8815
144
145void nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc);
146
147#else
148
149static inline void
150nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc)
151{
152}
153
154#endif
155
Linus Walleije98ea772012-04-26 23:57:25 +0200156#ifdef CONFIG_PINCTRL_DB8500
157
158void nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc);
159
160#else
161
162static inline void
163nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc)
164{
165}
166
167#endif
168
Patrice Chotard45a1b532012-07-20 15:45:22 +0200169#ifdef CONFIG_PINCTRL_DB8540
170
171void nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc);
172
173#else
174
175static inline void
176nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc)
177{
178}
179
180#endif
181
Linus Walleije98ea772012-04-26 23:57:25 +0200182#endif /* PINCTRL_PINCTRL_NOMADIK_H */