From c0e2bb910c4e2ad5d0db36707569fcc6734afe55 Mon Sep 17 00:00:00 2001 From: Gunjan Gupta Date: Wed, 11 Oct 2023 13:01:41 +0530 Subject: [PATCH] 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. --- config/boards/khadas-vim4.wip | 7 +++++++ config/sources/families/meson-s4t7.conf | 7 +++++++ packages/bsp/meson-s4t7/fan.service | 11 +++++++++++ 3 files changed, 25 insertions(+) create mode 100644 packages/bsp/meson-s4t7/fan.service diff --git a/config/boards/khadas-vim4.wip b/config/boards/khadas-vim4.wip index b24c7cfcff..a3d1bfb103 100644 --- a/config/boards/khadas-vim4.wip +++ b/config/boards/khadas-vim4.wip @@ -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 +} diff --git a/config/sources/families/meson-s4t7.conf b/config/sources/families/meson-s4t7.conf index 557c3fa3ba..1f7ec747e2 100644 --- a/config/sources/families/meson-s4t7.conf +++ b/config/sources/families/meson-s4t7.conf @@ -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 +} diff --git a/packages/bsp/meson-s4t7/fan.service b/packages/bsp/meson-s4t7/fan.service new file mode 100644 index 0000000000..e815d82a7b --- /dev/null +++ b/packages/bsp/meson-s4t7/fan.service @@ -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