Lines Matching +full:adc +full:- +full:dev

1 // SPDX-License-Identifier: GPL-2.0+
3 * Tests for the driver model ADC API
10 #include <adc.h>
19 #include <sandbox-adc.h>
24 struct udevice *dev; in dm_test_adc_bind() local
27 ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc", &dev)); in dm_test_adc_bind()
28 ut_asserteq_str(SANDBOX_ADC_DEVNAME, dev->name); in dm_test_adc_bind()
30 ut_assertok(adc_channel_mask(dev, &channel_mask)); in dm_test_adc_bind()
31 ut_asserteq((1 << SANDBOX_ADC_CHANNELS) - 1, channel_mask); in dm_test_adc_bind()
39 struct udevice *dev; in dm_test_adc_wrong_channel_selection() local
41 ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc", &dev)); in dm_test_adc_wrong_channel_selection()
42 ut_asserteq(-EINVAL, adc_start_channel(dev, SANDBOX_ADC_CHANNELS)); in dm_test_adc_wrong_channel_selection()
51 struct udevice *dev; in dm_test_adc_supply() local
54 ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc", &dev)); in dm_test_adc_supply()
56 /* Test Vss value - predefined 0 uV */ in dm_test_adc_supply()
57 ut_assertok(adc_vss_value(dev, &uV)); in dm_test_adc_supply()
60 /* Test Vdd initial value - buck2 */ in dm_test_adc_supply()
61 ut_assertok(adc_vdd_value(dev, &uV)); in dm_test_adc_supply()
64 /* Change Vdd value - buck2 manual preset */ in dm_test_adc_supply()
69 /* Update ADC platdata and get new Vdd value */ in dm_test_adc_supply()
70 ut_assertok(adc_vdd_value(dev, &uV)); in dm_test_adc_supply()
73 /* Disable buck2 and test ADC supply enable function */ in dm_test_adc_supply()
77 ut_assertok(adc_start_channel(dev, 0)); in dm_test_adc_supply()
95 struct udevice *dev; in dm_test_adc_single_channel_conversion() local
97 ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc", &dev)); in dm_test_adc_single_channel_conversion()
98 /* Test each ADC channel's value */ in dm_test_adc_single_channel_conversion()
100 ut_assertok(adc_start_channel(dev, tdata->id)); in dm_test_adc_single_channel_conversion()
101 ut_assertok(adc_channel_data(dev, tdata->id, &data)); in dm_test_adc_single_channel_conversion()
102 ut_asserteq(tdata->data, data); in dm_test_adc_single_channel_conversion()
112 struct udevice *dev; in dm_test_adc_multi_channel_conversion() local
120 ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc", &dev)); in dm_test_adc_multi_channel_conversion()
121 ut_assertok(adc_start_channels(dev, channel_mask)); in dm_test_adc_multi_channel_conversion()
122 ut_assertok(adc_channels_data(dev, channel_mask, channels)); in dm_test_adc_multi_channel_conversion()
126 ut_asserteq(tdata->data, channels[i].data); in dm_test_adc_multi_channel_conversion()
139 ut_assertok(adc_channel_single_shot("adc", tdata->id, &data)); in dm_test_adc_single_channel_shot()
141 ut_asserteq(tdata->data, data); in dm_test_adc_single_channel_shot()
158 ut_assertok(adc_channels_single_shot("adc", channel_mask, channels)); in dm_test_adc_multi_channel_shot()
162 ut_asserteq(tdata->data, channels[i].data); in dm_test_adc_multi_channel_shot()
183 struct udevice *dev; in dm_test_adc_raw_to_uV() local
186 ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc", &dev)); in dm_test_adc_raw_to_uV()
187 /* Test each ADC channel's value in microvolts */ in dm_test_adc_raw_to_uV()
189 ut_assertok(adc_start_channel(dev, tdata->id)); in dm_test_adc_raw_to_uV()
190 ut_assertok(adc_channel_data(dev, tdata->id, &data)); in dm_test_adc_raw_to_uV()
191 ut_assertok(adc_raw_to_uV(dev, data, &uV)); in dm_test_adc_raw_to_uV()