SPARC: Added AMBA PnP Information listing command for LEON3
PATCH 5/13 SPARC: Added AMBA PnP Information listing command for LEON3
Hello Wolfgang,
This patch adds an U-Boot command, ambapp, which prints a summary of AMBA Bus Plug & Play information.
AMBA is a bus specified by ARM. AMBA with Plug and Play information is a Gaisler extension to that bus. See www.gaisler.com.
######################
U-Boot 1.3.2-00273-gf85e20a (Mar 28 2008 - 13:13:48)GAISLER LEON3 GR-XC3S-1500
CPU: LEON3 Board: GR-XC3S-1500 FLASH: 8 MB In: serial Out: serial Err: serial Net: GRETH 10/100
Type "run flash_nfs" to mount root filesystem over NFS
Hit any key to stop autoboot: 0
=> ambapp
--------- AHB Masters ---------
0x00:0x01:0x03: VENDOR_GAISLER GAISLER_LEON3
irq: 0 (ver: 0)
--------- AHB Slaves ---------
0x00:0x04:0x0f: VENDOR_ESA ESA_MCTRL
mem: 0x00000000 - 0x10000000
mem: 0x20000000 - 0x30000000
mem: 0x40000000 - 0x70000000
irq: 1 (ver: 0)
0x01:0x01:0x06: VENDOR_GAISLER GAISLER_APBMST
mem: 0xc0000000 - 0xc0100000
irq: 3 (ver: 0)
--------- APB Slaves ---------
0x00:0x04:0x0f: VENDOR_ESA ESA_MCTRL
apb: 0xc0000000 - 0xc0000100
irq: 1 (ver: 0 )
0x01:0x01:0x0c: VENDOR_GAISLER GAISLER_APBUART
apb: 0xc0000100 - 0xc0000200
irq: 3 (ver: 0 )
0x02:0x01:0x0d: VENDOR_GAISLER GAISLER_IRQMP
apb: 0xc0000200 - 0xc0000300
irq: 7 (ver: 0 )
0x03:0x01:0x11: VENDOR_GAISLER GAISLER_GPTIMER
apb: 0xc0000300 - 0xc0000400
irq: 8 (ver: 0 )
0x04:0x01:0x1d: VENDOR_GAISLER GAISLER_ETHMAC
apb: 0xc0000800 - 0xc0001000
irq: 12 (ver: 0 )
=>
######################
This patch is also available at
ftp://ftp.gaisler.com/gaisler.com/u-boot/patches.
Best Regards,
Daniel Hellstrom
common/Makefile | 1 + common/cmd_ambapp.c | 278 ++++++++++++++++++++++++++++++++++++++++++++++ cpu/leon3/ambapp.c | 20 ++++ include/ambapp.h | 14 +++ include/config_cmd_all.h | 1 + 5 files changed, 314 insertions(+), 0 deletions(-)
common/Makefile +1 -0
@@ -32,6 +32,7 @@ COBJS-y += ACEX1K.o COBJS-y += altera.o COBJS-y += bedbug.o COBJS-y += circbuf.o +COBJS-$(CONFIG_CMD_AMBAPP) += cmd_ambapp.o COBJS-y += cmd_autoscript.o COBJS-$(CONFIG_CMD_BDI) += cmd_bdinfo.o COBJS-$(CONFIG_CMD_BEDBUG) += cmd_bedbug.o
common/cmd_ambapp.c new file +154 -0
154 lines not on this page · raw message
index)
+{
+ char *dev_str, *ven_str; + int irq, ver, vendor, deviceid; + unsigned int address, apbmst_base, mask; + + vendor = amba_vendor(apb->conf); + deviceid = amba_device(apb->conf); + irq = amba_irq(apb->conf); + ver = amba_ver(apb->conf); + apbmst_base = apbmst->address[0] & LEON3_IO_AREA; + address = (apbmst_base | (((apb->bar & 0xfff00000) >> 12))) &
+ (((apb->bar & 0x0000fff0) << 4) | 0xfff00000);
+
+ mask = amba_membar_mask(apb->bar) << 8;
+ mask = ((~mask) & 0x000fffff) + 1;
+
+ ven_str = ambapp_vendor_id2str(vendor);
+ if (!ven_str) {
+ ven_str = unknown;
+ dev_str = unknown;
+ } else {
+ dev_str = ambapp_device_id2str(vendor, deviceid);
+ if (!dev_str)
+ dev_str = unknown;
+ }
+
+ printf("0x%02x:0x%02x:0x%02x: %s %s\n"
+ " apb: 0x%08x - 0x%08x\n" + " irq: %-2d (ver: %-2d)\n", + index, vendor, deviceid, ven_str, dev_str, address, + address + mask, irq, ver);
+}
+
+void ambapp_print_ahb(ahbctrl_pp_dev * ahb, int index) +{
+ char *dev_str, *ven_str; + int irq, ver, vendor, deviceid; + unsigned int addr, mask; + int j; + + vendor = amba_vendor(ahb->conf); + deviceid = amba_device(ahb->conf); + irq = amba_irq(ahb->conf); + ver = amba_ver(ahb->conf);
+
+ ven_str = ambapp_vendor_id2str(vendor);
+ if (!ven_str) {
+ ven_str = unknown;
+ dev_str = unknown;
+ } else {
+ dev_str = ambapp_device_id2str(vendor, deviceid);
+ if (!dev_str)
+ dev_str = unknown;
+ }
+
+ printf("0x%02x:0x%02x:0x%02x: %s %s\n",
+ index, vendor, deviceid, ven_str, dev_str);
+
+ for (j = 0; j < 4; j++) {
+ addr = amba_membar_start(ahb->bars[j]);
+ if (amba_membar_type(ahb->bars[j]) == 0)
+ continue;
+ if (amba_membar_type(ahb->bars[j]) == AMBA_TYPE_AHBIO)
+ addr = AMBA_TYPE_AHBIO_ADDR(addr);
+ mask = amba_membar_mask(ahb->bars[j]) << 20;
+ printf(" mem: 0x%08x - 0x%08x\n", addr, addr + ((~mask) + 1));
+ }
+
+ printf(" irq: %-2d (ver: %d)\n", irq, ver);
+}
+
+int do_ambapp_print(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) +{
+
+ /* Print AHB Masters */
+ puts("--------- AHB Masters ---------\n");
+ ambapp_apb_print = 0;
+ ambapp_ahb_print = 1;
+ ambapp_ahbmst_count(99, 99); /* Get vendor&device 99 =
nonexistent... */
+
+ /* Print AHB Slaves */
+ puts("--------- AHB Slaves ---------\n");
+ ambapp_ahbslv_count(99, 99); /* Get vendor&device 99 =
nonexistent... */
+
+ /* Print APB Slaves */
+ puts("--------- APB Slaves ---------\n");
+ ambapp_apb_print = 1;
+ ambapp_ahb_print = 0;
+ ambapp_apb_count(99, 99); /* Get vendor&device 99 =
nonexistent... */
+
+ /* Reset, no futher printing */
+ ambapp_apb_print = 0;
+ ambapp_ahb_print = 0;
+ puts("\n");
+ return 0;+}
+
+int ambapp_init_reloc(void)
+{
+ ambapp_vendor_devnames *vend = vendors;
+ ambapp_device_name *dev;
+
+ while (vend->vendor_id && vend->name) {
+ vend->name = (char *)((unsigned int)vend->name + gd->reloc_off);
+ vend->devices =
+ (ambapp_device_name *) ((unsigned int)vend->devices +
+ gd->reloc_off);;
+ dev = vend->devices; + vend++; + if (!dev)
+ continue;
+ while (dev->device_id && dev->name) {
+ dev->name =
+ (char *)((unsigned int)dev->name + gd->reloc_off);;
+ dev++;
+ }
+ }
+ return 0;
+}
+
+U_BOOT_CMD(ambapp, 1, 1, do_ambapp_print,
+ "ambapp - list AMBA Plug&Play information\n", + "ambapp\n" + " - lists AMBA (AHB & APB) Plug&Play devices present on the
system\n");
cpu/leon3/ambapp.c +8 -0
@@ -28,6 +28,14 @@#include <command.h> #include <ambapp.h> +#if defined(CONFIG_CMD_AMBAPP ) +extern void ambapp_print_apb (apbctrl_pp_dev * apb, +ambapp_ahbdev * apbmst,int index); +extern void ambapp_print_ahb (ahbctrl_pp_dev * ahb,int index); +extern int ambapp_apb_print; +extern int ambapp_ahb_print; +#endif + static int ambapp_apb_scan(unsigned int vendor, /* Plug&Play Vendor
ID */
unsigned int driver, /* Plug&Play Device ID */
ambapp_apbdev * dev, /* Result(s) is placed here */
@@ -58,6 +66,12 @@ static int ambapp_apb_scan(unsigned int vendor, /*
Plug&Play Vendor ID */
apb = (apbctrl_pp_dev *) (apbmst_base | LEON3_CONF_AREA);
for (i = 0; i < LEON3_APB_SLAVES; i++) {+#if defined(CONFIG_CMD_AMBAPP)
+ if (ambapp_apb_print && amba_vendor(apb->conf)
+ && amba_device(apb->conf)) {
+ ambapp_print_apb(apb, &apbmst, i);
+ }
+#endif
if ((amba_vendor(apb->conf) == vendor) &&
(amba_device(apb->conf) == driver) && ((index < 0)
|| (index-- == 0))) {
@@ -192,6 +206,12 @@ static int ambapp_ahb_scan(unsigned int vendor,
/* Plug&Play Vendor ID */
}
for (i = 0; i < max_pp_devs; i++) {+#if defined(CONFIG_CMD_AMBAPP)
+ if (ambapp_ahb_print && amba_vendor(ahb->conf) &&
+ amba_device(ahb->conf)) {
+ ambapp_print_ahb(ahb, i);
+ }
+#endif
if ((amba_vendor(ahb->conf) == vendor) &&
(amba_device(ahb->conf) == driver) &&
((index < 0) || (index-- == 0))) {include/ambapp.h +14 -0
@@ -140,6 +140,20 @@#ifndef __ASSEMBLER__ +#ifdef CONFIG_CMD_AMBAPP + +/* AMBA Plug&Play relocation & initialization */ +int ambapp_init_reloc (void ); + +/* AMBA Plug&Play Name of Vendors and devices */ + +/* Return name of device */ +char *ambapp_device_id2str (int vendor,int id); + +/* Return name of vendor */ +char *ambapp_vendor_id2str (int vendor); +#endif +/* * Types and structure used for AMBA Plug & Play bus scanning */
include/config_cmd_all.h +1 -0
@@ -13,6 +13,7 @@* Alphabetical list of all possible commands. */ +#define CONFIG_CMD_AMBAPP /* AMBA Plug & Play Bus print utility */ #define CONFIG_CMD_ASKENV /* ask for env variable */ #define CONFIG_CMD_AUTOSCRIPT /* Autoscript Support */ #define CONFIG_CMD_BDI /* bdinfo */