diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /drivers/net/tulip/timer.c | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'drivers/net/tulip/timer.c')
-rw-r--r-- | drivers/net/tulip/timer.c | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/drivers/net/tulip/timer.c b/drivers/net/tulip/timer.c new file mode 100644 index 00000000000..2017faf2d0e --- /dev/null +++ b/drivers/net/tulip/timer.c | |||
@@ -0,0 +1,179 @@ | |||
1 | /* | ||
2 | drivers/net/tulip/timer.c | ||
3 | |||
4 | Copyright 2000,2001 The Linux Kernel Team | ||
5 | Written/copyright 1994-2001 by Donald Becker. | ||
6 | |||
7 | This software may be used and distributed according to the terms | ||
8 | of the GNU General Public License, incorporated herein by reference. | ||
9 | |||
10 | Please refer to Documentation/DocBook/tulip-user.{pdf,ps,html} | ||
11 | for more information on this driver. | ||
12 | |||
13 | Please submit bugs to http://bugzilla.kernel.org/ . | ||
14 | */ | ||
15 | |||
16 | |||
17 | #include "tulip.h" | ||
18 | |||
19 | |||
20 | void tulip_media_task(struct work_struct *work) | ||
21 | { | ||
22 | struct tulip_private *tp = | ||
23 | container_of(work, struct tulip_private, media_work); | ||
24 | struct net_device *dev = tp->dev; | ||
25 | void __iomem *ioaddr = tp->base_addr; | ||
26 | u32 csr12 = ioread32(ioaddr + CSR12); | ||
27 | int next_tick = 2*HZ; | ||
28 | unsigned long flags; | ||
29 | |||
30 | if (tulip_debug > 2) { | ||
31 | netdev_dbg(dev, "Media selection tick, %s, status %08x mode %08x SIA %08x %08x %08x %08x\n", | ||
32 | medianame[dev->if_port], | ||
33 | ioread32(ioaddr + CSR5), ioread32(ioaddr + CSR6), | ||
34 | csr12, ioread32(ioaddr + CSR13), | ||
35 | ioread32(ioaddr + CSR14), ioread32(ioaddr + CSR15)); | ||
36 | } | ||
37 | switch (tp->chip_id) { | ||
38 | case DC21140: | ||
39 | case DC21142: | ||
40 | case MX98713: | ||
41 | case COMPEX9881: | ||
42 | case DM910X: | ||
43 | default: { | ||
44 | struct medialeaf *mleaf; | ||
45 | unsigned char *p; | ||
46 | if (tp->mtable == NULL) { /* No EEPROM info, use generic code. */ | ||
47 | /* Not much that can be done. | ||
48 | Assume this a generic MII or SYM transceiver. */ | ||
49 | next_tick = 60*HZ; | ||
50 | if (tulip_debug > 2) | ||
51 | netdev_dbg(dev, "network media monitor CSR6 %08x CSR12 0x%02x\n", | ||
52 | ioread32(ioaddr + CSR6), | ||
53 | csr12 & 0xff); | ||
54 | break; | ||
55 | } | ||
56 | mleaf = &tp->mtable->mleaf[tp->cur_index]; | ||
57 | p = mleaf->leafdata; | ||
58 | switch (mleaf->type) { | ||
59 | case 0: case 4: { | ||
60 | /* Type 0 serial or 4 SYM transceiver. Check the link beat bit. */ | ||
61 | int offset = mleaf->type == 4 ? 5 : 2; | ||
62 | s8 bitnum = p[offset]; | ||
63 | if (p[offset+1] & 0x80) { | ||
64 | if (tulip_debug > 1) | ||
65 | netdev_dbg(dev, "Transceiver monitor tick CSR12=%#02x, no media sense\n", | ||
66 | csr12); | ||
67 | if (mleaf->type == 4) { | ||
68 | if (mleaf->media == 3 && (csr12 & 0x02)) | ||
69 | goto select_next_media; | ||
70 | } | ||
71 | break; | ||
72 | } | ||
73 | if (tulip_debug > 2) | ||
74 | netdev_dbg(dev, "Transceiver monitor tick: CSR12=%#02x bit %d is %d, expecting %d\n", | ||
75 | csr12, (bitnum >> 1) & 7, | ||
76 | (csr12 & (1 << ((bitnum >> 1) & 7))) != 0, | ||
77 | (bitnum >= 0)); | ||
78 | /* Check that the specified bit has the proper value. */ | ||
79 | if ((bitnum < 0) != | ||
80 | ((csr12 & (1 << ((bitnum >> 1) & 7))) != 0)) { | ||
81 | if (tulip_debug > 2) | ||
82 | netdev_dbg(dev, "Link beat detected for %s\n", | ||
83 | medianame[mleaf->media & MEDIA_MASK]); | ||
84 | if ((p[2] & 0x61) == 0x01) /* Bogus Znyx board. */ | ||
85 | goto actually_mii; | ||
86 | netif_carrier_on(dev); | ||
87 | break; | ||
88 | } | ||
89 | netif_carrier_off(dev); | ||
90 | if (tp->medialock) | ||
91 | break; | ||
92 | select_next_media: | ||
93 | if (--tp->cur_index < 0) { | ||
94 | /* We start again, but should instead look for default. */ | ||
95 | tp->cur_index = tp->mtable->leafcount - 1; | ||
96 | } | ||
97 | dev->if_port = tp->mtable->mleaf[tp->cur_index].media; | ||
98 | if (tulip_media_cap[dev->if_port] & MediaIsFD) | ||
99 | goto select_next_media; /* Skip FD entries. */ | ||
100 | if (tulip_debug > 1) | ||
101 | netdev_dbg(dev, "No link beat on media %s, trying transceiver type %s\n", | ||
102 | medianame[mleaf->media & MEDIA_MASK], | ||
103 | medianame[tp->mtable->mleaf[tp->cur_index].media]); | ||
104 | tulip_select_media(dev, 0); | ||
105 | /* Restart the transmit process. */ | ||
106 | tulip_restart_rxtx(tp); | ||
107 | next_tick = (24*HZ)/10; | ||
108 | break; | ||
109 | } | ||
110 | case 1: case 3: /* 21140, 21142 MII */ | ||
111 | actually_mii: | ||
112 | if (tulip_check_duplex(dev) < 0) { | ||
113 | netif_carrier_off(dev); | ||
114 | next_tick = 3*HZ; | ||
115 | } else { | ||
116 | netif_carrier_on(dev); | ||
117 | next_tick = 60*HZ; | ||
118 | } | ||
119 | break; | ||
120 | case 2: /* 21142 serial block has no link beat. */ | ||
121 | default: | ||
122 | break; | ||
123 | } | ||
124 | } | ||
125 | break; | ||
126 | } | ||
127 | |||
128 | |||
129 | spin_lock_irqsave(&tp->lock, flags); | ||
130 | if (tp->timeout_recovery) { | ||
131 | tulip_tx_timeout_complete(tp, ioaddr); | ||
132 | tp->timeout_recovery = 0; | ||
133 | } | ||
134 | spin_unlock_irqrestore(&tp->lock, flags); | ||
135 | |||
136 | /* mod_timer synchronizes us with potential add_timer calls | ||
137 | * from interrupts. | ||
138 | */ | ||
139 | mod_timer(&tp->timer, RUN_AT(next_tick)); | ||
140 | } | ||
141 | |||
142 | |||
143 | void mxic_timer(unsigned long data) | ||
144 | { | ||
145 | struct net_device *dev = (struct net_device *)data; | ||
146 | struct tulip_private *tp = netdev_priv(dev); | ||
147 | void __iomem *ioaddr = tp->base_addr; | ||
148 | int next_tick = 60*HZ; | ||
149 | |||
150 | if (tulip_debug > 3) { | ||
151 | dev_info(&dev->dev, "MXIC negotiation status %08x\n", | ||
152 | ioread32(ioaddr + CSR12)); | ||
153 | } | ||
154 | if (next_tick) { | ||
155 | mod_timer(&tp->timer, RUN_AT(next_tick)); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | |||
160 | void comet_timer(unsigned long data) | ||
161 | { | ||
162 | struct net_device *dev = (struct net_device *)data; | ||
163 | struct tulip_private *tp = netdev_priv(dev); | ||
164 | int next_tick = 60*HZ; | ||
165 | |||
166 | if (tulip_debug > 1) | ||
167 | netdev_dbg(dev, "Comet link status %04x partner capability %04x\n", | ||
168 | tulip_mdio_read(dev, tp->phys[0], 1), | ||
169 | tulip_mdio_read(dev, tp->phys[0], 5)); | ||
170 | /* mod_timer synchronizes us with potential add_timer calls | ||
171 | * from interrupts. | ||
172 | */ | ||
173 | if (tulip_check_duplex(dev) < 0) | ||
174 | { netif_carrier_off(dev); } | ||
175 | else | ||
176 | { netif_carrier_on(dev); } | ||
177 | mod_timer(&tp->timer, RUN_AT(next_tick)); | ||
178 | } | ||
179 | |||