From patchwork Mon May 11 09:48:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245569 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Mon, 11 May 2020 17:48:32 +0800 Subject: [PATCH 1/6] imx8: misc: use arm_smccc_smc In-Reply-To: <20200511094837.8572-1-peng.fan@nxp.com> References: <20200511094837.8572-1-peng.fan@nxp.com> Message-ID: <20200511094837.8572-2-peng.fan@nxp.com> Use arm_smccc_smc to replace call_imx_sip Signed-off-by: Peng Fan --- arch/arm/mach-imx/imx8/misc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/imx8/misc.c b/arch/arm/mach-imx/imx8/misc.c index 76d6571d8b..f3fdd22d28 100644 --- a/arch/arm/mach-imx/imx8/misc.c +++ b/arch/arm/mach-imx/imx8/misc.c @@ -3,6 +3,7 @@ #include #include #include +#include int sc_pm_setup_uart(sc_rsrc_t uart_rsrc, sc_pm_clock_rate_t clk_rate) { @@ -29,6 +30,7 @@ int sc_pm_setup_uart(sc_rsrc_t uart_rsrc, sc_pm_clock_rate_t clk_rate) void build_info(void) { + struct arm_smccc_res res; u32 seco_build = 0, seco_commit = 0; u32 sc_build = 0, sc_commit = 0; ulong atf_commit = 0; @@ -49,8 +51,9 @@ void build_info(void) } /* Get ARM Trusted Firmware commit id */ - atf_commit = call_imx_sip(IMX_SIP_BUILDINFO, - IMX_SIP_BUILDINFO_GET_COMMITHASH, 0, 0, 0); + arm_smccc_smc(IMX_SIP_BUILDINFO, IMX_SIP_BUILDINFO_GET_COMMITHASH, + 0, 0, 0, 0, 0, 0, &res); + atf_commit = res.a0; if (atf_commit == 0xffffffff) { debug("ATF does not support build info\n"); atf_commit = 0x30; /* Display 0 */ From patchwork Mon May 11 09:48:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245570 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Mon, 11 May 2020 17:48:33 +0800 Subject: [PATCH 2/6] imx8m: soc: use arm_smccc_smc In-Reply-To: <20200511094837.8572-1-peng.fan@nxp.com> References: <20200511094837.8572-1-peng.fan@nxp.com> Message-ID: <20200511094837.8572-3-peng.fan@nxp.com> Use arm_smccc_smc to replace call_imx_sip Signed-off-by: Peng Fan --- arch/arm/mach-imx/imx8m/soc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c index 347fd6d0ad..e6863ab5cf 100644 --- a/arch/arm/mach-imx/imx8m/soc.c +++ b/arch/arm/mach-imx/imx8m/soc.c @@ -20,6 +20,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -429,10 +430,12 @@ void reset_cpu(ulong addr) static void acquire_buildinfo(void) { u64 atf_commit = 0; + struct arm_smccc_res res; /* Get ARM Trusted Firmware commit id */ - atf_commit = call_imx_sip(IMX_SIP_BUILDINFO, - IMX_SIP_BUILDINFO_GET_COMMITHASH, 0, 0, 0); + arm_smccc_smc(IMX_SIP_BUILDINFO, IMX_SIP_BUILDINFO_GET_COMMITHASH, + 0, 0 , 0, 0, 0, 0, &res); + atf_commit = res.a0; if (atf_commit == 0xffffffff) { debug("ATF does not support build info\n"); atf_commit = 0x30; /* Display 0, 0 ascii is 0x30 */ From patchwork Mon May 11 09:48:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245571 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Mon, 11 May 2020 17:48:34 +0800 Subject: [PATCH 3/6] imx: bootaux: use arm_smccc_smc In-Reply-To: <20200511094837.8572-1-peng.fan@nxp.com> References: <20200511094837.8572-1-peng.fan@nxp.com> Message-ID: <20200511094837.8572-4-peng.fan@nxp.com> Use arm_smccc_smc to replace call_imx_sip Signed-off-by: Peng Fan --- arch/arm/mach-imx/imx_bootaux.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/imx_bootaux.c b/arch/arm/mach-imx/imx_bootaux.c index ec0da1164f..908125fff7 100644 --- a/arch/arm/mach-imx/imx_bootaux.c +++ b/arch/arm/mach-imx/imx_bootaux.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -54,7 +55,8 @@ int arch_auxiliary_core_up(u32 core_id, ulong addr) /* Enable M4 */ #ifdef CONFIG_IMX8M - call_imx_sip(IMX_SIP_SRC, IMX_SIP_SRC_M4_START, 0, 0, 0); + arm_smccc_smc(IMX_SIP_SRC, IMX_SIP_SRC_M4_START, 0, 0, + 0, 0, 0, 0, NULL); #else clrsetbits_le32(SRC_BASE_ADDR + SRC_M4_REG_OFFSET, SRC_M4C_NON_SCLR_RST_MASK, SRC_M4_ENABLE_MASK); @@ -66,7 +68,12 @@ int arch_auxiliary_core_up(u32 core_id, ulong addr) int arch_auxiliary_core_check_up(u32 core_id) { #ifdef CONFIG_IMX8M - return call_imx_sip(IMX_SIP_SRC, IMX_SIP_SRC_M4_STARTED, 0, 0, 0); + struct arm_smccc_res res; + + arm_smccc_smc(IMX_SIP_SRC, IMX_SIP_SRC_M4_STARTED, 0, 0, + 0, 0, 0, 0, &res); + + return res.a0; #else unsigned int val; From patchwork Mon May 11 09:48:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245572 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Mon, 11 May 2020 17:48:35 +0800 Subject: [PATCH 4/6] imx8: fuse: use arm_smccc_smc In-Reply-To: <20200511094837.8572-1-peng.fan@nxp.com> References: <20200511094837.8572-1-peng.fan@nxp.com> Message-ID: <20200511094837.8572-5-peng.fan@nxp.com> Use arm_smccc_smc to replace call_imx_sip Signed-off-by: Peng Fan --- drivers/misc/imx8/fuse.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/misc/imx8/fuse.c b/drivers/misc/imx8/fuse.c index 4d7f2f524d..be18122937 100644 --- a/drivers/misc/imx8/fuse.c +++ b/drivers/misc/imx8/fuse.c @@ -9,6 +9,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -36,22 +37,24 @@ int fuse_read(u32 bank, u32 word, u32 *val) int fuse_sense(u32 bank, u32 word, u32 *val) { - unsigned long ret = 0, value = 0; + struct arm_smccc_res res; if (bank != 0) { printf("Invalid bank argument, ONLY bank 0 is supported\n"); return -EINVAL; } - ret = call_imx_sip_ret2(FSL_SIP_OTP_READ, (unsigned long)word, &value, - 0, 0); - *val = (u32)value; + arm_smccc_smc(FSL_SIP_OTP_READ, (unsigned long)word, 0, 0, + 0, 0, 0, 0, &res); + *val = (u32)res.a1; - return ret; + return res.a0; } int fuse_prog(u32 bank, u32 word, u32 val) { + struct arm_smccc_res res; + if (bank != 0) { printf("Invalid bank argument, ONLY bank 0 is supported\n"); return -EINVAL; @@ -78,8 +81,10 @@ int fuse_prog(u32 bank, u32 word, u32 val) } } - return call_imx_sip(FSL_SIP_OTP_WRITE, (unsigned long)word, - (unsigned long)val, 0, 0); + arm_smccc_smc(FSL_SIP_OTP_WRITE, (unsigned long)word, + (unsigned long)val, 0, 0, 0, 0, 0, &res); + + return res.a0; } int fuse_override(u32 bank, u32 word, u32 val) From patchwork Mon May 11 09:48:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245573 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Mon, 11 May 2020 17:48:36 +0800 Subject: [PATCH 5/6] imx: power-domain: use arm_smccc_smc In-Reply-To: <20200511094837.8572-1-peng.fan@nxp.com> References: <20200511094837.8572-1-peng.fan@nxp.com> Message-ID: <20200511094837.8572-6-peng.fan@nxp.com> Use arm_smccc_smc to replace call_imx_sip Signed-off-by: Peng Fan --- drivers/power/domain/imx8m-power-domain.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/power/domain/imx8m-power-domain.c b/drivers/power/domain/imx8m-power-domain.c index 5b6467cda7..0ef460df8c 100644 --- a/drivers/power/domain/imx8m-power-domain.c +++ b/drivers/power/domain/imx8m-power-domain.c @@ -13,6 +13,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -30,6 +31,7 @@ static int imx8m_power_domain_on(struct power_domain *power_domain) { struct udevice *dev = power_domain->dev; struct imx8m_power_domain_platdata *pdata; + pdata = dev_get_platdata(dev); if (pdata->resource_id < 0) @@ -38,8 +40,8 @@ static int imx8m_power_domain_on(struct power_domain *power_domain) if (pdata->has_pd) power_domain_on(&pdata->pd); - call_imx_sip(IMX_SIP_GPC, IMX_SIP_GPC_PM_DOMAIN, - pdata->resource_id, 1, 0); + arm_smccc_smc(IMX_SIP_GPC, IMX_SIP_GPC_PM_DOMAIN, + pdata->resource_id, 1, 0, 0, 0, 0, NULL); return 0; } @@ -53,8 +55,8 @@ static int imx8m_power_domain_off(struct power_domain *power_domain) if (pdata->resource_id < 0) return -EINVAL; - call_imx_sip(IMX_SIP_GPC, IMX_SIP_GPC_PM_DOMAIN, - pdata->resource_id, 0, 0); + arm_smccc_smc(IMX_SIP_GPC, IMX_SIP_GPC_PM_DOMAIN, + pdata->resource_id, 0, 0, 0, 0, 0, NULL); if (pdata->has_pd) power_domain_off(&pdata->pd); From patchwork Mon May 11 09:48:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245574 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Mon, 11 May 2020 17:48:37 +0800 Subject: [PATCH 6/6] imx: remove imx sip file In-Reply-To: <20200511094837.8572-1-peng.fan@nxp.com> References: <20200511094837.8572-1-peng.fan@nxp.com> Message-ID: <20200511094837.8572-7-peng.fan@nxp.com> We have switch to use arm_smccc_smc, no need to keep i.MX specific sip wrapper. Signed-off-by: Peng Fan --- arch/arm/mach-imx/Makefile | 2 +- arch/arm/mach-imx/sip.c | 46 ---------------------------------------------- 2 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 arch/arm/mach-imx/sip.c diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index a70d51b5cf..1aa26a50ad 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -218,7 +218,7 @@ endif targets += $(addprefix ../../../,SPL spl/u-boot-spl.cfgout u-boot-dtb.cfgout u-boot.cfgout u-boot.uim spl/u-boot-nand-spl.imx) -obj-$(CONFIG_ARM64) += lowlevel.o sip.o +obj-$(CONFIG_ARM64) += lowlevel.o obj-$(CONFIG_MX5) += mx5/ obj-$(CONFIG_MX6) += mx6/ diff --git a/arch/arm/mach-imx/sip.c b/arch/arm/mach-imx/sip.c deleted file mode 100644 index fca520c671..0000000000 --- a/arch/arm/mach-imx/sip.c +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright 2017 NXP - */ - -#include -#include - -unsigned long call_imx_sip(unsigned long id, unsigned long reg0, - unsigned long reg1, unsigned long reg2, - unsigned long reg3) -{ - struct pt_regs regs; - - regs.regs[0] = id; - regs.regs[1] = reg0; - regs.regs[2] = reg1; - regs.regs[3] = reg2; - regs.regs[4] = reg3; - - smc_call(®s); - - return regs.regs[0]; -} - -/* - * Do an SMC call to return 2 registers by having reg1 passed in by reference - */ -unsigned long call_imx_sip_ret2(unsigned long id, unsigned long reg0, - unsigned long *reg1, unsigned long reg2, - unsigned long reg3) -{ - struct pt_regs regs; - - regs.regs[0] = id; - regs.regs[1] = reg0; - regs.regs[2] = *reg1; - regs.regs[3] = reg2; - regs.regs[4] = reg3; - - smc_call(®s); - - *reg1 = regs.regs[1]; - - return regs.regs[0]; -}