Commit c24326a8 authored by Alessandro Rubini's avatar Alessandro Rubini

general: remove TRACE_DEV (and shrink binary)

This removes TRACE_DEV(), turning it into pll_verbose() and wrc_verbose().

The functions are enabled and disabled by kconfig, with defaults matching
the previous behaviour.

So nothing changes, but the binary is smaller because the previous
wrc_debug_printf() was silent because of a run-time conditional
(though hardwired false at build time). The condional is now at build
time.  We save around 2k, between strings and calling code, in
all wrc builds (nothing is saved in wrs, which is verbose by default,
nor in devel_build_test_defconfig where all verbose options are on)).
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>

devel_build_test_defconfig: enable all verbose options
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 560f32f3
......@@ -26,6 +26,15 @@ config RAMSIZE
default 65536 if WR_SWITCH
default 131072
config PLL_VERBOSE
boolean
default y if WR_SWITCH
config WRC_VERBOSE
boolean
default y if WR_SWITCH
# CONFIG_WR_SWITCH has no further options at all at this point
config WR_NODE_PCS16
......@@ -237,6 +246,22 @@ config NET_VERBOSE
This is mainly a debug tool, to be left off unless you hack
in the network subsystem.
config PLL_VERBOSE
depends on DEVELOPER
boolean "Verbose messages in softpll"
help
The softpll is usually silent in WR node and verbose in WR
switch. You can enable pll messages in WR node for debugging.
config WRC_VERBOSE
depends on DEVELOPER
boolean "More verbose messages in wr core"
default y if WR_SWITCH
help
This enables some more diagnostic messages. Normally off.
config SDB_STORAGE
depends on WR_NODE
default y
......
......@@ -6,6 +6,8 @@ CONFIG_WR_NODE=y
CONFIG_PRINT_BUFSIZE=128
# CONFIG_PRINTF_XINT is not set
CONFIG_RAMSIZE=131072
CONFIG_PLL_VERBOSE=y
CONFIG_WRC_VERBOSE=y
# CONFIG_WR_NODE_PCS16 is not set
CONFIG_STACKSIZE=2048
CONFIG_PPSI=y
......
......@@ -361,7 +361,7 @@ int minic_tx_frame(uint8_t * hdr, uint8_t * payload, uint32_t size,
fid = MINIC_TSR0_FID_R(minic_readl(MINIC_REG_TSR0));
if (fid != WRPC_FID) {
TRACE_DEV("minic_tx_frame: unmatched fid %d vs %d\n",
wrc_verbose("minic_tx_frame: unmatched fid %d vs %d\n",
fid, WRPC_FID);
}
......@@ -376,7 +376,7 @@ int minic_tx_frame(uint8_t * hdr, uint8_t * payload, uint32_t size,
hwts->ahead = 0;
hwts->nsec = counter_r * (REF_CLOCK_PERIOD_PS / 1000);
// TRACE_DEV("minic_tx_frame [%d bytes] TS: %d.%d valid %d\n", size, hwts->utc, hwts->nsec, hwts->valid);
// wrc_verbose("minic_tx_frame [%d bytes] TS: %d.%d valid %d\n", size, hwts->utc, hwts->nsec, hwts->valid);
minic.tx_count++;
}
......
......@@ -45,7 +45,7 @@ void shw_pps_gen_init()
/* Adjusts the nanosecond (refclk cycle) counter by atomically adding (how_much) cycles. */
int shw_pps_gen_adjust(int counter, int64_t how_much)
{
TRACE_DEV("Adjust: counter = %s [%c%d]\n",
wrc_verbose("Adjust: counter = %s [%c%d]\n",
counter == PPSG_ADJUST_SEC ? "seconds" : "nanoseconds",
how_much < 0 ? '-' : '+', (int32_t) abs(how_much));
......
......@@ -149,7 +149,7 @@ int rxts_calibration_update(uint32_t *t24p_value)
if (cal_cur_phase >= CAL_SCAN_RANGE) {
if (det_rising.state != TD_DONE || det_falling.state != TD_DONE)
{
TRACE_DEV("RXTS calibration error.\n");
wrc_verbose("RXTS calibration error.\n");
return -1;
}
......@@ -172,7 +172,7 @@ int rxts_calibration_update(uint32_t *t24p_value)
if(ttrans >= REF_CLOCK_PERIOD_PS) ttrans -= REF_CLOCK_PERIOD_PS;
TRACE_DEV("RXTS calibration: R@%dps, F@%dps, transition@%dps\n",
wrc_verbose("RXTS calibration: R@%dps, F@%dps, transition@%dps\n",
det_rising.trans_phase, det_falling.trans_phase,
ttrans);
......
......@@ -7,16 +7,23 @@
#define NET_IS_VERBOSE 0
#endif
#ifdef CONFIG_WR_NODE
#include <wrc.h>
#ifdef CONFIG_PLL_VERBOSE
#define PLL_IS_VERBOSE 1
#else
#define PLL_IS_VERBOSE 0
#endif
#define TRACE_DEV(...) wrc_debug_printf(0, __VA_ARGS__)
#ifdef CONFIG_WRC_VERBOSE
#define WRC_IS_VERBOSE 1
#else
#define WRC_IS_VERBOSE 0
#endif
#else /* WR_SWITCH */
#define pll_verbose(...) \
({if (PLL_IS_VERBOSE) __debug_printf(__VA_ARGS__);})
#include <pp-printf.h>
#define TRACE_DEV(...) pp_printf(__VA_ARGS__)
#define wrc_verbose(...) \
({if (WRC_IS_VERBOSE) __debug_printf(__VA_ARGS__);})
#endif /* node/switch */
#endif
#endif /* __FREESTANDING_TRACE_H__ */
......@@ -21,9 +21,11 @@ char *format_time(uint64_t sec);
/* Color printf() variant. */
void cprintf(int color, const char *fmt, ...);
/* Color printf() variant, sets curspor position to (row, col) before printing. */
/* Color printf() variant, sets curspor position to (row, col) too. */
void pcprintf(int row, int col, int color, const char *fmt, ...);
void __debug_printf(const char *fmt, ...);
/* Clears the terminal scree. */
void term_clear(void);
......
......@@ -37,7 +37,6 @@
void wrc_mon_gui(void);
void shell_init(void);
int wrc_log_stats(void);
void wrc_debug_printf(int subsys, const char *fmt, ...);
/* This header is included by softpll: manage wrc/wrs difference */
#ifdef CONFIG_WR_NODE
......
......@@ -97,6 +97,15 @@ void pcprintf(int row, int col, int color, const char *fmt, ...)
pp_printf("\e[m");
}
void __debug_printf(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
}
void term_clear(void)
{
pp_printf("\e[2J\e[1;1H");
......
......@@ -346,12 +346,12 @@ void spll_init(int mode, int slave_ref_channel, int align_pps)
s->ext.main = &s->mpll;
external_init(&s->ext, spll_n_chan_ref + spll_n_chan_out, align_pps);
} else {
TRACE_DEV("softpll: attempting to enable GM mode on non-GM hardware.\n");
pll_verbose("softpll: attempting to enable GM mode on non-GM hardware.\n");
return;
}
}
TRACE_DEV
pll_verbose
("softpll: mode %s, %d ref channels, %d out channels\n",
modes[mode], spll_n_chan_ref, spll_n_chan_out);
......@@ -380,7 +380,7 @@ void spll_start_channel(int channel)
struct softpll_state *s = (struct softpll_state *) &softpll;
if (s->seq_state != SEQ_READY || !channel) {
TRACE_DEV("Can't start channel %d, the PLL is not ready\n",
pll_verbose("Can't start channel %d, the PLL is not ready\n",
channel);
return;
}
......@@ -501,13 +501,13 @@ void spll_enable_ptracker(int ref_channel, int enable)
ptracker_start((struct spll_ptracker_state *)&softpll.
ptrackers[ref_channel]);
ptracker_mask |= (1 << ref_channel);
TRACE_DEV("Enabling ptracker channel: %d\n", ref_channel);
pll_verbose("Enabling ptracker channel: %d\n", ref_channel);
} else {
ptracker_mask &= ~(1 << ref_channel);
if (ref_channel != softpll.mpll.id_ref)
spll_enable_tagger(ref_channel, 0);
TRACE_DEV("Disabling ptracker tagger: %d\n", ref_channel);
pll_verbose("Disabling ptracker tagger: %d\n", ref_channel);
}
}
......@@ -541,7 +541,7 @@ static int spll_update_aux_clocks(void)
if(s->seq_state != AUX_DISABLED && !aux_locking_enabled(ch))
{
TRACE_DEV("softpll: disabled aux channel %d\n", ch);
pll_verbose("softpll: disabled aux channel %d\n", ch);
spll_stop_channel(ch);
aux_set_channel_status(ch, 0);
s->seq_state = AUX_DISABLED;
......@@ -550,7 +550,7 @@ static int spll_update_aux_clocks(void)
switch (s->seq_state) {
case AUX_DISABLED:
if (softpll.mpll.ld.locked && aux_locking_enabled(ch)) {
TRACE_DEV("softpll: enabled aux channel %d\n", ch);
pll_verbose("softpll: enabled aux channel %d\n", ch);
spll_start_channel(ch);
s->seq_state = AUX_LOCK_PLL;
}
......@@ -558,7 +558,7 @@ static int spll_update_aux_clocks(void)
case AUX_LOCK_PLL:
if (s->pll.dmtd.ld.locked) {
TRACE_DEV ("softpll: channel %d locked [aligning @ %d ps]\n", ch, softpll.mpll_shift_ps);
pll_verbose ("softpll: channel %d locked [aligning @ %d ps]\n", ch, softpll.mpll_shift_ps);
set_phase_shift(ch, softpll.mpll_shift_ps);
s->seq_state = AUX_ALIGN_PHASE;
}
......@@ -567,7 +567,7 @@ static int spll_update_aux_clocks(void)
case AUX_ALIGN_PHASE:
if (!mpll_shifter_busy(&s->pll.dmtd)) {
TRACE_DEV("softpll: channel %d phase aligned\n", ch);
pll_verbose("softpll: channel %d phase aligned\n", ch);
aux_set_channel_status(ch, 1);
s->seq_state = AUX_READY;
}
......@@ -575,7 +575,7 @@ static int spll_update_aux_clocks(void)
case AUX_READY:
if (!softpll.mpll.ld.locked || !s->pll.dmtd.ld.locked) {
TRACE_DEV("softpll: aux channel %d or mpll lost lock\n", ch);
pll_verbose("softpll: aux channel %d or mpll lost lock\n", ch);
aux_set_channel_status(ch, 0);
s->seq_state = AUX_DISABLED;
}
......@@ -703,20 +703,20 @@ void check_vco_frequencies()
disable_irq();
int f_min, f_max;
TRACE_DEV("SoftPLL VCO Frequency/APR test:\n");
pll_verbose("SoftPLL VCO Frequency/APR test:\n");
spll_set_dac(-1, 0);
f_min = spll_measure_frequency(SPLL_OSC_DMTD);
spll_set_dac(-1, 65535);
f_max = spll_measure_frequency(SPLL_OSC_DMTD);
TRACE_DEV("DMTD VCO: Low=%d Hz Hi=%d Hz, APR = %d ppm.\n", f_min, f_max, calc_apr(f_min, f_max, 62500000));
pll_verbose("DMTD VCO: Low=%d Hz Hi=%d Hz, APR = %d ppm.\n", f_min, f_max, calc_apr(f_min, f_max, 62500000));
spll_set_dac(0, 0);
f_min = spll_measure_frequency(SPLL_OSC_REF);
spll_set_dac(0, 65535);
f_max = spll_measure_frequency(SPLL_OSC_REF);
TRACE_DEV("REF VCO: Low=%d Hz Hi=%d Hz, APR = %d ppm.\n", f_min, f_max, calc_apr(f_min, f_max, REF_CLOCK_FREQ_HZ));
pll_verbose("REF VCO: Low=%d Hz Hi=%d Hz, APR = %d ppm.\n", f_min, f_max, calc_apr(f_min, f_max, REF_CLOCK_FREQ_HZ));
f_min = spll_measure_frequency(SPLL_OSC_EXT);
TRACE_DEV("EXT clock: Freq=%d Hz\n", f_min);
pll_verbose("EXT clock: Freq=%d Hz\n", f_min);
}
......@@ -126,7 +126,7 @@ Channels (spll_n_chan_ref ... spll_n_chan_out + spll_n_chan_ref-1) are the outpu
void spll_enable_tagger(int channel, int enable)
{
TRACE_DEV("EnableTagger %d %d\n", channel, enable);
pll_verbose("EnableTagger %d %d\n", channel, enable);
if (channel >= spll_n_chan_ref) { /* Output channel? */
if (enable)
SPLL->OCER |= 1 << (channel - spll_n_chan_ref);
......@@ -139,7 +139,7 @@ void spll_enable_tagger(int channel, int enable)
SPLL->RCER &= ~(1 << channel);
}
TRACE_DEV("%s: ch %d, OCER 0x%x, RCER 0x%x\n", __FUNCTION__, channel, SPLL->OCER, SPLL->RCER);
pll_verbose("%s: ch %d, OCER 0x%x, RCER 0x%x\n", __FUNCTION__, channel, SPLL->OCER, SPLL->RCER);
}
void biquad_init(spll_biquad_t *bq, const int *coefs, int shift)
......
......@@ -133,7 +133,7 @@ void external_align_fsm(volatile struct spll_external_state *s)
PPSG->ADJ_NSEC = 3;
PPSG->ESCR = PPSG_ESCR_SYNC;
s->align_state = ALIGN_STATE_INIT_CSYNC;
TRACE_DEV("EXT: DMTD locked.\n");
pll_verbose("EXT: DMTD locked.\n");
}
break;
......@@ -149,7 +149,7 @@ void external_align_fsm(volatile struct spll_external_state *s)
if(time_after_eq(timer_get_tics(), s->align_timer)) {
s->align_state = ALIGN_STATE_START_ALIGNMENT;
s->align_shift = 0;
TRACE_DEV("EXT: CSync complete.\n");
pll_verbose("EXT: CSync complete.\n");
}
break;
......@@ -164,7 +164,7 @@ void external_align_fsm(volatile struct spll_external_state *s)
s->align_step = 100;
}
TRACE_DEV("EXT: Align target %d, step %d.\n", s->align_target, s->align_step);
pll_verbose("EXT: Align target %d, step %d.\n", s->align_target, s->align_step);
s->align_state = ALIGN_STATE_WAIT_SAMPLE;
}
break;
......@@ -185,7 +185,7 @@ void external_align_fsm(volatile struct spll_external_state *s)
case ALIGN_STATE_COMPENSATE_DELAY:
if(!mpll_shifter_busy(s->main)) {
TRACE_DEV("EXT: Align done.\n");
pll_verbose("EXT: Align done.\n");
s->align_state = ALIGN_STATE_LOCKED;
}
break;
......
......@@ -48,7 +48,7 @@ void mpll_init(struct spll_main_state *s, int id_ref,
s->id_out = id_out;
s->dac_index = id_out - spll_n_chan_ref;
TRACE_DEV("ref %d out %d idx %x \n", s->id_ref, s->id_out, s->dac_index);
pll_verbose("ref %d out %d idx %x \n", s->id_ref, s->id_out, s->dac_index);
pi_init((spll_pi_t *)&s->pi);
ld_init((spll_lock_det_t *)&s->ld);
......@@ -56,7 +56,7 @@ void mpll_init(struct spll_main_state *s, int id_ref,
void mpll_start(struct spll_main_state *s)
{
TRACE_DEV("MPLL_Start [dac %d]\n", s->dac_index);
pll_verbose("MPLL_Start [dac %d]\n", s->dac_index);
s->adder_ref = s->adder_out = 0;
s->tag_ref = -1;
......
......@@ -108,11 +108,11 @@ static int wrc_check_link(void)
int rv = 0;
if (!prev_link_state && link_state) {
TRACE_DEV("Link up.\n");
wrc_verbose("Link up.\n");
gpio_out(GPIO_LED_LINK, 1);
rv = LINK_WENT_UP;
} else if (prev_link_state && !link_state) {
TRACE_DEV("Link down.\n");
wrc_verbose("Link down.\n");
gpio_out(GPIO_LED_LINK, 0);
rv = LINK_WENT_DOWN;
} else
......@@ -122,21 +122,6 @@ static int wrc_check_link(void)
return rv;
}
void wrc_debug_printf(int subsys, const char *fmt, ...)
{
va_list ap;
if (wrc_ui_mode)
return;
va_start(ap, fmt);
if (subsys & (1 << 5) /* was: TRACE_SERVO -- see commit message */)
vprintf(fmt, ap);
va_end(ap);
}
int wrc_man_phase = 0;
static void ui_update(void)
......
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