Add infrastructure to build dtb files from dts files.

This commit is contained in:
Warner Losh 2015-01-08 18:28:06 +00:00
parent d7968c29ec
commit c4765af73f
5 changed files with 103 additions and 1 deletions

View File

@ -11,6 +11,7 @@ FILES= \
bsd.crunchgen.mk \
bsd.dep.mk \
bsd.doc.mk \
bsd.dtb.mk \
bsd.endian.mk \
bsd.files.mk \
bsd.incs.mk \

17
share/mk/bsd.dtb.mk Normal file
View File

@ -0,0 +1,17 @@
# $FreeBSD$
# Search for kernel source tree in standard places.
.for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. ${.CURDIR}/../../../.. \
${.CURDIR}/../../../../.. /sys /usr/src/sys
.if !defined(SYSDIR) && exists(${_dir}/kern/) && exists(${_dir}/conf/kmod.mk)
SYSDIR= ${_dir}
.endif
.endfor
.if !defined(SYSDIR) || !exists(${SYSDIR}/kern/) || \
!exists(${SYSDIR}/conf/kmod.mk)
.error Unable to locate the kernel source tree. Set SYSDIR to override.
.endif
.include "${SYSDIR}/conf/dtb.mk"
.include <bsd.sys.mk>

View File

@ -15,7 +15,7 @@ makeoptions KERNVIRTADDR=0xc0000000
options KERNPHYSADDR=0x20000000
options KERNVIRTADDR=0xc0000000
makeoptions MODULES_OVERRIDE=""
makeoptions MODULES_OVERRIDE="dtb/atmel"
# list all boards here, but not just yet (no multiboard in mainline).
options ARM_MANY_BOARD

75
sys/conf/dtb.mk Normal file
View File

@ -0,0 +1,75 @@
# $FreeBSD$
#
# The include file <dtb.mk> handles building and installing dtb files.
#
# +++ variables +++
#
# DTS List of the dts files to build and install.
#
# DTBDIR Base path for dtb modules [/boot/dtb]
#
# DTBOWN .dtb file owner. [${BINOWN}]
#
# DTBGRP .dtb file group. [${BINGRP}]
#
# DTBMODE Module file mode. [${BINMODE}]
#
# DESTDIR The tree where the module gets installed. [not set]
#
# +++ targets +++
#
# install:
# install the kernel module; if the Makefile
# does not itself define the target install, the targets
# beforeinstall and afterinstall may also be used to cause
# actions immediately before and after the install target
# is executed.
#
.include <bsd.init.mk>
# Grab all the options for a kernel build. For backwards compat, we need to
# do this after bsd.own.mk.
.include "kern.opts.mk"
# Search for kernel source tree in standard places.
.for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys
.if !defined(SYSDIR) && exists(${_dir}/kern/)
SYSDIR= ${_dir}
.endif
.endfor
.if !defined(SYSDIR) || !exists(${SYSDIR}/kern/)
.error "can't find kernel source tree"
.endif
.SUFFIXES: .dtb .dts
.PATH: ${SYSDIR}/gnu/dts/${MACHINE} ${SYSDIR}/boot/fdt/dts/${MACHINE}
DTBDIR?=/boot/dtb
DTB=${DTS:R:S/$/.dtb/}
all: ${DTB}
.if defined(DTS)
.for _dts in ${DTS}
${_dts:R:S/$/.dtb/}: ${_dts}
@echo Generating ${.TARGET} from ${_dts}
@${SYSDIR}/tools/fdt/make_dtb.sh ${SYSDIR} ${_dts} ${.OBJDIR}
CLEANFILES+=${_dts:R:S/$/.dtb/}
.endfor
.endif
.if !target(install)
.if !target(realinstall)
realinstall: _dtbinstall
.ORDER: beforeinstall _kmodinstall
_dtbinstall:
.for _dtb in ${DTB}
${INSTALL} -o ${DTBOWN} -g ${DTBGRP} -m ${DTBMODE} \
${_INSTALLFLAGS} ${_dtb} ${DESTDIR}${DTBDIR}
.endfor
.endif # !target(realinstall)
.endif # !target(install)
.include <bsd.dep.mk>
.include <bsd.obj.mk>

View File

@ -0,0 +1,9 @@
# $FreeBSD$
# All the dts files for the boards we might likely support made by Atmel,
# plus the SAMA5 offerings.
DTS=at91-sama5d3_xplained.dts at91sam9g20ek.dts ethernut5.dts \
at91-qil_a9260.dts sama5d31ek.dts sama5d33ek.dts sama5d34ek.dts \
sama5d35ek.dts sama5d36ek.dts tny_a9260.dts tny_a9g20.dts \
usb_a9260.dts usb_a9g20.dts
.include <bsd.dtb.mk>