u-boot/drivers/power/domain/imx8-power-domain.c
Peng Fan 99ac6c769f imx: move imx8 sci header file to include/firmware/imx
Move imx8 sci header file to include/firmware/imx, then we could
use build macro to reuse some i.MX8 drivers for i.MX9, such as
drivers/cpu/imx8_cpu.c.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Stefano Babic <sbabic@denx.de>
2023-05-21 16:54:32 +02:00

65 lines
1.4 KiB
C

// SPDX-License-Identifier: GPL-2.0
/*
* Copyright 2019 NXP
*/
#define DEBUG
#include <common.h>
#include <dm.h>
#include <log.h>
#include <malloc.h>
#include <power-domain-uclass.h>
#include <asm/arch/power-domain.h>
#include <firmware/imx/sci/sci.h>
static int imx8_power_domain_on(struct power_domain *power_domain)
{
u32 resource_id = power_domain->id;
int ret;
debug("%s: resource_id %u\n", __func__, resource_id);
ret = sc_pm_set_resource_power_mode(-1, resource_id, SC_PM_PW_MODE_ON);
if (ret) {
printf("Error: %u Power up failed! (error = %d)\n",
resource_id, ret);
return ret;
}
return 0;
}
static int imx8_power_domain_off(struct power_domain *power_domain)
{
u32 resource_id = power_domain->id;
int ret;
debug("%s: resource_id %u\n", __func__, resource_id);
ret = sc_pm_set_resource_power_mode(-1, resource_id, SC_PM_PW_MODE_OFF);
if (ret) {
printf("Error: %u Power off failed! (error = %d)\n",
resource_id, ret);
return ret;
}
return 0;
}
static const struct udevice_id imx8_power_domain_ids[] = {
{ .compatible = "fsl,imx8qxp-scu-pd" },
{ .compatible = "fsl,scu-pd" },
{ }
};
struct power_domain_ops imx8_power_domain_ops_v2 = {
.on = imx8_power_domain_on,
.off = imx8_power_domain_off,
};
U_BOOT_DRIVER(imx8_power_domain_v2) = {
.name = "imx8_power_domain_v2",
.id = UCLASS_POWER_DOMAIN,
.of_match = imx8_power_domain_ids,
.ops = &imx8_power_domain_ops_v2,
};