Commit ad82c9e8 authored by Federico Vaga's avatar Federico Vaga

kernel: use zio features

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 144a8bcf
......@@ -14,7 +14,8 @@
#ifndef __FMC_TDC_H__
#define __FMC_TDC_H__
#define FT_VERSION 2 /* version of the driver */
#define FT_VERSION_MAJ 2 /* version of the driver */
#define FT_VERSION_MIN 1
/* default gatewares */
#define FT_GATEWARE_SVEC "fmc/svec-fmc-tdc.bin"
......@@ -29,6 +30,7 @@ enum ft_zattr_dev_idx {
FT_ATTR_DEV_VERSION = 0,
FT_ATTR_DEV_SECONDS,
FT_ATTR_DEV_COARSE,
FT_ATTR_DEV_SEQUENCE,
FT_ATTR_DEV_COMMAND, /* see below for commands */
FT_ATTR_DEV_TEMP,
FT_ATTR_DEV_ENABLE_INPUTS,
......@@ -41,7 +43,6 @@ enum ft_zattr_in_idx {
FT_ATTR_TDC_SECONDS = FT_ATTR_DEV__LAST,
FT_ATTR_TDC_COARSE,
FT_ATTR_TDC_FRAC,
FT_ATTR_TDC_SEQ,
FT_ATTR_TDC_TERMINATION,
FT_ATTR_TDC_OFFSET,
FT_ATTR_TDC_USER_OFFSET,
......
......@@ -95,14 +95,15 @@ int ft_read_sw_fifo(struct fmctdc_dev *ft, int channel,
ctrl->nsamples = 1;
v = ctrl->attr_channel.ext_val;
v[FT_ATTR_TDC_SECONDS] = ts.seconds;
v[FT_ATTR_TDC_COARSE] = ts.coarse;
v[FT_ATTR_TDC_FRAC] = ts.frac;
v[FT_ATTR_TDC_SEQ] = ts.seq_id;
v[FT_ATTR_DEV_SEQUENCE] = ts.gseq_id;
v[FT_ATTR_TDC_OFFSET] = ft->calib.zero_offset[channel - 1];
v[FT_ATTR_TDC_USER_OFFSET] = st->user_offset;
/* Only for sysfs debugging */
v[FT_ATTR_TDC_SECONDS] = ctrl->tstamp.secs;
v[FT_ATTR_TDC_COARSE] = ctrl->tstamp.ticks;
v[FT_ATTR_TDC_FRAC] = ctrl->tstamp.bins;
return 0;
}
......@@ -263,6 +264,7 @@ static void ft_readout_tasklet(unsigned long arg)
uint32_t rd_ptr;
int count, dacapo, i;
pr_info("%s:%d\n", __func__, __LINE__);
ft->prev_wr_ptr = ft->cur_wr_ptr;
ft->cur_wr_ptr = ft_readl(ft, TDC_REG_BUFFER_PTR);
......
......@@ -32,28 +32,28 @@
/* The sample size. Mandatory, device-wide */
ZIO_ATTR_DEFINE_STD(ZIO_DEV, ft_zattr_dev_std) = {
ZIO_ATTR(zdev, ZIO_ATTR_NBITS, S_IRUGO, 0, 32), /* 32 bits. Really? */
ZIO_ATTR(zdev, ZIO_ATTR_NBITS, ZIO_RO_PERM, 0, 32), /* 32 bits. Really? */
ZIO_SET_ATTR_VERSION(ZIO_HEX_VERSION(FT_VERSION_MAJ, FT_VERSION_MIN, 0)),
};
/* Extended attributes for the device */
static struct zio_attribute ft_zattr_dev[] = {
ZIO_ATTR_EXT("version", S_IRUGO, FT_ATTR_DEV_VERSION, FT_VERSION),
ZIO_ATTR_EXT("seconds", _RW_, FT_ATTR_DEV_SECONDS, 0),
ZIO_ATTR_EXT("coarse", _RW_, FT_ATTR_DEV_COARSE, 0),
ZIO_ATTR_EXT("command", S_IWUGO, FT_ATTR_DEV_COMMAND, 0),
ZIO_ATTR_EXT("enable_inputs", _RW_, FT_ATTR_DEV_ENABLE_INPUTS, 0),
ZIO_PARAM_EXT("temperature", S_IRUGO, FT_ATTR_DEV_TEMP, 0)
ZIO_ATTR_EXT("seconds", ZIO_RW_PERM, FT_ATTR_DEV_SECONDS, 0),
ZIO_ATTR_EXT("coarse", ZIO_RW_PERM, FT_ATTR_DEV_COARSE, 0),
ZIO_ATTR_EXT("command", ZIO_WO_PERM, FT_ATTR_DEV_COMMAND, 0),
ZIO_ATTR_EXT("enable_inputs", ZIO_RW_PERM, FT_ATTR_DEV_ENABLE_INPUTS, 0),
ZIO_ATTR_EXT("sequence", ZIO_RW_PERM, FT_ATTR_DEV_SEQUENCE, 0),
ZIO_PARAM_EXT("temperature", ZIO_RO_PERM, FT_ATTR_DEV_TEMP, 0)
};
/* Extended attributes for the TDC (== input) cset */
static struct zio_attribute ft_zattr_input[] = {
ZIO_ATTR_EXT("seconds", S_IRUGO, FT_ATTR_TDC_SECONDS, 0),
ZIO_ATTR_EXT("coarse", S_IRUGO, FT_ATTR_TDC_COARSE, 0),
ZIO_ATTR_EXT("frac", S_IRUGO, FT_ATTR_TDC_FRAC, 0),
ZIO_ATTR_EXT("seq_id", S_IRUGO, FT_ATTR_TDC_SEQ, 0),
ZIO_ATTR_EXT("termination", _RW_, FT_ATTR_TDC_TERMINATION, 0),
ZIO_ATTR_EXT("offset", S_IRUGO, FT_ATTR_TDC_OFFSET, 0),
ZIO_ATTR_EXT("user-offset", _RW_, FT_ATTR_TDC_USER_OFFSET, 0),
ZIO_ATTR_EXT("seconds", ZIO_RO_PERM, FT_ATTR_TDC_SECONDS, 0),
ZIO_ATTR_EXT("coarse", ZIO_RO_PERM, FT_ATTR_TDC_COARSE, 0),
ZIO_ATTR_EXT("frac", ZIO_RO_PERM, FT_ATTR_TDC_FRAC, 0),
ZIO_ATTR_EXT("termination", ZIO_RW_PERM, FT_ATTR_TDC_TERMINATION, 0),
ZIO_ATTR_EXT("offset", ZIO_RO_PERM, FT_ATTR_TDC_OFFSET, 0),
ZIO_ATTR_EXT("user-offset", ZIO_RW_PERM, FT_ATTR_TDC_USER_OFFSET, 0),
};
/* This identifies if our "struct device" is device, input, output */
......@@ -121,13 +121,13 @@ static int ft_zio_info_get(struct device *dev, struct zio_attribute *zattr,
ft = zdev->priv_d;
switch (zattr->id) {
case FT_ATTR_DEV_VERSION:
return 0;
case FT_ATTR_DEV_SEQUENCE:
*usr_val = ft->sequence;
break;
case FT_ATTR_DEV_TEMP:
ft_read_temp(ft, ft->verbose);
*usr_val = ft->temp;
return 0;
break;
case FT_ATTR_DEV_COARSE:
case FT_ATTR_DEV_SECONDS:
{
......@@ -143,15 +143,15 @@ static int ft_zio_info_get(struct device *dev, struct zio_attribute *zattr,
*usr_val =
(zattr->id ==
FT_ATTR_DEV_COARSE ? coarse : (uint32_t) seconds);
return 0;
break;
}
case FT_ATTR_DEV_ENABLE_INPUTS:
attr[FT_ATTR_DEV_ENABLE_INPUTS].value =
ft->acquisition_on ? 1 : 0;
*usr_val = ft->acquisition_on ? 1 : 0;
return 0;
break;
}
return -EINVAL;
return 0;
}
static int ft_zio_conf_channel(struct device *dev, struct zio_attribute *zattr,
......
......@@ -98,9 +98,9 @@ int fmctdc_init(void)
if (fmctdc_sysfs_get(ft_boards, "version", &v) < 0)
return -1;
if (v != FT_VERSION) {
if (v != FT_VERSION_MAJ) {
fprintf(stderr, "%s: version mismatch, lib(%i) != drv(%i)\n",
__func__, FT_VERSION, v);
__func__, FT_VERSION_MAJ, v);
errno = EIO;
return -1;
}
......@@ -402,10 +402,11 @@ int fmctdc_read(struct fmctdc_board *userb, int channel, struct fmctdc_time *t,
if (j == sizeof(ctrl)) {
/* one sample: pick it */
attrs = ctrl.attr_channel.ext_val;
t->seconds = attrs[FT_ATTR_TDC_SECONDS];
t->coarse = attrs[FT_ATTR_TDC_COARSE];
t->frac = attrs[FT_ATTR_TDC_FRAC];
t->seq_id = attrs[FT_ATTR_TDC_SEQ];
t->seconds = ctrl.tstamp.secs;
t->coarse = ctrl.tstamp.ticks;
t->frac = ctrl.tstamp.bins;
t->seq_id = ctrl.seq_num;
t->gseq_id = attrs[FT_ATTR_DEV_SEQUENCE];
i++;
continue;
}
......
......@@ -37,8 +37,9 @@ struct fmctdc_board;
struct fmctdc_time {
uint64_t seconds; /**< number of seconds */
uint32_t coarse; /**< number of ticks of 8ns */
Uint32_t frac; /**< number of frac of 81.03ps */
uint32_t seq_id;
uint32_t frac; /**< number of frac of 81.03ps */
uint32_t seq_id; /**< channel sequence number*/
uint32_t gseq_id; /**< board sequence number */
};
......
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