1 | /* vmeconfig.c,v 1.1.2.2 2003/03/25 16:46:01 joel Exp */ |
---|
2 | |
---|
3 | /* Standard VME bridge configuration for VGM type boards */ |
---|
4 | |
---|
5 | /* |
---|
6 | * Authorship |
---|
7 | * ---------- |
---|
8 | * This software was created by |
---|
9 | * Till Straumann <strauman@slac.stanford.edu>, 2002, |
---|
10 | * Stanford Linear Accelerator Center, Stanford University. |
---|
11 | * |
---|
12 | * Acknowledgement of sponsorship |
---|
13 | * ------------------------------ |
---|
14 | * This software was produced by |
---|
15 | * the Stanford Linear Accelerator Center, Stanford University, |
---|
16 | * under Contract DE-AC03-76SFO0515 with the Department of Energy. |
---|
17 | * |
---|
18 | * Government disclaimer of liability |
---|
19 | * ---------------------------------- |
---|
20 | * Neither the United States nor the United States Department of Energy, |
---|
21 | * nor any of their employees, makes any warranty, express or implied, or |
---|
22 | * assumes any legal liability or responsibility for the accuracy, |
---|
23 | * completeness, or usefulness of any data, apparatus, product, or process |
---|
24 | * disclosed, or represents that its use would not infringe privately owned |
---|
25 | * rights. |
---|
26 | * |
---|
27 | * Stanford disclaimer of liability |
---|
28 | * -------------------------------- |
---|
29 | * Stanford University makes no representations or warranties, express or |
---|
30 | * implied, nor assumes any liability for the use of this software. |
---|
31 | * |
---|
32 | * Stanford disclaimer of copyright |
---|
33 | * -------------------------------- |
---|
34 | * Stanford University, owner of the copyright, hereby disclaims its |
---|
35 | * copyright and all other rights in this software. Hence, anyone may |
---|
36 | * freely use it for any purpose without restriction. |
---|
37 | * |
---|
38 | * Maintenance of notices |
---|
39 | * ---------------------- |
---|
40 | * In the interest of clarity regarding the origin and status of this |
---|
41 | * SLAC software, this and all the preceding Stanford University notices |
---|
42 | * are to remain affixed to any copy or derivative of this software made |
---|
43 | * or distributed by the recipient and are to be affixed to any copy of |
---|
44 | * software made or distributed by the recipient that contains a copy or |
---|
45 | * derivative of this software. |
---|
46 | * |
---|
47 | * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03 |
---|
48 | */ |
---|
49 | |
---|
50 | #include <bsp.h> |
---|
51 | #include <bsp/VME.h> |
---|
52 | #include <bsp/vmeUniverse.h> |
---|
53 | #include <bsp/VMEConfig.h> |
---|
54 | #include <bsp/irq.h> |
---|
55 | #include <libcpu/bat.h> |
---|
56 | #include <libcpu/spr.h> |
---|
57 | #include <bsp/motorola.h> |
---|
58 | |
---|
59 | /* Use a weak alias for the VME configuration. |
---|
60 | * This permits individual applications to override |
---|
61 | * this routine. |
---|
62 | * They may even create an 'empty' |
---|
63 | * |
---|
64 | * void BSP_vme_config(void) {} |
---|
65 | * |
---|
66 | * which will avoid linking in the Universe driver |
---|
67 | * at all :-). |
---|
68 | */ |
---|
69 | |
---|
70 | void BSP_vme_config(void) __attribute__ (( weak, alias("__BSP_default_vme_config") )); |
---|
71 | |
---|
72 | SPR_RO(DBAT0U) |
---|
73 | |
---|
74 | extern uint32_t VME_Slot1; |
---|
75 | |
---|
76 | void |
---|
77 | __BSP_default_vme_config(void) |
---|
78 | { |
---|
79 | union { |
---|
80 | struct _BATU bat; |
---|
81 | unsigned long batbits; |
---|
82 | } dbat0u; |
---|
83 | |
---|
84 | vmeUniverseInit(); |
---|
85 | vmeUniverseReset(); |
---|
86 | |
---|
87 | /* setup a PCI area to map the VME bus */ |
---|
88 | |
---|
89 | dbat0u.batbits = _read_DBAT0U(); |
---|
90 | |
---|
91 | /* map VME address ranges */ |
---|
92 | vmeUniverseMasterPortCfg( |
---|
93 | 0, |
---|
94 | VME_AM_EXT_SUP_DATA, |
---|
95 | _VME_A32_WIN0_ON_VME, |
---|
96 | _VME_A32_WIN0_ON_PCI, |
---|
97 | 0x0F000000); |
---|
98 | vmeUniverseMasterPortCfg( |
---|
99 | 1, |
---|
100 | VME_AM_STD_SUP_DATA, |
---|
101 | 0x00000000, |
---|
102 | _VME_A24_ON_PCI, |
---|
103 | 0x00ff0000); |
---|
104 | vmeUniverseMasterPortCfg( |
---|
105 | 2, |
---|
106 | VME_AM_SUP_SHORT_IO, |
---|
107 | 0x00000000, |
---|
108 | _VME_A16_ON_PCI, |
---|
109 | 0x00010000); |
---|
110 | |
---|
111 | #ifdef _VME_DRAM_OFFSET |
---|
112 | #if 0 |
---|
113 | if (VME_Slot1){ |
---|
114 | /* map our memory to VME */ |
---|
115 | printk("vmeUniverseSlavePortCfg length of 0x%x\n", BSP_mem_size); |
---|
116 | vmeUniverseSlavePortCfg( |
---|
117 | 0, |
---|
118 | VME_AM_EXT_SUP_DATA, |
---|
119 | _VME_DRAM_32_OFFSET1, |
---|
120 | PCI_DRAM_OFFSET, |
---|
121 | BSP_mem_size); |
---|
122 | printk("vmeUniverseSlavePortCfg length of 0x%x\n", _VME_A24_SIZE); |
---|
123 | vmeUniverseSlavePortCfg( |
---|
124 | 1, |
---|
125 | VME_AM_STD_SUP_DATA, |
---|
126 | _VME_DRAM_24_OFFSET1, |
---|
127 | PCI_DRAM_OFFSET, |
---|
128 | _VME_A24_SIZE); |
---|
129 | printk("vmeUniverseSlavePortCfg length of 0x%x\n", _VME_A16_SIZE); |
---|
130 | vmeUniverseSlavePortCfg( |
---|
131 | 2, |
---|
132 | VME_AM_SUP_SHORT_IO, |
---|
133 | _VME_DRAM_16_OFFSET1, |
---|
134 | PCI_DRAM_OFFSET, |
---|
135 | _VME_A16_SIZE); |
---|
136 | } |
---|
137 | else { |
---|
138 | printk("vmeUniverseSlavePortCfg length of 0x%x\n", BSP_mem_size); |
---|
139 | vmeUniverseSlavePortCfg( |
---|
140 | 0, |
---|
141 | VME_AM_EXT_SUP_DATA, |
---|
142 | _VME_DRAM_32_OFFSET2, |
---|
143 | PCI_DRAM_OFFSET, |
---|
144 | BSP_mem_size); |
---|
145 | printk("vmeUniverseSlavePortCfg length of 0x%x\n", _VME_A24_SIZE); |
---|
146 | vmeUniverseSlavePortCfg( |
---|
147 | 1, |
---|
148 | VME_AM_STD_SUP_DATA, |
---|
149 | _VME_DRAM_24_OFFSET2, |
---|
150 | PCI_DRAM_OFFSET, |
---|
151 | _VME_A24_SIZE); |
---|
152 | printk("vmeUniverseSlavePortCfg length of 0x%x\n", _VME_A16_SIZE); |
---|
153 | vmeUniverseSlavePortCfg( |
---|
154 | 2, |
---|
155 | VME_AM_SUP_SHORT_IO, |
---|
156 | _VME_DRAM_16_OFFSET2, |
---|
157 | PCI_DRAM_OFFSET, |
---|
158 | _VME_A16_SIZE); |
---|
159 | } |
---|
160 | #endif |
---|
161 | |
---|
162 | /* make sure the host bridge PCI master is enabled */ |
---|
163 | vmeUniverseWriteReg( |
---|
164 | vmeUniverseReadReg(UNIV_REGOFF_PCI_CSR) | UNIV_PCI_CSR_BM, |
---|
165 | UNIV_REGOFF_PCI_CSR); |
---|
166 | #endif |
---|
167 | |
---|
168 | |
---|
169 | /* stdio is not yet initialized; the driver will revert to printk */ |
---|
170 | vmeUniverseMasterPortsShow(0); |
---|
171 | vmeUniverseSlavePortsShow(0); |
---|
172 | |
---|
173 | /* install the VME insterrupt manager */ |
---|
174 | vmeUniverseInstallIrqMgr(0,5,1,6); |
---|
175 | if (vmeUniverse0PciIrqLine<0) |
---|
176 | BSP_panic("Unable to get interrupt line info from PCI config"); |
---|
177 | _BSP_vme_bridge_irq=BSP_PCI_IRQ_LOWEST_OFFSET+vmeUniverse0PciIrqLine; |
---|
178 | } |
---|