source: rtems/c/src/lib/libbsp/arm/imx/startup/bspstart.c @ 7e195e66

5
Last change on this file since 7e195e66 was 7e195e66, checked in by Sebastian Huber <sebastian.huber@…>, on 09/28/17 at 07:29:38

bsp/imx: Add imx_get_irq_of_node()

Update #3090.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 * Copyright (c) 2017 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <info@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#include <bsp.h>
16#include <bsp/bootcard.h>
17#include <bsp/fatal.h>
18#include <bsp/fdt.h>
19#include <bsp/irq-generic.h>
20#include <bsp/linker-symbols.h>
21
22#include <libfdt.h>
23
24#define MAGIC_IRQ_OFFSET 32
25
26rtems_vector_number imx_get_irq_of_node(
27  const void *fdt,
28  int node,
29  size_t index
30)
31{
32  int len;
33  const uint32_t *val;
34
35  val = fdt_getprop(fdt, node, "interrupts", &len);
36  if (val == NULL || len < (int) ((index + 1) * 12)) {
37    return UINT32_MAX;
38  }
39
40  return fdt32_to_cpu(val[index * 3 + 1]) + MAGIC_IRQ_OFFSET;
41}
42
43uint32_t bsp_fdt_map_intr(const uint32_t *intr, size_t icells)
44{
45  return intr[1] + MAGIC_IRQ_OFFSET;
46}
47
48void arm_generic_timer_get_config(
49  uint32_t *frequency,
50  uint32_t *irq
51)
52{
53  const void *fdt;
54  int node;
55  int len;
56  const uint32_t *val;
57
58  fdt = bsp_fdt_get();
59  node = fdt_path_offset(fdt, "/timer");
60
61  val = fdt_getprop(fdt, node, "clock-frequency", &len);
62  if (val != NULL && len >= 4) {
63    *frequency = fdt32_to_cpu(val[0]);
64  } else {
65    bsp_fatal(IMX_FATAL_GENERIC_TIMER_FREQUENCY);
66  }
67
68  /* FIXME: Figure out how Linux gets a proper IRQ number */
69  *irq = imx_get_irq_of_node(fdt, node, 0) - 16;
70}
71
72void bsp_start(void)
73{
74  bsp_interrupt_initialize();
75  rtems_cache_coherent_add_area(
76    bsp_section_nocacheheap_begin,
77    (uintptr_t) bsp_section_nocacheheap_size
78  );
79}
Note: See TracBrowser for help on using the repository browser.