source: rtems/c/src/lib/libbsp/powerpc/qoriq/startup/bspstart.c @ 1c193a2

5
Last change on this file since 1c193a2 was 1c193a2, checked in by Sebastian Huber <sebastian.huber@…>, on 11/21/17 at 10:43:13

powerpc: Replace BSP_panic() with rtems_panic()

Due to a new rtems_panic() implementation, it is possible to replace the
PowerPC-specific BSP_panic() with rtems_panic(). Remove BSP_panic()
implementations.

Close #3245.

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup QorIQ
5 *
6 * @brief BSP startup.
7 */
8
9/*
10 * Copyright (c) 2010, 2017 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Dornierstr. 4
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@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 <libfdt.h>
24
25#include <rtems.h>
26#include <rtems/config.h>
27#include <rtems/counter.h>
28
29#include <libcpu/powerpc-utility.h>
30
31#include <bsp.h>
32#include <bsp/bootcard.h>
33#include <bsp/console-termios.h>
34#include <bsp/fatal.h>
35#include <bsp/fdt.h>
36#include <bsp/irq-generic.h>
37#include <bsp/linker-symbols.h>
38#include <bsp/mmu.h>
39#include <bsp/qoriq.h>
40#include <bsp/vectors.h>
41
42LINKER_SYMBOL(bsp_exc_vector_base);
43
44qoriq_start_spin_table *
45qoriq_start_spin_table_addr[QORIQ_CPU_COUNT / QORIQ_THREAD_COUNT];
46
47/* Configuration parameters for console driver, ... */
48unsigned int BSP_bus_frequency;
49
50/* Configuration parameter for clock driver, ... */
51uint32_t bsp_time_base_frequency;
52
53uint32_t qoriq_clock_frequency;
54
55void _BSP_Fatal_error(unsigned n)
56{
57  rtems_interrupt_level level;
58
59  rtems_interrupt_local_disable(level);
60  (void) level;
61
62  printk("%s PANIC ERROR %u\n", rtems_get_version_string(), n);
63
64  while (1) {
65    /* Do nothing */
66  }
67}
68
69static void initialize_frequency_parameters(void)
70{
71  const void *fdt = bsp_fdt_get();
72  int node;
73  int len;
74  fdt32_t *val_fdt;
75
76  node = fdt_node_offset_by_prop_value(fdt, -1, "device_type", "cpu", 4);
77
78  val_fdt = (fdt32_t *) fdt_getprop(fdt, node, "bus-frequency", &len);
79  if (val_fdt == NULL || len != 4) {
80    bsp_fatal(QORIQ_FATAL_FDT_NO_BUS_FREQUENCY);
81  }
82  BSP_bus_frequency = fdt32_to_cpu(*val_fdt) / QORIQ_BUS_CLOCK_DIVIDER;
83
84  val_fdt = (fdt32_t *) fdt_getprop(fdt, node, "timebase-frequency", &len);
85  if (val_fdt == NULL || len != 4) {
86    bsp_fatal(QORIQ_FATAL_FDT_NO_BUS_FREQUENCY);
87  }
88  bsp_time_base_frequency = fdt32_to_cpu(*val_fdt);
89
90  #ifdef __PPC_CPU_E6500__
91    val_fdt = (fdt32_t *) fdt_getprop(fdt, node, "clock-frequency", &len);
92    if (val_fdt == NULL || len != 4) {
93      bsp_fatal(QORIQ_FATAL_FDT_NO_CLOCK_FREQUENCY);
94    }
95    qoriq_clock_frequency = fdt32_to_cpu(*val_fdt);
96  #endif
97  rtems_counter_initialize_converter(fdt32_to_cpu(*val_fdt));
98}
99
100#define MTIVPR(base) \
101  __asm__ volatile ("mtivpr %0" : : "r" (base))
102
103#ifdef __powerpc64__
104#define VECTOR_TABLE_ENTRY_SIZE 32
105#else
106#define VECTOR_TABLE_ENTRY_SIZE 16
107#endif
108
109#define MTIVOR(vec, offset) \
110  do { \
111    __asm__ volatile ("mtspr " RTEMS_XSTRING(vec) ", %0" : : "r" (offset)); \
112    offset += VECTOR_TABLE_ENTRY_SIZE; \
113  } while (0)
114
115void qoriq_initialize_exceptions(void *interrupt_stack_begin)
116{
117  uintptr_t addr;
118
119  ppc_exc_initialize_interrupt_stack(
120    (uintptr_t) interrupt_stack_begin,
121    rtems_configuration_get_interrupt_stack_size()
122  );
123
124  addr = (uintptr_t) bsp_exc_vector_base;
125  MTIVPR(addr);
126  MTIVOR(BOOKE_IVOR0,  addr);
127  MTIVOR(BOOKE_IVOR1,  addr);
128  MTIVOR(BOOKE_IVOR2,  addr);
129  MTIVOR(BOOKE_IVOR3,  addr);
130  MTIVOR(BOOKE_IVOR4,  addr);
131  MTIVOR(BOOKE_IVOR5,  addr);
132  MTIVOR(BOOKE_IVOR6,  addr);
133#ifdef __PPC_CPU_E6500__
134  MTIVOR(BOOKE_IVOR7,  addr);
135#endif
136  MTIVOR(BOOKE_IVOR8,  addr);
137#ifdef __PPC_CPU_E6500__
138  MTIVOR(BOOKE_IVOR9,  addr);
139#endif
140  MTIVOR(BOOKE_IVOR10, addr);
141  MTIVOR(BOOKE_IVOR11, addr);
142  MTIVOR(BOOKE_IVOR12, addr);
143  MTIVOR(BOOKE_IVOR13, addr);
144  MTIVOR(BOOKE_IVOR14, addr);
145  MTIVOR(BOOKE_IVOR15, addr);
146  MTIVOR(BOOKE_IVOR32, addr);
147  MTIVOR(BOOKE_IVOR33, addr);
148#ifndef __PPC_CPU_E6500__
149  MTIVOR(BOOKE_IVOR34, addr);
150#endif
151  MTIVOR(BOOKE_IVOR35, addr);
152#ifdef __PPC_CPU_E6500__
153  MTIVOR(BOOKE_IVOR36, addr);
154  MTIVOR(BOOKE_IVOR37, addr);
155#ifndef QORIQ_IS_HYPERVISOR_GUEST
156  MTIVOR(BOOKE_IVOR38, addr);
157  MTIVOR(BOOKE_IVOR39, addr);
158  MTIVOR(BOOKE_IVOR40, addr);
159  MTIVOR(BOOKE_IVOR41, addr);
160  MTIVOR(BOOKE_IVOR42, addr);
161#endif
162#endif
163}
164
165void bsp_start(void)
166{
167  /*
168   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
169   * store the result in global variables so that it can be used latter...
170   */
171  get_ppc_cpu_type();
172  get_ppc_cpu_revision();
173
174  initialize_frequency_parameters();
175
176  qoriq_initialize_exceptions(bsp_section_work_begin);
177  bsp_interrupt_initialize();
178
179  rtems_cache_coherent_add_area(
180    bsp_section_nocacheheap_begin,
181    (uintptr_t) bsp_section_nocacheheap_size
182  );
183
184#ifndef QORIQ_IS_HYPERVISOR_GUEST
185  /* Disable boot page translation */
186#if QORIQ_CHIP_IS_T_VARIANT(QORIQ_CHIP_VARIANT)
187  qoriq.lcc.bstar &= ~LCC_BSTAR_EN;
188#else
189  qoriq.lcc.bptr &= ~BPTR_EN;
190#endif
191#endif
192}
193
194uint32_t bsp_fdt_map_intr(const uint32_t *intr, size_t icells)
195{
196  return intr[0] - 16;
197}
Note: See TracBrowser for help on using the repository browser.