Quantcast
Channel: Linux Device Hacking
Viewing all articles
Browse latest Browse all 3247

NSA325 fan control (3 replies)

$
0
0
Hi,

I've got a NSA325 and it is currently running OpenWrt with the option to boot Debian from an USB stick. Both OpenWrt and Debian do not seem to have the ability to adjust the fan speed on the NSA325 at the moment. Based on the findings by 030theo in the NSA326 thread I decided to inspect the stock firmware to see if I could find something.

Running binwalk on the stock firmware does show the following script:

ext-root/etc/init.d/conf_ADT7463A.sh

ADT7463 is a Remote Thermal Controller and Voltage Monitor as can be seen in the following document.

https://www.onsemi.com/products/sensors/thermal-management/fan-controllers/adt7463

This is the script:

#!/bin/sh
        #
        # Automatic Fan Controlling of ZW1050 (by CCWu 2005-05-06)
        #

        # PWMx at Min Duty Cycle while temp < T_min
        #/sbin/i2cset -y 0x0 0x2e 0x62 0xa0 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x63 0x00 b 1>/dev/null 2>/dev/null

        # PWM_min = 25%, if temp is below T_min, fan will operate with 25% duty cycle
        #/sbin/i2cset -y 0x0 0x2e 0x64 0x40 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x65 0x40 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x66 0x40 b 1>/dev/null 2>/dev/null

        # T_min = 25
        #/sbin/i2cset -y 0x0 0x2e 0x67 0x19 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x68 0x19 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x69 0x19 b 1>/dev/null 2>/dev/null

        # THERM Limit = 55 degree C, if exceeded this, fan will operate with 100% duty cycle, full speed
        #/sbin/i2cset -y 0x0 0x2e 0x6A 0x37 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x6B 0x37 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x6C 0x37 b 1>/dev/null 2>/dev/null

        # Fastest Speed calculated by all three temperature channels controls PWMx
        # (Automatic Fan Control Mode)
        # work-around: disable fan control to avoid abnormal fan speed
        #/sbin/i2cset -y 0x0 0x2e 0x5C 0xC2 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x5D 0xC2 b 1>/dev/null 2>/dev/null
        #/sbin/i2cset -y 0x0 0x2e 0x5E 0xC2 b 1>/dev/null 2>/dev/null
        
        # (Manual Fan Control Mode)
        /sbin/i2cset -y 0x0 0x2e 0x5C 0xe2 b 1>/dev/null 2>/dev/null
        /sbin/i2cset -y 0x0 0x2e 0x5D 0xe2 b 1>/dev/null 2>/dev/null
        /sbin/i2cset -y 0x0 0x2e 0x5E 0xe2 b 1>/dev/null 2>/dev/null
        # Set PWMx current duty cycle
        /sbin/i2cset -y 0x0 0x2e 0x30 0x50 b 1>/dev/null 2>/dev/null
        /sbin/i2cset -y 0x0 0x2e 0x31 0x50 b 1>/dev/null 2>/dev/null
        /sbin/i2cset -y 0x0 0x2e 0x32 0x50 b 1>/dev/null 2>/dev/null

        ####################
        # Emma-2006.12.1  
        # Initialization of HW monitor interrupt

        # set ADT7463 pin 10 as /SMBALERT
        /sbin/i2cset -y 0x0 0x2e 0x78 0x1 b 1>/dev/null 2>/dev/null

        # set fan1 minimum to 0
        #i2cset -y 0x0 0x2e 0x54 0x0 b
        #i2cset -y 0x0 0x2e 0x55 0x0 b
        i2cset -y 0x0 0x2e 0x54 0xff b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x55 0xff b 1>/dev/null 2>/dev/null

        # set thermal interrupt limits, 0xb5=-75 degreeC, 0x4b=75 degreeC
        # (refer to ADT7463 dastasheet p.17)
        i2cset -y 0x0 0x2e 0x4e 0xb5 b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x4f 0x4b b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x50 0xb5 b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x51 0x4b b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x52 0xb5 b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x53 0x4b b 1>/dev/null 2>/dev/null

        # enable interrupts: Remote 1 temperature channel, local temperature channel, Remote 2 temperature channel, and fan1.
        i2cset -y 0x0 0x2e 0x74 0x0f b 1>/dev/null 2>/dev/null
        i2cset -y 0x0 0x2e 0x75 0xfb b 1>/dev/null 2>/dev/null

        # End of Initialization of HW monitor interrupt
        ###################

        ###################################################
        # Make sure fan speed will be greater than 2000 rpm
        #fanrpm=`cat /sys/devices/platform/i2c-0/0-002e/fan1_input`
        fanrpm=`cat /sys/bus/i2c/devices/0-002e/fan1_input`
        var=`i2cget -y 0x0 0x2e 0x30`

        while [ $fanrpm -lt 2000 ]; do
                var=$((var+0x8))
                if [ $var -gt 112 ]; then
                        break;
                fi 

                echo "fanspeed $fanrpm , pwm value $var"

                /sbin/i2cset -y 0x0 0x2e 0x30 $var b 1>/dev/null 2>/dev/null
                /sbin/i2cset -y 0x0 0x2e 0x31 $var b 1>/dev/null 2>/dev/null
                /sbin/i2cset -y 0x0 0x2e 0x32 $var b 1>/dev/null 2>/dev/null         
                sleep 1
                #fanrpm=`cat /sys/devices/platform/i2c-0/0-002e/fan1_input`
                fanrpm=`cat /sys/bus/i2c/devices/0-002e/fan1_input`
        done
        # End of fan speed adjustment
        ##################

        ###################################################
        # Start PID Fan  control
        if [ -x /sbin/fanctrld ]; then
                /bin/echo "Starting PID Fan Control.."
                /bin/nice -n 15 /sbin/fanctrld 0x0 0x2e
        fi

The ADT7463 chip seems to be supported by the hwmon lm85 kernel driver.

https://www.kernel.org/doc/Documentation/hwmon/lm85

However installing this driver in OpenWrt does not make the fan / sensor show up in lm-sensors. I guess the sensor / fan needs to be defined in the dts / dtb file first. I hope anybody on here has an idea how to get fancontrol working? I'm happy to use my NAS to experiment / run tests to get this working

Thanks,

Koen

Viewing all articles
Browse latest Browse all 3247

Trending Articles