Merge tag 'u-boot-imx-20200107' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
[platform/kernel/u-boot.git] / drivers / misc / irq-uclass.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
4  */
5
6 #include <common.h>
7 #include <dm.h>
8 #include <irq.h>
9
10 int irq_route_pmc_gpio_gpe(struct udevice *dev, uint pmc_gpe_num)
11 {
12         const struct irq_ops *ops = irq_get_ops(dev);
13
14         if (!ops->route_pmc_gpio_gpe)
15                 return -ENOSYS;
16
17         return ops->route_pmc_gpio_gpe(dev, pmc_gpe_num);
18 }
19
20 int irq_set_polarity(struct udevice *dev, uint irq, bool active_low)
21 {
22         const struct irq_ops *ops = irq_get_ops(dev);
23
24         if (!ops->set_polarity)
25                 return -ENOSYS;
26
27         return ops->set_polarity(dev, irq, active_low);
28 }
29
30 int irq_snapshot_polarities(struct udevice *dev)
31 {
32         const struct irq_ops *ops = irq_get_ops(dev);
33
34         if (!ops->snapshot_polarities)
35                 return -ENOSYS;
36
37         return ops->snapshot_polarities(dev);
38 }
39
40 int irq_restore_polarities(struct udevice *dev)
41 {
42         const struct irq_ops *ops = irq_get_ops(dev);
43
44         if (!ops->restore_polarities)
45                 return -ENOSYS;
46
47         return ops->restore_polarities(dev);
48 }
49
50 UCLASS_DRIVER(irq) = {
51         .id             = UCLASS_IRQ,
52         .name           = "irq",
53 };