Invensense MPU6050 and device trees
by Mike Davies from LinuxQuestions.org on (#6E2N5)
I have an InvenSense MPU-6050 on i2c bus /dev/i2c-3.
The kernel driver does not find it, e.g.
Code:# cat /var/log/messages | grep 6050
Jan 1 00:00:09 pryfyn kern.info kernel: [ 9.757536] inv-mpu6050-i2c 1-0068: mounting matrix not found: using identity...
Jan 1 00:00:09 pryfyn kern.warn kernel: [ 9.772087] inv-mpu6050-i2c 1-0068: supply vdd not found, using dummy regulator
Jan 1 00:00:09 pryfyn kern.warn kernel: [ 9.785356] inv-mpu6050-i2c 1-0068: supply vddio not found, using dummy regulator
Jan 1 00:00:09 pryfyn kern.warn kernel: [ 9.913415] inv-mpu6050-i2c: probe of 1-0068 failed with error -121
# i2cdetect -y 3
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
#I can only think that it is because it it looking on /dev/i2c-1 instead of /dev/i2c-3.
I am at a loss to understand how to specify that it must look on bus 3. The .dts looks like this, which seems to suggest the only things that can be tweaked are the device address and the interrupt pin.
Code:// Definitions for MPU6050
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
clock-frequency = <400000>;
mpu6050: mpu6050@68 {
compatible = "invensense,mpu6050";
reg = <0x68>;
interrupt-parent = <&gpio>;
interrupts = <4 1>;
};
};
};
__overrides__ {
interrupt = <&mpu6050>,"interrupts:0";
addr = <&mpu6050>,"reg:0";
};
};I tried changing i2c1 to i2c3, and whilst it compiled OK, the kernel did not generate any messages or files in /sys.
I guess I should say that i2c3 is a bit banging i2c but and not a real hardware device, and it setup with
Code:// i2c bus for IMU
dtoverlay=i2c-gpio,bus=3,i2c_gpio_sda=27,i2c_gpio_scl=17Does anyone know how to do this ? It must be possible, but the bit of code, or parameter to tweak is eluding me.
Thanks for your help.
The kernel driver does not find it, e.g.
Code:# cat /var/log/messages | grep 6050
Jan 1 00:00:09 pryfyn kern.info kernel: [ 9.757536] inv-mpu6050-i2c 1-0068: mounting matrix not found: using identity...
Jan 1 00:00:09 pryfyn kern.warn kernel: [ 9.772087] inv-mpu6050-i2c 1-0068: supply vdd not found, using dummy regulator
Jan 1 00:00:09 pryfyn kern.warn kernel: [ 9.785356] inv-mpu6050-i2c 1-0068: supply vddio not found, using dummy regulator
Jan 1 00:00:09 pryfyn kern.warn kernel: [ 9.913415] inv-mpu6050-i2c: probe of 1-0068 failed with error -121
# i2cdetect -y 3
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
#I can only think that it is because it it looking on /dev/i2c-1 instead of /dev/i2c-3.
I am at a loss to understand how to specify that it must look on bus 3. The .dts looks like this, which seems to suggest the only things that can be tweaked are the device address and the interrupt pin.
Code:// Definitions for MPU6050
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
clock-frequency = <400000>;
mpu6050: mpu6050@68 {
compatible = "invensense,mpu6050";
reg = <0x68>;
interrupt-parent = <&gpio>;
interrupts = <4 1>;
};
};
};
__overrides__ {
interrupt = <&mpu6050>,"interrupts:0";
addr = <&mpu6050>,"reg:0";
};
};I tried changing i2c1 to i2c3, and whilst it compiled OK, the kernel did not generate any messages or files in /sys.
I guess I should say that i2c3 is a bit banging i2c but and not a real hardware device, and it setup with
Code:// i2c bus for IMU
dtoverlay=i2c-gpio,bus=3,i2c_gpio_sda=27,i2c_gpio_scl=17Does anyone know how to do this ? It must be possible, but the bit of code, or parameter to tweak is eluding me.
Thanks for your help.