Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Dirk Eibach | 9459433 | 2015-10-28 11:46:36 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2015 |
Mario Six | b489358 | 2018-03-06 08:04:58 +0100 | [diff] [blame] | 4 | * Dirk Eibach, Guntermann & Drunck GmbH, dirk.eibach@gdsys.cc |
Dirk Eibach | 9459433 | 2015-10-28 11:46:36 +0100 | [diff] [blame] | 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 | |
| 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 | } |