Commit 8304358d authored by Tristan Gingold's avatar Tristan Gingold

Add 'ep' command (for debugging)

parent 4545a83c
......@@ -514,6 +514,13 @@ config FREQUENCY_MONITOR
Requires g_with_clock_freq_monitor to be enabled in the HDL
IP instantiation.
config CMD_EP
depends on WR_NODE
boolean "Add 'ep' command to diagnose endpoints"
default n
help
This enables ep command, which can be used to diagnose endpoint.
comment "wrpc-sw is tainted if you change the following options"
config DEVELOPER
depends on WR_NODE
......
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2024 CERN (www.cern.ch)
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <wrc.h>
#include "shell.h"
#include "dev/syscon.h"
#include "dev/endpoint.h"
#include "hw/ep_mdio_regs.h"
#include "hw/lpdc_mdio_regs.h"
struct reg_desc {
const char *name;
unsigned addr;
};
static const struct reg_desc regs[] = {
{ "msr", EP_MDIO_MSR },
{ "mcr", EP_MDIO_MCR },
{ "lpdc-ctrl", EP_MDIO_PHY_SPECIFIC_REGS + LPDC_MDIO_CTRL },
{ "lpdc-stat", EP_MDIO_PHY_SPECIFIC_REGS + LPDC_MDIO_STAT },
{ NULL, 0 }
};
static const char * const ep_cmds[] =
{
[0] = "link",
[1] = "rd",
};
static int cmd_ep(const char *args[])
{
struct wr_endpoint_device* dev = &wrc_endpoint_dev;
int icmd;
icmd = sub_cmd(ep_cmds, ARRAY_SIZE(ep_cmds), args);
switch (icmd) {
case 0:
pp_printf("%d\n", ep_link_up(dev, NULL));
return 0;
case 1:
{
const struct reg_desc *r;
for (r = regs; r->name; r++)
if (!strcmp(r->name, args[1]))
break;
if (r->name == NULL)
return -1;
pp_printf("%s (@%x): %04x\n",
r->name, r->addr, ep_pcs_read(dev, r->addr));
return 0;
}
default:
return -1;
}
}
DEFINE_WRC_COMMAND(ep) = {
.name = "ep",
.exec = cmd_ep,
};
......@@ -485,6 +485,9 @@ void shell_register_commands(void)
REGISTER_WRC_COMMAND(pll);
if (HAS_CMD_PPS)
REGISTER_WRC_COMMAND(pps);
#ifdef CONFIG_CMD_EP
REGISTER_WRC_COMMAND(ep);
#endif
REGISTER_WRC_COMMAND(ps);
REGISTER_WRC_COMMAND(ptp);
REGISTER_WRC_COMMAND(ptrack);
......
......@@ -27,7 +27,7 @@ obj-$(CONFIG_CMD_LL) += shell/cmd_ll.o
obj-$(CONFIG_CMD_PPS) += shell/cmd_pps.o
obj-$(CONFIG_CMD_LEAPSEC) += shell/cmd_leapsec.o
obj-$(CONFIG_CMD_REFRESH) += shell/cmd_refresh.o
obj-$(CONFIG_CMD_EP) += shell/cmd_ep.o
obj-$(CONFIG_FLASH_INIT) += shell/cmd_init.o
obj-$(CONFIG_VLAN) += shell/cmd_vlan.o
obj-$(CONFIG_FREQUENCY_MONITOR) += shell/cmd_freqmon.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