Module Name:    src
Committed By:   phx
Date:           Mon Sep  7 23:00:08 UTC 2015

Modified Files:
        src/sys/arch/sandpoint/sandpoint: flash_cfi.c machdep.c mainbus.c

Log Message:
Fix nor-flash bus space: extent limit should not be zero and bus space is
definitely big-endian. Reading the flash via /dev/flash0 works now.
Writing is untested.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sandpoint/sandpoint/flash_cfi.c
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/sandpoint/sandpoint/machdep.c
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sandpoint/sandpoint/mainbus.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/sandpoint/sandpoint/flash_cfi.c
diff -u src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.3 src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.4
--- src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.3	Mon Jan 30 15:47:01 2012
+++ src/sys/arch/sandpoint/sandpoint/flash_cfi.c	Mon Sep  7 23:00:08 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: flash_cfi.c,v 1.3 2012/01/30 15:47:01 phx Exp $ */
+/* $NetBSD: flash_cfi.c,v 1.4 2015/09/07 23:00:08 phx Exp $ */
 
 /*-
  * Copyright (c) 2011 Frank Wille.
@@ -32,7 +32,7 @@
  * NOR CFI driver support for sandpoint
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: flash_cfi.c,v 1.3 2012/01/30 15:47:01 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: flash_cfi.c,v 1.4 2015/09/07 23:00:08 phx Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -63,7 +63,7 @@ sandpointcfi_probe(device_t parent, cfda
 {
 	extern struct cfdriver cfi_cd;
 	struct mainbus_attach_args *ma = aux;
-	const bus_size_t tmpsize = CFI_QRY_MIN_MAP_SIZE;
+	const bus_size_t qrysize = CFI_QRY_MIN_MAP_SIZE;
 	struct cfi cfi;
 	int error, rv;
 
@@ -74,11 +74,12 @@ sandpointcfi_probe(device_t parent, cfda
 
 	cfi.cfi_bst = ma->ma_bst;
 
-	error = bus_space_map(cfi.cfi_bst, ma->ma_addr, tmpsize, 0,
+	/* flash should be at least 2 MiB in size at 0xffe00000 */
+	error = bus_space_map(cfi.cfi_bst, 0xffe00000, qrysize, 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);
+		    __func__, qrysize, ma->ma_addr, error);
 		return 0;
 	}
 
@@ -90,7 +91,7 @@ sandpointcfi_probe(device_t parent, cfda
 	} else
 		rv = 1;
 
-	bus_space_unmap(cfi.cfi_bst, cfi.cfi_bsh, tmpsize);
+	bus_space_unmap(cfi.cfi_bst, cfi.cfi_bsh, qrysize);
 	return rv;
 }
 
@@ -99,7 +100,7 @@ sandpointcfi_attach(device_t parent, dev
 {
 	struct mainbus_attach_args *ma = aux;
 	struct sandpointcfi_softc *sc;
-	const bus_size_t tmpsize = CFI_QRY_MIN_MAP_SIZE;
+	const bus_size_t qrysize = CFI_QRY_MIN_MAP_SIZE;
 	bus_addr_t addr;
 	bool found;
 	int error;
@@ -112,7 +113,7 @@ sandpointcfi_attach(device_t parent, dev
 	sc->sc_cfi.cfi_bst = ma->ma_bst;
 
 	/* map enough to identify, remap later when size is known */
-	error = bus_space_map(sc->sc_cfi.cfi_bst, ma->ma_addr, tmpsize, 0,
+	error = bus_space_map(sc->sc_cfi.cfi_bst, 0xffe00000, qrysize, 0,
 	    &sc->sc_cfi.cfi_bsh);
 	if (error != 0) {
 		aprint_error_dev(self, "could not map error %d\n", error);
@@ -122,7 +123,7 @@ sandpointcfi_attach(device_t parent, dev
 	/* identify the NOR flash */
 	found = cfi_identify(&sc->sc_cfi);
 
-	bus_space_unmap(sc->sc_cfi.cfi_bst, sc->sc_cfi.cfi_bsh, tmpsize);
+	bus_space_unmap(sc->sc_cfi.cfi_bst, sc->sc_cfi.cfi_bsh, qrysize);
 	if (!found) {
 		/* should not happen, we already probed OK in match */
 		aprint_error_dev(self, "could not map error %d\n", error);
@@ -132,7 +133,7 @@ sandpointcfi_attach(device_t parent, dev
 	/* get size of flash in bytes */
 	sc->sc_size = 1 << sc->sc_cfi.cfi_qry_data.device_size;
 
-	/* real base address */
+	/* determine real base address */
 	addr = (0xffffffff - sc->sc_size) + 1;
 
 	sc->sc_nor_if = nor_interface_cfi;

Index: src/sys/arch/sandpoint/sandpoint/machdep.c
diff -u src/sys/arch/sandpoint/sandpoint/machdep.c:1.63 src/sys/arch/sandpoint/sandpoint/machdep.c:1.64
--- src/sys/arch/sandpoint/sandpoint/machdep.c:1.63	Sun Apr 21 15:42:12 2013
+++ src/sys/arch/sandpoint/sandpoint/machdep.c	Mon Sep  7 23:00:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.63 2013/04/21 15:42:12 kiyohara Exp $	*/
+/*	$NetBSD: machdep.c,v 1.64 2015/09/07 23:00:08 phx Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.63 2013/04/21 15:42:12 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.64 2015/09/07 23:00:08 phx Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -450,8 +450,8 @@ struct powerpc_bus_space sandpoint_eumb_
 	0xfc000000, 0x00000000, 0x00100000,
 };
 struct powerpc_bus_space sandpoint_flash_space_tag = {
-	_BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
-	0x00000000, 0xff000000, 0x00000000,
+	_BUS_SPACE_BIG_ENDIAN|_BUS_SPACE_MEM_TYPE,
+	0x00000000, 0xff000000, 0xffffffff,
 };
 struct powerpc_bus_space sandpoint_nhgpio_space_tag = {
 	_BUS_SPACE_BIG_ENDIAN|_BUS_SPACE_MEM_TYPE,

Index: src/sys/arch/sandpoint/sandpoint/mainbus.c
diff -u src/sys/arch/sandpoint/sandpoint/mainbus.c:1.29 src/sys/arch/sandpoint/sandpoint/mainbus.c:1.30
--- src/sys/arch/sandpoint/sandpoint/mainbus.c:1.29	Tue Jan 31 21:12:03 2012
+++ src/sys/arch/sandpoint/sandpoint/mainbus.c	Mon Sep  7 23:00:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.29 2012/01/31 21:12:03 phx Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.30 2015/09/07 23:00:08 phx Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.29 2012/01/31 21:12:03 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.30 2015/09/07 23:00:08 phx Exp $");
 
 #include "opt_pci.h"
 #include "pci.h"
@@ -103,7 +103,6 @@ mainbus_attach(device_t parent, device_t
 
 	mba.ma_name = "cfi";
 	mba.ma_bst = &sandpoint_flash_space_tag;
-	mba.ma_addr = 0xffe00000; /* smallest flash is 2 MiB */
 	config_found_ia(self, "mainbus", &mba, mainbus_print);
 
 	/*

Reply via email to