Commit e505a960 authored by Alessandro Rubini's avatar Alessandro Rubini

Merge branch 'wrpc-dump' into rubi-160120

parents c31bcc0b c06700d8
......@@ -146,6 +146,15 @@ config CHECK_RESET
detects that it is re-executed and dumps a stack trace; it
then clears the stack (for next time) and restarts again.
config SPLL_FIFO_LOG
depends on DEVELOPER
bool "Add a circular buffer for spll logging, used by tools/wrpc-dump"
help
This option addrs 256 bytes to the wrpc bynary, to log
the DDMTD tags read from the fifos, the interrupts and the
related timing. The information is shown by tools/wrpc-dump
if present, no change/rebuild of the tool is needed.
choice
prompt "Implementation of pp_printf"
depends on DEVELOPER && WR_NODE
......
......@@ -24,6 +24,7 @@ obj-$(CONFIG_WR_NODE) += wrc_main.o
obj-$(CONFIG_WR_SWITCH) += wrs_main.o
obj-$(CONFIG_WR_SWITCH) += ipc/minipc-mem-server.o ipc/rt_ipc.o
obj-y += dump-info.o
# our linker script is preprocessed, so have a rule here
%.ld: %.ld.S $(AUTOCONF) .config
$(CC) -include $(AUTOCONF) -E -P $*.ld.S -o $@
......@@ -37,12 +38,15 @@ cflags-$(CONFIG_PPSI) += \
-ffreestanding \
-include include/ppsi-wrappers.h \
-Iinclude \
-I$(PPSI)/include \
-I$(PPSI)/arch-wrpc \
-I$(PPSI)/arch-wrpc/include \
-I$(PPSI)/proto-ext-whiterabbit \
-Iboards/spec
# in order to build tools/wrpc-dump, we need these flags, even for wrs builds
cflags-y += \
-I$(PPSI)/arch-wrpc/include \
-I$(PPSI)/include
obj-ppsi = \
$(PPSI)/ppsi.o
......
This diff is collapsed.
......@@ -84,5 +84,9 @@ SECTIONS
/* First location in stack is highest address in RAM (stack area) */
PROVIDE(_fstack = ORIGIN(stack) + LENGTH(stack) - 4);
/* We have no ppi_static nor fifo_log in wrs builds */
PROVIDE(ppi_static = 0);
PROVIDE(fifo_log = 0);
}
......@@ -64,4 +64,7 @@ SECTIONS
/* First location in stack is highest address in STACK */
PROVIDE(_fstack = ORIGIN(stack) + LENGTH(stack) - 4);
/* This may be missing, according to .config */
PROVIDE(fifo_log = 0);
}
......@@ -931,6 +931,92 @@ promgen -w -spi -p mcs -c FF -s 32768 -u 0 <your_bitstream>.bit \
After that, you can use the Xilinx JTAG cable and Xilinx ISE Impact tool to
write your @i{output.mcs} file to the Flash memory.
@c ##########################################################################
@page
@node wrpc-dump
@appendix wrpc-dump
In December 2015, we added @t{tools/wrpc-dump}. The program accesses
a wrpc memory image (the 128k binary dump) and prints the internal
status of the program.
@c ==========================================================================
@node wrpc-dump with Current Code
@section wrpc-dump with Current Code
@t{wrpc-dump} uses some information that we included at offset 0x80
in the binary, to detect endianness conversions and to find the actual data.
Thus, it only needs to receive the name of the file, either an on-disk file
or the live PCI memory if available (for @i{spec} devices, it's resource 0 of
the PCI space).
@example
tools/wrpc-dump /tmp/logs/vetar-dump-42
tools/wrpc-dump /sys/bus/pci/devices/0000:02:00.0/resource0
@end example
If you built @i{wrpc-sw} with @t{CONFIG_SPLL_FIFO_LOG} (a
``developer'' configuration option), the dump includes the last 16
tags being accessed by @i{softpll}, in relation with interrupts and
timing. Please see @i{sofpll/softpll_ng::_irq_enter} for details.
@c ==========================================================================
@node wrpc-dump with Older WRPC Binaries
@section wrpc-dump with Older WRPC Binaries
The tool has another working mode, that you can use with older
@i{wrpc} builds, where the special table is missing (but please be
aware that the data structures may have changed slightly). In this
mode, you provide the address of the data structure and its name. It
supports the names @i{pll}, @i{fifo} (the circular log described
above), @i{ppg}, @i{ppi}, @i{servo_state}, and @i{ds}. The last name
refers to the PTP data sets, and for this the pointer needed is
@t{ppg} (ppsi global data).
This is an example:
@smallexample
$ ./tools/wrpc-dump dump-file 00015798 servo_state
servo_state at 0x15798
if_name: ""
flags: 1
state: 4
delta_tx_m: 10
delta_rx_m: 174410
delta_tx_s: 0
delta_rx_s: 3200
fiber_fix_alpha: 73622176
clock_period_ps: 8000
t1: correct 1: 1448628309.390213200:0000
t2: correct 1: 1448628309.390213520:2921
t3: correct 1: 1448628310.419072616:0000
t4: correct 1: 1448628310.419073104:6041
[...]
@end smallexample
The address is specified as a hex number, and can be retrieved running
``@t{lm32-elf-nm wrc.elf}''.
Please note that the @i{spec} device has a strange memory mapping, and
it needs a special endian conversion. With current @i{wrpc} it is
autodetected, but if you dump an older binary you'll need to set the
@t{WRPC_SPEC} environment variable (to any value you like) to properly
access the PCI memory or a dump taken from PCI:
@smallexample
$ export WRPC_SPEC=y
@end smallexample
or
@smallexample
$ WRPC_SPEC=y ./tools/wrpc-dump dump-file 00015798 servo_state
@end smallexample
This is not needed if the dump is retrieved using Etherbone.
@c ##########################################################################
@bye
......
#include <sys/types.h>
#include <ppsi/ppsi.h>
#include <softpll_ng.h>
#include "dump-info.h"
struct dump_info dump_info[] = {
/* map for fields of ppsi structures */
#undef DUMP_STRUCT
#define DUMP_STRUCT struct pp_globals
DUMP_HEADER("pp_globals"),
DUMP_FIELD(pointer, pp_instances), /* FIXME: follow this */
DUMP_FIELD(pointer, servo), /* FIXME: follow this */
DUMP_FIELD(pointer, rt_opts),
DUMP_FIELD(pointer, defaultDS),
DUMP_FIELD(pointer, currentDS),
DUMP_FIELD(pointer, parentDS),
DUMP_FIELD(pointer, timePropertiesDS),
DUMP_FIELD(int, ebest_idx),
DUMP_FIELD(int, ebest_updated),
DUMP_FIELD(int, nlinks),
DUMP_FIELD(int, max_links),
//DUMP_FIELD(struct pp_globals_cfg cfg),
DUMP_FIELD(int, rxdrop),
DUMP_FIELD(int, txdrop),
DUMP_FIELD(pointer, arch_data),
DUMP_FIELD(pointer, global_ext_data),
#undef DUMP_STRUCT
#define DUMP_STRUCT DSDefault /* Horrible typedef */
DUMP_HEADER("DSDefault"),
DUMP_FIELD(Boolean, twoStepFlag),
DUMP_FIELD(ClockIdentity, clockIdentity),
DUMP_FIELD(UInteger16, numberPorts),
DUMP_FIELD(ClockQuality, clockQuality),
DUMP_FIELD(UInteger8, priority1),
DUMP_FIELD(UInteger8, priority2),
DUMP_FIELD(UInteger8, domainNumber),
DUMP_FIELD(Boolean, slaveOnly),
#undef DUMP_STRUCT
#define DUMP_STRUCT DSCurrent /* Horrible typedef */
DUMP_HEADER("DSCurrent"),
DUMP_FIELD(UInteger16, stepsRemoved),
DUMP_FIELD(TimeInternal, offsetFromMaster),
DUMP_FIELD(TimeInternal, meanPathDelay), /* oneWayDelay */
DUMP_FIELD(UInteger16, primarySlavePortNumber),
#undef DUMP_STRUCT
#define DUMP_STRUCT DSParent /* Horrible typedef */
DUMP_HEADER("DSParent"),
DUMP_FIELD(PortIdentity, parentPortIdentity),
DUMP_FIELD(UInteger16, observedParentOffsetScaledLogVariance),
DUMP_FIELD(Integer32, observedParentClockPhaseChangeRate),
DUMP_FIELD(ClockIdentity, grandmasterIdentity),
DUMP_FIELD(ClockQuality, grandmasterClockQuality),
DUMP_FIELD(UInteger8, grandmasterPriority1),
DUMP_FIELD(UInteger8, grandmasterPriority2),
#undef DUMP_STRUCT
#define DUMP_STRUCT DSTimeProperties /* Horrible typedef */
DUMP_HEADER("DSTimeProperties"),
DUMP_FIELD(Integer16, currentUtcOffset),
DUMP_FIELD(Boolean, currentUtcOffsetValid),
DUMP_FIELD(Boolean, leap59),
DUMP_FIELD(Boolean, leap61),
DUMP_FIELD(Boolean, timeTraceable),
DUMP_FIELD(Boolean, frequencyTraceable),
DUMP_FIELD(Boolean, ptpTimescale),
DUMP_FIELD(Enumeration8, timeSource),
#undef DUMP_STRUCT
#define DUMP_STRUCT struct wr_servo_state
DUMP_HEADER("servo_state"),
DUMP_FIELD_SIZE(char, if_name, 16),
DUMP_FIELD(unsigned_long, flags),
DUMP_FIELD(int, state),
DUMP_FIELD(Integer32, delta_tx_m),
DUMP_FIELD(Integer32, delta_rx_m),
DUMP_FIELD(Integer32, delta_tx_s),
DUMP_FIELD(Integer32, delta_rx_s),
DUMP_FIELD(Integer32, fiber_fix_alpha),
DUMP_FIELD(Integer32, clock_period_ps),
DUMP_FIELD(TimeInternal, t1),
DUMP_FIELD(TimeInternal, t2),
DUMP_FIELD(TimeInternal, t3),
DUMP_FIELD(TimeInternal, t4),
DUMP_FIELD(Integer32, delta_ms_prev),
DUMP_FIELD(int, missed_iters),
DUMP_FIELD(TimeInternal, mu), /* half of the RTT */
DUMP_FIELD(Integer64, picos_mu),
DUMP_FIELD(Integer32, cur_setpoint),
DUMP_FIELD(Integer32, delta_ms),
DUMP_FIELD(UInteger32, update_count),
DUMP_FIELD(int, tracking_enabled),
DUMP_FIELD_SIZE(char, servo_state_name, 32),
DUMP_FIELD(Integer64, skew),
DUMP_FIELD(Integer64, offset),
DUMP_FIELD(UInteger32, n_err_state),
DUMP_FIELD(UInteger32, n_err_offset),
DUMP_FIELD(UInteger32, n_err_delta_rtt),
#undef DUMP_STRUCT
#define DUMP_STRUCT struct pp_instance
DUMP_HEADER("pp_instance"),
DUMP_FIELD(int, state),
DUMP_FIELD(int, next_state),
DUMP_FIELD(int, next_delay),
DUMP_FIELD(int, is_new_state),
DUMP_FIELD(pointer, arch_data),
DUMP_FIELD(pointer, ext_data),
DUMP_FIELD(unsigned_long, d_flags),
DUMP_FIELD(unsigned_char, flags),
DUMP_FIELD(unsigned_char, role),
DUMP_FIELD(unsigned_char, proto),
DUMP_FIELD(pointer, glbs),
DUMP_FIELD(pointer, n_ops),
DUMP_FIELD(pointer, t_ops),
DUMP_FIELD(pointer, __tx_buffer),
DUMP_FIELD(pointer, __rx_buffer),
DUMP_FIELD(pointer, tx_frame),
DUMP_FIELD(pointer, rx_frame),
DUMP_FIELD(pointer, tx_ptp),
DUMP_FIELD(pointer, rx_ptp),
/* This is a sub-structure */
DUMP_FIELD(int, ch[0].fd),
DUMP_FIELD(pointer, ch[0].custom),
DUMP_FIELD(pointer, ch[0].arch_data),
DUMP_FIELD_SIZE(bina, ch[0].addr, 6),
DUMP_FIELD(int, ch[0].pkt_present),
DUMP_FIELD(int, ch[1].fd),
DUMP_FIELD(pointer, ch[1].custom),
DUMP_FIELD(pointer, ch[1].arch_data),
DUMP_FIELD_SIZE(bina, ch[1].addr, 6),
DUMP_FIELD(int, ch[1].pkt_present),
DUMP_FIELD(ip_address, mcast_addr),
DUMP_FIELD(int, tx_offset),
DUMP_FIELD(int, rx_offset),
DUMP_FIELD_SIZE(bina, peer, 6),
DUMP_FIELD(uint16_t, peer_vid),
DUMP_FIELD(TimeInternal, t1),
DUMP_FIELD(TimeInternal, t2),
DUMP_FIELD(TimeInternal, t3),
DUMP_FIELD(TimeInternal, t4),
DUMP_FIELD(TimeInternal, cField),
DUMP_FIELD(TimeInternal, last_rcv_time),
DUMP_FIELD(TimeInternal, last_snt_time),
DUMP_FIELD(UInteger16, frgn_rec_num),
DUMP_FIELD(Integer16, frgn_rec_best),
//DUMP_FIELD(struct pp_frgn_master frgn_master[PP_NR_FOREIGN_RECORDS]),
DUMP_FIELD(pointer, portDS),
//DUMP_FIELD(unsigned long timeouts[__PP_TO_ARRAY_SIZE]),
DUMP_FIELD(UInteger16, recv_sync_sequence_id),
DUMP_FIELD(Integer8, log_min_delay_req_interval),
//DUMP_FIELD(UInteger16 sent_seq[__PP_NR_MESSAGES_TYPES]),
DUMP_FIELD_SIZE(bina, received_ptp_header, sizeof(MsgHeader)),
//DUMP_FIELD(pointer, iface_name),
//DUMP_FIELD(pointer, port_name),
DUMP_FIELD(int, port_idx),
DUMP_FIELD(int, vlans_array_len),
/* FIXME: array */
DUMP_FIELD(int, nvlans),
/* sub structure */
DUMP_FIELD_SIZE(char, cfg.port_name, 16),
DUMP_FIELD_SIZE(char, cfg.iface_name, 16),
DUMP_FIELD(int, cfg.ext),
DUMP_FIELD(int, cfg.ext),
DUMP_FIELD(unsigned_long, ptp_tx_count),
DUMP_FIELD(unsigned_long, ptp_rx_count),
#undef DUMP_STRUCT
#define DUMP_STRUCT struct softpll_state
DUMP_HEADER("softpll"),
DUMP_FIELD(int, mode),
DUMP_FIELD(int, seq_state),
DUMP_FIELD(int, dac_timeout),
DUMP_FIELD(int, default_dac_main),
DUMP_FIELD(int, delock_count),
DUMP_FIELD(uint32_t, irq_count),
DUMP_FIELD(int, mpll_shift_ps),
DUMP_FIELD(int, helper.p_adder),
DUMP_FIELD(int, helper.p_setpoint),
DUMP_FIELD(int, helper.tag_d0),
DUMP_FIELD(int, helper.ref_src),
DUMP_FIELD(int, helper.sample_n),
DUMP_FIELD(int, helper.delock_count),
/* FIXME: missing helper.pi etc.. */
DUMP_FIELD(int, ext.enabled),
DUMP_FIELD(int, ext.align_state),
DUMP_FIELD(int, ext.align_timer),
DUMP_FIELD(int, ext.align_target),
DUMP_FIELD(int, ext.align_step),
DUMP_FIELD(int, ext.align_shift),
DUMP_FIELD(int, mpll.state),
/* FIXME: mpll.pi etc */
DUMP_FIELD(int, mpll.adder_ref),
DUMP_FIELD(int, mpll.adder_out),
DUMP_FIELD(int, mpll.tag_ref),
DUMP_FIELD(int, mpll.tag_out),
DUMP_FIELD(int, mpll.tag_ref_d),
DUMP_FIELD(int, mpll.tag_out_d),
DUMP_FIELD(uint32_t, mpll.seq_ref),
DUMP_FIELD(int, mpll.seq_out),
DUMP_FIELD(int, mpll.match_state),
DUMP_FIELD(int, mpll.match_seq),
DUMP_FIELD(int, mpll.phase_shift_target),
DUMP_FIELD(int, mpll.phase_shift_current),
DUMP_FIELD(int, mpll.id_ref),
DUMP_FIELD(int, mpll.id_out),
DUMP_FIELD(int, mpll.sample_n),
DUMP_FIELD(int, mpll.delock_count),
DUMP_FIELD(int, mpll.dac_index),
DUMP_FIELD(int, mpll.enabled),
#undef DUMP_STRUCT
#define DUMP_STRUCT struct spll_fifo_log
DUMP_HEADER("pll_fifo"),
DUMP_FIELD(uint32_t, trr),
DUMP_FIELD(uint32_t, tstamp),
DUMP_FIELD(uint32_t, duration),
DUMP_FIELD(uint16_t, irq_count),
DUMP_FIELD(uint16_t, tag_count),
/* FIXME: aux_state and ptracker_state -- variable-len arrays */
DUMP_HEADER("end"),
};
/*
* This header defines structures for dumping other structures from
* binary files. Every arch has a different endianness and alignment/size,
* so we can't just use the structures from the host compiler. It used to
* work for lm32/i386, but it fails with x86-64, so let's change attitude.
*/
#include <stdint.h>
/*
* To ease copying from header files, allow int, char and other known types.
* Please add more type as more structures are included here
*/
enum dump_type {
dump_type_char, /* for zero-terminated strings */
dump_type_bina, /* for binary stull in MAC format */
/* normal types follow */
dump_type_uint32_t,
dump_type_uint16_t,
dump_type_int,
dump_type_unsigned_long,
dump_type_unsigned_char,
dump_type_unsigned_short,
dump_type_double,
dump_type_float,
dump_type_pointer,
/* and strange ones, from IEEE */
dump_type_UInteger64,
dump_type_Integer64,
dump_type_UInteger32,
dump_type_Integer32,
dump_type_UInteger16,
dump_type_Integer16,
dump_type_UInteger8,
dump_type_Integer8,
dump_type_Enumeration8,
dump_type_Boolean,
dump_type_ClockIdentity,
dump_type_PortIdentity,
dump_type_ClockQuality,
/* and this is ours */
dump_type_TimeInternal,
dump_type_ip_address,
};
/* because of the sizeof later on, we need these typedefs */
typedef void * pointer;
typedef unsigned long unsigned_long;
typedef unsigned char unsigned_char;
typedef unsigned short unsigned_short;
typedef struct {unsigned char addr[4];} ip_address;
/*
* This is generated with the target compiler, and then linked
* by the host compiler, so size and alignment must be safe. Then, the
* first structure in each group has the endian flag and the structure name.
* Following ones have zero in endian flag and field name.
*/
#define DUMP_ENDIAN_FLAG 0x12345678
struct dump_info {
uint32_t endian_flag;
uint32_t type;
uint32_t offset;
uint32_t size;
char name[48];
};
extern struct dump_info dump_info[]; /* wrpc-sw/dump-info.c -> bina -> elf */
#define DUMP_HEADER(_struct) { \
.endian_flag = DUMP_ENDIAN_FLAG, \
.name = _struct, \
}
/* The macros below rely on DUMP_STRUCT that must be externally defined */
#define DUMP_FIELD(_type, _fname) { \
.endian_flag = 0, \
.type = dump_type_ ## _type, \
.offset = offsetof(DUMP_STRUCT, _fname),\
.size = sizeof(_type), \
.name = #_fname, \
}
#define DUMP_FIELD_SIZE(_type, _fname, _size) { \
.endian_flag = 0, \
.type = dump_type_ ## _type, \
.offset = offsetof(DUMP_STRUCT, _fname),\
.size = _size, \
.name = #_fname, \
}
......@@ -21,26 +21,20 @@
#include "irq.h"
volatile int irq_count = 0;
#ifdef CONFIG_SPLL_FIFO_LOG
struct spll_fifo_log fifo_log[FIFO_LOG_LEN];
#define HAS_FIFO_LOG 1
#else
#define HAS_FIFO_LOG 0
extern struct spll_fifo_log *fifo_log;
#endif
volatile struct SPLL_WB *SPLL;
volatile struct PPSG_WB *PPSG;
int spll_n_chan_ref, spll_n_chan_out;
/*
* The includes below contain code (not only declarations) to enable
* the compiler to inline functions where necessary and save some CPU
* cycles
*/
#include "spll_defs.h"
#include "spll_common.h"
#include "spll_debug.h"
#include "spll_helper.h"
#include "spll_main.h"
#include "spll_ptracker.h"
#include "spll_external.h"
#define MAIN_CHANNEL (spll_n_chan_ref)
......@@ -60,30 +54,6 @@ int spll_n_chan_ref, spll_n_chan_out;
#define AUX_ALIGN_PHASE 3
#define AUX_READY 4
struct spll_aux_state {
int seq_state;
int32_t phase_target;
union {
struct spll_main_state dmtd;
/* spll_external_state ch_bb */
} pll;
};
struct softpll_state {
int mode;
int seq_state;
int dac_timeout;
int default_dac_main;
int delock_count;
int32_t mpll_shift_ps;
struct spll_helper_state helper;
struct spll_external_state ext;
struct spll_main_state mpll;
struct spll_aux_state aux[MAX_CHAN_AUX];
struct spll_ptracker_state ptrackers[MAX_PTRACKERS];
};
static const struct stringlist_entry seq_states [] =
{
{ SEQ_START_EXT, "start-ext" },
......@@ -99,7 +69,7 @@ static const struct stringlist_entry seq_states [] =
{ 0, NULL }
};
static volatile struct softpll_state softpll;
volatile struct softpll_state softpll;
static volatile int ptracker_mask = 0;
/* fixme: should be done by spll_init() but spll_init is called to
......@@ -265,19 +235,43 @@ static inline void update_loops(struct softpll_state *s, int tag_value, int tag_
void _irq_entry(void)
{
struct softpll_state *s = (struct softpll_state *)&softpll;
uint32_t trr;
int i, tag_source, tag_value;
static uint16_t tag_count;
struct spll_fifo_log *l = NULL;
uint32_t enter_stamp;
/* check if there are more tags in the FIFO */
if (HAS_FIFO_LOG)
enter_stamp = (PPSG->CNTR_NSEC & 0xfffffff);
/* check if there are more tags in the FIFO, and log them if so configured to */
while (!(SPLL->TRR_CSR & SPLL_TRR_CSR_EMPTY)) {
volatile uint32_t trr = SPLL->TRR_R0;
int tag_source = SPLL_TRR_R0_CHAN_ID_R(trr);
int tag_value = SPLL_TRR_R0_VALUE_R(trr);
trr = SPLL->TRR_R0;
if (HAS_FIFO_LOG) {
/* save this to a circular buffer */
i = tag_count % FIFO_LOG_LEN;
l = fifo_log + i;
l->tstamp = (PPSG->CNTR_NSEC & 0xfffffff);
if (!enter_stamp)
enter_stamp = l->tstamp;
l->duration = 0;
l->trr = trr;
l->irq_count = s->irq_count & 0xffff;
l->tag_count = tag_count++;
}
/* And process the values */
tag_source = SPLL_TRR_R0_CHAN_ID_R(trr);
tag_value = SPLL_TRR_R0_VALUE_R(trr);
sequencing_fsm(s, tag_value, tag_source);
update_loops(s, tag_value, tag_source);
}
irq_count++;
if (HAS_FIFO_LOG && l)
l->duration = (PPSG->CNTR_NSEC & 0xfffffff) - enter_stamp;
s->irq_count++;
clear_irq();
}
......@@ -481,13 +475,16 @@ void spll_get_num_channels(int *n_ref, int *n_out)
void spll_show_stats()
{
struct softpll_state *s = (struct softpll_state *)&softpll;
if (softpll.mode > 0)
pp_printf("softpll: irqs %d seq %s mode %d "
"alignment_state %d HL%d ML%d HY=%d MY=%d DelCnt=%d\n",
irq_count, stringlist_lookup(seq_states, softpll.seq_state), softpll.mode,
softpll.ext.align_state, softpll.helper.ld.locked, softpll.mpll.ld.locked,
softpll.helper.pi.y, softpll.mpll.pi.y,
softpll.delock_count);
s->irq_count, stringlist_lookup(seq_states, s->seq_state),
s->mode, s->ext.align_state,
s->helper.ld.locked, s->mpll.ld.locked,
s->helper.pi.y, s->mpll.pi.y,
s->delock_count);
}
int spll_shifter_busy(int channel)
......@@ -657,7 +654,7 @@ void spll_update()
if (is_wr_switch) {
stats.sequence++;
stats.mode = softpll.mode;
stats.irq_cnt = irq_count;
stats.irq_cnt = softpll.irq_count;
stats.seq_state = softpll.seq_state;
stats.align_state = softpll.ext.align_state;
stats.H_lock = softpll.helper.ld.locked;
......
......@@ -13,6 +13,14 @@
#define __SOFTPLL_NG_H
#include <stdint.h>
#include "spll_defs.h"
#include "spll_common.h"
#include "spll_debug.h"
#include "spll_helper.h"
#include "spll_main.h"
#include "spll_ptracker.h"
#include "spll_external.h"
/* SoftPLL operating modes, for mode parameter of spll_init(). */
......@@ -155,5 +163,45 @@ struct spll_stats {
/* This only exists in wr-switch, but we should use it always */
extern struct spll_stats stats;
/*
* Aux and main state:
* used to be in .c file, but we need it here for memory dumping
*/
struct spll_aux_state {
int seq_state;
int32_t phase_target;
union {
struct spll_main_state dmtd;
/* spll_external_state ch_bb */
} pll;
};
struct softpll_state {
int mode;
int seq_state;
int dac_timeout;
int default_dac_main;
int delock_count;
unsigned irq_count;
int32_t mpll_shift_ps;
struct spll_helper_state helper;
struct spll_external_state ext;
struct spll_main_state mpll;
struct spll_aux_state aux[MAX_CHAN_AUX];
struct spll_ptracker_state ptrackers[MAX_PTRACKERS];
};
struct spll_fifo_log {
uint32_t trr;
uint32_t tstamp;
uint32_t duration;
uint16_t irq_count;
uint16_t tag_count;
};
#define FIFO_LOG_LEN 16
#endif // __SOFTPLL_NG_H
......@@ -13,8 +13,7 @@
#include <string.h>
#include <pp-printf.h>
#include "trace.h"
#include "spll_defs.h"
#include "spll_common.h"
#include "softpll_ng.h"
int pi_update(spll_pi_t *pi, int x)
{
......
......@@ -12,15 +12,11 @@
#ifndef __SPLL_COMMON_H
#define __SPLL_COMMON_H
#include <stdint.h>
#include <stdlib.h>
#include <syscon.h>
#include <hw/softpll_regs.h>
#include <hw/pps_gen_regs.h>
#include "spll_defs.h"
#define SPLL_LOCKED 1
#define SPLL_LOCKING 0
......
......@@ -10,8 +10,7 @@
/* spll_external.h - implementation of SoftPLL servo for the
external (10 MHz - Grandmaster mode) reference channel */
#include "spll_external.h"
#include "spll_debug.h"
#include "softpll_ng.h"
#include <pp-printf.h>
#include "trace.h"
......
......@@ -13,9 +13,7 @@
#ifndef __SPLL_EXTERNAL_H
#define __SPLL_EXTERNAL_H