fanctrl.c 635 B

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