Christian Daudt | 8ac49e0 | 2012-11-19 09:46:10 -0800 | [diff] [blame] | 1 | /* |
Markus Mayer | a21ea26 | 2014-02-25 14:17:44 -0800 | [diff] [blame] | 2 | * Copyright (C) 2012-2014 Broadcom Corporation |
Christian Daudt | 8ac49e0 | 2012-11-19 09:46:10 -0800 | [diff] [blame] | 3 | * |
| 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 Daudt | 8011657 | 2013-03-13 14:27:27 -0700 | [diff] [blame] | 14 | #include <linux/clocksource.h> |
Markus Mayer | 389df03 | 2014-02-25 14:17:45 -0800 | [diff] [blame] | 15 | #include <linux/of_address.h> |
Christian Daudt | 8ac49e0 | 2012-11-19 09:46:10 -0800 | [diff] [blame] | 16 | |
| 17 | #include <asm/mach/arch.h> |
Christian Daudt | 8ac49e0 | 2012-11-19 09:46:10 -0800 | [diff] [blame] | 18 | |
Alex Elder | eeda4cb | 2014-04-21 16:53:11 -0500 | [diff] [blame] | 19 | #include "kona_l2_cache.h" |
Christian Daudt | b8eb35f | 2013-02-26 21:48:49 -0800 | [diff] [blame] | 20 | |
Markus Mayer | a21ea26 | 2014-02-25 14:17:44 -0800 | [diff] [blame] | 21 | #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 Mayer | 257b49e | 2013-06-24 15:39:33 -0700 | [diff] [blame] | 28 | |
Markus Mayer | a21ea26 | 2014-02-25 14:17:44 -0800 | [diff] [blame] | 29 | static 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 Mayer | 257b49e | 2013-06-24 15:39:33 -0700 | [diff] [blame] | 39 | } |
Markus Mayer | a21ea26 | 2014-02-25 14:17:44 -0800 | [diff] [blame] | 40 | base = of_iomap(np_wdog, 0); |
Wen Yang | 8abc5a7 | 2019-03-05 19:33:53 +0800 | [diff] [blame] | 41 | of_node_put(np_wdog); |
Markus Mayer | a21ea26 | 2014-02-25 14:17:44 -0800 | [diff] [blame] | 42 | if (!base) { |
| 43 | pr_emerg("Couldn't map brcm,kona-wdt\n"); |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | /* Enable watchdog with short timeout (244us). */ |
| 48 | val = readl(base + SECWDOG_OFFSET); |
| 49 | val &= SECWDOG_RESERVED_MASK | SECWDOG_WD_LOAD_FLAG_MASK; |
| 50 | val |= SECWDOG_EN_MASK | SECWDOG_SRSTEN_MASK | |
| 51 | (0x15 << SECWDOG_CLKS_SHIFT) | |
| 52 | (0x8 << SECWDOG_COUNT_SHIFT); |
| 53 | writel(val, base + SECWDOG_OFFSET); |
| 54 | |
| 55 | /* Wait for reset */ |
| 56 | while (1); |
Markus Mayer | 257b49e | 2013-06-24 15:39:33 -0700 | [diff] [blame] | 57 | } |
| 58 | |
Markus Mayer | 0e8b860 | 2014-02-25 14:17:46 -0800 | [diff] [blame] | 59 | static void __init bcm281xx_init(void) |
Christian Daudt | 8ac49e0 | 2012-11-19 09:46:10 -0800 | [diff] [blame] | 60 | { |
Christian Daudt | b8eb35f | 2013-02-26 21:48:49 -0800 | [diff] [blame] | 61 | kona_l2_cache_init(); |
Christian Daudt | 8ac49e0 | 2012-11-19 09:46:10 -0800 | [diff] [blame] | 62 | } |
| 63 | |
Alex Elder | 9c6423a | 2014-02-25 17:01:45 -0600 | [diff] [blame] | 64 | static const char * const bcm281xx_dt_compat[] = { |
| 65 | "brcm,bcm11351", /* Have to use the first number upstreamed */ |
| 66 | NULL, |
| 67 | }; |
Christian Daudt | 8ac49e0 | 2012-11-19 09:46:10 -0800 | [diff] [blame] | 68 | |
Alex Elder | 9c6423a | 2014-02-25 17:01:45 -0600 | [diff] [blame] | 69 | DT_MACHINE_START(BCM281XX_DT, "BCM281xx Broadcom Application Processor") |
Markus Mayer | 0e8b860 | 2014-02-25 14:17:46 -0800 | [diff] [blame] | 70 | .init_machine = bcm281xx_init, |
Markus Mayer | a21ea26 | 2014-02-25 14:17:44 -0800 | [diff] [blame] | 71 | .restart = bcm281xx_restart, |
Alex Elder | 9c6423a | 2014-02-25 17:01:45 -0600 | [diff] [blame] | 72 | .dt_compat = bcm281xx_dt_compat, |
Christian Daudt | 8ac49e0 | 2012-11-19 09:46:10 -0800 | [diff] [blame] | 73 | MACHINE_END |