Merge branch develop-3.10
[firefly-linux-kernel-4.4.55.git] / sound / soc / codecs / cxpump.h
1 /****************************************************************************************\r
2 *****************************************************************************************\r
3 ***                                                                                   ***\r
4 ***                                 Copyright (c) 2011                                ***\r
5 ***                                                                                   ***\r
6 ***                                Conexant Systems, Inc.                             ***\r
7 ***                                                                                   ***\r
8 ***                                 All Rights Reserved                               ***\r
9 ***                                                                                   ***\r
10 ***                                    CONFIDENTIAL                                   ***\r
11 ***                                                                                   ***\r
12 ***               NO DISSEMINATION OR USE WITHOUT PRIOR WRITTEN PERMISSION            ***\r
13 ***                                                                                   ***\r
14 *****************************************************************************************\r
15 **\r
16 **  File Name:\r
17 **      pump.c\r
18 **\r
19 **  Abstract:\r
20 **      This code is to download the firmware to CX20709 device via I2C bus. \r
21 **      \r
22 **\r
23 **  Product Name:\r
24 **      Conexant Channel CX20709\r
25 **\r
26 **  Remark:\r
27 **      \r
28 **\r
29 ** \r
30 ********************************************************************************\r
31 **  Revision History\r
32 **      Date        Description                                 Author\r
33 **      01/21/11    Created.                                    Simon Ho\r
34 **      01/24/11    Speed up the firmware download by sending   Simon Ho\r
35 **                  I2C data continually without  addressing    \r
36 ********************************************************************************\r
37 *****************************************************************************************/\r
38 #ifdef __cplusplus\r
39 extern "C"{\r
40 #endif \r
41 \r
42 \r
43 typedef int (*fun_I2cWriteThenRead)(  void * pCallbackContext,\r
44                                       unsigned char ChipAddr, \r
45                                       unsigned long cbBuf,\r
46                                       unsigned char* pBuf,\r
47                                       unsigned long cbReadBuf, \r
48                                       unsigned char*pReadBuf);\r
49 \r
50 typedef int (*fun_I2cWrite)(  void * pCallbackContext,\r
51                               unsigned char ChipAddr,\r
52                               unsigned long cbBuf, \r
53                               unsigned char* pBuf);\r
54 \r
55 /*\r
56  * Set the I2cWrite callback function.\r
57  * \r
58  * PARAMETERS\r
59  *  \r
60  *    pCallbackContext [in] - A pointer to a caller-defined structure of data items\r
61  *                            to be passed as the context parameter of the callback\r
62  *                            routine each time it is called. \r
63  *\r
64  *    I2cWritePtr      [in] - A pointer to a i2cwirte callback routine, which is to \r
65  *                            write I2C data. The callback routine must conform to \r
66  *                            the following prototype:\r
67  * \r
68  *                        int (*fun_I2cWrite)(  \r
69  *                                void * pCallbackContext,\r
70  *                                unsigned char ChipAddr,\r
71  *                                unsigned long cbBuf, \r
72  *                                unsigned char* pBuf\r
73  *                             );\r
74  *\r
75  *                        The callback routine parameters are as follows:\r
76  *\r
77  *                        pCallbackContext [in] - A pointer to a caller-supplied \r
78  *                                                context area as specified in the\r
79  *                                                CallbackContext parameter of \r
80  *                                                SetupI2cWriteCallback. \r
81  *                        ChipAddr         [in] - The i2c chip address.\r
82  *                        cbBuf            [in] - The size of the input buffer, in bytes.\r
83  *                        pBuf             [in] - A pointer to the input buffer that contains \r
84  *                                                the data required to perform the operation.\r
85  *\r
86  *\r
87  *    cbMaxWriteBufSize [in] - Specify the maximux transfer size for a I2c continue \r
88  *                            writing with 'STOP'. This is limited in I2C bus Master\r
89  *                            device. The size can not less then 3 since Channel \r
90  *                            requires 2 address bytes plus a data byte.\r
91  *                              \r
92  *\r
93  *\r
94  * RETURN\r
95  *      None\r
96  *\r
97  */\r
98 void SetupI2cWriteCallback( void * pCallbackContext,\r
99                             fun_I2cWrite         I2cWritePtr,\r
100                             unsigned long        cbMaxWriteBufSize);\r
101 \r
102 \r
103 /*\r
104  * Set the SetupI2cWriteThenRead callback function.\r
105  * \r
106  * PARAMETERS\r
107  *  \r
108  *    pCallbackContext    [in] - A pointer to a caller-defined structure of data items\r
109  *                               to be passed as the context parameter of the callback\r
110  *                               routine each time it is called. \r
111  *\r
112  *    I2cWriteThenReadPtr [in] - A pointer to a i2cwirte callback routine, which is to \r
113  *                               write I2C data. The callback routine must conform to \r
114  *                               the following prototype:\r
115  *\r
116  *                        int (*fun_I2cWriteThenRead)(  \r
117  *                                void * pCallbackContext,\r
118  *                                unsigned char ChipAddr,\r
119  *                                unsigned long cbBuf, \r
120  *                                unsigned char* pBuf\r
121  *                             );\r
122  *\r
123  *                        The callback routine parameters are as follows:\r
124  *\r
125  *                         pCallbackContext [in] - A pointer to a caller-supplied \r
126  *                                                 context area as specified in the\r
127  *                                                 CallbackContext parameter of \r
128  *                                                 SetupI2cWriteCallback. \r
129  *                         ChipAddr         [in] - The i2c chip address.\r
130  *                         cbBuf            [in] - The size of the input buffer, in bytes.\r
131  *                         pBuf             [in] - A pointer to the input buffer that contains \r
132  *                                                 the data required to perform the operation.\r
133  *\r
134  * RETURN\r
135  *  \r
136  *    If the operation completes successfully, the return value is ERRNO_NOERR.\r
137  *    Otherwise, return ERRON_* error code. \r
138  *\r
139  */\r
140 void SetupI2cWriteThenReadCallback( void * pCallbackContext,\r
141                 fun_I2cWriteThenRead I2cWriteThenReadPtr);\r
142 \r
143 \r
144 void SetupMemoryBuffer(void * pAllocedMemoryBuffer);\r
145 \r
146 \r
147 /*\r
148  * Download Firmware to Channel.\r
149  * \r
150  * PARAMETERS\r
151  *  \r
152  *    pRomData            [in] - A pointer fo the input buffer that contains rom data.\r
153  *\r
154  * RETURN\r
155  *  \r
156  *    If the operation completes successfully, the return value is ERRNO_NOERR.\r
157  *    Otherwise, return ERRON_* error code. \r
158  * \r
159  * REMARKS\r
160  *  \r
161  *    You need to set up both I2cWrite and I2cWriteThenRead callback function by calling \r
162  *    SetupI2cWriteCallback and SetupI2cWriteThenReadCallback before you call this function.\r
163  */\r
164 int DownloadFW(const unsigned char *const pRomData);\r
165 \r
166 /*\r
167  * Apply the extra DSP changes from FW file.\r
168  * \r
169  * PARAMETERS\r
170  *  \r
171  *    pRomData            [in] - A pointer fo the input buffer that contains rom data.\r
172  *\r
173  * RETURN\r
174  *  \r
175  *    If the operation completes successfully, the return value is ERRNO_NOERR.\r
176  *    Otherwise, return ERRON_* error code. \r
177  * \r
178  * REMARKS\r
179  *  \r
180  *    You need to set up both I2C/SPI Write and I2C/SPI WriteThenRead callback function \r
181  *    by calling SetupI2cSpiWriteCallback and SetupI2cSpiWriteThenReadCallback before you call \r
182  *    this function.\r
183  */\r
184 int ApplyDSPChanges(const unsigned char *const pRom);\r
185 \r
186 #ifdef __cplusplus\r
187 }\r
188 #endif \r
189 \r
190 \r
191 /*Error codes*/\r
192 #define ERRNO_NOERR                 0\r
193 #define ERRNO_SRC_FILE_NOT_EXIST    101\r
194 #define ERRNO_WRITE_FILE_FAILED     102\r
195 #define ERRNO_INVALID_DATA          103\r
196 #define ERRNO_CHECKSUM_FAILED       104\r
197 #define ERRNO_FAILED                105\r
198 #define ERRNO_INVALID_PARAMETER     106\r
199 #define ERRNO_NOMEM                 107\r
200 #define ERRNO_I2CFUN_NOT_SET        108\r
201 #define ERRNO_UPDATE_MEMORY_FAILED  109\r
202 #define ERRNO_DEVICE_NOT_RESET      110\r
203 #define ERRNO_DEVICE_OUT_OF_CONTROL 111\r
204 #define ERRNO_DEVICE_DSP_LOCKUP     112\r
205 \r
206 \r