fanctrl.c 713 B

1234567891011121314151617181920212223242526272829303132333435
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2015
  4. * Dirk Eibach, Guntermann & Drunck GmbH, dirk.eibach@gdsys.cc
  5. */
  6. #ifdef CONFIG_GDSYS_LEGACY_DRIVERS
  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. }
  27. #endif /* CONFIG_GDSYS_LEGACY_DRIVERS */