Commit 23756326 authored by Federico Vaga's avatar Federico Vaga

kernel: move SPI register read-back to debugfs

The debugfs is the right place for such output
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent c7f8d72e
......@@ -45,6 +45,7 @@ fmc-adc-100m14b-y += fa-calibration.o
fmc-adc-100m14b-y += fa-regtable.o
fmc-adc-100m14b-y += fa-zio-trg.o
fmc-adc-100m14b-y += fa-irq.o
fmc-adc-100m14b-y += fa-debug.o
fmc-adc-100m14b-y += onewire.o
fmc-adc-100m14b-y += spi.o
fmc-adc-100m14b-y += fmc-util.o
......
......@@ -402,6 +402,7 @@ static struct fa_modlist mods[] = {
{"spi", fa_spi_init, fa_spi_exit},
{"onewire", fa_onewire_init, fa_onewire_exit},
{"zio", fa_zio_init, fa_zio_exit},
{"debug", fa_debug_init, fa_debug_exit},
};
/* probe and remove are called by fa-spec.c */
......
/*
* Copyright CERN 2018
* Author: Federico Vaga <federico.vaga@cern.ch>
*/
#include "fmc-adc-100m14b4cha.h"
static void fa_regdump_seq_read_spi(struct fa_dev *fa, struct seq_file *s)
{
int i, err;
seq_printf(s, "ADC SPI registers\n");
seq_printf(s, "Address Data\n");
for (i = 0; i < 5; ++i) {
uint32_t tx, rx;
tx = 0x8000 | (i << 8);
err = fa_spi_xfer(fa, FA_SPI_SS_ADC, 16, tx, &rx);
rx &= 0xFF; /* the value is 8bit */
if (err)
seq_printf(s, "A%d %02xh read failure!\n",
i, i);
else
seq_printf(s, "A%d %02xh 0x%02x\n",
i, i, rx);
}
}
static int fa_regdump_seq_read(struct seq_file *s, void *data)
{
struct fa_dev *fa = s->private;
fa_regdump_seq_read_spi(fa, s);
return 0;
}
static int fa_regdump_open(struct inode *inode, struct file *file)
{
return single_open(file, fa_regdump_seq_read, inode->i_private);
}
static const struct file_operations fa_regdump_ops = {
.owner = THIS_MODULE,
.open = fa_regdump_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
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,
"Cannot create regdump debugfs file\n");
}
return 0;
}
void fa_debug_exit(struct fa_dev *fa)
{
debugfs_remove_recursive(fa->reg_dump);
}
......@@ -99,6 +99,7 @@ enum fa100m14b4c_fsm_state {
#include <linux/dma-mapping.h>
#include <linux/scatterlist.h>
#include <linux/workqueue.h>
#include <linux/debugfs.h>
#include <linux/fmc.h>
#include <linux/fmc-sdb.h>
......@@ -372,6 +373,8 @@ struct fa_dev {
int enable_auto_start;
uint32_t trig_compensation;
struct dentry *reg_dump;
};
/*
......@@ -541,5 +544,10 @@ signed long fmc_find_sdb_device_ext(struct sdb_array *tree,
/* function exporetd by fa-calibration.c */
extern void fa_read_eeprom_calib(struct fa_dev *fa);
/* functions exported by fa-debug.c */
extern int fa_debug_init(struct fa_dev *fa);
extern void fa_debug_exit(struct fa_dev *fa);
#endif /* __KERNEL__ */
#endif /* FMC_ADC_H_ */
......@@ -75,8 +75,7 @@ out:
int fa_spi_init(struct fa_dev *fa)
{
uint32_t tx, rx;
int i;
uint32_t rx;
/* Divider must be 100, according to firmware guide */
fa_iowrite(fa, 100, fa->fa_spi_base + FA_SPI_DIV);
......@@ -88,15 +87,6 @@ int fa_spi_init(struct fa_dev *fa)
/* Force 2's complement data output (register 1, bit 5) */
fa_spi_xfer(fa, FA_SPI_SS_ADC, 16, (1 << 8) | (1 << 5), &rx);
if (0) {
/* Check the current configuration of the ADC chip */
for (i = 0; i < 5; i++) {
tx = 0x8000 | (i << 8);
fa_spi_xfer(fa, FA_SPI_SS_ADC, 16, tx, &rx);
dev_dbg(fa->msgdev, "LTC register %02x: 0x%02x\n",
i, rx & 0xff);
}
}
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