| 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: bpwr.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/1 $ |
|---|
| 12 | * $brcm_Date: 11/23/10 2:10p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/pwr/7552/bpwr.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/1 11/23/10 2:10p xhuang |
|---|
| 21 | * SW7552-9: Add support for 97552 |
|---|
| 22 | * |
|---|
| 23 | * |
|---|
| 24 | ***************************************************************************/ |
|---|
| 25 | #ifndef BPWR_H__ |
|---|
| 26 | #define BPWR_H__ |
|---|
| 27 | |
|---|
| 28 | #include "bstd_ids.h" |
|---|
| 29 | |
|---|
| 30 | #ifdef __cplusplus |
|---|
| 31 | extern "C" { |
|---|
| 32 | #endif |
|---|
| 33 | |
|---|
| 34 | /*=************************ Module Overview ******************************** |
|---|
| 35 | The Power Management API is a library that allows the shutting down and |
|---|
| 36 | subsequent power up of specified hardware blocks. |
|---|
| 37 | |
|---|
| 38 | This API is targeted for Hydra core based chip, and future chips. This API |
|---|
| 39 | exploits all possible power management modes provided by chip capabilities. |
|---|
| 40 | It also attempts to hide all the gritty hardware details from the application. |
|---|
| 41 | |
|---|
| 42 | The API operates on a context handle. There is a main PWR handle which |
|---|
| 43 | represents a certain state of the power management software object. This object |
|---|
| 44 | may contain information regarding the hardware blocks that are currently |
|---|
| 45 | active and RTS settings, if any of inactive blocks that were previously |
|---|
| 46 | shut down. |
|---|
| 47 | |
|---|
| 48 | Most of the API functions are used in user mode context. It is assumed that |
|---|
| 49 | there are no critical sections in the a software module whose |
|---|
| 50 | corespodning hardware blocks are shutdown. As such any register writes |
|---|
| 51 | are allowed without going through critical sections. |
|---|
| 52 | |
|---|
| 53 | In the user mode context, after one has completed the intended setup for a |
|---|
| 54 | ppwer management context, one "applies" it to the hardware. It is only at this time |
|---|
| 55 | that the actual configuration (i.e. register writes or queues) of the |
|---|
| 56 | hardware occurs. Modifying a power management context does not affect the |
|---|
| 57 | hardware at all until it is applied. Please notice that the setup calls |
|---|
| 58 | between two "applyings" is order independent, and that if there is conflict |
|---|
| 59 | found as "applying" all new settings would not be applied. |
|---|
| 60 | |
|---|
| 61 | For more details, please refer to the description of BPWR_Handle. |
|---|
| 62 | ***************************************************************************/ |
|---|
| 63 | |
|---|
| 64 | /*************************************************************************** |
|---|
| 65 | * PWR data types |
|---|
| 66 | **************************************************************************/ |
|---|
| 67 | |
|---|
| 68 | /*************************************************************************** |
|---|
| 69 | Summary: |
|---|
| 70 | This enum lists the possible power modes for a given module |
|---|
| 71 | |
|---|
| 72 | Description: |
|---|
| 73 | BPWR_ePowerMode is an enumeration that lists the possible power |
|---|
| 74 | modes for a given PI module. A module's initial mode is undefined and |
|---|
| 75 | is set via BPWR_SetMode or BPWR_SetAllMode. |
|---|
| 76 | |
|---|
| 77 | ***************************************************************************/ |
|---|
| 78 | typedef enum BPWR_ePowerMode |
|---|
| 79 | { |
|---|
| 80 | BPWR_Mode_ePowerDown = 0, |
|---|
| 81 | BPWR_Mode_ePowerUp, |
|---|
| 82 | BPWR_Mode_ePowerUndefined |
|---|
| 83 | } BPWR_ePowerMode; |
|---|
| 84 | |
|---|
| 85 | /*************************************************************************** |
|---|
| 86 | Summary: |
|---|
| 87 | This structure describes the settings for the power management. |
|---|
| 88 | |
|---|
| 89 | Description: |
|---|
| 90 | BPWR_Settings is a structure that use to describe the public |
|---|
| 91 | settings for power management. |
|---|
| 92 | |
|---|
| 93 | This structure is not used in 7405. The code will read from Sun_Top+Ctrl_Strap to figure out |
|---|
| 94 | the memory configuration. The portinginterface only handle MEMC 1 for non-UMA memory |
|---|
| 95 | configuration. |
|---|
| 96 | |
|---|
| 97 | ulMemc0ClientStartAddr - address of MEMC0's 1st client |
|---|
| 98 | ulMemc0ClientCount - number of MEMC0 clients |
|---|
| 99 | ulMemc1ClientStartAddr - address of MEMC1's 1st client |
|---|
| 100 | ulMemc1ClientCount - number of MEMC1 clients |
|---|
| 101 | ulMemc2ClientStartAddr - address of MEMC2's 1st client |
|---|
| 102 | ulMemc2ClientCount - number of MEMC2 clients |
|---|
| 103 | |
|---|
| 104 | The default values for all the fields is 0; hence, these must be defined |
|---|
| 105 | by the application. If none of the start addresses are defined, an error |
|---|
| 106 | will be returned. |
|---|
| 107 | |
|---|
| 108 | ***************************************************************************/ |
|---|
| 109 | typedef struct BPWR_Settings |
|---|
| 110 | { |
|---|
| 111 | uint32_t ulMemc0StartAddr; |
|---|
| 112 | uint32_t ulMemc0ClientCount; |
|---|
| 113 | uint32_t ulMemc1StartAddr; |
|---|
| 114 | uint32_t ulMemc1ClientCount; |
|---|
| 115 | uint32_t ulMemc2StartAddr; |
|---|
| 116 | uint32_t ulMemc2ClientCount; |
|---|
| 117 | } BPWR_Settings; |
|---|
| 118 | |
|---|
| 119 | /*************************************************************************** |
|---|
| 120 | * PWR handles |
|---|
| 121 | **************************************************************************/ |
|---|
| 122 | |
|---|
| 123 | /*************************************************************************** |
|---|
| 124 | Summary: |
|---|
| 125 | Main Power Management (PWR) context handle. |
|---|
| 126 | |
|---|
| 127 | Description: |
|---|
| 128 | This is an opaque handle that application created with BPWR_Open. |
|---|
| 129 | BPWR_Handle holds the context of the Power Management module. There |
|---|
| 130 | should only one BPWR_Handle per chip. |
|---|
| 131 | |
|---|
| 132 | See Also: |
|---|
| 133 | BPWR_Open, BPWR_Close. |
|---|
| 134 | ***************************************************************************/ |
|---|
| 135 | typedef struct BPWR_P_Context *BPWR_Handle; |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | /*************************************************************************** |
|---|
| 139 | * Public API |
|---|
| 140 | **************************************************************************/ |
|---|
| 141 | |
|---|
| 142 | /*************************************************************************** |
|---|
| 143 | * Function prototype |
|---|
| 144 | **************************************************************************/ |
|---|
| 145 | /*************************************************************************** |
|---|
| 146 | Summary: |
|---|
| 147 | This function gets BPWR's inherent default setting structure. |
|---|
| 148 | |
|---|
| 149 | Description: |
|---|
| 150 | BPWR's inherent default setting structure could be queried by this API |
|---|
| 151 | function prior to BPWR_Open, modified and then passed to BPWR_Open. |
|---|
| 152 | This save application tedious work of filling in the configuration |
|---|
| 153 | structure. |
|---|
| 154 | |
|---|
| 155 | Input: |
|---|
| 156 | <None> |
|---|
| 157 | |
|---|
| 158 | Output: |
|---|
| 159 | pDefSettings - A reference to default settings structure. |
|---|
| 160 | |
|---|
| 161 | Returns: |
|---|
| 162 | BERR_INVALID_PARAMETER - Invalid function parameters. |
|---|
| 163 | BERR_SUCCESS - Successfully get PWR default settings. |
|---|
| 164 | |
|---|
| 165 | See Also: |
|---|
| 166 | BPWR_Open. |
|---|
| 167 | **************************************************************************/ |
|---|
| 168 | BERR_Code BPWR_GetDefaultSettings |
|---|
| 169 | ( BPWR_Settings *pDefSettings ); |
|---|
| 170 | |
|---|
| 171 | /*************************************************************************** |
|---|
| 172 | Summary: |
|---|
| 173 | This function opens and initializes the power management object. |
|---|
| 174 | |
|---|
| 175 | Description: |
|---|
| 176 | The first thing one need to do is open a PWR (also create a PWR |
|---|
| 177 | main context handle, BPWR_Handle). This will hold the states |
|---|
| 178 | of different hardware blocks. From this handle, the user can |
|---|
| 179 | shutdown and/or power up desired hardware blocks. This handle is |
|---|
| 180 | required when we call BPWR_ApplyChanges to update the hardware. |
|---|
| 181 | This handle eventually be closed by calling BVDC_Close. |
|---|
| 182 | |
|---|
| 183 | Input: |
|---|
| 184 | hChip - BCHP handle |
|---|
| 185 | hReg - BREG handle |
|---|
| 186 | pDefSettings - The default setting that user want the BPWR to be |
|---|
| 187 | in. This parameter can be NULL. In this case BPWR's inherent default |
|---|
| 188 | structure will be used. This inherent structure could be queried prior |
|---|
| 189 | to BPWR_Open with BPWR_GetDefaultSettings, modified and passed to |
|---|
| 190 | BPWR_Open. |
|---|
| 191 | |
|---|
| 192 | Output: |
|---|
| 193 | phPwr - a reference to a PWR handle. Upon successful open this will |
|---|
| 194 | reference to a fresh new PWR handle (context). If error occur during |
|---|
| 195 | BPWR_Open *phPwr be NULL. |
|---|
| 196 | |
|---|
| 197 | Returns: |
|---|
| 198 | BERR_INVALID_PARAMETER - Invalid function parameters. |
|---|
| 199 | BERR_SUCCESS - Successfully opened PWR. |
|---|
| 200 | |
|---|
| 201 | See Also: |
|---|
| 202 | BPWR_Close, BPWR_GetDefaultSettings. |
|---|
| 203 | **************************************************************************/ |
|---|
| 204 | BERR_Code BPWR_Open |
|---|
| 205 | ( BPWR_Handle *phPwr, |
|---|
| 206 | BCHP_Handle hChip, |
|---|
| 207 | BREG_Handle hRegister, |
|---|
| 208 | const BPWR_Settings *pDefSettings ); |
|---|
| 209 | |
|---|
| 210 | /*************************************************************************** |
|---|
| 211 | Summary: |
|---|
| 212 | This function closes the power management object.. |
|---|
| 213 | |
|---|
| 214 | Description: |
|---|
| 215 | Upon terminating power managemment, the application needs to call BPWR_Close |
|---|
| 216 | to close the power management object. After close, PWR is an invalid handle, |
|---|
| 217 | and should not be use with any other PWR functions. Failure to close will |
|---|
| 218 | result in undefined consequences. BPWR_Close returns success if hPwr is NULL. |
|---|
| 219 | |
|---|
| 220 | Input: |
|---|
| 221 | hPwr - Power management handle that was previously opened by |
|---|
| 222 | BPWR_Open. |
|---|
| 223 | |
|---|
| 224 | Output: |
|---|
| 225 | hPwr - Power management handle becomes invalid. |
|---|
| 226 | |
|---|
| 227 | Returns: |
|---|
| 228 | BERR_INVALID_PARAMETER - Invalid function parameters. |
|---|
| 229 | BERR_SUCCESS - Successfully closed PWR. |
|---|
| 230 | |
|---|
| 231 | See Also: |
|---|
| 232 | BPWR_Open. |
|---|
| 233 | **************************************************************************/ |
|---|
| 234 | BERR_Code BPWR_Close |
|---|
| 235 | ( BPWR_Handle hPwr ); |
|---|
| 236 | |
|---|
| 237 | /*************************************************************************** |
|---|
| 238 | Summary: |
|---|
| 239 | This function "Apply Changes" and update the desired hardware in the |
|---|
| 240 | power management object. |
|---|
| 241 | |
|---|
| 242 | Description: |
|---|
| 243 | After all settings in the user mode context have been made which |
|---|
| 244 | include configuring the the hardware blocks clocks and other parameters, |
|---|
| 245 | BPWR_ApplyChanges will "apply" the "changes" to hardware. It is |
|---|
| 246 | possible the the context handle is not setup correctly. In that case an |
|---|
| 247 | error will return, and no hardware will be updated. The hardware it |
|---|
| 248 | updates will depend on the software modules specified by BPWR_SetMode. |
|---|
| 249 | This function is optimized to only update required registers. |
|---|
| 250 | |
|---|
| 251 | BPWR_ApplyChanges actually uses register reads and writes. |
|---|
| 252 | |
|---|
| 253 | Input: |
|---|
| 254 | hPwr - PowerManagement handle that was previously opened by |
|---|
| 255 | BPWR_Open, and setup with BPWR calls. |
|---|
| 256 | |
|---|
| 257 | Output: |
|---|
| 258 | <None> |
|---|
| 259 | |
|---|
| 260 | Returns: |
|---|
| 261 | BERR_INVALID_PARAMETER - Invalid function parameters. |
|---|
| 262 | BERR_SUCCESS - Successfully updated hardware. |
|---|
| 263 | |
|---|
| 264 | See Also: |
|---|
| 265 | BREG_Handle. |
|---|
| 266 | **************************************************************************/ |
|---|
| 267 | BERR_Code BPWR_ApplyChanges |
|---|
| 268 | ( BPWR_Handle hPwr ); |
|---|
| 269 | |
|---|
| 270 | /*************************************************************************** |
|---|
| 271 | Summary: |
|---|
| 272 | This function specifies which software module need to be shutdown or |
|---|
| 273 | powered up. |
|---|
| 274 | |
|---|
| 275 | Description: |
|---|
| 276 | |
|---|
| 277 | Input: |
|---|
| 278 | hPwr - A valid power management handle created ealier. |
|---|
| 279 | module - The software module to be shutdown. |
|---|
| 280 | eMode - BPWR_Mode_ePowerUp, BPWR_Mode_ePowerUp |
|---|
| 281 | |
|---|
| 282 | Output: |
|---|
| 283 | None. |
|---|
| 284 | |
|---|
| 285 | Returns: |
|---|
| 286 | BERR_INVALID_PARAMETER - Invalid function parameters. |
|---|
| 287 | BERR_SUCCESS - Function succeed |
|---|
| 288 | |
|---|
| 289 | See Also: |
|---|
| 290 | BPWR_ApplyChanges, BPWR_ePowerMode |
|---|
| 291 | **************************************************************************/ |
|---|
| 292 | BERR_Code BPWR_SetMode |
|---|
| 293 | ( const BPWR_Handle hPwr, |
|---|
| 294 | BSTD_Module module, |
|---|
| 295 | BPWR_ePowerMode eMode ); |
|---|
| 296 | |
|---|
| 297 | /*************************************************************************** |
|---|
| 298 | Summary: |
|---|
| 299 | This function gets the mode of a given module |
|---|
| 300 | |
|---|
| 301 | Description: |
|---|
| 302 | |
|---|
| 303 | Input: |
|---|
| 304 | hPwr - A valid power management handle created ealier. |
|---|
| 305 | module - The software module to be shutdown. |
|---|
| 306 | |
|---|
| 307 | Output: |
|---|
| 308 | peMode - the mode of the module |
|---|
| 309 | |
|---|
| 310 | Returns: |
|---|
| 311 | BERR_NOT_SUPPORTED - Module is not supported. |
|---|
| 312 | BERR_SUCCESS - Function succeed |
|---|
| 313 | |
|---|
| 314 | See Also: |
|---|
| 315 | BPWR_ApplyChanges, BPWR_ePowerMode |
|---|
| 316 | **************************************************************************/ |
|---|
| 317 | BERR_Code BPWR_GetMode |
|---|
| 318 | ( const BPWR_Handle hPwr, |
|---|
| 319 | BSTD_Module module, |
|---|
| 320 | BPWR_ePowerMode *peMode ); |
|---|
| 321 | |
|---|
| 322 | /*************************************************************************** |
|---|
| 323 | Summary: |
|---|
| 324 | This function gets the number of modules |
|---|
| 325 | |
|---|
| 326 | Description: |
|---|
| 327 | |
|---|
| 328 | Input: |
|---|
| 329 | hPwr - A valid power management handle created ealier. |
|---|
| 330 | |
|---|
| 331 | Output: |
|---|
| 332 | pulModuleCount - the number of modules |
|---|
| 333 | |
|---|
| 334 | Returns: |
|---|
| 335 | BERR_SUCCESS - Function succeed. This function cannot fail. |
|---|
| 336 | |
|---|
| 337 | See Also: BPWR_GetModuleList |
|---|
| 338 | **************************************************************************/ |
|---|
| 339 | |
|---|
| 340 | BERR_Code BPWR_GetModuleCount |
|---|
| 341 | ( BPWR_Handle hPwr, |
|---|
| 342 | uint32_t *pulModuleCount ); |
|---|
| 343 | |
|---|
| 344 | |
|---|
| 345 | /*************************************************************************** |
|---|
| 346 | Summary: |
|---|
| 347 | This function gets the list of available modules |
|---|
| 348 | |
|---|
| 349 | Description: |
|---|
| 350 | |
|---|
| 351 | Input: |
|---|
| 352 | hPwr - A valid power management handle created ealier. |
|---|
| 353 | |
|---|
| 354 | Output: |
|---|
| 355 | pModuleList - the list of modules |
|---|
| 356 | ulModuleCount - number of entries in pModuleList array |
|---|
| 357 | |
|---|
| 358 | Returns: |
|---|
| 359 | BERR_NOT_SUPPORTED - ulModuleCount not large enough hold all modules for this chip |
|---|
| 360 | BERR_SUCCESS - Function succeed |
|---|
| 361 | |
|---|
| 362 | See Also: BPWR_GetModuleCount, BSTD_Module |
|---|
| 363 | **************************************************************************/ |
|---|
| 364 | BERR_Code BPWR_GetModuleList |
|---|
| 365 | ( BPWR_Handle hPwr, |
|---|
| 366 | BSTD_Module *pModuleList, |
|---|
| 367 | unsigned ulModuleCount ); |
|---|
| 368 | |
|---|
| 369 | |
|---|
| 370 | /*************************************************************************** |
|---|
| 371 | Summary: |
|---|
| 372 | This function sets the modes of the modules in a given list |
|---|
| 373 | |
|---|
| 374 | Description: |
|---|
| 375 | |
|---|
| 376 | Input: |
|---|
| 377 | hPwr - A valid power management handle created ealier. |
|---|
| 378 | pModuleList - the list of modules |
|---|
| 379 | ulModuleCount - the number of modules |
|---|
| 380 | eMode - the power mode |
|---|
| 381 | |
|---|
| 382 | Output: |
|---|
| 383 | |
|---|
| 384 | Returns: |
|---|
| 385 | BERR_NOT_SUPPORTED - Module is not supported. |
|---|
| 386 | BERR_SUCCESS - Function succeed |
|---|
| 387 | |
|---|
| 388 | See Also: |
|---|
| 389 | BPWR_ApplyChanges, BPWR_ePowerMode, BSTD_Module |
|---|
| 390 | **************************************************************************/ |
|---|
| 391 | BERR_Code BPWR_SetModes |
|---|
| 392 | ( BPWR_Handle hPwr, |
|---|
| 393 | BSTD_Module *pModuleList, |
|---|
| 394 | uint32_t ulModuleCount, |
|---|
| 395 | BPWR_ePowerMode eMode ); |
|---|
| 396 | |
|---|
| 397 | |
|---|
| 398 | |
|---|
| 399 | #ifdef __cplusplus |
|---|
| 400 | } |
|---|
| 401 | #endif |
|---|
| 402 | |
|---|
| 403 | #endif /* #ifndef BPWR_H__ */ |
|---|
| 404 | |
|---|
| 405 | /* End of File */ |
|---|