.. | .. |
---|
6 | 6 | * Author: Mathias Nyman <mathias.nyman@linux.intel.com> |
---|
7 | 7 | */ |
---|
8 | 8 | |
---|
9 | | -#include <linux/kernel.h> |
---|
10 | | -#include <linux/init.h> |
---|
11 | | -#include <linux/types.h> |
---|
12 | | -#include <linux/bitops.h> |
---|
13 | | -#include <linux/interrupt.h> |
---|
14 | | -#include <linux/gpio.h> |
---|
15 | | -#include <linux/gpio/driver.h> |
---|
16 | 9 | #include <linux/acpi.h> |
---|
17 | | -#include <linux/platform_device.h> |
---|
18 | | -#include <linux/seq_file.h> |
---|
| 10 | +#include <linux/bitops.h> |
---|
| 11 | +#include <linux/gpio/driver.h> |
---|
| 12 | +#include <linux/init.h> |
---|
| 13 | +#include <linux/interrupt.h> |
---|
19 | 14 | #include <linux/io.h> |
---|
| 15 | +#include <linux/kernel.h> |
---|
| 16 | +#include <linux/types.h> |
---|
| 17 | +#include <linux/platform_device.h> |
---|
20 | 18 | #include <linux/pm_runtime.h> |
---|
| 19 | +#include <linux/property.h> |
---|
| 20 | +#include <linux/seq_file.h> |
---|
| 21 | + |
---|
21 | 22 | #include <linux/pinctrl/pinctrl.h> |
---|
22 | 23 | #include <linux/pinctrl/pinmux.h> |
---|
23 | 24 | #include <linux/pinctrl/pinconf.h> |
---|
24 | 25 | #include <linux/pinctrl/pinconf-generic.h> |
---|
| 26 | + |
---|
| 27 | +#include "pinctrl-intel.h" |
---|
25 | 28 | |
---|
26 | 29 | /* memory mapped register offsets */ |
---|
27 | 30 | #define BYT_CONF0_REG 0x000 |
---|
.. | .. |
---|
34 | 37 | /* BYT_CONF0_REG register bits */ |
---|
35 | 38 | #define BYT_IODEN BIT(31) |
---|
36 | 39 | #define BYT_DIRECT_IRQ_EN BIT(27) |
---|
| 40 | +#define BYT_TRIG_MASK GENMASK(26, 24) |
---|
37 | 41 | #define BYT_TRIG_NEG BIT(26) |
---|
38 | 42 | #define BYT_TRIG_POS BIT(25) |
---|
39 | 43 | #define BYT_TRIG_LVL BIT(24) |
---|
.. | .. |
---|
42 | 46 | #define BYT_GLITCH_F_SLOW_CLK BIT(17) |
---|
43 | 47 | #define BYT_GLITCH_F_FAST_CLK BIT(16) |
---|
44 | 48 | #define BYT_PULL_STR_SHIFT 9 |
---|
45 | | -#define BYT_PULL_STR_MASK (3 << BYT_PULL_STR_SHIFT) |
---|
| 49 | +#define BYT_PULL_STR_MASK GENMASK(10, 9) |
---|
46 | 50 | #define BYT_PULL_STR_2K (0 << BYT_PULL_STR_SHIFT) |
---|
47 | 51 | #define BYT_PULL_STR_10K (1 << BYT_PULL_STR_SHIFT) |
---|
48 | 52 | #define BYT_PULL_STR_20K (2 << BYT_PULL_STR_SHIFT) |
---|
49 | 53 | #define BYT_PULL_STR_40K (3 << BYT_PULL_STR_SHIFT) |
---|
50 | 54 | #define BYT_PULL_ASSIGN_SHIFT 7 |
---|
51 | | -#define BYT_PULL_ASSIGN_MASK (3 << BYT_PULL_ASSIGN_SHIFT) |
---|
| 55 | +#define BYT_PULL_ASSIGN_MASK GENMASK(8, 7) |
---|
52 | 56 | #define BYT_PULL_ASSIGN_UP (1 << BYT_PULL_ASSIGN_SHIFT) |
---|
53 | 57 | #define BYT_PULL_ASSIGN_DOWN (2 << BYT_PULL_ASSIGN_SHIFT) |
---|
54 | | -#define BYT_PIN_MUX 0x07 |
---|
| 58 | +#define BYT_PIN_MUX GENMASK(2, 0) |
---|
55 | 59 | |
---|
56 | 60 | /* BYT_VAL_REG register bits */ |
---|
| 61 | +#define BYT_DIR_MASK GENMASK(2, 1) |
---|
57 | 62 | #define BYT_INPUT_EN BIT(2) /* 0: input enabled (active low)*/ |
---|
58 | 63 | #define BYT_OUTPUT_EN BIT(1) /* 0: output enabled (active low)*/ |
---|
59 | 64 | #define BYT_LEVEL BIT(0) |
---|
60 | 65 | |
---|
61 | | -#define BYT_DIR_MASK (BIT(1) | BIT(2)) |
---|
62 | | -#define BYT_TRIG_MASK (BIT(26) | BIT(25) | BIT(24)) |
---|
63 | | - |
---|
64 | | -#define BYT_CONF0_RESTORE_MASK (BYT_DIRECT_IRQ_EN | BYT_TRIG_MASK | \ |
---|
65 | | - BYT_PIN_MUX) |
---|
| 66 | +#define BYT_CONF0_RESTORE_MASK (BYT_DIRECT_IRQ_EN | BYT_TRIG_MASK | BYT_PIN_MUX) |
---|
66 | 67 | #define BYT_VAL_RESTORE_MASK (BYT_DIR_MASK | BYT_LEVEL) |
---|
67 | 68 | |
---|
68 | 69 | /* BYT_DEBOUNCE_REG bits */ |
---|
69 | | -#define BYT_DEBOUNCE_PULSE_MASK 0x7 |
---|
| 70 | +#define BYT_DEBOUNCE_PULSE_MASK GENMASK(2, 0) |
---|
70 | 71 | #define BYT_DEBOUNCE_PULSE_375US 1 |
---|
71 | 72 | #define BYT_DEBOUNCE_PULSE_750US 2 |
---|
72 | 73 | #define BYT_DEBOUNCE_PULSE_1500US 3 |
---|
.. | .. |
---|
90 | 91 | * does not find a match for the requested function. |
---|
91 | 92 | */ |
---|
92 | 93 | #define BYT_DEFAULT_GPIO_MUX 0 |
---|
| 94 | +#define BYT_ALTER_GPIO_MUX 1 |
---|
93 | 95 | |
---|
94 | | -struct byt_gpio_pin_context { |
---|
| 96 | +struct intel_pad_context { |
---|
95 | 97 | u32 conf0; |
---|
96 | 98 | u32 val; |
---|
97 | 99 | }; |
---|
98 | | - |
---|
99 | | -struct byt_simple_func_mux { |
---|
100 | | - const char *name; |
---|
101 | | - unsigned short func; |
---|
102 | | -}; |
---|
103 | | - |
---|
104 | | -struct byt_mixed_func_mux { |
---|
105 | | - const char *name; |
---|
106 | | - const unsigned short *func_values; |
---|
107 | | -}; |
---|
108 | | - |
---|
109 | | -struct byt_pingroup { |
---|
110 | | - const char *name; |
---|
111 | | - const unsigned int *pins; |
---|
112 | | - size_t npins; |
---|
113 | | - unsigned short has_simple_funcs; |
---|
114 | | - union { |
---|
115 | | - const struct byt_simple_func_mux *simple_funcs; |
---|
116 | | - const struct byt_mixed_func_mux *mixed_funcs; |
---|
117 | | - }; |
---|
118 | | - size_t nfuncs; |
---|
119 | | -}; |
---|
120 | | - |
---|
121 | | -struct byt_function { |
---|
122 | | - const char *name; |
---|
123 | | - const char * const *groups; |
---|
124 | | - size_t ngroups; |
---|
125 | | -}; |
---|
126 | | - |
---|
127 | | -struct byt_community { |
---|
128 | | - unsigned int pin_base; |
---|
129 | | - size_t npins; |
---|
130 | | - const unsigned int *pad_map; |
---|
131 | | - void __iomem *reg_base; |
---|
132 | | -}; |
---|
133 | | - |
---|
134 | | -#define SIMPLE_FUNC(n, f) \ |
---|
135 | | - { \ |
---|
136 | | - .name = (n), \ |
---|
137 | | - .func = (f), \ |
---|
138 | | - } |
---|
139 | | -#define MIXED_FUNC(n, f) \ |
---|
140 | | - { \ |
---|
141 | | - .name = (n), \ |
---|
142 | | - .func_values = (f), \ |
---|
143 | | - } |
---|
144 | | - |
---|
145 | | -#define PIN_GROUP_SIMPLE(n, p, f) \ |
---|
146 | | - { \ |
---|
147 | | - .name = (n), \ |
---|
148 | | - .pins = (p), \ |
---|
149 | | - .npins = ARRAY_SIZE((p)), \ |
---|
150 | | - .has_simple_funcs = 1, \ |
---|
151 | | - { \ |
---|
152 | | - .simple_funcs = (f), \ |
---|
153 | | - }, \ |
---|
154 | | - .nfuncs = ARRAY_SIZE((f)), \ |
---|
155 | | - } |
---|
156 | | -#define PIN_GROUP_MIXED(n, p, f) \ |
---|
157 | | - { \ |
---|
158 | | - .name = (n), \ |
---|
159 | | - .pins = (p), \ |
---|
160 | | - .npins = ARRAY_SIZE((p)), \ |
---|
161 | | - .has_simple_funcs = 0, \ |
---|
162 | | - { \ |
---|
163 | | - .mixed_funcs = (f), \ |
---|
164 | | - }, \ |
---|
165 | | - .nfuncs = ARRAY_SIZE((f)), \ |
---|
166 | | - } |
---|
167 | | - |
---|
168 | | -#define FUNCTION(n, g) \ |
---|
169 | | - { \ |
---|
170 | | - .name = (n), \ |
---|
171 | | - .groups = (g), \ |
---|
172 | | - .ngroups = ARRAY_SIZE((g)), \ |
---|
173 | | - } |
---|
174 | 100 | |
---|
175 | 101 | #define COMMUNITY(p, n, map) \ |
---|
176 | 102 | { \ |
---|
.. | .. |
---|
178 | 104 | .npins = (n), \ |
---|
179 | 105 | .pad_map = (map),\ |
---|
180 | 106 | } |
---|
181 | | - |
---|
182 | | -struct byt_pinctrl_soc_data { |
---|
183 | | - const char *uid; |
---|
184 | | - const struct pinctrl_pin_desc *pins; |
---|
185 | | - size_t npins; |
---|
186 | | - const struct byt_pingroup *groups; |
---|
187 | | - size_t ngroups; |
---|
188 | | - const struct byt_function *functions; |
---|
189 | | - size_t nfunctions; |
---|
190 | | - const struct byt_community *communities; |
---|
191 | | - size_t ncommunities; |
---|
192 | | -}; |
---|
193 | | - |
---|
194 | | -struct byt_gpio { |
---|
195 | | - struct gpio_chip chip; |
---|
196 | | - struct platform_device *pdev; |
---|
197 | | - struct pinctrl_dev *pctl_dev; |
---|
198 | | - struct pinctrl_desc pctl_desc; |
---|
199 | | - const struct byt_pinctrl_soc_data *soc_data; |
---|
200 | | - struct byt_community *communities_copy; |
---|
201 | | - struct byt_gpio_pin_context *saved_context; |
---|
202 | | -}; |
---|
203 | 107 | |
---|
204 | 108 | /* SCORE pins, aka GPIOC_<pin_no> or GPIO_S0_SC[<pin_no>] */ |
---|
205 | 109 | static const struct pinctrl_pin_desc byt_score_pins[] = { |
---|
.. | .. |
---|
324 | 228 | /* SCORE groups */ |
---|
325 | 229 | static const unsigned int byt_score_uart1_pins[] = { 70, 71, 72, 73 }; |
---|
326 | 230 | static const unsigned int byt_score_uart2_pins[] = { 74, 75, 76, 77 }; |
---|
327 | | -static const struct byt_simple_func_mux byt_score_uart_mux[] = { |
---|
328 | | - SIMPLE_FUNC("uart", 1), |
---|
329 | | -}; |
---|
330 | 231 | |
---|
331 | 232 | static const unsigned int byt_score_pwm0_pins[] = { 94 }; |
---|
332 | 233 | static const unsigned int byt_score_pwm1_pins[] = { 95 }; |
---|
333 | | -static const struct byt_simple_func_mux byt_score_pwm_mux[] = { |
---|
334 | | - SIMPLE_FUNC("pwm", 1), |
---|
335 | | -}; |
---|
336 | 234 | |
---|
337 | 235 | static const unsigned int byt_score_sio_spi_pins[] = { 66, 67, 68, 69 }; |
---|
338 | | -static const struct byt_simple_func_mux byt_score_spi_mux[] = { |
---|
339 | | - SIMPLE_FUNC("spi", 1), |
---|
340 | | -}; |
---|
341 | 236 | |
---|
342 | 237 | static const unsigned int byt_score_i2c5_pins[] = { 88, 89 }; |
---|
343 | 238 | static const unsigned int byt_score_i2c6_pins[] = { 90, 91 }; |
---|
.. | .. |
---|
346 | 241 | static const unsigned int byt_score_i2c2_pins[] = { 82, 83 }; |
---|
347 | 242 | static const unsigned int byt_score_i2c1_pins[] = { 80, 81 }; |
---|
348 | 243 | static const unsigned int byt_score_i2c0_pins[] = { 78, 79 }; |
---|
349 | | -static const struct byt_simple_func_mux byt_score_i2c_mux[] = { |
---|
350 | | - SIMPLE_FUNC("i2c", 1), |
---|
351 | | -}; |
---|
352 | 244 | |
---|
353 | 245 | static const unsigned int byt_score_ssp0_pins[] = { 8, 9, 10, 11 }; |
---|
354 | 246 | static const unsigned int byt_score_ssp1_pins[] = { 12, 13, 14, 15 }; |
---|
355 | 247 | static const unsigned int byt_score_ssp2_pins[] = { 62, 63, 64, 65 }; |
---|
356 | | -static const struct byt_simple_func_mux byt_score_ssp_mux[] = { |
---|
357 | | - SIMPLE_FUNC("ssp", 1), |
---|
358 | | -}; |
---|
359 | 248 | |
---|
360 | 249 | static const unsigned int byt_score_sdcard_pins[] = { |
---|
361 | 250 | 7, 33, 34, 35, 36, 37, 38, 39, 40, 41, |
---|
362 | 251 | }; |
---|
363 | | -static const unsigned short byt_score_sdcard_mux_values[] = { |
---|
| 252 | +static const unsigned int byt_score_sdcard_mux_values[] = { |
---|
364 | 253 | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
---|
365 | | -}; |
---|
366 | | -static const struct byt_mixed_func_mux byt_score_sdcard_mux[] = { |
---|
367 | | - MIXED_FUNC("sdcard", byt_score_sdcard_mux_values), |
---|
368 | 254 | }; |
---|
369 | 255 | |
---|
370 | 256 | static const unsigned int byt_score_sdio_pins[] = { 27, 28, 29, 30, 31, 32 }; |
---|
371 | | -static const struct byt_simple_func_mux byt_score_sdio_mux[] = { |
---|
372 | | - SIMPLE_FUNC("sdio", 1), |
---|
373 | | -}; |
---|
374 | 257 | |
---|
375 | 258 | static const unsigned int byt_score_emmc_pins[] = { |
---|
376 | 259 | 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, |
---|
377 | | -}; |
---|
378 | | -static const struct byt_simple_func_mux byt_score_emmc_mux[] = { |
---|
379 | | - SIMPLE_FUNC("emmc", 1), |
---|
380 | 260 | }; |
---|
381 | 261 | |
---|
382 | 262 | static const unsigned int byt_score_ilb_lpc_pins[] = { |
---|
383 | 263 | 42, 43, 44, 45, 46, 47, 48, 49, 50, |
---|
384 | 264 | }; |
---|
385 | | -static const struct byt_simple_func_mux byt_score_lpc_mux[] = { |
---|
386 | | - SIMPLE_FUNC("lpc", 1), |
---|
387 | | -}; |
---|
388 | 265 | |
---|
389 | 266 | static const unsigned int byt_score_sata_pins[] = { 0, 1, 2 }; |
---|
390 | | -static const struct byt_simple_func_mux byt_score_sata_mux[] = { |
---|
391 | | - SIMPLE_FUNC("sata", 1), |
---|
392 | | -}; |
---|
393 | 267 | |
---|
394 | 268 | static const unsigned int byt_score_plt_clk0_pins[] = { 96 }; |
---|
395 | 269 | static const unsigned int byt_score_plt_clk1_pins[] = { 97 }; |
---|
.. | .. |
---|
397 | 271 | static const unsigned int byt_score_plt_clk3_pins[] = { 99 }; |
---|
398 | 272 | static const unsigned int byt_score_plt_clk4_pins[] = { 100 }; |
---|
399 | 273 | static const unsigned int byt_score_plt_clk5_pins[] = { 101 }; |
---|
400 | | -static const struct byt_simple_func_mux byt_score_plt_clk_mux[] = { |
---|
401 | | - SIMPLE_FUNC("plt_clk", 1), |
---|
402 | | -}; |
---|
403 | 274 | |
---|
404 | 275 | static const unsigned int byt_score_smbus_pins[] = { 51, 52, 53 }; |
---|
405 | | -static const struct byt_simple_func_mux byt_score_smbus_mux[] = { |
---|
406 | | - SIMPLE_FUNC("smbus", 1), |
---|
407 | | -}; |
---|
408 | 276 | |
---|
409 | | -static const struct byt_pingroup byt_score_groups[] = { |
---|
410 | | - PIN_GROUP_SIMPLE("uart1_grp", |
---|
411 | | - byt_score_uart1_pins, byt_score_uart_mux), |
---|
412 | | - PIN_GROUP_SIMPLE("uart2_grp", |
---|
413 | | - byt_score_uart2_pins, byt_score_uart_mux), |
---|
414 | | - PIN_GROUP_SIMPLE("pwm0_grp", |
---|
415 | | - byt_score_pwm0_pins, byt_score_pwm_mux), |
---|
416 | | - PIN_GROUP_SIMPLE("pwm1_grp", |
---|
417 | | - byt_score_pwm1_pins, byt_score_pwm_mux), |
---|
418 | | - PIN_GROUP_SIMPLE("ssp2_grp", |
---|
419 | | - byt_score_ssp2_pins, byt_score_pwm_mux), |
---|
420 | | - PIN_GROUP_SIMPLE("sio_spi_grp", |
---|
421 | | - byt_score_sio_spi_pins, byt_score_spi_mux), |
---|
422 | | - PIN_GROUP_SIMPLE("i2c5_grp", |
---|
423 | | - byt_score_i2c5_pins, byt_score_i2c_mux), |
---|
424 | | - PIN_GROUP_SIMPLE("i2c6_grp", |
---|
425 | | - byt_score_i2c6_pins, byt_score_i2c_mux), |
---|
426 | | - PIN_GROUP_SIMPLE("i2c4_grp", |
---|
427 | | - byt_score_i2c4_pins, byt_score_i2c_mux), |
---|
428 | | - PIN_GROUP_SIMPLE("i2c3_grp", |
---|
429 | | - byt_score_i2c3_pins, byt_score_i2c_mux), |
---|
430 | | - PIN_GROUP_SIMPLE("i2c2_grp", |
---|
431 | | - byt_score_i2c2_pins, byt_score_i2c_mux), |
---|
432 | | - PIN_GROUP_SIMPLE("i2c1_grp", |
---|
433 | | - byt_score_i2c1_pins, byt_score_i2c_mux), |
---|
434 | | - PIN_GROUP_SIMPLE("i2c0_grp", |
---|
435 | | - byt_score_i2c0_pins, byt_score_i2c_mux), |
---|
436 | | - PIN_GROUP_SIMPLE("ssp0_grp", |
---|
437 | | - byt_score_ssp0_pins, byt_score_ssp_mux), |
---|
438 | | - PIN_GROUP_SIMPLE("ssp1_grp", |
---|
439 | | - byt_score_ssp1_pins, byt_score_ssp_mux), |
---|
440 | | - PIN_GROUP_MIXED("sdcard_grp", |
---|
441 | | - byt_score_sdcard_pins, byt_score_sdcard_mux), |
---|
442 | | - PIN_GROUP_SIMPLE("sdio_grp", |
---|
443 | | - byt_score_sdio_pins, byt_score_sdio_mux), |
---|
444 | | - PIN_GROUP_SIMPLE("emmc_grp", |
---|
445 | | - byt_score_emmc_pins, byt_score_emmc_mux), |
---|
446 | | - PIN_GROUP_SIMPLE("lpc_grp", |
---|
447 | | - byt_score_ilb_lpc_pins, byt_score_lpc_mux), |
---|
448 | | - PIN_GROUP_SIMPLE("sata_grp", |
---|
449 | | - byt_score_sata_pins, byt_score_sata_mux), |
---|
450 | | - PIN_GROUP_SIMPLE("plt_clk0_grp", |
---|
451 | | - byt_score_plt_clk0_pins, byt_score_plt_clk_mux), |
---|
452 | | - PIN_GROUP_SIMPLE("plt_clk1_grp", |
---|
453 | | - byt_score_plt_clk1_pins, byt_score_plt_clk_mux), |
---|
454 | | - PIN_GROUP_SIMPLE("plt_clk2_grp", |
---|
455 | | - byt_score_plt_clk2_pins, byt_score_plt_clk_mux), |
---|
456 | | - PIN_GROUP_SIMPLE("plt_clk3_grp", |
---|
457 | | - byt_score_plt_clk3_pins, byt_score_plt_clk_mux), |
---|
458 | | - PIN_GROUP_SIMPLE("plt_clk4_grp", |
---|
459 | | - byt_score_plt_clk4_pins, byt_score_plt_clk_mux), |
---|
460 | | - PIN_GROUP_SIMPLE("plt_clk5_grp", |
---|
461 | | - byt_score_plt_clk5_pins, byt_score_plt_clk_mux), |
---|
462 | | - PIN_GROUP_SIMPLE("smbus_grp", |
---|
463 | | - byt_score_smbus_pins, byt_score_smbus_mux), |
---|
| 277 | +static const struct intel_pingroup byt_score_groups[] = { |
---|
| 278 | + PIN_GROUP("uart1_grp", byt_score_uart1_pins, 1), |
---|
| 279 | + PIN_GROUP("uart2_grp", byt_score_uart2_pins, 1), |
---|
| 280 | + PIN_GROUP("pwm0_grp", byt_score_pwm0_pins, 1), |
---|
| 281 | + PIN_GROUP("pwm1_grp", byt_score_pwm1_pins, 1), |
---|
| 282 | + PIN_GROUP("ssp2_grp", byt_score_ssp2_pins, 1), |
---|
| 283 | + PIN_GROUP("sio_spi_grp", byt_score_sio_spi_pins, 1), |
---|
| 284 | + PIN_GROUP("i2c5_grp", byt_score_i2c5_pins, 1), |
---|
| 285 | + PIN_GROUP("i2c6_grp", byt_score_i2c6_pins, 1), |
---|
| 286 | + PIN_GROUP("i2c4_grp", byt_score_i2c4_pins, 1), |
---|
| 287 | + PIN_GROUP("i2c3_grp", byt_score_i2c3_pins, 1), |
---|
| 288 | + PIN_GROUP("i2c2_grp", byt_score_i2c2_pins, 1), |
---|
| 289 | + PIN_GROUP("i2c1_grp", byt_score_i2c1_pins, 1), |
---|
| 290 | + PIN_GROUP("i2c0_grp", byt_score_i2c0_pins, 1), |
---|
| 291 | + PIN_GROUP("ssp0_grp", byt_score_ssp0_pins, 1), |
---|
| 292 | + PIN_GROUP("ssp1_grp", byt_score_ssp1_pins, 1), |
---|
| 293 | + PIN_GROUP("sdcard_grp", byt_score_sdcard_pins, byt_score_sdcard_mux_values), |
---|
| 294 | + PIN_GROUP("sdio_grp", byt_score_sdio_pins, 1), |
---|
| 295 | + PIN_GROUP("emmc_grp", byt_score_emmc_pins, 1), |
---|
| 296 | + PIN_GROUP("lpc_grp", byt_score_ilb_lpc_pins, 1), |
---|
| 297 | + PIN_GROUP("sata_grp", byt_score_sata_pins, 1), |
---|
| 298 | + PIN_GROUP("plt_clk0_grp", byt_score_plt_clk0_pins, 1), |
---|
| 299 | + PIN_GROUP("plt_clk1_grp", byt_score_plt_clk1_pins, 1), |
---|
| 300 | + PIN_GROUP("plt_clk2_grp", byt_score_plt_clk2_pins, 1), |
---|
| 301 | + PIN_GROUP("plt_clk3_grp", byt_score_plt_clk3_pins, 1), |
---|
| 302 | + PIN_GROUP("plt_clk4_grp", byt_score_plt_clk4_pins, 1), |
---|
| 303 | + PIN_GROUP("plt_clk5_grp", byt_score_plt_clk5_pins, 1), |
---|
| 304 | + PIN_GROUP("smbus_grp", byt_score_smbus_pins, 1), |
---|
464 | 305 | }; |
---|
465 | 306 | |
---|
466 | 307 | static const char * const byt_score_uart_groups[] = { |
---|
.. | .. |
---|
494 | 335 | "sdcard_grp", "sdio_grp", "emmc_grp", "lpc_grp", "sata_grp", |
---|
495 | 336 | "plt_clk0_grp", "plt_clk1_grp", "plt_clk2_grp", "plt_clk3_grp", |
---|
496 | 337 | "plt_clk4_grp", "plt_clk5_grp", "smbus_grp", |
---|
497 | | - |
---|
498 | 338 | }; |
---|
499 | 339 | |
---|
500 | | -static const struct byt_function byt_score_functions[] = { |
---|
| 340 | +static const struct intel_function byt_score_functions[] = { |
---|
501 | 341 | FUNCTION("uart", byt_score_uart_groups), |
---|
502 | 342 | FUNCTION("pwm", byt_score_pwm_groups), |
---|
503 | 343 | FUNCTION("ssp", byt_score_ssp_groups), |
---|
.. | .. |
---|
513 | 353 | FUNCTION("gpio", byt_score_gpio_groups), |
---|
514 | 354 | }; |
---|
515 | 355 | |
---|
516 | | -static const struct byt_community byt_score_communities[] = { |
---|
| 356 | +static const struct intel_community byt_score_communities[] = { |
---|
517 | 357 | COMMUNITY(0, BYT_NGPIO_SCORE, byt_score_pins_map), |
---|
518 | 358 | }; |
---|
519 | 359 | |
---|
520 | | -static const struct byt_pinctrl_soc_data byt_score_soc_data = { |
---|
| 360 | +static const struct intel_pinctrl_soc_data byt_score_soc_data = { |
---|
521 | 361 | .uid = BYT_SCORE_ACPI_UID, |
---|
522 | 362 | .pins = byt_score_pins, |
---|
523 | 363 | .npins = ARRAY_SIZE(byt_score_pins), |
---|
.. | .. |
---|
586 | 426 | }; |
---|
587 | 427 | |
---|
588 | 428 | static const unsigned int byt_sus_usb_over_current_pins[] = { 19, 20 }; |
---|
589 | | -static const struct byt_simple_func_mux byt_sus_usb_oc_mux[] = { |
---|
590 | | - SIMPLE_FUNC("usb", 0), |
---|
591 | | - SIMPLE_FUNC("gpio", 1), |
---|
592 | | -}; |
---|
| 429 | +static const unsigned int byt_sus_usb_over_current_mode_values[] = { 0, 0 }; |
---|
| 430 | +static const unsigned int byt_sus_usb_over_current_gpio_mode_values[] = { 1, 1 }; |
---|
593 | 431 | |
---|
594 | 432 | static const unsigned int byt_sus_usb_ulpi_pins[] = { |
---|
595 | 433 | 14, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, |
---|
596 | 434 | }; |
---|
597 | | -static const unsigned short byt_sus_usb_ulpi_mode_values[] = { |
---|
| 435 | +static const unsigned int byt_sus_usb_ulpi_mode_values[] = { |
---|
598 | 436 | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
---|
599 | 437 | }; |
---|
600 | | -static const unsigned short byt_sus_usb_ulpi_gpio_mode_values[] = { |
---|
601 | | - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
---|
602 | | -}; |
---|
603 | | -static const struct byt_mixed_func_mux byt_sus_usb_ulpi_mux[] = { |
---|
604 | | - MIXED_FUNC("usb", byt_sus_usb_ulpi_mode_values), |
---|
605 | | - MIXED_FUNC("gpio", byt_sus_usb_ulpi_gpio_mode_values), |
---|
| 438 | +static const unsigned int byt_sus_usb_ulpi_gpio_mode_values[] = { |
---|
| 439 | + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
---|
606 | 440 | }; |
---|
607 | 441 | |
---|
608 | 442 | static const unsigned int byt_sus_pcu_spi_pins[] = { 21 }; |
---|
609 | | -static const struct byt_simple_func_mux byt_sus_pcu_spi_mux[] = { |
---|
610 | | - SIMPLE_FUNC("spi", 0), |
---|
611 | | - SIMPLE_FUNC("gpio", 1), |
---|
612 | | -}; |
---|
| 443 | +static const unsigned int byt_sus_pcu_spi_mode_values[] = { 0 }; |
---|
| 444 | +static const unsigned int byt_sus_pcu_spi_gpio_mode_values[] = { 1 }; |
---|
613 | 445 | |
---|
614 | | -static const struct byt_pingroup byt_sus_groups[] = { |
---|
615 | | - PIN_GROUP_SIMPLE("usb_oc_grp", |
---|
616 | | - byt_sus_usb_over_current_pins, byt_sus_usb_oc_mux), |
---|
617 | | - PIN_GROUP_MIXED("usb_ulpi_grp", |
---|
618 | | - byt_sus_usb_ulpi_pins, byt_sus_usb_ulpi_mux), |
---|
619 | | - PIN_GROUP_SIMPLE("pcu_spi_grp", |
---|
620 | | - byt_sus_pcu_spi_pins, byt_sus_pcu_spi_mux), |
---|
| 446 | +static const struct intel_pingroup byt_sus_groups[] = { |
---|
| 447 | + PIN_GROUP("usb_oc_grp", byt_sus_usb_over_current_pins, byt_sus_usb_over_current_mode_values), |
---|
| 448 | + PIN_GROUP("usb_ulpi_grp", byt_sus_usb_ulpi_pins, byt_sus_usb_ulpi_mode_values), |
---|
| 449 | + PIN_GROUP("pcu_spi_grp", byt_sus_pcu_spi_pins, byt_sus_pcu_spi_mode_values), |
---|
| 450 | + PIN_GROUP("usb_oc_grp_gpio", byt_sus_usb_over_current_pins, byt_sus_usb_over_current_gpio_mode_values), |
---|
| 451 | + PIN_GROUP("usb_ulpi_grp_gpio", byt_sus_usb_ulpi_pins, byt_sus_usb_ulpi_gpio_mode_values), |
---|
| 452 | + PIN_GROUP("pcu_spi_grp_gpio", byt_sus_pcu_spi_pins, byt_sus_pcu_spi_gpio_mode_values), |
---|
621 | 453 | }; |
---|
622 | 454 | |
---|
623 | 455 | static const char * const byt_sus_usb_groups[] = { |
---|
.. | .. |
---|
625 | 457 | }; |
---|
626 | 458 | static const char * const byt_sus_spi_groups[] = { "pcu_spi_grp" }; |
---|
627 | 459 | static const char * const byt_sus_gpio_groups[] = { |
---|
628 | | - "usb_oc_grp", "usb_ulpi_grp", "pcu_spi_grp", |
---|
| 460 | + "usb_oc_grp_gpio", "usb_ulpi_grp_gpio", "pcu_spi_grp_gpio", |
---|
629 | 461 | }; |
---|
630 | 462 | |
---|
631 | | -static const struct byt_function byt_sus_functions[] = { |
---|
| 463 | +static const struct intel_function byt_sus_functions[] = { |
---|
632 | 464 | FUNCTION("usb", byt_sus_usb_groups), |
---|
633 | 465 | FUNCTION("spi", byt_sus_spi_groups), |
---|
634 | 466 | FUNCTION("gpio", byt_sus_gpio_groups), |
---|
635 | 467 | }; |
---|
636 | 468 | |
---|
637 | | -static const struct byt_community byt_sus_communities[] = { |
---|
| 469 | +static const struct intel_community byt_sus_communities[] = { |
---|
638 | 470 | COMMUNITY(0, BYT_NGPIO_SUS, byt_sus_pins_map), |
---|
639 | 471 | }; |
---|
640 | 472 | |
---|
641 | | -static const struct byt_pinctrl_soc_data byt_sus_soc_data = { |
---|
| 473 | +static const struct intel_pinctrl_soc_data byt_sus_soc_data = { |
---|
642 | 474 | .uid = BYT_SUS_ACPI_UID, |
---|
643 | 475 | .pins = byt_sus_pins, |
---|
644 | 476 | .npins = ARRAY_SIZE(byt_sus_pins), |
---|
.. | .. |
---|
651 | 483 | }; |
---|
652 | 484 | |
---|
653 | 485 | static const struct pinctrl_pin_desc byt_ncore_pins[] = { |
---|
654 | | - PINCTRL_PIN(0, "GPIO_NCORE0"), |
---|
655 | | - PINCTRL_PIN(1, "GPIO_NCORE1"), |
---|
656 | | - PINCTRL_PIN(2, "GPIO_NCORE2"), |
---|
657 | | - PINCTRL_PIN(3, "GPIO_NCORE3"), |
---|
658 | | - PINCTRL_PIN(4, "GPIO_NCORE4"), |
---|
659 | | - PINCTRL_PIN(5, "GPIO_NCORE5"), |
---|
660 | | - PINCTRL_PIN(6, "GPIO_NCORE6"), |
---|
661 | | - PINCTRL_PIN(7, "GPIO_NCORE7"), |
---|
662 | | - PINCTRL_PIN(8, "GPIO_NCORE8"), |
---|
663 | | - PINCTRL_PIN(9, "GPIO_NCORE9"), |
---|
664 | | - PINCTRL_PIN(10, "GPIO_NCORE10"), |
---|
665 | | - PINCTRL_PIN(11, "GPIO_NCORE11"), |
---|
666 | | - PINCTRL_PIN(12, "GPIO_NCORE12"), |
---|
667 | | - PINCTRL_PIN(13, "GPIO_NCORE13"), |
---|
668 | | - PINCTRL_PIN(14, "GPIO_NCORE14"), |
---|
669 | | - PINCTRL_PIN(15, "GPIO_NCORE15"), |
---|
670 | | - PINCTRL_PIN(16, "GPIO_NCORE16"), |
---|
671 | | - PINCTRL_PIN(17, "GPIO_NCORE17"), |
---|
672 | | - PINCTRL_PIN(18, "GPIO_NCORE18"), |
---|
673 | | - PINCTRL_PIN(19, "GPIO_NCORE19"), |
---|
674 | | - PINCTRL_PIN(20, "GPIO_NCORE20"), |
---|
675 | | - PINCTRL_PIN(21, "GPIO_NCORE21"), |
---|
676 | | - PINCTRL_PIN(22, "GPIO_NCORE22"), |
---|
677 | | - PINCTRL_PIN(23, "GPIO_NCORE23"), |
---|
678 | | - PINCTRL_PIN(24, "GPIO_NCORE24"), |
---|
679 | | - PINCTRL_PIN(25, "GPIO_NCORE25"), |
---|
680 | | - PINCTRL_PIN(26, "GPIO_NCORE26"), |
---|
681 | | - PINCTRL_PIN(27, "GPIO_NCORE27"), |
---|
| 486 | + PINCTRL_PIN(0, "HV_DDI0_HPD"), |
---|
| 487 | + PINCTRL_PIN(1, "HV_DDI0_DDC_SDA"), |
---|
| 488 | + PINCTRL_PIN(2, "HV_DDI0_DDC_SCL"), |
---|
| 489 | + PINCTRL_PIN(3, "PANEL0_VDDEN"), |
---|
| 490 | + PINCTRL_PIN(4, "PANEL0_BKLTEN"), |
---|
| 491 | + PINCTRL_PIN(5, "PANEL0_BKLTCTL"), |
---|
| 492 | + PINCTRL_PIN(6, "HV_DDI1_HPD"), |
---|
| 493 | + PINCTRL_PIN(7, "HV_DDI1_DDC_SDA"), |
---|
| 494 | + PINCTRL_PIN(8, "HV_DDI1_DDC_SCL"), |
---|
| 495 | + PINCTRL_PIN(9, "PANEL1_VDDEN"), |
---|
| 496 | + PINCTRL_PIN(10, "PANEL1_BKLTEN"), |
---|
| 497 | + PINCTRL_PIN(11, "PANEL1_BKLTCTL"), |
---|
| 498 | + PINCTRL_PIN(12, "GP_INTD_DSI_TE1"), |
---|
| 499 | + PINCTRL_PIN(13, "HV_DDI2_DDC_SDA"), |
---|
| 500 | + PINCTRL_PIN(14, "HV_DDI2_DDC_SCL"), |
---|
| 501 | + PINCTRL_PIN(15, "GP_CAMERASB00"), |
---|
| 502 | + PINCTRL_PIN(16, "GP_CAMERASB01"), |
---|
| 503 | + PINCTRL_PIN(17, "GP_CAMERASB02"), |
---|
| 504 | + PINCTRL_PIN(18, "GP_CAMERASB03"), |
---|
| 505 | + PINCTRL_PIN(19, "GP_CAMERASB04"), |
---|
| 506 | + PINCTRL_PIN(20, "GP_CAMERASB05"), |
---|
| 507 | + PINCTRL_PIN(21, "GP_CAMERASB06"), |
---|
| 508 | + PINCTRL_PIN(22, "GP_CAMERASB07"), |
---|
| 509 | + PINCTRL_PIN(23, "GP_CAMERASB08"), |
---|
| 510 | + PINCTRL_PIN(24, "GP_CAMERASB09"), |
---|
| 511 | + PINCTRL_PIN(25, "GP_CAMERASB10"), |
---|
| 512 | + PINCTRL_PIN(26, "GP_CAMERASB11"), |
---|
| 513 | + PINCTRL_PIN(27, "GP_INTD_DSI_TE2"), |
---|
682 | 514 | }; |
---|
683 | 515 | |
---|
684 | | -static unsigned const byt_ncore_pins_map[BYT_NGPIO_NCORE] = { |
---|
| 516 | +static const unsigned int byt_ncore_pins_map[BYT_NGPIO_NCORE] = { |
---|
685 | 517 | 19, 18, 17, 20, 21, 22, 24, 25, 23, 16, |
---|
686 | 518 | 14, 15, 12, 26, 27, 1, 4, 8, 11, 0, |
---|
687 | 519 | 3, 6, 10, 13, 2, 5, 9, 7, |
---|
688 | 520 | }; |
---|
689 | 521 | |
---|
690 | | -static const struct byt_community byt_ncore_communities[] = { |
---|
| 522 | +static const struct intel_community byt_ncore_communities[] = { |
---|
691 | 523 | COMMUNITY(0, BYT_NGPIO_NCORE, byt_ncore_pins_map), |
---|
692 | 524 | }; |
---|
693 | 525 | |
---|
694 | | -static const struct byt_pinctrl_soc_data byt_ncore_soc_data = { |
---|
| 526 | +static const struct intel_pinctrl_soc_data byt_ncore_soc_data = { |
---|
695 | 527 | .uid = BYT_NCORE_ACPI_UID, |
---|
696 | 528 | .pins = byt_ncore_pins, |
---|
697 | 529 | .npins = ARRAY_SIZE(byt_ncore_pins), |
---|
.. | .. |
---|
699 | 531 | .ncommunities = ARRAY_SIZE(byt_ncore_communities), |
---|
700 | 532 | }; |
---|
701 | 533 | |
---|
702 | | -static const struct byt_pinctrl_soc_data *byt_soc_data[] = { |
---|
| 534 | +static const struct intel_pinctrl_soc_data *byt_soc_data[] = { |
---|
703 | 535 | &byt_score_soc_data, |
---|
704 | 536 | &byt_sus_soc_data, |
---|
705 | 537 | &byt_ncore_soc_data, |
---|
706 | | - NULL, |
---|
| 538 | + NULL |
---|
707 | 539 | }; |
---|
708 | 540 | |
---|
709 | 541 | static DEFINE_RAW_SPINLOCK(byt_lock); |
---|
710 | 542 | |
---|
711 | | -static struct byt_community *byt_get_community(struct byt_gpio *vg, |
---|
712 | | - unsigned int pin) |
---|
| 543 | +static struct intel_community *byt_get_community(struct intel_pinctrl *vg, |
---|
| 544 | + unsigned int pin) |
---|
713 | 545 | { |
---|
714 | | - struct byt_community *comm; |
---|
| 546 | + struct intel_community *comm; |
---|
715 | 547 | int i; |
---|
716 | 548 | |
---|
717 | | - for (i = 0; i < vg->soc_data->ncommunities; i++) { |
---|
718 | | - comm = vg->communities_copy + i; |
---|
| 549 | + for (i = 0; i < vg->ncommunities; i++) { |
---|
| 550 | + comm = vg->communities + i; |
---|
719 | 551 | if (pin < comm->pin_base + comm->npins && pin >= comm->pin_base) |
---|
720 | 552 | return comm; |
---|
721 | 553 | } |
---|
.. | .. |
---|
723 | 555 | return NULL; |
---|
724 | 556 | } |
---|
725 | 557 | |
---|
726 | | -static void __iomem *byt_gpio_reg(struct byt_gpio *vg, unsigned int offset, |
---|
| 558 | +static void __iomem *byt_gpio_reg(struct intel_pinctrl *vg, unsigned int offset, |
---|
727 | 559 | int reg) |
---|
728 | 560 | { |
---|
729 | | - struct byt_community *comm = byt_get_community(vg, offset); |
---|
| 561 | + struct intel_community *comm = byt_get_community(vg, offset); |
---|
730 | 562 | u32 reg_offset; |
---|
731 | 563 | |
---|
732 | 564 | if (!comm) |
---|
.. | .. |
---|
745 | 577 | break; |
---|
746 | 578 | } |
---|
747 | 579 | |
---|
748 | | - return comm->reg_base + reg_offset + reg; |
---|
| 580 | + return comm->pad_regs + reg_offset + reg; |
---|
749 | 581 | } |
---|
750 | 582 | |
---|
751 | 583 | static int byt_get_groups_count(struct pinctrl_dev *pctldev) |
---|
752 | 584 | { |
---|
753 | | - struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
| 585 | + struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
754 | 586 | |
---|
755 | | - return vg->soc_data->ngroups; |
---|
| 587 | + return vg->soc->ngroups; |
---|
756 | 588 | } |
---|
757 | 589 | |
---|
758 | 590 | static const char *byt_get_group_name(struct pinctrl_dev *pctldev, |
---|
759 | 591 | unsigned int selector) |
---|
760 | 592 | { |
---|
761 | | - struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
| 593 | + struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
762 | 594 | |
---|
763 | | - return vg->soc_data->groups[selector].name; |
---|
| 595 | + return vg->soc->groups[selector].name; |
---|
764 | 596 | } |
---|
765 | 597 | |
---|
766 | 598 | static int byt_get_group_pins(struct pinctrl_dev *pctldev, |
---|
.. | .. |
---|
768 | 600 | const unsigned int **pins, |
---|
769 | 601 | unsigned int *num_pins) |
---|
770 | 602 | { |
---|
771 | | - struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
| 603 | + struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
772 | 604 | |
---|
773 | | - *pins = vg->soc_data->groups[selector].pins; |
---|
774 | | - *num_pins = vg->soc_data->groups[selector].npins; |
---|
| 605 | + *pins = vg->soc->groups[selector].pins; |
---|
| 606 | + *num_pins = vg->soc->groups[selector].npins; |
---|
775 | 607 | |
---|
776 | 608 | return 0; |
---|
777 | 609 | } |
---|
.. | .. |
---|
784 | 616 | |
---|
785 | 617 | static int byt_get_functions_count(struct pinctrl_dev *pctldev) |
---|
786 | 618 | { |
---|
787 | | - struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
| 619 | + struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
788 | 620 | |
---|
789 | | - return vg->soc_data->nfunctions; |
---|
| 621 | + return vg->soc->nfunctions; |
---|
790 | 622 | } |
---|
791 | 623 | |
---|
792 | 624 | static const char *byt_get_function_name(struct pinctrl_dev *pctldev, |
---|
793 | 625 | unsigned int selector) |
---|
794 | 626 | { |
---|
795 | | - struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
| 627 | + struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
796 | 628 | |
---|
797 | | - return vg->soc_data->functions[selector].name; |
---|
| 629 | + return vg->soc->functions[selector].name; |
---|
798 | 630 | } |
---|
799 | 631 | |
---|
800 | 632 | static int byt_get_function_groups(struct pinctrl_dev *pctldev, |
---|
.. | .. |
---|
802 | 634 | const char * const **groups, |
---|
803 | 635 | unsigned int *num_groups) |
---|
804 | 636 | { |
---|
805 | | - struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
| 637 | + struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
806 | 638 | |
---|
807 | | - *groups = vg->soc_data->functions[selector].groups; |
---|
808 | | - *num_groups = vg->soc_data->functions[selector].ngroups; |
---|
| 639 | + *groups = vg->soc->functions[selector].groups; |
---|
| 640 | + *num_groups = vg->soc->functions[selector].ngroups; |
---|
809 | 641 | |
---|
810 | 642 | return 0; |
---|
811 | 643 | } |
---|
812 | 644 | |
---|
813 | | -static int byt_get_group_simple_mux(const struct byt_pingroup group, |
---|
814 | | - const char *func_name, |
---|
815 | | - unsigned short *func) |
---|
816 | | -{ |
---|
817 | | - int i; |
---|
818 | | - |
---|
819 | | - for (i = 0; i < group.nfuncs; i++) { |
---|
820 | | - if (!strcmp(group.simple_funcs[i].name, func_name)) { |
---|
821 | | - *func = group.simple_funcs[i].func; |
---|
822 | | - return 0; |
---|
823 | | - } |
---|
824 | | - } |
---|
825 | | - |
---|
826 | | - return 1; |
---|
827 | | -} |
---|
828 | | - |
---|
829 | | -static int byt_get_group_mixed_mux(const struct byt_pingroup group, |
---|
830 | | - const char *func_name, |
---|
831 | | - const unsigned short **func) |
---|
832 | | -{ |
---|
833 | | - int i; |
---|
834 | | - |
---|
835 | | - for (i = 0; i < group.nfuncs; i++) { |
---|
836 | | - if (!strcmp(group.mixed_funcs[i].name, func_name)) { |
---|
837 | | - *func = group.mixed_funcs[i].func_values; |
---|
838 | | - return 0; |
---|
839 | | - } |
---|
840 | | - } |
---|
841 | | - |
---|
842 | | - return 1; |
---|
843 | | -} |
---|
844 | | - |
---|
845 | | -static void byt_set_group_simple_mux(struct byt_gpio *vg, |
---|
846 | | - const struct byt_pingroup group, |
---|
847 | | - unsigned short func) |
---|
| 645 | +static void byt_set_group_simple_mux(struct intel_pinctrl *vg, |
---|
| 646 | + const struct intel_pingroup group, |
---|
| 647 | + unsigned int func) |
---|
848 | 648 | { |
---|
849 | 649 | unsigned long flags; |
---|
850 | 650 | int i; |
---|
.. | .. |
---|
857 | 657 | |
---|
858 | 658 | padcfg0 = byt_gpio_reg(vg, group.pins[i], BYT_CONF0_REG); |
---|
859 | 659 | if (!padcfg0) { |
---|
860 | | - dev_warn(&vg->pdev->dev, |
---|
| 660 | + dev_warn(vg->dev, |
---|
861 | 661 | "Group %s, pin %i not muxed (no padcfg0)\n", |
---|
862 | 662 | group.name, i); |
---|
863 | 663 | continue; |
---|
.. | .. |
---|
872 | 672 | raw_spin_unlock_irqrestore(&byt_lock, flags); |
---|
873 | 673 | } |
---|
874 | 674 | |
---|
875 | | -static void byt_set_group_mixed_mux(struct byt_gpio *vg, |
---|
876 | | - const struct byt_pingroup group, |
---|
877 | | - const unsigned short *func) |
---|
| 675 | +static void byt_set_group_mixed_mux(struct intel_pinctrl *vg, |
---|
| 676 | + const struct intel_pingroup group, |
---|
| 677 | + const unsigned int *func) |
---|
878 | 678 | { |
---|
879 | 679 | unsigned long flags; |
---|
880 | 680 | int i; |
---|
.. | .. |
---|
887 | 687 | |
---|
888 | 688 | padcfg0 = byt_gpio_reg(vg, group.pins[i], BYT_CONF0_REG); |
---|
889 | 689 | if (!padcfg0) { |
---|
890 | | - dev_warn(&vg->pdev->dev, |
---|
| 690 | + dev_warn(vg->dev, |
---|
891 | 691 | "Group %s, pin %i not muxed (no padcfg0)\n", |
---|
892 | 692 | group.name, i); |
---|
893 | 693 | continue; |
---|
.. | .. |
---|
905 | 705 | static int byt_set_mux(struct pinctrl_dev *pctldev, unsigned int func_selector, |
---|
906 | 706 | unsigned int group_selector) |
---|
907 | 707 | { |
---|
908 | | - struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
909 | | - const struct byt_function func = vg->soc_data->functions[func_selector]; |
---|
910 | | - const struct byt_pingroup group = vg->soc_data->groups[group_selector]; |
---|
911 | | - const unsigned short *mixed_func; |
---|
912 | | - unsigned short simple_func; |
---|
913 | | - int ret = 1; |
---|
| 708 | + struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev); |
---|
| 709 | + const struct intel_function func = vg->soc->functions[func_selector]; |
---|
| 710 | + const struct intel_pingroup group = vg->soc->groups[group_selector]; |
---|
914 | 711 | |
---|
915 | | - if (group.has_simple_funcs) |
---|
916 | | - ret = byt_get_group_simple_mux(group, func.name, &simple_func); |
---|
917 | | - else |
---|
918 | | - ret = byt_get_group_mixed_mux(group, func.name, &mixed_func); |
---|
919 | | - |
---|
920 | | - if (ret) |
---|
| 712 | + if (group.modes) |
---|
| 713 | + byt_set_group_mixed_mux(vg, group, group.modes); |
---|
| 714 | + else if (!strcmp(func.name, "gpio")) |
---|
921 | 715 | byt_set_group_simple_mux(vg, group, BYT_DEFAULT_GPIO_MUX); |
---|
922 | | - else if (group.has_simple_funcs) |
---|
923 | | - byt_set_group_simple_mux(vg, group, simple_func); |
---|
924 | 716 | else |
---|
925 | | - byt_set_group_mixed_mux(vg, group, mixed_func); |
---|
| 717 | + byt_set_group_simple_mux(vg, group, group.mode); |
---|
926 | 718 | |
---|
927 | 719 | return 0; |
---|
928 | 720 | } |
---|
929 | 721 | |
---|
930 | | -static u32 byt_get_gpio_mux(struct byt_gpio *vg, unsigned offset) |
---|
| 722 | +static u32 byt_get_gpio_mux(struct intel_pinctrl *vg, unsigned int offset) |
---|
931 | 723 | { |
---|
932 | 724 | /* SCORE pin 92-93 */ |
---|
933 | | - if (!strcmp(vg->soc_data->uid, BYT_SCORE_ACPI_UID) && |
---|
| 725 | + if (!strcmp(vg->soc->uid, BYT_SCORE_ACPI_UID) && |
---|
934 | 726 | offset >= 92 && offset <= 93) |
---|
935 | | - return 1; |
---|
| 727 | + return BYT_ALTER_GPIO_MUX; |
---|
936 | 728 | |
---|
937 | 729 | /* SUS pin 11-21 */ |
---|
938 | | - if (!strcmp(vg->soc_data->uid, BYT_SUS_ACPI_UID) && |
---|
| 730 | + if (!strcmp(vg->soc->uid, BYT_SUS_ACPI_UID) && |
---|
939 | 731 | offset >= 11 && offset <= 21) |
---|
940 | | - return 1; |
---|
| 732 | + return BYT_ALTER_GPIO_MUX; |
---|
941 | 733 | |
---|
942 | | - return 0; |
---|
| 734 | + return BYT_DEFAULT_GPIO_MUX; |
---|
943 | 735 | } |
---|
944 | 736 | |
---|
945 | | -static void byt_gpio_clear_triggering(struct byt_gpio *vg, unsigned int offset) |
---|
| 737 | +static void byt_gpio_clear_triggering(struct intel_pinctrl *vg, unsigned int offset) |
---|
946 | 738 | { |
---|
947 | 739 | void __iomem *reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); |
---|
948 | 740 | unsigned long flags; |
---|
.. | .. |
---|
965 | 757 | struct pinctrl_gpio_range *range, |
---|
966 | 758 | unsigned int offset) |
---|
967 | 759 | { |
---|
968 | | - struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctl_dev); |
---|
| 760 | + struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctl_dev); |
---|
969 | 761 | void __iomem *reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); |
---|
970 | 762 | u32 value, gpio_mux; |
---|
971 | 763 | unsigned long flags; |
---|
.. | .. |
---|
988 | 780 | value |= gpio_mux; |
---|
989 | 781 | writel(value, reg); |
---|
990 | 782 | |
---|
991 | | - dev_warn(&vg->pdev->dev, FW_BUG |
---|
992 | | - "pin %u forcibly re-configured as GPIO\n", offset); |
---|
| 783 | + dev_warn(vg->dev, FW_BUG "pin %u forcibly re-configured as GPIO\n", offset); |
---|
993 | 784 | } |
---|
994 | 785 | |
---|
995 | 786 | raw_spin_unlock_irqrestore(&byt_lock, flags); |
---|
996 | 787 | |
---|
997 | | - pm_runtime_get(&vg->pdev->dev); |
---|
| 788 | + pm_runtime_get(vg->dev); |
---|
998 | 789 | |
---|
999 | 790 | return 0; |
---|
1000 | 791 | } |
---|
.. | .. |
---|
1003 | 794 | struct pinctrl_gpio_range *range, |
---|
1004 | 795 | unsigned int offset) |
---|
1005 | 796 | { |
---|
1006 | | - struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctl_dev); |
---|
| 797 | + struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctl_dev); |
---|
1007 | 798 | |
---|
1008 | 799 | byt_gpio_clear_triggering(vg, offset); |
---|
1009 | | - pm_runtime_put(&vg->pdev->dev); |
---|
| 800 | + pm_runtime_put(vg->dev); |
---|
1010 | 801 | } |
---|
1011 | 802 | |
---|
1012 | | -static void byt_gpio_direct_irq_check(struct byt_gpio *vg, |
---|
| 803 | +static void byt_gpio_direct_irq_check(struct intel_pinctrl *vg, |
---|
1013 | 804 | unsigned int offset) |
---|
1014 | 805 | { |
---|
1015 | 806 | void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); |
---|
.. | .. |
---|
1021 | 812 | * themselves in the foot. |
---|
1022 | 813 | */ |
---|
1023 | 814 | if (readl(conf_reg) & BYT_DIRECT_IRQ_EN) |
---|
1024 | | - dev_info_once(&vg->pdev->dev, "Potential Error: Setting GPIO with direct_irq_en to output"); |
---|
| 815 | + dev_info_once(vg->dev, "Potential Error: Setting GPIO with direct_irq_en to output"); |
---|
1025 | 816 | } |
---|
1026 | 817 | |
---|
1027 | 818 | static int byt_gpio_set_direction(struct pinctrl_dev *pctl_dev, |
---|
.. | .. |
---|
1029 | 820 | unsigned int offset, |
---|
1030 | 821 | bool input) |
---|
1031 | 822 | { |
---|
1032 | | - struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctl_dev); |
---|
| 823 | + struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctl_dev); |
---|
1033 | 824 | void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); |
---|
1034 | 825 | unsigned long flags; |
---|
1035 | 826 | u32 value; |
---|
.. | .. |
---|
1105 | 896 | static int byt_pin_config_get(struct pinctrl_dev *pctl_dev, unsigned int offset, |
---|
1106 | 897 | unsigned long *config) |
---|
1107 | 898 | { |
---|
1108 | | - struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctl_dev); |
---|
| 899 | + struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctl_dev); |
---|
1109 | 900 | enum pin_config_param param = pinconf_to_config_param(*config); |
---|
1110 | 901 | void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); |
---|
1111 | 902 | void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); |
---|
.. | .. |
---|
1190 | 981 | unsigned long *configs, |
---|
1191 | 982 | unsigned int num_configs) |
---|
1192 | 983 | { |
---|
1193 | | - struct byt_gpio *vg = pinctrl_dev_get_drvdata(pctl_dev); |
---|
| 984 | + struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctl_dev); |
---|
1194 | 985 | unsigned int param, arg; |
---|
1195 | 986 | void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); |
---|
1196 | 987 | void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); |
---|
.. | .. |
---|
1224 | 1015 | if (val & BYT_INPUT_EN) { |
---|
1225 | 1016 | val &= ~BYT_INPUT_EN; |
---|
1226 | 1017 | writel(val, val_reg); |
---|
1227 | | - dev_warn(&vg->pdev->dev, |
---|
| 1018 | + dev_warn(vg->dev, |
---|
1228 | 1019 | "pin %u forcibly set to input mode\n", |
---|
1229 | 1020 | offset); |
---|
1230 | 1021 | } |
---|
.. | .. |
---|
1246 | 1037 | if (val & BYT_INPUT_EN) { |
---|
1247 | 1038 | val &= ~BYT_INPUT_EN; |
---|
1248 | 1039 | writel(val, val_reg); |
---|
1249 | | - dev_warn(&vg->pdev->dev, |
---|
| 1040 | + dev_warn(vg->dev, |
---|
1250 | 1041 | "pin %u forcibly set to input mode\n", |
---|
1251 | 1042 | offset); |
---|
1252 | 1043 | } |
---|
.. | .. |
---|
1331 | 1122 | .owner = THIS_MODULE, |
---|
1332 | 1123 | }; |
---|
1333 | 1124 | |
---|
1334 | | -static int byt_gpio_get(struct gpio_chip *chip, unsigned offset) |
---|
| 1125 | +static int byt_gpio_get(struct gpio_chip *chip, unsigned int offset) |
---|
1335 | 1126 | { |
---|
1336 | | - struct byt_gpio *vg = gpiochip_get_data(chip); |
---|
| 1127 | + struct intel_pinctrl *vg = gpiochip_get_data(chip); |
---|
1337 | 1128 | void __iomem *reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); |
---|
1338 | 1129 | unsigned long flags; |
---|
1339 | 1130 | u32 val; |
---|
.. | .. |
---|
1345 | 1136 | return !!(val & BYT_LEVEL); |
---|
1346 | 1137 | } |
---|
1347 | 1138 | |
---|
1348 | | -static void byt_gpio_set(struct gpio_chip *chip, unsigned offset, int value) |
---|
| 1139 | +static void byt_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) |
---|
1349 | 1140 | { |
---|
1350 | | - struct byt_gpio *vg = gpiochip_get_data(chip); |
---|
| 1141 | + struct intel_pinctrl *vg = gpiochip_get_data(chip); |
---|
1351 | 1142 | void __iomem *reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); |
---|
1352 | 1143 | unsigned long flags; |
---|
1353 | 1144 | u32 old_val; |
---|
.. | .. |
---|
1366 | 1157 | |
---|
1367 | 1158 | static int byt_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) |
---|
1368 | 1159 | { |
---|
1369 | | - struct byt_gpio *vg = gpiochip_get_data(chip); |
---|
| 1160 | + struct intel_pinctrl *vg = gpiochip_get_data(chip); |
---|
1370 | 1161 | void __iomem *reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); |
---|
1371 | 1162 | unsigned long flags; |
---|
1372 | 1163 | u32 value; |
---|
.. | .. |
---|
1379 | 1170 | raw_spin_unlock_irqrestore(&byt_lock, flags); |
---|
1380 | 1171 | |
---|
1381 | 1172 | if (!(value & BYT_OUTPUT_EN)) |
---|
1382 | | - return GPIOF_DIR_OUT; |
---|
| 1173 | + return GPIO_LINE_DIRECTION_OUT; |
---|
1383 | 1174 | if (!(value & BYT_INPUT_EN)) |
---|
1384 | | - return GPIOF_DIR_IN; |
---|
| 1175 | + return GPIO_LINE_DIRECTION_IN; |
---|
1385 | 1176 | |
---|
1386 | 1177 | return -EINVAL; |
---|
1387 | 1178 | } |
---|
1388 | 1179 | |
---|
1389 | 1180 | static int byt_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) |
---|
1390 | 1181 | { |
---|
1391 | | - struct byt_gpio *vg = gpiochip_get_data(chip); |
---|
| 1182 | + struct intel_pinctrl *vg = gpiochip_get_data(chip); |
---|
1392 | 1183 | void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); |
---|
1393 | 1184 | unsigned long flags; |
---|
1394 | 1185 | u32 reg; |
---|
.. | .. |
---|
1413 | 1204 | static int byt_gpio_direction_output(struct gpio_chip *chip, |
---|
1414 | 1205 | unsigned int offset, int value) |
---|
1415 | 1206 | { |
---|
1416 | | - struct byt_gpio *vg = gpiochip_get_data(chip); |
---|
| 1207 | + struct intel_pinctrl *vg = gpiochip_get_data(chip); |
---|
1417 | 1208 | void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); |
---|
1418 | 1209 | unsigned long flags; |
---|
1419 | 1210 | u32 reg; |
---|
.. | .. |
---|
1437 | 1228 | |
---|
1438 | 1229 | static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) |
---|
1439 | 1230 | { |
---|
1440 | | - struct byt_gpio *vg = gpiochip_get_data(chip); |
---|
| 1231 | + struct intel_pinctrl *vg = gpiochip_get_data(chip); |
---|
1441 | 1232 | int i; |
---|
1442 | 1233 | u32 conf0, val; |
---|
1443 | 1234 | |
---|
1444 | | - for (i = 0; i < vg->soc_data->npins; i++) { |
---|
1445 | | - const struct byt_community *comm; |
---|
| 1235 | + for (i = 0; i < vg->soc->npins; i++) { |
---|
| 1236 | + const struct intel_community *comm; |
---|
1446 | 1237 | const char *pull_str = NULL; |
---|
1447 | 1238 | const char *pull = NULL; |
---|
1448 | 1239 | void __iomem *reg; |
---|
.. | .. |
---|
1451 | 1242 | unsigned int pin; |
---|
1452 | 1243 | |
---|
1453 | 1244 | raw_spin_lock_irqsave(&byt_lock, flags); |
---|
1454 | | - pin = vg->soc_data->pins[i].number; |
---|
| 1245 | + pin = vg->soc->pins[i].number; |
---|
1455 | 1246 | reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG); |
---|
1456 | 1247 | if (!reg) { |
---|
1457 | 1248 | seq_printf(s, |
---|
.. | .. |
---|
1547 | 1338 | static void byt_irq_ack(struct irq_data *d) |
---|
1548 | 1339 | { |
---|
1549 | 1340 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
---|
1550 | | - struct byt_gpio *vg = gpiochip_get_data(gc); |
---|
1551 | | - unsigned offset = irqd_to_hwirq(d); |
---|
| 1341 | + struct intel_pinctrl *vg = gpiochip_get_data(gc); |
---|
| 1342 | + unsigned int offset = irqd_to_hwirq(d); |
---|
1552 | 1343 | void __iomem *reg; |
---|
1553 | 1344 | |
---|
1554 | 1345 | reg = byt_gpio_reg(vg, offset, BYT_INT_STAT_REG); |
---|
.. | .. |
---|
1563 | 1354 | static void byt_irq_mask(struct irq_data *d) |
---|
1564 | 1355 | { |
---|
1565 | 1356 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
---|
1566 | | - struct byt_gpio *vg = gpiochip_get_data(gc); |
---|
| 1357 | + struct intel_pinctrl *vg = gpiochip_get_data(gc); |
---|
1567 | 1358 | |
---|
1568 | 1359 | byt_gpio_clear_triggering(vg, irqd_to_hwirq(d)); |
---|
1569 | 1360 | } |
---|
.. | .. |
---|
1571 | 1362 | static void byt_irq_unmask(struct irq_data *d) |
---|
1572 | 1363 | { |
---|
1573 | 1364 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
---|
1574 | | - struct byt_gpio *vg = gpiochip_get_data(gc); |
---|
1575 | | - unsigned offset = irqd_to_hwirq(d); |
---|
| 1365 | + struct intel_pinctrl *vg = gpiochip_get_data(gc); |
---|
| 1366 | + unsigned int offset = irqd_to_hwirq(d); |
---|
1576 | 1367 | unsigned long flags; |
---|
1577 | 1368 | void __iomem *reg; |
---|
1578 | 1369 | u32 value; |
---|
.. | .. |
---|
1587 | 1378 | switch (irqd_get_trigger_type(d)) { |
---|
1588 | 1379 | case IRQ_TYPE_LEVEL_HIGH: |
---|
1589 | 1380 | value |= BYT_TRIG_LVL; |
---|
1590 | | - /* fall through */ |
---|
| 1381 | + fallthrough; |
---|
1591 | 1382 | case IRQ_TYPE_EDGE_RISING: |
---|
1592 | 1383 | value |= BYT_TRIG_POS; |
---|
1593 | 1384 | break; |
---|
1594 | 1385 | case IRQ_TYPE_LEVEL_LOW: |
---|
1595 | 1386 | value |= BYT_TRIG_LVL; |
---|
1596 | | - /* fall through */ |
---|
| 1387 | + fallthrough; |
---|
1597 | 1388 | case IRQ_TYPE_EDGE_FALLING: |
---|
1598 | 1389 | value |= BYT_TRIG_NEG; |
---|
1599 | 1390 | break; |
---|
.. | .. |
---|
1609 | 1400 | |
---|
1610 | 1401 | static int byt_irq_type(struct irq_data *d, unsigned int type) |
---|
1611 | 1402 | { |
---|
1612 | | - struct byt_gpio *vg = gpiochip_get_data(irq_data_get_irq_chip_data(d)); |
---|
| 1403 | + struct intel_pinctrl *vg = gpiochip_get_data(irq_data_get_irq_chip_data(d)); |
---|
1613 | 1404 | u32 offset = irqd_to_hwirq(d); |
---|
1614 | 1405 | u32 value; |
---|
1615 | 1406 | unsigned long flags; |
---|
.. | .. |
---|
1645 | 1436 | return 0; |
---|
1646 | 1437 | } |
---|
1647 | 1438 | |
---|
1648 | | -static struct irq_chip byt_irqchip = { |
---|
1649 | | - .name = "BYT-GPIO", |
---|
1650 | | - .irq_ack = byt_irq_ack, |
---|
1651 | | - .irq_mask = byt_irq_mask, |
---|
1652 | | - .irq_unmask = byt_irq_unmask, |
---|
1653 | | - .irq_set_type = byt_irq_type, |
---|
1654 | | - .flags = IRQCHIP_SKIP_SET_WAKE, |
---|
1655 | | -}; |
---|
1656 | | - |
---|
1657 | 1439 | static void byt_gpio_irq_handler(struct irq_desc *desc) |
---|
1658 | 1440 | { |
---|
1659 | 1441 | struct irq_data *data = irq_desc_get_irq_data(desc); |
---|
1660 | | - struct byt_gpio *vg = gpiochip_get_data( |
---|
1661 | | - irq_desc_get_handler_data(desc)); |
---|
| 1442 | + struct intel_pinctrl *vg = gpiochip_get_data(irq_desc_get_handler_data(desc)); |
---|
1662 | 1443 | struct irq_chip *chip = irq_data_get_irq_chip(data); |
---|
1663 | 1444 | u32 base, pin; |
---|
1664 | 1445 | void __iomem *reg; |
---|
.. | .. |
---|
1670 | 1451 | reg = byt_gpio_reg(vg, base, BYT_INT_STAT_REG); |
---|
1671 | 1452 | |
---|
1672 | 1453 | if (!reg) { |
---|
1673 | | - dev_warn(&vg->pdev->dev, |
---|
| 1454 | + dev_warn(vg->dev, |
---|
1674 | 1455 | "Pin %i: could not retrieve interrupt status register\n", |
---|
1675 | 1456 | base); |
---|
1676 | 1457 | continue; |
---|
.. | .. |
---|
1687 | 1468 | chip->irq_eoi(data); |
---|
1688 | 1469 | } |
---|
1689 | 1470 | |
---|
1690 | | -static void byt_gpio_irq_init_hw(struct byt_gpio *vg) |
---|
| 1471 | +static void byt_init_irq_valid_mask(struct gpio_chip *chip, |
---|
| 1472 | + unsigned long *valid_mask, |
---|
| 1473 | + unsigned int ngpios) |
---|
1691 | 1474 | { |
---|
1692 | | - struct gpio_chip *gc = &vg->chip; |
---|
1693 | | - struct device *dev = &vg->pdev->dev; |
---|
| 1475 | + struct intel_pinctrl *vg = gpiochip_get_data(chip); |
---|
1694 | 1476 | void __iomem *reg; |
---|
1695 | | - u32 base, value; |
---|
| 1477 | + u32 value; |
---|
1696 | 1478 | int i; |
---|
1697 | 1479 | |
---|
1698 | 1480 | /* |
---|
.. | .. |
---|
1700 | 1482 | * do not use direct IRQ mode. This will prevent spurious |
---|
1701 | 1483 | * interrupts from misconfigured pins. |
---|
1702 | 1484 | */ |
---|
1703 | | - for (i = 0; i < vg->soc_data->npins; i++) { |
---|
1704 | | - unsigned int pin = vg->soc_data->pins[i].number; |
---|
| 1485 | + for (i = 0; i < vg->soc->npins; i++) { |
---|
| 1486 | + unsigned int pin = vg->soc->pins[i].number; |
---|
1705 | 1487 | |
---|
1706 | 1488 | reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG); |
---|
1707 | 1489 | if (!reg) { |
---|
1708 | | - dev_warn(&vg->pdev->dev, |
---|
| 1490 | + dev_warn(vg->dev, |
---|
1709 | 1491 | "Pin %i: could not retrieve conf0 register\n", |
---|
1710 | 1492 | i); |
---|
1711 | 1493 | continue; |
---|
.. | .. |
---|
1713 | 1495 | |
---|
1714 | 1496 | value = readl(reg); |
---|
1715 | 1497 | if (value & BYT_DIRECT_IRQ_EN) { |
---|
1716 | | - clear_bit(i, gc->irq.valid_mask); |
---|
1717 | | - dev_dbg(dev, "excluding GPIO %d from IRQ domain\n", i); |
---|
| 1498 | + clear_bit(i, valid_mask); |
---|
| 1499 | + dev_dbg(vg->dev, "excluding GPIO %d from IRQ domain\n", i); |
---|
1718 | 1500 | } else if ((value & BYT_PIN_MUX) == byt_get_gpio_mux(vg, i)) { |
---|
1719 | 1501 | byt_gpio_clear_triggering(vg, i); |
---|
1720 | | - dev_dbg(dev, "disabling GPIO %d\n", i); |
---|
| 1502 | + dev_dbg(vg->dev, "disabling GPIO %d\n", i); |
---|
1721 | 1503 | } |
---|
1722 | 1504 | } |
---|
| 1505 | +} |
---|
| 1506 | + |
---|
| 1507 | +static int byt_gpio_irq_init_hw(struct gpio_chip *chip) |
---|
| 1508 | +{ |
---|
| 1509 | + struct intel_pinctrl *vg = gpiochip_get_data(chip); |
---|
| 1510 | + void __iomem *reg; |
---|
| 1511 | + u32 base, value; |
---|
1723 | 1512 | |
---|
1724 | 1513 | /* clear interrupt status trigger registers */ |
---|
1725 | | - for (base = 0; base < vg->soc_data->npins; base += 32) { |
---|
| 1514 | + for (base = 0; base < vg->soc->npins; base += 32) { |
---|
1726 | 1515 | reg = byt_gpio_reg(vg, base, BYT_INT_STAT_REG); |
---|
1727 | 1516 | |
---|
1728 | 1517 | if (!reg) { |
---|
1729 | | - dev_warn(&vg->pdev->dev, |
---|
| 1518 | + dev_warn(vg->dev, |
---|
1730 | 1519 | "Pin %i: could not retrieve irq status reg\n", |
---|
1731 | 1520 | base); |
---|
1732 | 1521 | continue; |
---|
.. | .. |
---|
1737 | 1526 | might be misconfigured in bios */ |
---|
1738 | 1527 | value = readl(reg); |
---|
1739 | 1528 | if (value) |
---|
1740 | | - dev_err(&vg->pdev->dev, |
---|
| 1529 | + dev_err(vg->dev, |
---|
1741 | 1530 | "GPIO interrupt error, pins misconfigured. INT_STAT%u: 0x%08x\n", |
---|
1742 | 1531 | base / 32, value); |
---|
1743 | 1532 | } |
---|
| 1533 | + |
---|
| 1534 | + return 0; |
---|
1744 | 1535 | } |
---|
1745 | 1536 | |
---|
1746 | | -static int byt_gpio_probe(struct byt_gpio *vg) |
---|
| 1537 | +static int byt_gpio_add_pin_ranges(struct gpio_chip *chip) |
---|
1747 | 1538 | { |
---|
1748 | | - struct gpio_chip *gc; |
---|
1749 | | - struct resource *irq_rc; |
---|
| 1539 | + struct intel_pinctrl *vg = gpiochip_get_data(chip); |
---|
| 1540 | + struct device *dev = vg->dev; |
---|
1750 | 1541 | int ret; |
---|
| 1542 | + |
---|
| 1543 | + ret = gpiochip_add_pin_range(chip, dev_name(dev), 0, 0, vg->soc->npins); |
---|
| 1544 | + if (ret) |
---|
| 1545 | + dev_err(dev, "failed to add GPIO pin range\n"); |
---|
| 1546 | + |
---|
| 1547 | + return ret; |
---|
| 1548 | +} |
---|
| 1549 | + |
---|
| 1550 | +static int byt_gpio_probe(struct intel_pinctrl *vg) |
---|
| 1551 | +{ |
---|
| 1552 | + struct platform_device *pdev = to_platform_device(vg->dev); |
---|
| 1553 | + struct gpio_chip *gc; |
---|
| 1554 | + int irq, ret; |
---|
1751 | 1555 | |
---|
1752 | 1556 | /* Set up gpio chip */ |
---|
1753 | 1557 | vg->chip = byt_gpio_chip; |
---|
1754 | 1558 | gc = &vg->chip; |
---|
1755 | | - gc->label = dev_name(&vg->pdev->dev); |
---|
| 1559 | + gc->label = dev_name(vg->dev); |
---|
1756 | 1560 | gc->base = -1; |
---|
1757 | 1561 | gc->can_sleep = false; |
---|
1758 | | - gc->parent = &vg->pdev->dev; |
---|
1759 | | - gc->ngpio = vg->soc_data->npins; |
---|
1760 | | - gc->irq.need_valid_mask = true; |
---|
| 1562 | + gc->add_pin_ranges = byt_gpio_add_pin_ranges; |
---|
| 1563 | + gc->parent = vg->dev; |
---|
| 1564 | + gc->ngpio = vg->soc->npins; |
---|
1761 | 1565 | |
---|
1762 | 1566 | #ifdef CONFIG_PM_SLEEP |
---|
1763 | | - vg->saved_context = devm_kcalloc(&vg->pdev->dev, gc->ngpio, |
---|
1764 | | - sizeof(*vg->saved_context), GFP_KERNEL); |
---|
| 1567 | + vg->context.pads = devm_kcalloc(vg->dev, gc->ngpio, sizeof(*vg->context.pads), |
---|
| 1568 | + GFP_KERNEL); |
---|
| 1569 | + if (!vg->context.pads) |
---|
| 1570 | + return -ENOMEM; |
---|
1765 | 1571 | #endif |
---|
1766 | | - ret = devm_gpiochip_add_data(&vg->pdev->dev, gc, vg); |
---|
1767 | | - if (ret) { |
---|
1768 | | - dev_err(&vg->pdev->dev, "failed adding byt-gpio chip\n"); |
---|
1769 | | - return ret; |
---|
1770 | | - } |
---|
1771 | | - |
---|
1772 | | - ret = gpiochip_add_pin_range(&vg->chip, dev_name(&vg->pdev->dev), |
---|
1773 | | - 0, 0, vg->soc_data->npins); |
---|
1774 | | - if (ret) { |
---|
1775 | | - dev_err(&vg->pdev->dev, "failed to add GPIO pin range\n"); |
---|
1776 | | - return ret; |
---|
1777 | | - } |
---|
1778 | 1572 | |
---|
1779 | 1573 | /* set up interrupts */ |
---|
1780 | | - irq_rc = platform_get_resource(vg->pdev, IORESOURCE_IRQ, 0); |
---|
1781 | | - if (irq_rc && irq_rc->start) { |
---|
1782 | | - byt_gpio_irq_init_hw(vg); |
---|
1783 | | - ret = gpiochip_irqchip_add(gc, &byt_irqchip, 0, |
---|
1784 | | - handle_bad_irq, IRQ_TYPE_NONE); |
---|
1785 | | - if (ret) { |
---|
1786 | | - dev_err(&vg->pdev->dev, "failed to add irqchip\n"); |
---|
1787 | | - return ret; |
---|
1788 | | - } |
---|
| 1574 | + irq = platform_get_irq_optional(pdev, 0); |
---|
| 1575 | + if (irq > 0) { |
---|
| 1576 | + struct gpio_irq_chip *girq; |
---|
1789 | 1577 | |
---|
1790 | | - gpiochip_set_chained_irqchip(gc, &byt_irqchip, |
---|
1791 | | - (unsigned)irq_rc->start, |
---|
1792 | | - byt_gpio_irq_handler); |
---|
| 1578 | + vg->irqchip.name = "BYT-GPIO", |
---|
| 1579 | + vg->irqchip.irq_ack = byt_irq_ack, |
---|
| 1580 | + vg->irqchip.irq_mask = byt_irq_mask, |
---|
| 1581 | + vg->irqchip.irq_unmask = byt_irq_unmask, |
---|
| 1582 | + vg->irqchip.irq_set_type = byt_irq_type, |
---|
| 1583 | + vg->irqchip.flags = IRQCHIP_SKIP_SET_WAKE, |
---|
| 1584 | + |
---|
| 1585 | + girq = &gc->irq; |
---|
| 1586 | + girq->chip = &vg->irqchip; |
---|
| 1587 | + girq->init_hw = byt_gpio_irq_init_hw; |
---|
| 1588 | + girq->init_valid_mask = byt_init_irq_valid_mask; |
---|
| 1589 | + girq->parent_handler = byt_gpio_irq_handler; |
---|
| 1590 | + girq->num_parents = 1; |
---|
| 1591 | + girq->parents = devm_kcalloc(vg->dev, girq->num_parents, |
---|
| 1592 | + sizeof(*girq->parents), GFP_KERNEL); |
---|
| 1593 | + if (!girq->parents) |
---|
| 1594 | + return -ENOMEM; |
---|
| 1595 | + girq->parents[0] = irq; |
---|
| 1596 | + girq->default_type = IRQ_TYPE_NONE; |
---|
| 1597 | + girq->handler = handle_bad_irq; |
---|
| 1598 | + } |
---|
| 1599 | + |
---|
| 1600 | + ret = devm_gpiochip_add_data(vg->dev, gc, vg); |
---|
| 1601 | + if (ret) { |
---|
| 1602 | + dev_err(vg->dev, "failed adding byt-gpio chip\n"); |
---|
| 1603 | + return ret; |
---|
1793 | 1604 | } |
---|
1794 | 1605 | |
---|
1795 | 1606 | return ret; |
---|
1796 | 1607 | } |
---|
1797 | 1608 | |
---|
1798 | | -static int byt_set_soc_data(struct byt_gpio *vg, |
---|
1799 | | - const struct byt_pinctrl_soc_data *soc_data) |
---|
| 1609 | +static int byt_set_soc_data(struct intel_pinctrl *vg, |
---|
| 1610 | + const struct intel_pinctrl_soc_data *soc) |
---|
1800 | 1611 | { |
---|
| 1612 | + struct platform_device *pdev = to_platform_device(vg->dev); |
---|
1801 | 1613 | int i; |
---|
1802 | 1614 | |
---|
1803 | | - vg->soc_data = soc_data; |
---|
1804 | | - vg->communities_copy = devm_kcalloc(&vg->pdev->dev, |
---|
1805 | | - soc_data->ncommunities, |
---|
1806 | | - sizeof(*vg->communities_copy), |
---|
1807 | | - GFP_KERNEL); |
---|
1808 | | - if (!vg->communities_copy) |
---|
| 1615 | + vg->soc = soc; |
---|
| 1616 | + |
---|
| 1617 | + vg->ncommunities = vg->soc->ncommunities; |
---|
| 1618 | + vg->communities = devm_kcalloc(vg->dev, vg->ncommunities, |
---|
| 1619 | + sizeof(*vg->communities), GFP_KERNEL); |
---|
| 1620 | + if (!vg->communities) |
---|
1809 | 1621 | return -ENOMEM; |
---|
1810 | 1622 | |
---|
1811 | | - for (i = 0; i < soc_data->ncommunities; i++) { |
---|
1812 | | - struct byt_community *comm = vg->communities_copy + i; |
---|
1813 | | - struct resource *mem_rc; |
---|
| 1623 | + for (i = 0; i < vg->soc->ncommunities; i++) { |
---|
| 1624 | + struct intel_community *comm = vg->communities + i; |
---|
1814 | 1625 | |
---|
1815 | | - *comm = vg->soc_data->communities[i]; |
---|
| 1626 | + *comm = vg->soc->communities[i]; |
---|
1816 | 1627 | |
---|
1817 | | - mem_rc = platform_get_resource(vg->pdev, IORESOURCE_MEM, 0); |
---|
1818 | | - comm->reg_base = devm_ioremap_resource(&vg->pdev->dev, mem_rc); |
---|
1819 | | - if (IS_ERR(comm->reg_base)) |
---|
1820 | | - return PTR_ERR(comm->reg_base); |
---|
| 1628 | + comm->pad_regs = devm_platform_ioremap_resource(pdev, 0); |
---|
| 1629 | + if (IS_ERR(comm->pad_regs)) |
---|
| 1630 | + return PTR_ERR(comm->pad_regs); |
---|
1821 | 1631 | } |
---|
1822 | 1632 | |
---|
1823 | 1633 | return 0; |
---|
.. | .. |
---|
1828 | 1638 | { "INT33FC", (kernel_ulong_t)byt_soc_data }, |
---|
1829 | 1639 | { } |
---|
1830 | 1640 | }; |
---|
1831 | | -MODULE_DEVICE_TABLE(acpi, byt_gpio_acpi_match); |
---|
1832 | 1641 | |
---|
1833 | 1642 | static int byt_pinctrl_probe(struct platform_device *pdev) |
---|
1834 | 1643 | { |
---|
1835 | | - const struct byt_pinctrl_soc_data *soc_data = NULL; |
---|
1836 | | - const struct byt_pinctrl_soc_data **soc_table; |
---|
1837 | | - const struct acpi_device_id *acpi_id; |
---|
1838 | | - struct acpi_device *acpi_dev; |
---|
1839 | | - struct byt_gpio *vg; |
---|
1840 | | - int i, ret; |
---|
| 1644 | + const struct intel_pinctrl_soc_data *soc_data; |
---|
| 1645 | + struct device *dev = &pdev->dev; |
---|
| 1646 | + struct intel_pinctrl *vg; |
---|
| 1647 | + int ret; |
---|
1841 | 1648 | |
---|
1842 | | - acpi_dev = ACPI_COMPANION(&pdev->dev); |
---|
1843 | | - if (!acpi_dev) |
---|
1844 | | - return -ENODEV; |
---|
| 1649 | + soc_data = intel_pinctrl_get_soc_data(pdev); |
---|
| 1650 | + if (IS_ERR(soc_data)) |
---|
| 1651 | + return PTR_ERR(soc_data); |
---|
1845 | 1652 | |
---|
1846 | | - acpi_id = acpi_match_device(byt_gpio_acpi_match, &pdev->dev); |
---|
1847 | | - if (!acpi_id) |
---|
1848 | | - return -ENODEV; |
---|
1849 | | - |
---|
1850 | | - soc_table = (const struct byt_pinctrl_soc_data **)acpi_id->driver_data; |
---|
1851 | | - |
---|
1852 | | - for (i = 0; soc_table[i]; i++) { |
---|
1853 | | - if (!strcmp(acpi_dev->pnp.unique_id, soc_table[i]->uid)) { |
---|
1854 | | - soc_data = soc_table[i]; |
---|
1855 | | - break; |
---|
1856 | | - } |
---|
1857 | | - } |
---|
1858 | | - |
---|
1859 | | - if (!soc_data) |
---|
1860 | | - return -ENODEV; |
---|
1861 | | - |
---|
1862 | | - vg = devm_kzalloc(&pdev->dev, sizeof(*vg), GFP_KERNEL); |
---|
| 1653 | + vg = devm_kzalloc(dev, sizeof(*vg), GFP_KERNEL); |
---|
1863 | 1654 | if (!vg) |
---|
1864 | 1655 | return -ENOMEM; |
---|
1865 | 1656 | |
---|
1866 | | - vg->pdev = pdev; |
---|
| 1657 | + vg->dev = dev; |
---|
1867 | 1658 | ret = byt_set_soc_data(vg, soc_data); |
---|
1868 | 1659 | if (ret) { |
---|
1869 | | - dev_err(&pdev->dev, "failed to set soc data\n"); |
---|
| 1660 | + dev_err(dev, "failed to set soc data\n"); |
---|
1870 | 1661 | return ret; |
---|
1871 | 1662 | } |
---|
1872 | 1663 | |
---|
1873 | | - vg->pctl_desc = byt_pinctrl_desc; |
---|
1874 | | - vg->pctl_desc.name = dev_name(&pdev->dev); |
---|
1875 | | - vg->pctl_desc.pins = vg->soc_data->pins; |
---|
1876 | | - vg->pctl_desc.npins = vg->soc_data->npins; |
---|
| 1664 | + vg->pctldesc = byt_pinctrl_desc; |
---|
| 1665 | + vg->pctldesc.name = dev_name(dev); |
---|
| 1666 | + vg->pctldesc.pins = vg->soc->pins; |
---|
| 1667 | + vg->pctldesc.npins = vg->soc->npins; |
---|
1877 | 1668 | |
---|
1878 | | - vg->pctl_dev = devm_pinctrl_register(&pdev->dev, &vg->pctl_desc, vg); |
---|
1879 | | - if (IS_ERR(vg->pctl_dev)) { |
---|
1880 | | - dev_err(&pdev->dev, "failed to register pinctrl driver\n"); |
---|
1881 | | - return PTR_ERR(vg->pctl_dev); |
---|
| 1669 | + vg->pctldev = devm_pinctrl_register(dev, &vg->pctldesc, vg); |
---|
| 1670 | + if (IS_ERR(vg->pctldev)) { |
---|
| 1671 | + dev_err(dev, "failed to register pinctrl driver\n"); |
---|
| 1672 | + return PTR_ERR(vg->pctldev); |
---|
1882 | 1673 | } |
---|
1883 | 1674 | |
---|
1884 | 1675 | ret = byt_gpio_probe(vg); |
---|
.. | .. |
---|
1886 | 1677 | return ret; |
---|
1887 | 1678 | |
---|
1888 | 1679 | platform_set_drvdata(pdev, vg); |
---|
1889 | | - pm_runtime_enable(&pdev->dev); |
---|
| 1680 | + pm_runtime_enable(dev); |
---|
1890 | 1681 | |
---|
1891 | 1682 | return 0; |
---|
1892 | 1683 | } |
---|
.. | .. |
---|
1894 | 1685 | #ifdef CONFIG_PM_SLEEP |
---|
1895 | 1686 | static int byt_gpio_suspend(struct device *dev) |
---|
1896 | 1687 | { |
---|
1897 | | - struct platform_device *pdev = to_platform_device(dev); |
---|
1898 | | - struct byt_gpio *vg = platform_get_drvdata(pdev); |
---|
| 1688 | + struct intel_pinctrl *vg = dev_get_drvdata(dev); |
---|
1899 | 1689 | unsigned long flags; |
---|
1900 | 1690 | int i; |
---|
1901 | 1691 | |
---|
1902 | 1692 | raw_spin_lock_irqsave(&byt_lock, flags); |
---|
1903 | 1693 | |
---|
1904 | | - for (i = 0; i < vg->soc_data->npins; i++) { |
---|
| 1694 | + for (i = 0; i < vg->soc->npins; i++) { |
---|
1905 | 1695 | void __iomem *reg; |
---|
1906 | 1696 | u32 value; |
---|
1907 | | - unsigned int pin = vg->soc_data->pins[i].number; |
---|
| 1697 | + unsigned int pin = vg->soc->pins[i].number; |
---|
1908 | 1698 | |
---|
1909 | 1699 | reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG); |
---|
1910 | 1700 | if (!reg) { |
---|
1911 | | - dev_warn(&vg->pdev->dev, |
---|
| 1701 | + dev_warn(vg->dev, |
---|
1912 | 1702 | "Pin %i: could not retrieve conf0 register\n", |
---|
1913 | 1703 | i); |
---|
1914 | 1704 | continue; |
---|
1915 | 1705 | } |
---|
1916 | 1706 | value = readl(reg) & BYT_CONF0_RESTORE_MASK; |
---|
1917 | | - vg->saved_context[i].conf0 = value; |
---|
| 1707 | + vg->context.pads[i].conf0 = value; |
---|
1918 | 1708 | |
---|
1919 | 1709 | reg = byt_gpio_reg(vg, pin, BYT_VAL_REG); |
---|
1920 | 1710 | value = readl(reg) & BYT_VAL_RESTORE_MASK; |
---|
1921 | | - vg->saved_context[i].val = value; |
---|
| 1711 | + vg->context.pads[i].val = value; |
---|
1922 | 1712 | } |
---|
1923 | 1713 | |
---|
1924 | 1714 | raw_spin_unlock_irqrestore(&byt_lock, flags); |
---|
.. | .. |
---|
1927 | 1717 | |
---|
1928 | 1718 | static int byt_gpio_resume(struct device *dev) |
---|
1929 | 1719 | { |
---|
1930 | | - struct platform_device *pdev = to_platform_device(dev); |
---|
1931 | | - struct byt_gpio *vg = platform_get_drvdata(pdev); |
---|
| 1720 | + struct intel_pinctrl *vg = dev_get_drvdata(dev); |
---|
1932 | 1721 | unsigned long flags; |
---|
1933 | 1722 | int i; |
---|
1934 | 1723 | |
---|
1935 | 1724 | raw_spin_lock_irqsave(&byt_lock, flags); |
---|
1936 | 1725 | |
---|
1937 | | - for (i = 0; i < vg->soc_data->npins; i++) { |
---|
| 1726 | + for (i = 0; i < vg->soc->npins; i++) { |
---|
1938 | 1727 | void __iomem *reg; |
---|
1939 | 1728 | u32 value; |
---|
1940 | | - unsigned int pin = vg->soc_data->pins[i].number; |
---|
| 1729 | + unsigned int pin = vg->soc->pins[i].number; |
---|
1941 | 1730 | |
---|
1942 | 1731 | reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG); |
---|
1943 | 1732 | if (!reg) { |
---|
1944 | | - dev_warn(&vg->pdev->dev, |
---|
| 1733 | + dev_warn(vg->dev, |
---|
1945 | 1734 | "Pin %i: could not retrieve conf0 register\n", |
---|
1946 | 1735 | i); |
---|
1947 | 1736 | continue; |
---|
1948 | 1737 | } |
---|
1949 | 1738 | value = readl(reg); |
---|
1950 | 1739 | if ((value & BYT_CONF0_RESTORE_MASK) != |
---|
1951 | | - vg->saved_context[i].conf0) { |
---|
| 1740 | + vg->context.pads[i].conf0) { |
---|
1952 | 1741 | value &= ~BYT_CONF0_RESTORE_MASK; |
---|
1953 | | - value |= vg->saved_context[i].conf0; |
---|
| 1742 | + value |= vg->context.pads[i].conf0; |
---|
1954 | 1743 | writel(value, reg); |
---|
1955 | 1744 | dev_info(dev, "restored pin %d conf0 %#08x", i, value); |
---|
1956 | 1745 | } |
---|
.. | .. |
---|
1958 | 1747 | reg = byt_gpio_reg(vg, pin, BYT_VAL_REG); |
---|
1959 | 1748 | value = readl(reg); |
---|
1960 | 1749 | if ((value & BYT_VAL_RESTORE_MASK) != |
---|
1961 | | - vg->saved_context[i].val) { |
---|
| 1750 | + vg->context.pads[i].val) { |
---|
1962 | 1751 | u32 v; |
---|
1963 | 1752 | |
---|
1964 | 1753 | v = value & ~BYT_VAL_RESTORE_MASK; |
---|
1965 | | - v |= vg->saved_context[i].val; |
---|
| 1754 | + v |= vg->context.pads[i].val; |
---|
1966 | 1755 | if (v != value) { |
---|
1967 | 1756 | writel(v, reg); |
---|
1968 | 1757 | dev_dbg(dev, "restored pin %d val %#08x\n", |
---|
.. | .. |
---|
1999 | 1788 | .driver = { |
---|
2000 | 1789 | .name = "byt_gpio", |
---|
2001 | 1790 | .pm = &byt_gpio_pm_ops, |
---|
| 1791 | + .acpi_match_table = byt_gpio_acpi_match, |
---|
2002 | 1792 | .suppress_bind_attrs = true, |
---|
2003 | | - |
---|
2004 | | - .acpi_match_table = ACPI_PTR(byt_gpio_acpi_match), |
---|
2005 | 1793 | }, |
---|
2006 | 1794 | }; |
---|
2007 | 1795 | |
---|