3c589 PCMCIA on A1200 - possible resolution to PR port-amiga/31134

Martin Åberg <[email protected]>
Newsgroups gmane.os.netbsd.ports.amiga
Message-ID <[email protected]>
Hello,

I have made an effort to get the 3Com 3C589 EtherLink III PCMCIA 
Ethernet card going in NetBSD 9.0 on Amiga A1200.

The results look promising. However, since I don't have access to other 
PCMCIA cards, one concern is that the patch could break support for 
other PCMCIA cards with 8-bit and 16-bit I/O.

Below is some background, an example and the patch.

----
The NetBSD Amiga PCMCIA bus driver, gayle_pcmcia.c, appears to be
working well with 8-bit PCMCIA I/O accesses but not 16-bit I/O accesses. 
This
patch enables support for 16-bit I/O accesses which allows for use of 
the 3Com
3C589 EtherLink III Ethernet controller.


Summary:
Mapping of motherboard (CPU) bus accesses to the PCMCIA bus is handled 
by the
Gayle chip. The chip and how it interfaces with the Amiga computer is 
not very
well docuemented.

For 8-bit PCMCIA I/O accesses, PCMCIA address line A0 is controlled by 
CPU A16
and is handled correctly by the current gayle_pcmcia.c.

For 16-bit PCMCIA I/O accesses, no address translation is needed on the CPU
side. However, the word data (16-bit) bus between the CPU bus and the PCMCIA
bus is byte swapped. This patch accounts for the byte-swapping in software.


How it was tested:
The patch has been tested with NetBSD 9.0 on an Amiga A1200 and the 3Com 
3C689
PCMCIA card. Two different processor boards were been used: Blizzard 1230 IV
and Blizzard 1260.

NetBSD 9.0 kernel boot message without this patch (same as reported in 
the 2005
problem report):
   [   1.0000050] pccard0 at mainbus0
   [   1.0000050] pcmcia0 at pccard0
   [   1.0000050] ep0 at pcmcia0 function 0: <3Com Corporation, 3C589D, 
TP/BNC LAN Card Ver. 2a, 000002>
   [   1.0000050] ep0: wrote 0x7ff to TX_AVAIL_THRESH, read back 0x0. 
Interface disabled
   [   1.0000050] ep0: couldn't configure controller

NetBSD 9.0 kernel boot message with this patch:
   [   1.0000050] pccard0 at mainbus0
   [   1.0000050] pcmcia0 at pccard0
   [   1.0000050] ep0 at pcmcia0 function 0: <3Com Corporation, 3C589D, 
TP/BNC LAN Card Ver. 2a, 000002>
   [   1.0000050] ep0: address 00:60:08:22:32:e4, 8KB byte-wide FIFO, 
5:3 Rx:Tx split
   [   1.0000050] ep0: 10baseT, 10base5, 10base2 (default 10baseT)


Example use:
   # ifconfig ep0
   ep0: flags=0x8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
           address: 00:60:08:22:32:e4
           media: Ethernet 10baseT
           inet 192.168.1.2/24 broadcast 192.168.1.255 flags 0x0
           inet6 fe80::260:8ff:fe22:32e4%ep0/64 flags 0x0 scopeid 0x1
   # ping 192.168.1.1
   PING cl (192.168.1.1): 56 data bytes
   64 bytes from 192.168.1.1: icmp_seq=0 ttl=64 time=5.315917 ms
   64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=7.304981 ms
   64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=7.319078 ms
   64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=7.288065 ms

   ----cl PING Statistics----
   4 packets transmitted, 4 packets received, 0.0% packet loss
   round-trip min/avg/max/stddev = 5.315917/6.807010/7.319078/0.994143 ms


Others:
- Unplugging the card and inserting it again works.
- Not tested with other PCMCIA cards.
- Closes PR port-amiga/31134


Patch:
(Yes, it changes only a single source code line.)

$ git diff origin/netbsd-9
diff --git a/sys/arch/amiga/dev/gayle_pcmcia.c 
b/sys/arch/amiga/dev/gayle_pcmcia.c
index ea3a131b98ff..8bc49f61fd55 100644
--- a/sys/arch/amiga/dev/gayle_pcmcia.c
+++ b/sys/arch/amiga/dev/gayle_pcmcia.c
@@ -131,7 +131,7 @@ pccard_attach(device_t parent, device_t self, void *aux)
         pmap_update(vm_map_pmap(kernel_map));

         /* override the one-byte access methods for I/O space */
-       pcmio_bs_methods = amiga_bus_stride_1;
+       pcmio_bs_methods = amiga_bus_stride_1swap;
         pcmio_bs_methods.bsr1 = pcmio_bsr1;
         pcmio_bs_methods.bsw1 = pcmio_bsw1;
         pcmio_bs_methods.bsrm1 = pcmio_bsrm1;

----

/Martin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.