1/*- 2 * Copyright (c) 1996 Stefan Esser <se@freebsd.org> 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 9 * notice immediately at the beginning of the file, without modification, 10 * this list of conditions, and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. Absolutely no warranty of function or purpose is made by the author 15 * Stefan Esser. 16 * 4. Modifications may be freely made to this file if the above conditions 17 * are met. 18 */ 19 20#include <sys/cdefs.h>
| 1/*- 2 * Copyright (c) 1996 Stefan Esser <se@freebsd.org> 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 9 * notice immediately at the beginning of the file, without modification, 10 * this list of conditions, and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. Absolutely no warranty of function or purpose is made by the author 15 * Stefan Esser. 16 * 4. Modifications may be freely made to this file if the above conditions 17 * are met. 18 */ 19 20#include <sys/cdefs.h>
|
21__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed_pci.c 191234 2009-04-18 03:10:28Z imp $");
| 21__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed_pci.c 211792 2010-08-25 02:03:48Z imp $");
|
22 23#include <sys/param.h> 24#include <sys/systm.h> 25#include <sys/socket.h> 26#include <sys/kernel.h> 27 28#include <sys/module.h> 29#include <sys/bus.h> 30 31#include <machine/bus.h> 32#include <sys/rman.h> 33#include <machine/resource.h> 34 35#include <net/if.h> 36#include <net/if_arp.h> 37#include <net/if_media.h> 38#include <net/if_mib.h> 39 40#include <dev/pci/pcireg.h> 41#include <dev/pci/pcivar.h> 42 43#include <dev/ed/if_edvar.h> 44#include <dev/ed/rtl80x9reg.h> 45 46static struct _pcsid 47{ 48 uint32_t type; 49 const char *desc; 50} pci_ids[] = 51{
| 22 23#include <sys/param.h> 24#include <sys/systm.h> 25#include <sys/socket.h> 26#include <sys/kernel.h> 27 28#include <sys/module.h> 29#include <sys/bus.h> 30 31#include <machine/bus.h> 32#include <sys/rman.h> 33#include <machine/resource.h> 34 35#include <net/if.h> 36#include <net/if_arp.h> 37#include <net/if_media.h> 38#include <net/if_mib.h> 39 40#include <dev/pci/pcireg.h> 41#include <dev/pci/pcivar.h> 42 43#include <dev/ed/if_edvar.h> 44#include <dev/ed/rtl80x9reg.h> 45 46static struct _pcsid 47{ 48 uint32_t type; 49 const char *desc; 50} pci_ids[] = 51{
|
52 { ED_RTL8029_PCI_ID, "RealTek 8029" }, /* Needs realtek full duplex */ 53 { 0x50004a14, "NetVin NV5000SC" }, 54 { 0x09401050, "ProLAN" },
| |
55 { 0x140111f6, "Compex RL2000" },
| 52 { 0x140111f6, "Compex RL2000" },
|
| 53 { 0x005812c3, "Holtek HT80232" },
|
56 { 0x30008e2e, "KTI ET32P2" },
| 54 { 0x30008e2e, "KTI ET32P2" },
|
57 { 0x19808c4a, "Winbond W89C940" },
| 55 { 0x50004a14, "NetVin NV5000SC" }, 56 { 0x09401050, "ProLAN" }, 57 { ED_RTL8029_PCI_ID, "RealTek 8029" }, /* Needs realtek full duplex */
|
58 { 0x0e3410bd, "Surecom NE-34" },
| 58 { 0x0e3410bd, "Surecom NE-34" },
|
59 { 0x09261106, "VIA VT86C926" }, /* only do 16-bit */
| 59 { 0x09261106, "VIA VT86C926" }, 60 { 0x19808c4a, "Winbond W89C940" },
|
60 { 0x5a5a1050, "Winbond W89C940F" }, 61#if 0
| 61 { 0x5a5a1050, "Winbond W89C940F" }, 62#if 0
|
62 /* Holtek needs special lovin', disabled by default */ 63 { 0x005812c3, "Holtek HT80232" }, /* Only 16-bit I/O, Holtek fdx */
| 63 /* some Holtek needs special lovin', disabled by default */ 64 /* The Holtek can report/do full duplex, but that's unimplemented */
|
64 { 0x559812c3, "Holtek HT80229" }, /* Only 32-bit I/O, Holtek fdx, STOP_PG_60? */ 65#endif 66 { 0x00000000, NULL } 67}; 68 69static int ed_pci_probe(device_t); 70static int ed_pci_attach(device_t); 71 72static int 73ed_pci_probe(device_t dev) 74{ 75 uint32_t type = pci_get_devid(dev); 76 struct _pcsid *ep =pci_ids; 77 78 while (ep->type && ep->type != type) 79 ++ep; 80 if (ep->desc == NULL) 81 return (ENXIO); 82 device_set_desc(dev, ep->desc); 83 return (BUS_PROBE_DEFAULT); 84} 85 86static int 87ed_pci_attach(device_t dev) 88{ 89 struct ed_softc *sc = device_get_softc(dev);
| 65 { 0x559812c3, "Holtek HT80229" }, /* Only 32-bit I/O, Holtek fdx, STOP_PG_60? */ 66#endif 67 { 0x00000000, NULL } 68}; 69 70static int ed_pci_probe(device_t); 71static int ed_pci_attach(device_t); 72 73static int 74ed_pci_probe(device_t dev) 75{ 76 uint32_t type = pci_get_devid(dev); 77 struct _pcsid *ep =pci_ids; 78 79 while (ep->type && ep->type != type) 80 ++ep; 81 if (ep->desc == NULL) 82 return (ENXIO); 83 device_set_desc(dev, ep->desc); 84 return (BUS_PROBE_DEFAULT); 85} 86 87static int 88ed_pci_attach(device_t dev) 89{ 90 struct ed_softc *sc = device_get_softc(dev);
|
90 int flags = 0;
| |
91 int error = ENXIO; 92 93 /* 94 * Probe RTL8029 cards, but allow failure and try as a generic 95 * ne-2000. QEMU 0.9 and earlier use the RTL8029 PCI ID, but 96 * are areally just generic ne-2000 cards. 97 */ 98 if (pci_get_devid(dev) == ED_RTL8029_PCI_ID)
| 91 int error = ENXIO; 92 93 /* 94 * Probe RTL8029 cards, but allow failure and try as a generic 95 * ne-2000. QEMU 0.9 and earlier use the RTL8029 PCI ID, but 96 * are areally just generic ne-2000 cards. 97 */ 98 if (pci_get_devid(dev) == ED_RTL8029_PCI_ID)
|
99 error = ed_probe_RTL80x9(dev, PCIR_BAR(0), flags);
| 99 error = ed_probe_RTL80x9(dev, PCIR_BAR(0), 0);
|
100 if (error)
| 100 if (error)
|
101 error = ed_probe_Novell(dev, PCIR_BAR(0), flags);
| 101 error = ed_probe_Novell(dev, PCIR_BAR(0), 102 ED_FLAGS_FORCE_16BIT_MODE);
|
102 if (error) { 103 ed_release_resources(dev); 104 return (error); 105 } 106 ed_Novell_read_mac(sc); 107 108 error = ed_alloc_irq(dev, 0, RF_SHAREABLE); 109 if (error) { 110 ed_release_resources(dev); 111 return (error); 112 } 113 if (sc->sc_media_ioctl == NULL) 114 ed_gen_ifmedia_init(sc); 115 error = ed_attach(dev); 116 if (error) { 117 ed_release_resources(dev); 118 return (error); 119 } 120 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE, 121 NULL, edintr, sc, &sc->irq_handle); 122 if (error) 123 ed_release_resources(dev); 124 return (error); 125} 126 127static device_method_t ed_pci_methods[] = { 128 /* Device interface */ 129 DEVMETHOD(device_probe, ed_pci_probe), 130 DEVMETHOD(device_attach, ed_pci_attach), 131 DEVMETHOD(device_detach, ed_detach), 132 133 { 0, 0 } 134}; 135 136static driver_t ed_pci_driver = { 137 "ed", 138 ed_pci_methods, 139 sizeof(struct ed_softc), 140}; 141 142DRIVER_MODULE(ed, pci, ed_pci_driver, ed_devclass, 0, 0); 143MODULE_DEPEND(ed, pci, 1, 1, 1); 144MODULE_DEPEND(ed, ether, 1, 1, 1);
| 103 if (error) { 104 ed_release_resources(dev); 105 return (error); 106 } 107 ed_Novell_read_mac(sc); 108 109 error = ed_alloc_irq(dev, 0, RF_SHAREABLE); 110 if (error) { 111 ed_release_resources(dev); 112 return (error); 113 } 114 if (sc->sc_media_ioctl == NULL) 115 ed_gen_ifmedia_init(sc); 116 error = ed_attach(dev); 117 if (error) { 118 ed_release_resources(dev); 119 return (error); 120 } 121 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE, 122 NULL, edintr, sc, &sc->irq_handle); 123 if (error) 124 ed_release_resources(dev); 125 return (error); 126} 127 128static device_method_t ed_pci_methods[] = { 129 /* Device interface */ 130 DEVMETHOD(device_probe, ed_pci_probe), 131 DEVMETHOD(device_attach, ed_pci_attach), 132 DEVMETHOD(device_detach, ed_detach), 133 134 { 0, 0 } 135}; 136 137static driver_t ed_pci_driver = { 138 "ed", 139 ed_pci_methods, 140 sizeof(struct ed_softc), 141}; 142 143DRIVER_MODULE(ed, pci, ed_pci_driver, ed_devclass, 0, 0); 144MODULE_DEPEND(ed, pci, 1, 1, 1); 145MODULE_DEPEND(ed, ether, 1, 1, 1);
|