blob: 6461ab23d629fd46ef264c726c15667da1bc3927 [file] [log] [blame]
Peng Fan5a57b292019-09-02 18:16:32 +08001// 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 Glass0f2af882020-05-10 11:40:05 -06009#include <log.h>
Simon Glass9bc15642020-02-03 07:36:16 -070010#include <malloc.h>
Peng Fan5a57b292019-09-02 18:16:32 +080011#include <power-domain-uclass.h>
12#include <asm/arch/power-domain.h>
13#include <asm/arch/sci/sci.h>
14
15static 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
22static 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
29static 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
46static 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
63static int imx8_power_domain_probe(struct udevice *dev)
64{
65 debug("%s(dev=%s)\n", __func__, dev->name);
66
67 return 0;
68}
69
70static const struct udevice_id imx8_power_domain_ids[] = {
71 { .compatible = "fsl,imx8qxp-scu-pd" },
72 { .compatible = "fsl,scu-pd" },
73 { }
74};
75
76struct power_domain_ops imx8_power_domain_ops_v2 = {
77 .request = imx8_power_domain_request,
Simon Glass92ed3a32020-02-03 07:35:51 -070078 .rfree = imx8_power_domain_free,
Peng Fan5a57b292019-09-02 18:16:32 +080079 .on = imx8_power_domain_on,
80 .off = imx8_power_domain_off,
81};
82
83U_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};