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 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
Michal Simek | f0a6a32 | 2022-03-01 09:10:59 +0100 | [diff] [blame] | 8 | #include <dm/device_compat.h> |
Michal Simek | 0fd9f36 | 2022-02-07 10:27:37 +0100 | [diff] [blame] | 9 | #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 Simek | 0fd9f36 | 2022-02-07 10:27:37 +0100 | [diff] [blame] | 17 | static 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 | |
| 24 | static int zynqmp_power_domain_request(struct power_domain *power_domain) |
| 25 | { |
Michal Simek | f0a6a32 | 2022-03-01 09:10:59 +0100 | [diff] [blame] | 26 | 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] | 27 | |
Ashok Reddy Soma | 0569d5f | 2022-08-05 11:19:56 +0200 | [diff] [blame] | 28 | if (IS_ENABLED(CONFIG_ARCH_ZYNQMP)) |
| 29 | return zynqmp_pmufw_node(power_domain->id); |
| 30 | |
| 31 | return 0; |
Michal Simek | 0fd9f36 | 2022-02-07 10:27:37 +0100 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | static int zynqmp_power_domain_free(struct power_domain *power_domain) |
| 35 | { |
| 36 | /* nop now */ |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | static int zynqmp_power_domain_on(struct power_domain *power_domain) |
| 41 | { |
Michal Simek | f0a6a32 | 2022-03-01 09:10:59 +0100 | [diff] [blame] | 42 | dev_dbg(power_domain->dev, "Domain ON for id: %ld\n", power_domain->id); |
| 43 | |
Michal Simek | 0fd9f36 | 2022-02-07 10:27:37 +0100 | [diff] [blame] | 44 | return zynqmp_pm_request_node(power_domain->id, |
| 45 | ZYNQMP_PM_CAPABILITY_ACCESS, |
| 46 | ZYNQMP_PM_MAX_QOS, |
| 47 | ZYNQMP_PM_REQUEST_ACK_BLOCKING); |
| 48 | } |
| 49 | |
| 50 | static int zynqmp_power_domain_off(struct power_domain *power_domain) |
| 51 | { |
| 52 | /* nop now */ |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | struct power_domain_ops zynqmp_power_domain_ops = { |
| 57 | .request = zynqmp_power_domain_request, |
| 58 | .rfree = zynqmp_power_domain_free, |
| 59 | .on = zynqmp_power_domain_on, |
| 60 | .off = zynqmp_power_domain_off, |
| 61 | }; |
| 62 | |
| 63 | static int zynqmp_power_domain_probe(struct udevice *dev) |
| 64 | { |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | U_BOOT_DRIVER(zynqmp_power_domain) = { |
| 69 | .name = "zynqmp_power_domain", |
| 70 | .id = UCLASS_POWER_DOMAIN, |
| 71 | .probe = zynqmp_power_domain_probe, |
| 72 | .ops = &zynqmp_power_domain_ops, |
| 73 | }; |