power: reset: Add snapshot of vm power off driver

Add snapshot of vm power off driver as of msm-4.14
'commit 77a20e0a50e1
("power: reset: cache flush before VM restart")'.

Change-Id: I380b16f46429711284bb6717847a1eef5d8ee9b1
Signed-off-by: Ping Jiang <scottjiang@codeaurora.org>
This commit is contained in:
Ping Jiang 2020-08-14 22:03:02 +08:00
parent be60e6e783
commit bacd2262eb
3 changed files with 103 additions and 0 deletions

View File

@ -105,6 +105,14 @@ config POWER_RESET_MSM
help
Power off and restart support for Qualcomm boards.
config POWER_RESET_QCOM_VM
tristate "Qualcomm Technologies, Inc. MSM VM power-off driver"
help
Power off and restart support for Qualcomm Technologies, Inc. virtual
machine. This driver supports virtual machine power down and restart.
Say Y here if you have a MSM virtual machine and wish to enable
restart driver.
config POWER_RESET_QCOM_DOWNLOAD_MODE
tristate "MSM download mode driver"
depends on ARCH_QCOM

View File

@ -11,6 +11,7 @@ obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o
obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o
obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o
obj-$(CONFIG_POWER_RESET_QCOM_VM) += msm-vm-poweroff.o
obj-$(CONFIG_POWER_RESET_QCOM_DOWNLOAD_MODE) += qcom-dload-mode.o
obj-$(CONFIG_POWER_RESET_QCOM_PON) += qcom-pon.o
obj-$(CONFIG_POWER_RESET_QCOM_REBOOT_REASON) += qcom-reboot-reason.o

View File

@ -0,0 +1,94 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
*/
#include <linux/io.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/reboot.h>
#include <linux/pm.h>
#include <linux/delay.h>
#include <linux/of_address.h>
#include <asm/cacheflush.h>
#include <asm/system_misc.h>
#include <soc/qcom/watchdog.h>
static int in_panic;
static struct notifier_block restart_nb;
static int panic_prep_restart(struct notifier_block *this,
unsigned long event, void *ptr)
{
in_panic = 1;
return NOTIFY_DONE;
}
static struct notifier_block panic_blk = {
.notifier_call = panic_prep_restart,
};
static int do_vm_restart(struct notifier_block *unused, unsigned long action,
void *arg)
{
pr_notice("Going down for vm restart now\n");
flush_cache_all();
/*outer_flush_all is not supported by 64bit kernel*/
#ifndef CONFIG_ARM64
outer_flush_all();
#endif
if (in_panic)
qcom_wdt_trigger_bite();
return NOTIFY_DONE;
}
static int vm_restart_probe(struct platform_device *pdev)
{
atomic_notifier_chain_register(&panic_notifier_list, &panic_blk);
restart_nb.notifier_call = do_vm_restart;
restart_nb.priority = 200;
register_restart_handler(&restart_nb);
return 0;
}
static const struct of_device_id of_vm_restart_match[] = {
{ .compatible = "qcom,vm-restart", },
{},
};
MODULE_DEVICE_TABLE(of, of_vm_restart_match);
static struct platform_driver vm_restart_driver = {
.probe = vm_restart_probe,
.driver = {
.name = "msm-vm-restart",
.of_match_table = of_match_ptr(of_vm_restart_match),
},
};
static int __init vm_restart_init(void)
{
return platform_driver_register(&vm_restart_driver);
}
#if IS_MODULE(CONFIG_POWER_RESET_QCOM_VM)
module_init(vm_restart_init);
#else
pure_initcall(vm_restart_init);
#endif
static __exit void vm_restart_exit(void)
{
platform_driver_unregister(&vm_restart_driver);
}
module_exit(vm_restart_exit);
MODULE_DESCRIPTION("MSM VM Poweroff Driver");
MODULE_LICENSE("GPL v2");