2 drivers/net/ethernet/dec/tulip/timer.c
4 Copyright 2000,2001 The Linux Kernel Team
5 Written/copyright 1994-2001 by Donald Becker.
7 This software may be used and distributed according to the terms
8 of the GNU General Public License, incorporated herein by reference.
10 Please submit bugs to http://bugzilla.kernel.org/ .
17 void tulip_media_task(struct work_struct
*work
)
19 struct tulip_private
*tp
=
20 container_of(work
, struct tulip_private
, media_work
);
21 struct net_device
*dev
= tp
->dev
;
22 void __iomem
*ioaddr
= tp
->base_addr
;
23 u32 csr12
= ioread32(ioaddr
+ CSR12
);
27 if (tulip_debug
> 2) {
28 netdev_dbg(dev
, "Media selection tick, %s, status %08x mode %08x SIA %08x %08x %08x %08x\n",
29 medianame
[dev
->if_port
],
30 ioread32(ioaddr
+ CSR5
), ioread32(ioaddr
+ CSR6
),
31 csr12
, ioread32(ioaddr
+ CSR13
),
32 ioread32(ioaddr
+ CSR14
), ioread32(ioaddr
+ CSR15
));
34 switch (tp
->chip_id
) {
41 struct medialeaf
*mleaf
;
43 if (tp
->mtable
== NULL
) { /* No EEPROM info, use generic code. */
44 /* Not much that can be done.
45 Assume this a generic MII or SYM transceiver. */
48 netdev_dbg(dev
, "network media monitor CSR6 %08x CSR12 0x%02x\n",
49 ioread32(ioaddr
+ CSR6
),
53 mleaf
= &tp
->mtable
->mleaf
[tp
->cur_index
];
55 switch (mleaf
->type
) {
57 /* Type 0 serial or 4 SYM transceiver. Check the link beat bit. */
58 int offset
= mleaf
->type
== 4 ? 5 : 2;
59 s8 bitnum
= p
[offset
];
60 if (p
[offset
+1] & 0x80) {
62 netdev_dbg(dev
, "Transceiver monitor tick CSR12=%#02x, no media sense\n",
64 if (mleaf
->type
== 4) {
65 if (mleaf
->media
== 3 && (csr12
& 0x02))
66 goto select_next_media
;
71 netdev_dbg(dev
, "Transceiver monitor tick: CSR12=%#02x bit %d is %d, expecting %d\n",
72 csr12
, (bitnum
>> 1) & 7,
73 (csr12
& (1 << ((bitnum
>> 1) & 7))) != 0,
75 /* Check that the specified bit has the proper value. */
77 ((csr12
& (1 << ((bitnum
>> 1) & 7))) != 0)) {
79 netdev_dbg(dev
, "Link beat detected for %s\n",
80 medianame
[mleaf
->media
& MEDIA_MASK
]);
81 if ((p
[2] & 0x61) == 0x01) /* Bogus Znyx board. */
83 netif_carrier_on(dev
);
86 netif_carrier_off(dev
);
90 if (--tp
->cur_index
< 0) {
91 /* We start again, but should instead look for default. */
92 tp
->cur_index
= tp
->mtable
->leafcount
- 1;
94 dev
->if_port
= tp
->mtable
->mleaf
[tp
->cur_index
].media
;
95 if (tulip_media_cap
[dev
->if_port
] & MediaIsFD
)
96 goto select_next_media
; /* Skip FD entries. */
98 netdev_dbg(dev
, "No link beat on media %s, trying transceiver type %s\n",
99 medianame
[mleaf
->media
& MEDIA_MASK
],
100 medianame
[tp
->mtable
->mleaf
[tp
->cur_index
].media
]);
101 tulip_select_media(dev
, 0);
102 /* Restart the transmit process. */
103 tulip_restart_rxtx(tp
);
104 next_tick
= (24*HZ
)/10;
107 case 1: case 3: /* 21140, 21142 MII */
109 if (tulip_check_duplex(dev
) < 0) {
110 netif_carrier_off(dev
);
113 netif_carrier_on(dev
);
117 case 2: /* 21142 serial block has no link beat. */
126 spin_lock_irqsave(&tp
->lock
, flags
);
127 if (tp
->timeout_recovery
) {
128 tulip_tx_timeout_complete(tp
, ioaddr
);
129 tp
->timeout_recovery
= 0;
131 spin_unlock_irqrestore(&tp
->lock
, flags
);
133 /* mod_timer synchronizes us with potential add_timer calls
136 mod_timer(&tp
->timer
, RUN_AT(next_tick
));
140 void mxic_timer(unsigned long data
)
142 struct net_device
*dev
= (struct net_device
*)data
;
143 struct tulip_private
*tp
= netdev_priv(dev
);
144 void __iomem
*ioaddr
= tp
->base_addr
;
145 int next_tick
= 60*HZ
;
147 if (tulip_debug
> 3) {
148 dev_info(&dev
->dev
, "MXIC negotiation status %08x\n",
149 ioread32(ioaddr
+ CSR12
));
152 mod_timer(&tp
->timer
, RUN_AT(next_tick
));
157 void comet_timer(unsigned long data
)
159 struct net_device
*dev
= (struct net_device
*)data
;
160 struct tulip_private
*tp
= netdev_priv(dev
);
161 int next_tick
= 2*HZ
;
164 netdev_dbg(dev
, "Comet link status %04x partner capability %04x\n",
165 tulip_mdio_read(dev
, tp
->phys
[0], 1),
166 tulip_mdio_read(dev
, tp
->phys
[0], 5));
167 /* mod_timer synchronizes us with potential add_timer calls
170 if (tulip_check_duplex(dev
) < 0)
171 { netif_carrier_off(dev
); }
173 { netif_carrier_on(dev
); }
174 mod_timer(&tp
->timer
, RUN_AT(next_tick
));