Commit 2b60408c authored by Tomasz Wlostowski's avatar Tomasz Wlostowski Committed by Federico Vaga

kernel: add WR calibration offset

parent 212bf81c
......@@ -42,16 +42,15 @@ static int ft_read_calibration_eeprom(struct fmc_device *fmc, void *buf,
if (ret == 0)
break;
}
if (ret)
return ret;
/* Open "cali" as a device id, vendor is "FileData" -- big endian */
ret = sdbfs_open_id(&fs, 0x61746144656c6946LL, 0x696c6163);
ret = sdbfs_open_name(&fs, "calib");
if (ret)
return ret;
ret = sdbfs_fread(&fs, 0, buf, length);
sdbfs_dev_destroy(&fs);
return ret;
}
......@@ -62,7 +61,7 @@ int ft_handle_eeprom_calibration(struct fmctdc_dev *ft)
struct ft_calibration *calib;
struct device *d = &ft->fmc->dev;
int i;
u32 raw_calib[5];
u32 raw_calib[7];
/* Retrieve and validate the calibration */
calib = &ft->calib;
......@@ -85,11 +84,14 @@ int ft_handle_eeprom_calibration(struct fmctdc_dev *ft)
calib->vcxo_default_tune = le32_to_cpu(raw_calib[4]);
}
calib->calibration_temp = le32_to_cpu(raw_calib[5]);
calib->wr_offset = le32_to_cpu(raw_calib[6]) / 100;
for (i = 0; i < ARRAY_SIZE(calib->zero_offset); i++)
dev_info(d, "calib: zero_offset[%i] = %li\n", i,
(long)calib->zero_offset[i]);
dev_info(d, "calib: zero_offset[%i] = %i ps\n", i,
calib->zero_offset[i]);
dev_info(d, "calib: vcxo_default_tune %i\n", calib->vcxo_default_tune);
dev_info(d, "calib: wr offset = %i ps\n", calib->wr_offset);
return 0;
}
......@@ -91,6 +91,12 @@ struct ft_calibration { /* All of these are big endian in the EEPROM */
/* Default DAC value for VCXO. Set during init and for local timing */
uint32_t vcxo_default_tune;
/* Temperature at which the device has been calibrated */
uint32_t calibration_temp;
/* White Rabbit timescale offset in ps */
int32_t wr_offset;
};
/* Hardware TDC timestamp */
......@@ -226,7 +232,6 @@ struct zio_channel;
int ft_read_sw_fifo(struct fmctdc_dev *ft, int channel,
struct zio_channel *chan);
int ft_enable_termination(struct fmctdc_dev *ft, int channel, int enable);
signed long fmc_find_sdb_device_ext(struct sdb_array *tree,
uint64_t vid, uint32_t did, int index,
unsigned long *sz);
......
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