Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | cd55652 | 2015-07-06 12:54:35 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015 Google, Inc |
Simon Glass | cd55652 | 2015-07-06 12:54:35 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
| 8 | #include <syscon.h> |
| 9 | #include <asm/test.h> |
| 10 | #include <dm/test.h> |
| 11 | #include <test/ut.h> |
| 12 | |
Simon Glass | cd55652 | 2015-07-06 12:54:35 -0600 | [diff] [blame] | 13 | /* Base test of system controllers */ |
| 14 | static int dm_test_syscon_base(struct unit_test_state *uts) |
| 15 | { |
| 16 | struct udevice *dev; |
| 17 | |
| 18 | ut_assertok(uclass_get_device(UCLASS_SYSCON, 0, &dev)); |
| 19 | ut_asserteq(SYSCON0, dev->driver_data); |
| 20 | |
| 21 | ut_assertok(uclass_get_device(UCLASS_SYSCON, 1, &dev)); |
| 22 | ut_asserteq(SYSCON1, dev->driver_data); |
| 23 | |
| 24 | ut_asserteq(-ENODEV, uclass_get_device(UCLASS_SYSCON, 2, &dev)); |
| 25 | |
| 26 | return 0; |
| 27 | } |
| 28 | DM_TEST(dm_test_syscon_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |
Simon Glass | 6d5579c | 2016-01-17 16:11:08 -0700 | [diff] [blame] | 29 | |
| 30 | /* Test system controller finding */ |
| 31 | static int dm_test_syscon_by_driver_data(struct unit_test_state *uts) |
| 32 | { |
| 33 | struct udevice *dev; |
| 34 | |
| 35 | ut_assertok(syscon_get_by_driver_data(SYSCON0, &dev)); |
| 36 | ut_asserteq(SYSCON0, dev->driver_data); |
| 37 | |
| 38 | ut_assertok(syscon_get_by_driver_data(SYSCON1, &dev)); |
| 39 | ut_asserteq(SYSCON1, dev->driver_data); |
| 40 | |
| 41 | ut_asserteq(-ENODEV, syscon_get_by_driver_data(2, &dev)); |
| 42 | |
| 43 | return 0; |
| 44 | } |
| 45 | DM_TEST(dm_test_syscon_by_driver_data, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |