OpenCores
URL https://opencores.org/ocsvn/openarty/openarty/trunk

Subversion Repositories openarty

[/] [openarty/] [trunk/] [sw/] [host/] [netsetup.cpp] - Blame information for rev 60

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
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 51 dgisselq
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
16 30 dgisselq
//
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 51 dgisselq
// with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
29 30 dgisselq
// 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
        FPGAOPEN(m_fpga);
63
 
64
        signal(SIGSTOP, closeup);
65
        signal(SIGHUP, closeup);
66
 
67
        if ((argc < 1)||(argc > 2)) {
68
                // usage();
69
                printf("USAGE: netsetup\n");
70
                exit(-1);
71
        }
72
 
73
        unsigned        v;
74
        v = m_fpga->readio(R_MDIO_BMCR);
75
        printf("    BMCR    %04x\tBasic Mode Control Register\n", v);
76
        if (v & 0x08000)
77
                printf("                \tReset in progress\n");
78
        if (v & 0x04000)
79
                printf("                \tLoopback enabled\n");
80
        if (v & 0x01000)
81
                printf("                \tAuto-negotiation enabled\n");
82
        else if (v & 0x02000)
83
                printf("                \t100Mb/s -- manual selection\n");
84
        else
85
                printf("                \t 10Mb/s -- manual selection\n");
86
        if (v & 0x00800)
87
                printf("                \tPHY is powered down\n");
88
        if (v & 0x00400)
89
                printf("                \tPort is isolated from MII\n");
90
        if (v & 0x00200)
91
                printf("                \tRestart-auto-negotiation\n");
92
        if ((v& 0x00100)==0)
93
                printf("                \tHalf-duplex mode\n");
94
        if (v & 0x00080)
95
                printf("                \tCollision test enabled\n");
96
        v = m_fpga->readio(R_MDIO_BMSR);
97
        printf("R/O BMSR    %04x\tBasic Mode Status Register\n", v);
98
        if (v & 0x08000)
99
                printf("                \t100Base-T4 capable\n");
100
        if (v & 0x04000)
101
                printf("                \t100Base-TX Full Duplex capable\n");
102
        if (v & 0x02000)
103
                printf("                \t100Base-TX Half Duplex capable\n");
104
        if (v & 0x01000)
105
                printf("                \t 10Base-TX Full Duplex capable\n");
106
        if (v & 0x00800)
107
                printf("                \t 10Base-TX Half Duplex capable\n");
108
        if (v & 0x00040)
109
                printf("                \tPreamble suppression capable\n");
110
        if (v & 0x00020)
111
                printf("                \tAuto-negotiation complete\n");
112
        if (v & 0x00010)
113
                printf("                \tRemote fault detected\n");
114
        if (v & 0x00008)
115
                printf("                \tDevice is capable of auto-negotiation\n");
116
        if (v & 0x00004)
117
                printf("                \tLink is up\n");
118
        if (v & 0x00002)
119
                printf("                \tJabber condition detected (10Mb/s mode)\n");
120
        if (v & 0x00001)
121
                printf("                \tExtended register capabilities\n");
122
        v = m_fpga->readio(R_MDIO_PHYIDR1);
123
        printf("R/O PHYID1  %04x\tPHY Identifier Reg #1\n", v);
124
        //printf("            %4x\tOUI MSB\n", v);
125
        v = m_fpga->readio(R_MDIO_PHYIDR2);
126
        printf("R/O PHYID2  %04x\tPHY Identifier Reg #2\n", v);
127
        printf("            %4x\tOUI LSBs\n", (v>>10)&0x3f);
128
        printf("            %4x\tVendor model number\n",   (v>>4)&0x3f);
129
        printf("            %4x\tModel revision number\n", v&0x0f);
130
        v = m_fpga->readio(R_MDIO_ANAR);
131
        printf("    ANAR    %04x\tAuto-negotiation advertisement register\n", v);
132
        v = m_fpga->readio(R_MDIO_ANLPAR);
133
        printf("    ANLPAR  %04x\tAuto-negotiation link partner ability\n", v);
134
        v = m_fpga->readio(R_MDIO_ANER);
135
        printf("    ANER    %04x\tAuto-negotiation expansion register\n", v);
136
        v = m_fpga->readio(R_MDIO_ANNPTR);
137
        printf("    ANNPTR  %04x\tAuto-negotiation Next page TX\n", v);
138
        v = m_fpga->readio(R_MDIO_PHYSTS);
139
        printf("R/O PHYSTS  %04x\tPHY status register\n", v);
140
        if (v&0x4000)
141
                printf("                \tMDI pairs swapped\n");
142
        if (v&0x2000)
143
                printf("                \tReceive error event since last read of RXERCNT\n");
144
        if (v&0x1000)
145
                printf("                \tInverted polarity detected\n");
146
        if (v&0x800)
147
                printf("                \tFalse carrier sense latch\n");
148
        if (v&0x400)
149
                printf("                \tUnconditional signal detection from PMD\n");
150
        if (v&0x200)
151
                printf("                \tDescrambler lock from PMD\n");
152
        if (v&0x100)
153
                printf("                \tNew link codeword page has been received\n");
154
        if (v&0x40)
155
                printf("                \tRemote fault condition detected\n");
156
        if (v&0x20)
157
                printf("                \tJabber condition detected\n");
158
        if (v&0x10)
159
                printf("                \tAuto-negotiation complete\n");
160
        if (v&0x08)
161
                printf("                \tLoopback enabled\n");
162
        if (v&0x04)
163
                printf("                \tFull duplex mode\n");
164
        printf("             %3d\tSpeed from autonegotiation\n", (v&2)?10:100);
165
        if ((v&0x01)==0)
166
                printf("                \tNo link established\n");
167
        v = m_fpga->readio(R_MDIO_FCSCR);
168
        printf("    FCSCR   %04x\tFalse Carrier Sense Counter Register\n", v);
169
        v = m_fpga->readio(R_MDIO_RECR);
170
        printf("    RECR    %04x\tReceive Error Counter Register\n", v);
171
        v = m_fpga->readio(R_MDIO_PCSR);
172
        printf("    PCSR    %04x\tPCB Sub-Layer Configuration and Status Register\n", v);
173
        if (v&0x400)
174
                printf("                \tTrue Quiet (TQ) mode enabled\n");
175
        if (v&0x200)
176
                printf("                \tSignal detecttion forced in PMA\n");
177
        if (v&0x100)
178
                printf("                \tEnhanced signal detetion algorithm\n");
179
        if (v&0x80)
180
                printf("                \tDescrambler timeout = 2ms (for large packets)\n");
181
        if (v&0x20)
182
                printf("                \tForce 100Mb/s good link\n");
183
        if (v&0x4)
184
                printf("                \tNRZI bypass enabled\n");
185
        v = m_fpga->readio(R_MDIO_RBR);
186
        printf("    RBR     %04x\tRMII and Bypass Register\n", v);
187
        if (v&0x20)
188
                printf("                \tRMII mode enabled\n");
189
        v = m_fpga->readio(R_MDIO_LEDCR);
190
        printf("    LEDCR   %04x\tLED Direct Control Register\n", v);
191
        if (v&0x20)
192
                printf("             %s\tLED_SPEED LED\n", (v&0x4)?"ON ":"OFF");
193
        if (v&0x10)
194
                printf("             %s\tLED_LINK  LED\n", (v&0x2)?"ON ":"OFF");
195
 
196
        v = m_fpga->readio(R_MDIO_PHYCR);
197
        printf("    PHYCR   %04x\tPHY control register\n", v);
198
        if (v&0x8000)
199
                printf("                \tAuto-neg auto-MDIX enabled\n");
200
        if (v&0x4000)
201
                printf("                \tForce MDI pairs to cross\n");
202
        if (v&0x2000)
203
                printf("                \tPause receive negotiation\n");
204
        if (v&0x1000)
205
                printf("                \tPause transmit negotiation\n");
206
        if (v&0x0800)
207
                printf("                \tForce BIST error\n");
208
        if (v&0x0400)
209
                printf("                \tPSR15 BIST sequence selected\n");
210
        if (v&0x0200)
211
                printf("                \tBIST test passed\n");
212
        if (v&0x0100)
213
                printf("                \tBIST start\n");
214
        if (v&0x0080)
215
                printf("                \tBypass LED stretching\n");
216
        if ((v&0x0020)==0)
217
                printf("                \tDon\'t blink LED\'s on activity\n");
218
        if (v&0x001f)
219
                printf("            %4x\tPHY Addr\n", v & 0x01f);
220
        v = m_fpga->readio(R_MDIO_BTSCR);
221
        printf("    BTSCR   %04x\t10-Base T Status/Control Register\n", v);
222
        v = m_fpga->readio(R_MDIO_CDCTRL);
223
        printf("    CDCTRL  %04x\tCD Test Control Register, BIST Extension Register\n", v);
224
        if (v&0xff00)
225
                printf("            %04x\tBIST error counter\n", (v>>8)&0x0ff);
226
        if (v&0x20)
227
                printf("                \tPacket BIST continuous mode\n");
228
        if (v&0x10)
229
                printf("                \tCD pattern enable for 10Mb\n");
230
        v = m_fpga->readio(R_MDIO_EDCR);
231
        printf("    EDCR    %04x\tEnergy Detect Control Register\n", v);
232
        if (v&0x8000)
233
                printf("                \tEnergy detect mode enabled\n");
234
        if (v&0x4000)
235
                printf("                \tEnergy detect power up\n");
236
        if (v&0x2000)
237
                printf("                \tEnergy detect power down\n");
238
        if (v&0x1000)
239
                printf("                \tEnergy detect manual power up/down\n");
240
        if (v&0x0800)
241
                printf("                \tDisable bursting of energy detection bursts\n");
242
        if (v&0x0400)
243
                printf("                \tED Power state\n");
244
        if (v&0x0200)
245
                printf("                \tEnergy detect err threshold met\n");
246
        if (v&0x0100)
247
                printf("                \tEnergy detect data threshold met\n");
248
        printf("            %04x\tEnergy detect err  threshold\n", (v>>4)&15);
249
        printf("            %04x\tEnergy detect data threshold\n", (v)&15);
250
 
251
        delete  m_fpga;
252
}
253
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.