Commit 1980097a authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

userspce/wrsw_hal: share IPC structures with the RT CPU header, added ptracker…

userspce/wrsw_hal: share IPC structures with the RT CPU header, added ptracker enable/disable rts call and ptpd interface for it (HALEXP_LOCK_CMD_ENABLE_TRACKING)
parent 6da51eaf
......@@ -27,6 +27,10 @@ int halexp_lock_cmd(const char *port_name, int command, int priority)
switch(command)
{
case HEXP_LOCK_CMD_ENABLE_TRACKING:
return hal_enable_tracking(port_name);
/* Start locking - i.e. tell the HAL locking state machine to use the port (port_name) as the source of the reference
frequency. (priority) parameter allows to distinguish between various reference sources and establish
a switchover order. For example when wr0, wr1, wr2 have respectively priorities (1, 0, 2),
......
......@@ -27,6 +27,7 @@
#define HEXP_LOCK_CMD_START 1
#define HEXP_LOCK_CMD_CHECK 2
#define HEXP_LOCK_CMD_ENABLE_TRACKING 3
#define HEXP_LOCK_STATUS_LOCKED 0
#define HEXP_LOCK_STATUS_BUSY 1
......
......@@ -427,6 +427,7 @@ static int handle_link_down(hal_port_state_t *p, int link_up)
p->state = HAL_PORT_STATE_LINK_DOWN;
reset_port_state(p);
rts_enable_ptracker(p->hw_index, 0);
TRACE(TRACE_INFO, "%s: link down", p->name);
return 1;
......@@ -605,6 +606,15 @@ static hal_port_state_t *lookup_port(const char *name)
return NULL;
}
int hal_enable_tracking(const char *port_name)
{
hal_port_state_t *p = lookup_port(port_name);
if(!p) return PORT_ERROR;
return rts_enable_ptracker(p->hw_index, 1) < 0 ? PORT_ERROR : PORT_OK;
}
/* Triggers the locking state machine, called by the PTPd during the WR link setup phase. */
int hal_port_start_lock(const char *port_name, int priority)
{
......@@ -647,7 +657,7 @@ int halexp_get_port_state(hexp_port_state_t *state, const char *port_name)
{
hal_port_state_t *p = lookup_port(port_name);
TRACE(TRACE_INFO, "GetPorttState %s\n", port_name);
// TRACE(TRACE_INFO, "GetPortState %s [lup %x]\n", port_name, p);
if(!p)
return -1;
......@@ -704,10 +714,8 @@ int halexp_query_ports(hexp_port_list_t *list)
int n = 0;
for(i=0; i<HAL_MAX_PORTS;i++)
{
if(ports[i].in_use)
strcpy(list->port_names[n++], ports[i].name);
}
list->num_physical_ports = num_physical_ports;
list->num_ports = n;
......
......@@ -14,48 +14,13 @@
#include <sys/time.h>
#include "minipc.h"
#define RTIPC_EXPORT_STRUCTURES
#include "rt_ipc.h"
#define RTS_MAILBOX_ADDR "mem:10007000"
#define RTS_TIMEOUT 100 /* ms */
static const struct minipc_pd rtipc_rts_get_state_struct = {
.name = "aaaa",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRUCT, struct rts_pll_state),
.args = {
MINIPC_ARG_END
},
};
static const struct minipc_pd rtipc_rts_set_mode_struct = {
.name = "bbbb",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
MINIPC_ARG_END
},
};
static const struct minipc_pd rtipc_rts_lock_channel_struct = {
.name = "cccc",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
MINIPC_ARG_END
},
};
static const struct minipc_pd rtipc_rts_adjust_phase_struct = {
.name = "dddd",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
MINIPC_ARG_END
},
};
#define RTS_TIMEOUT 200 /* ms */
static struct minipc_ch *client;
......@@ -135,6 +100,17 @@ int rts_lock_channel(int channel, int priority)
return rval;
}
int rts_enable_ptracker(int channel, int enable)
{
int rval;
int ret = minipc_call(client, RTS_TIMEOUT, &rtipc_rts_enable_ptracker_struct, &rval, channel, enable);
if(ret < 0)
return ret;
return rval;
}
int rts_connect()
{
......
......@@ -18,6 +18,8 @@
#define CHAN_DISABLED (1<<4)
/* Channel is busy adjusting phase */
#define CHAN_SHIFTING (1<<5)
/* Channel is busy adjusting phase */
#define CHAN_PTRACKER_ENABLED (1<<6)
/* DMTD clock is present */
#define RTS_DMTD_LOCKED (1<<0)
......@@ -99,5 +101,58 @@ int rts_set_mode(int mode);
/* Reference channel configuration (BC mode only) */
int rts_lock_channel(int channel, int priority);
/* Enabled/disables phase tracking on a particular port */
int rts_enable_ptracker(int channel, int enable);
#ifdef RTIPC_EXPORT_STRUCTURES
static struct minipc_pd rtipc_rts_get_state_struct = {
.name = "aaaa",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRUCT, struct rts_pll_state),
.args = {
MINIPC_ARG_END
},
};
static struct minipc_pd rtipc_rts_set_mode_struct = {
.name = "bbbb",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
MINIPC_ARG_END
},
};
static struct minipc_pd rtipc_rts_lock_channel_struct = {
.name = "cccc",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
MINIPC_ARG_END
},
};
static struct minipc_pd rtipc_rts_adjust_phase_struct = {
.name = "dddd",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
MINIPC_ARG_END
},
};
static struct minipc_pd rtipc_rts_enable_ptracker_struct = {
.name = "eeee",
.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
.args = {
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
MINIPC_ARG_END
},
};
#endif
#endif
......@@ -71,6 +71,7 @@ int hal_add_cleanup_callback(hal_cleanup_callback_t cb);
int hal_port_start_lock(const char *port_name, int priority);
int hal_port_check_lock(const char *port_name);
int hal_enable_tracking(const char *port_name);
int hal_extsrc_check_lock(void); // added by ML
int hal_init_timing();
......
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