Author: imp
Date: Wed Aug 25 02:03:48 2010
New Revision: 211792
URL: http://svn.freebsd.org/changeset/base/211792

Log:
  Prodded by Yongari, add support for Holtek HT80232.  Add the device
  ID, plus the ability to force '16-bit mode' which really means NE-2000
  mode.  Other open source drivers suggest that the Holtek misbehaves if
  you allow the 8-bit probe.  Also, all of the PCI chips emulate
  NE-2000ish cards, so always force 16-bit mode for memory transfers.
  
  PR:           84202 (patch not used)

Modified:
  head/sys/dev/ed/if_ed_novell.c
  head/sys/dev/ed/if_ed_pci.c

Modified: head/sys/dev/ed/if_ed_novell.c
==============================================================================
--- head/sys/dev/ed/if_ed_novell.c      Wed Aug 25 01:50:12 2010        
(r211791)
+++ head/sys/dev/ed/if_ed_novell.c      Wed Aug 25 02:03:48 2010        
(r211792)
@@ -123,39 +123,50 @@ ed_probe_Novell_generic(device_t dev, in
        ed_nic_outb(sc, ED_P0_PSTART, 8192 / ED_PAGE_SIZE);
        ed_nic_outb(sc, ED_P0_PSTOP, 16384 / ED_PAGE_SIZE);
 
-       sc->isa16bit = 0;
-
        /*
-        * Write a test pattern in byte mode. If this fails, then there
-        * probably isn't any memory at 8k - which likely means that the board
-        * is an NE2000.
+        * Some devices identify themselves.  Some of those devices
+        * can't handle being probed, so we allow forcing a mode.  If
+        * these flags are set, force it, otherwise probe.
         */
-       ed_pio_writemem(sc, test_pattern, 8192, sizeof(test_pattern));
-       ed_pio_readmem(sc, 8192, test_buffer, sizeof(test_pattern));
-
-       if (bcmp(test_pattern, test_buffer, sizeof(test_pattern)) == 0) {
+       if (flags & ED_FLAGS_FORCE_8BIT_MODE) {
+               sc->isa16bit = 0;
                sc->type = ED_TYPE_NE1000;
                sc->type_str = "NE1000";
-       } else {
-
-               /* Not an NE1000 - try NE2000 */
-               ed_nic_outb(sc, ED_P0_DCR, ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
-               ed_nic_outb(sc, ED_P0_PSTART, 16384 / ED_PAGE_SIZE);
-               ed_nic_outb(sc, ED_P0_PSTOP, 32768 / ED_PAGE_SIZE);
-
+       } else if (flags & ED_FLAGS_FORCE_16BIT_MODE) {
                sc->isa16bit = 1;
-
+               sc->type = ED_TYPE_NE2000;
+               sc->type_str = "NE2000";
+       } else {
                /*
-                * Write a test pattern in word mode. If this also fails, then
-                * we don't know what this board is.
+                * Write a test pattern in byte mode. If this fails, then there
+                * probably isn't any memory at 8k - which likely means that 
the board
+                * is an NE2000.
                 */
-               ed_pio_writemem(sc, test_pattern, 16384, sizeof(test_pattern));
-               ed_pio_readmem(sc, 16384, test_buffer, sizeof(test_pattern));
+               ed_pio_writemem(sc, test_pattern, 8192, sizeof(test_pattern));
+               ed_pio_readmem(sc, 8192, test_buffer, sizeof(test_pattern));
+
                if (bcmp(test_pattern, test_buffer, sizeof(test_pattern)) == 0) 
{
-                       sc->type = ED_TYPE_NE2000;
-                       sc->type_str = "NE2000";
+                       sc->type = ED_TYPE_NE1000;
+                       sc->type_str = "NE1000";
+                       sc->isa16bit = 0;
                } else {
-                       return (ENXIO);
+                       /* Not an NE1000 - try NE2000 */
+                       sc->isa16bit = 1;
+                       ed_nic_outb(sc, ED_P0_DCR, ED_DCR_WTS | ED_DCR_FT1 | 
ED_DCR_LS);
+                       ed_nic_outb(sc, ED_P0_PSTART, 16384 / ED_PAGE_SIZE);
+                       ed_nic_outb(sc, ED_P0_PSTOP, 32768 / ED_PAGE_SIZE);
+                       /*
+                        * Write a test pattern in word mode. If this also 
fails, then
+                        * we don't know what this board is.
+                        */
+                       ed_pio_writemem(sc, test_pattern, 16384, 
sizeof(test_pattern));
+                       ed_pio_readmem(sc, 16384, test_buffer, 
sizeof(test_pattern));
+                       if (bcmp(test_pattern, test_buffer, 
sizeof(test_pattern)) == 0) {
+                               sc->type = ED_TYPE_NE2000;
+                               sc->type_str = "NE2000";
+                       } else {
+                               return (ENXIO);
+                       }
                }
        }
        sc->chip_type = ED_CHIP_TYPE_DP8390;

Modified: head/sys/dev/ed/if_ed_pci.c
==============================================================================
--- head/sys/dev/ed/if_ed_pci.c Wed Aug 25 01:50:12 2010        (r211791)
+++ head/sys/dev/ed/if_ed_pci.c Wed Aug 25 02:03:48 2010        (r211792)
@@ -49,18 +49,19 @@ static struct _pcsid
        const char      *desc;
 } pci_ids[] =
 {
-       { ED_RTL8029_PCI_ID, "RealTek 8029" }, /* Needs realtek full duplex */
-       { 0x50004a14, "NetVin NV5000SC" },
-       { 0x09401050, "ProLAN" },
        { 0x140111f6, "Compex RL2000" },
+       { 0x005812c3, "Holtek HT80232" },
        { 0x30008e2e, "KTI ET32P2" },
-       { 0x19808c4a, "Winbond W89C940" },
+       { 0x50004a14, "NetVin NV5000SC" },
+       { 0x09401050, "ProLAN" },
+       { ED_RTL8029_PCI_ID, "RealTek 8029" }, /* Needs realtek full duplex */
        { 0x0e3410bd, "Surecom NE-34" },
-       { 0x09261106, "VIA VT86C926" },         /* only do 16-bit */
+       { 0x09261106, "VIA VT86C926" },
+       { 0x19808c4a, "Winbond W89C940" },
        { 0x5a5a1050, "Winbond W89C940F" },
 #if 0
-       /* Holtek needs special lovin', disabled by default */
-       { 0x005812c3, "Holtek HT80232" },       /* Only 16-bit I/O, Holtek fdx 
*/
+       /* some Holtek needs special lovin', disabled by default */
+       /* The Holtek can report/do full duplex, but that's unimplemented */
        { 0x559812c3, "Holtek HT80229" },       /* Only 32-bit I/O, Holtek fdx, 
STOP_PG_60? */
 #endif
        { 0x00000000, NULL }
@@ -87,7 +88,6 @@ static int
 ed_pci_attach(device_t dev)
 {
        struct  ed_softc *sc = device_get_softc(dev);
-       int     flags = 0;
        int     error = ENXIO;
 
        /*
@@ -96,9 +96,10 @@ ed_pci_attach(device_t dev)
         * are areally just generic ne-2000 cards.
         */
        if (pci_get_devid(dev) == ED_RTL8029_PCI_ID)
-               error = ed_probe_RTL80x9(dev, PCIR_BAR(0), flags);
+               error = ed_probe_RTL80x9(dev, PCIR_BAR(0), 0);
        if (error)
-               error = ed_probe_Novell(dev, PCIR_BAR(0), flags);
+               error = ed_probe_Novell(dev, PCIR_BAR(0),
+                   ED_FLAGS_FORCE_16BIT_MODE);
        if (error) {
                ed_release_resources(dev);
                return (error);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to