Michal Simek | 0fd9f36 | 2022-02-07 10:27:37 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (c) 2021, Xilinx. Inc. |
| 4 | */ |
| 5 | |
Michal Simek | 0fd9f36 | 2022-02-07 10:27:37 +0100 | [diff] [blame] | 6 | #include <dm.h> |
Michal Simek | f0a6a32 | 2022-03-01 09:10:59 +0100 | [diff] [blame] | 7 | #include <dm/device_compat.h> |
Michal Simek | 0fd9f36 | 2022-02-07 10:27:37 +0100 | [diff] [blame] | 8 | #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 Simek | 0fd9f36 | 2022-02-07 10:27:37 +0100 | [diff] [blame] | 16 | static 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 | |
| 23 | static int zynqmp_power_domain_request(struct power_domain *power_domain) |
| 24 | { |
Stefan Herbrechtsmeier | 0fd9b97 | 2023-05-23 14:42:12 +0200 | [diff] [blame] | 25 | int ret = 0; |
| 26 | |
Michal Simek | f0a6a32 | 2022-03-01 09:10:59 +0100 | [diff] [blame] | 27 | dev_dbg(power_domain->dev, "Request for id: %ld\n", power_domain->id); |
Michal Simek | 0fd9f36 | 2022-02-07 10:27:37 +0100 | [diff] [blame] | 28 | |
Stefan Herbrechtsmeier | 0fd9b97 | 2023-05-23 14:42:12 +0200 | [diff] [blame] | 29 | if (IS_ENABLED(CONFIG_ARCH_ZYNQMP)) { |
| 30 | ret = zynqmp_pmufw_node(power_domain->id); |
| 31 | if (ret == -ENODEV) |
| 32 | ret = 0; |
| 33 | } |
Ashok Reddy Soma | 0569d5f | 2022-08-05 11:19:56 +0200 | [diff] [blame] | 34 | |
Stefan Herbrechtsmeier | 0fd9b97 | 2023-05-23 14:42:12 +0200 | [diff] [blame] | 35 | return ret; |
Michal Simek | 0fd9f36 | 2022-02-07 10:27:37 +0100 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | static int zynqmp_power_domain_free(struct power_domain *power_domain) |
| 39 | { |
| 40 | /* nop now */ |
| 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | static int zynqmp_power_domain_on(struct power_domain *power_domain) |
| 45 | { |
Michal Simek | f0a6a32 | 2022-03-01 09:10:59 +0100 | [diff] [blame] | 46 | dev_dbg(power_domain->dev, "Domain ON for id: %ld\n", power_domain->id); |
| 47 | |
Michal Simek | 0fd9f36 | 2022-02-07 10:27:37 +0100 | [diff] [blame] | 48 | 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 | |
| 54 | static int zynqmp_power_domain_off(struct power_domain *power_domain) |
| 55 | { |
| 56 | /* nop now */ |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | struct 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 | |
| 67 | static int zynqmp_power_domain_probe(struct udevice *dev) |
| 68 | { |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | U_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 | }; |