blob: 2a940a3160870dd1bffd936c4ea03b81fc049372 [file] [log] [blame]
Angel Pons0612b272020-04-05 15:46:56 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Lijian Zhaoc303d742018-02-11 17:20:34 -08002
3#include <intelblocks/pcr.h>
4
5/*
6 * Calculate PCR register base at specified PID
7 * Arg0 - PCR Port ID
8 */
9Method (PCRB, 1, NotSerialized)
10{
Alexey Buyanovd1824252020-06-16 17:53:22 -070011 Return (CONFIG_PCR_BASE_ADDRESS + (Arg0 << PCR_PORTID_SHIFT))
Lijian Zhaoc303d742018-02-11 17:20:34 -080012}
13
14/*
15 * Read a PCR register at specified PID and offset
16 * Arg0 - PCR Port ID
17 * Arg1 - Register Offset
18 */
19Method (PCRR, 2, Serialized)
20{
Alexey Buyanov03248032020-06-01 21:41:14 -070021 OperationRegion (PCRD, SystemMemory, PCRB (Arg0) + Arg1, 4)
Lijian Zhaoc303d742018-02-11 17:20:34 -080022 Field (PCRD, DWordAcc, NoLock, Preserve)
23 {
24 DATA, 32
25 }
26 Return (DATA)
27}
28
29/*
30 * AND a value with PCR register at specified PID and offset
31 * Arg0 - PCR Port ID
32 * Arg1 - Register Offset
33 * Arg2 - Value to AND
34 */
35Method (PCRA, 3, Serialized)
36{
Alexey Buyanov03248032020-06-01 21:41:14 -070037 OperationRegion (PCRD, SystemMemory, PCRB (Arg0) + Arg1, 4)
Lijian Zhaoc303d742018-02-11 17:20:34 -080038 Field (PCRD, DWordAcc, NoLock, Preserve)
39 {
40 DATA, 32
41 }
Alexey Buyanov03248032020-06-01 21:41:14 -070042 DATA &= Arg2
Lijian Zhaoc303d742018-02-11 17:20:34 -080043
44 /*
45 * After every write one needs to read an innocuous register
46 * to ensure the writes are completed for certain ports. This is done
47 * for all ports so that the callers don't need the per-port knowledge
48 * for each transaction.
49 */
50 PCRR (Arg0, Arg1)
51}
52
53/*
54 * OR a value with PCR register at specified PID and offset
55 * Arg0 - PCR Port ID
56 * Arg1 - Register Offset
57 * Arg2 - Value to OR
58 */
59Method (PCRO, 3, Serialized)
60{
Alexey Buyanov03248032020-06-01 21:41:14 -070061 OperationRegion (PCRD, SystemMemory, PCRB (Arg0) + Arg1, 4)
Lijian Zhaoc303d742018-02-11 17:20:34 -080062 Field (PCRD, DWordAcc, NoLock, Preserve)
63 {
64 DATA, 32
65 }
Alexey Buyanov03248032020-06-01 21:41:14 -070066 DATA |= Arg2
Lijian Zhaoc303d742018-02-11 17:20:34 -080067
68 /*
69 * After every write one needs to read an innocuous register
70 * to ensure the writes are completed for certain ports. This is done
71 * for all ports so that the callers don't need the per-port knowledge
72 * for each transaction.
73 */
74 PCRR (Arg0, Arg1)
75}