blob: 6dda1a4c442375a74b2db159f9229904cb87d45d [file] [log] [blame]
Simon Glass54028bc2019-12-06 21:41:59 -07001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Sandbox driver for interrupts
4 *
5 * Copyright 2019 Google LLC
6 */
7
8#include <common.h>
9#include <dm.h>
10#include <irq.h>
11
12static int sandbox_set_polarity(struct udevice *dev, uint irq, bool active_low)
13{
14 if (irq > 10)
15 return -EINVAL;
16
17 return 0;
18}
19
20static int sandbox_route_pmc_gpio_gpe(struct udevice *dev, uint pmc_gpe_num)
21{
22 if (pmc_gpe_num > 10)
23 return -ENOENT;
24
25 return pmc_gpe_num + 1;
26}
27
28static int sandbox_snapshot_polarities(struct udevice *dev)
29{
30 return 0;
31}
32
33static int sandbox_restore_polarities(struct udevice *dev)
34{
35 return 0;
36}
37
38static const struct irq_ops sandbox_irq_ops = {
39 .route_pmc_gpio_gpe = sandbox_route_pmc_gpio_gpe,
40 .set_polarity = sandbox_set_polarity,
41 .snapshot_polarities = sandbox_snapshot_polarities,
42 .restore_polarities = sandbox_restore_polarities,
43};
44
45static const struct udevice_id sandbox_irq_ids[] = {
46 { .compatible = "sandbox,irq"},
47 { }
48};
49
50U_BOOT_DRIVER(sandbox_irq_drv) = {
51 .name = "sandbox_irq",
52 .id = UCLASS_IRQ,
53 .of_match = sandbox_irq_ids,
54 .ops = &sandbox_irq_ops,
55};