2024-12-06 16:11:57 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* AMD Node helper functions and common defines
|
|
|
|
*
|
|
|
|
* Copyright (c) 2024, Advanced Micro Devices, Inc.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Author: Yazen Ghannam <Yazen.Ghannam@amd.com>
|
|
|
|
*
|
|
|
|
* Note:
|
|
|
|
* Items in this file may only be used in a single place.
|
|
|
|
* However, it's prudent to keep all AMD Node functionality
|
|
|
|
* in a unified place rather than spreading throughout the
|
|
|
|
* kernel.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ASM_X86_AMD_NODE_H_
|
|
|
|
#define _ASM_X86_AMD_NODE_H_
|
|
|
|
|
|
|
|
#include <linux/pci.h>
|
|
|
|
|
|
|
|
#define MAX_AMD_NUM_NODES 8
|
|
|
|
#define AMD_NODE0_PCI_SLOT 0x18
|
|
|
|
|
|
|
|
struct pci_dev *amd_node_get_func(u16 node, u8 func);
|
2024-12-06 16:11:59 +00:00
|
|
|
struct pci_dev *amd_node_get_root(u16 node);
|
2024-12-06 16:11:57 +00:00
|
|
|
|
2025-01-07 22:28:41 +00:00
|
|
|
static inline u16 amd_num_nodes(void)
|
|
|
|
{
|
|
|
|
return topology_amd_nodes_per_pkg() * topology_max_packages();
|
|
|
|
}
|
|
|
|
|
2025-01-30 19:48:55 +00:00
|
|
|
#ifdef CONFIG_AMD_NODE
|
2024-12-06 16:12:03 +00:00
|
|
|
int __must_check amd_smn_read(u16 node, u32 address, u32 *value);
|
|
|
|
int __must_check amd_smn_write(u16 node, u32 address, u32 value);
|
|
|
|
|
2025-01-30 19:48:55 +00:00
|
|
|
/* Should only be used by the HSMP driver. */
|
|
|
|
int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write);
|
|
|
|
#else
|
|
|
|
static inline int __must_check amd_smn_read(u16 node, u32 address, u32 *value) { return -ENODEV; }
|
|
|
|
static inline int __must_check amd_smn_write(u16 node, u32 address, u32 value) { return -ENODEV; }
|
|
|
|
|
|
|
|
static inline int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_AMD_NODE */
|
|
|
|
|
2025-02-17 17:17:41 -06:00
|
|
|
/* helper for use with read_poll_timeout */
|
|
|
|
static inline int smn_read_register(u32 reg)
|
|
|
|
{
|
|
|
|
int data, rc;
|
|
|
|
|
|
|
|
rc = amd_smn_read(0, reg, &data);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
2024-12-06 16:11:57 +00:00
|
|
|
#endif /*_ASM_X86_AMD_NODE_H_*/
|