Skip to content

mpu6050 device tree overlay #2031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 23, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion arch/arm/boot/dts/overlays/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
vga666.dtbo \
w1-gpio.dtbo \
w1-gpio-pullup.dtbo \
wittypi.dtbo
wittypi.dtbo \
mpu6050.dtbo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the other entries are in strict alphabetical order - please do the same. As well as being tidy and logical it helps to avoid merge conflicts.


targets += dtbs dtbs_install
targets += $(dtbo-y)
Expand Down
28 changes: 28 additions & 0 deletions arch/arm/boot/dts/overlays/mpu6050-overlay.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Definitions for MPU6050
/dts-v1/;
/plugin/;

/ {
compatible = "brcm,bcm2708";

fragment@0 {
target = <&i2c1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
clock-frequency = <400000>;

mpu6050: inv-mpu6050@68 {
compatible = "invensense,mpu6050";
reg = <0x68>;
interrupt-parent = <&gpio>;
interrupts = <4 1>;
};
};
};

__overrides__ {
mpu6050_interrupt_pin = <&mpu6050>,"interrupts:0";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to qualify the parameter name with the device name - the parameters exposed by an overlay are only in scope until the next overlay is loaded, so it is safe to have multiple overlays all using the same parameter names. Other overlays have used interrupt or int_pin.

};
};
2 changes: 2 additions & 0 deletions arch/arm/configs/bcm2709_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,8 @@ CONFIG_IIO=m
CONFIG_IIO_BUFFER=y
CONFIG_IIO_BUFFER_CB=m
CONFIG_IIO_KFIFO_BUF=m
CONFIG_INV_MPU6050_IIO=m
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't what savedefconfig generates - I get:

index 9164668..575cf99 100644
--- a/arch/arm/configs/bcm2709_defconfig
+++ b/arch/arm/configs/bcm2709_defconfig
@@ -1171,15 +1171,12 @@ CONFIG_RASPBERRYPI_POWER=y
 CONFIG_EXTCON=m
 CONFIG_EXTCON_ARIZONA=m
 CONFIG_IIO=m
-CONFIG_IIO_BUFFER=y
 CONFIG_IIO_BUFFER_CB=m
-CONFIG_IIO_KFIFO_BUF=m
-CONFIG_INV_MPU6050_IIO=m
-CONFIG_INV_MPU6050_I2C=m
 CONFIG_MCP320X=m
 CONFIG_MCP3422=m
 CONFIG_DHT11=m
 CONFIG_HTU21=m
+CONFIG_INV_MPU6050_I2C=m
 CONFIG_BMP280=m
 CONFIG_PWM_BCM2835=m

Setting INV_MPU6050_I2C is enough to imply INV_MPU6050_IIO, IIO_BUFFER and IIO_KFIFO_BUF. The order in the Kconfig files determines where they should go.

Using make ARCH=arm savedefconfig minimises the number of changes, and prevents others encountering spurious differences when they subsequently use the same mechanism themselves.

CONFIG_INV_MPU6050_I2C=m
CONFIG_MCP320X=m
CONFIG_MCP3422=m
CONFIG_DHT11=m
Expand Down