Module Name:    src
Committed By:   thorpej
Date:           Sat Mar  2 19:57:58 UTC 2024

Modified Files:
        src/sys/arch/alpha/conf: files.alpha
Added Files:
        src/sys/arch/alpha/gbus: gbus.c gbusreg.h gbusvar.h mcclock_gbus.c
Removed Files:
        src/sys/arch/alpha/tlsb: gbus.c gbusreg.h gbusvar.h mcclock_tlsb.c

Log Message:
Shuffle GBus-related files into their own directory in preparation for
other GBus attachments.  No functional change here; just minimal editing
to reflect path differences after moving the files.


To generate a diff of this commit:
cvs rdiff -u -r1.194 -r1.195 src/sys/arch/alpha/conf/files.alpha
cvs rdiff -u -r0 -r1.1 src/sys/arch/alpha/gbus/gbus.c \
    src/sys/arch/alpha/gbus/gbusreg.h src/sys/arch/alpha/gbus/gbusvar.h \
    src/sys/arch/alpha/gbus/mcclock_gbus.c
cvs rdiff -u -r1.25 -r0 src/sys/arch/alpha/tlsb/gbus.c
cvs rdiff -u -r1.2 -r0 src/sys/arch/alpha/tlsb/gbusreg.h
cvs rdiff -u -r1.3 -r0 src/sys/arch/alpha/tlsb/gbusvar.h
cvs rdiff -u -r1.18 -r0 src/sys/arch/alpha/tlsb/mcclock_tlsb.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/alpha/conf/files.alpha
diff -u src/sys/arch/alpha/conf/files.alpha:1.194 src/sys/arch/alpha/conf/files.alpha:1.195
--- src/sys/arch/alpha/conf/files.alpha:1.194	Wed Oct 21 13:31:50 2020
+++ src/sys/arch/alpha/conf/files.alpha	Sat Mar  2 19:57:57 2024
@@ -1,4 +1,4 @@
-# $NetBSD: files.alpha,v 1.194 2020/10/21 13:31:50 christos Exp $
+# $NetBSD: files.alpha,v 1.195 2024/03/02 19:57:57 thorpej Exp $
 #
 # alpha-specific configuration info
 
@@ -96,9 +96,13 @@ device	tlsbmem
 attach	tlsbmem at tlsb
 file	arch/alpha/tlsb/tlsbmem.c	tlsbmem
 
+#
+# GBus support
+#
+
 device	gbus { offset = -1 }
 attach	gbus at tlsb
-file	arch/alpha/tlsb/gbus.c		gbus
+file	arch/alpha/gbus/gbus.c		gbus
 
 #
 # MCBUS support
@@ -316,7 +320,6 @@ attach	fdc at sableio with fdc_sableio
 file	arch/alpha/sableio/fdc_sableio.c	fdc_sableio
 
 # CPU support files
-file	arch/alpha/alpha/dec_2000_300.c	dec_2000_300
 file	arch/alpha/pci/pci_2100_a50.c	dec_2100_a50
 file	arch/alpha/pci/pci_2100_a500.c	dec_2100_a500 | dec_2100a_a500
 file	arch/alpha/pci/pci_up1000.c	api_up1000
@@ -358,12 +361,12 @@ file	arch/alpha/pci/sio_pic.c	sio | pceb
 device	mcclock: mc146818
 attach	mcclock at ioasic with mcclock_ioasic
 attach	mcclock at isa with mcclock_isa
-attach	mcclock at gbus with mcclock_tlsb
+attach	mcclock at gbus with mcclock_gbus
 attach	mcclock at jensenio with mcclock_jensenio
 file	arch/alpha/alpha/mcclock.c	mcclock
 file	arch/alpha/tc/mcclock_ioasic.c	mcclock_ioasic
 file	arch/alpha/isa/mcclock_isa.c	mcclock_isa
-file	arch/alpha/tlsb/mcclock_tlsb.c	mcclock_tlsb
+file	arch/alpha/gbus/mcclock_gbus.c	mcclock_gbus
 file	arch/alpha/jensenio/mcclock_jensenio.c	mcclock_jensenio
 
 
@@ -401,6 +404,7 @@ file	dev/bus_dma/bus_dmamem_common.c
 file	arch/alpha/alpha/promcons.c
 
 # CPU support
+file	arch/alpha/alpha/dec_2000_300.c		dec_2000_300
 file	arch/alpha/alpha/dec_2100_a50.c		dec_2100_a50
 file	arch/alpha/alpha/dec_2100_a500.c	dec_2100_a500 | dec_2100a_a500
 file	arch/alpha/alpha/dec_3000_300.c		dec_3000_300

Added files:

Index: src/sys/arch/alpha/gbus/gbus.c
diff -u /dev/null src/sys/arch/alpha/gbus/gbus.c:1.1
--- /dev/null	Sat Mar  2 19:57:58 2024
+++ src/sys/arch/alpha/gbus/gbus.c	Sat Mar  2 19:57:57 2024
@@ -0,0 +1,131 @@
+/* $NetBSD: gbus.c,v 1.1 2024/03/02 19:57:57 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1997 by Matthew Jacob
+ * NASA AMES Research Center.
+ * All rights reserved.
+ *
+ * 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 immediately at the beginning of the file, without modification,
+ *    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.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+/*
+ * Autoconfiguration and support routines for the Gbus: the internal
+ * bus on AlphaServer CPU modules.
+ */
+
+#include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
+
+__KERNEL_RCSID(0, "$NetBSD: gbus.c,v 1.1 2024/03/02 19:57:57 thorpej Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <machine/rpb.h>
+#include <machine/pte.h>
+
+#include <alpha/gbus/gbusreg.h>
+#include <alpha/gbus/gbusvar.h>
+
+#include <alpha/tlsb/tlsbreg.h>
+#include <alpha/tlsb/tlsbvar.h>
+
+#include "locators.h"
+
+#define KV(_addr)	((void *)ALPHA_PHYS_TO_K0SEG((_addr)))
+
+struct gbus_softc {
+	device_t	sc_dev;
+	int		sc_tlsbnode;	/* node on the TurboLaser */
+};
+
+static int	gbusmatch(device_t, cfdata_t, void *);
+static void	gbusattach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(gbus, sizeof(struct gbus_softc),
+    gbusmatch, gbusattach, NULL, NULL);
+
+static int	gbusprint(void *, const char *);
+
+static const struct gbus_attach_args gbus_children[] = {
+	{ "zsc",	GBUS_DUART0_OFFSET },
+	{ "zsc",	GBUS_DUART1_OFFSET },
+	{ "mcclock",	GBUS_CLOCK_OFFSET },
+	{ NULL,		0 },
+};
+
+static int
+gbusprint(void *aux, const char *pnp)
+{
+	struct gbus_attach_args *ga = aux;
+
+	if (pnp)
+		aprint_normal("%s at %s", ga->ga_name, pnp);
+	aprint_normal(" offset 0x%lx", ga->ga_offset);
+	return (UNCONF);
+}
+
+static int
+gbusmatch(device_t parent, cfdata_t cf, void *aux)
+{
+	struct tlsb_dev_attach_args *ta = aux;
+
+	/*
+	 * Make sure we're looking for a Gbus.  The Gbus only
+	 * "exists" on the CPU module that holds the primary CPU.
+	 *
+	 * Compute which node this should exist on by dividing the
+	 * primary CPU by 2 (since there are up to 2 CPUs per CPU
+	 * module).
+	 */
+	if (TLDEV_ISCPU(ta->ta_dtype) &&
+	    ta->ta_node == (hwrpb->rpb_primary_cpu_id / 2))
+		return (1);
+
+	return (0);
+}
+
+static void
+gbusattach(device_t parent, device_t self, void *aux)
+{
+	struct gbus_softc *sc = device_private(self);
+	struct tlsb_dev_attach_args *ta = aux;
+	const struct gbus_attach_args *ga;
+	int locs[GBUSCF_NLOCS];
+
+	aprint_normal("\n");
+
+	sc->sc_dev = self;
+	sc->sc_tlsbnode = ta->ta_node;
+
+	/* Attach the children. */
+	for (ga = gbus_children; ga->ga_name != NULL; ga++) {
+		struct gbus_attach_args gaa = *ga;
+		locs[GBUSCF_OFFSET] = gaa.ga_offset;
+		config_found(self, &gaa, gbusprint,
+		    CFARGS(.submatch = config_stdsubmatch,
+			   .locators = locs));
+	}
+}
Index: src/sys/arch/alpha/gbus/gbusreg.h
diff -u /dev/null src/sys/arch/alpha/gbus/gbusreg.h:1.1
--- /dev/null	Sat Mar  2 19:57:58 2024
+++ src/sys/arch/alpha/gbus/gbusreg.h	Sat Mar  2 19:57:57 2024
@@ -0,0 +1,39 @@
+/* $NetBSD: gbusreg.h,v 1.1 2024/03/02 19:57:57 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * 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.
+ */
+
+/*
+ * Register definitions for the Gbus found on TurboLaser CPU modules.
+ */
+
+#define GBUS_DUART0_OFFSET	0x10000000		/* duart 0 */
+#define GBUS_DUART1_OFFSET	0x11000000		/* duart 1 */
+#define GBUS_CLOCK_OFFSET	0x20000000		/* clock */
Index: src/sys/arch/alpha/gbus/gbusvar.h
diff -u /dev/null src/sys/arch/alpha/gbus/gbusvar.h:1.1
--- /dev/null	Sat Mar  2 19:57:58 2024
+++ src/sys/arch/alpha/gbus/gbusvar.h	Sat Mar  2 19:57:57 2024
@@ -0,0 +1,42 @@
+/* $NetBSD: gbusvar.h,v 1.1 2024/03/02 19:57:57 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * 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.
+ */
+
+/*
+ * Autoconfiguration definitions for the Gbus found on TurboLaser CPU modules.
+ */
+
+#include <sys/bus.h>
+
+struct gbus_attach_args {
+	const char *ga_name;		/* name of device */
+	bus_addr_t  ga_offset;		/* offset from Gbus base */
+};
Index: src/sys/arch/alpha/gbus/mcclock_gbus.c
diff -u /dev/null src/sys/arch/alpha/gbus/mcclock_gbus.c:1.1
--- /dev/null	Sat Mar  2 19:57:58 2024
+++ src/sys/arch/alpha/gbus/mcclock_gbus.c	Sat Mar  2 19:57:57 2024
@@ -0,0 +1,123 @@
+/* $NetBSD: mcclock_gbus.c,v 1.1 2024/03/02 19:57:57 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1997 by Matthew Jacob
+ * NASA AMES Research Center.
+ * All rights reserved.
+ *
+ * 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 immediately at the beginning of the file, without modification,
+ *    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.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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>			/* RCS ID & Copyright macro defns */
+
+__KERNEL_RCSID(0, "$NetBSD: mcclock_gbus.c,v 1.1 2024/03/02 19:57:57 thorpej Exp $");
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <sys/bus.h>
+
+#include <alpha/gbus/gbusvar.h>
+
+#include <alpha/tlsb/tlsbreg.h>		/* XXX */
+
+#include <dev/clock_subr.h>
+
+#include <dev/ic/mc146818reg.h>
+#include <dev/ic/mc146818var.h>
+
+#include <alpha/alpha/mcclockvar.h>
+
+#include "ioconf.h"
+
+#define	KV(_addr)	((void *)ALPHA_PHYS_TO_K0SEG((_addr)))
+/*
+ * Registers are 64 bytes apart (and 1 byte wide)
+ */
+#define	REGSHIFT	6
+
+struct mcclock_tlsb_softc {
+	struct mc146818_softc	sc_mc146818;
+	unsigned long regbase;
+};
+
+static int	mcclock_tlsb_match(device_t, cfdata_t, void *);
+static void	mcclock_tlsb_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(mcclock_gbus, sizeof(struct mcclock_tlsb_softc),
+    mcclock_tlsb_match, mcclock_tlsb_attach, NULL, NULL);
+
+static void	mcclock_tlsb_write(struct mc146818_softc *, u_int, u_int);
+static u_int	mcclock_tlsb_read(struct mc146818_softc *, u_int);
+
+
+static int
+mcclock_tlsb_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct gbus_attach_args *ga = aux;
+
+	if (strcmp(ga->ga_name, mcclock_cd.cd_name))
+		return (0);
+	return (1);
+}
+
+static void
+mcclock_tlsb_attach(device_t parent, device_t self, void *aux)
+{
+	struct mcclock_tlsb_softc *tsc = device_private(self);
+	struct gbus_attach_args *ga = aux;
+	struct mc146818_softc *sc = &tsc->sc_mc146818;
+
+	/* XXX Should be bus.h'd, so we can accommodate the kn7aa. */
+	tsc->regbase = TLSB_GBUS_BASE + ga->ga_offset;
+
+	sc->sc_dev = self;
+	sc->sc_mcread  = mcclock_tlsb_read;
+	sc->sc_mcwrite = mcclock_tlsb_write;
+
+	mcclock_attach(sc);
+}
+
+static void
+mcclock_tlsb_write(struct mc146818_softc *sc, u_int reg, u_int val)
+{
+	struct mcclock_tlsb_softc *tsc = (void *)sc;
+	unsigned char *ptr = (unsigned char *)
+		KV(tsc->regbase + (reg << REGSHIFT));
+
+	*ptr = val;
+}
+
+static u_int
+mcclock_tlsb_read(struct mc146818_softc *sc, u_int reg)
+{
+	struct mcclock_tlsb_softc *tsc = (void *)sc;
+	unsigned char *ptr = (unsigned char *)
+		KV(tsc->regbase + (reg << REGSHIFT));
+
+	return *ptr;
+}

Reply via email to