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-user.{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
= netdev_priv(dev
);
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
) {
42 struct medialeaf
*mleaf
;
44 if (tp
->mtable
== NULL
) { /* No EEPROM info, use generic code. */
45 /* Not much that can be done.
46 Assume this a generic MII or SYM transceiver. */
49 printk(KERN_DEBUG
"%s: network media monitor CSR6 %8.8x "
51 dev
->name
, inl(ioaddr
+ CSR6
), csr12
& 0xff);
54 mleaf
= &tp
->mtable
->mleaf
[tp
->cur_index
];
56 switch (mleaf
->type
) {
58 /* Type 0 serial or 4 SYM transceiver. Check the link beat bit. */
59 int offset
= mleaf
->type
== 4 ? 5 : 2;
60 s8 bitnum
= p
[offset
];
61 if (p
[offset
+1] & 0x80) {
63 printk(KERN_DEBUG
"%s: Transceiver monitor tick "
64 "CSR12=%#2.2x, no media sense.\n",
66 if (mleaf
->type
== 4) {
67 if (mleaf
->media
== 3 && (csr12
& 0x02))
68 goto select_next_media
;
73 printk(KERN_DEBUG
"%s: Transceiver monitor tick: CSR12=%#2.2x"
74 " bit %d is %d, expecting %d.\n",
75 dev
->name
, csr12
, (bitnum
>> 1) & 7,
76 (csr12
& (1 << ((bitnum
>> 1) & 7))) != 0,
78 /* Check that the specified bit has the proper value. */
80 ((csr12
& (1 << ((bitnum
>> 1) & 7))) != 0)) {
82 printk(KERN_DEBUG
"%s: Link beat detected for %s.\n", dev
->name
,
83 medianame
[mleaf
->media
& MEDIA_MASK
]);
84 if ((p
[2] & 0x61) == 0x01) /* Bogus Znyx board. */
86 netif_carrier_on(dev
);
89 netif_carrier_off(dev
);
93 if (--tp
->cur_index
< 0) {
94 /* We start again, but should instead look for default. */
95 tp
->cur_index
= tp
->mtable
->leafcount
- 1;
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. */
101 printk(KERN_DEBUG
"%s: No link beat on media %s,"
102 " trying transceiver type %s.\n",
103 dev
->name
, medianame
[mleaf
->media
& MEDIA_MASK
],
104 medianame
[tp
->mtable
->mleaf
[tp
->cur_index
].media
]);
105 tulip_select_media(dev
, 0);
106 /* Restart the transmit process. */
107 tulip_restart_rxtx(tp
);
108 next_tick
= (24*HZ
)/10;
111 case 1: case 3: /* 21140, 21142 MII */
113 if (tulip_check_duplex(dev
) < 0) {
114 netif_carrier_off(dev
);
117 netif_carrier_on(dev
);
121 case 2: /* 21142 serial block has no link beat. */
128 /* mod_timer synchronizes us with potential add_timer calls
131 mod_timer(&tp
->timer
, RUN_AT(next_tick
));
135 void mxic_timer(unsigned long data
)
137 struct net_device
*dev
= (struct net_device
*)data
;
138 struct tulip_private
*tp
= netdev_priv(dev
);
139 long ioaddr
= dev
->base_addr
;
140 int next_tick
= 60*HZ
;
142 if (tulip_debug
> 3) {
143 printk(KERN_INFO
"%s: MXIC negotiation status %8.8x.\n", dev
->name
,
144 inl(ioaddr
+ CSR12
));
147 mod_timer(&tp
->timer
, RUN_AT(next_tick
));
152 void comet_timer(unsigned long data
)
154 struct net_device
*dev
= (struct net_device
*)data
;
155 struct tulip_private
*tp
= netdev_priv(dev
);
156 int next_tick
= 60*HZ
;
159 printk(KERN_DEBUG
"%s: Comet link status %4.4x partner capability "
162 tulip_mdio_read(dev
, tp
->phys
[0], 1),
163 tulip_mdio_read(dev
, tp
->phys
[0], 5));
164 /* mod_timer synchronizes us with potential add_timer calls
167 if (tulip_check_duplex(dev
) < 0)
168 { netif_carrier_off(dev
); }
170 { netif_carrier_on(dev
); }
171 mod_timer(&tp
->timer
, RUN_AT(next_tick
));