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

5
Last change on this file since 65f868c was 65f868c, checked in by Sebastian Huber <sebastian.huber@…>, on May 23, 2018 at 12:17:25 PM

Add _CPU_Counter_frequency()

Add rtems_counter_frequency() API function. Use it to initialize the
counter value converter via the new system initialization step
(RTEMS_SYSINIT_CPU_COUNTER). This decouples the counter implementation
and the counter converter. It avoids an unnecessary pull in of the
64-bit integer division from libgcc.

Update #3456.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup mpc83xx
5 *
6 * @brief Source for BSP startup code.
7 */
8
9/*
10 * Copyright (c) 2008-2014 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Dornierstr. 4
14 *  82178 Puchheim
15 *  Germany
16 *  <info@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#include <rtems/counter.h>
24
25#include <libchip/ns16550.h>
26
27#include <libcpu/powerpc-utility.h>
28
29#include <bsp.h>
30#include <bsp/vectors.h>
31#include <bsp/bootcard.h>
32#include <bsp/irq-generic.h>
33#include <bsp/linker-symbols.h>
34#include <bsp/u-boot.h>
35#include <bsp/console-termios.h>
36
37/* Configuration parameters for console driver, ... */
38unsigned int BSP_bus_frequency;
39
40/* Configuration parameter for clock driver */
41uint32_t bsp_time_base_frequency;
42
43/* Legacy */
44uint32_t bsp_clicks_per_usec;
45
46/* Default decrementer exception handler */
47static int mpc83xx_decrementer_exception_handler( BSP_Exception_frame *frame, unsigned number)
48{
49  ppc_set_decrementer_register(UINT32_MAX);
50
51  return 0;
52}
53
54uint32_t _CPU_Counter_frequency(void)
55{
56  return bsp_time_base_frequency;
57}
58
59void bsp_start( void)
60{
61  rtems_status_code sc = RTEMS_SUCCESSFUL;
62  unsigned long i = 0;
63
64  /*
65   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
66   * store the result in global variables so that it can be used latter...
67   */
68  get_ppc_cpu_type();
69  get_ppc_cpu_revision();
70
71  /* Basic CPU initialization */
72  cpu_init();
73
74  /*
75   * Enable instruction and data caches. Do not force writethrough mode.
76   */
77
78#ifdef BSP_INSTRUCTION_CACHE_ENABLED
79  rtems_cache_enable_instruction();
80#endif
81
82#ifdef BSP_DATA_CACHE_ENABLED
83  rtems_cache_enable_data();
84#endif
85
86  /*
87   * This is evaluated during runtime, so it should be ok to set it
88   * before we initialize the drivers.
89   */
90
91  /* Initialize some device driver parameters */
92
93#ifdef HAS_UBOOT
94  BSP_bus_frequency = bsp_uboot_board_info.bi_busfreq;
95#else /* HAS_UBOOT */
96  BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID;
97#endif /* HAS_UBOOT */
98  bsp_time_base_frequency = BSP_bus_frequency / 4;
99  bsp_clicks_per_usec = bsp_time_base_frequency / 1000000;
100
101  /* Initialize some console parameters */
102  for (i = 0; i < console_device_count; ++i) {
103    ns16550_context *ctx = (ns16550_context *) console_device_table[i].context;
104
105    ctx->clock = BSP_bus_frequency;
106
107    #ifdef HAS_UBOOT
108      ctx->initial_baud = bsp_uboot_board_info.bi_baudrate;
109    #endif
110  }
111
112  /* Initialize exception handler */
113#ifndef BSP_DATA_CACHE_ENABLED
114  ppc_exc_cache_wb_check = 0;
115#endif
116  ppc_exc_initialize(
117    (uintptr_t) bsp_section_work_begin,
118    rtems_configuration_get_interrupt_stack_size()
119  );
120
121  /* Install default handler for the decrementer exception */
122  sc = ppc_exc_set_handler( ASM_DEC_VECTOR, mpc83xx_decrementer_exception_handler);
123  if (sc != RTEMS_SUCCESSFUL) {
124    rtems_panic("cannot install decrementer exception handler");
125  }
126
127  /* Initalize interrupt support */
128  bsp_interrupt_initialize();
129
130#ifdef SHOW_MORE_INIT_SETTINGS
131  printk("Exit from bspstart\n");
132#endif
133}
Note: See TracBrowser for help on using the repository browser.