1 // SPDX-License-Identifier: GPL-2.0
3 * Intel pinctrl/GPIO core driver.
5 * Copyright (C) 2015, Intel Corporation
6 * Authors: Mathias Nyman <mathias.nyman@linux.intel.com>
7 * Mika Westerberg <mika.westerberg@linux.intel.com>
10 #include <linux/module.h>
11 #include <linux/interrupt.h>
12 #include <linux/gpio/driver.h>
13 #include <linux/log2.h>
14 #include <linux/platform_device.h>
15 #include <linux/pinctrl/pinctrl.h>
16 #include <linux/pinctrl/pinmux.h>
17 #include <linux/pinctrl/pinconf.h>
18 #include <linux/pinctrl/pinconf-generic.h>
21 #include "pinctrl-intel.h"
23 /* Offset from regs */
25 #define REVID_SHIFT 16
26 #define REVID_MASK GENMASK(31, 16)
32 #define PADOWN_SHIFT(p) ((p) % 8 * PADOWN_BITS)
33 #define PADOWN_MASK(p) (0xf << PADOWN_SHIFT(p))
34 #define PADOWN_GPP(p) ((p) / 8)
36 /* Offset from pad_regs */
38 #define PADCFG0_RXEVCFG_SHIFT 25
39 #define PADCFG0_RXEVCFG_MASK (3 << PADCFG0_RXEVCFG_SHIFT)
40 #define PADCFG0_RXEVCFG_LEVEL 0
41 #define PADCFG0_RXEVCFG_EDGE 1
42 #define PADCFG0_RXEVCFG_DISABLED 2
43 #define PADCFG0_RXEVCFG_EDGE_BOTH 3
44 #define PADCFG0_PREGFRXSEL BIT(24)
45 #define PADCFG0_RXINV BIT(23)
46 #define PADCFG0_GPIROUTIOXAPIC BIT(20)
47 #define PADCFG0_GPIROUTSCI BIT(19)
48 #define PADCFG0_GPIROUTSMI BIT(18)
49 #define PADCFG0_GPIROUTNMI BIT(17)
50 #define PADCFG0_PMODE_SHIFT 10
51 #define PADCFG0_PMODE_MASK (0xf << PADCFG0_PMODE_SHIFT)
52 #define PADCFG0_PMODE_GPIO 0
53 #define PADCFG0_GPIORXDIS BIT(9)
54 #define PADCFG0_GPIOTXDIS BIT(8)
55 #define PADCFG0_GPIORXSTATE BIT(1)
56 #define PADCFG0_GPIOTXSTATE BIT(0)
59 #define PADCFG1_TERM_UP BIT(13)
60 #define PADCFG1_TERM_SHIFT 10
61 #define PADCFG1_TERM_MASK (7 << PADCFG1_TERM_SHIFT)
62 #define PADCFG1_TERM_20K 4
63 #define PADCFG1_TERM_2K 3
64 #define PADCFG1_TERM_5K 2
65 #define PADCFG1_TERM_1K 1
68 #define PADCFG2_DEBEN BIT(0)
69 #define PADCFG2_DEBOUNCE_SHIFT 1
70 #define PADCFG2_DEBOUNCE_MASK GENMASK(4, 1)
72 #define DEBOUNCE_PERIOD 31250 /* ns */
74 struct intel_pad_context
{
80 struct intel_community_context
{
84 struct intel_pinctrl_context
{
85 struct intel_pad_context
*pads
;
86 struct intel_community_context
*communities
;
90 * struct intel_pinctrl - Intel pinctrl private structure
91 * @dev: Pointer to the device structure
92 * @lock: Lock to serialize register access
93 * @pctldesc: Pin controller description
94 * @pctldev: Pointer to the pin controller device
95 * @chip: GPIO chip in this pin controller
96 * @soc: SoC/PCH specific pin configuration data
97 * @communities: All communities in this pin controller
98 * @ncommunities: Number of communities in this pin controller
99 * @context: Configuration saved over system sleep
100 * @irq: pinctrl/GPIO chip irq number
102 struct intel_pinctrl
{
105 struct pinctrl_desc pctldesc
;
106 struct pinctrl_dev
*pctldev
;
107 struct gpio_chip chip
;
108 const struct intel_pinctrl_soc_data
*soc
;
109 struct intel_community
*communities
;
111 struct intel_pinctrl_context context
;
115 #define pin_to_padno(c, p) ((p) - (c)->pin_base)
116 #define padgroup_offset(g, p) ((p) - (g)->base)
118 static struct intel_community
*intel_get_community(struct intel_pinctrl
*pctrl
,
121 struct intel_community
*community
;
124 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
125 community
= &pctrl
->communities
[i
];
126 if (pin
>= community
->pin_base
&&
127 pin
< community
->pin_base
+ community
->npins
)
131 dev_warn(pctrl
->dev
, "failed to find community for pin %u\n", pin
);
135 static const struct intel_padgroup
*
136 intel_community_get_padgroup(const struct intel_community
*community
,
141 for (i
= 0; i
< community
->ngpps
; i
++) {
142 const struct intel_padgroup
*padgrp
= &community
->gpps
[i
];
144 if (pin
>= padgrp
->base
&& pin
< padgrp
->base
+ padgrp
->size
)
151 static void __iomem
*intel_get_padcfg(struct intel_pinctrl
*pctrl
, unsigned pin
,
154 const struct intel_community
*community
;
158 community
= intel_get_community(pctrl
, pin
);
162 padno
= pin_to_padno(community
, pin
);
163 nregs
= (community
->features
& PINCTRL_FEATURE_DEBOUNCE
) ? 4 : 2;
165 if (reg
== PADCFG2
&& !(community
->features
& PINCTRL_FEATURE_DEBOUNCE
))
168 return community
->pad_regs
+ reg
+ padno
* nregs
* 4;
171 static bool intel_pad_owned_by_host(struct intel_pinctrl
*pctrl
, unsigned pin
)
173 const struct intel_community
*community
;
174 const struct intel_padgroup
*padgrp
;
175 unsigned gpp
, offset
, gpp_offset
;
176 void __iomem
*padown
;
178 community
= intel_get_community(pctrl
, pin
);
181 if (!community
->padown_offset
)
184 padgrp
= intel_community_get_padgroup(community
, pin
);
188 gpp_offset
= padgroup_offset(padgrp
, pin
);
189 gpp
= PADOWN_GPP(gpp_offset
);
190 offset
= community
->padown_offset
+ padgrp
->padown_num
* 4 + gpp
* 4;
191 padown
= community
->regs
+ offset
;
193 return !(readl(padown
) & PADOWN_MASK(gpp_offset
));
196 static bool intel_pad_acpi_mode(struct intel_pinctrl
*pctrl
, unsigned pin
)
198 const struct intel_community
*community
;
199 const struct intel_padgroup
*padgrp
;
200 unsigned offset
, gpp_offset
;
201 void __iomem
*hostown
;
203 community
= intel_get_community(pctrl
, pin
);
206 if (!community
->hostown_offset
)
209 padgrp
= intel_community_get_padgroup(community
, pin
);
213 gpp_offset
= padgroup_offset(padgrp
, pin
);
214 offset
= community
->hostown_offset
+ padgrp
->reg_num
* 4;
215 hostown
= community
->regs
+ offset
;
217 return !(readl(hostown
) & BIT(gpp_offset
));
220 static bool intel_pad_locked(struct intel_pinctrl
*pctrl
, unsigned pin
)
222 struct intel_community
*community
;
223 const struct intel_padgroup
*padgrp
;
224 unsigned offset
, gpp_offset
;
227 community
= intel_get_community(pctrl
, pin
);
230 if (!community
->padcfglock_offset
)
233 padgrp
= intel_community_get_padgroup(community
, pin
);
237 gpp_offset
= padgroup_offset(padgrp
, pin
);
240 * If PADCFGLOCK and PADCFGLOCKTX bits are both clear for this pad,
241 * the pad is considered unlocked. Any other case means that it is
242 * either fully or partially locked and we don't touch it.
244 offset
= community
->padcfglock_offset
+ padgrp
->reg_num
* 8;
245 value
= readl(community
->regs
+ offset
);
246 if (value
& BIT(gpp_offset
))
249 offset
= community
->padcfglock_offset
+ 4 + padgrp
->reg_num
* 8;
250 value
= readl(community
->regs
+ offset
);
251 if (value
& BIT(gpp_offset
))
257 static bool intel_pad_usable(struct intel_pinctrl
*pctrl
, unsigned pin
)
259 return intel_pad_owned_by_host(pctrl
, pin
) &&
260 !intel_pad_locked(pctrl
, pin
);
263 static int intel_get_groups_count(struct pinctrl_dev
*pctldev
)
265 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
267 return pctrl
->soc
->ngroups
;
270 static const char *intel_get_group_name(struct pinctrl_dev
*pctldev
,
273 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
275 return pctrl
->soc
->groups
[group
].name
;
278 static int intel_get_group_pins(struct pinctrl_dev
*pctldev
, unsigned group
,
279 const unsigned **pins
, unsigned *npins
)
281 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
283 *pins
= pctrl
->soc
->groups
[group
].pins
;
284 *npins
= pctrl
->soc
->groups
[group
].npins
;
288 static void intel_pin_dbg_show(struct pinctrl_dev
*pctldev
, struct seq_file
*s
,
291 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
292 void __iomem
*padcfg
;
293 u32 cfg0
, cfg1
, mode
;
296 if (!intel_pad_owned_by_host(pctrl
, pin
)) {
297 seq_puts(s
, "not available");
301 cfg0
= readl(intel_get_padcfg(pctrl
, pin
, PADCFG0
));
302 cfg1
= readl(intel_get_padcfg(pctrl
, pin
, PADCFG1
));
304 mode
= (cfg0
& PADCFG0_PMODE_MASK
) >> PADCFG0_PMODE_SHIFT
;
305 if (mode
== PADCFG0_PMODE_GPIO
)
306 seq_puts(s
, "GPIO ");
308 seq_printf(s
, "mode %d ", mode
);
310 seq_printf(s
, "0x%08x 0x%08x", cfg0
, cfg1
);
312 /* Dump the additional PADCFG registers if available */
313 padcfg
= intel_get_padcfg(pctrl
, pin
, PADCFG2
);
315 seq_printf(s
, " 0x%08x", readl(padcfg
));
317 locked
= intel_pad_locked(pctrl
, pin
);
318 acpi
= intel_pad_acpi_mode(pctrl
, pin
);
320 if (locked
|| acpi
) {
323 seq_puts(s
, "LOCKED");
333 static const struct pinctrl_ops intel_pinctrl_ops
= {
334 .get_groups_count
= intel_get_groups_count
,
335 .get_group_name
= intel_get_group_name
,
336 .get_group_pins
= intel_get_group_pins
,
337 .pin_dbg_show
= intel_pin_dbg_show
,
340 static int intel_get_functions_count(struct pinctrl_dev
*pctldev
)
342 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
344 return pctrl
->soc
->nfunctions
;
347 static const char *intel_get_function_name(struct pinctrl_dev
*pctldev
,
350 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
352 return pctrl
->soc
->functions
[function
].name
;
355 static int intel_get_function_groups(struct pinctrl_dev
*pctldev
,
357 const char * const **groups
,
358 unsigned * const ngroups
)
360 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
362 *groups
= pctrl
->soc
->functions
[function
].groups
;
363 *ngroups
= pctrl
->soc
->functions
[function
].ngroups
;
367 static int intel_pinmux_set_mux(struct pinctrl_dev
*pctldev
, unsigned function
,
370 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
371 const struct intel_pingroup
*grp
= &pctrl
->soc
->groups
[group
];
375 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
378 * All pins in the groups needs to be accessible and writable
379 * before we can enable the mux for this group.
381 for (i
= 0; i
< grp
->npins
; i
++) {
382 if (!intel_pad_usable(pctrl
, grp
->pins
[i
])) {
383 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
388 /* Now enable the mux setting for each pin in the group */
389 for (i
= 0; i
< grp
->npins
; i
++) {
390 void __iomem
*padcfg0
;
393 padcfg0
= intel_get_padcfg(pctrl
, grp
->pins
[i
], PADCFG0
);
394 value
= readl(padcfg0
);
396 value
&= ~PADCFG0_PMODE_MASK
;
399 value
|= grp
->modes
[i
] << PADCFG0_PMODE_SHIFT
;
401 value
|= grp
->mode
<< PADCFG0_PMODE_SHIFT
;
403 writel(value
, padcfg0
);
406 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
411 static void __intel_gpio_set_direction(void __iomem
*padcfg0
, bool input
)
415 value
= readl(padcfg0
);
417 value
&= ~PADCFG0_GPIORXDIS
;
418 value
|= PADCFG0_GPIOTXDIS
;
420 value
&= ~PADCFG0_GPIOTXDIS
;
421 value
|= PADCFG0_GPIORXDIS
;
423 writel(value
, padcfg0
);
426 static int intel_gpio_get_gpio_mode(void __iomem
*padcfg0
)
428 return (readl(padcfg0
) & PADCFG0_PMODE_MASK
) >> PADCFG0_PMODE_SHIFT
;
431 static void intel_gpio_set_gpio_mode(void __iomem
*padcfg0
)
435 /* Put the pad into GPIO mode */
436 value
= readl(padcfg0
) & ~PADCFG0_PMODE_MASK
;
437 /* Disable SCI/SMI/NMI generation */
438 value
&= ~(PADCFG0_GPIROUTIOXAPIC
| PADCFG0_GPIROUTSCI
);
439 value
&= ~(PADCFG0_GPIROUTSMI
| PADCFG0_GPIROUTNMI
);
440 writel(value
, padcfg0
);
443 static int intel_gpio_request_enable(struct pinctrl_dev
*pctldev
,
444 struct pinctrl_gpio_range
*range
,
447 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
448 void __iomem
*padcfg0
;
451 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
453 if (!intel_pad_usable(pctrl
, pin
)) {
454 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
458 padcfg0
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
461 * If pin is already configured in GPIO mode, we assume that
462 * firmware provides correct settings. In such case we avoid
463 * potential glitches on the pin. Otherwise, for the pin in
464 * alternative mode, consumer has to supply respective flags.
466 if (intel_gpio_get_gpio_mode(padcfg0
) == PADCFG0_PMODE_GPIO
) {
467 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
471 intel_gpio_set_gpio_mode(padcfg0
);
473 /* Disable TX buffer and enable RX (this will be input) */
474 __intel_gpio_set_direction(padcfg0
, true);
476 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
481 static int intel_gpio_set_direction(struct pinctrl_dev
*pctldev
,
482 struct pinctrl_gpio_range
*range
,
483 unsigned pin
, bool input
)
485 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
486 void __iomem
*padcfg0
;
489 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
491 padcfg0
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
492 __intel_gpio_set_direction(padcfg0
, input
);
494 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
499 static const struct pinmux_ops intel_pinmux_ops
= {
500 .get_functions_count
= intel_get_functions_count
,
501 .get_function_name
= intel_get_function_name
,
502 .get_function_groups
= intel_get_function_groups
,
503 .set_mux
= intel_pinmux_set_mux
,
504 .gpio_request_enable
= intel_gpio_request_enable
,
505 .gpio_set_direction
= intel_gpio_set_direction
,
508 static int intel_config_get(struct pinctrl_dev
*pctldev
, unsigned pin
,
509 unsigned long *config
)
511 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
512 enum pin_config_param param
= pinconf_to_config_param(*config
);
513 const struct intel_community
*community
;
517 if (!intel_pad_owned_by_host(pctrl
, pin
))
520 community
= intel_get_community(pctrl
, pin
);
521 value
= readl(intel_get_padcfg(pctrl
, pin
, PADCFG1
));
522 term
= (value
& PADCFG1_TERM_MASK
) >> PADCFG1_TERM_SHIFT
;
525 case PIN_CONFIG_BIAS_DISABLE
:
530 case PIN_CONFIG_BIAS_PULL_UP
:
531 if (!term
|| !(value
& PADCFG1_TERM_UP
))
535 case PADCFG1_TERM_1K
:
538 case PADCFG1_TERM_2K
:
541 case PADCFG1_TERM_5K
:
544 case PADCFG1_TERM_20K
:
551 case PIN_CONFIG_BIAS_PULL_DOWN
:
552 if (!term
|| value
& PADCFG1_TERM_UP
)
556 case PADCFG1_TERM_1K
:
557 if (!(community
->features
& PINCTRL_FEATURE_1K_PD
))
561 case PADCFG1_TERM_5K
:
564 case PADCFG1_TERM_20K
:
571 case PIN_CONFIG_INPUT_DEBOUNCE
: {
572 void __iomem
*padcfg2
;
575 padcfg2
= intel_get_padcfg(pctrl
, pin
, PADCFG2
);
580 if (!(v
& PADCFG2_DEBEN
))
583 v
= (v
& PADCFG2_DEBOUNCE_MASK
) >> PADCFG2_DEBOUNCE_SHIFT
;
584 arg
= BIT(v
) * DEBOUNCE_PERIOD
/ 1000;
593 *config
= pinconf_to_config_packed(param
, arg
);
597 static int intel_config_set_pull(struct intel_pinctrl
*pctrl
, unsigned pin
,
598 unsigned long config
)
600 unsigned param
= pinconf_to_config_param(config
);
601 unsigned arg
= pinconf_to_config_argument(config
);
602 const struct intel_community
*community
;
603 void __iomem
*padcfg1
;
608 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
610 community
= intel_get_community(pctrl
, pin
);
611 padcfg1
= intel_get_padcfg(pctrl
, pin
, PADCFG1
);
612 value
= readl(padcfg1
);
615 case PIN_CONFIG_BIAS_DISABLE
:
616 value
&= ~(PADCFG1_TERM_MASK
| PADCFG1_TERM_UP
);
619 case PIN_CONFIG_BIAS_PULL_UP
:
620 value
&= ~PADCFG1_TERM_MASK
;
622 value
|= PADCFG1_TERM_UP
;
626 value
|= PADCFG1_TERM_20K
<< PADCFG1_TERM_SHIFT
;
629 value
|= PADCFG1_TERM_5K
<< PADCFG1_TERM_SHIFT
;
632 value
|= PADCFG1_TERM_2K
<< PADCFG1_TERM_SHIFT
;
635 value
|= PADCFG1_TERM_1K
<< PADCFG1_TERM_SHIFT
;
643 case PIN_CONFIG_BIAS_PULL_DOWN
:
644 value
&= ~(PADCFG1_TERM_UP
| PADCFG1_TERM_MASK
);
648 value
|= PADCFG1_TERM_20K
<< PADCFG1_TERM_SHIFT
;
651 value
|= PADCFG1_TERM_5K
<< PADCFG1_TERM_SHIFT
;
654 if (!(community
->features
& PINCTRL_FEATURE_1K_PD
)) {
658 value
|= PADCFG1_TERM_1K
<< PADCFG1_TERM_SHIFT
;
668 writel(value
, padcfg1
);
670 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
675 static int intel_config_set_debounce(struct intel_pinctrl
*pctrl
, unsigned pin
,
678 void __iomem
*padcfg0
, *padcfg2
;
683 padcfg2
= intel_get_padcfg(pctrl
, pin
, PADCFG2
);
687 padcfg0
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
689 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
691 value0
= readl(padcfg0
);
692 value2
= readl(padcfg2
);
694 /* Disable glitch filter and debouncer */
695 value0
&= ~PADCFG0_PREGFRXSEL
;
696 value2
&= ~(PADCFG2_DEBEN
| PADCFG2_DEBOUNCE_MASK
);
701 v
= order_base_2(debounce
* 1000 / DEBOUNCE_PERIOD
);
702 if (v
< 3 || v
> 15) {
706 /* Enable glitch filter and debouncer */
707 value0
|= PADCFG0_PREGFRXSEL
;
708 value2
|= v
<< PADCFG2_DEBOUNCE_SHIFT
;
709 value2
|= PADCFG2_DEBEN
;
713 writel(value0
, padcfg0
);
714 writel(value2
, padcfg2
);
717 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
722 static int intel_config_set(struct pinctrl_dev
*pctldev
, unsigned pin
,
723 unsigned long *configs
, unsigned nconfigs
)
725 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
728 if (!intel_pad_usable(pctrl
, pin
))
731 for (i
= 0; i
< nconfigs
; i
++) {
732 switch (pinconf_to_config_param(configs
[i
])) {
733 case PIN_CONFIG_BIAS_DISABLE
:
734 case PIN_CONFIG_BIAS_PULL_UP
:
735 case PIN_CONFIG_BIAS_PULL_DOWN
:
736 ret
= intel_config_set_pull(pctrl
, pin
, configs
[i
]);
741 case PIN_CONFIG_INPUT_DEBOUNCE
:
742 ret
= intel_config_set_debounce(pctrl
, pin
,
743 pinconf_to_config_argument(configs
[i
]));
756 static const struct pinconf_ops intel_pinconf_ops
= {
758 .pin_config_get
= intel_config_get
,
759 .pin_config_set
= intel_config_set
,
762 static const struct pinctrl_desc intel_pinctrl_desc
= {
763 .pctlops
= &intel_pinctrl_ops
,
764 .pmxops
= &intel_pinmux_ops
,
765 .confops
= &intel_pinconf_ops
,
766 .owner
= THIS_MODULE
,
770 * intel_gpio_to_pin() - Translate from GPIO offset to pin number
771 * @pctrl: Pinctrl structure
772 * @offset: GPIO offset from gpiolib
773 * @commmunity: Community is filled here if not %NULL
774 * @padgrp: Pad group is filled here if not %NULL
776 * When coming through gpiolib irqchip, the GPIO offset is not
777 * automatically translated to pinctrl pin number. This function can be
778 * used to find out the corresponding pinctrl pin.
780 static int intel_gpio_to_pin(struct intel_pinctrl
*pctrl
, unsigned offset
,
781 const struct intel_community
**community
,
782 const struct intel_padgroup
**padgrp
)
786 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
787 const struct intel_community
*comm
= &pctrl
->communities
[i
];
790 for (j
= 0; j
< comm
->ngpps
; j
++) {
791 const struct intel_padgroup
*pgrp
= &comm
->gpps
[j
];
793 if (pgrp
->gpio_base
< 0)
796 if (offset
>= pgrp
->gpio_base
&&
797 offset
< pgrp
->gpio_base
+ pgrp
->size
) {
800 pin
= pgrp
->base
+ offset
- pgrp
->gpio_base
;
814 static int intel_gpio_get(struct gpio_chip
*chip
, unsigned offset
)
816 struct intel_pinctrl
*pctrl
= gpiochip_get_data(chip
);
821 pin
= intel_gpio_to_pin(pctrl
, offset
, NULL
, NULL
);
825 reg
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
829 padcfg0
= readl(reg
);
830 if (!(padcfg0
& PADCFG0_GPIOTXDIS
))
831 return !!(padcfg0
& PADCFG0_GPIOTXSTATE
);
833 return !!(padcfg0
& PADCFG0_GPIORXSTATE
);
836 static void intel_gpio_set(struct gpio_chip
*chip
, unsigned offset
, int value
)
838 struct intel_pinctrl
*pctrl
= gpiochip_get_data(chip
);
844 pin
= intel_gpio_to_pin(pctrl
, offset
, NULL
, NULL
);
848 reg
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
852 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
853 padcfg0
= readl(reg
);
855 padcfg0
|= PADCFG0_GPIOTXSTATE
;
857 padcfg0
&= ~PADCFG0_GPIOTXSTATE
;
858 writel(padcfg0
, reg
);
859 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
862 static int intel_gpio_get_direction(struct gpio_chip
*chip
, unsigned int offset
)
864 struct intel_pinctrl
*pctrl
= gpiochip_get_data(chip
);
869 pin
= intel_gpio_to_pin(pctrl
, offset
, NULL
, NULL
);
873 reg
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
877 padcfg0
= readl(reg
);
879 if (padcfg0
& PADCFG0_PMODE_MASK
)
882 return !!(padcfg0
& PADCFG0_GPIOTXDIS
);
885 static int intel_gpio_direction_input(struct gpio_chip
*chip
, unsigned offset
)
887 return pinctrl_gpio_direction_input(chip
->base
+ offset
);
890 static int intel_gpio_direction_output(struct gpio_chip
*chip
, unsigned offset
,
893 intel_gpio_set(chip
, offset
, value
);
894 return pinctrl_gpio_direction_output(chip
->base
+ offset
);
897 static const struct gpio_chip intel_gpio_chip
= {
898 .owner
= THIS_MODULE
,
899 .request
= gpiochip_generic_request
,
900 .free
= gpiochip_generic_free
,
901 .get_direction
= intel_gpio_get_direction
,
902 .direction_input
= intel_gpio_direction_input
,
903 .direction_output
= intel_gpio_direction_output
,
904 .get
= intel_gpio_get
,
905 .set
= intel_gpio_set
,
906 .set_config
= gpiochip_generic_config
,
909 static void intel_gpio_irq_ack(struct irq_data
*d
)
911 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
912 struct intel_pinctrl
*pctrl
= gpiochip_get_data(gc
);
913 const struct intel_community
*community
;
914 const struct intel_padgroup
*padgrp
;
917 pin
= intel_gpio_to_pin(pctrl
, irqd_to_hwirq(d
), &community
, &padgrp
);
919 unsigned gpp
, gpp_offset
, is_offset
;
921 gpp
= padgrp
->reg_num
;
922 gpp_offset
= padgroup_offset(padgrp
, pin
);
923 is_offset
= community
->is_offset
+ gpp
* 4;
925 raw_spin_lock(&pctrl
->lock
);
926 writel(BIT(gpp_offset
), community
->regs
+ is_offset
);
927 raw_spin_unlock(&pctrl
->lock
);
931 static void intel_gpio_irq_enable(struct irq_data
*d
)
933 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
934 struct intel_pinctrl
*pctrl
= gpiochip_get_data(gc
);
935 const struct intel_community
*community
;
936 const struct intel_padgroup
*padgrp
;
939 pin
= intel_gpio_to_pin(pctrl
, irqd_to_hwirq(d
), &community
, &padgrp
);
941 unsigned gpp
, gpp_offset
, is_offset
;
945 gpp
= padgrp
->reg_num
;
946 gpp_offset
= padgroup_offset(padgrp
, pin
);
947 is_offset
= community
->is_offset
+ gpp
* 4;
949 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
950 /* Clear interrupt status first to avoid unexpected interrupt */
951 writel(BIT(gpp_offset
), community
->regs
+ is_offset
);
953 value
= readl(community
->regs
+ community
->ie_offset
+ gpp
* 4);
954 value
|= BIT(gpp_offset
);
955 writel(value
, community
->regs
+ community
->ie_offset
+ gpp
* 4);
956 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
960 static void intel_gpio_irq_mask_unmask(struct irq_data
*d
, bool mask
)
962 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
963 struct intel_pinctrl
*pctrl
= gpiochip_get_data(gc
);
964 const struct intel_community
*community
;
965 const struct intel_padgroup
*padgrp
;
968 pin
= intel_gpio_to_pin(pctrl
, irqd_to_hwirq(d
), &community
, &padgrp
);
970 unsigned gpp
, gpp_offset
;
975 gpp
= padgrp
->reg_num
;
976 gpp_offset
= padgroup_offset(padgrp
, pin
);
978 reg
= community
->regs
+ community
->ie_offset
+ gpp
* 4;
980 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
983 value
&= ~BIT(gpp_offset
);
985 value
|= BIT(gpp_offset
);
987 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
991 static void intel_gpio_irq_mask(struct irq_data
*d
)
993 intel_gpio_irq_mask_unmask(d
, true);
996 static void intel_gpio_irq_unmask(struct irq_data
*d
)
998 intel_gpio_irq_mask_unmask(d
, false);
1001 static int intel_gpio_irq_type(struct irq_data
*d
, unsigned type
)
1003 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
1004 struct intel_pinctrl
*pctrl
= gpiochip_get_data(gc
);
1005 unsigned pin
= intel_gpio_to_pin(pctrl
, irqd_to_hwirq(d
), NULL
, NULL
);
1006 unsigned long flags
;
1010 reg
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
1015 * If the pin is in ACPI mode it is still usable as a GPIO but it
1016 * cannot be used as IRQ because GPI_IS status bit will not be
1017 * updated by the host controller hardware.
1019 if (intel_pad_acpi_mode(pctrl
, pin
)) {
1020 dev_warn(pctrl
->dev
, "pin %u cannot be used as IRQ\n", pin
);
1024 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
1026 intel_gpio_set_gpio_mode(reg
);
1030 value
&= ~(PADCFG0_RXEVCFG_MASK
| PADCFG0_RXINV
);
1032 if ((type
& IRQ_TYPE_EDGE_BOTH
) == IRQ_TYPE_EDGE_BOTH
) {
1033 value
|= PADCFG0_RXEVCFG_EDGE_BOTH
<< PADCFG0_RXEVCFG_SHIFT
;
1034 } else if (type
& IRQ_TYPE_EDGE_FALLING
) {
1035 value
|= PADCFG0_RXEVCFG_EDGE
<< PADCFG0_RXEVCFG_SHIFT
;
1036 value
|= PADCFG0_RXINV
;
1037 } else if (type
& IRQ_TYPE_EDGE_RISING
) {
1038 value
|= PADCFG0_RXEVCFG_EDGE
<< PADCFG0_RXEVCFG_SHIFT
;
1039 } else if (type
& IRQ_TYPE_LEVEL_MASK
) {
1040 if (type
& IRQ_TYPE_LEVEL_LOW
)
1041 value
|= PADCFG0_RXINV
;
1043 value
|= PADCFG0_RXEVCFG_DISABLED
<< PADCFG0_RXEVCFG_SHIFT
;
1048 if (type
& IRQ_TYPE_EDGE_BOTH
)
1049 irq_set_handler_locked(d
, handle_edge_irq
);
1050 else if (type
& IRQ_TYPE_LEVEL_MASK
)
1051 irq_set_handler_locked(d
, handle_level_irq
);
1053 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
1058 static int intel_gpio_irq_wake(struct irq_data
*d
, unsigned int on
)
1060 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
1061 struct intel_pinctrl
*pctrl
= gpiochip_get_data(gc
);
1062 unsigned pin
= intel_gpio_to_pin(pctrl
, irqd_to_hwirq(d
), NULL
, NULL
);
1065 enable_irq_wake(pctrl
->irq
);
1067 disable_irq_wake(pctrl
->irq
);
1069 dev_dbg(pctrl
->dev
, "%sable wake for pin %u\n", on
? "en" : "dis", pin
);
1073 static irqreturn_t
intel_gpio_community_irq_handler(struct intel_pinctrl
*pctrl
,
1074 const struct intel_community
*community
)
1076 struct gpio_chip
*gc
= &pctrl
->chip
;
1077 irqreturn_t ret
= IRQ_NONE
;
1080 for (gpp
= 0; gpp
< community
->ngpps
; gpp
++) {
1081 const struct intel_padgroup
*padgrp
= &community
->gpps
[gpp
];
1082 unsigned long pending
, enabled
, gpp_offset
;
1084 pending
= readl(community
->regs
+ community
->is_offset
+
1085 padgrp
->reg_num
* 4);
1086 enabled
= readl(community
->regs
+ community
->ie_offset
+
1087 padgrp
->reg_num
* 4);
1089 /* Only interrupts that are enabled */
1092 for_each_set_bit(gpp_offset
, &pending
, padgrp
->size
) {
1095 irq
= irq_find_mapping(gc
->irq
.domain
,
1096 padgrp
->gpio_base
+ gpp_offset
);
1097 generic_handle_irq(irq
);
1106 static irqreturn_t
intel_gpio_irq(int irq
, void *data
)
1108 const struct intel_community
*community
;
1109 struct intel_pinctrl
*pctrl
= data
;
1110 irqreturn_t ret
= IRQ_NONE
;
1113 /* Need to check all communities for pending interrupts */
1114 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1115 community
= &pctrl
->communities
[i
];
1116 ret
|= intel_gpio_community_irq_handler(pctrl
, community
);
1122 static struct irq_chip intel_gpio_irqchip
= {
1123 .name
= "intel-gpio",
1124 .irq_enable
= intel_gpio_irq_enable
,
1125 .irq_ack
= intel_gpio_irq_ack
,
1126 .irq_mask
= intel_gpio_irq_mask
,
1127 .irq_unmask
= intel_gpio_irq_unmask
,
1128 .irq_set_type
= intel_gpio_irq_type
,
1129 .irq_set_wake
= intel_gpio_irq_wake
,
1130 .flags
= IRQCHIP_MASK_ON_SUSPEND
,
1133 static int intel_gpio_add_pin_ranges(struct intel_pinctrl
*pctrl
,
1134 const struct intel_community
*community
)
1138 for (i
= 0; i
< community
->ngpps
; i
++) {
1139 const struct intel_padgroup
*gpp
= &community
->gpps
[i
];
1141 if (gpp
->gpio_base
< 0)
1144 ret
= gpiochip_add_pin_range(&pctrl
->chip
, dev_name(pctrl
->dev
),
1145 gpp
->gpio_base
, gpp
->base
,
1154 static unsigned intel_gpio_ngpio(const struct intel_pinctrl
*pctrl
)
1156 const struct intel_community
*community
;
1160 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1161 community
= &pctrl
->communities
[i
];
1162 for (j
= 0; j
< community
->ngpps
; j
++) {
1163 const struct intel_padgroup
*gpp
= &community
->gpps
[j
];
1165 if (gpp
->gpio_base
< 0)
1168 if (gpp
->gpio_base
+ gpp
->size
> ngpio
)
1169 ngpio
= gpp
->gpio_base
+ gpp
->size
;
1176 static int intel_gpio_probe(struct intel_pinctrl
*pctrl
, int irq
)
1180 pctrl
->chip
= intel_gpio_chip
;
1182 pctrl
->chip
.ngpio
= intel_gpio_ngpio(pctrl
);
1183 pctrl
->chip
.label
= dev_name(pctrl
->dev
);
1184 pctrl
->chip
.parent
= pctrl
->dev
;
1185 pctrl
->chip
.base
= -1;
1188 ret
= devm_gpiochip_add_data(pctrl
->dev
, &pctrl
->chip
, pctrl
);
1190 dev_err(pctrl
->dev
, "failed to register gpiochip\n");
1194 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1195 struct intel_community
*community
= &pctrl
->communities
[i
];
1197 ret
= intel_gpio_add_pin_ranges(pctrl
, community
);
1199 dev_err(pctrl
->dev
, "failed to add GPIO pin range\n");
1205 * We need to request the interrupt here (instead of providing chip
1206 * to the irq directly) because on some platforms several GPIO
1207 * controllers share the same interrupt line.
1209 ret
= devm_request_irq(pctrl
->dev
, irq
, intel_gpio_irq
,
1210 IRQF_SHARED
| IRQF_NO_THREAD
,
1211 dev_name(pctrl
->dev
), pctrl
);
1213 dev_err(pctrl
->dev
, "failed to request interrupt\n");
1217 ret
= gpiochip_irqchip_add(&pctrl
->chip
, &intel_gpio_irqchip
, 0,
1218 handle_bad_irq
, IRQ_TYPE_NONE
);
1220 dev_err(pctrl
->dev
, "failed to add irqchip\n");
1224 gpiochip_set_chained_irqchip(&pctrl
->chip
, &intel_gpio_irqchip
, irq
,
1229 static int intel_pinctrl_add_padgroups(struct intel_pinctrl
*pctrl
,
1230 struct intel_community
*community
)
1232 struct intel_padgroup
*gpps
;
1233 unsigned npins
= community
->npins
;
1234 unsigned padown_num
= 0;
1237 if (community
->gpps
)
1238 ngpps
= community
->ngpps
;
1240 ngpps
= DIV_ROUND_UP(community
->npins
, community
->gpp_size
);
1242 gpps
= devm_kcalloc(pctrl
->dev
, ngpps
, sizeof(*gpps
), GFP_KERNEL
);
1246 for (i
= 0; i
< ngpps
; i
++) {
1247 if (community
->gpps
) {
1248 gpps
[i
] = community
->gpps
[i
];
1250 unsigned gpp_size
= community
->gpp_size
;
1252 gpps
[i
].reg_num
= i
;
1253 gpps
[i
].base
= community
->pin_base
+ i
* gpp_size
;
1254 gpps
[i
].size
= min(gpp_size
, npins
);
1255 npins
-= gpps
[i
].size
;
1258 if (gpps
[i
].size
> 32)
1261 if (!gpps
[i
].gpio_base
)
1262 gpps
[i
].gpio_base
= gpps
[i
].base
;
1264 gpps
[i
].padown_num
= padown_num
;
1267 * In older hardware the number of padown registers per
1268 * group is fixed regardless of the group size.
1270 if (community
->gpp_num_padown_regs
)
1271 padown_num
+= community
->gpp_num_padown_regs
;
1273 padown_num
+= DIV_ROUND_UP(gpps
[i
].size
* 4, 32);
1276 community
->ngpps
= ngpps
;
1277 community
->gpps
= gpps
;
1282 static int intel_pinctrl_pm_init(struct intel_pinctrl
*pctrl
)
1284 #ifdef CONFIG_PM_SLEEP
1285 const struct intel_pinctrl_soc_data
*soc
= pctrl
->soc
;
1286 struct intel_community_context
*communities
;
1287 struct intel_pad_context
*pads
;
1290 pads
= devm_kcalloc(pctrl
->dev
, soc
->npins
, sizeof(*pads
), GFP_KERNEL
);
1294 communities
= devm_kcalloc(pctrl
->dev
, pctrl
->ncommunities
,
1295 sizeof(*communities
), GFP_KERNEL
);
1300 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1301 struct intel_community
*community
= &pctrl
->communities
[i
];
1304 intmask
= devm_kcalloc(pctrl
->dev
, community
->ngpps
,
1305 sizeof(*intmask
), GFP_KERNEL
);
1309 communities
[i
].intmask
= intmask
;
1312 pctrl
->context
.pads
= pads
;
1313 pctrl
->context
.communities
= communities
;
1319 int intel_pinctrl_probe(struct platform_device
*pdev
,
1320 const struct intel_pinctrl_soc_data
*soc_data
)
1322 struct intel_pinctrl
*pctrl
;
1328 pctrl
= devm_kzalloc(&pdev
->dev
, sizeof(*pctrl
), GFP_KERNEL
);
1332 pctrl
->dev
= &pdev
->dev
;
1333 pctrl
->soc
= soc_data
;
1334 raw_spin_lock_init(&pctrl
->lock
);
1337 * Make a copy of the communities which we can use to hold pointers
1340 pctrl
->ncommunities
= pctrl
->soc
->ncommunities
;
1341 pctrl
->communities
= devm_kcalloc(&pdev
->dev
, pctrl
->ncommunities
,
1342 sizeof(*pctrl
->communities
), GFP_KERNEL
);
1343 if (!pctrl
->communities
)
1346 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1347 struct intel_community
*community
= &pctrl
->communities
[i
];
1348 struct resource
*res
;
1352 *community
= pctrl
->soc
->communities
[i
];
1354 res
= platform_get_resource(pdev
, IORESOURCE_MEM
,
1356 regs
= devm_ioremap_resource(&pdev
->dev
, res
);
1358 return PTR_ERR(regs
);
1361 * Determine community features based on the revision if
1362 * not specified already.
1364 if (!community
->features
) {
1367 rev
= (readl(regs
+ REVID
) & REVID_MASK
) >> REVID_SHIFT
;
1369 community
->features
|= PINCTRL_FEATURE_DEBOUNCE
;
1370 community
->features
|= PINCTRL_FEATURE_1K_PD
;
1374 /* Read offset of the pad configuration registers */
1375 padbar
= readl(regs
+ PADBAR
);
1377 community
->regs
= regs
;
1378 community
->pad_regs
= regs
+ padbar
;
1380 if (!community
->is_offset
)
1381 community
->is_offset
= GPI_IS
;
1383 ret
= intel_pinctrl_add_padgroups(pctrl
, community
);
1388 irq
= platform_get_irq(pdev
, 0);
1390 dev_err(&pdev
->dev
, "failed to get interrupt number\n");
1394 ret
= intel_pinctrl_pm_init(pctrl
);
1398 pctrl
->pctldesc
= intel_pinctrl_desc
;
1399 pctrl
->pctldesc
.name
= dev_name(&pdev
->dev
);
1400 pctrl
->pctldesc
.pins
= pctrl
->soc
->pins
;
1401 pctrl
->pctldesc
.npins
= pctrl
->soc
->npins
;
1403 pctrl
->pctldev
= devm_pinctrl_register(&pdev
->dev
, &pctrl
->pctldesc
,
1405 if (IS_ERR(pctrl
->pctldev
)) {
1406 dev_err(&pdev
->dev
, "failed to register pinctrl driver\n");
1407 return PTR_ERR(pctrl
->pctldev
);
1410 ret
= intel_gpio_probe(pctrl
, irq
);
1414 platform_set_drvdata(pdev
, pctrl
);
1418 EXPORT_SYMBOL_GPL(intel_pinctrl_probe
);
1420 #ifdef CONFIG_PM_SLEEP
1421 static bool intel_pinctrl_should_save(struct intel_pinctrl
*pctrl
, unsigned pin
)
1423 const struct pin_desc
*pd
= pin_desc_get(pctrl
->pctldev
, pin
);
1425 if (!pd
|| !intel_pad_usable(pctrl
, pin
))
1429 * Only restore the pin if it is actually in use by the kernel (or
1430 * by userspace). It is possible that some pins are used by the
1431 * BIOS during resume and those are not always locked down so leave
1434 if (pd
->mux_owner
|| pd
->gpio_owner
||
1435 gpiochip_line_is_irq(&pctrl
->chip
, pin
))
1441 int intel_pinctrl_suspend(struct device
*dev
)
1443 struct platform_device
*pdev
= to_platform_device(dev
);
1444 struct intel_pinctrl
*pctrl
= platform_get_drvdata(pdev
);
1445 struct intel_community_context
*communities
;
1446 struct intel_pad_context
*pads
;
1449 pads
= pctrl
->context
.pads
;
1450 for (i
= 0; i
< pctrl
->soc
->npins
; i
++) {
1451 const struct pinctrl_pin_desc
*desc
= &pctrl
->soc
->pins
[i
];
1452 void __iomem
*padcfg
;
1455 if (!intel_pinctrl_should_save(pctrl
, desc
->number
))
1458 val
= readl(intel_get_padcfg(pctrl
, desc
->number
, PADCFG0
));
1459 pads
[i
].padcfg0
= val
& ~PADCFG0_GPIORXSTATE
;
1460 val
= readl(intel_get_padcfg(pctrl
, desc
->number
, PADCFG1
));
1461 pads
[i
].padcfg1
= val
;
1463 padcfg
= intel_get_padcfg(pctrl
, desc
->number
, PADCFG2
);
1465 pads
[i
].padcfg2
= readl(padcfg
);
1468 communities
= pctrl
->context
.communities
;
1469 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1470 struct intel_community
*community
= &pctrl
->communities
[i
];
1474 base
= community
->regs
+ community
->ie_offset
;
1475 for (gpp
= 0; gpp
< community
->ngpps
; gpp
++)
1476 communities
[i
].intmask
[gpp
] = readl(base
+ gpp
* 4);
1481 EXPORT_SYMBOL_GPL(intel_pinctrl_suspend
);
1483 static void intel_gpio_irq_init(struct intel_pinctrl
*pctrl
)
1487 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1488 const struct intel_community
*community
;
1492 community
= &pctrl
->communities
[i
];
1493 base
= community
->regs
;
1495 for (gpp
= 0; gpp
< community
->ngpps
; gpp
++) {
1496 /* Mask and clear all interrupts */
1497 writel(0, base
+ community
->ie_offset
+ gpp
* 4);
1498 writel(0xffff, base
+ community
->is_offset
+ gpp
* 4);
1503 int intel_pinctrl_resume(struct device
*dev
)
1505 struct platform_device
*pdev
= to_platform_device(dev
);
1506 struct intel_pinctrl
*pctrl
= platform_get_drvdata(pdev
);
1507 const struct intel_community_context
*communities
;
1508 const struct intel_pad_context
*pads
;
1511 /* Mask all interrupts */
1512 intel_gpio_irq_init(pctrl
);
1514 pads
= pctrl
->context
.pads
;
1515 for (i
= 0; i
< pctrl
->soc
->npins
; i
++) {
1516 const struct pinctrl_pin_desc
*desc
= &pctrl
->soc
->pins
[i
];
1517 void __iomem
*padcfg
;
1520 if (!intel_pinctrl_should_save(pctrl
, desc
->number
))
1523 padcfg
= intel_get_padcfg(pctrl
, desc
->number
, PADCFG0
);
1524 val
= readl(padcfg
) & ~PADCFG0_GPIORXSTATE
;
1525 if (val
!= pads
[i
].padcfg0
) {
1526 writel(pads
[i
].padcfg0
, padcfg
);
1527 dev_dbg(dev
, "restored pin %u padcfg0 %#08x\n",
1528 desc
->number
, readl(padcfg
));
1531 padcfg
= intel_get_padcfg(pctrl
, desc
->number
, PADCFG1
);
1532 val
= readl(padcfg
);
1533 if (val
!= pads
[i
].padcfg1
) {
1534 writel(pads
[i
].padcfg1
, padcfg
);
1535 dev_dbg(dev
, "restored pin %u padcfg1 %#08x\n",
1536 desc
->number
, readl(padcfg
));
1539 padcfg
= intel_get_padcfg(pctrl
, desc
->number
, PADCFG2
);
1541 val
= readl(padcfg
);
1542 if (val
!= pads
[i
].padcfg2
) {
1543 writel(pads
[i
].padcfg2
, padcfg
);
1544 dev_dbg(dev
, "restored pin %u padcfg2 %#08x\n",
1545 desc
->number
, readl(padcfg
));
1550 communities
= pctrl
->context
.communities
;
1551 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1552 struct intel_community
*community
= &pctrl
->communities
[i
];
1556 base
= community
->regs
+ community
->ie_offset
;
1557 for (gpp
= 0; gpp
< community
->ngpps
; gpp
++) {
1558 writel(communities
[i
].intmask
[gpp
], base
+ gpp
* 4);
1559 dev_dbg(dev
, "restored mask %d/%u %#08x\n", i
, gpp
,
1560 readl(base
+ gpp
* 4));
1566 EXPORT_SYMBOL_GPL(intel_pinctrl_resume
);
1569 MODULE_AUTHOR("Mathias Nyman <mathias.nyman@linux.intel.com>");
1570 MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
1571 MODULE_DESCRIPTION("Intel pinctrl/GPIO core driver");
1572 MODULE_LICENSE("GPL v2");