Peng Fan | 5a57b29 | 2019-09-02 18:16:32 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright 2019 NXP |
| 4 | */ |
| 5 | |
| 6 | #define DEBUG |
| 7 | #include <common.h> |
| 8 | #include <dm.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 9 | #include <log.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 10 | #include <malloc.h> |
Peng Fan | 5a57b29 | 2019-09-02 18:16:32 +0800 | [diff] [blame] | 11 | #include <power-domain-uclass.h> |
| 12 | #include <asm/arch/power-domain.h> |
| 13 | #include <asm/arch/sci/sci.h> |
| 14 | |
| 15 | static int imx8_power_domain_request(struct power_domain *power_domain) |
| 16 | { |
| 17 | debug("%s(power_domain=%p)\n", __func__, power_domain); |
| 18 | |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | static int imx8_power_domain_free(struct power_domain *power_domain) |
| 23 | { |
| 24 | debug("%s(power_domain=%p)\n", __func__, power_domain); |
| 25 | |
| 26 | return 0; |
| 27 | } |
| 28 | |
| 29 | static int imx8_power_domain_on(struct power_domain *power_domain) |
| 30 | { |
| 31 | u32 resource_id = power_domain->id; |
| 32 | int ret; |
| 33 | |
| 34 | debug("%s: resource_id %u\n", __func__, resource_id); |
| 35 | |
| 36 | ret = sc_pm_set_resource_power_mode(-1, resource_id, SC_PM_PW_MODE_ON); |
| 37 | if (ret) { |
| 38 | printf("Error: %u Power up failed! (error = %d)\n", |
| 39 | resource_id, ret); |
| 40 | return ret; |
| 41 | } |
| 42 | |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | static int imx8_power_domain_off(struct power_domain *power_domain) |
| 47 | { |
| 48 | u32 resource_id = power_domain->id; |
| 49 | int ret; |
| 50 | |
| 51 | debug("%s: resource_id %u\n", __func__, resource_id); |
| 52 | |
| 53 | ret = sc_pm_set_resource_power_mode(-1, resource_id, SC_PM_PW_MODE_OFF); |
| 54 | if (ret) { |
| 55 | printf("Error: %u Power off failed! (error = %d)\n", |
| 56 | resource_id, ret); |
| 57 | return ret; |
| 58 | } |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | static int imx8_power_domain_probe(struct udevice *dev) |
| 64 | { |
| 65 | debug("%s(dev=%s)\n", __func__, dev->name); |
| 66 | |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | static const struct udevice_id imx8_power_domain_ids[] = { |
| 71 | { .compatible = "fsl,imx8qxp-scu-pd" }, |
| 72 | { .compatible = "fsl,scu-pd" }, |
| 73 | { } |
| 74 | }; |
| 75 | |
| 76 | struct power_domain_ops imx8_power_domain_ops_v2 = { |
| 77 | .request = imx8_power_domain_request, |
Simon Glass | 92ed3a3 | 2020-02-03 07:35:51 -0700 | [diff] [blame] | 78 | .rfree = imx8_power_domain_free, |
Peng Fan | 5a57b29 | 2019-09-02 18:16:32 +0800 | [diff] [blame] | 79 | .on = imx8_power_domain_on, |
| 80 | .off = imx8_power_domain_off, |
| 81 | }; |
| 82 | |
| 83 | U_BOOT_DRIVER(imx8_power_domain_v2) = { |
| 84 | .name = "imx8_power_domain_v2", |
| 85 | .id = UCLASS_POWER_DOMAIN, |
| 86 | .of_match = imx8_power_domain_ids, |
| 87 | .probe = imx8_power_domain_probe, |
| 88 | .ops = &imx8_power_domain_ops_v2, |
| 89 | }; |