blob: 01ded64f16017afce0cff6def5c6096ee6f4dded [file] [log] [blame]
Simon Glassff418d92019-12-06 21:41:58 -07001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * IRQ is a type of interrupt controller used on recent Intel SoC.
4 *
5 * Copyright 2019 Google LLC
6 */
7
8#ifndef __irq_H
9#define __irq_H
10
11/**
12 * struct irq_ops - Operations for the IRQ
13 */
14struct irq_ops {
15 /**
16 * route_pmc_gpio_gpe() - Get the GPIO for an event
17 *
18 * @dev: IRQ device
19 * @pmc_gpe_num: Event number to check
20 * @returns GPIO for the event, or -ENOENT if none
21 */
22 int (*route_pmc_gpio_gpe)(struct udevice *dev, uint pmc_gpe_num);
23
24 /**
25 * set_polarity() - Set the IRQ polarity
26 *
27 * @dev: IRQ device
28 * @irq: Interrupt number to set
29 * @active_low: true if active low, false for active high
30 * @return 0 if OK, -EINVAL if @irq is invalid
31 */
32 int (*set_polarity)(struct udevice *dev, uint irq, bool active_low);
33
34 /**
35 * snapshot_polarities() - record IRQ polarities for later restore
36 *
37 * @dev: IRQ device
38 * @return 0
39 */
40 int (*snapshot_polarities)(struct udevice *dev);
41
42 /**
43 * restore_polarities() - restore IRQ polarities
44 *
45 * @dev: IRQ device
46 * @return 0
47 */
48 int (*restore_polarities)(struct udevice *dev);
49};
50
51#define irq_get_ops(dev) ((struct irq_ops *)(dev)->driver->ops)
52
53/**
54 * irq_route_pmc_gpio_gpe() - Get the GPIO for an event
55 *
56 * @dev: IRQ device
57 * @pmc_gpe_num: Event number to check
58 * @returns GPIO for the event, or -ENOENT if none
59 */
60int irq_route_pmc_gpio_gpe(struct udevice *dev, uint pmc_gpe_num);
61
62/**
63 * irq_set_polarity() - Set the IRQ polarity
64 *
65 * @dev: IRQ device
66 * @irq: Interrupt number to set
67 * @active_low: true if active low, false for active high
68 * @return 0 if OK, -EINVAL if @irq is invalid
69 */
70int irq_set_polarity(struct udevice *dev, uint irq, bool active_low);
71
72/**
73 * irq_snapshot_polarities() - record IRQ polarities for later restore
74 *
75 * @dev: IRQ device
76 * @return 0
77 */
78int irq_snapshot_polarities(struct udevice *dev);
79
80/**
81 * irq_restore_polarities() - restore IRQ polarities
82 *
83 * @dev: IRQ device
84 * @return 0
85 */
86int irq_restore_polarities(struct udevice *dev);
87
88#endif