Thomas Gleixner | 74ba920 | 2019-05-20 09:19:02 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Jean Delvare | 303760b | 2005-07-31 21:52:01 +0200 | [diff] [blame] | 3 | hwmon-vid.h - VID/VRM/VRD voltage conversions |
| 4 | |
| 5 | Originally part of lm_sensors |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> |
| 7 | With assistance from Trent Piepho <xyzzy@speakeasy.org> |
| 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
Jean Delvare | d0f2827 | 2005-08-01 22:50:08 +0200 | [diff] [blame] | 11 | #ifndef _LINUX_HWMON_VID_H |
| 12 | #define _LINUX_HWMON_VID_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
Rudolf Marek | 734a12a | 2005-12-18 16:36:52 +0100 | [diff] [blame] | 14 | int vid_from_reg(int val, u8 vrm); |
| 15 | u8 vid_which_vrm(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Jean Delvare | d0f2827 | 2005-08-01 22:50:08 +0200 | [diff] [blame] | 17 | /* vrm is the VRM/VRD document version multiplied by 10. |
| 18 | val is in mV to avoid floating point in the kernel. |
| 19 | Returned value is the 4-, 5- or 6-bit VID code. |
| 20 | Note that only VRM 9.x is supported for now. */ |
Rudolf Marek | 734a12a | 2005-12-18 16:36:52 +0100 | [diff] [blame] | 21 | static inline int vid_to_reg(int val, u8 vrm) |
Sebastian Witt | 3886246 | 2005-04-13 22:25:39 +0200 | [diff] [blame] | 22 | { |
| 23 | switch (vrm) { |
| 24 | case 91: /* VRM 9.1 */ |
| 25 | case 90: /* VRM 9.0 */ |
| 26 | return ((val >= 1100) && (val <= 1850) ? |
| 27 | ((18499 - val * 10) / 25 + 5) / 10 : -1); |
| 28 | default: |
Guenter Roeck | 674d0ed | 2013-09-13 10:59:27 -0700 | [diff] [blame] | 29 | return -EINVAL; |
Sebastian Witt | 3886246 | 2005-04-13 22:25:39 +0200 | [diff] [blame] | 30 | } |
| 31 | } |
Jean Delvare | d0f2827 | 2005-08-01 22:50:08 +0200 | [diff] [blame] | 32 | |
| 33 | #endif /* _LINUX_HWMON_VID_H */ |