File indexing completed on 2025-05-11 08:23:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048 #include <rtems.h>
0049 #include <rtems/bspIo.h>
0050 #include <bsp.h>
0051 #include <bsp/VME.h>
0052 #include <bsp/VMEConfig.h>
0053 #include <bsp/irq.h>
0054 #include <bsp/vmeUniverse.h>
0055 #define _VME_TSI148_DECLARE_SHOW_ROUTINES
0056 #include <bsp/vmeTsi148.h>
0057 #include <libcpu/bat.h>
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 void BSP_vme_config(void) __attribute__ (( weak, alias("__BSP_default_vme_config") ));
0071
0072 typedef struct {
0073 int (*xlate_adrs)(int, int, unsigned long, unsigned long, unsigned long *);
0074 int (*install_isr)(unsigned long, BSP_VME_ISR_t, void *);
0075 int (*remove_isr)(unsigned long, BSP_VME_ISR_t, void *);
0076 BSP_VME_ISR_t (*get_isr)(unsigned long vector, void **);
0077 int (*enable_int_lvl)(unsigned int);
0078 int (*disable_int_lvl)(unsigned int);
0079 int (*outbound_p_cfg)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
0080 int (*inbound_p_cfg) (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);
0081 void (*outbound_p_show)(FILE*);
0082 void (*inbound_p_show) (FILE*);
0083 void (*reset_bus)(void);
0084 int (*install_irq_mgr)(int, int, int, ...);
0085 } VMEOpsRec, *VMEOps;
0086
0087 static VMEOpsRec uniOpsRec = {
0088 xlate_adrs: vmeUniverseXlateAddr,
0089 install_isr: vmeUniverseInstallISR,
0090 remove_isr: vmeUniverseRemoveISR,
0091 get_isr: vmeUniverseISRGet,
0092 enable_int_lvl: vmeUniverseIntEnable,
0093 disable_int_lvl: vmeUniverseIntDisable,
0094 outbound_p_cfg: vmeUniverseMasterPortCfg,
0095 inbound_p_cfg: vmeUniverseSlavePortCfg,
0096 outbound_p_show: vmeUniverseMasterPortsShow,
0097 inbound_p_show: vmeUniverseSlavePortsShow,
0098 reset_bus: vmeUniverseResetBus,
0099 install_irq_mgr: vmeUniverseInstallIrqMgrAlt,
0100 };
0101
0102 static VMEOpsRec tsiOpsRec = {
0103 xlate_adrs: vmeTsi148XlateAddr,
0104 install_isr: vmeTsi148InstallISR,
0105 remove_isr: vmeTsi148RemoveISR,
0106 get_isr: vmeTsi148ISRGet,
0107 enable_int_lvl: vmeTsi148IntEnable,
0108 disable_int_lvl: vmeTsi148IntDisable,
0109 outbound_p_cfg: vmeTsi148OutboundPortCfg,
0110 inbound_p_cfg: vmeTsi148InboundPortCfg,
0111 outbound_p_show: vmeTsi148OutboundPortsShow,
0112 inbound_p_show: vmeTsi148InboundPortsShow,
0113 reset_bus: vmeTsi148ResetBus,
0114 install_irq_mgr: vmeTsi148InstallIrqMgrAlt,
0115 };
0116
0117 static VMEOps theOps = 0;
0118
0119 int
0120 BSP_vme2local_adrs(unsigned long am, unsigned long vmeaddr, unsigned long *plocaladdr)
0121 {
0122 int rval=theOps->xlate_adrs(1,0,am,vmeaddr,plocaladdr);
0123 *plocaladdr+=PCI_MEM_BASE;
0124 return rval;
0125 }
0126
0127 int
0128 BSP_local2vme_adrs(unsigned long am, unsigned long localaddr, unsigned long *pvmeaddr)
0129 {
0130 return theOps->xlate_adrs(0, 0, am,localaddr+PCI_DRAM_OFFSET,pvmeaddr);
0131 }
0132
0133 int
0134 BSP_installVME_isr(unsigned long vector, BSP_VME_ISR_t handler, void *arg)
0135 {
0136 return theOps->install_isr(vector, handler, arg);
0137 }
0138
0139 int
0140 BSP_removeVME_isr(unsigned long vector, BSP_VME_ISR_t handler, void *arg)
0141 {
0142 return theOps->remove_isr(vector, handler, arg);
0143 }
0144
0145
0146 BSP_VME_ISR_t
0147 BSP_getVME_isr(unsigned long vector, void **parg)
0148 {
0149 return theOps->get_isr(vector, parg);
0150 }
0151
0152 int
0153 BSP_enableVME_int_lvl(unsigned int level)
0154 {
0155 return theOps->enable_int_lvl(level);
0156 }
0157
0158 int
0159 BSP_disableVME_int_lvl(unsigned int level)
0160 {
0161 return theOps->disable_int_lvl(level);
0162 }
0163
0164 int
0165 BSP_VMEOutboundPortCfg(
0166 unsigned long port,
0167 unsigned long address_space,
0168 unsigned long vme_address,
0169 unsigned long pci_address,
0170 unsigned long size)
0171 {
0172 return theOps->outbound_p_cfg(port, address_space, vme_address, pci_address, size);
0173 }
0174
0175 int
0176 BSP_VMEInboundPortCfg(
0177 unsigned long port,
0178 unsigned long address_space,
0179 unsigned long vme_address,
0180 unsigned long pci_address,
0181 unsigned long size)
0182 {
0183 return theOps->inbound_p_cfg(port, address_space, vme_address, pci_address, size);
0184 }
0185
0186 void
0187 BSP_VMEOutboundPortsShow(FILE *f)
0188 {
0189 theOps->outbound_p_show(f);
0190 }
0191
0192 void
0193 BSP_VMEInboundPortsShow(FILE *f)
0194 {
0195 theOps->inbound_p_show(f);
0196 }
0197
0198 void
0199 BSP_VMEResetBus(void)
0200 {
0201 theOps->reset_bus();
0202 }
0203
0204 static unsigned short
0205 tsi_clear_errors(int quiet)
0206 {
0207 unsigned long v;
0208 unsigned short rval;
0209 v = vmeTsi148ClearVMEBusErrors(0);
0210
0211
0212 rval = v ? ((v>>8) & 0xffff) | (1<<15) : 0;
0213 return rval;
0214 }
0215
0216 void
0217 __BSP_default_vme_config(void)
0218 {
0219 int err = 1;
0220 if ( 0 == vmeUniverseInit() ) {
0221 theOps = &uniOpsRec;
0222 vmeUniverseReset();
0223 } else if ( 0 == vmeTsi148Init() ) {
0224 theOps = &tsiOpsRec;
0225 vmeTsi148Reset();
0226 _BSP_clear_vmebridge_errors = tsi_clear_errors;
0227 } else
0228 return;
0229
0230
0231 BSP_VMEOutboundPortCfg(
0232 0,
0233 VME_AM_EXT_SUP_DATA,
0234 _VME_A32_WIN0_ON_VME,
0235 _VME_A32_WIN0_ON_PCI,
0236 0x0e000000
0237 );
0238 BSP_VMEOutboundPortCfg(
0239 1,
0240 VME_AM_STD_SUP_DATA,
0241 0x00000000,
0242 _VME_A24_ON_PCI,
0243 0x00ff0000);
0244 BSP_VMEOutboundPortCfg(
0245 2,
0246 VME_AM_SUP_SHORT_IO,
0247 0x00000000,
0248 _VME_A16_ON_PCI,
0249 0x00010000);
0250
0251 #ifdef _VME_CSR_ON_PCI
0252
0253 BSP_VMEOutboundPortCfg(
0254 7,
0255 VME_AM_CSR,
0256 0,
0257 _VME_CSR_ON_PCI,
0258 0x01000000);
0259 #endif
0260
0261 #ifdef _VME_DRAM_OFFSET
0262
0263 BSP_VMEInboundPortCfg(
0264 0,
0265 VME_AM_EXT_SUP_DATA | VME_AM_IS_MEMORY,
0266 _VME_DRAM_OFFSET,
0267 PCI_DRAM_OFFSET,
0268 BSP_mem_size);
0269 #endif
0270
0271
0272 BSP_VMEOutboundPortsShow(0);
0273 BSP_VMEInboundPortsShow(0);
0274
0275 switch (BSP_getBoardType()) {
0276 case MVME6100:
0277 err = theOps->install_irq_mgr(
0278 VMETSI148_IRQ_MGR_FLAG_SHARED,
0279 0, BSP_IRQ_GPP_0 + 20,
0280 1, BSP_IRQ_GPP_0 + 21,
0281 2, BSP_IRQ_GPP_0 + 22,
0282 3, BSP_IRQ_GPP_0 + 23,
0283 -1);
0284 break;
0285
0286 case MVME5500:
0287 err = theOps->install_irq_mgr(
0288 VMEUNIVERSE_IRQ_MGR_FLAG_SHARED |
0289 VMEUNIVERSE_IRQ_MGR_FLAG_PW_WORKAROUND,
0290 0, BSP_IRQ_GPP_0 + 12,
0291 1, BSP_IRQ_GPP_0 + 13,
0292 2, BSP_IRQ_GPP_0 + 14,
0293 3, BSP_IRQ_GPP_0 + 15,
0294 -1);
0295 break;
0296
0297 default:
0298 printk("WARNING: unknown board; ");
0299 break;
0300 }
0301 if ( err )
0302 printk("VME interrupt manager NOT INSTALLED (error: %i)\n", err);
0303 }