[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree
zrouter-src-freebsd at zrouter.org
zrouter-src-freebsd at zrouter.org
Wed Apr 18 14:10:08 UTC 2012
details: http://zrouter.org/hg/FreeBSD/head//rev/135feddfa0e3
changeset: 458:135feddfa0e3
user: Aleksandr Rybalko <ray at ddteam.net>
date: Wed Apr 18 17:08:03 2012 +0300
description:
Update debugability.
diffstat:
head/sys/mips/atheros/ar71xx_spi.c | 41 ++++++++++++++++++++++++++++++++++++-
1 files changed, 39 insertions(+), 2 deletions(-)
diffs (101 lines):
diff -r 5df8a434490a -r 135feddfa0e3 head/sys/mips/atheros/ar71xx_spi.c
--- a/head/sys/mips/atheros/ar71xx_spi.c Wed Apr 18 11:09:04 2012 +0300
+++ b/head/sys/mips/atheros/ar71xx_spi.c Wed Apr 18 17:08:03 2012 +0300
@@ -37,6 +37,7 @@
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/rman.h>
+#include <sys/sysctl.h>
#include <vm/vm.h>
#include <vm/pmap.h>
@@ -78,8 +79,25 @@
device_t sc_dev;
struct resource *sc_mem_res;
uint32_t sc_reg_ctrl;
+ uint32_t sc_debug;
};
+static void
+ar71xx_spi_attach_sysctl(device_t dev)
+{
+ struct ar71xx_spi_softc *sc = device_get_softc(dev);
+ struct sysctl_ctx_list *ctx;
+ struct sysctl_oid *tree;
+
+ sc = device_get_softc(dev);
+ ctx = device_get_sysctl_ctx(dev);
+ tree = device_get_sysctl_tree(dev);
+
+ SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
+ "debug", CTLFLAG_RW, &sc->sc_debug, 0,
+ "ar71xx_spi debugging flags");
+}
+
static int
ar71xx_spi_probe(device_t dev)
{
@@ -109,6 +127,8 @@
SPI_WRITE(sc, AR71XX_SPI_FS, 0);
device_add_child(dev, "spibus", 0);
+ ar71xx_spi_attach_sysctl(dev);
+
return (bus_generic_attach(dev));
}
@@ -173,6 +193,9 @@
sc = device_get_softc(dev);
+ if (sc->sc_debug & 0x8000)
+ printf("ar71xx_spi_transfer: CMD ");
+
/* Open SPI controller interface */
SPI_WRITE(sc, AR71XX_SPI_FS, 1);
ar71xx_spi_chip_activate(sc, devi->cs);
@@ -186,11 +209,18 @@
lin = cmd->rx_cmd_sz;
len = (lout > lin)?lout:lin;
for (i = 0; i < len; i++) {
+ if (sc->sc_debug & 0x8000)
+ printf("O%02x", (lout > i)?buf_out[i]:0);
in = ar71xx_spi_txrx(sc, devi->cs, (lout > i)?buf_out[i]:0);
- if (lin > i)
+ if (lin > i) {
buf_in[i] = in;
+ if (sc->sc_debug & 0x8000)
+ printf("I%02x ", in);
+ }
}
+ if (sc->sc_debug & 0x8000)
+ printf("\nDATA ");
/*
* Receive/transmit data (depends on command)
*/
@@ -200,9 +230,14 @@
lin = cmd->rx_data_sz;
len = (lout > lin)?lout:lin;
for (i = 0; i < len; i++) {
+ if (sc->sc_debug & 0x8000)
+ printf("O%02x", (lout > i)?buf_out[i]:0);
in = ar71xx_spi_txrx(sc, devi->cs, (lout > i)?buf_out[i]:0);
- if (lin > i)
+ if (lin > i) {
buf_in[i] = in;
+ if (sc->sc_debug & 0x8000)
+ printf("I%02x ", in);
+ }
}
ar71xx_spi_chip_deactivate(sc, devi->cs);
@@ -210,6 +245,8 @@
* Close SPI controller interface, restore flash memory mapped access.
*/
SPI_WRITE(sc, AR71XX_SPI_FS, 0);
+ if (sc->sc_debug & 0x8000)
+ printf("\n");
return (0);
}
More information about the Zrouter-src-freebsd
mailing list