Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC ADC 100M 14b 4cha
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC ADC 100M 14b 4cha
Commits
0c8bfab7
Commit
0c8bfab7
authored
Jun 27, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP kernel: better support for test data
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
8c78758f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
23 deletions
+32
-23
fa-core.c
kernel/fa-core.c
+2
-20
fa-zio-drv.c
kernel/fa-zio-drv.c
+26
-3
fmc-adc-100m14b4cha.h
kernel/fmc-adc-100m14b4cha.h
+4
-0
No files found.
kernel/fa-core.c
View file @
0c8bfab7
...
...
@@ -21,11 +21,8 @@ FMC_PARAM_GATEWARE(fa_dev_drv);
static
int
fa_enable_test_data_fpga
;
module_param_named
(
enable_test_data_fpga
,
fa_enable_test_data_fpga
,
int
,
0444
);
static
int
fa_enable_test_data_adc
;
int
fa_enable_test_data_adc
=
0
;
module_param_named
(
enable_test_data_adc
,
fa_enable_test_data_adc
,
int
,
0444
);
static
int
fa_enable_test_data_adc_pattern
=
0x555
;
module_param_named
(
enable_test_data_adc_pattern
,
fa_enable_test_data_adc_pattern
,
int
,
0664
);
static
const
int
zfad_hw_range
[]
=
{
[
FA100M14B4C_RANGE_10V
]
=
0x45
,
...
...
@@ -121,7 +118,7 @@ int zfad_apply_user_offset(struct fa_dev *fa, struct zio_channel *chan,
if
(
range
<
0
)
return
range
;
if
(
range
==
FA100M14B4C_RANGE_OPEN
)
{
if
(
range
==
FA100M14B4C_RANGE_OPEN
||
fa_enable_test_data_adc
)
{
offset
=
FA_CAL_NO_OFFSET
;
gain
=
FA_CAL_NO_GAIN
;
}
else
{
...
...
@@ -234,7 +231,6 @@ int zfad_fsm_command(struct fa_dev *fa, uint32_t command)
{
struct
zio_cset
*
cset
=
fa
->
zdev
->
cset
;
uint32_t
val
;
int
err
;
if
(
command
!=
FA100M14B4C_CMD_START
&&
command
!=
FA100M14B4C_CMD_STOP
)
{
...
...
@@ -300,20 +296,6 @@ int zfad_fsm_command(struct fa_dev *fa, uint32_t command)
dev_dbg
(
fa
->
msgdev
,
"FSM START Command, Enable interrupts
\n
"
);
fa_enable_irqs
(
fa
);
/*
* Set the test data if necessary. This is unlikely to happen,
* and when this is the case we do not care about performances
*/
if
(
unlikely
(
fa_enable_test_data_adc
))
{
fa_enable_test_data_adc_pattern
&=
0xFFF
;
err
=
zfad_pattern_data_enable
(
fa
,
fa_enable_test_data_adc_pattern
,
fa_enable_test_data_adc
);
if
(
err
)
dev_warn
(
fa
->
msgdev
,
"Failed to set the ADC test data. Continue without
\n
"
);
else
if
(
fa_enable_test_data_adc
)
dev_info
(
fa
->
msgdev
,
"the ADC test data is enabled on all channels
\n
"
);
}
fa_writel
(
fa
,
fa
->
fa_adc_csr_base
,
&
zfad_regs
[
ZFA_CTL_RST_TRG_STA
],
1
);
}
else
{
...
...
kernel/fa-zio-drv.c
View file @
0c8bfab7
...
...
@@ -19,7 +19,6 @@
ZIO_PARAM_BUFFER
(
adc_buffer
);
/*
* zio device attributes
*/
...
...
@@ -120,6 +119,7 @@ static struct zio_attribute zfad_cset_ext_zattr[] = {
ZIO_PARAM_EXT
(
"sample-frequency"
,
ZIO_RO_PERM
,
ZFAT_SAMPLING_HZ
,
0
),
ZIO_PARAM_EXT
(
"max-sample-mshot"
,
ZIO_RO_PERM
,
ZFA_MULT_MAX_SAMP
,
0
),
ZIO_PARAM_EXT
(
"sample-counter"
,
ZIO_RO_PERM
,
ZFAT_CNT
,
0
),
ZIO_PARAM_EXT
(
"test-data-pattern"
,
ZIO_RW_PERM
,
ZFAT_ADC_TST_PATTERN
,
0
),
};
#if 0 /* FIXME Unused until TLV control will be available */
...
...
@@ -167,7 +167,7 @@ static int zfad_conf_set(struct device *dev, struct zio_attribute *zattr,
struct
fa_dev
*
fa
=
get_zfadc
(
dev
);
unsigned
int
baseoff
=
fa
->
fa_adc_csr_base
;
struct
zio_channel
*
chan
;
int
i
,
range
,
err
,
reg_index
;
int
i
,
range
,
err
=
0
,
reg_index
;
reg_index
=
zattr
->
id
;
i
=
FA100M14B4C_NCHAN
;
...
...
@@ -274,6 +274,24 @@ static int zfad_conf_set(struct device *dev, struct zio_attribute *zattr,
break
;
case
ZFA_CTL_FMS_CMD
:
return
zfad_fsm_command
(
fa
,
usr_val
);
case
ZFAT_ADC_TST_PATTERN
:
if
(
unlikely
(
fa_enable_test_data_adc
))
{
usr_val
&=
0xFFF
;
err
=
zfad_pattern_data_enable
(
fa
,
usr_val
,
fa_enable_test_data_adc
);
if
(
err
)
dev_warn
(
fa
->
msgdev
,
"Failed to set the ADC test data. Continue without
\n
"
);
else
if
(
fa_enable_test_data_adc
)
dev_info
(
fa
->
msgdev
,
"the ADC test data (0x%x) is enabled on all channels
\n
"
,
usr_val
);
return
err
;
}
else
{
dev_err
(
fa
->
msgdev
,
"Cannot set the ADC test data. The driver is not in test mode
\n
"
);
return
-
EPERM
;
}
}
fa_writel
(
fa
,
baseoff
,
&
zfad_regs
[
reg_index
],
usr_val
);
...
...
@@ -313,7 +331,7 @@ static int zfad_info_get(struct device *dev, struct zio_attribute *zattr,
case
ZFA_CHx_OFFSET
:
*
usr_val
=
fa
->
user_offset
[
to_zio_chan
(
dev
)
->
index
];
return
0
;
case
ZFAT_ADC_TST_PATTERN
:
case
ZFA_SW_R_NOADDRES_NBIT
:
case
ZFA_SW_R_NOADDERS_AUTO
:
/* ZIO automatically return the attribute value */
...
...
@@ -491,11 +509,16 @@ static void zfad_stop_cset(struct zio_cset *cset)
static
int
zfad_zio_probe
(
struct
zio_device
*
zdev
)
{
struct
fa_dev
*
fa
=
zdev
->
priv_d
;
int
err
;
dev_dbg
(
fa
->
msgdev
,
"%s:%d
\n
"
,
__func__
,
__LINE__
);
/* Save also the pointer to the real zio_device */
fa
->
zdev
=
zdev
;
err
=
zfad_pattern_data_enable
(
fa
,
0
,
fa_enable_test_data_adc
);
if
(
err
)
return
err
;
/* We don't have csets at this point, so don't do anything more */
return
0
;
}
...
...
kernel/fmc-adc-100m14b4cha.h
View file @
0c8bfab7
...
...
@@ -141,6 +141,8 @@ enum fa100m14b4c_fsm_state {
#include "field-desc.h"
extern
int
fa_enable_test_data_adc
;
/*
* ZFA_CHx_MULT : the trick which requires channel regs id grouped and ordered
* address offset between two registers of the same type on consecutive channel
...
...
@@ -187,6 +189,8 @@ enum zfadc_dregs_enum {
ZFAT_POST
,
/* Sample counter */
ZFAT_CNT
,
/* Pattern data for the ADC chip */
ZFAT_ADC_TST_PATTERN
,
/* start:declaration block requiring some order */
/* Channel 1 */
ZFA_CH1_CTL_RANGE
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment