Changeset 1982a19 in rtems


Ignore:
Timestamp:
Sep 6, 2007, 12:01:30 AM (12 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
4393845e
Parents:
4d3933b3
Message:

2007-09-05 Daniel Hellstrom <daniel@…>

  • 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.
Location:
c/src/lib/libbsp/sparc/leon3
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/leon3/ChangeLog

    r4d3933b3 r1982a19  
     12007-09-05      Daniel Hellstrom <daniel@gaisler.com>
     2
     3        * Makefile.am, preinstall.am, amba/amba.c, include/amba.h,
     4        include/leon.h: LEON3 AMBA PnP bus scanning moved to
     5        shared/amba/amba.c and shared/include/ambapp.h. The AMBA scanning was
     6        improved to take account for PnP info address translation. This is
     7        useful when scanning remote AMBA busses for example when a board
     8        connected with PCI has an AMBA bus that needs to be scanned, before
     9        the addresses was hard coded. Also, LEON2 now have AMBA PnP bus
     10        scanning support. By using the new AMBA scanning routines it is
     11        possible to isolate the AMBA scanning code to ambapp.c, however
     12        existing drivers should be updated to use them in order to save
     13        space.
     14
    1152007-09-05      Daniel Hellstrom <daniel@gaisler.com>
    216
  • c/src/lib/libbsp/sparc/leon3/Makefile.am

    r4d3933b3 r1982a19  
    4848
    4949include_HEADERS += include/amba.h
     50include_HEADERS += ../../sparc/shared/include/ambapp.h
    5051
    5152noinst_PROGRAMS += amba.rel
    52 amba_rel_SOURCES = amba/amba.c
     53amba_rel_SOURCES = amba/amba.c ../../sparc/shared/amba/ambapp.c
    5354amba_rel_CPPFLAGS = $(AM_CPPFLAGS)
    5455amba_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
  • c/src/lib/libbsp/sparc/leon3/amba/amba.c

    r4d3933b3 r1982a19  
    1515
    1616#include <bsp.h>
    17 
    18 #define amba_insert_device(tab, address) \
    19 { \
    20   if (*(address)) \
    21   { \
    22     (tab)->addr[(tab)->devnr] = (address); \
    23     (tab)->devnr ++; \
    24   } \
    25 } while(0)
    26 
    2717
    2818/* Structure containing address to devices found on the Amba Plug&Play bus */
     
    5848void bsp_leon3_predriver_hook(void)
    5949{
    60   unsigned int *cfg_area;  /* address to configuration area */
    61   unsigned int mbar, iobar, conf;
    62   int i, j;
     50  unsigned int iobar, conf;
     51  int i;
    6352  unsigned int tmp;
    64 
    65   amba_conf.ahbmst.devnr = 0; amba_conf.ahbslv.devnr = 0; amba_conf.apbslv.devnr = 0;
    66   cfg_area = (unsigned int *) (LEON3_IO_AREA | LEON3_CONF_AREA);
    67 
    68   for (i = 0; i < LEON3_AHB_MASTERS; i++)
    69   {
    70     amba_insert_device(&amba_conf.ahbmst, cfg_area);
    71     cfg_area += LEON3_AHB_CONF_WORDS;
    72   }
    73 
    74   cfg_area = (unsigned int *) (LEON3_IO_AREA | LEON3_CONF_AREA | LEON3_AHB_SLAVE_CONF_AREA);
    75   for (i = 0; i < LEON3_AHB_SLAVES; i++)
    76   {
    77     amba_insert_device(&amba_conf.ahbslv, cfg_area);
    78     cfg_area += LEON3_AHB_CONF_WORDS;
    79   } 
    80 
    81   for (i = 0; i < amba_conf.ahbslv.devnr; i ++)
    82   {
    83     conf = amba_get_confword(amba_conf.ahbslv, i, 0);
    84     mbar = amba_ahb_get_membar(amba_conf.ahbslv, i, 0);
    85     if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_APBMST) &&
    86         (apb_init == 0))
    87     {
    88       amba_conf.apbmst = amba_membar_start(mbar);
    89       cfg_area = (unsigned int *) (amba_conf.apbmst | LEON3_CONF_AREA);
    90       for (j = amba_conf.apbslv.devnr; j < LEON3_APB_SLAVES; j++)
    91       {
    92         amba_insert_device(&amba_conf.apbslv, cfg_area);
    93         cfg_area += LEON3_APB_CONF_WORDS;
    94       }
    95       apb_init = 1;
    96     }
    97   }   
     53       
     54        /* Scan the AMBA Plug&Play info at the default LEON3 area */
     55        amba_scan(&amba_conf,LEON3_IO_AREA,NULL);
    9856
    9957  /* Find LEON3 Interrupt controler */
     
    10563    {
    10664      iobar = amba_apb_get_membar(amba_conf.apbslv, i);
    107       LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) amba_iobar_start(amba_conf.apbmst, iobar);
     65      LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) amba_iobar_start(amba_conf.apbslv.apbmst[i], iobar);
    10866      /* asm("mov %%asr17, %0": : "r" (tmp)); */
    10967      if (Configuration.User_multiprocessing_table != NULL)
    11068      {
    111         tmp = getasr17();
    112         LEON3_Cpu_Index = (tmp >> 28) & 3;
     69              tmp = getasr17();
     70        LEON3_Cpu_Index = (tmp >> 28) & 3;
    11371      }
    11472      break;
     
    12583      iobar = amba_apb_get_membar(amba_conf.apbslv, i);     
    12684      LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *)
    127         amba_iobar_start(amba_conf.apbmst, iobar);
     85      amba_iobar_start(amba_conf.apbslv.apbmst[i], iobar);
    12886      break;
    12987    }
     
    13290
    13391}
    134 
    135 
  • c/src/lib/libbsp/sparc/leon3/include/amba.h

    r4d3933b3 r1982a19  
    1414 */
    1515
     16#ifndef __AMBA_H__
     17#define __AMBA_H__
     18
    1619#define LEON3_IO_AREA 0xfff00000
    1720#define LEON3_CONF_AREA 0xff000
     
    2528#define LEON3_APBUARTS 8
    2629
    27 /* Vendor codes */
    28 #define VENDOR_GAISLER   1
    29 #define VENDOR_PENDER    2
    30 #define VENDOR_ESA       4
    31 #define VENDOR_OPENCORES 8
     30#include <ambapp.h>
    3231
    33 /* Gaisler Research device id's */
    34 #define GAISLER_LEON3    0x03
    35 #define GAISLER_LEON3DSU 0x04
    36 #define GAISLER_ETHAHB   0x05
    37 #define GAISLER_APBMST   0x06
    38 #define GAISLER_AHBUART  0x07
    39 #define GAISLER_SRCTRL   0x08
    40 #define GAISLER_SDCTRL   0x09
    41 #define GAISLER_APBUART  0x0C
    42 #define GAISLER_IRQMP    0x0D
    43 #define GAISLER_AHBRAM   0x0E
    44 #define GAISLER_GPTIMER  0x11
    45 #define GAISLER_PCITRG   0x12
    46 #define GAISLER_PCISBRG  0x13
    47 #define GAISLER_PCIFBRG  0x14
    48 #define GAISLER_PCITRACE 0x15
    49 #define GAISLER_DMACTRL  0x16
    50 #define GAISLER_PIOPORT  0x1A
    51 #define GAISLER_ETHMAC   0x1D
    52  
    53 #define GAISLER_SPACEWIRE 0x01f
     32#ifdef __cplusplus
     33extern "C" {
     34#endif
    5435
    55 /* European Space Agency device id's */
    56 #define ESA_LEON2        0x2
    57 #define ESA_MCTRL        0xF
     36/* The AMBA Plug&Play info of the bus that the LEON3 sits on */
     37extern amba_confarea_type amba_conf;
    5838
    59 /* Opencores device id's */
    60 #define OPENCORES_PCIBR  0x4 
    61 #define OPENCORES_ETHMAC 0x5
     39#ifdef __cplusplus
     40}
     41#endif
    6242
    63 
    64 /*
    65  *
    66  * Macros for manipulating Configuration registers 
    67  *
    68  */
    69 
    70 
    71 #define amba_get_confword(tab, index, word) (*((tab).addr[(index)]+(word)))
    72 
    73 #define amba_vendor(x) (((x) >> 24) & 0xff)
    74 
    75 #define amba_device(x) (((x) >> 12) & 0xfff)
    76 
    77 #define amba_ahb_get_membar(tab, index, nr) (*((tab).addr[(index)]+4+(nr)))
    78 
    79 #define amba_apb_get_membar(tab, index) (*((tab).addr[(index)]+1))
    80 
    81 #define amba_membar_start(mbar) (((mbar) & 0xfff00000) & (((mbar) & 0xfff0) << 16))
    82 
    83 #define amba_iobar_start(base, iobar) ((base) | ((((iobar) & 0xfff00000)>>12) & (((iobar) & 0xfff0)<<4)) )
    84 
    85 #define amba_irq(conf) ((conf) & 0xf)
    86 
    87 
     43#endif /* __AMBA_H__ */
  • c/src/lib/libbsp/sparc/leon3/include/leon.h

    r4d3933b3 r1982a19  
    115115
    116116typedef struct {
    117   volatile unsigned int ilevel;
    118   volatile unsigned int ipend;
    119   volatile unsigned int iforce;
    120   volatile unsigned int iclear;
    121   volatile unsigned int mpstat;
    122   volatile unsigned int notused01;
    123   volatile unsigned int notused02;
    124   volatile unsigned int notused03;
    125   volatile unsigned int notused10;
    126   volatile unsigned int notused11;
    127   volatile unsigned int notused12;
    128   volatile unsigned int notused13;
    129   volatile unsigned int notused20;
    130   volatile unsigned int notused21;
    131   volatile unsigned int notused22;
    132   volatile unsigned int notused23;
    133   volatile unsigned int mask[16];
    134   volatile unsigned int force[16];
    135 } LEON3_IrqCtrl_Regs_Map;
    136 
    137 typedef struct {
    138117  volatile unsigned int value;
    139118  volatile unsigned int reload;
     
    141120  volatile unsigned int notused;
    142121} LEON3_Timer_SubType;
    143 
    144122
    145123typedef struct {
     
    230208#define LEON_REG_UART_CTRL_LB     0x00000080 /* Loop Back enable */
    231209
    232 
    233 /*
    234  *  Types and structure used for AMBA Plug & Play bus scanning
    235  *
    236  */
    237 
    238 typedef struct amba_device_table {
    239   int            devnr;           /* numbrer of devices on AHB or APB bus */
    240   unsigned int   *addr[16];       /* addresses to the devices configuration tables */
    241 } amba_device_table;
    242 
    243 typedef struct amba_confarea_type {
    244   amba_device_table ahbmst;
    245   amba_device_table ahbslv;
    246   amba_device_table apbslv;
    247   unsigned int      apbmst;
    248 } amba_confarea_type;
    249 
    250   extern amba_confarea_type amba_conf; 
    251   /* extern amba_device_table amba_ahb_masters;
    252 extern amba_device_table amba_ahb_slaves; 
    253 extern amba_device_table amba_apb_slaves;  */
    254 extern unsigned int amba_apbmst_base;    /* APB master base address */
    255210extern volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs;  /* LEON3 Interrupt Controller */
    256211extern volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs; /* LEON3 GP Timer */
  • c/src/lib/libbsp/sparc/leon3/preinstall.am

    r4d3933b3 r1982a19  
    6969PREINSTALL_FILES += $(PROJECT_INCLUDE)/amba.h
    7070
     71# AMBA Plug&Play Bus
     72$(PROJECT_INCLUDE)/ambapp.h: ../../sparc/shared/include/ambapp.h $(PROJECT_INCLUDE)/$(dirstamp)
     73        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/ambapp.h
     74PREINSTALL_FILES += $(PROJECT_INCLUDE)/ambapp.h
Note: See TracChangeset for help on using the changeset viewer.