Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | 92c67fa | 2016-07-13 13:45:31 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016, NVIDIA CORPORATION. |
Stephen Warren | 92c67fa | 2016-07-13 13:45:31 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
Stephen Warren | 92c67fa | 2016-07-13 13:45:31 -0600 | [diff] [blame] | 6 | #include <dm.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 7 | #include <malloc.h> |
Stephen Warren | 92c67fa | 2016-07-13 13:45:31 -0600 | [diff] [blame] | 8 | #include <dm/test.h> |
| 9 | #include <asm/power-domain.h> |
Simon Glass | 75c4d41 | 2020-07-19 10:15:37 -0600 | [diff] [blame] | 10 | #include <test/test.h> |
Stephen Warren | 92c67fa | 2016-07-13 13:45:31 -0600 | [diff] [blame] | 11 | #include <test/ut.h> |
| 12 | |
| 13 | /* This must match the specifier for power-domains in the DT node */ |
| 14 | #define TEST_POWER_DOMAIN 2 |
| 15 | |
| 16 | static int dm_test_power_domain(struct unit_test_state *uts) |
| 17 | { |
| 18 | struct udevice *dev_power_domain; |
| 19 | struct udevice *dev_test; |
| 20 | |
| 21 | ut_assertok(uclass_get_device_by_name(UCLASS_POWER_DOMAIN, |
| 22 | "power-domain", |
| 23 | &dev_power_domain)); |
| 24 | ut_asserteq(0, sandbox_power_domain_query(dev_power_domain, 0)); |
| 25 | ut_asserteq(0, sandbox_power_domain_query(dev_power_domain, |
| 26 | TEST_POWER_DOMAIN)); |
| 27 | |
| 28 | ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "power-domain-test", |
| 29 | &dev_test)); |
Peng Fan | 7a2c2be | 2018-07-27 10:20:39 +0800 | [diff] [blame] | 30 | ut_asserteq(1, sandbox_power_domain_query(dev_power_domain, |
| 31 | TEST_POWER_DOMAIN)); |
Stephen Warren | 92c67fa | 2016-07-13 13:45:31 -0600 | [diff] [blame] | 32 | ut_assertok(sandbox_power_domain_test_get(dev_test)); |
| 33 | |
| 34 | ut_assertok(sandbox_power_domain_test_on(dev_test)); |
| 35 | ut_asserteq(0, sandbox_power_domain_query(dev_power_domain, 0)); |
| 36 | ut_asserteq(1, sandbox_power_domain_query(dev_power_domain, |
| 37 | TEST_POWER_DOMAIN)); |
| 38 | |
| 39 | ut_assertok(sandbox_power_domain_test_off(dev_test)); |
| 40 | ut_asserteq(0, sandbox_power_domain_query(dev_power_domain, 0)); |
| 41 | ut_asserteq(0, sandbox_power_domain_query(dev_power_domain, |
| 42 | TEST_POWER_DOMAIN)); |
| 43 | |
| 44 | ut_assertok(sandbox_power_domain_test_free(dev_test)); |
| 45 | |
| 46 | return 0; |
| 47 | } |
Simon Glass | 1a92f83 | 2024-08-22 07:57:48 -0600 | [diff] [blame^] | 48 | DM_TEST(dm_test_power_domain, UTF_SCAN_FDT); |