| 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_priv.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/10 $ |
|---|
| 12 | * $brcm_Date: 6/17/11 3:01p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/gio/7038/bgio_priv.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/10 6/17/11 3:01p tdo |
|---|
| 21 | * SWDTV-7592: add BDBG_OBJECT_ASSERT for BGIO |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/9 6/16/11 5:59p tdo |
|---|
| 24 | * SWDTV-7592: add BDBG_OBJECT_ASSERT for BGIO. |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/8 4/11/11 9:27a tdo |
|---|
| 27 | * SWBLURAY-23686: Add missing include file. |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/7 4/8/11 9:40a tdo |
|---|
| 30 | * SWBLURAY-23686: Add GIO PortingInterface support for Blast (7640) chip |
|---|
| 31 | * |
|---|
| 32 | * Hydra_Software_Devel/6 4/8/08 5:48p tdo |
|---|
| 33 | * PR41205: Add _isr functions to avoid deadlock |
|---|
| 34 | * |
|---|
| 35 | * Hydra_Software_Devel/5 9/13/07 4:11p syang |
|---|
| 36 | * PR 30391, PR 32351: clean up OpenDrain pin data set records when it is |
|---|
| 37 | * destroied or changed to diff type |
|---|
| 38 | * |
|---|
| 39 | * Hydra_Software_Devel/4 9/12/07 5:57p syang |
|---|
| 40 | * PR 30391, PR 32351: BGIO only init for the pin created by BGIO to ovoid |
|---|
| 41 | * override configures by other sw entity; BGIO read from HW reg (no more |
|---|
| 42 | * sw buffering); |
|---|
| 43 | * |
|---|
| 44 | * Hydra_Software_Devel/3 7/21/06 11:42a syang |
|---|
| 45 | * PR 22789: added support for gio control set *_EXT_HI and more pins with |
|---|
| 46 | * control set *_EXT, added suuport for 7118, 3563 and 7440 |
|---|
| 47 | * |
|---|
| 48 | * Hydra_Software_Devel/2 2/24/04 7:21p syang |
|---|
| 49 | * PR 9785: more api function implementations are added |
|---|
| 50 | * |
|---|
| 51 | * Hydra_Software_Devel/1 2/20/04 11:22a syang |
|---|
| 52 | * PR 9785: init version |
|---|
| 53 | * |
|---|
| 54 | ***************************************************************************/ |
|---|
| 55 | #ifndef BGIO_PRIV_H__ |
|---|
| 56 | #define BGIO_PRIV_H__ |
|---|
| 57 | |
|---|
| 58 | #include "bgio.h" |
|---|
| 59 | #include "bgio_macro.h" |
|---|
| 60 | #include "bgio_pin_priv.h" |
|---|
| 61 | #include "blst_list.h" |
|---|
| 62 | #include "bchp_common.h" |
|---|
| 63 | #ifdef BCHP_GIO_AON_REG_START |
|---|
| 64 | #include "bchp_gio_aon.h" |
|---|
| 65 | #endif |
|---|
| 66 | |
|---|
| 67 | #ifdef __cplusplus |
|---|
| 68 | extern "C" { |
|---|
| 69 | #endif |
|---|
| 70 | |
|---|
| 71 | BDBG_OBJECT_ID_DECLARE(BGIO); |
|---|
| 72 | |
|---|
| 73 | #define BGIO_P_MAIN_SET_BLACK_MAGIC(handle) \ |
|---|
| 74 | BGIO_GENERIC_SET_BLACK_MAGIC((handle), BGIO_P_Context) |
|---|
| 75 | |
|---|
| 76 | /* define PinContext head struct */ |
|---|
| 77 | typedef struct BGIO_P_Pin_Context_Head BGIO_P_Pin_Context_Head; |
|---|
| 78 | BLST_D_HEAD(BGIO_P_Pin_Context_Head, BGIO_P_Pin_Context); |
|---|
| 79 | |
|---|
| 80 | #define BGIO_P_BIT_MASK(bit) (1 << (bit)) |
|---|
| 81 | #define BGIO_P_REG_BASE BCHP_GIO_ODEN_LO |
|---|
| 82 | #define BGIO_P_REG_LOW_TOP BCHP_GIO_STAT_LO |
|---|
| 83 | #define BGIO_P_NUM_LOW_REGS 8 |
|---|
| 84 | #ifdef BCHP_GIO_AON_ODEN_LO |
|---|
| 85 | #define BGIO_P_AON_BASE BCHP_GIO_AON_ODEN_LO |
|---|
| 86 | #else |
|---|
| 87 | #define BGIO_P_AON_BASE 0 |
|---|
| 88 | #endif |
|---|
| 89 | #if (BCHP_CHIP==7400) |
|---|
| 90 | #define BGIO_P_NUM_CTRL_SETS 4 |
|---|
| 91 | #else |
|---|
| 92 | #define BGIO_P_NUM_CTRL_SETS 3 |
|---|
| 93 | #endif |
|---|
| 94 | |
|---|
| 95 | /*************************************************************************** |
|---|
| 96 | * BGIO main Context |
|---|
| 97 | */ |
|---|
| 98 | typedef struct BGIO_P_Context |
|---|
| 99 | { |
|---|
| 100 | BDBG_OBJECT(BGIO) |
|---|
| 101 | |
|---|
| 102 | uint32_t ulBlackMagic; /* Black magic for handle validation */ |
|---|
| 103 | |
|---|
| 104 | /* handed down from up level sw */ |
|---|
| 105 | BCHP_Handle hChip; |
|---|
| 106 | BREG_Handle hRegister; |
|---|
| 107 | |
|---|
| 108 | /* records of values set to the data bits of open drain pins */ |
|---|
| 109 | uint32_t aulOpenDrainSet[BGIO_P_NUM_LOW_REGS * BGIO_P_NUM_CTRL_SETS]; |
|---|
| 110 | |
|---|
| 111 | /* link list for managed pin records */ |
|---|
| 112 | BGIO_P_Pin_Context_Head PinHead; |
|---|
| 113 | |
|---|
| 114 | } BGIO_P_Context; |
|---|
| 115 | |
|---|
| 116 | /*************************************************************************** |
|---|
| 117 | * |
|---|
| 118 | * API functions |
|---|
| 119 | * |
|---|
| 120 | ***************************************************************************/ |
|---|
| 121 | |
|---|
| 122 | /*-------------------------------------------------------------------------- |
|---|
| 123 | * To be called to init HW registers as BGIO openning |
|---|
| 124 | */ |
|---|
| 125 | BERR_Code BGIO_P_InitReg( |
|---|
| 126 | BGIO_P_Context * pGpio, |
|---|
| 127 | BREG_Handle hRegister ); |
|---|
| 128 | |
|---|
| 129 | /*************************************************************************** |
|---|
| 130 | * |
|---|
| 131 | * Utility functions |
|---|
| 132 | * |
|---|
| 133 | ***************************************************************************/ |
|---|
| 134 | |
|---|
| 135 | /*-------------------------------------------------------------------------- |
|---|
| 136 | * To be called by BGIO_P_WritePinRegBit and BGIO_P_ReadPinRegBit to calculate the |
|---|
| 137 | * register offset relative to BGIO_P_REG_BASE and the bit offset |
|---|
| 138 | * relative to bit 0, based on pin ID. |
|---|
| 139 | */ |
|---|
| 140 | BERR_Code BGIO_P_CalcPinRegAndBit( |
|---|
| 141 | BGIO_PinId ePinId, |
|---|
| 142 | uint32_t ulRegLow, /* corresponding reg_low */ |
|---|
| 143 | uint32_t * pulRegOffset, |
|---|
| 144 | uint32_t * pulBitOffset ); |
|---|
| 145 | |
|---|
| 146 | /*-------------------------------------------------------------------------- |
|---|
| 147 | * To be called to write the GPIO pin's bit into one register |
|---|
| 148 | */ |
|---|
| 149 | BERR_Code BGIO_P_WritePinRegBit( |
|---|
| 150 | BGIO_Handle hGpio, |
|---|
| 151 | BGIO_PinId ePinId, |
|---|
| 152 | BGIO_PinType ePinType, |
|---|
| 153 | uint32_t ulRegLow, |
|---|
| 154 | BGIO_PinValue ePinValue, |
|---|
| 155 | bool bInIsr ); |
|---|
| 156 | |
|---|
| 157 | /*-------------------------------------------------------------------------- |
|---|
| 158 | * To be called to write the GPIO pin's bit into one register |
|---|
| 159 | */ |
|---|
| 160 | BERR_Code BGIO_P_ReadPinRegBit( |
|---|
| 161 | BGIO_Handle hGpio, |
|---|
| 162 | BGIO_PinId ePinId, |
|---|
| 163 | uint32_t ulRegLow, |
|---|
| 164 | BGIO_PinValue * pePinValue ); |
|---|
| 165 | |
|---|
| 166 | /*************************************************************************** |
|---|
| 167 | * To be called to add a pin handle into the pin list in BGIO's main |
|---|
| 168 | * context |
|---|
| 169 | */ |
|---|
| 170 | BERR_Code BGIO_P_AddPinToList( |
|---|
| 171 | BGIO_Handle hGpio, |
|---|
| 172 | BGIO_Pin_Handle hPin ); |
|---|
| 173 | |
|---|
| 174 | /*************************************************************************** |
|---|
| 175 | * To be called to remove a pin handle from the pin list in BGIO's main |
|---|
| 176 | * context |
|---|
| 177 | */ |
|---|
| 178 | BERR_Code BGIO_P_RemovePinFromList( |
|---|
| 179 | BGIO_Handle hGpio, |
|---|
| 180 | BGIO_Pin_Handle hPin ); |
|---|
| 181 | |
|---|
| 182 | /*-------------------------------------------------------------------------- |
|---|
| 183 | * To be called to get the pin handle for a PinId from the pin list in |
|---|
| 184 | * BGIO's main context. NULL returned if it does not exist. |
|---|
| 185 | */ |
|---|
| 186 | BGIO_Pin_Handle BGIO_P_GetPinHandle( |
|---|
| 187 | BGIO_Handle hGpio, |
|---|
| 188 | BGIO_PinId ePinId ); |
|---|
| 189 | |
|---|
| 190 | /*************************************************************************** |
|---|
| 191 | * To be called to get the register handle |
|---|
| 192 | */ |
|---|
| 193 | BREG_Handle BGIO_P_GetRegisterHandle( |
|---|
| 194 | BGIO_Handle hGpio ); |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | #ifdef __cplusplus |
|---|
| 198 | } |
|---|
| 199 | #endif |
|---|
| 200 | |
|---|
| 201 | #endif /* #ifndef BGIO_PRIV_H__ */ |
|---|
| 202 | |
|---|
| 203 | /* end of file */ |
|---|