Subject: kern/8634: pcmcia code can't do 8-bit memory accesses
To: None <gnats-bugs@gnats.netbsd.org>
From: Johan Danielsson <joda@pdc.kth.se>
List: netbsd-bugs
Date: 10/16/1999 05:49:03
>Number:         8634
>Category:       kern
>Synopsis:       pcmcia code can't do 8-bit memory accesses
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 16 05:48:00 1999
>Last-Modified:
>Originator:     Johan Danielsson
>Organization:
>Release:        1999-10-15
>Environment:
System: NetBSD blubb.pdc.kth.se 1.4L NetBSD 1.4L (BLUBB) #10: Fri Oct 15 18:21:51 CEST 1999 joda@blubb.pdc.kth.se:/usr/misc/src/netbsd/anoncvs/syssrc/sys/arch/i386/compile/BLUBB i386


>Description:

I have a network card that needs 8-bit memory accesses, unfortunately
the pcmcia code can't do this (it always does 16-bit accesses), and
there is no way to specify this in the interface to pcmcia_mem_map.

>How-To-Repeat:
>Fix:

This is a patch for the 82365 and cardbus bridges, a similar change
has to be made (i guess) to tcic_chip_do_mem_map,
stp4020_chip_mem_map, and (the to-be-written) shpcic_chip_do_mem_map.
I don't know enough about these to do the correct change.

Index: pcmcia/pcmciachip.h
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/pcmcia/pcmciachip.h,v
retrieving revision 1.4
diff -w -u -r1.4 pcmciachip.h
--- pcmciachip.h	1999/10/15 06:07:32	1.4
+++ pcmciachip.h	1999/10/16 12:41:32
@@ -47,6 +47,11 @@
 #define	PCMCIA_MEM_ATTR		1
 #define	PCMCIA_MEM_COMMON	2
 
+#define PCMCIA_WIDTH_MEM8	8
+#define PCMCIA_WIDTH_MEM16	16
+
+#define PCMCIA_WIDTH_MEM_MASK	24
+
 #define	PCMCIA_WIDTH_AUTO	0
 #define	PCMCIA_WIDTH_IO8	1
 #define	PCMCIA_WIDTH_IO16	2
Index: ic/i82365.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/ic/i82365.c,v
retrieving revision 1.25
diff -w -u -r1.25 i82365.c
--- i82365.c	1999/10/15 06:07:27	1.25
+++ i82365.c	1999/10/16 12:38:35
@@ -896,6 +896,9 @@
 {
 	int reg;
 
+	int kind = h->mem[win].kind & ~PCMCIA_WIDTH_MEM_MASK;
+	int mem8 = (h->mem[win].kind & PCMCIA_WIDTH_MEM_MASK) == PCMCIA_WIDTH_MEM8;
+
 	pcic_write(h, mem_map_index[win].sysmem_start_lsb,
 	    (h->mem[win].addr >> PCIC_SYSMEM_ADDRX_SHIFT) & 0xff);
 	pcic_write(h, mem_map_index[win].sysmem_start_msb,
@@ -921,11 +924,11 @@
 	pcic_write(h, mem_map_index[win].cardmem_msb,
 	    ((h->mem[win].offset >> (PCIC_CARDMEM_ADDRX_SHIFT + 8)) &
 	    PCIC_CARDMEM_ADDRX_MSB_ADDR_MASK) |
-	    ((h->mem[win].kind == PCMCIA_MEM_ATTR) ?
+	    ((kind == PCMCIA_MEM_ATTR) ?
 	    PCIC_CARDMEM_ADDRX_MSB_REGACTIVE_ATTR : 0));
 
 	reg = pcic_read(h, PCIC_ADDRWIN_ENABLE);
-	reg |= (mem_map_index[win].memenable | PCIC_ADDRWIN_ENABLE_MEMCS16);
+	reg |= (mem_map_index[win].memenable | (mem8 ? 0 : PCIC_ADDRWIN_ENABLE_MEMCS16));
 	pcic_write(h, PCIC_ADDRWIN_ENABLE, reg);
 
 	delay(100);
Index: pci/pccbb.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/pci/pccbb.c,v
retrieving revision 1.2
diff -w -u -r1.2 pccbb.c
--- pccbb.c	1999/10/15 06:42:39	1.2
+++ pccbb.c	1999/10/16 12:38:36
@@ -2337,6 +2337,9 @@
   u_int8_t mem_window;
   int reg;
 
+  int kind = ph->mem[win].kind & ~PCMCIA_WIDTH_MEM_MASK;
+  int mem8 = (ph->mem[win].kind & PCMCIA_WIDTH_MEM_MASK) == PCMCIA_WIDTH_MEM8;
+
   regbase_win = 0x10 + win*0x08;
 
   phys_addr = ph->mem[win].addr;
@@ -2351,7 +2354,7 @@
 
   start_low = (phys_addr >> PCIC_MEMREG_LSB_SHIFT) & 0xff; /* bit 19:12 */
   start_high = ((phys_addr >> PCIC_MEMREG_MSB_SHIFT) & 0x0f) /* bit 23:20 */
-    | PCIC_SYSMEM_ADDRX_START_MSB_DATASIZE_16BIT; /* bit 7 on */
+      | mem8 ? 0 : PCIC_SYSMEM_ADDRX_START_MSB_DATASIZE_16BIT; /* bit 7 on */
  /* bit 31:24, for 32-bit address */
   mem_window = (phys_addr >> PCIC_MEMREG_WIN_SHIFT) & 0xff; /* bit 31:24 */
 
@@ -2362,13 +2365,6 @@
     Pcic_write(ph, 0x40 + win, mem_window);
   }
 
-
-#if 0
-  /* XXX do I want 16 bit all the time? */
-  PCIC_SYSMEM_ADDRX_START_MSB_DATASIZE_16BIT;
-#endif
-
-
   stop_low = (phys_end >> PCIC_MEMREG_LSB_SHIFT) & 0xff;
   stop_high = ((phys_end >> PCIC_MEMREG_MSB_SHIFT) & 0x0f)
     | PCIC_SYSMEM_ADDRX_STOP_MSB_WAIT2;	/* wait 2 cycles */
@@ -2380,7 +2376,7 @@
   off_low = (ph->mem[win].offset >> PCIC_CARDMEM_ADDRX_SHIFT) & 0xff;
   off_high = ((ph->mem[win].offset >> (PCIC_CARDMEM_ADDRX_SHIFT + 8))
 	      & PCIC_CARDMEM_ADDRX_MSB_ADDR_MASK)
-    | ((ph->mem[win].kind == PCMCIA_MEM_ATTR) ?
+    | ((kind == PCMCIA_MEM_ATTR) ?
        PCIC_CARDMEM_ADDRX_MSB_REGACTIVE_ATTR : 0);
 
   Pcic_write(ph, regbase_win + PCIC_CMA_LOW, off_low);
>Audit-Trail:
>Unformatted: