[U-Boot] [PATCH 1/7] imx8qm: mek: enable dm-spl for pm

with u-boot,dm-spl added for imx8qm-pm node, and SPL_SIMPLE_BUS enabled, the bind and probe code in board file could be removed.
Also we need to enlarge SYS_MALLOC_F_LEN to avoid calloc fail.
Signed-off-by: Peng Fan peng.fan@nxp.com --- arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi | 5 +++++ board/freescale/imx8qm_mek/spl.c | 16 ---------------- configs/imx8qm_mek_defconfig | 1 + 3 files changed, 6 insertions(+), 16 deletions(-)
diff --git a/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi b/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi index 5d50eb028e..9a4a83b70e 100644 --- a/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi +++ b/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi @@ -3,6 +3,11 @@ * Copyright 2018 NXP */
+&{/imx8qm-pm} { + + u-boot,dm-spl; +}; + &mu { u-boot,dm-spl; }; diff --git a/board/freescale/imx8qm_mek/spl.c b/board/freescale/imx8qm_mek/spl.c index 95ce9f37e8..cb4006eb2a 100644 --- a/board/freescale/imx8qm_mek/spl.c +++ b/board/freescale/imx8qm_mek/spl.c @@ -18,7 +18,6 @@ DECLARE_GLOBAL_DATA_PTR; void spl_board_init(void) { struct udevice *dev; - int offset;
uclass_find_first_device(UCLASS_MISC, &dev);
@@ -27,21 +26,6 @@ void spl_board_init(void) continue; }
- offset = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "nxp,imx8-pd"); - while (offset != -FDT_ERR_NOTFOUND) { - lists_bind_fdt(gd->dm_root, offset_to_ofnode(offset), - NULL, true); - offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset, - "nxp,imx8-pd"); - } - - uclass_find_first_device(UCLASS_POWER_DOMAIN, &dev); - - for (; dev; uclass_find_next_device(&dev)) { - if (device_probe(dev)) - continue; - } - arch_cpu_init();
board_early_init_f(); diff --git a/configs/imx8qm_mek_defconfig b/configs/imx8qm_mek_defconfig index 3294931ef8..594eb9efb2 100644 --- a/configs/imx8qm_mek_defconfig +++ b/configs/imx8qm_mek_defconfig @@ -6,6 +6,7 @@ CONFIG_SYS_TEXT_BASE=0x80020000 CONFIG_SPL_GPIO_SUPPORT=y CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y +CONFIG_SYS_MALLOC_F_LEN=0x8000 CONFIG_TARGET_IMX8QM_MEK=y CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL_SERIAL_SUPPORT=y

lpuart0 is the uart used by SPL and U-Boot proper, and DM_SERIAL is enabled. Since uclass power domain is also enabled, to make lpuart work properly, need add u-boot,dm-spl for lpuart power domain and its parent.
Signed-off-by: Peng Fan peng.fan@nxp.com --- arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi b/arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi index 201559008c..771ab635f1 100644 --- a/arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi +++ b/arch/arm/dts/fsl-imx8qxp-mek-u-boot.dtsi @@ -72,6 +72,14 @@ u-boot,dm-spl; };
+&pd_dma { + u-boot,dm-spl; +}; + +&pd_dma_lpuart0 { + u-boot,dm-spl; +}; + &gpio0 { u-boot,dm-spl; };

lpuart0 is the uart used by SPL and U-Boot proper, and DM_SERIAL is enabled. Since uclass power domain is also enabled, to make lpuart work properly, need add u-boot,dm-spl for lpuart power domain and its parent.
Signed-off-by: Peng Fan peng.fan@nxp.com --- arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi b/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi index 9a4a83b70e..80d6475b7c 100644 --- a/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi +++ b/arch/arm/dts/fsl-imx8qm-mek-u-boot.dtsi @@ -72,6 +72,14 @@ u-boot,dm-spl; };
+&pd_dma { + u-boot,dm-spl; +}; + +&pd_dma_lpuart0 { + u-boot,dm-spl; +}; + &gpio0 { u-boot,dm-spl; };

clk and pinctrl will be get(probed) during each device probe, we don't need to probe them in scu driver. Only need to bind the sub-nodes (clk and iomuxc) of MU node with their drivers.
So drop the code to probe the clk/pinctrl, and this patch will make it easy to add more subnodes.
Signed-off-by: Peng Fan peng.fan@nxp.com --- drivers/misc/imx8/scu.c | 46 +++++++--------------------------------------- 1 file changed, 7 insertions(+), 39 deletions(-)
diff --git a/drivers/misc/imx8/scu.c b/drivers/misc/imx8/scu.c index 9ec00457b8..a7654a7817 100644 --- a/drivers/misc/imx8/scu.c +++ b/drivers/misc/imx8/scu.c @@ -26,8 +26,6 @@ struct mu_type {
struct imx8_scu { struct mu_type *base; - struct udevice *clk; - struct udevice *pinclk; };
#define MU_CR_GIE_MASK 0xF0000000u @@ -202,9 +200,6 @@ static int imx8_scu_probe(struct udevice *dev)
gd->arch.scu_dev = dev;
- device_probe(plat->clk); - device_probe(plat->pinclk); - return 0; }
@@ -215,44 +210,17 @@ static int imx8_scu_remove(struct udevice *dev)
static int imx8_scu_bind(struct udevice *dev) { - struct imx8_scu *plat = dev_get_platdata(dev); int ret; struct udevice *child; - int node; - char *clk_compatible, *iomuxc_compatible; - - if (IS_ENABLED(CONFIG_IMX8QXP)) { - clk_compatible = "fsl,imx8qxp-clk"; - iomuxc_compatible = "fsl,imx8qxp-iomuxc"; - } else if (IS_ENABLED(CONFIG_IMX8QM)) { - clk_compatible = "fsl,imx8qm-clk"; - iomuxc_compatible = "fsl,imx8qm-iomuxc"; - } else { - return -EINVAL; - } + ofnode node;
debug("%s(dev=%p)\n", __func__, dev); - - node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, clk_compatible); - if (node < 0) - panic("No clk node found\n"); - - ret = lists_bind_fdt(dev, offset_to_ofnode(node), &child, true); - if (ret) - return ret; - - plat->clk = child; - - node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, - iomuxc_compatible); - if (node < 0) - panic("No iomuxc node found\n"); - - ret = lists_bind_fdt(dev, offset_to_ofnode(node), &child, true); - if (ret) - return ret; - - plat->pinclk = child; + ofnode_for_each_subnode(node, dev_ofnode(dev)) { + ret = lists_bind_fdt(dev, node, &child, true); + if (ret) + return ret; + debug("bind child dev %s\n", child->name); + }
return 0; }

From: Ye Li ye.li@nxp.com
When power on some sources in Video system, current timeout 10ms is too short and returns before SCU response. So increase the timeout to 1s.
Signed-off-by: Ye Li ye.li@nxp.com Signed-off-by: Peng Fan peng.fan@nxp.com --- drivers/misc/imx8/scu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/imx8/scu.c b/drivers/misc/imx8/scu.c index a7654a7817..6916b754f6 100644 --- a/drivers/misc/imx8/scu.c +++ b/drivers/misc/imx8/scu.c @@ -74,7 +74,7 @@ static int mu_hal_receivemsg(struct mu_type *base, u32 reg_index, u32 *msg) assert(reg_index < MU_TR_COUNT);
/* Wait RX register to be full. */ - ret = readl_poll_timeout(&base->sr, val, val & mask, 10000); + ret = readl_poll_timeout(&base->sr, val, val & mask, 1000000); if (ret < 0) { printf("%s timeout\n", __func__); return -ETIMEDOUT;

The current i.MX8 power domain driver is based on i.MX vendor power domain tree which will retire later.
The Linux upstream use a single pd node for power domain driver, and U-Boot will adopt that. When U-Boot i.MX8 dts synced with Linux Kernel upstream and related driver ready, the legacy driver will be removed.
Signed-off-by: Peng Fan peng.fan@nxp.com --- drivers/power/domain/Makefile | 2 +- .../power/domain/{imx8-power-domain.c => imx8-power-domain-legacy.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename drivers/power/domain/{imx8-power-domain.c => imx8-power-domain-legacy.c} (100%)
diff --git a/drivers/power/domain/Makefile b/drivers/power/domain/Makefile index 695aafe17d..97194787c0 100644 --- a/drivers/power/domain/Makefile +++ b/drivers/power/domain/Makefile @@ -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.o +obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain.o diff --git a/drivers/power/domain/imx8-power-domain.c b/drivers/power/domain/imx8-power-domain-legacy.c similarity index 100% rename from drivers/power/domain/imx8-power-domain.c rename to drivers/power/domain/imx8-power-domain-legacy.c

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 | 2 +- drivers/power/domain/imx8-power-domain.c | 87 ++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 drivers/power/domain/imx8-power-domain.c
diff --git a/drivers/power/domain/Makefile b/drivers/power/domain/Makefile index 97194787c0..81fbd89e15 100644 --- a/drivers/power/domain/Makefile +++ b/drivers/power/domain/Makefile @@ -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_MTK_POWER_DOMAIN) += mtk-power-domain.o obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain.o diff --git a/drivers/power/domain/imx8-power-domain.c b/drivers/power/domain/imx8-power-domain.c new file mode 100644 index 0000000000..aa768365b4 --- /dev/null +++ b/drivers/power/domain/imx8-power-domain.c @@ -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, +};
participants (1)
-
Peng Fan