drivers:iio:stm:imu:st_asm330lhhx: Enable temperature sensor
Enable internal temperature sensor by default. Signed-off-by: Mario Tesi <mario.tesi@st.com> Change-Id: Id5e1b40957a13db670074cd574070d91ed7f6c9d Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/261192 Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com> Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
This commit is contained in:
parent
176587d492
commit
d5251c1ad2
@ -27,12 +27,6 @@ config IIO_ST_ASM330LHHX_MAY_WAKEUP
|
||||
help
|
||||
Enable wake-up irq on interrupt line
|
||||
|
||||
config IIO_ST_ASM330LHHX_EN_TEMPERATURE
|
||||
bool "Enable internal temperature sensor"
|
||||
depends on IIO_ST_ASM330LHHX
|
||||
help
|
||||
Enable internal temperature sensor channel
|
||||
|
||||
config IIO_ST_ASM330LHHX_EN_BASIC_FEATURES
|
||||
bool "Enable internal basic features event detection"
|
||||
depends on IIO_ST_ASM330LHHX
|
||||
|
@ -273,9 +273,7 @@ struct st_asm330lhhx_fs {
|
||||
#define ST_ASM330LHHX_FS_LIST_SIZE 5
|
||||
#define ST_ASM330LHHX_FS_ACC_LIST_SIZE 4
|
||||
#define ST_ASM330LHHX_FS_GYRO_LIST_SIZE 5
|
||||
#ifdef CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE
|
||||
#define ST_ASM330LHHX_FS_TEMP_LIST_SIZE 1
|
||||
#endif /* CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE */
|
||||
|
||||
/**
|
||||
* struct st_asm330lhhx_fs_table_entry - Full Scale sensor table
|
||||
@ -301,9 +299,7 @@ struct st_asm330lhhx_fs_table_entry {
|
||||
enum st_asm330lhhx_sensor_id {
|
||||
ST_ASM330LHHX_ID_GYRO = 0,
|
||||
ST_ASM330LHHX_ID_ACC,
|
||||
#ifdef CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE
|
||||
ST_ASM330LHHX_ID_TEMP,
|
||||
#endif /* CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE */
|
||||
ST_ASM330LHHX_ID_EVENT,
|
||||
ST_ASM330LHHX_ID_FF = ST_ASM330LHHX_ID_EVENT,
|
||||
ST_ASM330LHHX_ID_SC,
|
||||
|
@ -34,9 +34,7 @@
|
||||
enum {
|
||||
ST_ASM330LHHX_GYRO_TAG = 0x01,
|
||||
ST_ASM330LHHX_ACC_TAG = 0x02,
|
||||
#ifdef CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE
|
||||
ST_ASM330LHHX_TEMP_TAG = 0x03,
|
||||
#endif /* CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE */
|
||||
ST_ASM330LHHX_TS_TAG = 0x04,
|
||||
};
|
||||
|
||||
@ -211,11 +209,9 @@ static struct iio_dev *st_asm330lhhx_get_iiodev_from_tag(struct st_asm330lhhx_hw
|
||||
case ST_ASM330LHHX_ACC_TAG:
|
||||
iio_dev = hw->iio_devs[ST_ASM330LHHX_ID_ACC];
|
||||
break;
|
||||
#ifdef CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE
|
||||
case ST_ASM330LHHX_TEMP_TAG:
|
||||
iio_dev = hw->iio_devs[ST_ASM330LHHX_ID_TEMP];
|
||||
break;
|
||||
#endif /* CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE */
|
||||
default:
|
||||
iio_dev = NULL;
|
||||
break;
|
||||
@ -493,7 +489,6 @@ static int st_asm330lhhx_update_fifo(struct iio_dev *iio_dev,
|
||||
if (err < 0)
|
||||
goto out;
|
||||
|
||||
#ifdef CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE
|
||||
/*
|
||||
* This is an auxiliary sensor, it need to get batched
|
||||
* toghether at least with a primary sensor (Acc/Gyro).
|
||||
@ -521,7 +516,6 @@ static int st_asm330lhhx_update_fifo(struct iio_dev *iio_dev,
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE */
|
||||
|
||||
err = st_asm330lhhx_update_watermark(sensor, sensor->watermark);
|
||||
if (err < 0)
|
||||
|
@ -148,7 +148,6 @@ static const struct st_asm330lhhx_odr_table_entry st_asm330lhhx_odr_table[] = {
|
||||
.odr_avl[5] = { 416, 0, 0x06, 0x06 },
|
||||
.odr_avl[6] = { 833, 0, 0x07, 0x07 },
|
||||
},
|
||||
#ifdef CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE
|
||||
[ST_ASM330LHHX_ID_TEMP] = {
|
||||
.size = 2,
|
||||
.batching_reg = {
|
||||
@ -158,7 +157,6 @@ static const struct st_asm330lhhx_odr_table_entry st_asm330lhhx_odr_table[] = {
|
||||
.odr_avl[0] = { 12, 500000, 0x02, 0x02 },
|
||||
.odr_avl[1] = { 52, 0, 0x03, 0x03 },
|
||||
},
|
||||
#endif /* CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -263,7 +261,6 @@ static const struct st_asm330lhhx_fs_table_entry st_asm330lhhx_fs_table[] = {
|
||||
.val = 0x1,
|
||||
},
|
||||
},
|
||||
#ifdef CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE
|
||||
[ST_ASM330LHHX_ID_TEMP] = {
|
||||
.size = ST_ASM330LHHX_FS_TEMP_LIST_SIZE,
|
||||
.fs_avl[0] = {
|
||||
@ -271,7 +268,6 @@ static const struct st_asm330lhhx_fs_table_entry st_asm330lhhx_fs_table[] = {
|
||||
.val = 0x0
|
||||
},
|
||||
},
|
||||
#endif /* CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_IIO_ST_ASM330LHHX_EN_BASIC_FEATURES
|
||||
@ -965,9 +961,7 @@ static int st_asm330lhhx_set_odr(struct st_asm330lhhx_sensor *sensor, int req_od
|
||||
case ST_ASM330LHHX_ID_FF:
|
||||
case ST_ASM330LHHX_ID_SC:
|
||||
case ST_ASM330LHHX_ID_6D:
|
||||
#ifdef CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE
|
||||
case ST_ASM330LHHX_ID_TEMP:
|
||||
#endif /* CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE */
|
||||
case ST_ASM330LHHX_ID_ACC: {
|
||||
int odr;
|
||||
int i;
|
||||
@ -1084,13 +1078,11 @@ static int st_asm330lhhx_read_raw(struct iio_dev *iio_dev,
|
||||
break;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
switch (ch->type) {
|
||||
#ifdef CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE
|
||||
case IIO_TEMP:
|
||||
*val = 1;
|
||||
*val2 = ST_ASM330LHHX_TEMP_GAIN;
|
||||
ret = IIO_VAL_FRACTIONAL;
|
||||
break;
|
||||
#endif /* CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE */
|
||||
case IIO_ACCEL:
|
||||
case IIO_ANGL_VEL:
|
||||
*val = 0;
|
||||
@ -1562,11 +1554,13 @@ static const struct iio_info st_asm330lhhx_temp_info = {
|
||||
.write_raw = st_asm330lhhx_write_raw,
|
||||
};
|
||||
|
||||
static const unsigned long st_asm330lhhx_available_scan_masks[] = { BIT(0) |
|
||||
BIT(1) |
|
||||
BIT(2) |
|
||||
BIT(3),
|
||||
0x0 };
|
||||
static const unsigned long st_asm330lhhx_available_scan_masks[] = {
|
||||
GENMASK(3, 0), 0x0
|
||||
};
|
||||
|
||||
static const unsigned long st_asm330lhhx_temp_available_scan_masks[] = {
|
||||
GENMASK(1, 0), 0x0
|
||||
};
|
||||
|
||||
static int st_asm330lhhx_reset_device(struct st_asm330lhhx_hw *hw)
|
||||
{
|
||||
@ -1724,20 +1718,20 @@ static struct iio_dev *st_asm330lhhx_alloc_iiodev(struct st_asm330lhhx_hw *hw,
|
||||
sensor->min_st = ST_ASM330LHHX_SELFTEST_GYRO_MIN;
|
||||
sensor->max_st = ST_ASM330LHHX_SELFTEST_GYRO_MAX;
|
||||
break;
|
||||
#ifdef CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE
|
||||
case ST_ASM330LHHX_ID_TEMP:
|
||||
iio_dev->channels = st_asm330lhhx_temp_channels;
|
||||
iio_dev->num_channels = ARRAY_SIZE(st_asm330lhhx_temp_channels);
|
||||
scnprintf(sensor->name, sizeof(sensor->name),
|
||||
"%s_temp", hw->settings->id.name);
|
||||
iio_dev->info = &st_asm330lhhx_temp_info;
|
||||
iio_dev->available_scan_masks =
|
||||
st_asm330lhhx_temp_available_scan_masks;
|
||||
sensor->max_watermark = ST_ASM330LHHX_MAX_FIFO_DEPTH;
|
||||
sensor->gain = st_asm330lhhx_fs_table[id].fs_avl[ST_ASM330LHHX_DEFAULT_T_FS_INDEX].gain;
|
||||
sensor->odr = st_asm330lhhx_odr_table[id].odr_avl[ST_ASM330LHHX_DEFAULT_T_ODR_INDEX].hz;
|
||||
sensor->uodr = st_asm330lhhx_odr_table[id].odr_avl[ST_ASM330LHHX_DEFAULT_T_ODR_INDEX].uhz;
|
||||
sensor->offset = ST_ASM330LHHX_TEMP_OFFSET;
|
||||
break;
|
||||
#endif /* CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE */
|
||||
default:
|
||||
iio_device_free(iio_dev);
|
||||
|
||||
|
@ -63,14 +63,12 @@ static void st_asm330lhhx_read_hw_timestamp(struct st_asm330lhhx_hw *hw)
|
||||
iio_push_event(hw->iio_devs[ST_ASM330LHHX_ID_ACC], eventMSB,
|
||||
timestamp_cpu);
|
||||
}
|
||||
#ifdef CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE
|
||||
if (hw->enable_mask & BIT(ST_ASM330LHHX_ID_TEMP)) {
|
||||
iio_push_event(hw->iio_devs[ST_ASM330LHHX_ID_TEMP], eventLSB,
|
||||
timestamp_cpu);
|
||||
iio_push_event(hw->iio_devs[ST_ASM330LHHX_ID_TEMP], eventMSB,
|
||||
timestamp_cpu);
|
||||
}
|
||||
#endif /* CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE */
|
||||
|
||||
if (hw->timesync_c < 6)
|
||||
hw->timesync_c++;
|
||||
|
@ -1,6 +1,5 @@
|
||||
CONFIG_IIO_ST_ASM330LHHX=m
|
||||
CONFIG_IIO_ST_ASM330LHHX_I2C=m
|
||||
CONFIG_IIO_ST_ASM330LHHX_SPI=m
|
||||
CONFIG_IIO_ST_ASM330LHHX_EN_TEMPERATURE=y
|
||||
CONFIG_IIO_ST_ASM330LHHX_EN_BASIC_FEATURES=y
|
||||
CONFIG_IIO_ST_ASM330LHHX_MAY_WAKEUP=y
|
||||
|
Loading…
Reference in New Issue
Block a user