blob: 9409e1d207efd3eceafe0b719db27c8c80e98bf3 [file] [log] [blame]
Thomas Gleixner74ba9202019-05-20 09:19:02 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Jean Delvare303760b2005-07-31 21:52:01 +02003 hwmon-vid.h - VID/VRM/VRD voltage conversions
4
5 Originally part of lm_sensors
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
7 With assistance from Trent Piepho <xyzzy@speakeasy.org>
8
Linus Torvalds1da177e2005-04-16 15:20:36 -07009*/
10
Jean Delvared0f28272005-08-01 22:50:08 +020011#ifndef _LINUX_HWMON_VID_H
12#define _LINUX_HWMON_VID_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Rudolf Marek734a12a2005-12-18 16:36:52 +010014int vid_from_reg(int val, u8 vrm);
15u8 vid_which_vrm(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Jean Delvared0f28272005-08-01 22:50:08 +020017/* 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 Marek734a12a2005-12-18 16:36:52 +010021static inline int vid_to_reg(int val, u8 vrm)
Sebastian Witt38862462005-04-13 22:25:39 +020022{
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 Roeck674d0ed2013-09-13 10:59:27 -070029 return -EINVAL;
Sebastian Witt38862462005-04-13 22:25:39 +020030 }
31}
Jean Delvared0f28272005-08-01 22:50:08 +020032
33#endif /* _LINUX_HWMON_VID_H */