Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Nishanth Menon | bfaa2d9 | 2015-09-17 15:42:42 -0500 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2015 |
| 4 | * Texas Instruments Incorporated - http://www.ti.com/ |
Nishanth Menon | bfaa2d9 | 2015-09-17 15:42:42 -0500 | [diff] [blame] | 5 | */ |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
| 8 | #include <errno.h> |
| 9 | #include <remoteproc.h> |
| 10 | #include <dm/test.h> |
| 11 | #include <test/ut.h> |
| 12 | /** |
| 13 | * dm_test_remoteproc_base() - test the operations after initializations |
| 14 | * @uts: unit test state |
| 15 | * |
| 16 | * Return: 0 if test passed, else error |
| 17 | */ |
| 18 | static int dm_test_remoteproc_base(struct unit_test_state *uts) |
| 19 | { |
| 20 | if (!rproc_is_initialized()) |
| 21 | ut_assertok(rproc_init()); |
| 22 | |
| 23 | /* Ensure we are initialized */ |
| 24 | ut_asserteq(true, rproc_is_initialized()); |
| 25 | |
| 26 | |
| 27 | /* platform data device 1 */ |
| 28 | ut_assertok(rproc_stop(0)); |
| 29 | ut_assertok(rproc_reset(0)); |
| 30 | /* -> invalid attempt tests */ |
| 31 | ut_asserteq(-EINVAL, rproc_start(0)); |
| 32 | ut_asserteq(-EINVAL, rproc_ping(0)); |
| 33 | /* Valid tests */ |
| 34 | ut_assertok(rproc_load(0, 1, 0)); |
| 35 | ut_assertok(rproc_start(0)); |
| 36 | ut_assertok(rproc_is_running(0)); |
| 37 | ut_assertok(rproc_ping(0)); |
| 38 | ut_assertok(rproc_reset(0)); |
| 39 | ut_assertok(rproc_stop(0)); |
| 40 | |
| 41 | /* dt device device 1 */ |
| 42 | ut_assertok(rproc_stop(1)); |
| 43 | ut_assertok(rproc_reset(1)); |
| 44 | ut_assertok(rproc_load(1, 1, 0)); |
| 45 | ut_assertok(rproc_start(1)); |
| 46 | ut_assertok(rproc_is_running(1)); |
| 47 | ut_assertok(rproc_ping(1)); |
| 48 | ut_assertok(rproc_reset(1)); |
| 49 | ut_assertok(rproc_stop(1)); |
| 50 | |
| 51 | /* dt device device 2 */ |
| 52 | ut_assertok(rproc_stop(0)); |
| 53 | ut_assertok(rproc_reset(0)); |
| 54 | /* -> invalid attempt tests */ |
| 55 | ut_asserteq(-EINVAL, rproc_start(0)); |
| 56 | ut_asserteq(-EINVAL, rproc_ping(0)); |
| 57 | /* Valid tests */ |
| 58 | ut_assertok(rproc_load(2, 1, 0)); |
| 59 | ut_assertok(rproc_start(2)); |
| 60 | ut_assertok(rproc_is_running(2)); |
| 61 | ut_assertok(rproc_ping(2)); |
| 62 | ut_assertok(rproc_reset(2)); |
| 63 | ut_assertok(rproc_stop(2)); |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | DM_TEST(dm_test_remoteproc_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |