Lines Matching +full:model +full:- +full:dependent
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)
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 },
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()
108 ret = i2c_master_send(client, (u8 *)&buf, state->mreq_len); in abp060mg_get_measurement()
120 return -EIO; in abp060mg_get_measurement()
123 return -EIO; 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()