Skip to content

Commit 6947f31

Browse files
basuamdJiri Kosina
authored andcommitted
HID: amd_sfh: Move common macros and structures
Introduce common macros and structures to support multiple generations of AMD SOCs, move them to amd_sfh_common.h. Signed-off-by: Basavaraj Natikar <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 06aa2a4 commit 6947f31

File tree

2 files changed

+60
-41
lines changed

2 files changed

+60
-41
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
/*
3+
* AMD MP2 common macros and structures
4+
*
5+
* Copyright (c) 2022, Advanced Micro Devices, Inc.
6+
* All Rights Reserved.
7+
*
8+
* Author: Basavaraj Natikar <[email protected]>
9+
*/
10+
#ifndef AMD_SFH_COMMON_H
11+
#define AMD_SFH_COMMON_H
12+
13+
#include <linux/pci.h>
14+
#include "amd_sfh_hid.h"
15+
16+
#define PCI_DEVICE_ID_AMD_MP2 0x15E4
17+
18+
#define AMD_C2P_MSG(regno) (0x10500 + ((regno) * 4))
19+
#define AMD_P2C_MSG(regno) (0x10680 + ((regno) * 4))
20+
21+
#define SENSOR_ENABLED 4
22+
#define SENSOR_DISABLED 5
23+
24+
#define AMD_SFH_IDLE_LOOP 200
25+
26+
enum cmd_id {
27+
NO_OP,
28+
ENABLE_SENSOR,
29+
DISABLE_SENSOR,
30+
STOP_ALL_SENSORS = 8,
31+
};
32+
33+
struct amd_mp2_sensor_info {
34+
u8 sensor_idx;
35+
u32 period;
36+
dma_addr_t dma_address;
37+
};
38+
39+
struct amd_mp2_dev {
40+
struct pci_dev *pdev;
41+
struct amdtp_cl_data *cl_data;
42+
void __iomem *mmio;
43+
const struct amd_mp2_ops *mp2_ops;
44+
struct amd_input_data in_data;
45+
/* mp2 active control status */
46+
u32 mp2_acs;
47+
};
48+
49+
struct amd_mp2_ops {
50+
void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info);
51+
void (*stop)(struct amd_mp2_dev *privdata, u16 sensor_idx);
52+
void (*stop_all)(struct amd_mp2_dev *privdata);
53+
int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts);
54+
void (*clear_intr)(struct amd_mp2_dev *privdata);
55+
int (*init_intr)(struct amd_mp2_dev *privdata);
56+
int (*discovery_status)(struct amd_mp2_dev *privdata);
57+
};
58+
59+
#endif

drivers/hid/amd-sfh-hid/amd_sfh_pcie.h

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,20 @@
1010
#ifndef PCIE_MP2_AMD_H
1111
#define PCIE_MP2_AMD_H
1212

13-
#include <linux/pci.h>
14-
#include "amd_sfh_hid.h"
15-
16-
#define PCI_DEVICE_ID_AMD_MP2 0x15E4
17-
18-
#define ENABLE_SENSOR 1
19-
#define DISABLE_SENSOR 2
20-
#define STOP_ALL_SENSORS 8
13+
#include "amd_sfh_common.h"
2114

2215
/* MP2 C2P Message Registers */
2316
#define AMD_C2P_MSG0 0x10500
2417
#define AMD_C2P_MSG1 0x10504
2518
#define AMD_C2P_MSG2 0x10508
2619

27-
#define AMD_C2P_MSG(regno) (0x10500 + ((regno) * 4))
28-
#define AMD_P2C_MSG(regno) (0x10680 + ((regno) * 4))
29-
3020
/* MP2 P2C Message Registers */
3121
#define AMD_P2C_MSG3 0x1068C /* Supported Sensors info */
3222

3323
#define V2_STATUS 0x2
3424

35-
#define SENSOR_ENABLED 4
36-
#define SENSOR_DISABLED 5
37-
3825
#define HPD_IDX 16
3926

40-
#define AMD_SFH_IDLE_LOOP 200
41-
4227
#define SENSOR_DISCOVERY_STATUS_MASK GENMASK(5, 3)
4328
#define SENSOR_DISCOVERY_STATUS_SHIFT 3
4429

@@ -96,22 +81,6 @@ enum sensor_idx {
9681
als_idx = 19
9782
};
9883

99-
struct amd_mp2_dev {
100-
struct pci_dev *pdev;
101-
struct amdtp_cl_data *cl_data;
102-
void __iomem *mmio;
103-
const struct amd_mp2_ops *mp2_ops;
104-
struct amd_input_data in_data;
105-
/* mp2 active control status */
106-
u32 mp2_acs;
107-
};
108-
109-
struct amd_mp2_sensor_info {
110-
u8 sensor_idx;
111-
u32 period;
112-
dma_addr_t dma_address;
113-
};
114-
11584
enum mem_use_type {
11685
USE_DRAM,
11786
USE_C2P_REG,
@@ -140,13 +109,4 @@ void amd_mp2_suspend(struct amd_mp2_dev *mp2);
140109
void amd_mp2_resume(struct amd_mp2_dev *mp2);
141110
const char *get_sensor_name(int idx);
142111

143-
struct amd_mp2_ops {
144-
void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info);
145-
void (*stop)(struct amd_mp2_dev *privdata, u16 sensor_idx);
146-
void (*stop_all)(struct amd_mp2_dev *privdata);
147-
int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts);
148-
void (*clear_intr)(struct amd_mp2_dev *privdata);
149-
int (*init_intr)(struct amd_mp2_dev *privdata);
150-
int (*discovery_status)(struct amd_mp2_dev *privdata);
151-
};
152112
#endif

0 commit comments

Comments
 (0)