Commit 73a35b7d authored by Federico Vaga's avatar Federico Vaga

DEBUG no SDB

parent 67544fe0
......@@ -74,11 +74,11 @@ int ft_acam_init(struct fmctdc_dev *ft)
ft_writel(ft, acam_config[i].value,
TDC_REG_ACAM_CONFIG(acam_config[i].reg));
}
pr_info("%s:%d\n", __func__, __LINE__);
/* commit ACAM config regs */
ft_writel(ft, TDC_CTRL_LOAD_ACAM_CFG, TDC_REG_CTRL);
udelay(100);
pr_info("%s:%d\n", __func__, __LINE__);
/* and reset the chip (keeps configuration) */
ft_writel(ft, TDC_CTRL_RESET_ACAM, TDC_REG_CTRL);
udelay(100);
......
......@@ -253,16 +253,16 @@ int ft_probe(struct fmc_device *fmc)
/* Now use SDB to find the base addresses */
ord = fmc->slot_id;
ft->ft_core_base = fmc_sdb_find_nth_device(fmc->sdb, 0xce42, 0x604, &ord, NULL);
ft->ft_core_base = 0x50000 + (ord * 0x20000) + 0x1000;//fmc_sdb_find_nth_device(fmc->sdb, 0xce42, 0x604, &ord, NULL);
ft->ft_irq_base = ft->ft_core_base + TDC_MEZZ_EIC_OFFSET;
ft->ft_owregs_base = ft->ft_core_base + TDC_MEZZ_ONEWIRE_OFFSET;
ft->ft_buffer_base = ft->ft_core_base + TDC_MEZZ_MEM_OFFSET;
if (ft_verbose) {
if (ft_verbose || 1) {
dev_info(dev,
"Base addrs: core 0x%x, carrier_csr 0x%x, irq 0x%x, 1wire 0x%x, buffer/DMA 0x%X\n",
ft->ft_core_base, ft->ft_carrier_base, ft->ft_irq_base,
"Slot: %d, Base addrs: core 0x%x, carrier_csr 0x%x, irq 0x%x, 1wire 0x%x, buffer/DMA 0x%X\n",
ord, ft->ft_core_base, ft->ft_carrier_base, ft->ft_irq_base,
ft->ft_owregs_base, ft->ft_buffer_base);
}
......@@ -272,21 +272,23 @@ int ft_probe(struct fmc_device *fmc)
ret = ft_handle_eeprom_calibration(ft);
if (ret < 0)
return ret;
pr_info("%s:%d\n", __func__, __LINE__);
/* init all subsystems */
for (i = 0, m = init_subsystems; i < ARRAY_SIZE(init_subsystems);
i++, m++) {
pr_info("%s:%d init(%d)\n", __func__, __LINE__, i);
ret = m->init(ft);
if (ret < 0)
goto err;
}
pr_info("%s:%d\n", __func__, __LINE__);
ret = ft_irq_init(ft);
if (ret < 0)
goto err;
pr_info("%s:%d\n", __func__, __LINE__);
ft_enable_acquisition(ft, 1);
pr_info("%s:%d\n", __func__, __LINE__);
ft->initialized = 1;
ft->sequence = 0;
......
......@@ -30,6 +30,7 @@
#include "hw/tdc_regs.h"
static void ft_readout_tasklet(unsigned long arg);
static struct ft_wr_timestamp zero;
static void copy_timestamps(struct fmctdc_dev *ft, int base_addr,
int size, void *dst)
......@@ -50,13 +51,29 @@ static void copy_timestamps(struct fmctdc_dev *ft, int base_addr,
}
static void ft_calculate_delay(struct ft_channel_state *reference,
struct ft_wr_timestamp *ts,
struct ft_wr_timestamp *diff)
{
if (likely(memcmp(&reference->last_ts, &zero ,
sizeof(struct ft_wr_timestamp)) )) {
ft_ts_sub(diff, &reference->last_ts);
} else {
/*
* It seems that we are not able to compute the delay.
* Inform the user by setting the time stamp to 0
*/
memset(diff, 0 , sizeof(struct ft_wr_timestamp));
}
}
int ft_read_sw_fifo(struct fmctdc_dev *ft, int channel,
struct zio_channel *chan)
{
struct zio_control *ctrl;
struct zio_ti *ti = chan->cset->ti;
uint32_t *v;
struct ft_wr_timestamp ts, ts_last, *reflast;
struct ft_wr_timestamp ts, diff;
struct ft_channel_state *st;
int ret;
......@@ -82,34 +99,18 @@ int ft_read_sw_fifo(struct fmctdc_dev *ft, int channel,
* If we are in delay mode, replace the time stamp with the delay from
* the reference
*/
diff = ts;
if (st->delay_reference) {
pr_info("%s:%d calculate delay\n", __func__, __LINE__);
reflast = &ft->channels[st->delay_reference - 1].last_ts;
/* local copy of the last time stamp */
ts_last = *reflast;
/* update last time stamp with the current one */
memcpy(reflast, &ts, sizeof(struct ft_wr_timestamp));
if (likely(ts.gseq_id > ts_last.gseq_id)) {
ft_ts_sub(&ts, &ts_last);
v[FT_ATTR_TDC_DELAY_REF_SEQ] = ts_last.gseq_id;
pr_info("%s:%d gseq last ref %d\n", __func__, __LINE__,
ts_last.gseq_id);
} else {
/*
* It seems that we are not able to compute the delay.
* Inform the user by setting the time stamp to 0
*/
memset(&ts, 0 , sizeof(struct ft_wr_timestamp));
pr_info("%s:%d can't do it %d - %d %d\n", __func__, __LINE__,
st->delay_reference - 1, ts.gseq_id > ts_last.gseq_id);
}
ft_calculate_delay(&ft->channels[st->delay_reference - 1],
&ts, &diff);
v[FT_ATTR_TDC_DELAY_REF_SEQ] =
ft->channels[st->delay_reference - 1].last_ts.gseq_id;
}
/* Write the timestamp in the trigger, it will reach the control */
ti->tstamp.tv_sec = ts.seconds;
ti->tstamp.tv_nsec = ts.coarse; /* we use 8ns steps */
ti->tstamp_extra = ts.frac;
ti->tstamp.tv_sec = diff.seconds;
ti->tstamp.tv_nsec = diff.coarse; /* we use 8ns steps */
ti->tstamp_extra = diff.frac;
/*
* This is different than it was. We used to fill the active block,
......@@ -129,6 +130,9 @@ int ft_read_sw_fifo(struct fmctdc_dev *ft, int channel,
v[FT_ATTR_TDC_OFFSET] = ft->calib.zero_offset[channel - 1];
v[FT_ATTR_TDC_USER_OFFSET] = st->user_offset;
/* update last time stamp with the current one */
memcpy(&st->last_ts, &ts, sizeof(struct ft_wr_timestamp));
return 0;
}
......@@ -288,7 +292,6 @@ static void ft_readout_tasklet(unsigned long arg)
uint32_t rd_ptr;
int count, dacapo, i, err;
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);
......
......@@ -35,7 +35,7 @@ static int ft_svec_reset(struct fmctdc_dev *ft)
fmc_writel(ft->fmc, 0xff, TDC_SVEC_CARRIER_BASE + TDC_REG_CARRIER_RST);
msleep(3000);
msleep(6000);
return 0;
}
......
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