33
33
#include "gpe_util.h"
34
34
35
35
extern uint8_t G_apss_mode ;
36
-
36
+ extern gpe_shared_data_t * G_gpe_shared_data ;
37
37
/*
38
38
* Function Specifications:
39
39
*
@@ -97,12 +97,26 @@ void apss_start_pwr_meas_read(ipc_msg_t* cmd, void* arg)
97
97
if (APSS_MODE_COMPOSITE == G_apss_mode )
98
98
{
99
99
// clock_divider=36, frames=17 (i.e. 18)
100
- regValue = 0x8092200000000000 ;
100
+ if (G_gpe_shared_data -> spipss_spec_p9 )
101
+ {
102
+ regValue = 0x8092200000000000 ; // P9 Spec
103
+ }
104
+ else
105
+ {
106
+ regValue = 0x8093C00000000000 ; // P9 Actual (16 frames)
107
+ }
101
108
}
102
109
else
103
110
{
104
111
// clock_divider=36, frames=15 (i.e. 16)
105
- regValue = 0x8091E00000000000 ;
112
+ if (G_gpe_shared_data -> spipss_spec_p9 )
113
+ {
114
+ regValue = 0x8091E00000000000 ; // P9 Spec
115
+ }
116
+ else
117
+ {
118
+ regValue = 0x8093C00000000000 ; // P9 Actual
119
+ }
106
120
}
107
121
rc = putscom_abs (SPIPSS_ADC_CTRL_REG1 , regValue );
108
122
if (rc )
@@ -192,6 +206,7 @@ void apss_continue_pwr_meas_read(ipc_msg_t* cmd, void* arg)
192
206
// the ipc arguments are passed through the ipc_msg_t structure, has a pointer
193
207
// to the G_gpe_continue_pwr_meas_read_args
194
208
209
+ uint64_t regValue = 0 ;
195
210
int rc ;
196
211
ipc_async_cmd_t * async_cmd = (ipc_async_cmd_t * )cmd ;
197
212
apss_continue_args_t * args = (apss_continue_args_t * )async_cmd -> cmd_data ;
@@ -256,6 +271,45 @@ void apss_continue_pwr_meas_read(ipc_msg_t* cmd, void* arg)
256
271
gpe_set_ffdc (& (args -> error ), SPIPSS_ADC_RDATA_REG3 , GPE_RC_SCOM_GET_FAILED , rc );
257
272
break ;
258
273
}
274
+
275
+ // If we're trying to do composite mode for the P8 spec, we need to configure
276
+ // the ADC controller again. P9 spec does not need to do this since there would
277
+ // be room for up to 32 frames.
278
+ if ( (APSS_MODE_COMPOSITE == G_apss_mode ) && (!G_gpe_shared_data -> spipss_spec_p9 ) )
279
+ {
280
+ // ADC FSM, clock_divider=7, frames=1 (ie 2 for gpio ports)
281
+ regValue = 0x8090400000000000 ;
282
+ rc = putscom_abs (SPIPSS_ADC_CTRL_REG1 , regValue );
283
+ if (rc )
284
+ {
285
+ PK_TRACE ("apss_continue_pwr_meas_read: SPIPSS_ADC_CTRL_REG1 putscom failed. rc = 0x%08x" ,
286
+ rc );
287
+ gpe_set_ffdc (& (args -> error ), SPIPSS_ADC_CTRL_REG1 , GPE_RC_SCOM_PUT_FAILED , rc );
288
+ break ;
289
+ }
290
+
291
+ // APSS command to continue previous command
292
+ regValue = 0x0000000000000000 ;
293
+ rc = putscom_abs (SPIPSS_ADC_WDATA_REG , regValue );
294
+ if (rc )
295
+ {
296
+ PK_TRACE ("apss_continue_pwr_meas_read: SPIPSS_ADC_WDATA_REG putscom failed. rc = 0x%08x" ,
297
+ rc );
298
+ gpe_set_ffdc (& (args -> error ), SPIPSS_ADC_WDATA_REG , GPE_RC_SCOM_PUT_FAILED , rc );
299
+ break ;
300
+ }
301
+
302
+ // Start SPI Transaction
303
+ regValue = 0x8000000000000000 ;
304
+ rc = putscom_abs (SPIPSS_ADC_COMMAND_REG , regValue );
305
+ if (rc )
306
+ {
307
+ PK_TRACE ("apss_continue_pwr_meas_read: SPIPSS_ADC_COMMAND_REG putscom failed. rc = 0x%08x" ,
308
+ rc );
309
+ gpe_set_ffdc (& (args -> error ), SPIPSS_ADC_COMMAND_REG , GPE_RC_SCOM_PUT_FAILED , rc );
310
+ break ;
311
+ }
312
+ }
259
313
} while (0 );
260
314
261
315
#ifdef DEBUG_APSS_SEQ
@@ -302,7 +356,7 @@ void apss_complete_pwr_meas_read(ipc_msg_t* cmd, void* arg)
302
356
int rc ;
303
357
ipc_async_cmd_t * async_cmd = (ipc_async_cmd_t * )cmd ;
304
358
apss_complete_args_t * args = (apss_complete_args_t * )async_cmd -> cmd_data ;
305
-
359
+ uint32_t rdata_reg = 0 ;
306
360
do {
307
361
// wait for ADC completion, or timeout after 100 micro seconds.
308
362
// scom register SPIPSS_ADC_STATUS_REG's bit 0 (HWCTRL_ONGOING)
@@ -329,12 +383,16 @@ void apss_complete_pwr_meas_read(ipc_msg_t* cmd, void* arg)
329
383
// If we're in composite mode, collect the GPIO data
330
384
if (APSS_MODE_COMPOSITE == G_apss_mode )
331
385
{
386
+ // RDATA4-7 do not exist on P9 HW, spec says they should.
387
+ if (G_gpe_shared_data -> spipss_spec_p9 ) rdata_reg = SPIPSS_ADC_RDATA_REG4 ;
388
+ else rdata_reg = SPIPSS_ADC_RDATA_REG0 ;
389
+
332
390
// Read first 8 bytes of data (GPIO frames) into meas_data[0]
333
- rc = getscom_abs (SPIPSS_ADC_RDATA_REG4 , & args -> meas_data [0 ]);
391
+ rc = getscom_abs (rdata_reg , & args -> meas_data [0 ]);
334
392
if (rc )
335
393
{
336
- PK_TRACE ("apss_complete_pwr_meas_read: SPIPSS_ADC_RDATA_REG4 getscom failed. rc = 0x%08x" ,
337
- rc );
394
+ PK_TRACE ("apss_complete_pwr_meas_read: RDATA_REG(0x%08X) getscom failed. rc = 0x%08x" ,
395
+ rdata_reg , rc );
338
396
gpe_set_ffdc (& (args -> error ), SPIPSS_ADC_RDATA_REG4 , GPE_RC_SCOM_GET_FAILED , rc );
339
397
break ;
340
398
}
0 commit comments