@@ -30,6 +30,48 @@ static int sensor_mask_override = -1;
30
30
module_param_named (sensor_mask , sensor_mask_override , int , 0444 );
31
31
MODULE_PARM_DESC (sensor_mask , "override the detected sensors mask" );
32
32
33
+ static void amd_start_sensor_v2 (struct amd_mp2_dev * privdata , struct amd_mp2_sensor_info info )
34
+ {
35
+ union sfh_cmd_base cmd_base ;
36
+
37
+ cmd_base .ul = 0 ;
38
+ cmd_base .cmd_v2 .cmd_id = ENABLE_SENSOR ;
39
+ cmd_base .cmd_v2 .period = info .period ;
40
+ cmd_base .cmd_v2 .sensor_id = info .sensor_idx ;
41
+ cmd_base .cmd_v2 .length = 16 ;
42
+
43
+ if (info .sensor_idx == als_idx )
44
+ cmd_base .cmd_v2 .mem_type = USE_C2P_REG ;
45
+
46
+ writeq (info .dma_address , privdata -> mmio + AMD_C2P_MSG1 );
47
+ writel (cmd_base .ul , privdata -> mmio + AMD_C2P_MSG0 );
48
+ }
49
+
50
+ static void amd_stop_sensor_v2 (struct amd_mp2_dev * privdata , u16 sensor_idx )
51
+ {
52
+ union sfh_cmd_base cmd_base ;
53
+
54
+ cmd_base .ul = 0 ;
55
+ cmd_base .cmd_v2 .cmd_id = DISABLE_SENSOR ;
56
+ cmd_base .cmd_v2 .period = 0 ;
57
+ cmd_base .cmd_v2 .sensor_id = sensor_idx ;
58
+ cmd_base .cmd_v2 .length = 16 ;
59
+
60
+ writeq (0x0 , privdata -> mmio + AMD_C2P_MSG2 );
61
+ writel (cmd_base .ul , privdata -> mmio + AMD_C2P_MSG0 );
62
+ }
63
+
64
+ static void amd_stop_all_sensor_v2 (struct amd_mp2_dev * privdata )
65
+ {
66
+ union sfh_cmd_base cmd_base ;
67
+
68
+ cmd_base .cmd_v2 .cmd_id = STOP_ALL_SENSORS ;
69
+ cmd_base .cmd_v2 .period = 0 ;
70
+ cmd_base .cmd_v2 .sensor_id = 0 ;
71
+
72
+ writel (cmd_base .ul , privdata -> mmio + AMD_C2P_MSG0 );
73
+ }
74
+
33
75
void amd_start_sensor (struct amd_mp2_dev * privdata , struct amd_mp2_sensor_info info )
34
76
{
35
77
union sfh_cmd_param cmd_param ;
@@ -98,7 +140,6 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
98
140
{
99
141
int activestatus , num_of_sensors = 0 ;
100
142
const struct dmi_system_id * dmi_id ;
101
- u32 activecontrolstatus ;
102
143
103
144
if (sensor_mask_override == -1 ) {
104
145
dmi_id = dmi_first_match (dmi_sensor_mask_overrides );
@@ -109,8 +150,7 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
109
150
if (sensor_mask_override >= 0 ) {
110
151
activestatus = sensor_mask_override ;
111
152
} else {
112
- activecontrolstatus = readl (privdata -> mmio + AMD_P2C_MSG3 );
113
- activestatus = activecontrolstatus >> 4 ;
153
+ activestatus = privdata -> mp2_acs >> 4 ;
114
154
}
115
155
116
156
if (ACEL_EN & activestatus )
@@ -130,8 +170,38 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id)
130
170
131
171
static void amd_mp2_pci_remove (void * privdata )
132
172
{
173
+ struct amd_mp2_dev * mp2 = privdata ;
133
174
amd_sfh_hid_client_deinit (privdata );
134
- amd_stop_all_sensors (privdata );
175
+ mp2 -> mp2_ops -> stop_all (mp2 );
176
+ }
177
+
178
+ static const struct amd_mp2_ops amd_sfh_ops_v2 = {
179
+ .start = amd_start_sensor_v2 ,
180
+ .stop = amd_stop_sensor_v2 ,
181
+ .stop_all = amd_stop_all_sensor_v2 ,
182
+ };
183
+
184
+ static const struct amd_mp2_ops amd_sfh_ops = {
185
+ .start = amd_start_sensor ,
186
+ .stop = amd_stop_sensor ,
187
+ .stop_all = amd_stop_all_sensors ,
188
+ };
189
+
190
+ static void mp2_select_ops (struct amd_mp2_dev * privdata )
191
+ {
192
+ u8 acs ;
193
+
194
+ privdata -> mp2_acs = readl (privdata -> mmio + AMD_P2C_MSG3 );
195
+ acs = privdata -> mp2_acs & GENMASK (3 , 0 );
196
+
197
+ switch (acs ) {
198
+ case V2_STATUS :
199
+ privdata -> mp2_ops = & amd_sfh_ops_v2 ;
200
+ break ;
201
+ default :
202
+ privdata -> mp2_ops = & amd_sfh_ops ;
203
+ break ;
204
+ }
135
205
}
136
206
137
207
static int amd_mp2_pci_probe (struct pci_dev * pdev , const struct pci_device_id * id )
@@ -164,6 +234,8 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
164
234
if (rc )
165
235
return rc ;
166
236
237
+ mp2_select_ops (privdata );
238
+
167
239
return amd_sfh_hid_client_init (privdata );
168
240
}
169
241
0 commit comments