Module Name:    src
Committed By:   uebayasi
Date:           Sat Nov  6 16:30:16 UTC 2010

Modified Files:
        src/sys/arch/powerpc/conf: files.ibm4xx
        src/sys/arch/powerpc/ibm4xx/dev: plb.c
Added Files:
        src/sys/arch/powerpc/ibm4xx/dev: exb.c exbvar.h

Log Message:
Add IBM405GPr "External Bus" driver.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/powerpc/conf/files.ibm4xx
cvs rdiff -u -r0 -r1.2 src/sys/arch/powerpc/ibm4xx/dev/exb.c \
    src/sys/arch/powerpc/ibm4xx/dev/exbvar.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/powerpc/ibm4xx/dev/plb.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/powerpc/conf/files.ibm4xx
diff -u src/sys/arch/powerpc/conf/files.ibm4xx:1.11 src/sys/arch/powerpc/conf/files.ibm4xx:1.12
--- src/sys/arch/powerpc/conf/files.ibm4xx:1.11	Thu Mar 18 13:58:38 2010
+++ src/sys/arch/powerpc/conf/files.ibm4xx	Sat Nov  6 16:30:15 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ibm4xx,v 1.11 2010/03/18 13:58:38 kiyohara Exp $
+#	$NetBSD: files.ibm4xx,v 1.12 2010/11/06 16:30:15 uebayasi Exp $
 #
 # IBM 4xx specific configuration info
 
@@ -69,3 +69,8 @@
 device	gpiic: i2cbus, i2c_bitbang
 attach	gpiic at opb
 file	arch/powerpc/ibm4xx/dev/gpiic_opb.c	gpiic
+
+# External bus
+#device exb {[addr = -1]}
+#attach exb at plb
+#file	arch/powerpc/ibm4xx/dev/exb.c		exb

Index: src/sys/arch/powerpc/ibm4xx/dev/plb.c
diff -u src/sys/arch/powerpc/ibm4xx/dev/plb.c:1.15 src/sys/arch/powerpc/ibm4xx/dev/plb.c:1.16
--- src/sys/arch/powerpc/ibm4xx/dev/plb.c:1.15	Thu Mar 18 13:47:04 2010
+++ src/sys/arch/powerpc/ibm4xx/dev/plb.c	Sat Nov  6 16:30:15 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: plb.c,v 1.15 2010/03/18 13:47:04 kiyohara Exp $ */
+/* $NetBSD: plb.c,v 1.16 2010/11/06 16:30:15 uebayasi Exp $ */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: plb.c,v 1.15 2010/03/18 13:47:04 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plb.c,v 1.16 2010/11/06 16:30:15 uebayasi Exp $");
 
 #include "locators.h"
 #include "emac.h"
@@ -100,6 +100,7 @@
 	{ IBM405GPR,	"ecc", },
 	{ IBM405GPR,	"opb", },
 	{ IBM405GPR,	"pchb", },
+	{ IBM405GPR,    "exb", },
 
 	/* AMCC 405EX / EXR */
 	{ AMCC405EX,	"cpu", },

Added files:

Index: src/sys/arch/powerpc/ibm4xx/dev/exb.c
diff -u /dev/null src/sys/arch/powerpc/ibm4xx/dev/exb.c:1.2
--- /dev/null	Sat Nov  6 16:30:16 2010
+++ src/sys/arch/powerpc/ibm4xx/dev/exb.c	Sat Nov  6 16:30:15 2010
@@ -0,0 +1,138 @@
+/*	$Id: exb.c,v 1.2 2010/11/06 16:30:15 uebayasi Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation
+ * by Masao Uebayashi.
+ *
+ * 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: exb.c,v 1.2 2010/11/06 16:30:15 uebayasi Exp $");
+
+#include "locators.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/extent.h>
+#include <sys/bus.h>
+
+#include <powerpc/ibm4xx/dcr4xx.h>
+#include <powerpc/ibm4xx/dev/exbvar.h>
+
+struct exb_softc {
+};
+
+extern const struct exb_conf exb_confs[];
+
+static int exb_match(device_t, struct cfdata *, void *);
+static void exb_attach(device_t, struct device *, void *);
+static int exb_print(void *, const char *);
+
+CFATTACH_DECL_NEW(exb, sizeof(struct exb_softc), exb_match, exb_attach,
+    NULL, NULL);
+
+static struct powerpc_bus_space exb_bus_space_tag =
+    { _BUS_SPACE_BIG_ENDIAN | _BUS_SPACE_MEM_TYPE, 0 };
+
+static int
+exb_match(device_t parent, struct cfdata *cf, void *aux)
+{
+
+	return 1;
+}
+
+static void
+exb_attach(device_t parent, device_t self, void *aux)
+{
+	const struct exb_conf *ec = exb_confs;
+	uint32_t ebc0_bNcr;
+	bus_addr_t base, size;
+	int locs[EXBCF_NLOCS];
+
+	printf("\n");
+
+	/* mtdcr needs a constant */
+	switch (device_unit(self)) {
+	case 0: mtdcr(DCR_EBC0_CFGADDR, DCR_EBC0_B0CR);	break;
+	case 1: mtdcr(DCR_EBC0_CFGADDR, DCR_EBC0_B1CR);	break;
+	case 2: mtdcr(DCR_EBC0_CFGADDR, DCR_EBC0_B2CR);	break;
+	case 3: mtdcr(DCR_EBC0_CFGADDR, DCR_EBC0_B3CR);	break;
+	case 4: mtdcr(DCR_EBC0_CFGADDR, DCR_EBC0_B4CR);	break;
+	case 5: mtdcr(DCR_EBC0_CFGADDR, DCR_EBC0_B5CR);	break;
+	case 6: mtdcr(DCR_EBC0_CFGADDR, DCR_EBC0_B6CR);	break;
+	case 7: mtdcr(DCR_EBC0_CFGADDR, DCR_EBC0_B7CR);	break;
+	}
+	ebc0_bNcr = mfdcr(DCR_EBC0_CFGDATA);
+	base = ebc0_bNcr & 0xfff00000;
+	size = 0x00100000 << ((ebc0_bNcr & 0x000e0000) >> 17);
+
+	exb_bus_space_tag.pbs_base = base;
+	exb_bus_space_tag.pbs_limit = base + size - 1;
+
+	while (ec->ec_name) {
+		struct exb_conf ec1;
+
+		locs[EXBCF_ADDR] = ec->ec_addr;
+
+		ec1 = *ec;
+		ec1.ec_bust = exb_get_bus_space_tag();
+
+		config_found_sm_loc(self, "exb", locs, &ec1, exb_print,
+		    config_stdsubmatch);
+		ec++;
+	}
+}
+
+static int
+exb_print(void *aux, const char *bus)
+{
+	struct exb_conf *ec = aux;
+
+	if (bus)
+		return QUIET;
+
+	if (ec->ec_addr)
+		printf(" addr %"PRIxBUSADDR, ec->ec_addr);
+
+	return UNCONF;
+}
+
+bus_space_tag_t
+exb_get_bus_space_tag(void)
+{
+	static char ex_storage[EXTENT_FIXED_STORAGE_SIZE(8)]
+	    __attribute__((aligned(8)));
+	static int exb_bus_space_tag_inited;
+
+	if (exb_bus_space_tag_inited == 0) {
+		if (bus_space_init(&exb_bus_space_tag, "exbtag",
+		    ex_storage, sizeof(ex_storage)))
+			panic("exb_attach: Failed to initialise exb_bus_space_tag");
+		exb_bus_space_tag_inited = 1;
+	}
+	return &exb_bus_space_tag;
+}
Index: src/sys/arch/powerpc/ibm4xx/dev/exbvar.h
diff -u /dev/null src/sys/arch/powerpc/ibm4xx/dev/exbvar.h:1.2
--- /dev/null	Sat Nov  6 16:30:16 2010
+++ src/sys/arch/powerpc/ibm4xx/dev/exbvar.h	Sat Nov  6 16:30:15 2010
@@ -0,0 +1,46 @@
+/*	$Id: exbvar.h,v 1.2 2010/11/06 16:30:15 uebayasi Exp $	*/
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software developed for The NetBSD Foundation
+ * by Masao Uebayashi.
+ *
+ * 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 _POWERPC_IBM4XX_DEV_EXBVAR_H_
+#define _POWERPC_IBM4XX_DEV_EXBVAR_H_
+
+struct exb_conf {
+	const char *ec_name;
+
+	bus_addr_t ec_addr;
+	bus_size_t ec_size;
+
+	bus_space_tag_t ec_bust;
+};
+
+bus_space_tag_t exb_get_bus_space_tag(void);
+
+#endif	/* _POWERPC_IBM4XX_DEV_EXBVAR_H_ */

Reply via email to