blob: 5e776831dbb7689bdd3177d19aa08012f816c9f4 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Dirk Eibach94594332015-10-28 11:46:36 +01002/*
3 * (C) Copyright 2015
Mario Sixb4893582018-03-06 08:04:58 +01004 * Dirk Eibach, Guntermann & Drunck GmbH, dirk.eibach@gdsys.cc
Dirk Eibach94594332015-10-28 11:46:36 +01005 */
6
7#include <common.h>
8#include <i2c.h>
9
10enum {
11 FAN_CONFIG = 0x03,
12 FAN_TACHLIM_LSB = 0x48,
13 FAN_TACHLIM_MSB = 0x49,
14 FAN_PWM_FREQ = 0x4D,
15};
16
17void 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}