Lines Matching +full:power +full:- +full:domain

1 // SPDX-License-Identifier: GPL-2.0
13 #include <dt-bindings/power/raspberrypi-power.h>
14 #include <soc/bcm2835/raspberrypi-firmware.h>
17 * Firmware indices for the old power domains interface. Only a few
24 u32 domain; member
43 u32 domain; member
48 * Asks the firmware to enable or disable power on a specific power
49 * domain.
51 static int rpi_firmware_set_power(struct generic_pm_domain *domain, bool on) in rpi_firmware_set_power() argument
54 container_of(domain, struct rpi_power_domain, base); in rpi_firmware_set_power()
55 bool old_interface = rpi_domain->old_interface; in rpi_firmware_set_power()
59 packet.domain = rpi_domain->domain; in rpi_firmware_set_power()
62 ret = rpi_firmware_property(rpi_domain->fw, old_interface ? in rpi_firmware_set_power()
67 dev_err(&domain->dev, "Failed to set %s to %u (%d)\n", in rpi_firmware_set_power()
68 old_interface ? "power" : "domain", on, ret); in rpi_firmware_set_power()
70 dev_dbg(&domain->dev, "Set %s to %u\n", in rpi_firmware_set_power()
71 old_interface ? "power" : "domain", on); in rpi_firmware_set_power()
76 static int rpi_domain_off(struct generic_pm_domain *domain) in rpi_domain_off() argument
78 return rpi_firmware_set_power(domain, false); in rpi_domain_off()
81 static int rpi_domain_on(struct generic_pm_domain *domain) in rpi_domain_on() argument
83 return rpi_firmware_set_power(domain, true); in rpi_domain_on()
89 struct rpi_power_domain *dom = &rpi_domains->domains[xlate_index]; in rpi_common_init_power_domain()
91 dom->fw = rpi_domains->fw; in rpi_common_init_power_domain()
93 dom->base.name = name; in rpi_common_init_power_domain()
94 dom->base.flags = GENPD_FLAG_ACTIVE_WAKEUP; in rpi_common_init_power_domain()
95 dom->base.power_on = rpi_domain_on; in rpi_common_init_power_domain()
96 dom->base.power_off = rpi_domain_off; in rpi_common_init_power_domain()
99 * Treat all power domains as off at boot. in rpi_common_init_power_domain()
106 pm_genpd_init(&dom->base, NULL, true); in rpi_common_init_power_domain()
108 rpi_domains->xlate.domains[xlate_index] = &dom->base; in rpi_common_init_power_domain()
114 struct rpi_power_domain *dom = &rpi_domains->domains[xlate_index]; in rpi_init_power_domain()
116 if (!rpi_domains->has_new_interface) in rpi_init_power_domain()
119 /* The DT binding index is the firmware's domain index minus one. */ in rpi_init_power_domain()
120 dom->domain = xlate_index + 1; in rpi_init_power_domain()
126 int xlate_index, int domain, in rpi_init_old_power_domain() argument
129 struct rpi_power_domain *dom = &rpi_domains->domains[xlate_index]; in rpi_init_old_power_domain()
131 dom->old_interface = true; in rpi_init_old_power_domain()
132 dom->domain = domain; in rpi_init_old_power_domain()
138 * Detects whether the firmware supports the new power domains interface.
151 packet.domain = RPI_POWER_DOMAIN_ARM; in rpi_has_new_domain_support()
154 ret = rpi_firmware_property(rpi_domains->fw, in rpi_has_new_domain_support()
164 struct device *dev = &pdev->dev; in rpi_power_probe()
169 return -ENOMEM; in rpi_power_probe()
171 rpi_domains->xlate.domains = in rpi_power_probe()
174 sizeof(*rpi_domains->xlate.domains), in rpi_power_probe()
176 if (!rpi_domains->xlate.domains) in rpi_power_probe()
177 return -ENOMEM; in rpi_power_probe()
179 rpi_domains->xlate.num_domains = RPI_POWER_DOMAIN_COUNT; in rpi_power_probe()
181 fw_np = of_parse_phandle(pdev->dev.of_node, "firmware", 0); in rpi_power_probe()
183 dev_err(&pdev->dev, "no firmware node\n"); in rpi_power_probe()
184 return -ENODEV; in rpi_power_probe()
187 rpi_domains->fw = devm_rpi_firmware_get(&pdev->dev, fw_np); in rpi_power_probe()
189 if (!rpi_domains->fw) in rpi_power_probe()
190 return -EPROBE_DEFER; in rpi_power_probe()
192 rpi_domains->has_new_interface = in rpi_power_probe()
204 * Use the old firmware interface for USB power, so that we in rpi_power_probe()
228 of_genpd_add_provider_onecell(dev->of_node, &rpi_domains->xlate); in rpi_power_probe()
236 { .compatible = "raspberrypi,bcm2835-power", },
243 .name = "raspberrypi-power",
252 MODULE_DESCRIPTION("Raspberry Pi power domain driver");