1 |
30 |
dgisselq |
////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
//
|
3 |
|
|
// Filename: netsetup.cpp
|
4 |
|
|
//
|
5 |
|
|
// Project: OpenArty, an entirely open SoC based upon the Arty platform
|
6 |
|
|
//
|
7 |
|
|
// Purpose:
|
8 |
|
|
//
|
9 |
|
|
//
|
10 |
|
|
// Creator: Dan Gisselquist, Ph.D.
|
11 |
|
|
// Gisselquist Technology, LLC
|
12 |
|
|
//
|
13 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
14 |
|
|
//
|
15 |
|
|
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
|
16 |
|
|
//
|
17 |
|
|
// This program is free software (firmware): you can redistribute it and/or
|
18 |
|
|
// modify it under the terms of the GNU General Public License as published
|
19 |
|
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
20 |
|
|
// your option) any later version.
|
21 |
|
|
//
|
22 |
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
23 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
24 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
25 |
|
|
// for more details.
|
26 |
|
|
//
|
27 |
|
|
// You should have received a copy of the GNU General Public License along
|
28 |
|
|
// with this program. (It's in the $(ROOT)/doc directory, run make with no
|
29 |
|
|
// target there if the PDF file isn't present.) If not, see
|
30 |
|
|
// <http://www.gnu.org/licenses/> for a copy.
|
31 |
|
|
//
|
32 |
|
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
33 |
|
|
// http://www.gnu.org/licenses/gpl.html
|
34 |
|
|
//
|
35 |
|
|
//
|
36 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
37 |
|
|
//
|
38 |
|
|
//
|
39 |
|
|
#include <stdio.h>
|
40 |
|
|
#include <stdlib.h>
|
41 |
|
|
#include <unistd.h>
|
42 |
|
|
#include <strings.h>
|
43 |
|
|
#include <ctype.h>
|
44 |
|
|
#include <string.h>
|
45 |
|
|
#include <signal.h>
|
46 |
|
|
#include <assert.h>
|
47 |
|
|
|
48 |
|
|
#include "port.h"
|
49 |
|
|
#include "regdefs.h"
|
50 |
|
|
|
51 |
|
|
FPGA *m_fpga;
|
52 |
|
|
void closeup(int v) {
|
53 |
|
|
m_fpga->kill();
|
54 |
|
|
exit(0);
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
void usage(void) {
|
58 |
|
|
printf("USAGE: netsetup\n");
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
int main(int argc, char **argv) {
|
62 |
|
|
int skp=0, port = FPGAPORT;
|
63 |
|
|
|
64 |
|
|
FPGAOPEN(m_fpga);
|
65 |
|
|
|
66 |
|
|
signal(SIGSTOP, closeup);
|
67 |
|
|
signal(SIGHUP, closeup);
|
68 |
|
|
|
69 |
|
|
if ((argc < 1)||(argc > 2)) {
|
70 |
|
|
// usage();
|
71 |
|
|
printf("USAGE: netsetup\n");
|
72 |
|
|
exit(-1);
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
unsigned v;
|
76 |
|
|
v = m_fpga->readio(R_MDIO_BMCR);
|
77 |
|
|
printf(" BMCR %04x\tBasic Mode Control Register\n", v);
|
78 |
|
|
if (v & 0x08000)
|
79 |
|
|
printf(" \tReset in progress\n");
|
80 |
|
|
if (v & 0x04000)
|
81 |
|
|
printf(" \tLoopback enabled\n");
|
82 |
|
|
if (v & 0x01000)
|
83 |
|
|
printf(" \tAuto-negotiation enabled\n");
|
84 |
|
|
else if (v & 0x02000)
|
85 |
|
|
printf(" \t100Mb/s -- manual selection\n");
|
86 |
|
|
else
|
87 |
|
|
printf(" \t 10Mb/s -- manual selection\n");
|
88 |
|
|
if (v & 0x00800)
|
89 |
|
|
printf(" \tPHY is powered down\n");
|
90 |
|
|
if (v & 0x00400)
|
91 |
|
|
printf(" \tPort is isolated from MII\n");
|
92 |
|
|
if (v & 0x00200)
|
93 |
|
|
printf(" \tRestart-auto-negotiation\n");
|
94 |
|
|
if ((v& 0x00100)==0)
|
95 |
|
|
printf(" \tHalf-duplex mode\n");
|
96 |
|
|
if (v & 0x00080)
|
97 |
|
|
printf(" \tCollision test enabled\n");
|
98 |
|
|
v = m_fpga->readio(R_MDIO_BMSR);
|
99 |
|
|
printf("R/O BMSR %04x\tBasic Mode Status Register\n", v);
|
100 |
|
|
if (v & 0x08000)
|
101 |
|
|
printf(" \t100Base-T4 capable\n");
|
102 |
|
|
if (v & 0x04000)
|
103 |
|
|
printf(" \t100Base-TX Full Duplex capable\n");
|
104 |
|
|
if (v & 0x02000)
|
105 |
|
|
printf(" \t100Base-TX Half Duplex capable\n");
|
106 |
|
|
if (v & 0x01000)
|
107 |
|
|
printf(" \t 10Base-TX Full Duplex capable\n");
|
108 |
|
|
if (v & 0x00800)
|
109 |
|
|
printf(" \t 10Base-TX Half Duplex capable\n");
|
110 |
|
|
if (v & 0x00040)
|
111 |
|
|
printf(" \tPreamble suppression capable\n");
|
112 |
|
|
if (v & 0x00020)
|
113 |
|
|
printf(" \tAuto-negotiation complete\n");
|
114 |
|
|
if (v & 0x00010)
|
115 |
|
|
printf(" \tRemote fault detected\n");
|
116 |
|
|
if (v & 0x00008)
|
117 |
|
|
printf(" \tDevice is capable of auto-negotiation\n");
|
118 |
|
|
if (v & 0x00004)
|
119 |
|
|
printf(" \tLink is up\n");
|
120 |
|
|
if (v & 0x00002)
|
121 |
|
|
printf(" \tJabber condition detected (10Mb/s mode)\n");
|
122 |
|
|
if (v & 0x00001)
|
123 |
|
|
printf(" \tExtended register capabilities\n");
|
124 |
|
|
v = m_fpga->readio(R_MDIO_PHYIDR1);
|
125 |
|
|
printf("R/O PHYID1 %04x\tPHY Identifier Reg #1\n", v);
|
126 |
|
|
//printf(" %4x\tOUI MSB\n", v);
|
127 |
|
|
v = m_fpga->readio(R_MDIO_PHYIDR2);
|
128 |
|
|
printf("R/O PHYID2 %04x\tPHY Identifier Reg #2\n", v);
|
129 |
|
|
printf(" %4x\tOUI LSBs\n", (v>>10)&0x3f);
|
130 |
|
|
printf(" %4x\tVendor model number\n", (v>>4)&0x3f);
|
131 |
|
|
printf(" %4x\tModel revision number\n", v&0x0f);
|
132 |
|
|
v = m_fpga->readio(R_MDIO_ANAR);
|
133 |
|
|
printf(" ANAR %04x\tAuto-negotiation advertisement register\n", v);
|
134 |
|
|
v = m_fpga->readio(R_MDIO_ANLPAR);
|
135 |
|
|
printf(" ANLPAR %04x\tAuto-negotiation link partner ability\n", v);
|
136 |
|
|
v = m_fpga->readio(R_MDIO_ANER);
|
137 |
|
|
printf(" ANER %04x\tAuto-negotiation expansion register\n", v);
|
138 |
|
|
v = m_fpga->readio(R_MDIO_ANNPTR);
|
139 |
|
|
printf(" ANNPTR %04x\tAuto-negotiation Next page TX\n", v);
|
140 |
|
|
v = m_fpga->readio(R_MDIO_PHYSTS);
|
141 |
|
|
printf("R/O PHYSTS %04x\tPHY status register\n", v);
|
142 |
|
|
if (v&0x4000)
|
143 |
|
|
printf(" \tMDI pairs swapped\n");
|
144 |
|
|
if (v&0x2000)
|
145 |
|
|
printf(" \tReceive error event since last read of RXERCNT\n");
|
146 |
|
|
if (v&0x1000)
|
147 |
|
|
printf(" \tInverted polarity detected\n");
|
148 |
|
|
if (v&0x800)
|
149 |
|
|
printf(" \tFalse carrier sense latch\n");
|
150 |
|
|
if (v&0x400)
|
151 |
|
|
printf(" \tUnconditional signal detection from PMD\n");
|
152 |
|
|
if (v&0x200)
|
153 |
|
|
printf(" \tDescrambler lock from PMD\n");
|
154 |
|
|
if (v&0x100)
|
155 |
|
|
printf(" \tNew link codeword page has been received\n");
|
156 |
|
|
if (v&0x40)
|
157 |
|
|
printf(" \tRemote fault condition detected\n");
|
158 |
|
|
if (v&0x20)
|
159 |
|
|
printf(" \tJabber condition detected\n");
|
160 |
|
|
if (v&0x10)
|
161 |
|
|
printf(" \tAuto-negotiation complete\n");
|
162 |
|
|
if (v&0x08)
|
163 |
|
|
printf(" \tLoopback enabled\n");
|
164 |
|
|
if (v&0x04)
|
165 |
|
|
printf(" \tFull duplex mode\n");
|
166 |
|
|
printf(" %3d\tSpeed from autonegotiation\n", (v&2)?10:100);
|
167 |
|
|
if ((v&0x01)==0)
|
168 |
|
|
printf(" \tNo link established\n");
|
169 |
|
|
v = m_fpga->readio(R_MDIO_FCSCR);
|
170 |
|
|
printf(" FCSCR %04x\tFalse Carrier Sense Counter Register\n", v);
|
171 |
|
|
v = m_fpga->readio(R_MDIO_RECR);
|
172 |
|
|
printf(" RECR %04x\tReceive Error Counter Register\n", v);
|
173 |
|
|
v = m_fpga->readio(R_MDIO_PCSR);
|
174 |
|
|
printf(" PCSR %04x\tPCB Sub-Layer Configuration and Status Register\n", v);
|
175 |
|
|
if (v&0x400)
|
176 |
|
|
printf(" \tTrue Quiet (TQ) mode enabled\n");
|
177 |
|
|
if (v&0x200)
|
178 |
|
|
printf(" \tSignal detecttion forced in PMA\n");
|
179 |
|
|
if (v&0x100)
|
180 |
|
|
printf(" \tEnhanced signal detetion algorithm\n");
|
181 |
|
|
if (v&0x80)
|
182 |
|
|
printf(" \tDescrambler timeout = 2ms (for large packets)\n");
|
183 |
|
|
if (v&0x20)
|
184 |
|
|
printf(" \tForce 100Mb/s good link\n");
|
185 |
|
|
if (v&0x4)
|
186 |
|
|
printf(" \tNRZI bypass enabled\n");
|
187 |
|
|
v = m_fpga->readio(R_MDIO_RBR);
|
188 |
|
|
printf(" RBR %04x\tRMII and Bypass Register\n", v);
|
189 |
|
|
if (v&0x20)
|
190 |
|
|
printf(" \tRMII mode enabled\n");
|
191 |
|
|
v = m_fpga->readio(R_MDIO_LEDCR);
|
192 |
|
|
printf(" LEDCR %04x\tLED Direct Control Register\n", v);
|
193 |
|
|
if (v&0x20)
|
194 |
|
|
printf(" %s\tLED_SPEED LED\n", (v&0x4)?"ON ":"OFF");
|
195 |
|
|
if (v&0x10)
|
196 |
|
|
printf(" %s\tLED_LINK LED\n", (v&0x2)?"ON ":"OFF");
|
197 |
|
|
|
198 |
|
|
v = m_fpga->readio(R_MDIO_PHYCR);
|
199 |
|
|
printf(" PHYCR %04x\tPHY control register\n", v);
|
200 |
|
|
if (v&0x8000)
|
201 |
|
|
printf(" \tAuto-neg auto-MDIX enabled\n");
|
202 |
|
|
if (v&0x4000)
|
203 |
|
|
printf(" \tForce MDI pairs to cross\n");
|
204 |
|
|
if (v&0x2000)
|
205 |
|
|
printf(" \tPause receive negotiation\n");
|
206 |
|
|
if (v&0x1000)
|
207 |
|
|
printf(" \tPause transmit negotiation\n");
|
208 |
|
|
if (v&0x0800)
|
209 |
|
|
printf(" \tForce BIST error\n");
|
210 |
|
|
if (v&0x0400)
|
211 |
|
|
printf(" \tPSR15 BIST sequence selected\n");
|
212 |
|
|
if (v&0x0200)
|
213 |
|
|
printf(" \tBIST test passed\n");
|
214 |
|
|
if (v&0x0100)
|
215 |
|
|
printf(" \tBIST start\n");
|
216 |
|
|
if (v&0x0080)
|
217 |
|
|
printf(" \tBypass LED stretching\n");
|
218 |
|
|
if ((v&0x0020)==0)
|
219 |
|
|
printf(" \tDon\'t blink LED\'s on activity\n");
|
220 |
|
|
if (v&0x001f)
|
221 |
|
|
printf(" %4x\tPHY Addr\n", v & 0x01f);
|
222 |
|
|
v = m_fpga->readio(R_MDIO_BTSCR);
|
223 |
|
|
printf(" BTSCR %04x\t10-Base T Status/Control Register\n", v);
|
224 |
|
|
v = m_fpga->readio(R_MDIO_CDCTRL);
|
225 |
|
|
printf(" CDCTRL %04x\tCD Test Control Register, BIST Extension Register\n", v);
|
226 |
|
|
if (v&0xff00)
|
227 |
|
|
printf(" %04x\tBIST error counter\n", (v>>8)&0x0ff);
|
228 |
|
|
if (v&0x20)
|
229 |
|
|
printf(" \tPacket BIST continuous mode\n");
|
230 |
|
|
if (v&0x10)
|
231 |
|
|
printf(" \tCD pattern enable for 10Mb\n");
|
232 |
|
|
v = m_fpga->readio(R_MDIO_EDCR);
|
233 |
|
|
printf(" EDCR %04x\tEnergy Detect Control Register\n", v);
|
234 |
|
|
if (v&0x8000)
|
235 |
|
|
printf(" \tEnergy detect mode enabled\n");
|
236 |
|
|
if (v&0x4000)
|
237 |
|
|
printf(" \tEnergy detect power up\n");
|
238 |
|
|
if (v&0x2000)
|
239 |
|
|
printf(" \tEnergy detect power down\n");
|
240 |
|
|
if (v&0x1000)
|
241 |
|
|
printf(" \tEnergy detect manual power up/down\n");
|
242 |
|
|
if (v&0x0800)
|
243 |
|
|
printf(" \tDisable bursting of energy detection bursts\n");
|
244 |
|
|
if (v&0x0400)
|
245 |
|
|
printf(" \tED Power state\n");
|
246 |
|
|
if (v&0x0200)
|
247 |
|
|
printf(" \tEnergy detect err threshold met\n");
|
248 |
|
|
if (v&0x0100)
|
249 |
|
|
printf(" \tEnergy detect data threshold met\n");
|
250 |
|
|
printf(" %04x\tEnergy detect err threshold\n", (v>>4)&15);
|
251 |
|
|
printf(" %04x\tEnergy detect data threshold\n", (v)&15);
|
252 |
|
|
|
253 |
|
|
delete m_fpga;
|
254 |
|
|
}
|
255 |
|
|
|