Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Mar 2018 21:30:24 +0000 (UTC)
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r331499 - in head: share/mk sys/arm/conf sys/conf sys/dts sys/dts/arm/overlays sys/modules/dtb/overlays sys/tools/fdt
Message-ID:  <201803242130.w2OLUOx0076707@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: manu
Date: Sat Mar 24 21:30:24 2018
New Revision: 331499
URL: https://svnweb.freebsd.org/changeset/base/331499

Log:
  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

Added:
  head/sys/dts/arm/overlays/
  head/sys/dts/arm/overlays/Makefile   (contents, props changed)
  head/sys/dts/arm/overlays/sun8i-h3-sid.dtso   (contents, props changed)
  head/sys/modules/dtb/overlays/
  head/sys/modules/dtb/overlays/Makefile   (contents, props changed)
  head/sys/tools/fdt/make_dtbo.sh   (contents, props changed)
Modified:
  head/share/mk/bsd.own.mk
  head/sys/arm/conf/GENERIC
  head/sys/conf/dtb.mk
  head/sys/dts/Makefile.inc

Modified: head/share/mk/bsd.own.mk
==============================================================================
--- head/share/mk/bsd.own.mk	Sat Mar 24 21:27:10 2018	(r331498)
+++ head/share/mk/bsd.own.mk	Sat Mar 24 21:30:24 2018	(r331499)
@@ -146,6 +146,7 @@ KMODOWN?=	${BINOWN}
 KMODGRP?=	${BINGRP}
 KMODMODE?=	${BINMODE}
 DTBDIR?=	/boot/dtb
+DTBODIR?=	/boot/dtb/overlays
 DTBOWN?=	root
 DTBGRP?=	wheel
 DTBMODE?=	444

Modified: head/sys/arm/conf/GENERIC
==============================================================================
--- head/sys/arm/conf/GENERIC	Sat Mar 24 21:27:10 2018	(r331498)
+++ head/sys/arm/conf/GENERIC	Sat Mar 24 21:30:24 2018	(r331499)
@@ -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"

Modified: head/sys/conf/dtb.mk
==============================================================================
--- head/sys/conf/dtb.mk	Sat Mar 24 21:27:10 2018	(r331498)
+++ head/sys/conf/dtb.mk	Sat Mar 24 21:30:24 2018	(r331499)
@@ -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)

Modified: head/sys/dts/Makefile.inc
==============================================================================
--- head/sys/dts/Makefile.inc	Sat Mar 24 21:27:10 2018	(r331498)
+++ head/sys/dts/Makefile.inc	Sat Mar 24 21:30:24 2018	(r331499)
@@ -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

Added: head/sys/dts/arm/overlays/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dts/arm/overlays/Makefile	Sat Mar 24 21:30:24 2018	(r331499)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+DTSO!=ls *.dtso
+
+all: test-dtso
+
+.include <bsd.init.mk>

Added: head/sys/dts/arm/overlays/sun8i-h3-sid.dtso
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dts/arm/overlays/sun8i-h3-sid.dtso	Sat Mar 24 21:30:24 2018	(r331499)
@@ -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";
+			};
+		};
+	};
+};

Added: head/sys/modules/dtb/overlays/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/modules/dtb/overlays/Makefile	Sat Mar 24 21:30:24 2018	(r331499)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+# All the dtso files
+DTSO=	sun8i-h3-sid.dtso
+
+.include <bsd.dtb.mk>

Added: head/sys/tools/fdt/make_dtbo.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/tools/fdt/make_dtbo.sh	Sat Mar 24 21:30:24 2018	(r331499)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803242130.w2OLUOx0076707>