1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016, NVIDIA CORPORATION.
9 #include <power-domain-uclass.h>
11 #include <asm/power-domain.h>
13 #define SANDBOX_POWER_DOMAINS 3
15 struct sandbox_power_domain {
16 bool on[SANDBOX_POWER_DOMAINS];
19 static int sandbox_power_domain_request(struct power_domain *power_domain)
21 debug("%s(power_domain=%p)\n", __func__, power_domain);
23 if (power_domain->id >= SANDBOX_POWER_DOMAINS)
29 static int sandbox_power_domain_free(struct power_domain *power_domain)
31 debug("%s(power_domain=%p)\n", __func__, power_domain);
36 static int sandbox_power_domain_on(struct power_domain *power_domain)
38 struct sandbox_power_domain *sbr = dev_get_priv(power_domain->dev);
40 debug("%s(power_domain=%p)\n", __func__, power_domain);
42 sbr->on[power_domain->id] = true;
47 static int sandbox_power_domain_off(struct power_domain *power_domain)
49 struct sandbox_power_domain *sbr = dev_get_priv(power_domain->dev);
51 debug("%s(power_domain=%p)\n", __func__, power_domain);
53 sbr->on[power_domain->id] = false;
58 static int sandbox_power_domain_bind(struct udevice *dev)
60 debug("%s(dev=%p)\n", __func__, dev);
65 static int sandbox_power_domain_probe(struct udevice *dev)
67 debug("%s(dev=%p)\n", __func__, dev);
72 static const struct udevice_id sandbox_power_domain_ids[] = {
73 { .compatible = "sandbox,power-domain" },
77 struct power_domain_ops sandbox_power_domain_ops = {
78 .request = sandbox_power_domain_request,
79 .rfree = sandbox_power_domain_free,
80 .on = sandbox_power_domain_on,
81 .off = sandbox_power_domain_off,
84 U_BOOT_DRIVER(sandbox_power_domain) = {
85 .name = "sandbox_power_domain",
86 .id = UCLASS_POWER_DOMAIN,
87 .of_match = sandbox_power_domain_ids,
88 .bind = sandbox_power_domain_bind,
89 .probe = sandbox_power_domain_probe,
90 .priv_auto = sizeof(struct sandbox_power_domain),
91 .ops = &sandbox_power_domain_ops,
94 int sandbox_power_domain_query(struct udevice *dev, unsigned long id)
96 struct sandbox_power_domain *sbr = dev_get_priv(dev);
98 debug("%s(dev=%p, id=%ld)\n", __func__, dev, id);
100 if (id >= SANDBOX_POWER_DOMAINS)