1 /****************************************************************************************
\r
2 *****************************************************************************************
\r
4 *** Copyright (c) 2011 ***
\r
6 *** Conexant Systems, Inc. ***
\r
8 *** All Rights Reserved ***
\r
10 *** CONFIDENTIAL ***
\r
12 *** NO DISSEMINATION OR USE WITHOUT PRIOR WRITTEN PERMISSION ***
\r
14 *****************************************************************************************
\r
20 ** This code is to download the firmware to CX20709 device via I2C bus.
\r
24 ** Conexant Channel CX20709
\r
30 ********************************************************************************
\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
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
50 typedef int (*fun_I2cWrite)( void * pCallbackContext,
\r
51 unsigned char ChipAddr,
\r
52 unsigned long cbBuf,
\r
53 unsigned char* pBuf);
\r
56 * Set the I2cWrite callback function.
\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
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
68 * int (*fun_I2cWrite)(
\r
69 * void * pCallbackContext,
\r
70 * unsigned char ChipAddr,
\r
71 * unsigned long cbBuf,
\r
72 * unsigned char* pBuf
\r
75 * The callback routine parameters are as follows:
\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
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
98 void SetupI2cWriteCallback( void * pCallbackContext,
\r
99 fun_I2cWrite I2cWritePtr,
\r
100 unsigned long cbMaxWriteBufSize);
\r
104 * Set the SetupI2cWriteThenRead callback function.
\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
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
116 * int (*fun_I2cWriteThenRead)(
\r
117 * void * pCallbackContext,
\r
118 * unsigned char ChipAddr,
\r
119 * unsigned long cbBuf,
\r
120 * unsigned char* pBuf
\r
123 * The callback routine parameters are as follows:
\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
136 * If the operation completes successfully, the return value is ERRNO_NOERR.
\r
137 * Otherwise, return ERRON_* error code.
\r
140 void SetupI2cWriteThenReadCallback( void * pCallbackContext,
\r
141 fun_I2cWriteThenRead I2cWriteThenReadPtr);
\r
144 void SetupMemoryBuffer(void * pAllocedMemoryBuffer);
\r
148 * Download Firmware to Channel.
\r
152 * pRomData [in] - A pointer fo the input buffer that contains rom data.
\r
156 * If the operation completes successfully, the return value is ERRNO_NOERR.
\r
157 * Otherwise, return ERRON_* error code.
\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
164 int DownloadFW(const unsigned char *const pRomData);
\r
167 * Apply the extra DSP changes from FW file.
\r
171 * pRomData [in] - A pointer fo the input buffer that contains rom data.
\r
175 * If the operation completes successfully, the return value is ERRNO_NOERR.
\r
176 * Otherwise, return ERRON_* error code.
\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
184 int ApplyDSPChanges(const unsigned char *const pRom);
\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