| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003, 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: brsp.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/3 $ |
|---|
| 12 | * $brcm_Date: 10/19/04 12:06p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/commonutils/rsp/brsp.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/3 10/19/04 12:06p dlwin |
|---|
| 21 | * PR 13038: Added ability to do Read/Mod/Write. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/2 9/8/03 6:29p dlwin |
|---|
| 24 | * Updated API function parameter comment for DocJet. |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/1 9/3/03 3:33p dlwin |
|---|
| 27 | * Initial version |
|---|
| 28 | * |
|---|
| 29 | ***************************************************************************/ |
|---|
| 30 | |
|---|
| 31 | /*= Module Overview ********************************************************* |
|---|
| 32 | <verbatim> |
|---|
| 33 | |
|---|
| 34 | Overview |
|---|
| 35 | This common utility module is responsible for providing service to |
|---|
| 36 | parse Register Scripts. A Register Script is simple table that contains |
|---|
| 37 | register's address and the value to write to that register. The script |
|---|
| 38 | supports write operations in 8/16/32 bits as well as Multi-Byte writes |
|---|
| 39 | (used in Qam Downstream/Out-of-Band). Along with the write operation, the |
|---|
| 40 | script supports Delay and CallBack functions. Delays are implemented |
|---|
| 41 | using a busy loops. The CallBack functions are provided when a simple write |
|---|
| 42 | is not suffice to configure a register, for example, the register setting may |
|---|
| 43 | require a run-time conditional operation to determine the appropriate value |
|---|
| 44 | to configure it. |
|---|
| 45 | |
|---|
| 46 | All BRSP CallBack function must contain five parameters, four script |
|---|
| 47 | provided parameters and one device handle. CallBack function must |
|---|
| 48 | return BERR_Code. If an BERR_SUCCESS is not returned, then |
|---|
| 49 | script parser will terminate. |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | Design |
|---|
| 53 | None |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | Usage |
|---|
| 57 | The usage of BRSP involves the following: |
|---|
| 58 | |
|---|
| 59 | * Create Register Script (statically or dynamically) |
|---|
| 60 | * Call parse function to parse Register Script |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | Sample Code |
|---|
| 64 | // The following is simple example that writes to several registers |
|---|
| 65 | // in the RFM core. |
|---|
| 66 | static const BRSP_ScriptTbl regScript[] = |
|---|
| 67 | { |
|---|
| 68 | BRSP_ScriptType_eWrite32, BCHP_RFM_CLK27_LCF1A1, 0x12345678, |
|---|
| 69 | BRSP_ScriptType_eWrite32, BCHP_RFM_CLK27_LCF1B1, 0xFF00FF00, |
|---|
| 70 | BRSP_ScriptType_eWrite32, BCHP_RFM_CLK27_LCF1B2, 0xBABEFACE, |
|---|
| 71 | BRSP_ScriptType_eEndOfScript, 0x00, 0x00000000 |
|---|
| 72 | }; |
|---|
| 73 | |
|---|
| 74 | static BCHP_Handle hChip7038; |
|---|
| 75 | static BREG_Handle hReg7038; |
|---|
| 76 | static BINT_Handle hInt7038; |
|---|
| 77 | |
|---|
| 78 | main( void ) |
|---|
| 79 | { |
|---|
| 80 | // Initialize hChip7038, hReg7038, and hInt7038 . . . |
|---|
| 81 | |
|---|
| 82 | BRSP_ParseRegScript( hReg7038, regScript, NULL ); |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | </verbatim> |
|---|
| 87 | ***************************************************************************/ |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | #ifndef BRSP_H__ |
|---|
| 91 | #define BRSP_H__ |
|---|
| 92 | |
|---|
| 93 | #include "breg_mem.h" |
|---|
| 94 | |
|---|
| 95 | #ifdef __cplusplus |
|---|
| 96 | extern "C" { |
|---|
| 97 | #endif |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | /*************************************************************************** |
|---|
| 101 | Summary: |
|---|
| 102 | The typedef for BRSP Script Table. |
|---|
| 103 | |
|---|
| 104 | Description: |
|---|
| 105 | This typedef represents the BRSP Script Table. |
|---|
| 106 | |
|---|
| 107 | See Also: |
|---|
| 108 | BRSP_ParseRegScript() |
|---|
| 109 | |
|---|
| 110 | ****************************************************************************/ |
|---|
| 111 | typedef uint32_t BRSP_ScriptTbl; |
|---|
| 112 | |
|---|
| 113 | #define BRSP_RD_MOD_WR_32( reg, field, val ) BCHP_##reg, BCHP_MASK(reg, field), BCHP_FIELD_DATA(reg, field, val), 0x00000000, 0x00000000 |
|---|
| 114 | |
|---|
| 115 | /*************************************************************************** |
|---|
| 116 | Summary: |
|---|
| 117 | Enumeration for Script Type supported by BRSP. |
|---|
| 118 | |
|---|
| 119 | Description: |
|---|
| 120 | This enumeration defines the Script Type supported by BRSP. |
|---|
| 121 | |
|---|
| 122 | See Also: |
|---|
| 123 | BRSP_ParseRegScript() |
|---|
| 124 | |
|---|
| 125 | ****************************************************************************/ |
|---|
| 126 | typedef enum |
|---|
| 127 | { |
|---|
| 128 | BRSP_ScriptType_eEndOfScript, /* End of Script */ |
|---|
| 129 | BRSP_ScriptType_eNestedScript, /* Link to nested-script */ |
|---|
| 130 | BRSP_ScriptType_eDelay, /* Busy Delay, in Milliseconds */ |
|---|
| 131 | BRSP_ScriptType_eFunc, /* CallBack Function */ |
|---|
| 132 | BRSP_ScriptType_eWrite8, /* 8 bit single word write */ |
|---|
| 133 | BRSP_ScriptType_eWrite16, /* 16 bit single word write */ |
|---|
| 134 | BRSP_ScriptType_eWrite32, /* 32 bit single word write */ |
|---|
| 135 | BRSP_ScriptType_eMbWrite32, /* Multi-byte write, supported only for InBand and OutOfBand Qam cores */ |
|---|
| 136 | BRSP_ScriptType_eRdModWr32, /* Read/Mod./Write, 32 bit single word, requires six fields */ |
|---|
| 137 | BRSP_ScriptType_eLast |
|---|
| 138 | } BRSP_ScriptType; |
|---|
| 139 | |
|---|
| 140 | /*************************************************************************** |
|---|
| 141 | Summary: |
|---|
| 142 | This function parses a BRSP script. |
|---|
| 143 | |
|---|
| 144 | Description: |
|---|
| 145 | This function is responsible for parsing a BRSP script. |
|---|
| 146 | |
|---|
| 147 | Returns: |
|---|
| 148 | TODO: |
|---|
| 149 | |
|---|
| 150 | See Also: |
|---|
| 151 | BRSP_ScriptType |
|---|
| 152 | |
|---|
| 153 | ****************************************************************************/ |
|---|
| 154 | BERR_Code BRSP_ParseRegScript( |
|---|
| 155 | BREG_Handle hReg, /* [in] Handle to Register */ |
|---|
| 156 | const BRSP_ScriptTbl *pScriptTbl, /* [in] Pointer to Register Script Tbl */ |
|---|
| 157 | void *phDev /* [in] Handle of calling device */ |
|---|
| 158 | ); |
|---|
| 159 | |
|---|
| 160 | |
|---|
| 161 | #ifdef __cplusplus |
|---|
| 162 | } |
|---|
| 163 | #endif |
|---|
| 164 | |
|---|
| 165 | #endif |
|---|
| 166 | |
|---|
| 167 | |
|---|
| 168 | |
|---|