summaryrefslogtreecommitdiff
path: root/Silicon/Hisilicon/Include/Library/I2CLib.h
blob: 36e9f5f5f67f675a37297c15a4dca7c57c6e01b5 (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
/** @file
*
*  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
*  Copyright (c) 2015, Linaro Limited. All rights reserved.
*
*  This program and the accompanying materials
*  are licensed and made available under the terms and conditions of the BSD License
*  which accompanies this distribution.  The full text of the license may be found at
*  http://opensource.org/licenses/bsd-license.php
*
*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*
**/


#ifndef _I2C_LIB_H_
#define _I2C_LIB_H_

//I2C0 or I2C1
typedef enum {
  DEVICE_TYPE_SPD = 0,
  DEVICE_TYPE_E2PROM,
  DEVICE_TYPE_CPLD_3BYTE_OPERANDS,
  DEVICE_TYPE_CPLD_4BYTE_OPERANDS
}I2C_DEVICE_TYPE;


typedef enum {
  Normal = 0,
  Fast,
  SPEED_MODE_MAX
}SPEED_MODE;


#define    I2C_PORT_MAX            10



typedef struct {
    UINT32           Socket;
    UINT32           Port;
    I2C_DEVICE_TYPE  DeviceType;
    UINT32           SlaveDeviceAddress;
}I2C_DEVICE;


UINTN
EFIAPI
I2CInit(UINT32 Socket, UINT32 Port, SPEED_MODE SpeedMode);

EFI_STATUS
EFIAPI
I2CWrite(I2C_DEVICE *I2cInfo, UINT16 InfoOffset, UINT32 ulLength, UINT8 *pBuf);

EFI_STATUS
EFIAPI
I2CRead(I2C_DEVICE *I2cInfo, UINT16 InfoOffset,UINT32 ulRxLen,UINT8 *pBuf);

EFI_STATUS
EFIAPI
I2CWriteMultiByte(I2C_DEVICE *I2cInfo, UINT32 InfoOffset, UINT32 ulLength, UINT8 *pBuf);

EFI_STATUS
EFIAPI
I2CReadMultiByte(I2C_DEVICE *I2cInfo, UINT32 InfoOffset,UINT32 ulRxLen,UINT8 *pBuf);

EFI_STATUS
EFIAPI
I2CSdaConfig(UINT32 Socket, UINT32 Port);


#endif