Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sandpoint Added NOR flash driver, using nor(4) and ...
details: https://anonhg.NetBSD.org/src/rev/c7e244aeac24
branches: trunk
changeset: 772093:c7e244aeac24
user: phx <phx%NetBSD.org@localhost>
date: Sat Dec 17 20:20:37 2011 +0000
description:
Added NOR flash driver, using nor(4) and flash(4).
diffstat:
sys/arch/sandpoint/conf/GENERIC | 11 +-
sys/arch/sandpoint/conf/files.sandpoint | 17 ++-
sys/arch/sandpoint/include/autoconf.h | 37 ++++++
sys/arch/sandpoint/include/bus.h | 32 -----
sys/arch/sandpoint/include/bus_funcs.h | 3 +-
sys/arch/sandpoint/sandpoint/flash_cfi.c | 172 +++++++++++++++++++++++++++++++
sys/arch/sandpoint/sandpoint/machdep.c | 19 ++-
sys/arch/sandpoint/sandpoint/mainbus.c | 19 ++-
8 files changed, 258 insertions(+), 52 deletions(-)
diffs (truncated from 491 to 300 lines):
diff -r 6af3d67b5fe2 -r c7e244aeac24 sys/arch/sandpoint/conf/GENERIC
--- a/sys/arch/sandpoint/conf/GENERIC Sat Dec 17 20:05:38 2011 +0000
+++ b/sys/arch/sandpoint/conf/GENERIC Sat Dec 17 20:20:37 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.61 2011/11/22 21:25:34 tls Exp $
+# $NetBSD: GENERIC,v 1.62 2011/12/17 20:20:37 phx Exp $
#
# machine description file for GENERIC NAS
#
@@ -22,7 +22,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.61 $"
+#ident "GENERIC-$Revision: 1.62 $"
maxusers 32
@@ -174,8 +174,12 @@
mainbus0 at root
cpu* at mainbus0
+
+cfi0 at mainbus0
+nor* at cfi?
+flash* at nor?
+
pci* at mainbus0 bus ?
-
pchb* at pci? dev ? function ? # PCI host bridge
eumb* at mainbus0
@@ -197,6 +201,7 @@
iteide* at pci? dev ? function ? # IT Express IDE controllers
satalink* at pci? dev ? function ? # SiI SATALink controllers
viaide* at pci? dev ? function ? # VIA IDE controllers
+#options WDC_NO_IDS # fix Iomega viaide VT6410
# ATA (IDE) bus support
atabus* at ata?
diff -r 6af3d67b5fe2 -r c7e244aeac24 sys/arch/sandpoint/conf/files.sandpoint
--- a/sys/arch/sandpoint/conf/files.sandpoint Sat Dec 17 20:05:38 2011 +0000
+++ b/sys/arch/sandpoint/conf/files.sandpoint Sat Dec 17 20:20:37 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.sandpoint,v 1.29 2011/03/01 09:17:07 phx Exp $
+# $NetBSD: files.sandpoint,v 1.30 2011/12/17 20:20:37 phx Exp $
#
# Motorola's "SandPoint" evaluation board and multiplied descendents.
#
@@ -39,19 +39,30 @@
define mainbus { }
device mainbus: isabus, pcibus, mainbus
attach mainbus at root
+
device cpu
attach cpu at mainbus
file arch/sandpoint/sandpoint/mainbus.c mainbus|cpu needs-flag
+device cfi: norbus
+attach cfi at mainbus with sandpointcfi
+file arch/sandpoint/sandpoint/flash_cfi.c sandpointcfi
+
device eumb { [ unit = -1 ] }: mainbus
attach eumb at mainbus
file arch/sandpoint/sandpoint/eumb.c eumb
+
attach com at eumb with com_eumb
file arch/sandpoint/sandpoint/com_eumb.c com_eumb needs-flag
+
device ociic: motoi2c, i2cbus
attach ociic at eumb with iic_eumb
file arch/sandpoint/sandpoint/iic_eumb.c iic_eumb
+device satmgr: sysmon_power, sysmon_taskq
+attach satmgr at eumb
+file arch/sandpoint/sandpoint/satmgr.c satmgr
+
#
# PCI-only drivers
# XXX MUST BE INCLUDED BEFORE files.isa, as long as files.isa attaches
@@ -104,8 +115,4 @@
include "dev/usb/files.usb"
-device satmgr: sysmon_power, sysmon_taskq
-attach satmgr at eumb
-file arch/sandpoint/sandpoint/satmgr.c satmgr
-
include "arch/powerpc/conf/majors.powerpc"
diff -r 6af3d67b5fe2 -r c7e244aeac24 sys/arch/sandpoint/include/autoconf.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sandpoint/include/autoconf.h Sat Dec 17 20:20:37 2011 +0000
@@ -0,0 +1,37 @@
+/* $NetBSD: autoconf.h,v 1.1 2011/12/17 20:20:37 phx Exp $ */
+
+/*-
+ * Copyright (c) 2011 Frank Wille.
+ * All rights reserved.
+ *
+ * Written by Frank Wille for The NetBSD Project.
+ *
+ * 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/bus.h>
+
+struct mainbus_attach_args {
+ const char *ma_name;
+ bus_space_tag_t ma_bst;
+ bus_addr_t ma_addr;
+};
diff -r 6af3d67b5fe2 -r c7e244aeac24 sys/arch/sandpoint/include/bus.h
--- a/sys/arch/sandpoint/include/bus.h Sat Dec 17 20:05:38 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/* $NetBSD: bus.h,v 1.8 2007/10/17 19:56:56 garbled Exp $ */
-/* $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $ */
-
-#ifndef _SANDPOINT_BUS_H_
-#define _SANDPOINT_BUS_H_
-
-/*
- * Values for the SandPoint bus space tag, not to be used directly by MI code.
- */
-#define SANDPOINT_BUS_SPACE_IO 0xFE000000 /* i/o space */
-#define SANDPOINT_BUS_SPACE_MEM 0x80000000 /* mem space */
-#define SANDPOINT_BUS_SPACE_EUMB 0xFC000000 /* EUMB space */
-#define SANDPOINT_PCI_CONFIG_ADDR 0xFEC00CF8
-#define SANDPOINT_PCI_CONFIG_DATA 0xFEE00CFC
-
-/*
- * Address conversion as seen from a PCI master.
- */
-#define PHYS_TO_BUS_MEM(t,x) (x)
-#define BUS_MEM_TO_PHYS(t,x) (x)
-
-#ifdef _KERNEL
-extern struct powerpc_bus_space sandpoint_io_space_tag;
-extern struct powerpc_bus_space genppc_isa_io_space_tag;
-extern struct powerpc_bus_space sandpoint_mem_space_tag;
-extern struct powerpc_bus_space genppc_isa_mem_space_tag;
-extern struct powerpc_bus_space sandpoint_eumb_space_tag;
-#endif
-
-#include <powerpc/bus.h>
-
-#endif /* _SANDPOINT_BUS_H_ */
diff -r 6af3d67b5fe2 -r c7e244aeac24 sys/arch/sandpoint/include/bus_funcs.h
--- a/sys/arch/sandpoint/include/bus_funcs.h Sat Dec 17 20:05:38 2011 +0000
+++ b/sys/arch/sandpoint/include/bus_funcs.h Sat Dec 17 20:20:37 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_funcs.h,v 1.1 2011/07/01 17:10:00 dyoung Exp $ */
+/* $NetBSD: bus_funcs.h,v 1.2 2011/12/17 20:20:37 phx Exp $ */
/* $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $ */
#ifndef _SANDPOINT_BUS_FUNCS_H_
@@ -10,6 +10,7 @@
extern struct powerpc_bus_space sandpoint_mem_space_tag;
extern struct powerpc_bus_space genppc_isa_mem_space_tag;
extern struct powerpc_bus_space sandpoint_eumb_space_tag;
+extern struct powerpc_bus_space sandpoint_flash_space_tag;
#endif
#include <powerpc/bus_funcs.h>
diff -r 6af3d67b5fe2 -r c7e244aeac24 sys/arch/sandpoint/sandpoint/flash_cfi.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sandpoint/sandpoint/flash_cfi.c Sat Dec 17 20:20:37 2011 +0000
@@ -0,0 +1,172 @@
+/* $NetBSD: flash_cfi.c,v 1.1 2011/12/17 20:20:38 phx Exp $ */
+
+/*-
+ * Copyright (c) 2011 Frank Wille.
+ * All rights reserved.
+ *
+ * Written by Frank Wille for The NetBSD Project.
+ *
+ * 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.
+ */
+
+/*
+ * NOR CFI driver support for sandpoint
+ */
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: flash_cfi.c,v 1.1 2011/12/17 20:20:38 phx Exp $");
+
+#include <sys/param.h>
+#include <sys/device.h>
+
+#include <machine/autoconf.h>
+
+#include <dev/nor/nor.h>
+#include <dev/nor/cfi.h>
+
+
+static int sandpointcfi_probe(device_t, cfdata_t, void *);
+static void sandpointcfi_attach(device_t, device_t, void *);
+static int sandpointcfi_detach(device_t, int);
+
+struct sandpointcfi_softc {
+ device_t sc_dev;
+ device_t sc_nordev;
+ struct cfi sc_cfi;
+ bus_size_t sc_size;
+ struct nor_interface sc_nor_if;
+};
+
+CFATTACH_DECL_NEW(sandpointcfi, sizeof(struct sandpointcfi_softc),
+ sandpointcfi_probe, sandpointcfi_attach, sandpointcfi_detach, NULL);
+
+static int
+sandpointcfi_probe(device_t parent, cfdata_t cf, void *aux)
+{
+ extern struct cfdriver cfi_cd;
+ struct mainbus_attach_args *ma = aux;
+ const bus_size_t tmpsize = CFI_QRY_MIN_MAP_SIZE;
+ struct cfi cfi;
+ int error, rv;
+
+ if (strcmp(ma->ma_name, cfi_cd.cd_name) != 0)
+ return 0;
+
+ KASSERT(ma->ma_bst != NULL);
+
+ cfi.cfi_bst = ma->ma_bst;
+
+ error = bus_space_map(cfi.cfi_bst, ma->ma_addr, tmpsize, 0,
+ &cfi.cfi_bsh);
+ if (error != 0) {
+ aprint_error("%s: cannot map %d at offset %#x, error %d\n",
+ __func__, tmpsize, ma->ma_addr, error);
+ return 0;
+ }
+
+ /* probe for NOR flash */
+ if (!cfi_probe(&cfi)) {
+ aprint_debug("%s: probe addr %#x, CFI not found\n",
+ __func__, ma->ma_addr);
+ rv = 0;
+ } else
+ rv = 1;
+
+ bus_space_unmap(cfi.cfi_bst, cfi.cfi_bsh, tmpsize);
+ return rv;
+}
+
+static void
+sandpointcfi_attach(device_t parent, device_t self, void *aux)
+{
+ struct mainbus_attach_args *ma = aux;
+ struct sandpointcfi_softc *sc;
+ const bus_size_t tmpsize = CFI_QRY_MIN_MAP_SIZE;
+ bus_addr_t addr;
+ bool found;
+ int error;
+
+ aprint_naive("\n");
+ aprint_normal("\n");
+
+ sc = device_private(self);
+ sc->sc_dev = self;
+ sc->sc_cfi.cfi_bst = ma->ma_bst;
+
Home |
Main Index |
Thread Index |
Old Index