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