2024-10-21 11:14:21 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* AMD HSMP Platform Driver
|
|
|
|
* Copyright (c) 2024, AMD.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Header file for HSMP driver
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HSMP_H
|
|
|
|
#define HSMP_H
|
|
|
|
|
|
|
|
#include <linux/compiler_types.h>
|
|
|
|
#include <linux/device.h>
|
2025-05-06 10:15:41 +00:00
|
|
|
#include <linux/hwmon.h>
|
2025-06-03 05:58:07 +00:00
|
|
|
#include <linux/kconfig.h>
|
2024-10-21 11:14:21 +00:00
|
|
|
#include <linux/miscdevice.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/semaphore.h>
|
|
|
|
#include <linux/sysfs.h>
|
|
|
|
|
|
|
|
#define HSMP_METRICS_TABLE_NAME "metrics_bin"
|
|
|
|
|
|
|
|
#define HSMP_ATTR_GRP_NAME_SIZE 10
|
|
|
|
|
|
|
|
#define HSMP_CDEV_NAME "hsmp_cdev"
|
|
|
|
#define HSMP_DEVNODE_NAME "hsmp"
|
2025-04-25 10:23:57 +00:00
|
|
|
#define ACPI_HSMP_DEVICE_HID "AMDI0097"
|
2024-10-21 11:14:21 +00:00
|
|
|
|
2025-05-06 10:15:41 +00:00
|
|
|
#define DRIVER_VERSION "2.5"
|
2025-05-06 10:15:40 +00:00
|
|
|
|
2024-10-21 11:14:21 +00:00
|
|
|
struct hsmp_mbaddr_info {
|
|
|
|
u32 base_addr;
|
|
|
|
u32 msg_id_off;
|
|
|
|
u32 msg_resp_off;
|
|
|
|
u32 msg_arg_off;
|
|
|
|
u32 size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hsmp_socket {
|
|
|
|
struct bin_attribute hsmp_attr;
|
|
|
|
struct hsmp_mbaddr_info mbinfo;
|
|
|
|
void __iomem *metric_tbl_addr;
|
|
|
|
void __iomem *virt_base_addr;
|
|
|
|
struct semaphore hsmp_sem;
|
|
|
|
char name[HSMP_ATTR_GRP_NAME_SIZE];
|
|
|
|
struct device *dev;
|
|
|
|
u16 sock_ind;
|
|
|
|
int (*amd_hsmp_rdwr)(struct hsmp_socket *sock, u32 off, u32 *val, bool rw);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hsmp_plat_device {
|
2024-10-21 11:14:24 +00:00
|
|
|
struct miscdevice mdev;
|
2024-10-21 11:14:21 +00:00
|
|
|
struct hsmp_socket *sock;
|
|
|
|
u32 proto_ver;
|
|
|
|
u16 num_sockets;
|
|
|
|
bool is_probed;
|
|
|
|
};
|
2024-10-21 11:14:22 +00:00
|
|
|
|
|
|
|
int hsmp_cache_proto_ver(u16 sock_ind);
|
|
|
|
int hsmp_test(u16 sock_ind, u32 value);
|
2024-10-21 11:14:25 +00:00
|
|
|
long hsmp_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
|
|
|
|
void hsmp_misc_deregister(void);
|
|
|
|
int hsmp_misc_register(struct device *dev);
|
2024-10-21 11:14:27 +00:00
|
|
|
int hsmp_get_tbl_dram_base(u16 sock_ind);
|
|
|
|
ssize_t hsmp_metric_tbl_read(struct hsmp_socket *sock, char *buf, size_t size);
|
2024-10-21 11:14:28 +00:00
|
|
|
struct hsmp_plat_device *get_hsmp_pdev(void);
|
2025-06-03 05:58:07 +00:00
|
|
|
#if IS_ENABLED(CONFIG_HWMON)
|
2025-05-06 10:15:41 +00:00
|
|
|
int hsmp_create_sensor(struct device *dev, u16 sock_ind);
|
|
|
|
#else
|
|
|
|
static inline int hsmp_create_sensor(struct device *dev, u16 sock_ind) { return 0; }
|
|
|
|
#endif
|
2025-05-06 10:15:42 +00:00
|
|
|
int hsmp_msg_get_nargs(u16 sock_ind, u32 msg_id, u32 *data, u8 num_args);
|
2024-10-21 11:14:21 +00:00
|
|
|
#endif /* HSMP_H */
|