1#ifndef PINCTRL_PINCTRL_NOMADIK_H
2#define PINCTRL_PINCTRL_NOMADIK_H
3
4
5#define PINCTRL_NMK_STN8815 0
6#define PINCTRL_NMK_DB8500 1
7#define PINCTRL_NMK_DB8540 2
8
9
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
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
52
53
54enum prcm_gpiocr_reg_index {
55 PRCM_IDX_GPIOCR1,
56 PRCM_IDX_GPIOCR2,
57 PRCM_IDX_GPIOCR3
58};
59
60
61
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
73
74
75
76
77struct prcm_gpiocr_altcx {
78 bool used:1;
79 u8 reg_index:2;
80 u8 control_bit:5;
81} __packed;
82
83
84
85
86
87
88struct prcm_gpiocr_altcx_pin_desc {
89 unsigned short pin;
90 struct prcm_gpiocr_altcx altcx[PRCM_IDX_GPIOCR_ALTC_MAX];
91};
92
93
94
95
96
97
98
99struct nmk_function {
100 const char *name;
101 const char * const *groups;
102 unsigned ngroups;
103};
104
105
106
107
108
109
110
111
112
113
114
115struct nmk_pingroup {
116 const char *name;
117 const unsigned int *pins;
118 const unsigned npins;
119 int altsetting;
120};
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139struct nmk_pinctrl_soc_data {
140 struct pinctrl_gpio_range *gpio_ranges;
141 unsigned gpio_num_ranges;
142 const struct pinctrl_pin_desc *pins;
143 unsigned npins;
144 const struct nmk_function *functions;
145 unsigned nfunctions;
146 const struct nmk_pingroup *groups;
147 unsigned ngroups;
148 const struct prcm_gpiocr_altcx_pin_desc *altcx_pins;
149 unsigned npins_altcx;
150 const u16 *prcm_gpiocr_registers;
151};
152
153#ifdef CONFIG_PINCTRL_STN8815
154
155void nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc);
156
157#else
158
159static inline void
160nmk_pinctrl_stn8815_init(const struct nmk_pinctrl_soc_data **soc)
161{
162}
163
164#endif
165
166#ifdef CONFIG_PINCTRL_DB8500
167
168void nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc);
169
170#else
171
172static inline void
173nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc)
174{
175}
176
177#endif
178
179#ifdef CONFIG_PINCTRL_DB8540
180
181void nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc);
182
183#else
184
185static inline void
186nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc)
187{
188}
189
190#endif
191
192#endif
193