...
 
Commits (6)
......@@ -418,10 +418,7 @@ static int __fa_init(struct fa_dev *fa)
/* Set to single shot mode by default */
fa_writel(fa, fa->fa_adc_csr_base, &zfad_regs[ZFAT_SHOTS_NB], 1);
/* Enable the software trigger by default: there is no arm in this */
/* Enable the alternative time source: later it will be done by HDL */
fa_writel(fa, fa->fa_adc_csr_base, &zfad_regs[ZFAT_CFG_SRC],
FA100M14B4C_TRG_SRC_SW | FA100M14B4C_TRG_SRC_ALT);
zfat_trigger_source_reset(fa);
/* Zero offsets and release the DAC clear */
zfad_reset_offset(fa);
......@@ -535,11 +532,11 @@ int fa_probe(struct platform_device *pdev)
r = platform_get_resource(pdev, IORESOURCE_MEM, ADC_MEM_BASE);
fa->fa_top_level = ioremap(r->start, resource_size(r));
fa->fa_adc_csr_base = fa->fa_top_level + 0x1000;
fa->fa_irq_adc_base = fa->fa_top_level + 0x1500;
fa->fa_ow_base = fa->fa_top_level + 0x1700;
fa->fa_spi_base = fa->fa_top_level + 0x1800;
fa->fa_utc_base = fa->fa_top_level + 0x1900;
fa->fa_adc_csr_base = fa->fa_top_level + ADC_CSR_OFF;
fa->fa_irq_adc_base = fa->fa_top_level + ADC_EIC_OFF;
fa->fa_ow_base = fa->fa_top_level + ADC_OW_OFF;
fa->fa_spi_base = fa->fa_top_level + ADC_SPI_OFF;
fa->fa_utc_base = fa->fa_top_level + ADC_UTC_OFF;
/* init all subsystems */
for (i = 0, m = mods; i < ARRAY_SIZE(mods); i++, m++) {
......
......@@ -6,6 +6,116 @@
#include "fmc-adc-100m14b4cha.h"
#define FA_DBG_REG32_CH(_n) \
{.name = "ADC-CSR:ch"#_n"_ctl", .offset = ADC_CSR_OFF + 0x080 + ((_n - 1) * 0x40)}, \
{.name = "ADC-CSR:ch"#_n"_sta", .offset = ADC_CSR_OFF + 0x084 + ((_n - 1) * 0x40)}, \
{.name = "ADC-CSR:ch"#_n"_cal_nb", .offset = ADC_CSR_OFF + 0x088 + ((_n - 1) * 0x40)}, \
{.name = "ADC-CSR:ch"#_n"_sat", .offset = ADC_CSR_OFF + 0x08C + ((_n - 1) * 0x40)}, \
{.name = "ADC-CSR:ch"#_n"_trig_thres", .offset = ADC_CSR_OFF + 0x090 + ((_n - 1) * 0x40)}, \
{.name = "ADC-CSR:ch"#_n"_trig_dly", .offset = ADC_CSR_OFF + 0x094 + ((_n - 1) * 0x40)}
#define FA_DBG_REG32_TIM(_name, _off) \
{ \
.name = "TIME-TAG:"#_name"_seconds_upper", \
.offset = ADC_UTC_OFF + _off \
}, { \
.name = "TIME-TAG:"#_name"_seconds_lower", \
.offset = ADC_UTC_OFF + _off + 0x4, \
}, { \
.name = "TIME-TAG:"#_name"_coarse", \
.offset = ADC_UTC_OFF + _off + 0x8, \
}
static const struct debugfs_reg32 fa_debugfs_reg32[] = {
{
.name = "ADC-CSR:ctl",
.offset = ADC_CSR_OFF + 0x000,
},
{
.name = "ADC-CSR:sta",
.offset = ADC_CSR_OFF + 0x004,
},
{
.name = "ADC-CSR:trig_stat",
.offset = ADC_CSR_OFF + 0x008,
},
{
.name = "ADC-CSR:trig_en",
.offset = ADC_CSR_OFF + 0x00C,
},
{
.name = "ADC-CSR:trig_pol",
.offset = ADC_CSR_OFF + 0x010,
},
{
.name = "ADC-CSR:ext_trig_dly",
.offset = ADC_CSR_OFF + 0x014,
},
{
.name = "ADC-CSR:sw_trig",
.offset = ADC_CSR_OFF + 0x018,
},
{
.name = "ADC-CSR:shots",
.offset = ADC_CSR_OFF + 0x01C,
},
{
.name = "ADC-CSR:multi_depth",
.offset = ADC_CSR_OFF + 0x020,
},
{
.name = "ADC-CSR:trig_pos",
.offset = ADC_CSR_OFF + 0x024,
},
{
.name = "ADC-CSR:fs_freq",
.offset = ADC_CSR_OFF + 0x028,
},
{
.name = "ADC-CSR:downsample",
.offset = ADC_CSR_OFF + 0x02C,
},
{
.name = "ADC-CSR:pre_samples",
.offset = ADC_CSR_OFF + 0x030,
},
{
.name = "ADC-CSR:post_samples",
.offset = ADC_CSR_OFF + 0x034,
},
{
.name = "ADC-CSR:samples_cnt",
.offset = ADC_CSR_OFF + 0x038,
},
FA_DBG_REG32_CH(1),
FA_DBG_REG32_CH(2),
FA_DBG_REG32_CH(3),
FA_DBG_REG32_CH(4),
{
.name = "ADC-EIC:disable_mask",
.offset = ADC_EIC_OFF + 0x0,
},
{
.name = "ADC-EIC:enable_mask",
.offset = ADC_EIC_OFF + 0x4,
},
{
.name = "ADC-EIC:status_mask",
.offset = ADC_EIC_OFF + 0x8,
},
{
.name = "ADC-EIC:source",
.offset = ADC_EIC_OFF + 0xC,
},
FA_DBG_REG32_TIM(base_time, 0x00),
FA_DBG_REG32_TIM(time_trig, 0x0C),
FA_DBG_REG32_TIM(trig_tag, 0x18),
FA_DBG_REG32_TIM(acq_start_tag, 0x24),
FA_DBG_REG32_TIM(acq_stop_tag, 0x30),
FA_DBG_REG32_TIM(acq_end_tag, 0x3C),
};
static void fa_regdump_seq_read_spi(struct fa_dev *fa, struct seq_file *s)
{
......@@ -55,10 +165,34 @@ static const struct file_operations fa_regdump_ops = {
int fa_debug_init(struct fa_dev *fa)
{
fa->reg_dump = debugfs_create_file(dev_name(&fa->zdev->head.dev), 0444,
NULL, fa, &fa_regdump_ops);
if (IS_ERR_OR_NULL(fa->reg_dump)) {
dev_err(fa->msgdev,
int err;
fa->dbg_dir = debugfs_create_dir(dev_name(&fa->zdev->head.dev), NULL);
if (IS_ERR_OR_NULL(fa->dbg_dir)) {
err = PTR_ERR(fa->dbg_dir);
dev_err(&fa->zdev->head.dev,
"Cannot create debugfs directory \"%s\" (%d)\n",
dev_name(&fa->zdev->head.dev), err);
return err;
}
fa->dbg_reg32.regs = fa_debugfs_reg32;
fa->dbg_reg32.nregs = ARRAY_SIZE(fa_debugfs_reg32);
fa->dbg_reg32.base = fa->fa_top_level;
fa->dbg_reg = debugfs_create_regset32("regs", 0200, fa->dbg_dir,
&fa->dbg_reg32);
if (IS_ERR_OR_NULL(fa->dbg_reg)) {
err = PTR_ERR(fa->dbg_reg);
dev_warn(fa->msgdev,
"Cannot create debugfs file \"regs\" (%d)\n",
err);
}
fa->dbg_reg_spi = debugfs_create_file("spi-regs", 0444,
fa->dbg_dir, fa,
&fa_regdump_ops);
if (IS_ERR_OR_NULL(fa->dbg_reg_spi)) {
dev_warn(fa->msgdev,
"Cannot create regdump debugfs file\n");
}
......@@ -68,5 +202,5 @@ int fa_debug_init(struct fa_dev *fa)
void fa_debug_exit(struct fa_dev *fa)
{
debugfs_remove_recursive(fa->reg_dump);
debugfs_remove_recursive(fa->dbg_dir);
}
......@@ -324,11 +324,11 @@ static int zfad_dma_prep_slave_sg(struct dma_chan *dchan,
max_segment_size = dma_get_max_seg_size(dchan->device->dev);
/* With some version we cannot use the version from the Linux kernel */
fa->sg_alloc_table_from_pages(&zfad_block->sgt, pages, nr_pages,
offset_in_page(zfad_block->block->data),
zfad_block->block->datalen,
max_segment_size, GFP_KERNEL);
max_segment_size &= PAGE_MASK; /* to make alloc_table happy */
err = fa->sg_alloc_table_from_pages(&zfad_block->sgt, pages, nr_pages,
offset_in_page(zfad_block->block->data),
zfad_block->block->datalen,
max_segment_size, GFP_KERNEL);
if (unlikely(err))
goto err_sgt;
......@@ -336,7 +336,7 @@ static int zfad_dma_prep_slave_sg(struct dma_chan *dchan,
zfad_block->sgt.sgl,
zfad_block->sgt.nents,
DMA_DEV_TO_MEM);
if (sg_mapped < 0) {
if (sg_mapped <= 0) {
err = sg_mapped;
goto err_map;
}
......
......@@ -114,6 +114,15 @@ static struct zio_attribute zfat_ext_zattr[] = {
ZFA_UTC_TRIG_COARSE, 0),
};
/*
* Reset to default value
*/
void zfat_trigger_source_reset(struct fa_dev *fa)
{
fa_writel(fa, fa->fa_adc_csr_base,
&zfad_regs[ZFAT_CFG_SRC],
FA100M14B4C_TRG_SRC_SW | FA100M14B4C_TRG_SRC_ALT);
}
/*
* zfat_conf_set
......@@ -322,6 +331,12 @@ static int zfat_data_done(struct zio_cset *cset)
kfree(zfad_block);
cset->interleave->priv_d = NULL;
/*
* Reset trigger source to avoid clean up the register for the next
* acquisition
*/
zfat_trigger_source_reset(fa);
return 0;
}
......
......@@ -168,6 +168,12 @@ struct fa_calib {
#include "field-desc.h"
#define ADC_CSR_OFF 0x1000
#define ADC_EIC_OFF 0x1500
#define ADC_OW_OFF 0x1700
#define ADC_SPI_OFF 0x1800
#define ADC_UTC_OFF 0x1900
extern int fa_enable_test_data_adc;
enum fa_irq_resource {
......@@ -446,7 +452,10 @@ struct fa_dev {
/* flag */
int enable_auto_start;
struct dentry *reg_dump;
struct dentry *dbg_dir;
struct debugfs_regset32 dbg_reg32;
struct dentry *dbg_reg;
struct dentry *dbg_reg_spi;
/* Operations */
int (*sg_alloc_table_from_pages)(struct sg_table *sgt,
......@@ -598,6 +607,7 @@ extern int fa_zio_init(struct fa_dev *fa);
extern void fa_zio_exit(struct fa_dev *fa);
/* Functions exported by fa-zio-trg.c */
extern void zfat_trigger_source_reset(struct fa_dev *fa);
extern int fa_trig_init(void);
extern void fa_trig_exit(void);
......