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>
This commit is contained in:
Daniel Hellstrom
2012-04-17 16:25:38 +02:00
committed by Gedare Bloom
parent e99dbaa7cd
commit 9ea65119f4
19 changed files with 1846 additions and 641 deletions

View File

@@ -44,10 +44,21 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \
libbsp_a_SOURCES += ../../sparc/shared/irq_asm.S
# gnatsupp
libbsp_a_SOURCES += gnatsupp/gnatsupp.c ../../sparc/shared/gnatcommon.c
# amba
# AMBA bus
include_HEADERS += include/amba.h
include_HEADERS += ../../sparc/shared/include/ambapp.h
libbsp_a_SOURCES += amba/amba.c ../../sparc/shared/amba/ambapp.c
include_HEADERS += ../../sparc/shared/include/ambapp_ids.h
libbsp_a_SOURCES += amba/amba.c
libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp.c
libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_alloc.c
libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_count.c
libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_depth.c
libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_find_by_idx.c
libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_freq.c
libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_parent.c
libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_old.c
libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_names.c
libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_show.c
# console
libbsp_a_SOURCES += console/console.c
# debugio

View File

@@ -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 */

View File

@@ -34,7 +34,7 @@ extern "C" {
#endif
/* The AMBA Plug&Play info of the bus that the LEON3 sits on */
extern amba_confarea_type amba_conf;
extern struct ambapp_bus ambapp_plb;
#ifdef __cplusplus
}

View File

@@ -85,6 +85,10 @@ $(PROJECT_INCLUDE)/ambapp.h: ../../sparc/shared/include/ambapp.h $(PROJECT_INCLU
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/ambapp.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/ambapp.h
$(PROJECT_INCLUDE)/ambapp_ids.h: ../../sparc/shared/include/ambapp_ids.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/ambapp_ids.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/ambapp_ids.h
$(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h