Ivan Nikolaenko

Modifying the mpu6050 6-axis accel/gyro driver for devicetree support

Discussion created by Ivan Nikolaenko on Apr 29, 2016

Hi all!

I have successfully modified mpu6050 driver (3.14.52 "Jethro" kernel) for devicetree support and would like to share it with community.

Add this entry to the i2cX node of your devicetree before use the driver (replace interrupt gpio and orientation with yours):

mpu6050: mpu6050@68 {         compatible = "inv,mpu6050";         reg = <0x68>;         orientation = <2 0 0 0 1 0 0 0 2>; /* Use values > 1 instead of -1 */         interrupt-parent = <&gpio2>;         interrupts = <30 IRQ_TYPE_LEVEL_HIGH>; };

At this moment there is a "dirty hack" with an 'orientation' parameter in the driver. It is because pdata.orientation[9] is array of signed char, but devicetree arrays not support negative values (or I don't understand how to do it).

 

I would be grateful for any comments.

Best regards.

Original Attachment has been moved to: mpu6050.patch.zip

Outcomes