162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci drivers/net/ethernet/dec/tulip/pnic2.c 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci Copyright 2000,2001 The Linux Kernel Team 562306a36Sopenharmony_ci Written/copyright 1994-2001 by Donald Becker. 662306a36Sopenharmony_ci Modified to hep support PNIC_II by Kevin B. Hendricks 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci This software may be used and distributed according to the terms 962306a36Sopenharmony_ci of the GNU General Public License, incorporated herein by reference. 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci Please submit bugs to http://bugzilla.kernel.org/ . 1262306a36Sopenharmony_ci*/ 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci/* Understanding the PNIC_II - everything is this file is based 1662306a36Sopenharmony_ci * on the PNIC_II_PDF datasheet which is sorely lacking in detail 1762306a36Sopenharmony_ci * 1862306a36Sopenharmony_ci * As I understand things, here are the registers and bits that 1962306a36Sopenharmony_ci * explain the masks and constants used in this file that are 2062306a36Sopenharmony_ci * either different from the 21142/3 or important for basic operation. 2162306a36Sopenharmony_ci * 2262306a36Sopenharmony_ci * 2362306a36Sopenharmony_ci * CSR 6 (mask = 0xfe3bd1fd of bits not to change) 2462306a36Sopenharmony_ci * ----- 2562306a36Sopenharmony_ci * Bit 24 - SCR 2662306a36Sopenharmony_ci * Bit 23 - PCS 2762306a36Sopenharmony_ci * Bit 22 - TTM (Trasmit Threshold Mode) 2862306a36Sopenharmony_ci * Bit 18 - Port Select 2962306a36Sopenharmony_ci * Bit 13 - Start - 1, Stop - 0 Transmissions 3062306a36Sopenharmony_ci * Bit 11:10 - Loop Back Operation Mode 3162306a36Sopenharmony_ci * Bit 9 - Full Duplex mode (Advertise 10BaseT-FD is CSR14<7> is set) 3262306a36Sopenharmony_ci * Bit 1 - Start - 1, Stop - 0 Receive 3362306a36Sopenharmony_ci * 3462306a36Sopenharmony_ci * 3562306a36Sopenharmony_ci * CSR 14 (mask = 0xfff0ee39 of bits not to change) 3662306a36Sopenharmony_ci * ------ 3762306a36Sopenharmony_ci * Bit 19 - PAUSE-Pause 3862306a36Sopenharmony_ci * Bit 18 - Advertise T4 3962306a36Sopenharmony_ci * Bit 17 - Advertise 100baseTx-FD 4062306a36Sopenharmony_ci * Bit 16 - Advertise 100baseTx-HD 4162306a36Sopenharmony_ci * Bit 12 - LTE - Link Test Enable 4262306a36Sopenharmony_ci * Bit 7 - ANE - Auto Negotiate Enable 4362306a36Sopenharmony_ci * Bit 6 - HDE - Advertise 10baseT-HD 4462306a36Sopenharmony_ci * Bit 2 - Reset to Power down - kept as 1 for normal operation 4562306a36Sopenharmony_ci * Bit 1 - Loop Back enable for 10baseT MCC 4662306a36Sopenharmony_ci * 4762306a36Sopenharmony_ci * 4862306a36Sopenharmony_ci * CSR 12 4962306a36Sopenharmony_ci * ------ 5062306a36Sopenharmony_ci * Bit 25 - Partner can do T4 5162306a36Sopenharmony_ci * Bit 24 - Partner can do 100baseTx-FD 5262306a36Sopenharmony_ci * Bit 23 - Partner can do 100baseTx-HD 5362306a36Sopenharmony_ci * Bit 22 - Partner can do 10baseT-FD 5462306a36Sopenharmony_ci * Bit 21 - Partner can do 10baseT-HD 5562306a36Sopenharmony_ci * Bit 15 - LPN is 1 if all above bits are valid other wise 0 5662306a36Sopenharmony_ci * Bit 14:12 - autonegotiation state (write 001 to start autonegotiate) 5762306a36Sopenharmony_ci * Bit 3 - Autopolarity state 5862306a36Sopenharmony_ci * Bit 2 - LS10B - link state of 10baseT 0 - good, 1 - failed 5962306a36Sopenharmony_ci * Bit 1 - LS100B - link state of 100baseT 0 - good, 1 - failed 6062306a36Sopenharmony_ci * 6162306a36Sopenharmony_ci * 6262306a36Sopenharmony_ci * Data Port Selection Info 6362306a36Sopenharmony_ci *------------------------- 6462306a36Sopenharmony_ci * 6562306a36Sopenharmony_ci * CSR14<7> CSR6<18> CSR6<22> CSR6<23> CSR6<24> MODE/PORT 6662306a36Sopenharmony_ci * 1 0 0 (X) 0 (X) 1 NWAY 6762306a36Sopenharmony_ci * 0 0 1 0 (X) 0 10baseT 6862306a36Sopenharmony_ci * 0 1 0 1 1 (X) 100baseT 6962306a36Sopenharmony_ci * 7062306a36Sopenharmony_ci * 7162306a36Sopenharmony_ci */ 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci#include "tulip.h" 7662306a36Sopenharmony_ci#include <linux/delay.h> 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_civoid pnic2_timer(struct timer_list *t) 8062306a36Sopenharmony_ci{ 8162306a36Sopenharmony_ci struct tulip_private *tp = from_timer(tp, t, timer); 8262306a36Sopenharmony_ci struct net_device *dev = tp->dev; 8362306a36Sopenharmony_ci void __iomem *ioaddr = tp->base_addr; 8462306a36Sopenharmony_ci int next_tick = 60*HZ; 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci if (tulip_debug > 3) 8762306a36Sopenharmony_ci dev_info(&dev->dev, "PNIC2 negotiation status %08x\n", 8862306a36Sopenharmony_ci ioread32(ioaddr + CSR12)); 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci if (next_tick) { 9162306a36Sopenharmony_ci mod_timer(&tp->timer, RUN_AT(next_tick)); 9262306a36Sopenharmony_ci } 9362306a36Sopenharmony_ci} 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_civoid pnic2_start_nway(struct net_device *dev) 9762306a36Sopenharmony_ci{ 9862306a36Sopenharmony_ci struct tulip_private *tp = netdev_priv(dev); 9962306a36Sopenharmony_ci void __iomem *ioaddr = tp->base_addr; 10062306a36Sopenharmony_ci int csr14; 10162306a36Sopenharmony_ci int csr12; 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci /* set up what to advertise during the negotiation */ 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci /* load in csr14 and mask off bits not to touch 10662306a36Sopenharmony_ci * comment at top of file explains mask value 10762306a36Sopenharmony_ci */ 10862306a36Sopenharmony_ci csr14 = (ioread32(ioaddr + CSR14) & 0xfff0ee39); 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci /* bit 17 - advetise 100baseTx-FD */ 11162306a36Sopenharmony_ci if (tp->sym_advertise & 0x0100) csr14 |= 0x00020000; 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci /* bit 16 - advertise 100baseTx-HD */ 11462306a36Sopenharmony_ci if (tp->sym_advertise & 0x0080) csr14 |= 0x00010000; 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci /* bit 6 - advertise 10baseT-HD */ 11762306a36Sopenharmony_ci if (tp->sym_advertise & 0x0020) csr14 |= 0x00000040; 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci /* Now set bit 12 Link Test Enable, Bit 7 Autonegotiation Enable 12062306a36Sopenharmony_ci * and bit 0 Don't PowerDown 10baseT 12162306a36Sopenharmony_ci */ 12262306a36Sopenharmony_ci csr14 |= 0x00001184; 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci if (tulip_debug > 1) 12562306a36Sopenharmony_ci netdev_dbg(dev, "Restarting PNIC2 autonegotiation, csr14=%08x\n", 12662306a36Sopenharmony_ci csr14); 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci /* tell pnic2_lnk_change we are doing an nway negotiation */ 12962306a36Sopenharmony_ci dev->if_port = 0; 13062306a36Sopenharmony_ci tp->nway = tp->mediasense = 1; 13162306a36Sopenharmony_ci tp->nwayset = tp->lpar = 0; 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci /* now we have to set up csr6 for NWAY state */ 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci tp->csr6 = ioread32(ioaddr + CSR6); 13662306a36Sopenharmony_ci if (tulip_debug > 1) 13762306a36Sopenharmony_ci netdev_dbg(dev, "On Entry to Nway, csr6=%08x\n", tp->csr6); 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci /* mask off any bits not to touch 14062306a36Sopenharmony_ci * comment at top of file explains mask value 14162306a36Sopenharmony_ci */ 14262306a36Sopenharmony_ci tp->csr6 = tp->csr6 & 0xfe3bd1fd; 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci /* don't forget that bit 9 is also used for advertising */ 14562306a36Sopenharmony_ci /* advertise 10baseT-FD for the negotiation (bit 9) */ 14662306a36Sopenharmony_ci if (tp->sym_advertise & 0x0040) tp->csr6 |= 0x00000200; 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci /* set bit 24 for nway negotiation mode ... 14962306a36Sopenharmony_ci * see Data Port Selection comment at top of file 15062306a36Sopenharmony_ci * and "Stop" - reset both Transmit (bit 13) and Receive (bit 1) 15162306a36Sopenharmony_ci */ 15262306a36Sopenharmony_ci tp->csr6 |= 0x01000000; 15362306a36Sopenharmony_ci iowrite32(csr14, ioaddr + CSR14); 15462306a36Sopenharmony_ci iowrite32(tp->csr6, ioaddr + CSR6); 15562306a36Sopenharmony_ci udelay(100); 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_ci /* all set up so now force the negotiation to begin */ 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci /* read in current values and mask off all but the 16062306a36Sopenharmony_ci * Autonegotiation bits 14:12. Writing a 001 to those bits 16162306a36Sopenharmony_ci * should start the autonegotiation 16262306a36Sopenharmony_ci */ 16362306a36Sopenharmony_ci csr12 = (ioread32(ioaddr + CSR12) & 0xffff8fff); 16462306a36Sopenharmony_ci csr12 |= 0x1000; 16562306a36Sopenharmony_ci iowrite32(csr12, ioaddr + CSR12); 16662306a36Sopenharmony_ci} 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_civoid pnic2_lnk_change(struct net_device *dev, int csr5) 17162306a36Sopenharmony_ci{ 17262306a36Sopenharmony_ci struct tulip_private *tp = netdev_priv(dev); 17362306a36Sopenharmony_ci void __iomem *ioaddr = tp->base_addr; 17462306a36Sopenharmony_ci int csr14; 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci /* read the staus register to find out what is up */ 17762306a36Sopenharmony_ci int csr12 = ioread32(ioaddr + CSR12); 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci if (tulip_debug > 1) 18062306a36Sopenharmony_ci dev_info(&dev->dev, 18162306a36Sopenharmony_ci "PNIC2 link status interrupt %08x, CSR5 %x, %08x\n", 18262306a36Sopenharmony_ci csr12, csr5, ioread32(ioaddr + CSR14)); 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci /* If NWay finished and we have a negotiated partner capability. 18562306a36Sopenharmony_ci * check bits 14:12 for bit pattern 101 - all is good 18662306a36Sopenharmony_ci */ 18762306a36Sopenharmony_ci if (tp->nway && !tp->nwayset) { 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_ci /* we did an auto negotiation */ 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci if ((csr12 & 0x7000) == 0x5000) { 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ci /* negotiation ended successfully */ 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci /* get the link partners reply and mask out all but 19662306a36Sopenharmony_ci * bits 24-21 which show the partners capabilities 19762306a36Sopenharmony_ci * and match those to what we advertised 19862306a36Sopenharmony_ci * 19962306a36Sopenharmony_ci * then begin to interpret the results of the negotiation. 20062306a36Sopenharmony_ci * Always go in this order : (we are ignoring T4 for now) 20162306a36Sopenharmony_ci * 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD 20262306a36Sopenharmony_ci */ 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci int negotiated = ((csr12 >> 16) & 0x01E0) & tp->sym_advertise; 20562306a36Sopenharmony_ci tp->lpar = (csr12 >> 16); 20662306a36Sopenharmony_ci tp->nwayset = 1; 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci if (negotiated & 0x0100) dev->if_port = 5; 20962306a36Sopenharmony_ci else if (negotiated & 0x0080) dev->if_port = 3; 21062306a36Sopenharmony_ci else if (negotiated & 0x0040) dev->if_port = 4; 21162306a36Sopenharmony_ci else if (negotiated & 0x0020) dev->if_port = 0; 21262306a36Sopenharmony_ci else { 21362306a36Sopenharmony_ci if (tulip_debug > 1) 21462306a36Sopenharmony_ci dev_info(&dev->dev, 21562306a36Sopenharmony_ci "funny autonegotiate result csr12 %08x advertising %04x\n", 21662306a36Sopenharmony_ci csr12, tp->sym_advertise); 21762306a36Sopenharmony_ci tp->nwayset = 0; 21862306a36Sopenharmony_ci /* so check if 100baseTx link state is okay */ 21962306a36Sopenharmony_ci if ((csr12 & 2) == 0 && (tp->sym_advertise & 0x0180)) 22062306a36Sopenharmony_ci dev->if_port = 3; 22162306a36Sopenharmony_ci } 22262306a36Sopenharmony_ci 22362306a36Sopenharmony_ci /* now record the duplex that was negotiated */ 22462306a36Sopenharmony_ci tp->full_duplex = 0; 22562306a36Sopenharmony_ci if ((dev->if_port == 4) || (dev->if_port == 5)) 22662306a36Sopenharmony_ci tp->full_duplex = 1; 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_ci if (tulip_debug > 1) { 22962306a36Sopenharmony_ci if (tp->nwayset) 23062306a36Sopenharmony_ci dev_info(&dev->dev, 23162306a36Sopenharmony_ci "Switching to %s based on link negotiation %04x & %04x = %04x\n", 23262306a36Sopenharmony_ci medianame[dev->if_port], 23362306a36Sopenharmony_ci tp->sym_advertise, tp->lpar, 23462306a36Sopenharmony_ci negotiated); 23562306a36Sopenharmony_ci } 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_ci /* remember to turn off bit 7 - autonegotiate 23862306a36Sopenharmony_ci * enable so we can properly end nway mode and 23962306a36Sopenharmony_ci * set duplex (ie. use csr6<9> again) 24062306a36Sopenharmony_ci */ 24162306a36Sopenharmony_ci csr14 = (ioread32(ioaddr + CSR14) & 0xffffff7f); 24262306a36Sopenharmony_ci iowrite32(csr14,ioaddr + CSR14); 24362306a36Sopenharmony_ci 24462306a36Sopenharmony_ci 24562306a36Sopenharmony_ci /* now set the data port and operating mode 24662306a36Sopenharmony_ci * (see the Data Port Selection comments at 24762306a36Sopenharmony_ci * the top of the file 24862306a36Sopenharmony_ci */ 24962306a36Sopenharmony_ci 25062306a36Sopenharmony_ci /* get current csr6 and mask off bits not to touch */ 25162306a36Sopenharmony_ci /* see comment at top of file */ 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_ci tp->csr6 = (ioread32(ioaddr + CSR6) & 0xfe3bd1fd); 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ci /* so if using if_port 3 or 5 then select the 100baseT 25662306a36Sopenharmony_ci * port else select the 10baseT port. 25762306a36Sopenharmony_ci * See the Data Port Selection table at the top 25862306a36Sopenharmony_ci * of the file which was taken from the PNIC_II.PDF 25962306a36Sopenharmony_ci * datasheet 26062306a36Sopenharmony_ci */ 26162306a36Sopenharmony_ci if (dev->if_port & 1) tp->csr6 |= 0x01840000; 26262306a36Sopenharmony_ci else tp->csr6 |= 0x00400000; 26362306a36Sopenharmony_ci 26462306a36Sopenharmony_ci /* now set the full duplex bit appropriately */ 26562306a36Sopenharmony_ci if (tp->full_duplex) tp->csr6 |= 0x00000200; 26662306a36Sopenharmony_ci 26762306a36Sopenharmony_ci iowrite32(1, ioaddr + CSR13); 26862306a36Sopenharmony_ci 26962306a36Sopenharmony_ci if (tulip_debug > 2) 27062306a36Sopenharmony_ci netdev_dbg(dev, "Setting CSR6 %08x/%x CSR12 %08x\n", 27162306a36Sopenharmony_ci tp->csr6, 27262306a36Sopenharmony_ci ioread32(ioaddr + CSR6), 27362306a36Sopenharmony_ci ioread32(ioaddr + CSR12)); 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_ci /* now the following actually writes out the 27662306a36Sopenharmony_ci * new csr6 values 27762306a36Sopenharmony_ci */ 27862306a36Sopenharmony_ci tulip_start_rxtx(tp); 27962306a36Sopenharmony_ci 28062306a36Sopenharmony_ci return; 28162306a36Sopenharmony_ci 28262306a36Sopenharmony_ci } else { 28362306a36Sopenharmony_ci dev_info(&dev->dev, 28462306a36Sopenharmony_ci "Autonegotiation failed, using %s, link beat status %04x\n", 28562306a36Sopenharmony_ci medianame[dev->if_port], csr12); 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_ci /* remember to turn off bit 7 - autonegotiate 28862306a36Sopenharmony_ci * enable so we don't forget 28962306a36Sopenharmony_ci */ 29062306a36Sopenharmony_ci csr14 = (ioread32(ioaddr + CSR14) & 0xffffff7f); 29162306a36Sopenharmony_ci iowrite32(csr14,ioaddr + CSR14); 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_ci /* what should we do when autonegotiate fails? 29462306a36Sopenharmony_ci * should we try again or default to baseline 29562306a36Sopenharmony_ci * case. I just don't know. 29662306a36Sopenharmony_ci * 29762306a36Sopenharmony_ci * for now default to some baseline case 29862306a36Sopenharmony_ci */ 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_ci dev->if_port = 0; 30162306a36Sopenharmony_ci tp->nway = 0; 30262306a36Sopenharmony_ci tp->nwayset = 1; 30362306a36Sopenharmony_ci 30462306a36Sopenharmony_ci /* set to 10baseTx-HD - see Data Port Selection 30562306a36Sopenharmony_ci * comment given at the top of the file 30662306a36Sopenharmony_ci */ 30762306a36Sopenharmony_ci tp->csr6 = (ioread32(ioaddr + CSR6) & 0xfe3bd1fd); 30862306a36Sopenharmony_ci tp->csr6 |= 0x00400000; 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_ci tulip_restart_rxtx(tp); 31162306a36Sopenharmony_ci 31262306a36Sopenharmony_ci return; 31362306a36Sopenharmony_ci 31462306a36Sopenharmony_ci } 31562306a36Sopenharmony_ci } 31662306a36Sopenharmony_ci 31762306a36Sopenharmony_ci if ((tp->nwayset && (csr5 & 0x08000000) && 31862306a36Sopenharmony_ci (dev->if_port == 3 || dev->if_port == 5) && 31962306a36Sopenharmony_ci (csr12 & 2) == 2) || (tp->nway && (csr5 & (TPLnkFail)))) { 32062306a36Sopenharmony_ci 32162306a36Sopenharmony_ci /* Link blew? Maybe restart NWay. */ 32262306a36Sopenharmony_ci 32362306a36Sopenharmony_ci if (tulip_debug > 2) 32462306a36Sopenharmony_ci netdev_dbg(dev, "Ugh! Link blew?\n"); 32562306a36Sopenharmony_ci 32662306a36Sopenharmony_ci del_timer_sync(&tp->timer); 32762306a36Sopenharmony_ci pnic2_start_nway(dev); 32862306a36Sopenharmony_ci tp->timer.expires = RUN_AT(3*HZ); 32962306a36Sopenharmony_ci add_timer(&tp->timer); 33062306a36Sopenharmony_ci 33162306a36Sopenharmony_ci return; 33262306a36Sopenharmony_ci } 33362306a36Sopenharmony_ci 33462306a36Sopenharmony_ci 33562306a36Sopenharmony_ci if (dev->if_port == 3 || dev->if_port == 5) { 33662306a36Sopenharmony_ci 33762306a36Sopenharmony_ci /* we are at 100mb and a potential link change occurred */ 33862306a36Sopenharmony_ci 33962306a36Sopenharmony_ci if (tulip_debug > 1) 34062306a36Sopenharmony_ci dev_info(&dev->dev, "PNIC2 %s link beat %s\n", 34162306a36Sopenharmony_ci medianame[dev->if_port], 34262306a36Sopenharmony_ci (csr12 & 2) ? "failed" : "good"); 34362306a36Sopenharmony_ci 34462306a36Sopenharmony_ci /* check 100 link beat */ 34562306a36Sopenharmony_ci 34662306a36Sopenharmony_ci tp->nway = 0; 34762306a36Sopenharmony_ci tp->nwayset = 1; 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_ci /* if failed then try doing an nway to get in sync */ 35062306a36Sopenharmony_ci if ((csr12 & 2) && ! tp->medialock) { 35162306a36Sopenharmony_ci del_timer_sync(&tp->timer); 35262306a36Sopenharmony_ci pnic2_start_nway(dev); 35362306a36Sopenharmony_ci tp->timer.expires = RUN_AT(3*HZ); 35462306a36Sopenharmony_ci add_timer(&tp->timer); 35562306a36Sopenharmony_ci } 35662306a36Sopenharmony_ci 35762306a36Sopenharmony_ci return; 35862306a36Sopenharmony_ci } 35962306a36Sopenharmony_ci 36062306a36Sopenharmony_ci if (dev->if_port == 0 || dev->if_port == 4) { 36162306a36Sopenharmony_ci 36262306a36Sopenharmony_ci /* we are at 10mb and a potential link change occurred */ 36362306a36Sopenharmony_ci 36462306a36Sopenharmony_ci if (tulip_debug > 1) 36562306a36Sopenharmony_ci dev_info(&dev->dev, "PNIC2 %s link beat %s\n", 36662306a36Sopenharmony_ci medianame[dev->if_port], 36762306a36Sopenharmony_ci (csr12 & 4) ? "failed" : "good"); 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ci tp->nway = 0; 37162306a36Sopenharmony_ci tp->nwayset = 1; 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ci /* if failed, try doing an nway to get in sync */ 37462306a36Sopenharmony_ci if ((csr12 & 4) && ! tp->medialock) { 37562306a36Sopenharmony_ci del_timer_sync(&tp->timer); 37662306a36Sopenharmony_ci pnic2_start_nway(dev); 37762306a36Sopenharmony_ci tp->timer.expires = RUN_AT(3*HZ); 37862306a36Sopenharmony_ci add_timer(&tp->timer); 37962306a36Sopenharmony_ci } 38062306a36Sopenharmony_ci 38162306a36Sopenharmony_ci return; 38262306a36Sopenharmony_ci } 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_ci 38562306a36Sopenharmony_ci if (tulip_debug > 1) 38662306a36Sopenharmony_ci dev_info(&dev->dev, "PNIC2 Link Change Default?\n"); 38762306a36Sopenharmony_ci 38862306a36Sopenharmony_ci /* if all else fails default to trying 10baseT-HD */ 38962306a36Sopenharmony_ci dev->if_port = 0; 39062306a36Sopenharmony_ci 39162306a36Sopenharmony_ci /* make sure autonegotiate enable is off */ 39262306a36Sopenharmony_ci csr14 = (ioread32(ioaddr + CSR14) & 0xffffff7f); 39362306a36Sopenharmony_ci iowrite32(csr14,ioaddr + CSR14); 39462306a36Sopenharmony_ci 39562306a36Sopenharmony_ci /* set to 10baseTx-HD - see Data Port Selection 39662306a36Sopenharmony_ci * comment given at the top of the file 39762306a36Sopenharmony_ci */ 39862306a36Sopenharmony_ci tp->csr6 = (ioread32(ioaddr + CSR6) & 0xfe3bd1fd); 39962306a36Sopenharmony_ci tp->csr6 |= 0x00400000; 40062306a36Sopenharmony_ci 40162306a36Sopenharmony_ci tulip_restart_rxtx(tp); 40262306a36Sopenharmony_ci} 40362306a36Sopenharmony_ci 404