Module Name:    src
Committed By:   rkujawa
Date:           Tue May 15 17:35:44 UTC 2012

Modified Files:
        src/sys/arch/amiga/clockport: clockportvar.h files.clockport
        src/sys/arch/amiga/conf: GENERIC.in files.amiga
        src/sys/arch/amiga/dev: if_ne_zbus.c
Added Files:
        src/sys/arch/amiga/clockport: gencp.c gencp_xsurf.c
        src/sys/arch/amiga/dev: if_ne_xsurf.c xsurf.c xsurfvar.h

Log Message:
- Split X-Surf driver from if_ne_zbus, rework, add support for clockports 
present on X-Surf boards.
- Add gencp(4), a driver for generic clockports (it just needs a base address).

Approved by phx.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/amiga/clockport/clockportvar.h \
    src/sys/arch/amiga/clockport/files.clockport
cvs rdiff -u -r0 -r1.1 src/sys/arch/amiga/clockport/gencp.c \
    src/sys/arch/amiga/clockport/gencp_xsurf.c
cvs rdiff -u -r1.98 -r1.99 src/sys/arch/amiga/conf/GENERIC.in
cvs rdiff -u -r1.155 -r1.156 src/sys/arch/amiga/conf/files.amiga
cvs rdiff -u -r0 -r1.1 src/sys/arch/amiga/dev/if_ne_xsurf.c \
    src/sys/arch/amiga/dev/xsurf.c src/sys/arch/amiga/dev/xsurfvar.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/amiga/dev/if_ne_zbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amiga/clockport/clockportvar.h
diff -u src/sys/arch/amiga/clockport/clockportvar.h:1.1 src/sys/arch/amiga/clockport/clockportvar.h:1.2
--- src/sys/arch/amiga/clockport/clockportvar.h:1.1	Tue Apr 17 09:59:03 2012
+++ src/sys/arch/amiga/clockport/clockportvar.h	Tue May 15 17:35:43 2012
@@ -1,4 +1,4 @@
-/*      $NetBSD: clockportvar.h,v 1.1 2012/04/17 09:59:03 rkujawa Exp $ */
+/*      $NetBSD: clockportvar.h,v 1.2 2012/05/15 17:35:43 rkujawa Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -31,10 +31,18 @@
 
 #include <sys/types.h>
 
+struct gencp_softc {
+	device_t	sc_dev;
+
+	struct clockportbus_attach_args *cpb_aa;
+};
+
 struct clockportbus_softc {
+
 	struct clockportbus_attach_args *cpb_aa;
 };
 
+/* Struct passed down to clockportbus. */
 struct clockportbus_attach_args {
 
 	bus_space_tag_t cp_iot;
@@ -42,6 +50,10 @@ struct clockportbus_attach_args {
 	void *(*cp_intr_establish)(int (*)(void *), void *);
 };
 
+/*
+ * Struct passed down to devices attached to clockportbus, currently
+ * has the same data as above. 
+ */
 struct clockport_attach_args {
 
 	bus_space_tag_t cp_iot;
@@ -51,3 +63,5 @@ struct clockport_attach_args {
 
 void *clockport_generic_intr_establish(int (*)(void *), void *);
 
+void gencp_attach(struct gencp_softc *gsc);
+
Index: src/sys/arch/amiga/clockport/files.clockport
diff -u src/sys/arch/amiga/clockport/files.clockport:1.1 src/sys/arch/amiga/clockport/files.clockport:1.2
--- src/sys/arch/amiga/clockport/files.clockport:1.1	Tue Apr 17 09:59:03 2012
+++ src/sys/arch/amiga/clockport/files.clockport	Tue May 15 17:35:43 2012
@@ -1,26 +1,41 @@
-#	$NetBSD: files.clockport,v 1.1 2012/04/17 09:59:03 rkujawa Exp $
+#	$NetBSD: files.clockport,v 1.2 2012/05/15 17:35:43 rkujawa Exp $
 
 define	clockportbus {}
 
-define	clockport_common
-file	arch/amiga/clockport/clockport_common.c clockport_generic
+define	clockport_common {}
+file	arch/amiga/clockport/clockport_common.c clockport_common
+
+# Generic clockport (can be attached on top of Zorro boards)
+device	gencp: clockportbus, clockport_common
+file	arch/amiga/clockport/gencp.c		gencp needs-flag
 
 # A1200 clockport
 device	a1k2cp: clockportbus, clockport_common
 attach	a1k2cp at mainbus
 file	arch/amiga/clockport/a1k2cp.c		a1k2cp
 
+# X-Surf clockports
+attach	gencp at xsurfbus with gencp_xsurf
+file	arch/amiga/clockport/gencp_xsurf.c	gencp_xsurf needs-flag
+
+# more zbus clockports should be added, like:
+# Highway clockport
+# attach gencp at highwaybus with gencp_highway
+# file	arch/amiga/clockport/gencp_highway.c
+# 
+# also for clockports like the second one on A604:
+# device obio at mainbus {[address = -1]}
+# attach gencp at obio  with gencp_obio
+# file	arch/amiga/clockport/gencp_obio.c
+#
+# etc.
+
 device	clockport {}
 attach	clockport at clockportbus
 file	arch/amiga/clockport/clockport.c	clockport
 
 # Individual Computers SilverSurfer serial
-#device	com
 attach	com at clockport with com_ss
 file	arch/amiga/clockport/com_ss.c
 
-# TODO: We should support for generic clockports, like:
-# device obio at mainbus {[address = -1]}
-# device gencp
-# attach gencp at obio 
 

Index: src/sys/arch/amiga/conf/GENERIC.in
diff -u src/sys/arch/amiga/conf/GENERIC.in:1.98 src/sys/arch/amiga/conf/GENERIC.in:1.99
--- src/sys/arch/amiga/conf/GENERIC.in:1.98	Tue Apr 17 09:59:03 2012
+++ src/sys/arch/amiga/conf/GENERIC.in	Tue May 15 17:35:44 2012
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC.in,v 1.98 2012/04/17 09:59:03 rkujawa Exp $
+# $NetBSD: GENERIC.in,v 1.99 2012/05/15 17:35:44 rkujawa Exp $
 #
 ##
 # GENERIC machine description file
@@ -52,7 +52,7 @@ include "arch/amiga/conf/std.amiga"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.98 $"
+#ident 		"GENERIC-$Revision: 1.99 $"
 
 m4_ifdef(`INSTALL_CONFIGURATION', `m4_dnl
 makeoptions	COPTS="-Os"
@@ -416,8 +416,8 @@ m4_ifdef(`INSTALL_CONFIGURATION', `', `m
 aucc*		at mainbus0		# Amiga CC audio
 audio*		at aucc?
 
-#a1k2cp0         at mainbus0             # A1200 on-board clockport
-#clockport*      at a1k2cp0
+a1k2cp0         at mainbus0             # A1200 on-board clockport
+clockport*      at a1k2cp0
 
 #com*            at clockport?           # Individual Computers SilverSurfer
 ')m4_dnl
@@ -456,11 +456,16 @@ audio*		at toccata?
 
 # Ethernet cards:
 le*		at zbus0		# A2065, Ameristar, Ariadne
-ne*		at zbus0		# AriadneII, X-surf
+ne*		at zbus0		# AriadneII
 ed*		at zbus0		# Hydra, ASDG LanRover
 es*		at zbus0		# CEI A4066 EthernetPLUS
 qn*		at zbus0		# Quicknet
 
+xsurf*		at zbus0		# X-Surf
+ne*		at xsurfbus?		# NE2000 chip on X-Surf
+gencp*		at xsurfbus?		# clockports on X-Surf
+clockport*	at gencp?
+
 # Arcnet
 bah*		at zbus0		# C=/Ameristar A2060 / 560
 

Index: src/sys/arch/amiga/conf/files.amiga
diff -u src/sys/arch/amiga/conf/files.amiga:1.155 src/sys/arch/amiga/conf/files.amiga:1.156
--- src/sys/arch/amiga/conf/files.amiga:1.155	Tue Apr 17 09:59:03 2012
+++ src/sys/arch/amiga/conf/files.amiga	Tue May 15 17:35:44 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: files.amiga,v 1.155 2012/04/17 09:59:03 rkujawa Exp $
+#	$NetBSD: files.amiga,v 1.156 2012/05/15 17:35:44 rkujawa Exp $
 
 # maxpartitions must be first item in files.${ARCH}.newconf
 maxpartitions 16			# NOTE THAT AMIGA IS SPECIAL!
@@ -220,6 +220,16 @@ file	arch/amiga/dev/if_le.c		le_zbus nee
 attach	ne at zbus with ne_zbus: rtl80x9
 file	arch/amiga/dev/if_ne_zbus.c	ne_zbus needs-flag
 
+# X-Surf
+define	xsurfbus {}
+
+device	xsurf: xsurfbus 
+attach	xsurf at zbus
+file	arch/amiga/dev/xsurf.c		xsurf needs-flag
+
+attach	ne at xsurfbus with ne_xsurf: rtl80x9
+file	arch/amiga/dev/if_ne_xsurf.c	ne_xsurf needs-flag
+
 # Hydra ethernet card
 device	ed: ifnet, ether, arp
 attach	ed at zbus with ed_zbus
@@ -530,4 +540,3 @@ include	"dev/pci/files.pci"
 include "arch/amiga/clockport/files.clockport"
 
 include	"arch/amiga/conf/majors.amiga"
-

Index: src/sys/arch/amiga/dev/if_ne_zbus.c
diff -u src/sys/arch/amiga/dev/if_ne_zbus.c:1.15 src/sys/arch/amiga/dev/if_ne_zbus.c:1.16
--- src/sys/arch/amiga/dev/if_ne_zbus.c:1.15	Mon Apr  9 19:55:00 2012
+++ src/sys/arch/amiga/dev/if_ne_zbus.c	Tue May 15 17:35:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ne_zbus.c,v 1.15 2012/04/09 19:55:00 rkujawa Exp $ */
+/*	$NetBSD: if_ne_zbus.c,v 1.16 2012/05/15 17:35:44 rkujawa Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ne_zbus.c,v 1.15 2012/04/09 19:55:00 rkujawa Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ne_zbus.c,v 1.16 2012/05/15 17:35:44 rkujawa Exp $");
 
 /*
  * Thanks to Village Tronic for giving me a card.
@@ -86,13 +86,6 @@ CFATTACH_DECL_NEW(ne_zbus, sizeof(struct
 #define	NE_ARIADNE_II_ASICBASE	0x0310	/* 0x0620 */
 #define	NE_ARIADNE_II_ASICSIZE	0x10
 
-/*
- * E3B Deneb firmware v11 creates fake X-Surf autoconfig entry.
- * Do not attach ne driver to this fake card, otherwise kernel panic
- * may occur.
- */
-#define DENEB_XSURF_SERNO	0xC0FFEE01	/* Serial of the fake card */
-
 int
 ne_zbus_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -102,12 +95,6 @@ ne_zbus_match(device_t parent, cfdata_t 
 	if (zap->manid == 2167 && zap->prodid == 202)
 		return (1);
 
-	/* X-surf ethernet card */
-	if (zap->manid == 4626 && zap->prodid == 23) {
-		if (zap->serno != DENEB_XSURF_SERNO)
-			return (1);
-	}
-
 	return (0);
 }
 
@@ -133,8 +120,6 @@ ne_zbus_attach(device_t parent, device_t
 	dsc->sc_media_init = rtl80x9_media_init;
 
 	zsc->sc_bst.base = (u_long)zap->va + 0;
-	if (zap->manid == 4626)
-		 zsc->sc_bst.base += 0x8000;
 
 	zsc->sc_bst.absm = &amiga_bus_stride_2;
 

Added files:

Index: src/sys/arch/amiga/clockport/gencp.c
diff -u /dev/null src/sys/arch/amiga/clockport/gencp.c:1.1
--- /dev/null	Tue May 15 17:35:44 2012
+++ src/sys/arch/amiga/clockport/gencp.c	Tue May 15 17:35:43 2012
@@ -0,0 +1,61 @@
+/*      $NetBSD: gencp.c,v 1.1 2012/05/15 17:35:43 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Radoslaw Kujawa.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Totally generic clockport, not much to do here... */
+
+#include <sys/cdefs.h>
+
+#include <sys/systm.h>
+#include <sys/types.h>
+#include <sys/device.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kmem.h>
+
+#include <machine/cpu.h>
+
+#include <amiga/amiga/device.h>
+
+#include <amiga/dev/zbusvar.h>
+
+#include <amiga/clockport/clockportvar.h>
+
+void
+gencp_attach(struct gencp_softc *gsc)
+{
+	aprint_normal(": generic clockport pa 0x%x\n",
+	    (bus_addr_t) kvtop((void*) gsc->cpb_aa->cp_iot->base));
+
+	gsc->cpb_aa->cp_intr_establish = clockport_generic_intr_establish;
+
+	config_found(gsc->sc_dev, gsc->cpb_aa, 0);
+}
+
Index: src/sys/arch/amiga/clockport/gencp_xsurf.c
diff -u /dev/null src/sys/arch/amiga/clockport/gencp_xsurf.c:1.1
--- /dev/null	Tue May 15 17:35:44 2012
+++ src/sys/arch/amiga/clockport/gencp_xsurf.c	Tue May 15 17:35:43 2012
@@ -0,0 +1,99 @@
+/*      $NetBSD: gencp_xsurf.c,v 1.1 2012/05/15 17:35:43 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Radoslaw Kujawa.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Clockports on top of X-Surf. */
+
+#include <sys/cdefs.h>
+
+#include <sys/systm.h>
+#include <sys/types.h>
+#include <sys/device.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kmem.h>
+
+#include <machine/cpu.h>
+
+#include <amiga/amiga/device.h>
+
+#include <amiga/dev/zbusvar.h>
+#include <amiga/dev/xsurfvar.h>
+
+#include <amiga/clockport/clockportvar.h>
+
+static int	gencp_xsurf_match(struct device *pdp, struct cfdata *cfp, void *aux);
+static void	gencp_xsurf_attach(device_t parent, device_t self, void *aux);
+
+CFATTACH_DECL_NEW(gencp_xsurf, sizeof(struct gencp_softc),
+    gencp_xsurf_match, gencp_xsurf_attach, NULL, NULL);
+
+static int
+gencp_xsurf_match(struct device *pdp, struct cfdata *cfp, void *aux)
+{
+	struct xsurfbus_attach_args *xsb_aa;
+	static int attach_count = 0;
+
+	xsb_aa = (struct xsurfbus_attach_args *) aux;
+
+	if (strcmp(xsb_aa->xaa_name, "gencp_xsurf") != 0) 
+		return 0;
+
+	/* No X-Surf with more than 2 clockports exists. */
+	if (attach_count >= 2)
+		return 0;	
+
+	attach_count++;
+
+	return 1;
+}
+
+static void
+gencp_xsurf_attach(device_t parent, device_t self, void *aux)
+{
+	struct gencp_softc *sc;
+	struct bus_space_tag cpb_bst;
+	struct clockportbus_attach_args cpb_aa;
+	struct xsurfbus_attach_args *xsb_aa;
+
+	xsb_aa = (struct xsurfbus_attach_args *) aux;
+	sc = device_private(self);
+	sc->sc_dev = self;
+	sc->cpb_aa = &cpb_aa;
+
+	/* Set the address and bus access methods. */
+	cpb_bst.base = xsb_aa->xaa_base;
+	cpb_bst.absm = &amiga_bus_stride_4;
+
+	sc->cpb_aa->cp_iot = &cpb_bst;
+
+	gencp_attach(sc);
+}
+

Index: src/sys/arch/amiga/dev/if_ne_xsurf.c
diff -u /dev/null src/sys/arch/amiga/dev/if_ne_xsurf.c:1.1
--- /dev/null	Tue May 15 17:35:44 2012
+++ src/sys/arch/amiga/dev/if_ne_xsurf.c	Tue May 15 17:35:44 2012
@@ -0,0 +1,175 @@
+/*	$NetBSD: if_ne_xsurf.c,v 1.1 2012/05/15 17:35:44 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Bernd Ernesti.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+/*
+ * X-Surf driver, ne(4) attachment. 
+ */
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/socket.h>
+#include <sys/syslog.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+
+#include <net/if.h>
+#include <net/if_media.h>
+#include <net/if_ether.h>
+
+#include <dev/ic/dp8390reg.h>
+#include <dev/ic/dp8390var.h>
+
+#include <dev/ic/ne2000reg.h>
+#include <dev/ic/ne2000var.h>
+
+#include <dev/ic/rtl80x9reg.h>
+#include <dev/ic/rtl80x9var.h>
+
+#include <amiga/amiga/device.h>
+#include <amiga/amiga/isr.h>
+
+#include <amiga/dev/xsurfvar.h>
+#include <amiga/dev/zbusvar.h>
+
+int	ne_xsurf_match(device_t, cfdata_t , void *);
+void	ne_xsurf_attach(device_t, device_t, void *);
+
+struct ne_xsurf_softc {
+	struct ne2000_softc	sc_ne2000;
+	struct bus_space_tag	sc_bst;
+	struct isr		sc_isr;
+};
+
+CFATTACH_DECL_NEW(ne_xsurf, sizeof(struct ne_xsurf_softc),
+    ne_xsurf_match, ne_xsurf_attach, NULL, NULL);
+
+/*
+ * The Amiga address are shifted by one bit to the ISA-Bus, but
+ * this is handled by the bus_space functions.
+ */
+#define	NE_XSURF_NPORTS		0x20
+#define	NE_XSURF_NICBASE	0x0300	/* 0x0600 */
+#define	NE_XSURF_NICSIZE	0x10
+#define	NE_XSURF_ASICBASE	0x0310	/* 0x0620 */
+#define	NE_XSURF_ASICSIZE	0x10
+
+#define XSURF_NE_OFFSET		0x8000
+
+/*
+ * Clockport offsets.
+ */
+#define XSURF_CP1_BASE		0xA001
+#define XSURF_CP2_BASE		0xC000
+
+/*
+ * E3B Deneb firmware v11 creates fake X-Surf autoconfig entry.
+ * Do not attach ne driver to this fake card, otherwise kernel panic
+ * may occur.
+ */
+#define DENEB_XSURF_SERNO	0xC0FFEE01	/* Serial of the fake card */
+
+int
+ne_xsurf_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct xsurfbus_attach_args *xap = aux;
+
+	if (strcmp(xap->xaa_name, "ne_xsurf") != 0)
+		return 0;
+
+	return 1;
+}
+
+/*
+ * Install interface into kernel networking data structures.
+ */
+void
+ne_xsurf_attach(device_t parent, device_t self, void *aux)
+{
+	struct ne_xsurf_softc *zsc = device_private(self);
+	struct ne2000_softc *nsc = &zsc->sc_ne2000;
+	struct dp8390_softc *dsc = &nsc->sc_dp8390;
+
+	struct xsurfbus_attach_args *xap = aux;
+
+	bus_space_tag_t nict = &zsc->sc_bst;
+	bus_space_handle_t nich;
+	bus_space_tag_t asict = nict;
+	bus_space_handle_t asich;
+
+	dsc->sc_dev = self;
+	dsc->sc_mediachange = rtl80x9_mediachange;
+	dsc->sc_mediastatus = rtl80x9_mediastatus;
+	dsc->init_card = rtl80x9_init_card;
+	dsc->sc_media_init = rtl80x9_media_init;
+
+	zsc->sc_bst.base = xap->xaa_base;
+
+	zsc->sc_bst.absm = &amiga_bus_stride_2;
+
+	aprint_normal("\n");
+
+	/* Map i/o space. */
+	if (bus_space_map(nict, NE_XSURF_NICBASE, 
+	    NE_XSURF_NPORTS, 0, &nich)) {
+		aprint_error_dev(self, "can't map nic i/o space\n");
+		return;
+	}
+
+	if (bus_space_subregion(nict, nich, NE2000_ASIC_OFFSET, 
+	    NE_XSURF_ASICSIZE, &asich)) {
+		aprint_error_dev(self, "can't map asic i/o space\n");
+		return;
+	}
+
+	dsc->sc_regt = nict;
+	dsc->sc_regh = nich;
+
+	nsc->sc_asict = asict;
+	nsc->sc_asich = asich;
+
+	/* This interface is always enabled. */
+	dsc->sc_enabled = 1;
+
+	/*
+	 * Do generic NE2000 attach.  This will read the station address
+	 * from the EEPROM.
+	 */
+	ne2000_attach(nsc, NULL);
+
+	zsc->sc_isr.isr_intr = dp8390_intr;
+	zsc->sc_isr.isr_arg = dsc;
+	zsc->sc_isr.isr_ipl = 2;
+	add_isr(&zsc->sc_isr);
+}
Index: src/sys/arch/amiga/dev/xsurf.c
diff -u /dev/null src/sys/arch/amiga/dev/xsurf.c:1.1
--- /dev/null	Tue May 15 17:35:44 2012
+++ src/sys/arch/amiga/dev/xsurf.c	Tue May 15 17:35:44 2012
@@ -0,0 +1,156 @@
+/*	$NetBSD: xsurf.c,v 1.1 2012/05/15 17:35:44 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Bernd Ernesti.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: xsurf.c,v 1.1 2012/05/15 17:35:44 rkujawa Exp $");
+
+/*
+ * X-Surf driver, split from ne_zbus. 
+ */
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/socket.h>
+#include <sys/syslog.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+
+#include <net/if.h>
+#include <net/if_media.h>
+#include <net/if_ether.h>
+
+#include <dev/ic/dp8390reg.h>
+#include <dev/ic/dp8390var.h>
+
+#include <dev/ic/ne2000reg.h>
+#include <dev/ic/ne2000var.h>
+
+#include <dev/ic/rtl80x9reg.h>
+#include <dev/ic/rtl80x9var.h>
+
+#include <amiga/amiga/device.h>
+#include <amiga/amiga/isr.h>
+
+#include <amiga/dev/zbusvar.h>
+#include <amiga/dev/xsurfvar.h>
+
+//#include <amiga/clockport/clockportvar.h>
+
+int	xsurf_match(device_t, cfdata_t , void *);
+void	xsurf_attach(device_t, device_t, void *);
+static int xsurf_print(void *aux, const char *w);
+
+struct xsurf_softc {
+	device_t sc_dev;	
+};
+
+CFATTACH_DECL_NEW(xsurf, sizeof(struct xsurf_softc),
+    xsurf_match, xsurf_attach, NULL, NULL);
+
+#define XSURF_NE_OFFSET		0x8000
+
+/*
+ * Clockport offsets.
+ */
+#define XSURF_CP1_BASE		0xA001
+#define XSURF_CP2_BASE		0xC000
+
+/*
+ * E3B Deneb firmware v11 creates fake X-Surf autoconfig entry.
+ * Do not attach ne driver to this fake card, otherwise kernel panic
+ * may occur.
+ */
+#define DENEB_XSURF_SERNO	0xC0FFEE01	/* Serial of the fake card */
+
+int
+xsurf_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct zbus_args *zap = aux;
+
+	/* X-surf ethernet card */
+	if (zap->manid == 4626 && zap->prodid == 23) {
+			return (1);
+	}
+
+	return (0);
+}
+
+/*
+ * Install interface into kernel networking data structures.
+ */
+void
+xsurf_attach(device_t parent, device_t self, void *aux)
+{
+	struct xsurf_softc *sc;
+	struct xsurfbus_attach_args xaa_ne;
+	struct xsurfbus_attach_args xaa_gencp1;
+	struct xsurfbus_attach_args xaa_gencp2;
+
+	struct zbus_args *zap = aux;
+
+	sc = device_private(self);
+	sc->sc_dev = self;
+
+	aprint_normal(": Individual Computers X-Surf\n");
+
+	/* Add clockport. */
+	xaa_gencp1.xaa_base = (bus_addr_t)zap->va + XSURF_CP1_BASE;
+	strcpy(xaa_gencp1.xaa_name, "gencp_xsurf");
+	config_found_ia(sc->sc_dev, "xsurfbus", &xaa_gencp1, xsurf_print);
+
+	/* Now... if we are a fake X-Surf that's enough. */
+	if (zap->serno == DENEB_XSURF_SERNO) {
+		aprint_naive_dev(sc->sc_dev, "fake X-Surf on E3B Deneb");
+		return;
+	}
+
+	/* Otherwise add one more clockport and continue... */
+	xaa_gencp2.xaa_base = (bus_addr_t)zap->va + XSURF_CP2_BASE;
+	strcpy(xaa_gencp2.xaa_name, "gencp_xsurf");
+	config_found_ia(sc->sc_dev, "xsurfbus", &xaa_gencp2, xsurf_print);
+		
+	/* Add ne(4). */
+	xaa_ne.xaa_base = (bus_addr_t)zap->va + XSURF_NE_OFFSET;
+	strcpy(xaa_ne.xaa_name, "ne_xsurf");
+	config_found_ia(sc->sc_dev, "xsurfbus", &xaa_ne, xsurf_print);
+}
+
+static int
+xsurf_print(void *aux, const char *w)
+{
+	if (w == NULL)
+		return 0;
+
+	return 0;
+}
+
Index: src/sys/arch/amiga/dev/xsurfvar.h
diff -u /dev/null src/sys/arch/amiga/dev/xsurfvar.h:1.1
--- /dev/null	Tue May 15 17:35:44 2012
+++ src/sys/arch/amiga/dev/xsurfvar.h	Tue May 15 17:35:44 2012
@@ -0,0 +1,44 @@
+/*	$NetBSD: xsurfvar.h,v 1.1 2012/05/15 17:35:44 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Radoslaw Kujawa.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _AMIGA_XSURFVAR_H_
+
+#include <sys/bus.h>
+
+struct xsurfbus_attach_args {
+
+	char		xaa_name[32];	
+	bus_addr_t	xaa_base;
+
+};
+
+#endif /* _AMIGA_XSURFVAR_H_ */
+

Reply via email to