DESCRIPTION = "Linux Kernel for Pinephone"
SECTION = "kernel"
LICENSE = "GPL-2.0-only"
LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

SRCREV = "${AUTOREV}"

COMPATIBLE_MACHINE = "(sun50i)"

LINUX_PINEPHONE_BRANCH ?= "pp-6.15"

SRC_URI = " \
    git://codeberg.org/megi/linux.git;branch=${LINUX_PINEPHONE_BRANCH};protocol=https \
    file://defconfig \
    file://0217-arm64-dts-allwinner-a64-Add-hdmi-sound-card.patch \
    "
# Pull in the devicetree files into the rootfs
RDEPENDS_${KERNEL_PACKAGE_NAME}-base += "kernel-devicetree"

KERNEL_EXTRA_ARGS += "LOADADDR=${UBOOT_ENTRYPOINT}"

inherit kernel

require linux.inc
 
LINUX_VERSION ?= "${PV}"
S = "${UNPACKDIR}/git"

do_deploy:append() {
    install -d ${DEPLOY_DIR_IMAGE}
    install -d ${DEPLOY_DIR_IMAGE}/allwinner
    install -d ${DEPLOY_DIR_IMAGE}/allwinner/overlay
    for file in ${KERNEL_DEVICETREE}; do
        name=$(basename $file)
        ext="${name##*.}"
        if [ "$ext" = "dtb" ]; then
            ln -sf ${DEPLOY_DIR_IMAGE}/${name} ${DEPLOY_DIR_IMAGE}/allwinner/${name}
        else
            ln -sf ${DEPLOY_DIR_IMAGE}/${name} ${DEPLOY_DIR_IMAGE}/allwinner/overlay/${name}
        fi
    done
    # install -m 0755 ${S}/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-fixup.scr ${DEPLOY_DIR_IMAGE}/allwinner/overlay/

}

FILES_${KERNEL_PACKAGE_NAME}-base:append = " ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin.modinfo"
