X-Git-Url: https://git.kernelconcepts.de/?a=blobdiff_plain;f=board%2Fa4m072%2Fa4m072.c;h=09a5a5183bf9e4e6fa91ab5c79a230f0638be338;hb=d963e84c92a63b4e6c4f2f80482a5ecbe9b24fe0;hp=9c272a0ec88e860a9cd47ab8fb23ba1b92536f61;hpb=cb5639cbc01a73bd72226c076696b92fce1292ff;p=karo-tx-uboot.git diff --git a/board/a4m072/a4m072.c b/board/a4m072/a4m072.c index 9c272a0ec8..09a5a5183b 100644 --- a/board/a4m072/a4m072.c +++ b/board/a4m072/a4m072.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "mt46v32m16.h" @@ -269,8 +270,6 @@ static u8 display_buf[DISPLAY_BUF_SIZE]; static u8 display_putc_pos; static u8 display_out_pos; -static u8 display_dot_enable; - void display_set(int cmd) { if (cmd & DISPLAY_CLEAR) { @@ -280,12 +279,6 @@ void display_set(int cmd) { if (cmd & DISPLAY_HOME) { display_putc_pos = 0; } - - if (cmd & DISPLAY_MARK) { - display_dot_enable = 1; - } else { - display_dot_enable = 0; - } } #define SEG_A (1<<0) @@ -313,10 +306,12 @@ void display_set(int cmd) { * A..Z index 10..35 * - index 36 * _ index 37 + * . index 38 */ #define SYMBOL_DASH (36) #define SYMBOL_UNDERLINE (37) +#define SYMBOL_DOT (38) static u8 display_char2seg7_tbl[]= { @@ -336,28 +331,29 @@ static u8 display_char2seg7_tbl[]= SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, /* d */ SEG_A | SEG_D | SEG_E | SEG_F | SEG_G, /* E */ SEG_A | SEG_E | SEG_F | SEG_G, /* F */ - SEG_A | SEG_B | SEG_C | SEG_D | SEG_F | SEG_G, /* g */ + 0, /* g - not displayed */ SEG_B | SEG_C | SEG_E | SEG_F | SEG_G, /* H */ - SEG_E | SEG_F, /* I */ - SEG_B | SEG_C | SEG_D | SEG_E, /* J */ - SEG_A, /* K - special 1 */ + SEG_B | SEG_C, /* I */ + 0, /* J - not displayed */ + 0, /* K - not displayed */ SEG_D | SEG_E | SEG_F, /* L */ - SEG_B, /* m - special 2 */ - SEG_C | SEG_E | SEG_G, /* n */ - SEG_C | SEG_D | SEG_E | SEG_G, /* o */ + 0, /* m - not displayed */ + 0, /* n - not displayed */ + SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F, /* O */ SEG_A | SEG_B | SEG_E | SEG_F | SEG_G, /* P */ - SEG_A | SEG_B | SEG_C | SEG_F | SEG_G, /* q */ - SEG_E | SEG_G, /* r */ + 0, /* q - not displayed */ + 0, /* r - not displayed */ SEG_A | SEG_C | SEG_D | SEG_F | SEG_G, /* S */ SEG_D | SEG_E | SEG_F | SEG_G, /* t */ SEG_B | SEG_C | SEG_D | SEG_E | SEG_F, /* U */ - SEG_C | SEG_D | SEG_E | SEG_F, /* V */ - SEG_C, /* w - special 3 */ - SEG_B | SEG_C | SEG_E | SEG_F | SEG_G, /* X */ + 0, /* V - not displayed */ + 0, /* w - not displayed */ + 0, /* X - not displayed */ SEG_B | SEG_C | SEG_D | SEG_F | SEG_G, /* Y */ - SEG_A | SEG_B | SEG_D | SEG_E | SEG_G, /* Z */ + 0, /* Z - not displayed */ SEG_G, /* - */ - SEG_D /* _ */ + SEG_D, /* _ */ + SEG_P /* . */ }; /* Convert char to the LED segments representation */ @@ -373,23 +369,20 @@ static u8 display_char2seg7(char c) c -= 'A' - 10; else if (c == '-') c = SYMBOL_DASH; - else if ((c == '_') || (c == '.')) + else if (c == '_') c = SYMBOL_UNDERLINE; + else if (c == '.') + c = SYMBOL_DOT; else c = ' '; /* display unsupported symbols as space */ if (c != ' ') val = display_char2seg7_tbl[(int)c]; - /* Handle DP LED here */ - if (display_dot_enable) { - val |= SEG_P; - } - return val; } -static inline int display_putc_nomark(char c) +int display_putc(char c) { if (display_putc_pos >= DISPLAY_BUF_SIZE) return -1; @@ -402,26 +395,27 @@ static inline int display_putc_nomark(char c) return c; } -int display_putc(char c) +/* + * Flush current symbol to the LED display hardware + */ +static inline void display_flush(void) { - /* Mark the codes from the "display" command with the DP LED */ - display_set(DISPLAY_MARK); - return display_putc_nomark(c); + u32 val = display_buf[display_out_pos]; + + val |= (val << 8) | (val << 16) | (val << 24); + out_be32((void *)CONFIG_SYS_DISP_CHR_RAM, val); } /* - * Output content of the software display buffer to the LED display every 0.5s + * 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 +429,62 @@ 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_putc(buf[0]); + display_putc(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