blob: 24a24445db64edd7d1388c35f3bd471e049489a9 [file] [log] [blame]
Maxime Bizone7300d02009-08-18 13:23:37 +01001/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
7 */
8
9#include <linux/init.h>
10#include <linux/kernel.h>
11#include <linux/delay.h>
12#include <linux/bootmem.h>
13#include <linux/ioport.h>
14#include <linux/pm.h>
15#include <asm/bootinfo.h>
16#include <asm/time.h>
17#include <asm/reboot.h>
18#include <asm/cacheflush.h>
19#include <bcm63xx_board.h>
20#include <bcm63xx_cpu.h>
21#include <bcm63xx_regs.h>
22#include <bcm63xx_io.h>
23
24void bcm63xx_machine_halt(void)
25{
26 printk(KERN_INFO "System halted\n");
27 while (1)
28 ;
29}
30
31static void bcm6348_a1_reboot(void)
32{
33 u32 reg;
34
35 /* soft reset all blocks */
Masanari Iida881b9992012-01-28 22:36:56 +090036 printk(KERN_INFO "soft-resetting all blocks ...\n");
Maxime Bizone7300d02009-08-18 13:23:37 +010037 reg = bcm_perf_readl(PERF_SOFTRESET_REG);
38 reg &= ~SOFTRESET_6348_ALL;
39 bcm_perf_writel(reg, PERF_SOFTRESET_REG);
40 mdelay(10);
41
42 reg = bcm_perf_readl(PERF_SOFTRESET_REG);
43 reg |= SOFTRESET_6348_ALL;
44 bcm_perf_writel(reg, PERF_SOFTRESET_REG);
45 mdelay(10);
46
47 /* Jump to the power on address. */
48 printk(KERN_INFO "jumping to reset vector.\n");
49 /* set high vectors (base at 0xbfc00000 */
50 set_c0_status(ST0_BEV | ST0_ERL);
51 /* run uncached in kseg0 */
52 change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
53 __flush_cache_all();
54 /* remove all wired TLB entries */
55 write_c0_wired(0);
56 __asm__ __volatile__(
57 "jr\t%0"
58 :
59 : "r" (0xbfc00000));
60 while (1)
61 ;
62}
63
64void bcm63xx_machine_reboot(void)
65{
Maxime Bizon62248922011-11-04 19:09:34 +010066 u32 reg, perf_regs[2] = { 0, 0 };
67 unsigned int i;
Maxime Bizone7300d02009-08-18 13:23:37 +010068
69 /* mask and clear all external irq */
Maxime Bizon62248922011-11-04 19:09:34 +010070 switch (bcm63xx_get_cpu_id()) {
Jonas Gorskie5766ae2012-07-24 16:33:12 +020071 case BCM6328_CPU_ID:
72 perf_regs[0] = PERF_EXTIRQ_CFG_REG_6328;
73 break;
Maxime Bizon62248922011-11-04 19:09:34 +010074 case BCM6338_CPU_ID:
75 perf_regs[0] = PERF_EXTIRQ_CFG_REG_6338;
76 break;
Maxime Bizon64eaea42012-07-13 07:46:03 +000077 case BCM6345_CPU_ID:
78 perf_regs[0] = PERF_EXTIRQ_CFG_REG_6345;
79 break;
Maxime Bizon62248922011-11-04 19:09:34 +010080 case BCM6348_CPU_ID:
81 perf_regs[0] = PERF_EXTIRQ_CFG_REG_6348;
82 break;
83 case BCM6358_CPU_ID:
84 perf_regs[0] = PERF_EXTIRQ_CFG_REG_6358;
85 break;
Jonas Gorski2c8aaf72013-03-21 14:03:17 +000086 case BCM6362_CPU_ID:
87 perf_regs[0] = PERF_EXTIRQ_CFG_REG_6362;
88 break;
Maxime Bizon62248922011-11-04 19:09:34 +010089 }
90
91 for (i = 0; i < 2; i++) {
Maxime Bizon6d5918052012-07-13 07:46:04 +000092 if (!perf_regs[i])
93 break;
94
Maxime Bizon62248922011-11-04 19:09:34 +010095 reg = bcm_perf_readl(perf_regs[i]);
96 if (BCMCPU_IS_6348()) {
97 reg &= ~EXTIRQ_CFG_MASK_ALL_6348;
98 reg |= EXTIRQ_CFG_CLEAR_ALL_6348;
99 } else {
100 reg &= ~EXTIRQ_CFG_MASK_ALL;
101 reg |= EXTIRQ_CFG_CLEAR_ALL;
102 }
103 bcm_perf_writel(reg, perf_regs[i]);
104 }
Maxime Bizone7300d02009-08-18 13:23:37 +0100105
106 if (BCMCPU_IS_6348() && (bcm63xx_get_cpu_rev() == 0xa1))
107 bcm6348_a1_reboot();
108
109 printk(KERN_INFO "triggering watchdog soft-reset...\n");
Jonas Gorskie5766ae2012-07-24 16:33:12 +0200110 if (BCMCPU_IS_6328()) {
111 bcm_wdt_writel(1, WDT_SOFTRESET_REG);
112 } else {
113 reg = bcm_perf_readl(PERF_SYS_PLL_CTL_REG);
114 reg |= SYS_PLL_SOFT_RESET;
115 bcm_perf_writel(reg, PERF_SYS_PLL_CTL_REG);
116 }
Maxime Bizone7300d02009-08-18 13:23:37 +0100117 while (1)
118 ;
119}
120
121static void __bcm63xx_machine_reboot(char *p)
122{
123 bcm63xx_machine_reboot();
124}
125
126/*
127 * return system type in /proc/cpuinfo
128 */
129const char *get_system_type(void)
130{
131 static char buf[128];
Jonas Gorski66054282013-03-21 14:03:15 +0000132 snprintf(buf, sizeof(buf), "bcm63xx/%s (0x%04x/0x%02X)",
Maxime Bizone7300d02009-08-18 13:23:37 +0100133 board_get_name(),
134 bcm63xx_get_cpu_id(), bcm63xx_get_cpu_rev());
135 return buf;
136}
137
138void __init plat_time_init(void)
139{
140 mips_hpt_frequency = bcm63xx_get_cpu_freq() / 2;
141}
142
143void __init plat_mem_setup(void)
144{
145 add_memory_region(0, bcm63xx_get_memory_size(), BOOT_MEM_RAM);
146
147 _machine_halt = bcm63xx_machine_halt;
148 _machine_restart = __bcm63xx_machine_reboot;
149 pm_power_off = bcm63xx_machine_halt;
150
151 set_io_port_base(0);
152 ioport_resource.start = 0;
153 ioport_resource.end = ~0;
154
155 board_setup();
156}
157
158int __init bcm63xx_register_devices(void)
159{
160 return board_register_devices();
161}
162
Jonas Gorski1762c5a2013-03-19 13:20:19 +0000163arch_initcall(bcm63xx_register_devices);