blob: 6943658be429aa32f7938d2c5759e44b628f3bf9 [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
6#include <common.h>
7#include <dm.h>
Michal Simekf0a6a322022-03-01 09:10:59 +01008#include <dm/device_compat.h>
Michal Simek0fd9f362022-02-07 10:27:37 +01009#include <log.h>
10#include <malloc.h>
11#include <misc.h>
12#include <power-domain-uclass.h>
13#include <linux/bitops.h>
14
15#include <zynqmp_firmware.h>
16
Michal Simek0fd9f362022-02-07 10:27:37 +010017static int zynqmp_pm_request_node(const u32 node, const u32 capabilities,
18 const u32 qos, const enum zynqmp_pm_request_ack ack)
19{
20 return xilinx_pm_request(PM_REQUEST_NODE, node, capabilities,
21 qos, ack, NULL);
22}
23
24static int zynqmp_power_domain_request(struct power_domain *power_domain)
25{
Michal Simekf0a6a322022-03-01 09:10:59 +010026 dev_dbg(power_domain->dev, "Request for id: %ld\n", power_domain->id);
Michal Simek0fd9f362022-02-07 10:27:37 +010027
Michal Simekf0a6a322022-03-01 09:10:59 +010028 return zynqmp_pmufw_node(power_domain->id);
Michal Simek0fd9f362022-02-07 10:27:37 +010029}
30
31static int zynqmp_power_domain_free(struct power_domain *power_domain)
32{
33 /* nop now */
34 return 0;
35}
36
37static int zynqmp_power_domain_on(struct power_domain *power_domain)
38{
Michal Simekf0a6a322022-03-01 09:10:59 +010039 dev_dbg(power_domain->dev, "Domain ON for id: %ld\n", power_domain->id);
40
Michal Simek0fd9f362022-02-07 10:27:37 +010041 return zynqmp_pm_request_node(power_domain->id,
42 ZYNQMP_PM_CAPABILITY_ACCESS,
43 ZYNQMP_PM_MAX_QOS,
44 ZYNQMP_PM_REQUEST_ACK_BLOCKING);
45}
46
47static int zynqmp_power_domain_off(struct power_domain *power_domain)
48{
49 /* nop now */
50 return 0;
51}
52
53struct power_domain_ops zynqmp_power_domain_ops = {
54 .request = zynqmp_power_domain_request,
55 .rfree = zynqmp_power_domain_free,
56 .on = zynqmp_power_domain_on,
57 .off = zynqmp_power_domain_off,
58};
59
60static int zynqmp_power_domain_probe(struct udevice *dev)
61{
62 return 0;
63}
64
65U_BOOT_DRIVER(zynqmp_power_domain) = {
66 .name = "zynqmp_power_domain",
67 .id = UCLASS_POWER_DOMAIN,
68 .probe = zynqmp_power_domain_probe,
69 .ops = &zynqmp_power_domain_ops,
70};