Felix Held | 23a398e | 2023-03-23 23:44:03 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <amdblocks/cpu.h> |
Felix Held | 2c9de49 | 2023-03-23 23:57:44 +0100 | [diff] [blame] | 4 | #include <soc/msr.h> |
Felix Held | 23a398e | 2023-03-23 23:44:03 +0100 | [diff] [blame] | 5 | #include <types.h> |
| 6 | |
| 7 | /* Value defined in Serial VID Interface 2.0 spec (#48022, NDA only) */ |
| 8 | #define SERIAL_VID_2_DECODE_MICROVOLTS 6250 |
| 9 | #define SERIAL_VID_2_MAX_MICROVOLTS 1550000L |
| 10 | |
| 11 | uint32_t get_uvolts_from_vid(uint16_t core_vid) |
| 12 | { |
Felix Held | 00d496f | 2023-03-24 00:25:39 +0100 | [diff] [blame] | 13 | if (core_vid >= 0xF8) { |
| 14 | /* Voltage off for VID codes >= 0xF8 */ |
Felix Held | 23a398e | 2023-03-23 23:44:03 +0100 | [diff] [blame] | 15 | return 0; |
| 16 | } else { |
| 17 | return SERIAL_VID_2_MAX_MICROVOLTS - |
| 18 | (SERIAL_VID_2_DECODE_MICROVOLTS * core_vid); |
| 19 | } |
| 20 | } |
Felix Held | 2c9de49 | 2023-03-23 23:57:44 +0100 | [diff] [blame] | 21 | |
| 22 | uint32_t get_pstate_core_uvolts(union pstate_msr pstate_reg) |
| 23 | { |
| 24 | return get_uvolts_from_vid(pstate_reg.cpu_vid_0_7); |
| 25 | } |