2 drivers/net/tulip/timer.c
4 Maintained by Jeff Garzik <jgarzik@pobox.com>
5 Copyright 2000,2001 The Linux Kernel Team
6 Written/copyright 1994-2001 by Donald Becker.
8 This software may be used and distributed according to the terms
9 of the GNU General Public License, incorporated herein by reference.
11 Please refer to Documentation/DocBook/tulip.{pdf,ps,html}
12 for more information on this driver, or visit the project
13 Web page at http://sourceforge.net/projects/tulip/
20 void tulip_timer(unsigned long data)
22 struct net_device *dev = (struct net_device *)data;
23 struct tulip_private *tp = (struct tulip_private *)dev->priv;
24 long ioaddr = dev->base_addr;
25 u32 csr12 = inl(ioaddr + CSR12);
28 if (tulip_debug > 2) {
29 printk(KERN_DEBUG "%s: Media selection tick, %s, status %8.8x mode"
30 " %8.8x SIA %8.8x %8.8x %8.8x %8.8x.\n",
31 dev->name, medianame[dev->if_port], inl(ioaddr + CSR5),
32 inl(ioaddr + CSR6), csr12, inl(ioaddr + CSR13),
33 inl(ioaddr + CSR14), inl(ioaddr + CSR15));
35 switch (tp->chip_id) {
37 if (!tp->medialock && csr12 & 0x0002) { /* Network error */
38 printk(KERN_INFO "%s: No link beat found.\n",
40 dev->if_port = (dev->if_port == 2 ? 0 : 2);
41 tulip_select_media(dev, 0);
42 dev->trans_start = jiffies;
47 printk(KERN_DEBUG "%s: 21041 media tick CSR12 %8.8x.\n",
49 if (tp->medialock) break;
50 switch (dev->if_port) {
51 case 0: case 3: case 4:
52 if (csr12 & 0x0004) { /*LnkFail */
53 /* 10baseT is dead. Check for activity on alternate port. */
59 printk(KERN_INFO "%s: No 21041 10baseT link beat, Media switched to %s.\n",
60 dev->name, medianame[dev->if_port]);
61 outl(0, ioaddr + CSR13); /* Reset */
62 outl(t21041_csr14[dev->if_port], ioaddr + CSR14);
63 outl(t21041_csr15[dev->if_port], ioaddr + CSR15);
64 outl(t21041_csr13[dev->if_port], ioaddr + CSR13);
65 next_tick = 10*HZ; /* 2.4 sec. */
72 next_tick = (30*HZ); /* 30 sec. */
74 } else if ((csr12 & 0x0004) == 0) {
75 printk(KERN_INFO "%s: 21041 media switched to 10baseT.\n",
78 tulip_select_media(dev, 0);
79 next_tick = (24*HZ)/10; /* 2.4 sec. */
80 } else if (tp->mediasense || (csr12 & 0x0002)) {
81 dev->if_port = 3 - dev->if_port; /* Swap ports. */
82 tulip_select_media(dev, 0);
96 struct medialeaf *mleaf;
98 if (tp->mtable == NULL) { /* No EEPROM info, use generic code. */
99 /* Not much that can be done.
100 Assume this a generic MII or SYM transceiver. */
103 printk(KERN_DEBUG "%s: network media monitor CSR6 %8.8x "
105 dev->name, inl(ioaddr + CSR6), csr12 & 0xff);
108 mleaf = &tp->mtable->mleaf[tp->cur_index];
110 switch (mleaf->type) {
112 /* Type 0 serial or 4 SYM transceiver. Check the link beat bit. */
113 int offset = mleaf->type == 4 ? 5 : 2;
114 s8 bitnum = p[offset];
115 if (p[offset+1] & 0x80) {
117 printk(KERN_DEBUG"%s: Transceiver monitor tick "
118 "CSR12=%#2.2x, no media sense.\n",
120 if (mleaf->type == 4) {
121 if (mleaf->media == 3 && (csr12 & 0x02))
122 goto select_next_media;
127 printk(KERN_DEBUG "%s: Transceiver monitor tick: CSR12=%#2.2x"
128 " bit %d is %d, expecting %d.\n",
129 dev->name, csr12, (bitnum >> 1) & 7,
130 (csr12 & (1 << ((bitnum >> 1) & 7))) != 0,
132 /* Check that the specified bit has the proper value. */
134 ((csr12 & (1 << ((bitnum >> 1) & 7))) != 0)) {
136 printk(KERN_DEBUG "%s: Link beat detected for %s.\n", dev->name,
137 medianame[mleaf->media & MEDIA_MASK]);
138 if ((p[2] & 0x61) == 0x01) /* Bogus Znyx board. */
140 /* netif_carrier_on(dev); */
143 /* netif_carrier_off(dev); */
147 if (--tp->cur_index < 0) {
148 /* We start again, but should instead look for default. */
149 tp->cur_index = tp->mtable->leafcount - 1;
151 dev->if_port = tp->mtable->mleaf[tp->cur_index].media;
152 if (tulip_media_cap[dev->if_port] & MediaIsFD)
153 goto select_next_media; /* Skip FD entries. */
155 printk(KERN_DEBUG "%s: No link beat on media %s,"
156 " trying transceiver type %s.\n",
157 dev->name, medianame[mleaf->media & MEDIA_MASK],
158 medianame[tp->mtable->mleaf[tp->cur_index].media]);
159 tulip_select_media(dev, 0);
160 /* Restart the transmit process. */
161 tulip_restart_rxtx(tp);
162 next_tick = (24*HZ)/10;
165 case 1: case 3: /* 21140, 21142 MII */
167 if (tulip_check_duplex(dev) < 0)
168 { /* netif_carrier_off(dev); */ }
170 { /* netif_carrier_on(dev); */ }
173 case 2: /* 21142 serial block has no link beat. */
180 /* mod_timer synchronizes us with potential add_timer calls
183 mod_timer(&tp->timer, RUN_AT(next_tick));
187 void mxic_timer(unsigned long data)
189 struct net_device *dev = (struct net_device *)data;
190 struct tulip_private *tp = (struct tulip_private *)dev->priv;
191 long ioaddr = dev->base_addr;
192 int next_tick = 60*HZ;
194 if (tulip_debug > 3) {
195 printk(KERN_INFO"%s: MXIC negotiation status %8.8x.\n", dev->name,
196 inl(ioaddr + CSR12));
199 mod_timer(&tp->timer, RUN_AT(next_tick));
204 void comet_timer(unsigned long data)
206 struct net_device *dev = (struct net_device *)data;
207 struct tulip_private *tp = (struct tulip_private *)dev->priv;
208 long ioaddr = dev->base_addr;
209 int next_tick = 60*HZ;
212 printk(KERN_DEBUG "%s: Comet link status %4.4x partner capability "
214 dev->name, inl(ioaddr + 0xB8), inl(ioaddr + 0xC8));
215 /* mod_timer synchronizes us with potential add_timer calls
218 mod_timer(&tp->timer, RUN_AT(next_tick));