summaryrefslogtreecommitdiffstats
path: root/wbsio_spi.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2010-01-07 03:32:17 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2010-01-07 03:32:17 +0000
commit5609fa752ca1c36d00d915e94d481a9a457c85cf (patch)
treeff145bc4ed987c3c81870ddb6e7ce6a929ca9b47 /wbsio_spi.c
parenta84835a7eadadb715a61d993da6766bdf1b37c5e (diff)
downloadast2050-flashrom-5609fa752ca1c36d00d915e94d481a9a457c85cf.zip
ast2050-flashrom-5609fa752ca1c36d00d915e94d481a9a457c85cf.tar.gz
Allow one to disable programmer debug messages at compile time
Programmer debug messages during programmer init/shutdown are useful because they print hardware settings and desired configuration. They help in getting a quick overview of hardware and software state on startup and shutdown. Programmer debug messages during flash chip access are mostly a distraction in logs and should only be enabled if someone is having problems which are suspected to stem from a programmer hardware or programmer software bug. Disable those messages by default, they can be reenabled by #define COMM_DEBUG in the affected programmer file. An added benefit is a tremendous size reduction in verbose probe/read/write/erase logs because only flash chip driver messages remain. In some cases, logs will shrink from 65 MB to 10 kB or less. The right(tm) fix would be two different debug levels (DEBUG and SPEW) and the ability to differentiate between programmer debug messages and flash chip debug messages. Until the design for the message printing infrastructure is finished, this is the best stop-gap measure we can get. Corresponding to flashrom svn r834. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Sean Nelson <audioahcked@gmail.com>
Diffstat (limited to 'wbsio_spi.c')
-rw-r--r--wbsio_spi.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/wbsio_spi.c b/wbsio_spi.c
index 6b9425f..e6b94ad 100644
--- a/wbsio_spi.c
+++ b/wbsio_spi.c
@@ -2,6 +2,7 @@
* This file is part of the flashrom project.
*
* Copyright (C) 2008 Peter Stuge <peter@stuge.se>
+ * Copyright (C) 2009,2010 Carl-Daniel Hailfinger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,6 +22,17 @@
#include "flash.h"
#include "spi.h"
+/* Change this to #define if you want lowlevel debugging of commands
+ * sent to the Winbond W836xx SPI controller.
+ */
+#undef COMM_DEBUG
+
+#ifdef COMM_DEBUG
+#define msg_comm_debug printf_debug
+#else
+#define msg_comm_debug(...) do {} while (0)
+#endif
+
#define WBSIO_PORT1 0x2e
#define WBSIO_PORT2 0x4e
@@ -62,7 +74,7 @@ int wbsio_check_for_spi(const char *name)
if (0 == (wbsio_spibase = wbsio_get_spibase(WBSIO_PORT2)))
return 1;
- printf_debug("\nwbsio_spibase = 0x%x\n", wbsio_spibase);
+ msg_comm_debug("\nwbsio_spibase = 0x%x\n", wbsio_spibase);
buses_supported |= CHIP_BUSTYPE_SPI;
spi_controller = SPI_CONTROLLER_WBSIO;
@@ -96,42 +108,42 @@ int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
int i;
uint8_t mode = 0;
- printf_debug("%s:", __func__);
+ msg_comm_debug("%s:", __func__);
if (1 == writecnt && 0 == readcnt) {
mode = 0x10;
} else if (2 == writecnt && 0 == readcnt) {
OUTB(writearr[1], wbsio_spibase + 4);
- printf_debug(" data=0x%02x", writearr[1]);
+ msg_comm_debug(" data=0x%02x", writearr[1]);
mode = 0x20;
} else if (1 == writecnt && 2 == readcnt) {
mode = 0x30;
} else if (4 == writecnt && 0 == readcnt) {
- printf_debug(" addr=0x%02x", (writearr[1] & 0x0f));
+ msg_comm_debug(" addr=0x%02x", (writearr[1] & 0x0f));
for (i = 2; i < writecnt; i++) {
OUTB(writearr[i], wbsio_spibase + i);
- printf_debug("%02x", writearr[i]);
+ msg_comm_debug("%02x", writearr[i]);
}
mode = 0x40 | (writearr[1] & 0x0f);
} else if (5 == writecnt && 0 == readcnt) {
- printf_debug(" addr=0x%02x", (writearr[1] & 0x0f));
+ msg_comm_debug(" addr=0x%02x", (writearr[1] & 0x0f));
for (i = 2; i < 4; i++) {
OUTB(writearr[i], wbsio_spibase + i);
- printf_debug("%02x", writearr[i]);
+ msg_comm_debug("%02x", writearr[i]);
}
OUTB(writearr[i], wbsio_spibase + i);
- printf_debug(" data=0x%02x", writearr[i]);
+ msg_comm_debug(" data=0x%02x", writearr[i]);
mode = 0x50 | (writearr[1] & 0x0f);
} else if (8 == writecnt && 0 == readcnt) {
- printf_debug(" addr=0x%02x", (writearr[1] & 0x0f));
+ msg_comm_debug(" addr=0x%02x", (writearr[1] & 0x0f));
for (i = 2; i < 4; i++) {
OUTB(writearr[i], wbsio_spibase + i);
- printf_debug("%02x", writearr[i]);
+ msg_comm_debug("%02x", writearr[i]);
}
- printf_debug(" data=0x");
+ msg_comm_debug(" data=0x");
for (; i < writecnt; i++) {
OUTB(writearr[i], wbsio_spibase + i);
- printf_debug("%02x", writearr[i]);
+ msg_comm_debug("%02x", writearr[i]);
}
mode = 0x60 | (writearr[1] & 0x0f);
} else if (5 == writecnt && 4 == readcnt) {
@@ -142,14 +154,14 @@ int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
*/
;
} else if (4 == writecnt && readcnt >= 1 && readcnt <= 4) {
- printf_debug(" addr=0x%02x", (writearr[1] & 0x0f));
+ msg_comm_debug(" addr=0x%02x", (writearr[1] & 0x0f));
for (i = 2; i < writecnt; i++) {
OUTB(writearr[i], wbsio_spibase + i);
- printf_debug("%02x", writearr[i]);
+ msg_comm_debug("%02x", writearr[i]);
}
mode = ((7 + readcnt) << 4) | (writearr[1] & 0x0f);
}
- printf_debug(" cmd=%02x mode=%02x\n", writearr[0], mode);
+ msg_comm_debug(" cmd=%02x mode=%02x\n", writearr[0], mode);
if (!mode) {
fprintf(stderr, "%s: unsupported command type wr=%d rd=%d\n",
@@ -165,12 +177,12 @@ int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
if (!readcnt)
return 0;
- printf_debug("%s: returning data =", __func__);
+ msg_comm_debug("%s: returning data =", __func__);
for (i = 0; i < readcnt; i++) {
readarr[i] = INB(wbsio_spibase + 4 + i);
- printf_debug(" 0x%02x", readarr[i]);
+ msg_comm_debug(" 0x%02x", readarr[i]);
}
- printf_debug("\n");
+ msg_comm_debug("\n");
return 0;
}
OpenPOWER on IntegriCloud