From de2c276d1329777b95f7a1d6dec6a0f7b111a991 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Sun, 3 Jun 2018 23:29:54 +1000 Subject: Cleanup starting up, add trace flags to API version Signed-off-by: Benjamin Herrenschmidt --- cf-code/cf-fsi-fw.S | 14 +++++++++++--- cf-fsi-fw.h | 30 ++++++++++++++++++------------ cf-fsi-test.c | 27 +++++++++++++++------------ 3 files changed, 44 insertions(+), 27 deletions(-) diff --git a/cf-code/cf-fsi-fw.S b/cf-code/cf-fsi-fw.S index 533cf39..abfea09 100644 --- a/cf-code/cf-fsi-fw.S +++ b/cf-code/cf-fsi-fw.S @@ -195,13 +195,21 @@ _start: /* Configure GPIOs to output */ bsr config_gpio_out + /* Clear arbitration register */ + move.b #0,%a1@(ARB_REG) + /* Populate version & signature */ move.w #SYS_SIG,%a1@(SYS_SIG_REG) move.b #FW_VERSION,%a1@(FW_VERS_REG) - move.b #API_VERSION,%a1@(API_VERS_REG) - /* Clear arbitration register */ - move.b #0,%a1@(ARB_REG) + /* This must happen last as it's the signal to the host + * that we are ready + */ +#ifdef ENABLE_TRACE + move.b #(API_VERSION + API_VERSION_TRACE_EN),%a1@(API_VERS_REG) +#else + move.b #API_VERSION,%a1@(API_VERS_REG) +#endif /* * Main command loop diff --git a/cf-fsi-fw.h b/cf-fsi-fw.h index 36df3c9..0cbcb20 100644 --- a/cf-fsi-fw.h +++ b/cf-fsi-fw.h @@ -60,7 +60,9 @@ #define API_VERS_REG 0x0f /* Current API version */ +#define API_VERSION_MASK 0x7f #define API_VERSION 1 +#define API_VERSION_TRACE_EN 0x80 /* Command data area * @@ -74,18 +76,6 @@ /* Misc */ #define INT_CNT 0x30 /* 32-bit interrupt count */ #define BAD_INT_VEC 0x34 -#define TRACEBUF 0x100 -#define TR_CLKOSTART 0x00 -#define TR_OLEN 0x01/* + len */ -#define TR_CLKOBIT0 0x02 -#define TR_CLKOBIT1 0x03 -#define TR_CLKZ 0x04 /* + count */ -#define TR_CLKWSTART 0x05 -#define TR_CLKTAG 0x06 /* + tag */ -#define TR_CLKDATA 0x07 /* + len */ -#define TR_CLKCRC 0x08 /* + raw crc */ -#define TR_CLKIBIT0 0x80 -#define TR_CLKIBIT1 0x81 /* * SRAM layout: GPIO arbitration part @@ -94,5 +84,21 @@ #define ARB_ARM_REQ 0x01 #define ARB_ARM_ACK 0x02 +/* + * SRAM layout: Trace buffer (debug builds only) + */ +#define TRACEBUF 0x100 +#define TR_CLKOBIT0 0x80 +#define TR_CLKOBIT1 0x81 +#define TR_CLKOSTART 0x82 +#define TR_OLEN 0x83/* + len */ +#define TR_CLKZ 0x84 /* + count */ +#define TR_CLKWSTART 0x85 +#define TR_CLKTAG 0x86 /* + tag */ +#define TR_CLKDATA 0x87 /* + len */ +#define TR_CLKCRC 0x88 /* + raw crc */ +#define TR_CLKIBIT0 0x90 +#define TR_CLKIBIT1 0x91 + #endif /* __CF_FSI_FW_H */ diff --git a/cf-fsi-test.c b/cf-fsi-test.c index 56e8a8f..059ce68 100644 --- a/cf-fsi-test.c +++ b/cf-fsi-test.c @@ -139,6 +139,7 @@ static void *cfmem; #define LAST_ADDR_INVALID 0x1 uint32_t g_last_addr; +bool trace_enabled; static void open_mem(void) { @@ -438,7 +439,7 @@ static void dump_stuff(void) ntohl(readl(sysreg + SRAM_BASE + RSP_DATA)), ntohl(readl(sysreg + SRAM_BASE + INT_CNT))); - for (i = 0; i < 128; i++) { + for (i = 0; trace_enabled && i < 128; i++) { printf("%02x ", readb(sysreg + SRAM_BASE + TRACEBUF + i)); if ((i % 16) == 15) printf("\n"); @@ -620,23 +621,25 @@ int main(int argc, char *argv[]) gpio_source_cf(); - /* Mark command invalid and clear sram */ - // writel(0xffffffff, sysreg + SRAM_BASE + CMD_REG); - memset(sysreg + SRAM_BASE, 0xff, 0x1000); + /* Clear SRAM */ + memset(sysreg + SRAM_BASE, 0x00, 0x1000); + dsb(); /* Start ColdFire */ start_cf(); - /* Wait for ack */ + /* Wait for ack API version register*/ do { - val = readb(sysreg + SRAM_BASE + STAT_REG); - } while (val != 0x80); - writeb(0, sysreg + SRAM_BASE + STAT_REG); + val = readb(sysreg + SRAM_BASE + API_VERS_REG); + } while (val == 0x00); - printf("CMD:%08x STAT:%02x INT: %08x\n", - ntohl(readl(sysreg + SRAM_BASE + CMD_REG)), - readb(sysreg + SRAM_BASE + STAT_REG), - ntohl(readl(sysreg + SRAM_BASE + INT_CNT))); + trace_enabled = !!(val & API_VERSION_TRACE_EN); + + printf("SYS_SIG=%.4x FW_VERSION=%d API_VERSION=%d (trace %s)\n", + ntohs(readw(sysreg + SRAM_BASE + SYS_SIG_REG)), + readb(sysreg + SRAM_BASE + FW_VERS_REG), + val & API_VERSION_MASK, + trace_enabled ? "enabled" : "disabled"); /* Configure echo & send delay */ writeb(16, sysreg + SRAM_BASE + ECHO_DLY_REG); -- cgit v1.2.1