2023-04-12 09:14 PM
I am using lis2dw12 on congnitec board on linux. lis2dw12 is enumerated only as iio device as I do not configure spidev. I have to configure the interrupts 0x3F , CTL_1. How can I set this from sysfs interface ?
2023-04-13 01:54 AM
Guys any update on this ? I know it might trivial thing I might be missing.
2023-04-13 05:41 AM
Ciao @RRath.2 ,
Where did you find the driver?
You can find here the repository managed by ST, let me know if it is the one you are using.
2023-04-13 06:41 PM
Hello @Federica Bossi
Thanks for helping me out.
This is the kernel/ version , I am using and I could not see TAP or TAP TAP or gesture events being added to main line kernel from ST.
https://elixir.bootlin.com/linux/v6.2.11/source/drivers/iio/accel/st_accel_core.c
Also even with your repository - https://github.com/STMicroelectronics/st-mems-android-linux-drivers-iio/tree/master/drivers/iio/stm/accel
1. Write 64h in CTRL1 // Turn on the accelerometer
// ODR = 200 Hz, High-Performance
2. Write 04h in CTRL6 // FS ±2 g, LOW_NOISE enabled
3. Write 20h in CTRL7 // Do not use low-pass filter for 6D, enable interrupts
4. Write 40h in TAP_THS_X // Set 6D threshold (6D_THS[1:0] = 10b = 60 degrees)
5. Write 80h in CTRL4_INT1_PAD_CTRL // 6D interrupt driven to INT1 pin
Now how can I configure such this via sysfs. My understanding is that when I configure lis2dw12 like above , I should be able to verify GPIO toggle or read INT1/INT2 pin.
2023-04-14 02:21 AM
Ciao @RRath.2 ,
Up to now we do not yet support the k6.1 version, we are bringing it, in the previous kernel version (up to 5.15) the TAP and Double TAP types didn't exist as events and for this reason they had to be added in types.h by the patches that are included in the github repository.
In order to receive tap/tap_tap/wu events (some events like free fall, 6d rotation, sleep monitoring etc... are not yet supported by the driver but can be easly added), you must first enable them and then poll the fd relating to the IIO events. An application example can be found in the IIO utils documentation (https://github.com/torvalds/linux/blob/master/tools/iio/iio_event_monitor.c)
As regards the configurability of the thresholds, let's say that the driver we release is a reference code that can be modified according to the customer's needs.
If my replies answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster.
2023-04-19 12:18 AM
@Federica Bossi
Thanks for helping.
Existing Release kernel even version 5.x.x
https://elixir.bootlin.com/linux/v5.19.17/source/drivers/iio/accel/st_accel_core.c
With ST IIO Linux Driver
https://github.com/STMicroelectronics/st-mems-android-linux-drivers-iio/tree/master/drivers/iio/stm/acce
int st_lis2dw12_fifo_setup(struct st_lis2dw12_hw *hw)
{
struct iio_dev *iio_dev = hw->iio_devs[ST_LIS2DW12_ID_ACC];
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,13,0)
struct iio_buffer *buffer;
#endif /* LINUX_VERSION_CODE */
int ret;
ret = devm_request_threaded_irq(hw->dev, hw->irq,
st_lis2dw12_handler_irq,
st_lis2dw12_handler_thread,
IRQF_TRIGGER_HIGH | IRQF_ONESHOT ,
"st_lis2dw12", hw);
if (ret) {
dev_err(hw->dev, "failed to request trigger irq %d\n",
hw->irq);
return ret;
}
Since my driver interrupt pin can only be configured as interrupts = <4 IRQ_TYPE_EDGE_RISING>; I am not able to use this driver.
Question is : Why driver code is supporting only IRQF_TRIGGER_HIGH | IRQF_ONESHOT ?
I am still trying to figure out what is preventing my device tree to use as IRQF_TRIGGER_HIGH but somehow it doesn't work. Driver only loads if I use interrupts = <4 IRQ_TYPE_EDGE_RISING> and change the driver code to use this as well
ret = devm_request_threaded_irq(hw->dev, hw->irq,
st_lis2dw12_handler_irq,
st_lis2dw12_handler_thread,
IRQF_TRIGGER_HIGH | IRQF_ONESHOT | IRQF_TRIGGER_RISING ,
"st_lis2dw12", hw);
but I am not sure what is the implication of this on other parts of driver code.
Regards,
Ravi Rathore
2023-04-25 09:34 PM
@@Federica Boss , please help here
2023-04-25 10:09 PM
@Federica Bossi - Is there any official support email id ,which I can send my query to ?
2023-04-26 01:47 PM
@A ST Supporter can any one help?
2023-04-26 11:50 PM
Ciao @RRath.2 ,
We do not recommend using spidev to write to the device's internal registers, rather we can check what your requests are and give you support on the driver we manage here also because for the driver version on mainline kernel the times are obviously longer.
To detect driver events when certain gestures are recognized by the device (such as tap, dtap, wake-up, free fall and 6d), the driver generates an IIO event related to the device that recognized that event, so it is just needed to poll the IIO device descriptor file, for reference you can see the iio_event_monitor test application. You can download it from https://github.com/torvalds/linux/tree/master/tools/iio
Configuring the driver with IRQ_TYPE_EDGE_RISING could risk losing an interrupt when using the FIFO and this would lead to the interruption of reading data from the sensor, generally when using the FIFO it is recommended to use a level interrupt.
If you want more support, you need to open a ticket on the OLS support here.