1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * AMD Address Translation Library 4 * 5 * prm.c : Plumbing code for ACPI Platform Runtime Mechanism (PRM) 6 * 7 * Information on AMD PRM modules and handlers including the GUIDs and buffer 8 * structures used here are defined in the AMD ACPI Porting Guide in the 9 * chapter "Platform Runtime Mechanism Table (PRMT)" 10 * 11 * Copyright (c) 2024, Advanced Micro Devices, Inc. 12 * All Rights Reserved. 13 * 14 * Author: John Allen <john.allen@amd.com> 15 */ 16 17 #include "internal.h" 18 19 #include <linux/prmt.h> 20 21 /* 22 * PRM parameter buffer - normalized to system physical address, as described 23 * in the "PRM Parameter Buffer" section of the AMD ACPI Porting Guide. 24 */ 25 struct norm_to_sys_param_buf { 26 u64 norm_addr; 27 u8 socket; 28 u64 bank_id; 29 void *out_buf; 30 } __packed; 31 32 unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 bank_id, unsigned long addr) 33 { 34 struct norm_to_sys_param_buf p_buf; 35 unsigned long ret_addr; 36 int ret; 37 38 p_buf.norm_addr = addr; 39 p_buf.socket = socket_id; 40 p_buf.bank_id = bank_id; 41 p_buf.out_buf = &ret_addr; 42 43 ret = acpi_call_prm_handler(norm_to_sys_guid, &p_buf); 44 if (!ret) 45 return ret_addr; 46 47 if (ret == -ENODEV) 48 pr_debug("PRM module/handler not available\n"); 49 else 50 pr_notice_once("PRM address translation failed\n"); 51 52 return ret; 53 } 54