]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/DxeSmbusLib/InternalSmbusLib.h
3c0b597fc5f64caf9e828da6b25b4e159d0f0ccd
[mirror_edk2.git] / MdePkg / Library / DxeSmbusLib / InternalSmbusLib.h
1 /** @file
2 Internal header file for Smbus library.
3
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. 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
9
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.
12
13
14 Module Name: SmbusLib.c
15
16 **/
17
18 #ifndef __INTERNAL_SMBUS_LIB_H
19 #define __INTERNAL_SMBUS_LIB_H
20
21 #define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) ((SmBusAddress) & 0x01))
22 #define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f)
23 #define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff)
24 #define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x1f)
25 #define SMBUS_LIB_RESEARVED(SmBusAddress) (((SmBusAddress) >> 21))
26
27 //
28 // Declaration for internal functions
29 //
30 /**
31 Executes an SMBus operation to an SMBus controller.
32
33 This function provides a standard way to execute Smbus script
34 as defined in the SmBus Specification. The data can either be of
35 the Length byte, word, or a block of data.
36
37 @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to
38 execute the SMBus transactions.
39 @param SmBusAddress Address that encodes the SMBUS Slave Address,
40 SMBUS Command, SMBUS Data Length, and PEC.
41 @param Length Signifies the number of bytes that this operation will do. The maximum number of
42 bytes can be revision specific and operation specific.
43 @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations
44 require this argument. The length of this buffer is identified by Length.
45 @param Status Return status for the executed command.
46 This is an optional parameter and may be NULL.
47
48 @return The actual number of bytes that are executed for this operation..
49
50 **/
51 UINTN
52 InternalSmBusExec (
53 IN EFI_SMBUS_OPERATION SmbusOperation,
54 IN UINTN SmBusAddress,
55 IN UINTN Length,
56 IN VOID *Buffer,
57 OUT RETURN_STATUS *Status OPTIONAL
58 );
59
60 /**
61 Assigns an SMBUS slave addresses.
62
63 Assigns the SMBUS device specified by Uuid the slave address specified by SmBusAddress.
64 The status of the executed command is returned.
65 If Command in SmBusAddress is not zero, then ASSERT().
66 If Length in SmBusAddress is not zero, then ASSERT().
67 If PEC in SmBusAddress is set, then ASSERT().
68 If any reserved bits of SmBusAddress are set, then ASSERT().
69
70 @param SmBusAddress Address that encodes the SMBUS Slave Address,
71 SMBUS Command, SMBUS Data Length, and PEC.
72 @param Uuid Pointer to the UUID of the device to assign a slave address.
73 It will assign to all SMBUS slave devices if it is NULL.
74
75 @retval RETURN_SUCCESS The SMBUS command was executed.
76 @retval RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
77 @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected
78 in the Host Status Register bit.
79 Device errors are a result of a transaction collision, illegal command field,
80 unclaimed cycle (host initiated), or bus errors (collisions).
81
82 **/
83 RETURN_STATUS
84 InternalSmBusArpDevice (
85 IN UINTN SmBusAddress,
86 IN CONST GUID *Uuid OPTIONAL
87 );
88
89 /**
90 Retrieves the mapping of all the SMBus devices.
91
92 The GetArpMap() function returns the mapping of all the SMBus devices
93 that are enumerated by the SMBus host driver.
94
95 @param Length Size of the buffer that contains the SMBus device map.
96 @param SmbusDeviceMap The pointer to the device map as enumerated by the SMBus controller driver.
97
98 @retval RETURN_SUCCESS The SMBUS command was executed.
99 @retval RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
100 @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected
101 in the Host Status Register bit.
102 Device errors are a result of a transaction collision, illegal command field,
103 unclaimed cycle (host initiated), or bus errors (collisions).
104
105 **/
106 RETURN_STATUS
107 InternalGetArpMap (
108 OUT UINTN *Length,
109 OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap
110 );
111
112 #endif