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 */ |
---|
19 | amba_confarea_type amba_conf; |
---|
20 | |
---|
21 | /* Pointers to Interrupt Controller configuration registers */ |
---|
22 | volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs; |
---|
23 | |
---|
24 | int LEON3_Cpu_Index = 0; |
---|
25 | static 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 | |
---|
37 | unsigned int getasr17(); |
---|
38 | |
---|
39 | asm(" .text \n" |
---|
40 | "getasr17: \n" |
---|
41 | "retl \n" |
---|
42 | "mov %asr17, %o0\n" |
---|
43 | ); |
---|
44 | |
---|
45 | |
---|
46 | extern rtems_configuration_table Configuration; |
---|
47 | |
---|
48 | void 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 | } |
---|