tizen 2.4 release
[kernel/u-boot-tm1.git] / drivers / i2c / i2c_phy.h
1 /******************************************************************************
2  ** File Name:      I2C_phy.h                                                 *
3  ** Author:         liuhao                                                   *
4  ** DATE:           06/28/2010                                                *
5  ** Copyright:      2010 Spreatrum, Incoporated. All Rights Reserved.         *
6  ** Description:    This file define the basic hw interfaces of I2C device.      *
7  ******************************************************************************
8
9  ******************************************************************************
10  **                        Edit History                                       *
11  ** ------------------------------------------------------------------------- *
12  ** DATE           NAME             DESCRIPTION                               *
13  ** 06/28/2010     liuhao     Create.                                   *
14  ******************************************************************************/
15
16 #ifndef _I2C_PHY_H_
17 #define _I2C_PHY_H_
18 /*----------------------------------------------------------------------------*
19  **                         Dependencies                                      *
20  **------------------------------------------------------------------------- */
21
22 #include "asm/arch/sci_types.h"
23
24
25 /**---------------------------------------------------------------------------*
26  **                             Compiler Flag                                 *
27  **--------------------------------------------------------------------------*/
28 #ifdef   __cplusplus
29 extern   "C"
30 {
31 #endif
32 /**---------------------------------------------------------------------------*
33 **                               Micro Define                                **
34 **---------------------------------------------------------------------------*/
35 //I2C error code define
36 typedef enum
37 {
38     ERR_I2C_NONE = 0,               // Success,no error
39     ERR_I2C_ACK_TIMEOUT,            // I2C wait ACK timeout
40     ERR_I2C_INT_TIMEOUT,            // I2C wait INT timeout
41     ERR_I2C_BUSY_TIMEOUT,           // I2C wait BUSY timeout
42     ERR_I2C_DEVICE_NOT_FOUND,       // I2C device not found
43     ERR_I2C_NO_MUTEX        // No mutex created
44 } ERR_I2C_E;
45
46 typedef ERR_I2C_E (*_init) (uint32 phy_id, uint32 freq, uint32 port);
47 typedef ERR_I2C_E (*_start) (uint32 phy_id, uint8 addr, BOOLEAN rw, BOOLEAN ack_en);
48 typedef ERR_I2C_E (*_write) (uint32 phy_id, uint8 *pCmd, uint32 len, BOOLEAN ack_en, BOOLEAN no_stop);
49 typedef ERR_I2C_E (*_read) (uint32 phy_id, uint8 *pCmd, uint32 len, BOOLEAN ack_en);
50 typedef ERR_I2C_E (*_stop) (uint32 phy_id);
51 typedef ERR_I2C_E (*_sendack) (uint32 phy_id);
52 typedef ERR_I2C_E (*_getack) (uint32 phy_id);
53
54 typedef struct
55 {
56     _init init;
57     _start start;
58     _write write;
59     _read read;
60     _stop stop;
61     _sendack sendack;
62     _getack getack;
63 } I2C_PHY_FUN;
64
65 /**----------------------------------------------------------------------------*
66 **                         Local Function Prototype                           **
67 **----------------------------------------------------------------------------*/
68
69
70 /**----------------------------------------------------------------------------*
71 **                           Function Prototype                               **
72 **----------------------------------------------------------------------------*/
73
74 /**----------------------------------------------------------------------------*
75 **                         Compiler Flag                                      **
76 **----------------------------------------------------------------------------*/
77 #ifdef   __cplusplus
78 }
79 #endif
80 /**---------------------------------------------------------------------------*/
81 #endif
82 // End