--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * AMD MP2 common macros and structures
+ *
+ * Copyright (c) 2022, Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
+ */
+#ifndef AMD_SFH_COMMON_H
+#define AMD_SFH_COMMON_H
+
+#include <linux/pci.h>
+#include "amd_sfh_hid.h"
+
+#define PCI_DEVICE_ID_AMD_MP2 0x15E4
+
+#define AMD_C2P_MSG(regno) (0x10500 + ((regno) * 4))
+#define AMD_P2C_MSG(regno) (0x10680 + ((regno) * 4))
+
+#define SENSOR_ENABLED 4
+#define SENSOR_DISABLED 5
+
+#define AMD_SFH_IDLE_LOOP 200
+
+enum cmd_id {
+ NO_OP,
+ ENABLE_SENSOR,
+ DISABLE_SENSOR,
+ STOP_ALL_SENSORS = 8,
+};
+
+struct amd_mp2_sensor_info {
+ u8 sensor_idx;
+ u32 period;
+ dma_addr_t dma_address;
+};
+
+struct amd_mp2_dev {
+ struct pci_dev *pdev;
+ struct amdtp_cl_data *cl_data;
+ void __iomem *mmio;
+ const struct amd_mp2_ops *mp2_ops;
+ struct amd_input_data in_data;
+ /* mp2 active control status */
+ u32 mp2_acs;
+};
+
+struct amd_mp2_ops {
+ void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info);
+ void (*stop)(struct amd_mp2_dev *privdata, u16 sensor_idx);
+ void (*stop_all)(struct amd_mp2_dev *privdata);
+ int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts);
+ void (*clear_intr)(struct amd_mp2_dev *privdata);
+ int (*init_intr)(struct amd_mp2_dev *privdata);
+ int (*discovery_status)(struct amd_mp2_dev *privdata);
+};
+
+#endif
#ifndef PCIE_MP2_AMD_H
#define PCIE_MP2_AMD_H
-#include <linux/pci.h>
-#include "amd_sfh_hid.h"
-
-#define PCI_DEVICE_ID_AMD_MP2 0x15E4
-
-#define ENABLE_SENSOR 1
-#define DISABLE_SENSOR 2
-#define STOP_ALL_SENSORS 8
+#include "amd_sfh_common.h"
/* MP2 C2P Message Registers */
#define AMD_C2P_MSG0 0x10500
#define AMD_C2P_MSG1 0x10504
#define AMD_C2P_MSG2 0x10508
-#define AMD_C2P_MSG(regno) (0x10500 + ((regno) * 4))
-#define AMD_P2C_MSG(regno) (0x10680 + ((regno) * 4))
-
/* MP2 P2C Message Registers */
#define AMD_P2C_MSG3 0x1068C /* Supported Sensors info */
#define V2_STATUS 0x2
-#define SENSOR_ENABLED 4
-#define SENSOR_DISABLED 5
-
#define HPD_IDX 16
-#define AMD_SFH_IDLE_LOOP 200
-
#define SENSOR_DISCOVERY_STATUS_MASK GENMASK(5, 3)
#define SENSOR_DISCOVERY_STATUS_SHIFT 3
als_idx = 19
};
-struct amd_mp2_dev {
- struct pci_dev *pdev;
- struct amdtp_cl_data *cl_data;
- void __iomem *mmio;
- const struct amd_mp2_ops *mp2_ops;
- struct amd_input_data in_data;
- /* mp2 active control status */
- u32 mp2_acs;
-};
-
-struct amd_mp2_sensor_info {
- u8 sensor_idx;
- u32 period;
- dma_addr_t dma_address;
-};
-
enum mem_use_type {
USE_DRAM,
USE_C2P_REG,
void amd_mp2_resume(struct amd_mp2_dev *mp2);
const char *get_sensor_name(int idx);
-struct amd_mp2_ops {
- void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info);
- void (*stop)(struct amd_mp2_dev *privdata, u16 sensor_idx);
- void (*stop_all)(struct amd_mp2_dev *privdata);
- int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts);
- void (*clear_intr)(struct amd_mp2_dev *privdata);
- int (*init_intr)(struct amd_mp2_dev *privdata);
- int (*discovery_status)(struct amd_mp2_dev *privdata);
-};
#endif