Merge tag 'fixes-for-v2020.04' of https://gitlab.denx.de/u-boot/custodians/u-boot...
[platform/kernel/u-boot.git] / drivers / misc / irq_sandbox.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Sandbox driver for interrupts
4  *
5  * Copyright 2019 Google LLC
6  */
7
8 #include <common.h>
9 #include <dm.h>
10 #include <irq.h>
11
12 static int sandbox_set_polarity(struct udevice *dev, uint irq, bool active_low)
13 {
14         if (irq > 10)
15                 return -EINVAL;
16
17         return 0;
18 }
19
20 static int sandbox_route_pmc_gpio_gpe(struct udevice *dev, uint pmc_gpe_num)
21 {
22         if (pmc_gpe_num > 10)
23                 return -ENOENT;
24
25         return pmc_gpe_num + 1;
26 }
27
28 static int sandbox_snapshot_polarities(struct udevice *dev)
29 {
30         return 0;
31 }
32
33 static int sandbox_restore_polarities(struct udevice *dev)
34 {
35         return 0;
36 }
37
38 static const struct irq_ops sandbox_irq_ops = {
39         .route_pmc_gpio_gpe     = sandbox_route_pmc_gpio_gpe,
40         .set_polarity           = sandbox_set_polarity,
41         .snapshot_polarities    = sandbox_snapshot_polarities,
42         .restore_polarities     = sandbox_restore_polarities,
43 };
44
45 static const struct udevice_id sandbox_irq_ids[] = {
46         { .compatible = "sandbox,irq"},
47         { }
48 };
49
50 U_BOOT_DRIVER(sandbox_irq_drv) = {
51         .name           = "sandbox_irq",
52         .id             = UCLASS_IRQ,
53         .of_match       = sandbox_irq_ids,
54         .ops            = &sandbox_irq_ops,
55 };