Commit 03f503b9 authored by Tristan Gingold's avatar Tristan Gingold

wrtd: more cleanup.

parent 9d98a661
......@@ -22,6 +22,7 @@
/* By default use lxi-evntsvc. */
#define WRTD_UDP_PORT 5044
/* Functions defined by the user. */
static void wrtd_local_output(struct wrtd_event *ev, unsigned ch);
static void wrtd_io(void);
static int wrtd_user_init(void);
......
......@@ -6,14 +6,9 @@
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include <errno.h>
#include <string.h>
#include "mockturtle-rt.h"
#include <mockturtle-framework.h>
#include "wrtd-common.h"
#include "hw/fd_channel_regs.h"
#include "hw/fd_main_regs.h"
#include "wrtd-fd.h"
......
......@@ -6,13 +6,11 @@
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include <string.h>
#include "mockturtle-rt.h"
#include <mockturtle-framework.h>
#include "wrtd-common.h"
#include "hw/fmctdc-direct.h"
#include "hw/tdc_regs.h"
#define NBR_CPUS 2
#define CPU_IDX 0
......@@ -68,6 +66,7 @@ static inline int wr_sync_timeout(void)
static void wrtd_local_output(struct wrtd_event *ev, unsigned ch)
{
/* No output. */
return;
}
......
......@@ -14,8 +14,7 @@
#define BASE_DP_TDC_REGS 0x2000
#define BASE_DP_TDC_DIRECT 0x8000
#define FT_CH_1 1
#define FT_NUM_CHANNELS 5
#define TDC_NUM_CHANNELS 5
#define NB_ACAM_REGS 11
......@@ -130,15 +129,12 @@ static int tdc_enable_termination(struct wrtd_tdc_dev *tdc,
{
uint32_t ien;
if (channel < FT_CH_1 || channel > FT_NUM_CHANNELS)
return -EINVAL;
ien = tdc_readl(tdc, BASE_DP_TDC_REGS + TDC_REG_INPUT_ENABLE);
if (enable)
ien |= (1 << (channel - 1));
ien |= (1 << channel);
else
ien &= ~(1 << (channel - 1));
ien &= ~(1 << channel);
tdc_writel(tdc, ien, BASE_DP_TDC_REGS + TDC_REG_INPUT_ENABLE);
......@@ -149,7 +145,7 @@ static int tdc_channels_init(struct wrtd_tdc_dev *tdc)
{
int i;
for (i = FT_CH_1; i <= FT_NUM_CHANNELS; i++) {
for (i = 0; i < TDC_NUM_CHANNELS; i++) {
/* termination is off by default */
tdc_enable_termination(tdc, i, 0);
}
......@@ -177,15 +173,6 @@ static void tdc_enable_acquisition(struct wrtd_tdc_dev *tdc, int enable)
}
}
static int tdc_irq_init(struct wrtd_tdc_dev *tdc)
{
/* IRQ coalescing: 40 timestamps or 40 milliseconds */
tdc_writel(tdc, 40, BASE_DP_TDC_REGS + TDC_REG_IRQ_THRESHOLD);
tdc_writel(tdc, 40, BASE_DP_TDC_REGS + TDC_REG_IRQ_TIMEOUT);
return 0;
}
/* FIXME missing all calibration */
static int tdc_init(struct wrtd_tdc_dev *tdc)
{
......@@ -211,10 +198,6 @@ static int tdc_init(struct wrtd_tdc_dev *tdc)
if (err)
return err;
err = tdc_irq_init(tdc);
if (err)
return err;
tdc_enable_acquisition(tdc, 1);
pr_debug("%s: TDC initialization complete\n\r", __func__);
......@@ -239,7 +222,7 @@ static inline int tdc_wr_time_ready(struct wrtd_tdc_dev *tdc)
static inline int tdc_wr_sync_timeout(void)
{
/* Wait 4 seconds until the tcd is ready. */
/* Wait 3 seconds until the tcd is ready (+ 1 for truncation). */
return 4;
}
......
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