| 1 | /*************************************************************************** |
|---|
| 2 | * (c)2007-2010 Broadcom Corporation |
|---|
| 3 | * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | * |
|---|
| 14 | * Except as expressly set forth in the Authorized License, |
|---|
| 15 | * |
|---|
| 16 | * 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | * and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | * |
|---|
| 20 | * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | * USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | * |
|---|
| 29 | * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | * ANY LIMITED REMEDY. |
|---|
| 37 | * |
|---|
| 38 | * $brcm_Workfile: bchp_pwr.h $ |
|---|
| 39 | * $brcm_Revision: Hydra_Software_Devel/13 $ |
|---|
| 40 | * $brcm_Date: 12/12/11 2:12p $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * |
|---|
| 44 | * Revision History: |
|---|
| 45 | * |
|---|
| 46 | * $brcm_Log: /magnum/basemodules/chp/bchp_pwr.h $ |
|---|
| 47 | * |
|---|
| 48 | * Hydra_Software_Devel/13 12/12/11 2:12p jtna |
|---|
| 49 | * SW7425-1708: add BCHP_PWR_Standby/Resume() for clockgen power down |
|---|
| 50 | * |
|---|
| 51 | * Hydra_Software_Devel/12 2/9/11 2:35p jtna |
|---|
| 52 | * SW7420-1456: remove _isr functions |
|---|
| 53 | * |
|---|
| 54 | * Hydra_Software_Devel/11 2/3/11 7:19p jtna |
|---|
| 55 | * SW7420-1456: added _isr functions |
|---|
| 56 | * |
|---|
| 57 | * Hydra_Software_Devel/10 11/18/10 7:34p jtna |
|---|
| 58 | * SW7420-972: refactor init process |
|---|
| 59 | * |
|---|
| 60 | * Hydra_Software_Devel/9 9/17/10 5:53p jtna |
|---|
| 61 | * SW7420-972: update comments |
|---|
| 62 | * |
|---|
| 63 | * Hydra_Software_Devel/8 9/9/10 5:02p jtna |
|---|
| 64 | * SW7420-972: replace BCHP_CHIP==7420 with BCHP_PWR_SUPPORT. this is now |
|---|
| 65 | * the magnum global define |
|---|
| 66 | * |
|---|
| 67 | * Hydra_Software_Devel/7 9/8/10 4:07p jtna |
|---|
| 68 | * SW7420-972: conditionally include bchp_pwr_resources.h |
|---|
| 69 | * |
|---|
| 70 | * Hydra_Software_Devel/6 9/8/10 3:44p jtna |
|---|
| 71 | * SW7420-972: bchp_pwr.h now includes bchp_pwr_resources.h |
|---|
| 72 | * |
|---|
| 73 | * Hydra_Software_Devel/5 9/1/10 3:34p jtna |
|---|
| 74 | * SW7420-972: add bchp_pwr resource init scheme |
|---|
| 75 | * |
|---|
| 76 | * Hydra_Software_Devel/4 8/13/10 5:27p jtna |
|---|
| 77 | * SW7405-4433: changed node representation from pointer to #define |
|---|
| 78 | * uint32_t |
|---|
| 79 | * |
|---|
| 80 | * Hydra_Software_Devel/3 6/9/10 3:34p jtna |
|---|
| 81 | * SW7405-4433: add breg handle to bchp handle and don't require a breg |
|---|
| 82 | * handle to be passed to the pwr functions |
|---|
| 83 | * |
|---|
| 84 | * Hydra_Software_Devel/2 6/8/10 6:55p jtna |
|---|
| 85 | * SW7405-4433: extended refcnt functionality and added basic dump |
|---|
| 86 | * function |
|---|
| 87 | * |
|---|
| 88 | * Hydra_Software_Devel/1 6/1/10 7:32p jtna |
|---|
| 89 | * SW7405-4433: added bchp_pwr files |
|---|
| 90 | * |
|---|
| 91 | ***************************************************************************/ |
|---|
| 92 | |
|---|
| 93 | #ifndef BCHP_PWR_H__ |
|---|
| 94 | #define BCHP_PWR_H__ |
|---|
| 95 | |
|---|
| 96 | #include "bchp.h" |
|---|
| 97 | #include "bchp_priv.h" |
|---|
| 98 | #ifdef BCHP_PWR_SUPPORT |
|---|
| 99 | #include "bchp_pwr_resources.h" /* platform-specific resources file */ |
|---|
| 100 | #endif |
|---|
| 101 | |
|---|
| 102 | #ifdef __cplusplus |
|---|
| 103 | extern "C" { |
|---|
| 104 | #endif |
|---|
| 105 | |
|---|
| 106 | /*************************************************************************** |
|---|
| 107 | Summary: |
|---|
| 108 | Power resource identifier. |
|---|
| 109 | |
|---|
| 110 | Description: |
|---|
| 111 | Power resources are chip-specific abstractions that are defined in |
|---|
| 112 | bchp_pwr_resources.h. A power resource is identified by a single |
|---|
| 113 | uint32_t number. |
|---|
| 114 | |
|---|
| 115 | **************************************************************************/ |
|---|
| 116 | typedef uint32_t BCHP_PWR_ResourceId; |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | /*************************************************************************** |
|---|
| 120 | Summary: |
|---|
| 121 | Acquire a power resource. |
|---|
| 122 | |
|---|
| 123 | Description: |
|---|
| 124 | This function acquires a single power resource. You can only acquire |
|---|
| 125 | high-level, non-HW power resources. |
|---|
| 126 | |
|---|
| 127 | Acquiring a power resource causes the internal reference count for |
|---|
| 128 | the resource and all its successive dependants to increase by one. |
|---|
| 129 | The dependent HW clocks turn on only when the internal reference |
|---|
| 130 | count is increased from 0 to 1. |
|---|
| 131 | |
|---|
| 132 | The same power resource can be acquired multiple times. |
|---|
| 133 | |
|---|
| 134 | See Also: |
|---|
| 135 | BCHP_PWR_Resource_Release |
|---|
| 136 | **************************************************************************/ |
|---|
| 137 | BERR_Code BCHP_PWR_AcquireResource(BCHP_Handle handle, BCHP_PWR_ResourceId resourceId); |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | /*************************************************************************** |
|---|
| 141 | Summary: |
|---|
| 142 | Release a power resource. |
|---|
| 143 | |
|---|
| 144 | Description: |
|---|
| 145 | This function releases a single power resource. You can only release |
|---|
| 146 | high-level, non-HW power resources. Furthermore, you can only release |
|---|
| 147 | power resources that were previously explicitly acquired. |
|---|
| 148 | |
|---|
| 149 | Releasing a power resource causes the internal reference count for |
|---|
| 150 | the resource and all its successive dependants to decrease by one. |
|---|
| 151 | The dependent HW clocks turn off only when the internal reference |
|---|
| 152 | count becomes zero. |
|---|
| 153 | |
|---|
| 154 | The same power resource can be released as many times as it was |
|---|
| 155 | previously acquired. |
|---|
| 156 | |
|---|
| 157 | See Also: |
|---|
| 158 | BCHP_PWR_Resource_Acquire |
|---|
| 159 | **************************************************************************/ |
|---|
| 160 | BERR_Code BCHP_PWR_ReleaseResource(BCHP_Handle handle, BCHP_PWR_ResourceId resourceId); |
|---|
| 161 | |
|---|
| 162 | |
|---|
| 163 | /*************************************************************************** |
|---|
| 164 | Summary: |
|---|
| 165 | Initialize all HW power resources so that they can be acquired and released. |
|---|
| 166 | |
|---|
| 167 | Description: |
|---|
| 168 | A HW resource must be initialized before it is allowed to be acquired and |
|---|
| 169 | released. An initialized HW resource is one that is powered down and has |
|---|
| 170 | a reference count of 0. |
|---|
| 171 | |
|---|
| 172 | During BCHP_PWR_Open, HW resources associated with the special |
|---|
| 173 | BCHP_PWR_RESOURCE_MAGNUM_CONTROLLED node are automatically |
|---|
| 174 | initialized. Calling this function initializes the rest. |
|---|
| 175 | |
|---|
| 176 | **************************************************************************/ |
|---|
| 177 | void BCHP_PWR_InitAllHwResources(BCHP_Handle handle); |
|---|
| 178 | |
|---|
| 179 | |
|---|
| 180 | /*************************************************************************** |
|---|
| 181 | Summary: |
|---|
| 182 | Print current power status. |
|---|
| 183 | |
|---|
| 184 | Description: |
|---|
| 185 | This function prints which power resources are powered up and down, |
|---|
| 186 | and their current reference counts. This is used to debug power usage |
|---|
| 187 | across the system, and is functionally equivalent to looking for |
|---|
| 188 | memory leaks. |
|---|
| 189 | |
|---|
| 190 | When a power resource is acquired, the "public" reference count is |
|---|
| 191 | increased only for that particular resource. The "private" reference |
|---|
| 192 | count, on the other hand, is increased for all its successive |
|---|
| 193 | dependants. |
|---|
| 194 | |
|---|
| 195 | **************************************************************************/ |
|---|
| 196 | void BCHP_PWR_Dump(BCHP_Handle handle); |
|---|
| 197 | |
|---|
| 198 | |
|---|
| 199 | /*************************************************************************** |
|---|
| 200 | Summary: |
|---|
| 201 | Standby settings. |
|---|
| 202 | |
|---|
| 203 | Description: |
|---|
| 204 | Currently unused. |
|---|
| 205 | **************************************************************************/ |
|---|
| 206 | typedef struct BCHP_PWR_StandbySettings { |
|---|
| 207 | unsigned unused; /* dummy placeholder */ |
|---|
| 208 | } BCHP_PWR_StandbySettings; |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | /*************************************************************************** |
|---|
| 212 | Summary: |
|---|
| 213 | Enter standby. |
|---|
| 214 | |
|---|
| 215 | Description: |
|---|
| 216 | This function causes the BCHP_PWR sub-module to enter standby. |
|---|
| 217 | Currently, this function is a no-op; it does not change any SW |
|---|
| 218 | reference counts or HW state. |
|---|
| 219 | **************************************************************************/ |
|---|
| 220 | BERR_Code BCHP_PWR_Standby( |
|---|
| 221 | BCHP_Handle handle, |
|---|
| 222 | const BCHP_PWR_StandbySettings *pSettings /* optional */ |
|---|
| 223 | ); |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | /*************************************************************************** |
|---|
| 227 | Summary: |
|---|
| 228 | Exit standby. |
|---|
| 229 | |
|---|
| 230 | Description: |
|---|
| 231 | This function causes BCHP_PWR to exit standby by re-applying the HW state. |
|---|
| 232 | |
|---|
| 233 | A power management operation such as passive standby can cause the HW |
|---|
| 234 | to lose state, while the SW state remains unchanged. This results in a |
|---|
| 235 | mismatch between the SW reference counts and the HW state. |
|---|
| 236 | |
|---|
| 237 | Calling this function causes BCHP_PWR to re-apply the HW state based on |
|---|
| 238 | the current SW reference counts, thereby synchronizing the two states |
|---|
| 239 | again. |
|---|
| 240 | **************************************************************************/ |
|---|
| 241 | void BCHP_PWR_Resume( |
|---|
| 242 | BCHP_Handle handle |
|---|
| 243 | ); |
|---|
| 244 | |
|---|
| 245 | #ifdef __cplusplus |
|---|
| 246 | } /* extern "C" */ |
|---|
| 247 | #endif |
|---|
| 248 | |
|---|
| 249 | #endif |
|---|