PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
ssbusc.h
Go to the documentation of this file.
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
16#ifndef __SSBUSC_H__
17#define __SSBUSC_H__
18
19#include <irx.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/* Extract of the SSBUSC control registers by wisi.
26 For more information, refer to the SSBUSC documentation by Wisi.
27
28 Delay / Configuration channel registers:
29 All bit-fields are r/w unless otherwise noted.
30
31 3 3 2 2 2 2 2 2 2 1 1 1 1 1 1 1 0 0 0 0 0 0
32 1 0 9 8 7 4 3 1 0 6 5 4 3 2 1 0 9 8 7 4 3 0
33 --------------------------------------------------
34 |W|W|D|A| D | | D |E|I|A|A|S|F|H|R| R | W |
35 |A|D|M|D| M | - | E |X|O|I|T|T|L|O|E| D | R |
36 |I|M|A|E| A | | C |D|I|N|Y|R|O|L|C| D | D |
37 |T|A|F|R| T | | R |L|S|C|P|B|T|D|V| L | L |
38 --------------------------------------------------
39
40 3:0 WRDL Write delay: /SWR active low period: 0-15 [cycles+1]
41 7:4 RDDL Read delay: /SRD active low period: 0-15 [cycles+1]
42 8 RECV Recovery period: 0= off / 1= use commonDelay.3:0
43 9 HOLD Hold period: 0= off / 1= use commonDelay.7:4
44 10 FLOT Floating period: 0= off / 1= use commonDelay.11:8
45 11 STRB Pre-Strobe period: 0= off / 1= use commonDelay.15:12
46 12 ATYP Access type: 0= 8bit / 1= 16bit. Also affects DMA bus width, when not using Wide DMA mode.
47 13 AINC Increment address when accessing a register shorter than the access instruction: 0= off / 1= increment.
48 Example: when reading a word from a byte-wide bus, this option sets whether the address on each consecutive 8-bit access would increment or not.
49 If disabled the byte at the base address of the word would be read 4 times, otherwise the bytes at +0, +1, +2, +3 will be read in that order.
50 This is useful (to be disabled) for devices like ATA interfaces, where some ATA registers are written twice for extended LBA
51 (which can be done with a single word-access).
52 14 IOIS16 I/O is 16-bit: /IOIS16 signal: 0= don't use it / 1= regard it.
53 Supported by only(?) DEV9 (but which Dev9M or Dev9I(more likely) or both?).
54 Most likely overrides the Access Type (8/16 -bit) setting (tested, but doesn't seem to have any effect).
55 /IOIS16 should be an input to the IOP, but is marked as output.
56 A peripheral signals by this signal that the register accessed is 16-bit (when low). See Dev9C document for more info.
57
58 From PCMCIA specs (volume 2 / r7.0, february 1999).
59 -----
60 The IOIS16# output signal is asserted when the address at the socket corresponds to an I/O address to which the card responds,
61 and the I/O port addressed is capable of 16-bit access.
62 When this signal is not asserted during a 16-bit I/O access,
63 the system will generate 8-bit references to the even and odd byte of the 16-bit port being accessed.
64 -----
65 15 EXDL Extended delay: MSb of /SRD active low period. Not found to have any effect (regardless of reg. 1020).
66 20:16 DECR Decoding range = 2^n bytes. Values: 0 - 27 = 1B - 128MB.
67 23:21 r/o Unused, 0.
68 27:24 DMAT DMA timing: /SRD /SWR active.low period: 0-14 [cycles+1]. The inactive period is always 1cycle.
69 0=1cycle, 1=2cycles, ..., 14=15cy
70 15(0xF)= '0.5cycles' Each word still remains on the bus for 1cy, but there are no inactive pauses between the words.
71 - 'fastest' DMA mode: /SRD/SWR is kept active low over the whole transfer and the SSCLK clocks the data words.
72 On some devices (PS2 mode only?) the /SRD active low period cannot be 1 cycle, thus with DMAT = 0 or 1, the resulting period is 2cy.
73 It is unknown if this is caused by some setting. The /SWR period is unaffected.
74 28 ADER r/o Address error flag (when =1). When the an address error within the memory range of this channel occurs this bit becomes set.
75 Writing 1 clears it. Unknown what Address Error means. This doesn't become set by unaligned access.
76 It might be for the DMAC accessing RAM past its end when doing DMA through this SSBUSC channel, but it doesn't activate on that either.
77 29 DMAF DMA select timing source flag: 0= use PIO timing / 1= use DMA timing bit-field 28:24 for DMA.
78 30 WDMA Wide DMA mode. When = 1 this overrides the Access Type (8/16 bit) setting, and causes 32 bits to be transferred in one go.
79 The low 16bits are mapped to the SD15:SD0 data lines, and the high 16bits - to the low address lines SA15:SA0, which become inputs,
80 if the transfer is done 'to RAM'.
81 This is why most devices get all the low 16 address bits, even though their address space is much smaller than 64kbyte.
82 The SPU2 doesn't get all 16 low address lines, so this is disabled for it, while it is enabled for the CDVD and Dev9M, Dev9I.
83 31 WAIT /WAIT signal. When = 1 enables the IOP waiting on the /WAIT (input to IOP) signal, when accessing the range of the given device.
84 Slow devices can make the IOP wait (indefinitely) before transferring data, by asserting the /WAIT line low while a PIO access is being done
85 (after the device detected assertion of /CS and decoded the address).
86 On read, once /WAIT is deasserted, IOP loads the data (it was made to wait for) from the device/bus (on read) and continues execution.
87 On write the write operation completes even if /WAIT is asserted low and the IOP can continue executing. This is true for any device.
88 However if /WAIT is kept asserted low and another write (or a read) access is done (to any device - even such with /WAIT hardwired to disabled state),
89 then the IOP will stall before (or after?) transferring any data, until /WAIT is deasserted.
90 This can be used as a hack to use /WAIT even of devices that have it disabled (like the BOOT ROM for example):
91 write a device that has it enabled (while /WAIT is low) then access (r/w) the BOOT ROM and the IOP will stall until /WAIT is deasserted.
92 /WAIT should be driven most likely by OC/OD drivers (or a tri-state output enabled on /CS). The output of the Dev9C seems to be just such.
93
94 There are two main modes of transfer: PIO and DMA.
95 The timing parameters of the PIO mode can be set in detail, while for the DMA mode a symmetric clock is assumed only with period configurable.
96 PIO timing configuration can be used for DMA transfers too.
97
98 For DMA on read (->IOP) both for 0 and 1 DMA periods 1 cycle is added, which results in 2 cycle transfer - reason unknown.
99 On write, 0->1cycle, 1->2cycles (reason unknown).
100
101 Besides the /SRD /SWR active.low periods that can be set individually for each channel,
102 the following parameters exist, that can only be enabled for the individual channels,
103 but the value is common for all. Their values are set by the Common Delay register.
104
105 1020 Common delay register r/w:
106 3:0 Recovery period 0 - 15 cycles.
107 7:4 Hold period 0 - 15 cycles.
108 11:8 Floating release delay 0 - 15 cycles.
109 15:12 Strobe active-going edge delay 0 - 15 cycles.
110 16 r/w ? 0 by default.
111 17 r/w ? 0 by default.
112 31:18 r/o, = 0 unused.
113
114 Recovery period: Elongates with commonDelay.3:0 cycles the period after the data bus is released by the IOP (write) (after the added hold period, if any)
115 or after /SRD goes inact.high, to the next active /SRD/SWR pulse or /CS going inactive transition,
116 to give the device more time to release the bus on read or give more bus turnaround time to the next access on write.
117
118 Hold period: The period after /SWR goes inact.high when the data bus keeps its data valid, necessary for signal propagation and correct latching.
119 The /SWR active.low inter-pulse period will be elongated with commonDelay.7:4 cycles in which after /SWR goes inactive.high the data output from the IOP would still be kept valid.
120 This setting has no effect on /SRD read timing.
121
122 Floating period: Elongate the /CS (active low) and the inter-/SRD pulses periods after /SRD goes inactive to give the device more time to leave the bus
123 floating after driving it (for slow devices that release the bus slowly).
124 Give the device commonDelay.11:8 cycles more after /SRD goes inactive to the next /SRD pulse or the end of the cycle (/CS -> inact.high),
125 to leave the bus floating. When set to 0, the period /SRD inact.high-going edge to /CS inact.high -going edge is 1/2 cycle and is 1cy between /SRD pulses act.low pulses.
126 This setting has no effect on /SWR write timing.
127
128 Pre-Strobe period: Delay from the start of data output (and /CS going active.low) to the active.low -going edge of /SRD or /SWR:
129 Shifts the active-going edge of /SWR the commonDelay.15:12 cycles later than it would usually come,
130 so data can be read on the active-going falling edge.
131 If the active period of the act.low pulse is less than this strobe delay, then the inactive periods between pulses are elongated to account for that.
132 The active pulse is shrunk to a minimum of 1cy in this case. /CS act.low-going edge to /SRD or /SWR act-low going edge is of this number of cycles (otherwise = 0).
133 While delayReg./SRD/SWR_act.low_period <= strobePeriod, no change in the total period is done.
134 Pulse active.low period = max((delayReg.act.low_period - strobePer), 1). - at least 1 cy. This has the same effect on both /SRD and /SWR. */
135
151 SSBUSC_DEV3,
156 SSBUSC_DEV6,
157 SSBUSC_DEV7,
158 SSBUSC_DEV8,
161 //Controls for the DEV9 expansion interface.
162 SSBUSC_DEV_DEV9I, //DEV9 I/O Window
163 SSBUSC_DEV_DEV9M, //DEV9 Memory Window
164 SSBUSC_DEV_DEV9C //DEV9 Controller
165};
166
167/* SSBUSC Register Map, by Wisi
168
169ID - PS2 Function - PS Function - Address - Delay (Configuration)
170---------------------------------------------------------------------------------------
1710 - Exp1 - Exp1 - 0xBF801000 - 0xBF801008
1721 - DVD ROM - Exp3 - 0xBF801400 - 0xBF80100C
1732 - Boot ROM - Boot ROM - - - 0xBF801010
1743 - ??? - ??? - -
1754 - SPU - SPU - 0xBF801404 - 0xBF801014
1765 - CD/DVD - CD-ROM - 0xBF801408 - 0xBF801018
1776 - ??? - ??? - - - -
1787 - ??? - ??? - - - -
1798 - Exp2 - Exp2 - 0xBF801004 - 0xBF80101C
1809 - SPU2 - N/A - 0xBF80140C - 0xBF801414
18110 - DEV9I - N/A - - - 0xBF801418
18211 - DEV9M - N/A - 0xBF801410 - 0xBF80141C
18312 - DEV9C - N/A - - - 0xBF801420
184
185Common Delay register: 0xBF801020 */
186
187//These functions control access configuration (i.e. window size and access cycles) and memory map of the devices.
188int SetDelay(int device, unsigned int value);
189int GetDelay(int device);
190int SetBaseAddress(int device, unsigned int value);
191int GetBaseAddress(int device);
192
193//Helper functions for getting/setting various fields within the common delay register.
194int SetRecoveryTime(unsigned int value);
195int GetRecoveryTime(void);
196int SetHoldTime(unsigned int value);
197int GetHoldTime(void);
198int SetFloatTime(unsigned int value);
199int GetFloatTime(void);
200int SetStrobeTime(unsigned int value);
201int GetStrobeTime(void);
202
203//Direct access to the common delay register.
204int SetCommonDelay(unsigned int value);
205int GetCommonDelay(void);
206
207#define ssbusc_IMPORTS_start DECLARE_IMPORT_TABLE(ssbusc, 1, 1)
208#define ssbusc_IMPORTS_end END_IMPORT_TABLE
209
210#define I_SetDelay DECLARE_IMPORT(4, SetDelay)
211#define I_GetDelay DECLARE_IMPORT(5, GetDelay)
212#define I_SetBaseAddress DECLARE_IMPORT(6, SetBaseAddress)
213#define I_GetBaseAddress DECLARE_IMPORT(7, GetBaseAddress)
214#define I_SetRecoveryTime DECLARE_IMPORT(8, SetRecoveryTime)
215#define I_GetRecoveryTime DECLARE_IMPORT(9, GetRecoveryTime)
216#define I_SetHoldTime DECLARE_IMPORT(10, SetHoldTime)
217#define I_GetHoldTime DECLARE_IMPORT(11, GetHoldTime)
218#define I_SetFloatTime DECLARE_IMPORT(12, SetFloatTime)
219#define I_GetFloatTime DECLARE_IMPORT(13, GetFloatTime)
220#define I_SetStrobeTime DECLARE_IMPORT(14, SetStrobeTime)
221#define I_GetStrobeTime DECLARE_IMPORT(15, GetStrobeTime)
222#define I_SetCommonDelay DECLARE_IMPORT(16, SetCommonDelay)
223#define I_GetCommonDelay DECLARE_IMPORT(17, GetCommonDelay)
224
225#ifdef __cplusplus
226}
227#endif
228
229#endif /* __SSBUSC_H__ */
SSBUSC_DEV
Definition ssbusc.h:144
@ SSBUSC_DEV0
Definition ssbusc.h:146
@ SSBUSC_DEV_SPU2
Definition ssbusc.h:160
@ SSBUSC_DEV_DVDROM
Definition ssbusc.h:148
@ SSBUSC_DEV_SPU
Definition ssbusc.h:153
@ SSBUSC_DEV_CDVD
Definition ssbusc.h:155
@ SSBUSC_DEV_BOOTROM
Definition ssbusc.h:150