meta-facebook: clemente: add 998-rtc-detection script Add the 998-rtc-detection script to phosphor-static-norootfs-init to dynamically detect and bind the correct RTC device driver during the early boot stage (initramfs). Since the Clemente platform might be populated with different RTC components at the same I2C address (0x6f on bus 6), this script reads the device ID from register 0x10 to identify the hardware: - If 0x5c: Instantiates the NCT3018Y RTC driver. - If 0x4e: Instantiates the PCF85053A RTC driver. Change-Id: I3d7f7beee1ddcbc0219d6a7eb8dde6fef92e36f0 Signed-off-by: Mike Hsieh <mike_hsieh@quantatw.com>
diff --git a/meta-facebook/meta-catalina/meta-clemente/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bbappend b/meta-facebook/meta-catalina/meta-clemente/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bbappend new file mode 100644 index 0000000..eca7182 --- /dev/null +++ b/meta-facebook/meta-catalina/meta-clemente/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init.bbappend
@@ -0,0 +1,2 @@ +FILESEXTRAPATHS:append := ":${THISDIR}/${PN}" +SOURCE_FILES:append = " 998-rtc-detection" \ No newline at end of file
diff --git a/meta-facebook/meta-catalina/meta-clemente/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/998-rtc-detection b/meta-facebook/meta-catalina/meta-clemente/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/998-rtc-detection new file mode 100644 index 0000000..3e89ad6 --- /dev/null +++ b/meta-facebook/meta-catalina/meta-clemente/recipes-phosphor/initrdscripts/phosphor-static-norootfs-init/998-rtc-detection
@@ -0,0 +1,28 @@ +#!/bin/sh + +I2C_BUS=6 +I2C_ADDR=0x6f + +#Detect the rtc device by reading a vendor register +DEVICE_ID=$(i2cget -f -y $I2C_BUS $I2C_ADDR 0x10) + +if [ "$DEVICE_ID" = "0x5c" ]; then + echo "NCT3018Y rtc device detected" + + if ! echo nct3018y 0x6f > /sys/class/i2c-dev/i2c-6/device/new_device; then + echo "NCT3018Y rtc driver not bind" + fi + exit 0 + +elif [ "$DEVICE_ID" = "0x4e" ]; then + echo "PCF85053A rtc device detected" + + if ! echo pcf85053a 0x6f > /sys/class/i2c-dev/i2c-6/device/new_device; then + echo "PCF85053A rtc driver not bind" + fi + exit 0 + +else + echo "Unknown device at address $I2C_ADDR" + exit 1 +fi \ No newline at end of file