Commit 3985cf77 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

adding diag shell command for reading/writing aux diag registers

parent 73631711
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2016 CERN (www.cern.ch)
* Author: Grzegorz Daniluk <grzegorz.daniluk@cern.ch>
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#include "shell.h"
#include <wrc.h>
#include <syscon.h>
#include <string.h>
#include <errno.h>
static int cmd_diag(const char *args[])
{
uint32_t id, ver, nrw, nro;
uint32_t addr, val;
int ret = 0;
if (!args[0]) {
diag_read_info(&id, &ver, &nrw, &nro);
pp_printf("Aux diagnostics info:\n");
pp_printf("id: %d.%d, r/w words: %d, r/o words: %d\n", id, ver,
nrw, nro);
return 0;
}
if (!strcasecmp(args[0], "ro") && args[1]) {
addr = atoi(args[1]);
ret = diag_read_word(addr, DIAG_RO_BANK, &val);
if (!ret)
pp_printf("Word %d is 0x%08x\n", addr, val);
return ret;
}
if (!strcasecmp(args[0], "rw") && args[1]) {
addr = atoi(args[1]);
ret = diag_read_word(addr, DIAG_RW_BANK, &val);
if (!ret)
pp_printf("Word %d is 0x%08x\n", addr, val);
return ret;
}
if (!strcasecmp(args[0], "w") && args[1] && args[2]) {
addr = atoi(args[1]);
val = atoi(args[2]);
ret = diag_write_word(addr, val);
if (!ret)
pp_printf("Value 0x%08x written to the word %d\n",
val, addr);
return ret;
}
return -EINVAL;
}
DEFINE_WRC_COMMAND(diag) = {
.name = "diag",
.exec = cmd_diag,
};
......@@ -17,6 +17,7 @@ obj-$(CONFIG_EMBEDDED_NODE) += \
shell/cmd_gui.o \
shell/cmd_sdb.o \
shell/cmd_ptrack.o \
shell/cmd_diag.o \
obj-$(CONFIG_IP) += shell/cmd_ip.o
obj-$(CONFIG_PPSI) += shell/cmd_verbose.o
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment