Commit 63ccf423 authored by Federico Vaga's avatar Federico Vaga

drv: handle also calibration ranges

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 23090067
......@@ -25,6 +25,9 @@ int fa_enable_test_data_adc = 0;
module_param_named(enable_test_data_adc, fa_enable_test_data_adc, int, 0444);
static const int zfad_hw_range[] = {
[FA100M14B4C_RANGE_10V_CAL] = 0x44,
[FA100M14B4C_RANGE_1V_CAL] = 0x40,
[FA100M14B4C_RANGE_100mV_CAL] = 0x42,
[FA100M14B4C_RANGE_10V] = 0x45,
[FA100M14B4C_RANGE_1V] = 0x11,
[FA100M14B4C_RANGE_100mV] = 0x23,
......@@ -159,6 +162,8 @@ int zfad_apply_offset(struct zio_channel *chan)
if (range == FA100M14B4C_RANGE_OPEN || fa_enable_test_data_adc)
range = FA100M14B4C_RANGE_1V;
else if (range >= FA100M14B4C_RANGE_10V_CAL)
range -= FA100M14B4C_RANGE_10V_CAL;
hwval = zfad_offset_to_dac(chan, off_uv, range);
return zfad_dac_set(chan, hwval);
......@@ -216,6 +221,8 @@ int zfad_set_range(struct fa_dev *fa, struct zio_channel *chan,
if (range == FA100M14B4C_RANGE_OPEN || fa_enable_test_data_adc)
range = FA100M14B4C_RANGE_1V;
else if (range >= FA100M14B4C_RANGE_10V_CAL)
range -= FA100M14B4C_RANGE_10V_CAL;
if (range < 0 || range > ARRAY_SIZE(fa->calib.adc)) {
dev_info(fa->msgdev, "Invalid range %i or ch %i\n",
......
......@@ -108,6 +108,9 @@ enum fa100m14b4c_input_range {
FA100M14B4C_RANGE_1V,
FA100M14B4C_RANGE_100mV,
FA100M14B4C_RANGE_OPEN, /* Channel disconnected from ADC */
FA100M14B4C_RANGE_10V_CAL, /* Channel disconnected from ADC */
FA100M14B4C_RANGE_1V_CAL, /* Channel disconnected from ADC */
FA100M14B4C_RANGE_100mV_CAL, /* Channel disconnected from ADC */
};
enum fa100m14b4c_fsm_cmd {
......
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