summaryrefslogtreecommitdiff
path: root/board/eltec/bab7xx/misc.c
blob: 1b4376dcdabf155f9b512bd2e170b2341f2751cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
/*
 * (C) Copyright 2002 ELTEC Elektronik AG
 * Frank Gottschling <fgottschling@eltec.de>
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

/* includes */
#include <common.h>
#include <linux/ctype.h>
#include <pci.h>
#include <net.h>
#include <mpc106.h>
#include <w83c553f.h>
#include "srom.h"

/* imports  */
extern char console_buffer[CFG_CBSIZE];
extern int l2_cache_enable (int l2control);
extern void *nvram_read (void *dest, const short src, size_t count);
extern void nvram_write (short dest, const void *src, size_t count);

/* globals */
unsigned int ata_reset_time = 60;
unsigned int scsi_reset_time = 10;
unsigned int eltec_board;

/* BAB750 uses SYM53C875(default) and BAB740 uses SYM53C860
 * values fixed after board identification
 */
unsigned short scsi_dev_id = PCI_DEVICE_ID_NCR_53C875;
unsigned int   scsi_max_scsi_id = 15;
unsigned char  scsi_sym53c8xx_ccf = 0x13;

/*----------------------------------------------------------------------------*/
/*
 * handle sroms on BAB740/750
 * fix ether address
 * L2 cache initialization
 * ide dma control
 */
int misc_init_r (void)
{
    revinfo eerev;
    u_char *ptr;
    u_int  i, l, initSrom, copyNv;
    char buf[256];
    char hex[23] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0,
             0, 0, 0, 0, 10, 11, 12, 13, 14, 15 };
    pci_dev_t bdf;

    char sromSYM[] = {
#ifdef TULIP_BUG
    /* 10BaseT, 100BaseTx no full duplex modes */
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x08,
    0x02, 0x86, 0x02, 0x00, 0xaf, 0x08, 0xa5, 0x00,
    0x88, 0x04, 0x03, 0x27, 0x08, 0x25, 0x00, 0x61,
    0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xe8
#endif
    /* 10BaseT, 10BaseT-FD, 100BaseTx, 100BaseTx-FD */
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x08,
    0x04, 0x86, 0x02, 0x00, 0xaf, 0x08, 0xa5, 0x00,
    0x86, 0x02, 0x04, 0xaf, 0x08, 0xa5, 0x00, 0x88,
    0x04, 0x03, 0x27, 0x08, 0x25, 0x00, 0x61, 0x80,
    0x88, 0x04, 0x05, 0x27, 0x08, 0x25, 0x00, 0x61,
    0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x77
    };

    char sromMII[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x5b, 0x00,
    0x2e, 0x4d, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x08,
    0x01, 0x95, 0x03, 0x00, 0x00, 0x04, 0x01, 0x08,
    0x00, 0x00, 0x02, 0x08, 0x02, 0x00, 0x00, 0x78,
    0xe0, 0x01, 0x00, 0x50, 0x00, 0x18, 0x80, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0x41
    };

    /*
     * Check/Remake revision info
     */
    initSrom = 0;
    copyNv   = 0;

    /* read out current revision srom contens */
    el_srom_load (0x0000, (u_char*)&eerev, sizeof(revinfo),
                SECOND_DEVICE, FIRST_BLOCK);

    /* read out current nvram shadow image */
    nvram_read (buf, CFG_NV_SROM_COPY_ADDR, CFG_SROM_SIZE);

    if (strcmp (eerev.magic, "ELTEC") != 0)
    {
        /* srom is not initialized -> create a default revision info */
        for (i = 0, ptr = (u_char *)&eerev; i < sizeof(revinfo); i++)
            *ptr++ = 0x00;
        strcpy(eerev.magic, "ELTEC");
        eerev.revrev[0] = 1;
        eerev.revrev[1] = 0;
        eerev.size = 0x00E0;
        eerev.category[0] = 0x01;

        /* node id from dead e128 as default */
        eerev.etheraddr[0] = 0x00;
        eerev.etheraddr[1] = 0x00;
        eerev.etheraddr[2] = 0x5B;
        eerev.etheraddr[3] = 0x00;
        eerev.etheraddr[4] = 0x2E;
        eerev.etheraddr[5] = 0x4D;

        /* cache config word for bab750 */
        *(int*)&eerev.res[0] = CLK2P0TO1_1MB_PB_0P5DH;

        initSrom = 1;  /* force dialog */
        copyNv   = 1;  /* copy to nvram */
    }

    if ((copyNv == 0) &&   (el_srom_checksum((u_char*)&eerev, CFG_SROM_SIZE) !=
                el_srom_checksum((u_char*)buf, CFG_SROM_SIZE)))
    {
        printf ("Invalid revision info copy in nvram !\n");
        printf ("Press key:\n  <c> to copy current revision info to nvram.\n");
        printf ("  <r> to reenter revision info.\n");
        printf ("=> ");
        if (0 != readline (NULL))
        {
            switch ((char)toupper(console_buffer[0]))
            {
            case 'C':
                copyNv = 1;
                break;
            case 'R':
                copyNv = 1;
                initSrom = 1;
                break;
            }
        }
    }

    if (initSrom)
    {
        memcpy (buf, &eerev.revision[0][0], 14);     /* save all revision info */
        printf ("Enter revision number (0-9): %c  ", eerev.revision[0][0]);
        if (0 != readline (NULL))
        {
            eerev.revision[0][0] = (char)toupper(console_buffer[0]);
            memcpy (&eerev.revision[1][0], buf, 12); /* shift rest of rev info */
        }

        printf ("Enter revision character (A-Z): %c  ", eerev.revision[0][1]);
        if (1 == readline (NULL))
        {
            eerev.revision[0][1] = (char)toupper(console_buffer[0]);
        }

        printf ("Enter board name (V-XXXX-XXXX): %s  ", (char *)&eerev.board);
        if (11 == readline (NULL))
        {
            for (i=0; i<11; i++)
                eerev.board[i] =  (char)toupper(console_buffer[i]);
            eerev.board[11] = '\0';
        }

        printf ("Enter serial number: %s ", (char *)&eerev.serial );
        if (6 == readline (NULL))
        {
            for (i=0; i<6; i++)
                eerev.serial[i] = console_buffer[i];
            eerev.serial[6] = '\0';
        }

        printf ("Enter ether node ID with leading zero (HEX): %02x%02x%02x%02x%02x%02x  ",
            eerev.etheraddr[0], eerev.etheraddr[1],
            eerev.etheraddr[2], eerev.etheraddr[3],
            eerev.etheraddr[4], eerev.etheraddr[5]);
        if (12 == readline (NULL))
        {
            for (i=0; i<12; i+=2)
            eerev.etheraddr[i>>1] = (char)(16*hex[toupper(console_buffer[i])-'0'] +
                               hex[toupper(console_buffer[i+1])-'0']);
        }

        l = strlen ((char *)&eerev.text);
        printf("Add to text section (max 64 chr): %s ", (char *)&eerev.text );
        if (0 != readline (NULL))
        {
            for (i = l; i<63; i++)
                eerev.text[i] = console_buffer[i-l];
            eerev.text[63] = '\0';
        }

        if (strstr ((char *)&eerev.board, "75") != NULL)
            eltec_board = 750;
        else
            eltec_board = 740;

        if (eltec_board == 750)
        {
            if (CPU_TYPE == CPU_TYPE_750)
                *(int*)&eerev.res[0] = CLK2P0TO1_1MB_PB_0P5DH;
                else
                *(int*)&eerev.res[0] = CLK2P5TO1_1MB_PB_0P5DH;

            printf("Enter L2Cache config word with leading zero (HEX): %08X  ",
                    *(int*)&eerev.res[0] );
            if (0 != readline (NULL))
            {
                for (i=0; i<7; i+=2)
                {
                    eerev.res[i>>1] =
                    (char)(16*hex[toupper(console_buffer[i])-'0'] +
                    hex[toupper(console_buffer[i+1])-'0']);
                }
            }

            /* prepare network eeprom */
            sromMII[20] = eerev.etheraddr[0];
            sromMII[21] = eerev.etheraddr[1];
            sromMII[22] = eerev.etheraddr[2];
            sromMII[23] = eerev.etheraddr[3];
            sromMII[24] = eerev.etheraddr[4];
            sromMII[25] = eerev.etheraddr[5];
            printf("\nSRom:  Writing DEC21143 MII info .. ");

            if (dc_srom_store ((u_short *)sromMII) == -1)
                printf("FAILED\n");
            else
                printf("OK\n");
        }

        if (eltec_board == 740)
        {
            *(int *)&eerev.res[0] = 0;
            sromSYM[20] = eerev.etheraddr[0];
            sromSYM[21] = eerev.etheraddr[1];
            sromSYM[22] = eerev.etheraddr[2];
            sromSYM[23] = eerev.etheraddr[3];
            sromSYM[24] = eerev.etheraddr[4];
            sromSYM[25] = eerev.etheraddr[5];
            printf("\nSRom:  Writing DEC21143 SYM info .. ");

            if (dc_srom_store ((u_short *)sromSYM) == -1)
                printf("FAILED\n");
            else
                printf("OK\n");
        }

        /* update CRC */
        eerev.crc = el_srom_checksum((u_char *)eerev.board, eerev.size);

        /* write new values */
        printf("\nSRom:  Writing revision info ...... ");
        if (el_srom_store((BLOCK_SIZE-sizeof(revinfo)), (u_char *)&eerev,
                            sizeof(revinfo), SECOND_DEVICE, FIRST_BLOCK) == -1)
            printf("FAILED\n\n");
        else
            printf("OK\n\n");

        /* write new values as shadow image to nvram */
        nvram_write (CFG_NV_SROM_COPY_ADDR, (void *)&eerev, CFG_SROM_SIZE);

    } /*if (initSrom) */

    /* copy current values as shadow image to nvram */
    if (initSrom == 0 && copyNv == 1)
        nvram_write (CFG_NV_SROM_COPY_ADDR, (void *)&eerev, CFG_SROM_SIZE);

    /* update environment */
    sprintf (buf, "%02x:%02x:%02x:%02x:%02x:%02x",
            eerev.etheraddr[0], eerev.etheraddr[1],
            eerev.etheraddr[2], eerev.etheraddr[3],
            eerev.etheraddr[4], eerev.etheraddr[5]);
    setenv ("ethaddr", buf);

    /* print actual board identification */
    printf("Ident: %s  Ser %s  Rev %c%c\n",
            eerev.board, (char *)&eerev.serial,
            eerev.revision[0][0], eerev.revision[0][1]);

    /* global board ident */
    if (strstr ((char *)&eerev.board, "75") != NULL)
        eltec_board = 750;
    else
        eltec_board = 740;

   /*
    * L2 cache configuration
    */
#if defined(CFG_L2_BAB7xx)
    ptr = getenv("l2cache");
    if (*ptr == '0')
    {
        printf ("Cache: L2 NOT activated on BAB%d\n", eltec_board);
    }
    else
    {
        printf ("Cache: L2 activated on BAB%d\n", eltec_board);
        l2_cache_enable(*(int*)&eerev.res[0]);
    }
#endif

   /*
    * Reconfig ata reset timeout from environment
    */
    if ((ptr = getenv ("ata_reset_time")) != NULL)
    {
        ata_reset_time = (int)simple_strtoul (ptr, NULL, 10);
    }
    else
    {
        sprintf (buf, "%d", ata_reset_time);
        setenv ("ata_reset_time", buf);
    }

   /*
    * Reconfig scsi reset timeout from environment
    */
    if ((ptr = getenv ("scsi_reset_time")) != NULL)
    {
        scsi_reset_time = (int)simple_strtoul (ptr, NULL, 10);
    }
    else
    {
        sprintf (buf, "%d", scsi_reset_time);
        setenv ("scsi_reset_time", buf);
    }


    if ((bdf = pci_find_device(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_83C553, 0)) > 0)
    {
        if (pci_find_device(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C860, 0) > 0)
        {
            /* BAB740 with SCSI=IRQ 11; SCC=IRQ 9; no IDE; NCR860 at 80 Mhz */
            scsi_dev_id = PCI_DEVICE_ID_NCR_53C860;
            scsi_max_scsi_id = 7;
            scsi_sym53c8xx_ccf = 0x15;
            pci_write_config_byte (bdf, WINBOND_IDEIRCR, 0xb0);
        }

        if ((ptr = getenv ("ide_dma_off")) != NULL)
        {
            u_long dma_off = simple_strtoul (ptr, NULL, 10);
            /*
            * setup user defined registers
            * s.a. linux/drivers/ide/sl82c105.c
            */
            bdf |= PCI_BDF(0,0,1);            /* ide user reg at bdf function 1 */
            if (dma_off & 1)
            {
                pci_write_config_byte (bdf, 0x46, 1);
                printf("IDE:   DMA off flag set: Bus 0 : Dev 0\n");
            }
            if (dma_off & 2)
            {
                pci_write_config_byte (bdf, 0x4a, 1);
                printf("IDE:   DMA off flag set: Bus 0 : Dev 1\n");
            }
            if (dma_off & 4)
            {
                pci_write_config_byte (bdf, 0x4e, 1);
                printf("IDE:   DMA off flag set: Bus 1 : Dev 0\n");
            }
            if (dma_off & 8)
            {
                pci_write_config_byte (bdf, 0x52, 1);
                printf("IDE:   DMA off flag set: Bus 1 : Dev 1\n");
            }
        }
    }
    return (0);
}

/*----------------------------------------------------------------------------*/
/*
 * BAB740 uses KENDIN KS8761 modem chip with not common setup values
 */
#ifdef CONFIG_TULIP_SELECT_MEDIA

/* Register bits.
 */
#define BMR_SWR         0x00000001      /* Software Reset */
#define STS_TS          0x00700000      /* Transmit Process State */
#define STS_RS          0x000e0000      /* Receive Process State */
#define OMR_ST          0x00002000      /* Start/Stop Transmission Command */
#define OMR_SR          0x00000002      /* Start/Stop Receive */
#define OMR_PS          0x00040000      /* Port Select */
#define OMR_SDP         0x02000000      /* SD Polarity - MUST BE ASSERTED */
#define OMR_PM          0x00000080      /* Pass All Multicast */
#define OMR_PR          0x00000040      /* Promiscuous Mode */
#define OMR_PCS         0x00800000      /* PCS Function */
#define OMR_TTM         0x00400000      /* Transmit Threshold Mode */

/* Ethernet chip registers.
 */
#define DE4X5_BMR       0x000           /* Bus Mode Register */
#define DE4X5_TPD       0x008           /* Transmit Poll Demand Reg */
#define DE4X5_RRBA      0x018           /* RX Ring Base Address Reg */
#define DE4X5_TRBA      0x020           /* TX Ring Base Address Reg */
#define DE4X5_STS       0x028           /* Status Register */
#define DE4X5_OMR       0x030           /* Operation Mode Register */
#define DE4X5_SISR      0x060           /* SIA Status Register */
#define DE4X5_SICR      0x068           /* SIA Connectivity Register */
#define DE4X5_TXRX      0x070           /* SIA Transmit and Receive Register */
#define DE4X5_GPPR      0x078           /* General Purpose Port register */
#define DE4X5_APROM      0x048          /* Ethernet Address PROM */

/*----------------------------------------------------------------------------*/

static int INL(struct eth_device* dev, u_long addr)
{
    return le32_to_cpu(*(volatile u_long *)(addr + dev->iobase));
}

/*----------------------------------------------------------------------------*/

static void OUTL(struct eth_device* dev, int command, u_long addr)
{
    *(volatile u_long *)(addr + dev->iobase) = cpu_to_le32(command);
}

/*----------------------------------------------------------------------------*/

static void media_reg_init (
    struct eth_device* dev,
    u32 csr14,
    u32 csr15_dir,
    u32 csr15_v0,
    u32 csr15_v1,
    u32 csr6 )
{
    OUTL(dev, 0, DE4X5_OMR);            /* CSR6  */
    udelay(10 * 1000);
    OUTL(dev, 0, DE4X5_SICR);           /* CSR13 */
    OUTL(dev, 1, DE4X5_SICR);           /* CSR13 */
    udelay(10 * 1000);
    OUTL(dev, csr14, DE4X5_TXRX);       /* CSR14 */
    OUTL(dev, csr15_dir, DE4X5_GPPR);   /* CSR15 */
    OUTL(dev, csr15_v0,  DE4X5_GPPR);   /* CSR15 */
    udelay(10 * 1000);
    OUTL(dev, csr15_v1,  DE4X5_GPPR);   /* CSR15 */
    OUTL(dev, 0x00000301, DE4X5_SISR);  /* CSR12 */
    OUTL(dev, csr6, DE4X5_OMR);         /* CSR6 */
}

/*----------------------------------------------------------------------------*/

void dc21x4x_select_media(struct eth_device* dev)
{
    int i, status, ext;
    extern unsigned int eltec_board;

    if (eltec_board == 740)
    {
        printf("SYM media select "); /* BAB740 */
        /* start autoneg. with 10 mbit */
        media_reg_init (dev, 0x3ffff, 0x08af0008, 0x00a10008, 0x00a50008, 0x02400080);
        ext = status = 0;
        for (i=0; i<2000+ext; i++)
        {
            status = INL(dev, DE4X5_SISR);
            udelay(1000);
            if (status & 0x2000) ext = 2000;
            if ((status & 0x7000) == 0x5000) break;
        }

        /* autoneg. ok -> 100MB FD */
        if ((status & 0x0100f000) == 0x0100d000)
        {
            media_reg_init (dev, 0x37f7f, 0x08270008, 0x00210008, 0x00250008, 0x03c40280);
            printf("100baseTx-FD\n");
        }
        /* autoneg. ok -> 100MB HD */
        else if ((status & 0x0080f000) == 0x0080d000)
        {
            media_reg_init (dev, 0x17f7f, 0x08270008, 0x00210008, 0x00250008, 0x03c40080);
            printf("100baseTx\n");
        }
        /* autoneg. ok -> 10MB FD */
        else if ((status & 0x0040f000) == 0x0040d000)
        {
            media_reg_init (dev, 0x07f7f, 0x08af0008, 0x00a10008, 0x00a50008, 0x02400280);
            printf("10baseT-FD\n");
        }
        /* autoneg. fail -> 10MB HD */
        else
        {
            media_reg_init (dev, 0x7f7f, 0x08af0008, 0x00a10008, 0x00a50008,
                        (OMR_SDP | OMR_TTM | OMR_PM));
            printf("10baseT\n");
        }
    }
    else
    {
        printf("MII media selected\n");                     /* BAB750 */
        OUTL(dev, OMR_SDP | OMR_PS | OMR_PM, DE4X5_OMR);    /* CSR6 */
    }
}
#endif /* CONFIG_TULIP_SELECT_MEDIA */

/*---------------------------------------------------------------------------*/