Subject: kern/8443: Some isapnp devices are not activated.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <mer@interlink.or.jp>
List: netbsd-bugs
Date: 09/18/1999 23:35:49
>Number:         8443
>Category:       kern
>Synopsis:       Some isapnp devices are not activated.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 18 23:35:01 1999
>Last-Modified:
>Originator:     YAMANO-UCHI, Hidetoshi
>Organization:
>Release:        NetBSD-1.4.1
>Environment:
NetBSD printemps 1.4.1 NetBSD 1.4.1 (PRINTEMPS_OPTI) #7: Sun Sep 19 13:18:33 JST 1999     mer@printemps:/usr/src/sys/arch/i386/compile/PRINTEMPS_OPTI i386

>Description:
Some isapnp devices are not activate in NetBSD-1.4.1.
The specs. on isapnp said that isapnp devices are activated
AFTER sending WAIT_FOR_KEY.

And some isapnp devices are assigned duplicated DRQ
as follow.

wss1 at isapnp0 port 0x534/4,0x380/12,0x220/16,0xe0c/4 irq 5 drq 0,0

P.S.  PR:kern/7370 is obsoleted.  
P.S.2 This fix is not good.
>How-To-Repeat:


>Fix:
--- /sys/dev/isapnp/isapnp.c    Mon Mar 22 18:38:58 1999
+++ isapnp.c    Sun Sep 19 13:53:41 1999
@@ -106,6 +106,8 @@
        int i;
        u_char v = ISAPNP_LFSR_INIT;
 
+       isapnp_write_reg(sc, ISAPNP_CONFIG_CONTROL, ISAPNP_CC_WAIT_FOR_KEY);
+
        /* First write 0's twice to enter the Wait for Key state */
        ISAPNP_WRITE_ADDR(sc, 0);
        ISAPNP_WRITE_ADDR(sc, 0);
@@ -115,6 +117,7 @@
                ISAPNP_WRITE_ADDR(sc, v);
                v = ISAPNP_LFSR_NEXT(v);
        }
+       DELAY(2000);
 }
 
 
@@ -337,6 +340,12 @@
                error = isapnp_alloc_drq(ipa->ipa_ic, &ipa->ipa_drq[ndrq]);
                if (error)
                        goto bad;
+               {
+                 int b;
+
+                 for (b = ndrq + 1; b < ipa->ipa_ndrq; b++)
+                   ipa->ipa_drq[b].bits &= ~( 1 << ipa->ipa_drq[ndrq].num );
+               }
        }
 
        if (alloc)
@@ -721,6 +730,12 @@
                if (isapnp_findcard(sc))
                        break;
                isapnp_unmap_readport(sc);
+               /* Reset the cards */
+               isapnp_write_reg(sc, ISAPNP_CONFIG_CONTROL, ISAPNP_CC_RESET_DRV)
;
+               DELAY(2000);
+               /* Send the key again */
+               isapnp_init(sc);
+               DELAY(2000);
        }
 
        if (p > ISAPNP_RDDATA_MAX) {
@@ -970,6 +985,9 @@
        struct isapnp_attach_args *ipa, *lpa;
        int c, d;
 
+       int i = 0;
+       struct isapnp_attach_args lpa_array[20];
+
        /*
         * Look for cards.  If none are found, we say so and just return.
         */
@@ -981,12 +999,14 @@
 
        printf("%s: read port 0x%x\n", sc->sc_dev.dv_xname, sc->sc_read_port);
 
+        isapnp_init(sc);
        /*
         * Now configure all of the cards.
         */
        for (c = 0; c < sc->sc_ncards; c++) {
                /* Good morning card c */
                isapnp_write_reg(sc, ISAPNP_WAKE, c + 1);
+               DELAY(250);
 
                if ((ipa = isapnp_get_resource(sc, c)) == NULL)
                        continue;
@@ -994,7 +1014,14 @@
                DPRINTF(("Selecting attachments\n"));
                for (d = 0;
                    (lpa = isapnp_bestconfig(sc, &ipa)) != NULL; d++) {
-                       isapnp_write_reg(sc, ISAPNP_LOGICAL_DEV_NUM, d);
+                         isapnp_write_reg(sc, ISAPNP_WAKE, c + 1);
+                         isapnp_write_reg(sc, ISAPNP_LOGICAL_DEV_NUM, d);
+                         /* search apropreate device driver */
+                         if (config_search(isapnp_submatch, self, 
+                                           lpa) == NULL ) {
+                           isapnp_write_reg(sc, ISAPNP_ACTIVATE, 0);
+                           continue;
+                         }
                        isapnp_configure(sc, lpa);
 #ifdef DEBUG_ISAPNP
                        {
@@ -1024,11 +1051,23 @@
                        lpa->ipa_memt = sc->sc_memt;
                        lpa->ipa_dmat = sc->sc_dmat;
 
-                       isapnp_write_reg(sc, ISAPNP_ACTIVATE, 1);
 #ifdef _KERNEL
+#if 0
                        if (config_found_sm(self, lpa, isapnp_print,
-                           isapnp_submatch) == NULL)
-                               isapnp_write_reg(sc, ISAPNP_ACTIVATE, 0);
+                            isapnp_submatch) == NULL)
+#else
+                       {
+                         if (i<=20) {
+                           isapnp_write_reg(sc, ISAPNP_LOGICAL_DEV_NUM, d);
+                           isapnp_write_reg(sc, ISAPNP_IO_RANGE_CHECK, 0);
+                           DELAY(1000); /* XXX is it really necessary ? */
+                           isapnp_write_reg(sc, ISAPNP_ACTIVATE, 1);
+                           DELAY(1000); /* XXX is it really necessary ? */
+                           lpa_array[i] = *lpa;
+                           i++;
+                         }
+                       }
+#endif
 #else
                        isapnp_print(lpa, NULL);
                        printf("\n");
@@ -1037,4 +1076,11 @@
                }
                isapnp_write_reg(sc, ISAPNP_WAKE, 0);    /* Good night cards */
        }
+       isapnp_write_reg(sc, ISAPNP_CONFIG_CONTROL, ISAPNP_CC_WAIT_FOR_KEY);
+       DELAY(1000); /* XXX is it really necessary ? */
+#if 1
+       for(d=0;d<i;d++) {
+         config_found_sm(self, &lpa_array[d], isapnp_print, isapnp_submatch);
+       }
+#endif
 }


>Audit-Trail:
>Unformatted: