Subject: S900 patch(es)
To: netbsd-macppc <port-macppc@netbsd.org>
From: Michael <macallan18@earthlink.net>
List: port-macppc
Date: 07/15/2004 19:22:04
--Apple-Mail-4--42625219
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed

Hello,

so, I send-pr'ed my work. Now it uses pci_conf_hook() to configure the 
E100's ethernet
part before the normal autoconfig stuff - it shouldn't touch anything 
else than that. The tulip driver just got one more quirk function and 
doesn't contain any weird hack anymore.
All you need is
option PCI_NETBSD_CONFIGURE
tlp*	at pci? dev ? function ?
nsphy* at mii? phy ?
in your kernel config and NetBSD 2.0G. It may work on earlier releases 
too but I wouldn't bet on it and the pci_machdep.c patch will need 
work. Attached files are the patch itself ( it includes a little patch 
I made earlier which fixes a bug in interrupt assignment for cards 
behind the S900's PCI-PCI bridge ) and my dmesg output.

have fun
Michael

--Apple-Mail-4--42625219
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name="log"
Content-Disposition: attachment;
	filename=log

NetBSD 2.0G (MACALLAN) #66: Thu Jul 15 18:29:54 EDT 2004
	ml@Macallan:/usr/src/sys/arch/macppc/compile/MACALLAN
total memory = 224 MB
avail memory = 212 MB
mainbus0 (root)
cpu0 at mainbus0: 750 (Revision 2.2), ID 0 (primary)
cpu0: HID0 8090c0a4<EMCP,DOZE,DPM,ICE,DCE,SGE,BTIC,BHT>
cpu0: 300.00 MHz, no-parity 1MB WB L2 cache (PB SRAM) at 2:1 ratio
bandit0 at mainbus0
pci0 at bandit0 bus 0
pci0: i/o space, memory space enabled
pchb0 at pci0 dev 11 function 0
pchb0: Apple Computer Bandit Host-PCI Bridge (rev. 0x03)
isp0 at pci0 dev 13 function 0: QLogic 1020 Fast Wide SCSI HBA
isp0: interrupting at irq 23
isp0: Ram Checksum Failure
ofb0 at pci0 dev 14 function 0: 3Dfx Interactive Voodoo3
ofb0: 640 x 480, 8bpp
wsdisplay0 at ofb0 kbdmux 1: console (std, vt100 emulation)
wsmux1: connecting to wsdisplay0
ppb0 at pci0 dev 15 function 0: Digital Equipment DECchip 21052 PCI-PCI Bridge (rev. 0x01)
pci1 at ppb0 bus 1
pci1: i/o space, memory space enabled
ohci0 at pci1 dev 0 function 0: CMD Technology USB0673 (rev. 0x05)
ohci0: interrupting at irq 25
ohci0: OHCI version 1.0, legacy support
usb0 at ohci0: USB revision 1.0
uhub0 at usb0
uhub0: CMD Technology OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
ne0 at pci1 dev 1 function 0: Realtek 8029 Ethernet
ne0: Ethernet address 00:00:e8:e6:a5:74
ne0: 10base2, 10baseT, 10baseT-FDX, auto, default [0x00 0x30] auto
ne0: interrupting at irq 25
yds0 at pci1 dev 2 function 0: Yamaha 724 Audio (rev. 0x05)
yds0: interrupting at irq 25
yds0: ac97: Asahi Kasei AK4540 codec; no 3D stereo
yds0: ac97: ext id 4d00<SECONDARY01,AC97_23,AC97_22,LDAC>
audio0 at yds0: full duplex, mmap, independent
Zoran Corporation product 0x6057 (video multimedia, revision 0x01) at pci1 dev 3 function 0 not configured
opl at yds0 not configured
opl at yds0 not configured
opl at yds0 not configured
opl at yds0 not configured
mpu at yds0 not configured
mpu at yds0 not configured
mpu at yds0 not configured
mpu at yds0 not configured
obio0 at pci0 dev 16 function 0: addr 0xf3000000
esp0 at obio0 offset 0x10000 irq 12: NCR53C94, 25MHz, SCSI ID 7
scsibus0 at esp0: 8 targets, 8 luns per target
mc0 at obio0 offset 0x11000: irq 14,2,3: address 00:a0:59:03:26:52
zsc0 at obio0 offset 0x13000: irq 15,16
zstty0 at zsc0 channel 0
zstty1 at zsc0 channel 1
awacs0 at obio0 offset 0x14000: irq 17,8,9
audio1 at awacs0: full duplex
swim3 at obio0 offset 0x15000 not configured
adb0 at obio0 offset 0x16000 irq 18: 1 targets
aed0 at adb0 addr 0: ADB Event device
akbd0 at adb0 addr 2: extended keyboard (ISO layout)
wskbd0 at akbd0: console keyboard, using wsdisplay0
mesh0 at obio0 offset 0x18000 irq 13: 50MHz, SCSI ID 7
scsibus1 at mesh0: 8 targets, 8 luns per target
nvram0 at obio0 offset 0x1d000
tlp0 at pci0 dev 17 function 0: DECchip 21140 Ethernet, pass 1.2
tlp0: broken MicroWire interface detected; setting SROM size to 1Kb
tlp0: interrupting at irq 23
tlp0: UMAX E100, Ethernet address 00:a0:59:03:b0:55
nsphy0 at tlp0 phy 1: DP83840 10/100 media interface, rev. 0
nsphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
scsibus0: waiting 2 seconds for devices to settle...
scsibus1: waiting 2 seconds for devices to settle...
uhidev0 at uhub0 port 2 configuration 1 interface 0
uhidev0: Sun Microsystems Type 6 USB keyboard, rev 1.00/1.02, addr 2, iclass 3/1
ukbd0 at uhidev0: 8 modifier keys, 6 key codes
wskbd1 at ukbd0 mux 1
wskbd1: connecting to wsdisplay0
sd0 at scsibus1 target 0 lun 0: <SEAGATE, ST34520N, 1281> disk fixed
sd0: drive offline
cd0 at scsibus1 target 3 lun 0: <PIONEER, CD-ROM DR-U03S, 1.01> cdrom removable
sd1 at scsibus1 target 5 lun 0: <IOMEGA, ZIP 100, J.03> disk removable
sd1: drive offline
boot device: sd0
root on sd0a dumps on sd0b
root file system type: ffs


--Apple-Mail-4--42625219
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name="patch"
Content-Disposition: attachment;
	filename=patch

Index: src/sys/arch/macppc/pci/pci_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/pci/pci_machdep.c,v
retrieving revision 1.25
diff --context -r1.25 pci_machdep.c
*** src/sys/arch/macppc/pci/pci_machdep.c	8 Apr 2004 23:58:24 -0000	1.25
--- src/sys/arch/macppc/pci/pci_machdep.c	15 Jul 2004 22:54:17 -0000
***************
*** 64,71 ****
--- 64,76 ----
  #include <dev/pci/pcivar.h>
  #include <dev/pci/pcireg.h>
  
+ #include <sys/malloc.h>
+ #include <sys/extent.h>
+ #include <dev/pci/pciconf.h>
+ 
  #include <dev/ofw/openfirm.h>
  #include <dev/ofw/ofw_pci.h>
+ #include "opt_pci.h"
  
  static void fixpci __P((int, pci_chipset_tag_t));
  static int find_node_intr __P((int, u_int32_t *, u_int32_t *));
***************
*** 101,106 ****
--- 106,126 ----
  	int node, nn, sz;
  	int32_t busrange[2];
  
+ #ifdef PCI_NETBSD_CONFIGURE
+ 	/* 
+ 	FIXME: the extent ranges are purely guesswork, someone should change them... 
+ 	*/
+ 	struct extent *ioext, *memext;
+ 	ioext  = extent_create("pciio",  0x00000000, 0x0fffffff, M_DEVBUF,
+                  NULL, 0, EX_NOWAIT);
+     memext = extent_create("pcimem", 0x80000000, 0xffffffff, M_DEVBUF,
+                  NULL, 0, EX_NOWAIT);
+ 	pci_configure_bus(pc, ioext, memext, NULL, 0,0);
+ 	extent_destroy(ioext);
+ 	extent_destroy(memext);
+ #endif
+ 
+ 
  	for (node = pc->node; node; node = nn) {
  		sz = OF_getprop(node, "bus-range", busrange, 8);
  		if (sz == 8 && busrange[0] == bus) {
***************
*** 267,273 ****
  
  	if (ih == 0 || ih >= ICU_LEN)
  		panic("pci_intr_establish: bogus handle 0x%x", ih);
- 
  	return intr_establish(ih, IST_LEVEL, level, func, arg);
  }
  
--- 287,292 ----
***************
*** 369,375 ****
--- 388,406 ----
  			intr &= ~PCI_INTERRUPT_LINE_MASK;
  			intr |= irqs[0] & PCI_INTERRUPT_LINE_MASK;
  			pci_conf_write(pc, tag, PCI_INTERRUPT_REG, intr);
+ 		} else
+ 		{
+ 		#ifdef DEBUG_PCI
+ 			printf("fixing interrupt...\n");
+ 		#endif
+ 			if(find_node_intr(node, &addr[0].phys_hi, irqs) == -1)
+ 				continue;
+ 			intr = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
+ 			intr &= ~PCI_INTERRUPT_LINE_MASK;
+ 			intr |= irqs[0] & PCI_INTERRUPT_LINE_MASK;
+ 			pci_conf_write(pc, tag, PCI_INTERRUPT_REG, intr);	
  		}
+ 			
  	}
  }
  
***************
*** 503,505 ****
--- 534,581 ----
  
  	return -1;
  }
+ 
+ int
+ pci_conf_hook(pci_chipset_tag_t pc, int bus, int dev, int func, pcireg_t id)
+ {
+ 	/* check if there's an E100 board in 0:11:0 */
+ 	pcitag_t tag=pci_make_tag(pc,bus,dev,func);
+ 	if(tag==0x80008800)
+ 	{
+ 		if(id==0x00091011)
+ 		{
+ 			pcireg_t mem, isp;
+ 			pcitag_t tag_isp=pci_make_tag(pc,0,0xd,0);
+ 			/* here we go. We shouldn't encounter this anywhere else than
+ 			   on a UMAX S900 with an E100 board */
+ 			/* look at 00:0d:00 for a 10201077 ( Qlogic ISP ) to make
+ 			   sure we really have an E100 here */
+ 			isp=pci_conf_read(pc,tag_isp,0);
+ 			if(isp==0x10201077)
+ 			{
+ 				pci_conf_write(pc,tag,0x14,0x80900000);
+ 				pci_conf_write(pc,tag,PCI_INTERRUPT_REG,0x00000117);
+ 				mem=pci_conf_read(pc,tag,PCI_COMMAND_STATUS_REG);
+ 				mem|=(PCI_COMMAND_IO_ENABLE|PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_MASTER_ENABLE);
+ 				pci_conf_write(pc,tag,PCI_COMMAND_STATUS_REG,mem);
+ 				return PCI_CONF_MAP_IO|PCI_CONF_MAP_MEM|PCI_CONF_ENABLE_IO|PCI_CONF_ENABLE_MEM|PCI_CONF_ENABLE_BM;
+ 			}
+ 		}
+ 	}
+ 	return 0;
+ }
+ 
+ void pci_conf_interrupt(pci_chipset_tag_t pc, int bus, int dev, int
+      func, int swiz, int *iline)
+ {
+ 	pcitag_t tag=pci_make_tag(pc,bus,dev,func);
+ 	pcireg_t id;
+ 	if(tag==0x80008800)
+ 	{
+ 		id=pci_conf_read(pc,tag,0);
+ 		if(id==0x00091011)
+ 		{
+ 			*iline=23;
+ 		}
+ 	}
+ }
Index: src/sys/dev/pci/if_tlp_pci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_tlp_pci.c,v
retrieving revision 1.76
diff --context -r1.76 if_tlp_pci.c
*** src/sys/dev/pci/if_tlp_pci.c	17 Mar 2004 13:54:09 -0000	1.76
--- src/sys/dev/pci/if_tlp_pci.c	15 Jul 2004 22:57:43 -0000
***************
*** 224,229 ****
--- 224,231 ----
  
  void	tlp_pci_asante_21140_quirks __P((struct tulip_pci_softc *,
  	    const u_int8_t *));
+ void	tlp_pci_e100_quirks __P((struct tulip_pci_softc *,
+ 	    const u_int8_t *));
  void	tlp_pci_smc_21140_quirks __P((struct tulip_pci_softc *,
  	    const u_int8_t *));
  void	tlp_pci_vpc_21140_quirks __P((struct tulip_pci_softc *,
***************
*** 232,237 ****
--- 234,240 ----
  const struct tlp_pci_quirks tlp_pci_21140_quirks[] = {
  	{ tlp_pci_dec_quirks,		{ 0x08, 0x00, 0x2b } },
  	{ tlp_pci_dec_quirks,		{ 0x00, 0x00, 0xf8 } },
+ 	{ tlp_pci_e100_quirks,		{ 0x00, 0xa0, 0x59 } },	// enable quirks for E100 Ethernet
  	{ tlp_pci_asante_21140_quirks,	{ 0x00, 0x00, 0x94 } },
  	{ tlp_pci_adaptec_quirks,	{ 0x00, 0x00, 0x92 } },
  	{ tlp_pci_adaptec_quirks,	{ 0x00, 0x00, 0xd1 } },
***************
*** 357,363 ****
  	const struct tulip_pci_product *tpp;
  	u_int8_t enaddr[ETHER_ADDR_LEN];
  	u_int32_t val = 0;
! 	pcireg_t reg;
  	int pmreg;
  
  	sc->sc_devno = pa->pa_device;
--- 360,366 ----
  	const struct tulip_pci_product *tpp;
  	u_int8_t enaddr[ETHER_ADDR_LEN];
  	u_int32_t val = 0;
! 	pcireg_t reg, addr, size;
  	int pmreg;
  
  	sc->sc_devno = pa->pa_device;
***************
*** 545,557 ****
  	/*
  	 * Map the device.
  	 */
  	ioh_valid = (pci_mapreg_map(pa, TULIP_PCI_IOBA,
  	    PCI_MAPREG_TYPE_IO, 0,
  	    &iot, &ioh, NULL, NULL) == 0);
  	memh_valid = (pci_mapreg_map(pa, TULIP_PCI_MMBA,
  	    PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT, 0,
! 	    &memt, &memh, NULL, NULL) == 0);
! 
  	if (memh_valid) {
  		sc->sc_st = memt;
  		sc->sc_sh = memh;
--- 548,560 ----
  	/*
  	 * Map the device.
  	 */
+ 	 	 
  	ioh_valid = (pci_mapreg_map(pa, TULIP_PCI_IOBA,
  	    PCI_MAPREG_TYPE_IO, 0,
  	    &iot, &ioh, NULL, NULL) == 0);
  	memh_valid = (pci_mapreg_map(pa, TULIP_PCI_MMBA,
  	    PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT, 0,
! 	    &memt, &memh, &addr, &size) == 0);
  	if (memh_valid) {
  		sc->sc_st = memt;
  		sc->sc_sh = memh;
***************
*** 1251,1256 ****
--- 1254,1275 ----
  	sc->sc_mediasw = &tlp_sio_mii_mediasw;
  }
  
+ void tlp_pci_e100_quirks(psc, enaddr)
+ 	struct tulip_pci_softc *psc;
+ 	const u_int8_t *enaddr;
+ {
+ 	struct tulip_softc *sc = &psc->sc_tulip;
+ 
+ 	if (sc->sc_mediasw == &tlp_2114x_isv_mediasw)
+ 		return;
+ 
+ 	strcpy(sc->sc_name, "UMAX E100");
+ 
+ 	sc->sc_gp_dir = 0xbf;
+ 	sc->sc_reset = tlp_pci_asante_21140_reset;
+ 	sc->sc_mediasw = &tlp_sio_mii_mediasw;
+ }
+ 
  void
  tlp_pci_asante_21140_reset(sc)
  	struct tulip_softc *sc;

--Apple-Mail-4--42625219--