File Index
Files and directories
Sign in
FILE

node.h

File preview with syntax highlighting.

linux-6.19.14/arch/x86/include/asm/amd/node.h C
 1/* SPDX-License-Identifier: GPL-2.0 */
 2/*
 3 * AMD Node helper functions and common defines
 4 *
 5 * Copyright (c) 2024, Advanced Micro Devices, Inc.
 6 * All Rights Reserved.
 7 *
 8 * Author: Yazen Ghannam <Yazen.Ghannam@amd.com>
 9 *
10 * Note:
11 * Items in this file may only be used in a single place.
12 * However, it's prudent to keep all AMD Node functionality
13 * in a unified place rather than spreading throughout the
14 * kernel.
15 */
16
17#ifndef _ASM_X86_AMD_NODE_H_
18#define _ASM_X86_AMD_NODE_H_
19
20#include <linux/pci.h>
21
22#define MAX_AMD_NUM_NODES	8
23#define AMD_NODE0_PCI_SLOT	0x18
24
25struct pci_dev *amd_node_get_func(u16 node, u8 func);
26
27static inline u16 amd_num_nodes(void)
28{
29	return topology_amd_nodes_per_pkg() * topology_max_packages();
30}
31
32#ifdef CONFIG_AMD_NODE
33int __must_check amd_smn_read(u16 node, u32 address, u32 *value);
34int __must_check amd_smn_write(u16 node, u32 address, u32 value);
35
36/* Should only be used by the HSMP driver. */
37int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write);
38#else
39static inline int __must_check amd_smn_read(u16 node, u32 address, u32 *value) { return -ENODEV; }
40static inline int __must_check amd_smn_write(u16 node, u32 address, u32 value) { return -ENODEV; }
41
42static inline int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write)
43{
44	return -ENODEV;
45}
46#endif /* CONFIG_AMD_NODE */
47
48/* helper for use with read_poll_timeout */
49static inline int smn_read_register(u32 reg)
50{
51	int data, rc;
52
53	rc = amd_smn_read(0, reg, &data);
54	if (rc)
55		return rc;
56
57	return data;
58}
59#endif /*_ASM_X86_AMD_NODE_H_*/
~/ Read-only file preview.