Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*  MEMSCRUB driver interface
0004  *
0005  *  COPYRIGHT (c) 2017.
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 __MEMSCRUB_H__
0031 #define __MEMSCRUB_H__
0032 
0033 #include <stdint.h>
0034 
0035 #ifdef __cplusplus
0036 extern "C" {
0037 #endif
0038 
0039 #define MEMSCRUB_ERR_OK 0
0040 #define MEMSCRUB_ERR_EINVAL -1
0041 #define MEMSCRUB_ERR_ERROR -2
0042 
0043 extern void memscrub_register_drv(void);
0044 
0045 /* 
0046  * MEMORYSCRUBBER CONFIG register fields
0047  */
0048 #define CONFIG_DELAY_BIT 8
0049 #define CONFIG_IRQD_BIT 7
0050 #define CONFIG_SERA_BIT 5
0051 #define CONFIG_LOOP_BIT 4
0052 #define CONFIG_MODE_BIT 2
0053 #define CONFIG_ES_BIT 1
0054 #define CONFIG_SCEN_BIT 0
0055 
0056 #define CONFIG_DELAY (0xff << CONFIG_DELAY_BIT)
0057 #define CONFIG_IRQD (0x1 << CONFIG_IRQD_BIT)
0058 #define CONFIG_SERA (0x1 << CONFIG_SERA_BIT)
0059 #define CONFIG_LOOP (0x1 << CONFIG_LOOP_BIT)
0060 #define CONFIG_MODE (0x3 << CONFIG_MODE_BIT)
0061 #define CONFIG_ES (0x1 << CONFIG_ES_BIT)
0062 #define CONFIG_SCEN (0x1 << CONFIG_SCEN_BIT)
0063 #define CONFIG_MODE_SCRUB (0x0 << CONFIG_MODE_BIT)
0064 #define CONFIG_MODE_REGEN (0x1 << CONFIG_MODE_BIT)
0065 #define CONFIG_MODE_INIT (0x2 << CONFIG_MODE_BIT)
0066 
0067 #define MEMSCRUB_OPTIONS_INTERRUPTDONE_ENABLE CONFIG_IRQD
0068 #define MEMSCRUB_OPTIONS_INTERRUPTDONE_DISABLE 0
0069 #define MEMSCRUB_OPTIONS_EXTERNALSTART_ENABLE CONFIG_ES
0070 #define MEMSCRUB_OPTIONS_EXTERNALSTART_DISABLE 0
0071 #define MEMSCRUB_OPTIONS_LOOPMODE_ENABLE CONFIG_LOOP
0072 #define MEMSCRUB_OPTIONS_LOOPMODE_DISABLE 0
0073 #define MEMSCRUB_OPTIONS_SECONDARY_MEMRANGE_ENABLE CONFIG_SERA
0074 #define MEMSCRUB_OPTIONS_SECONDARY_MEMRANGE_DISABLE 0
0075 
0076 /* Scrubbing modes */
0077 extern int memscrub_init_start(uint32_t value, uint8_t delay, int options);
0078 extern int memscrub_scrub_start(uint8_t delay, int options);
0079 extern int memscrub_regen_start(uint8_t delay, int options);
0080 extern int memscrub_stop(void);
0081 extern int memscrub_active(void);
0082 
0083 /* Set/get memory ranges */
0084 extern int memscrub_range_set(uint32_t start, uint32_t end);
0085 extern int memscrub_range_get(uint32_t * start, uint32_t * end);
0086 extern int memscrub_secondary_range_set(uint32_t start, uint32_t end);
0087 extern int memscrub_secondary_range_get(uint32_t * start, uint32_t * end);
0088 
0089 /* Interrupts */
0090 /* MEMSCRUB Interrupts */
0091 /* Function Interrupt-Code ISR callback prototype.
0092  * arg     - Custom arg provided by user
0093  * access  - AHB Access that failed
0094  * ahbstatus  - AHB status register of the MEMSCRUB core
0095  * status  - status register of the MEMSCRUB core
0096  */
0097 typedef void (*memscrub_isr_t)(void *arg, uint32_t ahbaccess, 
0098         uint32_t ahbstatus, uint32_t scrubstatus);
0099 extern int memscrub_isr_register(memscrub_isr_t isr, void * data);
0100 extern int memscrub_isr_unregister(void);
0101 
0102 extern int memscrub_error_status(uint32_t *ahbaccess, uint32_t *ahbstatus, 
0103         uint32_t *scrubstatus);
0104 
0105 /* Set the different error thresholds. */
0106 
0107 /* 
0108  * MEMORYSCRUBBER AHBS register fields
0109  */
0110 #define AHBS_CECNT_BIT 22
0111 #define AHBS_UECNT_BIT 14
0112 #define AHBS_DONE_BIT 13
0113 #define AHBS_SEC_BIT 11
0114 #define AHBS_SBC_BIT 10
0115 #define AHBS_CE_BIT 9
0116 #define AHBS_NE_BIT 8
0117 #define AHBS_HW_BIT 7
0118 #define AHBS_HM_BIT 3
0119 #define AHBS_HS_BIT 0
0120 
0121 #define AHBS_CECNT (0x3ff << AHBS_CECNT_BIT)
0122 #define AHBS_UECNT (0xff << AHBS_UECNT_BIT)
0123 #define AHBS_DONE (1 << AHBS_DONE_BIT)
0124 #define AHBS_SEC (1 << AHBS_SEC_BIT)
0125 #define AHBS_SBC (1 << AHBS_SBC_BIT)
0126 #define AHBS_CE (1 << AHBS_CE_BIT)
0127 #define AHBS_NE (1 << AHBS_NE_BIT)
0128 #define AHBS_HW (1 << AHBS_HW_BIT)
0129 #define AHBS_HM (0xf << AHBS_HM_BIT)
0130 #define AHBS_HS (0x7 << AHBS_HS_BIT)
0131 
0132 /* 
0133  * MEMORYSCRUBBER STAT register fields
0134  */
0135 #define STAT_RUNCOUNT_BIT 22
0136 #define STAT_BLKCOUNT_BIT 14
0137 #define STAT_DONE_BIT 13
0138 #define STAT_BURSTLEN_BIT 1
0139 #define STAT_ACTIVE_BIT 0
0140 
0141 #define STAT_RUNCOUNT (0x3ff << STAT_RUNCOUNT_BIT)
0142 #define STAT_BLKCOUNT (0xff << STAT_BLKCOUNT_BIT)
0143 #define STAT_DONE (0x1 << STAT_DONE_BIT)
0144 #define STAT_BURSTLEN (0xf << STAT_BURSTLEN_BIT)
0145 #define STAT_ACTIVE (0x1 << STAT_ACTIVE_BIT)
0146 
0147 /* 
0148  * MEMORYSCRUBBER AHBERC register fields
0149  */
0150 #define AHBERC_CECNTT_BIT 22
0151 #define AHBERC_UECNTT_BIT 14
0152 #define AHBERC_CECTE_BIT 1
0153 #define AHBERC_UECTE_BIT 0
0154 
0155 #define AHBERC_CECNTT (0x3ff << AHBERC_CECNTT_BIT)
0156 #define AHBERC_UECNTT (0xff << AHBERC_UECNTT_BIT)
0157 #define AHBERC_CECTE (0x1 << AHBERC_CECTE_BIT)
0158 #define AHBERC_UECTE (0x1 << AHBERC_UECTE_BIT)
0159 
0160 /* 
0161  * MEMORYSCRUBBER ETHRES register fields
0162  */
0163 #define ETHRES_RECT_BIT 22
0164 #define ETHRES_BECT_BIT 14
0165 #define ETHRES_RECTE_BIT 1
0166 #define ETHRES_BECTE_BIT 0
0167 
0168 #define ETHRES_RECT (0x3ff << ETHRES_RECT_BIT)
0169 #define ETHRES_BECT (0xff << ETHRES_BECT_BIT)
0170 #define ETHRES_RECTE (0x1 << ETHRES_RECTE_BIT)
0171 #define ETHRES_BECTE (0x1 << ETHRES_BECTE_BIT)
0172 
0173 #define MEMSCRUB_OPTIONS_AHBERROR_CORTHRES_ENABLE AHBERC_CECTE
0174 #define MEMSCRUB_OPTIONS_AHBERROR_CORTHRES_DISABLE 0
0175 #define MEMSCRUB_OPTIONS_AHBERROR_UNCORTHRES_ENABLE AHBERC_UECTE
0176 #define MEMSCRUB_OPTIONS_AHBERROR_UNCORTHRES_DISABLE 0
0177 #define MEMSCRUB_OPTIONS_SCRUBERROR_RUNTHRES_ENABLE ETHRES_RECTE
0178 #define MEMSCRUB_OPTIONS_SCRUBERROR_RUNTHRES_DISABLE 0
0179 #define MEMSCRUB_OPTIONS_SCRUBERROR_BLOCKTHRES_ENABLE ETHRES_BECTE
0180 #define MEMSCRUB_OPTIONS_SCRUBERROR_BLOCKTHRES_DISABLE 0
0181 extern int memscrub_ahberror_setup(int uethres, int cethres, int options);
0182 extern int memscrub_scruberror_setup(int blkthres, int runthres, 
0183         int options);
0184 
0185 extern int memscrub_scrub_position(uint32_t * position); 
0186 
0187 #ifdef __cplusplus
0188 }
0189 #endif
0190 
0191 #endif