u-boot/test/dm/irq.c
Simon Glass ba87607971 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 <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: remove the new bland line at EOF of test/dm/irq.c]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2020-02-07 22:44:59 +08:00

45 lines
1.1 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Test for irq uclass
*
* Copyright 2019 Google LLC
*/
#include <common.h>
#include <dm.h>
#include <irq.h>
#include <asm/test.h>
#include <dm/test.h>
#include <test/ut.h>
/* Base test of the irq uclass */
static int dm_test_irq_base(struct unit_test_state *uts)
{
struct udevice *dev;
ut_assertok(uclass_first_device_err(UCLASS_IRQ, &dev));
ut_asserteq(5, irq_route_pmc_gpio_gpe(dev, 4));
ut_asserteq(-ENOENT, irq_route_pmc_gpio_gpe(dev, 14));
ut_assertok(irq_set_polarity(dev, 4, true));
ut_asserteq(-EINVAL, irq_set_polarity(dev, 14, true));
ut_assertok(irq_snapshot_polarities(dev));
ut_assertok(irq_restore_polarities(dev));
return 0;
}
DM_TEST(dm_test_irq_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
/* Test of irq_first_device_type() */
static int dm_test_irq_type(struct unit_test_state *uts)
{
struct udevice *dev;
ut_assertok(irq_first_device_type(SANDBOX_IRQT_BASE, &dev));
ut_asserteq(-ENODEV, irq_first_device_type(X86_IRQT_BASE, &dev));
return 0;
}
DM_TEST(dm_test_irq_type, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);