summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-16 14:35:59 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-26 09:17:42 +0200
commit1ad863d9f156a20366552bd0d700923f46789980 (patch)
tree6439f68f86b9d79836df5e143cb332f636448c09
parentd7fbd6329dbeebf3c007695427a8978c5d3ba34a (diff)
bsp/leon3: Untangle interrupt controller support
Separate the probing of the interrupt controller from the initialization.
-rw-r--r--bsps/sparc/leon3/include/bsp/leon3.h82
-rw-r--r--bsps/sparc/leon3/include/leon.h10
-rw-r--r--bsps/sparc/leon3/start/amba.c9
-rw-r--r--bsps/sparc/leon3/start/eirq.c14
4 files changed, 94 insertions, 21 deletions
diff --git a/bsps/sparc/leon3/include/bsp/leon3.h b/bsps/sparc/leon3/include/bsp/leon3.h
new file mode 100644
index 0000000000..ff1ef261e6
--- /dev/null
+++ b/bsps/sparc/leon3/include/bsp/leon3.h
@@ -0,0 +1,82 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup sparc_leon3
+ *
+ * @brief This header file provides interfaces used by the BSP implementation.
+ */
+
+/*
+ * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _BSP_LEON3_H
+#define _BSP_LEON3_H
+
+#include <rtems.h>
+#include <grlib/grlib.h>
+
+struct ambapp_dev;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup sparc_leon3
+ *
+ * @{
+ */
+
+/**
+ * @brief This lock serializes the interrupt controller access.
+ */
+extern rtems_interrupt_lock LEON3_IrqCtrl_Lock;
+
+/**
+ * @brief This pointer provides the IRQ(A)MP register block address.
+ */
+extern volatile struct irqmp_regs *LEON3_IrqCtrl_Regs;
+
+/**
+ * @brief This pointer provides the IRQ(A)MP device information block.
+ */
+extern struct ambapp_dev *LEON3_IrqCtrl_Adev;
+
+/**
+ * @brief Initializes the interrupt controller for the boot processor.
+ *
+ * @param[in, out] regs is the IRQ(A)MP register block address.
+ */
+void leon3_ext_irq_init( volatile struct irqmp_regs *regs );
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _BSP_LEON3_H */
diff --git a/bsps/sparc/leon3/include/leon.h b/bsps/sparc/leon3/include/leon.h
index 5fadb08052..8cee0972d4 100644
--- a/bsps/sparc/leon3/include/leon.h
+++ b/bsps/sparc/leon3/include/leon.h
@@ -25,6 +25,7 @@
#include <rtems.h>
#include <amba.h>
+#include <bsp/leon3.h>
#ifdef __cplusplus
extern "C" {
@@ -127,10 +128,6 @@ extern "C" {
#define LEON3_REG_CACHE_CTRL_FI 0x00200000 /* Flush instruction cache */
#define LEON3_REG_CACHE_CTRL_DS 0x00800000 /* Data cache snooping */
-/* LEON3 Interrupt Controller */
-extern volatile struct irqmp_regs *LEON3_IrqCtrl_Regs;
-extern struct ambapp_dev *LEON3_IrqCtrl_Adev;
-
/* LEON3 GP Timer */
extern volatile struct gptimer_regs *LEON3_Timer_Regs;
extern struct ambapp_dev *LEON3_Timer_Adev;
@@ -174,8 +171,6 @@ static __inline__ int bsp_irq_fixup(int irq)
* store the result back are vulnerable.
*/
-extern rtems_interrupt_lock LEON3_IrqCtrl_Lock;
-
#define LEON3_IRQCTRL_ACQUIRE( _lock_context ) \
rtems_interrupt_lock_acquire( &LEON3_IrqCtrl_Lock, _lock_context )
@@ -391,9 +386,6 @@ extern int leon3_timer_core_index;
*/
extern unsigned int leon3_timer_prescaler;
-/* GRLIB extended IRQ controller register */
-void leon3_ext_irq_init(void);
-
RTEMS_NO_RETURN void leon3_power_down_loop(void);
static inline uint32_t leon3_get_cpu_count(
diff --git a/bsps/sparc/leon3/start/amba.c b/bsps/sparc/leon3/start/amba.c
index 4801916825..e13d07e85d 100644
--- a/bsps/sparc/leon3/start/amba.c
+++ b/bsps/sparc/leon3/start/amba.c
@@ -96,9 +96,6 @@ RTEMS_SYSINIT_ITEM(
);
#endif
-rtems_interrupt_lock LEON3_IrqCtrl_Lock =
- RTEMS_INTERRUPT_LOCK_INITIALIZER("LEON3 IrqCtrl");
-
/* Pointers to Interrupt Controller configuration registers */
volatile struct irqmp_regs *LEON3_IrqCtrl_Regs;
struct ambapp_dev *LEON3_IrqCtrl_Adev;
@@ -147,12 +144,6 @@ static void amba_initialize(void)
icsel = (icsel >> ((7 - (LEON3_Cpu_Index & 0x7)) * 4)) & 0xf;
LEON3_IrqCtrl_Regs += icsel;
}
- LEON3_IrqCtrl_Regs->mask[LEON3_Cpu_Index] = 0;
- LEON3_IrqCtrl_Regs->force[LEON3_Cpu_Index] = 0;
- LEON3_IrqCtrl_Regs->iclear = 0xffffffff;
-
- /* Init Extended IRQ controller if available */
- leon3_ext_irq_init();
/* find GP Timer */
adev = (void *)ambapp_for_each(plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
diff --git a/bsps/sparc/leon3/start/eirq.c b/bsps/sparc/leon3/start/eirq.c
index 0d71b79f1c..6b15b9eef9 100644
--- a/bsps/sparc/leon3/start/eirq.c
+++ b/bsps/sparc/leon3/start/eirq.c
@@ -19,12 +19,19 @@
/* GRLIB extended IRQ controller IRQ number */
int LEON3_IrqCtrl_EIrq = -1;
+rtems_interrupt_lock LEON3_IrqCtrl_Lock =
+ RTEMS_INTERRUPT_LOCK_INITIALIZER("LEON3 IrqCtrl");
+
/* Initialize Extended Interrupt controller */
-void leon3_ext_irq_init(void)
+void leon3_ext_irq_init(volatile struct irqmp_regs *regs)
{
- if ( (LEON3_IrqCtrl_Regs->mpstat >> 16) & 0xf ) {
+ regs->mask[LEON3_Cpu_Index] = 0;
+ regs->force[LEON3_Cpu_Index] = 0;
+ regs->iclear = 0xffffffff;
+
+ if ( (regs->mpstat >> 16) & 0xf ) {
/* Extended IRQ controller available */
- LEON3_IrqCtrl_EIrq = (LEON3_IrqCtrl_Regs->mpstat >> 16) & 0xf;
+ LEON3_IrqCtrl_EIrq = (regs->mpstat >> 16) & 0xf;
}
}
@@ -58,6 +65,7 @@ rtems_status_code bsp_interrupt_facility_initialize(void)
}
#endif
+ leon3_ext_irq_init(LEON3_IrqCtrl_Regs);
return RTEMS_SUCCESSFUL;
}