diff options
Diffstat (limited to 'c/src/lib/libbsp/arm/imx/startup/bspstart.c')
-rw-r--r-- | c/src/lib/libbsp/arm/imx/startup/bspstart.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/arm/imx/startup/bspstart.c b/c/src/lib/libbsp/arm/imx/startup/bspstart.c new file mode 100644 index 0000000000..eb2ba29a3e --- /dev/null +++ b/c/src/lib/libbsp/arm/imx/startup/bspstart.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <info@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#include <bsp.h> +#include <bsp/bootcard.h> +#include <bsp/fatal.h> +#include <bsp/fdt.h> +#include <bsp/irq-generic.h> + +#include <libfdt.h> + +uint32_t bsp_fdt_map_intr(uint32_t intr) +{ + return intr + 32; +} + +void arm_generic_timer_get_config( + uint32_t *frequency, + uint32_t *irq +) +{ + const void *fdt; + int node; + int len; + const uint32_t *val; + + fdt = bsp_fdt_get(); + node = fdt_path_offset(fdt, "/timer"); + + val = fdt_getprop(fdt, node, "clock-frequency", &len); + if (val != NULL && len >= 4) { + *frequency = fdt32_to_cpu(val[0]); + } else { + bsp_fatal(IMX_FATAL_GENERIC_TIMER_FREQUENCY); + } + + val = fdt_getprop(fdt, node, "interrupts", &len); + if (val != NULL && len >= 8) { + /* FIXME: Figure out how Linux gets a proper IRQ number */ + *irq = 16 + fdt32_to_cpu(val[1]); + } else { + bsp_fatal(IMX_FATAL_GENERIC_TIMER_IRQ); + } +} + +void bsp_start(void) +{ + bsp_interrupt_initialize(); +} |