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