MA-15813 [Android] imx8q: Enable reset in spl stage
authorJi Luo <ji.luo@nxp.com>
Mon, 4 Nov 2019 14:32:45 +0000 (22:32 +0800)
committerJi Luo <ji.luo@nxp.com>
Thu, 13 May 2021 01:49:17 +0000 (09:49 +0800)
To avoid both A/B slots are marked as unbootable because
of some random failures, we will need to reset at spl stage
when current slot load/verify fail but already with flag
"successful_boot" set.

imx8q can't be reset via the psci driver because the atf
is not avaiable at spl stage, porting the sc_pm_reboot()
scu api so we can do reset at spl stage for imx8qm/imx8qxp
mek boards.

Test: reset on imx8qm_mek and imx8qxp_mek.

Change-Id: Ifa0bdea9393e413942a8a0188a4f937fa0aa9ab8
Signed-off-by: Ji Luo <ji.luo@nxp.com>
(cherry picked from a5c5748101c383bc3afb424a3ef2689ab2664846)
(cherry picked from c9f8d7c19a7fc20c99e061beabbb094b6bd50f52)

arch/arm/include/asm/arch-imx8/sci/sci.h
board/freescale/imx8qm_mek/imx8qm_mek.c
board/freescale/imx8qxp_mek/imx8qxp_mek.c
drivers/misc/imx8/scu_api.c

index 8809b5e..bab8ad9 100644 (file)
@@ -74,6 +74,7 @@ int sc_pm_set_clock_parent(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk,
                           sc_pm_clk_parent_t parent);
 int sc_pm_cpu_start(sc_ipc_t ipc, sc_rsrc_t resource, sc_bool_t enable,
                    sc_faddr_t address);
+void sc_pm_reboot(sc_ipc_t ipc, sc_pm_reset_type_t type);
 sc_bool_t sc_pm_is_partition_started(sc_ipc_t ipc, sc_rm_pt_t pt);
 int sc_pm_resource_reset(sc_ipc_t ipc, sc_rsrc_t resource);
 
index e6b0ec7..80e60aa 100644 (file)
@@ -428,7 +428,8 @@ void board_quiesce_devices(void)
  */
 void reset_cpu(ulong addr)
 {
-       /* TODO */
+       sc_pm_reboot(-1, SC_PM_RESET_TYPE_COLD);
+       while(1);
 }
 
 #ifdef CONFIG_OF_BOARD_SETUP
index 6e210a3..96f99c7 100644 (file)
@@ -363,7 +363,9 @@ void board_quiesce_devices(void)
  */
 void reset_cpu(ulong addr)
 {
-       /* TODO */
+       sc_pm_reboot(-1, SC_PM_RESET_TYPE_COLD);
+       while(1);
+
 }
 
 #ifdef CONFIG_OF_BOARD_SETUP
index b0da958..1380223 100644 (file)
@@ -851,6 +851,21 @@ int sc_pm_cpu_start(sc_ipc_t ipc, sc_rsrc_t resource, sc_bool_t enable,
        return ret;
 }
 
+void sc_pm_reboot(sc_ipc_t ipc, sc_pm_reset_type_t type)
+{
+       struct udevice *dev = gd->arch.scu_dev;
+       struct sc_rpc_msg_s msg;
+       int size = sizeof(struct sc_rpc_msg_s);
+
+       RPC_VER(&msg) = SC_RPC_VERSION;
+       RPC_SVC(&msg) = (u8)(SC_RPC_SVC_PM);
+       RPC_FUNC(&msg) = (u8)(PM_FUNC_REBOOT);
+       RPC_U8(&msg, 0U) = (u8)(type);
+       RPC_SIZE(&msg) = 2U;
+
+       misc_call(dev, SC_TRUE, &msg, size, &msg, size);
+}
+
 int sc_pm_get_resource_power_mode(sc_ipc_t ipc, sc_rsrc_t resource,
                                  sc_pm_power_mode_t *mode)
 {