Module Name:    src
Committed By:   hkenken
Date:           Wed Jun 20 08:03:55 UTC 2018

Modified Files:
        src/sys/arch/arm/cortex: pl310.c
        src/sys/arch/arm/fdt: files.fdt
Added Files:
        src/sys/arch/arm/fdt: l2cc_fdt.c

Log Message:
Add l2cc support.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/cortex/pl310.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/fdt/files.fdt
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/l2cc_fdt.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/arm/cortex/pl310.c
diff -u src/sys/arch/arm/cortex/pl310.c:1.17 src/sys/arch/arm/cortex/pl310.c:1.18
--- src/sys/arch/arm/cortex/pl310.c:1.17	Fri Feb 27 20:40:09 2015
+++ src/sys/arch/arm/cortex/pl310.c	Wed Jun 20 08:03:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pl310.c,v 1.17 2015/02/27 20:40:09 jmcneill Exp $	*/
+/*	$NetBSD: pl310.c,v 1.18 2018/06/20 08:03:55 hkenken Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pl310.c,v 1.17 2015/02/27 20:40:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pl310.c,v 1.18 2018/06/20 08:03:55 hkenken Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -47,7 +47,6 @@ __KERNEL_RCSID(0, "$NetBSD: pl310.c,v 1.
 static int arml2cc_match(device_t, cfdata_t, void *);
 static void arml2cc_attach(device_t, device_t, void *);
 
-#define	L2CC_BASE	0x2000
 #define	L2CC_SIZE	0x1000
 
 struct arml2cc_softc {
@@ -150,7 +149,7 @@ arml2cc_attach(device_t parent, device_t
 			aprint_normal(": not configured\n");
 			return;
 		}
-		off = L2CC_BASE;
+		off = mpcaa->mpcaa_off1;
 	}
 
 	arml2cc_sc = sc;

Index: src/sys/arch/arm/fdt/files.fdt
diff -u src/sys/arch/arm/fdt/files.fdt:1.16 src/sys/arch/arm/fdt/files.fdt:1.17
--- src/sys/arch/arm/fdt/files.fdt:1.16	Tue Jun  5 08:03:28 2018
+++ src/sys/arch/arm/fdt/files.fdt	Wed Jun 20 08:03:55 2018
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.16 2018/06/05 08:03:28 hkenken Exp $
+# $NetBSD: files.fdt,v 1.17 2018/06/20 08:03:55 hkenken Exp $
 
 include	"dev/pckbport/files.pckbport"
 
@@ -25,6 +25,10 @@ device  gic: mpcorebus
 attach  gic at fdt with gic_fdt
 file    arch/arm/fdt/gic_fdt.c             	gic_fdt
 
+device  l2cc: mpcorebus
+attach  l2cc at fdt with l2cc_fdt
+file    arch/arm/fdt/l2cc_fdt.c             	l2cc_fdt
+
 attach	plcom at fdt with plcom_fdt
 file	arch/arm/fdt/plcom_fdt.c		plcom_fdt
 

Added files:

Index: src/sys/arch/arm/fdt/l2cc_fdt.c
diff -u /dev/null src/sys/arch/arm/fdt/l2cc_fdt.c:1.1
--- /dev/null	Wed Jun 20 08:03:55 2018
+++ src/sys/arch/arm/fdt/l2cc_fdt.c	Wed Jun 20 08:03:55 2018
@@ -0,0 +1,88 @@
+/*	$NetBSD: l2cc_fdt.c,v 1.1 2018/06/20 08:03:55 hkenken Exp $	*/
+/*
+ * Copyright (c) 2018  Genetec Corporation.  All rights reserved.
+ * Written by Hashimoto Kenichi for Genetec Corporation.
+ *
+ * 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 GENETEC CORPORATION ``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 GENETEC CORPORATION
+ * 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: l2cc_fdt.c,v 1.1 2018/06/20 08:03:55 hkenken Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/intr.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/kmem.h>
+
+#include <arm/cortex/mpcore_var.h>
+
+#include <dev/fdt/fdtvar.h>
+#include <arm/fdt/arm_fdtvar.h>
+
+static int l2cc_fdt_match(device_t, cfdata_t, void *);
+static void l2cc_fdt_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(l2cc_fdt, 0, l2cc_fdt_match, l2cc_fdt_attach, NULL, NULL);
+
+static int
+l2cc_fdt_match(device_t parent, cfdata_t cf, void *aux)
+{
+	const char * const compatible[] = {
+		"arm,pl310-cache",
+		NULL
+	};
+	struct fdt_attach_args * const faa = aux;
+
+	return of_compatible(faa->faa_phandle, compatible) >= 0;
+}
+
+static void
+l2cc_fdt_attach(device_t parent, device_t self, void *aux)
+{
+	struct fdt_attach_args * const faa = aux;
+	const int phandle = faa->faa_phandle;
+	bus_space_handle_t bsh;
+
+	bus_addr_t addr;
+	bus_size_t size;
+	if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
+		aprint_error(": couldn't get distributor address\n");
+		return;
+	}
+	if (bus_space_map(faa->faa_bst, addr, size, 0, &bsh)) {
+		aprint_error(": couldn't map registers\n");
+		return;
+	}
+
+	struct mpcore_attach_args mpcaa = {
+		.mpcaa_name = "arml2cc",
+		.mpcaa_memt = faa->faa_bst,
+		.mpcaa_memh = bsh,
+		.mpcaa_off1 = 0,
+		.mpcaa_off2 = 0,
+	};
+
+	config_found(self, &mpcaa, NULL);
+}

Reply via email to