Commit 27066e77 authored by Alessandro Rubini's avatar Alessandro Rubini

shell low-level commands, and use 0 as default delays

This adds two commands: devemem (to read and write registers/RAM)
and delays (to read and change the constant delays.  The commands are
only available for CONFIG_DEVELOPER builds.

The default delays were just wrong, they are valid of an older
gateware version.  Using 0, it is clearer to the user that the right
value is missing (if the SFP database is populated, the right value
applies anyways).
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 9491e61b
......@@ -127,6 +127,16 @@ config PRINT_BUFSIZE
also constraints the maximum lenght of text that can be written
in a single call to printf.
config CMD_LL
depends on DEVELOPER && WR_NODE
bool "Build low-level commands for development/testing"
help
This enables low-level commands: "devmem" to read/write memory
and "delays" to read/write the constant delays in this device.
Please note that the delays have no immediate effect when set
on the master, because they are just sent to the slave
during the initial handshake
# CHECK_RESET for switch and node
config CHECK_RESET
depends on DEVELOPER
......
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2013 CERN (www.cern.ch)
* Author: Alessandro Rubini <rubini@gnudd.com>
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#include <wrc.h>
#include <shell.h>
#include <storage.h>
#include <endpoint.h>
#include <ppsi/ppsi.h>
#include "wr-api.h"
static int cmd_devmem(const char *args[])
{
uint32_t *addr, value;
if (!args[0]) {
pp_printf("devmem: use: \"devmem <address> [<value>]\"\n");
return 0;
}
fromhex(args[0], (void *)&addr);
if (args[1]) {
fromhex(args[1], (void *)&value);
*addr = value;
} else {
pp_printf("%08x = %08x\n", (int)addr, *addr);
}
return 0;
}
DEFINE_WRC_COMMAND(devmem) = {
.name = "devmem",
.exec = cmd_devmem,
};
extern struct pp_instance ppi_static;
static int cmd_delays(const char *args[])
{
int tx, rx;
struct wr_data *wrp = (void *)(ppi_static.ext_data);
struct wr_servo_state *s = &wrp->servo_state;
if (args[0] && !args[1]) {
pp_printf("delays: use: \"delays [<txdelay> <rxdelay>]\"\n");
return 0;
}
if (args[1]) {
fromdec(args[0], &tx);
fromdec(args[1], &rx);
sfp_deltaTx = tx;
sfp_deltaRx = rx;
/* Change the active value too (add bislide here) */
s->delta_tx_m = tx;
s->delta_rx_m = rx + ep_get_bitslide();
} else {
pp_printf("tx: %i rx: %i\n", sfp_deltaTx, sfp_deltaRx);
}
return 0;
}
DEFINE_WRC_COMMAND(delays) = {
.name = "delays",
.exec = cmd_delays,
};
......@@ -20,3 +20,4 @@ obj-$(CONFIG_ETHERBONE) += shell/cmd_ip.o
obj-$(CONFIG_PPSI) += shell/cmd_verbose.o
obj-$(CONFIG_CMD_CONFIG) += shell/cmd_config.o
obj-$(CONFIG_CMD_SLEEP) += shell/cmd_sleep.o
obj-$(CONFIG_CMD_LL) += shell/cmd_ll.o
......@@ -40,8 +40,8 @@ int wrc_phase_tracking = 1;
///////////////////////////////////
//Calibration data (from EEPROM if available)
int32_t sfp_alpha = 73622176; //default values if could not read EEPROM
int32_t sfp_deltaTx = 46407;
int32_t sfp_deltaRx = 167843;
int32_t sfp_deltaTx = 0;
int32_t sfp_deltaRx = 0;
uint32_t cal_phase_transition = 2389;
static void wrc_initialize()
......
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