blob: 1e0682f8e7e270ea33eb907da3036b122464ecf1 [file] [log] [blame]
mustafae67e2282021-03-29 15:08:45 -05001#!/bin/bash
2#
3# Set all fans to pwm mode.
4
Charles Boyeraf721712022-02-09 09:17:35 -06005# Provide source directive to shellcheck.
6# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
7source /usr/libexec/kudo-fw/kudo-lib.sh
8
mustafae67e2282021-03-29 15:08:45 -05009# Set all pwm_enable to 1
Charles Boyer0dd80062022-03-17 14:57:50 -050010find /sys/class/hwmon/hwmon*/ -name 'pwm*_enable' -exec bash -c 'echo "$1" && echo 1 > "$1" && cat "$1"' -- {} \;
avenash.thambif2b509f2021-11-24 14:42:31 -060011
12for i in {0..5}
13do
14 fan_pwm_rate_of_change=0x$(printf '%02x' $((8 + i)) | \
15 awk '{print $1}')
16 # Set Fan PWM Rate-of-Change Bits(bits 4:2) to 000b
17 # Register 08h to 0Dh
Charles Boyeraf721712022-02-09 09:17:35 -060018 oriRegVal=$(i2cget -y -f "${I2C_FANCTRL[0]}" 0x"${I2C_FANCTRL[1]}" \
avenash.thambif2b509f2021-11-24 14:42:31 -060019 "${fan_pwm_rate_of_change}")
20 updateVal=$((oriRegVal & 0xe3))
21 updateVal=0x$(printf "%x" ${updateVal})
Charles Boyeraf721712022-02-09 09:17:35 -060022 i2cset -y -f "${I2C_FANCTRL[0]}" 0x"${I2C_FANCTRL[1]}" \
avenash.thambif2b509f2021-11-24 14:42:31 -060023 "${fan_pwm_rate_of_change}" "${updateVal}"
24done