Lines Matching +full:cold +full:- +full:temp

1 // SPDX-License-Identifier: GPL-2.0
6 * Copyright (C) 2018-2019 Rockwell Collins
20 #include <dt-bindings/iio/temperature/thermocouple.h>
65 { /* Cold Junction Temperature */
90 return spi_write_then_read(data->spi, &reg, 1, val, read_size); in max31856_read()
101 return spi_write(data->spi, buf, 2); in max31856_write()
128 reg_cr1_val |= data->thermocouple_type; in max31856_init()
131 reg_cr1_val |= data->averaging << MAX31856_AVERAGING_SHIFT; in max31856_init()
149 if (data->filter_50hz) in max31856_init()
164 switch (chan->channel2) { in max31856_thermocouple_read()
177 *val -= 0x80000; in max31856_thermocouple_read()
188 /* Get Cold Junction Temp. offset register value */ in max31856_thermocouple_read()
196 *val -= 0x4000; in max31856_thermocouple_read()
200 return -EINVAL; in max31856_thermocouple_read()
208 return -EIO; in max31856_thermocouple_read()
227 switch (chan->channel2) { in max31856_read_raw()
229 /* Cold junction Temp. Data resolution is 0.015625 */ in max31856_read_raw()
235 /* Thermocouple Temp. Data resolution is 0.0078125 */ in max31856_read_raw()
242 *val = 1 << data->averaging; in max31856_read_raw()
245 *val = max31856_tc_types[data->thermocouple_type]; in max31856_read_raw()
248 ret = -EINVAL; in max31856_read_raw()
277 return -EINVAL; in max31856_write_raw()
278 msb = fls(val) - 1; in max31856_write_raw()
283 data->averaging = msb; in max31856_write_raw()
288 int tc_type = -1; in max31856_write_raw()
298 return -EINVAL; in max31856_write_raw()
300 data->thermocouple_type = tc_type; in max31856_write_raw()
305 return -EINVAL; in max31856_write_raw()
349 return sysfs_emit(buf, "%d\n", data->filter_50hz ? 50 : 60); in show_filter()
368 data->filter_50hz = true; in set_filter()
371 data->filter_50hz = false; in set_filter()
374 return -EINVAL; in set_filter()
411 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*data)); in max31856_probe()
413 return -ENOMEM; in max31856_probe()
416 data->spi = spi; in max31856_probe()
417 data->filter_50hz = false; in max31856_probe()
421 indio_dev->info = &max31856_info; in max31856_probe()
422 indio_dev->name = id->name; in max31856_probe()
423 indio_dev->modes = INDIO_DIRECT_MODE; in max31856_probe()
424 indio_dev->channels = max31856_channels; in max31856_probe()
425 indio_dev->num_channels = ARRAY_SIZE(max31856_channels); in max31856_probe()
427 ret = device_property_read_u32(&spi->dev, "thermocouple-type", &data->thermocouple_type); in max31856_probe()
429 dev_info(&spi->dev, in max31856_probe()
430 "Could not read thermocouple type DT property, configuring as a K-Type\n"); in max31856_probe()
431 data->thermocouple_type = THERMOCOUPLE_TYPE_K; in max31856_probe()
438 switch (data->thermocouple_type) { in max31856_probe()
449 dev_err(&spi->dev, in max31856_probe()
450 "error: thermocouple-type %u not supported by max31856\n" in max31856_probe()
451 , data->thermocouple_type); in max31856_probe()
452 return -EINVAL; in max31856_probe()
457 dev_err(&spi->dev, "error: Failed to configure max31856\n"); in max31856_probe()
461 return devm_iio_device_register(&spi->dev, indio_dev); in max31856_probe()