1 // SPDX-License-Identifier: GPL-2.0+
3 // Exynos specific support for Samsung pinctrl/gpiolib driver with eint support.
5 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 // http://www.samsung.com
7 // Copyright (c) 2012 Linaro Ltd
8 // http://www.linaro.org
10 // Author: Thomas Abraham <thomas.ab@samsung.com>
12 // This file contains the Samsung Exynos specific information required by the
13 // the Samsung pinctrl/gpiolib driver. It also includes the implementation of
14 // external gpio and wakeup interrupt support.
16 #include <linux/device.h>
17 #include <linux/interrupt.h>
18 #include <linux/irqdomain.h>
19 #include <linux/irq.h>
20 #include <linux/irqchip/chained_irq.h>
22 #include <linux/of_irq.h>
23 #include <linux/slab.h>
24 #include <linux/spinlock.h>
25 #include <linux/regmap.h>
26 #include <linux/err.h>
27 #include <linux/soc/samsung/exynos-pmu.h>
28 #include <linux/soc/samsung/exynos-regs-pmu.h>
30 #include <dt-bindings/pinctrl/samsung.h>
32 #include "pinctrl-samsung.h"
33 #include "pinctrl-exynos.h"
35 struct exynos_irq_chip
{
41 u32 eint_wake_mask_value
;
42 u32 eint_wake_mask_reg
;
45 static inline struct exynos_irq_chip
*to_exynos_irq_chip(struct irq_chip
*chip
)
47 return container_of(chip
, struct exynos_irq_chip
, chip
);
50 static void exynos_irq_mask(struct irq_data
*irqd
)
52 struct irq_chip
*chip
= irq_data_get_irq_chip(irqd
);
53 struct exynos_irq_chip
*our_chip
= to_exynos_irq_chip(chip
);
54 struct samsung_pin_bank
*bank
= irq_data_get_irq_chip_data(irqd
);
55 unsigned long reg_mask
= our_chip
->eint_mask
+ bank
->eint_offset
;
59 spin_lock_irqsave(&bank
->slock
, flags
);
61 mask
= readl(bank
->eint_base
+ reg_mask
);
62 mask
|= 1 << irqd
->hwirq
;
63 writel(mask
, bank
->eint_base
+ reg_mask
);
65 spin_unlock_irqrestore(&bank
->slock
, flags
);
68 static void exynos_irq_ack(struct irq_data
*irqd
)
70 struct irq_chip
*chip
= irq_data_get_irq_chip(irqd
);
71 struct exynos_irq_chip
*our_chip
= to_exynos_irq_chip(chip
);
72 struct samsung_pin_bank
*bank
= irq_data_get_irq_chip_data(irqd
);
73 unsigned long reg_pend
= our_chip
->eint_pend
+ bank
->eint_offset
;
75 writel(1 << irqd
->hwirq
, bank
->eint_base
+ reg_pend
);
78 static void exynos_irq_unmask(struct irq_data
*irqd
)
80 struct irq_chip
*chip
= irq_data_get_irq_chip(irqd
);
81 struct exynos_irq_chip
*our_chip
= to_exynos_irq_chip(chip
);
82 struct samsung_pin_bank
*bank
= irq_data_get_irq_chip_data(irqd
);
83 unsigned long reg_mask
= our_chip
->eint_mask
+ bank
->eint_offset
;
88 * Ack level interrupts right before unmask
90 * If we don't do this we'll get a double-interrupt. Level triggered
91 * interrupts must not fire an interrupt if the level is not
92 * _currently_ active, even if it was active while the interrupt was
95 if (irqd_get_trigger_type(irqd
) & IRQ_TYPE_LEVEL_MASK
)
98 spin_lock_irqsave(&bank
->slock
, flags
);
100 mask
= readl(bank
->eint_base
+ reg_mask
);
101 mask
&= ~(1 << irqd
->hwirq
);
102 writel(mask
, bank
->eint_base
+ reg_mask
);
104 spin_unlock_irqrestore(&bank
->slock
, flags
);
107 static int exynos_irq_set_type(struct irq_data
*irqd
, unsigned int type
)
109 struct irq_chip
*chip
= irq_data_get_irq_chip(irqd
);
110 struct exynos_irq_chip
*our_chip
= to_exynos_irq_chip(chip
);
111 struct samsung_pin_bank
*bank
= irq_data_get_irq_chip_data(irqd
);
112 unsigned int shift
= EXYNOS_EINT_CON_LEN
* irqd
->hwirq
;
113 unsigned int con
, trig_type
;
114 unsigned long reg_con
= our_chip
->eint_con
+ bank
->eint_offset
;
117 case IRQ_TYPE_EDGE_RISING
:
118 trig_type
= EXYNOS_EINT_EDGE_RISING
;
120 case IRQ_TYPE_EDGE_FALLING
:
121 trig_type
= EXYNOS_EINT_EDGE_FALLING
;
123 case IRQ_TYPE_EDGE_BOTH
:
124 trig_type
= EXYNOS_EINT_EDGE_BOTH
;
126 case IRQ_TYPE_LEVEL_HIGH
:
127 trig_type
= EXYNOS_EINT_LEVEL_HIGH
;
129 case IRQ_TYPE_LEVEL_LOW
:
130 trig_type
= EXYNOS_EINT_LEVEL_LOW
;
133 pr_err("unsupported external interrupt type\n");
137 if (type
& IRQ_TYPE_EDGE_BOTH
)
138 irq_set_handler_locked(irqd
, handle_edge_irq
);
140 irq_set_handler_locked(irqd
, handle_level_irq
);
142 con
= readl(bank
->eint_base
+ reg_con
);
143 con
&= ~(EXYNOS_EINT_CON_MASK
<< shift
);
144 con
|= trig_type
<< shift
;
145 writel(con
, bank
->eint_base
+ reg_con
);
150 static int exynos_irq_request_resources(struct irq_data
*irqd
)
152 struct samsung_pin_bank
*bank
= irq_data_get_irq_chip_data(irqd
);
153 const struct samsung_pin_bank_type
*bank_type
= bank
->type
;
154 unsigned long reg_con
, flags
;
155 unsigned int shift
, mask
, con
;
158 ret
= gpiochip_lock_as_irq(&bank
->gpio_chip
, irqd
->hwirq
);
160 dev_err(bank
->gpio_chip
.parent
,
161 "unable to lock pin %s-%lu IRQ\n",
162 bank
->name
, irqd
->hwirq
);
166 reg_con
= bank
->pctl_offset
+ bank_type
->reg_offset
[PINCFG_TYPE_FUNC
];
167 shift
= irqd
->hwirq
* bank_type
->fld_width
[PINCFG_TYPE_FUNC
];
168 mask
= (1 << bank_type
->fld_width
[PINCFG_TYPE_FUNC
]) - 1;
170 spin_lock_irqsave(&bank
->slock
, flags
);
172 con
= readl(bank
->pctl_base
+ reg_con
);
173 con
&= ~(mask
<< shift
);
174 con
|= EXYNOS_PIN_FUNC_EINT
<< shift
;
175 writel(con
, bank
->pctl_base
+ reg_con
);
177 spin_unlock_irqrestore(&bank
->slock
, flags
);
182 static void exynos_irq_release_resources(struct irq_data
*irqd
)
184 struct samsung_pin_bank
*bank
= irq_data_get_irq_chip_data(irqd
);
185 const struct samsung_pin_bank_type
*bank_type
= bank
->type
;
186 unsigned long reg_con
, flags
;
187 unsigned int shift
, mask
, con
;
189 reg_con
= bank
->pctl_offset
+ bank_type
->reg_offset
[PINCFG_TYPE_FUNC
];
190 shift
= irqd
->hwirq
* bank_type
->fld_width
[PINCFG_TYPE_FUNC
];
191 mask
= (1 << bank_type
->fld_width
[PINCFG_TYPE_FUNC
]) - 1;
193 spin_lock_irqsave(&bank
->slock
, flags
);
195 con
= readl(bank
->pctl_base
+ reg_con
);
196 con
&= ~(mask
<< shift
);
197 con
|= EXYNOS_PIN_FUNC_INPUT
<< shift
;
198 writel(con
, bank
->pctl_base
+ reg_con
);
200 spin_unlock_irqrestore(&bank
->slock
, flags
);
202 gpiochip_unlock_as_irq(&bank
->gpio_chip
, irqd
->hwirq
);
206 * irq_chip for gpio interrupts.
208 static struct exynos_irq_chip exynos_gpio_irq_chip
= {
210 .name
= "exynos_gpio_irq_chip",
211 .irq_unmask
= exynos_irq_unmask
,
212 .irq_mask
= exynos_irq_mask
,
213 .irq_ack
= exynos_irq_ack
,
214 .irq_set_type
= exynos_irq_set_type
,
215 .irq_request_resources
= exynos_irq_request_resources
,
216 .irq_release_resources
= exynos_irq_release_resources
,
218 .eint_con
= EXYNOS_GPIO_ECON_OFFSET
,
219 .eint_mask
= EXYNOS_GPIO_EMASK_OFFSET
,
220 .eint_pend
= EXYNOS_GPIO_EPEND_OFFSET
,
221 /* eint_wake_mask_value not used */
224 static int exynos_eint_irq_map(struct irq_domain
*h
, unsigned int virq
,
227 struct samsung_pin_bank
*b
= h
->host_data
;
229 irq_set_chip_data(virq
, b
);
230 irq_set_chip_and_handler(virq
, &b
->irq_chip
->chip
,
236 * irq domain callbacks for external gpio and wakeup interrupt controllers.
238 static const struct irq_domain_ops exynos_eint_irqd_ops
= {
239 .map
= exynos_eint_irq_map
,
240 .xlate
= irq_domain_xlate_twocell
,
243 static irqreturn_t
exynos_eint_gpio_irq(int irq
, void *data
)
245 struct samsung_pinctrl_drv_data
*d
= data
;
246 struct samsung_pin_bank
*bank
= d
->pin_banks
;
247 unsigned int svc
, group
, pin
, virq
;
249 svc
= readl(bank
->eint_base
+ EXYNOS_SVC_OFFSET
);
250 group
= EXYNOS_SVC_GROUP(svc
);
251 pin
= svc
& EXYNOS_SVC_NUM_MASK
;
257 virq
= irq_linear_revmap(bank
->irq_domain
, pin
);
260 generic_handle_irq(virq
);
264 struct exynos_eint_gpio_save
{
271 * exynos_eint_gpio_init() - setup handling of external gpio interrupts.
272 * @d: driver data of samsung pinctrl driver.
274 int exynos_eint_gpio_init(struct samsung_pinctrl_drv_data
*d
)
276 struct samsung_pin_bank
*bank
;
277 struct device
*dev
= d
->dev
;
282 dev_err(dev
, "irq number not available\n");
286 ret
= devm_request_irq(dev
, d
->irq
, exynos_eint_gpio_irq
,
287 0, dev_name(dev
), d
);
289 dev_err(dev
, "irq request failed\n");
294 for (i
= 0; i
< d
->nr_banks
; ++i
, ++bank
) {
295 if (bank
->eint_type
!= EINT_TYPE_GPIO
)
297 bank
->irq_domain
= irq_domain_add_linear(bank
->of_node
,
298 bank
->nr_pins
, &exynos_eint_irqd_ops
, bank
);
299 if (!bank
->irq_domain
) {
300 dev_err(dev
, "gpio irq domain add failed\n");
305 bank
->soc_priv
= devm_kzalloc(d
->dev
,
306 sizeof(struct exynos_eint_gpio_save
), GFP_KERNEL
);
307 if (!bank
->soc_priv
) {
308 irq_domain_remove(bank
->irq_domain
);
313 bank
->irq_chip
= &exynos_gpio_irq_chip
;
319 for (--i
, --bank
; i
>= 0; --i
, --bank
) {
320 if (bank
->eint_type
!= EINT_TYPE_GPIO
)
322 irq_domain_remove(bank
->irq_domain
);
328 static int exynos_wkup_irq_set_wake(struct irq_data
*irqd
, unsigned int on
)
330 struct irq_chip
*chip
= irq_data_get_irq_chip(irqd
);
331 struct exynos_irq_chip
*our_chip
= to_exynos_irq_chip(chip
);
332 struct samsung_pin_bank
*bank
= irq_data_get_irq_chip_data(irqd
);
333 unsigned long bit
= 1UL << (2 * bank
->eint_offset
+ irqd
->hwirq
);
335 pr_info("wake %s for irq %d\n", on
? "enabled" : "disabled", irqd
->irq
);
338 our_chip
->eint_wake_mask_value
|= bit
;
340 our_chip
->eint_wake_mask_value
&= ~bit
;
346 * irq_chip for wakeup interrupts
348 static const struct exynos_irq_chip s5pv210_wkup_irq_chip __initconst
= {
350 .name
= "s5pv210_wkup_irq_chip",
351 .irq_unmask
= exynos_irq_unmask
,
352 .irq_mask
= exynos_irq_mask
,
353 .irq_ack
= exynos_irq_ack
,
354 .irq_set_type
= exynos_irq_set_type
,
355 .irq_set_wake
= exynos_wkup_irq_set_wake
,
356 .irq_request_resources
= exynos_irq_request_resources
,
357 .irq_release_resources
= exynos_irq_release_resources
,
359 .eint_con
= EXYNOS_WKUP_ECON_OFFSET
,
360 .eint_mask
= EXYNOS_WKUP_EMASK_OFFSET
,
361 .eint_pend
= EXYNOS_WKUP_EPEND_OFFSET
,
362 .eint_wake_mask_value
= EXYNOS_EINT_WAKEUP_MASK_DISABLED
,
363 /* Only difference with exynos4210_wkup_irq_chip: */
364 .eint_wake_mask_reg
= S5PV210_EINT_WAKEUP_MASK
,
367 static const struct exynos_irq_chip exynos4210_wkup_irq_chip __initconst
= {
369 .name
= "exynos4210_wkup_irq_chip",
370 .irq_unmask
= exynos_irq_unmask
,
371 .irq_mask
= exynos_irq_mask
,
372 .irq_ack
= exynos_irq_ack
,
373 .irq_set_type
= exynos_irq_set_type
,
374 .irq_set_wake
= exynos_wkup_irq_set_wake
,
375 .irq_request_resources
= exynos_irq_request_resources
,
376 .irq_release_resources
= exynos_irq_release_resources
,
378 .eint_con
= EXYNOS_WKUP_ECON_OFFSET
,
379 .eint_mask
= EXYNOS_WKUP_EMASK_OFFSET
,
380 .eint_pend
= EXYNOS_WKUP_EPEND_OFFSET
,
381 .eint_wake_mask_value
= EXYNOS_EINT_WAKEUP_MASK_DISABLED
,
382 .eint_wake_mask_reg
= EXYNOS_EINT_WAKEUP_MASK
,
385 static const struct exynos_irq_chip exynos7_wkup_irq_chip __initconst
= {
387 .name
= "exynos7_wkup_irq_chip",
388 .irq_unmask
= exynos_irq_unmask
,
389 .irq_mask
= exynos_irq_mask
,
390 .irq_ack
= exynos_irq_ack
,
391 .irq_set_type
= exynos_irq_set_type
,
392 .irq_set_wake
= exynos_wkup_irq_set_wake
,
393 .irq_request_resources
= exynos_irq_request_resources
,
394 .irq_release_resources
= exynos_irq_release_resources
,
396 .eint_con
= EXYNOS7_WKUP_ECON_OFFSET
,
397 .eint_mask
= EXYNOS7_WKUP_EMASK_OFFSET
,
398 .eint_pend
= EXYNOS7_WKUP_EPEND_OFFSET
,
399 .eint_wake_mask_value
= EXYNOS_EINT_WAKEUP_MASK_DISABLED
,
400 .eint_wake_mask_reg
= EXYNOS5433_EINT_WAKEUP_MASK
,
403 /* list of external wakeup controllers supported */
404 static const struct of_device_id exynos_wkup_irq_ids
[] = {
405 { .compatible
= "samsung,s5pv210-wakeup-eint",
406 .data
= &s5pv210_wkup_irq_chip
},
407 { .compatible
= "samsung,exynos4210-wakeup-eint",
408 .data
= &exynos4210_wkup_irq_chip
},
409 { .compatible
= "samsung,exynos7-wakeup-eint",
410 .data
= &exynos7_wkup_irq_chip
},
414 /* interrupt handler for wakeup interrupts 0..15 */
415 static void exynos_irq_eint0_15(struct irq_desc
*desc
)
417 struct exynos_weint_data
*eintd
= irq_desc_get_handler_data(desc
);
418 struct samsung_pin_bank
*bank
= eintd
->bank
;
419 struct irq_chip
*chip
= irq_desc_get_chip(desc
);
422 chained_irq_enter(chip
, desc
);
424 eint_irq
= irq_linear_revmap(bank
->irq_domain
, eintd
->irq
);
425 generic_handle_irq(eint_irq
);
427 chained_irq_exit(chip
, desc
);
430 static inline void exynos_irq_demux_eint(unsigned long pend
,
431 struct irq_domain
*domain
)
437 generic_handle_irq(irq_find_mapping(domain
, irq
));
442 /* interrupt handler for wakeup interrupt 16 */
443 static void exynos_irq_demux_eint16_31(struct irq_desc
*desc
)
445 struct irq_chip
*chip
= irq_desc_get_chip(desc
);
446 struct exynos_muxed_weint_data
*eintd
= irq_desc_get_handler_data(desc
);
451 chained_irq_enter(chip
, desc
);
453 for (i
= 0; i
< eintd
->nr_banks
; ++i
) {
454 struct samsung_pin_bank
*b
= eintd
->banks
[i
];
455 pend
= readl(b
->eint_base
+ b
->irq_chip
->eint_pend
457 mask
= readl(b
->eint_base
+ b
->irq_chip
->eint_mask
459 exynos_irq_demux_eint(pend
& ~mask
, b
->irq_domain
);
462 chained_irq_exit(chip
, desc
);
466 * exynos_eint_wkup_init() - setup handling of external wakeup interrupts.
467 * @d: driver data of samsung pinctrl driver.
469 int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data
*d
)
471 struct device
*dev
= d
->dev
;
472 struct device_node
*wkup_np
= NULL
;
473 struct device_node
*np
;
474 struct samsung_pin_bank
*bank
;
475 struct exynos_weint_data
*weint_data
;
476 struct exynos_muxed_weint_data
*muxed_data
;
477 struct exynos_irq_chip
*irq_chip
;
478 unsigned int muxed_banks
= 0;
482 for_each_child_of_node(dev
->of_node
, np
) {
483 const struct of_device_id
*match
;
485 match
= of_match_node(exynos_wkup_irq_ids
, np
);
487 irq_chip
= kmemdup(match
->data
,
488 sizeof(*irq_chip
), GFP_KERNEL
);
499 for (i
= 0; i
< d
->nr_banks
; ++i
, ++bank
) {
500 if (bank
->eint_type
!= EINT_TYPE_WKUP
)
503 bank
->irq_domain
= irq_domain_add_linear(bank
->of_node
,
504 bank
->nr_pins
, &exynos_eint_irqd_ops
, bank
);
505 if (!bank
->irq_domain
) {
506 dev_err(dev
, "wkup irq domain add failed\n");
510 bank
->irq_chip
= irq_chip
;
512 if (!of_find_property(bank
->of_node
, "interrupts", NULL
)) {
513 bank
->eint_type
= EINT_TYPE_WKUP_MUX
;
518 weint_data
= devm_kcalloc(dev
,
519 bank
->nr_pins
, sizeof(*weint_data
),
524 for (idx
= 0; idx
< bank
->nr_pins
; ++idx
) {
525 irq
= irq_of_parse_and_map(bank
->of_node
, idx
);
527 dev_err(dev
, "irq number for eint-%s-%d not found\n",
531 weint_data
[idx
].irq
= idx
;
532 weint_data
[idx
].bank
= bank
;
533 irq_set_chained_handler_and_data(irq
,
542 irq
= irq_of_parse_and_map(wkup_np
, 0);
544 dev_err(dev
, "irq number for muxed EINTs not found\n");
548 muxed_data
= devm_kzalloc(dev
, sizeof(*muxed_data
)
549 + muxed_banks
*sizeof(struct samsung_pin_bank
*), GFP_KERNEL
);
553 irq_set_chained_handler_and_data(irq
, exynos_irq_demux_eint16_31
,
558 for (i
= 0; i
< d
->nr_banks
; ++i
, ++bank
) {
559 if (bank
->eint_type
!= EINT_TYPE_WKUP_MUX
)
562 muxed_data
->banks
[idx
++] = bank
;
564 muxed_data
->nr_banks
= muxed_banks
;
570 exynos_pinctrl_set_eint_wakeup_mask(struct samsung_pinctrl_drv_data
*drvdata
,
571 struct exynos_irq_chip
*irq_chip
)
573 struct regmap
*pmu_regs
;
575 if (!drvdata
->retention_ctrl
|| !drvdata
->retention_ctrl
->priv
) {
576 dev_warn(drvdata
->dev
,
577 "No retention data configured bank with external wakeup interrupt. Wake-up mask will not be set.\n");
581 pmu_regs
= drvdata
->retention_ctrl
->priv
;
582 dev_info(drvdata
->dev
,
583 "Setting external wakeup interrupt mask: 0x%x\n",
584 irq_chip
->eint_wake_mask_value
);
586 regmap_write(pmu_regs
, irq_chip
->eint_wake_mask_reg
,
587 irq_chip
->eint_wake_mask_value
);
590 static void exynos_pinctrl_suspend_bank(
591 struct samsung_pinctrl_drv_data
*drvdata
,
592 struct samsung_pin_bank
*bank
)
594 struct exynos_eint_gpio_save
*save
= bank
->soc_priv
;
595 void __iomem
*regs
= bank
->eint_base
;
597 save
->eint_con
= readl(regs
+ EXYNOS_GPIO_ECON_OFFSET
598 + bank
->eint_offset
);
599 save
->eint_fltcon0
= readl(regs
+ EXYNOS_GPIO_EFLTCON_OFFSET
600 + 2 * bank
->eint_offset
);
601 save
->eint_fltcon1
= readl(regs
+ EXYNOS_GPIO_EFLTCON_OFFSET
602 + 2 * bank
->eint_offset
+ 4);
604 pr_debug("%s: save con %#010x\n", bank
->name
, save
->eint_con
);
605 pr_debug("%s: save fltcon0 %#010x\n", bank
->name
, save
->eint_fltcon0
);
606 pr_debug("%s: save fltcon1 %#010x\n", bank
->name
, save
->eint_fltcon1
);
609 void exynos_pinctrl_suspend(struct samsung_pinctrl_drv_data
*drvdata
)
611 struct samsung_pin_bank
*bank
= drvdata
->pin_banks
;
612 struct exynos_irq_chip
*irq_chip
= NULL
;
615 for (i
= 0; i
< drvdata
->nr_banks
; ++i
, ++bank
) {
616 if (bank
->eint_type
== EINT_TYPE_GPIO
)
617 exynos_pinctrl_suspend_bank(drvdata
, bank
);
618 else if (bank
->eint_type
== EINT_TYPE_WKUP
) {
620 irq_chip
= bank
->irq_chip
;
621 exynos_pinctrl_set_eint_wakeup_mask(drvdata
,
623 } else if (bank
->irq_chip
!= irq_chip
) {
624 dev_warn(drvdata
->dev
,
625 "More than one external wakeup interrupt chip configured (bank: %s). This is not supported by hardware nor by driver.\n",
632 static void exynos_pinctrl_resume_bank(
633 struct samsung_pinctrl_drv_data
*drvdata
,
634 struct samsung_pin_bank
*bank
)
636 struct exynos_eint_gpio_save
*save
= bank
->soc_priv
;
637 void __iomem
*regs
= bank
->eint_base
;
639 pr_debug("%s: con %#010x => %#010x\n", bank
->name
,
640 readl(regs
+ EXYNOS_GPIO_ECON_OFFSET
641 + bank
->eint_offset
), save
->eint_con
);
642 pr_debug("%s: fltcon0 %#010x => %#010x\n", bank
->name
,
643 readl(regs
+ EXYNOS_GPIO_EFLTCON_OFFSET
644 + 2 * bank
->eint_offset
), save
->eint_fltcon0
);
645 pr_debug("%s: fltcon1 %#010x => %#010x\n", bank
->name
,
646 readl(regs
+ EXYNOS_GPIO_EFLTCON_OFFSET
647 + 2 * bank
->eint_offset
+ 4), save
->eint_fltcon1
);
649 writel(save
->eint_con
, regs
+ EXYNOS_GPIO_ECON_OFFSET
650 + bank
->eint_offset
);
651 writel(save
->eint_fltcon0
, regs
+ EXYNOS_GPIO_EFLTCON_OFFSET
652 + 2 * bank
->eint_offset
);
653 writel(save
->eint_fltcon1
, regs
+ EXYNOS_GPIO_EFLTCON_OFFSET
654 + 2 * bank
->eint_offset
+ 4);
657 void exynos_pinctrl_resume(struct samsung_pinctrl_drv_data
*drvdata
)
659 struct samsung_pin_bank
*bank
= drvdata
->pin_banks
;
662 for (i
= 0; i
< drvdata
->nr_banks
; ++i
, ++bank
)
663 if (bank
->eint_type
== EINT_TYPE_GPIO
)
664 exynos_pinctrl_resume_bank(drvdata
, bank
);
667 static void exynos_retention_enable(struct samsung_pinctrl_drv_data
*drvdata
)
669 if (drvdata
->retention_ctrl
->refcnt
)
670 atomic_inc(drvdata
->retention_ctrl
->refcnt
);
673 static void exynos_retention_disable(struct samsung_pinctrl_drv_data
*drvdata
)
675 struct samsung_retention_ctrl
*ctrl
= drvdata
->retention_ctrl
;
676 struct regmap
*pmu_regs
= ctrl
->priv
;
679 if (ctrl
->refcnt
&& !atomic_dec_and_test(ctrl
->refcnt
))
682 for (i
= 0; i
< ctrl
->nr_regs
; i
++)
683 regmap_write(pmu_regs
, ctrl
->regs
[i
], ctrl
->value
);
686 struct samsung_retention_ctrl
*
687 exynos_retention_init(struct samsung_pinctrl_drv_data
*drvdata
,
688 const struct samsung_retention_data
*data
)
690 struct samsung_retention_ctrl
*ctrl
;
691 struct regmap
*pmu_regs
;
694 ctrl
= devm_kzalloc(drvdata
->dev
, sizeof(*ctrl
), GFP_KERNEL
);
696 return ERR_PTR(-ENOMEM
);
698 pmu_regs
= exynos_get_pmu_regmap();
699 if (IS_ERR(pmu_regs
))
700 return ERR_CAST(pmu_regs
);
702 ctrl
->priv
= pmu_regs
;
703 ctrl
->regs
= data
->regs
;
704 ctrl
->nr_regs
= data
->nr_regs
;
705 ctrl
->value
= data
->value
;
706 ctrl
->refcnt
= data
->refcnt
;
707 ctrl
->enable
= exynos_retention_enable
;
708 ctrl
->disable
= exynos_retention_disable
;
710 /* Ensure that retention is disabled on driver init */
711 for (i
= 0; i
< ctrl
->nr_regs
; i
++)
712 regmap_write(pmu_regs
, ctrl
->regs
[i
], ctrl
->value
);