power: domain: add i.MX8 scu power domain driver
authorPeng Fan <peng.fan@nxp.com>
Mon, 2 Sep 2019 10:16:32 +0000 (18:16 +0800)
committerStefano Babic <sbabic@denx.de>
Tue, 5 Nov 2019 09:27:18 +0000 (10:27 +0100)
The power domain tree is not accepted by Linux Kernel upstream.
only a single pd node is used currently, as following:

pd: imx8qx-pd {
compatible = "fsl,imx8qm-scu-pd", "fsl,scu-pd";
#power-domain-cells = <1>;
};

So to migrate to use upstream linux dts, we also need a driver
to support this.

This patch is to support the new method, compared with legacy power
domain tree, it will be simpiler, because each device will
has resource id as power domain index, it will be directly passed
to scfw, and no need to let power domain build that tree. If multiple
power domain is needed, it is the dts node should has correctly power
domains entry added and sequence correct.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
drivers/power/domain/Makefile
drivers/power/domain/imx8-power-domain.c [new file with mode: 0644]

index 6bd090562f3bb5ec41084a2a42903996d2d63b5b..45bf9f638345cd1cdb4766ff491dd233ffeceb86 100644 (file)
@@ -5,7 +5,7 @@
 
 obj-$(CONFIG_$(SPL_)POWER_DOMAIN) += power-domain-uclass.o
 obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
-obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o
+obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o imx8-power-domain.o
 obj-$(CONFIG_IMX8M_POWER_DOMAIN) += imx8m-power-domain.o
 obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o
 obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o
diff --git a/drivers/power/domain/imx8-power-domain.c b/drivers/power/domain/imx8-power-domain.c
new file mode 100644 (file)
index 0000000..aa76836
--- /dev/null
@@ -0,0 +1,87 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2019 NXP
+ */
+
+#define DEBUG
+#include <common.h>
+#include <dm.h>
+#include <power-domain-uclass.h>
+#include <asm/arch/power-domain.h>
+#include <asm/arch/sci/sci.h>
+
+static int imx8_power_domain_request(struct power_domain *power_domain)
+{
+       debug("%s(power_domain=%p)\n", __func__, power_domain);
+
+       return 0;
+}
+
+static int imx8_power_domain_free(struct power_domain *power_domain)
+{
+       debug("%s(power_domain=%p)\n", __func__, power_domain);
+
+       return 0;
+}
+
+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 int imx8_power_domain_probe(struct udevice *dev)
+{
+       debug("%s(dev=%s)\n", __func__, dev->name);
+
+       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 = {
+       .request = imx8_power_domain_request,
+       .free = imx8_power_domain_free,
+       .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,
+       .probe = imx8_power_domain_probe,
+       .ops = &imx8_power_domain_ops_v2,
+};