Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / dev / usb / power-on.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: power-on.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: @(#)power-on.fth 1.27 03/03/13
43purpose:
44copyright: Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved
45copyright: Use is subject to license terms.
46
47: activate-chip ( -- ok? )
48 get-mem new-mem-table init-controller
49;
50
51\ the proper value here is dependent on the particular OBP implementation,
52\ especially the depth of the return stack. this value is used to set an
53\ internal value used by the two external words in ...builtin-drivers.
54\ 6 constant max-depth \ full usb tree
553 constant max-depth
56
57\ has dependency on main OBP. puts the recursion depth for hubs back to the
58\ maximum allowed for this onboard usb host adapter. this word works with
59\ go-deeper? in the hub fcode, and with onboard-usb-max-depth and onboard-usb-recurse?
60\ in SUNW,builtin-drivers.
61: max-recursion ( -- )
62 max-depth
63 " onboard-usb-max-depth"
64 " SUNW,builtin-drivers" find-package drop \ must be present
65 find-method if
66 execute
67 else drop
68 then
69;
70
71\ XXX some devices take a long time to turn on after reset. Do some
72\ require two resets?
73\ XXX the order of activation pieces may differ between regular speed and
74\ low speed devices.
75
76\ Hack -- up to 2 tries if error occurs on first try.
77: probe-guts ( port speed -- port speed )
78 2 0 do
79 2dup
80 over clean-port
81 probe-once
82 if leave then
83 loop
84;
85
86\ give a device two chances. if not enumerated ok after two tries, make a
87\ bad device node. Leave open the option for other actions, depending on the
88\ precise failure.
89\ Hack-- up to 5 tries, ignoring fatal errors. With probe-guts, up to 9
90\ fatal errors will be ignored.
91: probe-port ( port speed -- )
92 max-recursion
93 5 0 do \ Hack for taco bad usb mouse
94 probe-guts
95 ['] 2drop ['] complete-probe behavior =
96 if leave then
97 loop
98 complete-probe
99;
100
101\ loop works because RIO powers all ports on at power-on time.
102\ otherwise may need to power port, then look to see if connected.
103: power-on ( -- )
104 my-self to saved-self
105 ['] take-done-q to bless-done-q \ running polled during probe;
106 \ could use quit-take-done-q
107 publish-finder
108 activate-chip if
109 #root-ports 1+ 1 do \ usb ports start at 1
110 i port-connected? if
111 i power-port
112 i dup port-low-speed?
113 dup to child-speed
114 probe-port
115 then
116 loop
117 then
118 toss-controller give-mem
119 0 to open-count
120 0 to saved-self
121 ['] quit-take-done-q to bless-done-q \ setup for 10 ms tick
122;
123
124power-on