firmware: imx: Add support to start/stop a CPU
authorDaniel Baluta <daniel.baluta@nxp.com>
Wed, 30 Jan 2019 13:30:22 +0000 (13:30 +0000)
committerShawn Guo <shawnguo@kernel.org>
Mon, 11 Feb 2019 02:00:47 +0000 (10:00 +0800)
This is done via RPC call to SCU.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
drivers/firmware/imx/misc.c
include/linux/firmware/imx/svc/misc.h

index 97f5424dbac9872da032fdb221a8a932cfc47a26..4b56a587dacd4b5b65d6d74e83eaec177ba0b7cb 100644 (file)
@@ -18,6 +18,14 @@ struct imx_sc_msg_req_misc_set_ctrl {
        u16 resource;
 } __packed;
 
+struct imx_sc_msg_req_cpu_start {
+       struct imx_sc_rpc_msg hdr;
+       u32 address_hi;
+       u32 address_lo;
+       u16 resource;
+       u8 enable;
+} __packed;
+
 struct imx_sc_msg_req_misc_get_ctrl {
        struct imx_sc_rpc_msg hdr;
        u32 ctrl;
@@ -97,3 +105,33 @@ int imx_sc_misc_get_control(struct imx_sc_ipc *ipc, u32 resource,
        return 0;
 }
 EXPORT_SYMBOL(imx_sc_misc_get_control);
+
+/*
+ * This function starts/stops a CPU identified by @resource
+ *
+ * @param[in]     ipc         IPC handle
+ * @param[in]     resource    resource the control is associated with
+ * @param[in]     enable      true for start, false for stop
+ * @param[in]     phys_addr   initial instruction address to be executed
+ *
+ * @return Returns 0 for success and < 0 for errors.
+ */
+int imx_sc_pm_cpu_start(struct imx_sc_ipc *ipc, u32 resource,
+                       bool enable, u64 phys_addr)
+{
+       struct imx_sc_msg_req_cpu_start msg;
+       struct imx_sc_rpc_msg *hdr = &msg.hdr;
+
+       hdr->ver = IMX_SC_RPC_VERSION;
+       hdr->svc = IMX_SC_RPC_SVC_PM;
+       hdr->func = IMX_SC_PM_FUNC_CPU_START;
+       hdr->size = 4;
+
+       msg.address_hi = phys_addr >> 32;
+       msg.address_lo = phys_addr;
+       msg.resource = resource;
+       msg.enable = enable;
+
+       return imx_scu_call_rpc(ipc, &msg, true);
+}
+EXPORT_SYMBOL(imx_sc_pm_cpu_start);
index e21c49aba92fe3cd0b0c1d29b8fb3c0de44910e2..031dd4d3c766b12f571b074c8579c7bac9445ca9 100644 (file)
@@ -52,4 +52,7 @@ int imx_sc_misc_set_control(struct imx_sc_ipc *ipc, u32 resource,
 int imx_sc_misc_get_control(struct imx_sc_ipc *ipc, u32 resource,
                            u8 ctrl, u32 *val);
 
+int imx_sc_pm_cpu_start(struct imx_sc_ipc *ipc, u32 resource,
+                       bool enable, u64 phys_addr);
+
 #endif /* _SC_MISC_API_H */