]>
git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/Library/I2CLibPei/I2CIoLibPei.c
6a37dbec1d4ba49cec98ae907f1735cb21735fe9
2 Functions for access I2C MMIO register.
4 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/DebugLib.h>
11 #include <Library/PeiServicesTablePointerLib.h>
14 Reads an 8-bit MMIO register.
16 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
17 returned. This function must guarantee that all MMIO read and write
18 operations are serialized.
20 If 8-bit MMIO register operations are not supported, then ASSERT().
22 @param Address The MMIO register to read.
24 @return The value read.
35 Value
= *(volatile UINT8
*)Address
;
40 Reads a 16-bit MMIO register.
42 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
43 returned. This function must guarantee that all MMIO read and write
44 operations are serialized.
46 If 16-bit MMIO register operations are not supported, then ASSERT().
47 If Address is not aligned on a 16-bit boundary, then ASSERT().
49 @param Address The MMIO register to read.
51 @return The value read.
62 ASSERT ((Address
& 1) == 0);
63 Value
= *(volatile UINT16
*)Address
;
68 Writes a 16-bit MMIO register.
70 Writes the 16-bit MMIO register specified by Address with the value specified
71 by Value and returns Value. This function must guarantee that all MMIO read
72 and write operations are serialized.
74 If 16-bit MMIO register operations are not supported, then ASSERT().
75 If Address is not aligned on a 16-bit boundary, then ASSERT().
77 @param Address The MMIO register to write.
78 @param Value The value to write to the MMIO register.
85 I2CLibPeiMmioWrite16 (
90 ASSERT ((Address
& 1) == 0);
91 *(volatile UINT16
*)Address
= Value
;
96 Reads a 32-bit MMIO register.
98 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
99 returned. This function must guarantee that all MMIO read and write
100 operations are serialized.
102 If 32-bit MMIO register operations are not supported, then ASSERT().
103 If Address is not aligned on a 32-bit boundary, then ASSERT().
105 @param Address The MMIO register to read.
107 @return The value read.
112 I2CLibPeiMmioRead32 (
118 ASSERT ((Address
& 3) == 0);
119 Value
= *(volatile UINT32
*)Address
;
125 Writes a 32-bit MMIO register.
127 Writes the 32-bit MMIO register specified by Address with the value specified
128 by Value and returns Value. This function must guarantee that all MMIO read
129 and write operations are serialized.
131 If 32-bit MMIO register operations are not supported, then ASSERT().
132 If Address is not aligned on a 32-bit boundary, then ASSERT().
134 @param Address The MMIO register to write.
135 @param Value The value to write to the MMIO register.
142 I2CLibPeiMmioWrite32 (
147 ASSERT ((Address
& 3) == 0);
148 *(volatile UINT32
*)Address
= Value
;
153 OR a 32-bit MMIO register.
155 OR the 32-bit MMIO register specified by Address with the value specified
156 by Value and returns Value. This function must guarantee that all MMIO read
157 and write operations are serialized.
159 If 32-bit MMIO register operations are not supported, then ASSERT().
160 If Address is not aligned on a 32-bit boundary, then ASSERT().
162 @param Address The MMIO register to write OR.
163 @param Value The value to OR to the MMIO register.
175 return I2CLibPeiMmioWrite32 (Address
, I2CLibPeiMmioRead32(Address
) | OrData
);