wii.h revision 1.1 1 /* $NetBSD: wii.h,v 1.1 2024/01/20 21:36:00 jmcneill Exp $ */
2
3 /*-
4 * Copyright (c) 2024 Jared McNeill <jmcneill (at) invisible.ca>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 /*
30 * Nintendo Wii platform definitions.
31 */
32
33 #ifndef _WII_H
34 #define _WII_H
35
36 #include <powerpc/pio.h>
37
38 #define WII_MEM1_BASE 0x00000000
39 #define WII_MEM1_SIZE 0x01800000 /* 24 MB */
40 #define WII_MEM2_BASE 0x10000000
41 #define WII_MEM2_SIZE 0x04000000 /* 64 MB */
42
43 #define WII_IOMEM_BASE 0x0c000000
44
45 #define GLOBAL_BASE 0x00000000
46 #define GLOBAL_SIZE 0x00003400
47
48 #define BROADWAY_BASE 0x0c000000
49 #define BROADWAY_SIZE 0x00000004
50
51 #define VI_BASE 0x0c002000
52 #define VI_SIZE 0x00000100
53
54 #define PI_BASE 0x0c003000
55 #define PI_SIZE 0x00000100
56
57 #define HOLLYWOOD_BASE 0x0d000000
58 #define HOLLYWOOD_PRIV_BASE 0x0d800000
59 #define HOLLYWOOD_SIZE 0x00008000
60
61 #define XFB_START 0x01698000
62 #define XFB_SIZE 0x00168000
63
64 #define DSP_START 0x10000000
65 #define DSP_SIZE 0x00004000
66
67 #define IPC_START 0x133e0000
68 #define IPC_SIZE 0x00020000
69
70 #define ARM_START 0x13400000
71 #define ARM_SIZE 0x00c00000
72
73 #define BUS_FREQ_HZ 243000000
74 #define CPU_FREQ_HZ (BUS_FREQ_HZ * 3)
75 #define TIMEBASE_FREQ_HZ (BUS_FREQ_HZ / 4)
76
77 /* Global memory structure */
78 #define GLOBAL_MEM1_SIZE (GLOBAL_BASE + 0x0028)
79 #define GLOBAL_CUR_VID_MODE (GLOBAL_BASE + 0x00cc)
80 #define GLOBAL_BUS_SPEED (GLOBAL_BASE + 0x00f8)
81 #define GLOBAL_CPU_SPEED (GLOBAL_BASE + 0x00fc)
82 #define GLOBAL_SYSTEM_TIME (GLOBAL_BASE + 0x30d8)
83 #define GLOBAL_MEM2_SIZE (GLOBAL_BASE + 0x3118)
84 #define GLOBAL_MEM2_AVAIL_START (GLOBAL_BASE + 0x3124)
85 #define GLOBAL_MEM2_AVAIL_END (GLOBAL_BASE + 0x3128)
86 #define GLOBAL_IOS_VERSION (GLOBAL_BASE + 0x3140)
87
88 /* Processor interface registers */
89 #define PI_INTSR (PI_BASE + 0x00)
90 #define PI_INTMR (PI_BASE + 0x04)
91
92 /* Processor IRQs */
93 #define PI_IRQ_HOLLYWOOD 14
94
95 /* Hollywood registers */
96 #define HW_PPCIRQFLAGS (HOLLYWOOD_BASE + 0x030)
97 #define HW_PPCIRQMASK (HOLLYWOOD_BASE + 0x034)
98 #define HW_ARMIRQFLAGS (HOLLYWOOD_PRIV_BASE + 0x038)
99 #define HW_ARMIRQMASK (HOLLYWOOD_PRIV_BASE + 0x03c)
100 #define HW_AHBPROT (HOLLYWOOD_PRIV_BASE + 0x064)
101 #define HW_GPIOB_OUT (HOLLYWOOD_BASE + 0x0c0)
102 #define HW_GPIO_OUT (HOLLYWOOD_PRIV_BASE + 0x0e0)
103 #define HW_RESETS (HOLLYWOOD_PRIV_BASE + 0x194)
104 #define RSTB_IOP __BIT(23)
105 #define RSTBINB __BIT(0)
106 #define HW_VERSION (HOLLYWOOD_BASE + 0x214)
107 #define HWVER_MASK __BITS(7,4)
108 #define HWREV_MASK __BITS(3,0)
109
110 /* GPIOs */
111 #define GPIO_SLOT_LED 5
112
113 /* Blink the slot LED forever at the specified interval. */
114 static inline void __dead
115 wii_slot_led_blink(u_int interval_us)
116 {
117 uint32_t val;
118
119 for (val = in32(HW_GPIOB_OUT); ; val ^= __BIT(GPIO_SLOT_LED)) {
120 delay(interval_us);
121 out32(HW_GPIOB_OUT, val);
122 }
123 }
124
125 #endif /* !_WII_H */
126