Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:00

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *
0005  * Copyright (C) 2024 Kevin Kirspel
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
0017  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0019  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
0020  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0021  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
0022  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0023  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0024  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
0025  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0026  * SUCH DAMAGE.
0027  */
0028 
0029 /******************************************************************************
0030 *                                                                             *
0031 * License Agreement                                                           *
0032 *                                                                             *
0033 * Copyright (c) 2008 Altera Corporation, San Jose, California, USA.           *
0034 * All rights reserved.                                                        *
0035 *                                                                             *
0036 * Permission is hereby granted, free of charge, to any person obtaining a     *
0037 * copy of this software and associated documentation files (the "Software"),  *
0038 * to deal in the Software without restriction, including without limitation   *
0039 * the rights to use, copy, modify, merge, publish, distribute, sublicense,    *
0040 * and/or sell copies of the Software, and to permit persons to whom the       *
0041 * Software is furnished to do so, subject to the following conditions:        *
0042 *                                                                             *
0043 * The above copyright notice and this permission notice shall be included in  *
0044 * all copies or substantial portions of the Software.                         *
0045 *                                                                             *
0046 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  *
0047 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,    *
0048 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
0049 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      *
0050 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING     *
0051 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER         *
0052 * DEALINGS IN THE SOFTWARE.                                                   *
0053 *                                                                             *
0054 * This agreement shall be governed in all respects by the laws of the State   *
0055 * of California and by the laws of the United States of America.              *
0056 *                                                                             *
0057 ******************************************************************************/
0058 
0059 #ifndef __ALTERA_AVALON_TIMER_REGS_H__
0060 #define __ALTERA_AVALON_TIMER_REGS_H__
0061 
0062 #include <bsp_system.h>
0063 
0064 #ifdef __cplusplus
0065 extern "C" {
0066 #endif
0067 
0068 #define ALTERA_AVALON_TIMER_STATUS_TO_MSK             (0x1)
0069 #define ALTERA_AVALON_TIMER_STATUS_TO_OFST            (0)
0070 #define ALTERA_AVALON_TIMER_STATUS_RUN_MSK            (0x2)
0071 #define ALTERA_AVALON_TIMER_STATUS_RUN_OFST           (1)
0072 
0073 #define ALTERA_AVALON_TIMER_CONTROL_ITO_MSK           (0x1)
0074 #define ALTERA_AVALON_TIMER_CONTROL_ITO_OFST          (0)
0075 #define ALTERA_AVALON_TIMER_CONTROL_CONT_MSK          (0x2)
0076 #define ALTERA_AVALON_TIMER_CONTROL_CONT_OFST         (1)
0077 #define ALTERA_AVALON_TIMER_CONTROL_START_MSK         (0x4)
0078 #define ALTERA_AVALON_TIMER_CONTROL_START_OFST        (2)
0079 #define ALTERA_AVALON_TIMER_CONTROL_STOP_MSK          (0x8)
0080 #define ALTERA_AVALON_TIMER_CONTROL_STOP_OFST         (3)
0081 
0082 #define ALTERA_AVALON_TIMER_PERIODL_MSK             (0xFFFF)
0083 #define ALTERA_AVALON_TIMER_PERIODL_OFST            (0)
0084 
0085 #define ALTERA_AVALON_TIMER_PERIODH_MSK             (0xFFFF)
0086 #define ALTERA_AVALON_TIMER_PERIODH_OFST            (0)
0087 
0088 #define ALTERA_AVALON_TIMER_SNAPL_MSK               (0xFFFF)
0089 #define ALTERA_AVALON_TIMER_SNAPL_OFST              (0)
0090 
0091 #define ALTERA_AVALON_TIMER_SNAPH_MSK               (0xFFFF)
0092 #define ALTERA_AVALON_TIMER_SNAPH_OFST              (0)
0093 
0094 #define ALTERA_AVALON_TIMER_PERIOD_0_MSK             (0xFFFF)
0095 #define ALTERA_AVALON_TIMER_PERIOD_0_OFST            (0)
0096 
0097 #define ALTERA_AVALON_TIMER_PERIOD_1_MSK             (0xFFFF)
0098 #define ALTERA_AVALON_TIMER_PERIOD_1_OFST            (0)
0099 
0100 #define ALTERA_AVALON_TIMER_PERIOD_2_MSK             (0xFFFF)
0101 #define ALTERA_AVALON_TIMER_PERIOD_2_OFST            (0)
0102 
0103 #define ALTERA_AVALON_TIMER_PERIOD_3_MSK             (0xFFFF)
0104 #define ALTERA_AVALON_TIMER_PERIOD_3_OFST            (0)
0105 
0106 #define ALTERA_AVALON_TIMER_SNAP_0_MSK               (0xFFFF)
0107 #define ALTERA_AVALON_TIMER_SNAP_0_OFST              (0)
0108 
0109 #define ALTERA_AVALON_TIMER_SNAP_1_MSK               (0xFFFF)
0110 #define ALTERA_AVALON_TIMER_SNAP_1_OFST              (0)
0111 
0112 #define ALTERA_AVALON_TIMER_SNAP_2_MSK               (0xFFFF)
0113 #define ALTERA_AVALON_TIMER_SNAP_2_OFST              (0)
0114 
0115 #define ALTERA_AVALON_TIMER_SNAP_3_MSK               (0xFFFF)
0116 #define ALTERA_AVALON_TIMER_SNAP_3_OFST              (0)
0117 
0118 #define MTIMECMP_MAX_VALUE                            0xFFFFFFFFFFFFFFFF
0119 
0120 typedef struct
0121 {
0122   volatile uint32_t status;
0123   volatile uint32_t control;
0124   volatile uint32_t period_lo;
0125   volatile uint32_t period_hi;
0126   volatile uint32_t snap_lo;
0127   volatile uint32_t snap_hi;
0128 }altera_avalon_timer_regs_32;
0129 
0130 typedef struct
0131 {
0132   volatile uint32_t status;
0133   volatile uint32_t control;
0134   volatile uint32_t period_0;
0135   volatile uint32_t period_1;
0136   volatile uint32_t period_2;
0137   volatile uint32_t period_3;
0138   volatile uint32_t snap_0;
0139   volatile uint32_t snap_1;
0140   volatile uint32_t snap_2;
0141   volatile uint32_t snap_3;
0142 }altera_avalon_timer_regs_64;
0143 
0144 typedef struct
0145 {
0146   volatile uint32_t status;
0147   volatile uint32_t control;
0148   volatile uint32_t period;
0149   volatile uint32_t snap;
0150   volatile uint32_t prescalar;
0151 }altera_avalon_timer_precale_regs;
0152 
0153 typedef struct
0154 {
0155   volatile uint32_t mtimecmp_lo;
0156   volatile uint32_t mtimecmp_hi;
0157   volatile uint32_t mtime_lo;
0158   volatile uint32_t mtime_hi;
0159 }altera_niosv_timer_regs;
0160 
0161 #define CLOCK_REGS \
0162   ((volatile altera_niosv_timer_regs* )ALT_CPU_MTIME_OFFSET)
0163 #define CLOCK_FREQ      ALT_CPU_FREQ
0164 #define CLOCK_VECTOR    NIOSV_INTERRUPT_VECTOR_TIMER
0165 
0166 #define TIMER_REGS \
0167   ((volatile altera_avalon_timer_precale_regs* )BENCHMARK_TIMER_BASE)
0168 #define TIMER_FREQ      BENCHMARK_TIMER_FREQ
0169 #define TIMER_VECTOR    BENCHMARK_TIMER_IRQ
0170 
0171 #define WATCHDOG_REGS \
0172   ((volatile altera_avalon_timer_regs_32* )WATCHDOG_TIMER_BASE)
0173 #define WATCHDOG_FREQ   WATCHDOG_TIMER_FREQ
0174 #define WATCHDOG_VECTOR WATCHDOG_TIMER_IRQ
0175 
0176 #ifdef __cplusplus
0177 }
0178 #endif
0179 
0180 #endif /* __ALTERA_AVALON_TIMER_REGS_H__ */