Shad Ansari | 2f7f9be | 2017-06-07 13:34:53 -0700 | [diff] [blame^] | 1 | /* |
| 2 | <:copyright-BRCM:2016:DUAL/GPL:standard |
| 3 | |
| 4 | Broadcom Proprietary and Confidential.(c) 2016 Broadcom |
| 5 | All Rights Reserved |
| 6 | |
| 7 | Unless you and Broadcom execute a separate written software license |
| 8 | agreement governing use of this software, this software is licensed |
| 9 | to you under the terms of the GNU General Public License version 2 |
| 10 | (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, |
| 11 | with the following added to such license: |
| 12 | |
| 13 | As a special exception, the copyright holders of this software give |
| 14 | you permission to link this software with independent modules, and |
| 15 | to copy and distribute the resulting executable under terms of your |
| 16 | choice, provided that you also meet, for each linked independent |
| 17 | module, the terms and conditions of the license of that module. |
| 18 | An independent module is a module which is not derived from this |
| 19 | software. The special exception does not apply to any modifications |
| 20 | of the software. |
| 21 | |
| 22 | Not withstanding the above, under no circumstances may you combine |
| 23 | this software in any way with any other Broadcom software provided |
| 24 | under a license other than the GPL, without Broadcom's express prior |
| 25 | written consent. |
| 26 | |
| 27 | :> |
| 28 | */ |
| 29 | |
| 30 | #ifndef BCMOLT_FLD_H |
| 31 | #define BCMOLT_FLD_H |
| 32 | |
| 33 | #include "bcmos_system.h" |
| 34 | #include "bcmolt_model_types.h" |
| 35 | #include "bcmolt_model_ids.h" |
| 36 | #include "bcm_fld_common.h" |
| 37 | |
| 38 | /** \defgroup \fld_data_types Data Types |
| 39 | * \ingroup fld |
| 40 | * @{ |
| 41 | */ |
| 42 | |
| 43 | #define PCIE_REVISION_REGISTER_OFFSET 0x6406CU /* PCIE_PCIE_PCIE_0_PCIE_PCIE_0_MISC_REVISION */ |
| 44 | |
| 45 | typedef struct |
| 46 | { |
| 47 | unsigned long soc_regs_base; |
| 48 | unsigned long soc_sram_base; |
| 49 | unsigned long soc_ddr_base; |
| 50 | uint32_t soc_ddr_length; /* ddr window length */ |
| 51 | uint32_t soc_crt_length; /* ddr used for load length */ |
| 52 | } bcm_fld_device_info; |
| 53 | |
| 54 | typedef struct |
| 55 | { |
| 56 | uint32_t os_entry_offset; |
| 57 | uint32_t protocol_version; |
| 58 | uint32_t state; |
| 59 | uint32_t reason; |
| 60 | } bcm_fld_device_stat; |
| 61 | |
| 62 | /** |
| 63 | * \brief Initialize internal data base |
| 64 | * |
| 65 | * allocate the array of pointers to info per device allocate |
| 66 | * and clear the info structure for every possible device |
| 67 | * |
| 68 | * \param[in] max_devices How many devices might be defined |
| 69 | * |
| 70 | * \return |
| 71 | * 0 if successful, <0 if failed |
| 72 | */ |
| 73 | bcmos_errno bcm_fld_init(uint32_t max_devices); |
| 74 | |
| 75 | /** |
| 76 | * \brief Initialize communication area |
| 77 | * |
| 78 | * clear the communication area |
| 79 | * |
| 80 | * \param[in] device Identifies the device |
| 81 | * |
| 82 | */ |
| 83 | void bcm_fld_clear_comm_area(uint32_t device); |
| 84 | |
| 85 | /** |
| 86 | * \brief Release internal data base |
| 87 | * |
| 88 | * \return |
| 89 | * 0 if successful, <0 if failed |
| 90 | */ |
| 91 | bcmos_errno bcm_fld_exit(void); |
| 92 | |
| 93 | /** |
| 94 | * \brief Register a device to driver |
| 95 | * |
| 96 | * store user's information about the device |
| 97 | * |
| 98 | * \param[in] device Identifies the device |
| 99 | * \param[in] info Information |
| 100 | * - regs base address |
| 101 | * - sram base address |
| 102 | * - ddr base address |
| 103 | * - ddr window size |
| 104 | * |
| 105 | * \return |
| 106 | * 0 if successful, <0 if failed |
| 107 | */ |
| 108 | bcmos_errno bcm_fld_register(uint32_t device, bcm_fld_device_info *info); |
| 109 | |
| 110 | /** |
| 111 | * \brief Unregister a device from driver |
| 112 | * |
| 113 | * remove the device from the internal db |
| 114 | * |
| 115 | * \param[in] device Identifies the device |
| 116 | * |
| 117 | * \return |
| 118 | * 0 if successful, <0 if failed |
| 119 | */ |
| 120 | bcmos_errno bcm_fld_unregister(uint32_t device); |
| 121 | |
| 122 | /** |
| 123 | * \brief Read from communication SoC debug information |
| 124 | * |
| 125 | * \param[in] device Identifies the device |
| 126 | * \param[in] debug_state Information to be filled pointer |
| 127 | * |
| 128 | * \return |
| 129 | * 0 if successful, <0 if failed |
| 130 | */ |
| 131 | bcmos_errno bcm_fld_get_device_status(uint32_t device, bcm_fld_device_stat *debug_state); |
| 132 | |
| 133 | /** |
| 134 | * \brief Read from communication SoC status |
| 135 | * |
| 136 | * \param[in] device Identifies the device |
| 137 | * \param[in] cpu_state Information to be filled pointer |
| 138 | * |
| 139 | * \return |
| 140 | * 0 if successful, <0 if failed |
| 141 | */ |
| 142 | bcmos_errno bcm_fld_get_device_loading_state(uint32_t device, BCM_FLD_CPU_STATE *cpu_state); |
| 143 | |
| 144 | /** |
| 145 | * \brief Write in communication area the finish writing DDR |
| 146 | * indicator |
| 147 | * |
| 148 | * \param[in] device Identifies the device |
| 149 | * \param[in] os_entry_address Entry point for embedded |
| 150 | * application |
| 151 | * |
| 152 | * \return |
| 153 | * 0 if successful, <0 if failed |
| 154 | */ |
| 155 | bcmos_errno bcm_fld_host_finish_write_ddr(uint32_t device, uint32_t os_entry_address); |
| 156 | |
| 157 | /** |
| 158 | * \brief Read from communication the logs area |
| 159 | * |
| 160 | * \param[in] device Identifies the device |
| 161 | * \param[out] log_area Pointer logger area |
| 162 | * \param[out] length Length logger area |
| 163 | * |
| 164 | * \return |
| 165 | * 0 if successful, <0 if failed |
| 166 | */ |
| 167 | bcmos_errno bcm_fld_get_logs(uint32_t device, char **log_area, int *length); |
| 168 | |
| 169 | /** |
| 170 | * \brief Write the received buffer to memory according to offset |
| 171 | * and type |
| 172 | * |
| 173 | * \param[in] device Identifies the device |
| 174 | * \param[in] buff Pointer to the buffer to be written |
| 175 | * \param[in] buff_size Buffer size |
| 176 | * \param[in] offset_in_image offset to write the buffer |
| 177 | * \param[in] image_type Loading type, according to destination : |
| 178 | * SRAM or DDR |
| 179 | * |
| 180 | * \return |
| 181 | * 0 if successful, <0 if failed |
| 182 | */ |
| 183 | bcmos_errno bcm_fld_write(uint32_t device, char *buff, uint32_t buff_size, uint32_t offset_in_image, bcmolt_device_image_type image_type); |
| 184 | |
| 185 | /** |
| 186 | * \brief Read into received buffer from memory according to |
| 187 | * offset and type |
| 188 | * |
| 189 | * \param[in] device Identifies the device |
| 190 | * \param[in] buff Pointer to the buffer to receive the content |
| 191 | * \param[in] buff_size Buffer size |
| 192 | * \param[in] offset_in_image offset to read into the buffer |
| 193 | * \param[in] image_type Loading type, according to destination : |
| 194 | * SRAM or DDR |
| 195 | * |
| 196 | * \return |
| 197 | * 0 if successful, <0 if failed |
| 198 | */ |
| 199 | bcmos_errno bcm_fld_read(uint32_t device, char *buff, uint32_t *buff_size, uint32_t offset_in_image, bcmolt_device_image_type image_type); |
| 200 | |
| 201 | /** |
| 202 | * \brief Take soc cpu out of reset |
| 203 | * |
| 204 | * \param[in] device Identifies the device |
| 205 | * |
| 206 | * \return |
| 207 | * 0 if successful, <0 if failed |
| 208 | */ |
| 209 | bcmos_errno bcm_fld_start_bootloader(uint32_t device, uint32_t test_ddr); |
| 210 | |
| 211 | /** |
| 212 | * \brief Check if bootloader finished to run |
| 213 | * |
| 214 | * \param[in] device Identifies the device |
| 215 | * |
| 216 | * \return |
| 217 | * BCMOS_TRUE if successful, BCMOS_FALSE if failed |
| 218 | */ |
| 219 | bcmos_bool bcm_fld_is_bootloader_done(uint32_t device); |
| 220 | |
| 221 | bcmos_bool bcm_fld_is_ddr_test_done(uint32_t device); |
| 222 | |
| 223 | /** |
| 224 | * \brief Check if SoC finished synchronization process |
| 225 | * |
| 226 | * \param[in] device Identifies the device |
| 227 | * |
| 228 | * \return |
| 229 | */ |
| 230 | bcmos_bool bcm_fld_test_device_bootrecord(uint32_t device); |
| 231 | |
| 232 | /** |
| 233 | * \brief Returns the bootrecord of the SoC |
| 234 | * |
| 235 | * \param[in] device Identifies the device |
| 236 | * \param[in] opaque_data Pointer to information |
| 237 | * - physical address of the buffer descriptors ring |
| 238 | * - physical address of shadow buffer descriptors ring |
| 239 | * info_length MUST be modulo 4 |
| 240 | * |
| 241 | * \return |
| 242 | * 0 if successful, <0 if failed |
| 243 | */ |
| 244 | bcmos_errno bcm_fld_get_device_bootrecord(uint32_t device, uint32_t *opaque_data); |
| 245 | |
| 246 | /** |
| 247 | * \brief Set bootrecord valid bit to be checked by the device |
| 248 | * |
| 249 | * \param[in] device Identifies the device |
| 250 | * \return |
| 251 | * 0 if successful, <0 if failed |
| 252 | */ |
| 253 | bcmos_errno bcm_fld_set_host_bootrecord_flag(uint32_t device); |
| 254 | |
| 255 | /** |
| 256 | * \brief Check bootrecord valid bit set previously by the device |
| 257 | * |
| 258 | * \param[in] device Identifies the device |
| 259 | * \return |
| 260 | * 0 if successful, <0 if failed |
| 261 | */ |
| 262 | bcmos_bool bcm_fld_test_host_bootrecord_flag(uint32_t device); |
| 263 | |
| 264 | /** |
| 265 | * \brief Clear bootrecord valid bit to be checked by the device |
| 266 | * |
| 267 | * \param[in] device Identifies the device |
| 268 | * \return |
| 269 | * 0 if successful, <0 if failed |
| 270 | */ |
| 271 | bcmos_errno bcm_fld_clear_device_bootrecord_flag(uint32_t device); |
| 272 | |
| 273 | /** |
| 274 | * \brief Check bootrecord valid bit set previously by the device |
| 275 | * |
| 276 | * \param[in] device Identifies the device |
| 277 | * \return |
| 278 | * 0 if successful, <0 if failed |
| 279 | */ |
| 280 | bcmos_bool bcm_fld_test_device_bootrecord_flag(uint32_t device); |
| 281 | |
| 282 | /** |
| 283 | * \brief Write the tx and rx queue sizes to communication area |
| 284 | * set queue validity bit for the device |
| 285 | * |
| 286 | * \param[in] device Identifies the device |
| 287 | * \param[in] host_tx_size Queue size : is also the device rx |
| 288 | * queue size |
| 289 | * \param[in] host_rx_size Queue size : is also the device tx |
| 290 | * queue size |
| 291 | * \return |
| 292 | * 0 if successful, <0 if failed |
| 293 | */ |
| 294 | bcmos_errno bcm_fld_set_rings_size(uint32_t device, uint32_t host_tx_size, uint32_t host_rx_size); |
| 295 | |
| 296 | /** |
| 297 | * \brief set DDR RASconfiguration properties |
| 298 | * |
| 299 | * \param[in] device Identifies the device |
| 300 | * |
| 301 | * \param[in] ras Identifies the ras number , can be 0 or 1 |
| 302 | * |
| 303 | * \param[in] mode Identifies mode - disable 0, gpon 1, xgpon 2, |
| 304 | * |
| 305 | * \return |
| 306 | * 0 if successful, <0 if failed |
| 307 | */ |
| 308 | bcmos_errno bcm_fld_set_ras_mode_set(uint32_t device, uint32_t ras, uint32_t mode); |
| 309 | |
| 310 | /** |
| 311 | * \brief Notify device about an event that occurred on the host side |
| 312 | * |
| 313 | * \param[in] device Identifies the device |
| 314 | * |
| 315 | * \param[in] event User defined event |
| 316 | * |
| 317 | * \return |
| 318 | * 0 if successful, <0 if failed |
| 319 | */ |
| 320 | bcmos_errno bcm_fld_set_host_event(uint32_t device, uint32_t event); |
| 321 | |
| 322 | /** |
| 323 | * \brief Check queues valid bit set previously by Host |
| 324 | * |
| 325 | * \param[in] device Identifies the device |
| 326 | * |
| 327 | * \return |
| 328 | * FALSE if PRM_VALID bit is not set, TRUE if PRM_VALID bit is |
| 329 | * set |
| 330 | */ |
| 331 | bcmos_bool bcm_fld_test_queues_flag(uint32_t device); |
| 332 | |
| 333 | /** |
| 334 | * \brief Get the exception area state, set by the device exception |
| 335 | * handler |
| 336 | * |
| 337 | * \param[in] device Identifies the device |
| 338 | * \param[out] state Pointer to exception state on cpu0 value |
| 339 | * \param[out] state Pointer to exception state on cpu1 value |
| 340 | * |
| 341 | * \return |
| 342 | * 0 if successful, <0 if failed |
| 343 | */ |
| 344 | |
| 345 | bcmos_errno bcm_fld_get_exception_state(uint32_t device, uint32_t *state0, uint32_t *state1); |
| 346 | |
| 347 | /** |
| 348 | * \brief Clear the exception area state |
| 349 | * |
| 350 | * \param[in] device Identifies the device |
| 351 | * \param[in] cpuid Identifies the the device cpu |
| 352 | * |
| 353 | * \return |
| 354 | * 0 if successful, <0 if failed |
| 355 | */ |
| 356 | bcmos_errno bcm_fld_clear_exception_state(uint32_t device, uint32_t cpuid); |
| 357 | |
| 358 | /** |
| 359 | * \brief Fill buffer with the exception area content, set by |
| 360 | * the device exception handler |
| 361 | * |
| 362 | * \param[in] device Identifies the device |
| 363 | * \param[in] cpuid Identifies the the device cpu |
| 364 | * \param[out] buffer Pointer to be filled with the exception |
| 365 | * area content |
| 366 | * \param[out] length Length of the buffer |
| 367 | * |
| 368 | * \return |
| 369 | * 0 if successful, <0 if failed |
| 370 | */ |
| 371 | bcmos_errno bcm_fld_copy_exception_log(uint32_t device, uint32_t cpuid, char *buffer, int *length); |
| 372 | |
| 373 | #ifdef TX_ENABLE_EVENT_TRACE |
| 374 | /** |
| 375 | * \brief Set event trace flag to be read by embedded and start |
| 376 | * traceing |
| 377 | * |
| 378 | * \param[in] device Identifies the device |
| 379 | * |
| 380 | * \return |
| 381 | * 0 if successful, <0 if failed |
| 382 | */ |
| 383 | bcmos_errno bcm_fld_set_event_trace(uint32_t device); |
| 384 | |
| 385 | /** |
| 386 | * \brief Clear event trace flag to be read by embedded and stop |
| 387 | * traceing |
| 388 | * |
| 389 | * \param[in] device Identifies the device |
| 390 | * |
| 391 | * \return |
| 392 | * 0 if successful, <0 if failed |
| 393 | */ |
| 394 | bcmos_errno bcm_fld_clear_event_trace(uint32_t device); |
| 395 | #endif |
| 396 | |
| 397 | /** |
| 398 | * \Debug states and functions |
| 399 | */ |
| 400 | typedef struct |
| 401 | { |
| 402 | uint32_t write_sram; |
| 403 | uint32_t start_device; |
| 404 | uint32_t write_ddr; |
| 405 | uint32_t finish_ddr; |
| 406 | } bcm_fld_host_debug_state; |
| 407 | |
| 408 | typedef enum |
| 409 | { |
| 410 | BCM_FLD_HOST_NONE, |
| 411 | BCM_FLD_HOST_WRITE_SRAM, /* set before load image to SRAM */ |
| 412 | BCM_FLD_HOST_START_CPU, /* set before resume ARM */ |
| 413 | BCM_FLD_HOST_WRITE_DDR /* set before load image to DDR */ |
| 414 | } BCM_FLD_HOST_DEBUG_VALUES; |
| 415 | |
| 416 | typedef struct |
| 417 | { |
| 418 | uint32_t boot_from_sram_states; |
| 419 | uint32_t boot_from_sram_errors; |
| 420 | uint32_t boot_from_sram_exception; |
| 421 | uint32_t run_from_ddr_state; |
| 422 | } bcm_fld_device_debug_state; |
| 423 | |
| 424 | /** |
| 425 | * \brief Set and get debugging traceing from communication area |
| 426 | * |
| 427 | * \param[in] device Identifies the device |
| 428 | * \param[in] info Pointer to information |
| 429 | * |
| 430 | * \return |
| 431 | * 0 if successful, <0 if failed |
| 432 | */ |
| 433 | /* returns soc debug states */ |
| 434 | bcmos_errno bcm_fld_get_device_debug_status(uint32_t device, bcm_fld_device_debug_state *info); |
| 435 | /* deal with host states - functional and debug */ |
| 436 | bcmos_errno bcm_fld_get_host_debug_status(uint32_t device, bcm_fld_host_debug_state *info); |
| 437 | bcmos_errno bcm_fld_set_host_debug_status(uint32_t device, BCM_FLD_HOST_DEBUG_VALUES stat); |
| 438 | /** |
| 439 | * \brief Check if swap needed for the respective memory |
| 440 | * |
| 441 | * \param[in] device Identifies the device |
| 442 | * |
| 443 | * \return |
| 444 | * true if swap needed, false if swap not needed |
| 445 | */ |
| 446 | bcmos_bool bcm_fld_regs_swap_needed(uint32_t device); |
| 447 | bcmos_bool bcm_fld_sram_swap_needed(uint32_t device); |
| 448 | bcmos_bool bcm_fld_ddr_swap_needed(uint32_t device); |
| 449 | |
| 450 | bcmos_errno bcm_fld_set_avs_cont(uint32_t device, uint32_t value); |
| 451 | |
| 452 | void *bcm_fld_get_sw_error_table(uint32_t device, uint32_t *size); |
| 453 | uint32_t bcm_fld_ddr_test_result_get(uint32_t device, uint32_t word); |
| 454 | |
| 455 | #endif |
| 456 | |