How to access accelerometer interrupt?

Hi! I want to use the MMA8652 accelerometer to automatically trigger a motion detection interrupt in order to wake up the iMX6ULL.

I’ve configured the device tree as follows:

&i2c1 {
	mma8652fc@1d {
		compatible = "fsl,mma8652";
		reg = <0x1d>;
                interrupt-parent = <&gpio4>;
		interrupts = <16 0>;
		interrupt-names = "INT1";
		status = "okay";

And I can access the device in /sys/bus/iio/devices/iio\:device0. I have enabled motion detection interrupts as follows:

echo 15 > events/in_accel_mag_rising_value
echo 1 > events/in_accel_mag_rising_period
echo 1 > events/in_accel_x_mag_rising_en
echo 1 > events/in_accel_y_mag_rising_en
echo 1 > events/in_accel_z_mag_rising_en

And I can see the interrupt source for the accelerometer using cat /proc/interrupts.

My question is how can I get access to this interrupt or event from user space in order to see if it actually triggers the interrupt? (I’ve tried cat /dev/iio\:device0 but it is always empty) Also, how can I configure the device tree to use the interrupt GPIO (INT1) as a wakeup source?

Any help would be appreciated. If someone has done something similar with other accelerometers or sensors in general, please provide advice.

Colibri iMX6ULL 512MB WB IT
Custom carrier board
Linux TDX X11 5.2.0-devel-20210226152038+build.0 (dunfell)

Hi @CristianM,

Thank you for using the Toradex community.

Did you see this post here ?

Also there is some documentation on how to do it in the following link:

Kernel Documentation

Let me know if this helped you.

Best Regards

Thank you. It turns out the accelerometer’s driver is buggy, because I get IRQ not handled errors during boot. I ended up writing my own driver in Python.

Magic constants are evil. 0 ^^ here means IRQ_TYPE_NONE. Are you sure it is the right setting? Are you sure about 16 as well?

@Edward Thank you for noticing this. Indeed, it was a device tree misconfiguration and there are no errors at boot with the following configuration:

mma8652fc@1d {
		compatible = "fsl,mma8652";
		reg = <0x1d>;
		interrupt-parent = <&gpio2>;
		interrupts = <5 IRQ_TYPE_EDGE_FALLING>; // SODIMM 30
		interrupt-names = "INT2";
		status = "okay";

Hi @CristianM ,

is the issue now solved?

Best Regards

@kevin.tx Yes, it is.