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