source: rtems/c/src/lib/libbsp/powerpc/beatnik/vme/vmeconfig.c @ 183af89

4.115
Last change on this file since 183af89 was b7a6d23a, checked in by Till Straumann <strauman@…>, on 12/03/09 at 16:56:50
  • importing 'beatnik' BSP from SLAC repository.
  • Property mode set to 100644
File size: 8.0 KB
Line 
1/* $Id$ */
2
3/* Standard VME bridge configuration for MVME5500, MVME6100 */
4
5/*
6 * Authorship
7 * ----------
8 * This software ('beatnik' RTEMS BSP for MVME6100 and MVME5500) was
9 *     created by Till Straumann <strauman@slac.stanford.edu>, 2005-2007,
10 *         Stanford Linear Accelerator Center, Stanford University.
11 *
12 * Acknowledgement of sponsorship
13 * ------------------------------
14 * The 'beatnik' BSP 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 <rtems.h>
51#include <rtems/bspIo.h>
52#include <bsp.h>
53#include <bsp/VME.h>
54#include <bsp/VMEConfig.h>
55#include <bsp/irq.h>
56#include <bsp/vmeUniverse.h>
57#define _VME_TSI148_DECLARE_SHOW_ROUTINES
58#include <bsp/vmeTsi148.h>
59#include <libcpu/bat.h>
60
61/* Use a weak alias for the VME configuration.
62 * This permits individual applications to override
63 * this routine.
64 * They may even create an 'empty'
65 *
66 *    void BSP_vme_config(void) {}
67 *
68 * which will avoid linking in the Universe driver
69 * at all :-).
70 */
71
72void BSP_vme_config(void) __attribute__ (( weak, alias("__BSP_default_vme_config") ));
73
74typedef struct {
75        int                             (*xlate_adrs)(int, int, unsigned long, unsigned long, unsigned long *);
76        int                             (*install_isr)(unsigned long, BSP_VME_ISR_t, void *);
77        int                             (*remove_isr)(unsigned long, BSP_VME_ISR_t, void *);
78        BSP_VME_ISR_t   (*get_isr)(unsigned long vector, void **);
79        int                             (*enable_int_lvl)(unsigned int);
80        int                             (*disable_int_lvl)(unsigned int);
81        int                             (*outbound_p_cfg)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
82        int                             (*inbound_p_cfg) (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
83        void                    (*outbound_p_show)(FILE*);
84        void                    (*inbound_p_show) (FILE*);
85        void            (*reset_bus)(void);
86        int                             (*install_irq_mgr)(int, int, int, ...);
87} VMEOpsRec, *VMEOps;
88
89static VMEOpsRec uniOpsRec = {
90        xlate_adrs:             vmeUniverseXlateAddr,
91        install_isr:            vmeUniverseInstallISR,
92        remove_isr:             vmeUniverseRemoveISR,
93        get_isr:                        vmeUniverseISRGet,
94        enable_int_lvl:         vmeUniverseIntEnable,
95        disable_int_lvl:        vmeUniverseIntDisable,
96        outbound_p_cfg:         vmeUniverseMasterPortCfg,
97        inbound_p_cfg:          vmeUniverseSlavePortCfg,
98        outbound_p_show:        vmeUniverseMasterPortsShow,
99        inbound_p_show:         vmeUniverseSlavePortsShow,
100        reset_bus:          vmeUniverseResetBus,
101        install_irq_mgr:        vmeUniverseInstallIrqMgrAlt,
102};
103
104static VMEOpsRec tsiOpsRec = {
105        xlate_adrs:             vmeTsi148XlateAddr,
106        install_isr:            vmeTsi148InstallISR,
107        remove_isr:             vmeTsi148RemoveISR,
108        get_isr:                        vmeTsi148ISRGet,
109        enable_int_lvl:         vmeTsi148IntEnable,
110        disable_int_lvl:        vmeTsi148IntDisable,
111        outbound_p_cfg:         vmeTsi148OutboundPortCfg,
112        inbound_p_cfg:          vmeTsi148InboundPortCfg,
113        outbound_p_show:        vmeTsi148OutboundPortsShow,
114        inbound_p_show:         vmeTsi148InboundPortsShow,
115        reset_bus:          vmeTsi148ResetBus,
116        install_irq_mgr:        vmeTsi148InstallIrqMgrAlt,
117};
118
119static VMEOps theOps = 0;
120
121int
122BSP_vme2local_adrs(unsigned long am, unsigned long vmeaddr, unsigned long *plocaladdr)
123{
124int rval=theOps->xlate_adrs(1,0,am,vmeaddr,plocaladdr);
125        *plocaladdr+=PCI_MEM_BASE;
126        return rval;
127}
128
129int
130BSP_local2vme_adrs(unsigned long am, unsigned long localaddr, unsigned long *pvmeaddr)
131{
132        return theOps->xlate_adrs(0, 0, am,localaddr+PCI_DRAM_OFFSET,pvmeaddr);
133}
134
135int
136BSP_installVME_isr(unsigned long vector, BSP_VME_ISR_t handler, void *arg)
137{
138        return theOps->install_isr(vector, handler, arg);
139}
140
141int
142BSP_removeVME_isr(unsigned long vector, BSP_VME_ISR_t handler, void *arg)
143{
144        return theOps->remove_isr(vector, handler, arg);
145}
146
147/* retrieve the currently installed ISR for a given vector */
148BSP_VME_ISR_t
149BSP_getVME_isr(unsigned long vector, void **parg)
150{
151        return theOps->get_isr(vector, parg);
152}
153
154int
155BSP_enableVME_int_lvl(unsigned int level)
156{
157        return theOps->enable_int_lvl(level);
158}
159
160int
161BSP_disableVME_int_lvl(unsigned int level)
162{
163        return theOps->disable_int_lvl(level);
164}
165
166int
167BSP_VMEOutboundPortCfg(
168        unsigned long port,
169        unsigned long address_space,
170        unsigned long vme_address,
171        unsigned long pci_address,
172        unsigned long size)
173{
174        return theOps->outbound_p_cfg(port, address_space, vme_address, pci_address, size);
175}
176
177int
178BSP_VMEInboundPortCfg(
179        unsigned long port,
180        unsigned long address_space,
181        unsigned long vme_address,
182        unsigned long pci_address,
183        unsigned long size)
184{
185        return theOps->inbound_p_cfg(port, address_space, vme_address, pci_address, size);
186}
187
188void
189BSP_VMEOutboundPortsShow(FILE *f)
190{
191        theOps->outbound_p_show(f);
192}
193
194void
195BSP_VMEInboundPortsShow(FILE *f)
196{
197        theOps->inbound_p_show(f);
198}
199
200void
201BSP_VMEResetBus(void)
202{
203        theOps->reset_bus();
204}
205
206static unsigned short
207tsi_clear_errors(int quiet)
208{
209unsigned long   v;
210unsigned short  rval;
211        v = vmeTsi148ClearVMEBusErrors(0);
212
213        /* return bits 8..23 of VEAT; set bit 15 to make sure rval is nonzero on error */
214        rval =  v ? ((v>>8) & 0xffff) | (1<<15) : 0;
215        return rval;
216}
217
218void
219__BSP_default_vme_config(void)
220{
221int err = 1;
222        if ( 0 == vmeUniverseInit() ) {
223                theOps = &uniOpsRec;
224                vmeUniverseReset();
225        } else if ( 0 == vmeTsi148Init() ) {
226                theOps = &tsiOpsRec;
227                vmeTsi148Reset();
228                _BSP_clear_vmebridge_errors = tsi_clear_errors;
229        } else
230                return; /* no VME bridge found chip */
231
232  /* map VME address ranges */
233  BSP_VMEOutboundPortCfg(
234        0,
235        VME_AM_EXT_SUP_DATA,
236        _VME_A32_WIN0_ON_VME,
237        _VME_A32_WIN0_ON_PCI,
238        0x0e000000
239        );
240  BSP_VMEOutboundPortCfg(
241        1,
242        VME_AM_STD_SUP_DATA,
243        0x00000000,
244        _VME_A24_ON_PCI,
245        0x00ff0000);
246  BSP_VMEOutboundPortCfg(
247        2,
248        VME_AM_SUP_SHORT_IO,
249        0x00000000,
250        _VME_A16_ON_PCI,
251        0x00010000);
252
253#ifdef _VME_CSR_ON_PCI
254  /* Map VME64 CSR */
255  BSP_VMEOutboundPortCfg(
256                  7,
257                  VME_AM_CSR,
258                  0,
259                  _VME_CSR_ON_PCI,
260                  0x01000000);
261#endif
262
263#ifdef _VME_DRAM_OFFSET
264  /* map our memory to VME */
265  BSP_VMEInboundPortCfg(
266        0,
267        VME_AM_EXT_SUP_DATA | VME_AM_IS_MEMORY,
268        _VME_DRAM_OFFSET,
269        PCI_DRAM_OFFSET,
270        BSP_mem_size);
271#endif
272
273  /* stdio is not yet initialized; the driver will revert to printk */
274  BSP_VMEOutboundPortsShow(0);
275  BSP_VMEInboundPortsShow(0);
276
277  switch (BSP_getBoardType()) {
278        case MVME6100:
279                err = theOps->install_irq_mgr(
280                                        VMETSI148_IRQ_MGR_FLAG_SHARED,
281                                        0, BSP_IRQ_GPP_0 + 20,
282                                        1, BSP_IRQ_GPP_0 + 21,
283                                        2, BSP_IRQ_GPP_0 + 22,
284                                        3, BSP_IRQ_GPP_0 + 23,
285                                        -1);
286        break;
287
288        case MVME5500:
289                err = theOps->install_irq_mgr(
290                                        VMEUNIVERSE_IRQ_MGR_FLAG_SHARED |
291                                        VMEUNIVERSE_IRQ_MGR_FLAG_PW_WORKAROUND,
292                                        0, BSP_IRQ_GPP_0 + 12,
293                                        1, BSP_IRQ_GPP_0 + 13,
294                                        2, BSP_IRQ_GPP_0 + 14,
295                                        3, BSP_IRQ_GPP_0 + 15,
296                                        -1);
297        break;
298
299        default:
300                printk("WARNING: unknown board; ");
301        break;
302  }
303  if ( err )
304        printk("VME interrupt manager NOT INSTALLED (error: %i)\n", err);
305}
Note: See TracBrowser for help on using the repository browser.