Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  * RTEMS generic mcf548x BSP
0005  *
0006  * The file contains the diagnostic timer code of generic MCF548x
0007  * BSP.
0008  *
0009  * Parts of the code has been derived from the "dBUG source code"
0010  * package Freescale is providing for M548X EVBs. The usage of
0011  * the modified or unmodified code and it's integration into the
0012  * generic mcf548x BSP has been done according to the Freescale
0013  * license terms.
0014  *
0015  * The Freescale license terms can be reviewed in the file
0016  *
0017  *    LICENSE.Freescale
0018  *
0019  * The generic mcf548x BSP has been developed on the basic
0020  * structures and modules of the av5282 BSP.
0021  */
0022 
0023 /*
0024  * Copyright (c) 2007 embedded brains GmbH & Co. KG
0025  *
0026  * Redistribution and use in source and binary forms, with or without
0027  * modification, are permitted provided that the following conditions
0028  * are met:
0029  * 1. Redistributions of source code must retain the above copyright
0030  *    notice, this list of conditions and the following disclaimer.
0031  * 2. Redistributions in binary form must reproduce the above copyright
0032  *    notice, this list of conditions and the following disclaimer in the
0033  *    documentation and/or other materials provided with the distribution.
0034  *
0035  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0036  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0037  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0038  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0039  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0040  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0041  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0042  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0043  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0044  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0045  * POSSIBILITY OF SUCH DAMAGE.
0046  */
0047 
0048 /*
0049  *  Timer Init
0050  *
0051  *  Use the second slice timer (SLT1) as the diagnostic timer.
0052  */
0053 
0054 #include <rtems.h>
0055 #include <rtems/btimer.h>
0056 #include <bsp.h>
0057 #include <mcf548x/mcf548x.h>
0058 
0059 bool benchmark_timer_find_average_overhead;
0060 static uint32_t microsecond_timer_value = 0;
0061 
0062 void benchmark_timer_initialize(void)
0063 {
0064     MCF548X_SLT_SLTCNT1 = 0xFFFFFFFF;
0065     MCF548X_SLT_SCR1 |= (MCF548X_SLT_SCR_TEN | MCF548X_SLT_SCR_RUN);
0066 }
0067 
0068 /*
0069  * Return timer value in microsecond units
0070  * XLB clock 100 MHz / 1us is equal to 100 counts
0071  */
0072 uint32_t
0073 benchmark_timer_read(void)
0074 {
0075     microsecond_timer_value = (0xFFFFFFFF - MCF548X_SLT_SCNT1)/100;
0076 
0077     return microsecond_timer_value;
0078 }
0079 
0080 void
0081 benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
0082 {
0083     benchmark_timer_find_average_overhead = find_flag;
0084 }