2 Platform TPM Profile Specification definition for TPM2.0.
3 It covers both FIFO and CRB interface.
5 Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
14 // PTP FIFO definition
18 // Set structure alignment to 1-byte
23 // Register set map as specified in PTP specification Chapter 5
27 /// Used to gain ownership for this particular port.
30 UINT8 Reserved1
[7]; // 1
32 /// Controls interrupts.
34 UINT32 IntEnable
; // 8
36 /// SIRQ vector to be used by the TPM.
38 UINT8 IntVector
; // 0ch
39 UINT8 Reserved2
[3]; // 0dh
41 /// What caused interrupt.
45 /// Shows which interrupts are supported by that particular TPM.
47 UINT32 InterfaceCapability
;// 14h
49 /// Status Register. Provides status of the TPM.
53 /// Number of consecutive writes that can be done to the TPM.
55 UINT16 BurstCount
; // 19h
57 /// Additional Status Register.
59 UINT8 StatusEx
; // 1Bh
62 /// Read or write FIFO, depending on transaction.
64 UINT32 DataFifo
; // 24h
65 UINT8 Reserved4
[8]; // 28h
67 /// Used to identify the Interface types supported by the TPM.
69 UINT32 InterfaceId
; // 30h
70 UINT8 Reserved5
[0x4c]; // 34h
72 /// Extended ReadFIFO or WriteFIFO, depending on the current bus cycle (read or write)
74 UINT32 XDataFifo
; // 80h
75 UINT8 Reserved6
[0xe7c]; // 84h
88 UINT8 Reserved
[0xfb]; // 0f05h
92 // Restore original structure alignment
97 // Define pointer types used to access TIS registers on PC
99 typedef PTP_FIFO_REGISTERS
*PTP_FIFO_REGISTERS_PTR
;
102 // Define bits of FIFO Interface Identifier Register
106 UINT32 InterfaceType
:4;
107 UINT32 InterfaceVersion
:4;
108 UINT32 CapLocality
:1;
110 UINT32 CapDataXferSizeSupport
:2;
114 UINT32 InterfaceSelector
:2;
115 UINT32 IntfSelLock
:1;
120 } PTP_FIFO_INTERFACE_IDENTIFIER
;
123 // Define bits of FIFO Interface Capability Register
127 UINT32 DataAvailIntSupport
:1;
128 UINT32 StsValidIntSupport
:1;
129 UINT32 LocalityChangeIntSupport
:1;
130 UINT32 InterruptLevelHigh
:1;
131 UINT32 InterruptLevelLow
:1;
132 UINT32 InterruptEdgeRising
:1;
133 UINT32 InterruptEdgeFalling
:1;
134 UINT32 CommandReadyIntSupport
:1;
135 UINT32 BurstCountStatic
:1;
136 UINT32 DataTransferSizeSupport
:2;
138 UINT32 InterfaceVersion
:3;
142 } PTP_FIFO_INTERFACE_CAPABILITY
;
147 #define INTERFACE_CAPABILITY_INTERFACE_VERSION_TIS_12 0x0
148 #define INTERFACE_CAPABILITY_INTERFACE_VERSION_TIS_13 0x2
149 #define INTERFACE_CAPABILITY_INTERFACE_VERSION_PTP 0x3
153 // Define bits of ACCESS and STATUS registers
157 /// This bit is a 1 to indicate that the other bits in this register are valid.
159 #define PTP_FIFO_VALID BIT7
161 /// Indicate that this locality is active.
163 #define PTP_FIFO_ACC_ACTIVE BIT5
165 /// Set to 1 to indicate that this locality had the TPM taken away while
166 /// this locality had the TIS_PC_ACC_ACTIVE bit set.
168 #define PTP_FIFO_ACC_SEIZED BIT4
170 /// Set to 1 to indicate that TPM MUST reset the
171 /// TIS_PC_ACC_ACTIVE bit and remove ownership for localities less than the
172 /// locality that is writing this bit.
174 #define PTP_FIFO_ACC_SEIZE BIT3
176 /// When this bit is 1, another locality is requesting usage of the TPM.
178 #define PTP_FIFO_ACC_PENDIND BIT2
180 /// Set to 1 to indicate that this locality is requesting to use TPM.
182 #define PTP_FIFO_ACC_RQUUSE BIT1
184 /// A value of 1 indicates that a T/OS has not been established on the platform
186 #define PTP_FIFO_ACC_ESTABLISH BIT0
189 /// This field indicates that STS_DATA and STS_EXPECT are valid
191 #define PTP_FIFO_STS_VALID BIT7
193 /// When this bit is 1, TPM is in the Ready state,
194 /// indicating it is ready to receive a new command.
196 #define PTP_FIFO_STS_READY BIT6
198 /// Write a 1 to this bit to cause the TPM to execute that command.
200 #define PTP_FIFO_STS_GO BIT5
202 /// This bit indicates that the TPM has data available as a response.
204 #define PTP_FIFO_STS_DATA BIT4
206 /// The TPM sets this bit to a value of 1 when it expects another byte of data for a command.
208 #define PTP_FIFO_STS_EXPECT BIT3
210 /// Indicates that the TPM has completed all self-test actions following a TPM_ContinueSelfTest command.
212 #define PTP_FIFO_STS_SELFTEST_DONE BIT2
214 /// Writes a 1 to this bit to force the TPM to re-send the response.
216 #define PTP_FIFO_STS_RETRY BIT1
219 /// TPM Family Identifier.
220 /// 00: TPM 1.2 Family
221 /// 01: TPM 2.0 Family
223 #define PTP_FIFO_STS_EX_TPM_FAMILY (BIT2 | BIT3)
224 #define PTP_FIFO_STS_EX_TPM_FAMILY_OFFSET (2)
225 #define PTP_FIFO_STS_EX_TPM_FAMILY_TPM12 (0)
226 #define PTP_FIFO_STS_EX_TPM_FAMILY_TPM20 (BIT2)
228 /// A write of 1 after tpmGo and before dataAvail aborts the currently executing command, resulting in a response of TPM_RC_CANCELLED.
229 /// A write of 1 after dataAvail and before tpmGo is ignored by the TPM.
231 #define PTP_FIFO_STS_EX_CANCEL BIT0
235 // PTP CRB definition
239 // Set structure alignment to 1-byte
244 // Register set map as specified in PTP specification Chapter 5
248 /// Used to determine current state of Locality of the TPM.
250 UINT32 LocalityState
; // 0
251 UINT8 Reserved1
[4]; // 4
253 /// Used to gain control of the TPM by this Locality.
255 UINT32 LocalityControl
; // 8
257 /// Used to determine whether Locality has been granted or Seized.
259 UINT32 LocalityStatus
; // 0ch
260 UINT8 Reserved2
[0x20]; // 10h
262 /// Used to identify the Interface types supported by the TPM.
264 UINT32 InterfaceId
; // 30h
274 /// Optional Register used in low memory environments prior to CRB_DATA_BUFFER availability.
276 UINT64 CrbControlExtension
; // 38h
278 /// Register used to initiate transactions for the CRB interface.
280 UINT32 CrbControlRequest
; // 40h
282 /// Register used by the TPM to provide status of the CRB interface.
284 UINT32 CrbControlStatus
; // 44h
286 /// Register used by software to cancel command processing.
288 UINT32 CrbControlCancel
; // 48h
290 /// Register used to indicate presence of command or response data in the CRB buffer.
292 UINT32 CrbControlStart
; // 4Ch
294 /// Register used to configure and respond to interrupts.
296 UINT32 CrbInterruptEnable
; // 50h
297 UINT32 CrbInterruptStatus
; // 54h
299 /// Size of the Command buffer.
301 UINT32 CrbControlCommandSize
; // 58h
303 /// Command buffer start address
305 UINT32 CrbControlCommandAddressLow
; // 5Ch
306 UINT32 CrbControlCommandAddressHigh
; // 60h
308 /// Size of the Response buffer
310 UINT32 CrbControlResponseSize
; // 64h
312 /// Address of the start of the Response buffer
314 UINT64 CrbControlResponseAddrss
; // 68h
315 UINT8 Reserved4
[0x10]; // 70h
317 /// Command/Response Data may be defined as large as 3968 (0xF80).
319 UINT8 CrbDataBuffer
[0xF80]; // 80h
323 // Define pointer types used to access CRB registers on PTP
325 typedef PTP_CRB_REGISTERS
*PTP_CRB_REGISTERS_PTR
;
328 // Define bits of CRB Interface Identifier Register
332 UINT32 InterfaceType
:4;
333 UINT32 InterfaceVersion
:4;
334 UINT32 CapLocality
:1;
335 UINT32 CapCRBIdleBypass
:1;
337 UINT32 CapDataXferSizeSupport
:2;
341 UINT32 InterfaceSelector
:2;
342 UINT32 IntfSelLock
:1;
347 } PTP_CRB_INTERFACE_IDENTIFIER
;
352 #define PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_FIFO 0x0
353 #define PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_CRB 0x1
354 #define PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_TIS 0xF
359 #define PTP_INTERFACE_IDENTIFIER_INTERFACE_VERSION_FIFO 0x0
360 #define PTP_INTERFACE_IDENTIFIER_INTERFACE_VERSION_CRB 0x1
363 /// InterfaceSelector
365 #define PTP_INTERFACE_IDENTIFIER_INTERFACE_SELECTOR_FIFO 0x0
366 #define PTP_INTERFACE_IDENTIFIER_INTERFACE_SELECTOR_CRB 0x1
369 // Define bits of Locality State Register
373 /// This bit indicates whether all other bits of this register contain valid values, if it is a 1.
375 #define PTP_CRB_LOCALITY_STATE_TPM_REG_VALID_STATUS BIT7
384 #define PTP_CRB_LOCALITY_STATE_ACTIVE_LOCALITY_MASK (BIT2 | BIT3 | BIT4)
385 #define PTP_CRB_LOCALITY_STATE_ACTIVE_LOCALITY_0 (0)
386 #define PTP_CRB_LOCALITY_STATE_ACTIVE_LOCALITY_1 (BIT2)
387 #define PTP_CRB_LOCALITY_STATE_ACTIVE_LOCALITY_2 (BIT3)
388 #define PTP_CRB_LOCALITY_STATE_ACTIVE_LOCALITY_3 (BIT2 | BIT3)
389 #define PTP_CRB_LOCALITY_STATE_ACTIVE_LOCALITY_4 (BIT4)
392 /// A 0 indicates to the host that no locality is assigned.
393 /// A 1 indicates a locality has been assigned.
395 #define PTP_CRB_LOCALITY_STATE_LOCALITY_ASSIGNED BIT1
398 /// The TPM clears this bit to 0 upon receipt of _TPM_Hash_End
399 /// The TPM sets this bit to a 1 when the TPM_LOC_CTRL_x.resetEstablishment field is set to 1.
401 #define PTP_CRB_LOCALITY_STATE_TPM_ESTABLISHED BIT0
404 // Define bits of Locality Control Register
408 /// Writes (1): Reset TPM_LOC_STATE_x.tpmEstablished bit if the write occurs from Locality 3 or 4.
410 #define PTP_CRB_LOCALITY_CONTROL_RESET_ESTABLISHMENT_BIT BIT3
413 /// Writes (1): The TPM gives control of the TPM to the locality setting this bit if it is the higher priority locality.
415 #define PTP_CRB_LOCALITY_CONTROL_SEIZE BIT2
418 /// Writes (1): The active Locality is done with the TPM.
420 #define PTP_CRB_LOCALITY_CONTROL_RELINQUISH BIT1
423 /// Writes (1): Interrupt the TPM and generate a locality arbitration algorithm.
425 #define PTP_CRB_LOCALITY_CONTROL_REQUEST_ACCESS BIT0
428 // Define bits of Locality Status Register
432 /// 0: A higher locality has not initiated a Seize arbitration process.
433 /// 1: A higher locality has Seized the TPM from this locality.
435 #define PTP_CRB_LOCALITY_STATUS_BEEN_SEIZED BIT1
438 /// 0: Locality has not been granted to the TPM.
439 /// 1: Locality has been granted access to the TPM
441 #define PTP_CRB_LOCALITY_STATUS_GRANTED BIT0
444 // Define bits of CRB Control Area Request Register
448 /// Used by Software to indicate transition the TPM to and from the Idle state
449 /// 1: Set by Software to indicate response has been read from the response buffer and TPM can transition to Idle
450 /// 0: Cleared to 0 by TPM to acknowledge the request when TPM enters Idle state.
451 /// TPM SHALL complete this transition within TIMEOUT_C.
453 #define PTP_CRB_CONTROL_AREA_REQUEST_GO_IDLE BIT1
456 /// Used by Software to request the TPM transition to the Ready State.
457 /// 1: Set to 1 by Software to indicate the TPM should be ready to receive a command.
458 /// 0: Cleared to 0 by TPM to acknowledge the request.
459 /// TPM SHALL complete this transition within TIMEOUT_C.
461 #define PTP_CRB_CONTROL_AREA_REQUEST_COMMAND_READY BIT0
464 // Define bits of CRB Control Area Status Register
468 /// Used by TPM to indicate it is in the Idle State
469 /// 1: Set by TPM when in the Idle State
470 /// 0: Cleared by TPM on receipt of TPM_CRB_CTRL_REQ_x.cmdReady when TPM transitions to the Ready State.
471 /// SHALL be cleared by TIMEOUT_C.
473 #define PTP_CRB_CONTROL_AREA_STATUS_TPM_IDLE BIT1
476 /// Used by the TPM to indicate current status.
477 /// 1: Set by TPM to indicate a FATAL Error
478 /// 0: Indicates TPM is operational
480 #define PTP_CRB_CONTROL_AREA_STATUS_TPM_STATUS BIT0
483 // Define bits of CRB Control Cancel Register
487 /// Used by software to cancel command processing Reads return correct value
488 /// Writes (0000 0001h): Cancel a command
489 /// Writes (0000 0000h): Clears field when command has been cancelled
491 #define PTP_CRB_CONTROL_CANCEL BIT0
494 // Define bits of CRB Control Start Register
498 /// When set by software, indicates a command is ready for processing.
499 /// Writes (0000 0001h): TPM transitions to Command Execution
500 /// Writes (0000 0000h): TPM clears this field and transitions to Command Completion
502 #define PTP_CRB_CONTROL_START BIT0
505 // Restore original structure alignment
510 // Default TimeOut value
512 #define PTP_TIMEOUT_A (750 * 1000) // 750ms
513 #define PTP_TIMEOUT_B (2000 * 1000) // 2s
514 #define PTP_TIMEOUT_C (200 * 1000) // 200ms
515 #define PTP_TIMEOUT_D (30 * 1000) // 30ms