tizen 2.4 release
[kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc8825 / sc8825_i2c.h
1 /******************************************************************************\r
2  ** File Name:      I2C_drv.c                                                 *\r
3  ** Author:         Lin.liu                                                   *\r
4  ** DATE:           04/23/2002                                                *\r
5  ** Copyright:      2002 Spreatrum, Incoporated. All Rights Reserved.         *\r
6  ** Description:    This file define the basic interfaces of I2C device.      *\r
7  ******************************************************************************\r
8 \r
9  ******************************************************************************\r
10  **                        Edit History                                       *\r
11  ** ------------------------------------------------------------------------- *\r
12  ** DATE           NAME             DESCRIPTION                               *\r
13  ** 01/16/2001     Richard.Yang     Create.                                   *\r
14  ** 04/02/2002     Lin.Liu              Code                                      *\r
15  ******************************************************************************/\r
16 #ifndef I2C_H\r
17 #define I2C_H\r
18 \r
19 /**---------------------------------------------------------------------------*\r
20  **                         Dependencies                                      *\r
21  **---------------------------------------------------------------------------*/\r
22 #include <asm/arch/sci_types.h>\r
23 #include <asm/arch/arm_reg.h>\r
24 \r
25 /**---------------------------------------------------------------------------*\r
26  **                         Debugging Flag                                    *\r
27  **---------------------------------------------------------------------------*/\r
28  \r
29 /**---------------------------------------------------------------------------*\r
30  **                         Compiler Flag                                     *\r
31  **---------------------------------------------------------------------------*/\r
32 #ifdef   __cplusplus\r
33     extern   "C" \r
34     {\r
35 #endif\r
36 \r
37 #define  PUBLIC  \r
38 \r
39 //      I2C command define \r
40 #define   I2C_CMD_ICLR      BIT_0\r
41 #define   I2C_CMD_TX_ACK    BIT_1\r
42 #define   I2C_CMD_WRITE     BIT_2\r
43 #define   I2C_CMD_READ      BIT_3\r
44 #define   I2C_CMD_STOP      BIT_4\r
45 #define   I2C_CMD_START     BIT_5\r
46 #define   I2C_CMD_ACK       BIT_6\r
47 #define   I2C_CMD_BUSY      BIT_7\r
48 \r
49 //I2C error code define\r
50 typedef enum\r
51 {\r
52         ERR_I2C_NONE = 0,                               // Success,no error\r
53         ERR_I2C_ACK_TIMEOUT,                    // I2C wait ACK timeout\r
54         ERR_I2C_INT_TIMEOUT,                    // I2C wait INT timeout\r
55         ERR_I2C_BUSY_TIMEOUT,                   // I2C wait BUSY timeout\r
56         ERR_I2C_DEVICE_NOT_FOUND                // I2C device not found\r
57 } ERR_I2C_E;\r
58 \r
59 \r
60 \r
61 \r
62 /**---------------------------------------------------------------------------*\r
63  **                      Function  Prototype\r
64  **---------------------------------------------------------------------------*/\r
65 /*********************************************************************/\r
66 //  Description: i2c interrupt service \r
67 //  Input:\r
68 //      param         not use\r
69 //  Return:\r
70 //      None\r
71 //      Note: \r
72 //      None       \r
73 /*********************************************************************/\r
74 PUBLIC void I2C_Handler(uint32 param);\r
75 \r
76 /*********************************************************************/\r
77 //  Description: Write a command to a slave device\r
78 //  Input:\r
79 //      addr     the slave device's address\r
80 //      command  the command to be set into the slave device's address\r
81 //              ack_en   Enable/Disable check the slave device rsp ACK\r
82 //  Return:\r
83 //      ERR_I2C_NONE    successfully\r
84 //      Note: \r
85 //      None       \r
86 /*********************************************************************/\r
87 PUBLIC ERR_I2C_E I2C_WriteCmd(uint8 addr,uint8 command, BOOLEAN ack_en);\r
88 \r
89 /*********************************************************************/\r
90 //  Description: read a command from the slave device\r
91 //  Input:\r
92 //      addr     the slave device's address\r
93 //      pCmd     the command's pointer\r
94 //              ack_en   Enable/Disable check the slave device rsp ACK\r
95 //  Return:\r
96 //      ERR_I2C_NONE    successfully\r
97 //      Note: \r
98 //      None       \r
99 /*********************************************************************/\r
100 PUBLIC ERR_I2C_E I2C_ReadCmd(uint8 addr,uint8 *pCmd,BOOLEAN ack_en);\r
101 \r
102 /*********************************************************************/\r
103 //  Description: Write the command array into the slave device \r
104 //  Input:\r
105 //      addr     the slave device's address\r
106 //      pCmd     the command array's pointer\r
107 //      len      the length of the command array\r
108 //              ack_en   Enable/Disable check the slave device rsp ACK\r
109 //  Return:\r
110 //      ERR_I2C_NONE    successfully\r
111 //      Note: \r
112 //      None       \r
113 /*********************************************************************/\r
114 PUBLIC ERR_I2C_E I2C_WriteCmdArr(uint8 addr, uint8 *pCmd, uint32 len, BOOLEAN ack_en);\r
115 \r
116 /*********************************************************************/\r
117 //  Description: Read a command array from the slave device \r
118 //  Input:\r
119 //      addr     the slave device's address\r
120 //      pCmd     the command array's pointer\r
121 //      len      the length of command array\r
122 //              ack_en   Enable/Disable check the slave device rsp ACK\r
123 //  Return:\r
124 //      ERR_I2C_NONE    successfully\r
125 //      Note: \r
126 //      None       \r
127 /*********************************************************************/\r
128 PUBLIC ERR_I2C_E I2C_ReadCmdArr(uint8 addr, uint8 *pCmd, uint32 len,BOOLEAN ack_en  );\r
129 \r
130 /*********************************************************************/\r
131 //  Description: i2c set SCL clock\r
132 //  Input:\r
133 //      freq     I2C SCL's frequency to be set\r
134 //  Return:\r
135 //      ERR_I2C_NONE    successfully\r
136 //      Note: \r
137 //      None       \r
138 /*********************************************************************/\r
139 PUBLIC ERR_I2C_E I2C_SetSCLclk(uint32 freq);\r
140 \r
141 /*********************************************************************/\r
142 //  Description: get i2c SCL clock\r
143 //  Input:\r
144 //      None\r
145 //  Return:\r
146 //      the freq of i2c SCL clock\r
147 //      Note: \r
148 //      None       \r
149 /*********************************************************************/\r
150 PUBLIC uint32 I2C_GetSCLclk(void);\r
151 \r
152 /*********************************************************************/\r
153 //  Description: i2c init fuction \r
154 //  Input:\r
155 //      freq     I2C SCL's frequency\r
156 //  Return:\r
157 //      ERR_I2C_NONE    successfully\r
158 //      Note: \r
159 //      None       \r
160 /*********************************************************************/\r
161 PUBLIC ERR_I2C_E I2C_Init(uint32 freq);\r
162 \r
163 \r
164 \r
165 \r
166 /**---------------------------------------------------------------------------*\r
167  **                         Compiler Flag                                     *\r
168  **---------------------------------------------------------------------------*/\r
169 #ifdef   __cplusplus\r
170     }\r
171 #endif\r
172 \r
173 #endif /* I2C_H  */\r
174 \r
175 /* End Of File  */\r