]>
git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/Library/I2CLibPei/I2CIoLibPei.c
2 Functions for access I2C MMIO register.
4 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <Library/DebugLib.h>
17 #include <Library/PeiServicesTablePointerLib.h>
20 Reads an 8-bit MMIO register.
22 Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
23 returned. This function must guarantee that all MMIO read and write
24 operations are serialized.
26 If 8-bit MMIO register operations are not supported, then ASSERT().
28 @param Address The MMIO register to read.
30 @return The value read.
41 Value
= *(volatile UINT8
*)Address
;
46 Reads a 16-bit MMIO register.
48 Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
49 returned. This function must guarantee that all MMIO read and write
50 operations are serialized.
52 If 16-bit MMIO register operations are not supported, then ASSERT().
53 If Address is not aligned on a 16-bit boundary, then ASSERT().
55 @param Address The MMIO register to read.
57 @return The value read.
68 ASSERT ((Address
& 1) == 0);
69 Value
= *(volatile UINT16
*)Address
;
74 Writes a 16-bit MMIO register.
76 Writes the 16-bit MMIO register specified by Address with the value specified
77 by Value and returns Value. This function must guarantee that all MMIO read
78 and write operations are serialized.
80 If 16-bit MMIO register operations are not supported, then ASSERT().
81 If Address is not aligned on a 16-bit boundary, then ASSERT().
83 @param Address The MMIO register to write.
84 @param Value The value to write to the MMIO register.
91 I2CLibPeiMmioWrite16 (
96 ASSERT ((Address
& 1) == 0);
97 *(volatile UINT16
*)Address
= Value
;
102 Reads a 32-bit MMIO register.
104 Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
105 returned. This function must guarantee that all MMIO read and write
106 operations are serialized.
108 If 32-bit MMIO register operations are not supported, then ASSERT().
109 If Address is not aligned on a 32-bit boundary, then ASSERT().
111 @param Address The MMIO register to read.
113 @return The value read.
118 I2CLibPeiMmioRead32 (
124 ASSERT ((Address
& 3) == 0);
125 Value
= *(volatile UINT32
*)Address
;
131 Writes a 32-bit MMIO register.
133 Writes the 32-bit MMIO register specified by Address with the value specified
134 by Value and returns Value. This function must guarantee that all MMIO read
135 and write operations are serialized.
137 If 32-bit MMIO register operations are not supported, then ASSERT().
138 If Address is not aligned on a 32-bit boundary, then ASSERT().
140 @param Address The MMIO register to write.
141 @param Value The value to write to the MMIO register.
148 I2CLibPeiMmioWrite32 (
153 ASSERT ((Address
& 3) == 0);
154 *(volatile UINT32
*)Address
= Value
;
159 OR a 32-bit MMIO register.
161 OR the 32-bit MMIO register specified by Address with the value specified
162 by Value and returns Value. This function must guarantee that all MMIO read
163 and write operations are serialized.
165 If 32-bit MMIO register operations are not supported, then ASSERT().
166 If Address is not aligned on a 32-bit boundary, then ASSERT().
168 @param Address The MMIO register to write OR.
169 @param Value The value to OR to the MMIO register.
181 return I2CLibPeiMmioWrite32 (Address
, I2CLibPeiMmioRead32(Address
) | OrData
);