hwmon-vid.h 862 B

123456789101112131415161718192021222324252627282930313233
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. hwmon-vid.h - VID/VRM/VRD voltage conversions
  4. Originally part of lm_sensors
  5. Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
  6. With assistance from Trent Piepho <xyzzy@speakeasy.org>
  7. */
  8. #ifndef _LINUX_HWMON_VID_H
  9. #define _LINUX_HWMON_VID_H
  10. int vid_from_reg(int val, u8 vrm);
  11. u8 vid_which_vrm(void);
  12. /* vrm is the VRM/VRD document version multiplied by 10.
  13. val is in mV to avoid floating point in the kernel.
  14. Returned value is the 4-, 5- or 6-bit VID code.
  15. Note that only VRM 9.x is supported for now. */
  16. static inline int vid_to_reg(int val, u8 vrm)
  17. {
  18. switch (vrm) {
  19. case 91: /* VRM 9.1 */
  20. case 90: /* VRM 9.0 */
  21. return ((val >= 1100) && (val <= 1850) ?
  22. ((18499 - val * 10) / 25 + 5) / 10 : -1);
  23. default:
  24. return -EINVAL;
  25. }
  26. }
  27. #endif /* _LINUX_HWMON_VID_H */