Skip to content
Snippets Groups Projects
Commit 00349d64 authored by Alessandro Rubini's avatar Alessandro Rubini
Browse files

kernel/wr-nic-dio: fix output delay; remove fifo hack


The previous commit (resetting fpga) fixed the fifo problem,
so the associated code is not needed any more.

Signed-off-by: default avatarAlessandro Rubini <rubini@gnudd.com>
parent a1236565
Branches
Tags
No related merge requests found
...@@ -86,6 +86,15 @@ static struct regmap regmap[] = { ...@@ -86,6 +86,15 @@ static struct regmap regmap[] = {
} }
}; };
static inline void wrn_ts_sub(struct timespec *ts, int nano)
{
ts->tv_nsec -= nano;
if (ts->tv_nsec < 0) {
ts->tv_nsec += 1000 * 1000 * 1000;
ts->tv_sec--;
}
}
/* FIXME: should this access use fmc_readl/writel? */ /* FIXME: should this access use fmc_readl/writel? */
static int wrn_dio_cmd_pulse(struct wrn_drvdata *drvdata, static int wrn_dio_cmd_pulse(struct wrn_drvdata *drvdata,
struct wr_dio_cmd *cmd) struct wr_dio_cmd *cmd)
...@@ -120,12 +129,12 @@ static int wrn_dio_cmd_pulse(struct wrn_drvdata *drvdata, ...@@ -120,12 +129,12 @@ static int wrn_dio_cmd_pulse(struct wrn_drvdata *drvdata,
now = l; now = l;
SET_HI32(now, h2); SET_HI32(now, h2);
ts->tv_sec += now; ts->tv_sec += now;
printk("relative: %li -> %li\n", now, ts->tv_sec);
} }
/* if not "now", set trig, trigh, cycles */ /* if not "now", set trig, trigh, cycles */
if (!(cmd->flags & WR_DIO_F_NOW)) { if (!(cmd->flags & WR_DIO_F_NOW)) {
/* not now: set relevant registers */ /* Subtract 1 cycle, to count for output latencies */
wrn_ts_sub(ts, 8);
writel(ts->tv_nsec / 8, base + map->cycle); writel(ts->tv_nsec / 8, base + map->cycle);
writel(GET_HI32(ts->tv_sec), base + map->trig_h); writel(GET_HI32(ts->tv_sec), base + map->trig_h);
writel(ts->tv_sec, base + map->trig_l); writel(ts->tv_sec, base + map->trig_l);
...@@ -133,7 +142,6 @@ static int wrn_dio_cmd_pulse(struct wrn_drvdata *drvdata, ...@@ -133,7 +142,6 @@ static int wrn_dio_cmd_pulse(struct wrn_drvdata *drvdata,
/* set the width */ /* set the width */
ts++; ts++;
printk("%x\n", map->pulse);
writel(ts->tv_nsec / 8, base + map->pulse); writel(ts->tv_nsec / 8, base + map->pulse);
/* no loop yet (FIXME: interrupts) */ /* no loop yet (FIXME: interrupts) */
...@@ -186,15 +194,8 @@ static int wrn_dio_cmd_stamp(struct wrn_drvdata *drvdata, ...@@ -186,15 +194,8 @@ static int wrn_dio_cmd_stamp(struct wrn_drvdata *drvdata,
/* reading the low tai pops the fifo */ /* reading the low tai pops the fifo */
ts->tv_sec |= readl(base + map->fifo_tai_l); ts->tv_sec |= readl(base + map->fifo_tai_l);
/* At startup I get many zero values: discard them */
if (!ts->tv_sec)
continue;
/* subtract 5 cycles lost in input sync circuits */ /* subtract 5 cycles lost in input sync circuits */
ts->tv_nsec -= 40; wrn_ts_sub(ts, 40);
if (ts->tv_nsec < 0) {
ts->tv_nsec += 1000 * 1000 * 1000;
ts->tv_sec--;
}
nstamp++; nstamp++;
ts++; ts++;
} }
...@@ -233,7 +234,6 @@ int wrn_mezzanine_ioctl(struct net_device *dev, struct ifreq *rq, ...@@ -233,7 +234,6 @@ int wrn_mezzanine_ioctl(struct net_device *dev, struct ifreq *rq,
if (copy_from_user(cmd, rq->ifr_data, sizeof(*cmd))) if (copy_from_user(cmd, rq->ifr_data, sizeof(*cmd)))
goto out; goto out;
switch(cmd->command) { switch(cmd->command) {
case WR_DIO_CMD_PULSE: case WR_DIO_CMD_PULSE:
ret = wrn_dio_cmd_pulse(drvdata, cmd); ret = wrn_dio_cmd_pulse(drvdata, cmd);
......
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