Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | /* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2020 Marvell International Ltd. * * Interface to the Octeon extended error status. */ #ifndef __CVMX_ERROR_H__ #define __CVMX_ERROR_H__ /** * There are generally many error status bits associated with a * single logical group. The enumeration below is used to * communicate high level groups to the error infastructure so * error status bits can be enable or disabled in large groups. */ typedef enum { CVMX_ERROR_GROUP_INTERNAL, CVMX_ERROR_GROUP_L2C, CVMX_ERROR_GROUP_ETHERNET, CVMX_ERROR_GROUP_MGMT_PORT, CVMX_ERROR_GROUP_PCI, CVMX_ERROR_GROUP_SRIO, CVMX_ERROR_GROUP_USB, CVMX_ERROR_GROUP_LMC, CVMX_ERROR_GROUP_ILK, CVMX_ERROR_GROUP_DFM, CVMX_ERROR_GROUP_ILA, } cvmx_error_group_t; /** * Flags representing special handling for some error registers. * These flags are passed to cvmx_error_initialize() to control * the handling of bits where the same flags were passed to the * added cvmx_error_info_t. */ typedef enum { CVMX_ERROR_TYPE_NONE = 0, CVMX_ERROR_TYPE_SBE = 1 << 0, CVMX_ERROR_TYPE_DBE = 1 << 1, } cvmx_error_type_t; /** * When registering for interest in an error status register, the * type of the register needs to be known by cvmx-error. Most * registers are either IO64 or IO32, but some blocks contain * registers that can't be directly accessed. A good example of * would be PCIe extended error state stored in config space. */ typedef enum { __CVMX_ERROR_REGISTER_NONE, CVMX_ERROR_REGISTER_IO64, CVMX_ERROR_REGISTER_IO32, CVMX_ERROR_REGISTER_PCICONFIG, CVMX_ERROR_REGISTER_SRIOMAINT, } cvmx_error_register_t; struct cvmx_error_info; /** * Error handling functions must have the following prototype. */ typedef int (*cvmx_error_func_t)(const struct cvmx_error_info *info); /** * This structure is passed to all error handling functions. */ typedef struct cvmx_error_info { cvmx_error_register_t reg_type; u64 status_addr; u64 status_mask; u64 enable_addr; u64 enable_mask; cvmx_error_type_t flags; cvmx_error_group_t group; int group_index; cvmx_error_func_t func; u64 user_info; struct { cvmx_error_register_t reg_type; u64 status_addr; u64 status_mask; } parent; } cvmx_error_info_t; /** * Initialize the error status system. This should be called once * before any other functions are called. This function adds default * handlers for most all error events but does not enable them. Later * calls to cvmx_error_enable() are needed. * * @param flags Optional flags. * * Return: Zero on success, negative on failure. */ int cvmx_error_initialize(void); /** * Poll the error status registers and call the appropriate error * handlers. This should be called in the RSL interrupt handler * for your application or operating system. * * Return: Number of error handlers called. Zero means this call * found no errors and was spurious. */ int cvmx_error_poll(void); /** * Register to be called when an error status bit is set. Most users * will not need to call this function as cvmx_error_initialize() * registers default handlers for most error conditions. This function * is normally used to add more handlers without changing the existing * handlers. * * @param new_info Information about the handler for a error register. The * structure passed is copied and can be destroyed after the * call. All members of the structure must be populated, even the * parent information. * * Return: Zero on success, negative on failure. */ int cvmx_error_add(const cvmx_error_info_t *new_info); /** * Remove all handlers for a status register and mask. Normally * this function should not be called. Instead a new handler should be * installed to replace the existing handler. In the even that all * reporting of a error bit should be removed, then use this * function. * * @param reg_type Type of the status register to remove * @param status_addr * Status register to remove. * @param status_mask * All handlers for this status register with this mask will be * removed. * @param old_info If not NULL, this is filled with information about the handler * that was removed. * * Return: Zero on success, negative on failure (not found). */ int cvmx_error_remove(cvmx_error_register_t reg_type, u64 status_addr, u64 status_mask, cvmx_error_info_t *old_info); /** * Change the function and user_info for an existing error status * register. This function should be used to replace the default * handler with an application specific version as needed. * * @param reg_type Type of the status register to change * @param status_addr * Status register to change. * @param status_mask * All handlers for this status register with this mask will be * changed. * @param new_func New function to use to handle the error status * @param new_user_info * New user info parameter for the function * @param old_func If not NULL, the old function is returned. Useful for restoring * the old handler. * @param old_user_info * If not NULL, the old user info parameter. * * Return: Zero on success, negative on failure */ int cvmx_error_change_handler(cvmx_error_register_t reg_type, u64 status_addr, u64 status_mask, cvmx_error_func_t new_func, u64 new_user_info, cvmx_error_func_t *old_func, u64 *old_user_info); /** * Enable all error registers for a logical group. This should be * called whenever a logical group is brought online. * * @param group Logical group to enable * @param group_index * Index for the group as defined in the cvmx_error_group_t * comments. * * Return: Zero on success, negative on failure. */ /* * Rather than conditionalize the calls throughout the executive to not enable * interrupts in Uboot, simply make the enable function do nothing */ static inline int cvmx_error_enable_group(cvmx_error_group_t group, int group_index) { return 0; } /** * Disable all error registers for a logical group. This should be * called whenever a logical group is brought offline. Many blocks * will report spurious errors when offline unless this function * is called. * * @param group Logical group to disable * @param group_index * Index for the group as defined in the cvmx_error_group_t * comments. * * Return: Zero on success, negative on failure. */ /* * Rather than conditionalize the calls throughout the executive to not disable * interrupts in Uboot, simply make the enable function do nothing */ static inline int cvmx_error_disable_group(cvmx_error_group_t group, int group_index) { return 0; } /** * Enable all handlers for a specific status register mask. * * @param reg_type Type of the status register * @param status_addr * Status register address * @param status_mask * All handlers for this status register with this mask will be * enabled. * * Return: Zero on success, negative on failure. */ int cvmx_error_enable(cvmx_error_register_t reg_type, u64 status_addr, u64 status_mask); /** * Disable all handlers for a specific status register and mask. * * @param reg_type Type of the status register * @param status_addr * Status register address * @param status_mask * All handlers for this status register with this mask will be * disabled. * * Return: Zero on success, negative on failure. */ int cvmx_error_disable(cvmx_error_register_t reg_type, u64 status_addr, u64 status_mask); /** * @INTERNAL * Function for processing non leaf error status registers. This function * calls all handlers for this passed register and all children linked * to it. * * @param info Error register to check * * Return: Number of error status bits found or zero if no bits were set. */ int __cvmx_error_decode(const cvmx_error_info_t *info); /** * @INTERNAL * This error bit handler simply prints a message and clears the status bit * * @param info Error register to check * * @return */ int __cvmx_error_display(const cvmx_error_info_t *info); /** * Find the handler for a specific status register and mask * * @param status_addr * Status register address * * Return: Return the handler on success or null on failure. */ cvmx_error_info_t *cvmx_error_get_index(u64 status_addr); void __cvmx_install_gmx_error_handler_for_xaui(void); /** * 78xx related */ /** * Compare two INTSN values. * * @param key INTSN value to search for * @param data current entry from the searched array * * Return: Negative, 0 or positive when respectively key is less than, * equal or greater than data. */ int cvmx_error_intsn_cmp(const void *key, const void *data); /** * @INTERNAL * * @param intsn Interrupt source number to display * * @param node Node number * * Return: Zero on success, -1 on error */ int cvmx_error_intsn_display_v3(int node, u32 intsn); /** * Initialize the error status system for cn78xx. This should be called once * before any other functions are called. This function enables the interrupts * described in the array. * * @param node Node number * * Return: Zero on success, negative on failure. */ int cvmx_error_initialize_cn78xx(int node); /** * Enable interrupt for a specific INTSN. * * @param node Node number * @param intsn Interrupt source number * * Return: Zero on success, negative on failure. */ int cvmx_error_intsn_enable_v3(int node, u32 intsn); /** * Disable interrupt for a specific INTSN. * * @param node Node number * @param intsn Interrupt source number * * Return: Zero on success, negative on failure. */ int cvmx_error_intsn_disable_v3(int node, u32 intsn); /** * Clear interrupt for a specific INTSN. * * @param intsn Interrupt source number * * Return: Zero on success, negative on failure. */ int cvmx_error_intsn_clear_v3(int node, u32 intsn); /** * Enable interrupts for a specific CSR(all the bits/intsn in the csr). * * @param node Node number * @param csr_address CSR address * * Return: Zero on success, negative on failure. */ int cvmx_error_csr_enable_v3(int node, u64 csr_address); /** * Disable interrupts for a specific CSR (all the bits/intsn in the csr). * * @param node Node number * @param csr_address CSR address * * Return: Zero */ int cvmx_error_csr_disable_v3(int node, u64 csr_address); /** * Enable all error registers for a logical group. This should be * called whenever a logical group is brought online. * * @param group Logical group to enable * @param xipd_port The IPD port value * * Return: Zero. */ int cvmx_error_enable_group_v3(cvmx_error_group_t group, int xipd_port); /** * Disable all error registers for a logical group. * * @param group Logical group to enable * @param xipd_port The IPD port value * * Return: Zero. */ int cvmx_error_disable_group_v3(cvmx_error_group_t group, int xipd_port); /** * Enable all error registers for a specific category in a logical group. * This should be called whenever a logical group is brought online. * * @param group Logical group to enable * @param type Category in a logical group to enable * @param xipd_port The IPD port value * * Return: Zero. */ int cvmx_error_enable_group_type_v3(cvmx_error_group_t group, cvmx_error_type_t type, int xipd_port); /** * Disable all error registers for a specific category in a logical group. * This should be called whenever a logical group is brought online. * * @param group Logical group to disable * @param type Category in a logical group to disable * @param xipd_port The IPD port value * * Return: Zero. */ int cvmx_error_disable_group_type_v3(cvmx_error_group_t group, cvmx_error_type_t type, int xipd_port); /** * Clear all error registers for a logical group. * * @param group Logical group to disable * @param xipd_port The IPD port value * * Return: Zero. */ int cvmx_error_clear_group_v3(cvmx_error_group_t group, int xipd_port); /** * Enable all error registers for a particular category. * * @param node CCPI node * @param type category to enable * *Return: Zero. */ int cvmx_error_enable_type_v3(int node, cvmx_error_type_t type); /** * Disable all error registers for a particular category. * * @param node CCPI node * @param type category to disable * *Return: Zero. */ int cvmx_error_disable_type_v3(int node, cvmx_error_type_t type); void cvmx_octeon_hang(void) __attribute__((__noreturn__)); /** * @INTERNAL * * Process L2C single and multi-bit ECC errors * */ int __cvmx_cn7xxx_l2c_l2d_ecc_error_display(int node, int intsn); /** * Handle L2 cache TAG ECC errors and noway errors * * @param CCPI node * @param intsn intsn from error array. * @param remote true for remote node (cn78xx only) * * Return: 1 if handled, 0 if not handled */ int __cvmx_cn7xxx_l2c_tag_error_display(int node, int intsn, bool remote); #endif |