source: rtems/c/src/lib/libbsp/sparc/leon3/amba/amba.c @ 1982a19

4.104.114.84.95
Last change on this file since 1982a19 was 1982a19, checked in by Joel Sherrill <joel.sherrill@…>, on 09/06/07 at 00:01:30

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.
  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  AMBA Plag & Play Bus Driver
3 *
4 *  This driver hook performs bus scanning.
5 *
6 *  COPYRIGHT (c) 2004.
7 *  Gaisler Research
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#include <bsp.h>
17
18/* Structure containing address to devices found on the Amba Plug&Play bus */
19amba_confarea_type amba_conf;
20
21/* Pointers to Interrupt Controller configuration registers */
22volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs;
23
24int LEON3_Cpu_Index = 0;
25static int apb_init = 0;
26
27/*
28 *  bsp_leon3_predriver_hook
29 *
30 *  BSP predriver hook.  Called just before drivers are initialized.
31 *  Used to scan system bus. Probes for AHB masters, AHB slaves and
32 *  APB slaves. Addresses to configuration areas of the AHB masters,
33 *  AHB slaves, APB slaves and APB master are storeds in
34 *  amba_ahb_masters, amba_ahb_slaves and amba.
35 */
36
37unsigned int getasr17();
38
39asm(" .text  \n"
40    "getasr17:   \n"
41    "retl \n"
42    "mov %asr17, %o0\n"
43);
44   
45     
46extern rtems_configuration_table Configuration;
47
48void bsp_leon3_predriver_hook(void)
49{
50  unsigned int iobar, conf;
51  int i;
52  unsigned int tmp;
53       
54        /* Scan the AMBA Plug&Play info at the default LEON3 area */
55        amba_scan(&amba_conf,LEON3_IO_AREA,NULL);
56
57  /* Find LEON3 Interrupt controler */
58  i = 0;
59  while (i < amba_conf.apbslv.devnr)
60  {
61    conf = amba_get_confword(amba_conf.apbslv, i, 0);
62    if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_IRQMP))
63    {
64      iobar = amba_apb_get_membar(amba_conf.apbslv, i);
65      LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) amba_iobar_start(amba_conf.apbslv.apbmst[i], iobar);
66      /* asm("mov %%asr17, %0": : "r" (tmp)); */
67      if (Configuration.User_multiprocessing_table != NULL)
68      {
69              tmp = getasr17();
70        LEON3_Cpu_Index = (tmp >> 28) & 3;
71      }
72      break;
73    }
74    i++;
75  }
76  /* find GP Timer */
77  i = 0;
78 while (i < amba_conf.apbslv.devnr)
79  {
80    conf = amba_get_confword(amba_conf.apbslv, i, 0);
81    if ((amba_vendor(conf) == VENDOR_GAISLER) &&
82       (amba_device(conf) == GAISLER_GPTIMER)) {
83      iobar = amba_apb_get_membar(amba_conf.apbslv, i);     
84      LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *)
85      amba_iobar_start(amba_conf.apbslv.apbmst[i], iobar);
86      break;
87    }
88    i++;
89  }
90
91}
Note: See TracBrowser for help on using the repository browser.