Lines Matching +full:vref +full:- +full:n +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0+
12 #include <dm/device-internal.h>
13 #include <dm/uclass-internal.h>
36 * 1-st and 3-rd are valid, then channel mask is: 0b1010, so request in check_channel()
39 if ((uc_pdata->channel_mask >= mask) && (uc_pdata->channel_mask & mask)) in check_channel()
42 printf("Error in %s/%s().\nWrong channel selection for device: %s\n", in check_channel()
43 __FILE__, caller_function, dev->name); in check_channel()
45 return -EINVAL; in check_channel()
54 if (uc_pdata->vdd_supply) { in adc_supply_enable()
56 ret = regulator_set_enable(uc_pdata->vdd_supply, true); in adc_supply_enable()
59 if (!ret && uc_pdata->vss_supply) { in adc_supply_enable()
61 ret = regulator_set_enable(uc_pdata->vss_supply, true); in adc_supply_enable()
65 pr_err("%s: can't enable %s-supply!", dev->name, supply_type); in adc_supply_enable()
75 return -ENOSYS; in adc_data_mask()
77 *data_mask = uc_pdata->data_mask; in adc_data_mask()
86 return -ENOSYS; in adc_channel_mask()
88 *channel_mask = uc_pdata->channel_mask; in adc_channel_mask()
97 if (!ops->stop) in adc_stop()
98 return -ENOSYS; in adc_stop()
100 return ops->stop(dev); in adc_stop()
108 if (!ops->start_channel) in adc_start_channel()
109 return -ENOSYS; in adc_start_channel()
119 return ops->start_channel(dev, channel); in adc_start_channel()
127 if (!ops->start_channels) in adc_start_channels()
128 return -ENOSYS; in adc_start_channels()
138 return ops->start_channels(dev, channel_mask); in adc_start_channels()
145 unsigned int timeout_us = uc_pdata->data_timeout_us; in adc_channel_data()
148 if (!ops->channel_data) in adc_channel_data()
149 return -ENOSYS; in adc_channel_data()
156 ret = ops->channel_data(dev, channel, data); in adc_channel_data()
157 if (!ret || ret != -EBUSY) in adc_channel_data()
162 } while (timeout_us--); in adc_channel_data()
171 unsigned int timeout_us = uc_pdata->multidata_timeout_us; in adc_channels_data()
175 if (!ops->channels_data) in adc_channels_data()
176 return -ENOSYS; in adc_channels_data()
183 ret = ops->channels_data(dev, channel_mask, channels); in adc_channels_data()
184 if (!ret || ret != -EBUSY) in adc_channels_data()
189 } while (timeout_us--); in adc_channels_data()
234 channels->id = channel; in _adc_channels_single_shot()
235 channels->data = data; in _adc_channels_single_shot()
263 if (ret != -ENOSYS) in adc_channels_single_shot()
275 * This function can't return supply device before its bind. in adc_vdd_platdata_update()
277 * will bind before its supply regulator device, then the below 'get' in adc_vdd_platdata_update()
280 if (!uc_pdata->vdd_supply) in adc_vdd_platdata_update()
283 ret = regulator_get_value(uc_pdata->vdd_supply); in adc_vdd_platdata_update()
287 uc_pdata->vdd_microvolts = ret; in adc_vdd_platdata_update()
297 if (!uc_pdata->vss_supply) in adc_vss_platdata_update()
300 ret = regulator_get_value(uc_pdata->vss_supply); in adc_vss_platdata_update()
304 uc_pdata->vss_microvolts = ret; in adc_vss_platdata_update()
312 int ret, value_sign = uc_pdata->vdd_polarity_negative ? -1 : 1; in adc_vdd_value()
319 if (uc_pdata->vdd_microvolts == -ENODATA) in adc_vdd_value()
320 return -ENODATA; in adc_vdd_value()
322 *uV = uc_pdata->vdd_microvolts * value_sign; in adc_vdd_value()
330 int ret, value_sign = uc_pdata->vss_polarity_negative ? -1 : 1; in adc_vss_value()
337 if (uc_pdata->vss_microvolts == -ENODATA) in adc_vss_value()
338 return -ENODATA; in adc_vss_value()
340 *uV = uc_pdata->vss_microvolts * value_sign; in adc_vss_value()
348 int ret, val, vref; in adc_raw_to_uV() local
351 ret = adc_vdd_value(dev, &vref); in adc_raw_to_uV()
356 vref -= val; in adc_raw_to_uV()
362 raw64 *= vref; in adc_raw_to_uV()
375 prop = "vdd-polarity-negative"; in adc_vdd_platdata_set()
376 uc_pdata->vdd_polarity_negative = dev_read_bool(dev, prop); in adc_vdd_platdata_set()
379 ret = device_get_supply_regulator(dev, "vdd-supply", in adc_vdd_platdata_set()
380 &uc_pdata->vdd_supply); in adc_vdd_platdata_set()
384 if (ret != -ENOENT) in adc_vdd_platdata_set()
387 /* No vdd-supply phandle. */ in adc_vdd_platdata_set()
388 prop = "vdd-microvolts"; in adc_vdd_platdata_set()
389 uc_pdata->vdd_microvolts = dev_read_u32_default(dev, prop, -ENODATA); in adc_vdd_platdata_set()
400 prop = "vss-polarity-negative"; in adc_vss_platdata_set()
401 uc_pdata->vss_polarity_negative = dev_read_bool(dev, prop); in adc_vss_platdata_set()
403 ret = device_get_supply_regulator(dev, "vss-supply", in adc_vss_platdata_set()
404 &uc_pdata->vss_supply); in adc_vss_platdata_set()
408 if (ret != -ENOENT) in adc_vss_platdata_set()
411 /* No vss-supply phandle. */ in adc_vss_platdata_set()
412 prop = "vss-microvolts"; in adc_vss_platdata_set()
413 uc_pdata->vss_microvolts = dev_read_u32_default(dev, prop, -ENODATA); in adc_vss_platdata_set()
425 pr_err("%s: Can't update Vdd. Error: %d", dev->name, ret); in adc_pre_probe()
430 pr_err("%s: Can't update Vss. Error: %d", dev->name, ret); in adc_pre_probe()