blob: 48318218a9e2227662c81fabeb60cb055ede4d59 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Stephen Warren61f5ddc2016-07-13 13:45:31 -06002/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
Stephen Warren61f5ddc2016-07-13 13:45:31 -06004 */
5
6#include <common.h>
7#include <dm.h>
8#include <dm/test.h>
9#include <asm/power-domain.h>
10#include <test/ut.h>
11
12/* This must match the specifier for power-domains in the DT node */
13#define TEST_POWER_DOMAIN 2
14
15static int dm_test_power_domain(struct unit_test_state *uts)
16{
17 struct udevice *dev_power_domain;
18 struct udevice *dev_test;
19
20 ut_assertok(uclass_get_device_by_name(UCLASS_POWER_DOMAIN,
21 "power-domain",
22 &dev_power_domain));
23 ut_asserteq(0, sandbox_power_domain_query(dev_power_domain, 0));
24 ut_asserteq(0, sandbox_power_domain_query(dev_power_domain,
25 TEST_POWER_DOMAIN));
26
27 ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "power-domain-test",
28 &dev_test));
Peng Fan4624faa2018-07-27 10:20:39 +080029 ut_asserteq(1, sandbox_power_domain_query(dev_power_domain,
30 TEST_POWER_DOMAIN));
Stephen Warren61f5ddc2016-07-13 13:45:31 -060031 ut_assertok(sandbox_power_domain_test_get(dev_test));
32
33 ut_assertok(sandbox_power_domain_test_on(dev_test));
34 ut_asserteq(0, sandbox_power_domain_query(dev_power_domain, 0));
35 ut_asserteq(1, sandbox_power_domain_query(dev_power_domain,
36 TEST_POWER_DOMAIN));
37
38 ut_assertok(sandbox_power_domain_test_off(dev_test));
39 ut_asserteq(0, sandbox_power_domain_query(dev_power_domain, 0));
40 ut_asserteq(0, sandbox_power_domain_query(dev_power_domain,
41 TEST_POWER_DOMAIN));
42
43 ut_assertok(sandbox_power_domain_test_free(dev_test));
44
45 return 0;
46}
47DM_TEST(dm_test_power_domain, DM_TESTF_SCAN_FDT);