1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2016, NVIDIA CORPORATION.
4  */
5 
6 #include <common.h>
7 #include <dm.h>
8 #include <power-domain.h>
9 #include <asm/io.h>
10 #include <asm/power-domain.h>
11 
12 struct sandbox_power_domain_test {
13 	struct power_domain pd;
14 };
15 
sandbox_power_domain_test_get(struct udevice * dev)16 int sandbox_power_domain_test_get(struct udevice *dev)
17 {
18 	struct sandbox_power_domain_test *sbrt = dev_get_priv(dev);
19 
20 	return power_domain_get(dev, &sbrt->pd);
21 }
22 
sandbox_power_domain_test_on(struct udevice * dev)23 int sandbox_power_domain_test_on(struct udevice *dev)
24 {
25 	struct sandbox_power_domain_test *sbrt = dev_get_priv(dev);
26 
27 	return power_domain_on(&sbrt->pd);
28 }
29 
sandbox_power_domain_test_off(struct udevice * dev)30 int sandbox_power_domain_test_off(struct udevice *dev)
31 {
32 	struct sandbox_power_domain_test *sbrt = dev_get_priv(dev);
33 
34 	return power_domain_off(&sbrt->pd);
35 }
36 
sandbox_power_domain_test_free(struct udevice * dev)37 int sandbox_power_domain_test_free(struct udevice *dev)
38 {
39 	struct sandbox_power_domain_test *sbrt = dev_get_priv(dev);
40 
41 	return power_domain_free(&sbrt->pd);
42 }
43 
44 static const struct udevice_id sandbox_power_domain_test_ids[] = {
45 	{ .compatible = "sandbox,power-domain-test" },
46 	{ }
47 };
48 
49 U_BOOT_DRIVER(sandbox_power_domain_test) = {
50 	.name = "sandbox_power_domain_test",
51 	.id = UCLASS_MISC,
52 	.of_match = sandbox_power_domain_test_ids,
53 	.priv_auto_alloc_size = sizeof(struct sandbox_power_domain_test),
54 };
55