blob: af2901e026ee3c70713402ebd4082f50c44884a1 [file] [log] [blame]
inherit kernel
require recipes-kernel/linux/linux-yocto.inc
require recipes-bsp/gbmc-bsp-common/gbmc-bsp-common.inc
DEFAULT_PREFERENCE = "-1"
PROVIDES += "virtual/kernel linux-gbmc"
KCONFIG_MODE = "--allnoconfig"
# We do not want kernel images installed into /boot
RRECOMMENDS:${KERNEL_PACKAGE_NAME}-base = ""
SRC_URI += " \
file://DOWNSTREAM_0001-gBMC-Splice.patch \
file://linux-gbmc \
file://gbmc-trim-kconfig.sh \
file://gbmc-verify-pins.sh \
file://gbmc-delta-kconfig.sh \
file://DOWNSTREAM_0001-misc-Add-gBMC-subfolder.patch \
${@'file://asan.cfg' if (d.getVar('GBMC_SAN_MODE', False) or '' ).endswith('asan') else ''} \
${@bb.utils.contains('PACKAGECONFIG', 'emmc', 'file://emmc.cfg', '', d)} \
${@bb.utils.contains('PACKAGECONFIG', 'udc-nic', 'file://udc-nic.cfg', '', d)} \
${@bb.utils.contains('PACKAGECONFIG', 'usb-host', 'file://usb-host.cfg', '', d)} \
${@bb.utils.contains('PACKAGECONFIG', 'usb-host-net', 'file://usb-host-net.cfg', '', d)} \
"
PACKAGECONFIG[diorite_c0] = ""
DIORITE_C0_SUPPORTED = "0"
DIORITE_C0_SUPPORTED:npcm7xx = "1"
PACKAGECONFIG[emmc] = ""
EMMC_SUPPORTED = "0"
EMMC_SUPPORTED:npcm7xx = "1"
EMMC_SUPPORTED:npcm8xx = "1"
PACKAGECONFIG[udc-nic] = ""
UDC_NIC_SUPPORTED = "0"
UDC_NIC_SUPPORTED:npcm7xx = "1"
UDC_NIC_SUPPORTED:npcm8xx = "1"
PACKAGECONFIG[usb-host] = ""
USB_HOST_SUPPORTED = "0"
USB_HOST_SUPPORTED:npcm7xx = "1"
USB_HOST_SUPPORTED:npcm8xx = "1"
PACKAGECONFIG[usb-host-net] = ""
python __anonymous () {
if bb.utils.contains('PACKAGECONFIG', 'diorite_c0', True, False, d) and d.getVar('DIORITE_C0_SUPPORTED') != "1":
bb.fatal("Diorite C0 workaround not supported for this platform")
if bb.utils.contains('PACKAGECONFIG', 'emmc', True, False, d) and d.getVar('USB_HOST_SUPPORTED') != "1":
bb.fatal("EMMC not supported for this platform")
if bb.utils.contains('PACKAGECONFIG', 'udc-nic', True, False, d) and d.getVar('UDC_NIC_SUPPORTED') != "1":
bb.fatal("USB Host not supported for this platform")
if bb.utils.contains('PACKAGECONFIG', 'usb-host', True, False, d) and d.getVar('USB_HOST_SUPPORTED') != "1":
bb.fatal("USB Host not supported for this platform")
if bb.utils.contains('PACKAGECONFIG', 'usb-host-net', True, False, d) and bb.utils.contains('PACKAGECONFIG', 'usb-host', False, True, d):
bb.fatal("USB Host Networking requires usb-host")
}
USB_HOST_STATUS = "${@bb.utils.contains('PACKAGECONFIG', 'usb-host', '"okay"', '"disabled"', d)}"
EMMC_STATUS = "${@bb.utils.contains('PACKAGECONFIG', 'emmc', '"okay"', '"disabled"', d)}"
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI += "file://defconfig"
SRC_URI:append:dev = " file://dev.cfg"
LINUX_PLATFORMS = ""
LINUX_PLATFORMS:npcm7xx = "arm armv7 npcm npcm7xx"
LINUX_PLATFORMS:npcm8xx = "arm armv8 npcm npcm8xx"
LINUX_PLATFORMS:aspeed-g6 = "arm armv7 ast ast26xx"
SRC_URI:append:npcm7xx = " \
${@bb.utils.contains('PACKAGECONFIG', 'diorite_c0', 'file://DOWNSTREAM_0001-Diorite-workaround-for-c0-card.patch', '', d)} \
"
do_ksrc_apply() {
if [ -e ${WORKDIR}/patch-* ]; then
cd ${S}
check_git_config
if git log -n1 --oneline | grep -q ksrc-apply-linux-gbmc; then
git reset --hard 'HEAD^'
fi
git clean -d -f
git apply ${WORKDIR}/patch-*
git add .
git commit -n -m "ksrc-apply-linux-gbmc ${LINUX_VERSION}"
fi
}
# We only have a special flash layout for 32MB platforms, the 64MB layout is
# generic and should be used by all other sized flashes with dynamic image
# support turned on.
FLASH_LAYOUT_SIZE = "${@32 if d.getVar('FLASH_SIZE') == '32768' else 64}"
do_ksrc_splice() {
# Ensure that our SPI override file is correctly in place over a valid file in the tree
test -e ${S}/drivers/mtd/spi-nor/everspin.c
grep -q 'everspin.o' ${S}/drivers/mtd/spi-nor/Makefile
cp -r ${WORKDIR}/linux-gbmc/* ${S}/
# Fill in PACKAGECONFIG defines
sed -e 's,@USB_HOST_STATUS@,${USB_HOST_STATUS},g' \
-e 's,@EMMC_STATUS@,${EMMC_STATUS},g' \
-e 's,@FLASH_LAYOUT_SIZE@,${FLASH_LAYOUT_SIZE},g' \
-e 's,@FLASH_HZ@,${@int(int(d.getVar('GBMC_BOOT_SPI_MHZ'))*1000*1000)},g' \
-i ${S}/arch/arm/boot/dts/nuvoton/npcm7xx-gbmc.dtsi
# Compatability symlinks for the DTS move from `nuvoton-*` to `nuvoton/nuvoton-*`
for file in ${S}/arch/arm/boot/dts/nuvoton/*.dtsi; do
[ ! -L "$file" ] || continue
ln -fsrv "$file" ${S}/arch/arm/boot/dts/
done
}
do_ksrc_splice:prepend:npcm7xx() {
mkdir -p ${S}/arch/arm/boot/dts/nuvoton
cp ${WORKDIR}/npcm7xx-gbmc-common.dtsi ${S}/arch/arm/boot/dts/nuvoton/
}
do_compile:prepend:npcm7xx() {
# We need the file after running the preprocessor so we get the macro expanded struct values
oe_runmake -C ${S} O=${B} drivers/pinctrl/nuvoton/pinctrl-npcm7xx.i
# Compare the struct values to the values in the dtsi
bash ${WORKDIR}/gbmc-verify-pins.sh ${B}/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.i ${S}/arch/arm/boot/dts/nuvoton/npcm7xx-gbmc-common.dtsi
}
# Rewrite the splice patch to include all of the dropped-in files
do_ksrc_splice_post() {
cd ${S}
check_git_config
git add .
git commit -n -m "gBMC: Splice contents into source tree"
patch="$(git format-patch 'HEAD^')"
git reset --hard 'HEAD^'
mv "$patch" ${WORKDIR}/DOWNSTREAM_0001-gBMC-Splice.patch
}
do_kernel_checkout[postfuncs] =+ "do_ksrc_apply do_ksrc_splice do_ksrc_splice_post"
# We need to make sure the subsequent fetch gets overridden by our modified patch
do_kernel_metadata:append() {
test -e ${S}/.kernel-meta/patches/DOWNSTREAM_0001-gBMC-Splice.patch
cp ${WORKDIR}/DOWNSTREAM_0001-gBMC-Splice.patch ${S}/.kernel-meta/patches/
if [ -e "${S}/.kernel-meta/configs" ]; then
bash ${WORKDIR}/gbmc-trim-kconfig.sh ${LINUX_VERSION} "${LINUX_PLATFORMS}" ${S}/.kernel-meta/configs/*
fi
}
GBMC_CONFIGCHECK ?= "1"
do_gbmc_configcheck() {
st=0
bash ${WORKDIR}/gbmc-delta-kconfig.sh ${B}/.config ${S}/.kernel-meta/configs/* || st=$?
if [ "${GBMC_CONFIGCHECK}" = "1" -a $st -ne 0 ]; then
exit 1
fi
}
do_kernel_configcheck[postfuncs] =+ "do_gbmc_configcheck"
do_compile_headers() {
oe_runmake -C ${S} O=${B} headers
}
do_shared_headers() {
mkdir -p ${STAGING_KERNEL_BUILDDIR}/usr
cp -r ${B}/usr/include/ ${STAGING_KERNEL_BUILDDIR}/usr/
}
addtask do_compile_headers after do_configure
addtask do_shared_headers after do_shared_workdir do_compile_headers