Merge tag 'u-boot-amlogic-20200108' of https://gitlab.denx.de/u-boot/custodians/u...
[oweals/u-boot.git] / test / dm / irq.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Test for irq uclass
4  *
5  * Copyright 2019 Google LLC
6  */
7
8 #include <common.h>
9 #include <dm.h>
10 #include <irq.h>
11 #include <dm/test.h>
12 #include <test/ut.h>
13
14 /* Base test of the irq uclass */
15 static int dm_test_irq_base(struct unit_test_state *uts)
16 {
17         struct udevice *dev;
18
19         ut_assertok(uclass_first_device_err(UCLASS_IRQ, &dev));
20
21         ut_asserteq(5, irq_route_pmc_gpio_gpe(dev, 4));
22         ut_asserteq(-ENOENT, irq_route_pmc_gpio_gpe(dev, 14));
23
24         ut_assertok(irq_set_polarity(dev, 4, true));
25         ut_asserteq(-EINVAL, irq_set_polarity(dev, 14, true));
26
27         ut_assertok(irq_snapshot_polarities(dev));
28         ut_assertok(irq_restore_polarities(dev));
29
30         return 0;
31 }
32 DM_TEST(dm_test_irq_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);