xref: /openbmc/linux/arch/mips/bcm47xx/setup.c (revision 1c0c13eb935c95fd2ca0b0aca6dd4860487fb242)
1*1c0c13ebSAurelien Jarno /*
2*1c0c13ebSAurelien Jarno  *  Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
3*1c0c13ebSAurelien Jarno  *  Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
4*1c0c13ebSAurelien Jarno  *  Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
5*1c0c13ebSAurelien Jarno  *  Copyright (C) 2006 Michael Buesch <mb@bu3sch.de>
6*1c0c13ebSAurelien Jarno  *
7*1c0c13ebSAurelien Jarno  *  This program is free software; you can redistribute  it and/or modify it
8*1c0c13ebSAurelien Jarno  *  under  the terms of  the GNU General  Public License as published by the
9*1c0c13ebSAurelien Jarno  *  Free Software Foundation;  either version 2 of the  License, or (at your
10*1c0c13ebSAurelien Jarno  *  option) any later version.
11*1c0c13ebSAurelien Jarno  *
12*1c0c13ebSAurelien Jarno  *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
13*1c0c13ebSAurelien Jarno  *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
14*1c0c13ebSAurelien Jarno  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
15*1c0c13ebSAurelien Jarno  *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
16*1c0c13ebSAurelien Jarno  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17*1c0c13ebSAurelien Jarno  *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
18*1c0c13ebSAurelien Jarno  *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19*1c0c13ebSAurelien Jarno  *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
20*1c0c13ebSAurelien Jarno  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21*1c0c13ebSAurelien Jarno  *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22*1c0c13ebSAurelien Jarno  *
23*1c0c13ebSAurelien Jarno  *  You should have received a copy of the  GNU General Public License along
24*1c0c13ebSAurelien Jarno  *  with this program; if not, write  to the Free Software Foundation, Inc.,
25*1c0c13ebSAurelien Jarno  *  675 Mass Ave, Cambridge, MA 02139, USA.
26*1c0c13ebSAurelien Jarno  */
27*1c0c13ebSAurelien Jarno 
28*1c0c13ebSAurelien Jarno #include <linux/types.h>
29*1c0c13ebSAurelien Jarno #include <linux/ssb/ssb.h>
30*1c0c13ebSAurelien Jarno #include <asm/reboot.h>
31*1c0c13ebSAurelien Jarno #include <asm/time.h>
32*1c0c13ebSAurelien Jarno #include <bcm47xx.h>
33*1c0c13ebSAurelien Jarno 
34*1c0c13ebSAurelien Jarno struct ssb_bus ssb_bcm47xx;
35*1c0c13ebSAurelien Jarno EXPORT_SYMBOL(ssb_bcm47xx);
36*1c0c13ebSAurelien Jarno 
37*1c0c13ebSAurelien Jarno static void bcm47xx_machine_restart(char *command)
38*1c0c13ebSAurelien Jarno {
39*1c0c13ebSAurelien Jarno 	printk(KERN_ALERT "Please stand by while rebooting the system...\n");
40*1c0c13ebSAurelien Jarno 	local_irq_disable();
41*1c0c13ebSAurelien Jarno 	/* Set the watchdog timer to reset immediately */
42*1c0c13ebSAurelien Jarno 	ssb_chipco_watchdog_timer_set(&ssb_bcm47xx.chipco, 1);
43*1c0c13ebSAurelien Jarno 	while (1)
44*1c0c13ebSAurelien Jarno 		cpu_relax();
45*1c0c13ebSAurelien Jarno }
46*1c0c13ebSAurelien Jarno 
47*1c0c13ebSAurelien Jarno static void bcm47xx_machine_halt(void)
48*1c0c13ebSAurelien Jarno {
49*1c0c13ebSAurelien Jarno 	/* Disable interrupts and watchdog and spin forever */
50*1c0c13ebSAurelien Jarno 	local_irq_disable();
51*1c0c13ebSAurelien Jarno 	ssb_chipco_watchdog_timer_set(&ssb_bcm47xx.chipco, 0);
52*1c0c13ebSAurelien Jarno 	while (1)
53*1c0c13ebSAurelien Jarno 		cpu_relax();
54*1c0c13ebSAurelien Jarno }
55*1c0c13ebSAurelien Jarno 
56*1c0c13ebSAurelien Jarno static int bcm47xx_get_invariants(struct ssb_bus *bus,
57*1c0c13ebSAurelien Jarno 				   struct ssb_init_invariants *iv)
58*1c0c13ebSAurelien Jarno {
59*1c0c13ebSAurelien Jarno 	/* TODO: fill ssb_init_invariants using boardtype/boardrev
60*1c0c13ebSAurelien Jarno 	 * CFE environment variables.
61*1c0c13ebSAurelien Jarno 	 */
62*1c0c13ebSAurelien Jarno 	return 0;
63*1c0c13ebSAurelien Jarno }
64*1c0c13ebSAurelien Jarno 
65*1c0c13ebSAurelien Jarno void __init plat_mem_setup(void)
66*1c0c13ebSAurelien Jarno {
67*1c0c13ebSAurelien Jarno 	int err;
68*1c0c13ebSAurelien Jarno 
69*1c0c13ebSAurelien Jarno 	err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE,
70*1c0c13ebSAurelien Jarno 				      bcm47xx_get_invariants);
71*1c0c13ebSAurelien Jarno 	if (err)
72*1c0c13ebSAurelien Jarno 		panic("Failed to initialize SSB bus (err %d)\n", err);
73*1c0c13ebSAurelien Jarno 
74*1c0c13ebSAurelien Jarno 	_machine_restart = bcm47xx_machine_restart;
75*1c0c13ebSAurelien Jarno 	_machine_halt = bcm47xx_machine_halt;
76*1c0c13ebSAurelien Jarno 	pm_power_off = bcm47xx_machine_halt;
77*1c0c13ebSAurelien Jarno 	board_time_init = bcm47xx_time_init;
78*1c0c13ebSAurelien Jarno }
79*1c0c13ebSAurelien Jarno 
80