Commit f88114a4 authored by Federico Vaga's avatar Federico Vaga

fmc-adc: add support to auto star

When an acquisition finish, the ADC automatically stop. If you enable
the auto start option from sysfs, when the acquisition finish, the
driver send immediatly the start command to start a new acquisition
Signed-off-by: 's avatarFederico Vaga <federico.vaga@gmail.com>
parent 353f92ed
......@@ -22,11 +22,13 @@
#include "spec.h"
#include "fmc-adc.h"
int enable_auto_start = 0;
static int enable_test_data = 0;
static int enable_calibration = 0;
module_param(enable_test_data, int, 0444);
module_param(enable_calibration, int, 0444);
/* Definition of the fmc-adc registers address - mask - mask offset */
const struct zio_reg_desc zfad_regs[] = {
/* Control registers */
......@@ -148,6 +150,12 @@ static struct zio_attribute zfad_cset_ext_zattr[] = {
* 2: stop
*/
PARAM_EXT_REG("fsm-command", S_IWUGO, ZFA_CTL_FMS_CMD, 0),
/*
* Automatic start acquisition
* 1: enabled
* 0: disabled
*/
PARAM_EXT_REG("fsm-auto-start", S_IRUGO | S_IWUGO, ZFA_SW_R_NOADDERS_AUTO, 0),
/*
* fsm - status of the state machine:
* 1: IDLE
......@@ -202,7 +210,7 @@ static inline int zfad_get_chx_index(unsigned long addr,
{
return addr + ZFA_CHx_MULT * (1 + chan->index - chan->cset->n_chan);
}
static int zfad_fsm_command(struct fa_dev *fa, uint32_t command)
int zfad_fsm_command(struct fa_dev *fa, uint32_t command)
{
uint32_t val;
......@@ -256,6 +264,9 @@ static int zfad_conf_set(struct device *dev, struct zio_attribute *zattr,
int i, err;
switch (zattr->priv.addr) {
case ZFA_SW_R_NOADDERS_AUTO:
enable_auto_start = usr_val;
return 0;
case ZFA_CHx_OFFSET:
err = fa_spi_xfer(fa, to_zio_chan(dev)->index, 16,
usr_val, &tmp);
......@@ -312,6 +323,7 @@ static int zfad_info_get(struct device *dev, struct zio_attribute *zattr,
switch (zattr->priv.addr) {
case ZFA_CHx_OFFSET:
case ZFA_SW_R_NOADDRES_NBIT:
case ZFA_SW_R_NOADDERS_AUTO:
/* ZIO automatically return the attribute value */
return 0;
case ZFA_SW_R_NOADDRES_TEMP:
......
......@@ -196,6 +196,11 @@ static void zfat_start_next_dma(struct zio_ti *ti)
(ti->flags & ZIO_STATUS ? 0 : 1));
zfa_common_conf_set(fa, &zfad_regs[ZFAT_CFG_SW_EN],
ti->zattr_set.ext_zattr[5].value);
/* Automatic start next acquisition */
if (enable_auto_start) {
dev_dbg(&ti->head.dev, "Automatic start\n");
zfad_fsm_command(fa, ZFA_START);
}
return;
}
......
......@@ -13,6 +13,8 @@
#define FA_GATEWARE_DEFAULT_NAME "fmc/fmc-adc.bin"
extern int enable_auto_start;
/* ADC register offset */
#define FA_DMA_MEM_OFF 0x00000
#define FA_CAR_MEM_OFF 0x30000
......@@ -190,6 +192,7 @@ enum zfadc_dregs_enum {
/* Other "address" */
ZFA_SW_R_NOADDRES_NBIT,
ZFA_SW_R_NOADDRES_TEMP,
ZFA_SW_R_NOADDERS_AUTO,
};
/*
* ZFA_CHx_MULT
......@@ -313,6 +316,8 @@ extern int fa_spi_xfer(struct fa_dev *fa, int cs, int num_bits,
uint32_t tx, uint32_t *rx);
extern int fa_spi_init(struct fa_dev *fd);
extern void fa_spi_exit(struct fa_dev *fd);
/* function in fa-zio-drv.c */
extern int zfad_fsm_command(struct fa_dev *fa, uint32_t command);
#endif /* __KERNEL__ */
#endif /* _fa_dev_H_ */
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