ARM: EXYNOS: Enable multi-platform build support
[cascardo/linux.git] / arch / arm / mach-bcm / board_bcm21664.c
1 /*
2  * Copyright (C) 2014 Broadcom Corporation
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
14 #include <linux/clocksource.h>
15 #include <linux/of_address.h>
16 #include <linux/of_platform.h>
17
18 #include <asm/mach/arch.h>
19
20 #include "bcm_kona_smc.h"
21 #include "kona.h"
22
23 #define RSTMGR_DT_STRING                "brcm,bcm21664-resetmgr"
24
25 #define RSTMGR_REG_WR_ACCESS_OFFSET     0
26 #define RSTMGR_REG_CHIP_SOFT_RST_OFFSET 4
27
28 #define RSTMGR_WR_PASSWORD              0xa5a5
29 #define RSTMGR_WR_PASSWORD_SHIFT        8
30 #define RSTMGR_WR_ACCESS_ENABLE         1
31
32 static void bcm21664_restart(enum reboot_mode mode, const char *cmd)
33 {
34         void __iomem *base;
35         struct device_node *resetmgr;
36
37         resetmgr = of_find_compatible_node(NULL, NULL, RSTMGR_DT_STRING);
38         if (!resetmgr) {
39                 pr_emerg("Couldn't find " RSTMGR_DT_STRING "\n");
40                 return;
41         }
42         base = of_iomap(resetmgr, 0);
43         if (!base) {
44                 pr_emerg("Couldn't map " RSTMGR_DT_STRING "\n");
45                 return;
46         }
47
48         /*
49          * A soft reset is triggered by writing a 0 to bit 0 of the soft reset
50          * register. To write to that register we must first write the password
51          * and the enable bit in the write access enable register.
52          */
53         writel((RSTMGR_WR_PASSWORD << RSTMGR_WR_PASSWORD_SHIFT) |
54                 RSTMGR_WR_ACCESS_ENABLE,
55                 base + RSTMGR_REG_WR_ACCESS_OFFSET);
56         writel(0, base + RSTMGR_REG_CHIP_SOFT_RST_OFFSET);
57
58         /* Wait for reset */
59         while (1);
60 }
61
62 static void __init bcm21664_init(void)
63 {
64         of_platform_populate(NULL, of_default_bus_match_table, NULL,
65                 &platform_bus);
66         kona_l2_cache_init();
67 }
68
69 static const char * const bcm21664_dt_compat[] = {
70         "brcm,bcm21664",
71         NULL,
72 };
73
74 DT_MACHINE_START(BCM21664_DT, "BCM21664 Broadcom Application Processor")
75         .init_machine = bcm21664_init,
76         .restart = bcm21664_restart,
77         .dt_compat = bcm21664_dt_compat,
78 MACHINE_END