Lines Matching +full:datasheet +full:- +full:recommended
1 // SPDX-License-Identifier: GPL-2.0
3 * 3-axis accelerometer driver supporting following Bosch-Sensortec chips:
4 * - BMI088
6 * Copyright (c) 2018-2021, Topic Embedded Products
21 #include "bmi088-accel.h"
96 /* Available OSR (over sampling rate) sets the 3dB cut-off frequency */
137 /* Mark the RESET as volatile too, it is self-clearing */
160 ret = regmap_write(data->regmap, BMI088_ACCEL_REG_PWR_CTRL, 0x4); in bmi088_accel_power_up()
164 /* Datasheet recommends to wait at least 5ms before communication */ in bmi088_accel_power_up()
168 ret = regmap_write(data->regmap, BMI088_ACCEL_REG_PWR_CONF, 0x0); in bmi088_accel_power_up()
172 /* Recommended at least 1ms before further communication */ in bmi088_accel_power_up()
183 ret = regmap_write(data->regmap, BMI088_ACCEL_REG_PWR_CONF, 0x3); in bmi088_accel_power_down()
187 /* Recommended at least 1ms before further communication */ in bmi088_accel_power_down()
191 ret = regmap_write(data->regmap, BMI088_ACCEL_REG_PWR_CTRL, 0x0); in bmi088_accel_power_down()
195 /* Datasheet recommends to wait at least 5ms before communication */ in bmi088_accel_power_down()
207 ret = regmap_read(data->regmap, BMI088_ACCEL_REG_ACC_CONF, in bmi088_accel_get_sample_freq()
213 value -= BMI088_ACCEL_MODE_ODR_12_5; in bmi088_accel_get_sample_freq()
216 if (value >= ARRAY_SIZE(bmi088_sample_freqs) - 1) in bmi088_accel_get_sample_freq()
217 return -EINVAL; in bmi088_accel_get_sample_freq()
235 return -EINVAL; in bmi088_accel_set_sample_freq()
239 return regmap_update_bits(data->regmap, BMI088_ACCEL_REG_ACC_CONF, in bmi088_accel_set_sample_freq()
248 if (val == data->chip_info->scale_table[i][0] && in bmi088_accel_set_scale()
249 val2 == data->chip_info->scale_table[i][1]) in bmi088_accel_set_scale()
253 return -EINVAL; in bmi088_accel_set_scale()
255 return regmap_write(data->regmap, BMI088_ACCEL_REG_ACC_RANGE, i); in bmi088_accel_set_scale()
263 ret = regmap_bulk_read(data->regmap, BMI088_ACCEL_REG_TEMP, in bmi088_accel_get_temp()
264 &data->buffer, sizeof(__be16)); in bmi088_accel_get_temp()
268 /* data->buffer is cacheline aligned */ in bmi088_accel_get_temp()
269 temp = be16_to_cpu(*(__be16 *)data->buffer); in bmi088_accel_get_temp()
283 ret = regmap_bulk_read(data->regmap, in bmi088_accel_get_axis()
284 BMI088_ACCEL_AXIS_TO_REG(chan->scan_index), in bmi088_accel_get_axis()
285 data->buffer, sizeof(__le16)); in bmi088_accel_get_axis()
289 raw_val = le16_to_cpu(*(__le16 *)data->buffer); in bmi088_accel_get_axis()
300 struct device *dev = regmap_get_device(data->regmap); in bmi088_accel_read_raw()
306 switch (chan->type) { in bmi088_accel_read_raw()
330 return -EINVAL; in bmi088_accel_read_raw()
333 switch (chan->type) { in bmi088_accel_read_raw()
339 return -EINVAL; in bmi088_accel_read_raw()
342 switch (chan->type) { in bmi088_accel_read_raw()
352 ret = regmap_read(data->regmap, in bmi088_accel_read_raw()
358 *val = data->chip_info->scale_table[reg][0]; in bmi088_accel_read_raw()
359 *val2 = data->chip_info->scale_table[reg][1]; in bmi088_accel_read_raw()
364 return -EINVAL; in bmi088_accel_read_raw()
377 return -EINVAL; in bmi088_accel_read_raw()
395 *vals = (const int *)data->chip_info->scale_table; in bmi088_accel_read_avail()
405 return -EINVAL; in bmi088_accel_read_avail()
414 struct device *dev = regmap_get_device(data->regmap); in bmi088_accel_write_raw()
437 return -EINVAL; in bmi088_accel_write_raw()
459 .scan_index = -1,
469 .name = "bmi085-accel",
476 .name = "bmi088-accel",
483 .name = "bmi090l-accel",
504 struct device *dev = regmap_get_device(data->regmap); in bmi088_accel_chip_init()
509 return -ENODEV; in bmi088_accel_chip_init()
512 regmap_read(data->regmap, BMI088_ACCEL_REG_INT_STATUS, &val); in bmi088_accel_chip_init()
518 ret = regmap_write(data->regmap, BMI088_ACCEL_REG_RESET, in bmi088_accel_chip_init()
526 regmap_read(data->regmap, BMI088_ACCEL_REG_INT_STATUS, &val); in bmi088_accel_chip_init()
529 ret = regmap_read(data->regmap, BMI088_ACCEL_REG_CHIP_ID, &val); in bmi088_accel_chip_init()
541 data->chip_info = &bmi088_accel_chip_info_tbl[type]; in bmi088_accel_chip_init()
543 data->chip_info = &bmi088_accel_chip_info_tbl[i]; in bmi088_accel_chip_init()
560 return -ENOMEM; in bmi088_accel_core_probe()
565 data->regmap = regmap; in bmi088_accel_core_probe()
571 indio_dev->channels = data->chip_info->channels; in bmi088_accel_core_probe()
572 indio_dev->num_channels = data->chip_info->num_channels; in bmi088_accel_core_probe()
573 indio_dev->name = data->chip_info->name; in bmi088_accel_core_probe()
574 indio_dev->available_scan_masks = bmi088_accel_scan_masks; in bmi088_accel_core_probe()
575 indio_dev->modes = INDIO_DIRECT_MODE; in bmi088_accel_core_probe()
576 indio_dev->info = &bmi088_accel_info; in bmi088_accel_core_probe()