sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
aifregs.h
Go to the documentation of this file.
1
6
7#ifndef __AIFREGS_H__
8#define __AIFREGS_H__
9
10#include <tamtypes.h>
11
12// clang-format off
13/*
14 * Slightly modified from "Basic AIF driver set" by sp193 ("[140524]AIF.7z")
15 * The Sony PlayStation 2 TOOL DTL-T10000(H) units have a slightly different SSBUSC design from the SCPH-10000 unit:
16 * its expansion interface (the PC CARD slot) seems to be connected and managed from an interface known as the "AIF".
17 * Nothing too much is known about this interface, other than the fact that it's only present on TOOL units.
18 *
19 * Every TOOL unit has two ATA disks: one which is connected to the SBC PCI card,
20 * while the other is connected to a PCB that has the PC CARD slot on it.
21 *
22 * While the HDD that is connected to the SBC card obviously has a purpose (it contains the PC-side Linux installation),
23 * the purpose of the other unit is not very clear because it was never used for any official applications.
24 *
25 * That HDD unit, which is accessible via the AIF on the PlayStation 2 side of the TOOL,
26 * was reported to have contained a pristine copy of the PC-side Linux installation.
27 * However, it does not seem possible to restore the SBC HDD unit without external help because the AIF HDD is not directly accessible from the SBC.
28 *
29 * The AIF is known to have support for only three devices: ATA HDD unit 0, a Motorola MC146818A RTC, and the PC CARD interface.
30 *
31 * While the AIF seems to have support for ATA HDD unit 1, there isn't a physical port to connect a second HDD unit to.
32 *
33 * The lack of DMA support in the official Sony code (within the PS2 Linux kernel) and the apparent lack of hardware registers for DMA support
34 * suggests that it might be indeed incapable of any DMA transfer modes.
35 *
36 * Memory seems to be mirrored after offset 0x200.
37 *
38 * Legend:
39 * R Read-only
40 * W Write-only
41 * X R/W
42 * . Unused
43 *
44 * Offset: Register: Detected bits: Default value:
45 * 0x0000 IDENT RRRRRRRRRRRRRRRR 0x0061
46 * 0x0002 REVISION RRRRRRRRRRRRRRRR 0x0003
47 * 0x0004 INTSR/INTCL .............XXX 0x0002
48 * 0x0006 INTEN .............XXX 0x0000
49 * 0x0008 TIMCFG ...............X 0x0000
50 * 0x000A unknown ...............R 0x0001
51 * 0x000C unknown ...............R 0x0001
52 * 0x0010 COUNT_L RRRRRRRRRRRRRRRR ??????
53 * 0x0012 COUNT_H RRRRRRRRRRRRRRRR ??????
54 * 0x0014-0x003E unknown ...............R 0x0001
55 * 0x0040 ATA_TCFG ........XXXXXXXX 0x0000
56 * 0x0042-0x005E unknown ...............R 0x0001
57 * 0x0060 ATA_DATA ........XXXXXXXX 0xFF50
58 * 0x0062 ATA_FEATURE ........XXXXXXXX 0xFF00
59 * 0x0064 ATA_NSECTOR ........XXXXXXXX 0xFF00
60 * 0x0066 ATA_SECTOR ........XXXXXXXX 0xFF01
61 * 0x0068 ATA_LCYL ........XXXXXXXX 0xFF01
62 * 0x006A ATA_HCYL ........XXXXXXXX 0xFF01
63 * 0x006C ATA_SELECT ........XXXXXXXX 0xFF00
64 * 0x006E ATA_COMMAND ........XXXXXXXX 0xFF00
65 * 0x0070 unknown ...............X 0xFF00
66 * 0x0072 unknown ...............X 0xFF00
67 * 0x0074 unknown ...............X 0xFF00
68 * 0x0076 unknown ...............X 0xFF01
69 * 0x0078 unknown ...............X 0xFF01
70 * 0x007A unknown ...............X 0xFF00
71 * 0x007C ATA_CONTROL ........XXXXXXXX 0xFF00
72 * 0x007E unknown ........XXXXXXXX 0xFF50
73 * 0x0080-0x00DE unknown ...............R 0x0001
74 * 0x00E0-0x00FE A second ATA port? The power-on defaults appear to be the same as the ATA registers above.
75 * 0x0100-0x011A MC146818A RTC registers.
76 * 0x011C-0x01FE unknown Probably the RTC's user RAM region. Seems to be fully readable from and writable to.
77 *
78 * Reading from all the unknown seems to be wonky, as it takes the second read from the register to read in the written value.
79 * Sometimes, it even feels as if the value that is read was from elsewhere. Are they possibly write-only or unmapped?
80 *
81 * The purpose of TIMCFG, COUNT_L and COUNT_H is not known because the official Sony code within the PS2 Linux kernel does not seem to use these registers anywhere.
82 *
83 * INTEN, INTSR and INTCL bits:
84 * Bit 1: ATA0
85 * Bit 2: RTC? The purpose of the bit here isn't known because it isn't used, but it seems likely to be the RTC's because the RTC doesn't have a known interrupt even bit for itself.
86 * Bit 3: PCMCIA interrupt.
87*/
88// clang-format on
89
90#define AIF_REGBASE (SPD_REGBASE + 0x4000000)
91
92#define USE_AIF_REGS volatile u16 *aif_regs = \
93 (volatile u16 *)AIF_REGBASE
94
95enum AIF_REGS {
96 AIF_IDENT = 0x00,
97 AIF_REVISION,
98 AIF_INTSR,
99 AIF_INTEN,
100 AIF_TIMCFG,
101 AIF_COUNT_L = 0x08,
102 AIF_COUNT_H,
103 AIF_ATA_TCFG = 0x20,
104 AIF_ATA = 0x30, // ATA register base.
105 AIF_ATACTL = 0x3C,
106 AIF_RTC = 0x80 // RTC register base.
107};
108
109#define AIF_INTCL AIF_INTSR
110
111// AIF interrupt management
112enum AIF_INUM {
113 AIF_INUM_ATA0 = 0,
114 AIF_INUM_RTC, // I don't know what this interrupt event is, but it should be for the RTC because it doesn't have a known bit for itself.
115 AIF_INUM_PCMCIA,
116
117 AIF_INUM_COUNT
118};
119
120#define AIF_INTR_ATA0 (1 << AIF_INUM_ATA0)
121#define AIF_INTR_RTC (1 << AIF_INUM_RTC)
122#define AIF_INTR_PCMCIA (1 << AIF_INUM_PCMCIA)
123
124// Motorola MC146818 RTC management
125#define USE_AIF_RTC_REGS volatile u16 *aif_rtc_regs = \
126 (&aif_regs[AIF_RTC])
127
128enum RTC_REGS {
129 RTC_SECONDS = 0x00,
130 RTC_SECONDS_ALARM,
131 RTC_MINUTES,
132 RTC_MINUTES_ALARM,
133 RTC_HOURS,
134 RTC_HOURS_ALARM,
135 RTC_DAY_OF_WEEK,
136 RTC_DAY_OF_MONTH,
137 RTC_MONTH,
138 RTC_YEAR,
139 RTC_REG_A,
140 RTC_REG_B,
141 RTC_REG_C,
142 RTC_REG_D
143};
144
145/**********************************************************************
146 * RTC register details, taken from mc146818rtc.h
147 **********************************************************************/
148#define RTC_FREQ_SELECT RTC_REG_A
149
155#define RTC_UIP 0x80
156#define RTC_DIV_CTL 0x70
158#define RTC_REF_CLCK_4MHZ 0x00
159#define RTC_REF_CLCK_1MHZ 0x10
160#define RTC_REF_CLCK_32KHZ 0x20
162#define RTC_DIV_RESET1 0x60
163#define RTC_DIV_RESET2 0x70
165#define RTC_RATE_SELECT 0x0F
166
167/**********************************************************************/
168#define RTC_CONTROL RTC_REG_B
170#define RTC_SET 0x80
172#define RTC_PIE 0x40
174#define RTC_AIE 0x20
176#define RTC_UIE 0x10
178#define RTC_SQWE 0x08
180#define RTC_DM_BINARY 0x04
182#define RTC_24H 0x02
184#define RTC_DST_EN 0x01
185
186
187/**********************************************************************/
188#define RTC_INTR_FLAGS RTC_REG_C
189/* caution - cleared by read */
191#define RTC_IRQF 0x80
192#define RTC_PF 0x40
193#define RTC_AF 0x20
194#define RTC_UF 0x10
195
196/**********************************************************************/
197#define RTC_VALID RTC_REG_D
199#define RTC_VRT 0x80
200/**********************************************************************/
201
202#endif /* __AIFREGS_H__ */