Simon Glass | fbb0efd | 2019-12-06 21:41:59 -0700 | [diff] [blame] | 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> |
Simon Glass | ba87607 | 2020-02-06 09:54:57 -0700 | [diff] [blame] | 11 | #include <asm/test.h> |
Simon Glass | fbb0efd | 2019-12-06 21:41:59 -0700 | [diff] [blame] | 12 | #include <dm/test.h> |
| 13 | #include <test/ut.h> |
| 14 | |
| 15 | /* Base test of the irq uclass */ |
| 16 | static int dm_test_irq_base(struct unit_test_state *uts) |
| 17 | { |
| 18 | struct udevice *dev; |
| 19 | |
| 20 | ut_assertok(uclass_first_device_err(UCLASS_IRQ, &dev)); |
| 21 | |
| 22 | ut_asserteq(5, irq_route_pmc_gpio_gpe(dev, 4)); |
| 23 | ut_asserteq(-ENOENT, irq_route_pmc_gpio_gpe(dev, 14)); |
| 24 | |
| 25 | ut_assertok(irq_set_polarity(dev, 4, true)); |
| 26 | ut_asserteq(-EINVAL, irq_set_polarity(dev, 14, true)); |
| 27 | |
| 28 | ut_assertok(irq_snapshot_polarities(dev)); |
| 29 | ut_assertok(irq_restore_polarities(dev)); |
| 30 | |
| 31 | return 0; |
| 32 | } |
| 33 | DM_TEST(dm_test_irq_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |
Simon Glass | ba87607 | 2020-02-06 09:54:57 -0700 | [diff] [blame] | 34 | |
| 35 | /* Test of irq_first_device_type() */ |
| 36 | static int dm_test_irq_type(struct unit_test_state *uts) |
| 37 | { |
| 38 | struct udevice *dev; |
| 39 | |
| 40 | ut_assertok(irq_first_device_type(SANDBOX_IRQT_BASE, &dev)); |
| 41 | ut_asserteq(-ENODEV, irq_first_device_type(X86_IRQT_BASE, &dev)); |
| 42 | |
| 43 | return 0; |
| 44 | } |
| 45 | DM_TEST(dm_test_irq_type, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |