Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.8.
 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 */
25struct norm_to_sys_param_buf {
26	u64 norm_addr;
27	u8 socket;
28	u64 bank_id;
29	void *out_buf;
30} __packed;
31
32static const guid_t norm_to_sys_guid = GUID_INIT(0xE7180659, 0xA65D, 0x451D,
33						 0x92, 0xCD, 0x2B, 0x56, 0xF1,
34						 0x2B, 0xEB, 0xA6);
35
36unsigned long prm_umc_norm_to_sys_addr(u8 socket_id, u64 bank_id, unsigned long addr)
37{
38	struct norm_to_sys_param_buf p_buf;
39	unsigned long ret_addr;
40	int ret;
41
42	p_buf.norm_addr = addr;
43	p_buf.socket    = socket_id;
44	p_buf.bank_id   = bank_id;
45	p_buf.out_buf   = &ret_addr;
46
47	ret = acpi_call_prm_handler(norm_to_sys_guid, &p_buf);
48	if (!ret)
49		return ret_addr;
50
51	if (ret == -ENODEV)
52		pr_debug("PRM module/handler not available\n");
53	else
54		pr_notice_once("PRM address translation failed\n");
55
56	return ret;
57}