1 /* 2 * (C) Copyright 2015 3 * Dirk Eibach, Guntermann & Drunck GmbH, dirk.eibach@gdsys.cc 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 7 8 #include <common.h> 9 #include <i2c.h> 10 11 enum { 12 FAN_CONFIG = 0x03, 13 FAN_TACHLIM_LSB = 0x48, 14 FAN_TACHLIM_MSB = 0x49, 15 FAN_PWM_FREQ = 0x4D, 16 }; 17 18 void init_fan_controller(u8 addr) 19 { 20 int val; 21 22 /* set PWM Frequency to 2.5% resolution */ 23 i2c_reg_write(addr, FAN_PWM_FREQ, 20); 24 25 /* set Tachometer Limit */ 26 i2c_reg_write(addr, FAN_TACHLIM_LSB, 0x10); 27 i2c_reg_write(addr, FAN_TACHLIM_MSB, 0x0a); 28 29 /* enable Tach input */ 30 val = i2c_reg_read(addr, FAN_CONFIG) | 0x04; 31 i2c_reg_write(addr, FAN_CONFIG, val); 32 } 33