Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSBSPsARMTMS570
0007  *
0008  * @brief This header file provides a TM27 support implementation.
0009  */
0010 
0011 /*
0012  * Copyright (c) 2023 embedded brains GmbH & Co. KG
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #ifndef _RTEMS_TMTEST27
0037 #error "This is an RTEMS internal file you must not include directly."
0038 #endif
0039 
0040 #ifndef __tm27_h
0041 #define __tm27_h
0042 
0043 #include <rtems.h>
0044 
0045 #include <bsp/irq.h>
0046 #include <bsp/tms570.h>
0047 #include <rtems/score/armv4.h>
0048 
0049 #define MUST_WAIT_FOR_INTERRUPT 1
0050 
0051 #define TM27_INTERRUPT_VECTOR_DEFAULT TMS570_IRQ_TIMER_3
0052 
0053 #define TM27_INTERRUPT_VECTOR_ALTERNATIVE TMS570_IRQ_TIMER_1
0054 
0055 static inline void Install_tm27_vector( rtems_interrupt_handler handler )
0056 {
0057   static rtems_interrupt_entry entry_2;
0058   static rtems_interrupt_entry entry_3;
0059 
0060   TMS570_RTI.CNT[1].CPUCx = 1;
0061   TMS570_RTI.CNT[1].UCx = 0;
0062   TMS570_RTI.CNT[1].FRCx = 0;
0063   TMS570_RTI.CMP[1].COMPx = 1;
0064   TMS570_RTI.CMP[1].UDCPx = 1;
0065   TMS570_RTI.CMP[2].COMPx = 1;
0066   TMS570_RTI.CMP[2].UDCPx = 1;
0067   TMS570_RTI.CMP[3].COMPx = 1;
0068   TMS570_RTI.CMP[3].UDCPx = 1;
0069   TMS570_RTI.COMPCTRL |= TMS570_RTI_COMPCTRL_COMPSEL1 |
0070     TMS570_RTI_COMPCTRL_COMPSEL2 |
0071     TMS570_RTI_COMPCTRL_COMPSEL3;
0072   TMS570_RTI.GCTRL |= TMS570_RTI_GCTRL_CNT1EN;
0073 
0074   rtems_interrupt_entry_initialize(
0075     &entry_2,
0076     handler,
0077     NULL,
0078     "tm27"
0079   );
0080   (void) rtems_interrupt_entry_install(
0081     TMS570_IRQ_TIMER_2,
0082     RTEMS_INTERRUPT_SHARED,
0083     &entry_2
0084   );
0085 
0086   rtems_interrupt_entry_initialize(
0087     &entry_3,
0088     handler,
0089     NULL,
0090     "tm27"
0091   );
0092   (void) rtems_interrupt_entry_install(
0093     TMS570_IRQ_TIMER_3,
0094     RTEMS_INTERRUPT_SHARED,
0095     &entry_3
0096   );
0097 }
0098 
0099 static inline void Cause_tm27_intr(void)
0100 {
0101   TMS570_RTI.SETINTENA = TMS570_RTI_SETINTENA_SETINT3;
0102 }
0103 
0104 static inline void Clear_tm27_intr(void)
0105 {
0106   TMS570_RTI.CLEARINTENA = TMS570_RTI_CLEARINTENA_CLEARINT2 |
0107     TMS570_RTI_CLEARINTENA_CLEARINT3;
0108 }
0109 
0110 static inline void Lower_tm27_intr(void)
0111 {
0112   TMS570_RTI.SETINTENA = TMS570_RTI_SETINTENA_SETINT2;
0113   (void) _ARMV4_Status_irq_enable();
0114 }
0115 
0116 static inline rtems_status_code _TM27_Raise_alternative(void)
0117 {
0118   TMS570_RTI.SETINTENA = TMS570_RTI_SETINTENA_SETINT1;
0119   return RTEMS_SUCCESSFUL;
0120 }
0121 
0122 static inline rtems_status_code _TM27_Clear_alternative(void)
0123 {
0124   TMS570_RTI.CLEARINTENA = TMS570_RTI_CLEARINTENA_CLEARINT1;
0125   return RTEMS_SUCCESSFUL;
0126 }
0127 
0128 #endif /* __tm27_h */