fanctrl.c 633 B

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