if_le_pci.c (158647) | if_le_pci.c (158663) |
---|---|
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> | 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 $"); | 75__FBSDID("$FreeBSD: head/sys/dev/le/if_le_pci.c 158663 2006-05-16 21:04:01Z marius $"); |
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 | 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 | 106#define PCNET_MEMSIZE (32*1024) |
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); | 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); | 149MODULE_DEPEND(le, 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 | 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); | 266 /* Chip is stopped. Set software style to ILACC (32-bit). */ 267 le_pci_wrbcr(sc, LE_BCR20, LE_B20_SSTYLE_ILACC); |
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: | 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 device_set_desc(dev, "AMD PCnet-PCI"); 291 /* Let pcn(4) win. */ 292 return (BUS_PROBE_LOW_PRIORITY); |
|
290 case AMD_PCNET_HOME: | 293 case AMD_PCNET_HOME: |
291 device_set_desc(dev, "AMD PCnet Ethernet"); 292 return (BUS_PROBE_DEFAULT); | 294 device_set_desc(dev, "AMD PCnet-Home"); 295 /* Let pcn(4) win. */ 296 return (BUS_PROBE_LOW_PRIORITY); |
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 */ | 297 default: 298 return (ENXIO); 299 } 300} 301 302static int 303le_pci_attach(device_t dev) 304{ --- 25 unchanged lines hidden (view full) --- 330 &lesc->sc_irid, RF_SHAREABLE | RF_ACTIVE)) == NULL) { 331 device_printf(dev, "cannot allocate interrupt\n"); 332 error = ENXIO; 333 goto fail_rres; 334 } 335 336 error = bus_dma_tag_create( 337 NULL, /* parent */ |
334 PAGE_SIZE, 0, /* alignment, boundary */ | 338 1, 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; | 339 BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ 340 BUS_SPACE_MAXADDR, /* highaddr */ 341 NULL, NULL, /* filter, filterarg */ 342 BUS_SPACE_MAXSIZE_32BIT, /* maxsize */ 343 0, /* nsegments */ 344 BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 345 BUS_DMA_WAITOK, /* flags */ 346 NULL, NULL, /* lockfunc, lockarg */ 347 &lesc->sc_pdmat); 348 if (error != 0) { 349 device_printf(dev, "cannot allocate parent DMA tag\n"); 350 goto fail_ires; 351 } 352 353 sc->sc_memsize = PCNET_MEMSIZE; |
354 /* 355 * For Am79C970A, Am79C971 and Am79C978 the init block must be 2-byte 356 * aligned and the ring descriptors must be 16-byte aligned when using 357 * a 32-bit software style. 358 */ |
|
350 error = bus_dma_tag_create( 351 lesc->sc_pdmat, /* parent */ | 359 error = bus_dma_tag_create( 360 lesc->sc_pdmat, /* parent */ |
352 1, 0, /* alignment, boundary */ | 361 16, 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 | 362 BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ 363 BUS_SPACE_MAXADDR, /* highaddr */ 364 NULL, NULL, /* filter, filterarg */ 365 sc->sc_memsize, /* maxsize */ 366 1, /* nsegments */ 367 sc->sc_memsize, /* maxsegsize */ 368 BUS_DMA_WAITOK, /* flags */ 369 NULL, NULL, /* lockfunc, lockarg */ --- 16 unchanged lines hidden (view full) --- 386 if (error != 0 || sc->sc_addr == 0) { 387 device_printf(dev, "cannot load DMA buffer map\n"); 388 goto fail_dmem; 389 } 390 391 sc->sc_flags = LE_BSWAP; 392 sc->sc_conf3 = 0; 393 |
394 sc->sc_mediastatus = NULL; |
|
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; | 395 switch (pci_get_device(dev)) { 396 case AMD_PCNET_HOME: 397 sc->sc_mediachange = le_pci_mediachange; 398 sc->sc_supmedia = le_home_supmedia; 399 sc->sc_nsupmedia = sizeof(le_home_supmedia) / sizeof(int); 400 sc->sc_defaultmedia = le_home_supmedia[0]; 401 break; 402 default: --- 14 unchanged lines hidden (view full) --- 417 sc->sc_copyfromdesc = lance_copyfrombuf_contig; 418 sc->sc_copytobuf = lance_copytobuf_contig; 419 sc->sc_copyfrombuf = lance_copyfrombuf_contig; 420 sc->sc_zerobuf = lance_zerobuf_contig; 421 422 sc->sc_rdcsr = le_pci_rdcsr; 423 sc->sc_wrcsr = le_pci_wrcsr; 424 sc->sc_hwreset = le_pci_hwreset; |
425 sc->sc_hwinit = NULL; 426 sc->sc_hwintr = NULL; 427 sc->sc_nocarrier = NULL; |
|
415 416 error = am79900_config(&lesc->sc_am79900, device_get_name(dev), 417 device_get_unit(dev)); 418 if (error != 0) { | 428 429 error = am79900_config(&lesc->sc_am79900, device_get_name(dev), 430 device_get_unit(dev)); 431 if (error != 0) { |
419 device_printf(dev, "cannot attach AM79900\n"); | 432 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 --- | 433 goto fail_dmap; 434 } 435 436 error = bus_setup_intr(dev, lesc->sc_ires, INTR_TYPE_NET | INTR_MPSAFE, 437 am79900_intr, sc, &lesc->sc_ih); 438 if (error != 0) { 439 device_printf(dev, "cannot set up interrupt\n"); 440 goto fail_am79900; --- 68 unchanged lines hidden --- |