Browse Source

[tulip] Use iPXE debugging infrastructure

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
ae34edbd3b
1 changed files with 79 additions and 209 deletions
  1. 79
    209
      src/drivers/net/tulip.c

+ 79
- 209
src/drivers/net/tulip.c View File

116
 
116
 
117
 /* User settable parameters */
117
 /* User settable parameters */
118
 
118
 
119
-#undef	TULIP_DEBUG
120
-#undef	TULIP_DEBUG_WHERE
121
-#ifdef	TULIP_DEBUG
122
-static int tulip_debug = 2;             /* 1 normal messages, 0 quiet .. 7 verbose. */
123
-#endif
124
-
125
 #define TX_TIME_OUT       2*TICKS_PER_SEC
119
 #define TX_TIME_OUT       2*TICKS_PER_SEC
126
 
120
 
127
 /* helpful macros if on a big_endian machine for changing byte order.
121
 /* helpful macros if on a big_endian machine for changing byte order.
510
 
504
 
511
 static void tulip_wait(unsigned int nticks);
505
 static void tulip_wait(unsigned int nticks);
512
 
506
 
513
-#ifdef TULIP_DEBUG_WHERE
514
-static void whereami(const char *str);
515
-#endif
516
-
517
-#ifdef TULIP_DEBUG
518
-static void tulip_more(void);
519
-#endif
520
-
521
 
507
 
522
 /*********************************************************************/
508
 /*********************************************************************/
523
 /* Utility Routines                                                  */
509
 /* Utility Routines                                                  */
524
 /*********************************************************************/
510
 /*********************************************************************/
525
 
511
 
526
-#ifdef TULIP_DEBUG_WHERE
527
-static void whereami (const char *str, struct pci_device *pci)
512
+static void whereami (const char *str)
528
 {
513
 {
529
-    printf("%s: %s\n", tp->nic_name, str);
514
+    DBGP("%s\n", str);
530
     /* sleep(2); */
515
     /* sleep(2); */
531
 }
516
 }
532
-#endif
533
-
534
-#ifdef  TULIP_DEBUG
535
-static void tulip_more(void)
536
-{
537
-    printf("\n\n-- more --");
538
-    while (!iskey())
539
-        /* wait */;
540
-    getchar();
541
-    printf("\n\n");
542
-}
543
-#endif /* TULIP_DEBUG */
544
 
517
 
545
 static void tulip_wait(unsigned int nticks)
518
 static void tulip_wait(unsigned int nticks)
546
 {
519
 {
586
     int retval = 0;
559
     int retval = 0;
587
     long mdio_addr = ioaddr + CSR9;
560
     long mdio_addr = ioaddr + CSR9;
588
 
561
 
589
-#ifdef TULIP_DEBUG_WHERE
590
     whereami("mdio_read\n");
562
     whereami("mdio_read\n");
591
-#endif
592
 
563
 
593
     if (tp->chip_id == LC82C168) {
564
     if (tp->chip_id == LC82C168) {
594
 	int i = 1000;
565
 	int i = 1000;
646
     int cmd = (0x5002 << 16) | (phy_id << 23) | (location<<18) | value;
617
     int cmd = (0x5002 << 16) | (phy_id << 23) | (location<<18) | value;
647
     long mdio_addr = ioaddr + CSR9;
618
     long mdio_addr = ioaddr + CSR9;
648
 
619
 
649
-#ifdef TULIP_DEBUG_WHERE
650
     whereami("mdio_write\n");
620
     whereami("mdio_write\n");
651
-#endif
652
 
621
 
653
     if (tp->chip_id == LC82C168) {
622
     if (tp->chip_id == LC82C168) {
654
 	int i = 1000;
623
 	int i = 1000;
711
     long ee_addr = ioaddr + CSR9;
680
     long ee_addr = ioaddr + CSR9;
712
     int read_cmd = location | EE_READ_CMD;
681
     int read_cmd = location | EE_READ_CMD;
713
 
682
 
714
-#ifdef TULIP_DEBUG_WHERE
715
     whereami("read_eeprom\n");
683
     whereami("read_eeprom\n");
716
-#endif
717
 
684
 
718
     outl(EE_ENB & ~EE_CS, ee_addr);
685
     outl(EE_ENB & ~EE_CS, ee_addr);
719
     outl(EE_ENB, ee_addr);
686
     outl(EE_ENB, ee_addr);
751
     int new_advertise = 0;
718
     int new_advertise = 0;
752
     int i;
719
     int i;
753
 
720
 
754
-#ifdef TULIP_DEBUG_WHERE
755
     whereami("parse_eeprom\n");
721
     whereami("parse_eeprom\n");
756
-#endif
757
 
722
 
758
     tp->mtable = 0;
723
     tp->mtable = 0;
759
     /* Detect an old-style (SA only) EEPROM layout:
724
     /* Detect an old-style (SA only) EEPROM layout:
771
                     i++;                /* An Accton EN1207, not an outlaw Maxtech. */
736
                     i++;                /* An Accton EN1207, not an outlaw Maxtech. */
772
                 memcpy(ee_data + 26, eeprom_fixups[i].newtable,
737
                 memcpy(ee_data + 26, eeprom_fixups[i].newtable,
773
                        sizeof(eeprom_fixups[i].newtable));
738
                        sizeof(eeprom_fixups[i].newtable));
774
-#ifdef TULIP_DEBUG
775
-                printf("%s: Old format EEPROM on '%s' board.\n%s: Using substitute media control info.\n",
739
+                DBG("%s: Old format EEPROM on '%s' board.\n%s: Using substitute media control info.\n",
776
                        tp->nic_name, eeprom_fixups[i].name, tp->nic_name);
740
                        tp->nic_name, eeprom_fixups[i].name, tp->nic_name);
777
-#endif
778
                 break;
741
                 break;
779
             }
742
             }
780
         }
743
         }
781
         if (eeprom_fixups[i].name == NULL) { /* No fixup found. */
744
         if (eeprom_fixups[i].name == NULL) { /* No fixup found. */
782
-#ifdef TULIP_DEBUG
783
-            printf("%s: Old style EEPROM with no media selection information.\n",
745
+            DBG("%s: Old style EEPROM with no media selection information.\n",
784
                    tp->nic_name);
746
                    tp->nic_name);
785
-#endif
786
             return;
747
             return;
787
         }
748
         }
788
     }
749
     }
789
 
750
 
790
     if (ee_data[19] > 1) {
751
     if (ee_data[19] > 1) {
791
-#ifdef TULIP_DEBUG
792
-        printf("%s:  Multiport cards (%d ports) may not work correctly.\n", 
752
+        DBG("%s:  Multiport cards (%d ports) may not work correctly.\n",
793
                tp->nic_name, ee_data[19]);
753
                tp->nic_name, ee_data[19]);
794
-#endif
795
     }
754
     }
796
 
755
 
797
     p = (void *)ee_data + ee_data[27];
756
     p = (void *)ee_data + ee_data[27];
798
 
757
 
799
     if (ee_data[27] == 0) {             /* No valid media table. */
758
     if (ee_data[27] == 0) {             /* No valid media table. */
800
-#ifdef TULIP_DEBUG
801
-        if (tulip_debug > 1) {
802
-            printf("%s:  No Valid Media Table. ee_data[27] = %hhX\n", 
803
-                   tp->nic_name, ee_data[27]);
804
-        }
805
-#endif
759
+            DBG2("%s:  No Valid Media Table. ee_data[27] = %hhX\n",
760
+		 tp->nic_name, ee_data[27]);
806
     } else if (tp->chip_id == DC21041) {
761
     } else if (tp->chip_id == DC21041) {
807
         int media = get_u16(p);
762
         int media = get_u16(p);
808
         int count = p[2];
763
         int count = p[2];
809
         p += 3;
764
         p += 3;
810
 
765
 
811
-        printf("%s: 21041 Media table, default media %hX (%s).\n",
766
+        DBG("%s: 21041 Media table, default media %hX (%s).\n",
812
                tp->nic_name, media,
767
                tp->nic_name, media,
813
                media & 0x0800 ? "Autosense" : medianame[media & 15]);
768
                media & 0x0800 ? "Autosense" : medianame[media & 15]);
814
         for (i = 0; i < count; i++) {
769
         for (i = 0; i < count; i++) {
820
             case 0: new_advertise |= 0x0020; break;
775
             case 0: new_advertise |= 0x0020; break;
821
             case 4: new_advertise |= 0x0040; break;
776
             case 4: new_advertise |= 0x0040; break;
822
             }
777
             }
823
-            printf("%s:  21041 media #%d, %s.\n",
778
+            DBG("%s:  21041 media #%d, %s.\n",
824
                    tp->nic_name, media_code, medianame[media_code]);
779
                    tp->nic_name, media_code, medianame[media_code]);
825
         }
780
         }
826
     } else {
781
     } else {
842
         mtable->has_nonmii = mtable->has_mii = mtable->has_reset = 0;
797
         mtable->has_nonmii = mtable->has_mii = mtable->has_reset = 0;
843
         mtable->csr15dir = mtable->csr15val = 0;
798
         mtable->csr15dir = mtable->csr15val = 0;
844
 
799
 
845
-        printf("%s:  EEPROM default media type %s.\n", tp->nic_name,
800
+        DBG("%s:  EEPROM default media type %s.\n", tp->nic_name,
846
                media & 0x0800 ? "Autosense" : medianame[media & MEDIA_MASK]);
801
                media & 0x0800 ? "Autosense" : medianame[media & MEDIA_MASK]);
847
 
802
 
848
         for (i = 0; i < count; i++) {
803
         for (i = 0; i < count; i++) {
890
                 leaf->leafdata = p + 2;
845
                 leaf->leafdata = p + 2;
891
                 p += (p[0] & 0x3f) + 1;
846
                 p += (p[0] & 0x3f) + 1;
892
             }
847
             }
893
-#ifdef TULIP_DEBUG
894
-            if (tulip_debug > 1  &&  leaf->media == 11) {
848
+            if (leaf->media == 11) {
895
                 unsigned char *bp = leaf->leafdata;
849
                 unsigned char *bp = leaf->leafdata;
896
-                printf("%s:  MII interface PHY %d, setup/reset sequences %d/%d long, capabilities %hhX %hhX.\n",
897
-                       tp->nic_name, bp[0], bp[1], bp[2 + bp[1]*2],
898
-                       bp[5 + bp[2 + bp[1]*2]*2], bp[4 + bp[2 + bp[1]*2]*2]);
850
+                DBG2("%s:  MII interface PHY %d, setup/reset sequences %d/%d long, capabilities %hhX %hhX.\n",
851
+		     tp->nic_name, bp[0], bp[1], bp[2 + bp[1]*2],
852
+		     bp[5 + bp[2 + bp[1]*2]*2], bp[4 + bp[2 + bp[1]*2]*2]);
899
             }
853
             }
900
-#endif
901
-            printf("%s:  Index #%d - Media %s (#%d) described "
854
+            DBG("%s:  Index #%d - Media %s (#%d) described "
902
                    "by a %s (%d) block.\n",
855
                    "by a %s (%d) block.\n",
903
                    tp->nic_name, i, medianame[leaf->media], leaf->media,
856
                    tp->nic_name, i, medianame[leaf->media], leaf->media,
904
                    leaf->type < 6 ? block_name[leaf->type] : "UNKNOWN",
857
                    leaf->type < 6 ? block_name[leaf->type] : "UNKNOWN",
917
 {
870
 {
918
     int i;
871
     int i;
919
 
872
 
920
-#ifdef TULIP_DEBUG_WHERE
921
     whereami("tulip_init_ring\n");
873
     whereami("tulip_init_ring\n");
922
-#endif
923
 
874
 
924
     tp->cur_rx = 0;
875
     tp->cur_rx = 0;
925
 
876
 
974
     int i;
925
     int i;
975
     unsigned long to;
926
     unsigned long to;
976
 
927
 
977
-#ifdef TULIP_DEBUG_WHERE
978
     whereami("tulip_reset\n");
928
     whereami("tulip_reset\n");
979
-#endif
980
 
929
 
981
     /* Stop Tx and RX */
930
     /* Stop Tx and RX */
982
     outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
931
     outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
1071
 	    /* wait */ ;
1020
 	    /* wait */ ;
1072
 
1021
 
1073
 	if (currticks() >= to) {
1022
 	if (currticks() >= to) {
1074
-	    printf ("%s: TX Setup Timeout.\n", tp->nic_name);
1023
+	    DBG ("%s: TX Setup Timeout.\n", tp->nic_name);
1075
 	}
1024
 	}
1076
     }
1025
     }
1077
 
1026
 
1095
     u32 to;
1044
     u32 to;
1096
     u32 csr6 = inl(ioaddr + CSR6);
1045
     u32 csr6 = inl(ioaddr + CSR6);
1097
 
1046
 
1098
-#ifdef TULIP_DEBUG_WHERE    
1099
     whereami("tulip_transmit\n");
1047
     whereami("tulip_transmit\n");
1100
-#endif
1101
 
1048
 
1102
     /* Disable Tx */
1049
     /* Disable Tx */
1103
     outl(csr6 & ~0x00002000, ioaddr + CSR6);
1050
     outl(csr6 & ~0x00002000, ioaddr + CSR6);
1115
     while (s < ETH_ZLEN)  
1062
     while (s < ETH_ZLEN)  
1116
         txb[s++] = '\0';
1063
         txb[s++] = '\0';
1117
 
1064
 
1118
-#ifdef TULIP_DEBUG
1119
-    if (tulip_debug > 1)
1120
-	printf("%s: sending %d bytes ethtype %hX\n", tp->nic_name, s, t);
1121
-#endif
1065
+    DBG2("%s: sending %d bytes ethtype %hX\n", tp->nic_name, s, t);
1122
         
1066
         
1123
     /* setup the transmit descriptor */
1067
     /* setup the transmit descriptor */
1124
     /* 0x60000000 = no interrupt on completion */
1068
     /* 0x60000000 = no interrupt on completion */
1138
         /* wait */ ;
1082
         /* wait */ ;
1139
 
1083
 
1140
     if (currticks() >= to) {
1084
     if (currticks() >= to) {
1141
-        printf ("TX Timeout!\n");
1085
+        DBG ("TX Timeout!\n");
1142
     }
1086
     }
1143
 
1087
 
1144
     /* Disable Tx */
1088
     /* Disable Tx */
1151
 static int tulip_poll(struct nic *nic, int retrieve)
1095
 static int tulip_poll(struct nic *nic, int retrieve)
1152
 {
1096
 {
1153
 
1097
 
1154
-#ifdef TULIP_DEBUG_WHERE
1155
     whereami("tulip_poll\n");
1098
     whereami("tulip_poll\n");
1156
-#endif
1157
 
1099
 
1158
     /* no packet waiting. packet still owned by NIC */
1100
     /* no packet waiting. packet still owned by NIC */
1159
     if (rx_ring[tp->cur_rx].status & 0x80000000)
1101
     if (rx_ring[tp->cur_rx].status & 0x80000000)
1161
 
1103
 
1162
     if ( ! retrieve ) return 1;
1104
     if ( ! retrieve ) return 1;
1163
 
1105
 
1164
-#ifdef TULIP_DEBUG_WHERE
1165
     whereami("tulip_poll got one\n");
1106
     whereami("tulip_poll got one\n");
1166
-#endif
1167
 
1107
 
1168
     nic->packetlen = (rx_ring[tp->cur_rx].status & 0x3FFF0000) >> 16;
1108
     nic->packetlen = (rx_ring[tp->cur_rx].status & 0x3FFF0000) >> 16;
1169
 
1109
 
1190
 /*********************************************************************/
1130
 /*********************************************************************/
1191
 static void tulip_disable ( struct nic *nic ) {
1131
 static void tulip_disable ( struct nic *nic ) {
1192
 
1132
 
1193
-#ifdef TULIP_DEBUG_WHERE
1194
     whereami("tulip_disable\n");
1133
     whereami("tulip_disable\n");
1195
-#endif
1196
 
1134
 
1197
     tulip_reset(nic);
1135
     tulip_reset(nic);
1198
 
1136
 
1269
     /* Clear the missed-packet counter. */
1207
     /* Clear the missed-packet counter. */
1270
     inl(ioaddr + CSR8);
1208
     inl(ioaddr + CSR8);
1271
 
1209
 
1272
-    printf("\n");                /* so we start on a fresh line */
1273
-#ifdef TULIP_DEBUG_WHERE
1210
+    DBG("\n");                /* so we start on a fresh line */
1274
     whereami("tulip_probe\n");
1211
     whereami("tulip_probe\n");
1275
-#endif
1276
 
1212
 
1277
-#ifdef TULIP_DEBUG
1278
-    if (tulip_debug > 1)
1279
-	printf ("%s: Looking for Tulip Chip: Vendor=%hX  Device=%hX\n", tp->nic_name,
1280
-		tp->vendor, tp->dev_id);
1281
-#endif
1213
+    DBG2 ("%s: Looking for Tulip Chip: Vendor=%hX  Device=%hX\n", tp->nic_name,
1214
+	  tp->vendor_id, tp->dev_id);
1282
 
1215
 
1283
     /* Figure out which chip we're dealing with */
1216
     /* Figure out which chip we're dealing with */
1284
     i = 0;
1217
     i = 0;
1294
     }
1227
     }
1295
 
1228
 
1296
     if (chip_idx == -1) {
1229
     if (chip_idx == -1) {
1297
-        printf ("%s: Unknown Tulip Chip: Vendor=%hX  Device=%hX\n", tp->nic_name,
1230
+        DBG ("%s: Unknown Tulip Chip: Vendor=%hX  Device=%hX\n", tp->nic_name,
1298
                 tp->vendor_id, tp->dev_id);
1231
                 tp->vendor_id, tp->dev_id);
1299
         return 0;
1232
         return 0;
1300
     }
1233
     }
1302
     tp->pci_id_idx = i;
1235
     tp->pci_id_idx = i;
1303
     tp->flags = tulip_tbl[chip_idx].flags;
1236
     tp->flags = tulip_tbl[chip_idx].flags;
1304
 
1237
 
1305
-#ifdef TULIP_DEBUG
1306
-    if (tulip_debug > 1) {
1307
-	printf ("%s: tp->pci_id_idx == %d,  name == %s\n", tp->nic_name, 
1308
-		tp->pci_id_idx, pci_id_tbl[tp->pci_id_idx].name);
1309
-	printf ("%s: chip_idx == %d, name == %s\n", tp->nic_name, chip_idx, 
1310
-		tulip_tbl[chip_idx].chip_name);
1311
-    }
1312
-#endif
1238
+    DBG2 ("%s: tp->pci_id_idx == %d,  name == %s\n", tp->nic_name,
1239
+	  tp->pci_id_idx, pci_id_tbl[tp->pci_id_idx].name);
1240
+    DBG2 ("%s: chip_idx == %d, name == %s\n", tp->nic_name, chip_idx,
1241
+	  tulip_tbl[chip_idx].chip_name);
1313
   
1242
   
1314
     /* Bring the 21041/21143 out of sleep mode.
1243
     /* Bring the 21041/21143 out of sleep mode.
1315
        Caution: Snooze mode does not work with some boards! */
1244
        Caution: Snooze mode does not work with some boards! */
1317
         pci_write_config_dword(pci, 0x40, 0x00000000);
1246
         pci_write_config_dword(pci, 0x40, 0x00000000);
1318
 
1247
 
1319
     if (inl(ioaddr + CSR5) == 0xFFFFFFFF) {
1248
     if (inl(ioaddr + CSR5) == 0xFFFFFFFF) {
1320
-        printf("%s: The Tulip chip at %X is not functioning.\n",
1249
+        DBG("%s: The Tulip chip at %X is not functioning.\n",
1321
                tp->nic_name, (unsigned int) ioaddr);
1250
                tp->nic_name, (unsigned int) ioaddr);
1322
         return 0;
1251
         return 0;
1323
     }
1252
     }
1324
    
1253
    
1325
     pci_read_config_byte(pci, PCI_REVISION, &chip_rev);
1254
     pci_read_config_byte(pci, PCI_REVISION, &chip_rev);
1326
 
1255
 
1327
-    printf("%s: [chip: %s] rev %d at %hX\n", tp->nic_name,
1256
+    DBG("%s: [chip: %s] rev %d at %hX\n", tp->nic_name,
1328
            tulip_tbl[chip_idx].chip_name, chip_rev, (unsigned int) ioaddr);
1257
            tulip_tbl[chip_idx].chip_name, chip_rev, (unsigned int) ioaddr);
1329
-    printf("%s: Vendor=%hX  Device=%hX", tp->nic_name, tp->vendor_id, tp->dev_id);
1258
+    DBG("%s: Vendor=%hX  Device=%hX", tp->nic_name, tp->vendor_id, tp->dev_id);
1330
 
1259
 
1331
     if (chip_idx == DC21041  &&  inl(ioaddr + CSR9) & 0x8000) {
1260
     if (chip_idx == DC21041  &&  inl(ioaddr + CSR9) & 0x8000) {
1332
-        printf(" 21040 compatible mode.");
1261
+        DBG(" 21040 compatible mode.");
1333
         chip_idx = DC21040;
1262
         chip_idx = DC21040;
1334
     }
1263
     }
1335
 
1264
 
1336
-    printf("\n");
1265
+    DBG("\n");
1337
 
1266
 
1338
     /* The SROM/EEPROM interface varies dramatically. */
1267
     /* The SROM/EEPROM interface varies dramatically. */
1339
     sum = 0;
1268
     sum = 0;
1396
         }
1325
         }
1397
 
1326
 
1398
     if (sum == 0  || sum == ETH_ALEN*0xff) {
1327
     if (sum == 0  || sum == ETH_ALEN*0xff) {
1399
-        printf("%s: EEPROM not present!\n", tp->nic_name);
1328
+        DBG("%s: EEPROM not present!\n", tp->nic_name);
1400
         for (i = 0; i < ETH_ALEN-1; i++)
1329
         for (i = 0; i < ETH_ALEN-1; i++)
1401
             nic->node_addr[i] = last_phys_addr[i];
1330
             nic->node_addr[i] = last_phys_addr[i];
1402
         nic->node_addr[i] = last_phys_addr[i] + 1;
1331
         nic->node_addr[i] = last_phys_addr[i] + 1;
1449
 {
1378
 {
1450
     int i;
1379
     int i;
1451
 
1380
 
1452
-#ifdef TULIP_DEBUG_WHERE
1453
     whereami("start_link\n");
1381
     whereami("start_link\n");
1454
-#endif
1455
 
1382
 
1456
     if ((tp->flags & ALWAYS_CHECK_MII) ||
1383
     if ((tp->flags & ALWAYS_CHECK_MII) ||
1457
         (tp->mtable  &&  tp->mtable->has_mii) ||
1384
         (tp->mtable  &&  tp->mtable->has_mii) ||
1486
                     tp->mii_advertise = to_advert = mii_advert;
1413
                     tp->mii_advertise = to_advert = mii_advert;
1487
 
1414
 
1488
                 tp->phys[phy_idx++] = phy;
1415
                 tp->phys[phy_idx++] = phy;
1489
-                printf("%s:  MII transceiver %d config %hX status %hX advertising %hX.\n",
1416
+                DBG("%s:  MII transceiver %d config %hX status %hX advertising %hX.\n",
1490
                        tp->nic_name, phy, mii_reg0, mii_status, mii_advert);
1417
                        tp->nic_name, phy, mii_reg0, mii_status, mii_advert);
1491
                                 /* Fixup for DLink with miswired PHY. */
1418
                                 /* Fixup for DLink with miswired PHY. */
1492
                 if (mii_advert != to_advert) {
1419
                 if (mii_advert != to_advert) {
1493
-                    printf("%s:  Advertising %hX on PHY %d previously advertising %hX.\n",
1420
+                    DBG("%s:  Advertising %hX on PHY %d previously advertising %hX.\n",
1494
                            tp->nic_name, to_advert, phy, mii_advert);
1421
                            tp->nic_name, to_advert, phy, mii_advert);
1495
                     mdio_write(nic, phy, 4, to_advert);
1422
                     mdio_write(nic, phy, 4, to_advert);
1496
                 }
1423
                 }
1502
         }
1429
         }
1503
         tp->mii_cnt = phy_idx;
1430
         tp->mii_cnt = phy_idx;
1504
         if (tp->mtable  &&  tp->mtable->has_mii  &&  phy_idx == 0) {
1431
         if (tp->mtable  &&  tp->mtable->has_mii  &&  phy_idx == 0) {
1505
-            printf("%s: ***WARNING***: No MII transceiver found!\n",
1432
+            DBG("%s: ***WARNING***: No MII transceiver found!\n",
1506
                    tp->nic_name);
1433
                    tp->nic_name);
1507
             tp->phys[0] = 1;
1434
             tp->phys[0] = 1;
1508
         }
1435
         }
1569
     int csr14 = ((tp->sym_advertise & 0x0780) << 9)  |
1496
     int csr14 = ((tp->sym_advertise & 0x0780) << 9)  |
1570
         ((tp->sym_advertise&0x0020)<<1) | 0xffbf;
1497
         ((tp->sym_advertise&0x0020)<<1) | 0xffbf;
1571
 
1498
 
1572
-#ifdef TULIP_DEBUG_WHERE
1573
     whereami("nway_start\n");
1499
     whereami("nway_start\n");
1574
-#endif
1575
 
1500
 
1576
     tp->if_port = 0;
1501
     tp->if_port = 0;
1577
     tp->nway = tp->mediasense = 1;
1502
     tp->nway = tp->mediasense = 1;
1580
         tp->csr6 = 0x01000000 | (tp->sym_advertise & 0x0040 ? 0x0200 : 0);
1505
         tp->csr6 = 0x01000000 | (tp->sym_advertise & 0x0040 ? 0x0200 : 0);
1581
         return;
1506
         return;
1582
     }
1507
     }
1583
-#ifdef TULIP_DEBUG
1584
-    if (tulip_debug > 1)
1585
-        printf("%s: Restarting internal NWay autonegotiation, %X.\n",
1586
-               tp->nic_name, csr14);
1587
-#endif
1508
+    DBG2("%s: Restarting internal NWay autonegotiation, %X.\n",
1509
+	 tp->nic_name, csr14);
1588
     outl(0x0001, ioaddr + CSR13);
1510
     outl(0x0001, ioaddr + CSR13);
1589
     outl(csr14, ioaddr + CSR14);
1511
     outl(csr14, ioaddr + CSR14);
1590
     tp->csr6 = 0x82420000 | (tp->sym_advertise & 0x0040 ? 0x0200 : 0);
1512
     tp->csr6 = 0x82420000 | (tp->sym_advertise & 0x0040 ? 0x0200 : 0);
1604
 {
1526
 {
1605
     int i;
1527
     int i;
1606
 
1528
 
1607
-#ifdef TULIP_DEBUG_WHERE
1608
     whereami("init_media\n");
1529
     whereami("init_media\n");
1609
-#endif
1610
 
1530
 
1611
     tp->saved_if_port = tp->if_port;
1531
     tp->saved_if_port = tp->if_port;
1612
     if (tp->if_port == 0)
1532
     if (tp->if_port == 0)
1621
             (tp->if_port == 12 ? 0 : tp->if_port);
1541
             (tp->if_port == 12 ? 0 : tp->if_port);
1622
         for (i = 0; i < tp->mtable->leafcount; i++)
1542
         for (i = 0; i < tp->mtable->leafcount; i++)
1623
             if (tp->mtable->mleaf[i].media == looking_for) {
1543
             if (tp->mtable->mleaf[i].media == looking_for) {
1624
-                printf("%s: Using user-specified media %s.\n",
1544
+                DBG("%s: Using user-specified media %s.\n",
1625
                        tp->nic_name, medianame[tp->if_port]);
1545
                        tp->nic_name, medianame[tp->if_port]);
1626
                 goto media_picked;
1546
                 goto media_picked;
1627
             }
1547
             }
1630
         int looking_for = tp->mtable->defaultmedia & 15;
1550
         int looking_for = tp->mtable->defaultmedia & 15;
1631
         for (i = 0; i < tp->mtable->leafcount; i++)
1551
         for (i = 0; i < tp->mtable->leafcount; i++)
1632
             if (tp->mtable->mleaf[i].media == looking_for) {
1552
             if (tp->mtable->mleaf[i].media == looking_for) {
1633
-                printf("%s: Using EEPROM-set media %s.\n",
1553
+                DBG("%s: Using EEPROM-set media %s.\n",
1634
                        tp->nic_name, medianame[looking_for]);
1554
                        tp->nic_name, medianame[looking_for]);
1635
                 goto media_picked;
1555
                 goto media_picked;
1636
             }
1556
             }
1663
     case DC21142:
1583
     case DC21142:
1664
         if (tp->mii_cnt) {
1584
         if (tp->mii_cnt) {
1665
             select_media(nic, 1);
1585
             select_media(nic, 1);
1666
-#ifdef TULIP_DEBUG
1667
-            if (tulip_debug > 1)
1668
-                printf("%s: Using MII transceiver %d, status %hX.\n",
1669
-                       tp->nic_name, tp->phys[0], mdio_read(nic, tp->phys[0], 1));
1670
-#endif
1586
+	    DBG2("%s: Using MII transceiver %d, status %hX.\n",
1587
+		 tp->nic_name, tp->phys[0], mdio_read(nic, tp->phys[0], 1));
1671
             outl(0x82020000, ioaddr + CSR6);
1588
             outl(0x82020000, ioaddr + CSR6);
1672
             tp->csr6 = 0x820E0000;
1589
             tp->csr6 = 0x820E0000;
1673
             tp->if_port = 11;
1590
             tp->if_port = 11;
1725
     u32 phy_reg = inl(ioaddr + 0xB8);
1642
     u32 phy_reg = inl(ioaddr + 0xB8);
1726
     u32 new_csr6 = tp->csr6 & ~0x40C40200;
1643
     u32 new_csr6 = tp->csr6 & ~0x40C40200;
1727
 
1644
 
1728
-#ifdef TULIP_DEBUG_WHERE
1729
     whereami("pnic_do_nway\n");
1645
     whereami("pnic_do_nway\n");
1730
-#endif
1731
 
1646
 
1732
     if (phy_reg & 0x78000000) { /* Ignore baseT4 */
1647
     if (phy_reg & 0x78000000) { /* Ignore baseT4 */
1733
         if (phy_reg & 0x20000000)               tp->if_port = 5;
1648
         if (phy_reg & 0x20000000)               tp->if_port = 5;
1743
             tp->full_duplex = 1;
1658
             tp->full_duplex = 1;
1744
             new_csr6 |= 0x00000200;
1659
             new_csr6 |= 0x00000200;
1745
         }
1660
         }
1746
-#ifdef TULIP_DEBUG
1747
-        if (tulip_debug > 1)
1748
-            printf("%s: PNIC autonegotiated status %X, %s.\n",
1749
-                   tp->nic_name, phy_reg, medianame[tp->if_port]);
1750
-#endif
1661
+	DBG2("%s: PNIC autonegotiated status %X, %s.\n",
1662
+	     tp->nic_name, phy_reg, medianame[tp->if_port]);
1751
         if (tp->csr6 != new_csr6) {
1663
         if (tp->csr6 != new_csr6) {
1752
             tp->csr6 = new_csr6;
1664
             tp->csr6 = new_csr6;
1753
             outl(tp->csr6 | 0x0002, ioaddr + CSR6);     /* Restart Tx */
1665
             outl(tp->csr6 | 0x0002, ioaddr + CSR6);     /* Restart Tx */
1763
     u32 new_csr6;
1675
     u32 new_csr6;
1764
     int i;
1676
     int i;
1765
 
1677
 
1766
-#ifdef TULIP_DEBUG_WHERE
1767
     whereami("select_media\n");
1678
     whereami("select_media\n");
1768
-#endif
1769
 
1679
 
1770
     if (mtable) {
1680
     if (mtable) {
1771
         struct medialeaf *mleaf = &mtable->mleaf[tp->cur_index];
1681
         struct medialeaf *mleaf = &mtable->mleaf[tp->cur_index];
1772
         unsigned char *p = mleaf->leafdata;
1682
         unsigned char *p = mleaf->leafdata;
1773
         switch (mleaf->type) {
1683
         switch (mleaf->type) {
1774
         case 0:                                 /* 21140 non-MII xcvr. */
1684
         case 0:                                 /* 21140 non-MII xcvr. */
1775
-#ifdef TULIP_DEBUG
1776
-            if (tulip_debug > 1)
1777
-                printf("%s: Using a 21140 non-MII transceiver"
1778
-                       " with control setting %hhX.\n",
1779
-                       tp->nic_name, p[1]);
1780
-#endif
1685
+            DBG2("%s: Using a 21140 non-MII transceiver"
1686
+		 " with control setting %hhX.\n",
1687
+		 tp->nic_name, p[1]);
1781
             tp->if_port = p[0];
1688
             tp->if_port = p[0];
1782
             if (startup)
1689
             if (startup)
1783
                 outl(mtable->csr12dir | 0x100, ioaddr + CSR12);
1690
                 outl(mtable->csr12dir | 0x100, ioaddr + CSR12);
1797
             if (startup && mtable->has_reset) {
1704
             if (startup && mtable->has_reset) {
1798
                 struct medialeaf *rleaf = &mtable->mleaf[mtable->has_reset];
1705
                 struct medialeaf *rleaf = &mtable->mleaf[mtable->has_reset];
1799
                 unsigned char *rst = rleaf->leafdata;
1706
                 unsigned char *rst = rleaf->leafdata;
1800
-#ifdef TULIP_DEBUG
1801
-                if (tulip_debug > 1)
1802
-                    printf("%s: Resetting the transceiver.\n",
1803
-                           tp->nic_name);
1804
-#endif
1707
+		DBG2("%s: Resetting the transceiver.\n",
1708
+		     tp->nic_name);
1805
                 for (i = 0; i < rst[0]; i++)
1709
                 for (i = 0; i < rst[0]; i++)
1806
                     outl(get_u16(rst + 1 + (i<<1)) << 16, ioaddr + CSR15);
1710
                     outl(get_u16(rst + 1 + (i<<1)) << 16, ioaddr + CSR15);
1807
             }
1711
             }
1808
-#ifdef TULIP_DEBUG
1809
-            if (tulip_debug > 1)
1810
-                printf("%s: 21143 non-MII %s transceiver control "
1811
-                       "%hX/%hX.\n",
1812
-                       tp->nic_name, medianame[tp->if_port], setup[0], setup[1]);
1813
-#endif
1712
+	    DBG2("%s: 21143 non-MII %s transceiver control %hX/%hX.\n",
1713
+		 tp->nic_name, medianame[tp->if_port], setup[0], setup[1]);
1814
             if (p[0] & 0x40) {  /* SIA (CSR13-15) setup values are provided. */
1714
             if (p[0] & 0x40) {  /* SIA (CSR13-15) setup values are provided. */
1815
                 csr13val = setup[0];
1715
                 csr13val = setup[0];
1816
                 csr14val = setup[1];
1716
                 csr14val = setup[1];
1836
                 outl(csr15val, ioaddr + CSR15); /* Data */
1736
                 outl(csr15val, ioaddr + CSR15); /* Data */
1837
                 if (startup) outl(csr13val, ioaddr + CSR13);
1737
                 if (startup) outl(csr13val, ioaddr + CSR13);
1838
             }
1738
             }
1839
-#ifdef TULIP_DEBUG
1840
-            if (tulip_debug > 1)
1841
-                printf("%s:  Setting CSR15 to %X/%X.\n",
1842
-                       tp->nic_name, csr15dir, csr15val);
1843
-#endif
1739
+	    DBG2("%s:  Setting CSR15 to %X/%X.\n",
1740
+		 tp->nic_name, csr15dir, csr15val);
1844
             if (mleaf->type == 4)
1741
             if (mleaf->type == 4)
1845
                 new_csr6 = 0x82020000 | ((setup[2] & 0x71) << 18);
1742
                 new_csr6 = 0x82020000 | ((setup[2] & 0x71) << 18);
1846
             else
1743
             else
1881
             if (startup < 2) {
1778
             if (startup < 2) {
1882
                 if (tp->mii_advertise == 0)
1779
                 if (tp->mii_advertise == 0)
1883
                     tp->mii_advertise = tp->advertising[phy_num];
1780
                     tp->mii_advertise = tp->advertising[phy_num];
1884
-#ifdef TULIP_DEBUG
1885
-                if (tulip_debug > 1)
1886
-                    printf("%s:  Advertising %hX on MII %d.\n",
1887
-                           tp->nic_name, tp->mii_advertise, tp->phys[phy_num]);
1888
-#endif
1781
+		DBG2("%s:  Advertising %hX on MII %d.\n",
1782
+		     tp->nic_name, tp->mii_advertise, tp->phys[phy_num]);
1889
                 mdio_write(nic, tp->phys[phy_num], 4, tp->mii_advertise);
1783
                 mdio_write(nic, tp->phys[phy_num], 4, tp->mii_advertise);
1890
             }
1784
             }
1891
             break;
1785
             break;
1892
         }
1786
         }
1893
         default:
1787
         default:
1894
-            printf("%s:  Invalid media table selection %d.\n",
1788
+            DBG("%s:  Invalid media table selection %d.\n",
1895
                    tp->nic_name, mleaf->type);
1789
                    tp->nic_name, mleaf->type);
1896
             new_csr6 = 0x020E0000;
1790
             new_csr6 = 0x020E0000;
1897
         }
1791
         }
1898
-#ifdef TULIP_DEBUG
1899
-        if (tulip_debug > 1)
1900
-            printf("%s: Using media type %s, CSR12 is %hhX.\n",
1901
-                   tp->nic_name, medianame[tp->if_port],
1902
-                   inl(ioaddr + CSR12) & 0xff);
1903
-#endif
1792
+	DBG2("%s: Using media type %s, CSR12 is %hhX.\n",
1793
+	     tp->nic_name, medianame[tp->if_port],
1794
+	     inl(ioaddr + CSR12) & 0xff);
1904
     } else if (tp->chip_id == DC21041) {
1795
     } else if (tp->chip_id == DC21041) {
1905
         int port = tp->if_port <= 4 ? tp->if_port : 0;
1796
         int port = tp->if_port <= 4 ? tp->if_port : 0;
1906
-#ifdef TULIP_DEBUG
1907
-        if (tulip_debug > 1)
1908
-            printf("%s: 21041 using media %s, CSR12 is %hX.\n",
1909
-                   tp->nic_name, medianame[port == 3 ? 12: port],
1910
-                   inl(ioaddr + CSR12));
1911
-#endif
1797
+	DBG2("%s: 21041 using media %s, CSR12 is %hX.\n",
1798
+	     tp->nic_name, medianame[port == 3 ? 12: port],
1799
+	     inl(ioaddr + CSR12));
1912
         outl(0x00000000, ioaddr + CSR13); /* Reset the serial interface */
1800
         outl(0x00000000, ioaddr + CSR13); /* Reset the serial interface */
1913
         outl(t21041_csr14[port], ioaddr + CSR14);
1801
         outl(t21041_csr14[port], ioaddr + CSR14);
1914
         outl(t21041_csr15[port], ioaddr + CSR15);
1802
         outl(t21041_csr15[port], ioaddr + CSR15);
1917
     } else if (tp->chip_id == LC82C168) {
1805
     } else if (tp->chip_id == LC82C168) {
1918
         if (startup && ! tp->medialock)
1806
         if (startup && ! tp->medialock)
1919
             tp->if_port = tp->mii_cnt ? 11 : 0;
1807
             tp->if_port = tp->mii_cnt ? 11 : 0;
1920
-#ifdef TULIP_DEBUG
1921
-        if (tulip_debug > 1)
1922
-	    printf("%s: PNIC PHY status is %hX, media %s.\n",
1923
-                   tp->nic_name, inl(ioaddr + 0xB8), medianame[tp->if_port]);
1924
-#endif
1808
+	DBG2("%s: PNIC PHY status is %hX, media %s.\n",
1809
+	     tp->nic_name, inl(ioaddr + 0xB8), medianame[tp->if_port]);
1925
         if (tp->mii_cnt) {
1810
         if (tp->mii_cnt) {
1926
             new_csr6 = 0x810C0000;
1811
             new_csr6 = 0x810C0000;
1927
             outl(0x0001, ioaddr + CSR15);
1812
             outl(0x0001, ioaddr + CSR15);
1944
         }
1829
         }
1945
     } else if (tp->chip_id == DC21040) {                                        /* 21040 */
1830
     } else if (tp->chip_id == DC21040) {                                        /* 21040 */
1946
         /* Turn on the xcvr interface. */
1831
         /* Turn on the xcvr interface. */
1947
-#ifdef TULIP_DEBUG
1948
         int csr12 = inl(ioaddr + CSR12);
1832
         int csr12 = inl(ioaddr + CSR12);
1949
-        if (tulip_debug > 1)
1950
-            printf("%s: 21040 media type is %s, CSR12 is %hhX.\n",
1951
-                   tp->nic_name, medianame[tp->if_port], csr12);
1952
-#endif
1833
+	DBG2("%s: 21040 media type is %s, CSR12 is %hhX.\n",
1834
+	     tp->nic_name, medianame[tp->if_port], csr12);
1953
         if (media_cap[tp->if_port] & MediaAlwaysFD)
1835
         if (media_cap[tp->if_port] & MediaAlwaysFD)
1954
             tp->full_duplex = 1;
1836
             tp->full_duplex = 1;
1955
         new_csr6 = 0x20000;
1837
         new_csr6 = 0x20000;
1973
             new_csr6 = 0x028600000;
1855
             new_csr6 = 0x028600000;
1974
         } else
1856
         } else
1975
             new_csr6 = 0x038600000;
1857
             new_csr6 = 0x038600000;
1976
-#ifdef TULIP_DEBUG
1977
-        if (tulip_debug > 1)
1978
-            printf("%s: No media description table, assuming "
1979
-                   "%s transceiver, CSR12 %hhX.\n",
1980
-                   tp->nic_name, medianame[tp->if_port],
1981
-                   inl(ioaddr + CSR12));
1982
-#endif
1858
+	DBG2("%s: No media description table, assuming "
1859
+	     "%s transceiver, CSR12 %hhX.\n",
1860
+	     tp->nic_name, medianame[tp->if_port],
1861
+	     inl(ioaddr + CSR12));
1983
     }
1862
     }
1984
 
1863
 
1985
     tp->csr6 = new_csr6 | (tp->csr6 & 0xfdff) | (tp->full_duplex ? 0x0200 : 0);
1864
     tp->csr6 = new_csr6 | (tp->csr6 & 0xfdff) | (tp->full_duplex ? 0x0200 : 0);
1999
         bmsr = mdio_read(nic, tp->phys[0], 1);
1878
         bmsr = mdio_read(nic, tp->phys[0], 1);
2000
         lpa = mdio_read(nic, tp->phys[0], 5);
1879
         lpa = mdio_read(nic, tp->phys[0], 5);
2001
 
1880
 
2002
-#ifdef TULIP_DEBUG
2003
-        if (tulip_debug > 1)
2004
-                printf("%s: MII status %#x, Link partner report "
2005
-                           "%#x.\n", tp->nic_name, bmsr, lpa);
2006
-#endif
1881
+	DBG2("%s: MII status %#x, Link partner report %#x.\n",
1882
+	     tp->nic_name, bmsr, lpa);
2007
 
1883
 
2008
         if (bmsr == 0xffff)
1884
         if (bmsr == 0xffff)
2009
                 return -2;
1885
                 return -2;
2010
         if ((bmsr & 4) == 0) { 
1886
         if ((bmsr & 4) == 0) { 
2011
                 int new_bmsr = mdio_read(nic, tp->phys[0], 1); 
1887
                 int new_bmsr = mdio_read(nic, tp->phys[0], 1); 
2012
                 if ((new_bmsr & 4) == 0) { 
1888
                 if ((new_bmsr & 4) == 0) { 
2013
-#ifdef TULIP_DEBUG
2014
-                        if (tulip_debug  > 1)
2015
-                                printf("%s: No link beat on the MII interface,"
2016
-                                           " status %#x.\n", tp->nic_name, 
2017
-                                           new_bmsr);
2018
-#endif
1889
+			DBG2("%s: No link beat on the MII interface,"
1890
+			     " status %#x.\n", tp->nic_name,
1891
+			     new_bmsr);
2019
                         return -1;
1892
                         return -1;
2020
                 }
1893
                 }
2021
         }
1894
         }
2032
         if (new_csr6 != tp->csr6) {
1905
         if (new_csr6 != tp->csr6) {
2033
                 tp->csr6 = new_csr6;
1906
                 tp->csr6 = new_csr6;
2034
 
1907
 
2035
-#ifdef TULIP_DEBUG
2036
-                if (tulip_debug > 0)
2037
-                        printf("%s: Setting %s-duplex based on MII"
2038
-                                   "#%d link partner capability of %#x.\n",
2039
-                                   tp->nic_name, 
2040
-                                   tp->full_duplex ? "full" : "half",
2041
-                                   tp->phys[0], lpa);
2042
-#endif
1908
+		DBG("%s: Setting %s-duplex based on MII"
1909
+		    "#%d link partner capability of %#x.\n",
1910
+		    tp->nic_name,
1911
+		    tp->full_duplex ? "full" : "half",
1912
+		    tp->phys[0], lpa);
2043
                 return 1;
1913
                 return 1;
2044
         }
1914
         }
2045
 
1915
 

Loading…
Cancel
Save