source: svn/trunk/newcon3bcm2_21bu/magnum/basemodules/reg/breg_i2c.h @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 17.8 KB
Line 
1/***************************************************************************
2 *         Copyright (c) 2003-2011, Broadcom Corporation
3 *         All Rights Reserved
4 *         Confidential Property of Broadcom Corporation
5 *
6 *      THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *      AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *      EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: breg_i2c.h $
11 * $brcm_Revision: Hydra_Software_Devel/22 $
12 * $brcm_Date: 3/21/11 4:04p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/basemodules/reg/breg_i2c.h $
19 *
20 * Hydra_Software_Devel/22   3/21/11 4:04p agin
21 * SW7346-96:  Add additional prototypes for read and write sw i2c.
22 *
23 * Hydra_Software_Devel/21   10/4/10 3:39p adtran
24 * SW35230-1525: add WriteRead atomic operation
25 *
26 * Hydra_Software_Devel/20   3/24/10 11:46a vle
27 * SW7601-171: Add BI2C_P_SetupHdmiHwAccess to set up I2C for HDMI HDCP
28 * auto Ri/Pj link integrity check feature
29 *
30 * Hydra_Software_Devel/SW7601-171/1   3/9/10 3:22p vle
31 * SW7601-171: Add BI2C_P_SetupHdmiHwAccess to set up I2C for HDMI HDCP
32 * auto Ri/Pj link integrity check feature
33 *
34 * Hydra_Software_Devel/19   2/5/09 1:08p vle
35 * PR51682: Add declarations for BREG_I2C_ReadSwEDDC
36 *
37 * Hydra_Software_Devel/18   12/9/08 11:59a mward
38 * PR48987: Add declarations for some  I2C bit-bang functions now used by
39 * bhdm.
40 *
41 * Hydra_Software_Devel/17   4/24/08 10:17a farshidf
42 * PR41729: correct the compile
43 *
44 * Hydra_Software_Devel/16   4/23/08 6:27p farshidf
45 * PR41729: update the function name
46 *
47 * Hydra_Software_Devel/15   4/23/08 6:23p farshidf
48 * PR41729: Add BREG_I2C_ReadNoAddrNoAck_Func
49 *
50 * Hydra_Software_Devel/14   4/18/05 10:46a agin
51 * PR14828: add read and write no ack functions.
52 *
53 * Hydra_Software_Devel/13   3/14/05 5:51p agin
54 * PR14351: Fassl's changes
55 *
56 * Hydra_Software_Devel/12   3/2/05 5:49p agin
57 * PR14318:  Added support for I2C write for NVRAM devices.
58 *
59 * Hydra_Software_Devel/11   7/8/04 2:23p brianlee
60 * PR11845: Add I2C API for 3-byte sub address.
61 *
62 * Hydra_Software_Devel/10   1/13/04 5:02p brianlee
63 * PR9268: Make write structures constant.
64 *
65 * Hydra_Software_Devel/9   9/12/03 4:58p brianlee
66 * Add chip address to EDDC read/write functions.
67 *
68 * Hydra_Software_Devel/8   9/11/03 10:59a brianlee
69 * Modified function definitions to match I2C definitions.
70 *
71 * Hydra_Software_Devel/7   8/22/03 2:52p marcusk
72 * Updated with latest changes discussed in the UPG design review.
73 *
74 * Hydra_Software_Devel/6   5/30/03 12:04p marcusk
75 * Updated documentation to use Open rather than Create to be more
76 * consistant.
77 *
78 * Hydra_Software_Devel/5   3/31/03 1:20p marcusk
79 * Updated with comments on threadsafety
80 *
81 * Hydra_Software_Devel/4   3/31/03 10:32a marcusk
82 * Updated comments.
83 *
84 * Hydra_Software_Devel/3   3/31/03 9:42a marcusk
85 * Updated with comments.
86 *
87 * Hydra_Software_Devel/2   3/10/03 2:39p marcusk
88 * Removed const keyword from read routines (copy paste error).
89 *
90 * Hydra_Software_Devel/1   3/5/03 5:13p marcusk
91 * Initial version.
92 *
93 ***************************************************************************/
94
95/*= Module Overview ********************************************************
96This module provides a standard abstraction API for accessing I2C registers.
97Several I2C busses may exist on a single platform. Some may be hardware based,
98while others software based (using GPIO pins). In order to hide the
99specific implementation of the I2C bus from a PortingInterface this I2C
100register access abstraction is used.
101
102---++++ 7 or 10 Bit I2C Chip Addresses
103For all I2C functions, the chipAddr parameter is always used as the
104*un-shifted* 7 bit (bits 15:7 = 0) or 10 bit (bits 15:10 = 0) chip address.
105If (bits 9:7 == 0) then 7 bit addressing is used by default. Some I2C
106implementations will return errors for 10 bit chip addresses (for example
107if a hardware I2C implementation does not support 10 bit chip addresses).
108
109---++++ Non 8-Bit Sub-Address Handling
110Although most I2C devices use 8 or 16 bit sub-addresses, some may require
111larger sub addresses. These devices must be use the BREG_I2C_WriteNoAddr and
112BREG_I2C_ReadNoAddr in order to form larger sub-addresses.
113
114The following example shows how to access read from a device with a 32 bit sub
115address:
116
117<verbatim>
118BERR_Code BXXX_ReadRegister(
119                        BREG_I2C_Handle cntx,
120                        uint16_t chipAddr,
121                        uint32_t subAddr,
122                        uint8_t *pData,
123                        size_t length )
124{
125   BREG_I2C_WriteNoAddr(cntx, chipAddr, &subAddr, sizeof(subAddr) );
126   BREG_I2C_ReadNoAddr(cntx, chipAddr, pData, length);
127}
128</verbatim>
129
130Writing to a device with a non 8 or 16 bit sub address is slightly different;
131you need to pre-pend your data with the sub address you wish to write.
132
133---++++ I2C Register Handles
134Hardware and software I2C implementations must follow the defined function
135prototype definitions. All I2C PortingInterfaces supply the a function
136that initializes a standard BREG_I2C_Handle (and fills it with function
137pointers provided by the specific I2C PortingInterfaces implementation).
138Please refer to the specific I2C PortingInterface implementations for more
139details.
140
141An example of this type of function would be:
142
143<verbatim>
144BERR_Code BI2C_Open( BI2C_Handle I2cHandle, BREG_I2C_Handle *pI2cRegHandle );
145</verbatim>
146
147This handle should be created during initialization and passed to the
148appropriate porting interfaces.  The porting interfaces in turn pass
149this handle to the abstract I2C functions when then call the appropriate
150I2C implementation though function pointers contained in the BREG_I2C_Handle.
151
152---++++ Handling ThreadSafe with I2C
153Since multiple modules (PortingInterface and otherwise) may be sharing the
154same I2C bus, any function calls to the modules in question must be serialized
155to prevent thread collisions.
156
157        1 All calls to the modules sharing the same I2C handle must be protected
158          through the use of a mutex.  This protection must be handled by the
159          upper level software (driver, middleware, etc).
160        1 Upper level software can create an additional layer between the I2C
161          RegisterInterface and the corresponding I2C PortingInterface instance
162          that implements the I2C register access.  In this layer a mutex is
163          used to protect all I2C accesses.  This could easily be done
164          using the BREG_I2C_Impl structure.
165***************************************************************************/
166
167#ifndef BREG_I2C_H
168#define BREG_I2C_H
169
170#ifdef __cplusplus
171extern "C" {
172#endif
173
174/*
175Summary:
176This is an opaque handle that is used for I2C register functions.
177*/
178typedef struct BREG_I2C_Impl *BREG_I2C_Handle;
179
180/*
181Summary:
182This function writes a programmable number of I2C registers using an 8 bit
183sub address.
184*/
185BERR_Code BREG_I2C_Write(
186                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
187                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
188                                                 uint8_t subAddr, /* 8 bit sub address */
189                                                 const uint8_t *pData, /* pointer to data to write */
190                                                 size_t length /* number of bytes to write */
191                                                 );
192
193/*
194Summary:
195This function uses software "bit-bang" to write a programmable number of I2C registers using an 8 bit
196sub address.
197*/
198BERR_Code BREG_I2C_WriteSw(
199                            BREG_I2C_Handle i2cHandle, /* I2C Handle */
200                            uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
201                            uint8_t subAddr, /* 8 bit sub address */
202                            const uint8_t *pData, /* pointer to data to write */
203                            size_t length /* number of bytes to write */
204                          );
205
206/*
207Summary:
208This function writes a programmable number of I2C registers using an 8 bit
209sub address and no ack.
210*/
211BERR_Code BREG_I2C_WriteNoAck(
212                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
213                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
214                                                 uint8_t subAddr, /* 8 bit sub address */
215                                                 const uint8_t *pData, /* pointer to data to write */
216                                                 size_t length /* number of bytes to write */
217                                                 );
218
219/*
220Summary:
221This function writes a programmable number of I2C registers using a 16 bit
222sub address.
223*/
224BERR_Code BREG_I2C_WriteA16(
225                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
226                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
227                                                 uint16_t subAddr, /* 16 bit sub address */
228                                                 const uint8_t *pData, /* pointer to data to write */
229                                                 size_t length /* number of bytes to write */
230                                                 );
231
232/*
233Summary:
234This function uses software "bit-bang" to write a programmable number of I2C registers using a 16 bit
235sub address.
236*/
237BERR_Code BREG_I2C_WriteSwA16(
238                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
239                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
240                                                 uint16_t subAddr, /* 16 bit sub address */
241                                                 const uint8_t *pData, /* pointer to data to write */
242                                                 size_t length /* number of bytes to write */
243                                                 );
244
245/*
246Summary:
247This function writes a programmable number of I2C registers using a 24 bit
248sub address.
249*/
250BERR_Code BREG_I2C_WriteA24(
251                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
252                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
253                                                 uint32_t subAddr, /* 24 bit sub address */
254                                                 const uint8_t *pData, /* pointer to data to write */
255                                                 size_t length /* number of bytes to write */
256                                                 );
257
258/*
259Summary:
260This function uses software "bit-bang" to write a programmable number of I2C registers using a 24 bit
261sub address.
262*/
263BERR_Code BREG_I2C_WriteSwA24(
264                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
265                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
266                                                 uint32_t subAddr, /* 24 bit sub address */
267                                                 const uint8_t *pData, /* pointer to data to write */
268                                                 size_t length /* number of bytes to write */
269                                                 );
270
271/*
272Summary:
273This function writes a programmable number of I2C registers without a sub address
274(raw write).
275*/
276BERR_Code BREG_I2C_WriteNoAddr(
277                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
278                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
279                                                 const uint8_t *pData, /* pointer to data to write */
280                                                 size_t length /* number of bytes to write */
281                                             );
282
283/*
284Summary:
285This function writes a programmable number of I2C registers without a sub address
286(raw write), and without waiting for an ack.
287*/
288BERR_Code BREG_I2C_WriteNoAddrNoAck(
289                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
290                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
291                                                 const uint8_t *pData, /* pointer to data to write */
292                                                 size_t length /* number of bytes to write */
293                                             );
294
295/*
296Summary:
297This function writes an I2C NVRAM device using an 8 bit sub address.
298*/
299BERR_Code BREG_I2C_WriteNvram(
300                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
301                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
302                                                 uint8_t subAddr, /* 8 bit sub address */
303                                                 const uint8_t *pData, /* pointer to data to write */
304                                                 size_t length /* number of bytes to write */
305                                                 );
306
307/*
308Summary:
309This function reads a programmable number of I2C registers using an 8 bit
310sub address.
311*/
312BERR_Code BREG_I2C_Read(
313                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
314                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
315                                                 uint8_t subAddr, /* 8 bit sub address */
316                                                 uint8_t *pData, /* pointer to memory location to store read data */
317                                                 size_t length /* number of bytes to read */
318                                                 );
319
320/*
321Summary:
322This function uses software "bit-bang" to read a programmable number of I2C registers using an 8 bit
323sub address.
324*/
325BERR_Code BREG_I2C_ReadSw(
326                           BREG_I2C_Handle i2cHandle, /* I2C Handle */
327                           uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
328                           uint8_t subAddr, /* 8 bit sub address */
329                           uint8_t *pData, /* pointer to memory location to store read data */
330                           size_t length /* number of bytes to read */
331                          );
332
333/*
334Summary:
335This function reads a programmable number of I2C registers using an 8 bit
336sub address and no ack..
337*/
338BERR_Code BREG_I2C_ReadNoAck(
339                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
340                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
341                                                 uint8_t subAddr, /* 8 bit sub address */
342                                                 uint8_t *pData, /* pointer to memory location to store read data */
343                                                 size_t length /* number of bytes to read */
344                                                 );
345
346/*
347Summary:
348This function reads a programmable number of I2C registers using a 16 bit
349sub address.
350*/
351BERR_Code BREG_I2C_ReadA16(
352                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
353                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
354                                                 uint16_t subAddr, /* 16 bit sub address */
355                                                 uint8_t *pData, /* pointer to memory location to store read data */
356                                                 size_t length /* number of bytes to read */
357                                                 );
358
359/*
360Summary:
361This function uses software "bit-bang" to read a programmable number of I2C registers using a 16 bit
362sub address.
363*/
364BERR_Code BREG_I2C_ReadSwA16(
365                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
366                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
367                                                 uint16_t subAddr, /* 16 bit sub address */
368                                                 uint8_t *pData, /* pointer to memory location to store read data */
369                                                 size_t length /* number of bytes to read */
370                                                 );
371
372/*
373Summary:
374This function reads a programmable number of I2C registers using a 24 bit
375sub address.
376*/
377BERR_Code BREG_I2C_ReadA24(
378                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
379                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
380                                                 uint32_t subAddr, /* 32 bit sub address */
381                                                 uint8_t *pData, /* pointer to memory location to store read data */
382                                                 size_t length /* number of bytes to read */
383                                                 );
384
385/*
386Summary:
387This function uses software "bit-bang" to read a programmable number of I2C registers using a 24 bit
388sub address.
389*/
390BERR_Code BREG_I2C_ReadSwA24(
391                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
392                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
393                                                 uint32_t subAddr, /* 32 bit sub address */
394                                                 uint8_t *pData, /* pointer to memory location to store read data */
395                                                 size_t length /* number of bytes to read */
396                                                 );
397
398/*
399Summary:
400This function reads a programmable number of I2C registers without a sub address
401(raw read).
402*/
403BERR_Code BREG_I2C_ReadNoAddr(
404                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
405                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
406                                                 uint8_t *pData, /* pointer to memory location to store read data */
407                                                 size_t length /* number of bytes to read */
408                                                 );
409
410/*
411Summary:
412This function uses software "bit-bang" to read a programmable number of I2C registers without a sub address
413(raw read).
414*/
415BERR_Code BREG_I2C_ReadSwNoAddr(
416                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
417                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
418                                 uint8_t *pData, /* pointer to memory location to store read data */
419                                 size_t length /* number of bytes to read */
420                                );
421
422/*
423Summary:
424This function reads a programmable number of I2C registers without a sub address and no Ack
425(raw read).
426*/
427
428BERR_Code BREG_I2C_ReadNoAddrNoAck(
429                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
430                                                 uint16_t chipAddr, /* 7 or 10 bit chip address (_unshifted_) */
431                                                 uint8_t *pData, /* pointer to memory location to store read data */
432                                                 size_t length /* number of bytes to read */
433                                                 );
434/*
435Summary:
436This function is used to perform an Enhanced Display Data Channel read protocol.
437*/
438BERR_Code BREG_I2C_ReadEDDC(
439                                                BREG_I2C_Handle i2cHandle,      /* I2C Handle */
440                                                uint8_t chipAddr,                       /* chip address */
441                                                uint8_t segment,                        /* EDDC segment pointer */
442                                                uint8_t subAddr,                        /* 8-bit sub address */
443                                                uint8_t *pData,                         /* pointer to memory location to store read data  */
444                                                size_t length                           /* number of bytes to read */
445                                                );
446
447/*
448Summary:
449This function uses software "bit-bang" to read an Enhanced Display Data Channel read protocol.
450*/
451BERR_Code BREG_I2C_ReadSwEDDC(
452                                                BREG_I2C_Handle i2cHandle,      /* I2C Handle */
453                                                uint8_t chipAddr,                       /* chip address */
454                                                uint8_t segment,                        /* EDDC segment pointer */
455                                                uint8_t subAddr,                        /* 8-bit sub address */
456                                                uint8_t *pData,                         /* pointer to memory location to store read data  */
457                                                size_t length                           /* number of bytes to read */
458                                                );
459
460/*
461Summary:
462This function is used to perform an Enhanced Display Data Channel write protocol.
463*/
464BERR_Code BREG_I2C_WriteEDDC(
465                                                BREG_I2C_Handle i2cHandle,      /* I2C Handle */
466                                                uint8_t chipAddr,                       /* chip address */
467                                                uint8_t segment,                        /* EDDC segment pointer */
468                                                uint8_t subAddr,                        /* 8-bit sub address */
469                                                const uint8_t *pData,           /* pointer to data to write */
470                                                size_t length                           /* number of bytes to write */
471                                                );
472
473
474/*
475Summary:
476This function set up i2c for HDMI HDCP HW Ri/Pj Link integrity check
477*/
478BERR_Code BREG_I2C_SetupHdmiHwAccess(
479                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
480                                                 uint32_t dataTransferFormat,   /* Data Transfer Format */
481                                                 uint32_t cnt1,   /* Counter 1 value */
482                                                 uint32_t cnt2    /* Counter 2 value */
483                                                 );
484
485
486/*
487Summary:
488This function is used to perform write and read as an atomic operation.
489*/
490BERR_Code BREG_I2C_WriteRead(
491                                                 BREG_I2C_Handle i2cHandle, /* I2C Handle */
492                                                 uint16_t chipAddr,                  /* 7 or 10 bit chip address (_unshifted_) */
493                                                 uint8_t subAddr,                    /* 8 bit sub address */
494                                                 const uint8_t *pWriteData,     /* pointer to data to write */
495                                                 size_t writeLength,                /* number of bytes to write */
496                                                 const uint8_t *pReadData,      /* pointer to data to write */
497                                                 size_t readLength                  /* number of bytes to write */
498                                                 );
499
500
501#ifdef __cplusplus
502}
503#endif
504 
505#endif
506/* End of File */
Note: See TracBrowser for help on using the repository browser.