blob: b81bb386951dc2b414c0df526d720480afcf701a [file] [log] [blame]
Christian Daudt8ac49e02012-11-19 09:46:10 -08001/*
Markus Mayera21ea262014-02-25 14:17:44 -08002 * Copyright (C) 2012-2014 Broadcom Corporation
Christian Daudt8ac49e02012-11-19 09:46:10 -08003 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation version 2.
7 *
8 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 * kind, whether express or implied; without even the implied warranty
10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
Christian Daudt80116572013-03-13 14:27:27 -070014#include <linux/clocksource.h>
Markus Mayer389df032014-02-25 14:17:45 -080015#include <linux/of_address.h>
Christian Daudt8ac49e02012-11-19 09:46:10 -080016
17#include <asm/mach/arch.h>
Christian Daudt8ac49e02012-11-19 09:46:10 -080018
Alex Eldereeda4cb2014-04-21 16:53:11 -050019#include "kona_l2_cache.h"
Christian Daudtb8eb35f2013-02-26 21:48:49 -080020
Markus Mayera21ea262014-02-25 14:17:44 -080021#define SECWDOG_OFFSET 0x00000000
22#define SECWDOG_RESERVED_MASK 0xe2000000
23#define SECWDOG_WD_LOAD_FLAG_MASK 0x10000000
24#define SECWDOG_EN_MASK 0x08000000
25#define SECWDOG_SRSTEN_MASK 0x04000000
26#define SECWDOG_CLKS_SHIFT 20
27#define SECWDOG_COUNT_SHIFT 0
Markus Mayer257b49e2013-06-24 15:39:33 -070028
Markus Mayera21ea262014-02-25 14:17:44 -080029static void bcm281xx_restart(enum reboot_mode mode, const char *cmd)
30{
31 uint32_t val;
32 void __iomem *base;
33 struct device_node *np_wdog;
34
35 np_wdog = of_find_compatible_node(NULL, NULL, "brcm,kona-wdt");
36 if (!np_wdog) {
37 pr_emerg("Couldn't find brcm,kona-wdt\n");
38 return;
Markus Mayer257b49e2013-06-24 15:39:33 -070039 }
Markus Mayera21ea262014-02-25 14:17:44 -080040 base = of_iomap(np_wdog, 0);
41 if (!base) {
42 pr_emerg("Couldn't map brcm,kona-wdt\n");
43 return;
44 }
45
46 /* Enable watchdog with short timeout (244us). */
47 val = readl(base + SECWDOG_OFFSET);
48 val &= SECWDOG_RESERVED_MASK | SECWDOG_WD_LOAD_FLAG_MASK;
49 val |= SECWDOG_EN_MASK | SECWDOG_SRSTEN_MASK |
50 (0x15 << SECWDOG_CLKS_SHIFT) |
51 (0x8 << SECWDOG_COUNT_SHIFT);
52 writel(val, base + SECWDOG_OFFSET);
53
54 /* Wait for reset */
55 while (1);
Markus Mayer257b49e2013-06-24 15:39:33 -070056}
57
Markus Mayer0e8b8602014-02-25 14:17:46 -080058static void __init bcm281xx_init(void)
Christian Daudt8ac49e02012-11-19 09:46:10 -080059{
Christian Daudtb8eb35f2013-02-26 21:48:49 -080060 kona_l2_cache_init();
Christian Daudt8ac49e02012-11-19 09:46:10 -080061}
62
Alex Elder9c6423a2014-02-25 17:01:45 -060063static const char * const bcm281xx_dt_compat[] = {
64 "brcm,bcm11351", /* Have to use the first number upstreamed */
65 NULL,
66};
Christian Daudt8ac49e02012-11-19 09:46:10 -080067
Alex Elder9c6423a2014-02-25 17:01:45 -060068DT_MACHINE_START(BCM281XX_DT, "BCM281xx Broadcom Application Processor")
Markus Mayer0e8b8602014-02-25 14:17:46 -080069 .init_machine = bcm281xx_init,
Markus Mayera21ea262014-02-25 14:17:44 -080070 .restart = bcm281xx_restart,
Alex Elder9c6423a2014-02-25 17:01:45 -060071 .dt_compat = bcm281xx_dt_compat,
Christian Daudt8ac49e02012-11-19 09:46:10 -080072MACHINE_END