Add dtb overlays support
DTB Overlays are useful to change/add nodes to a dtb without the need to modify it. Add support for building dtbo during buildkernel. The goal of DTBO present in the FreeBSD source tree is to fill a gap in time when we submit changes upstream (Linux). Instead of waiting 2 to 4 months we can add a DTBO in tree in the meantime. This is not for adding DTBO for capes/hat/addon boards, those will be better to put in a ports. This is also not for enabling a i2c/spi/pwm controller on certain pins, each user have a different use case for those (which pins to use etc ...) and we cannot have all possible configuration. Add a dtbo for sun8i-h3-sid which add the SID node missing in upstream dts. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D14782
This commit is contained in:
parent
44f0dfb9b7
commit
623c6cd68e
@ -146,6 +146,7 @@ KMODOWN?= ${BINOWN}
|
||||
KMODGRP?= ${BINGRP}
|
||||
KMODMODE?= ${BINMODE}
|
||||
DTBDIR?= /boot/dtb
|
||||
DTBODIR?= /boot/dtb/overlays
|
||||
DTBOWN?= root
|
||||
DTBGRP?= wheel
|
||||
DTBMODE?= 444
|
||||
|
@ -246,4 +246,4 @@ options EFI
|
||||
|
||||
# Flattened Device Tree
|
||||
options FDT # Configure using FDT/DTB data
|
||||
makeoptions MODULES_EXTRA="dtb/allwinner dtb/am335x dtb/imx6 dtb/nvidia dtb/rpi dtb/zynq dtb/omap4"
|
||||
makeoptions MODULES_EXTRA="dtb/allwinner dtb/am335x dtb/imx6 dtb/nvidia dtb/rpi dtb/zynq dtb/omap4 dtb/overlays"
|
||||
|
@ -45,13 +45,14 @@ SYSDIR= ${_dir:tA}
|
||||
.error "can't find kernel source tree"
|
||||
.endif
|
||||
|
||||
.SUFFIXES: .dtb .dts
|
||||
.SUFFIXES: .dtb .dts .dtbo .dtso
|
||||
|
||||
.PATH: ${SYSDIR}/gnu/dts/${MACHINE} ${SYSDIR}/dts/${MACHINE}
|
||||
.PATH: ${SYSDIR}/gnu/dts/${MACHINE} ${SYSDIR}/dts/${MACHINE} ${SYSDIR}/dts/${MACHINE}/overlays
|
||||
|
||||
DTB=${DTS:R:S/$/.dtb/}
|
||||
DTBO=${DTSO:R:S/$/.dtbo/}
|
||||
|
||||
all: ${DTB}
|
||||
all: ${DTB} ${DTBO}
|
||||
|
||||
.if defined(DTS)
|
||||
.export DTC
|
||||
@ -63,6 +64,16 @@ CLEANFILES+=${_dts:R:S/$/.dtb/}
|
||||
.endfor
|
||||
.endif
|
||||
|
||||
.if defined(DTSO)
|
||||
.export DTC
|
||||
.for _dtso in ${DTSO}
|
||||
${_dtso:R:S/$/.dtbo/}: ${_dtso} ${OP_META}
|
||||
@echo Generating ${.TARGET} from ${_dtso}
|
||||
@${SYSDIR}/tools/fdt/make_dtbo.sh ${SYSDIR} overlays/${_dtso} ${.OBJDIR}
|
||||
CLEANFILES+=${_dtso:R:S/$/.dtbo/}
|
||||
.endfor
|
||||
.endif
|
||||
|
||||
.if !target(install)
|
||||
.if !target(realinstall)
|
||||
realinstall: _dtbinstall
|
||||
@ -75,6 +86,11 @@ _dtbinstall:
|
||||
.for _dtb in ${DTB}
|
||||
${INSTALL} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \
|
||||
${_INSTALLFLAGS} ${_dtb} ${DESTDIR}${DTBDIR}/
|
||||
.endfor
|
||||
test -d ${DESTDIR}${DTBODIR} || ${INSTALL} -d -o ${DTBOWN} -g ${DTBGRP} ${DESTDIR}${DTBODIR}
|
||||
.for _dtbo in ${DTBO}
|
||||
${INSTALL} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \
|
||||
${_INSTALLFLAGS} ${_dtbo} ${DESTDIR}${DTBODIR}/
|
||||
.endfor
|
||||
.endif # !target(realinstall)
|
||||
.endif # !target(install)
|
||||
|
@ -6,5 +6,8 @@ test-dts:
|
||||
.for dts in ${DTS}
|
||||
@env MACHINE=`basename ${.CURDIR}` ${SYSDIR}/tools/fdt/make_dtb.sh ${SYSDIR} ${dts} /tmp
|
||||
|
||||
.endfor
|
||||
test-dtso:
|
||||
.for dtso in ${DTSO}
|
||||
@env MACHINE=`basename ${.CURDIR}` ${SYSDIR}/tools/fdt/make_dtbo.sh ${SYSDIR} ${dtso} /tmp
|
||||
|
||||
.endfor
|
||||
|
7
sys/dts/arm/overlays/Makefile
Normal file
7
sys/dts/arm/overlays/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
DTSO!=ls *.dtso
|
||||
|
||||
all: test-dtso
|
||||
|
||||
.include <bsd.init.mk>
|
18
sys/dts/arm/overlays/sun8i-h3-sid.dtso
Normal file
18
sys/dts/arm/overlays/sun8i-h3-sid.dtso
Normal file
@ -0,0 +1,18 @@
|
||||
/dts-v1/;
|
||||
/plugin/;
|
||||
|
||||
/ {
|
||||
compatible = "allwinner,sun8i-h3";
|
||||
|
||||
fragment@0 {
|
||||
target-path = "/soc";
|
||||
|
||||
__overlay__ {
|
||||
sid: eeprom@1c14000 {
|
||||
compatible = "allwinner,sun8i-h3-sid";
|
||||
reg = <0x1c14000 0x400>;
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
5
sys/modules/dtb/overlays/Makefile
Normal file
5
sys/modules/dtb/overlays/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
# $FreeBSD$
|
||||
# All the dtso files
|
||||
DTSO= sun8i-h3-sid.dtso
|
||||
|
||||
.include <bsd.dtb.mk>
|
26
sys/tools/fdt/make_dtbo.sh
Executable file
26
sys/tools/fdt/make_dtbo.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
# Script generates dtbo file ($3) from dtso source ($2) in build tree S ($1)
|
||||
S=$1
|
||||
dtso="$2"
|
||||
dtbo_path=$3
|
||||
|
||||
if [ -z "$dtso" ]; then
|
||||
echo "No DTS overlays specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${MACHINE}" ]; then
|
||||
MACHINE=$(uname -m)
|
||||
fi
|
||||
|
||||
: ${DTC:=dtc}
|
||||
|
||||
for d in ${dtso}; do
|
||||
dtb=${dtbo_path}/`basename $d .dtso`.dtbo
|
||||
echo "converting $d -> $dtb"
|
||||
cpp -P -x assembler-with-cpp -I $S/gnu/dts/include -I $S/dts/${MACHINE} -I $S/gnu/dts/${MACHINE} -include $d /dev/null |
|
||||
${DTC} -@ -O dtb -o $dtb -i $S/dts/${MACHINE} -i $S/gnu/dts/${MACHINE}
|
||||
done
|
Loading…
x
Reference in New Issue
Block a user