Deleted Added
full compact
if_ep_isa.c (139749) if_ep_isa.c (140523)
1/*-
2 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
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

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

24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
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

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

24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/dev/ep/if_ep_isa.c 139749 2005-01-06 01:43:34Z imp $");
32__FBSDID("$FreeBSD: head/sys/dev/ep/if_ep_isa.c 140523 2005-01-20 19:39:33Z imp $");
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/kernel.h>
37#include <sys/socket.h>
38#include <sys/module.h>
39#include <sys/bus.h>
40

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

51#include <dev/ep/if_epreg.h>
52#include <dev/ep/if_epvar.h>
53
54#ifdef __i386__
55#include <i386/isa/elink.h>
56#endif
57
58#ifdef __i386__
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/kernel.h>
37#include <sys/socket.h>
38#include <sys/module.h>
39#include <sys/bus.h>
40

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

51#include <dev/ep/if_epreg.h>
52#include <dev/ep/if_epvar.h>
53
54#ifdef __i386__
55#include <i386/isa/elink.h>
56#endif
57
58#ifdef __i386__
59static u_int16_t get_eeprom_data(int, int);
59static uint16_t get_eeprom_data(int, int);
60static void ep_isa_identify(driver_t *, device_t);
61#endif
62
63static int ep_isa_probe(device_t);
64static int ep_isa_attach(device_t);
65static int ep_eeprom_cksum(struct ep_softc *);
66
67struct isa_ident {
60static void ep_isa_identify(driver_t *, device_t);
61#endif
62
63static int ep_isa_probe(device_t);
64static int ep_isa_attach(device_t);
65static int ep_eeprom_cksum(struct ep_softc *);
66
67struct isa_ident {
68 u_int32_t id;
68 uint32_t id;
69 char *name;
70};
69 char *name;
70};
71const char *ep_isa_match_id(u_int32_t, struct isa_ident *);
71const char *ep_isa_match_id(uint32_t, struct isa_ident *);
72
73#define ISA_ID_3C509_XXX 0x0506d509
74#define ISA_ID_3C509_TP 0x506d5090
75#define ISA_ID_3C509_BNC 0x506d5091
76#define ISA_ID_3C509_COMBO 0x506d5094
77#define ISA_ID_3C509_TPO 0x506d5095
78#define ISA_ID_3C509_TPC 0x506d5098
79#ifdef PC98

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

114 * cards check for contention (ie: if one card writes a 0 bit and another
115 * writes a 1 bit then the host sees a 0. At the end of the cycle; each card
116 * compares the data on the bus; if there is a difference then that card goes
117 * into ID_WAIT state again). In the meantime; one bit of data is returned in
118 * the AX register which is conveniently returned to us by inb(). Hence; we
119 * read 16 times getting one bit of data with each read.
120 */
121#ifdef __i386__
72
73#define ISA_ID_3C509_XXX 0x0506d509
74#define ISA_ID_3C509_TP 0x506d5090
75#define ISA_ID_3C509_BNC 0x506d5091
76#define ISA_ID_3C509_COMBO 0x506d5094
77#define ISA_ID_3C509_TPO 0x506d5095
78#define ISA_ID_3C509_TPC 0x506d5098
79#ifdef PC98

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

114 * cards check for contention (ie: if one card writes a 0 bit and another
115 * writes a 1 bit then the host sees a 0. At the end of the cycle; each card
116 * compares the data on the bus; if there is a difference then that card goes
117 * into ID_WAIT state again). In the meantime; one bit of data is returned in
118 * the AX register which is conveniently returned to us by inb(). Hence; we
119 * read 16 times getting one bit of data with each read.
120 */
121#ifdef __i386__
122static u_int16_t
122static uint16_t
123get_eeprom_data(int id_port, int offset)
124{
125 int i;
123get_eeprom_data(int id_port, int offset)
124{
125 int i;
126 u_int16_t data = 0;
126 uint16_t data = 0;
127
128 outb(id_port, EEPROM_CMD_RD | offset);
129 DELAY(BIT_DELAY_MULTIPLE * 1000);
130 for (i = 0; i < 16; i++) {
131 DELAY(50);
132 data = (data << 1) | (inw(id_port) & 1);
133 }
134 return (data);
135}
136#endif
137
138const char *
127
128 outb(id_port, EEPROM_CMD_RD | offset);
129 DELAY(BIT_DELAY_MULTIPLE * 1000);
130 for (i = 0; i < 16; i++) {
131 DELAY(50);
132 data = (data << 1) | (inw(id_port) & 1);
133 }
134 return (data);
135}
136#endif
137
138const char *
139ep_isa_match_id(u_int32_t id, struct isa_ident *isa_devs)
139ep_isa_match_id(uint32_t id, struct isa_ident *isa_devs)
140{
141 struct isa_ident *i = isa_devs;
142
143 while (i->name != NULL) {
144 if (id == i->id)
145 return (i->name);
146 i++;
147 }

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

159static void
160ep_isa_identify(driver_t * driver, device_t parent)
161{
162 int tag = EP_LAST_TAG;
163 int found = 0;
164 int i;
165 int j;
166 const char *desc;
140{
141 struct isa_ident *i = isa_devs;
142
143 while (i->name != NULL) {
144 if (id == i->id)
145 return (i->name);
146 i++;
147 }

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

159static void
160ep_isa_identify(driver_t * driver, device_t parent)
161{
162 int tag = EP_LAST_TAG;
163 int found = 0;
164 int i;
165 int j;
166 const char *desc;
167 u_int16_t data;
168 u_int32_t irq;
169 u_int32_t ioport;
170 u_int32_t isa_id;
167 uint16_t data;
168 uint32_t irq;
169 uint32_t ioport;
170 uint32_t isa_id;
171 device_t child;
172
173 outb(ELINK_ID_PORT, 0);
174 outb(ELINK_ID_PORT, 0);
175 elink_idseq(ELINK_509_POLY);
176 elink_reset();
177
178 DELAY(DELAY_MULTIPLE * 10000);

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

351 return (error);
352}
353
354static int
355ep_eeprom_cksum(struct ep_softc *sc)
356{
357 int i;
358 int error;
171 device_t child;
172
173 outb(ELINK_ID_PORT, 0);
174 outb(ELINK_ID_PORT, 0);
175 elink_idseq(ELINK_509_POLY);
176 elink_reset();
177
178 DELAY(DELAY_MULTIPLE * 10000);

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

351 return (error);
352}
353
354static int
355ep_eeprom_cksum(struct ep_softc *sc)
356{
357 int i;
358 int error;
359 u_int16_t val;
360 u_int16_t cksum;
361 u_int8_t cksum_high = 0;
362 u_int8_t cksum_low = 0;
359 uint16_t val;
360 uint16_t cksum;
361 uint8_t cksum_high = 0;
362 uint8_t cksum_low = 0;
363
364 error = get_e(sc, 0x0f, &val);
365 if (error)
366 return (ENXIO);
367 cksum = val;
368
369 for (i = 0; i < 0x0f; i++) {
370 error = get_e(sc, i, &val);
371 if (error)
372 return (ENXIO);
373 switch (i) {
374 case 0x08:
375 case 0x09:
376 case 0x0d:
363
364 error = get_e(sc, 0x0f, &val);
365 if (error)
366 return (ENXIO);
367 cksum = val;
368
369 for (i = 0; i < 0x0f; i++) {
370 error = get_e(sc, i, &val);
371 if (error)
372 return (ENXIO);
373 switch (i) {
374 case 0x08:
375 case 0x09:
376 case 0x0d:
377 cksum_low ^= (u_int8_t) (val & 0x00ff) ^
378 (u_int8_t)((val & 0xff00) >> 8);
377 cksum_low ^= (uint8_t) (val & 0x00ff) ^
378 (uint8_t)((val & 0xff00) >> 8);
379 break;
380 default:
379 break;
380 default:
381 cksum_high ^= (u_int8_t) (val & 0x00ff) ^
382 (u_int8_t)((val & 0xff00) >> 8);
381 cksum_high ^= (uint8_t) (val & 0x00ff) ^
382 (uint8_t)((val & 0xff00) >> 8);
383 break;
384 }
385 }
383 break;
384 }
385 }
386 return (cksum != ((u_int16_t)cksum_low | (u_int16_t)(cksum_high << 8)));
386 return (cksum != ((uint16_t)cksum_low | (uint16_t)(cksum_high << 8)));
387}
388
389static device_method_t ep_isa_methods[] = {
390 /* Device interface */
391#ifdef __i386__
392 DEVMETHOD(device_identify, ep_isa_identify),
393#endif
394 DEVMETHOD(device_probe, ep_isa_probe),

--- 18 unchanged lines hidden ---
387}
388
389static device_method_t ep_isa_methods[] = {
390 /* Device interface */
391#ifdef __i386__
392 DEVMETHOD(device_identify, ep_isa_identify),
393#endif
394 DEVMETHOD(device_probe, ep_isa_probe),

--- 18 unchanged lines hidden ---