@@ -73,6 +73,8 @@
#define BMI088_ACCEL_FIFO_MODE_FIFO 0x40
#define BMI088_ACCEL_FIFO_MODE_STREAM 0x80
+#define BMIO088_ACCEL_ACC_RANGE_MSK GENMASK(1, 0)
+
enum bmi088_accel_axis {
AXIS_X,
AXIS_Y,
@@ -119,6 +121,7 @@ struct bmi088_accel_chip_info {
u8 chip_id;
const struct iio_chan_spec *channels;
int num_channels;
+ const int scale_table[4][2];
};
struct bmi088_accel_data {
@@ -280,6 +283,7 @@ static int bmi088_accel_read_raw(struct iio_dev *indio_dev,
struct bmi088_accel_data *data = iio_priv(indio_dev);
struct device *dev = regmap_get_device(data->regmap);
int ret;
+ int reg;
switch (mask) {
case IIO_CHAN_INFO_RAW:
@@ -330,13 +334,14 @@ static int bmi088_accel_read_raw(struct iio_dev *indio_dev,
return ret;
ret = regmap_read(data->regmap,
- BMI088_ACCEL_REG_ACC_RANGE, val);
+ BMI088_ACCEL_REG_ACC_RANGE, ®);
if (ret)
goto out_read_raw_pm_put;
- *val2 = 15 - (*val & 0x3);
- *val = 3 * 980;
- ret = IIO_VAL_FRACTIONAL_LOG2;
+ reg = FIELD_GET(BMIO088_ACCEL_ACC_RANGE_MSK, reg);
+ *val = data->chip_info->scale_table[reg][0];
+ *val2 = data->chip_info->scale_table[reg][1];
+ ret = IIO_VAL_INT_PLUS_MICRO;
goto out_read_raw_pm_put;
default:
@@ -432,6 +437,7 @@ static const struct bmi088_accel_chip_info bmi088_accel_chip_info_tbl[] = {
.chip_id = 0x1E,
.channels = bmi088_accel_channels,
.num_channels = ARRAY_SIZE(bmi088_accel_channels),
+ .scale_table = {{0, 897}, {0, 1795}, {0, 3590}, {0, 7179}},
},
};