From ba876079714db52887cab9f068ea1136de4cc107 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 6 Feb 2020 09:54:57 -0700 Subject: dm: irq: Add support for interrupt controller types There can be different types of interrupt controllers in a system and some drivers may need to distinguish between these. In general this can be handled using the device tree by adding the interrupt information to device nodes. However on x86 devices we have interrupt controllers which are not tied to any particular device and not really used in U-Boot. These still need to be inited, so a convenient method is to give each controller a type and allow a particular controller type to be probed. Add support for this in sandbox along with a test. Signed-off-by: Simon Glass Reviewed-by: Bin Meng [bmeng: remove the new bland line at EOF of test/dm/irq.c] Signed-off-by: Bin Meng --- drivers/misc/irq-uclass.c | 15 ++++++++++++++- drivers/misc/irq_sandbox.c | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/misc/irq-uclass.c b/drivers/misc/irq-uclass.c index d5182cf..c52c813 100644 --- a/drivers/misc/irq-uclass.c +++ b/drivers/misc/irq-uclass.c @@ -1,11 +1,13 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright (C) 2015, Bin Meng + * Copyright 2019 Google, LLC + * Written by Simon Glass */ #include #include #include +#include int irq_route_pmc_gpio_gpe(struct udevice *dev, uint pmc_gpe_num) { @@ -47,6 +49,17 @@ int irq_restore_polarities(struct udevice *dev) return ops->restore_polarities(dev); } +int irq_first_device_type(enum irq_dev_t type, struct udevice **devp) +{ + int ret; + + ret = uclass_first_device_drvdata(UCLASS_IRQ, type, devp); + if (ret) + return log_msg_ret("find", ret); + + return 0; +} + UCLASS_DRIVER(irq) = { .id = UCLASS_IRQ, .name = "irq", diff --git a/drivers/misc/irq_sandbox.c b/drivers/misc/irq_sandbox.c index 6dda1a4..011022a 100644 --- a/drivers/misc/irq_sandbox.c +++ b/drivers/misc/irq_sandbox.c @@ -43,7 +43,7 @@ static const struct irq_ops sandbox_irq_ops = { }; static const struct udevice_id sandbox_irq_ids[] = { - { .compatible = "sandbox,irq"}, + { .compatible = "sandbox,irq", SANDBOX_IRQT_BASE }, { } }; -- cgit v1.1