summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2011-12-08 14:02:00 +0100
committerDaniel Hellstrom <daniel@gaisler.com>2012-03-27 15:20:12 +0200
commit444aa4db8dc0d9201d93036dbbfab46bcd30f17e (patch)
treeecbee088ed2654e541aa37478ddcde2d693af3aa
parent6979ea46a4fdbd22dc670885665fb77262a64d3b (diff)
LEON3: converted to use new AMBAPP helper functions
-rw-r--r--c/src/lib/libbsp/sparc/leon3/amba/amba.c14
-rw-r--r--c/src/lib/libbsp/sparc/leon3/clock/ckinit.c10
-rw-r--r--c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c11
3 files changed, 15 insertions, 20 deletions
diff --git a/c/src/lib/libbsp/sparc/leon3/amba/amba.c b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
index ddc0fcaa55..20a3028978 100644
--- a/c/src/lib/libbsp/sparc/leon3/amba/amba.c
+++ b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
@@ -87,7 +87,7 @@ int find_matching_adev(struct ambapp_dev *dev, int index, void *arg)
void amba_initialize(void)
{
- int i, icsel;
+ int icsel;
struct ambapp_dev *adev;
/* Scan AMBA Plug&Play information, assuming malloc() works.
@@ -98,9 +98,9 @@ void amba_initialize(void)
ambapp_scan(&ambapp_plb, LEON3_IO_AREA, NULL, NULL);
/* Find LEON3 Interrupt controller */
- i = ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
- VENDOR_GAISLER, GAISLER_IRQMP, find_matching_adev, &adev);
- 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 ...
@@ -135,9 +135,9 @@ void amba_initialize(void)
#ifndef RTEMS_DRVMGR_STARTUP
/* find GP Timer */
- i = ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
- VENDOR_GAISLER, GAISLER_GPTIMER, find_matching_adev, &adev);
- if ( i > 0 ){
+ 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 *)
((struct ambapp_apb_info *)adev->devinfo)->start;
diff --git a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
index 89e84df838..1776ac0332 100644
--- a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
+++ b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
@@ -51,7 +51,6 @@
volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs = 0;
static int clkirq;
-extern int find_matching_adev(struct ambapp_dev *dev, int index, void *arg);
#define CLOCK_VECTOR LEON_TRAP_TYPE( clkirq )
@@ -70,13 +69,12 @@ extern int find_matching_adev(struct ambapp_dev *dev, int index, void *arg);
#define Clock_driver_support_find_timer() \
do { \
- int cnt; \
struct ambapp_dev *adev; \
\
- /* Find LEON3 GP Timer */ \
- cnt = ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), \
- VENDOR_GAISLER, GAISLER_GPTIMER, find_matching_adev, &adev); \
- if ( cnt > 0 ){ \
+ /* Find first LEON3 GP Timer */ \
+ adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),\
+ VENDOR_GAISLER, GAISLER_GPTIMER, ambapp_find_by_idx, NULL); \
+ if ( adev ) { \
/* Found APB GPTIMER Timer */ \
LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) \
((struct ambapp_apb_info *)adev->devinfo)->start; \
diff --git a/c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c b/c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c
index 648f06582a..3254b6043d 100644
--- a/c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c
+++ b/c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c
@@ -26,25 +26,22 @@
greth_configuration_t leon_greth_configuration;
-extern int find_matching_adev(struct ambapp_dev *dev, int index, void *arg);
-
int rtems_leon_greth_driver_attach(
struct rtems_bsdnet_ifconfig *config,
int attach
)
{
- int device_found = 0;
unsigned int base_addr = 0; /* avoid warnings */
unsigned int eth_irq = 0; /* avoid warnings */
struct ambapp_dev *adev;
struct ambapp_common_info *apb;
/* Scan for MAC AHB slave interface */
- device_found = ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
+ adev = ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
VENDOR_GAISLER, GAISLER_ETHMAC,
- find_matching_adev, &adev);
- if (device_found == 1) {
- apb = (struct ambapp_common_info *)dev->devinfo;
+ ambapp_find_by_idx, NULL);
+ if (adev) {
+ apb = (struct ambapp_common_info *)adev->devinfo;
base_addr = apb->start;
eth_irq = apb->irq;