1/*
2 * BK Id: %F% %I% %G% %U% %#%
3 */
4/*
5 *  arch/ppc/kernel/gemini_prom.S
6 *
7 *  Not really prom support code (yet), but sort of anti-prom code.  The current
8 *  bootloader does a number of things it shouldn't and doesn't do things that it
9 *  should.  The stuff in here is mainly a hodge-podge collection of setup code
10 *  to get the board up and running.
11 *    ---Dan
12 */
13
14#include <linux/config.h>
15#include <asm/processor.h>
16#include <asm/page.h>
17#include <platforms/gemini.h>
18#include <asm/ppc_asm.h>
19
20#define HID0_ABE (1<<3)
21
22/*
23 *  On 750's the MMU is on when Linux is booted, so we need to clear out the
24 *  bootloader's BAT settings, make sure we're in supervisor state (gotcha!),
25 *  and turn off the MMU.
26 *
27 */
28
29_GLOBAL(gemini_prom_init)
30#ifdef CONFIG_SMP
31	/* Since the MMU's on, get stuff in rom space that we'll need */
32	lis	r4,GEMINI_CPUSTAT@h
33	ori	r4,r4,GEMINI_CPUSTAT@l
34	lbz	r5,0(r4)
35	andi.	r5,r5,3
36	mr	r24,r5		/* cpu # used later on */
37#endif
38	mfmsr	r4
39	li	r3,MSR_PR	/* ensure supervisor! */
40	ori	r3,r3,MSR_IR|MSR_DR
41	andc	r4,r4,r3
42	mtmsr	r4
43	isync
44
45	/* the bootloader (as far as I'm currently aware) doesn't mess with page
46	   tables, but since we're already here, might as well zap these, too */
47	li	r4,0
48	mtspr	SDR1,r4
49
50	li	r4,16
51	mtctr	r4
52	li	r3,0
53	li	r4,0
543:	mtsrin	r3,r4
55	addi	r3,r3,1
56	bdnz	3b
57
58#ifdef CONFIG_SMP
59	/* The 750 book (and Mot/IBM support) says that this will "assist" snooping
60	   when in SMP.  Not sure yet whether this should stay or leave... */
61	mfspr	r4,HID0
62	ori	r4,r4,HID0_ABE
63	mtspr	HID0,r4
64	sync
65#endif /* CONFIG_SMP */
66	blr
67
68/*  apparently, SMon doesn't pay attention to HID0[SRST].  Disable the MMU and
69    branch to 0xfff00100 */
70_GLOBAL(_gemini_reboot)
71	lis	r5,GEMINI_BOOT_INIT@h
72	ori	r5,r5,GEMINI_BOOT_INIT@l
73	li	r6,MSR_IP
74	mtspr	SRR0,r5
75	mtspr	SRR1,r6
76	rfi
77