meta-facebook: yosemite4: Enable all fan input initially

Summary:

Fan controller need a time interval to count fan speed,to read fan speed
immediately after enable fan input will get a fake zero reading.

Enable all fan input to prevent bmc log fan sensor read 0 value and
logging critical low threshold assert during SLED cycle.

Tested:
Tested pass on yosemite4 system.

Before change:

Log a fake low threshold assert and it deaaset 1 sec later due to fan controller success to read an actual reading

    {
      "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/13",
      "@odata.type": "#LogEntry.v1_9_0.LogEntry",
      "AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/13/attachment",
      "Created": "2023-12-15T20:25:29.312+00:00",
      "EntryType": "Event",
      "Id": "13",
      "Message": "FANBOARD0_FAN0_TACH_IL critical low threshold assert. Reading=0.000000 Threshold=1000.000000.",
      "Modified": "2023-12-15T20:25:29.312+00:00",
      "Name": "System Event Log Entry",
      "Resolved": false,
      "Severity": "Critical"
    },
    {
      "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/15",
      "@odata.type": "#LogEntry.v1_9_0.LogEntry",
      "AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/15/attachment",
      "Created": "2023-12-15T20:25:30.226+00:00",
      "EntryType": "Event",
      "Id": "15",
      "Message": "FANBOARD0_FAN0_TACH_IL critical low threshold deassert. Reading=15603.000000 Threshold=1000.000000.",
      "Modified": "2023-12-15T20:25:30.226+00:00",
      "Name": "System Event Log Entry",
      "Resolved": false,
      "Severity": "OK"
    },
    {
      "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/14",
      "@odata.type": "#LogEntry.v1_9_0.LogEntry",
      "AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/14/attachment",
      "Created": "2023-12-15T20:25:30.187+00:00",
      "EntryType": "Event",
      "Id": "14",
      "Message": "FANBOARD0_FAN0_TACH_IL warning high threshold assert. Reading=15603.000000 Threshold=13915.000000.",
      "Modified": "2023-12-15T20:25:30.187+00:00",
      "Name": "System Event Log Entry",
      "Resolved": false,
      "Severity": "Warning"
    },

After change:
No fake low threshold assert/deassert occurs during sled cycle

cat sledcycle.log|grep FANBOARD
[2024-04-03 12:07:15.363]       "Message": "FANBOARD0_FAN1_TACH_OL warning high threshold assert. Reading=13466.000000 Threshold=11970.000000.",
[2024-04-03 12:07:15.392]       "Message": "FANBOARD0_FAN1_TACH_IL warning high threshold assert. Reading=15603.000000 Threshold=13140.000000.",
[2024-04-03 12:07:15.413]       "Message": "FANBOARD0_FAN0_TACH_OL warning high threshold assert. Reading=13284.000000 Threshold=11970.000000.",
[2024-04-03 12:07:15.413]       "Message": "FANBOARD0_FAN2_TACH_OL warning high threshold assert. Reading=13284.000000 Threshold=11970.000000.",
[2024-04-03 12:07:15.424]       "Message": "FANBOARD0_FAN2_TACH_IL warning high threshold assert. Reading=15603.000000 Threshold=13140.000000.",
[2024-04-03 12:07:15.441]       "Message": "FANBOARD0_FAN0_TACH_IL warning high threshold assert. Reading=15603.000000 Threshold=13140.000000.",
[2024-04-03 12:07:15.441]       "Message": "FANBOARD1_FAN1_TACH_OL warning high threshold assert. Reading=13284.000000 Threshold=11970.000000.",
[2024-04-03 12:07:15.455]       "Message": "FANBOARD1_FAN1_TACH_IL warning high threshold assert. Reading=15603.000000 Threshold=13140.000000.",
[2024-04-03 12:07:15.455]       "Message": "FANBOARD1_FAN0_TACH_OL warning high threshold assert. Reading=13466.000000 Threshold=11970.000000.",
[2024-04-03 12:07:15.471]       "Message": "FANBOARD1_FAN2_TACH_OL warning high threshold assert. Reading=13466.000000 Threshold=11970.000000.",
[2024-04-03 12:07:15.488]       "Message": "FANBOARD1_FAN2_TACH_IL warning high threshold assert. Reading=15603.000000 Threshold=13140.000000.",
[2024-04-03 12:07:15.488]       "Message": "FANBOARD1_FAN0_TACH_IL warning high threshold assert. Reading=15603.000000 Threshold=13140.000000.",
[2024-04-03 12:07:15.503]       "Message": "FANBOARD0_FAN4_TACH_OL warning high threshold assert. Reading=13107.000000 Threshold=11970.000000.",
[2024-04-03 12:07:15.503]       "Message": "FANBOARD0_FAN4_TACH_IL warning high threshold assert. Reading=15603.000000 Threshold=13140.000000.",
[2024-04-03 12:07:15.515]       "Message": "FANBOARD0_FAN3_TACH_OL warning high threshold assert. Reading=13284.000000 Threshold=11970.000000.",
[2024-04-03 12:07:15.531]       "Message": "FANBOARD0_FAN5_TACH_OL warning high threshold assert. Reading=13284.000000 Threshold=11970.000000.",
[2024-04-03 12:07:15.531]       "Message": "FANBOARD0_FAN5_TACH_IL warning high threshold assert. Reading=15603.000000 Threshold=13140.000000.",
[2024-04-03 12:07:15.548]       "Message": "FANBOARD0_FAN3_TACH_IL warning high threshold assert. Reading=15855.000000 Threshold=13140.000000.",
[2024-04-03 12:07:15.565]       "Message": "FANBOARD1_FAN4_TACH_OL warning high threshold assert. Reading=13284.000000 Threshold=11970.000000.",
[2024-04-03 12:07:15.565]       "Message": "FANBOARD1_FAN4_TACH_IL warning high threshold assert. Reading=15603.000000 Threshold=13140.000000.",
[2024-04-03 12:07:15.581]       "Message": "FANBOARD1_FAN3_TACH_OL warning high threshold assert. Reading=14672.000000 Threshold=11970.000000.",
[2024-04-03 12:07:15.581]       "Message": "FANBOARD1_FAN5_TACH_OL warning high threshold assert. Reading=13284.000000 Threshold=11970.000000.",
[2024-04-03 12:07:15.595]       "Message": "FANBOARD1_FAN5_TACH_IL warning high threshold assert. Reading=15855.000000 Threshold=13140.000000.",
[2024-04-03 12:07:15.601]       "Message": "FANBOARD1_FAN3_TACH_IL warning high threshold assert. Reading=15603.000000 Threshold=13140.000000.",

Signed-off-by: Allen.Wang <Allen_Wang@quantatw.com>
Change-Id: I803dc113624c3693fde8f12e5c0aadd339d6dd0b
diff --git a/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-early-sys-init b/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-early-sys-init
index dafaa18..ec8ed1f 100644
--- a/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-early-sys-init
+++ b/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-early-sys-init
@@ -2,6 +2,15 @@
 # shellcheck source=meta-facebook/meta-yosemite4/recipes-yosemite4/plat-tool/files/yosemite4-common-functions
 source /usr/libexec/yosemite4-common-functions
 
+
+enable_all_fan_input()
+{
+    for file in /sys/bus/i2c/devices/*/hwmon/*/fan*_enable
+    do
+      echo 1 > "${file}"
+    done
+}
+
 # probe devices behind mux for management board cpld
 
 rev_id_gpiochip=$(basename "/sys/bus/i2c/devices/13-0020/"*gpiochip*)
@@ -41,4 +50,7 @@
 chown root:kmem /dev/mem
 devmem 0x1e78008c 32 0x19000000
 
+# Enable all fan input as early as possible
+enable_all_fan_input
+
 exit 0
diff --git a/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-sys-init.service b/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-sys-init.service
index d2377f4..627a2d8 100644
--- a/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-sys-init.service
+++ b/meta-facebook/meta-yosemite4/recipes-yosemite4/plat-svc/files/yosemite4-sys-init.service
@@ -1,6 +1,7 @@
 [Unit]
 Description=Yosemite4 Early System Init
 Before=phosphor-pid-control.service
+Before=xyz.openbmc_project.fansensor.service
 
 [Service]
 Type=oneshot