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 #ifdef CONFIG_GDSYS_LEGACY_DRIVERS
8 
9 #include <common.h>
10 #include <i2c.h>
11 
12 enum {
13 	FAN_CONFIG = 0x03,
14 	FAN_TACHLIM_LSB = 0x48,
15 	FAN_TACHLIM_MSB = 0x49,
16 	FAN_PWM_FREQ = 0x4D,
17 };
18 
init_fan_controller(u8 addr)19 void init_fan_controller(u8 addr)
20 {
21 	int val;
22 
23 	/* set PWM Frequency to 2.5% resolution */
24 	i2c_reg_write(addr, FAN_PWM_FREQ, 20);
25 
26 	/* set Tachometer Limit */
27 	i2c_reg_write(addr, FAN_TACHLIM_LSB, 0x10);
28 	i2c_reg_write(addr, FAN_TACHLIM_MSB, 0x0a);
29 
30 	/* enable Tach input */
31 	val = i2c_reg_read(addr, FAN_CONFIG) | 0x04;
32 	i2c_reg_write(addr, FAN_CONFIG, val);
33 }
34 
35 #endif /* CONFIG_GDSYS_LEGACY_DRIVERS */
36