~ubuntu-branches/ubuntu/warty/nictools-pci/warty

« back to all changes in this revision

Viewing changes to vortex-diag.c

  • Committer: Bazaar Package Importer
  • Author(s): Alain Schroeder
  • Date: 2003-06-07 15:49:19 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20030607154919-94glbk5i7db18ve3
Tags: 1.3.6-1
* New Upstream
  * libmii v2.10
    * New chip-ids added
    * Better support for TDK, VIA and Intel chips
  * libflash v2.06
    * Include <sys/io.h> instead of <asm/io.h> on newer glibc to fix
      compile problem on alpha. (Closes: #183512)
  * alta-diag v2.03
    * added online help.
  * eepro100 v2.12
    * more cards known
    * some dokumentation changes
  * myson-diag v1.07
    * added online help
  * natsemi-diag v2.07
    * more error checking
    * support emergency eeprom rewrite
  * ns820-diag v2.04
    * added online help
    * more error checking
  * rtl8139-diag v2.11
    * added online help
    * now more informative
  * tulip-diag v2.17
    * added online help
    * more known cards and flags
  * via-diag v2.09
    * knows about more cards
    * added online help
    * more detailed information
  * vortex-diag v2.14
    * added online help
    * more detailed information
  * winbond-diag v2.01
    * added online help
* Fix compile problems with gcc-3.3 by rewriting multiline
  strings. (Closes: #194996)
* Incorporate all changes from Petter Reinholdtsen <pere@gigs.hungry.com>
  nicely prepared NMU, which never made it out of the delay queue.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
   based on the 3Com Vortex, Boomerang and Cyclone chips, as used on the
5
5
   3Com 3c590/595/900/905 PCI EtherLink XL adapters.
6
6
 
7
 
   Copyright 1997-2001 by Donald Becker.
 
7
        Copyright 1997-2003 by Donald Becker.
8
8
        This software may be used and distributed according to the terms of
9
9
        the GNU General Public License (GPL), incorporated herein by reference.
10
10
        Contact the author for use under other terms.
17
17
         410 Severn Ave., Suite 210
18
18
         Annapolis MD 21403
19
19
 
20
 
        Support and updates available at
21
 
         http://www.scyld.com/diag/index.html
 
20
        Updates and additional information are available at
 
21
        http://www.scyld.com/diag/index.html
 
22
        http://scyld.com/expert/mii-status.html
 
23
        http://scyld.com/expert/NWay.html
 
24
 
 
25
        Common-sense licensing statement: Using any portion of this program in
 
26
        your own program means that you must give credit to the original author
 
27
        and release the resulting code under the GPL.  To use this code under
 
28
        other terms requires an explicit license from the copyright holder.
22
29
 
23
30
        References
24
31
         3Com Vortex Engineering Release Specification
25
32
         3Com Boomerang modifications (unreleased)
26
 
         http://scyld.com/expert/mii-status.html
27
 
         http://scyld.com/expert/NWay.html
28
 
     http://www.national.com/pf/DP/DP83840.html
 
33
         http://www.national.com/pf/DP/DP83840.html
29
34
*/
30
35
 
31
36
static char *version_msg =
32
 
"vortex-diag.c:v2.05 5/15/2001 Donald Becker (becker@scyld.com)\n"
 
37
"vortex-diag.c:v2.14 12/28/2002 Donald Becker (becker@scyld.com)\n"
33
38
" http://www.scyld.com/diag/index.html\n";
34
39
static char *usage_msg =
35
 
"Usage: vortex-diag [-aDeEfFgGmpPqrRtvVwW] [-p <IOport>] [-[AF] <media>]\n"
 
40
"Usage: vortex-diag [-aDEefFgGhmPqrRtvVwW] [-p <IOport>] [-[AF] <media>]\n"
36
41
"  For details and other options see http://www.scyld.com/diag/index.html\n";
37
42
 
 
43
static const char long_usage_msg[] =
 
44
"Usage: %s [-aDfrRvVw] [-AF <speed+duplex>] [-#<BoardNum>]\n"
 
45
"\n"
 
46
"   Show the internal state of a network adapter.\n"
 
47
"\n"
 
48
"   The common usage is\n"
 
49
"      vortex-diag -aem\n"
 
50
"\n"
 
51
" Frequently used options are\n"
 
52
"   -a  --show_all_registers    Print all registers.\n"
 
53
"   -e  --show-eeprom   Dump EEPROM contents, \"-ee\" shows the details.\n"
 
54
"   -m  --show_mii              Print the MII transceiver state\n"
 
55
"                                       Using -mm monitors the link.\n"
 
56
"   -f  --force         Perform operation, even on a running NIC.\n"
 
57
"\n"
 
58
" To operate on a single NIC, or one that hasn't been automatically found:\n"
 
59
"   -#  --card_num      INDEX   Operate on the specified card index.\n"
 
60
"   -p  --port-base     IOADDR  Assume an adapter at the specified I/O address.\n"
 
61
"   -t  --chip-type     TYPE    Specify adapter type with '-p', use '-1' to list.\n"
 
62
"\n"
 
63
" To change the persistent EEPROM settings\n"
 
64
"   -G  --parameters PARMS      Set adapter-specific parameters.\n"
 
65
"   -H  --new-hwaddr 01:23:45:67:ab:cd\n"
 
66
"        Set a new hardware station address.  Read the documentation first!\n"
 
67
"   -w  --write-EEPROM   Actually write the new settings into the EEPROM.\n"
 
68
" To read and write the boot BIOS extension Flash ROM\n"
 
69
"   -B       Show the first few bytes of the ROM\n"
 
70
"   -L FILE  Load the Flash from FILE.\n"
 
71
"   -S FILE  Store the Flash image to FILE.\n"
 
72
"\n"
 
73
"   -D  --debug\n"
 
74
"   -v  --verbose       Report each action taken.\n"
 
75
"   -V  --version       Emit version information.\n"
 
76
"\n"
 
77
"   -A  --advertise <speed|setting>  (See the mii-diag manual page.)\n"
 
78
"\n";
 
79
 
38
80
#if ! defined(__OPTIMIZE__)
39
81
#warning  You must compile this program with the correct options!
40
82
#warning  See the last lines of the source file.
47
89
#include <getopt.h>
48
90
#include <string.h>
49
91
#include <errno.h>
 
92
#include <sys/types.h>
 
93
#include <ctype.h>
50
94
#if defined(__linux__)  &&  __GNU_LIBRARY__ == 1
51
95
#include <asm/io.h>                     /* Newer libraries use <sys/io.h> instead. */
52
96
#else
53
97
#include <sys/io.h>
54
98
#endif
55
99
 
56
 
/* No libmii.h or libflash.h yet. */
 
100
/* No libmii.h or libflash.h yet, thus the declarations here. */
57
101
extern int show_mii_details(long ioaddr, int phy_id);
58
102
extern int monitor_mii(long ioaddr, int phy_id);
59
103
 
64
108
extern void (*flash_out_hook)(long addr, int offset, int val);
65
109
 
66
110
/* We should use __u8 .. __u32, but they are not always defined. */
67
 
typedef unsigned int u32;
68
 
typedef unsigned short u16;
69
 
typedef unsigned char u8;
 
111
typedef u_int32_t u32;
 
112
typedef u_int16_t u16;
 
113
typedef u_int8_t u8;
70
114
 
71
115
struct option longopts[] = {
72
116
 /* { name  has_arg  *flag  val } */
 
117
        {"card-num", 1, 0, '#'},                /* Operate on the specified card index. */
73
118
        {"Advertise", 1, 0, 'A'},
74
119
        {"base-address", 1, 0, 'p'},
75
120
        {"show_all_registers",  0, 0, 'a'},     /* Print all registers. */
76
 
        {"help",        0, 0, 'h'},     /* Give help */
77
 
        {"show-eeprom",  0, 0, 'e'}, /* Dump EEPROM contents (-ee valid). */
 
121
        {"help",        0, 0, 'h'},                     /* Print a long usage message. */
 
122
        {"show-eeprom",  0, 0, 'e'},    /* Dump EEPROM contents (-ee valid). */
78
123
        {"emergency-rewrite",  0, 0, 'E'}, /* Re-write a corrupted EEPROM.  */
79
124
        {"force-detection",  0, 0, 'f'},
80
125
        {"new-interface",  1, 0, 'F'},  /* New interface (built-in, AUI, etc.) */
82
127
        {"show-mii",  0, 0, 'm'},       /* Dump MII management registers. */
83
128
        {"port-base",  1, 0, 'p'},      /* Use the specified I/O address. */
84
129
        {"quiet",       0, 0, 'q'},             /* Decrease verbosity */
85
 
        {"Reset",       0, 0, 'R'},             /* Reset the transceiver. */
 
130
        {"reset",       0, 0, 'R'},             /* Reset the transceiver. */
 
131
        {"restart",     0, 0, 'r'},             /* Restart autonegotiation. */
86
132
        {"chip-type",  1, 0, 't'},      /* Assume the specified chip type index. */
87
133
        {"test",        0, 0, 'T'},             /* Do register and SRAM test. */
88
134
        {"verbose",     0, 0, 'v'},             /* Verbose mode */
94
140
extern int  vortex_diag(int vend_id, int dev_id, long ioaddr, int part_idx);
95
141
 
96
142
/* Chip-specific flags. Yes, it's grungy to have the enum here. */
97
 
enum { HAS_FLASH_BUG=1, ROADRUNNER=2 };
 
143
enum { HAS_FLASH_BUG=1, ROADRUNNER=2, IS_CYCLONE=4 };
98
144
 
99
 
/* This table is searched in order: place specific entries followed by
 
145
/* The table of known chips.
 
146
   Because of the bogus /proc/pci interface we must have both the exact
 
147
   name from the kernel, a common name and the PCI vendor/device IDs.
 
148
   This table is searched in order: place specific entries followed by
100
149
   'catch-all' general entries. */
101
150
struct pcidev_entry {
102
151
        const char *part_name;
109
158
        {"3Com Generic Vortex/Boomerag/Cyclone", 0,
110
159
         0x10B7, 0x9999, 0xffff, 0, 256, vortex_diag},
111
160
        {"3Com 3c590 Vortex 10Mbps", "3Com Vortex (rev ",
112
 
         0x10B7, 0x5900, 0xffff, 0, 256, vortex_diag},
 
161
         0x10B7, 0x5900, 0xffff, 0, 32, vortex_diag},
113
162
        {"3c592 EISA 10mbps Demon/Vortex", 0,
114
 
         0x10B7, 0x5920, 0xffff, 0, 256, vortex_diag},
 
163
         0x10B7, 0x5920, 0xffff, 0, 32, vortex_diag},
115
164
        {"3Com 3c595 Vortex 10/100baseTx", "3Com Vortex (rev ",
116
 
         0x10B7, 0x5950, 0xffff, 0, 256, vortex_diag},
 
165
         0x10B7, 0x5950, 0xffff, 0, 32, vortex_diag},
117
166
        {"3Com 3c595 Vortex 10/100baseT4", 0,
118
 
         0x10B7, 0x5951, 0xffff, 0, 256, vortex_diag},
 
167
         0x10B7, 0x5951, 0xffff, 0, 32, vortex_diag},
119
168
        {"3Com 3c595 Vortex 10/100baseT-MII", 0,
120
 
         0x10B7, 0x5952, 0xffff, 0, 256, vortex_diag},
 
169
         0x10B7, 0x5952, 0xffff, 0, 32, vortex_diag},
121
170
        {"3c597 EISA Fast Demon/Vortex", 0,
122
 
         0x10B7, 0x5970, 0xffff, 0, 256, vortex_diag},
 
171
         0x10B7, 0x5970, 0xffff, 0, 32, vortex_diag},
123
172
        {"3c900 Boomerang 10baseT", "3Com 3C900",
124
 
         0x10B7, 0x9000, 0xffff, 0, 256, vortex_diag},
 
173
         0x10B7, 0x9000, 0xffff, 0, 64, vortex_diag},
125
174
        {"3c900 Boomerang 10Mbps Combo", 0,
126
 
         0x10B7, 0x9001, 0xffff, 0, 256, vortex_diag},
 
175
         0x10B7, 0x9001, 0xffff, 0, 64, vortex_diag},
127
176
        {"3c900 Cyclone 10Mbps TPO", 0,
128
 
         0x10B7, 0x9004, 0xffff, 0, 256, vortex_diag},
 
177
         0x10B7, 0x9004, 0xffff, IS_CYCLONE, 256, vortex_diag},
129
178
        {"3c900 Cyclone 10Mbps Combo", 0,
130
 
         0x10B7, 0x9005, 0xffff, 0, 256, vortex_diag},
 
179
         0x10B7, 0x9005, 0xffff, IS_CYCLONE, 256, vortex_diag},
131
180
        {"3c900 Cyclone 10Mbps TPC", 0,
132
 
         0x10B7, 0x9006, 0xffff, 0, 256, vortex_diag},
 
181
         0x10B7, 0x9006, 0xffff, IS_CYCLONE, 256, vortex_diag},
133
182
        {"3c905 Boomerang 100baseTx", "3Com 3C905",
134
 
         0x10B7, 0x9050, 0xffff, 0, 256, vortex_diag},
 
183
         0x10B7, 0x9050, 0xffff, 0, 64, vortex_diag},
135
184
        {"3c905 Boomerang 100baseT4", 0,
136
 
         0x10B7, 0x9051, 0xffff, 0, 256, vortex_diag},
 
185
         0x10B7, 0x9051, 0xffff, 0, 64, vortex_diag},
137
186
        {"3c905B Cyclone 100baseTx", 0,
138
 
         0x10B7, 0x9055, 0xffff, HAS_FLASH_BUG, 256, vortex_diag},
 
187
         0x10B7, 0x9055, 0xffff, HAS_FLASH_BUG | IS_CYCLONE, 256, vortex_diag},
139
188
        {"3c905B Cyclone 10/100/BNC", "3Com 3C905BNC",
140
 
         0x10B7, 0x9058, 0xffff, HAS_FLASH_BUG, 256, vortex_diag},
 
189
         0x10B7, 0x9058, 0xffff, HAS_FLASH_BUG | IS_CYCLONE, 256, vortex_diag},
141
190
        {"3c905B Cyclone 100baseFx", "3Com 3C905B-FX",
142
 
         0x10B7, 0x905A, 0xffff, HAS_FLASH_BUG, 256, vortex_diag},
 
191
         0x10B7, 0x905A, 0xffff, HAS_FLASH_BUG | IS_CYCLONE, 256, vortex_diag},
143
192
        {"3c905C Tornado 100baseTx", 0,
144
 
         0x10B7, 0x9200, 0xff00, HAS_FLASH_BUG, 256, vortex_diag},
 
193
         0x10B7, 0x9200, 0xff00, HAS_FLASH_BUG | IS_CYCLONE, 256, vortex_diag},
145
194
        {"3c980 Cyclone, server edition", 0,
146
 
         0x10B7, 0x9800, 0xffff, HAS_FLASH_BUG, 256, vortex_diag},
 
195
         0x10B7, 0x9800, 0xffff, HAS_FLASH_BUG | IS_CYCLONE, 256, vortex_diag},
147
196
        {"3c982 Dual Port server NIC", 0,
148
 
         0x10B7, 0x9805, 0xffff, HAS_FLASH_BUG, 256, vortex_diag},
 
197
         0x10B7, 0x9805, 0xffff, HAS_FLASH_BUG | IS_CYCLONE, 256, vortex_diag},
149
198
        {"3c980 series, server edition", 0,
150
 
         0x10B7, 0x9800, 0xfff0, HAS_FLASH_BUG, 256, vortex_diag},
 
199
         0x10B7, 0x9800, 0xfff0, HAS_FLASH_BUG | IS_CYCLONE, 256, vortex_diag},
151
200
        {"3Com 3cSOHO100-TX", 0,
152
 
         0x10B7, 0x7646, 0xff00, HAS_FLASH_BUG, 256, vortex_diag},
 
201
         0x10B7, 0x7646, 0xff00, HAS_FLASH_BUG | IS_CYCLONE, 256, vortex_diag},
153
202
        {"3c450 HomePNA Cyclone", 0,
154
 
         0x10B7, 0x4500, 0xffff, 0, 256, vortex_diag},
 
203
         0x10B7, 0x4500, 0xffff, IS_CYCLONE, 256, vortex_diag},
155
204
        {"3c555 Laptop Hurricane",      0,
156
205
         0x10B7, 0x5055, 0xffff, HAS_FLASH_BUG, 256, vortex_diag},
157
206
        {"3c556 Laptop Hurricane",      0,
161
210
        {"3Com 3CCFE556", "3ccfe556 Roadrunner PCMCIA",
162
211
         0x10B7, 0x0556, 0xffff, ROADRUNNER, 32, vortex_diag},
163
212
        {"3c575 CardBus", 0,
164
 
         0x10B7, 0x5057, 0xffff, HAS_FLASH_BUG, 32, vortex_diag},
 
213
         0x10B7, 0x5057, 0xffff, HAS_FLASH_BUG | IS_CYCLONE, 32, vortex_diag},
165
214
        {"3CCFE575BT CardBus", 0,
166
 
         0x10B7, 0x5157, 0xffff, HAS_FLASH_BUG, 128, vortex_diag},
 
215
         0x10B7, 0x5157, 0xffff, HAS_FLASH_BUG | IS_CYCLONE, 128, vortex_diag},
167
216
        {"3CCFE575CT CardBus", 0,
168
 
         0x10B7, 0x5257, 0xffff, HAS_FLASH_BUG, 128, vortex_diag},
 
217
         0x10B7, 0x5257, 0xffff, HAS_FLASH_BUG | IS_CYCLONE, 128, vortex_diag},
169
218
        {"3C575 CardBus (unknown version)", 0,
170
219
         0x10B7, 0x5057, 0x0fff, HAS_FLASH_BUG, 32, vortex_diag},
171
220
        {"3ccfe656 Cyclone CardBus", 0,
172
 
         0x10B7, 0x6560, 0xffff, HAS_FLASH_BUG, 256, vortex_diag},
 
221
         0x10B7, 0x6560, 0xffff, HAS_FLASH_BUG | IS_CYCLONE, 256, vortex_diag},
173
222
        {"3Com 3CCFE656B Cyclone+WinModem CardBus", 0,
174
 
         0x10B7, 0x6562, 0xffff, HAS_FLASH_BUG, 256, vortex_diag},
 
223
         0x10B7, 0x6562, 0xffff, HAS_FLASH_BUG | IS_CYCLONE, 256, vortex_diag},
175
224
        {"3Com 3CCFE656C Tornado CardBus", 0,
176
 
         0x10B7, 0x6564, 0xffff, HAS_FLASH_BUG, 256, vortex_diag},
 
225
         0x10B7, 0x6564, 0xffff, HAS_FLASH_BUG | IS_CYCLONE, 256, vortex_diag},
177
226
        {"3Com 3CCFE656 Series", 0,
178
 
         0x10B7, 0x6560, 0xfff0, HAS_FLASH_BUG, 256, vortex_diag},
 
227
         0x10B7, 0x6560, 0xfff0, HAS_FLASH_BUG | IS_CYCLONE, 256, vortex_diag},
 
228
        /* Added most new/unverified entries here. */
179
229
        { 0, 0, 0, 0},
180
230
};
181
231
 
192
242
int new_default_media = -1;
193
243
static unsigned int opt_flash_show = 0;
194
244
static char     *opt_flash_dumpfile = NULL, *opt_flash_loadfile = NULL;
 
245
 
195
246
static unsigned char new_hwaddr[6], set_hwaddr = 0;
196
247
static int emergency_rewrite = 0;
197
248
static unsigned set_ee_rom = 0;
211
262
        int card_num = 0;
212
263
        extern char *optarg;
213
264
 
214
 
        while ((c = getopt_long(argc, argv, "#:aA:DeEfF:gG:mp:PqrRst:vVwWH:BL:S:",
 
265
        while ((c = getopt_long(argc, argv, "#:aA:DeEfF:gG:hH:mp:PqrRt:vVwWBL:S:",
215
266
                                                        longopts, &longind))
216
267
                   != -1)
217
268
                switch (c) {
227
278
                                errflag++;
228
279
                        break;
229
280
                case 'g': opt_dma_diag++;       break;
230
 
                case 'G': opt_G++; opt_GPIO = strtoul(optarg, NULL, 16); break;
 
281
                case 'G': opt_G++; opt_GPIO = strtoul(optarg, NULL, 0); break;
 
282
                case 'h': fprintf(stderr, long_usage_msg, argv[0]); return 0;
231
283
                case 'H':
232
284
                        {
233
285
                                int hwaddr[6], i;
459
511
                "100baseT4", "100baseTx", "100baseTx-FD", "100baseTx-HD",
460
512
                "10baseT", "10baseT-FD", "10baseT-HD", 0,
461
513
        };
 
514
        char *endptr;
462
515
        int cap_map[] = { 0x0200, 0x0180, 0x0100, 0x0080, 0x0060, 0x0040, 0x0020,};
463
516
        int i;
464
517
        if (debug)
466
519
        for (i = 0; mtypes[i]; i++)
467
520
                if (strcasecmp(mtypes[i], capabilities) == 0)
468
521
                        return cap_map[i];
469
 
        if ((i = strtoul(capabilities, NULL, 16)) <= 0xffff)
 
522
        i = strtoul(capabilities, &endptr, 16);
 
523
        if (*endptr == 0  &&  0 < i  &&  i <= 0xffff)
470
524
                return i;
471
525
        fprintf(stderr, "Invalid media advertisement '%s'.\n", capabilities);
472
526
        return 0;
476
530
   0x0800       Power up autosense (check speed only once)
477
531
   0x8000       Dynamic Autosense
478
532
*/
479
 
/* A table of media names to indices.  This matches the Digital Tulip
480
 
   SROM numbering, primarily because that is the most complete list.
481
 
   Other chips will have to map these number to their internal values.
 
533
/* A table of media names to EEPROM setting.
 
534
   These match the 3Com internal values.
482
535
*/
483
 
struct { char *name; int value; } mediamap[] = {
484
 
        { "10baseT", 0 },
485
 
        { "10base2", 1 },
486
 
        { "AUI", 2 },
487
 
        { "100baseTx", 3 },
488
 
        { "10baseT-FDX", 0x204 },
489
 
        { "100baseTx-FDX", 0x205 },
490
 
        { "100baseT4", 6 },
491
 
        { "100baseFx", 7 },
492
 
        { "100baseFx-FDX", 8 },
493
 
        { "MII", 11 },
494
 
        { "Autosense", 0x0800 },
 
536
struct { int value; char *name; } mediamap[] = {
 
537
        { 0, "10baseT-serial"},
 
538
        { 1, "10Mbps-AUI"},
 
539
        { 3, "10base2"},
 
540
        { 5, "100baseFx"},
 
541
        { 6, "MII/100baseT4"},
 
542
        { 8, "Autonegotiation"},
495
543
        { 0, 0 },
496
544
};
497
545
 
498
546
static int get_media_index(const char *name)
499
547
{
 
548
        char *endptr;
500
549
        int i;
 
550
 
 
551
        if (! name)
 
552
                return -1;
501
553
        for (i = 0; mediamap[i].name; i++)
502
554
                if (strcasecmp(name, mediamap[i].name) == 0)
503
555
                        return i;
504
 
        if (name  &&  atoi(name) >= 00)
505
 
                return atoi(name);
506
 
        fprintf(stderr, "Invalid interface specified: it must be one of\n  ");
 
556
        i = strtol(name, &endptr, 0);
 
557
        if (*endptr == 0)
 
558
                return i;
 
559
        fprintf(stderr, "Invalid interface specified.  It must be one of\n");
507
560
        for (i = 0; mediamap[i].name; i++)
508
 
                fprintf(stderr, "  %s", mediamap[i].name);
509
 
        fprintf(stderr, ".\n");
 
561
                fprintf(stderr, "  %d %s\n", mediamap[i].value, mediamap[i].name);
510
562
        return -1;
511
563
}
512
564
 
514
566
/* Chip-specific section. */
515
567
 
516
568
/* The 3Com Vortex/Boomerang/Cyclone designs. */
517
 
static int read_eeprom(long ioaddr, int addrsize, int location);
518
 
static void write_eeprom(long ioaddr, int addrsize, int index, int value);
519
 
static int do_update(long ioaddr, int addrlen, 
520
 
                                         unsigned short *ee_values, unsigned short *old_ee_values);
 
569
static void interpret_eeprom(long ioaddr);
521
570
static void mdio_sync(long ioaddr);
522
571
int mdio_read(long ioaddr, int phy_id, int location);
523
572
void mdio_write(long ioaddr, int phy_id, int location, int value);
524
573
 
525
 
static void parse_eeprom(unsigned short *ee_data);
526
574
static void show_dma_state(long ioaddr);
527
575
int vortex_flash_in(long addr, int offset);
528
576
void vortex_flash_out(long addr, int offset, int val);
540
588
        SetStatusEnb = 15<<11, SetRxFilter = 16<<11, SetRxThreshold = 17<<11,
541
589
        SetTxThreshold = 18<<11, SetTxStart = 19<<11,
542
590
        StartDMAUp = 20<<11, StartDMADown = (20<<11)+1, StatsEnable = 21<<11,
543
 
        StatsDisable = 22<<11, StopCoax = 23<<11,};
 
591
        StatsDisable = 22<<11, StopCoax = 23<<11, SetFilterBit = 25<<11,
 
592
};
544
593
 
545
594
/* Bits in the general status register. */
546
595
enum vortex_status {
561
610
enum Window0 {
562
611
        Wn0EepromCmd = 10,              /* Window 0: EEPROM command register. */
563
612
        Wn0EepromData = 12,             /* Window 0: EEPROM results register. */
564
 
        IntrStatus=0x0E,                        /* Valid in all windows. */
 
613
        IntrStatus=0x0E,                /* Valid in all windows. */
565
614
};
566
615
#define MAX_EEPROM_SIZE 256
567
616
/* In undocumented bogusness, these value depend on the EEPROM size. */
580
629
enum Window4 {          /* Window 4: Xcvr/media bits. */
581
630
        Wn4_FIFODiag = 4, Wn4_NetDiag = 6, Wn4_PhysicalMgmt=8, Wn4_Media = 10,
582
631
};
 
632
enum Window5 {
 
633
        Wn5_TxThreshold = 0, Wn5_RxFilter = 8,
 
634
};
 
635
 
583
636
/* Media names in Wn3_Config bits 24:20. */
584
637
const char *el_medianames[16] ={
585
638
        "10baseT", "10Mbs AUI", "undefined", "10base2",
587
640
        "Autonegotiate", "MII-External", "undefined-10", "undefined-11",
588
641
        "undefined-12", "undefined-13", "undefined-14", "undefined-15",
589
642
};
 
643
/* Media available in Wn3_Options and EEPROM. */
 
644
const char *medias[] = {
 
645
        "100baseT4", "100baseTx", "100baseFx", "10baseT",
 
646
        "10base2", "AUI", "MII", "",   "10baseFL"
 
647
};
 
648
 
 
649
struct config_name { int val, mask; const char*name;}
 
650
/* Bits in Wn5_RxFilter. */
 
651
static rcvr_mode[] = {
 
652
        {0x05, 0x1f, "Normal unicast"},
 
653
        {0x15, 0x1f, "Normal unicast and hashed multicast"},
 
654
        {0x07, 0x0f, "Normal unicast and all multicast"},
 
655
        {0x08, 0x08, "Promiscuous"},
 
656
        {0x00, 0x00, "Unknown/invalid"},
 
657
};
 
658
 
590
659
 
591
660
/* Values read from the EEPROM, and the new image. */
592
661
unsigned short eeprom_contents[MAX_EEPROM_SIZE];
596
665
{
597
666
        int chip_active = 0;
598
667
        int saved_window = inw(ioaddr + EL3_CMD) >> 13;
599
 
        int internal_config;
600
 
        int eeaddrlen, eesize, ee_tbl_offset = 0;
 
668
        int flags = pcidev_tbl[part_idx].flags;
 
669
        int internal_config, rx_mode;
601
670
        int i;
602
671
 
603
672
        /* It's mostly safe to examine the registers and EEPROM during
607
676
                chip_active = 1;
608
677
#endif
609
678
 
 
679
        EL3WINDOW(2);
 
680
        printf(" Station address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x.\n",
 
681
                   inb(ioaddr + 0), inb(ioaddr + 1), inb(ioaddr + 2),
 
682
                   inb(ioaddr + 3), inb(ioaddr + 4), inb(ioaddr + 5));
 
683
        EL3WINDOW(5);
 
684
        rx_mode = inb(ioaddr + Wn5_RxFilter);
 
685
        for (i = 0; rcvr_mode[i].mask; i++)
 
686
                if ((rx_mode & rcvr_mode[i].mask) == rcvr_mode[i].val) break;
 
687
        printf("  Receive mode is 0x%2.2x: %s.\n", rx_mode, rcvr_mode[i].name);
 
688
 
610
689
        if (opt_a) {
611
690
                int io_size = pcidev_tbl[part_idx].io_size;
612
691
                int j;
632
711
                        printf(".\n");
633
712
                }
634
713
                printf("Vortex chip registers at %#lx", ioaddr);
635
 
                for (i = 0x10;
636
 
                         i < (io_size > 0x40 ? 0x40 : io_size);
637
 
                         i += 4) {
 
714
                if (io_size > 0x80) io_size = 0x80;
 
715
                for (i = 0x10; i < io_size; i += 4) {
638
716
                        if ((i & 0x0f) == 0)
639
717
                                printf("\n  0x%3.3lX:", ioaddr + i);
640
718
                        if (! opt_f) {
643
721
                                else if (i == 0x1c)
644
722
                                        printf(" *STATUS*");
645
723
                                else
646
 
                                        printf(" %8.8x", inl(ioaddr + i));
 
724
                                        printf(" %8.8x", (int)inl(ioaddr + i));
647
725
                        } else
648
 
                                printf(" %8.8x", inl(ioaddr + i));
 
726
                                printf(" %8.8x", (int)inl(ioaddr + i));
649
727
                }
650
728
                printf("\n");
651
 
        }
652
 
        if (opt_dma_diag)
653
 
                show_dma_state(ioaddr);
 
729
                if (opt_dma_diag || (flags & IS_CYCLONE))
 
730
                        show_dma_state(ioaddr);
 
731
        }
 
732
        if (opt_G) {
 
733
#if defined(OPTG_MULTICAST)
 
734
                printf("Setting filter bit, %4.4x.\n", SetFilterBit|0x0400|opt_GPIO);
 
735
                outw(SetRxFilter | 0x15, ioaddr + EL3_CMD);
 
736
                for (i = 0; i < 255; i++)
 
737
                        outw(SetFilterBit|0x0000|i, ioaddr + EL3_CMD);
 
738
                outw(SetFilterBit|0x0400|opt_GPIO, ioaddr + EL3_CMD);
 
739
#elif defined(OPTG_RXTHRESH)
 
740
                printf("Setting the Rx Priority Thrshold to %d bytes.\n",
 
741
                           opt_GPIO);
 
742
                outb((opt_GPIO + 0x1f)>>5, ioaddr + 0x3C);
 
743
                printf("Setting the Rx Priority Thrshold to %d bytes.\n",
 
744
                           inb(ioaddr + 0x3C)<<5);
 
745
#else
 
746
                EL3WINDOW(2);
 
747
                outw(opt_GPIO, ioaddr + Wn2_ResetOptions);
 
748
#endif
 
749
        }
654
750
        EL3WINDOW(3);
655
751
        internal_config = inl(ioaddr + Wn3_Config);
656
752
        if (verbose > 1 || opt_a) {
666
762
                                        printf("   %s indication.\n", intr_names[i]);
667
763
                }
668
764
                {
669
 
                        const char *medias[] = {"100baseT4", "100baseTx", "100baseFx",
670
 
                        "10baseT", "10base2", "AUI", "MII", "", "10baseFL"};
671
765
                        int MediaOptions, MacCtrl;
672
766
                        EL3WINDOW(3);
673
767
                        MediaOptions = inw(ioaddr + Wn3_Options);
675
769
                        for (i = 0; i < 8; i++)
676
770
                                if (MediaOptions & 1<<i)
677
771
                                        printf(" %s", medias[i]);
678
 
                        printf("%s.\n", (MediaOptions&0xE010)==0x0010 ? "10baseFL" : "");
 
772
                        printf("%s.\n", (MediaOptions&0xE100)==0x0100 ? " 10baseFL" : "");
679
773
                        printf("Transceiver type in use:  %s.\n",
680
774
                                   el_medianames[(internal_config >> 20) & 15]);
681
775
                        MacCtrl = inw(ioaddr + Wn3_MAC_Ctrl);
696
790
                printf(" Configuration options %4.4x.\n",
697
791
                           inw(ioaddr + Wn2_ResetOptions));
698
792
        }
699
 
        /* Read the EEPROM. */
700
 
        EL3WINDOW(0);
701
 
 
702
 
        outw(0x5555, ioaddr + Wn0EepromData);
703
 
        if (read_eeprom(ioaddr, 6, 0) != 0x5555) {
704
 
                if (debug)
705
 
                        printf(" EEPROM Address length is 6 bits (%4.4x).\n",
706
 
                                   read_eeprom(ioaddr, 6, 0));
707
 
                eeaddrlen = 6;
708
 
        } else {
709
 
                int val = read_eeprom(ioaddr, 6, 0);
710
 
                int e6 = read_eeprom(ioaddr, 6, 0);
711
 
                int e8 = read_eeprom(ioaddr, 8, 0);
712
 
                if (debug)
713
 
                        printf(" EEPROM address sizing read returned %4.4x/%4.4x/%4.4x.\n",
714
 
                                   e6, e8, val);
715
 
                eeaddrlen = (e6 != 0xffff) ? 8 : 6;
716
 
        }
717
 
        eesize = 1 << eeaddrlen;
718
 
 
719
 
        if (debug)
720
 
                printf(" EEPROM address size is %d bits.\n", eeaddrlen);
721
 
        for (i = 0; i < eesize; i++)
722
 
                eeprom_contents[i] = read_eeprom(ioaddr, eeaddrlen, i);
723
 
 
724
 
        if (eeprom_contents[0x37] == 0x6d50) {
725
 
                ee_tbl_offset = 0x30;
726
 
        } else if (eeprom_contents[0] == 0x10b7  ||  eeprom_contents[0] == 0x1570
727
 
                || eeprom_contents[0] == 0x2978) {
728
 
                printf("  Questionable EEPROM offset for software information!\n");
729
 
                ee_tbl_offset = 0x30;
730
 
        }
731
 
        if (set_hwaddr) {
732
 
                unsigned short sum = 0;
733
 
                memcpy(new_ee_contents, eeprom_contents, eesize << 1);
734
 
                for (i = 0; i < 3; i++)
735
 
                        new_ee_contents[ee_tbl_offset + 10 + i] =
736
 
                                (new_hwaddr[i*2]<<8) + new_hwaddr[i*2+1];
737
 
                /* Recalculate the checksum: Cyclone only! */
738
 
                for (i = 0; i < 0x1A; i++)
739
 
                        sum ^= new_ee_contents[ee_tbl_offset + i];
740
 
                new_ee_contents[ee_tbl_offset + 0x20] = (sum ^ (sum>>8)) & 0xff;
741
 
                do_update(ioaddr, eeaddrlen, new_ee_contents, eeprom_contents);
742
 
                for (i = 0; i < eesize; i++)
743
 
                        eeprom_contents[i] = read_eeprom(ioaddr, eeaddrlen, i);
744
 
        }
745
 
 
746
 
        if (set_ee_rom) {
747
 
                unsigned short sum = 0;
748
 
                memcpy(new_ee_contents, eeprom_contents, eesize << 1);
749
 
                new_ee_contents[9] = 0x3001;
750
 
                /* Recalculate the checksum: Cyclone only! */
751
 
                for (i = 0; i < 0x1B; i++)
752
 
                        sum ^= new_ee_contents[i];
753
 
                new_ee_contents[0x20] = (sum ^ (sum>>8)) & 0xff;
754
 
                printf("Setting the EEPROM BIOS ROM field to %4.4x, new checksum "
755
 
                           "%2.2x.\n", new_ee_contents[9], new_ee_contents[0x20]);
756
 
                do_update(ioaddr, eeaddrlen, new_ee_contents, eeprom_contents);
757
 
                for (i = 0; i < eesize; i++)
758
 
                        eeprom_contents[i] = read_eeprom(ioaddr, eeaddrlen, i);
759
 
        }
760
 
        if (verbose + show_eeprom > 2) {
761
 
                unsigned short sum = 0;
762
 
                printf("EEPROM contents (%d words, offset %#x):",
763
 
                           eesize, ee_tbl_offset);
764
 
                for (i = 0; i < eesize; i++) {
765
 
                        if (i % 8 == 0)
766
 
                                printf("\n 0x%3.3x:", i);
767
 
                        printf(" %4.4x", eeprom_contents[i]);
768
 
                        sum += eeprom_contents[i];
769
 
                }
770
 
                printf("\n The word-wide EEPROM checksum is %#4.4x.\n", sum);
771
 
        }
772
 
 
773
 
        /* The user will usually want to see the interpreted EEPROM contents. */
774
 
        if (verbose > 1 || show_eeprom) {
775
 
                parse_eeprom(eeprom_contents);
776
 
        }
 
793
 
 
794
        interpret_eeprom(ioaddr);
777
795
 
778
796
        /* Show up to four (not just the on-board) PHYs. */
779
797
        if (verbose > 1 || show_mii) {
844
862
           to read the flash on one Hurricane rev. */
845
863
        /* Turn on the MII transceiver for some cards. */
846
864
        {
847
 
                if (pcidev_tbl[part_idx].flags & HAS_FLASH_BUG) {
 
865
                if (flags & HAS_FLASH_BUG) {
848
866
                        EL3WINDOW(3);
849
867
                        outl((internal_config & ~0x00f00000)|0x00600000,
850
868
                                 ioaddr + Wn3_Config);
872
890
                                EL3WINDOW(saved_window);
873
891
                                return 4;
874
892
                        }
875
 
                if (pcidev_tbl[part_idx].flags & HAS_FLASH_BUG) {
 
893
                if (flags & HAS_FLASH_BUG) {
876
894
                        EL3WINDOW(3);
877
895
                        outl(internal_config, ioaddr + Wn3_Config);
878
896
                }
912
930
{
913
931
        int timer;
914
932
 
 
933
        if (addrlen == 6 && location > 0x3f)
 
934
                location = (location & 0x3f) + ((location<<2) & 0x0f00);
 
935
 
915
936
        outw((2 << addrlen) + location, ioaddr + Wn0EepromCmd);
916
 
        /* Wait for the read to take place, worst-case 162 us. */
 
937
        /* Wait for the read to take place, worst-case 162 us. */
917
938
        for (timer = 1620; timer >= 0; timer--) {
918
939
                if ((inw(ioaddr + Wn0EepromCmd) & 0x8000) == 0)
919
940
                        break;
969
990
                        index, value);
970
991
}
971
992
 
972
 
static int do_update(long ioaddr, int addrlen, 
 
993
static int do_update(long ioaddr, int addrlen,
973
994
                                         unsigned short *ee_values, unsigned short *old_ee_values)
974
995
{
975
996
        int i;
986
1007
                                                   i, ee_values[i]);
987
1008
                                write_eeprom(ioaddr, addrlen, i, ee_values[i]);
988
1009
                        } else
989
 
                                printf(" Would write new %d entry 0x%4.4x (old value 0x%4.4x).\n", 
 
1010
                                printf(" Would write new %d entry 0x%4.4x (old value 0x%4.4x).\n",
990
1011
                                           i, ee_values[i], old_ee_values[i]);
991
1012
                }
992
1013
        }
995
1016
                ;
996
1017
        return 0;
997
1018
}
 
1019
 
 
1020
static void parse_eeprom(unsigned short *eeprom)
 
1021
{
 
1022
        unsigned char *p = (void *)eeprom;              /* Assumes little-endian */
 
1023
        u16 *ee = eeprom;
 
1024
        int i, sum = 0;
 
1025
 
 
1026
        printf("Saved EEPROM settings of a 3Com Vortex/Boomerang:\n");
 
1027
        if (eeprom[0x37] == 0x6d50) {
 
1028
                printf(" The CardBus product ID is %4.4x %4.4x.\n",
 
1029
                           eeprom[0], eeprom[1]);
 
1030
                p += 0x60;
 
1031
                ee += 0x30;
 
1032
        }
 
1033
        printf(" 3Com Node Address ");
 
1034
        for (i = 0; i < 5; i++)
 
1035
                printf("%2.2X:", p[i^1]);
 
1036
        printf("%2.2X (used as a unique ID only).\n", p[i^1]);
 
1037
        printf(" OEM Station address %2.2X", p[1 + 20]);
 
1038
        for (i = 1; i < 6; i++)
 
1039
                printf(":%2.2X", p[(i^1) + 20]);
 
1040
        printf(" (used as the ethernet address).\n");
 
1041
        /* The original 3Com layout did not consider post-Y2K production. */
 
1042
        printf("  Device ID %4.4x,  Manufacturer ID %4.4x.\n", ee[3], ee[7]);
 
1043
        printf("  Manufacture date (MM/DD/YYYY) %d/%d/%d, division %c,"
 
1044
                   " product %c%c.\n", ((p[8]>>5) & 7) + ((p[9]<<3) & 8),
 
1045
                   p[8] & 31, (p[9]>>1) + ((p[9]>>1) < 95 ? 2000 : 1900),
 
1046
                   p[10], p[12], p[13]);
 
1047
        if (ee[9] & 0x0800)
 
1048
                printf("  A BIOS ROM of size %dKx8 is expected.\n",
 
1049
                           (ee[9]>>12)*64);
 
1050
        else
 
1051
                printf("  No BIOS ROM is present.\n");
 
1052
        printf(" Transceiver selection: %s.\n",
 
1053
                   el_medianames[(ee[19] >> 4) & 15]);
 
1054
        printf("   Options: %s duplex, link beat %s.\n",
 
1055
                   ee[13] & 0x8000 ? "force full" : "negotiated",
 
1056
                   ee[13] & 0x4000 ? "check disabled" : "required");
 
1057
        if (ee[0x18]) {
 
1058
                int MediaOptions = ee[0x19];
 
1059
                printf(" PCI Subsystem IDs: Vendor %4.4x Device %4.4x.\n",
 
1060
                           ee[0x17], ee[0x18]);
 
1061
                for (i = 0; i < 8; i++)
 
1062
                        if (MediaOptions & 1<<i)
 
1063
                                printf(" %s", medias[i]);
 
1064
                printf("%s.\n", (MediaOptions&0xE100)==0x0100 ? "10baseFL" : "");
 
1065
        }
 
1066
        for (i = 0; i < 0x16; i++)
 
1067
                sum ^= ee[i];
 
1068
        printf("  Vortex format checksum is %scorrect (%2.2x vs. %2.2x).\n",
 
1069
                   ((sum ^ (sum>>8)) & 0xff) == ee[0x17] ? "" : "in",
 
1070
                   (sum ^ (sum>>8)) & 0xff, ee[0x17]);
 
1071
        for ( ; i < 0x1A; i++)
 
1072
                sum ^= ee[i];
 
1073
        sum ^= sum>>8;
 
1074
        printf("  Cyclone format checksum is %scorrect (%#2.2x vs. %#2.2x).\n",
 
1075
                   (sum  & 0xff) == (ee[0x20] & 0xff) ? "" : "in",
 
1076
                   sum & 0xff, ee[0x20] & 0xff);
 
1077
        for (sum = 0, i = 0; i < 0x20*2; i++)
 
1078
                sum ^= ((unsigned char *)ee)[i];
 
1079
        printf("  Hurricane format checksum is %scorrect (%#2.2x vs. %#2.2x).\n",
 
1080
                   sum == (ee[0x20] & 0xff) ? "" : "in",
 
1081
                   sum, ee[0x20] & 0xff);
 
1082
        return;
 
1083
}
 
1084
 
 
1085
static void interpret_eeprom(long ioaddr)
 
1086
{
 
1087
        int eeaddrlen, eesize, ee_tbl_offset = 0;
 
1088
        int e6, eeprom_update = 0;
 
1089
        int i;
 
1090
 
 
1091
        /* Read the EEPROM. */
 
1092
        EL3WINDOW(0);
 
1093
 
 
1094
        outw(0x5555, ioaddr + Wn0EepromData);
 
1095
        e6 = read_eeprom(ioaddr, 6, 0);
 
1096
        if (e6 != 0x5555) {
 
1097
                if (debug)
 
1098
                        printf(" EEPROM Address length is 6 bits (%4.4x).\n",
 
1099
                                   read_eeprom(ioaddr, 6, 0));
 
1100
                eeaddrlen = 6;
 
1101
        } else {
 
1102
                int e8 = read_eeprom(ioaddr, 8, 0);
 
1103
                if (debug)
 
1104
                        printf(" EEPROM address sizing read returned %4.4x/%4.4x.\n",
 
1105
                                   e6, e8);
 
1106
                eeaddrlen = (e8 != 0xffff) ? 8 : 6;
 
1107
        }
 
1108
        eesize = 1 << eeaddrlen;
 
1109
 
 
1110
        if (debug)
 
1111
                printf(" EEPROM address size is %d bits.\n", eeaddrlen);
 
1112
        for (i = 0; i < eesize; i++)
 
1113
                eeprom_contents[i] = read_eeprom(ioaddr, eeaddrlen, i);
 
1114
 
 
1115
        if (eeprom_contents[0x37] == 0x6d50) {
 
1116
                ee_tbl_offset = 0x30;
 
1117
        } else if (eeprom_contents[0] == 0x10b7  ||  eeprom_contents[0] == 0x1570
 
1118
                || eeprom_contents[0] == 0x2978) {
 
1119
                printf("  Questionable EEPROM offset for software information!\n");
 
1120
                ee_tbl_offset = 0x30;
 
1121
        }
 
1122
 
 
1123
        memcpy(new_ee_contents, eeprom_contents, eesize << 1);
 
1124
        if (set_hwaddr) {
 
1125
                for (i = 0; i < 3; i++)
 
1126
                        new_ee_contents[ee_tbl_offset + 10 + i] =
 
1127
                                (new_hwaddr[i*2]<<8) + new_hwaddr[i*2+1];
 
1128
                eeprom_update++;
 
1129
        }
 
1130
        if (set_ee_rom) {
 
1131
                new_ee_contents[ee_tbl_offset + 9] = 0x3001;
 
1132
                eeprom_update++;
 
1133
        }
 
1134
        if (new_default_media >= 0) {
 
1135
                new_ee_contents[ee_tbl_offset + 19] &= 0x00ff;
 
1136
                new_ee_contents[ee_tbl_offset + 19] |= (new_default_media << 8);
 
1137
                eeprom_update++;
 
1138
        }
 
1139
        if (eeprom_update) {
 
1140
                u16 *ee = eeprom_contents + ee_tbl_offset;
 
1141
                unsigned short sum = 0;
 
1142
                int sum_range = 0x1A, sum_location = 0x20;
 
1143
 
 
1144
                /* Recalculate the checksum:
 
1145
                   First find the checksum range and location. */
 
1146
                for (i = 0; i < 0x16; i++)
 
1147
                        sum ^= ee[i];
 
1148
                if (((sum ^ (sum>>8)) & 0xff) == ee[0x17]) {
 
1149
                        sum_range = 0x16;
 
1150
                        sum_location = 0x17;
 
1151
                }
 
1152
                for ( ; i < 0x1A; i++)
 
1153
                        sum ^= ee[i];
 
1154
                if (((sum ^ (sum>>8)) & 0xff) == (ee[0x20] & 0xff)) {
 
1155
                        sum_range = 0x1A;
 
1156
                        sum_location = 0x20;
 
1157
                }                       
 
1158
                for ( ; i < 0x20; i++)
 
1159
                        sum ^= ee[i];
 
1160
                if (((sum ^ (sum>>8)) & 0xff) == (ee[0x20] & 0xff)) {
 
1161
                        sum_range = 0x20;
 
1162
                        sum_location = 0x20;
 
1163
                }                       
 
1164
                sum = 0;
 
1165
                for (i = 0; i < sum_range; i++)
 
1166
                        sum ^= new_ee_contents[ee_tbl_offset + i];
 
1167
                new_ee_contents[ee_tbl_offset + sum_location] =
 
1168
                        (sum ^ (sum>>8)) & 0xff;
 
1169
                do_update(ioaddr, eeaddrlen, new_ee_contents, eeprom_contents);
 
1170
                for (i = 0; i < eesize; i++)
 
1171
                        eeprom_contents[i] = read_eeprom(ioaddr, eeaddrlen, i);
 
1172
        }
 
1173
 
 
1174
        if (verbose > 2 || show_eeprom > 1) {
 
1175
                unsigned short sum = 0;
 
1176
                int previous_row_same = 0;
 
1177
 
 
1178
                printf("EEPROM format %dx16, configuration table at offset %#x:\n",
 
1179
                           eesize, ee_tbl_offset);
 
1180
                for (i = 0; i < eesize; i += 8) {
 
1181
                        int j;
 
1182
                        if (i == 0 ||           /* Always show first row. */
 
1183
                                (memcmp(eeprom_contents+i, eeprom_contents+i - 8, 16) != 0)) {
 
1184
                                previous_row_same = 0;
 
1185
                                printf("  %#4.2x:", i);
 
1186
                                for (j = 0; j < 8; j++) {
 
1187
                                        printf(" %4.4x", eeprom_contents[i + j]);
 
1188
                                        sum += eeprom_contents[i + j];
 
1189
                                }
 
1190
                                if (show_eeprom > 2) {
 
1191
                                        printf("  ");
 
1192
                                        for (j = 0; j < 8; j++) {
 
1193
                                                int ew = eeprom_contents[i + j];
 
1194
                                                printf("%c%c",
 
1195
                                                           isprint(ew & 0xff) ? ew & 0xff : '_',
 
1196
                                                           isprint(ew >>   8) ? ew >> 8   : '_' );
 
1197
                                        }
 
1198
                                }
 
1199
                                printf("\n");
 
1200
                        } else if ( ! previous_row_same) {
 
1201
                                previous_row_same = 1;
 
1202
                                printf("      ...\n");
 
1203
                        }
 
1204
                }
 
1205
                printf("\n The word-wide EEPROM checksum is %#4.4x.\n", sum);
 
1206
        }
 
1207
 
 
1208
        /* The user will usually want to see the interpreted EEPROM contents. */
 
1209
        if (verbose > 1 || show_eeprom) {
 
1210
                parse_eeprom(eeprom_contents);
 
1211
        }
 
1212
        return;
 
1213
}
 
1214
 
998
1215
 
999
1216
 
1000
1217
/* Read and write the MII registers using software-generated serial
1015
1232
{
1016
1233
        long mdio_addr = ioaddr + Wn4_PhysicalMgmt;
1017
1234
        int i;
1018
 
        /* Establish sync by sending at least 32 logic ones. */ 
 
1235
        /* Establish sync by sending at least 32 logic ones. */
1019
1236
        for (i = 32; i >= 0; i--) {
1020
1237
                outw(MDIO_DATA_WRITE1, mdio_addr);
1021
1238
                mdio_delay(mdio_addr);
1110
1327
}
1111
1328
 
1112
1329
 
1113
 
static void parse_eeprom(unsigned short *eeprom)
1114
 
{
1115
 
        unsigned char *p = (void *)eeprom;
1116
 
        u16 *ee = eeprom;
1117
 
        int i, sum = 0;
1118
 
 
1119
 
        printf("Saved EEPROM settings of a 3Com Vortex/Boomerang:\n");
1120
 
        if (eeprom[0x37] == 0x6d50) {
1121
 
                printf(" The CardBus product ID is %4.4x %4.4x.\n",
1122
 
                           eeprom[0], eeprom[1]);
1123
 
                p += 0x60;
1124
 
                ee += 0x30;
1125
 
        }
1126
 
        printf(" 3Com Node Address ");
1127
 
        for (i = 0; i < 5; i++)
1128
 
                printf("%2.2X:", p[i^1]);
1129
 
        printf("%2.2X (used as a unique ID only).\n", p[i^1]);
1130
 
        printf(" OEM Station address %2.2x", p[1 + 20]);
1131
 
        for (i = 1; i < 6; i++)
1132
 
                printf(":%2.2X", p[(i^1) + 20]);
1133
 
        printf(" (used as the ethernet address).\n");
1134
 
        /* The original 3Com layout did not consider post-Y2K production. */
1135
 
        printf(" Manufacture date (MM/DD/YYYY) %d/%d/%d, division %c,"
1136
 
                   " product %c%c.\n", ((p[8]>>5) & 7) + ((p[9]<<3) & 8),
1137
 
                   p[8] & 31, (p[9]>>1) + ((p[9]>>1) < 95 ? 2000 : 1900),
1138
 
                   p[10], p[12], p[13]);
1139
 
        printf(" Options: %s duplex, link beat %s.\n",
1140
 
                   ee[13] & 0x8000 ? "force full" : "negotiated",
1141
 
                   ee[13] & 0x4000 ? "check disabled" : "required");
1142
 
        for (i = 0; i < 0x16; i++)
1143
 
                sum ^= ee[i];
1144
 
        printf("  Vortex format checksum is %scorrect (%4.4x vs. %4.4x).\n",
1145
 
                   ((sum ^ (sum>>8)) & 0xff) == ee[0x17] ? "" : "in",
1146
 
                   (sum ^ (sum>>8)) & 0xff, ee[0x17]);
1147
 
        for ( ; i < 0x1A; i++)
1148
 
                sum ^= ee[i];
1149
 
        sum ^= sum>>8;
1150
 
        printf("  Cyclone format checksum is %scorrect (%#2.2x vs. %#2.2x).\n",
1151
 
                   (sum  & 0xff) == (ee[0x20] & 0xff) ? "" : "in",
1152
 
                   sum & 0xff, ee[0x20] & 0xff);
1153
 
        for (sum = 0, i = 0; i < 0x20*2; i++)
1154
 
                sum ^= ((unsigned char *)ee)[i];
1155
 
        printf("  Hurricane format checksum is %scorrect (%#2.2x vs. %#2.2x).\n",
1156
 
                   sum == (ee[0x20] & 0xff) ? "" : "in",
1157
 
                   sum, ee[0x20] & 0xff);
1158
 
        return;
1159
 
}
1160
 
 
1161
1330
static void show_dma_state(long ioaddr)
1162
1331
{
1163
1332
        int dma_ctrl = inl(ioaddr + 0x20);
1165
1334
        if (dma_ctrl & 0x0080) {
1166
1335
                outw(DownStall, ioaddr + EL3_CMD);
1167
1336
                printf("   DMA control register is %8.8x (during Tx Stall).\n",
1168
 
                           inl(ioaddr + 0x20));
 
1337
                           (int)inl(ioaddr + 0x20));
1169
1338
                outw(DownUnstall, ioaddr + EL3_CMD);
1170
1339
        }
1171
1340
        printf("   Tx list starts at %8.8x.\n",
1172
 
                   inl(ioaddr + 0x24));
 
1341
                   (int)inl(ioaddr + 0x24));
1173
1342
        printf("   Tx FIFO thresholds: min. burst %d bytes, "
1174
1343
                   "priority with %d bytes to empty.\n",
1175
 
                   inb(ioaddr + 0x2A)<<5, inl(ioaddr + 0x2C)<<5);
1176
 
        printf("   Tx poll period %d0 ns.\n",
1177
 
                   inb(ioaddr + 0x2D)<<5);
1178
 
        printf("   Tx maximum burst recorded %d.\n",
1179
 
                   inw(ioaddr + 0x78));
 
1344
                   inb(ioaddr + 0x2A)<<5, inb(ioaddr + 0x2C)<<5);
 
1345
        printf("   Rx FIFO thresholds: min. burst %d bytes, "
 
1346
                   "priority with %d bytes to full.\n",
 
1347
                   inb(ioaddr + 0x3E)<<5, inb(ioaddr + 0x3C)<<5);
 
1348
        printf("   Poll period Tx %d0 ns.,  Rx %d ns.\n",
 
1349
                   inb(ioaddr + 0x2D)<<5, inb(ioaddr + 0x3D)<<5);
 
1350
        printf("   Maximum burst recorded Tx %d,  Rx %d.\n",
 
1351
                   inw(ioaddr + 0x78), inw(ioaddr + 0x7A));
1180
1352
}
1181
1353
 
1182
1354