MLK-13733-5 ARM: imx: imx_rpmsg: add shutdown for rpmsg
authorRobin Gong <yibin.gong@nxp.com>
Mon, 6 Feb 2017 05:33:42 +0000 (13:33 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:58:25 +0000 (14:58 -0500)
Add shutdown message to notify m4 side so that rpmsg can work
after A7 boot again.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
arch/arm/mach-imx/common.h
arch/arm/mach-imx/imx_rpmsg.c
arch/arm/mach-imx/pm-rpmsg.c

index 54a000d..6c0e83d 100644 (file)
@@ -215,6 +215,7 @@ static inline void imx7_suspend(void __iomem *ocram_vbase) {}
 static inline void imx7ulp_suspend(void __iomem *ocram_vbase) {}
 void pm_vlls_notify_m4(bool enter) {}
 #endif
+void pm_shutdown_notify_m4(void);
 
 void imx6_pm_ccm_init(const char *ccm_compat);
 void imx6q_pm_init(void);
index 2e2f534..0e7bb06 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
  *
  * derived from the omap-rpmsg implementation.
  *
@@ -25,6 +26,7 @@
 #include <linux/virtio_ids.h>
 #include <linux/virtio_ring.h>
 #include <linux/imx_rpmsg.h>
+#include "common.h"
 
 struct imx_virdev {
        struct virtio_device vdev;
@@ -388,6 +390,12 @@ static int imx_rpmsg_remove(struct platform_device *pdev)
        return 0;
 }
 
+static void imx_rpmsg_shutdown(struct platform_device *pdev)
+{
+       pm_shutdown_notify_m4();
+       pr_info("shutdown imx rpmsg.\n");
+}
+
 static struct platform_driver imx_rpmsg_driver = {
        .driver = {
                   .owner = THIS_MODULE,
@@ -396,6 +404,7 @@ static struct platform_driver imx_rpmsg_driver = {
                   },
        .probe = imx_rpmsg_probe,
        .remove = imx_rpmsg_remove,
+       .shutdown = imx_rpmsg_shutdown,
 };
 
 static int __init imx_rpmsg_init(void)
index a98bf8f..6307902 100644 (file)
@@ -41,6 +41,7 @@ enum pm_rpmsg_power_mode {
        PM_RPMSG_WAIT,
        PM_RPMSG_VLPS,
        PM_RPMSG_VLLS,
+       PM_RPMSG_SHUTDOWN,
 };
 
 struct pm_rpmsg_info {
@@ -95,6 +96,21 @@ void pm_vlls_notify_m4(bool enter)
        pm_send_message(&msg, &pm_rpmsg);
 }
 
+void pm_shutdown_notify_m4(void)
+{
+       struct pm_rpmsg_data msg;
+
+       msg.header.cate = IMX_RMPSG_LIFECYCLE;
+       msg.header.major = IMX_RMPSG_MAJOR;
+       msg.header.minor = IMX_RMPSG_MINOR;
+       msg.header.type = PM_RPMSG_TYPE;
+       msg.header.cmd = PM_RPMSG_MODE;
+       msg.data = PM_RPMSG_SHUTDOWN;
+
+       pm_send_message(&msg, &pm_rpmsg);
+
+}
+
 static void pm_heart_beat_work_handler(struct work_struct *work)
 {
        struct pm_rpmsg_data msg;