Lines Matching +full:range +full:- +full:microvolt
1 // SPDX-License-Identifier: GPL-2.0+
3 // Copyright (c) 2010-2024 Analog Devices Inc.
18 [AD3552R_CH_OUTPUT_RANGE_NEG_5__5V] = { -5000, 5000 },
19 [AD3552R_CH_OUTPUT_RANGE_NEG_10__10V] = { -10000, 10000 }
28 [AD3542R_CH_OUTPUT_RANGE_NEG_2P5__7P5V] = { -2500, 7500 },
29 [AD3542R_CH_OUTPUT_RANGE_NEG_5__5V] = { -5000, 5000 }
58 * Vmax = 2.5 - [(GainP + Offset / 1024) * 2.5 * Rfb * 1.03] in ad3552r_get_custom_range()
63 common = 2575 * ch_data->rfb; in ad3552r_get_custom_range()
64 offset = ch_data->gain_offset; in ad3552r_get_custom_range()
66 gn = gains_scaling_table[ch_data->n]; in ad3552r_get_custom_range()
71 gp = gains_scaling_table[ch_data->p]; in ad3552r_get_custom_range()
72 tmp = (1024 * gp - AD3552R_GAIN_SCALE * offset) * common; in ad3552r_get_custom_range()
74 *v_min = vref - tmp; in ad3552r_get_custom_range()
83 if (ch_data->range_override) { in ad3552r_calc_gain_and_offset()
86 /* Normal range */ in ad3552r_calc_gain_and_offset()
87 idx = ch_data->range; in ad3552r_calc_gain_and_offset()
88 v_min = model_data->ranges_table[idx][0]; in ad3552r_calc_gain_and_offset()
89 v_max = model_data->ranges_table[idx][1]; in ad3552r_calc_gain_and_offset()
102 span = v_max - v_min; in ad3552r_calc_gain_and_offset()
103 ch_data->scale_int = div_s64_rem(span, 65536, &rem); in ad3552r_calc_gain_and_offset()
105 ch_data->scale_dec = DIV_ROUND_CLOSEST((s64)rem * 1000000, 65536); in ad3552r_calc_gain_and_offset()
107 ch_data->offset_int = div_s64_rem(v_min * 65536, span, &rem); in ad3552r_calc_gain_and_offset()
109 ch_data->offset_dec = div_s64(tmp, span); in ad3552r_calc_gain_and_offset()
119 if (voltage < 0 && voltage != -ENODEV) in ad3552r_get_ref_voltage()
123 if (voltage == -ENODEV) { in ad3552r_get_ref_voltage()
124 if (device_property_read_bool(dev, "adi,vref-out-en")) in ad3552r_get_ref_voltage()
132 if (voltage > 2500000 + delta || voltage < 2500000 - delta) { in ad3552r_get_ref_voltage()
133 dev_warn(dev, "vref-supply must be 2.5V"); in ad3552r_get_ref_voltage()
134 return -EINVAL; in ad3552r_get_ref_voltage()
148 err = device_property_read_u32(dev, "adi,sdo-drive-strength", in ad3552r_get_drive_strength()
154 dev_err_probe(dev, -EINVAL, in ad3552r_get_drive_strength()
155 "adi,sdo-drive-strength must be less than 4\n"); in ad3552r_get_drive_strength()
156 return -EINVAL; in ad3552r_get_drive_strength()
172 "custom-output-range-config"); in ad3552r_get_custom_gain()
175 return dev_err_probe(dev, -EINVAL, in ad3552r_get_custom_gain()
176 "custom-output-range-config mandatory\n"); in ad3552r_get_custom_gain()
178 err = fwnode_property_read_u32(gain_child, "adi,gain-scaling-p", &val); in ad3552r_get_custom_gain()
181 "adi,gain-scaling-p mandatory\n"); in ad3552r_get_custom_gain()
184 err = fwnode_property_read_u32(gain_child, "adi,gain-scaling-n", &val); in ad3552r_get_custom_gain()
187 "adi,gain-scaling-n property mandatory\n"); in ad3552r_get_custom_gain()
190 err = fwnode_property_read_u32(gain_child, "adi,rfb-ohms", &val); in ad3552r_get_custom_gain()
193 "adi,rfb-ohms mandatory\n"); in ad3552r_get_custom_gain()
196 err = fwnode_property_read_u32(gain_child, "adi,gain-offset", &val); in ad3552r_get_custom_gain()
199 "adi,gain-offset mandatory\n"); in ad3552r_get_custom_gain()
211 for (i = 0; i < model_info->num_ranges; i++) in ad3552r_find_range()
212 if (vals[0] == model_info->ranges_table[i][0] * 1000 && in ad3552r_find_range()
213 vals[1] == model_info->ranges_table[i][1] * 1000) in ad3552r_find_range()
216 return -EINVAL; in ad3552r_find_range()
226 /* This property is optional, so returning -ENOENT if missing */ in ad3552r_get_output_range()
227 if (!fwnode_property_present(child, "adi,output-range-microvolt")) in ad3552r_get_output_range()
228 return -ENOENT; in ad3552r_get_output_range()
231 "adi,output-range-microvolt", in ad3552r_get_output_range()
235 "invalid adi,output-range-microvolt\n"); in ad3552r_get_output_range()
240 "invalid adi,output-range-microvolt value\n"); in ad3552r_get_output_range()