summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-09-06 00:01:30 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-09-06 00:01:30 +0000
commit1982a1957492daa80511504c955d765386c31055 (patch)
treea1758de0e0d2f2a2e858a8047b4514e2359a2875 /c
parent2007-09-05 Daniel Hellstrom <daniel@gaisler.com> (diff)
downloadrtems-1982a1957492daa80511504c955d765386c31055.tar.bz2
2007-09-05 Daniel Hellstrom <daniel@gaisler.com>
* Makefile.am, preinstall.am, amba/amba.c, include/amba.h, include/leon.h: LEON3 AMBA PnP bus scanning moved to shared/amba/amba.c and shared/include/ambapp.h. The AMBA scanning was improved to take account for PnP info address translation. This is useful when scanning remote AMBA busses for example when a board connected with PCI has an AMBA bus that needs to be scanned, before the addresses was hard coded. Also, LEON2 now have AMBA PnP bus scanning support. By using the new AMBA scanning routines it is possible to isolate the AMBA scanning code to ambapp.c, however existing drivers should be updated to use them in order to save space.
Diffstat (limited to 'c')
-rw-r--r--c/src/lib/libbsp/sparc/leon3/ChangeLog14
-rw-r--r--c/src/lib/libbsp/sparc/leon3/Makefile.am3
-rw-r--r--c/src/lib/libbsp/sparc/leon3/amba/amba.c62
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/amba.h70
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/leon.h45
-rw-r--r--c/src/lib/libbsp/sparc/leon3/preinstall.am4
6 files changed, 42 insertions, 156 deletions
diff --git a/c/src/lib/libbsp/sparc/leon3/ChangeLog b/c/src/lib/libbsp/sparc/leon3/ChangeLog
index 69466fcdf3..6abc98391d 100644
--- a/c/src/lib/libbsp/sparc/leon3/ChangeLog
+++ b/c/src/lib/libbsp/sparc/leon3/ChangeLog
@@ -1,5 +1,19 @@
2007-09-05 Daniel Hellstrom <daniel@gaisler.com>
+ * Makefile.am, preinstall.am, amba/amba.c, include/amba.h,
+ include/leon.h: LEON3 AMBA PnP bus scanning moved to
+ shared/amba/amba.c and shared/include/ambapp.h. The AMBA scanning was
+ improved to take account for PnP info address translation. This is
+ useful when scanning remote AMBA busses for example when a board
+ connected with PCI has an AMBA bus that needs to be scanned, before
+ the addresses was hard coded. Also, LEON2 now have AMBA PnP bus
+ scanning support. By using the new AMBA scanning routines it is
+ possible to isolate the AMBA scanning code to ambapp.c, however
+ existing drivers should be updated to use them in order to save
+ space.
+
+2007-09-05 Daniel Hellstrom <daniel@gaisler.com>
+
* include/bsp.h: This patch prepares bsp.h so that shared code (new
drivers) can easily have small small sections of BSP specific code.
diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am b/c/src/lib/libbsp/sparc/leon3/Makefile.am
index 4ff0accb95..bbf4c7d3d2 100644
--- a/c/src/lib/libbsp/sparc/leon3/Makefile.am
+++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am
@@ -47,9 +47,10 @@ gnatsupp_rel_CPPFLAGS = $(AM_CPPFLAGS)
gnatsupp_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
include_HEADERS += include/amba.h
+include_HEADERS += ../../sparc/shared/include/ambapp.h
noinst_PROGRAMS += amba.rel
-amba_rel_SOURCES = amba/amba.c
+amba_rel_SOURCES = amba/amba.c ../../sparc/shared/amba/ambapp.c
amba_rel_CPPFLAGS = $(AM_CPPFLAGS)
amba_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
diff --git a/c/src/lib/libbsp/sparc/leon3/amba/amba.c b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
index ffcabf0497..c0477ccc9b 100644
--- a/c/src/lib/libbsp/sparc/leon3/amba/amba.c
+++ b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
@@ -15,16 +15,6 @@
#include <bsp.h>
-#define amba_insert_device(tab, address) \
-{ \
- if (*(address)) \
- { \
- (tab)->addr[(tab)->devnr] = (address); \
- (tab)->devnr ++; \
- } \
-} while(0)
-
-
/* Structure containing address to devices found on the Amba Plug&Play bus */
amba_confarea_type amba_conf;
@@ -57,44 +47,12 @@ extern rtems_configuration_table Configuration;
void bsp_leon3_predriver_hook(void)
{
- unsigned int *cfg_area; /* address to configuration area */
- unsigned int mbar, iobar, conf;
- int i, j;
+ unsigned int iobar, conf;
+ int i;
unsigned int tmp;
-
- amba_conf.ahbmst.devnr = 0; amba_conf.ahbslv.devnr = 0; amba_conf.apbslv.devnr = 0;
- cfg_area = (unsigned int *) (LEON3_IO_AREA | LEON3_CONF_AREA);
-
- for (i = 0; i < LEON3_AHB_MASTERS; i++)
- {
- amba_insert_device(&amba_conf.ahbmst, cfg_area);
- cfg_area += LEON3_AHB_CONF_WORDS;
- }
-
- cfg_area = (unsigned int *) (LEON3_IO_AREA | LEON3_CONF_AREA | LEON3_AHB_SLAVE_CONF_AREA);
- for (i = 0; i < LEON3_AHB_SLAVES; i++)
- {
- amba_insert_device(&amba_conf.ahbslv, cfg_area);
- cfg_area += LEON3_AHB_CONF_WORDS;
- }
-
- for (i = 0; i < amba_conf.ahbslv.devnr; i ++)
- {
- conf = amba_get_confword(amba_conf.ahbslv, i, 0);
- mbar = amba_ahb_get_membar(amba_conf.ahbslv, i, 0);
- if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_APBMST) &&
- (apb_init == 0))
- {
- amba_conf.apbmst = amba_membar_start(mbar);
- cfg_area = (unsigned int *) (amba_conf.apbmst | LEON3_CONF_AREA);
- for (j = amba_conf.apbslv.devnr; j < LEON3_APB_SLAVES; j++)
- {
- amba_insert_device(&amba_conf.apbslv, cfg_area);
- cfg_area += LEON3_APB_CONF_WORDS;
- }
- apb_init = 1;
- }
- }
+
+ /* Scan the AMBA Plug&Play info at the default LEON3 area */
+ amba_scan(&amba_conf,LEON3_IO_AREA,NULL);
/* Find LEON3 Interrupt controler */
i = 0;
@@ -104,12 +62,12 @@ void bsp_leon3_predriver_hook(void)
if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_IRQMP))
{
iobar = amba_apb_get_membar(amba_conf.apbslv, i);
- LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) amba_iobar_start(amba_conf.apbmst, iobar);
+ LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) amba_iobar_start(amba_conf.apbslv.apbmst[i], iobar);
/* asm("mov %%asr17, %0": : "r" (tmp)); */
if (Configuration.User_multiprocessing_table != NULL)
{
- tmp = getasr17();
- LEON3_Cpu_Index = (tmp >> 28) & 3;
+ tmp = getasr17();
+ LEON3_Cpu_Index = (tmp >> 28) & 3;
}
break;
}
@@ -124,12 +82,10 @@ void bsp_leon3_predriver_hook(void)
(amba_device(conf) == GAISLER_GPTIMER)) {
iobar = amba_apb_get_membar(amba_conf.apbslv, i);
LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *)
- amba_iobar_start(amba_conf.apbmst, iobar);
+ amba_iobar_start(amba_conf.apbslv.apbmst[i], iobar);
break;
}
i++;
}
}
-
-
diff --git a/c/src/lib/libbsp/sparc/leon3/include/amba.h b/c/src/lib/libbsp/sparc/leon3/include/amba.h
index fb98df9582..9167ff111f 100644
--- a/c/src/lib/libbsp/sparc/leon3/include/amba.h
+++ b/c/src/lib/libbsp/sparc/leon3/include/amba.h
@@ -13,6 +13,9 @@
* $Id$
*/
+#ifndef __AMBA_H__
+#define __AMBA_H__
+
#define LEON3_IO_AREA 0xfff00000
#define LEON3_CONF_AREA 0xff000
#define LEON3_AHB_SLAVE_CONF_AREA (1 << 11)
@@ -24,64 +27,17 @@
#define LEON3_APB_SLAVES 16
#define LEON3_APBUARTS 8
-/* Vendor codes */
-#define VENDOR_GAISLER 1
-#define VENDOR_PENDER 2
-#define VENDOR_ESA 4
-#define VENDOR_OPENCORES 8
-
-/* Gaisler Research device id's */
-#define GAISLER_LEON3 0x03
-#define GAISLER_LEON3DSU 0x04
-#define GAISLER_ETHAHB 0x05
-#define GAISLER_APBMST 0x06
-#define GAISLER_AHBUART 0x07
-#define GAISLER_SRCTRL 0x08
-#define GAISLER_SDCTRL 0x09
-#define GAISLER_APBUART 0x0C
-#define GAISLER_IRQMP 0x0D
-#define GAISLER_AHBRAM 0x0E
-#define GAISLER_GPTIMER 0x11
-#define GAISLER_PCITRG 0x12
-#define GAISLER_PCISBRG 0x13
-#define GAISLER_PCIFBRG 0x14
-#define GAISLER_PCITRACE 0x15
-#define GAISLER_DMACTRL 0x16
-#define GAISLER_PIOPORT 0x1A
-#define GAISLER_ETHMAC 0x1D
-
-#define GAISLER_SPACEWIRE 0x01f
-
-/* European Space Agency device id's */
-#define ESA_LEON2 0x2
-#define ESA_MCTRL 0xF
-
-/* Opencores device id's */
-#define OPENCORES_PCIBR 0x4
-#define OPENCORES_ETHMAC 0x5
-
-
-/*
- *
- * Macros for manipulating Configuration registers
- *
- */
-
-
-#define amba_get_confword(tab, index, word) (*((tab).addr[(index)]+(word)))
-
-#define amba_vendor(x) (((x) >> 24) & 0xff)
-
-#define amba_device(x) (((x) >> 12) & 0xfff)
-
-#define amba_ahb_get_membar(tab, index, nr) (*((tab).addr[(index)]+4+(nr)))
-
-#define amba_apb_get_membar(tab, index) (*((tab).addr[(index)]+1))
-
-#define amba_membar_start(mbar) (((mbar) & 0xfff00000) & (((mbar) & 0xfff0) << 16))
+#include <ambapp.h>
-#define amba_iobar_start(base, iobar) ((base) | ((((iobar) & 0xfff00000)>>12) & (((iobar) & 0xfff0)<<4)) )
+#ifdef __cplusplus
+extern "C" {
+#endif
-#define amba_irq(conf) ((conf) & 0xf)
+/* The AMBA Plug&Play info of the bus that the LEON3 sits on */
+extern amba_confarea_type amba_conf;
+#ifdef __cplusplus
+}
+#endif
+#endif /* __AMBA_H__ */
diff --git a/c/src/lib/libbsp/sparc/leon3/include/leon.h b/c/src/lib/libbsp/sparc/leon3/include/leon.h
index e90b2f5950..8c130ad6cc 100644
--- a/c/src/lib/libbsp/sparc/leon3/include/leon.h
+++ b/c/src/lib/libbsp/sparc/leon3/include/leon.h
@@ -114,34 +114,12 @@ typedef struct {
} LEON3_UART_Regs_Map;
typedef struct {
- volatile unsigned int ilevel;
- volatile unsigned int ipend;
- volatile unsigned int iforce;
- volatile unsigned int iclear;
- volatile unsigned int mpstat;
- volatile unsigned int notused01;
- volatile unsigned int notused02;
- volatile unsigned int notused03;
- volatile unsigned int notused10;
- volatile unsigned int notused11;
- volatile unsigned int notused12;
- volatile unsigned int notused13;
- volatile unsigned int notused20;
- volatile unsigned int notused21;
- volatile unsigned int notused22;
- volatile unsigned int notused23;
- volatile unsigned int mask[16];
- volatile unsigned int force[16];
-} LEON3_IrqCtrl_Regs_Map;
-
-typedef struct {
volatile unsigned int value;
volatile unsigned int reload;
volatile unsigned int conf;
volatile unsigned int notused;
} LEON3_Timer_SubType;
-
typedef struct {
volatile unsigned int scaler_value; /* common timer registers */
volatile unsigned int scaler_reload;
@@ -229,29 +207,6 @@ typedef struct {
#define LEON_REG_UART_CTRL_FL 0x00000040 /* Flow control enable */
#define LEON_REG_UART_CTRL_LB 0x00000080 /* Loop Back enable */
-
-/*
- * Types and structure used for AMBA Plug & Play bus scanning
- *
- */
-
-typedef struct amba_device_table {
- int devnr; /* numbrer of devices on AHB or APB bus */
- unsigned int *addr[16]; /* addresses to the devices configuration tables */
-} amba_device_table;
-
-typedef struct amba_confarea_type {
- amba_device_table ahbmst;
- amba_device_table ahbslv;
- amba_device_table apbslv;
- unsigned int apbmst;
-} amba_confarea_type;
-
- extern amba_confarea_type amba_conf;
- /* extern amba_device_table amba_ahb_masters;
-extern amba_device_table amba_ahb_slaves;
-extern amba_device_table amba_apb_slaves; */
-extern unsigned int amba_apbmst_base; /* APB master base address */
extern volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs; /* LEON3 Interrupt Controller */
extern volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs; /* LEON3 GP Timer */
extern volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS];
diff --git a/c/src/lib/libbsp/sparc/leon3/preinstall.am b/c/src/lib/libbsp/sparc/leon3/preinstall.am
index cafe918754..ccbc9a705b 100644
--- a/c/src/lib/libbsp/sparc/leon3/preinstall.am
+++ b/c/src/lib/libbsp/sparc/leon3/preinstall.am
@@ -68,3 +68,7 @@ $(PROJECT_INCLUDE)/amba.h: include/amba.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/amba.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/amba.h
+# AMBA Plug&Play Bus
+$(PROJECT_INCLUDE)/ambapp.h: ../../sparc/shared/include/ambapp.h $(PROJECT_INCLUDE)/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/ambapp.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/ambapp.h