Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / southbridge / usb / southroot.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: southroot.fth
4\
5\ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6\
7\ - Do no alter or remove copyright notices
8\
9\ - Redistribution and use of this software in source and binary forms, with
10\ or without modification, are permitted provided that the following
11\ conditions are met:
12\
13\ - Redistribution of source code must retain the above copyright notice,
14\ this list of conditions and the following disclaimer.
15\
16\ - Redistribution in binary form must reproduce the above copyright notice,
17\ this list of conditions and the following disclaimer in the
18\ documentation and/or other materials provided with the distribution.
19\
20\ Neither the name of Sun Microsystems, Inc. or the names of contributors
21\ may be used to endorse or promote products derived from this software
22\ without specific prior written permission.
23\
24\ This software is provided "AS IS," without a warranty of any kind.
25\ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
26\ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
27\ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
28\ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
29\ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
30\ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
31\ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
32\ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
33\ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
34\ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
35\ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
36\
37\ You acknowledge that this software is not designed, licensed or
38\ intended for use in the design, construction, operation or maintenance of
39\ any nuclear facility.
40\
41\ ========== Copyright Header End ============================================
42id: @(#)southroot.fth 1.3 03/10/01
43purpose:
44copyright: Copyright 1998-2003 Sun Microsystems, Inc. All Rights Reserved
45copyright: Use is subject to license terms.
46
47\ These two actually must be set via set-root-hub
482 value #root-ports \ read from hc-roota; global
49ff value power-on-time \ in ms -- NOT 2 ms chunks; from hc-roota; global
50
51\ enchilada:
52\ ndp = 2 nps = 1 psm = 0 dt = 0 ocpm = 0 nocp = 0 potpgt = 2
53\ dr = 0 ppcm = 0
54\ ports are always powered. over-current reported for all ports.
55\ must wait 4 ms after port is powered to access it.
56\ all devices are removable.
57\ no port power control.
58\ must run set-root-hub before running get-root-info for southbridge
59: get-root-info ( -- )
60 chip-base hc-roota rl@
61 dup h# ff and to #root-ports
62 dup d# 24 rshift 2* h# ff and to power-on-time
63 drop \ XXX more later
64;
65
66\ some registers must be written for southbridge on enchilada
67: set-root-hub ( -- ) \ root hub descriptor regs
68 h# 200.0202 chip-base hc-roota rl!
69 0 chip-base hc-rootb rl! \ 2 removable device ports, no per-port power
70;
71
72\ root-status and port-status writeable during operational state
73
74\ OS hc-root-status = 0
75
76\ Nothing to do for cmd root hub, RIO root hub, or southbridge root hub
77: set-root-status ( -- ) \ root hub status reg
78;
79
80: unpower-ports ( -- ) \ magic for power on
81 1 chip-base hc-root-status rl!
82;
83
84: power-ports ( -- ) \ magic for power on
85 h# 1.0000 chip-base hc-root-status rl!
86;
87
88\ port addressing is nominally 1 based.
89: port-status ( port# -- addr )
90 chip-base hc-port-status swap 1- 4 * +
91;
92
93: bits>port ( port# bits -- ) swap port-status rl! ;
94
95: disable-port ( port# -- ) 1 bits>port ;
96
97: enable-port ( port# -- ) 2 bits>port ;
98
99: 1reset-port ( port# -- )
100 h# 10 bits>port
101;
102
103: unpower-port ( port# -- ) h# 200 bits>port ;
104
105: clear-connect-change ( port# -- ) h# 1.0000 bits>port ;
106
107: clear-port-enable ( port# -- ) h# 2.0000 bits>port ;
108
109: clear-port-suspend ( port# -- ) h# 4.0000 bits>port ;
110
111: clear-port-reset ( port# -- ) h# 10.0000 bits>port ;
112
113
114: port>bits ( port# mask -- bits ) swap port-status rl@ and ;
115
116: port-connected? ( port# -- connected? ) 1 port>bits ;
117
118: port-powered? ( port# -- power-on? ) h# 100 port>bits ;
119
120: port-low-speed? ( port# -- low-speed? )
121 h# 200 port>bits if 1 else 0 then
122;
123
124: port-reset-done? ( port# -- reset-done? ) h# 10.0000 port>bits ;
125
126
1270 value power-time \ can be global; only used at probe time.
128
129: power-timed-out? ( -- timed-out? )
130 get-msecs power-time u>
131;
132
133\ southbridge: all ports on all the time
134: power-port ( port# -- )
135 get-msecs power-on-time + is power-time
136 begin \ loop until port-powered
137 1 ms
138 dup port-powered?
139 power-timed-out? or \ better not happen -- bad chip if it does.
140 until
141 drop
142 d# 200 ms \ delay for balky devices -- could delay
143 \ once for all since southbridge gang powers
144;
145
146
1470 value reset-time \ can be global; doesn't normally change.
148
149: reset-timed-out? ( -- timed-out? )
150 get-msecs reset-time u>
151;
152
153\ should take only 10 ms; book says it could take 50 ms or more
154: wait-for-reset ( port -- )
155 get-msecs d# 100 + is reset-time
156 begin
157 1 ms
158 dup port-reset-done?
159 reset-timed-out? or
160 until
161 drop
162;
163
164\ XXX do multiple times to get 50 ms reset from host. May not be needed from a port on
165\ the host, but I couldn't find a reference to how long the reset lasts on southbridge;
166\ this assumes 10 ms. Nominally 10 ms is enough, but usb1.1 7.1.7.3 and
167\ usb2.0 7.1.7.5 says 50 ms from host.
168: reset-port ( port# -- )
169 5 0 do
170 dup 1reset-port
171 dup wait-for-reset
172 dup clear-port-reset
173 loop
174 drop
175 d# 200 ms \ balky device reset delay;
176 \ should not have to wait this long
177;