| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2010, 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.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/18 $ |
|---|
| 12 | * $brcm_Date: 10/4/10 3:39p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/basemodules/reg/breg_i2c.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/18 10/4/10 3:39p adtran |
|---|
| 21 | * SW35230-1525: add WriteRead atomic operation |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/17 3/24/10 11:48a vle |
|---|
| 24 | * SW7601-171: Add BI2C_P_SetupHdmiHwAccess to set up I2C for HDMI HDCP |
|---|
| 25 | * auto Ri/Pj link integrity check feature |
|---|
| 26 | * |
|---|
| 27 | * Hydra_Software_Devel/SW7601-171/1 3/9/10 3:22p vle |
|---|
| 28 | * SW7601-171: Add BI2C_P_SetupHdmiHwAccess to set up I2C for HDMI HDCP |
|---|
| 29 | * auto Ri/Pj link integrity check feature |
|---|
| 30 | * |
|---|
| 31 | * Hydra_Software_Devel/16 10/22/09 3:01p agin |
|---|
| 32 | * SW7405-2686: Warn users to switch to new way of handling sw i2c. |
|---|
| 33 | * |
|---|
| 34 | * Hydra_Software_Devel/15 12/13/08 3:44p agin |
|---|
| 35 | * PR42305: Support i2c via gpio for read EDDC. |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/14 11/21/08 10:56a agin |
|---|
| 38 | * PR49585: Add sw i2c support for 7601. |
|---|
| 39 | * |
|---|
| 40 | * Hydra_Software_Devel/13 5/4/08 1:40a agin |
|---|
| 41 | * PR42305: Support i2c via gpio. |
|---|
| 42 | * |
|---|
| 43 | * Hydra_Software_Devel/12 4/23/08 6:27p farshidf |
|---|
| 44 | * PR41729: Add BERR_Code BI2C_P_ReadNoAddrNoAck |
|---|
| 45 | * |
|---|
| 46 | * Hydra_Software_Devel/11 4/18/05 10:46a agin |
|---|
| 47 | * PR14828: add read and write no ack functions. |
|---|
| 48 | * |
|---|
| 49 | * Hydra_Software_Devel/10 4/4/05 10:18a agin |
|---|
| 50 | * PR14351: Added BREG_I2C_WriteNoAddrNoAck function. |
|---|
| 51 | * |
|---|
| 52 | * Hydra_Software_Devel/9 3/2/05 5:49p agin |
|---|
| 53 | * PR14318: Added support for I2C write for NVRAM devices. |
|---|
| 54 | * |
|---|
| 55 | * Hydra_Software_Devel/8 7/8/04 2:22p brianlee |
|---|
| 56 | * PR11845: Add I2C API for 3-byte sub address. |
|---|
| 57 | * |
|---|
| 58 | * Hydra_Software_Devel/7 1/13/04 5:02p brianlee |
|---|
| 59 | * PR9268: Make write structures constant. |
|---|
| 60 | * |
|---|
| 61 | * Hydra_Software_Devel/6 9/12/03 5:05p brianlee |
|---|
| 62 | * Add chip address to function call. |
|---|
| 63 | * |
|---|
| 64 | * Hydra_Software_Devel/5 9/12/03 4:58p brianlee |
|---|
| 65 | * Add chip address to EDDC read/write functions. |
|---|
| 66 | * |
|---|
| 67 | * Hydra_Software_Devel/4 9/11/03 10:59a brianlee |
|---|
| 68 | * Modified function definitions to match I2C definitions. |
|---|
| 69 | * |
|---|
| 70 | * Hydra_Software_Devel/3 8/22/03 2:52p marcusk |
|---|
| 71 | * Updated with latest changes discussed in the UPG design review. |
|---|
| 72 | * |
|---|
| 73 | * Hydra_Software_Devel/2 3/10/03 2:39p marcusk |
|---|
| 74 | * Removed const keyword from read routines (copy paste error). |
|---|
| 75 | * |
|---|
| 76 | * Hydra_Software_Devel/1 3/5/03 5:13p marcusk |
|---|
| 77 | * Initial version. |
|---|
| 78 | * |
|---|
| 79 | ***************************************************************************/ |
|---|
| 80 | #include "bstd.h" |
|---|
| 81 | #include "breg_i2c.h" |
|---|
| 82 | #include "breg_i2c_priv.h" |
|---|
| 83 | |
|---|
| 84 | BDBG_MODULE(breg_i2c); |
|---|
| 85 | |
|---|
| 86 | BERR_Code BREG_I2C_Write(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint8_t subAddr, const uint8_t *pData, size_t length) |
|---|
| 87 | { |
|---|
| 88 | return (i2cHandle->BREG_I2C_Write_Func)( i2cHandle->context, chipAddr, subAddr, pData, length ); |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | BERR_Code BREG_I2C_WriteSw(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint8_t subAddr, const uint8_t *pData, size_t length) |
|---|
| 92 | { |
|---|
| 93 | BDBG_WRN(("BREG_I2C_WriteSw() will be removed in the future. To prepare for this, call BI2C_OpenChannel() with the softI2c field set to true. Then call BREG_I2C_Write() instead.\n")); |
|---|
| 94 | return (i2cHandle->BREG_I2C_WriteSw_Func)( i2cHandle->context, chipAddr, subAddr, pData, length ); |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | BERR_Code BREG_I2C_WriteNoAck(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint8_t subAddr, const uint8_t *pData, size_t length) |
|---|
| 98 | { |
|---|
| 99 | return (i2cHandle->BREG_I2C_WriteNoAck_Func)( i2cHandle->context, chipAddr, subAddr, pData, length ); |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | BERR_Code BREG_I2C_WriteA16(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint16_t subAddr, const uint8_t *pData, size_t length) |
|---|
| 103 | { |
|---|
| 104 | return (i2cHandle->BREG_I2C_WriteA16_Func)( i2cHandle->context, chipAddr, subAddr, pData, length ); |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | BERR_Code BREG_I2C_WriteSwA16(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint16_t subAddr, const uint8_t *pData, size_t length) |
|---|
| 108 | { |
|---|
| 109 | BDBG_WRN(("BREG_I2C_WriteSwA16() will be removed in the future. To prepare for this, call BI2C_OpenChannel() with the softI2c field set to true. Then call BREG_I2C_WriteA16() instead.\n")); |
|---|
| 110 | return (i2cHandle->BREG_I2C_WriteSwA16_Func)( i2cHandle->context, chipAddr, subAddr, pData, length ); |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | BERR_Code BREG_I2C_WriteA24(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint32_t subAddr, const uint8_t *pData, size_t length) |
|---|
| 114 | { |
|---|
| 115 | return (i2cHandle->BREG_I2C_WriteA24_Func)( i2cHandle->context, chipAddr, subAddr, pData, length ); |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | BERR_Code BREG_I2C_WriteNoAddr(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, const uint8_t *pData, size_t length) |
|---|
| 119 | { |
|---|
| 120 | return (i2cHandle->BREG_I2C_WriteNoAddr_Func)( i2cHandle->context, chipAddr, pData, length ); |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | BERR_Code BREG_I2C_WriteSwNoAddr(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, const uint8_t *pData, size_t length) |
|---|
| 124 | { |
|---|
| 125 | BDBG_WRN(("BREG_I2C_WriteSwNoAddr() will be removed in the future. To prepare for this, call BI2C_OpenChannel() with the softI2c field set to true. Then call BREG_I2C_WriteNoAddr() instead.\n")); |
|---|
| 126 | return (i2cHandle->BREG_I2C_WriteSwNoAddr_Func)( i2cHandle->context, chipAddr, pData, length ); |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | BERR_Code BREG_I2C_WriteNoAddrNoAck(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, const uint8_t *pData, size_t length) |
|---|
| 130 | { |
|---|
| 131 | return (i2cHandle->BREG_I2C_WriteNoAddrNoAck_Func)( i2cHandle->context, chipAddr, pData, length ); |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | BERR_Code BREG_I2C_WriteNvram(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint8_t subAddr, const uint8_t *pData, size_t length) |
|---|
| 135 | { |
|---|
| 136 | return (i2cHandle->BREG_I2C_WriteNvram_Func)( i2cHandle->context, chipAddr, subAddr, pData, length ); |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | BERR_Code BREG_I2C_Read(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint8_t subAddr, uint8_t *pData, size_t length) |
|---|
| 140 | { |
|---|
| 141 | return (i2cHandle->BREG_I2C_Read_Func)( i2cHandle->context, chipAddr, subAddr, pData, length ); |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | BERR_Code BREG_I2C_ReadSw(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint8_t subAddr, uint8_t *pData, size_t length) |
|---|
| 145 | { |
|---|
| 146 | BDBG_WRN(("BREG_I2C_ReadSw() will be removed in the future. To prepare for this, call BI2C_OpenChannel() with the softI2c field set to true. Then call BREG_I2C_Read() instead.\n")); |
|---|
| 147 | return (i2cHandle->BREG_I2C_ReadSw_Func)( i2cHandle->context, chipAddr, subAddr, pData, length ); |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | BERR_Code BREG_I2C_ReadNoAck(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint8_t subAddr, uint8_t *pData, size_t length) |
|---|
| 151 | { |
|---|
| 152 | return (i2cHandle->BREG_I2C_ReadNoAck_Func)( i2cHandle->context, chipAddr, subAddr, pData, length ); |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | BERR_Code BREG_I2C_ReadA16(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint16_t subAddr, uint8_t *pData, size_t length) |
|---|
| 156 | { |
|---|
| 157 | return (i2cHandle->BREG_I2C_ReadA16_Func)( i2cHandle->context, chipAddr, subAddr, pData, length ); |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | BERR_Code BREG_I2C_ReadSwA16(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint16_t subAddr, uint8_t *pData, size_t length) |
|---|
| 161 | { |
|---|
| 162 | BDBG_WRN(("BREG_I2C_ReadSwA16() will be removed in the future. To prepare for this, call BI2C_OpenChannel() with the softI2c field set to true. Then call BREG_I2C_ReadA16() instead.\n")); |
|---|
| 163 | return (i2cHandle->BREG_I2C_ReadSwA16_Func)( i2cHandle->context, chipAddr, subAddr, pData, length ); |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | BERR_Code BREG_I2C_ReadA24(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint32_t subAddr, uint8_t *pData, size_t length) |
|---|
| 167 | { |
|---|
| 168 | return (i2cHandle->BREG_I2C_ReadA24_Func)( i2cHandle->context, chipAddr, subAddr, pData, length ); |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | BERR_Code BREG_I2C_ReadNoAddr(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint8_t *pData, size_t length) |
|---|
| 172 | { |
|---|
| 173 | return (i2cHandle->BREG_I2C_ReadNoAddr_Func)( i2cHandle->context, chipAddr, pData, length ); |
|---|
| 174 | } |
|---|
| 175 | |
|---|
| 176 | BERR_Code BREG_I2C_ReadSwNoAddr(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint8_t *pData, size_t length) |
|---|
| 177 | { |
|---|
| 178 | BDBG_WRN(("BREG_I2C_ReadSwNoAddr() will be removed in the future. To prepare for this, call BI2C_OpenChannel() with the softI2c field set to true. Then call BREG_I2C_ReadNoAddr() instead.\n")); |
|---|
| 179 | return (i2cHandle->BREG_I2C_ReadSwNoAddr_Func)( i2cHandle->context, chipAddr, pData, length ); |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | BERR_Code BREG_I2C_ReadNoAddrNoAck(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint8_t *pData, size_t length) |
|---|
| 183 | { |
|---|
| 184 | return (i2cHandle->BREG_I2C_ReadNoAddrNoAck_Func)( i2cHandle->context, chipAddr, pData, length ); |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | BERR_Code BREG_I2C_ReadEDDC(BREG_I2C_Handle i2cHandle, uint8_t chipAddr, uint8_t segment, uint8_t subAddr, uint8_t *pData, size_t length) |
|---|
| 188 | { |
|---|
| 189 | return (i2cHandle->BREG_I2C_ReadEDDC_Func)( i2cHandle->context, chipAddr, segment, subAddr, pData, length ); |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | BERR_Code BREG_I2C_ReadSwEDDC(BREG_I2C_Handle i2cHandle, uint8_t chipAddr, uint8_t segment, uint8_t subAddr, uint8_t *pData, size_t length) |
|---|
| 193 | { |
|---|
| 194 | BDBG_WRN(("BREG_I2C_ReadSwEDDC() will be removed in the future. To prepare for this, call BI2C_OpenChannel() with the softI2c field set to true. Then call BREG_I2C_ReadEDDC() instead.\n")); |
|---|
| 195 | return (i2cHandle->BREG_I2C_ReadSwEDDC_Func)( i2cHandle->context, chipAddr, segment, subAddr, pData, length ); |
|---|
| 196 | } |
|---|
| 197 | |
|---|
| 198 | BERR_Code BREG_I2C_WriteEDDC(BREG_I2C_Handle i2cHandle, uint8_t chipAddr, uint8_t segment, uint8_t subAddr, const uint8_t *pData, size_t length) |
|---|
| 199 | { |
|---|
| 200 | return (i2cHandle->BREG_I2C_WriteEDDC_Func)( i2cHandle->context, chipAddr, segment, subAddr, pData, length ); |
|---|
| 201 | } |
|---|
| 202 | |
|---|
| 203 | BERR_Code BREG_I2C_SetupHdmiHwAccess(BREG_I2C_Handle i2cHandle, uint32_t dataTransferFormat,uint32_t cnt1, uint32_t cnt2) |
|---|
| 204 | { |
|---|
| 205 | return (i2cHandle->BREG_I2C_SetupHdmiHwAccess_Func)( i2cHandle->context, dataTransferFormat, cnt1, cnt2); |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | BERR_Code BREG_I2C_WriteRead(BREG_I2C_Handle i2cHandle, uint16_t chipAddr, uint8_t subAddr, const uint8_t *pWriteData, size_t writeLength, const uint8_t *pReadData, size_t readLength) |
|---|
| 209 | { |
|---|
| 210 | return (i2cHandle->BREG_I2C_WriteRead_Func)( i2cHandle->context, chipAddr, subAddr, pWriteData, writeLength, pReadData, readLength ); |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | /* End of File */ |
|---|