1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016, NVIDIA CORPORATION.
8 #include <power-domain-uclass.h>
10 #include <asm/power-domain.h>
12 #define SANDBOX_POWER_DOMAINS 3
14 struct sandbox_power_domain {
15 bool on[SANDBOX_POWER_DOMAINS];
18 static int sandbox_power_domain_request(struct power_domain *power_domain)
20 debug("%s(power_domain=%p)\n", __func__, power_domain);
22 if (power_domain->id >= SANDBOX_POWER_DOMAINS)
28 static int sandbox_power_domain_free(struct power_domain *power_domain)
30 debug("%s(power_domain=%p)\n", __func__, power_domain);
35 static int sandbox_power_domain_on(struct power_domain *power_domain)
37 struct sandbox_power_domain *sbr = dev_get_priv(power_domain->dev);
39 debug("%s(power_domain=%p)\n", __func__, power_domain);
41 sbr->on[power_domain->id] = true;
46 static int sandbox_power_domain_off(struct power_domain *power_domain)
48 struct sandbox_power_domain *sbr = dev_get_priv(power_domain->dev);
50 debug("%s(power_domain=%p)\n", __func__, power_domain);
52 sbr->on[power_domain->id] = false;
57 static int sandbox_power_domain_bind(struct udevice *dev)
59 debug("%s(dev=%p)\n", __func__, dev);
64 static int sandbox_power_domain_probe(struct udevice *dev)
66 debug("%s(dev=%p)\n", __func__, dev);
71 static const struct udevice_id sandbox_power_domain_ids[] = {
72 { .compatible = "sandbox,power-domain" },
76 struct power_domain_ops sandbox_power_domain_ops = {
77 .request = sandbox_power_domain_request,
78 .rfree = sandbox_power_domain_free,
79 .on = sandbox_power_domain_on,
80 .off = sandbox_power_domain_off,
83 U_BOOT_DRIVER(sandbox_power_domain) = {
84 .name = "sandbox_power_domain",
85 .id = UCLASS_POWER_DOMAIN,
86 .of_match = sandbox_power_domain_ids,
87 .bind = sandbox_power_domain_bind,
88 .probe = sandbox_power_domain_probe,
89 .priv_auto_alloc_size = sizeof(struct sandbox_power_domain),
90 .ops = &sandbox_power_domain_ops,
93 int sandbox_power_domain_query(struct udevice *dev, unsigned long id)
95 struct sandbox_power_domain *sbr = dev_get_priv(dev);
97 debug("%s(dev=%p, id=%ld)\n", __func__, dev, id);
99 if (id >= SANDBOX_POWER_DOMAINS)