Lines Matching +full:sens +full:-

1 // SPDX-License-Identifier: GPL-2.0-only
20 * 0x50 ... read-only EEPROM with calibration data
21 * 0x77 ... read-write ADC for pressure and temperature
85 ret = i2c_smbus_write_byte_data(priv->client, HP03_ADC_WRITE_REG, reg); in hp03_get_temp_pressure()
91 return i2c_smbus_read_word_data(priv->client, HP03_ADC_READ_REG); in hp03_get_temp_pressure()
96 struct device *dev = &priv->client->dev; in hp03_update_temp_pressure()
99 int ab_val, d1_val, d2_val, diff_val, dut, off, sens, x; in hp03_update_temp_pressure() local
103 ret = regmap_bulk_read(priv->eeprom_regmap, HP03_EEPROM_CX_OFFSET, in hp03_update_temp_pressure()
112 gpiod_set_value_cansleep(priv->xclr_gpio, 1); in hp03_update_temp_pressure()
128 gpiod_set_value_cansleep(priv->xclr_gpio, 0); in hp03_update_temp_pressure()
138 ab_val = coefs[14]; /* A-value */ in hp03_update_temp_pressure()
140 ab_val = coefs[15]; /* B-value */ in hp03_update_temp_pressure()
142 diff_val = d2_val - cx_val[4]; in hp03_update_temp_pressure()
144 dut = diff_val - dut; in hp03_update_temp_pressure()
146 off = (cx_val[1] + (((cx_val[3] - 1024) * dut) >> 14)) * 4; in hp03_update_temp_pressure()
147 sens = cx_val[0] + ((cx_val[2] * dut) >> 10); in hp03_update_temp_pressure()
148 x = ((sens * (d1_val - 7168)) >> 14) - off; in hp03_update_temp_pressure()
150 priv->pressure = ((x * 100) >> 5) + (cx_val[6] * 10); in hp03_update_temp_pressure()
151 priv->temp = 250 + ((dut * cx_val[5]) >> 16) - (dut >> coefs[17]); in hp03_update_temp_pressure()
156 gpiod_set_value_cansleep(priv->xclr_gpio, 0); in hp03_update_temp_pressure()
167 mutex_lock(&priv->lock); in hp03_read_raw()
169 mutex_unlock(&priv->lock); in hp03_read_raw()
176 switch (chan->type) { in hp03_read_raw()
178 *val = priv->pressure; in hp03_read_raw()
181 *val = priv->temp; in hp03_read_raw()
184 return -EINVAL; in hp03_read_raw()
188 switch (chan->type) { in hp03_read_raw()
197 return -EINVAL; in hp03_read_raw()
201 return -EINVAL; in hp03_read_raw()
204 return -EINVAL; in hp03_read_raw()
214 struct device *dev = &client->dev; in hp03_probe()
221 return -ENOMEM; in hp03_probe()
224 priv->client = client; in hp03_probe()
225 mutex_init(&priv->lock); in hp03_probe()
227 indio_dev->name = id->name; in hp03_probe()
228 indio_dev->channels = hp03_channels; in hp03_probe()
229 indio_dev->num_channels = ARRAY_SIZE(hp03_channels); in hp03_probe()
230 indio_dev->info = &hp03_info; in hp03_probe()
231 indio_dev->modes = INDIO_DIRECT_MODE; in hp03_probe()
233 priv->xclr_gpio = devm_gpiod_get_index(dev, "xclr", 0, GPIOD_OUT_HIGH); in hp03_probe()
234 if (IS_ERR(priv->xclr_gpio)) { in hp03_probe()
236 ret = PTR_ERR(priv->xclr_gpio); in hp03_probe()
241 * Allocate another device for the on-sensor EEPROM, in hp03_probe()
245 priv->eeprom_client = devm_i2c_new_dummy_device(dev, client->adapter, in hp03_probe()
247 if (IS_ERR(priv->eeprom_client)) { in hp03_probe()
249 return PTR_ERR(priv->eeprom_client); in hp03_probe()
252 priv->eeprom_regmap = devm_regmap_init_i2c(priv->eeprom_client, in hp03_probe()
254 if (IS_ERR(priv->eeprom_regmap)) { in hp03_probe()
256 return PTR_ERR(priv->eeprom_regmap); in hp03_probe()