build/patch/kernel/archive/rockchip64-4.4/check/0034-add-device-tree-overlay-for-rockpi.patch

118 lines
3.6 KiB
Diff

From 8319cfe761a6b045e142d8a2052220d16aff5379 Mon Sep 17 00:00:00 2001
From: stephen <stephen@vamrs.com>
Date: Fri, 22 Feb 2019 19:07:26 +0800
Subject: [PATCH 34/97] add device tree overlay for rockpi
Here uses the at24c02 module as a test sample.
Signed-off-by: stephen <stephen@vamrs.com>
---
arch/arm64/boot/dts/.gitignore | 1 +
arch/arm64/boot/dts/rockchip/Makefile | 13 +++++++++++-
.../arm64/boot/dts/rockchip/overlays/Makefile | 10 +++++++++
.../dts/rockchip/overlays/at24c02-overlay.dts | 21 +++++++++++++++++++
arch/arm64/configs/rockchip_linux_defconfig | 1 +
scripts/Makefile.lib | 11 ++++++++++
6 files changed, 56 insertions(+), 1 deletion(-)
create mode 100644 arch/arm64/boot/dts/rockchip/overlays/Makefile
create mode 100644 arch/arm64/boot/dts/rockchip/overlays/at24c02-overlay.dts
diff --git a/arch/arm64/boot/dts/.gitignore b/arch/arm64/boot/dts/.gitignore
index b60ed208c779..77ed402cbbc8 100644
--- a/arch/arm64/boot/dts/.gitignore
+++ b/arch/arm64/boot/dts/.gitignore
@@ -1 +1,2 @@
*.dtb
+*.dtbo
diff --git a/arch/arm64/boot/dts/rockchip/Makefile b/arch/arm64/boot/dts/rockchip/Makefile
index cb02dda8e20e..9aa944b743e2 100644
--- a/arch/arm64/boot/dts/rockchip/Makefile
+++ b/arch/arm64/boot/dts/rockchip/Makefile
@@ -84,6 +84,17 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rock960-model-ab-linux.dtb
dtb-$(CONFIG_ARCH_ROCKCHIP) += rock960-model-c-linux.dtb
dtb-$(CONFIG_ARCH_ROCKCHIP) += rockpi-4b-linux.dtb
+targets += dtbs dtbs_instal
+targets += $(dtb-y)
+dtstree := $(srctree)/$(src)
+dtb-$(CONFIG_OF_ALL_DTBS) := $(patsubst $(dtstree)/%.dts,%.dtb, $(wildcard $(dtstree)/*.dts))
+
always := $(dtb-y)
-subdir-y := $(dts-dirs)
+subdir-y := $(dts-dirs) overlays
clean-files := *.dtb
+
+# Enable fixups to support overlays on ROCK Pi platforms
+ifeq ($(CONFIG_ARCH_ROCKCHIP),y)
+ DTC_FLAGS ?= -@ -H epapr
+ dts-dirs += overlays
+endif
diff --git a/arch/arm64/boot/dts/rockchip/overlays/Makefile b/arch/arm64/boot/dts/rockchip/overlays/Makefile
new file mode 100644
index 000000000000..b4ded11e7a8f
--- /dev/null
+++ b/arch/arm64/boot/dts/rockchip/overlays/Makefile
@@ -0,0 +1,10 @@
+# Overlays for the ROCK Pi platform
+
+dtbo-$(CONFIG_ARCH_ROCKCHIP) += \
+ at24c02.dtbo
+
+targets += dtbs dtbs_install
+targets += $(dtbo-y)
+
+always := $(dtbo-y)
+clean-files := *.dtbo
diff --git a/arch/arm64/boot/dts/rockchip/overlays/at24c02-overlay.dts b/arch/arm64/boot/dts/rockchip/overlays/at24c02-overlay.dts
new file mode 100644
index 000000000000..535753163ff0
--- /dev/null
+++ b/arch/arm64/boot/dts/rockchip/overlays/at24c02-overlay.dts
@@ -0,0 +1,21 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+ model = "ROCK PI 4B";
+ compatible = "rockchip,rockpi","rockchip,rk3399";
+
+ fragment@0 {
+ target = <&i2c2>;
+
+ __overlay__ {
+
+ at24c02@50 {
+ status = "okay";
+ compatible = "atmel,24c02";
+ reg = <0x50>;
+ pagesize = <8>;
+ };
+ };
+ };
+};
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3fb2aaa00411..75aa16f7baa9 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -319,6 +319,17 @@ cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
$(obj)/%.dtb: $(src)/%.dts FORCE
$(call if_changed_dep,dtc)
+quiet_cmd_dtco = DTCO $@
+cmd_dtco = mkdir -p $(dir ${dtc-tmp}) ; \
+ $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
+ $(DTC) -@ -H epapr -O dtb -o $@ -b 0 \
+ -i $(dir $<) $(DTC_FLAGS) \
+ -d $(depfile).dtc.tmp $(dtc-tmp) ; \
+ cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
+
+$(obj)/%.dtbo: $(src)/%-overlay.dts FORCE
+ $(call if_changed_dep,dtco)
+
dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
# cat
--
2.25.1