Commit e5458a4b authored by Aurelio Colosimo's avatar Aurelio Colosimo Committed by Alessandro Rubini

arch-wrs: implemented all the missing functions still needed by WR

All the placeholders in wrs-time.c and wrs-calibration.c are here
filled with their proper implementation.

Note: some functions were already implemented in commit 19a203b4.
Signed-off-by: Aurelio Colosimo's avatarAurelio Colosimo <aurelio@aureliocolosimo.it>
parent beb71a16
......@@ -10,11 +10,35 @@
#include <hal_exports.h>
static int wrs_read_calibration_data(struct pp_instance *ppi,
uint32_t *deltaTx, uint32_t *deltaRx, int32_t *fix_alpha,
int32_t *clock_period)
uint32_t *delta_tx, uint32_t *delta_rx, int32_t *fix_alpha,
int32_t *clock_period)
{
/* FIXME wrs_read_calibration_data */
return 0;
hexp_port_state_t state;
minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_get_port_state,
&state, ppi->iface_name);
if(state.valid && state.tx_calibrated && state.rx_calibrated) {
pp_diag(ppi, servo, 1, "deltas: tx=%d, rx=%d)\n",
state.delta_tx ,state.delta_rx);
if(delta_tx)
*delta_tx = state.delta_tx;
if(delta_rx)
*delta_rx = state.delta_rx;
if(fix_alpha)
*fix_alpha = state.fiber_fix_alpha;
if(clock_period)
*clock_period = state.clock_period;
return WR_HW_CALIB_OK;
}
return WR_HW_CALIB_NOT_FOUND;
}
int wrs_calibrating_disable(struct pp_instance *ppi, int txrx)
......@@ -29,23 +53,26 @@ int wrs_calibrating_enable(struct pp_instance *ppi, int txrx)
int wrs_calibrating_poll(struct pp_instance *ppi, int txrx, uint32_t *delta)
{
/* FIXME wrpc_calibrating_poll */
return 0;
uint32_t delta_tx, delta_rx;
wrs_read_calibration_data(ppi, &delta_tx, &delta_rx, NULL, NULL);
*delta = (txrx == WR_HW_CALIB_TX) ? delta_tx : delta_rx;
return WR_HW_CALIB_READY;
}
int wrs_calibration_pattern_enable(struct pp_instance *ppi,
unsigned int calibrationPeriod,
unsigned int calibrationPattern,
unsigned int calibrationPatternLen)
unsigned int calib_period,
unsigned int calib_pattern,
unsigned int calib_pattern_len)
{
/* FIXME wrs_calibration_pattern_enable */
return 0;
return WR_HW_CALIB_OK;
}
int wrs_calibration_pattern_disable(struct pp_instance *ppi)
{
/* FIXME wrpc_calibration_pattern_disable */
return 0;
return WR_HW_CALIB_OK;
}
int wr_calibrating_disable(struct pp_instance *ppi, int txrx)
......
......@@ -70,32 +70,65 @@ int wrs_adjust_in_progress(void)
int wrs_enable_ptracker(struct pp_instance *ppi)
{
/* FIXME wrs_enable_ptracker */
return 0;
int ret, rval;
ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_lock_cmd,
&rval, ppi->iface_name, HEXP_LOCK_CMD_ENABLE_TRACKING, 0);
if ((ret < 0) || (rval < 0))
return WR_SPLL_ERROR;
return WR_SPLL_OK;
}
int wrs_enable_timing_output(struct pp_instance *ppi, int enable)
{
/* FIXME wrs_enable_timing_output */
return 0;
int ret, rval;
hexp_pps_params_t p;
p.pps_valid = enable;
ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_pps_cmd,
&rval, HEXP_PPSG_CMD_SET_VALID, &p);
if ((ret < 0) || (rval < 0))
return WR_SPLL_ERROR;
return WR_SPLL_OK;
}
int wrs_locking_disable(struct pp_instance *ppi)
{
/* FIXME wrs_locking_disable */
return 0;
return WR_SPLL_OK;
}
int wrs_locking_enable(struct pp_instance *ppi)
{
/* FIXME wrs_locking_enable */
return 0;
int ret, rval;
pp_diag(ppi, time, 1, "Start locking\n");
ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_lock_cmd,
&rval, ppi->iface_name, HEXP_LOCK_CMD_START, 0);
if ((ret < 0) || (rval < 0))
return WR_SPLL_ERROR;
return WR_SPLL_OK;
}
int wrs_locking_poll(struct pp_instance *ppi)
{
/* FIXME wrs_locking_poll */
return 0;
int ret, rval;
ret = minipc_call(hal_ch, DEFAULT_TO, &__rpcdef_lock_cmd,
&rval, ppi->iface_name, HEXP_LOCK_CMD_START, 0);
if (ret != HEXP_LOCK_STATUS_LOCKED)
return WR_SPLL_ERROR; /* FIXME should be WR_SPLL_NOT_READY */
return WR_SPLL_READY;
}
int wr_locking_enable(struct pp_instance *ppi)
......
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