^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Copyright (C) 2012-2014 Broadcom Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * This program is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * modify it under the terms of the GNU General Public License as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * published by the Free Software Foundation version 2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * This program is distributed "as is" WITHOUT ANY WARRANTY of any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * kind, whether express or implied; without even the implied warranty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/clocksource.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/of_address.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/mach/arch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "kona_l2_cache.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define SECWDOG_OFFSET 0x00000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define SECWDOG_RESERVED_MASK 0xe2000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define SECWDOG_WD_LOAD_FLAG_MASK 0x10000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define SECWDOG_EN_MASK 0x08000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define SECWDOG_SRSTEN_MASK 0x04000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define SECWDOG_CLKS_SHIFT 20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define SECWDOG_COUNT_SHIFT 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static void bcm281xx_restart(enum reboot_mode mode, const char *cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) uint32_t val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) void __iomem *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct device_node *np_wdog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) np_wdog = of_find_compatible_node(NULL, NULL, "brcm,kona-wdt");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (!np_wdog) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) pr_emerg("Couldn't find brcm,kona-wdt\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) base = of_iomap(np_wdog, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) of_node_put(np_wdog);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) if (!base) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) pr_emerg("Couldn't map brcm,kona-wdt\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* Enable watchdog with short timeout (244us). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) val = readl(base + SECWDOG_OFFSET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) val &= SECWDOG_RESERVED_MASK | SECWDOG_WD_LOAD_FLAG_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) val |= SECWDOG_EN_MASK | SECWDOG_SRSTEN_MASK |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) (0x15 << SECWDOG_CLKS_SHIFT) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) (0x8 << SECWDOG_COUNT_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) writel(val, base + SECWDOG_OFFSET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /* Wait for reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) while (1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static void __init bcm281xx_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) kona_l2_cache_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static const char * const bcm281xx_dt_compat[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) "brcm,bcm11351", /* Have to use the first number upstreamed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) DT_MACHINE_START(BCM281XX_DT, "BCM281xx Broadcom Application Processor")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) .init_machine = bcm281xx_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) .restart = bcm281xx_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) .dt_compat = bcm281xx_dt_compat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) MACHINE_END