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/acpi.h>
11 #include <linux/module.h>
12 #include <linux/interrupt.h>
13 #include <linux/gpio/driver.h>
14 #include <linux/log2.h>
15 #include <linux/platform_device.h>
16 #include <linux/property.h>
18 #include <linux/pinctrl/pinctrl.h>
19 #include <linux/pinctrl/pinmux.h>
20 #include <linux/pinctrl/pinconf.h>
21 #include <linux/pinctrl/pinconf-generic.h>
24 #include "pinctrl-intel.h"
26 /* Offset from regs */
28 #define REVID_SHIFT 16
29 #define REVID_MASK GENMASK(31, 16)
35 #define PADOWN_SHIFT(p) ((p) % 8 * PADOWN_BITS)
36 #define PADOWN_MASK(p) (0xf << PADOWN_SHIFT(p))
37 #define PADOWN_GPP(p) ((p) / 8)
39 /* Offset from pad_regs */
41 #define PADCFG0_RXEVCFG_SHIFT 25
42 #define PADCFG0_RXEVCFG_MASK (3 << PADCFG0_RXEVCFG_SHIFT)
43 #define PADCFG0_RXEVCFG_LEVEL 0
44 #define PADCFG0_RXEVCFG_EDGE 1
45 #define PADCFG0_RXEVCFG_DISABLED 2
46 #define PADCFG0_RXEVCFG_EDGE_BOTH 3
47 #define PADCFG0_PREGFRXSEL BIT(24)
48 #define PADCFG0_RXINV BIT(23)
49 #define PADCFG0_GPIROUTIOXAPIC BIT(20)
50 #define PADCFG0_GPIROUTSCI BIT(19)
51 #define PADCFG0_GPIROUTSMI BIT(18)
52 #define PADCFG0_GPIROUTNMI BIT(17)
53 #define PADCFG0_PMODE_SHIFT 10
54 #define PADCFG0_PMODE_MASK (0xf << PADCFG0_PMODE_SHIFT)
55 #define PADCFG0_GPIORXDIS BIT(9)
56 #define PADCFG0_GPIOTXDIS BIT(8)
57 #define PADCFG0_GPIORXSTATE BIT(1)
58 #define PADCFG0_GPIOTXSTATE BIT(0)
61 #define PADCFG1_TERM_UP BIT(13)
62 #define PADCFG1_TERM_SHIFT 10
63 #define PADCFG1_TERM_MASK (7 << PADCFG1_TERM_SHIFT)
64 #define PADCFG1_TERM_20K 4
65 #define PADCFG1_TERM_2K 3
66 #define PADCFG1_TERM_5K 2
67 #define PADCFG1_TERM_1K 1
70 #define PADCFG2_DEBEN BIT(0)
71 #define PADCFG2_DEBOUNCE_SHIFT 1
72 #define PADCFG2_DEBOUNCE_MASK GENMASK(4, 1)
74 #define DEBOUNCE_PERIOD 31250 /* ns */
76 struct intel_pad_context
{
82 struct intel_community_context
{
86 struct intel_pinctrl_context
{
87 struct intel_pad_context
*pads
;
88 struct intel_community_context
*communities
;
92 * struct intel_pinctrl - Intel pinctrl private structure
93 * @dev: Pointer to the device structure
94 * @lock: Lock to serialize register access
95 * @pctldesc: Pin controller description
96 * @pctldev: Pointer to the pin controller device
97 * @chip: GPIO chip in this pin controller
98 * @soc: SoC/PCH specific pin configuration data
99 * @communities: All communities in this pin controller
100 * @ncommunities: Number of communities in this pin controller
101 * @context: Configuration saved over system sleep
102 * @irq: pinctrl/GPIO chip irq number
104 struct intel_pinctrl
{
107 struct pinctrl_desc pctldesc
;
108 struct pinctrl_dev
*pctldev
;
109 struct gpio_chip chip
;
110 const struct intel_pinctrl_soc_data
*soc
;
111 struct intel_community
*communities
;
113 struct intel_pinctrl_context context
;
117 #define pin_to_padno(c, p) ((p) - (c)->pin_base)
118 #define padgroup_offset(g, p) ((p) - (g)->base)
120 static struct intel_community
*intel_get_community(struct intel_pinctrl
*pctrl
,
123 struct intel_community
*community
;
126 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
127 community
= &pctrl
->communities
[i
];
128 if (pin
>= community
->pin_base
&&
129 pin
< community
->pin_base
+ community
->npins
)
133 dev_warn(pctrl
->dev
, "failed to find community for pin %u\n", pin
);
137 static const struct intel_padgroup
*
138 intel_community_get_padgroup(const struct intel_community
*community
,
143 for (i
= 0; i
< community
->ngpps
; i
++) {
144 const struct intel_padgroup
*padgrp
= &community
->gpps
[i
];
146 if (pin
>= padgrp
->base
&& pin
< padgrp
->base
+ padgrp
->size
)
153 static void __iomem
*intel_get_padcfg(struct intel_pinctrl
*pctrl
,
154 unsigned int pin
, unsigned int reg
)
156 const struct intel_community
*community
;
160 community
= intel_get_community(pctrl
, pin
);
164 padno
= pin_to_padno(community
, pin
);
165 nregs
= (community
->features
& PINCTRL_FEATURE_DEBOUNCE
) ? 4 : 2;
167 if (reg
== PADCFG2
&& !(community
->features
& PINCTRL_FEATURE_DEBOUNCE
))
170 return community
->pad_regs
+ reg
+ padno
* nregs
* 4;
173 static bool intel_pad_owned_by_host(struct intel_pinctrl
*pctrl
, unsigned int pin
)
175 const struct intel_community
*community
;
176 const struct intel_padgroup
*padgrp
;
177 unsigned int gpp
, offset
, gpp_offset
;
178 void __iomem
*padown
;
180 community
= intel_get_community(pctrl
, pin
);
183 if (!community
->padown_offset
)
186 padgrp
= intel_community_get_padgroup(community
, pin
);
190 gpp_offset
= padgroup_offset(padgrp
, pin
);
191 gpp
= PADOWN_GPP(gpp_offset
);
192 offset
= community
->padown_offset
+ padgrp
->padown_num
* 4 + gpp
* 4;
193 padown
= community
->regs
+ offset
;
195 return !(readl(padown
) & PADOWN_MASK(gpp_offset
));
198 static bool intel_pad_acpi_mode(struct intel_pinctrl
*pctrl
, unsigned int pin
)
200 const struct intel_community
*community
;
201 const struct intel_padgroup
*padgrp
;
202 unsigned int offset
, gpp_offset
;
203 void __iomem
*hostown
;
205 community
= intel_get_community(pctrl
, pin
);
208 if (!community
->hostown_offset
)
211 padgrp
= intel_community_get_padgroup(community
, pin
);
215 gpp_offset
= padgroup_offset(padgrp
, pin
);
216 offset
= community
->hostown_offset
+ padgrp
->reg_num
* 4;
217 hostown
= community
->regs
+ offset
;
219 return !(readl(hostown
) & BIT(gpp_offset
));
222 static bool intel_pad_locked(struct intel_pinctrl
*pctrl
, unsigned int pin
)
224 struct intel_community
*community
;
225 const struct intel_padgroup
*padgrp
;
226 unsigned int offset
, gpp_offset
;
229 community
= intel_get_community(pctrl
, pin
);
232 if (!community
->padcfglock_offset
)
235 padgrp
= intel_community_get_padgroup(community
, pin
);
239 gpp_offset
= padgroup_offset(padgrp
, pin
);
242 * If PADCFGLOCK and PADCFGLOCKTX bits are both clear for this pad,
243 * the pad is considered unlocked. Any other case means that it is
244 * either fully or partially locked and we don't touch it.
246 offset
= community
->padcfglock_offset
+ padgrp
->reg_num
* 8;
247 value
= readl(community
->regs
+ offset
);
248 if (value
& BIT(gpp_offset
))
251 offset
= community
->padcfglock_offset
+ 4 + padgrp
->reg_num
* 8;
252 value
= readl(community
->regs
+ offset
);
253 if (value
& BIT(gpp_offset
))
259 static bool intel_pad_usable(struct intel_pinctrl
*pctrl
, unsigned int pin
)
261 return intel_pad_owned_by_host(pctrl
, pin
) &&
262 !intel_pad_locked(pctrl
, pin
);
265 static int intel_get_groups_count(struct pinctrl_dev
*pctldev
)
267 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
269 return pctrl
->soc
->ngroups
;
272 static const char *intel_get_group_name(struct pinctrl_dev
*pctldev
,
275 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
277 return pctrl
->soc
->groups
[group
].name
;
280 static int intel_get_group_pins(struct pinctrl_dev
*pctldev
, unsigned int group
,
281 const unsigned int **pins
, unsigned int *npins
)
283 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
285 *pins
= pctrl
->soc
->groups
[group
].pins
;
286 *npins
= pctrl
->soc
->groups
[group
].npins
;
290 static void intel_pin_dbg_show(struct pinctrl_dev
*pctldev
, struct seq_file
*s
,
293 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
294 void __iomem
*padcfg
;
295 u32 cfg0
, cfg1
, mode
;
298 if (!intel_pad_owned_by_host(pctrl
, pin
)) {
299 seq_puts(s
, "not available");
303 cfg0
= readl(intel_get_padcfg(pctrl
, pin
, PADCFG0
));
304 cfg1
= readl(intel_get_padcfg(pctrl
, pin
, PADCFG1
));
306 mode
= (cfg0
& PADCFG0_PMODE_MASK
) >> PADCFG0_PMODE_SHIFT
;
308 seq_puts(s
, "GPIO ");
310 seq_printf(s
, "mode %d ", mode
);
312 seq_printf(s
, "0x%08x 0x%08x", cfg0
, cfg1
);
314 /* Dump the additional PADCFG registers if available */
315 padcfg
= intel_get_padcfg(pctrl
, pin
, PADCFG2
);
317 seq_printf(s
, " 0x%08x", readl(padcfg
));
319 locked
= intel_pad_locked(pctrl
, pin
);
320 acpi
= intel_pad_acpi_mode(pctrl
, pin
);
322 if (locked
|| acpi
) {
325 seq_puts(s
, "LOCKED");
335 static const struct pinctrl_ops intel_pinctrl_ops
= {
336 .get_groups_count
= intel_get_groups_count
,
337 .get_group_name
= intel_get_group_name
,
338 .get_group_pins
= intel_get_group_pins
,
339 .pin_dbg_show
= intel_pin_dbg_show
,
342 static int intel_get_functions_count(struct pinctrl_dev
*pctldev
)
344 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
346 return pctrl
->soc
->nfunctions
;
349 static const char *intel_get_function_name(struct pinctrl_dev
*pctldev
,
350 unsigned int function
)
352 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
354 return pctrl
->soc
->functions
[function
].name
;
357 static int intel_get_function_groups(struct pinctrl_dev
*pctldev
,
358 unsigned int function
,
359 const char * const **groups
,
360 unsigned int * const ngroups
)
362 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
364 *groups
= pctrl
->soc
->functions
[function
].groups
;
365 *ngroups
= pctrl
->soc
->functions
[function
].ngroups
;
369 static int intel_pinmux_set_mux(struct pinctrl_dev
*pctldev
,
370 unsigned int function
, unsigned int group
)
372 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
373 const struct intel_pingroup
*grp
= &pctrl
->soc
->groups
[group
];
377 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
380 * All pins in the groups needs to be accessible and writable
381 * before we can enable the mux for this group.
383 for (i
= 0; i
< grp
->npins
; i
++) {
384 if (!intel_pad_usable(pctrl
, grp
->pins
[i
])) {
385 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
390 /* Now enable the mux setting for each pin in the group */
391 for (i
= 0; i
< grp
->npins
; i
++) {
392 void __iomem
*padcfg0
;
395 padcfg0
= intel_get_padcfg(pctrl
, grp
->pins
[i
], PADCFG0
);
396 value
= readl(padcfg0
);
398 value
&= ~PADCFG0_PMODE_MASK
;
401 value
|= grp
->modes
[i
] << PADCFG0_PMODE_SHIFT
;
403 value
|= grp
->mode
<< PADCFG0_PMODE_SHIFT
;
405 writel(value
, padcfg0
);
408 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
413 static void __intel_gpio_set_direction(void __iomem
*padcfg0
, bool input
)
417 value
= readl(padcfg0
);
419 value
&= ~PADCFG0_GPIORXDIS
;
420 value
|= PADCFG0_GPIOTXDIS
;
422 value
&= ~PADCFG0_GPIOTXDIS
;
423 value
|= PADCFG0_GPIORXDIS
;
425 writel(value
, padcfg0
);
428 static void intel_gpio_set_gpio_mode(void __iomem
*padcfg0
)
432 /* Put the pad into GPIO mode */
433 value
= readl(padcfg0
) & ~PADCFG0_PMODE_MASK
;
434 /* Disable SCI/SMI/NMI generation */
435 value
&= ~(PADCFG0_GPIROUTIOXAPIC
| PADCFG0_GPIROUTSCI
);
436 value
&= ~(PADCFG0_GPIROUTSMI
| PADCFG0_GPIROUTNMI
);
437 writel(value
, padcfg0
);
440 static int intel_gpio_request_enable(struct pinctrl_dev
*pctldev
,
441 struct pinctrl_gpio_range
*range
,
444 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
445 void __iomem
*padcfg0
;
448 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
450 if (!intel_pad_usable(pctrl
, pin
)) {
451 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
455 padcfg0
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
456 intel_gpio_set_gpio_mode(padcfg0
);
457 /* Disable TX buffer and enable RX (this will be input) */
458 __intel_gpio_set_direction(padcfg0
, true);
460 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
465 static int intel_gpio_set_direction(struct pinctrl_dev
*pctldev
,
466 struct pinctrl_gpio_range
*range
,
467 unsigned int pin
, bool input
)
469 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
470 void __iomem
*padcfg0
;
473 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
475 padcfg0
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
476 __intel_gpio_set_direction(padcfg0
, input
);
478 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
483 static const struct pinmux_ops intel_pinmux_ops
= {
484 .get_functions_count
= intel_get_functions_count
,
485 .get_function_name
= intel_get_function_name
,
486 .get_function_groups
= intel_get_function_groups
,
487 .set_mux
= intel_pinmux_set_mux
,
488 .gpio_request_enable
= intel_gpio_request_enable
,
489 .gpio_set_direction
= intel_gpio_set_direction
,
492 static int intel_config_get(struct pinctrl_dev
*pctldev
, unsigned int pin
,
493 unsigned long *config
)
495 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
496 enum pin_config_param param
= pinconf_to_config_param(*config
);
497 const struct intel_community
*community
;
501 if (!intel_pad_owned_by_host(pctrl
, pin
))
504 community
= intel_get_community(pctrl
, pin
);
505 value
= readl(intel_get_padcfg(pctrl
, pin
, PADCFG1
));
506 term
= (value
& PADCFG1_TERM_MASK
) >> PADCFG1_TERM_SHIFT
;
509 case PIN_CONFIG_BIAS_DISABLE
:
514 case PIN_CONFIG_BIAS_PULL_UP
:
515 if (!term
|| !(value
& PADCFG1_TERM_UP
))
519 case PADCFG1_TERM_1K
:
522 case PADCFG1_TERM_2K
:
525 case PADCFG1_TERM_5K
:
528 case PADCFG1_TERM_20K
:
535 case PIN_CONFIG_BIAS_PULL_DOWN
:
536 if (!term
|| value
& PADCFG1_TERM_UP
)
540 case PADCFG1_TERM_1K
:
541 if (!(community
->features
& PINCTRL_FEATURE_1K_PD
))
545 case PADCFG1_TERM_5K
:
548 case PADCFG1_TERM_20K
:
555 case PIN_CONFIG_INPUT_DEBOUNCE
: {
556 void __iomem
*padcfg2
;
559 padcfg2
= intel_get_padcfg(pctrl
, pin
, PADCFG2
);
564 if (!(v
& PADCFG2_DEBEN
))
567 v
= (v
& PADCFG2_DEBOUNCE_MASK
) >> PADCFG2_DEBOUNCE_SHIFT
;
568 arg
= BIT(v
) * DEBOUNCE_PERIOD
/ 1000;
577 *config
= pinconf_to_config_packed(param
, arg
);
581 static int intel_config_set_pull(struct intel_pinctrl
*pctrl
, unsigned int pin
,
582 unsigned long config
)
584 unsigned int param
= pinconf_to_config_param(config
);
585 unsigned int arg
= pinconf_to_config_argument(config
);
586 const struct intel_community
*community
;
587 void __iomem
*padcfg1
;
592 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
594 community
= intel_get_community(pctrl
, pin
);
595 padcfg1
= intel_get_padcfg(pctrl
, pin
, PADCFG1
);
596 value
= readl(padcfg1
);
599 case PIN_CONFIG_BIAS_DISABLE
:
600 value
&= ~(PADCFG1_TERM_MASK
| PADCFG1_TERM_UP
);
603 case PIN_CONFIG_BIAS_PULL_UP
:
604 value
&= ~PADCFG1_TERM_MASK
;
606 value
|= PADCFG1_TERM_UP
;
610 value
|= PADCFG1_TERM_20K
<< PADCFG1_TERM_SHIFT
;
613 value
|= PADCFG1_TERM_5K
<< PADCFG1_TERM_SHIFT
;
616 value
|= PADCFG1_TERM_2K
<< PADCFG1_TERM_SHIFT
;
619 value
|= PADCFG1_TERM_1K
<< PADCFG1_TERM_SHIFT
;
627 case PIN_CONFIG_BIAS_PULL_DOWN
:
628 value
&= ~(PADCFG1_TERM_UP
| PADCFG1_TERM_MASK
);
632 value
|= PADCFG1_TERM_20K
<< PADCFG1_TERM_SHIFT
;
635 value
|= PADCFG1_TERM_5K
<< PADCFG1_TERM_SHIFT
;
638 if (!(community
->features
& PINCTRL_FEATURE_1K_PD
)) {
642 value
|= PADCFG1_TERM_1K
<< PADCFG1_TERM_SHIFT
;
652 writel(value
, padcfg1
);
654 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
659 static int intel_config_set_debounce(struct intel_pinctrl
*pctrl
,
660 unsigned int pin
, unsigned int debounce
)
662 void __iomem
*padcfg0
, *padcfg2
;
667 padcfg2
= intel_get_padcfg(pctrl
, pin
, PADCFG2
);
671 padcfg0
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
673 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
675 value0
= readl(padcfg0
);
676 value2
= readl(padcfg2
);
678 /* Disable glitch filter and debouncer */
679 value0
&= ~PADCFG0_PREGFRXSEL
;
680 value2
&= ~(PADCFG2_DEBEN
| PADCFG2_DEBOUNCE_MASK
);
685 v
= order_base_2(debounce
* 1000 / DEBOUNCE_PERIOD
);
686 if (v
< 3 || v
> 15) {
690 /* Enable glitch filter and debouncer */
691 value0
|= PADCFG0_PREGFRXSEL
;
692 value2
|= v
<< PADCFG2_DEBOUNCE_SHIFT
;
693 value2
|= PADCFG2_DEBEN
;
697 writel(value0
, padcfg0
);
698 writel(value2
, padcfg2
);
701 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
706 static int intel_config_set(struct pinctrl_dev
*pctldev
, unsigned int pin
,
707 unsigned long *configs
, unsigned int nconfigs
)
709 struct intel_pinctrl
*pctrl
= pinctrl_dev_get_drvdata(pctldev
);
712 if (!intel_pad_usable(pctrl
, pin
))
715 for (i
= 0; i
< nconfigs
; i
++) {
716 switch (pinconf_to_config_param(configs
[i
])) {
717 case PIN_CONFIG_BIAS_DISABLE
:
718 case PIN_CONFIG_BIAS_PULL_UP
:
719 case PIN_CONFIG_BIAS_PULL_DOWN
:
720 ret
= intel_config_set_pull(pctrl
, pin
, configs
[i
]);
725 case PIN_CONFIG_INPUT_DEBOUNCE
:
726 ret
= intel_config_set_debounce(pctrl
, pin
,
727 pinconf_to_config_argument(configs
[i
]));
740 static const struct pinconf_ops intel_pinconf_ops
= {
742 .pin_config_get
= intel_config_get
,
743 .pin_config_set
= intel_config_set
,
746 static const struct pinctrl_desc intel_pinctrl_desc
= {
747 .pctlops
= &intel_pinctrl_ops
,
748 .pmxops
= &intel_pinmux_ops
,
749 .confops
= &intel_pinconf_ops
,
750 .owner
= THIS_MODULE
,
754 * intel_gpio_to_pin() - Translate from GPIO offset to pin number
755 * @pctrl: Pinctrl structure
756 * @offset: GPIO offset from gpiolib
757 * @community: Community is filled here if not %NULL
758 * @padgrp: Pad group is filled here if not %NULL
760 * When coming through gpiolib irqchip, the GPIO offset is not
761 * automatically translated to pinctrl pin number. This function can be
762 * used to find out the corresponding pinctrl pin.
764 static int intel_gpio_to_pin(struct intel_pinctrl
*pctrl
, unsigned int offset
,
765 const struct intel_community
**community
,
766 const struct intel_padgroup
**padgrp
)
770 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
771 const struct intel_community
*comm
= &pctrl
->communities
[i
];
774 for (j
= 0; j
< comm
->ngpps
; j
++) {
775 const struct intel_padgroup
*pgrp
= &comm
->gpps
[j
];
777 if (pgrp
->gpio_base
< 0)
780 if (offset
>= pgrp
->gpio_base
&&
781 offset
< pgrp
->gpio_base
+ pgrp
->size
) {
784 pin
= pgrp
->base
+ offset
- pgrp
->gpio_base
;
798 static int intel_gpio_get(struct gpio_chip
*chip
, unsigned int offset
)
800 struct intel_pinctrl
*pctrl
= gpiochip_get_data(chip
);
805 pin
= intel_gpio_to_pin(pctrl
, offset
, NULL
, NULL
);
809 reg
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
813 padcfg0
= readl(reg
);
814 if (!(padcfg0
& PADCFG0_GPIOTXDIS
))
815 return !!(padcfg0
& PADCFG0_GPIOTXSTATE
);
817 return !!(padcfg0
& PADCFG0_GPIORXSTATE
);
820 static void intel_gpio_set(struct gpio_chip
*chip
, unsigned int offset
,
823 struct intel_pinctrl
*pctrl
= gpiochip_get_data(chip
);
829 pin
= intel_gpio_to_pin(pctrl
, offset
, NULL
, NULL
);
833 reg
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
837 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
838 padcfg0
= readl(reg
);
840 padcfg0
|= PADCFG0_GPIOTXSTATE
;
842 padcfg0
&= ~PADCFG0_GPIOTXSTATE
;
843 writel(padcfg0
, reg
);
844 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
847 static int intel_gpio_get_direction(struct gpio_chip
*chip
, unsigned int offset
)
849 struct intel_pinctrl
*pctrl
= gpiochip_get_data(chip
);
854 pin
= intel_gpio_to_pin(pctrl
, offset
, NULL
, NULL
);
858 reg
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
862 padcfg0
= readl(reg
);
864 if (padcfg0
& PADCFG0_PMODE_MASK
)
867 return !!(padcfg0
& PADCFG0_GPIOTXDIS
);
870 static int intel_gpio_direction_input(struct gpio_chip
*chip
, unsigned int offset
)
872 return pinctrl_gpio_direction_input(chip
->base
+ offset
);
875 static int intel_gpio_direction_output(struct gpio_chip
*chip
, unsigned int offset
,
878 intel_gpio_set(chip
, offset
, value
);
879 return pinctrl_gpio_direction_output(chip
->base
+ offset
);
882 static const struct gpio_chip intel_gpio_chip
= {
883 .owner
= THIS_MODULE
,
884 .request
= gpiochip_generic_request
,
885 .free
= gpiochip_generic_free
,
886 .get_direction
= intel_gpio_get_direction
,
887 .direction_input
= intel_gpio_direction_input
,
888 .direction_output
= intel_gpio_direction_output
,
889 .get
= intel_gpio_get
,
890 .set
= intel_gpio_set
,
891 .set_config
= gpiochip_generic_config
,
894 static void intel_gpio_irq_ack(struct irq_data
*d
)
896 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
897 struct intel_pinctrl
*pctrl
= gpiochip_get_data(gc
);
898 const struct intel_community
*community
;
899 const struct intel_padgroup
*padgrp
;
902 pin
= intel_gpio_to_pin(pctrl
, irqd_to_hwirq(d
), &community
, &padgrp
);
904 unsigned int gpp
, gpp_offset
, is_offset
;
906 gpp
= padgrp
->reg_num
;
907 gpp_offset
= padgroup_offset(padgrp
, pin
);
908 is_offset
= community
->is_offset
+ gpp
* 4;
910 raw_spin_lock(&pctrl
->lock
);
911 writel(BIT(gpp_offset
), community
->regs
+ is_offset
);
912 raw_spin_unlock(&pctrl
->lock
);
916 static void intel_gpio_irq_mask_unmask(struct irq_data
*d
, bool mask
)
918 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
919 struct intel_pinctrl
*pctrl
= gpiochip_get_data(gc
);
920 const struct intel_community
*community
;
921 const struct intel_padgroup
*padgrp
;
924 pin
= intel_gpio_to_pin(pctrl
, irqd_to_hwirq(d
), &community
, &padgrp
);
926 unsigned int gpp
, gpp_offset
;
928 void __iomem
*reg
, *is
;
931 gpp
= padgrp
->reg_num
;
932 gpp_offset
= padgroup_offset(padgrp
, pin
);
934 reg
= community
->regs
+ community
->ie_offset
+ gpp
* 4;
935 is
= community
->regs
+ community
->is_offset
+ gpp
* 4;
937 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
939 /* Clear interrupt status first to avoid unexpected interrupt */
940 writel(BIT(gpp_offset
), is
);
944 value
&= ~BIT(gpp_offset
);
946 value
|= BIT(gpp_offset
);
948 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
952 static void intel_gpio_irq_mask(struct irq_data
*d
)
954 intel_gpio_irq_mask_unmask(d
, true);
957 static void intel_gpio_irq_unmask(struct irq_data
*d
)
959 intel_gpio_irq_mask_unmask(d
, false);
962 static int intel_gpio_irq_type(struct irq_data
*d
, unsigned int type
)
964 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
965 struct intel_pinctrl
*pctrl
= gpiochip_get_data(gc
);
966 unsigned int pin
= intel_gpio_to_pin(pctrl
, irqd_to_hwirq(d
), NULL
, NULL
);
971 reg
= intel_get_padcfg(pctrl
, pin
, PADCFG0
);
976 * If the pin is in ACPI mode it is still usable as a GPIO but it
977 * cannot be used as IRQ because GPI_IS status bit will not be
978 * updated by the host controller hardware.
980 if (intel_pad_acpi_mode(pctrl
, pin
)) {
981 dev_warn(pctrl
->dev
, "pin %u cannot be used as IRQ\n", pin
);
985 raw_spin_lock_irqsave(&pctrl
->lock
, flags
);
987 intel_gpio_set_gpio_mode(reg
);
991 value
&= ~(PADCFG0_RXEVCFG_MASK
| PADCFG0_RXINV
);
993 if ((type
& IRQ_TYPE_EDGE_BOTH
) == IRQ_TYPE_EDGE_BOTH
) {
994 value
|= PADCFG0_RXEVCFG_EDGE_BOTH
<< PADCFG0_RXEVCFG_SHIFT
;
995 } else if (type
& IRQ_TYPE_EDGE_FALLING
) {
996 value
|= PADCFG0_RXEVCFG_EDGE
<< PADCFG0_RXEVCFG_SHIFT
;
997 value
|= PADCFG0_RXINV
;
998 } else if (type
& IRQ_TYPE_EDGE_RISING
) {
999 value
|= PADCFG0_RXEVCFG_EDGE
<< PADCFG0_RXEVCFG_SHIFT
;
1000 } else if (type
& IRQ_TYPE_LEVEL_MASK
) {
1001 if (type
& IRQ_TYPE_LEVEL_LOW
)
1002 value
|= PADCFG0_RXINV
;
1004 value
|= PADCFG0_RXEVCFG_DISABLED
<< PADCFG0_RXEVCFG_SHIFT
;
1009 if (type
& IRQ_TYPE_EDGE_BOTH
)
1010 irq_set_handler_locked(d
, handle_edge_irq
);
1011 else if (type
& IRQ_TYPE_LEVEL_MASK
)
1012 irq_set_handler_locked(d
, handle_level_irq
);
1014 raw_spin_unlock_irqrestore(&pctrl
->lock
, flags
);
1019 static int intel_gpio_irq_wake(struct irq_data
*d
, unsigned int on
)
1021 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
1022 struct intel_pinctrl
*pctrl
= gpiochip_get_data(gc
);
1023 unsigned int pin
= intel_gpio_to_pin(pctrl
, irqd_to_hwirq(d
), NULL
, NULL
);
1026 enable_irq_wake(pctrl
->irq
);
1028 disable_irq_wake(pctrl
->irq
);
1030 dev_dbg(pctrl
->dev
, "%sable wake for pin %u\n", on
? "en" : "dis", pin
);
1034 static irqreturn_t
intel_gpio_community_irq_handler(struct intel_pinctrl
*pctrl
,
1035 const struct intel_community
*community
)
1037 struct gpio_chip
*gc
= &pctrl
->chip
;
1038 irqreturn_t ret
= IRQ_NONE
;
1041 for (gpp
= 0; gpp
< community
->ngpps
; gpp
++) {
1042 const struct intel_padgroup
*padgrp
= &community
->gpps
[gpp
];
1043 unsigned long pending
, enabled
, gpp_offset
;
1045 pending
= readl(community
->regs
+ community
->is_offset
+
1046 padgrp
->reg_num
* 4);
1047 enabled
= readl(community
->regs
+ community
->ie_offset
+
1048 padgrp
->reg_num
* 4);
1050 /* Only interrupts that are enabled */
1053 for_each_set_bit(gpp_offset
, &pending
, padgrp
->size
) {
1056 irq
= irq_find_mapping(gc
->irq
.domain
,
1057 padgrp
->gpio_base
+ gpp_offset
);
1058 generic_handle_irq(irq
);
1067 static irqreturn_t
intel_gpio_irq(int irq
, void *data
)
1069 const struct intel_community
*community
;
1070 struct intel_pinctrl
*pctrl
= data
;
1071 irqreturn_t ret
= IRQ_NONE
;
1074 /* Need to check all communities for pending interrupts */
1075 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1076 community
= &pctrl
->communities
[i
];
1077 ret
|= intel_gpio_community_irq_handler(pctrl
, community
);
1083 static struct irq_chip intel_gpio_irqchip
= {
1084 .name
= "intel-gpio",
1085 .irq_ack
= intel_gpio_irq_ack
,
1086 .irq_mask
= intel_gpio_irq_mask
,
1087 .irq_unmask
= intel_gpio_irq_unmask
,
1088 .irq_set_type
= intel_gpio_irq_type
,
1089 .irq_set_wake
= intel_gpio_irq_wake
,
1090 .flags
= IRQCHIP_MASK_ON_SUSPEND
,
1093 static int intel_gpio_add_pin_ranges(struct intel_pinctrl
*pctrl
,
1094 const struct intel_community
*community
)
1098 for (i
= 0; i
< community
->ngpps
; i
++) {
1099 const struct intel_padgroup
*gpp
= &community
->gpps
[i
];
1101 if (gpp
->gpio_base
< 0)
1104 ret
= gpiochip_add_pin_range(&pctrl
->chip
, dev_name(pctrl
->dev
),
1105 gpp
->gpio_base
, gpp
->base
,
1114 static unsigned intel_gpio_ngpio(const struct intel_pinctrl
*pctrl
)
1116 const struct intel_community
*community
;
1117 unsigned int ngpio
= 0;
1120 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1121 community
= &pctrl
->communities
[i
];
1122 for (j
= 0; j
< community
->ngpps
; j
++) {
1123 const struct intel_padgroup
*gpp
= &community
->gpps
[j
];
1125 if (gpp
->gpio_base
< 0)
1128 if (gpp
->gpio_base
+ gpp
->size
> ngpio
)
1129 ngpio
= gpp
->gpio_base
+ gpp
->size
;
1136 static int intel_gpio_probe(struct intel_pinctrl
*pctrl
, int irq
)
1140 pctrl
->chip
= intel_gpio_chip
;
1142 pctrl
->chip
.ngpio
= intel_gpio_ngpio(pctrl
);
1143 pctrl
->chip
.label
= dev_name(pctrl
->dev
);
1144 pctrl
->chip
.parent
= pctrl
->dev
;
1145 pctrl
->chip
.base
= -1;
1148 ret
= devm_gpiochip_add_data(pctrl
->dev
, &pctrl
->chip
, pctrl
);
1150 dev_err(pctrl
->dev
, "failed to register gpiochip\n");
1154 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1155 struct intel_community
*community
= &pctrl
->communities
[i
];
1157 ret
= intel_gpio_add_pin_ranges(pctrl
, community
);
1159 dev_err(pctrl
->dev
, "failed to add GPIO pin range\n");
1165 * We need to request the interrupt here (instead of providing chip
1166 * to the irq directly) because on some platforms several GPIO
1167 * controllers share the same interrupt line.
1169 ret
= devm_request_irq(pctrl
->dev
, irq
, intel_gpio_irq
,
1170 IRQF_SHARED
| IRQF_NO_THREAD
,
1171 dev_name(pctrl
->dev
), pctrl
);
1173 dev_err(pctrl
->dev
, "failed to request interrupt\n");
1177 ret
= gpiochip_irqchip_add(&pctrl
->chip
, &intel_gpio_irqchip
, 0,
1178 handle_bad_irq
, IRQ_TYPE_NONE
);
1180 dev_err(pctrl
->dev
, "failed to add irqchip\n");
1184 gpiochip_set_chained_irqchip(&pctrl
->chip
, &intel_gpio_irqchip
, irq
,
1189 static int intel_pinctrl_add_padgroups(struct intel_pinctrl
*pctrl
,
1190 struct intel_community
*community
)
1192 struct intel_padgroup
*gpps
;
1193 unsigned int npins
= community
->npins
;
1194 unsigned int padown_num
= 0;
1197 if (community
->gpps
)
1198 ngpps
= community
->ngpps
;
1200 ngpps
= DIV_ROUND_UP(community
->npins
, community
->gpp_size
);
1202 gpps
= devm_kcalloc(pctrl
->dev
, ngpps
, sizeof(*gpps
), GFP_KERNEL
);
1206 for (i
= 0; i
< ngpps
; i
++) {
1207 if (community
->gpps
) {
1208 gpps
[i
] = community
->gpps
[i
];
1210 unsigned int gpp_size
= community
->gpp_size
;
1212 gpps
[i
].reg_num
= i
;
1213 gpps
[i
].base
= community
->pin_base
+ i
* gpp_size
;
1214 gpps
[i
].size
= min(gpp_size
, npins
);
1215 npins
-= gpps
[i
].size
;
1218 if (gpps
[i
].size
> 32)
1221 if (!gpps
[i
].gpio_base
)
1222 gpps
[i
].gpio_base
= gpps
[i
].base
;
1224 gpps
[i
].padown_num
= padown_num
;
1227 * In older hardware the number of padown registers per
1228 * group is fixed regardless of the group size.
1230 if (community
->gpp_num_padown_regs
)
1231 padown_num
+= community
->gpp_num_padown_regs
;
1233 padown_num
+= DIV_ROUND_UP(gpps
[i
].size
* 4, 32);
1236 community
->ngpps
= ngpps
;
1237 community
->gpps
= gpps
;
1242 static int intel_pinctrl_pm_init(struct intel_pinctrl
*pctrl
)
1244 #ifdef CONFIG_PM_SLEEP
1245 const struct intel_pinctrl_soc_data
*soc
= pctrl
->soc
;
1246 struct intel_community_context
*communities
;
1247 struct intel_pad_context
*pads
;
1250 pads
= devm_kcalloc(pctrl
->dev
, soc
->npins
, sizeof(*pads
), GFP_KERNEL
);
1254 communities
= devm_kcalloc(pctrl
->dev
, pctrl
->ncommunities
,
1255 sizeof(*communities
), GFP_KERNEL
);
1260 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1261 struct intel_community
*community
= &pctrl
->communities
[i
];
1264 intmask
= devm_kcalloc(pctrl
->dev
, community
->ngpps
,
1265 sizeof(*intmask
), GFP_KERNEL
);
1269 communities
[i
].intmask
= intmask
;
1272 pctrl
->context
.pads
= pads
;
1273 pctrl
->context
.communities
= communities
;
1279 static int intel_pinctrl_probe(struct platform_device
*pdev
,
1280 const struct intel_pinctrl_soc_data
*soc_data
)
1282 struct intel_pinctrl
*pctrl
;
1288 pctrl
= devm_kzalloc(&pdev
->dev
, sizeof(*pctrl
), GFP_KERNEL
);
1292 pctrl
->dev
= &pdev
->dev
;
1293 pctrl
->soc
= soc_data
;
1294 raw_spin_lock_init(&pctrl
->lock
);
1297 * Make a copy of the communities which we can use to hold pointers
1300 pctrl
->ncommunities
= pctrl
->soc
->ncommunities
;
1301 pctrl
->communities
= devm_kcalloc(&pdev
->dev
, pctrl
->ncommunities
,
1302 sizeof(*pctrl
->communities
), GFP_KERNEL
);
1303 if (!pctrl
->communities
)
1306 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1307 struct intel_community
*community
= &pctrl
->communities
[i
];
1308 struct resource
*res
;
1312 *community
= pctrl
->soc
->communities
[i
];
1314 res
= platform_get_resource(pdev
, IORESOURCE_MEM
,
1316 regs
= devm_ioremap_resource(&pdev
->dev
, res
);
1318 return PTR_ERR(regs
);
1321 * Determine community features based on the revision if
1322 * not specified already.
1324 if (!community
->features
) {
1327 rev
= (readl(regs
+ REVID
) & REVID_MASK
) >> REVID_SHIFT
;
1329 community
->features
|= PINCTRL_FEATURE_DEBOUNCE
;
1330 community
->features
|= PINCTRL_FEATURE_1K_PD
;
1334 /* Read offset of the pad configuration registers */
1335 padbar
= readl(regs
+ PADBAR
);
1337 community
->regs
= regs
;
1338 community
->pad_regs
= regs
+ padbar
;
1340 if (!community
->is_offset
)
1341 community
->is_offset
= GPI_IS
;
1343 ret
= intel_pinctrl_add_padgroups(pctrl
, community
);
1348 irq
= platform_get_irq(pdev
, 0);
1350 dev_err(&pdev
->dev
, "failed to get interrupt number\n");
1354 ret
= intel_pinctrl_pm_init(pctrl
);
1358 pctrl
->pctldesc
= intel_pinctrl_desc
;
1359 pctrl
->pctldesc
.name
= dev_name(&pdev
->dev
);
1360 pctrl
->pctldesc
.pins
= pctrl
->soc
->pins
;
1361 pctrl
->pctldesc
.npins
= pctrl
->soc
->npins
;
1363 pctrl
->pctldev
= devm_pinctrl_register(&pdev
->dev
, &pctrl
->pctldesc
,
1365 if (IS_ERR(pctrl
->pctldev
)) {
1366 dev_err(&pdev
->dev
, "failed to register pinctrl driver\n");
1367 return PTR_ERR(pctrl
->pctldev
);
1370 ret
= intel_gpio_probe(pctrl
, irq
);
1374 platform_set_drvdata(pdev
, pctrl
);
1379 int intel_pinctrl_probe_by_hid(struct platform_device
*pdev
)
1381 const struct intel_pinctrl_soc_data
*data
;
1383 data
= device_get_match_data(&pdev
->dev
);
1384 return intel_pinctrl_probe(pdev
, data
);
1386 EXPORT_SYMBOL_GPL(intel_pinctrl_probe_by_hid
);
1388 int intel_pinctrl_probe_by_uid(struct platform_device
*pdev
)
1390 const struct intel_pinctrl_soc_data
*data
= NULL
;
1391 const struct intel_pinctrl_soc_data
**table
;
1392 struct acpi_device
*adev
;
1395 adev
= ACPI_COMPANION(&pdev
->dev
);
1397 const void *match
= device_get_match_data(&pdev
->dev
);
1399 table
= (const struct intel_pinctrl_soc_data
**)match
;
1400 for (i
= 0; table
[i
]; i
++) {
1401 if (!strcmp(adev
->pnp
.unique_id
, table
[i
]->uid
)) {
1407 const struct platform_device_id
*id
;
1409 id
= platform_get_device_id(pdev
);
1413 table
= (const struct intel_pinctrl_soc_data
**)id
->driver_data
;
1414 data
= table
[pdev
->id
];
1419 return intel_pinctrl_probe(pdev
, data
);
1421 EXPORT_SYMBOL_GPL(intel_pinctrl_probe_by_uid
);
1423 #ifdef CONFIG_PM_SLEEP
1424 static bool intel_pinctrl_should_save(struct intel_pinctrl
*pctrl
, unsigned int pin
)
1426 const struct pin_desc
*pd
= pin_desc_get(pctrl
->pctldev
, pin
);
1428 if (!pd
|| !intel_pad_usable(pctrl
, pin
))
1432 * Only restore the pin if it is actually in use by the kernel (or
1433 * by userspace). It is possible that some pins are used by the
1434 * BIOS during resume and those are not always locked down so leave
1437 if (pd
->mux_owner
|| pd
->gpio_owner
||
1438 gpiochip_line_is_irq(&pctrl
->chip
, pin
))
1444 int intel_pinctrl_suspend_noirq(struct device
*dev
)
1446 struct intel_pinctrl
*pctrl
= dev_get_drvdata(dev
);
1447 struct intel_community_context
*communities
;
1448 struct intel_pad_context
*pads
;
1451 pads
= pctrl
->context
.pads
;
1452 for (i
= 0; i
< pctrl
->soc
->npins
; i
++) {
1453 const struct pinctrl_pin_desc
*desc
= &pctrl
->soc
->pins
[i
];
1454 void __iomem
*padcfg
;
1457 if (!intel_pinctrl_should_save(pctrl
, desc
->number
))
1460 val
= readl(intel_get_padcfg(pctrl
, desc
->number
, PADCFG0
));
1461 pads
[i
].padcfg0
= val
& ~PADCFG0_GPIORXSTATE
;
1462 val
= readl(intel_get_padcfg(pctrl
, desc
->number
, PADCFG1
));
1463 pads
[i
].padcfg1
= val
;
1465 padcfg
= intel_get_padcfg(pctrl
, desc
->number
, PADCFG2
);
1467 pads
[i
].padcfg2
= readl(padcfg
);
1470 communities
= pctrl
->context
.communities
;
1471 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1472 struct intel_community
*community
= &pctrl
->communities
[i
];
1476 base
= community
->regs
+ community
->ie_offset
;
1477 for (gpp
= 0; gpp
< community
->ngpps
; gpp
++)
1478 communities
[i
].intmask
[gpp
] = readl(base
+ gpp
* 4);
1483 EXPORT_SYMBOL_GPL(intel_pinctrl_suspend_noirq
);
1485 static void intel_gpio_irq_init(struct intel_pinctrl
*pctrl
)
1489 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1490 const struct intel_community
*community
;
1494 community
= &pctrl
->communities
[i
];
1495 base
= community
->regs
;
1497 for (gpp
= 0; gpp
< community
->ngpps
; gpp
++) {
1498 /* Mask and clear all interrupts */
1499 writel(0, base
+ community
->ie_offset
+ gpp
* 4);
1500 writel(0xffff, base
+ community
->is_offset
+ gpp
* 4);
1505 int intel_pinctrl_resume_noirq(struct device
*dev
)
1507 struct intel_pinctrl
*pctrl
= dev_get_drvdata(dev
);
1508 const struct intel_community_context
*communities
;
1509 const struct intel_pad_context
*pads
;
1512 /* Mask all interrupts */
1513 intel_gpio_irq_init(pctrl
);
1515 pads
= pctrl
->context
.pads
;
1516 for (i
= 0; i
< pctrl
->soc
->npins
; i
++) {
1517 const struct pinctrl_pin_desc
*desc
= &pctrl
->soc
->pins
[i
];
1518 void __iomem
*padcfg
;
1521 if (!intel_pinctrl_should_save(pctrl
, desc
->number
))
1524 padcfg
= intel_get_padcfg(pctrl
, desc
->number
, PADCFG0
);
1525 val
= readl(padcfg
) & ~PADCFG0_GPIORXSTATE
;
1526 if (val
!= pads
[i
].padcfg0
) {
1527 writel(pads
[i
].padcfg0
, padcfg
);
1528 dev_dbg(dev
, "restored pin %u padcfg0 %#08x\n",
1529 desc
->number
, readl(padcfg
));
1532 padcfg
= intel_get_padcfg(pctrl
, desc
->number
, PADCFG1
);
1533 val
= readl(padcfg
);
1534 if (val
!= pads
[i
].padcfg1
) {
1535 writel(pads
[i
].padcfg1
, padcfg
);
1536 dev_dbg(dev
, "restored pin %u padcfg1 %#08x\n",
1537 desc
->number
, readl(padcfg
));
1540 padcfg
= intel_get_padcfg(pctrl
, desc
->number
, PADCFG2
);
1542 val
= readl(padcfg
);
1543 if (val
!= pads
[i
].padcfg2
) {
1544 writel(pads
[i
].padcfg2
, padcfg
);
1545 dev_dbg(dev
, "restored pin %u padcfg2 %#08x\n",
1546 desc
->number
, readl(padcfg
));
1551 communities
= pctrl
->context
.communities
;
1552 for (i
= 0; i
< pctrl
->ncommunities
; i
++) {
1553 struct intel_community
*community
= &pctrl
->communities
[i
];
1557 base
= community
->regs
+ community
->ie_offset
;
1558 for (gpp
= 0; gpp
< community
->ngpps
; gpp
++) {
1559 writel(communities
[i
].intmask
[gpp
], base
+ gpp
* 4);
1560 dev_dbg(dev
, "restored mask %d/%u %#08x\n", i
, gpp
,
1561 readl(base
+ gpp
* 4));
1567 EXPORT_SYMBOL_GPL(intel_pinctrl_resume_noirq
);
1570 MODULE_AUTHOR("Mathias Nyman <mathias.nyman@linux.intel.com>");
1571 MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
1572 MODULE_DESCRIPTION("Intel pinctrl/GPIO core driver");
1573 MODULE_LICENSE("GPL v2");