source: rtems/bsps/powerpc/gen83xx/start/bspstart.c @ fe8b4b6c

Last change on this file since fe8b4b6c was fe8b4b6c, checked in by Joel Sherrill <joel@…>, on 07/11/22 at 22:28:07

bsps/powerpc/83xx: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup mpc83xx
7 *
8 * @brief Source for BSP startup code.
9 */
10
11/*
12 * Copyright (c) 2008-2014 embedded brains GmbH.  All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 *    notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 *    notice, this list of conditions and the following disclaimer in the
21 *    documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#include <rtems/counter.h>
37
38#include <libchip/ns16550.h>
39
40#include <libcpu/powerpc-utility.h>
41
42#include <bsp.h>
43#include <bsp/vectors.h>
44#include <bsp/bootcard.h>
45#include <bsp/irq-generic.h>
46#include <bsp/linker-symbols.h>
47#include <bsp/u-boot.h>
48#include <bsp/console-termios.h>
49
50/* Configuration parameters for console driver, ... */
51unsigned int BSP_bus_frequency;
52
53/* Configuration parameter for clock driver */
54uint32_t bsp_time_base_frequency;
55
56/* Legacy */
57uint32_t bsp_clicks_per_usec;
58
59/* Default decrementer exception handler */
60static int mpc83xx_decrementer_exception_handler( BSP_Exception_frame *frame, unsigned number)
61{
62  ppc_set_decrementer_register(UINT32_MAX);
63
64  return 0;
65}
66
67uint32_t _CPU_Counter_frequency(void)
68{
69  return bsp_time_base_frequency;
70}
71
72void bsp_start( void)
73{
74  rtems_status_code sc = RTEMS_SUCCESSFUL;
75  unsigned long i = 0;
76
77  /*
78   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
79   * store the result in global variables so that it can be used latter...
80   */
81  get_ppc_cpu_type();
82  get_ppc_cpu_revision();
83
84  /* Basic CPU initialization */
85  cpu_init();
86
87  /*
88   * Enable instruction and data caches. Do not force writethrough mode.
89   */
90
91#ifdef BSP_INSTRUCTION_CACHE_ENABLED
92  rtems_cache_enable_instruction();
93#endif
94
95#ifdef BSP_DATA_CACHE_ENABLED
96  rtems_cache_enable_data();
97#endif
98
99  /*
100   * This is evaluated during runtime, so it should be ok to set it
101   * before we initialize the drivers.
102   */
103
104  /* Initialize some device driver parameters */
105
106#ifdef HAS_UBOOT
107  BSP_bus_frequency = bsp_uboot_board_info.bi_busfreq;
108#else /* HAS_UBOOT */
109  BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID;
110#endif /* HAS_UBOOT */
111  bsp_time_base_frequency = BSP_bus_frequency / 4;
112  bsp_clicks_per_usec = bsp_time_base_frequency / 1000000;
113
114  /* Initialize some console parameters */
115  for (i = 0; i < console_device_count; ++i) {
116    ns16550_context *ctx = (ns16550_context *) console_device_table[i].context;
117
118    ctx->clock = BSP_bus_frequency;
119
120    #ifdef HAS_UBOOT
121      ctx->initial_baud = bsp_uboot_board_info.bi_baudrate;
122    #endif
123  }
124
125  /* Initialize exception handler */
126#ifndef BSP_DATA_CACHE_ENABLED
127  ppc_exc_cache_wb_check = 0;
128#endif
129  ppc_exc_initialize();
130
131  /* Install default handler for the decrementer exception */
132  sc = ppc_exc_set_handler( ASM_DEC_VECTOR, mpc83xx_decrementer_exception_handler);
133  if (sc != RTEMS_SUCCESSFUL) {
134    rtems_panic("cannot install decrementer exception handler");
135  }
136
137  /* Initalize interrupt support */
138  bsp_interrupt_initialize();
139
140#ifdef SHOW_MORE_INIT_SETTINGS
141  printk("Exit from bspstart\n");
142#endif
143}
Note: See TracBrowser for help on using the repository browser.