mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-11 15:40:50 +00:00
Allow parent rate changes for i2s on rk3288
and rockchip as well as s3c24xx restart handlers. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAABCAAGBQJUK/GYAAoJEPOmecmc0R2Bnc8IAJY3NpUhN2It0WqL1meeIDr7 jGVphxhiEsAlXMbHyO0V/LhUTbGtjfDotd43Y84cZW43R7G2ErvvBsWMKCff2xIB cVtjXJ8JI+s2T/gBEssZDnhh1dcP04fnZ2LMdLCGudnmn2AyR2AXQQBqFiO+kQWe 0x2dsGgcQPn93X9i9sT03BKJTZjRoCZkUh0aJ2y+yL9Y5A9CNXCVGfJ5E1GNw3Px ffeKA0OsOhUMw9aqb8fLvDuRd0mo1i+BSCaOeNTlwzASmxCUJ9MOOKtF/Khx7x2r 6N3w/EN4F8R+qJ/gOyZR9I3SrnLU1rMBOHvaSxDJb0RXAq5AROvQS1t4GiF2A68= =bvGz -----END PGP SIGNATURE----- Merge tag 'v3.18-rockchip-clk2' of git://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip into clk-next Allow parent rate changes for i2s on rk3288 and rockchip as well as s3c24xx restart handlers.
This commit is contained in:
commit
a797900950
@ -114,18 +114,13 @@ void soft_restart(unsigned long addr)
|
||||
BUG();
|
||||
}
|
||||
|
||||
static void null_restart(enum reboot_mode reboot_mode, const char *cmd)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Function pointers to optional machine specific functions
|
||||
*/
|
||||
void (*pm_power_off)(void);
|
||||
EXPORT_SYMBOL(pm_power_off);
|
||||
|
||||
void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd) = null_restart;
|
||||
EXPORT_SYMBOL_GPL(arm_pm_restart);
|
||||
void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
|
||||
|
||||
/*
|
||||
* This is our default idle handler.
|
||||
@ -230,7 +225,10 @@ void machine_restart(char *cmd)
|
||||
local_irq_disable();
|
||||
smp_send_stop();
|
||||
|
||||
arm_pm_restart(reboot_mode, cmd);
|
||||
if (arm_pm_restart)
|
||||
arm_pm_restart(reboot_mode, cmd);
|
||||
else
|
||||
do_kernel_restart(cmd);
|
||||
|
||||
/* Give a grace period for failure to restart of 1s */
|
||||
mdelay(1000);
|
||||
|
@ -98,7 +98,6 @@ void (*pm_power_off)(void);
|
||||
EXPORT_SYMBOL_GPL(pm_power_off);
|
||||
|
||||
void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
|
||||
EXPORT_SYMBOL_GPL(arm_pm_restart);
|
||||
|
||||
/*
|
||||
* This is our default idle handler.
|
||||
@ -180,6 +179,8 @@ void machine_restart(char *cmd)
|
||||
/* Now call the architecture specific reboot code. */
|
||||
if (arm_pm_restart)
|
||||
arm_pm_restart(reboot_mode, cmd);
|
||||
else
|
||||
do_kernel_restart(cmd);
|
||||
|
||||
/*
|
||||
* Whoops - the architecture was unable to reboot.
|
||||
|
@ -735,6 +735,8 @@ static void __init rk3188_common_clk_init(struct device_node *np)
|
||||
|
||||
rockchip_register_softrst(np, 9, reg_base + RK2928_SOFTRST_CON(0),
|
||||
ROCKCHIP_SOFTRST_HIWORD_MASK);
|
||||
|
||||
rockchip_register_restart_notifier(RK2928_GLB_SRST_FST);
|
||||
}
|
||||
|
||||
static void __init rk3066a_clk_init(struct device_node *np)
|
||||
|
@ -300,15 +300,15 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
|
||||
COMPOSITE(0, "i2s_src", mux_pll_src_cpll_gpll_p, 0,
|
||||
RK3288_CLKSEL_CON(4), 15, 1, MFLAGS, 0, 7, DFLAGS,
|
||||
RK3288_CLKGATE_CON(4), 1, GFLAGS),
|
||||
COMPOSITE_FRAC(0, "i2s_frac", "i2s_src", 0,
|
||||
COMPOSITE_FRAC(0, "i2s_frac", "i2s_src", CLK_SET_RATE_PARENT,
|
||||
RK3288_CLKSEL_CON(8), 0,
|
||||
RK3288_CLKGATE_CON(4), 2, GFLAGS),
|
||||
MUX(0, "i2s_pre", mux_i2s_pre_p, 0,
|
||||
MUX(0, "i2s_pre", mux_i2s_pre_p, CLK_SET_RATE_PARENT,
|
||||
RK3288_CLKSEL_CON(4), 8, 2, MFLAGS),
|
||||
COMPOSITE_NODIV(0, "i2s0_clkout", mux_i2s_clkout_p, 0,
|
||||
COMPOSITE_NODIV(0, "i2s0_clkout", mux_i2s_clkout_p, CLK_SET_RATE_PARENT,
|
||||
RK3288_CLKSEL_CON(4), 12, 1, MFLAGS,
|
||||
RK3288_CLKGATE_CON(4), 0, GFLAGS),
|
||||
GATE(SCLK_I2S0, "sclk_i2s0", "i2s_pre", 0,
|
||||
GATE(SCLK_I2S0, "sclk_i2s0", "i2s_pre", CLK_SET_RATE_PARENT,
|
||||
RK3288_CLKGATE_CON(4), 3, GFLAGS),
|
||||
|
||||
MUX(0, "spdif_src", mux_pll_src_cpll_gpll_p, 0,
|
||||
@ -808,5 +808,7 @@ static void __init rk3288_clk_init(struct device_node *np)
|
||||
|
||||
rockchip_register_softrst(np, 12, reg_base + RK3288_SOFTRST_CON(0),
|
||||
ROCKCHIP_SOFTRST_HIWORD_MASK);
|
||||
|
||||
rockchip_register_restart_notifier(RK3288_GLB_SRST_FST);
|
||||
}
|
||||
CLK_OF_DECLARE(rk3288_cru, "rockchip,rk3288-cru", rk3288_clk_init);
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <linux/clk-provider.h>
|
||||
#include <linux/mfd/syscon.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/reboot.h>
|
||||
#include "clk.h"
|
||||
|
||||
/**
|
||||
@ -330,3 +331,27 @@ void __init rockchip_clk_protect_critical(const char *clocks[], int nclocks)
|
||||
clk_prepare_enable(clk);
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int reg_restart;
|
||||
static int rockchip_restart_notify(struct notifier_block *this,
|
||||
unsigned long mode, void *cmd)
|
||||
{
|
||||
writel(0xfdb9, reg_base + reg_restart);
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static struct notifier_block rockchip_restart_handler = {
|
||||
.notifier_call = rockchip_restart_notify,
|
||||
.priority = 128,
|
||||
};
|
||||
|
||||
void __init rockchip_register_restart_notifier(unsigned int reg)
|
||||
{
|
||||
int ret;
|
||||
|
||||
reg_restart = reg;
|
||||
ret = register_restart_handler(&rockchip_restart_handler);
|
||||
if (ret)
|
||||
pr_err("%s: cannot register restart handler, %d\n",
|
||||
__func__, ret);
|
||||
}
|
||||
|
@ -367,6 +367,7 @@ void rockchip_clk_register_armclk(unsigned int lookup_id, const char *name,
|
||||
const struct rockchip_cpuclk_rate_table *rates,
|
||||
int nrates);
|
||||
void rockchip_clk_protect_critical(const char *clocks[], int nclocks);
|
||||
void rockchip_register_restart_notifier(unsigned int reg);
|
||||
|
||||
#define ROCKCHIP_SOFTRST_HIWORD_MASK BIT(0)
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/syscore_ops.h>
|
||||
#include <linux/reboot.h>
|
||||
|
||||
#include <dt-bindings/clock/s3c2412.h>
|
||||
|
||||
@ -26,6 +27,7 @@
|
||||
#define CLKCON 0x0c
|
||||
#define CLKDIVN 0x14
|
||||
#define CLKSRC 0x1c
|
||||
#define SWRST 0x30
|
||||
|
||||
/* list of PLLs to be registered */
|
||||
enum s3c2412_plls {
|
||||
@ -204,6 +206,28 @@ struct samsung_clock_alias s3c2412_aliases[] __initdata = {
|
||||
ALIAS(MSYSCLK, NULL, "fclk"),
|
||||
};
|
||||
|
||||
static int s3c2412_restart(struct notifier_block *this,
|
||||
unsigned long mode, void *cmd)
|
||||
{
|
||||
/* errata "Watch-dog/Software Reset Problem" specifies that
|
||||
* this reset must be done with the SYSCLK sourced from
|
||||
* EXTCLK instead of FOUT to avoid a glitch in the reset
|
||||
* mechanism.
|
||||
*
|
||||
* See the watchdog section of the S3C2412 manual for more
|
||||
* information on this fix.
|
||||
*/
|
||||
|
||||
__raw_writel(0x00, reg_base + CLKSRC);
|
||||
__raw_writel(0x533C2412, reg_base + SWRST);
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static struct notifier_block s3c2412_restart_handler = {
|
||||
.notifier_call = s3c2412_restart,
|
||||
.priority = 129,
|
||||
};
|
||||
|
||||
/*
|
||||
* fixed rate clocks generated outside the soc
|
||||
* Only necessary until the devicetree-move is complete
|
||||
@ -233,6 +257,7 @@ void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f,
|
||||
unsigned long ext_f, void __iomem *base)
|
||||
{
|
||||
struct samsung_clk_provider *ctx;
|
||||
int ret;
|
||||
reg_base = base;
|
||||
|
||||
if (np) {
|
||||
@ -267,6 +292,10 @@ void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f,
|
||||
s3c2412_clk_sleep_init();
|
||||
|
||||
samsung_clk_of_add_provider(np, ctx);
|
||||
|
||||
ret = register_restart_handler(&s3c2412_restart_handler);
|
||||
if (ret)
|
||||
pr_warn("cannot register restart handler, %d\n", ret);
|
||||
}
|
||||
|
||||
static void __init s3c2412_clk_init(struct device_node *np)
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/syscore_ops.h>
|
||||
#include <linux/reboot.h>
|
||||
|
||||
#include <dt-bindings/clock/s3c2443.h>
|
||||
|
||||
@ -33,6 +34,7 @@
|
||||
#define HCLKCON 0x30
|
||||
#define PCLKCON 0x34
|
||||
#define SCLKCON 0x38
|
||||
#define SWRST 0x44
|
||||
|
||||
/* the soc types */
|
||||
enum supported_socs {
|
||||
@ -354,6 +356,18 @@ struct samsung_clock_alias s3c2450_aliases[] __initdata = {
|
||||
ALIAS(PCLK_I2C1, "s3c2410-i2c.1", "i2c"),
|
||||
};
|
||||
|
||||
static int s3c2443_restart(struct notifier_block *this,
|
||||
unsigned long mode, void *cmd)
|
||||
{
|
||||
__raw_writel(0x533c2443, reg_base + SWRST);
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static struct notifier_block s3c2443_restart_handler = {
|
||||
.notifier_call = s3c2443_restart,
|
||||
.priority = 129,
|
||||
};
|
||||
|
||||
/*
|
||||
* fixed rate clocks generated outside the soc
|
||||
* Only necessary until the devicetree-move is complete
|
||||
@ -378,6 +392,7 @@ void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
|
||||
void __iomem *base)
|
||||
{
|
||||
struct samsung_clk_provider *ctx;
|
||||
int ret;
|
||||
reg_base = base;
|
||||
|
||||
if (np) {
|
||||
@ -447,6 +462,10 @@ void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
|
||||
s3c2443_clk_sleep_init();
|
||||
|
||||
samsung_clk_of_add_provider(np, ctx);
|
||||
|
||||
ret = register_restart_handler(&s3c2443_restart_handler);
|
||||
if (ret)
|
||||
pr_warn("cannot register restart handler, %d\n", ret);
|
||||
}
|
||||
|
||||
static void __init s3c2416_clk_init(struct device_node *np)
|
||||
|
@ -20,7 +20,8 @@
|
||||
|
||||
static void restart_poweroff_do_poweroff(void)
|
||||
{
|
||||
arm_pm_restart(REBOOT_HARD, NULL);
|
||||
reboot_mode = REBOOT_HARD;
|
||||
machine_restart(NULL);
|
||||
}
|
||||
|
||||
static int restart_poweroff_probe(struct platform_device *pdev)
|
||||
|
@ -301,6 +301,28 @@ static struct miscdevice wdt_miscdev = {
|
||||
.fops = &wdt_fops,
|
||||
};
|
||||
|
||||
static int wdt_restart_handle(struct notifier_block *this, unsigned long mode,
|
||||
void *cmd)
|
||||
{
|
||||
/*
|
||||
* Cobalt devices have no way of rebooting themselves other
|
||||
* than getting the watchdog to pull reset, so we restart the
|
||||
* watchdog on reboot with no heartbeat.
|
||||
*/
|
||||
wdt_change(WDT_ENABLE);
|
||||
|
||||
/* loop until the watchdog fires */
|
||||
while (true)
|
||||
;
|
||||
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static struct notifier_block wdt_restart_handler = {
|
||||
.notifier_call = wdt_restart_handle,
|
||||
.priority = 128,
|
||||
};
|
||||
|
||||
/*
|
||||
* Notifier for system down
|
||||
*/
|
||||
@ -311,15 +333,6 @@ static int wdt_notify_sys(struct notifier_block *this,
|
||||
if (code == SYS_DOWN || code == SYS_HALT)
|
||||
wdt_turnoff();
|
||||
|
||||
if (code == SYS_RESTART) {
|
||||
/*
|
||||
* Cobalt devices have no way of rebooting themselves other
|
||||
* than getting the watchdog to pull reset, so we restart the
|
||||
* watchdog on reboot with no heartbeat
|
||||
*/
|
||||
wdt_change(WDT_ENABLE);
|
||||
pr_info("Watchdog timer is now enabled with no heartbeat - should reboot in ~1 second\n");
|
||||
}
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
@ -338,6 +351,7 @@ static void __exit alim7101_wdt_unload(void)
|
||||
/* Deregister */
|
||||
misc_deregister(&wdt_miscdev);
|
||||
unregister_reboot_notifier(&wdt_notifier);
|
||||
unregister_restart_handler(&wdt_restart_handler);
|
||||
pci_dev_put(alim7101_pmu);
|
||||
}
|
||||
|
||||
@ -390,11 +404,17 @@ static int __init alim7101_wdt_init(void)
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
rc = register_restart_handler(&wdt_restart_handler);
|
||||
if (rc) {
|
||||
pr_err("cannot register restart handler (err=%d)\n", rc);
|
||||
goto err_out_reboot;
|
||||
}
|
||||
|
||||
rc = misc_register(&wdt_miscdev);
|
||||
if (rc) {
|
||||
pr_err("cannot register miscdev on minor=%d (err=%d)\n",
|
||||
wdt_miscdev.minor, rc);
|
||||
goto err_out_reboot;
|
||||
goto err_out_restart;
|
||||
}
|
||||
|
||||
if (nowayout)
|
||||
@ -404,6 +424,8 @@ static int __init alim7101_wdt_init(void)
|
||||
timeout, nowayout);
|
||||
return 0;
|
||||
|
||||
err_out_restart:
|
||||
unregister_restart_handler(&wdt_restart_handler);
|
||||
err_out_reboot:
|
||||
unregister_reboot_notifier(&wdt_notifier);
|
||||
err_out:
|
||||
|
@ -15,12 +15,12 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/reboot.h>
|
||||
#include <linux/watchdog.h>
|
||||
#include <linux/moduleparam.h>
|
||||
|
||||
#include <asm/system_misc.h>
|
||||
|
||||
#define REG_COUNT 0x4
|
||||
#define REG_MODE 0x8
|
||||
#define REG_ENABLE 0xC
|
||||
@ -29,17 +29,22 @@ struct moxart_wdt_dev {
|
||||
struct watchdog_device dev;
|
||||
void __iomem *base;
|
||||
unsigned int clock_frequency;
|
||||
struct notifier_block restart_handler;
|
||||
};
|
||||
|
||||
static struct moxart_wdt_dev *moxart_restart_ctx;
|
||||
|
||||
static int heartbeat;
|
||||
|
||||
static void moxart_wdt_restart(enum reboot_mode reboot_mode, const char *cmd)
|
||||
static int moxart_restart_handle(struct notifier_block *this,
|
||||
unsigned long mode, void *cmd)
|
||||
{
|
||||
writel(1, moxart_restart_ctx->base + REG_COUNT);
|
||||
writel(0x5ab9, moxart_restart_ctx->base + REG_MODE);
|
||||
writel(0x03, moxart_restart_ctx->base + REG_ENABLE);
|
||||
struct moxart_wdt_dev *moxart_wdt = container_of(this,
|
||||
struct moxart_wdt_dev,
|
||||
restart_handler);
|
||||
writel(1, moxart_wdt->base + REG_COUNT);
|
||||
writel(0x5ab9, moxart_wdt->base + REG_MODE);
|
||||
writel(0x03, moxart_wdt->base + REG_ENABLE);
|
||||
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static int moxart_wdt_stop(struct watchdog_device *wdt_dev)
|
||||
@ -136,8 +141,12 @@ static int moxart_wdt_probe(struct platform_device *pdev)
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
moxart_restart_ctx = moxart_wdt;
|
||||
arm_pm_restart = moxart_wdt_restart;
|
||||
moxart_wdt->restart_handler.notifier_call = moxart_restart_handle;
|
||||
moxart_wdt->restart_handler.priority = 128;
|
||||
err = register_restart_handler(&moxart_wdt->restart_handler);
|
||||
if (err)
|
||||
dev_err(dev, "cannot register restart notifier (err=%d)\n",
|
||||
err);
|
||||
|
||||
dev_dbg(dev, "Watchdog enabled (heartbeat=%d sec, nowayout=%d)\n",
|
||||
moxart_wdt->dev.timeout, nowayout);
|
||||
@ -149,9 +158,8 @@ static int moxart_wdt_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct moxart_wdt_dev *moxart_wdt = platform_get_drvdata(pdev);
|
||||
|
||||
arm_pm_restart = NULL;
|
||||
unregister_restart_handler(&moxart_wdt->restart_handler);
|
||||
moxart_wdt_stop(&moxart_wdt->dev);
|
||||
watchdog_unregister_device(&moxart_wdt->dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -21,14 +21,13 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/reboot.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/watchdog.h>
|
||||
|
||||
#include <asm/system_misc.h>
|
||||
|
||||
#define WDT_MAX_TIMEOUT 16
|
||||
#define WDT_MIN_TIMEOUT 1
|
||||
#define WDT_MODE_TIMEOUT(n) ((n) << 3)
|
||||
@ -50,6 +49,7 @@ static unsigned int timeout = WDT_MAX_TIMEOUT;
|
||||
struct sunxi_wdt_dev {
|
||||
struct watchdog_device wdt_dev;
|
||||
void __iomem *wdt_base;
|
||||
struct notifier_block restart_handler;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -74,24 +74,29 @@ static const int wdt_timeout_map[] = {
|
||||
[16] = 0xB, /* 16s */
|
||||
};
|
||||
|
||||
static void __iomem *reboot_wdt_base;
|
||||
|
||||
static void sun4i_wdt_restart(enum reboot_mode mode, const char *cmd)
|
||||
static int sunxi_restart_handle(struct notifier_block *this, unsigned long mode,
|
||||
void *cmd)
|
||||
{
|
||||
struct sunxi_wdt_dev *sunxi_wdt = container_of(this,
|
||||
struct sunxi_wdt_dev,
|
||||
restart_handler);
|
||||
void __iomem *wdt_base = sunxi_wdt->wdt_base;
|
||||
|
||||
/* Enable timer and set reset bit in the watchdog */
|
||||
writel(WDT_MODE_EN | WDT_MODE_RST_EN, reboot_wdt_base + WDT_MODE);
|
||||
writel(WDT_MODE_EN | WDT_MODE_RST_EN, wdt_base + WDT_MODE);
|
||||
|
||||
/*
|
||||
* Restart the watchdog. The default (and lowest) interval
|
||||
* value for the watchdog is 0.5s.
|
||||
*/
|
||||
writel(WDT_CTRL_RELOAD, reboot_wdt_base + WDT_CTRL);
|
||||
writel(WDT_CTRL_RELOAD, wdt_base + WDT_CTRL);
|
||||
|
||||
while (1) {
|
||||
mdelay(5);
|
||||
writel(WDT_MODE_EN | WDT_MODE_RST_EN,
|
||||
reboot_wdt_base + WDT_MODE);
|
||||
writel(WDT_MODE_EN | WDT_MODE_RST_EN, wdt_base + WDT_MODE);
|
||||
}
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static int sunxi_wdt_ping(struct watchdog_device *wdt_dev)
|
||||
@ -205,8 +210,12 @@ static int sunxi_wdt_probe(struct platform_device *pdev)
|
||||
if (unlikely(err))
|
||||
return err;
|
||||
|
||||
reboot_wdt_base = sunxi_wdt->wdt_base;
|
||||
arm_pm_restart = sun4i_wdt_restart;
|
||||
sunxi_wdt->restart_handler.notifier_call = sunxi_restart_handle;
|
||||
sunxi_wdt->restart_handler.priority = 128;
|
||||
err = register_restart_handler(&sunxi_wdt->restart_handler);
|
||||
if (err)
|
||||
dev_err(&pdev->dev,
|
||||
"cannot register restart handler (err=%d)\n", err);
|
||||
|
||||
dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)",
|
||||
sunxi_wdt->wdt_dev.timeout, nowayout);
|
||||
@ -218,7 +227,7 @@ static int sunxi_wdt_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct sunxi_wdt_dev *sunxi_wdt = platform_get_drvdata(pdev);
|
||||
|
||||
arm_pm_restart = NULL;
|
||||
unregister_restart_handler(&sunxi_wdt->restart_handler);
|
||||
|
||||
watchdog_unregister_device(&sunxi_wdt->wdt_dev);
|
||||
watchdog_set_drvdata(&sunxi_wdt->wdt_dev, NULL);
|
||||
|
@ -38,6 +38,9 @@ extern int reboot_force;
|
||||
extern int register_reboot_notifier(struct notifier_block *);
|
||||
extern int unregister_reboot_notifier(struct notifier_block *);
|
||||
|
||||
extern int register_restart_handler(struct notifier_block *);
|
||||
extern int unregister_restart_handler(struct notifier_block *);
|
||||
extern void do_kernel_restart(char *cmd);
|
||||
|
||||
/*
|
||||
* Architecture-specific implementations of sys_reboot commands.
|
||||
|
@ -104,6 +104,87 @@ int unregister_reboot_notifier(struct notifier_block *nb)
|
||||
}
|
||||
EXPORT_SYMBOL(unregister_reboot_notifier);
|
||||
|
||||
/*
|
||||
* Notifier list for kernel code which wants to be called
|
||||
* to restart the system.
|
||||
*/
|
||||
static ATOMIC_NOTIFIER_HEAD(restart_handler_list);
|
||||
|
||||
/**
|
||||
* register_restart_handler - Register function to be called to reset
|
||||
* the system
|
||||
* @nb: Info about handler function to be called
|
||||
* @nb->priority: Handler priority. Handlers should follow the
|
||||
* following guidelines for setting priorities.
|
||||
* 0: Restart handler of last resort,
|
||||
* with limited restart capabilities
|
||||
* 128: Default restart handler; use if no other
|
||||
* restart handler is expected to be available,
|
||||
* and/or if restart functionality is
|
||||
* sufficient to restart the entire system
|
||||
* 255: Highest priority restart handler, will
|
||||
* preempt all other restart handlers
|
||||
*
|
||||
* Registers a function with code to be called to restart the
|
||||
* system.
|
||||
*
|
||||
* Registered functions will be called from machine_restart as last
|
||||
* step of the restart sequence (if the architecture specific
|
||||
* machine_restart function calls do_kernel_restart - see below
|
||||
* for details).
|
||||
* Registered functions are expected to restart the system immediately.
|
||||
* If more than one function is registered, the restart handler priority
|
||||
* selects which function will be called first.
|
||||
*
|
||||
* Restart handlers are expected to be registered from non-architecture
|
||||
* code, typically from drivers. A typical use case would be a system
|
||||
* where restart functionality is provided through a watchdog. Multiple
|
||||
* restart handlers may exist; for example, one restart handler might
|
||||
* restart the entire system, while another only restarts the CPU.
|
||||
* In such cases, the restart handler which only restarts part of the
|
||||
* hardware is expected to register with low priority to ensure that
|
||||
* it only runs if no other means to restart the system is available.
|
||||
*
|
||||
* Currently always returns zero, as atomic_notifier_chain_register()
|
||||
* always returns zero.
|
||||
*/
|
||||
int register_restart_handler(struct notifier_block *nb)
|
||||
{
|
||||
return atomic_notifier_chain_register(&restart_handler_list, nb);
|
||||
}
|
||||
EXPORT_SYMBOL(register_restart_handler);
|
||||
|
||||
/**
|
||||
* unregister_restart_handler - Unregister previously registered
|
||||
* restart handler
|
||||
* @nb: Hook to be unregistered
|
||||
*
|
||||
* Unregisters a previously registered restart handler function.
|
||||
*
|
||||
* Returns zero on success, or %-ENOENT on failure.
|
||||
*/
|
||||
int unregister_restart_handler(struct notifier_block *nb)
|
||||
{
|
||||
return atomic_notifier_chain_unregister(&restart_handler_list, nb);
|
||||
}
|
||||
EXPORT_SYMBOL(unregister_restart_handler);
|
||||
|
||||
/**
|
||||
* do_kernel_restart - Execute kernel restart handler call chain
|
||||
*
|
||||
* Calls functions registered with register_restart_handler.
|
||||
*
|
||||
* Expected to be called from machine_restart as last step of the restart
|
||||
* sequence.
|
||||
*
|
||||
* Restarts the system immediately if a restart handler function has been
|
||||
* registered. Otherwise does nothing.
|
||||
*/
|
||||
void do_kernel_restart(char *cmd)
|
||||
{
|
||||
atomic_notifier_call_chain(&restart_handler_list, reboot_mode, cmd);
|
||||
}
|
||||
|
||||
void migrate_to_reboot_cpu(void)
|
||||
{
|
||||
/* The boot cpu is always logical cpu 0 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user