[U-Boot] [PATCH 4/4] a4m072: support for SHOW_BOOT_PROGRESS feature using LED display
Ilya Yanok
yanok at emcraft.com
Thu Sep 9 23:03:34 CEST 2010
This patch adds support for displaying boot progress codes on a4m072 board
using LED display. As we can display only one symbol at any time on the hardware
(two symbols with blinking) we can't display progress codes directly and have
to map them to 2-symbol codes.
We use the following mapping on the a4m972 board:
[1, 8] U [100, 108] -> 5
[-9, -1] U [-101, -100] U [-113, -103] -> -5
[9, 14] U [120, 123] U [125, 129] -> 8
[-13, -10] U [-122, -120] U [-127, -124] U {-129} -> -8
{15} -> 9
[-32, -30] -> -A
[-40, -35] U [-51, -42] U [-58, -53] U
[-83, -80] U {-64, -130, -140, -150} -> -B
Other progress code are ignored. One symbol codes are displayed steady while
two-symbol codes are displayed using blinking. Boot progress codes are
displayed with decimal got unset (as opposed to 'display' command output).
Signed-off-by: Ilya Yanok <yanok at emcraft.com>
---
board/a4m072/a4m072.c | 79 +++++++++++++++++++++++++++++++++++++++++++---
include/configs/a4m072.h | 2 +
2 files changed, 76 insertions(+), 5 deletions(-)
diff --git a/board/a4m072/a4m072.c b/board/a4m072/a4m072.c
index 9c272a0..ae7ccbb 100644
--- a/board/a4m072/a4m072.c
+++ b/board/a4m072/a4m072.c
@@ -35,6 +35,7 @@
#include <libfdt.h>
#include <netdev.h>
#include <led-display.h>
+#include <linux/err.h>
#include "mt46v32m16.h"
@@ -410,18 +411,26 @@ int display_putc(char c)
}
/*
- * Output content of the software display buffer to the LED display every 0.5s
+ * Flush current symbol to the LED display hardware
+ */
+static inline void display_flush(void)
+{
+ u32 val = display_buf[display_out_pos];
+
+ val |= (val << 8) | (val << 16) | (val << 24);
+ out_be32((void *)CONFIG_SYS_DISP_CHR_RAM, val);
+}
+
+/*
+ * Output contents of the software display buffer to the LED display every 0.5s
*/
void board_show_activity(ulong timestamp)
{
static ulong last;
static u8 once;
- u32 val;
if (!once || (timestamp - last >= (CONFIG_SYS_HZ / 2))) {
- val = display_buf[display_out_pos];
- val |= (val << 8) | (val << 16) | (val << 24);
- out_be32((void *)CONFIG_SYS_DISP_CHR_RAM, val);
+ display_flush();
display_out_pos ^= 1;
last = timestamp;
once = 1;
@@ -435,3 +444,63 @@ void show_activity(int arg)
{
}
#endif
+#if defined (CONFIG_SHOW_BOOT_PROGRESS)
+static int a4m072_status2code(int status, char *buf)
+{
+ char c = 0;
+
+ if (((status > 0) && (status <= 8)) ||
+ ((status >= 100) && (status <= 108)) ||
+ ((status < 0) && (status >= -9)) ||
+ (status == -100) || (status == -101) ||
+ ((status <= -103) && (status >= -113))) {
+ c = '5';
+ } else if (((status >= 9) && (status <= 14)) ||
+ ((status >= 120) && (status <= 123)) ||
+ ((status >= 125) && (status <= 129)) ||
+ ((status >= -13) && (status <= -10)) ||
+ (status == -120) || (status == -122) ||
+ ((status <= -124) && (status >= -127)) ||
+ (status == -129)) {
+ c = '8';
+ } else if (status == 15) {
+ c = '9';
+ } else if ((status <= -30) && (status >= -32)) {
+ c = 'A';
+ } else if (((status <= -35) && (status >= -40)) ||
+ ((status <= -42) && (status >= -51)) ||
+ ((status <= -53) && (status >= -58)) ||
+ (status == -64) ||
+ ((status <= -80) && (status >= -83)) ||
+ (status == -130) || (status == -140) ||
+ (status == -150)) {
+ c = 'B';
+ }
+
+ if (c == 0)
+ return -EINVAL;
+
+ buf[0] = (status < 0) ? '-' : c;
+ buf[1] = c;
+
+ return 0;
+}
+
+void show_boot_progress(int status)
+{
+ char buf[2];
+
+ if (a4m072_status2code(status, buf) < 0)
+ return;
+
+ display_set(0); /* Clear DP Led */
+ display_putc_nomark(buf[0]);
+ display_putc_nomark(buf[1]);
+ display_set(DISPLAY_HOME);
+ display_out_pos = 0; /* reset output position */
+
+ /* we want to flush status 15 now */
+ if (status == 15)
+ display_flush();
+}
+#endif
diff --git a/include/configs/a4m072.h b/include/configs/a4m072.h
index ce931d7..a54ab1d 100644
--- a/include/configs/a4m072.h
+++ b/include/configs/a4m072.h
@@ -382,4 +382,6 @@
#define CONFIG_SYS_DISP_CHR_RAM CONFIG_SYS_CS7_START
#define CONFIG_SHOW_ACTIVITY /* used for display realization */
+#define CONFIG_SHOW_BOOT_PROGRESS
+
#endif /* __CONFIG_H */
--
1.6.2.5
More information about the U-Boot
mailing list