Deleted Added
sdiff udiff text old ( 158647 ) new ( 158663 )
full compact
1/* $NetBSD: if_le_pci.c,v 1.43 2005/12/11 12:22:49 christos Exp $ */
2
3/*-
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace

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

67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * SUCH DAMAGE.
70 *
71 * @(#)if_le.c 8.2 (Berkeley) 11/16/93
72 */
73
74#include <sys/cdefs.h>
75__FBSDID("$FreeBSD: head/sys/dev/le/if_le_pci.c 158647 2006-05-16 12:15:39Z ru $");
76
77#include <sys/param.h>
78#include <sys/systm.h>
79#include <sys/bus.h>
80#include <sys/endian.h>
81#include <sys/kernel.h>
82#include <sys/lock.h>
83#include <sys/module.h>

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

98
99#include <dev/le/lancereg.h>
100#include <dev/le/lancevar.h>
101#include <dev/le/am79900var.h>
102
103#define AMD_VENDOR 0x1022
104#define AMD_PCNET_PCI 0x2000
105#define AMD_PCNET_HOME 0x2001
106#define PCNET_MEMSIZE 16384
107#define PCNET_PCI_RDP 0x10
108#define PCNET_PCI_RAP 0x12
109#define PCNET_PCI_BDP 0x16
110
111struct le_pci_softc {
112 struct am79900_softc sc_am79900; /* glue to MI code */
113
114 int sc_rrid;

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

141 DEVMETHOD(device_suspend, le_pci_suspend),
142 DEVMETHOD(device_resume, le_pci_resume),
143
144 { 0, 0 }
145};
146
147DEFINE_CLASS_0(le, le_pci_driver, le_pci_methods, sizeof(struct le_pci_softc));
148DRIVER_MODULE(le, pci, le_pci_driver, le_devclass, 0, 0);
149MODULE_DEPEND(le_DRIVER_NAME, ether, 1, 1, 1);
150
151static const int le_home_supmedia[] = {
152 IFM_MAKEWORD(IFM_ETHER, IFM_HPNA_1, 0, 0)
153};
154
155static const int le_pci_supmedia[] = {
156 IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, 0),
157 IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, IFM_FDX, 0),

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

258
259 return (0);
260}
261
262static void
263le_pci_hwreset(struct lance_softc *sc)
264{
265
266 /* Chip is stopped. Set "software style" to 32-bit. */
267 le_pci_wrbcr(sc, LE_BCR20, LE_B20_SSTYLE_PCNETPCI2);
268}
269
270static void
271le_pci_dma_callback(void *xsc, bus_dma_segment_t *segs, int nsegs, int error)
272{
273 struct lance_softc *sc = (struct lance_softc *)xsc;
274
275 if (error != 0)

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

282le_pci_probe(device_t dev)
283{
284
285 if (pci_get_vendor(dev) != AMD_VENDOR)
286 return (ENXIO);
287
288 switch (pci_get_device(dev)) {
289 case AMD_PCNET_PCI:
290 case AMD_PCNET_HOME:
291 device_set_desc(dev, "AMD PCnet Ethernet");
292 return (BUS_PROBE_DEFAULT);
293 default:
294 return (ENXIO);
295 }
296}
297
298static int
299le_pci_attach(device_t dev)
300{

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

326 &lesc->sc_irid, RF_SHAREABLE | RF_ACTIVE)) == NULL) {
327 device_printf(dev, "cannot allocate interrupt\n");
328 error = ENXIO;
329 goto fail_rres;
330 }
331
332 error = bus_dma_tag_create(
333 NULL, /* parent */
334 PAGE_SIZE, 0, /* alignment, boundary */
335 BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
336 BUS_SPACE_MAXADDR, /* highaddr */
337 NULL, NULL, /* filter, filterarg */
338 BUS_SPACE_MAXSIZE_32BIT, /* maxsize */
339 0, /* nsegments */
340 BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */
341 BUS_DMA_WAITOK, /* flags */
342 NULL, NULL, /* lockfunc, lockarg */
343 &lesc->sc_pdmat);
344 if (error != 0) {
345 device_printf(dev, "cannot allocate parent DMA tag\n");
346 goto fail_ires;
347 }
348
349 sc->sc_memsize = PCNET_MEMSIZE;
350 error = bus_dma_tag_create(
351 lesc->sc_pdmat, /* parent */
352 1, 0, /* alignment, boundary */
353 BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
354 BUS_SPACE_MAXADDR, /* highaddr */
355 NULL, NULL, /* filter, filterarg */
356 sc->sc_memsize, /* maxsize */
357 1, /* nsegments */
358 sc->sc_memsize, /* maxsegsize */
359 BUS_DMA_WAITOK, /* flags */
360 NULL, NULL, /* lockfunc, lockarg */

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

377 if (error != 0 || sc->sc_addr == 0) {
378 device_printf(dev, "cannot load DMA buffer map\n");
379 goto fail_dmem;
380 }
381
382 sc->sc_flags = LE_BSWAP;
383 sc->sc_conf3 = 0;
384
385 switch (pci_get_device(dev)) {
386 case AMD_PCNET_HOME:
387 sc->sc_mediachange = le_pci_mediachange;
388 sc->sc_supmedia = le_home_supmedia;
389 sc->sc_nsupmedia = sizeof(le_home_supmedia) / sizeof(int);
390 sc->sc_defaultmedia = le_home_supmedia[0];
391 break;
392 default:

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

407 sc->sc_copyfromdesc = lance_copyfrombuf_contig;
408 sc->sc_copytobuf = lance_copytobuf_contig;
409 sc->sc_copyfrombuf = lance_copyfrombuf_contig;
410 sc->sc_zerobuf = lance_zerobuf_contig;
411
412 sc->sc_rdcsr = le_pci_rdcsr;
413 sc->sc_wrcsr = le_pci_wrcsr;
414 sc->sc_hwreset = le_pci_hwreset;
415
416 error = am79900_config(&lesc->sc_am79900, device_get_name(dev),
417 device_get_unit(dev));
418 if (error != 0) {
419 device_printf(dev, "cannot attach AM79900\n");
420 goto fail_dmap;
421 }
422
423 error = bus_setup_intr(dev, lesc->sc_ires, INTR_TYPE_NET | INTR_MPSAFE,
424 am79900_intr, sc, &lesc->sc_ih);
425 if (error != 0) {
426 device_printf(dev, "cannot set up interrupt\n");
427 goto fail_am79900;

--- 68 unchanged lines hidden ---