rockchip 添加设备树插件功能
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -137,4 +137,5 @@ defconfig
|
||||
|
||||
# Kdevelop4
|
||||
*.kdev4
|
||||
|
||||
*.dtb*
|
||||
*.scr
|
||||
|
||||
@ -113,3 +113,5 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-nvr-demo-v12-linux.dtb
|
||||
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-nvr-demo-v12-linux-spi-nand.dtb
|
||||
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-lubancat2.dtb
|
||||
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-lubancat2-io.dtb
|
||||
|
||||
subdir-y := $(dts-dirs) overlay
|
||||
|
||||
15
arch/arm64/boot/dts/rockchip/overlay/Makefile
Normal file
15
arch/arm64/boot/dts/rockchip/overlay/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
dtbo-$(CONFIG_ARCH_ROCKCHIP) += \
|
||||
lubancat2-uart3-overlay.dtbo
|
||||
|
||||
scr-$(CONFIG_ARCH_ROCKCHIP) += \
|
||||
rockchip-fixup.scr
|
||||
|
||||
dtbotxt-$(CONFIG_ARCH_ROCKCHIP) += \
|
||||
README.rockchip-overlays
|
||||
|
||||
targets += $(dtbo-y) $(scr-y) $(dtbotxt-y)
|
||||
|
||||
always := $(dtbo-y) $(scr-y) $(dtbotxt-y)
|
||||
clean-files := *.dtbo *.scr
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
## Introduction
|
||||
|
||||
## Platform and Chips:
|
||||
|
||||
rockchip (Rockchip)
|
||||
- rk3566
|
||||
- rk3568
|
||||
|
||||
## usage
|
||||
|
||||
Kernel provided DT overlay files are in
|
||||
/boot/dtbs/$(uname -r)/rockchip/overlay/
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2022 - All Rights Reserved by
|
||||
* filename : lubancat2-uart-overlay.dts
|
||||
* brief : Device Tree overlay for ebf lubancat2 uart device
|
||||
* author : embedfire
|
||||
* date : 2022-05-31
|
||||
* version : A001
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
#include <dt-bindings/pinctrl/rockchip.h>
|
||||
#include <dt-bindings/clock/rk3568-cru.h>
|
||||
|
||||
|
||||
/ {
|
||||
fragment@0 {
|
||||
target = <&uart3>;
|
||||
|
||||
__overlay__ {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
30
arch/arm64/boot/dts/rockchip/overlay/rockchip-fixup.scr-cmd
Normal file
30
arch/arm64/boot/dts/rockchip/overlay/rockchip-fixup.scr-cmd
Normal file
@ -0,0 +1,30 @@
|
||||
# overlays fixup script
|
||||
# implements (or rather substitutes) overlay arguments functionality
|
||||
# using u-boot scripting, environment variables and "fdt" command
|
||||
|
||||
setenv decompose_pin 'setexpr tmp_pinctrl sub "GPIO(0|1|2|3|4)_\\S\\d+" "\\1";
|
||||
setexpr tmp_bank sub "GPIO\\d_(\\S)\\d+" "\\1";
|
||||
test "${tmp_bank}" = "A" && setenv tmp_bank 0;
|
||||
test "${tmp_bank}" = "B" && setenv tmp_bank 1;
|
||||
test "${tmp_bank}" = "C" && setenv tmp_bank 2;
|
||||
test "${tmp_bank}" = "D" && setenv tmp_bank 3;
|
||||
setexpr tmp_pin sub "GPIO\\d_\\S(\\d+)" "\\1";
|
||||
setexpr tmp_bank ${tmp_bank} * 8;
|
||||
setexpr tmp_pin ${tmp_bank} + ${tmp_pin}'
|
||||
|
||||
if test -n "${param_w1_pin}"; then
|
||||
setenv tmp_pinctrl "${param_w1_pin}"
|
||||
setenv tmp_bank "${param_w1_pin}"
|
||||
setenv tmp_pin "${param_w1_pin}"
|
||||
run decompose_pin
|
||||
echo "${param_w1_pin} ---> pinctrl = ${tmp_pinctrl}"
|
||||
echo "${param_w1_pin} ---> bank = ${tmp_bank}"
|
||||
echo "${param_w1_pin} ---> pin = ${tmp_pin}"
|
||||
fdt get value tmp_pinctrl /__symbols__ gpio${tmp_pinctrl}
|
||||
echo "${param_w1_pin} ---> tmp_pinctrl = ${tmp_pinctrl}"
|
||||
fdt get value tmp_phandle ${tmp_pinctrl} phandle
|
||||
echo "${param_w1_pin} ---> tmp_phandle = ${tmp_phandle}"
|
||||
fdt set /onewire@0 gpios "<${tmp_phandle} ${tmp_pin} 0 0>"
|
||||
env delete tmp_pinctrl tmp_bank tmp_pin tmp_phandle
|
||||
fi
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -126,6 +126,7 @@ CONFIG_MTD=y
|
||||
CONFIG_MTD_CMDLINE_PARTS=y
|
||||
CONFIG_MTD_BLOCK=y
|
||||
CONFIG_MTD_UBI=y
|
||||
CONFIG_OF_OVERLAY=y
|
||||
CONFIG_ZRAM=y
|
||||
CONFIG_BLK_DEV_LOOP=y
|
||||
CONFIG_BLK_DEV_RAM=y
|
||||
|
||||
@ -20,6 +20,9 @@ include scripts/Kbuild.include
|
||||
include $(src)/Makefile
|
||||
|
||||
dtbinst-files := $(sort $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS), $(dtb-)))
|
||||
dtboinst-files := $(dtbo-y)
|
||||
script-files := $(scr-y)
|
||||
readme-files := $(dtbotxt-y)
|
||||
dtbinst-dirs := $(subdir-y) $(subdir-m)
|
||||
|
||||
# Helper targets for Installing DTBs into the boot directory
|
||||
@ -31,10 +34,19 @@ install-dir = $(patsubst $(dtbinst_root)%,$(INSTALL_DTBS_PATH)%,$(obj))
|
||||
$(dtbinst-files): %.dtb: $(obj)/%.dtb
|
||||
$(call cmd,dtb_install,$(install-dir))
|
||||
|
||||
$(dtboinst-files): %.dtbo: $(obj)/%.dtbo
|
||||
$(call cmd,dtb_install,$(install-dir))
|
||||
|
||||
$(script-files): %.scr: $(obj)/%.scr
|
||||
$(call cmd,dtb_install,$(install-dir))
|
||||
|
||||
$(readme-files): %: $(src)/%
|
||||
$(call cmd,dtb_install,$(install-dir))
|
||||
|
||||
$(dtbinst-dirs):
|
||||
$(Q)$(MAKE) $(dtbinst)=$(obj)/$@
|
||||
|
||||
PHONY += $(dtbinst-files) $(dtbinst-dirs)
|
||||
__dtbs_install: $(dtbinst-files) $(dtbinst-dirs)
|
||||
PHONY += $(dtbinst-files) $(dtboinst-files) $(script-files) $(readme-files) $(dtbinst-dirs)
|
||||
__dtbs_install: $(dtbinst-files) $(dtboinst-files) $(script-files) $(readme-files) $(dtbinst-dirs)
|
||||
|
||||
.PHONY: $(PHONY)
|
||||
|
||||
@ -61,6 +61,9 @@ real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))
|
||||
extra-y += $(dtb-y)
|
||||
extra-$(CONFIG_OF_ALL_DTBS) += $(dtb-)
|
||||
|
||||
# Overlay targets
|
||||
extra-y += $(dtbo-y) $(scr-y) $(dtbotxt-y)
|
||||
|
||||
# Add subdir path
|
||||
|
||||
extra-y := $(addprefix $(obj)/,$(extra-y))
|
||||
@ -277,6 +280,9 @@ endif
|
||||
|
||||
DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
|
||||
|
||||
# Overlay support
|
||||
DTC_FLAGS += -@ -Wno-unit_address_format -Wno-simple_bus_reg
|
||||
|
||||
# Generate an assembly file to wrap the output of the device tree compiler
|
||||
quiet_cmd_dt_S_dtb= DTB $@
|
||||
cmd_dt_S_dtb= \
|
||||
@ -306,6 +312,23 @@ cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
|
||||
$(obj)/%.dtb: $(src)/%.dts $(DTC) 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) -@ -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)/%.dts FORCE
|
||||
$(call if_changed_dep,dtco)
|
||||
|
||||
quiet_cmd_scr = MKIMAGE $@
|
||||
cmd_scr = mkimage -C none -A $(ARCH) -T script -d $< $@
|
||||
|
||||
$(obj)/%.scr: $(src)/%.scr-cmd FORCE
|
||||
$(call if_changed,scr)
|
||||
|
||||
dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
|
||||
|
||||
# Bzip2
|
||||
|
||||
Reference in New Issue
Block a user