blob: ac93934eb42089cbe326667c8bfa79b101f66b78 [file] [log] [blame]
Michal Simek0fd9f362022-02-07 10:27:37 +01001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2021, Xilinx. Inc.
4 */
5
Michal Simek0fd9f362022-02-07 10:27:37 +01006#include <dm.h>
Michal Simekf0a6a322022-03-01 09:10:59 +01007#include <dm/device_compat.h>
Michal Simek0fd9f362022-02-07 10:27:37 +01008#include <log.h>
9#include <malloc.h>
10#include <misc.h>
11#include <power-domain-uclass.h>
12#include <linux/bitops.h>
13
14#include <zynqmp_firmware.h>
15
Michal Simek0fd9f362022-02-07 10:27:37 +010016static int zynqmp_pm_request_node(const u32 node, const u32 capabilities,
17 const u32 qos, const enum zynqmp_pm_request_ack ack)
18{
19 return xilinx_pm_request(PM_REQUEST_NODE, node, capabilities,
20 qos, ack, NULL);
21}
22
23static int zynqmp_power_domain_request(struct power_domain *power_domain)
24{
Stefan Herbrechtsmeier0fd9b972023-05-23 14:42:12 +020025 int ret = 0;
26
Michal Simekf0a6a322022-03-01 09:10:59 +010027 dev_dbg(power_domain->dev, "Request for id: %ld\n", power_domain->id);
Michal Simek0fd9f362022-02-07 10:27:37 +010028
Stefan Herbrechtsmeier0fd9b972023-05-23 14:42:12 +020029 if (IS_ENABLED(CONFIG_ARCH_ZYNQMP)) {
30 ret = zynqmp_pmufw_node(power_domain->id);
31 if (ret == -ENODEV)
32 ret = 0;
33 }
Ashok Reddy Soma0569d5f2022-08-05 11:19:56 +020034
Stefan Herbrechtsmeier0fd9b972023-05-23 14:42:12 +020035 return ret;
Michal Simek0fd9f362022-02-07 10:27:37 +010036}
37
38static int zynqmp_power_domain_free(struct power_domain *power_domain)
39{
40 /* nop now */
41 return 0;
42}
43
44static int zynqmp_power_domain_on(struct power_domain *power_domain)
45{
Michal Simekf0a6a322022-03-01 09:10:59 +010046 dev_dbg(power_domain->dev, "Domain ON for id: %ld\n", power_domain->id);
47
Michal Simek0fd9f362022-02-07 10:27:37 +010048 return zynqmp_pm_request_node(power_domain->id,
49 ZYNQMP_PM_CAPABILITY_ACCESS,
50 ZYNQMP_PM_MAX_QOS,
51 ZYNQMP_PM_REQUEST_ACK_BLOCKING);
52}
53
54static int zynqmp_power_domain_off(struct power_domain *power_domain)
55{
56 /* nop now */
57 return 0;
58}
59
60struct power_domain_ops zynqmp_power_domain_ops = {
61 .request = zynqmp_power_domain_request,
62 .rfree = zynqmp_power_domain_free,
63 .on = zynqmp_power_domain_on,
64 .off = zynqmp_power_domain_off,
65};
66
67static int zynqmp_power_domain_probe(struct udevice *dev)
68{
69 return 0;
70}
71
72U_BOOT_DRIVER(zynqmp_power_domain) = {
73 .name = "zynqmp_power_domain",
74 .id = UCLASS_POWER_DOMAIN,
75 .probe = zynqmp_power_domain_probe,
76 .ops = &zynqmp_power_domain_ops,
77};