Deleted Added
full compact
if_cs.c (38286) if_cs.c (38305)
1/*
2 * Copyright (c) 1997,1998 Maxim Bolotin and Oleg Sharoiko.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 */
28
29/*
1/*
2 * Copyright (c) 1997,1998 Maxim Bolotin and Oleg Sharoiko.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 */
28
29/*
30 * $Id: if_cs.c,v 1.1 1998/07/20 20:00:42 msmith Exp $
30 * $Id: if_cs.c,v 1.2 1998/08/12 18:02:48 bde Exp $
31 *
32 * Device driver for Crystal Semiconductor CS8920 based ethernet
33 * adapters. By Maxim Bolotin and Oleg Sharoiko, 27-April-1997
34 */
35
36/* #define CS_DEBUG */
37#include "cs.h"
38#include "bpfilter.h"

--- 214 unchanged lines hidden (view full) ---

253static int
254send_test_pkt(struct cs_softc *sc)
255{
256 int unit = sc->arpcom.ac_if.if_unit;
257 char test_packet[] = { 0,0,0,0,0,0, 0,0,0,0,0,0,
258 0, 46, /* A 46 in network order */
259 0, 0, /* DSAP=0 & SSAP=0 fields */
260 0xf3, 0 /* Control (Test Req + P bit set) */ };
31 *
32 * Device driver for Crystal Semiconductor CS8920 based ethernet
33 * adapters. By Maxim Bolotin and Oleg Sharoiko, 27-April-1997
34 */
35
36/* #define CS_DEBUG */
37#include "cs.h"
38#include "bpfilter.h"

--- 214 unchanged lines hidden (view full) ---

253static int
254send_test_pkt(struct cs_softc *sc)
255{
256 int unit = sc->arpcom.ac_if.if_unit;
257 char test_packet[] = { 0,0,0,0,0,0, 0,0,0,0,0,0,
258 0, 46, /* A 46 in network order */
259 0, 0, /* DSAP=0 & SSAP=0 fields */
260 0xf3, 0 /* Control (Test Req + P bit set) */ };
261 int i;
262 u_char ether_address_backup[ETHER_ADDR_LEN];
261
263
264 for (i = 0; i < ETHER_ADDR_LEN; i++) {
265 ether_address_backup[i] = sc->arpcom.ac_enaddr[i];
266 }
267
262 cs_writereg(sc->nic_addr, PP_LineCTL,
263 cs_readreg(sc->nic_addr, PP_LineCTL) | SERIAL_TX_ON );
264 bcopy(test_packet,
265 sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
266 bcopy(test_packet+ETHER_ADDR_LEN,
267 sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
268 outw(sc->nic_addr + TX_CMD_PORT, sc->send_cmd);
269 outw(sc->nic_addr + TX_LEN_PORT, sizeof(test_packet));
270
271 /* Wait for chip to allocate memory */
272 DELAY(50000);
268 cs_writereg(sc->nic_addr, PP_LineCTL,
269 cs_readreg(sc->nic_addr, PP_LineCTL) | SERIAL_TX_ON );
270 bcopy(test_packet,
271 sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
272 bcopy(test_packet+ETHER_ADDR_LEN,
273 sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
274 outw(sc->nic_addr + TX_CMD_PORT, sc->send_cmd);
275 outw(sc->nic_addr + TX_LEN_PORT, sizeof(test_packet));
276
277 /* Wait for chip to allocate memory */
278 DELAY(50000);
273 if (!(cs_readreg(sc->nic_addr, PP_BusST) & READY_FOR_TX_NOW))
279 if (!(cs_readreg(sc->nic_addr, PP_BusST) & READY_FOR_TX_NOW)) {
280 for (i = 0; i < ETHER_ADDR_LEN; i++) {
281 sc->arpcom.ac_enaddr[i] = ether_address_backup[i];
282 }
274 return 0;
283 return 0;
284 }
275
276 outsw(sc->nic_addr + TX_FRAME_PORT, test_packet, sizeof(test_packet));
277
278 DELAY(30000);
279
285
286 outsw(sc->nic_addr + TX_FRAME_PORT, test_packet, sizeof(test_packet));
287
288 DELAY(30000);
289
280 if ((cs_readreg(sc->nic_addr,PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK)
290 if ((cs_readreg(sc->nic_addr,PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK) {
291 for (i = 0; i < ETHER_ADDR_LEN; i++) {
292 sc->arpcom.ac_enaddr[i] = ether_address_backup[i];
293 }
281 return 1;
294 return 1;
295 }
296 for (i = 0; i < ETHER_ADDR_LEN; i++) {
297 sc->arpcom.ac_enaddr[i] = ether_address_backup[i];
298 }
282 return 0;
283}
284
285/*
286 * XXX This was rewritten from Linux driver without any tests.
287 */
288static int
289enable_aui(struct cs_softc *sc)

--- 352 unchanged lines hidden (view full) ---

642 s=splimp();
643
644 /*
645 * Hardware initialization of cs
646 */
647
648 /* Enable receiver and transmitter */
649 cs_writereg(sc->nic_addr, PP_LineCTL,
299 return 0;
300}
301
302/*
303 * XXX This was rewritten from Linux driver without any tests.
304 */
305static int
306enable_aui(struct cs_softc *sc)

--- 352 unchanged lines hidden (view full) ---

659 s=splimp();
660
661 /*
662 * Hardware initialization of cs
663 */
664
665 /* Enable receiver and transmitter */
666 cs_writereg(sc->nic_addr, PP_LineCTL,
650 sc->line_ctl | SERIAL_RX_ON | SERIAL_TX_ON);
667 cs_readreg( sc->nic_addr, PP_LineCTL ) |
668 SERIAL_RX_ON | SERIAL_TX_ON);
651
652 /* Configure the receiver mode */
653 cs_setmode(sc);
654
655 /*
656 * This defines what type of frames will cause interrupts
657 * Bad frames should generate interrupts so that the driver
658 * could track statistics of discarded packets

--- 500 unchanged lines hidden (view full) ---

1159 ifmr->ifm_active |= IFM_FDX;
1160 if (cs_readreg(sc->nic_addr, PP_AutoNegST) & HDX_ACTIVE)
1161 ifmr->ifm_active |= IFM_HDX;
1162 }
1163 ifmr->ifm_status = IFM_AVALID;
1164 if (line_status & LINK_OK)
1165 ifmr->ifm_status |= IFM_ACTIVE;
1166 } else {
669
670 /* Configure the receiver mode */
671 cs_setmode(sc);
672
673 /*
674 * This defines what type of frames will cause interrupts
675 * Bad frames should generate interrupts so that the driver
676 * could track statistics of discarded packets

--- 500 unchanged lines hidden (view full) ---

1177 ifmr->ifm_active |= IFM_FDX;
1178 if (cs_readreg(sc->nic_addr, PP_AutoNegST) & HDX_ACTIVE)
1179 ifmr->ifm_active |= IFM_HDX;
1180 }
1181 ifmr->ifm_status = IFM_AVALID;
1182 if (line_status & LINK_OK)
1183 ifmr->ifm_status |= IFM_ACTIVE;
1184 } else {
1167 /*
1168 * XXX I don't know if this is correct or not.
1169 * If AUI will be reported instead of BNC
1170 * then this is wrong.
1171 */
1172 if (line_status & AUI_ON)
1173 ifmr->ifm_active |= IFM_10_5;
1174 else
1175 ifmr->ifm_active |= IFM_10_2;
1176#ifdef CS_BROKEN_BNC_DETECT
1177 printf(CS_NAME"%d: PP_LineST: %02x PP_SelfST: %02x\n",
1178 ifp->if_unit,line_status,
1179 cs_readreg(sc->nic_addr,PP_SelfST));
1180#endif
1185 if (line_status & AUI_ON) {
1186 cs_writereg(sc->nic_addr, PP_SelfCTL,
1187 cs_readreg(sc->nic_addr, PP_SelfCTL) |
1188 HCB1_ENBL);
1189 if (((sc->adapter_cnf & A_CNF_DC_DC_POLARITY)!=0)^
1190 (cs_readreg(sc->nic_addr, PP_SelfCTL)&HCB1))
1191 ifmr->ifm_active |= IFM_10_2;
1192 else
1193 ifmr->ifm_active |= IFM_10_5;
1194 }
1181 }
1182}
1183
1184static int
1185cs_mediaset(struct cs_softc *sc, int media)
1186{
1187 int error;
1188

--- 196 unchanged lines hidden ---
1195 }
1196}
1197
1198static int
1199cs_mediaset(struct cs_softc *sc, int media)
1200{
1201 int error;
1202

--- 196 unchanged lines hidden ---