summaryrefslogtreecommitdiff
path: root/Include/SmBus.h
blob: 0ea31f25783cc699b0146b3e7465562fd9e0bdb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2009, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**             6145-F Northbelt Pkwy, Norcross, GA 30071            **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************
//**********************************************************************
// $Header: /Alaska/BIN/Core/Include/SmBus.h 2     2/05/11 2:05p Artems $
//
// $Revision: 2 $
//
// $Date: 2/05/11 2:05p $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/BIN/Core/Include/SmBus.h $
// 
// 2     2/05/11 2:05p Artems
// Added helper macros to simplify SMBUS address handling
// 
// 1     1/16/09 9:57a Felixp
// SM Bus Protocol and PPI headers are updated. Common code moved into
// newly created header file (Include\SmBus.h).
// 
//**********************************************************************
//<AMI_FHDR_START>
//
// Name:	SmBus.h
//
// Description:	SM BUS data structure declarations
//
//<AMI_FHDR_END>
//**********************************************************************
#ifndef __SMBUS_MAIN__H__
#define __SMBUS_MAIN__H__
#ifdef __cplusplus
extern "C" {
#endif

#include <Efi.h>

#pragma pack(1)

// PEC BIT is bit 22 in SMBUS address
#define SMBUS_LIB_PEC_BIT   (1 << 22)

/**
  Macro that converts SMBUS slave address, SMBUS command, SMBUS data length,
  and PEC to a value that can be passed to the SMBUS Library functions.

  Computes an address that is compatible with the SMBUS Library functions.
  The unused upper bits of SlaveAddress, Command, and Length are stripped
  prior to the generation of the address.
  
  @param  SlaveAddress    SMBUS Slave Address.  Range 0..127.
  @param  Command         SMBUS Command.  Range 0..255.
  @param  Length          SMBUS Data Length.  Range 0..32.
  @param  Pec             TRUE if Packet Error Checking is enabled.  Otherwise FALSE.

**/
#define SMBUS_LIB_ADDRESS(SlaveAddress,Command,Length,Pec)  \
  ( ((Pec) ? SMBUS_LIB_PEC_BIT: 0)      | \
    (((SlaveAddress) & 0x7f) << 1)      | \
    (((Command)      & 0xff) << 8)      | \
    (((Length)       & 0x3f) << 16)       \
  )

#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress)      (((SmBusAddress) >> 1)  & 0x7f)
#define SMBUS_LIB_COMMAND(SmBusAddress)            (((SmBusAddress) >> 8)  & 0xff)
#define SMBUS_LIB_LENGTH(SmBusAddress)             (((SmBusAddress) >> 16) & 0x3f)
#define SMBUS_LIB_PEC(SmBusAddress)     ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0))
#define SMBUS_LIB_RESERVED(SmBusAddress)            ((SmBusAddress) & ~(((1 << 22) - 2) | SMBUS_LIB_PEC_BIT))

typedef struct {
  UINTN   SmbusDeviceAddress:7;
} EFI_SMBUS_DEVICE_ADDRESS;

typedef UINTN EFI_SMBUS_DEVICE_COMMAND;

typedef enum _EFI_SMBUS_OPERATION {
  EfiSmbusQuickRead,
  EfiSmbusQuickWrite,
  EfiSmbusReceiveByte,
  EfiSmbusSendByte,
  EfiSmbusReadByte,
  EfiSmbusWriteByte,
  EfiSmbusReadWord,
  EfiSmbusWriteWord,
  EfiSmbusReadBlock,
  EfiSmbusWriteBlock,
  EfiSmbusProcessCall,
  EfiSmbusBWBRProcessCall
} EFI_SMBUS_OPERATION;
//******************************************************
// EFI_SMBUS_UDID 
//******************************************************
typedef struct {
  UINT32  VendorSpecificId;
  UINT16  SubsystemDeviceId;
  UINT16  SubsystemVendorId;
  UINT16  Interface;
  UINT16  DeviceId;
  UINT16  VendorId;
  UINT8   VendorRevision;
  UINT8   DeviceCapabilities;
} EFI_SMBUS_UDID;
//******************************************************* 
// EFI_SMBUS_DEVICE_MAP 
//*******************************************************
typedef struct {
  EFI_SMBUS_DEVICE_ADDRESS  SmbusDeviceAddress;
  EFI_SMBUS_UDID            SmbusDeviceUdid;
} EFI_SMBUS_DEVICE_MAP;
#pragma pack()
/****** DO NOT WRITE BELOW THIS LINE *******/
#ifdef __cplusplus
}
#endif
#endif
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2009, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**             6145-F Northbelt Pkwy, Norcross, GA 30071            **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************