Skip to content

Commit 5bd49c2

Browse files
authored
Merge pull request hardkernel#47 from yan-wyb/khadas-vims-4.9.y
Khadas vims 4.9.y
2 parents 6a47e5c + f25b6d9 commit 5bd49c2

File tree

10 files changed

+176
-6
lines changed

10 files changed

+176
-6
lines changed

arch/arm64/boot/dts/amlogic/overlays/kvim/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ dtbo-y += uart4.dtbo \
44
pwm_f.dtbo \
55
i2c0.dtbo \
66
watchdog.dtbo \
7-
i2s.dtbo
7+
i2s.dtbo \
8+
mpu6050-i2c.dtbo
89

910
targets += $(dtbo-y)
1011
always := $(dtbo-y)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/dts-v1/;
2+
/plugin/;
3+
4+
#include <dt-bindings/gpio/meson-g12a-gpio.h>
5+
#include <dt-bindings/gpio/gpio.h>
6+
7+
/ {
8+
fragment@0 {
9+
target = <&i2c0>;
10+
11+
__overlay__ {
12+
status = "okay";
13+
14+
mpu6050@68 {
15+
compatible = "invensense,mpu6050";
16+
reg = <0x68>;
17+
int-gpio = <&gpio GPIOH_5 GPIO_ACTIVE_LOW>;
18+
mount-matrix = "-0.984807753012208", /* x0 */
19+
"0", /* y0 */
20+
"-0.173648177666930", /* z0 */
21+
"0", /* x1 */
22+
"-1", /* y1 */
23+
"0", /* z1 */
24+
"-0.173648177666930", /* x2 */
25+
"0", /* y2 */
26+
"0.984807753012208"; /* z2 */
27+
};
28+
};
29+
};
30+
31+
};

arch/arm64/boot/dts/amlogic/overlays/kvim2/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ dtbo-y += uart4.dtbo \
33
pwm_d.dtbo \
44
i2c0.dtbo \
55
watchdog.dtbo \
6-
i2s.dtbo
6+
i2s.dtbo \
7+
mpu6050-i2c.dtbo
78

89
targets += $(dtbo-y)
910
always := $(dtbo-y)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/dts-v1/;
2+
/plugin/;
3+
4+
#include <dt-bindings/gpio/meson-g12a-gpio.h>
5+
#include <dt-bindings/gpio/gpio.h>
6+
7+
/ {
8+
fragment@0 {
9+
target = <&i2c0>;
10+
11+
__overlay__ {
12+
status = "okay";
13+
14+
mpu6050@68 {
15+
compatible = "invensense,mpu6050";
16+
reg = <0x68>;
17+
int-gpio = <&gpio GPIOH_5 GPIO_ACTIVE_LOW>;
18+
mount-matrix = "-0.984807753012208", /* x0 */
19+
"0", /* y0 */
20+
"-0.173648177666930", /* z0 */
21+
"0", /* x1 */
22+
"-1", /* y1 */
23+
"0", /* z1 */
24+
"-0.173648177666930", /* x2 */
25+
"0", /* y2 */
26+
"0.984807753012208"; /* z2 */
27+
};
28+
};
29+
};
30+
};

arch/arm64/boot/dts/amlogic/overlays/kvim3/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ dtbo-y += uart3.dtbo \
99
otg-device.dtbo \
1010
watchdog.dtbo \
1111
i2s.dtbo \
12-
can.dtbo
12+
can.dtbo \
13+
mpu6050-i2c.dtbo
1314

1415
targets += $(dtbo-y)
1516
always := $(dtbo-y)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/dts-v1/;
2+
/plugin/;
3+
4+
#include <dt-bindings/gpio/meson-g12a-gpio.h>
5+
#include <dt-bindings/gpio/gpio.h>
6+
7+
/ {
8+
fragment@0 {
9+
target = <&spicc1>;
10+
11+
__overlay__ {
12+
status = "disabled";
13+
};
14+
};
15+
16+
fragment@1 {
17+
target = <&i2c3>;
18+
19+
__overlay__ {
20+
status = "okay";
21+
22+
mpu6050@68 {
23+
compatible = "invensense,mpu6050";
24+
reg = <0x68>;
25+
int-gpio = <&gpio GPIOH_4 GPIO_ACTIVE_LOW>;
26+
mount-matrix = "-0.984807753012208", /* x0 */
27+
"0", /* y0 */
28+
"-0.173648177666930", /* z0 */
29+
"0", /* x1 */
30+
"-1", /* y1 */
31+
"0", /* z1 */
32+
"-0.173648177666930", /* x2 */
33+
"0", /* y2 */
34+
"0.984807753012208"; /* z2 */
35+
};
36+
};
37+
};
38+
39+
fragment@2 {
40+
target = <&pwm_ef>;
41+
42+
__overlay__ {
43+
// NOTE: This syntax DOES NOT work on device tree overlays
44+
// If you want to use mpu6050, you have to remove pwm_f overlay
45+
/delete-property/ pinctrl-names;
46+
/delete-property/ pinctrl-0;
47+
};
48+
};
49+
50+
};

arch/arm64/boot/dts/amlogic/overlays/kvim3l/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ dtbo-y += uart3.dtbo \
88
otg-device.dtbo \
99
watchdog.dtbo \
1010
i2s.dtbo \
11-
can.dtbo
11+
can.dtbo \
12+
mpu6050-i2c.dtbo
1213

1314
targets += $(dtbo-y)
1415
always := $(dtbo-y)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/dts-v1/;
2+
/plugin/;
3+
4+
#include <dt-bindings/gpio/meson-g12a-gpio.h>
5+
#include <dt-bindings/gpio/gpio.h>
6+
7+
/ {
8+
fragment@0 {
9+
target = <&spicc1>;
10+
11+
__overlay__ {
12+
status = "disabled";
13+
};
14+
};
15+
16+
fragment@1 {
17+
target = <&i2c3>;
18+
19+
__overlay__ {
20+
status = "okay";
21+
22+
mpu6050@68 {
23+
compatible = "invensense,mpu6050";
24+
reg = <0x68>;
25+
int-gpio = <&gpio GPIOH_4 GPIO_ACTIVE_LOW>;
26+
mount-matrix = "-0.984807753012208", /* x0 */
27+
"0", /* y0 */
28+
"-0.173648177666930", /* z0 */
29+
"0", /* x1 */
30+
"-1", /* y1 */
31+
"0", /* z1 */
32+
"-0.173648177666930", /* x2 */
33+
"0", /* y2 */
34+
"0.984807753012208"; /* z2 */
35+
};
36+
};
37+
};
38+
39+
fragment@2 {
40+
target = <&pwm_ef>;
41+
42+
__overlay__ {
43+
// NOTE: This syntax DOES NOT work on device tree overlays
44+
// If you want to use mpu6050, you have to remove pwm_f overlay
45+
/delete-property/ pinctrl-names;
46+
/delete-property/ pinctrl-0;
47+
};
48+
};
49+
50+
};

arch/arm64/configs/kvims_defconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,8 @@ CONFIG_DEVFREQ_GOV_POWERSAVE=y
655655
CONFIG_DEVFREQ_GOV_USERSPACE=y
656656
CONFIG_EXTCON=y
657657
CONFIG_IIO=y
658-
CONFIG_IIO_BUFFER=y
659-
CONFIG_IIO_KFIFO_BUF=y
658+
CONFIG_INV_MPU6050_I2C=y
659+
CONFIG_INV_MPU6050_SPI=y
660660
CONFIG_PWM=y
661661
CONFIG_ANDROID=y
662662
CONFIG_MALI_MIDGARD=m

drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <linux/iio/iio.h>
1919
#include <linux/module.h>
2020
#include "inv_mpu_iio.h"
21+
#include <linux/of_gpio.h>
22+
#include <linux/gpio.h>
2123

2224
static const struct regmap_config inv_mpu_regmap_config = {
2325
.reg_bits = 8,
@@ -119,6 +121,9 @@ static int inv_mpu_probe(struct i2c_client *client,
119121
return PTR_ERR(regmap);
120122
}
121123

124+
printk("of_get_named_gpio: %d\n", of_get_named_gpio(client->dev.of_node, "int-gpio", 0));
125+
client->irq = gpio_to_irq(of_get_named_gpio(client->dev.of_node, "int-gpio", 0));
126+
122127
result = inv_mpu_core_probe(regmap, client->irq, name,
123128
NULL, chip_type);
124129
if (result < 0)

0 commit comments

Comments
 (0)