Lines Matching +full:lsb +full:- +full:first

1 // SPDX-License-Identifier: GPL-2.0
6 * Copyright (C) 2016-17 Renesas Electronics Corporation
7 * Copyright (C) 2016-17 Jacopo Mondi
21 * LSB is the ADC single digital step
22 * 1 LSB = (vref_mv / 2 ^ 16)
24 * LSB is used to calculate analog voltage value
27 * Ain = (count * LSB)
55 ret = spi_read(state->spi, state->buffer, sizeof(state->buffer)); in max11100_read_single()
57 dev_err(&indio_dev->dev, "SPI transfer failed\n"); in max11100_read_single()
61 /* the first 8 bits sent out from ADC must be 0s */ in max11100_read_single()
62 if (state->buffer[0]) { in max11100_read_single()
63 dev_err(&indio_dev->dev, "Invalid value: buffer[0] != 0\n"); in max11100_read_single()
64 return -EINVAL; in max11100_read_single()
67 *val = get_unaligned_be16(&state->buffer[1]); in max11100_read_single()
88 vref_uv = regulator_get_voltage(state->vref_reg); in max11100_read_raw()
90 /* dummy regulator "get_voltage" returns -EINVAL */ in max11100_read_raw()
91 return -EINVAL; in max11100_read_raw()
98 return -EINVAL; in max11100_read_raw()
116 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*state)); in max11100_probe()
118 return -ENOMEM; in max11100_probe()
121 state->spi = spi; in max11100_probe()
123 indio_dev->name = "max11100"; in max11100_probe()
124 indio_dev->info = &max11100_info; in max11100_probe()
125 indio_dev->modes = INDIO_DIRECT_MODE; in max11100_probe()
126 indio_dev->channels = max11100_channels; in max11100_probe()
127 indio_dev->num_channels = ARRAY_SIZE(max11100_channels); in max11100_probe()
129 state->vref_reg = devm_regulator_get(&spi->dev, "vref"); in max11100_probe()
130 if (IS_ERR(state->vref_reg)) in max11100_probe()
131 return PTR_ERR(state->vref_reg); in max11100_probe()
133 ret = regulator_enable(state->vref_reg); in max11100_probe()
137 ret = devm_add_action_or_reset(&spi->dev, max11100_regulator_disable, in max11100_probe()
138 state->vref_reg); in max11100_probe()
142 return devm_iio_device_register(&spi->dev, indio_dev); in max11100_probe()