meson-s4t7: add systemd service to enable fan in automatic mode

The service is only enabled by default on Vim4 as that board heats
a lot and a fan is absolutely necessary. Service will be available
on vim1s as well and if someone has purchased the fan for it, they
would be able to enable it themselves.

The service is only added for legacy kernel right now as I am not
sure if the upcoming 5.15 kernel will have same sysfs interface for
fan.
This commit is contained in:
Gunjan Gupta
2023-10-11 13:01:41 +05:30
committed by Igor
parent c1dd4ed3a5
commit c0e2bb910c
3 changed files with 25 additions and 0 deletions

View File

@@ -25,3 +25,10 @@ function post_family_tweaks_bsp__kvim4_isp_modprobe() {
softdep iv009_isp pre: iv009_isp_iq iv009_isp_lens iv009_isp_sensor
EOD
}
function post_family_tweaks_bsp__enable_fan_service() {
if [[ ${BRANCH} = "legacy" ]]; then
run_host_command_logged mkdir -p "${destination}"/etc/systemd/system/mutli-user.target.wants
run_host_command_logged ln -sf /etc/systemd/system/fan.service "${destination}"/etc/systemd/system/mutli-user.target.wants/fan.service
fi
}

View File

@@ -106,3 +106,10 @@ function image_specific_armbian_env_ready__force_16x9_display() {
run_host_command_logged echo "force_16x9_display=true" >>${SDCARD}/boot/armbianEnv.txt
fi
}
function post_family_tweaks_bsp__add_fan_service() {
if [[ ${BRANCH} = "legacy" ]]; then
run_host_command_logged mkdir -p "${destination}"/etc/systemd/system
run_host_command_logged cp "${SRC}"/packages/bsp/meson-s4t7/fan.service "${destination}"/etc/systemd/system
fi
}

View File

@@ -0,0 +1,11 @@
[Unit]
Description=Automatic Fan Control Service
[Service]
Type=oneshot
RemainAfterExit=Yes
ExecStart=/bin/sh -c "echo 1 > /sys/class/fan/mode"
ExecStart=/bin/sh -c "echo 1 > /sys/class/fan/enable"
[Install]
WantedBy=multi-user.target