summaryrefslogtreecommitdiffstats
path: root/cf-fsi-test.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2018-06-11 18:27:44 +1000
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2018-06-11 20:29:47 +1000
commit2afecf01ee2e948176124f917b5c000fdf95c41b (patch)
tree86f1e753bd9e3c10d7676fdfb5e9d8828ca04863 /cf-fsi-test.c
parent28f10b0fd0f638662f88a221d81e7e8e8c40e5c0 (diff)
downloadcf-fsi-2afecf01ee2e948176124f917b5c000fdf95c41b.tar.gz
cf-fsi-2afecf01ee2e948176124f917b5c000fdf95c41b.zip
Rework interfaces
We now use a portion of the ucode itself for version information and to configure the base of SRAM, this will allow the driver to use a pool allocator with less constraints. We put the status register as part of the command register, this speeds things up a bit and remove the need to clear it from the host. We also turn some SRAM stores from byte to long stores, they seem to be faster (still room for improvement) Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'cf-fsi-test.c')
-rw-r--r--cf-fsi-test.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/cf-fsi-test.c b/cf-fsi-test.c
index ef9435b..bf209f3 100644
--- a/cf-fsi-test.c
+++ b/cf-fsi-test.c
@@ -222,12 +222,26 @@ static void start_cf(void)
static void load_cf_code(void)
{
extern uint8_t cf_code_start, cf_code_end;
+ uint16_t sig, fw_vers, api_vers;
+ uint32_t fw_options;
uint8_t *code = &cf_code_start;
uint8_t *mem = cfmem;
while(code < &cf_code_end)
writeb(*(code++), mem++);
+
+ sig = ntohs(readw(cfmem + HDR_OFFSET + HDR_SYS_SIG));
+ fw_vers = ntohs(readw(cfmem + HDR_OFFSET + HDR_FW_VERS));
+ api_vers = ntohs(readw(cfmem + HDR_OFFSET + HDR_API_VERS));
+ fw_options = ntohl(readl(cfmem + HDR_OFFSET + HDR_FW_OPTIONS));
+
+ trace_enabled = !!(fw_options & FW_OPTION_TRACE_EN);
+
+ printf("SYS_SIG=%.4x FW_VERSION=%d API_VERSION=%d.%d (trace %s)\n",
+ sig, fw_vers, api_vers >> 8, api_vers & 0xff,
+ trace_enabled ? "enabled" : "disabled");
+
}
static void gpio_source_arm(void)
@@ -544,9 +558,8 @@ static void dump_stuff(void)
{
int i;
- printf("CMD:%08x STAT:%02x RTAG=%02x RCRC=%02x RDATA=%02x #INT=%08x\n",
- ntohl(readl(sysreg + SRAM_BASE + CMD_REG)),
- readb(sysreg + SRAM_BASE + STAT_REG),
+ printf("CMD:%08x RTAG=%02x RCRC=%02x RDATA=%02x #INT=%08x\n",
+ ntohl(readl(sysreg + SRAM_BASE + CMD_STAT_REG)),
readb(sysreg + SRAM_BASE + STAT_RTAG),
readb(sysreg + SRAM_BASE + STAT_RCRC),
ntohl(readl(sysreg + SRAM_BASE + RSP_DATA)),
@@ -564,11 +577,8 @@ static int do_command(uint32_t op)
uint32_t timeout = 100000;
uint8_t stat;
- /* Clear status reg */
- writeb(0, sysreg + SRAM_BASE + STAT_REG);
-
/* Send command */
- writel(htonl(op), sysreg + SRAM_BASE + CMD_REG);
+ writel(htonl(op), sysreg + SRAM_BASE + CMD_STAT_REG);
/* Ring doorbell */
writel(0x2, sysreg + CVIC_BASE + CVIC_TRIG_REG);
@@ -581,7 +591,7 @@ static int do_command(uint32_t op)
dump_stuff();
return -ETIMEDOUT;
}
- stat = readb(sysreg + SRAM_BASE + STAT_REG);
+ stat = readb(sysreg + SRAM_BASE + CMD_STAT_REG);
} while(stat < STAT_COMPLETE || stat == 0xff);
if (stat == STAT_COMPLETE)
@@ -738,19 +748,11 @@ int main(int argc, char *argv[])
/* Start ColdFire */
start_cf();
- /* Wait for ack API version register*/
+ /* Wait for status register to say command complete */
do {
- val = readb(sysreg + SRAM_BASE + API_VERS_REG);
+ val = readb(sysreg + SRAM_BASE + CMD_STAT_REG);
} while (val == 0x00);
- 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);
writeb(16, sysreg + SRAM_BASE + SEND_DLY_REG);
OpenPOWER on IntegriCloud