Subject: port-macppc/23287 ahc support
To: None <port-macppc@NetBSD.org>
From: Michael Wolfson <michael@nosflow.com>
List: port-macppc
Date: 10/16/2004 15:42:42
Y'all,

Tim Kelly sent me a quick hack that enabled my Adaptec 2940UW card 
(finally) after its breakage sometime in mid 2003.  The hack is 
included below.

I've applied this to both -current and 2.0RC4 as of yesterday.  In both 
cases, it allows my 2940UW card to work (though compilation produces a 
warning).  Without the above patch, GENERIC kernels (-current and 
2.0RC4) fail to map the registers on my card:
Adaptec AHA-2940 Ultra (SCSI mass storage) at ? dev 15 function 0 
(intrswiz 0, i
ntrpin 0x1, i/o off, mem on, no quirks): Adaptec 2940 Ultra SCSI adapter
: unable to map registers

If anyone's interested I can also send them the output of an unpatched 
-current kernel with PCI_CONFIG_DUMP enabled.

What's unusual is that the 2940UW works fine with a stock GENERIC 
kernel on my sparc64 machine, so the problem is specific to macppc.  
Additionally, a stock 1.6.2 GENERIC kernel works fine with the 2940UW 
on my macppc.

I haven't yet tried any kernels with Tim's posted pci_map_intr patch.

So, I guess the question is, how to proceed from here.

Thanks!

   -- MW


*** sys/dev/pci/ahc_pci.c   Sat Oct 16 13:20:14 2004
--- sys/dev/pci/ahc_pci.c.orig      Sat Oct 16 13:19:40 2004
***************
*** 66,74 ****
   #include <dev/pci/pcireg.h>
   #include <dev/pci/pcivar.h>

- #define AHC_ALLOW_MEMIO
-
   #define AHC_PCI_IOADDR        PCI_MAPREG_START        /* I/O Address 
*/
   #define AHC_PCI_MEMADDR       (PCI_MAPREG_START + 4)  /* Mem I/O 
Address */

--- 66,71 ----
***************
*** 838,844 ****
         ioh_valid = (pci_mapreg_map(pa, AHC_PCI_IOADDR,
                                     PCI_MAPREG_TYPE_IO, 0, &iot,
                                     &ioh, NULL, NULL) == 0);
! #if 1
         printf("%s: mem mapping: memt 0x%x, memh 0x%x, iot 0x%x, ioh 
0x%lx\n",
                ahc_name(ahc), memt, (u_int32_t)memh, (u_int32_t)iot, 
ioh);
   #endif
--- 836,842 ----
         ioh_valid = (pci_mapreg_map(pa, AHC_PCI_IOADDR,
                                     PCI_MAPREG_TYPE_IO, 0, &iot,
                                     &ioh, NULL, NULL) == 0);
! #if 0
         printf("%s: mem mapping: memt 0x%x, memh 0x%x, iot 0x%x, ioh 
0x%lx\n",
                ahc_name(ahc), memt, (u_int32_t)memh, (u_int32_t)iot, 
ioh);
   #endif