Skip to content

Instantly share code, notes, and snippets.

@michaeljs1990
Created June 17, 2019 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save michaeljs1990/78a1f17cb9d7351554e0f36aad726728 to your computer and use it in GitHub Desktop.
Save michaeljs1990/78a1f17cb9d7351554e0f36aad726728 to your computer and use it in GitHub Desktop.
PfSense XG-7100 Quite Fan Config
#!/bin/sh
#
# Script to configure the fan controller on the XG-7100.
# The EMC2104 is accessed via the smbus on the ICH.
#
#
#
# Load required modules if they are not loaded
kldstat | grep " ichsmb.ko" > /dev/null
if [ $? -eq 1 ]
then
kldload ichsmb
echo "ichsmb loaded"
else
echo "ichsmb already loaded"
fi
kldstat | grep " smb.ko" > /dev/null
if [ $? -eq 1 ]
then
kldload smb
echo "smb loaded"
else
echo "smb already loaded"
fi
# Test we can "see" the fan controller on the smbus
if [ "$(smbmsg -f /dev/smb0 -s 0x5e -c 0xfd -i 1)" = 0x1d ]
then
smb_dev="/dev/smb0"
echo "Found EMC2104 on $smb_dev"
else
if [ "$(smbmsg -f /dev/smb1 -s 0x5e -c 0xfd -i 1)" = 0x1d ]
then
smb_dev="/dev/smb1"
echo "Found EMC2104 on $smb_dev"
else
echo "EMC2104 not found"
exit 1
fi
fi
# Set both fan controllers to manual drive mode (unlocks LUTs)
smbmsg -f $smb_dev -s 0x5e -c 0x50 -o 1 0x10
smbmsg -f $smb_dev -s 0x5e -c 0x90 -o 1 0x10
echo "Fan controllers set to manual"
# Set Hysteresis
hysteresis=0x01
smbmsg -f $smb_dev -s 0x5e -c 0x79 -o 1 $hysteresis
smbmsg -f $smb_dev -s 0x5e -c 0xb9 -o 1 $hysteresis
echo "Hysteresis set to $hysteresis"
# Set Look-up table 1.
smbmsg -f $smb_dev -s 0x5e -c 0x51 -o 1 0x38 #Setting 1 drive value
smbmsg -f $smb_dev -s 0x5e -c 0x52 -o 1 0x14 #20C
smbmsg -f $smb_dev -s 0x5e -c 0x53 -o 1 0x14
smbmsg -f $smb_dev -s 0x5e -c 0x54 -o 1 0x14
smbmsg -f $smb_dev -s 0x5e -c 0x55 -o 1 0x14
smbmsg -f $smb_dev -s 0x5e -c 0x56 -o 1 0x48 #Setting 2 drive value
smbmsg -f $smb_dev -s 0x5e -c 0x57 -o 1 0x22 #34C
smbmsg -f $smb_dev -s 0x5e -c 0x58 -o 1 0x22
smbmsg -f $smb_dev -s 0x5e -c 0x59 -o 1 0x22
smbmsg -f $smb_dev -s 0x5e -c 0x5a -o 1 0x22
smbmsg -f $smb_dev -s 0x5e -c 0x5b -o 1 0x50 #Setting 3 drive value
smbmsg -f $smb_dev -s 0x5e -c 0x5c -o 1 0x24 #36C
smbmsg -f $smb_dev -s 0x5e -c 0x5d -o 1 0x24
smbmsg -f $smb_dev -s 0x5e -c 0x5e -o 1 0x24
smbmsg -f $smb_dev -s 0x5e -c 0x5f -o 1 0x24
smbmsg -f $smb_dev -s 0x5e -c 0x60 -o 1 0x58 #Setting 4 drive value
smbmsg -f $smb_dev -s 0x5e -c 0x61 -o 1 0x26 #38C
smbmsg -f $smb_dev -s 0x5e -c 0x62 -o 1 0x26
smbmsg -f $smb_dev -s 0x5e -c 0x63 -o 1 0x26
smbmsg -f $smb_dev -s 0x5e -c 0x64 -o 1 0x26
smbmsg -f $smb_dev -s 0x5e -c 0x65 -o 1 0x60 #Setting 5 drive value
smbmsg -f $smb_dev -s 0x5e -c 0x66 -o 1 0x28 #40C
smbmsg -f $smb_dev -s 0x5e -c 0x67 -o 1 0x28
smbmsg -f $smb_dev -s 0x5e -c 0x68 -o 1 0x28
smbmsg -f $smb_dev -s 0x5e -c 0x69 -o 1 0x28
smbmsg -f $smb_dev -s 0x5e -c 0x6a -o 1 0x68 #Setting 6 drive value
smbmsg -f $smb_dev -s 0x5e -c 0x6b -o 1 0x2a #42C
smbmsg -f $smb_dev -s 0x5e -c 0x6c -o 1 0x2a
smbmsg -f $smb_dev -s 0x5e -c 0x6d -o 1 0x2a
smbmsg -f $smb_dev -s 0x5e -c 0x6e -o 1 0x2a
smbmsg -f $smb_dev -s 0x5e -c 0x6f -o 1 0x80 #Setting 7 drive value
smbmsg -f $smb_dev -s 0x5e -c 0x70 -o 1 0x2c #44C
smbmsg -f $smb_dev -s 0x5e -c 0x71 -o 1 0x2c
smbmsg -f $smb_dev -s 0x5e -c 0x72 -o 1 0x2c
smbmsg -f $smb_dev -s 0x5e -c 0x73 -o 1 0x2c
smbmsg -f $smb_dev -s 0x5e -c 0x74 -o 1 0xa0 #Setting 8 drive value
smbmsg -f $smb_dev -s 0x5e -c 0x75 -o 1 0x32 #50C
smbmsg -f $smb_dev -s 0x5e -c 0x76 -o 1 0x32
smbmsg -f $smb_dev -s 0x5e -c 0x77 -o 1 0x32
smbmsg -f $smb_dev -s 0x5e -c 0x78 -o 1 0x32
echo "LUT1 configured"
# Set Look-up table 2.
smbmsg -f $smb_dev -s 0x5e -c 0x91 -o 1 0x38 #Setting 1 drive value
smbmsg -f $smb_dev -s 0x5e -c 0x92 -o 1 0x14 #20C
smbmsg -f $smb_dev -s 0x5e -c 0x93 -o 1 0x14
smbmsg -f $smb_dev -s 0x5e -c 0x94 -o 1 0x14
smbmsg -f $smb_dev -s 0x5e -c 0x95 -o 1 0x14
smbmsg -f $smb_dev -s 0x5e -c 0x96 -o 1 0x48 #Setting 2 drive value
smbmsg -f $smb_dev -s 0x5e -c 0x97 -o 1 0x22 #34C
smbmsg -f $smb_dev -s 0x5e -c 0x98 -o 1 0x22
smbmsg -f $smb_dev -s 0x5e -c 0x99 -o 1 0x22
smbmsg -f $smb_dev -s 0x5e -c 0x9a -o 1 0x22
smbmsg -f $smb_dev -s 0x5e -c 0x9b -o 1 0x50 #Setting 3 drive value
smbmsg -f $smb_dev -s 0x5e -c 0x9c -o 1 0x24 #36C
smbmsg -f $smb_dev -s 0x5e -c 0x9d -o 1 0x24
smbmsg -f $smb_dev -s 0x5e -c 0x9e -o 1 0x24
smbmsg -f $smb_dev -s 0x5e -c 0x9f -o 1 0x24
smbmsg -f $smb_dev -s 0x5e -c 0xa0 -o 1 0x58 #Setting 4 drive value
smbmsg -f $smb_dev -s 0x5e -c 0xa1 -o 1 0x26 #38C
smbmsg -f $smb_dev -s 0x5e -c 0xa2 -o 1 0x26
smbmsg -f $smb_dev -s 0x5e -c 0xa3 -o 1 0x26
smbmsg -f $smb_dev -s 0x5e -c 0xa4 -o 1 0x26
smbmsg -f $smb_dev -s 0x5e -c 0xa5 -o 1 0x60 #Setting 5 drive value
smbmsg -f $smb_dev -s 0x5e -c 0xa6 -o 1 0x28 #40C
smbmsg -f $smb_dev -s 0x5e -c 0xa7 -o 1 0x28
smbmsg -f $smb_dev -s 0x5e -c 0xa8 -o 1 0x28
smbmsg -f $smb_dev -s 0x5e -c 0xa9 -o 1 0x28
smbmsg -f $smb_dev -s 0x5e -c 0xaa -o 1 0x68 #Setting 6 drive value
smbmsg -f $smb_dev -s 0x5e -c 0xab -o 1 0x2a #42C
smbmsg -f $smb_dev -s 0x5e -c 0xac -o 1 0x2a
smbmsg -f $smb_dev -s 0x5e -c 0xad -o 1 0x2a
smbmsg -f $smb_dev -s 0x5e -c 0xae -o 1 0x2a
smbmsg -f $smb_dev -s 0x5e -c 0xaf -o 1 0x80 #Setting 7 drive value
smbmsg -f $smb_dev -s 0x5e -c 0xb0 -o 1 0x2c #44C
smbmsg -f $smb_dev -s 0x5e -c 0xb1 -o 1 0x2c
smbmsg -f $smb_dev -s 0x5e -c 0xb2 -o 1 0x2c
smbmsg -f $smb_dev -s 0x5e -c 0xb3 -o 1 0x2c
smbmsg -f $smb_dev -s 0x5e -c 0xb4 -o 1 0xa0 #Setting 8 drive value
smbmsg -f $smb_dev -s 0x5e -c 0xb5 -o 1 0x32 #50C
smbmsg -f $smb_dev -s 0x5e -c 0xb6 -o 1 0x32
smbmsg -f $smb_dev -s 0x5e -c 0xb7 -o 1 0x32
smbmsg -f $smb_dev -s 0x5e -c 0xb8 -o 1 0x32
echo "LUT2 configured"
# Set both fan controllers to direct drive mode with look-up tables.
smbmsg -f $smb_dev -s 0x5e -c 0x50 -o 1 0x30
smbmsg -f $smb_dev -s 0x5e -c 0x90 -o 1 0x30
echo "Fan controllers set to auto"
@smartpierre
Copy link

Works perfectly, thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment