1 /** @file
2 *
3 *  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
4 *  Copyright (c) 2015, Linaro Limited. All rights reserved.
5 *
6 *  This program and the accompanying materials
7 *  are licensed and made available under the terms and conditions of the BSD License
8 *  which accompanies this distribution.  The full text of the license may be found at
9 *  http://opensource.org/licenses/bsd-license.php
10 *
11 *  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 *
14 **/
15 
16 
17 #ifndef _I2C_LIB_H_
18 #define _I2C_LIB_H_
19 
20 //I2C0 or I2C1
21 typedef enum {
22   DEVICE_TYPE_SPD = 0,
23   DEVICE_TYPE_E2PROM,
24   DEVICE_TYPE_CPLD_3BYTE_OPERANDS,
25   DEVICE_TYPE_CPLD_4BYTE_OPERANDS
26 }I2C_DEVICE_TYPE;
27 
28 
29 typedef enum {
30   Normal = 0,
31   Fast,
32   SPEED_MODE_MAX
33 }SPEED_MODE;
34 
35 
36 #define    I2C_PORT_MAX            10
37 
38 
39 
40 typedef struct {
41     UINT32           Socket;
42     UINT32           Port;
43     I2C_DEVICE_TYPE  DeviceType;
44     UINT32           SlaveDeviceAddress;
45 }I2C_DEVICE;
46 
47 
48 UINTN
49 EFIAPI
50 I2CInit(UINT32 Socket, UINT32 Port, SPEED_MODE SpeedMode);
51 
52 EFI_STATUS
53 EFIAPI
54 I2CWrite(I2C_DEVICE *I2cInfo, UINT16 InfoOffset, UINT32 ulLength, UINT8 *pBuf);
55 
56 EFI_STATUS
57 EFIAPI
58 I2CRead(I2C_DEVICE *I2cInfo, UINT16 InfoOffset,UINT32 ulRxLen,UINT8 *pBuf);
59 
60 EFI_STATUS
61 EFIAPI
62 I2CWriteMultiByte(I2C_DEVICE *I2cInfo, UINT32 InfoOffset, UINT32 ulLength, UINT8 *pBuf);
63 
64 EFI_STATUS
65 EFIAPI
66 I2CReadMultiByte(I2C_DEVICE *I2cInfo, UINT32 InfoOffset,UINT32 ulRxLen,UINT8 *pBuf);
67 
68 EFI_STATUS
69 EFIAPI
70 I2CSdaConfig(UINT32 Socket, UINT32 Port);
71 
72 
73 #endif
74