2 drivers/net/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 refer to Documentation/DocBook/tulip-user.{pdf,ps,html}
11 for more information on this driver.
13 Please submit bugs to http://bugzilla.kernel.org/ .
20 void tulip_media_task(struct work_struct
*work
)
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
);
30 if (tulip_debug
> 2) {
31 printk(KERN_DEBUG
"%s: Media selection tick, %s, status %8.8x mode"
32 " %8.8x SIA %8.8x %8.8x %8.8x %8.8x.\n",
33 dev
->name
, medianame
[dev
->if_port
], ioread32(ioaddr
+ CSR5
),
34 ioread32(ioaddr
+ CSR6
), csr12
, ioread32(ioaddr
+ CSR13
),
35 ioread32(ioaddr
+ CSR14
), ioread32(ioaddr
+ CSR15
));
37 switch (tp
->chip_id
) {
44 struct medialeaf
*mleaf
;
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. */
51 printk(KERN_DEBUG
"%s: network media monitor CSR6 %8.8x "
53 dev
->name
, ioread32(ioaddr
+ CSR6
), csr12
& 0xff);
56 mleaf
= &tp
->mtable
->mleaf
[tp
->cur_index
];
58 switch (mleaf
->type
) {
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) {
65 printk(KERN_DEBUG
"%s: Transceiver monitor tick "
66 "CSR12=%#2.2x, no media sense.\n",
68 if (mleaf
->type
== 4) {
69 if (mleaf
->media
== 3 && (csr12
& 0x02))
70 goto select_next_media
;
75 printk(KERN_DEBUG
"%s: Transceiver monitor tick: CSR12=%#2.2x"
76 " bit %d is %d, expecting %d.\n",
77 dev
->name
, csr12
, (bitnum
>> 1) & 7,
78 (csr12
& (1 << ((bitnum
>> 1) & 7))) != 0,
80 /* Check that the specified bit has the proper value. */
82 ((csr12
& (1 << ((bitnum
>> 1) & 7))) != 0)) {
84 printk(KERN_DEBUG
"%s: Link beat detected for %s.\n", dev
->name
,
85 medianame
[mleaf
->media
& MEDIA_MASK
]);
86 if ((p
[2] & 0x61) == 0x01) /* Bogus Znyx board. */
88 netif_carrier_on(dev
);
91 netif_carrier_off(dev
);
95 if (--tp
->cur_index
< 0) {
96 /* We start again, but should instead look for default. */
97 tp
->cur_index
= tp
->mtable
->leafcount
- 1;
99 dev
->if_port
= tp
->mtable
->mleaf
[tp
->cur_index
].media
;
100 if (tulip_media_cap
[dev
->if_port
] & MediaIsFD
)
101 goto select_next_media
; /* Skip FD entries. */
103 printk(KERN_DEBUG
"%s: No link beat on media %s,"
104 " trying transceiver type %s.\n",
105 dev
->name
, medianame
[mleaf
->media
& MEDIA_MASK
],
106 medianame
[tp
->mtable
->mleaf
[tp
->cur_index
].media
]);
107 tulip_select_media(dev
, 0);
108 /* Restart the transmit process. */
109 tulip_restart_rxtx(tp
);
110 next_tick
= (24*HZ
)/10;
113 case 1: case 3: /* 21140, 21142 MII */
115 if (tulip_check_duplex(dev
) < 0) {
116 netif_carrier_off(dev
);
119 netif_carrier_on(dev
);
123 case 2: /* 21142 serial block has no link beat. */
132 spin_lock_irqsave(&tp
->lock
, flags
);
133 if (tp
->timeout_recovery
) {
134 tulip_tx_timeout_complete(tp
, ioaddr
);
135 tp
->timeout_recovery
= 0;
137 spin_unlock_irqrestore(&tp
->lock
, flags
);
139 /* mod_timer synchronizes us with potential add_timer calls
142 mod_timer(&tp
->timer
, RUN_AT(next_tick
));
146 void mxic_timer(unsigned long data
)
148 struct net_device
*dev
= (struct net_device
*)data
;
149 struct tulip_private
*tp
= netdev_priv(dev
);
150 void __iomem
*ioaddr
= tp
->base_addr
;
151 int next_tick
= 60*HZ
;
153 if (tulip_debug
> 3) {
154 printk(KERN_INFO
"%s: MXIC negotiation status %8.8x.\n", dev
->name
,
155 ioread32(ioaddr
+ CSR12
));
158 mod_timer(&tp
->timer
, RUN_AT(next_tick
));
163 void comet_timer(unsigned long data
)
165 struct net_device
*dev
= (struct net_device
*)data
;
166 struct tulip_private
*tp
= netdev_priv(dev
);
167 int next_tick
= 60*HZ
;
170 printk(KERN_DEBUG
"%s: Comet link status %4.4x partner capability "
173 tulip_mdio_read(dev
, tp
->phys
[0], 1),
174 tulip_mdio_read(dev
, tp
->phys
[0], 5));
175 /* mod_timer synchronizes us with potential add_timer calls
178 if (tulip_check_duplex(dev
) < 0)
179 { netif_carrier_off(dev
); }
181 { netif_carrier_on(dev
); }
182 mod_timer(&tp
->timer
, RUN_AT(next_tick
));