| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2002-2006, 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: bfpga.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/9 $ |
|---|
| 12 | * $brcm_Date: 5/12/06 4:37p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /rockford/commondrivers/fpga/97038/bfpga.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/9 5/12/06 4:37p erickson |
|---|
| 21 | * PR20219: don't use hardcoded value |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/8 5/12/06 2:47p erickson |
|---|
| 24 | * PR20219: added PKT4 for 7401/7400 |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/7 10/20/05 3:54p vsilyaev |
|---|
| 27 | * PR 17710: Add suppor for 97401 board |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/1 3/24/05 4:50p dlwin |
|---|
| 30 | * PR 14606: Merge to main development branch. |
|---|
| 31 | * |
|---|
| 32 | * Hydra_Software_Devel/6 1/12/05 2:58p dlwin |
|---|
| 33 | * PR 13700: Updated to support 97038C0 board, which has the FPGA on I2C |
|---|
| 34 | * bus instead of EBI. |
|---|
| 35 | * |
|---|
| 36 | * Hydra_Software_Devel/5 9/29/04 11:34a marcusk |
|---|
| 37 | * PR12850: UPdated with support for AVC daughter card setting. |
|---|
| 38 | * |
|---|
| 39 | * Hydra_Software_Devel/4 2/4/04 3:51p marcusk |
|---|
| 40 | * PR9588: Updated with proper detection of POD and 1394 Ts selects |
|---|
| 41 | * (documentation was wrong) |
|---|
| 42 | * |
|---|
| 43 | * Hydra_Software_Devel/3 2/4/04 11:38a marcusk |
|---|
| 44 | * PR9588: Added documentation and comments. |
|---|
| 45 | * |
|---|
| 46 | * Hydra_Software_Devel/2 2/4/04 7:57a marcusk |
|---|
| 47 | * PR9588: Added support for fpga, tested and working. |
|---|
| 48 | * |
|---|
| 49 | * Hydra_Software_Devel/1 2/2/04 5:38p marcusk |
|---|
| 50 | * PR9588: First version (may not compile yet) |
|---|
| 51 | * |
|---|
| 52 | ***************************************************************************/ |
|---|
| 53 | |
|---|
| 54 | /*================== Module Overview ===================================== |
|---|
| 55 | This module is used to program the FPGA on the 97038 reference design. |
|---|
| 56 | |
|---|
| 57 | It requires the EBI bus to be configured such that the FPGA's registers |
|---|
| 58 | are memory mapped. Normally, this is done in the boot ROM, but can be |
|---|
| 59 | configured as part of the application software using the following. |
|---|
| 60 | |
|---|
| 61 | Sample Code: |
|---|
| 62 | |
|---|
| 63 | #include "bchp_ebi.h" |
|---|
| 64 | #include "boardmap.h" |
|---|
| 65 | static void BFramework_InitFpga(const BFramework_Info *pFrameworkInfo) |
|---|
| 66 | { |
|---|
| 67 | BREG_Write32(pFrameworkInfo->hRegister, BCHP_EBI_CS_BASE_3, CPU_PHYS_FPGA_BASE|BCHP_EBI_CS_BASE_3_size_SIZE_32MB); |
|---|
| 68 | BREG_Write32(pFrameworkInfo->hRegister, BCHP_EBI_CS_CONFIG_3, |
|---|
| 69 | BCHP_FIELD_DATA(EBI_CS_CONFIG_3, enable, 1) | |
|---|
| 70 | BCHP_FIELD_DATA(EBI_CS_CONFIG_3, ta_wait, 1) | |
|---|
| 71 | #if BSTD_CPU_ENDIAN==BSTD_ENDIAN_LITTLE |
|---|
| 72 | BCHP_FIELD_DATA(EBI_CS_CONFIG_3, le, 1) |
|---|
| 73 | #else |
|---|
| 74 | 0 |
|---|
| 75 | #endif |
|---|
| 76 | ); |
|---|
| 77 | } |
|---|
| 78 | =============== End of Module Overview ===================================*/ |
|---|
| 79 | |
|---|
| 80 | #ifndef BFPGA__ |
|---|
| 81 | #define BFPGA__ |
|---|
| 82 | |
|---|
| 83 | #include "breg_mem.h" |
|---|
| 84 | #include "breg_i2c.h" |
|---|
| 85 | |
|---|
| 86 | #ifdef __cplusplus |
|---|
| 87 | extern "C" { |
|---|
| 88 | #endif |
|---|
| 89 | |
|---|
| 90 | /* |
|---|
| 91 | Summary: |
|---|
| 92 | This structure is used to communicate the read only information from |
|---|
| 93 | the FPGA. |
|---|
| 94 | */ |
|---|
| 95 | typedef struct |
|---|
| 96 | { |
|---|
| 97 | uint8_t board_cfg; /* board config from BOARD_FPGA_CFG[3:0] pins */ |
|---|
| 98 | uint8_t fpga_ver; /* FPGA version high and low */ |
|---|
| 99 | uint8_t strap_pins; /* value strapped from BOARD_CFG[3:0] pins */ |
|---|
| 100 | } BFPGA_info; |
|---|
| 101 | |
|---|
| 102 | /* |
|---|
| 103 | Summary: |
|---|
| 104 | This enumeration describes the possible TS input sources that can |
|---|
| 105 | be configured in the FPGA. |
|---|
| 106 | */ |
|---|
| 107 | typedef enum |
|---|
| 108 | { |
|---|
| 109 | BFPGA_TsSelect_eQam_Ds1=0, /* 3250 DS1 */ |
|---|
| 110 | BFPGA_TsSelect_eMb4500=0, /* MB 4500 SDS */ |
|---|
| 111 | BFPGA_TsSelect_eQam_Oob=1, /* 3250 OOB */ |
|---|
| 112 | BFPGA_TsSelect_eMb3517=1, /* MB 3517 VSB/QAM */ |
|---|
| 113 | BFPGA_TsSelect_eHsx_1=2, /* 7038 HSX 1 */ |
|---|
| 114 | BFPGA_TsSelect_eRmx_0=2, /* 7401 RMX 0 */ |
|---|
| 115 | BFPGA_TsSelect_eHsx_2=3, /* 7038 HSX 2 */ |
|---|
| 116 | BFPGA_TsSelect_eRmx_1=3, /* 7401 RMX 1 */ |
|---|
| 117 | BFPGA_TsSelect_eEnc_Ts0=4, /* 7041 TS 0 */ |
|---|
| 118 | BFPGA_TsSelect_e1394=5, /* 1394 */ |
|---|
| 119 | BFPGA_TsSelect_eLvds_2=6, /* LVDS JP2803 or ASI J1801 (Streamer 2) */ |
|---|
| 120 | BFPGA_TsSelect_eLvds_1=7, /* LVDS JP2801 (Streamer 1) */ |
|---|
| 121 | BFPGA_TsSelect_eQam_Ds2=8, /* 3250 DS 2 */ |
|---|
| 122 | BFPGA_TsSelect_eSlot0_Ts2=8, /* Slot0 TS2 */ |
|---|
| 123 | BFPGA_TsSelect_eEnc_Ts1=9, /* 7041 TS 0 */ |
|---|
| 124 | BFPGA_TsSelect_eSlot0_Ts3=9, /* Slot0 TS3 */ |
|---|
| 125 | BFPGA_TsSelect_ePod=10, /* POD (reserved for BFPGA_OutputSelect_ePod) */ |
|---|
| 126 | BFPGA_TsSelect_eVsb_1=11, /* VSB 1 */ |
|---|
| 127 | BFPGA_TsSelect_eSlot1_Ts4=11, /* Slot1 TS4 */ |
|---|
| 128 | BFPGA_TsSelect_eVsb_2=12, /* VSB 2 */ |
|---|
| 129 | BFPGA_TsSelect_eSlot1_Ts5=12, /* Slot1 TS5 */ |
|---|
| 130 | BFPGA_TsSelect_e8psk_1 = BFPGA_TsSelect_eVsb_1, /* 8PSK 1 */ |
|---|
| 131 | BFPGA_TsSelect_e8psk_2 = BFPGA_TsSelect_eVsb_2, /* 8PSK 2 */ |
|---|
| 132 | BFPGA_TsSelect_eReserved_1=13, /* reserved */ |
|---|
| 133 | BFPGA_TsSelect_eMultiStreamPod=14, /* Multi-stream POD mode (valid for BFPGA_OutputSelect_ePod only) */ |
|---|
| 134 | BFPGA_TsSelect_eSlot2_Ts6=14, /* Slot1 TS6 */ |
|---|
| 135 | BFPGA_TsSelect_eDisable=15 /* disable */ |
|---|
| 136 | } BFPGA_TsSelect; |
|---|
| 137 | |
|---|
| 138 | /* |
|---|
| 139 | Summary: |
|---|
| 140 | This enumeration describes all of the TS outputs that |
|---|
| 141 | the FPGA supports. |
|---|
| 142 | |
|---|
| 143 | Description: |
|---|
| 144 | The order of this enum is used for the FPGA configuration register address for most of the enums, therefore order matters. |
|---|
| 145 | */ |
|---|
| 146 | typedef enum |
|---|
| 147 | { |
|---|
| 148 | BFPGA_OutputSelect_ePkt0, /* Packet 0 */ |
|---|
| 149 | BFPGA_OutputSelect_ePkt1, /* Packet 1 */ |
|---|
| 150 | BFPGA_OutputSelect_ePkt2, /* Packet 2 */ |
|---|
| 151 | BFPGA_OutputSelect_ePkt3, /* Packet 3 */ |
|---|
| 152 | BFPGA_OutputSelect_e1394, /* 1394 */ |
|---|
| 153 | BFPGA_OutputSelect_eTest, /* Test */ |
|---|
| 154 | BFPGA_OutputSelect_ePod, /* POD */ |
|---|
| 155 | BFPGA_OutputSelect_eAvc, /* AVC Daughter card */ |
|---|
| 156 | BFPGA_OutputSelect_ePkt4 /* Packet 4 */ |
|---|
| 157 | } BFPGA_OutputSelect; |
|---|
| 158 | |
|---|
| 159 | /* |
|---|
| 160 | Summary: |
|---|
| 161 | This enumeration describes the clock polarities. |
|---|
| 162 | */ |
|---|
| 163 | typedef enum |
|---|
| 164 | { |
|---|
| 165 | BFPGA_ClockPolarity_ePositiveEdge, /* Clock on Positive Edge */ |
|---|
| 166 | BFPGA_ClockPolarity_eNegativeEdge /* Clock on Negative Edge */ |
|---|
| 167 | } BFPGA_ClockPolarity; |
|---|
| 168 | |
|---|
| 169 | /* |
|---|
| 170 | Summary: |
|---|
| 171 | This handle is used for all calls to the fgpa module. |
|---|
| 172 | */ |
|---|
| 173 | typedef struct BFPGA_Impl *BFPGA_Handle; /* Opaique Handle */ |
|---|
| 174 | |
|---|
| 175 | /* |
|---|
| 176 | Summary: |
|---|
| 177 | Required default settings structure for FPGA module. |
|---|
| 178 | |
|---|
| 179 | Description: |
|---|
| 180 | The default setting structure defines the default configuration of |
|---|
| 181 | FPGA when the device is opened. |
|---|
| 182 | |
|---|
| 183 | */ |
|---|
| 184 | typedef struct |
|---|
| 185 | { |
|---|
| 186 | uint32_t regBase; /* FPGA EBI: base address of where FPGA is located */ |
|---|
| 187 | unsigned short i2cAddr; /* FPGA I2C: 7bit I2C address of FPGA, */ |
|---|
| 188 | } BFPGA_Settings; |
|---|
| 189 | |
|---|
| 190 | /* |
|---|
| 191 | Summary: |
|---|
| 192 | This function creates and returns a fpga handle. |
|---|
| 193 | |
|---|
| 194 | Description: |
|---|
| 195 | Before this function is called, the FPGA must be memory mapped on |
|---|
| 196 | the EBI bus (see module overview), and a register handle must be |
|---|
| 197 | created. |
|---|
| 198 | */ |
|---|
| 199 | BERR_Code BFPGA_Open( |
|---|
| 200 | BFPGA_Handle *phFpga, /* [out] returns handle to fpga */ |
|---|
| 201 | BREG_Handle hReg, /* [in] Handle to Memory Mapped register */ |
|---|
| 202 | BREG_I2C_Handle hI2CReg, /* [in] I2C Register handle */ |
|---|
| 203 | const BFPGA_Settings *pDefSettings /* [in] Default settings */ |
|---|
| 204 | ); |
|---|
| 205 | |
|---|
| 206 | /* |
|---|
| 207 | Summary: |
|---|
| 208 | This function closes a fpga handle. |
|---|
| 209 | */ |
|---|
| 210 | void BFPGA_Close( |
|---|
| 211 | BFPGA_Handle hFpga /* handle to fpga */ |
|---|
| 212 | ); |
|---|
| 213 | |
|---|
| 214 | /* |
|---|
| 215 | Summary: |
|---|
| 216 | This function returns the default settings |
|---|
| 217 | |
|---|
| 218 | Description: |
|---|
| 219 | */ |
|---|
| 220 | BERR_Code BFPGA_GetDefaultSettings( |
|---|
| 221 | BFPGA_Settings *pDefSettings /* [out] Returns default setting */ |
|---|
| 222 | ); |
|---|
| 223 | |
|---|
| 224 | /* |
|---|
| 225 | Summary: |
|---|
| 226 | This function returns the FPGA info structure. |
|---|
| 227 | */ |
|---|
| 228 | BERR_Code BFPGA_GetInfo( |
|---|
| 229 | BFPGA_Handle hFpga, /* handle to fpga */ |
|---|
| 230 | BFPGA_info *pInfo /* [out] pointer to info structure that will be filled with data */ |
|---|
| 231 | ); |
|---|
| 232 | |
|---|
| 233 | /* |
|---|
| 234 | Summary: |
|---|
| 235 | This function resets the FPGA. |
|---|
| 236 | */ |
|---|
| 237 | BERR_Code BFPGA_Reset( |
|---|
| 238 | BFPGA_Handle hFpga /* handle to fpga */ |
|---|
| 239 | ); |
|---|
| 240 | |
|---|
| 241 | /* |
|---|
| 242 | Summary: |
|---|
| 243 | This function configures a specified output of the FPGA. |
|---|
| 244 | |
|---|
| 245 | Description: |
|---|
| 246 | Each output of the FPGA can be assigned an input. The same |
|---|
| 247 | input can be mapped to any number of outputs, but for obvious |
|---|
| 248 | reasons an output can only have a single input. |
|---|
| 249 | */ |
|---|
| 250 | BERR_Code BFPGA_SetTsOutput( |
|---|
| 251 | BFPGA_Handle hFpga, /* handle to fpga */ |
|---|
| 252 | BFPGA_OutputSelect outputSelect, /* Selects which of the FPGA TS outputs to configure */ |
|---|
| 253 | BFPGA_TsSelect tsSelect /* Selects the ts stream to send to selected output */ |
|---|
| 254 | ); |
|---|
| 255 | |
|---|
| 256 | /* |
|---|
| 257 | Summary: |
|---|
| 258 | This function returns the input source for a specified output of the FPGA. |
|---|
| 259 | */ |
|---|
| 260 | BERR_Code BFPGA_GetTsOutput( |
|---|
| 261 | BFPGA_Handle hFpga, /* handle to fpga */ |
|---|
| 262 | BFPGA_OutputSelect outputSelect, /* Selects which of the FPGA TS outputs to configure */ |
|---|
| 263 | BFPGA_TsSelect *p_tsSelect, /* [out] Returns the ts stream that is routed to selected output */ |
|---|
| 264 | bool *p_softwareConfigured /* [out] Returns if the ts stream is configured by software (if not it is configured by the jumper setting) */ |
|---|
| 265 | ); |
|---|
| 266 | |
|---|
| 267 | /* |
|---|
| 268 | Summary: |
|---|
| 269 | This function configures the clock polarity for a specified output of the FPGA. |
|---|
| 270 | */ |
|---|
| 271 | BERR_Code BFPGA_SetClockPolarity( |
|---|
| 272 | BFPGA_Handle hFpga, /* handle to fpga */ |
|---|
| 273 | BFPGA_OutputSelect outputSelect, /* Selects which of the FPGA TS outputs to configure */ |
|---|
| 274 | BFPGA_ClockPolarity inputClockPolarity, /* Selects the input clock polarity */ |
|---|
| 275 | BFPGA_ClockPolarity outputClockPolarity /* Selects the output clock polarity */ |
|---|
| 276 | ); |
|---|
| 277 | |
|---|
| 278 | /* |
|---|
| 279 | Summary: |
|---|
| 280 | This function returns the clock polarity for a specified output of the FPGA. |
|---|
| 281 | */ |
|---|
| 282 | BERR_Code BFPGA_GetClockPolarity( |
|---|
| 283 | BFPGA_Handle hFpga, /* handle to fpga */ |
|---|
| 284 | BFPGA_OutputSelect outputSelect, /* Selects which of the FPGA TS outputs to configure */ |
|---|
| 285 | BFPGA_ClockPolarity *p_inputClockPolarity, /* [out] Returns the input clock polarity */ |
|---|
| 286 | BFPGA_ClockPolarity *p_outputClockPolarity /* [out] Returns the output clock polarity */ |
|---|
| 287 | ); |
|---|
| 288 | |
|---|
| 289 | #ifdef __cplusplus |
|---|
| 290 | } |
|---|
| 291 | #endif |
|---|
| 292 | |
|---|
| 293 | #endif |
|---|
| 294 | |
|---|