reboot: add reboot driver for m8b

PD#141217: add reboot driver for m8b

Change-Id: I99201af1d13744278b30e11f37f1551ad3289ca3
Signed-off-by: Jianxin Pan <jianxin.pan@amlogic.com>
This commit is contained in:
Jianxin Pan
2017-05-02 17:25:50 +08:00
parent 7409424495
commit 52ec2af13f
8 changed files with 205 additions and 3 deletions

View File

@@ -13461,7 +13461,7 @@ M: Yun Cai <yum.cai@amlogic.com>
F: drivers/amlogic/efuse/*
F: include/linux/amlogic/efuse.h
AMLOGIC reboot
AMLOGIC reboot for gx and M8b
M: Jianxin Pan <jianxin.pan@amlogic.com>
F: drivers/amlogic/reboot/*

View File

@@ -952,5 +952,11 @@ dwc2_b {
reg = <0xc110875c 0x4>,
<0xc1108764 0x4>;
};
aml_reboot{
compatible = "aml, reboot_m8b";
status = "okay";
};
}; /* end of soc*/
}; /* end of / */

View File

@@ -180,6 +180,8 @@ CONFIG_AMLOGIC_SARADC=y
CONFIG_AMLOGIC_REMOTE=y
CONFIG_AMLOGIC_MESON_REMOTE=y
CONFIG_AMLOGIC_EFUSE=y
CONFIG_AMLOGIC_REBOOT=y
CONFIG_AMLOGIC_M8B_REBOOT=y
CONFIG_AMLOGIC_CPU_HOTPLUG=y
CONFIG_AMLOGIC_PWM=y
CONFIG_AMLOGIC_MMC=y

View File

@@ -192,6 +192,7 @@ CONFIG_AMLOGIC_REMOTE=y
CONFIG_AMLOGIC_MESON_REMOTE=y
CONFIG_AMLOGIC_EFUSE=y
CONFIG_AMLOGIC_REBOOT=y
CONFIG_AMLOGIC_GX_REBOOT=y
CONFIG_AMLOGIC_INTERNAL_PHY=y
CONFIG_AMLOGIC_CPU_HOTPLUG=y
CONFIG_AMLOGIC_PWM=y

View File

@@ -8,3 +8,23 @@ config AMLOGIC_REBOOT
or poweroff
driver.
config AMLOGIC_GX_REBOOT
bool "Amlogic reboot gx"
depends on AMLOGIC_REBOOT
default n
help
This is the Amlogic GX reboot driver.
config AMLOGIC_M8B_REBOOT
bool "Amlogic reboot m8b"
depends on AMLOGIC_REBOOT
default n
help
This is the Amlogic M8b reboot driver.
config AMLOGIC_M8B_REBOOT_UBOOT_SUSPEND
bool "Amlogic reboot uboot suspend"
depends on AMLOGIC_M8B_REBOOT
default n
help
This is the Amlogic M8b reboot uboot suspend driver.

View File

@@ -1,5 +1,5 @@
#
#Makefile for the RESET dirver
#
obj-$(CONFIG_AMLOGIC_REBOOT) += reboot.o
obj-$(CONFIG_AMLOGIC_GX_REBOOT) += reboot.o
obj-$(CONFIG_AMLOGIC_M8B_REBOOT) += reboot_m8b.o

View File

@@ -0,0 +1,140 @@
/*
* drivers/amlogic/reboot/reboot_m8b.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 <asm/compiler.h>
#include <linux/kdebug.h>
#include <linux/amlogic/iomap.h>
#include <linux/cpuidle.h>
#include <asm/cpuidle.h>
#include <linux/amlogic/reboot_m8b.h>
#define WATCHDOG_ENABLE_BIT (1<<19)
#define DUAL_CORE_RESET (3<<24)
#define AO_RTI_STATUS_REG1 ((0x00 << 10) | (0x01 << 2))
#define VENC_VDAC_SETTING 0x1b7e
#define WATCHDOG_RESET 0x2641
#define WATCHDOG_TC 0x2640
#ifdef AMLOGIC_M8B_REBOOT_UBOOT_SUSPEND
static int reboot_flag;
static int __init do_parse_args(char *line)
{
if (strcmp(line, "uboot_suspend") == 0)
reboot_flag = 1;
pr_info("reboot_flag=%x\n", reboot_flag);
return 1;
}
__setup("reboot_args=", do_parse_args);
#endif
static inline void arch_reset(char mode, const char *cmd)
{
aml_write_cbus(VENC_VDAC_SETTING, 0xf);
aml_write_cbus(WATCHDOG_RESET, 0);
aml_write_cbus(WATCHDOG_TC,
DUAL_CORE_RESET | WATCHDOG_ENABLE_BIT | 100);
while (1)
cpu_do_idle();
}
void meson_common_restart(char mode, const char *cmd)
{
u32 reboot_reason = MESON_NORMAL_BOOT;
if (cmd) {
if (strcmp(cmd, "charging_reboot") == 0)
reboot_reason = MESON_CHARGING_REBOOT;
else 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, "report_crash") == 0)
reboot_reason = MESON_CRASH_REBOOT;
else if (strcmp(cmd, "factory_testl_reboot") == 0)
reboot_reason = MESON_FACTORY_TEST_REBOOT;
else if (strcmp(cmd, "switch_system") == 0)
reboot_reason = MESON_SYSTEM_SWITCH_REBOOT;
else if (strcmp(cmd, "safe_mode") == 0)
reboot_reason = MESON_SAFE_REBOOT;
else if (strcmp(cmd, "lock_system") == 0)
reboot_reason = MESON_LOCK_REBOOT;
else if (strcmp(cmd, "usb_burner_reboot") == 0)
reboot_reason = MESON_USB_BURNER_REBOOT;
else if (strcmp(cmd, "uboot_suspend") == 0)
reboot_reason = MESON_UBOOT_SUSPEND;
}
aml_write_aobus(AO_RTI_STATUS_REG1, reboot_reason);
pr_info("reboot_reason(0x%x) = 0x%x\n", AO_RTI_STATUS_REG1,
aml_read_aobus(AO_RTI_STATUS_REG1));
arch_reset(mode, cmd);
}
static void do_aml_restart(enum reboot_mode reboot_mode, const char *cmd)
{
pr_info("meson power off\n");
#ifdef AMLOGIC_M8B_REBOOT_UBOOT_SUSPEND
if (reboot_flag)
meson_common_restart('h', "uboot_suspend");
else
#endif
meson_common_restart('h', "charging_reboot");
}
static int aml_restart_probe(struct platform_device *pdev)
{
arm_pm_restart = do_aml_restart;
return 0;
}
static const struct of_device_id of_aml_restart_match[] = {
{ .compatible = "aml, reboot_m8b", },
{},
};
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);

View File

@@ -0,0 +1,33 @@
#ifndef __reboot_m8b_h_
#define __reboot_m8b_h_
/*
* include/linux/amlogic/reboot_m8b.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_CHARGING_REBOOT 0x0
#define MESON_NORMAL_BOOT 0x01010101
#define MESON_FACTORY_RESET_REBOOT 0x02020202
#define MESON_UPDATE_REBOOT 0x03030303
#define MESON_CRASH_REBOOT 0x04040404
#define MESON_FACTORY_TEST_REBOOT 0x05050505
#define MESON_SYSTEM_SWITCH_REBOOT 0x06060606
#define MESON_SAFE_REBOOT 0x07070707
#define MESON_LOCK_REBOOT 0x08080808
#define MESON_USB_BURNER_REBOOT 0x09090909
#define MESON_UBOOT_SUSPEND 0x0b0b0b0b
#define MESON_REBOOT_CLEAR 0xdeaddead
#endif