2 * arch/powerpc/boot/wii.c
4 * Nintendo Wii bootwrapper support
5 * Copyright (C) 2008-2009 The GameCube Linux Team
6 * Copyright (C) 2008,2009 Albert Herranz
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
25 #define HW_REG(x) ((void *)(x))
27 #define EXI_CTRL HW_REG(0x0d800070)
28 #define EXI_CTRL_ENABLE (1<<0)
30 #define MEM2_TOP (0x10000000 + 64*1024*1024)
31 #define FIRMWARE_DEFAULT_SIZE (12*1024*1024)
44 static int mipc_check_address(u32 pa
)
46 /* only MEM2 addresses */
47 if (pa
< 0x10000000 || pa
> 0x14000000)
52 static struct mipc_infohdr
*mipc_get_infohdr(void)
54 struct mipc_infohdr
**hdrp
, *hdr
;
56 /* 'mini' header pointer is the last word of MEM2 memory */
57 hdrp
= (struct mipc_infohdr
**)0x13fffffc;
58 if (mipc_check_address((u32
)hdrp
)) {
59 printf("mini: invalid hdrp %08X\n", (u32
)hdrp
);
65 if (mipc_check_address((u32
)hdr
)) {
66 printf("mini: invalid hdr %08X\n", (u32
)hdr
);
70 if (memcmp(hdr
->magic
, "IPC", 3)) {
71 printf("mini: invalid magic\n");
80 static int mipc_get_mem2_boundary(u32
*mem2_boundary
)
82 struct mipc_infohdr
*hdr
;
85 hdr
= mipc_get_infohdr();
91 if (mipc_check_address(hdr
->mem2_boundary
)) {
92 printf("mini: invalid mem2_boundary %08X\n",
97 *mem2_boundary
= hdr
->mem2_boundary
;
104 static void platform_fixups(void)
112 mem
= finddevice("/memory");
114 fatal("Can't find memory node\n");
116 /* two ranges of (address, size) words */
117 len
= getprop(mem
, "reg", reg
, sizeof(reg
));
118 if (len
!= sizeof(reg
)) {
123 /* retrieve MEM2 boundary from 'mini' */
124 error
= mipc_get_mem2_boundary(&mem2_boundary
);
126 /* if that fails use a sane value */
127 mem2_boundary
= MEM2_TOP
- FIRMWARE_DEFAULT_SIZE
;
130 if (mem2_boundary
> reg
[2] && mem2_boundary
< reg
[2] + reg
[3]) {
131 reg
[3] = mem2_boundary
- reg
[2];
132 printf("top of MEM2 @ %08X\n", reg
[2] + reg
[3]);
133 setprop(mem
, "reg", reg
, sizeof(reg
));
140 void platform_init(unsigned long r3
, unsigned long r4
, unsigned long r5
)
142 u32 heapsize
= 24*1024*1024 - (u32
)_end
;
144 simple_alloc_init(_end
, heapsize
, 32, 64);
145 fdt_init(_dtb_start
);
148 * 'mini' boots the Broadway processor with EXI disabled.
149 * We need it enabled before probing for the USB Gecko.
151 out_be32(EXI_CTRL
, in_be32(EXI_CTRL
) | EXI_CTRL_ENABLE
);
154 console_ops
.write
= ug_console_write
;
156 platform_ops
.fixups
= platform_fixups
;