[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Fri May 4 20:28:51 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/a92b653f5b46
changeset: 478:a92b653f5b46
user:      Aleksandr Rybalko <ray at ddteam.net>
date:      Fri May 04 23:28:08 2012 +0300
description:
Implement SPI Flash read acceleration. Atheros AR71xx have memory mapped window
with flash content, so we can use it to not use Bit-banging operations for read.

diffstat:

 head/sys/dev/flash/mx25l.c         |   4 ++++
 head/sys/dev/spibus/spibus.c       |   9 +++++++++
 head/sys/dev/spibus/spibus_if.m    |  23 +++++++++++++++++++++++
 head/sys/mips/atheros/ar71xx_spi.c |  18 ++++++++++++++++++
 4 files changed, 54 insertions(+), 0 deletions(-)

diffs (112 lines):

diff -r 836e04b655a0 -r a92b653f5b46 head/sys/dev/flash/mx25l.c
--- a/head/sys/dev/flash/mx25l.c	Mon Apr 30 15:27:19 2012 +0300
+++ b/head/sys/dev/flash/mx25l.c	Fri May 04 23:28:08 2012 +0300
@@ -394,6 +394,10 @@
 	    "%s(dev, offset=0x%08x, data, count=0x%08x)\n",
 	    __func__, (uint32_t)offset, (uint32_t)count);
 
+	err = SPIBUS_GET_BLOCK(pdev, dev, offset, data, count);
+	if (!err)
+		return (0);
+
 	/*
 	 * Enforce the disk read sectorsize not the erase sectorsize.
 	 * In this way, smaller read IO is possible,dramatically
diff -r 836e04b655a0 -r a92b653f5b46 head/sys/dev/spibus/spibus.c
--- a/head/sys/dev/spibus/spibus.c	Mon Apr 30 15:27:19 2012 +0300
+++ b/head/sys/dev/spibus/spibus.c	Fri May 04 23:28:08 2012 +0300
@@ -168,6 +168,14 @@
 	return (SPIBUS_TRANSFER(device_get_parent(dev), child, cmd));
 }
 
+static int
+spibus_get_block_impl(device_t dev, device_t child, off_t offset,
+    caddr_t data, off_t count)
+{
+	return (SPIBUS_GET_BLOCK(device_get_parent(dev), child, offset, data,
+	    count));
+}
+
 static device_method_t spibus_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_probe,		spibus_probe),
@@ -188,6 +196,7 @@
 
 	/* spibus interface */
 	DEVMETHOD(spibus_transfer,	spibus_transfer_impl),
+	DEVMETHOD(spibus_get_block,	spibus_get_block_impl),
 
 	DEVMETHOD_END
 };
diff -r 836e04b655a0 -r a92b653f5b46 head/sys/dev/spibus/spibus_if.m
--- a/head/sys/dev/spibus/spibus_if.m	Mon Apr 30 15:27:19 2012 +0300
+++ b/head/sys/dev/spibus/spibus_if.m	Fri May 04 23:28:08 2012 +0300
@@ -31,6 +31,15 @@
 
 INTERFACE spibus;
 
+CODE {
+	static int
+	get_block_unimpl(device_t dev, device_t child, off_t offset,
+	    caddr_t data, off_t count)
+	{
+		return (EOPNOTSUPP);
+	}
+};
+
 #
 # Do a spi command
 #
@@ -39,3 +48,17 @@
 	device_t child;
 	struct spi_command *cmd;
 };
+
+#
+# Do a spibus_get_block if driver able
+# return 0 on success
+#
+METHOD int get_block {
+	device_t dev;
+	device_t child;
+	off_t offset;
+	caddr_t data;
+	off_t count;
+} DEFAULT get_block_unimpl;
+
+
diff -r 836e04b655a0 -r a92b653f5b46 head/sys/mips/atheros/ar71xx_spi.c
--- a/head/sys/mips/atheros/ar71xx_spi.c	Mon Apr 30 15:27:19 2012 +0300
+++ b/head/sys/mips/atheros/ar71xx_spi.c	Fri May 04 23:28:08 2012 +0300
@@ -184,6 +184,23 @@
 }
 
 static int
+ar71xx_spi_get_block(device_t dev, device_t child, off_t offset, caddr_t data,
+    off_t count)
+{
+	struct ar71xx_spi_softc *sc;
+
+	sc = device_get_softc(dev);
+
+	if ((offset + count) > rman_get_size(sc->sc_mem_res))
+		return (EINVAL);
+
+	bus_read_region_4(sc->sc_mem_res, offset, (uint32_t *)data,
+	    (bus_size_t)(count/4));
+
+	return (0);
+}
+
+static int
 ar71xx_spi_transfer(device_t dev, device_t child, struct spi_command *cmd)
 {
 	struct ar71xx_spi_softc *sc;
@@ -273,6 +290,7 @@
 	DEVMETHOD(device_detach,	ar71xx_spi_detach),
 
 	DEVMETHOD(spibus_transfer,	ar71xx_spi_transfer),
+	DEVMETHOD(spibus_get_block,	ar71xx_spi_get_block),
 
 	DEVMETHOD_END
 };


More information about the Zrouter-src-freebsd mailing list