1 // SPDX-License-Identifier: GPL-2.0
3 * Sandbox driver for interrupts
5 * Copyright 2019 Google LLC
14 * struct sandbox_irq_priv - private data for this driver
16 * @count: Counts the number calls to the read_and_clear() method
17 * @pending: true if an interrupt is pending, else false
19 struct sandbox_irq_priv {
24 static int sandbox_set_polarity(struct udevice *dev, uint irq, bool active_low)
32 static int sandbox_route_pmc_gpio_gpe(struct udevice *dev, uint pmc_gpe_num)
37 return pmc_gpe_num + 1;
40 static int sandbox_snapshot_polarities(struct udevice *dev)
45 static int sandbox_restore_polarities(struct udevice *dev)
50 static int sandbox_irq_read_and_clear(struct irq *irq)
52 struct sandbox_irq_priv *priv = dev_get_priv(irq->dev);
54 if (irq->id != SANDBOX_IRQN_PEND)
58 priv->pending = false;
62 if (!(priv->count % 3))
68 static int sandbox_irq_of_xlate(struct irq *irq,
69 struct ofnode_phandle_args *args)
71 irq->id = args->args[0];
76 static const struct irq_ops sandbox_irq_ops = {
77 .route_pmc_gpio_gpe = sandbox_route_pmc_gpio_gpe,
78 .set_polarity = sandbox_set_polarity,
79 .snapshot_polarities = sandbox_snapshot_polarities,
80 .restore_polarities = sandbox_restore_polarities,
81 .read_and_clear = sandbox_irq_read_and_clear,
82 .of_xlate = sandbox_irq_of_xlate,
85 static const struct udevice_id sandbox_irq_ids[] = {
86 { .compatible = "sandbox,irq", SANDBOX_IRQT_BASE },
90 U_BOOT_DRIVER(sandbox_irq_drv) = {
91 .name = "sandbox_irq",
93 .of_match = sandbox_irq_ids,
94 .ops = &sandbox_irq_ops,
95 .priv_auto_alloc_size = sizeof(struct sandbox_irq_priv),