Deleted Added
full compact
if_ep.c (139749) if_ep.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.c 139749 2005-01-06 01:43:34Z imp $");
32__FBSDID("$FreeBSD: head/sys/dev/ep/if_ep.c 140523 2005-01-20 19:39:33Z imp $");
33
34/*
35 * Modified from the FreeBSD 1.1.5.1 version by:
36 * Andres Vega Garcia
37 * INRIA - Sophia Antipolis, France
38 * avega@sophia.inria.fr
39 */
40

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

123 return (0);
124}
125
126/*
127 * get_e: gets a 16 bits word from the EEPROM. we must have set the window
128 * before
129 */
130int
33
34/*
35 * Modified from the FreeBSD 1.1.5.1 version by:
36 * Andres Vega Garcia
37 * INRIA - Sophia Antipolis, France
38 * avega@sophia.inria.fr
39 */
40

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

123 return (0);
124}
125
126/*
127 * get_e: gets a 16 bits word from the EEPROM. we must have set the window
128 * before
129 */
130int
131get_e(struct ep_softc *sc, u_int16_t offset, u_int16_t *result)
131get_e(struct ep_softc *sc, uint16_t offset, uint16_t *result)
132{
133
134 if (eeprom_rdy(sc))
135 return (ENXIO);
136
137 CSR_WRITE_2(sc, EP_W0_EEPROM_COMMAND,
138 (EEPROM_CMD_RD << sc->epb.cmd_off) | offset);
139

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

144
145 return (0);
146}
147
148int
149ep_get_macaddr(struct ep_softc *sc, u_char *addr)
150{
151 int i;
132{
133
134 if (eeprom_rdy(sc))
135 return (ENXIO);
136
137 CSR_WRITE_2(sc, EP_W0_EEPROM_COMMAND,
138 (EEPROM_CMD_RD << sc->epb.cmd_off) | offset);
139

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

144
145 return (0);
146}
147
148int
149ep_get_macaddr(struct ep_softc *sc, u_char *addr)
150{
151 int i;
152 u_int16_t result;
152 uint16_t result;
153 int error;
153 int error;
154 u_int16_t *macaddr;
154 uint16_t *macaddr;
155
155
156 macaddr = (u_int16_t *) addr;
156 macaddr = (uint16_t *) addr;
157
158 GO_WINDOW(sc, 0);
159 for (i = EEPROM_NODE_ADDR_0; i <= EEPROM_NODE_ADDR_2; i++) {
160 error = get_e(sc, i, &result);
161 if (error)
162 return (error);
163 macaddr[i] = htons(result);
164 }
165
166 return (0);
167}
168
169int
170ep_alloc(device_t dev)
171{
172 struct ep_softc *sc = device_get_softc(dev);
173 int rid;
174 int error = 0;
157
158 GO_WINDOW(sc, 0);
159 for (i = EEPROM_NODE_ADDR_0; i <= EEPROM_NODE_ADDR_2; i++) {
160 error = get_e(sc, i, &result);
161 if (error)
162 return (error);
163 macaddr[i] = htons(result);
164 }
165
166 return (0);
167}
168
169int
170ep_alloc(device_t dev)
171{
172 struct ep_softc *sc = device_get_softc(dev);
173 int rid;
174 int error = 0;
175 u_int16_t result;
175 uint16_t result;
176
177 rid = 0;
178 sc->iobase = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid,
179 RF_ACTIVE);
180 if (!sc->iobase) {
181 device_printf(dev, "No I/O space?!\n");
182 error = ENXIO;
183 goto bad;

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

216 if (error != 0)
217 ep_free(dev);
218 return (error);
219}
220
221void
222ep_get_media(struct ep_softc *sc)
223{
176
177 rid = 0;
178 sc->iobase = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid,
179 RF_ACTIVE);
180 if (!sc->iobase) {
181 device_printf(dev, "No I/O space?!\n");
182 error = ENXIO;
183 goto bad;

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

216 if (error != 0)
217 ep_free(dev);
218 return (error);
219}
220
221void
222ep_get_media(struct ep_softc *sc)
223{
224 u_int16_t config;
224 uint16_t config;
225
226 GO_WINDOW(sc, 0);
227 config = CSR_READ_2(sc, EP_W0_CONFIG_CTRL);
228 if (config & IS_AUI)
229 sc->ep_connectors |= AUI;
230 if (config & IS_BNC)
231 sc->ep_connectors |= BNC;
232 if (config & IS_UTP)

--- 754 unchanged lines hidden ---
225
226 GO_WINDOW(sc, 0);
227 config = CSR_READ_2(sc, EP_W0_CONFIG_CTRL);
228 if (config & IS_AUI)
229 sc->ep_connectors |= AUI;
230 if (config & IS_BNC)
231 sc->ep_connectors |= BNC;
232 if (config & IS_UTP)

--- 754 unchanged lines hidden ---