Lines Matching +full:pressure +full:- +full:max

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2016 - Marcin Malagowski <mrc@bourne.st>
18 #define ABP060MG_NUM_COUNTS (ABP060MG_MAX_COUNTS - ABP060MG_MIN_COUNTS)
35 int max; member
40 [ABP006KG] = { .min = 0, .max = 6000 },
41 [ABP010KG] = { .min = 0, .max = 10000 },
42 [ABP016KG] = { .min = 0, .max = 16000 },
43 [ABP025KG] = { .min = 0, .max = 25000 },
44 [ABP040KG] = { .min = 0, .max = 40000 },
45 [ABP060KG] = { .min = 0, .max = 60000 },
46 [ABP100KG] = { .min = 0, .max = 100000 },
47 [ABP160KG] = { .min = 0, .max = 160000 },
48 [ABP250KG] = { .min = 0, .max = 250000 },
49 [ABP400KG] = { .min = 0, .max = 400000 },
50 [ABP600KG] = { .min = 0, .max = 600000 },
51 [ABP001GG] = { .min = 0, .max = 1000000 },
52 [ABP006KD] = { .min = -6000, .max = 6000 },
53 [ABP010KD] = { .min = -10000, .max = 10000 },
54 [ABP016KD] = { .min = -16000, .max = 16000 },
55 [ABP025KD] = { .min = -25000, .max = 25000 },
56 [ABP040KD] = { .min = -40000, .max = 40000 },
57 [ABP060KD] = { .min = -60000, .max = 60000 },
58 [ABP100KD] = { .min = -100000, .max = 100000 },
59 [ABP160KD] = { .min = -160000, .max = 160000 },
60 [ABP250KD] = { .min = -250000, .max = 250000 },
61 [ABP400KD] = { .min = -400000, .max = 400000 },
63 [ABP001PG] = { .min = 0, .max = 6985 },
64 [ABP005PG] = { .min = 0, .max = 34474 },
65 [ABP015PG] = { .min = 0, .max = 103421 },
66 [ABP030PG] = { .min = 0, .max = 206843 },
67 [ABP060PG] = { .min = 0, .max = 413686 },
68 [ABP100PG] = { .min = 0, .max = 689476 },
69 [ABP150PG] = { .min = 0, .max = 1034214 },
70 [ABP001PD] = { .min = -6895, .max = 6895 },
71 [ABP005PD] = { .min = -34474, .max = 34474 },
72 [ABP015PD] = { .min = -103421, .max = 103421 },
73 [ABP030PD] = { .min = -206843, .max = 206843 },
74 [ABP060PD] = { .min = -413686, .max = 413686 },
82 * bus-dependent MEASURE_REQUEST length.
87 /* model-dependent values (calculated on probe) */
102 struct i2c_client *client = state->client; in abp060mg_get_measurement()
104 u16 pressure; in abp060mg_get_measurement() local
108 ret = i2c_master_send(client, (u8 *)&buf, state->mreq_len); in abp060mg_get_measurement()
118 pressure = be16_to_cpu(buf[0]); in abp060mg_get_measurement()
119 if (pressure & ABP060MG_ERROR_MASK) in abp060mg_get_measurement()
120 return -EIO; in abp060mg_get_measurement()
122 if (pressure < ABP060MG_MIN_COUNTS || pressure > ABP060MG_MAX_COUNTS) in abp060mg_get_measurement()
123 return -EIO; in abp060mg_get_measurement()
125 *val = pressure; in abp060mg_get_measurement()
137 mutex_lock(&state->lock); in abp060mg_read_raw()
144 *val = state->offset; in abp060mg_read_raw()
148 *val = state->scale; in abp060mg_read_raw()
153 ret = -EINVAL; in abp060mg_read_raw()
157 mutex_unlock(&state->lock); in abp060mg_read_raw()
170 state->scale = cfg->max - cfg->min; in abp060mg_init_device()
171 state->offset = -ABP060MG_MIN_COUNTS; in abp060mg_init_device()
173 if (cfg->min < 0) /* differential */ in abp060mg_init_device()
174 state->offset -= ABP060MG_NUM_COUNTS >> 1; in abp060mg_init_device()
182 unsigned long cfg_id = id->driver_data; in abp060mg_probe()
184 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*state)); in abp060mg_probe()
186 return -ENOMEM; in abp060mg_probe()
190 state->client = client; in abp060mg_probe()
192 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_QUICK)) in abp060mg_probe()
193 state->mreq_len = 1; in abp060mg_probe()
197 indio_dev->name = dev_name(&client->dev); in abp060mg_probe()
198 indio_dev->modes = INDIO_DIRECT_MODE; in abp060mg_probe()
199 indio_dev->info = &abp060mg_info; in abp060mg_probe()
201 indio_dev->channels = abp060mg_channels; in abp060mg_probe()
202 indio_dev->num_channels = ARRAY_SIZE(abp060mg_channels); in abp060mg_probe()
204 mutex_init(&state->lock); in abp060mg_probe()
206 return devm_iio_device_register(&client->dev, indio_dev); in abp060mg_probe()
264 MODULE_DESCRIPTION("Honeywell ABP pressure sensor driver");