blob: aa768365b47eccba757cd00a994616d10d168b91 [file] [log] [blame]
Peng Fanafd267a2019-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>
9#include <power-domain-uclass.h>
10#include <asm/arch/power-domain.h>
11#include <asm/arch/sci/sci.h>
12
13static int imx8_power_domain_request(struct power_domain *power_domain)
14{
15 debug("%s(power_domain=%p)\n", __func__, power_domain);
16
17 return 0;
18}
19
20static int imx8_power_domain_free(struct power_domain *power_domain)
21{
22 debug("%s(power_domain=%p)\n", __func__, power_domain);
23
24 return 0;
25}
26
27static int imx8_power_domain_on(struct power_domain *power_domain)
28{
29 u32 resource_id = power_domain->id;
30 int ret;
31
32 debug("%s: resource_id %u\n", __func__, resource_id);
33
34 ret = sc_pm_set_resource_power_mode(-1, resource_id, SC_PM_PW_MODE_ON);
35 if (ret) {
36 printf("Error: %u Power up failed! (error = %d)\n",
37 resource_id, ret);
38 return ret;
39 }
40
41 return 0;
42}
43
44static int imx8_power_domain_off(struct power_domain *power_domain)
45{
46 u32 resource_id = power_domain->id;
47 int ret;
48
49 debug("%s: resource_id %u\n", __func__, resource_id);
50
51 ret = sc_pm_set_resource_power_mode(-1, resource_id, SC_PM_PW_MODE_OFF);
52 if (ret) {
53 printf("Error: %u Power off failed! (error = %d)\n",
54 resource_id, ret);
55 return ret;
56 }
57
58 return 0;
59}
60
61static int imx8_power_domain_probe(struct udevice *dev)
62{
63 debug("%s(dev=%s)\n", __func__, dev->name);
64
65 return 0;
66}
67
68static const struct udevice_id imx8_power_domain_ids[] = {
69 { .compatible = "fsl,imx8qxp-scu-pd" },
70 { .compatible = "fsl,scu-pd" },
71 { }
72};
73
74struct power_domain_ops imx8_power_domain_ops_v2 = {
75 .request = imx8_power_domain_request,
76 .free = imx8_power_domain_free,
77 .on = imx8_power_domain_on,
78 .off = imx8_power_domain_off,
79};
80
81U_BOOT_DRIVER(imx8_power_domain_v2) = {
82 .name = "imx8_power_domain_v2",
83 .id = UCLASS_POWER_DOMAIN,
84 .of_match = imx8_power_domain_ids,
85 .probe = imx8_power_domain_probe,
86 .ops = &imx8_power_domain_ops_v2,
87};