Deleted Added
full compact
if_vx_pci.c (146734) if_vx_pci.c (151014)
1/*-
2 * Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp>
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

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

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp>
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

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

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/vx/if_vx_pci.c 146734 2005-05-29 04:42:30Z nyan $");
31__FBSDID("$FreeBSD: head/sys/dev/vx/if_vx_pci.c 151014 2005-10-06 18:27:59Z jhb $");
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/kernel.h>
36#include <sys/module.h>
37#include <sys/socket.h>
38
39#include <net/if.h>

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

76MODULE_DEPEND(vx, ether, 1, 1, 1);
77
78static void
79vx_pci_shutdown(device_t dev)
80{
81 struct vx_softc *sc;
82
83 sc = device_get_softc(dev);
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/kernel.h>
36#include <sys/module.h>
37#include <sys/socket.h>
38
39#include <net/if.h>

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

76MODULE_DEPEND(vx, ether, 1, 1, 1);
77
78static void
79vx_pci_shutdown(device_t dev)
80{
81 struct vx_softc *sc;
82
83 sc = device_get_softc(dev);
84 vxstop(sc);
84 VX_LOCK(sc);
85 vx_stop(sc);
86 VX_UNLOCK(sc);
85}
86
87static int
88vx_pci_probe(device_t dev)
89{
90 u_int32_t device_id;
91
92 device_id = pci_read_config(dev, PCIR_DEVVENDOR, 4);

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

126
127 rid = PCIR_BAR(0);
128 sc->vx_res =
129 bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
130
131 if (sc->vx_res == NULL)
132 goto bad;
133
87}
88
89static int
90vx_pci_probe(device_t dev)
91{
92 u_int32_t device_id;
93
94 device_id = pci_read_config(dev, PCIR_DEVVENDOR, 4);

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

128
129 rid = PCIR_BAR(0);
130 sc->vx_res =
131 bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
132
133 if (sc->vx_res == NULL)
134 goto bad;
135
134 sc->bst = rman_get_bustag(sc->vx_res);
135 sc->bsh = rman_get_bushandle(sc->vx_res);
136 sc->vx_bst = rman_get_bustag(sc->vx_res);
137 sc->vx_bsh = rman_get_bushandle(sc->vx_res);
136
137 rid = 0;
138 sc->vx_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
139 RF_SHAREABLE | RF_ACTIVE);
140
141 if (sc->vx_irq == NULL)
142 goto bad;
143
138
139 rid = 0;
140 sc->vx_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
141 RF_SHAREABLE | RF_ACTIVE);
142
143 if (sc->vx_irq == NULL)
144 goto bad;
145
144 if (bus_setup_intr(dev, sc->vx_irq, INTR_TYPE_NET,
145 vxintr, sc, &sc->vx_intrhand))
146 if (vx_attach(dev) == 0)
146 goto bad;
147
147 goto bad;
148
148 if (vxattach(dev) == 0)
149 goto bad;
149 if (bus_setup_intr(dev, sc->vx_irq, INTR_TYPE_NET | INTR_MPSAFE,
150 vx_intr, sc, &sc->vx_intrhand))
151 goto bad_mtx;
150
151 /* defect check for 3C590 */
152 if ((pci_read_config(dev, PCIR_DEVVENDOR, 4) >> 16) == 0x5900) {
153 GO_WINDOW(0);
152
153 /* defect check for 3C590 */
154 if ((pci_read_config(dev, PCIR_DEVVENDOR, 4) >> 16) == 0x5900) {
155 GO_WINDOW(0);
154 if (vxbusyeeprom(sc))
155 goto bad;
156 if (vx_busy_eeprom(sc))
157 goto bad_mtx;
156 CSR_WRITE_2(sc, VX_W0_EEPROM_COMMAND,
157 EEPROM_CMD_RD | EEPROM_SOFTINFO2);
158 CSR_WRITE_2(sc, VX_W0_EEPROM_COMMAND,
159 EEPROM_CMD_RD | EEPROM_SOFTINFO2);
158 if (vxbusyeeprom(sc))
159 goto bad;
160 if (vx_busy_eeprom(sc))
161 goto bad_mtx;
160 if (!(CSR_READ_2(sc, VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY))
162 if (!(CSR_READ_2(sc, VX_W0_EEPROM_DATA) & NO_RX_OVN_ANOMALY))
161 printf("Warning! Defective early revision adapter!\n");
163 device_printf(dev,
164 "Warning! Defective early revision adapter!\n");
162 }
163 return (0);
164
165 }
166 return (0);
167
168bad_mtx:
169 mtx_destroy(&sc->vx_mtx);
165bad:
166 if (sc->vx_intrhand != NULL)
167 bus_teardown_intr(dev, sc->vx_irq, sc->vx_intrhand);
168 if (sc->vx_res != NULL)
169 bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->vx_res);
170 if (sc->vx_irq != NULL)
171 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vx_irq);
172 return (ENXIO);
173}
170bad:
171 if (sc->vx_intrhand != NULL)
172 bus_teardown_intr(dev, sc->vx_irq, sc->vx_intrhand);
173 if (sc->vx_res != NULL)
174 bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->vx_res);
175 if (sc->vx_irq != NULL)
176 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vx_irq);
177 return (ENXIO);
178}