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 clock driver code of generic MCF548x BSP. |
0007  *
0008  * Parts of the code has been derived from the "dBUG source code"
0009  * package Freescale is providing for M548X EVBs. The usage of
0010  * the modified or unmodified code and it's integration into the
0011  * generic mcf548x BSP has been done according to the Freescale
0012  * license terms.
0013  *
0014  * The Freescale license terms can be reviewed in the file
0015  *
0016  *    LICENSE.Freescale
0017  *
0018  * The generic mcf548x BSP has been developed on the basic
0019  * structures and modules of the av5282 BSP.
0020  */
0021 
0022 /*
0023  * Copyright (c) 2008 embedded brains GmbH & Co. KG
0024  *
0025  * Redistribution and use in source and binary forms, with or without
0026  * modification, are permitted provided that the following conditions
0027  * are met:
0028  * 1. Redistributions of source code must retain the above copyright
0029  *    notice, this list of conditions and the following disclaimer.
0030  * 2. Redistributions in binary form must reproduce the above copyright
0031  *    notice, this list of conditions and the following disclaimer in the
0032  *    documentation and/or other materials provided with the distribution.
0033  *
0034  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0035  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0036  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0037  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0038  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0039  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0040  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0041  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0042  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0043  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0044  * POSSIBILITY OF SUCH DAMAGE.
0045  */
0046 
0047 /*
0048  * Use first slice timer (SLT0) as the system clock.
0049  *
0050  */
0051 
0052 #include <rtems.h>
0053 #include <bsp.h>
0054 #include <bsp/irq-generic.h>
0055 #include <mcf548x/mcf548x.h>
0056 
0057 /*
0058  * Use SLT 0
0059  */
0060 #define CLOCK_IRQ MCF548X_IRQ_SLT0
0061 
0062 /*
0063  * Periodic interval timer interrupt handler
0064  */
0065 #define Clock_driver_support_at_tick(arg)          \
0066     do {                                           \
0067         MCF548X_SLT_SSR0 = MCF548X_SLT_SSR_ST;     \
0068     } while (0)                                    \
0069 
0070 /*
0071  * Attach clock interrupt handler
0072  */
0073 #define Clock_driver_support_install_isr( _new ) \
0074     set_vector(_new, CLOCK_IRQ + 64, 1)
0075 
0076 /*
0077  * Set up the clock hardware
0078  *
0079  * We need to have 1 interrupt every 10,000 microseconds
0080  * XLB clock 100 MHz / MCF548X_SLT_SLTCNT0 = XLB clock/100
0081  */
0082 #define Clock_driver_support_initialize_hardware()          \
0083   do {                                  \
0084     bsp_interrupt_vector_enable(CLOCK_IRQ);             \
0085     MCF548X_SLT_SLTCNT0 = get_CPU_clock_speed()             \
0086       / 1000                                \
0087       * rtems_configuration_get_microseconds_per_tick()         \
0088       / 1000;                               \
0089     MCF548X_SLT_SCR0 |= (MCF548X_SLT_SCR_TEN | MCF548X_SLT_SCR_RUN | MCF548X_SLT_SCR_IEN); \
0090   } while (0)
0091 
0092 #define CLOCK_DRIVER_USE_DUMMY_TIMECOUNTER
0093 
0094 #include "../../../shared/dev/clock/clockimpl.h"
0095