system.c 2.3 KB
Newer Older
1 2 3 4 5
/*
 * Copyright (C) 1999 ARM Limited
 * Copyright (C) 2000 Deep Blue Solutions Ltd
 * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
I
Ilya Yanok 已提交
6
 * Copyright 2009 Ilya Yanok, Emcraft Systems Ltd, yanok@emcraft.com
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 * 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/kernel.h>
#include <linux/clk.h>
#include <linux/io.h>
I
Ilya Yanok 已提交
22 23
#include <linux/err.h>
#include <linux/delay.h>
24 25
#include <linux/of.h>
#include <linux/of_address.h>
26

27
#include <asm/system_misc.h>
28
#include <asm/proc-fns.h>
A
Arnaud Patard (Rtp) 已提交
29
#include <asm/mach-types.h>
30

31
#include "common.h"
32
#include "hardware.h"
33

S
Sascha Hauer 已提交
34
static void __iomem *wdog_base;
35
static struct clk *wdog_clk;
36 37 38 39

/*
 * Reset the system. It is called by machine_restart().
 */
40
void mxc_restart(char mode, const char *cmd)
41
{
S
Sascha Hauer 已提交
42 43
	unsigned int wcr_enable;

44 45
	if (wdog_clk)
		clk_enable(wdog_clk);
46

47 48 49
	if (cpu_is_mx1())
		wcr_enable = (1 << 0);
	else
S
Sascha Hauer 已提交
50
		wcr_enable = (1 << 2);
51 52

	/* Assert SRS signal */
S
Sascha Hauer 已提交
53
	__raw_writew(wcr_enable, wdog_base);
I
Ilya Yanok 已提交
54 55 56 57

	/* wait for reset to assert... */
	mdelay(500);

58
	pr_err("%s: Watchdog reset failed to assert reset\n", __func__);
I
Ilya Yanok 已提交
59 60 61 62 63

	/* delay to allow the serial port to show the message */
	mdelay(50);

	/* we'll take a jump through zero as a poor second */
64
	soft_restart(0);
65
}
S
Sascha Hauer 已提交
66

67
void __init mxc_arch_reset_init(void __iomem *base)
S
Sascha Hauer 已提交
68 69
{
	wdog_base = base;
70 71 72 73 74 75 76 77 78

	wdog_clk = clk_get_sys("imx2-wdt.0", NULL);
	if (IS_ERR(wdog_clk)) {
		pr_warn("%s: failed to get wdog clock\n", __func__);
		wdog_clk = NULL;
		return;
	}

	clk_prepare(wdog_clk);
S
Sascha Hauer 已提交
79
}
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97

void __init mxc_arch_reset_init_dt(void)
{
	struct device_node *np;

	np = of_find_compatible_node(NULL, NULL, "fsl,imx21-wdt");
	wdog_base = of_iomap(np, 0);
	WARN_ON(!wdog_base);

	wdog_clk = of_clk_get(np, 0);
	if (IS_ERR(wdog_clk)) {
		pr_warn("%s: failed to get wdog clock\n", __func__);
		wdog_clk = NULL;
		return;
	}

	clk_prepare(wdog_clk);
}