summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/sparc/leon3/amba/amba.c
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2012-04-17 16:25:38 +0200
committerGedare Bloom <gedare@rtems.org>2012-04-17 22:01:46 -0400
commit9ea65119f400d5ad9acc3c52bdfd978fb96b930c (patch)
tree7b1175a757256e3772f9c8afb3f366591a5c093c /c/src/lib/libbsp/sparc/leon3/amba/amba.c
parentno_cpu: replace no_cpu_isr with rtems_isr (diff)
downloadrtems-9ea65119f400d5ad9acc3c52bdfd978fb96b930c.tar.bz2
LEON: updated AMBA PnP API
The old layer had some limitations/problems for multiple AHB buses since the data structure containing all AMBA devices were allocated before scanning. The new layer create devices as they are found and memory is allocated using malloc() or bsp_early_malloc() during booting. The old 8 functions for finding a specific AHB-Slave or APB-Slave device has been replaced with one function, ambapp_for_each(), which iterates over all devices matching the specified search options and calls a user provided function. The new way lowers the footprint and makes searching more flexible. The frequency information is now supported, if the frequency of one device is reported by the user. More AHB-to-AHB bridges are supported. The API has been split into several parts in order to lower the footprint. The API also introduces the AMBAPP CORE concept, where one ambapp_core can be created from one AHB Master, AHB Slave and one APB Slave, at least one device is required for creating a core. Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
Diffstat (limited to 'c/src/lib/libbsp/sparc/leon3/amba/amba.c')
-rw-r--r--c/src/lib/libbsp/sparc/leon3/amba/amba.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/c/src/lib/libbsp/sparc/leon3/amba/amba.c b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
index 16fb8dee81..e41d0aaee5 100644
--- a/c/src/lib/libbsp/sparc/leon3/amba/amba.c
+++ b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
@@ -1,10 +1,10 @@
/*
- * AMBA Plag & Play Bus Driver
+ * AMBA Plug & Play Bus Driver
*
* This driver hook performs bus scanning.
*
- * COPYRIGHT (c) 2004.
- * Gaisler Research
+ * COPYRIGHT (c) 2011.
+ * Aeroflex Gaisler
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -14,9 +14,14 @@
*/
#include <bsp.h>
+#include <ambapp.h>
-/* Structure containing address to devices found on the Amba Plug&Play bus */
-amba_confarea_type amba_conf;
+/* AMBA Plug&Play information description.
+ *
+ * After software has scanned AMBA PnP it builds a tree to make
+ * it easier for drivers to work with the bus architecture.
+ */
+struct ambapp_bus ambapp_plb;
/* GRLIB extended IRQ controller register */
extern void leon3_ext_irq_init(void);
@@ -38,16 +43,21 @@ extern int scan_uarts(void);
void amba_initialize(void)
{
- int i;
int icsel;
- amba_apb_device dev;
+ struct ambapp_dev *adev;
- /* Scan the AMBA Plug&Play info at the default LEON3 area */
- amba_scan(&amba_conf,LEON3_IO_AREA,NULL);
+ /* Scan AMBA Plug&Play read-only information. The routine builds a PnP
+ * tree into ambapp_plb in RAM, after this we never access the PnP
+ * information in hardware directly any more.
+ * Since on Processor Local Bus (PLB) memory mapping is 1:1
+ */
+ ambapp_scan(&ambapp_plb, LEON3_IO_AREA, NULL, NULL);
/* Find LEON3 Interrupt controller */
- i = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_IRQMP,&dev);
- if (i <= 0){
+ adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
+ VENDOR_GAISLER, GAISLER_IRQMP,
+ ambapp_find_by_idx, NULL);
+ if (adev == NULL) {
/* PANIC IRQ controller not found!
*
* What else can we do but stop ...
@@ -55,7 +65,8 @@ void amba_initialize(void)
asm volatile( "mov 1, %g1; ta 0x0" );
}
- LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) dev.start;
+ LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *)
+ DEV_TO_APB(adev)->start;
if ((LEON3_IrqCtrl_Regs->ampctrl >> 28) > 0) {
/* IRQ Controller has support for multiple IRQ Controllers, each
* CPU can be routed to different Controllers, we find out which
@@ -74,9 +85,15 @@ void amba_initialize(void)
leon3_ext_irq_init();
/* find GP Timer */
- i = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_GPTIMER,&dev);
- if ( i > 0 ) {
- LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) dev.start;
+ adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
+ VENDOR_GAISLER, GAISLER_GPTIMER,
+ ambapp_find_by_idx, NULL);
+ if (adev) {
+ LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *)DEV_TO_APB(adev)->start;
+
+ /* Register AMBA Bus Frequency */
+ ambapp_freq_init(&ambapp_plb, adev,
+ (LEON3_Timer_Regs->scaler_reload + 1) * 1000000);
}
/* find UARTS */