Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:42

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*  AHBSTAT driver interface
0004  *
0005  *  COPYRIGHT (c) 2011.
0006  *  Cobham Gaisler AB.
0007  *
0008  * Redistribution and use in source and binary forms, with or without
0009  * modification, are permitted provided that the following conditions
0010  * are met:
0011  * 1. Redistributions of source code must retain the above copyright
0012  *    notice, this list of conditions and the following disclaimer.
0013  * 2. Redistributions in binary form must reproduce the above copyright
0014  *    notice, this list of conditions and the following disclaimer in the
0015  *    documentation and/or other materials provided with the distribution.
0016  *
0017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0027  * POSSIBILITY OF SUCH DAMAGE.
0028  */
0029 
0030 #ifndef __AHBSTAT_H__
0031 #define __AHBSTAT_H__
0032 
0033 #include <stdint.h>
0034 
0035 #ifdef __cplusplus
0036 extern "C" {
0037 #endif
0038 
0039 /* AHBSTAT Registers layout */
0040 struct ahbstat_regs {
0041     volatile uint32_t status;
0042     volatile uint32_t failing;
0043     volatile uint32_t status2;
0044     volatile uint32_t failing2;
0045 };
0046 
0047 /* AHB fail interrupt callback to user. This function is declared weak so that
0048  * the user can define a function pointer variable containing the address
0049  * responsible for handling errors
0050  *
0051  * minor              Index of AHBSTAT hardware
0052  * regs               Register address of AHBSTAT
0053  * status             AHBSTAT status register at IRQ
0054  * failing_address    AHBSTAT Failing address register at IRQ
0055  *
0056  * * User return 
0057  *  0: print error onto terminal with printk and reenable AHBSTAT
0058  *  1: just re-enable AHBSTAT
0059  *  2: just print error
0060  *  3: do nothing, let user do custom handling
0061  */
0062 extern int (*ahbstat_error)(
0063     int minor,
0064     struct ahbstat_regs *regs,
0065     uint32_t status,
0066     uint32_t failing_address);
0067 
0068 /* Get Last received AHB Error
0069  *
0070  * \param minor    Index used to indentify a specific AHBSTAT core
0071  * \param status   Status register at time of error IRQ was recevied
0072  * \param address  Failing address register at time of error IRQ
0073  *
0074  * Return
0075  *   0: No error received
0076  *   1: Error Received, last status and address stored into argument pointers
0077  *  -1: No such AHBSTAT device
0078  */
0079 extern int ahbstat_last_error(int minor, uint32_t *status, uint32_t *address);
0080 
0081 /* Get AHBSTAT registers address from minor. Can also be used to check if
0082  * AHBSTAT hardware is present.
0083  *
0084  * Return 
0085  *   NULL       returned if no such device
0086  *   non-zero   Address to AHBSTAT register
0087  */
0088 extern struct ahbstat_regs *ahbstat_get_regs(int minor);
0089 
0090 /* Registers the AHBSTAT driver to the Driver Manager */
0091 void ahbstat_register_drv (void);
0092 
0093 #ifdef __cplusplus
0094 }
0095 #endif
0096 
0097 #endif