Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: mac_init_class.vr | |
4 | // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
5 | // 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
6 | // | |
7 | // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 | // | |
9 | // This program is free software; you can redistribute it and/or modify | |
10 | // it under the terms of the GNU General Public License as published by | |
11 | // the Free Software Foundation; version 2 of the License. | |
12 | // | |
13 | // This program is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | // | |
18 | // You should have received a copy of the GNU General Public License | |
19 | // along with this program; if not, write to the Free Software | |
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | // | |
22 | // For the avoidance of doubt, and except that if any non-GPL license | |
23 | // choice is available it will apply instead, Sun elects to use only | |
24 | // the General Public License version 2 (GPLv2) at this time for any | |
25 | // software where a choice of GPL license versions is made | |
26 | // available with the language indicating that GPLv2 or any later version | |
27 | // may be used, or where a choice of which version of the GPL is applied is | |
28 | // otherwise unspecified. | |
29 | // | |
30 | // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
31 | // CA 95054 USA or visit www.sun.com if you need additional information or | |
32 | // have any questions. | |
33 | // | |
34 | // ========== Copyright Header End ============================================ | |
35 | #include <vera_defines.vrh> | |
36 | #include "mac_pio_class.vrh" | |
37 | #include "xmac_util.vrh" | |
38 | #include "bmac_util.vrh" | |
39 | #include "pcs_util.vrh" | |
40 | #include "xpcs_util.vrh" | |
41 | ||
42 | extern event mac_init_done; | |
43 | extern mac_util_class mac_util; | |
44 | extern bmac_util_class bmac_util; | |
45 | extern pcs_util_class pcs_util; | |
46 | extern xpcs_util_class xpcs_util; | |
47 | extern mac_pio_cl mac_pio_class; | |
48 | ||
49 | ||
50 | class mac_init_class { | |
51 | task new(); | |
52 | task init_mac(); | |
53 | } | |
54 | ||
55 | task mac_init_class::new() { | |
56 | trigger(OFF,mac_init_done); | |
57 | } | |
58 | ||
59 | task mac_init_class::init_mac(){ | |
60 | integer mac_id, ii; | |
61 | integer port_no[]; | |
62 | integer mac_speed0, mac_speed1, mac_speed2, mac_speed3; | |
63 | string str; | |
64 | string init_mac_ports,temp_port; | |
65 | bit[2047:0] bit_str; | |
66 | bit[3:0] rtl_mac; | |
67 | bit[31:0] get_mac_port; | |
68 | bit[31:0] rd_data; | |
69 | integer mac_config0[4], mac_config1[4]; | |
70 | ||
71 | if(get_plus_arg(CHECK, "MAC_SPEED0=") ) { | |
72 | mac_speed0 = get_plus_arg(NUM, "MAC_SPEED0") ; | |
73 | printf("mac_init:MAC0 speed=%0d\n" ,mac_speed0); | |
74 | } | |
75 | if(get_plus_arg(CHECK, "MAC_SPEED1=") ) { | |
76 | mac_speed1 = get_plus_arg(NUM, "MAC_SPEED1") ; | |
77 | printf("mac_init:MAC1 speed=%0d\n" ,mac_speed1); | |
78 | } | |
79 | if(get_plus_arg(CHECK, "MAC_SPEED2=") ) { | |
80 | mac_speed2 = get_plus_arg(NUM, "MAC_SPEED2") ; | |
81 | printf("mac_init:MAC2 speed=%0d\n" ,mac_speed2); | |
82 | } | |
83 | if(get_plus_arg(CHECK, "MAC_SPEED3=") ) { | |
84 | mac_speed3 = get_plus_arg(NUM, "MAC_SPEED3") ; | |
85 | printf("mac_init:MAC3 speed=%0d\n" ,mac_speed3); | |
86 | } | |
87 | ||
88 | get_mac_port = get_plus_arg( STR, "GET_MAC_PORTS="); | |
89 | printf("mac_init:GET_MAC_PORTS=%h\n",get_mac_port); | |
90 | init_mac_ports.bittostr(get_mac_port); | |
91 | ||
92 | for(ii=0; ii<init_mac_ports.len(); ii++) { | |
93 | temp_port =init_mac_ports.substr(ii, ii); | |
94 | port_no[ii]=temp_port.atoi(); | |
95 | } | |
96 | ||
97 | mac_config0[0] =1; // config1 config0 | |
98 | mac_config0[1] =1; // 0 1 RTL | |
99 | mac_config0[2] =1; // 1 1 DUmmy | |
100 | mac_config0[3] =1; | |
101 | ||
102 | mac_config1[0] =1; | |
103 | mac_config1[1] =1; | |
104 | mac_config1[2] =1; | |
105 | mac_config1[3] =1; | |
106 | ||
107 | for(ii=0; ii<init_mac_ports.len(); ii++) { | |
108 | case(port_no[ii]) { | |
109 | 0: mac_config1[0]=0; | |
110 | 1: mac_config1[1]=0; | |
111 | 2: mac_config1[2]=0; | |
112 | 3: mac_config1[3]=0; | |
113 | } | |
114 | } | |
115 | ||
116 | for(ii=0; ii<4; ii++) rtl_mac[ii] = (!mac_config1[ii] & mac_config0[ii]); | |
117 | ||
118 | // XMAC INIT | |
119 | if( get_plus_arg( CHECK, "REG_TEST")) { } | |
120 | else { | |
121 | for(mac_id=0; mac_id<2; mac_id++) { | |
122 | case(mac_id){ | |
123 | 0: case(mac_speed0){ | |
124 | 10: if(rtl_mac[0]) { | |
125 | printf("mac_init:MAC0 setting to 10 time=%0d\n", get_time(LO)); | |
126 | mac_util.xmii_init(0, MAC_CONF_10); | |
127 | } | |
128 | 100: if(rtl_mac[0]) { | |
129 | printf("mac_init:MAC0 setting to 100 time=%0d\n", get_time(LO)); | |
130 | mac_util.xmii_init(0, MAC_CONF_100); | |
131 | } | |
132 | 1000: if(rtl_mac[0]) { | |
133 | printf("mac_init:MAC0 setting to 1000 time=%0d\n", get_time(LO)); | |
134 | mac_util.xmii_init(0, MAC_CONF_1000); | |
135 | pcs_util.pcs_init(0); | |
136 | } | |
137 | 10000: if(rtl_mac[0]) { | |
138 | printf("mac_init:MAC0 setting to 10000 time=%0d\n", get_time(LO)); | |
139 | mac_util.xmii_init(0, MAC_CONF_10000); | |
140 | } | |
141 | } | |
142 | 1: case(mac_speed1) { | |
143 | 10: if(rtl_mac[1]){ | |
144 | printf("mac_init:MAC1 setting to 10 time=%0d\n", get_time(LO)); | |
145 | mac_util.xmii_init(1, MAC_CONF_10); | |
146 | } | |
147 | 100: if(rtl_mac[1]){ | |
148 | printf("mac_init:MAC1 setting to 100 time=%0d\n", get_time(LO)); | |
149 | mac_util.xmii_init(1, MAC_CONF_100); | |
150 | } | |
151 | 1000: if(rtl_mac[1]) { | |
152 | printf("mac_init:MAC1 setting to 1000 time=%0d\n", get_time(LO)); | |
153 | mac_util.xmii_init(1,MAC_CONF_1000); | |
154 | pcs_util.pcs_init(1); | |
155 | } | |
156 | 10000: if(rtl_mac[1]) { | |
157 | printf("mac_init:MAC1 setting to 10000 time=%0d\n", get_time(LO)); | |
158 | mac_util.xmii_init(1,MAC_CONF_10000); | |
159 | } | |
160 | } | |
161 | } | |
162 | } | |
163 | } | |
164 | ||
165 | // XPCS INIT | |
166 | if( get_plus_arg( CHECK, "REG_TEST")) { repeat(5) @(posedge CLOCK); } | |
167 | else { | |
168 | if((mac_speed0==10000)| (mac_speed1==10000)) { | |
169 | printf("mac_init:before XPCS init \n"); | |
170 | for(mac_id =0; mac_id<2; mac_id++) { | |
171 | case(mac_id){ | |
172 | 0: xpcs_util.xpcs_init(0); | |
173 | 1: xpcs_util.xpcs_init(1); | |
174 | } | |
175 | } | |
176 | } | |
177 | } | |
178 | ||
179 | // BMAC/PCS INIT | |
180 | if( get_plus_arg( CHECK, "REG_TEST")) { repeat(5) @(posedge CLOCK); } | |
181 | else { | |
182 | for(mac_id =2; mac_id<4; mac_id++) { | |
183 | case(mac_id) { | |
184 | 2: case(mac_speed2) { | |
185 | 10: if(rtl_mac[2]){ | |
186 | printf("mac_init:MAC2 setting to 10 time=%0d\n", get_time(LO)); | |
187 | bmac_util.bmac_init(mac_id, MAC_INIT_ALL_REG | MI_DEBUG | MAC_CONF_10); | |
188 | } | |
189 | 100: if(rtl_mac[2]) { | |
190 | printf("mac_init:MAC2 setting to 100 time=%0d\n", get_time(LO)); | |
191 | bmac_util.bmac_init(mac_id, MAC_INIT_ALL_REG | MI_DEBUG | MAC_CONF_100); | |
192 | } | |
193 | 1000: if(rtl_mac[2]) { | |
194 | pcs_util.pcs_init(2); | |
195 | printf("mac_init:MAC2 setting to 1000 time=%0d\n", get_time(LO) ); | |
196 | bmac_util.bmac_init(mac_id, MAC_INIT_ALL_REG | MI_DEBUG | MAC_CONF_1000); | |
197 | } | |
198 | } | |
199 | 3: case(mac_speed3) { | |
200 | 10: if (rtl_mac[3]){ | |
201 | printf("mac_init:MAC3 setting to 10 time=%0d\n", get_time(LO)); | |
202 | bmac_util.bmac_init(mac_id, MAC_INIT_ALL_REG | MI_DEBUG | MAC_CONF_10); | |
203 | } | |
204 | 100: if (rtl_mac[3]){ | |
205 | printf("mac_init:MAC3 setting to 100 time=%0d\n", get_time(LO)); | |
206 | bmac_util.bmac_init(mac_id, MAC_INIT_ALL_REG | MI_DEBUG | MAC_CONF_100); | |
207 | } | |
208 | 1000: if (rtl_mac[3]){ | |
209 | printf("mac_init:MAC3 setting to 1000 time=%d\n", get_time(LO)); | |
210 | pcs_util.pcs_init(3); | |
211 | bmac_util.bmac_init(mac_id, MAC_INIT_ALL_REG | MI_DEBUG | MAC_CONF_1000); | |
212 | } | |
213 | } | |
214 | } | |
215 | } | |
216 | } //else | |
217 | ||
218 | mac_pio_class.xmac_pio_rd(XPCS0_BASE + XPCS_CONTROL1, rd_data,1'b0); | |
219 | printf("mac_init:READ FROM MAC_INIT TO COMPLETE THE INIT\n"); | |
220 | trigger(ON,mac_init_done); | |
221 | } |