1 // SPDX-License-Identifier: GPL-2.0
3 * Sandbox driver for interrupts
5 * Copyright 2019 Google LLC
10 #include <acpi/acpi_device.h>
14 static int sandbox_set_polarity(struct udevice *dev, uint irq, bool active_low)
22 static int sandbox_route_pmc_gpio_gpe(struct udevice *dev, uint pmc_gpe_num)
27 return pmc_gpe_num + 1;
30 static int sandbox_snapshot_polarities(struct udevice *dev)
35 static int sandbox_restore_polarities(struct udevice *dev)
40 static int sandbox_irq_read_and_clear(struct irq *irq)
42 struct sandbox_irq_priv *priv = dev_get_priv(irq->dev);
44 if (irq->id != SANDBOX_IRQN_PEND)
48 priv->pending = false;
52 if (!(priv->count % 3))
58 static int sandbox_irq_of_xlate(struct irq *irq,
59 struct ofnode_phandle_args *args)
61 irq->id = args->args[0];
66 static __maybe_unused int sandbox_get_acpi(const struct irq *irq,
67 struct acpi_irq *acpi_irq)
69 acpi_irq->pin = irq->id;
70 acpi_irq->mode = ACPI_IRQ_LEVEL_TRIGGERED;
71 acpi_irq->polarity = ACPI_IRQ_ACTIVE_HIGH;
72 acpi_irq->shared = ACPI_IRQ_SHARED;
73 acpi_irq->wake = ACPI_IRQ_WAKE;
78 static const struct irq_ops sandbox_irq_ops = {
79 .route_pmc_gpio_gpe = sandbox_route_pmc_gpio_gpe,
80 .set_polarity = sandbox_set_polarity,
81 .snapshot_polarities = sandbox_snapshot_polarities,
82 .restore_polarities = sandbox_restore_polarities,
83 .read_and_clear = sandbox_irq_read_and_clear,
84 .of_xlate = sandbox_irq_of_xlate,
85 #if CONFIG_IS_ENABLED(ACPIGEN)
86 .get_acpi = sandbox_get_acpi,
90 static const struct udevice_id sandbox_irq_ids[] = {
91 { .compatible = "sandbox,irq", SANDBOX_IRQT_BASE },
95 U_BOOT_DRIVER(sandbox_irq) = {
96 .name = "sandbox_irq",
98 .of_match = sandbox_irq_ids,
99 .ops = &sandbox_irq_ops,
100 .priv_auto = sizeof(struct sandbox_irq_priv),
101 DM_HEADER(<asm/irq.h>)