Commit a000ca6b authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

ertm14: skeleton code (untested) for SPLL debugger API

parent c26677fd
......@@ -198,6 +198,25 @@ struct ertm14_nco_reset {
uint32_t unused[7];
};
struct ertm14_spll_debug_dump_request
{
int enabled;
int undersample;
};
// Must be in sync with common-uart-link.h. I don't want to include it here to prevent dependency hell, but I'm aware
// I'm probably summoning other, hopefully less evil daemons by doing so.
#define ERTM14_SPLL_DEBUG_DUMP_MAX_PAYLOAD 512
#define ERTM14_SPLL_DEBUG_DUMP_OVERFLOW 0x80000000
#define ERTM14_SPLL_DEBUG_DUMP_HEADER 0x0000dead
struct ertm14_spll_debug_dump_data
{
uint32_t flags;
uint32_t payload[ ERTM14_SPLL_DEBUG_DUMP_MAX_PAYLOAD / sizeof(uint32_t) - 1 ];
};
/* FIXME: this is lifted from ertm_board_info; structs *must* match */
struct ertm14_device_metadata {
union {
......
......@@ -1181,6 +1181,56 @@ static void get_wrc_diags(struct wrc_diags *diags)
word[i] = htonl(word[i]);
}
static int spll_dbg_enabled = 0;
static int spll_dbg_oversample = 0;
static void configure_spll_debug_dump( int enabled, int oversample )
{
spll_dbg_enabled = enabled;
spll_dbg_oversample = oversample;
if( enabled )
spll_debug_queue_purge();
}
static void ertm14_spll_debug_dump_task_init(void)
{
spll_dbg_enabled = 0;
spll_dbg_oversample = 8;
}
static int ertm14_spll_debug_dump_task_poll(void)
{
struct uart_packet tx_pkt;
struct ertm14_spll_debug_dump_data *tx_payload;
int count = sizeof( *tx_payload ) / sizeof( uint32_t ) - 2;
if( !spll_dbg_enabled )
return 0;
int r = spll_get_debug_queue_samples( tx_payload->payload, &count, spll_dbg_oversample );
if( count <= 0 )
return 0;
tx_payload->flags = ERTM14_SPLL_DEBUG_DUMP_HEADER;
tx_pkt.ptype = ERTM14_UART_PTYPE_SNMP_RESP;
tx_pkt.length = sizeof( uint32_t ) * count + 4;
if( r == -ENOSPC )
tx_payload->flags |= ERTM14_SPLL_DEBUG_DUMP_OVERFLOW;
tx_payload->flags = host_to_be32( tx_payload->flags );
for( int i = 0; i < count; i ++ )
tx_payload->payload[i] = host_to_be32( tx_payload->payload[i] );
uart_link_send( &board.control_uart_link, &tx_pkt );
return 0;
}
static void get_streamers_diags(struct WR_STREAMERS_WB *diags)
{
memset( diags, 0, sizeof( struct WR_STREAMERS_WB ) );
......@@ -1356,12 +1406,18 @@ static int ertm_process_psnmp(struct uart_packet *rx_pkt, struct uart_packet *tx
streamer_diags = (struct WR_STREAMERS_WB *)&tx_pkt->payload[0];
get_streamers_diags(streamer_diags);
break;
case ertm14_reset_streamers_stats:
streamers_reset_rx_stats();
break;
case ertm14_force_measure_channels_power:
ertm15_force_rf_power_measurement();
break;
case ertm14_reset_streamers_stats:
streamers_reset_rx_stats();
break;
case ertm14_force_measure_channels_power:
ertm15_force_rf_power_measurement();
break;
case ertm14_configure_spll_debug_dump:
{
struct ertm14_spll_debug_dump_request *dbgs = (struct ertm14_spll_debug_dump_request *)&tx_pkt->payload[0];
configure_spll_debug_dump( dbgs->enabled, dbgs->undersample );
break;
}
case ertm14_get_wrc_nco:
nco = (struct ertm14_nco_reset *)&tx_pkt->payload[op->offset2];
get_wrc_nco(nco);
......@@ -3011,6 +3067,8 @@ int wrc_board_init()
wrc_task_create( "rf-monitor", ertm15_init_rf_monitor, ertm15_update_rf_monitor );
}
wrc_task_create( "spll-dbg", ertm14_spll_debug_dump_task_init, ertm14_spll_debug_dump_task_poll );
struct ertm14_board_state mask;
memset(&mask, 0xff, sizeof( struct ertm14_board_state )); // make sure we commit everything to HW
......
......@@ -22,6 +22,8 @@
#define ertm14_get_streamers_diags 0x23
#define ertm14_reset_streamers_stats 0x24
#define ertm14_force_measure_channels_power 0x25
#define ertm14_configure_spll_debug_dump 0x26
#define ertm14_spll_debug_data 0x27
static struct ertm14_protocol_op {
int8_t opcode;
......@@ -127,6 +129,13 @@ static struct ertm14_protocol_op {
.length1 = 1,
.offset2 = 0,
.length2 = 0,
},
{
.opcode = ertm14_configure_spll_debug_dump,
.offset1 = 1,
.length1 = sizeof(struct ertm14_spll_debug_dump_request),
.offset2 = 0,
.length2 = 0,
},
{
.opcode = -1,
......
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