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

5
Last change on this file since b742de2 was b742de2, checked in by Sebastian Huber <sebastian.huber@…>, on 09/08/17 at 08:11:48

bsp/qoriq: Boot page translation

Do not mingle with the boot page translation as hypervisor guest.

Update #3085.

  • Property mode set to 100644
File size: 4.7 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_clicks_per_usec;
52
53void BSP_panic(char *s)
54{
55  rtems_interrupt_level level;
56
57  rtems_interrupt_local_disable(level);
58  (void) level;
59
60  printk("%s PANIC %s\n", rtems_get_version_string(), s);
61
62  while (1) {
63    /* Do nothing */
64  }
65}
66
67void _BSP_Fatal_error(unsigned n)
68{
69  rtems_interrupt_level level;
70
71  rtems_interrupt_local_disable(level);
72  (void) level;
73
74  printk("%s PANIC ERROR %u\n", rtems_get_version_string(), n);
75
76  while (1) {
77    /* Do nothing */
78  }
79}
80
81static void initialize_frequency_parameters(void)
82{
83  const void *fdt = bsp_fdt_get();
84  int node;
85  int len;
86  fdt32_t *val_fdt;
87
88  node = fdt_node_offset_by_prop_value(fdt, -1, "device_type", "cpu", 4);
89
90  val_fdt = (fdt32_t *) fdt_getprop(fdt, node, "bus-frequency", &len);
91  if (val_fdt == NULL || len != 4) {
92    bsp_fatal(QORIQ_FATAL_FDT_NO_BUS_FREQUENCY);
93  }
94  BSP_bus_frequency = fdt32_to_cpu(*val_fdt) / QORIQ_BUS_CLOCK_DIVIDER;
95
96  val_fdt = (fdt32_t *) fdt_getprop(fdt, node, "timebase-frequency", &len);
97  if (val_fdt == NULL || len != 4) {
98    bsp_fatal(QORIQ_FATAL_FDT_NO_BUS_FREQUENCY);
99  }
100  bsp_clicks_per_usec = fdt32_to_cpu(*val_fdt) / 1000000;
101
102  #ifdef __PPC_CPU_E6500__
103    val_fdt = (fdt32_t *) fdt_getprop(fdt, node, "clock-frequency", &len);
104    if (val_fdt == NULL || len != 4) {
105      bsp_fatal(QORIQ_FATAL_FDT_NO_CLOCK_FREQUENCY);
106    }
107  #endif
108  rtems_counter_initialize_converter(fdt32_to_cpu(*val_fdt));
109}
110
111#define MTIVPR(base) \
112  __asm__ volatile ("mtivpr %0" : : "r" (base))
113
114#ifdef __powerpc64__
115#define VECTOR_TABLE_ENTRY_SIZE 32
116#else
117#define VECTOR_TABLE_ENTRY_SIZE 16
118#endif
119
120#define MTIVOR(vec, offset) \
121  do { \
122    __asm__ volatile ("mtspr " RTEMS_XSTRING(vec) ", %0" : : "r" (offset)); \
123    offset += VECTOR_TABLE_ENTRY_SIZE; \
124  } while (0)
125
126void qoriq_initialize_exceptions(void *interrupt_stack_begin)
127{
128  uintptr_t addr;
129
130  ppc_exc_initialize_interrupt_stack(
131    (uintptr_t) interrupt_stack_begin,
132    rtems_configuration_get_interrupt_stack_size()
133  );
134
135  addr = (uintptr_t) bsp_exc_vector_base;
136  MTIVPR(addr);
137  MTIVOR(BOOKE_IVOR0,  addr);
138  MTIVOR(BOOKE_IVOR1,  addr);
139  MTIVOR(BOOKE_IVOR2,  addr);
140  MTIVOR(BOOKE_IVOR3,  addr);
141  MTIVOR(BOOKE_IVOR4,  addr);
142  MTIVOR(BOOKE_IVOR5,  addr);
143  MTIVOR(BOOKE_IVOR6,  addr);
144#ifdef __PPC_CPU_E6500__
145  MTIVOR(BOOKE_IVOR7,  addr);
146#endif
147  MTIVOR(BOOKE_IVOR8,  addr);
148#ifdef __PPC_CPU_E6500__
149  MTIVOR(BOOKE_IVOR9,  addr);
150#endif
151  MTIVOR(BOOKE_IVOR10, addr);
152  MTIVOR(BOOKE_IVOR11, addr);
153  MTIVOR(BOOKE_IVOR12, addr);
154  MTIVOR(BOOKE_IVOR13, addr);
155  MTIVOR(BOOKE_IVOR14, addr);
156  MTIVOR(BOOKE_IVOR15, addr);
157  MTIVOR(BOOKE_IVOR32, addr);
158  MTIVOR(BOOKE_IVOR33, addr);
159#ifndef __PPC_CPU_E6500__
160  MTIVOR(BOOKE_IVOR34, addr);
161#endif
162  MTIVOR(BOOKE_IVOR35, addr);
163#ifdef __PPC_CPU_E6500__
164  MTIVOR(BOOKE_IVOR36, addr);
165  MTIVOR(BOOKE_IVOR37, addr);
166  MTIVOR(BOOKE_IVOR38, addr);
167  MTIVOR(BOOKE_IVOR39, addr);
168  MTIVOR(BOOKE_IVOR40, addr);
169  MTIVOR(BOOKE_IVOR41, addr);
170  MTIVOR(BOOKE_IVOR42, addr);
171#endif
172}
173
174void bsp_start(void)
175{
176  /*
177   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
178   * store the result in global variables so that it can be used latter...
179   */
180  get_ppc_cpu_type();
181  get_ppc_cpu_revision();
182
183  initialize_frequency_parameters();
184
185  qoriq_initialize_exceptions(bsp_section_work_begin);
186  bsp_interrupt_initialize();
187
188  rtems_cache_coherent_add_area(
189    bsp_section_nocacheheap_begin,
190    (uintptr_t) bsp_section_nocacheheap_size
191  );
192
193#ifndef QORIQ_IS_HYPERVISOR_GUEST
194  /* Disable boot page translation */
195#if QORIQ_CHIP_IS_T_VARIANT(QORIQ_CHIP_VARIANT)
196  qoriq.lcc.bstar &= ~LCC_BSTAR_EN;
197#else
198  qoriq.lcc.bptr &= ~BPTR_EN;
199#endif
200#endif
201}
202
203uint32_t bsp_fdt_map_intr(uint32_t intr)
204{
205  return intr - 16;
206}
Note: See TracBrowser for help on using the repository browser.