Commit f5e21870 authored by Alessandro Rubini's avatar Alessandro Rubini

lib/ppsi-wrappers.c: new file, code from ptp-noposix wrappers

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent adaa65e4
......@@ -81,6 +81,7 @@ cflags-$(CONFIG_PPSI) += \
obj-$(CONFIG_PPSI) += wrc_ptp_ppsi.o \
monitor/monitor_ppsi.o \
lib/ppsi-wrappers.o \
$(PPSI)/ppsi.o \
$(PPSI)/arch-spec/libarch.a
......
#include <stdint.h>
#include <hal_exports.h>
#include <wrc_ptp.h>
#include <syscon.h>
#include <endpoint.h>
#include <softpll_ng.h>
/* Following code from ptp-noposix/libposix/freestanding-wrapper.c */
uint64_t ptpd_netif_get_msec_tics(void)
{
return timer_get_tics();
}
static int read_phase_val(hexp_port_state_t *state)
{
int32_t dmtd_phase;
if(spll_read_ptracker(0, &dmtd_phase, NULL))
{
state->phase_val = dmtd_phase;
state->phase_val_valid = 1;
}
else
{
state->phase_val = 0;
state->phase_val_valid = 0;
}
return 0;
}
extern int32_t cal_phase_transition;
extern int32_t sfp_alpha;
int halexp_get_port_state(hexp_port_state_t *state, const char *port_name)
{
state->valid = 1;
if(wrc_ptp_get_mode()==WRC_MODE_SLAVE)
state->mode = HEXP_PORT_MODE_WR_SLAVE;
else
state->mode = HEXP_PORT_MODE_WR_MASTER;
ep_get_deltas( &state->delta_tx, &state->delta_rx);
read_phase_val(state);
state->up = ep_link_up(NULL);
state->tx_calibrated = 1;
state->rx_calibrated = 1;
state->is_locked = spll_check_lock(0);
state->lock_priority = 0;
spll_get_phase_shift(0, NULL, (int32_t *)&state->phase_setpoint);
state->clock_period = 8000;
state->t2_phase_transition = cal_phase_transition;
state->t4_phase_transition = cal_phase_transition;
get_mac_addr(state->hw_addr);
state->hw_index = 0;
state->fiber_fix_alpha = sfp_alpha;
return 0;
}
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