| 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: bgio_pin.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/3 $ |
|---|
| 12 | * $brcm_Date: 6/16/11 5:58p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * |
|---|
| 17 | * Revision History: |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/gio/7038/bgio_pin.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/3 6/16/11 5:58p tdo |
|---|
| 21 | * SWDTV-7592: add BDBG_OBJECT_ASSERT for BGIO. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/2 4/8/08 5:47p tdo |
|---|
| 24 | * PR41205: Add _isr functions to avoid deadlock |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/1 2/24/04 7:17p syang |
|---|
| 27 | * PR 9785: init version |
|---|
| 28 | * |
|---|
| 29 | ***************************************************************************/ |
|---|
| 30 | #include "bgio_priv.h" |
|---|
| 31 | #include "bgio_pin_priv.h" |
|---|
| 32 | #include "berr.h" |
|---|
| 33 | |
|---|
| 34 | BDBG_MODULE(BGIO); |
|---|
| 35 | |
|---|
| 36 | /*************************************************************************** |
|---|
| 37 | * |
|---|
| 38 | * API support functions |
|---|
| 39 | * |
|---|
| 40 | ***************************************************************************/ |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | /*************************************************************************** |
|---|
| 44 | * |
|---|
| 45 | */ |
|---|
| 46 | BERR_Code BGIO_Pin_Create( |
|---|
| 47 | BGIO_Handle hGpio, |
|---|
| 48 | BGIO_PinId ePinId, |
|---|
| 49 | BGIO_Pin_Handle * phPin ) |
|---|
| 50 | { |
|---|
| 51 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 52 | BDBG_OBJECT_ASSERT(hGpio, BGIO); |
|---|
| 53 | |
|---|
| 54 | /* input para validation done in BGIO_P_Pin_Create */ |
|---|
| 55 | eResult = BGIO_P_Pin_Create( hGpio, ePinId, phPin ); |
|---|
| 56 | return BERR_TRACE(eResult); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | /*************************************************************************** |
|---|
| 60 | * |
|---|
| 61 | */ |
|---|
| 62 | BERR_Code BGIO_Pin_Destroy( |
|---|
| 63 | BGIO_Pin_Handle hPin ) |
|---|
| 64 | { |
|---|
| 65 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 66 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 67 | |
|---|
| 68 | /* input para validation done in BGIO_P_Pin_Destroy */ |
|---|
| 69 | eResult = BGIO_P_Pin_Destroy( hPin ); |
|---|
| 70 | return BERR_TRACE(eResult); |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | /*************************************************************************** |
|---|
| 74 | * |
|---|
| 75 | */ |
|---|
| 76 | BERR_Code BGIO_Pin_GetId( |
|---|
| 77 | BGIO_Pin_Handle hPin, |
|---|
| 78 | BGIO_PinId * pePinId ) |
|---|
| 79 | { |
|---|
| 80 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 81 | if (NULL == pePinId) |
|---|
| 82 | { |
|---|
| 83 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | BDBG_ASSERT( BGIO_PinId_eInvalid > hPin->ePinId ); |
|---|
| 87 | *pePinId = hPin->ePinId; |
|---|
| 88 | return BERR_SUCCESS; |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | /*************************************************************************** |
|---|
| 92 | * |
|---|
| 93 | */ |
|---|
| 94 | BERR_Code BGIO_Pin_GetType( |
|---|
| 95 | BGIO_Pin_Handle hPin, |
|---|
| 96 | BGIO_PinType * pePinType ) |
|---|
| 97 | { |
|---|
| 98 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 99 | if (NULL == pePinType) |
|---|
| 100 | { |
|---|
| 101 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | BDBG_ASSERT( BGIO_PinType_eInvalid > hPin->ePinType ); |
|---|
| 105 | *pePinType = hPin->ePinType; |
|---|
| 106 | return BERR_SUCCESS; |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | /*************************************************************************** |
|---|
| 110 | * |
|---|
| 111 | */ |
|---|
| 112 | BERR_Code BGIO_Pin_SetType( |
|---|
| 113 | BGIO_Pin_Handle hPin, |
|---|
| 114 | BGIO_PinType ePinType ) |
|---|
| 115 | { |
|---|
| 116 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 117 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 118 | |
|---|
| 119 | /* input para validation done in BGIO_P_Pin_SetType */ |
|---|
| 120 | eResult = BGIO_P_Pin_SetType( hPin, ePinType, false ); |
|---|
| 121 | return BERR_TRACE(eResult); |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | /*************************************************************************** |
|---|
| 125 | * |
|---|
| 126 | */ |
|---|
| 127 | BERR_Code BGIO_Pin_SetType_isr( |
|---|
| 128 | BGIO_Pin_Handle hPin, |
|---|
| 129 | BGIO_PinType ePinType ) |
|---|
| 130 | { |
|---|
| 131 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 132 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 133 | |
|---|
| 134 | /* input para validation done in BGIO_P_Pin_SetType */ |
|---|
| 135 | eResult = BGIO_P_Pin_SetType( hPin, ePinType, true ); |
|---|
| 136 | return BERR_TRACE(eResult); |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | /*************************************************************************** |
|---|
| 140 | * |
|---|
| 141 | */ |
|---|
| 142 | BERR_Code BGIO_Pin_GetValue( |
|---|
| 143 | BGIO_Pin_Handle hPin, |
|---|
| 144 | BGIO_PinValue * pePinValue ) |
|---|
| 145 | { |
|---|
| 146 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 147 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 148 | |
|---|
| 149 | /* input para validation done in BGIO_P_Pin_GetValue */ |
|---|
| 150 | eResult = BGIO_P_Pin_GetValue( hPin, pePinValue ); |
|---|
| 151 | return BERR_TRACE(eResult); |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | /*************************************************************************** |
|---|
| 155 | * |
|---|
| 156 | */ |
|---|
| 157 | BERR_Code BGIO_Pin_PushPull_SetValue( |
|---|
| 158 | BGIO_Pin_Handle hPin, |
|---|
| 159 | BGIO_PinValue ePinValue ) |
|---|
| 160 | { |
|---|
| 161 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 162 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 163 | |
|---|
| 164 | if (BGIO_PinType_ePushPull != hPin->ePinType) |
|---|
| 165 | { |
|---|
| 166 | eResult = BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 167 | return eResult; |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | /* more input para validation done in BGIO_P_Pin_SetType */ |
|---|
| 171 | eResult = BGIO_P_Pin_SetValue( hPin, ePinValue, false ); |
|---|
| 172 | return BERR_TRACE(eResult); |
|---|
| 173 | } |
|---|
| 174 | |
|---|
| 175 | /*************************************************************************** |
|---|
| 176 | * |
|---|
| 177 | */ |
|---|
| 178 | BERR_Code BGIO_Pin_PushPull_SetValue_isr( |
|---|
| 179 | BGIO_Pin_Handle hPin, |
|---|
| 180 | BGIO_PinValue ePinValue ) |
|---|
| 181 | { |
|---|
| 182 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 183 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 184 | |
|---|
| 185 | if (BGIO_PinType_ePushPull != hPin->ePinType) |
|---|
| 186 | { |
|---|
| 187 | eResult = BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 188 | return eResult; |
|---|
| 189 | } |
|---|
| 190 | |
|---|
| 191 | /* more input para validation done in BGIO_P_Pin_SetType */ |
|---|
| 192 | eResult = BGIO_P_Pin_SetValue( hPin, ePinValue, true ); |
|---|
| 193 | return BERR_TRACE(eResult); |
|---|
| 194 | } |
|---|
| 195 | |
|---|
| 196 | /*************************************************************************** |
|---|
| 197 | * |
|---|
| 198 | */ |
|---|
| 199 | BERR_Code BGIO_Pin_OpenDrain_PullDown( |
|---|
| 200 | BGIO_Pin_Handle hPin ) |
|---|
| 201 | { |
|---|
| 202 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 203 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 204 | |
|---|
| 205 | if (BGIO_PinType_eOpenDrain != hPin->ePinType) |
|---|
| 206 | { |
|---|
| 207 | eResult = BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 208 | return eResult; |
|---|
| 209 | } |
|---|
| 210 | |
|---|
| 211 | /* more input para validation done in BGIO_P_Pin_SetType */ |
|---|
| 212 | eResult = BGIO_P_Pin_SetValue( hPin, BGIO_PinValue_e0, false ); |
|---|
| 213 | return BERR_TRACE(eResult); |
|---|
| 214 | } |
|---|
| 215 | |
|---|
| 216 | /*************************************************************************** |
|---|
| 217 | * |
|---|
| 218 | */ |
|---|
| 219 | BERR_Code BGIO_Pin_OpenDrain_PullDown_isr( |
|---|
| 220 | BGIO_Pin_Handle hPin ) |
|---|
| 221 | { |
|---|
| 222 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 223 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 224 | |
|---|
| 225 | if (BGIO_PinType_eOpenDrain != hPin->ePinType) |
|---|
| 226 | { |
|---|
| 227 | eResult = BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 228 | return eResult; |
|---|
| 229 | } |
|---|
| 230 | |
|---|
| 231 | /* more input para validation done in BGIO_P_Pin_SetType */ |
|---|
| 232 | eResult = BGIO_P_Pin_SetValue( hPin, BGIO_PinValue_e0, true ); |
|---|
| 233 | return BERR_TRACE(eResult); |
|---|
| 234 | } |
|---|
| 235 | |
|---|
| 236 | /*************************************************************************** |
|---|
| 237 | * |
|---|
| 238 | */ |
|---|
| 239 | BERR_Code BGIO_Pin_OpenDrain_Release( |
|---|
| 240 | BGIO_Pin_Handle hPin ) |
|---|
| 241 | { |
|---|
| 242 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 243 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 244 | |
|---|
| 245 | if (BGIO_PinType_eOpenDrain != hPin->ePinType) |
|---|
| 246 | { |
|---|
| 247 | eResult = BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 248 | return eResult; |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | /* more input para validation done in BGIO_P_Pin_SetType */ |
|---|
| 252 | eResult = BGIO_P_Pin_SetValue( hPin, BGIO_PinValue_e1, false ); |
|---|
| 253 | return BERR_TRACE(eResult); |
|---|
| 254 | } |
|---|
| 255 | |
|---|
| 256 | /*************************************************************************** |
|---|
| 257 | * |
|---|
| 258 | */ |
|---|
| 259 | BERR_Code BGIO_Pin_OpenDrain_Release_isr( |
|---|
| 260 | BGIO_Pin_Handle hPin ) |
|---|
| 261 | { |
|---|
| 262 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 263 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 264 | |
|---|
| 265 | if (BGIO_PinType_eOpenDrain != hPin->ePinType) |
|---|
| 266 | { |
|---|
| 267 | eResult = BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 268 | return eResult; |
|---|
| 269 | } |
|---|
| 270 | |
|---|
| 271 | /* more input para validation done in BGIO_P_Pin_SetType */ |
|---|
| 272 | eResult = BGIO_P_Pin_SetValue( hPin, BGIO_PinValue_e1, true ); |
|---|
| 273 | return BERR_TRACE(eResult); |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | /*************************************************************************** |
|---|
| 277 | * |
|---|
| 278 | */ |
|---|
| 279 | BERR_Code BGIO_Pin_SetIntrMode( |
|---|
| 280 | BGIO_Pin_Handle hPin, |
|---|
| 281 | BGIO_IntrMode eIntrMode ) |
|---|
| 282 | { |
|---|
| 283 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 284 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 285 | |
|---|
| 286 | /* input para validation done in BGIO_P_Pin_SetIntrMode */ |
|---|
| 287 | eResult = BGIO_P_Pin_SetIntrMode( hPin, eIntrMode, false ); |
|---|
| 288 | return BERR_TRACE(eResult); |
|---|
| 289 | } |
|---|
| 290 | |
|---|
| 291 | /*************************************************************************** |
|---|
| 292 | * |
|---|
| 293 | */ |
|---|
| 294 | BERR_Code BGIO_Pin_SetIntrMode_isr( |
|---|
| 295 | BGIO_Pin_Handle hPin, |
|---|
| 296 | BGIO_IntrMode eIntrMode ) |
|---|
| 297 | { |
|---|
| 298 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 299 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 300 | |
|---|
| 301 | /* input para validation done in BGIO_P_Pin_SetIntrMode */ |
|---|
| 302 | eResult = BGIO_P_Pin_SetIntrMode( hPin, eIntrMode, true ); |
|---|
| 303 | return BERR_TRACE(eResult); |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | /*************************************************************************** |
|---|
| 307 | * |
|---|
| 308 | */ |
|---|
| 309 | BERR_Code BGIO_Pin_ClearIntrStatus( |
|---|
| 310 | BGIO_Pin_Handle hPin ) |
|---|
| 311 | { |
|---|
| 312 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 313 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 314 | |
|---|
| 315 | /* input para validation done in BGIO_P_Pin_ClearIntrStatus */ |
|---|
| 316 | eResult = BGIO_P_Pin_ClearIntrStatus( hPin, false ); |
|---|
| 317 | return BERR_TRACE(eResult); |
|---|
| 318 | } |
|---|
| 319 | |
|---|
| 320 | /*************************************************************************** |
|---|
| 321 | * |
|---|
| 322 | */ |
|---|
| 323 | BERR_Code BGIO_Pin_ClearIntrStatus_isr( |
|---|
| 324 | BGIO_Pin_Handle hPin ) |
|---|
| 325 | { |
|---|
| 326 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 327 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 328 | |
|---|
| 329 | /* input para validation done in BGIO_P_Pin_ClearIntrStatus */ |
|---|
| 330 | eResult = BGIO_P_Pin_ClearIntrStatus( hPin, true ); |
|---|
| 331 | return BERR_TRACE(eResult); |
|---|
| 332 | } |
|---|
| 333 | |
|---|
| 334 | /*************************************************************************** |
|---|
| 335 | * |
|---|
| 336 | */ |
|---|
| 337 | BERR_Code BGIO_Pin_GetIntrStatus( |
|---|
| 338 | BGIO_Pin_Handle hPin, |
|---|
| 339 | bool * pbFire ) |
|---|
| 340 | { |
|---|
| 341 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 342 | BDBG_OBJECT_ASSERT(hPin, BGIO_PIN); |
|---|
| 343 | |
|---|
| 344 | /* input para validation done in BGIO_P_Pin_GetIntrStatus */ |
|---|
| 345 | eResult = BGIO_P_Pin_GetIntrStatus( hPin, pbFire ); |
|---|
| 346 | return BERR_TRACE(eResult); |
|---|
| 347 | } |
|---|
| 348 | |
|---|
| 349 | /* End of File */ |
|---|
| 350 | |
|---|