mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 12:57:06 +09:00
reboot: enable reboot on gxm and gxl
PD#138714: enable reboot on gxm and gxl Change-Id: I4375aaa546d67b093fd2268bc27e805c9dce8091 Signed-off-by: Jianxin Pan <jianxin.pan@amlogic.com>
This commit is contained in:
@@ -13459,3 +13459,7 @@ AMLOGIC EFUSE DRIVER
|
||||
M: Yun Cai <yum.cai@amlogic.com>
|
||||
F: drivers/amlogic/efuse/*
|
||||
F: include/linux/amlogic/efuse.h
|
||||
|
||||
AMLOGIC reboot
|
||||
M: Jianxin Pan <jianxin.pan@amlogic.com>
|
||||
F: drivers/amlogic/reboot/*
|
||||
|
||||
@@ -747,5 +747,11 @@
|
||||
size = <16>;
|
||||
};
|
||||
};
|
||||
|
||||
aml_reboot {
|
||||
compatible = "aml, reboot";
|
||||
sys_reset = <0x84000009>;
|
||||
sys_poweroff = <0x84000008>;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -792,5 +792,11 @@
|
||||
size = <16>;
|
||||
};
|
||||
};
|
||||
|
||||
aml_reboot{
|
||||
compatible = "aml, reboot";
|
||||
sys_reset = <0x84000009>;
|
||||
sys_poweroff = <0x84000008>;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -173,6 +173,7 @@ CONFIG_AMLOGIC_INPUT_KEYBOARD=y
|
||||
CONFIG_AMLOGIC_ADC_KEYPADS=y
|
||||
CONFIG_AMLOGIC_SARADC=y
|
||||
CONFIG_AMLOGIC_EFUSE=y
|
||||
CONFIG_AMLOGIC_REBOOT=y
|
||||
CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
|
||||
CONFIG_DEVTMPFS=y
|
||||
CONFIG_DEVTMPFS_MOUNT=y
|
||||
|
||||
@@ -36,5 +36,7 @@ source "drivers/amlogic/crypto/Kconfig"
|
||||
source "drivers/amlogic/input/Kconfig"
|
||||
|
||||
source "drivers/amlogic/efuse/Kconfig"
|
||||
|
||||
source "drivers/amlogic/reboot/Kconfig"
|
||||
endmenu
|
||||
endif
|
||||
|
||||
@@ -33,3 +33,5 @@ obj-$(CONFIG_AMLOGIC_CRYPTO) += crypto/
|
||||
obj-$(CONFIG_AMLOGIC_INPUT) += input/
|
||||
|
||||
obj-$(CONFIG_AMLOGIC_EFUSE) += efuse/
|
||||
|
||||
obj-$(CONFIG_AMLOGIC_REBOOT) += reboot/
|
||||
|
||||
10
drivers/amlogic/reboot/Kconfig
Normal file
10
drivers/amlogic/reboot/Kconfig
Normal file
@@ -0,0 +1,10 @@
|
||||
# Amlogic POWER OFF
|
||||
config AMLOGIC_REBOOT
|
||||
bool "Amlogic Board level reboot or power off"
|
||||
default n
|
||||
help
|
||||
This is the Amlogic
|
||||
Board reboot
|
||||
or poweroff
|
||||
driver.
|
||||
|
||||
5
drivers/amlogic/reboot/Makefile
Normal file
5
drivers/amlogic/reboot/Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
#
|
||||
#Makefile for the RESET dirver
|
||||
#
|
||||
obj-$(CONFIG_AMLOGIC_REBOOT) += reboot.o
|
||||
|
||||
160
drivers/amlogic/reboot/reboot.c
Normal file
160
drivers/amlogic/reboot/reboot.c
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* drivers/amlogic/reboot/reboot.c
|
||||
*
|
||||
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/reboot.h>
|
||||
|
||||
#include <asm/system_misc.h>
|
||||
|
||||
#include <linux/amlogic/iomap.h>
|
||||
#include <linux/amlogic/cpu_version.h>
|
||||
#include <linux/amlogic/reboot.h>
|
||||
#include <asm/compiler.h>
|
||||
#include <linux/kdebug.h>
|
||||
|
||||
static u32 psci_function_id_restart;
|
||||
static u32 psci_function_id_poweroff;
|
||||
static char *kernel_panic;
|
||||
static u32 parse_reason(const char *cmd)
|
||||
{
|
||||
u32 reboot_reason = MESON_NORMAL_BOOT;
|
||||
|
||||
if (cmd) {
|
||||
if (strcmp(cmd, "recovery") == 0 ||
|
||||
strcmp(cmd, "factory_reset") == 0)
|
||||
reboot_reason = MESON_FACTORY_RESET_REBOOT;
|
||||
else if (strcmp(cmd, "update") == 0)
|
||||
reboot_reason = MESON_UPDATE_REBOOT;
|
||||
else if (strcmp(cmd, "fastboot") == 0)
|
||||
reboot_reason = MESON_FASTBOOT_REBOOT;
|
||||
else if (strcmp(cmd, "bootloader") == 0)
|
||||
reboot_reason = MESON_BOOTLOADER_REBOOT;
|
||||
else if (strcmp(cmd, "report_crash") == 0)
|
||||
reboot_reason = MESON_CRASH_REBOOT;
|
||||
else if (strcmp(cmd, "uboot_suspend") == 0)
|
||||
reboot_reason = MESON_UBOOT_SUSPEND;
|
||||
} else {
|
||||
if (kernel_panic) {
|
||||
if (strcmp(kernel_panic, "kernel_panic") == 0)
|
||||
reboot_reason = MESON_KERNEL_PANIC;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pr_info("reboot reason %d\n", reboot_reason);
|
||||
return reboot_reason;
|
||||
}
|
||||
static noinline int __invoke_psci_fn_smc(u64 function_id, u64 arg0, u64 arg1,
|
||||
u64 arg2)
|
||||
{
|
||||
register long x0 asm("x0") = function_id;
|
||||
register long x1 asm("x1") = arg0;
|
||||
register long x2 asm("x2") = arg1;
|
||||
register long x3 asm("x3") = arg2;
|
||||
asm volatile(
|
||||
__asmeq("%0", "x0")
|
||||
__asmeq("%1", "x1")
|
||||
__asmeq("%2", "x2")
|
||||
__asmeq("%3", "x3")
|
||||
"smc #0\n"
|
||||
: "+r" (x0)
|
||||
: "r" (x1), "r" (x2), "r" (x3));
|
||||
|
||||
return function_id;
|
||||
}
|
||||
void meson_smc_restart(u64 function_id, u64 reboot_reason)
|
||||
{
|
||||
__invoke_psci_fn_smc(function_id,
|
||||
reboot_reason, 0, 0);
|
||||
}
|
||||
void meson_common_restart(char mode, const char *cmd)
|
||||
{
|
||||
u32 reboot_reason = parse_reason(cmd);
|
||||
|
||||
if (psci_function_id_restart)
|
||||
meson_smc_restart((u64)psci_function_id_restart,
|
||||
(u64)reboot_reason);
|
||||
}
|
||||
static void do_aml_restart(enum reboot_mode reboot_mode, const char *cmd)
|
||||
{
|
||||
meson_common_restart(reboot_mode, cmd);
|
||||
}
|
||||
|
||||
static void do_aml_poweroff(void)
|
||||
{
|
||||
/* TODO: Add poweroff capability */
|
||||
__invoke_psci_fn_smc(0x82000042, 1, 0, 0);
|
||||
__invoke_psci_fn_smc(psci_function_id_poweroff,
|
||||
0, 0, 0);
|
||||
}
|
||||
static int panic_notify(struct notifier_block *self,
|
||||
unsigned long cmd, void *ptr)
|
||||
{
|
||||
kernel_panic = "kernel_panic";
|
||||
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static struct notifier_block panic_notifier = {
|
||||
.notifier_call = panic_notify,
|
||||
};
|
||||
|
||||
static int aml_restart_probe(struct platform_device *pdev)
|
||||
{
|
||||
u32 id;
|
||||
int ret;
|
||||
|
||||
if (!of_property_read_u32(pdev->dev.of_node, "sys_reset", &id)) {
|
||||
psci_function_id_restart = id;
|
||||
arm_pm_restart = do_aml_restart;
|
||||
}
|
||||
|
||||
if (!of_property_read_u32(pdev->dev.of_node, "sys_poweroff", &id)) {
|
||||
psci_function_id_poweroff = id;
|
||||
pm_power_off = do_aml_poweroff;
|
||||
}
|
||||
|
||||
ret = register_die_notifier(&panic_notifier);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct of_device_id of_aml_restart_match[] = {
|
||||
{ .compatible = "aml, reboot", },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, of_aml_restart_match);
|
||||
|
||||
static struct platform_driver aml_restart_driver = {
|
||||
.probe = aml_restart_probe,
|
||||
.driver = {
|
||||
.name = "aml-restart",
|
||||
.of_match_table = of_match_ptr(of_aml_restart_match),
|
||||
},
|
||||
};
|
||||
|
||||
static int __init aml_restart_init(void)
|
||||
{
|
||||
return platform_driver_register(&aml_restart_driver);
|
||||
}
|
||||
device_initcall(aml_restart_init);
|
||||
28
include/linux/amlogic/reboot.h
Normal file
28
include/linux/amlogic/reboot.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* include/linux/amlogic/reboot.h
|
||||
*
|
||||
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
*/
|
||||
|
||||
/*******************************************************************/
|
||||
#define MESON_COLD_REBOOT 0
|
||||
#define MESON_NORMAL_BOOT 1
|
||||
#define MESON_FACTORY_RESET_REBOOT 2
|
||||
#define MESON_UPDATE_REBOOT 3
|
||||
#define MESON_FASTBOOT_REBOOT 4
|
||||
#define MESON_UBOOT_SUSPEND 5
|
||||
#define MESON_HIBERNATE 6
|
||||
#define MESON_BOOTLOADER_REBOOT 7
|
||||
#define MESON_CRASH_REBOOT 11
|
||||
#define MESON_KERNEL_PANIC 12
|
||||
Reference in New Issue
Block a user