From 32b8f0c20331a3aff6b6e77a0576b755fdcfc2d6 Mon Sep 17 00:00:00 2001 From: Tobias Poganiuch <tobias.poganiuch@garz-fricke.com> Date: Mon, 11 Jul 2022 13:27:15 +0200 Subject: [PATCH] fng-install:rtc: Added RTC detection for the TANARO The TANARO will be produced with one of two RTC variants. We detect the RTC by querying the first register during the post-install and activate one of two devicetree overlays. BCS 746-000877 --- recipes-bsp/fng-install/prepare-image.bb | 10 +++++ .../prepare-image/gf-prepare-rtc.sh | 43 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 recipes-bsp/fng-install/prepare-image/gf-prepare-rtc.sh diff --git a/recipes-bsp/fng-install/prepare-image.bb b/recipes-bsp/fng-install/prepare-image.bb index 182663e0..07d8c279 100644 --- a/recipes-bsp/fng-install/prepare-image.bb +++ b/recipes-bsp/fng-install/prepare-image.bb @@ -7,6 +7,7 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7ca RDEPENDS_${PN} = " \ fng-install-postinstallation \ sharedconf \ + i2c-tools \ " SRC_URI = " \ @@ -22,6 +23,10 @@ SRC_URI_append_mx6 = " \ file://gf-prepare-xml2dto.sh \ " +SRC_URI_append_mx8 = " \ + file://gf-prepare-rtc.sh \ +" + do_configure_append_fng () { # Exchange the bootpartitions for Flash-N-Go System sed -i ${WORKDIR}/gf-prepare-kernel.sh -e 's|^BOOTPARTITIONS=".*|BOOTPARTITIONS="/dev/disk/by-label/Flash-N-Go /dev/mmcblk0p1 /dev/mmcblk1p1"|' @@ -48,3 +53,8 @@ do_install_append_mx6() { ln -s ${sbindir}/gf-prepare-dt.sh ${D}${sysconfdir}/fng-postinstall/12-gf-prepare-dt ln -s ${sbindir}/gf-prepare-xml2dto.sh ${D}${sysconfdir}/fng-postinstall/13-gf-prepare-xml2dto } + +do_install_append_mx8() { + install -m 0755 ${WORKDIR}/gf-prepare-rtc.sh ${D}${sbindir} + ln -s ${sbindir}/gf-prepare-rtc.sh ${D}${sysconfdir}/fng-postinstall/14-gf-prepare-rtc +} diff --git a/recipes-bsp/fng-install/prepare-image/gf-prepare-rtc.sh b/recipes-bsp/fng-install/prepare-image/gf-prepare-rtc.sh new file mode 100644 index 00000000..b73d042d --- /dev/null +++ b/recipes-bsp/fng-install/prepare-image/gf-prepare-rtc.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# shellcheck source=../../../recipes-guf/sharedconf/sharedconf/gf-functions.sh +if ! . /usr/sbin/gf-functions.sh; then + echo "Unable to include gf-functions" +fi +# shellcheck source=./gf-prepare-common.sh +if ! . /usr/sbin/gf-prepare-common.sh; then + echo "Unable to include gf-prepare-common" +fi + +poll_rtc() { + if i2cget -y 2 "$1" 0x00 2>&1 | grep -E '.*0x.*|.*Device or resource busy.*'; then + echo "Device found at address $1" + return 0 + else + echo "No device found at address $1" + return 1 + fi +} + +# Get the directory containing the bootfiles +mount_bootpartition BOOTFILES_DIR + +# Change into the boot directory +cd "$BOOTFILES_DIR" || exit 1 + +# RX8803 +if poll_rtc 0x32; then + append_overlay "rx8803-overlay.dtb" +else + # PCF8563 + if poll_rtc 0x51; then + append_overlay "pcf8563-overlay.dtb" + else + echo "Error: Unable to find any valid device" + exit 1 + fi +fi + +exit 0 + +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 -- GitLab