2 * Pinctrl GPIO driver for Intel Baytrail
3 * Copyright (c) 2012-2013, Intel Corporation.
5 * Author: Mathias Nyman <mathias.nyman@linux.intel.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/init.h>
20 #include <linux/types.h>
21 #include <linux/bitops.h>
22 #include <linux/interrupt.h>
23 #include <linux/gpio/driver.h>
24 #include <linux/acpi.h>
25 #include <linux/platform_device.h>
26 #include <linux/seq_file.h>
28 #include <linux/pm_runtime.h>
29 #include <linux/pinctrl/pinctrl.h>
31 /* memory mapped register offsets */
32 #define BYT_CONF0_REG 0x000
33 #define BYT_CONF1_REG 0x004
34 #define BYT_VAL_REG 0x008
35 #define BYT_DFT_REG 0x00c
36 #define BYT_INT_STAT_REG 0x800
38 /* BYT_CONF0_REG register bits */
39 #define BYT_IODEN BIT(31)
40 #define BYT_DIRECT_IRQ_EN BIT(27)
41 #define BYT_TRIG_NEG BIT(26)
42 #define BYT_TRIG_POS BIT(25)
43 #define BYT_TRIG_LVL BIT(24)
44 #define BYT_PULL_STR_SHIFT 9
45 #define BYT_PULL_STR_MASK (3 << BYT_PULL_STR_SHIFT)
46 #define BYT_PULL_STR_2K (0 << BYT_PULL_STR_SHIFT)
47 #define BYT_PULL_STR_10K (1 << BYT_PULL_STR_SHIFT)
48 #define BYT_PULL_STR_20K (2 << BYT_PULL_STR_SHIFT)
49 #define BYT_PULL_STR_40K (3 << BYT_PULL_STR_SHIFT)
50 #define BYT_PULL_ASSIGN_SHIFT 7
51 #define BYT_PULL_ASSIGN_MASK (3 << BYT_PULL_ASSIGN_SHIFT)
52 #define BYT_PULL_ASSIGN_UP (1 << BYT_PULL_ASSIGN_SHIFT)
53 #define BYT_PULL_ASSIGN_DOWN (2 << BYT_PULL_ASSIGN_SHIFT)
54 #define BYT_PIN_MUX 0x07
56 /* BYT_VAL_REG register bits */
57 #define BYT_INPUT_EN BIT(2) /* 0: input enabled (active low)*/
58 #define BYT_OUTPUT_EN BIT(1) /* 0: output enabled (active low)*/
59 #define BYT_LEVEL BIT(0)
61 #define BYT_DIR_MASK (BIT(1) | BIT(2))
62 #define BYT_TRIG_MASK (BIT(26) | BIT(25) | BIT(24))
64 #define BYT_CONF0_RESTORE_MASK (BYT_DIRECT_IRQ_EN | BYT_TRIG_MASK | \
66 #define BYT_VAL_RESTORE_MASK (BYT_DIR_MASK | BYT_LEVEL)
68 #define BYT_NGPIO_SCORE 102
69 #define BYT_NGPIO_NCORE 28
70 #define BYT_NGPIO_SUS 44
72 #define BYT_SCORE_ACPI_UID "1"
73 #define BYT_NCORE_ACPI_UID "2"
74 #define BYT_SUS_ACPI_UID "3"
77 * Baytrail gpio controller consist of three separate sub-controllers called
78 * SCORE, NCORE and SUS. The sub-controllers are identified by their acpi UID.
80 * GPIO numbering is _not_ ordered meaning that gpio # 0 in ACPI namespace does
81 * _not_ correspond to the first gpio register at controller's gpio base.
82 * There is no logic or pattern in mapping gpio numbers to registers (pads) so
83 * each sub-controller needs to have its own mapping table
86 /* score_pins[gpio_nr] = pad_nr */
88 static unsigned const score_pins
[BYT_NGPIO_SCORE
] = {
89 85, 89, 93, 96, 99, 102, 98, 101, 34, 37,
90 36, 38, 39, 35, 40, 84, 62, 61, 64, 59,
91 54, 56, 60, 55, 63, 57, 51, 50, 53, 47,
92 52, 49, 48, 43, 46, 41, 45, 42, 58, 44,
93 95, 105, 70, 68, 67, 66, 69, 71, 65, 72,
94 86, 90, 88, 92, 103, 77, 79, 83, 78, 81,
95 80, 82, 13, 12, 15, 14, 17, 18, 19, 16,
96 2, 1, 0, 4, 6, 7, 9, 8, 33, 32,
97 31, 30, 29, 27, 25, 28, 26, 23, 21, 20,
98 24, 22, 5, 3, 10, 11, 106, 87, 91, 104,
102 static unsigned const ncore_pins
[BYT_NGPIO_NCORE
] = {
103 19, 18, 17, 20, 21, 22, 24, 25, 23, 16,
104 14, 15, 12, 26, 27, 1, 4, 8, 11, 0,
105 3, 6, 10, 13, 2, 5, 9, 7,
108 static unsigned const sus_pins
[BYT_NGPIO_SUS
] = {
109 29, 33, 30, 31, 32, 34, 36, 35, 38, 37,
110 18, 7, 11, 20, 17, 1, 8, 10, 19, 12,
111 0, 2, 23, 39, 28, 27, 22, 21, 24, 25,
112 26, 51, 56, 54, 49, 55, 48, 57, 50, 58,
116 static struct pinctrl_gpio_range byt_ranges
[] = {
118 .name
= BYT_SCORE_ACPI_UID
, /* match with acpi _UID in probe */
119 .npins
= BYT_NGPIO_SCORE
,
123 .name
= BYT_NCORE_ACPI_UID
,
124 .npins
= BYT_NGPIO_NCORE
,
128 .name
= BYT_SUS_ACPI_UID
,
129 .npins
= BYT_NGPIO_SUS
,
136 struct byt_gpio_pin_context
{
142 struct gpio_chip chip
;
143 struct platform_device
*pdev
;
145 void __iomem
*reg_base
;
146 struct pinctrl_gpio_range
*range
;
147 struct byt_gpio_pin_context
*saved_context
;
150 static void __iomem
*byt_gpio_reg(struct gpio_chip
*chip
, unsigned offset
,
153 struct byt_gpio
*vg
= gpiochip_get_data(chip
);
156 if (reg
== BYT_INT_STAT_REG
)
157 reg_offset
= (offset
/ 32) * 4;
159 reg_offset
= vg
->range
->pins
[offset
] * 16;
161 return vg
->reg_base
+ reg_offset
+ reg
;
164 static void byt_gpio_clear_triggering(struct byt_gpio
*vg
, unsigned offset
)
166 void __iomem
*reg
= byt_gpio_reg(&vg
->chip
, offset
, BYT_CONF0_REG
);
170 raw_spin_lock_irqsave(&vg
->lock
, flags
);
172 value
&= ~(BYT_TRIG_POS
| BYT_TRIG_NEG
| BYT_TRIG_LVL
);
174 raw_spin_unlock_irqrestore(&vg
->lock
, flags
);
177 static u32
byt_get_gpio_mux(struct byt_gpio
*vg
, unsigned offset
)
179 /* SCORE pin 92-93 */
180 if (!strcmp(vg
->range
->name
, BYT_SCORE_ACPI_UID
) &&
181 offset
>= 92 && offset
<= 93)
185 if (!strcmp(vg
->range
->name
, BYT_SUS_ACPI_UID
) &&
186 offset
>= 11 && offset
<= 21)
192 static int byt_gpio_request(struct gpio_chip
*chip
, unsigned offset
)
194 struct byt_gpio
*vg
= gpiochip_get_data(chip
);
195 void __iomem
*reg
= byt_gpio_reg(chip
, offset
, BYT_CONF0_REG
);
199 raw_spin_lock_irqsave(&vg
->lock
, flags
);
202 * In most cases, func pin mux 000 means GPIO function.
203 * But, some pins may have func pin mux 001 represents
206 * Because there are devices out there where some pins were not
207 * configured correctly we allow changing the mux value from
208 * request (but print out warning about that).
210 value
= readl(reg
) & BYT_PIN_MUX
;
211 gpio_mux
= byt_get_gpio_mux(vg
, offset
);
212 if (WARN_ON(gpio_mux
!= value
)) {
213 value
= readl(reg
) & ~BYT_PIN_MUX
;
217 dev_warn(&vg
->pdev
->dev
,
218 "pin %u forcibly re-configured as GPIO\n", offset
);
221 raw_spin_unlock_irqrestore(&vg
->lock
, flags
);
223 pm_runtime_get(&vg
->pdev
->dev
);
228 static void byt_gpio_free(struct gpio_chip
*chip
, unsigned offset
)
230 struct byt_gpio
*vg
= gpiochip_get_data(chip
);
232 byt_gpio_clear_triggering(vg
, offset
);
233 pm_runtime_put(&vg
->pdev
->dev
);
236 static int byt_irq_type(struct irq_data
*d
, unsigned type
)
238 struct byt_gpio
*vg
= gpiochip_get_data(irq_data_get_irq_chip_data(d
));
239 u32 offset
= irqd_to_hwirq(d
);
242 void __iomem
*reg
= byt_gpio_reg(&vg
->chip
, offset
, BYT_CONF0_REG
);
244 if (offset
>= vg
->chip
.ngpio
)
247 raw_spin_lock_irqsave(&vg
->lock
, flags
);
250 WARN(value
& BYT_DIRECT_IRQ_EN
,
251 "Bad pad config for io mode, force direct_irq_en bit clearing");
253 /* For level trigges the BYT_TRIG_POS and BYT_TRIG_NEG bits
254 * are used to indicate high and low level triggering
256 value
&= ~(BYT_DIRECT_IRQ_EN
| BYT_TRIG_POS
| BYT_TRIG_NEG
|
261 if (type
& IRQ_TYPE_EDGE_BOTH
)
262 irq_set_handler_locked(d
, handle_edge_irq
);
263 else if (type
& IRQ_TYPE_LEVEL_MASK
)
264 irq_set_handler_locked(d
, handle_level_irq
);
266 raw_spin_unlock_irqrestore(&vg
->lock
, flags
);
271 static int byt_gpio_get(struct gpio_chip
*chip
, unsigned offset
)
273 void __iomem
*reg
= byt_gpio_reg(chip
, offset
, BYT_VAL_REG
);
274 struct byt_gpio
*vg
= gpiochip_get_data(chip
);
278 raw_spin_lock_irqsave(&vg
->lock
, flags
);
280 raw_spin_unlock_irqrestore(&vg
->lock
, flags
);
282 return !!(val
& BYT_LEVEL
);
285 static void byt_gpio_set(struct gpio_chip
*chip
, unsigned offset
, int value
)
287 struct byt_gpio
*vg
= gpiochip_get_data(chip
);
288 void __iomem
*reg
= byt_gpio_reg(chip
, offset
, BYT_VAL_REG
);
292 raw_spin_lock_irqsave(&vg
->lock
, flags
);
294 old_val
= readl(reg
);
297 writel(old_val
| BYT_LEVEL
, reg
);
299 writel(old_val
& ~BYT_LEVEL
, reg
);
301 raw_spin_unlock_irqrestore(&vg
->lock
, flags
);
304 static int byt_gpio_direction_input(struct gpio_chip
*chip
, unsigned offset
)
306 struct byt_gpio
*vg
= gpiochip_get_data(chip
);
307 void __iomem
*reg
= byt_gpio_reg(chip
, offset
, BYT_VAL_REG
);
311 raw_spin_lock_irqsave(&vg
->lock
, flags
);
313 value
= readl(reg
) | BYT_DIR_MASK
;
314 value
&= ~BYT_INPUT_EN
; /* active low */
317 raw_spin_unlock_irqrestore(&vg
->lock
, flags
);
322 static int byt_gpio_direction_output(struct gpio_chip
*chip
,
323 unsigned gpio
, int value
)
325 struct byt_gpio
*vg
= gpiochip_get_data(chip
);
326 void __iomem
*conf_reg
= byt_gpio_reg(chip
, gpio
, BYT_CONF0_REG
);
327 void __iomem
*reg
= byt_gpio_reg(chip
, gpio
, BYT_VAL_REG
);
331 raw_spin_lock_irqsave(&vg
->lock
, flags
);
334 * Before making any direction modifications, do a check if gpio
335 * is set for direct IRQ. On baytrail, setting GPIO to output does
336 * not make sense, so let's at least warn the caller before they shoot
337 * themselves in the foot.
339 WARN(readl(conf_reg
) & BYT_DIRECT_IRQ_EN
,
340 "Potential Error: Setting GPIO with direct_irq_en to output");
342 reg_val
= readl(reg
) | BYT_DIR_MASK
;
343 reg_val
&= ~(BYT_OUTPUT_EN
| BYT_INPUT_EN
);
346 writel(reg_val
| BYT_LEVEL
, reg
);
348 writel(reg_val
& ~BYT_LEVEL
, reg
);
350 raw_spin_unlock_irqrestore(&vg
->lock
, flags
);
355 static void byt_gpio_dbg_show(struct seq_file
*s
, struct gpio_chip
*chip
)
357 struct byt_gpio
*vg
= gpiochip_get_data(chip
);
359 u32 conf0
, val
, offs
;
361 for (i
= 0; i
< vg
->chip
.ngpio
; i
++) {
362 const char *pull_str
= NULL
;
363 const char *pull
= NULL
;
366 offs
= vg
->range
->pins
[i
] * 16;
368 raw_spin_lock_irqsave(&vg
->lock
, flags
);
369 conf0
= readl(vg
->reg_base
+ offs
+ BYT_CONF0_REG
);
370 val
= readl(vg
->reg_base
+ offs
+ BYT_VAL_REG
);
371 raw_spin_unlock_irqrestore(&vg
->lock
, flags
);
373 label
= gpiochip_is_requested(chip
, i
);
375 label
= "Unrequested";
377 switch (conf0
& BYT_PULL_ASSIGN_MASK
) {
378 case BYT_PULL_ASSIGN_UP
:
381 case BYT_PULL_ASSIGN_DOWN
:
386 switch (conf0
& BYT_PULL_STR_MASK
) {
387 case BYT_PULL_STR_2K
:
390 case BYT_PULL_STR_10K
:
393 case BYT_PULL_STR_20K
:
396 case BYT_PULL_STR_40K
:
402 " gpio-%-3d (%-20.20s) %s %s %s pad-%-3d offset:0x%03x mux:%d %s%s%s",
405 val
& BYT_INPUT_EN
? " " : "in",
406 val
& BYT_OUTPUT_EN
? " " : "out",
407 val
& BYT_LEVEL
? "hi" : "lo",
408 vg
->range
->pins
[i
], offs
,
410 conf0
& BYT_TRIG_NEG
? " fall" : " ",
411 conf0
& BYT_TRIG_POS
? " rise" : " ",
412 conf0
& BYT_TRIG_LVL
? " level" : " ");
414 if (pull
&& pull_str
)
415 seq_printf(s
, " %-4s %-3s", pull
, pull_str
);
419 if (conf0
& BYT_IODEN
)
420 seq_puts(s
, " open-drain");
426 static void byt_gpio_irq_handler(struct irq_desc
*desc
)
428 struct irq_data
*data
= irq_desc_get_irq_data(desc
);
429 struct byt_gpio
*vg
= gpiochip_get_data(irq_desc_get_handler_data(desc
));
430 struct irq_chip
*chip
= irq_data_get_irq_chip(data
);
433 unsigned long pending
;
436 /* check from GPIO controller which pin triggered the interrupt */
437 for (base
= 0; base
< vg
->chip
.ngpio
; base
+= 32) {
438 reg
= byt_gpio_reg(&vg
->chip
, base
, BYT_INT_STAT_REG
);
439 pending
= readl(reg
);
440 for_each_set_bit(pin
, &pending
, 32) {
441 virq
= irq_find_mapping(vg
->chip
.irqdomain
, base
+ pin
);
442 generic_handle_irq(virq
);
448 static void byt_irq_ack(struct irq_data
*d
)
450 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
451 struct byt_gpio
*vg
= gpiochip_get_data(gc
);
452 unsigned offset
= irqd_to_hwirq(d
);
455 raw_spin_lock(&vg
->lock
);
456 reg
= byt_gpio_reg(&vg
->chip
, offset
, BYT_INT_STAT_REG
);
457 writel(BIT(offset
% 32), reg
);
458 raw_spin_unlock(&vg
->lock
);
461 static void byt_irq_unmask(struct irq_data
*d
)
463 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
464 struct byt_gpio
*vg
= gpiochip_get_data(gc
);
465 unsigned offset
= irqd_to_hwirq(d
);
470 reg
= byt_gpio_reg(&vg
->chip
, offset
, BYT_CONF0_REG
);
472 raw_spin_lock_irqsave(&vg
->lock
, flags
);
475 switch (irqd_get_trigger_type(d
)) {
476 case IRQ_TYPE_LEVEL_HIGH
:
477 value
|= BYT_TRIG_LVL
;
478 case IRQ_TYPE_EDGE_RISING
:
479 value
|= BYT_TRIG_POS
;
481 case IRQ_TYPE_LEVEL_LOW
:
482 value
|= BYT_TRIG_LVL
;
483 case IRQ_TYPE_EDGE_FALLING
:
484 value
|= BYT_TRIG_NEG
;
486 case IRQ_TYPE_EDGE_BOTH
:
487 value
|= (BYT_TRIG_NEG
| BYT_TRIG_POS
);
493 raw_spin_unlock_irqrestore(&vg
->lock
, flags
);
496 static void byt_irq_mask(struct irq_data
*d
)
498 struct gpio_chip
*gc
= irq_data_get_irq_chip_data(d
);
499 struct byt_gpio
*vg
= gpiochip_get_data(gc
);
501 byt_gpio_clear_triggering(vg
, irqd_to_hwirq(d
));
504 static struct irq_chip byt_irqchip
= {
506 .irq_ack
= byt_irq_ack
,
507 .irq_mask
= byt_irq_mask
,
508 .irq_unmask
= byt_irq_unmask
,
509 .irq_set_type
= byt_irq_type
,
510 .flags
= IRQCHIP_SKIP_SET_WAKE
,
513 static void byt_gpio_irq_init_hw(struct byt_gpio
*vg
)
520 * Clear interrupt triggers for all pins that are GPIOs and
521 * do not use direct IRQ mode. This will prevent spurious
522 * interrupts from misconfigured pins.
524 for (i
= 0; i
< vg
->chip
.ngpio
; i
++) {
525 value
= readl(byt_gpio_reg(&vg
->chip
, i
, BYT_CONF0_REG
));
526 if ((value
& BYT_PIN_MUX
) == byt_get_gpio_mux(vg
, i
) &&
527 !(value
& BYT_DIRECT_IRQ_EN
)) {
528 byt_gpio_clear_triggering(vg
, i
);
529 dev_dbg(&vg
->pdev
->dev
, "disabling GPIO %d\n", i
);
533 /* clear interrupt status trigger registers */
534 for (base
= 0; base
< vg
->chip
.ngpio
; base
+= 32) {
535 reg
= byt_gpio_reg(&vg
->chip
, base
, BYT_INT_STAT_REG
);
536 writel(0xffffffff, reg
);
537 /* make sure trigger bits are cleared, if not then a pin
538 might be misconfigured in bios */
541 dev_err(&vg
->pdev
->dev
,
542 "GPIO interrupt error, pins misconfigured\n");
546 static int byt_gpio_probe(struct platform_device
*pdev
)
549 struct gpio_chip
*gc
;
550 struct resource
*mem_rc
, *irq_rc
;
551 struct device
*dev
= &pdev
->dev
;
552 struct acpi_device
*acpi_dev
;
553 struct pinctrl_gpio_range
*range
;
554 acpi_handle handle
= ACPI_HANDLE(dev
);
557 if (acpi_bus_get_device(handle
, &acpi_dev
))
560 vg
= devm_kzalloc(dev
, sizeof(struct byt_gpio
), GFP_KERNEL
);
562 dev_err(&pdev
->dev
, "can't allocate byt_gpio chip data\n");
566 for (range
= byt_ranges
; range
->name
; range
++) {
567 if (!strcmp(acpi_dev
->pnp
.unique_id
, range
->name
)) {
568 vg
->chip
.ngpio
= range
->npins
;
574 if (!vg
->chip
.ngpio
|| !vg
->range
)
578 platform_set_drvdata(pdev
, vg
);
580 mem_rc
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
581 vg
->reg_base
= devm_ioremap_resource(dev
, mem_rc
);
582 if (IS_ERR(vg
->reg_base
))
583 return PTR_ERR(vg
->reg_base
);
585 raw_spin_lock_init(&vg
->lock
);
588 gc
->label
= dev_name(&pdev
->dev
);
589 gc
->owner
= THIS_MODULE
;
590 gc
->request
= byt_gpio_request
;
591 gc
->free
= byt_gpio_free
;
592 gc
->direction_input
= byt_gpio_direction_input
;
593 gc
->direction_output
= byt_gpio_direction_output
;
594 gc
->get
= byt_gpio_get
;
595 gc
->set
= byt_gpio_set
;
596 gc
->dbg_show
= byt_gpio_dbg_show
;
598 gc
->can_sleep
= false;
601 #ifdef CONFIG_PM_SLEEP
602 vg
->saved_context
= devm_kcalloc(&pdev
->dev
, gc
->ngpio
,
603 sizeof(*vg
->saved_context
), GFP_KERNEL
);
606 ret
= gpiochip_add_data(gc
, vg
);
608 dev_err(&pdev
->dev
, "failed adding byt-gpio chip\n");
612 /* set up interrupts */
613 irq_rc
= platform_get_resource(pdev
, IORESOURCE_IRQ
, 0);
614 if (irq_rc
&& irq_rc
->start
) {
615 byt_gpio_irq_init_hw(vg
);
616 ret
= gpiochip_irqchip_add(gc
, &byt_irqchip
, 0,
617 handle_simple_irq
, IRQ_TYPE_NONE
);
619 dev_err(dev
, "failed to add irqchip\n");
624 gpiochip_set_chained_irqchip(gc
, &byt_irqchip
,
625 (unsigned)irq_rc
->start
,
626 byt_gpio_irq_handler
);
629 pm_runtime_enable(dev
);
634 #ifdef CONFIG_PM_SLEEP
635 static int byt_gpio_suspend(struct device
*dev
)
637 struct platform_device
*pdev
= to_platform_device(dev
);
638 struct byt_gpio
*vg
= platform_get_drvdata(pdev
);
641 for (i
= 0; i
< vg
->chip
.ngpio
; i
++) {
645 reg
= byt_gpio_reg(&vg
->chip
, i
, BYT_CONF0_REG
);
646 value
= readl(reg
) & BYT_CONF0_RESTORE_MASK
;
647 vg
->saved_context
[i
].conf0
= value
;
649 reg
= byt_gpio_reg(&vg
->chip
, i
, BYT_VAL_REG
);
650 value
= readl(reg
) & BYT_VAL_RESTORE_MASK
;
651 vg
->saved_context
[i
].val
= value
;
657 static int byt_gpio_resume(struct device
*dev
)
659 struct platform_device
*pdev
= to_platform_device(dev
);
660 struct byt_gpio
*vg
= platform_get_drvdata(pdev
);
663 for (i
= 0; i
< vg
->chip
.ngpio
; i
++) {
667 reg
= byt_gpio_reg(&vg
->chip
, i
, BYT_CONF0_REG
);
669 if ((value
& BYT_CONF0_RESTORE_MASK
) !=
670 vg
->saved_context
[i
].conf0
) {
671 value
&= ~BYT_CONF0_RESTORE_MASK
;
672 value
|= vg
->saved_context
[i
].conf0
;
674 dev_info(dev
, "restored pin %d conf0 %#08x", i
, value
);
677 reg
= byt_gpio_reg(&vg
->chip
, i
, BYT_VAL_REG
);
679 if ((value
& BYT_VAL_RESTORE_MASK
) !=
680 vg
->saved_context
[i
].val
) {
683 v
= value
& ~BYT_VAL_RESTORE_MASK
;
684 v
|= vg
->saved_context
[i
].val
;
687 dev_dbg(dev
, "restored pin %d val %#08x\n",
698 static int byt_gpio_runtime_suspend(struct device
*dev
)
703 static int byt_gpio_runtime_resume(struct device
*dev
)
709 static const struct dev_pm_ops byt_gpio_pm_ops
= {
710 SET_LATE_SYSTEM_SLEEP_PM_OPS(byt_gpio_suspend
, byt_gpio_resume
)
711 SET_RUNTIME_PM_OPS(byt_gpio_runtime_suspend
, byt_gpio_runtime_resume
,
715 static const struct acpi_device_id byt_gpio_acpi_match
[] = {
720 MODULE_DEVICE_TABLE(acpi
, byt_gpio_acpi_match
);
722 static int byt_gpio_remove(struct platform_device
*pdev
)
724 struct byt_gpio
*vg
= platform_get_drvdata(pdev
);
726 pm_runtime_disable(&pdev
->dev
);
727 gpiochip_remove(&vg
->chip
);
732 static struct platform_driver byt_gpio_driver
= {
733 .probe
= byt_gpio_probe
,
734 .remove
= byt_gpio_remove
,
737 .pm
= &byt_gpio_pm_ops
,
738 .acpi_match_table
= ACPI_PTR(byt_gpio_acpi_match
),
742 static int __init
byt_gpio_init(void)
744 return platform_driver_register(&byt_gpio_driver
);
746 subsys_initcall(byt_gpio_init
);
748 static void __exit
byt_gpio_exit(void)
750 platform_driver_unregister(&byt_gpio_driver
);
752 module_exit(byt_gpio_exit
);