source: rtems/c/src/lib/libbsp/sparc/leon3/amba/amba.c @ 438b6eca

Last change on this file since 438b6eca was 438b6eca, checked in by Daniel Hellstrom <daniel@…>, on 04/05/12 at 15:23:21

LEON3: added IRQAMP support

  • Property mode set to 100644
File size: 2.4 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/* GRLIB extended IRQ controller register */
22extern void leon3_ext_irq_init(void);
23
24/* Pointers to Interrupt Controller configuration registers */
25volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs;
26
27/*
28 *  amba_initialize
29 *
30 *  Must be 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
37extern int scan_uarts(void);
38
39void amba_initialize(void)
40{
41  int i;
42  int icsel;
43  amba_apb_device dev;
44
45  /* Scan the AMBA Plug&Play info at the default LEON3 area */
46  amba_scan(&amba_conf,LEON3_IO_AREA,NULL);
47
48  /* Find LEON3 Interrupt controller */
49  i = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_IRQMP,&dev);
50  if (i <= 0){
51    /* PANIC IRQ controller not found!
52     *
53     *  What else can we do but stop ...
54     */
55    asm volatile( "mov 1, %g1; ta 0x0" );
56  }
57
58  LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) dev.start;
59  if ((LEON3_IrqCtrl_Regs->ampctrl >> 28) > 0) {
60    /* IRQ Controller has support for multiple IRQ Controllers, each
61     * CPU can be routed to different Controllers, we find out which
62     * controller by looking at the IRQCTRL Select Register for this CPU.
63     * Each Controller is located at a 4KByte offset.
64     */
65    icsel = LEON3_IrqCtrl_Regs->icsel[LEON3_Cpu_Index/8];
66    icsel = (icsel >> ((7 - (LEON3_Cpu_Index & 0x7)) * 4)) & 0xf;
67    LEON3_IrqCtrl_Regs += icsel;
68    LEON3_IrqCtrl_Regs->mask[LEON3_Cpu_Index] = 0;
69    LEON3_IrqCtrl_Regs->force[LEON3_Cpu_Index] = 0;
70    LEON3_IrqCtrl_Regs->iclear = 0xffffffff;
71  }
72
73  /* Init Extended IRQ controller if available */
74  leon3_ext_irq_init();
75
76  /* find GP Timer */
77  i = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_GPTIMER,&dev);
78  if ( i > 0 ){
79    LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) dev.start;
80  }
81
82  /* find UARTS */
83  scan_uarts();
84}
Note: See TracBrowser for help on using the repository browser.