blob: c52c813ff370b702cc631326f5d89028394cce12 [file] [log] [blame]
Simon Glass79d66a62019-12-06 21:41:58 -07001// SPDX-License-Identifier: GPL-2.0+
2/*
Simon Glassba876072020-02-06 09:54:57 -07003 * Copyright 2019 Google, LLC
4 * Written by Simon Glass <sjg@chromium.org>
Simon Glass79d66a62019-12-06 21:41:58 -07005 */
6
7#include <common.h>
8#include <dm.h>
9#include <irq.h>
Simon Glassba876072020-02-06 09:54:57 -070010#include <dm/device-internal.h>
Simon Glass79d66a62019-12-06 21:41:58 -070011
12int irq_route_pmc_gpio_gpe(struct udevice *dev, uint pmc_gpe_num)
13{
14 const struct irq_ops *ops = irq_get_ops(dev);
15
16 if (!ops->route_pmc_gpio_gpe)
17 return -ENOSYS;
18
19 return ops->route_pmc_gpio_gpe(dev, pmc_gpe_num);
20}
21
22int irq_set_polarity(struct udevice *dev, uint irq, bool active_low)
23{
24 const struct irq_ops *ops = irq_get_ops(dev);
25
26 if (!ops->set_polarity)
27 return -ENOSYS;
28
29 return ops->set_polarity(dev, irq, active_low);
30}
31
32int irq_snapshot_polarities(struct udevice *dev)
33{
34 const struct irq_ops *ops = irq_get_ops(dev);
35
36 if (!ops->snapshot_polarities)
37 return -ENOSYS;
38
39 return ops->snapshot_polarities(dev);
40}
41
42int irq_restore_polarities(struct udevice *dev)
43{
44 const struct irq_ops *ops = irq_get_ops(dev);
45
46 if (!ops->restore_polarities)
47 return -ENOSYS;
48
49 return ops->restore_polarities(dev);
50}
51
Simon Glassba876072020-02-06 09:54:57 -070052int irq_first_device_type(enum irq_dev_t type, struct udevice **devp)
53{
54 int ret;
55
56 ret = uclass_first_device_drvdata(UCLASS_IRQ, type, devp);
57 if (ret)
58 return log_msg_ret("find", ret);
59
60 return 0;
61}
62
Simon Glass79d66a62019-12-06 21:41:58 -070063UCLASS_DRIVER(irq) = {
64 .id = UCLASS_IRQ,
65 .name = "irq",
66};