Skip to content

Commit

Permalink
Merge pull request hardkernel#47 from yan-wyb/khadas-vims-4.9.y
Browse files Browse the repository at this point in the history
Khadas vims 4.9.y
  • Loading branch information
numbqq authored Sep 29, 2021
2 parents 6a47e5c + f25b6d9 commit 5bd49c2
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 6 deletions.
3 changes: 2 additions & 1 deletion arch/arm64/boot/dts/amlogic/overlays/kvim/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ dtbo-y += uart4.dtbo \
pwm_f.dtbo \
i2c0.dtbo \
watchdog.dtbo \
i2s.dtbo
i2s.dtbo \
mpu6050-i2c.dtbo

targets += $(dtbo-y)
always := $(dtbo-y)
31 changes: 31 additions & 0 deletions arch/arm64/boot/dts/amlogic/overlays/kvim/mpu6050-i2c.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/meson-g12a-gpio.h>
#include <dt-bindings/gpio/gpio.h>

/ {
fragment@0 {
target = <&i2c0>;

__overlay__ {
status = "okay";

mpu6050@68 {
compatible = "invensense,mpu6050";
reg = <0x68>;
int-gpio = <&gpio GPIOH_5 GPIO_ACTIVE_LOW>;
mount-matrix = "-0.984807753012208", /* x0 */
"0", /* y0 */
"-0.173648177666930", /* z0 */
"0", /* x1 */
"-1", /* y1 */
"0", /* z1 */
"-0.173648177666930", /* x2 */
"0", /* y2 */
"0.984807753012208"; /* z2 */
};
};
};

};
3 changes: 2 additions & 1 deletion arch/arm64/boot/dts/amlogic/overlays/kvim2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ dtbo-y += uart4.dtbo \
pwm_d.dtbo \
i2c0.dtbo \
watchdog.dtbo \
i2s.dtbo
i2s.dtbo \
mpu6050-i2c.dtbo

targets += $(dtbo-y)
always := $(dtbo-y)
30 changes: 30 additions & 0 deletions arch/arm64/boot/dts/amlogic/overlays/kvim2/mpu6050-i2c.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/meson-g12a-gpio.h>
#include <dt-bindings/gpio/gpio.h>

/ {
fragment@0 {
target = <&i2c0>;

__overlay__ {
status = "okay";

mpu6050@68 {
compatible = "invensense,mpu6050";
reg = <0x68>;
int-gpio = <&gpio GPIOH_5 GPIO_ACTIVE_LOW>;
mount-matrix = "-0.984807753012208", /* x0 */
"0", /* y0 */
"-0.173648177666930", /* z0 */
"0", /* x1 */
"-1", /* y1 */
"0", /* z1 */
"-0.173648177666930", /* x2 */
"0", /* y2 */
"0.984807753012208"; /* z2 */
};
};
};
};
3 changes: 2 additions & 1 deletion arch/arm64/boot/dts/amlogic/overlays/kvim3/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ dtbo-y += uart3.dtbo \
otg-device.dtbo \
watchdog.dtbo \
i2s.dtbo \
can.dtbo
can.dtbo \
mpu6050-i2c.dtbo

targets += $(dtbo-y)
always := $(dtbo-y)
50 changes: 50 additions & 0 deletions arch/arm64/boot/dts/amlogic/overlays/kvim3/mpu6050-i2c.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/meson-g12a-gpio.h>
#include <dt-bindings/gpio/gpio.h>

/ {
fragment@0 {
target = <&spicc1>;

__overlay__ {
status = "disabled";
};
};

fragment@1 {
target = <&i2c3>;

__overlay__ {
status = "okay";

mpu6050@68 {
compatible = "invensense,mpu6050";
reg = <0x68>;
int-gpio = <&gpio GPIOH_4 GPIO_ACTIVE_LOW>;
mount-matrix = "-0.984807753012208", /* x0 */
"0", /* y0 */
"-0.173648177666930", /* z0 */
"0", /* x1 */
"-1", /* y1 */
"0", /* z1 */
"-0.173648177666930", /* x2 */
"0", /* y2 */
"0.984807753012208"; /* z2 */
};
};
};

fragment@2 {
target = <&pwm_ef>;

__overlay__ {
// NOTE: This syntax DOES NOT work on device tree overlays
// If you want to use mpu6050, you have to remove pwm_f overlay
/delete-property/ pinctrl-names;
/delete-property/ pinctrl-0;
};
};

};
3 changes: 2 additions & 1 deletion arch/arm64/boot/dts/amlogic/overlays/kvim3l/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ dtbo-y += uart3.dtbo \
otg-device.dtbo \
watchdog.dtbo \
i2s.dtbo \
can.dtbo
can.dtbo \
mpu6050-i2c.dtbo

targets += $(dtbo-y)
always := $(dtbo-y)
50 changes: 50 additions & 0 deletions arch/arm64/boot/dts/amlogic/overlays/kvim3l/mpu6050-i2c.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/meson-g12a-gpio.h>
#include <dt-bindings/gpio/gpio.h>

/ {
fragment@0 {
target = <&spicc1>;

__overlay__ {
status = "disabled";
};
};

fragment@1 {
target = <&i2c3>;

__overlay__ {
status = "okay";

mpu6050@68 {
compatible = "invensense,mpu6050";
reg = <0x68>;
int-gpio = <&gpio GPIOH_4 GPIO_ACTIVE_LOW>;
mount-matrix = "-0.984807753012208", /* x0 */
"0", /* y0 */
"-0.173648177666930", /* z0 */
"0", /* x1 */
"-1", /* y1 */
"0", /* z1 */
"-0.173648177666930", /* x2 */
"0", /* y2 */
"0.984807753012208"; /* z2 */
};
};
};

fragment@2 {
target = <&pwm_ef>;

__overlay__ {
// NOTE: This syntax DOES NOT work on device tree overlays
// If you want to use mpu6050, you have to remove pwm_f overlay
/delete-property/ pinctrl-names;
/delete-property/ pinctrl-0;
};
};

};
4 changes: 2 additions & 2 deletions arch/arm64/configs/kvims_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,8 @@ CONFIG_DEVFREQ_GOV_POWERSAVE=y
CONFIG_DEVFREQ_GOV_USERSPACE=y
CONFIG_EXTCON=y
CONFIG_IIO=y
CONFIG_IIO_BUFFER=y
CONFIG_IIO_KFIFO_BUF=y
CONFIG_INV_MPU6050_I2C=y
CONFIG_INV_MPU6050_SPI=y
CONFIG_PWM=y
CONFIG_ANDROID=y
CONFIG_MALI_MIDGARD=m
Expand Down
5 changes: 5 additions & 0 deletions drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <linux/iio/iio.h>
#include <linux/module.h>
#include "inv_mpu_iio.h"
#include <linux/of_gpio.h>
#include <linux/gpio.h>

static const struct regmap_config inv_mpu_regmap_config = {
.reg_bits = 8,
Expand Down Expand Up @@ -119,6 +121,9 @@ static int inv_mpu_probe(struct i2c_client *client,
return PTR_ERR(regmap);
}

printk("of_get_named_gpio: %d\n", of_get_named_gpio(client->dev.of_node, "int-gpio", 0));
client->irq = gpio_to_irq(of_get_named_gpio(client->dev.of_node, "int-gpio", 0));

result = inv_mpu_core_probe(regmap, client->irq, name,
NULL, chip_type);
if (result < 0)
Expand Down

0 comments on commit 5bd49c2

Please sign in to comment.