aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2014-03-11 16:27:04 -0400
committerOlof Johansson <olof@lixom.net>2014-03-11 16:27:21 -0400
commit50776b6cf85d4b2bf3c4f209c4e01f354d0daa2c (patch)
treef01c38f7223b3365d4bc3e4e5594b0ed28132365
parent555e2a5cf234f5cbce74200281c8754934126824 (diff)
parent0e8b860ac6d65209beea03ee9b718089838476ef (diff)
Merge tag 'armsoc/for-3.15/cleanup' of git://github.com/broadcom/mach-bcm into next/cleanup
Merge "ARM: mach-bcm: cleanups for 3.15" from Matt Porter: - make bcm281xx symbol naming consistent with SoC name - remove unneeded and reorder bcm281xx header files - consolidate bcm281xx reboot and l2 cache code * tag 'armsoc/for-3.15/cleanup' of git://github.com/broadcom/mach-bcm: ARM: bcm281xx: Rename board_init() function ARM: bcm281xx: Re-order hearder files ARM: bcm281xx: Consolidate reboot code ARM: bcm281xx: Move kona_l2_cache_init() so it can be shared ARM: bcm281xx: symbol cleanup Signed-off-by: Olof Johansson <olof@lixom.net>
-rw-r--r--arch/arm/mach-bcm/board_bcm281xx.c83
-rw-r--r--arch/arm/mach-bcm/kona.c64
-rw-r--r--arch/arm/mach-bcm/kona.h7
3 files changed, 65 insertions, 89 deletions
diff --git a/arch/arm/mach-bcm/board_bcm281xx.c b/arch/arm/mach-bcm/board_bcm281xx.c
index cb3dc364405c..6be54c10f8cb 100644
--- a/arch/arm/mach-bcm/board_bcm281xx.c
+++ b/arch/arm/mach-bcm/board_bcm281xx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2012-2013 Broadcom Corporation 2 * Copyright (C) 2012-2014 Broadcom Corporation
3 * 3 *
4 * This program is free software; you can redistribute it and/or 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 5 * modify it under the terms of the GNU General Public License as
@@ -11,64 +11,65 @@
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 */ 12 */
13 13
14#include <linux/of_platform.h>
15#include <linux/init.h>
16#include <linux/device.h>
17#include <linux/platform_device.h>
18#include <linux/clocksource.h> 14#include <linux/clocksource.h>
15#include <linux/of_address.h>
16#include <linux/of_platform.h>
19 17
20#include <asm/mach/arch.h> 18#include <asm/mach/arch.h>
21#include <asm/mach/time.h>
22#include <asm/hardware/cache-l2x0.h>
23 19
24#include "bcm_kona_smc.h"
25#include "kona.h" 20#include "kona.h"
26 21
27static int __init kona_l2_cache_init(void) 22#define SECWDOG_OFFSET 0x00000000
23#define SECWDOG_RESERVED_MASK 0xe2000000
24#define SECWDOG_WD_LOAD_FLAG_MASK 0x10000000
25#define SECWDOG_EN_MASK 0x08000000
26#define SECWDOG_SRSTEN_MASK 0x04000000
27#define SECWDOG_CLKS_SHIFT 20
28#define SECWDOG_COUNT_SHIFT 0
29
30static void bcm281xx_restart(enum reboot_mode mode, const char *cmd)
28{ 31{
29 if (!IS_ENABLED(CONFIG_CACHE_L2X0)) 32 uint32_t val;
30 return 0; 33 void __iomem *base;
34 struct device_node *np_wdog;
31 35
32 if (bcm_kona_smc_init() < 0) { 36 np_wdog = of_find_compatible_node(NULL, NULL, "brcm,kona-wdt");
33 pr_info("Kona secure API not available. Skipping L2 init\n"); 37 if (!np_wdog) {
34 return 0; 38 pr_emerg("Couldn't find brcm,kona-wdt\n");
39 return;
40 }
41 base = of_iomap(np_wdog, 0);
42 if (!base) {
43 pr_emerg("Couldn't map brcm,kona-wdt\n");
44 return;
35 } 45 }
36 46
37 bcm_kona_smc(SSAPI_ENABLE_L2_CACHE, 0, 0, 0, 0); 47 /* Enable watchdog with short timeout (244us). */
38 48 val = readl(base + SECWDOG_OFFSET);
39 /* 49 val &= SECWDOG_RESERVED_MASK | SECWDOG_WD_LOAD_FLAG_MASK;
40 * The aux_val and aux_mask have no effect since L2 cache is already 50 val |= SECWDOG_EN_MASK | SECWDOG_SRSTEN_MASK |
41 * enabled. Pass 0s for aux_val and 1s for aux_mask for default value. 51 (0x15 << SECWDOG_CLKS_SHIFT) |
42 */ 52 (0x8 << SECWDOG_COUNT_SHIFT);
43 return l2x0_of_init(0, ~0); 53 writel(val, base + SECWDOG_OFFSET);
44}
45
46static void bcm_board_setup_restart(void)
47{
48 struct device_node *np;
49 54
50 np = of_find_compatible_node(NULL, NULL, "brcm,bcm11351"); 55 /* Wait for reset */
51 if (np) { 56 while (1);
52 if (of_device_is_available(np))
53 bcm_kona_setup_restart();
54 of_node_put(np);
55 }
56 /* Restart setup for other boards goes here */
57} 57}
58 58
59static void __init board_init(void) 59static void __init bcm281xx_init(void)
60{ 60{
61 of_platform_populate(NULL, of_default_bus_match_table, NULL, 61 of_platform_populate(NULL, of_default_bus_match_table, NULL,
62 &platform_bus); 62 &platform_bus);
63
64 bcm_board_setup_restart();
65 kona_l2_cache_init(); 63 kona_l2_cache_init();
66} 64}
67 65
68static const char * const bcm11351_dt_compat[] = { "brcm,bcm11351", NULL, }; 66static const char * const bcm281xx_dt_compat[] = {
67 "brcm,bcm11351", /* Have to use the first number upstreamed */
68 NULL,
69};
69 70
70DT_MACHINE_START(BCM11351_DT, "BCM281xx Broadcom Application Processor") 71DT_MACHINE_START(BCM281XX_DT, "BCM281xx Broadcom Application Processor")
71 .init_machine = board_init, 72 .init_machine = bcm281xx_init,
72 .restart = bcm_kona_restart, 73 .restart = bcm281xx_restart,
73 .dt_compat = bcm11351_dt_compat, 74 .dt_compat = bcm281xx_dt_compat,
74MACHINE_END 75MACHINE_END
diff --git a/arch/arm/mach-bcm/kona.c b/arch/arm/mach-bcm/kona.c
index 6939d9017f63..768bc2837bf5 100644
--- a/arch/arm/mach-bcm/kona.c
+++ b/arch/arm/mach-bcm/kona.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2013 Broadcom Corporation 2 * Copyright (C) 2012-2014 Broadcom Corporation
3 * 3 *
4 * This program is free software; you can redistribute it and/or 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 5 * modify it under the terms of the GNU General Public License as
@@ -11,55 +11,33 @@
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 */ 12 */
13 13
14#include <linux/of_address.h> 14#include <linux/of_platform.h>
15#include <asm/io.h> 15#include <asm/hardware/cache-l2x0.h>
16 16
17#include "bcm_kona_smc.h"
17#include "kona.h" 18#include "kona.h"
18 19
19static void __iomem *watchdog_base; 20void __init kona_l2_cache_init(void)
20
21void bcm_kona_setup_restart(void)
22{ 21{
23 struct device_node *np_wdog; 22 int ret;
24 23
25 /* 24 if (!IS_ENABLED(CONFIG_CACHE_L2X0))
26 * The assumption is that whoever calls bcm_kona_setup_restart()
27 * also needs a Kona Watchdog Timer entry in Device Tree, i.e. we
28 * report an error if the DT entry is missing.
29 */
30 np_wdog = of_find_compatible_node(NULL, NULL, "brcm,kona-wdt");
31 if (!np_wdog) {
32 pr_err("brcm,kona-wdt not found in DT, reboot disabled\n");
33 return; 25 return;
34 }
35 watchdog_base = of_iomap(np_wdog, 0);
36 WARN(!watchdog_base, "failed to map watchdog base");
37 of_node_put(np_wdog);
38}
39
40#define SECWDOG_OFFSET 0x00000000
41#define SECWDOG_RESERVED_MASK 0xE2000000
42#define SECWDOG_WD_LOAD_FLAG_MASK 0x10000000
43#define SECWDOG_EN_MASK 0x08000000
44#define SECWDOG_SRSTEN_MASK 0x04000000
45#define SECWDOG_CLKS_SHIFT 20
46#define SECWDOG_LOCK_SHIFT 0
47 26
48void bcm_kona_restart(enum reboot_mode mode, const char *cmd) 27 ret = bcm_kona_smc_init();
49{ 28 if (ret) {
50 uint32_t val; 29 pr_info("Secure API not available (%d). Skipping L2 init.\n",
51 30 ret);
52 if (!watchdog_base) 31 return;
53 panic("Watchdog not mapped. Reboot failed.\n"); 32 }
54 33
55 /* Enable watchdog2 with very short timeout. */ 34 bcm_kona_smc(SSAPI_ENABLE_L2_CACHE, 0, 0, 0, 0);
56 val = readl(watchdog_base + SECWDOG_OFFSET);
57 val &= SECWDOG_RESERVED_MASK | SECWDOG_WD_LOAD_FLAG_MASK;
58 val |= SECWDOG_EN_MASK | SECWDOG_SRSTEN_MASK |
59 (0x8 << SECWDOG_CLKS_SHIFT) |
60 (0x8 << SECWDOG_LOCK_SHIFT);
61 writel(val, watchdog_base + SECWDOG_OFFSET);
62 35
63 while (1) 36 /*
64 ; 37 * The aux_val and aux_mask have no effect since L2 cache is already
38 * enabled. Pass 0s for aux_val and 1s for aux_mask for default value.
39 */
40 ret = l2x0_of_init(0, ~0);
41 if (ret)
42 pr_err("Couldn't enable L2 cache: %d\n", ret);
65} 43}
diff --git a/arch/arm/mach-bcm/kona.h b/arch/arm/mach-bcm/kona.h
index 291eca3e06ff..3a7a017c29cd 100644
--- a/arch/arm/mach-bcm/kona.h
+++ b/arch/arm/mach-bcm/kona.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2013 Broadcom Corporation 2 * Copyright (C) 2012-2014 Broadcom Corporation
3 * 3 *
4 * This program is free software; you can redistribute it and/or 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 5 * modify it under the terms of the GNU General Public License as
@@ -11,7 +11,4 @@
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 */ 12 */
13 13
14#include <linux/reboot.h> 14void __init kona_l2_cache_init(void);
15
16void bcm_kona_setup_restart(void);
17void bcm_kona_restart(enum reboot_mode mode, const char *cmd);