Simon Glass | 79d66a6 | 2019-12-06 21:41:58 -0700 | [diff] [blame] | 1 | /* 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 | |
Simon Glass | ba87607 | 2020-02-06 09:54:57 -0700 | [diff] [blame^] | 11 | /* |
| 12 | * Interrupt controller types available. You can find a particular one with |
| 13 | * irq_first_device_type() |
| 14 | */ |
| 15 | enum irq_dev_t { |
| 16 | X86_IRQT_BASE, /* Base controller */ |
| 17 | X86_IRQT_ITSS, /* ITSS controller, e.g. on APL */ |
| 18 | X86_IRQT_ACPI_GPE, /* ACPI General-Purpose Events controller */ |
| 19 | SANDBOX_IRQT_BASE, /* Sandbox testing */ |
| 20 | }; |
| 21 | |
Simon Glass | 79d66a6 | 2019-12-06 21:41:58 -0700 | [diff] [blame] | 22 | /** |
| 23 | * struct irq_ops - Operations for the IRQ |
| 24 | */ |
| 25 | struct irq_ops { |
| 26 | /** |
| 27 | * route_pmc_gpio_gpe() - Get the GPIO for an event |
| 28 | * |
| 29 | * @dev: IRQ device |
| 30 | * @pmc_gpe_num: Event number to check |
| 31 | * @returns GPIO for the event, or -ENOENT if none |
| 32 | */ |
| 33 | int (*route_pmc_gpio_gpe)(struct udevice *dev, uint pmc_gpe_num); |
| 34 | |
| 35 | /** |
| 36 | * set_polarity() - Set the IRQ polarity |
| 37 | * |
| 38 | * @dev: IRQ device |
| 39 | * @irq: Interrupt number to set |
| 40 | * @active_low: true if active low, false for active high |
| 41 | * @return 0 if OK, -EINVAL if @irq is invalid |
| 42 | */ |
| 43 | int (*set_polarity)(struct udevice *dev, uint irq, bool active_low); |
| 44 | |
| 45 | /** |
| 46 | * snapshot_polarities() - record IRQ polarities for later restore |
| 47 | * |
| 48 | * @dev: IRQ device |
| 49 | * @return 0 |
| 50 | */ |
| 51 | int (*snapshot_polarities)(struct udevice *dev); |
| 52 | |
| 53 | /** |
| 54 | * restore_polarities() - restore IRQ polarities |
| 55 | * |
| 56 | * @dev: IRQ device |
| 57 | * @return 0 |
| 58 | */ |
| 59 | int (*restore_polarities)(struct udevice *dev); |
| 60 | }; |
| 61 | |
| 62 | #define irq_get_ops(dev) ((struct irq_ops *)(dev)->driver->ops) |
| 63 | |
| 64 | /** |
| 65 | * irq_route_pmc_gpio_gpe() - Get the GPIO for an event |
| 66 | * |
| 67 | * @dev: IRQ device |
| 68 | * @pmc_gpe_num: Event number to check |
| 69 | * @returns GPIO for the event, or -ENOENT if none |
| 70 | */ |
| 71 | int irq_route_pmc_gpio_gpe(struct udevice *dev, uint pmc_gpe_num); |
| 72 | |
| 73 | /** |
| 74 | * irq_set_polarity() - Set the IRQ polarity |
| 75 | * |
| 76 | * @dev: IRQ device |
| 77 | * @irq: Interrupt number to set |
| 78 | * @active_low: true if active low, false for active high |
| 79 | * @return 0 if OK, -EINVAL if @irq is invalid |
| 80 | */ |
| 81 | int irq_set_polarity(struct udevice *dev, uint irq, bool active_low); |
| 82 | |
| 83 | /** |
| 84 | * irq_snapshot_polarities() - record IRQ polarities for later restore |
| 85 | * |
| 86 | * @dev: IRQ device |
| 87 | * @return 0 |
| 88 | */ |
| 89 | int irq_snapshot_polarities(struct udevice *dev); |
| 90 | |
| 91 | /** |
| 92 | * irq_restore_polarities() - restore IRQ polarities |
| 93 | * |
| 94 | * @dev: IRQ device |
| 95 | * @return 0 |
| 96 | */ |
| 97 | int irq_restore_polarities(struct udevice *dev); |
| 98 | |
Simon Glass | ba87607 | 2020-02-06 09:54:57 -0700 | [diff] [blame^] | 99 | /** |
| 100 | * irq_first_device_type() - Get a particular interrupt controller |
| 101 | * |
| 102 | * On success this returns an activated interrupt device. |
| 103 | * |
| 104 | * @type: Type to find |
| 105 | * @devp: Returns the device, if found |
| 106 | * @return 0 if OK, -ENODEV if not found, other -ve error if uclass failed to |
| 107 | * probe |
| 108 | */ |
| 109 | int irq_first_device_type(enum irq_dev_t type, struct udevice **devp); |
| 110 | |
Simon Glass | 79d66a6 | 2019-12-06 21:41:58 -0700 | [diff] [blame] | 111 | #endif |