/* file: test_bpmd.h Definitions for testing the SLAC BPM Digitizer module W. Ross, SLAC Created 5/8/07, WCR Modified 8/15/07, WCR (Initial creation, adding tests) Modified 6/23/08, WCR (Update for Version 2 firmware) */ #ifndef WCR_TEST_BPMD_H #define WCR_TEST_BPMD_H #define OK_STAT 0 #define WARN_STAT -1 #define FATAL_STAT -2 #define PROG_ERROR -3 #define EXIT_STAT -4 /* BPMD VME64x Configuration ROM offsets and values */ /* Checksum */ #define CR_CHKSUM_OFS 0x3 #define CR_CHKSUM_NWRDS 0x1 #define CR_CHKSUM_IVAL 0xd3 #define CR_CHKSUM2_IVAL 0xd5 /* ROM length for checksum (starting at addr 0x7)*/ #define CR_ROM_LEN_OFS 0x7 #define CR_ROM_LEN_NWRDS 0x3 #define CR_ROM_LEN_IVAL 0x00043F /* Configuration ROM width (D32, D16 or D8(EO)) */ #define CR_CR_WDTH_OFS 0x13 #define CR_CR_WDTH_NWRDS 0x1 #define CR_CR_WDTH_IVAL 0x84 /* CSR ROM width (D32, D16 or D8(EO)) */ #define CR_CSR_WDT_OFS 0x17 #define CR_CSR_WDT_NWRDS 0x1 #define CR_CSR_WDT_IVAL 0x84 /* CR/CSR space specification ID (VME64X) */ #define CR_CSR_SSI_OFS 0x1b #define CR_CSR_SSI_NWRDS 0x1 #define CR_CSR_SSI_IVAL 0x02 /* Ascii 'CR' marker */ #define CR_CR_MARK_OFS 0x1f #define CR_CR_MARK_NWRDS 0x2 #define CR_CR_MARK_IVAL 0x4352 /* Manufacturer ID (null for now) */ #define CR_MAN_ID_OFS 0x27 #define CR_MAN_ID_NWRDS 0x3 #define CR_MAN_ID_IVAL 0x000000 /* Module ID (1440451 base 10) */ #define CR_MOD_ID_OFS 0x33 #define CR_MOD_ID_NWRDS 0x4 #define CR_MOD_ID_IVAL 0x0015fac3 /* Revision ID (F/W vers.1, H/W vers.1) */ #define CR_REV_ID_OFS 0x43 #define CR_REV_ID_NWRDS 0x4 #define CR_REV_ID_IVAL 0x00010001 #define CR_FWREV2_ID_IVAL 0x00020001 /* Byte offset to module ID text string */ #define CR_P_NAME_OFS 0x53 #define CR_P_NAME_NWRDS 0x3 #define CR_P_NAME_IVAL 0x001000 /* Program ID code (No program, ID ROM only)*/ #define CR_PRG_ID_OFS 0x7f #define CR_PRG_ID_NWRDS 0x1 #define CR_PRG_ID_IVAL 0x01 /* Offset to beginning of User CSR */ #define CR_UCSR_B_OFS 0xb3 #define CR_UCSR_B_NWRDS 0x3 #define CR_UCSR_B_IVAL 0x07fa00 /* Offset to end of User CSR */ #define CR_UCSR_E_OFS 0xbf #define CR_UCSR_E_NWRDS 0x3 #define CR_UCSR_E_IVAL 0x07fbff /* Offset to beginning of serial number */ #define CR_SNBR_B_OFS 0xcb #define CR_SNBR_B_NWRDS 0x3 #define CR_SNBR_B_IVAL 0x07fa2c /* Offset to end of serial number */ #define CR_SNBR_E_OFS 0xd7 #define CR_SNBR_E_NWRDS 0x3 #define CR_SNBR_E_IVAL 0x07fa2f /* Slave characteristics (has P2,and has ETL xcvers) */ /* (No support for unaligned, RMW, addr-only, retry cycles) */ #define CR_SLV_CH_OFS 0xe3 #define CR_SLV_CH_NWRDS 0x1 #define CR_SLV_CH_IVAL 0x06 /* Interrupter capabilities (supports levels 7:1) */ #define CR_I_LVLS_OFS 0xf7 #define CR_I_LVLS_NWRDS 0x1 #define CR_I_LVLS_IVAL 0xfe /* Functions 0-3 data access width (functs 0 and 1: D32 max) */ /* (No code is defined for D64 MBLT) */ #define CR_F0_3_W_OFS 0x103 #define CR_F0_3_W_NWRDS 0x4 #define CR_F0_3_W_IVAL 0x84840000 /* Functions 4-7 data access width */ #define CR_F4_7_W_OFS 0x113 #define CR_F4_7_W_NWRDS 0x4 #define CR_F4_7_W_IVAL 0x00000000 /* Function 0 AM code mask, bits 63-32 */ #define CR_F0AM_H_OFS 0x123 #define CR_F0AM_H_NWRDS 0x4 #define CR_F0AM_H_IVAL 0x00000000 /* Function 0 AM code mask, bits 31-0 (A32,s/s,data,supv+nonpriv) */ #define CR_F0AM_L_OFS 0x133 #define CR_F0AM_L_NWRDS 0x4 #define CR_F0AM_L_IVAL 0x00002200 /* Function 1 AM code mask, bits 63-32 */ #define CR_F1AM_H_OFS 0x143 #define CR_F1AM_H_NWRDS 0x4 #define CR_F1AM_H_IVAL 0x00000000 /* Function 1 AM code mask, bits 31-0 (A32,mblt,data,supv+nonpriv) */ #define CR_F1AM_L_OFS 0x153 #define CR_F1AM_L_NWRDS 0x4 #define CR_F1AM_L_IVAL 0x00001100 /* Function 0 address decoder mask (0x40000 byte space) */ #define CR_F0_ADM_OFS 0x623 #define CR_F0_ADM_NWRDS 0x4 #define CR_F0_ADM_IVAL 0xfffc0000 /* Function 1 address decoder mask (0x40000 byte space) */ #define CR_F1_ADM_OFS 0x633 #define CR_F1_ADM_NWRDS 0x4 #define CR_F1_ADM_IVAL 0xfffc0000 /* BPMD VME64x Control Status Reg. offsets and values */ /* CR/CSR base address (initially geographic address x 8) */ #define CSR_BASE_OFS 0x7ffff #define CSR_BASE_NWRDS 0x1 /* bit fields */ #define CSR_BASE_ADR_FLD 0xf8 /* Bit set register */ #define CSR_BSET_OFS 0x7fffb #define CSR_BSET_NWRDS 0x1 #define CSR_BSET_MASK 0xbf #define CSR_BSET_IVAL 0x00 /* use bit field definitions for VME64 control register */ /* Bit clear register */ #define CSR_BCLR_OFS 0x7fff7 #define CSR_BCLR_NWRDS 0x1 #define CSR_BCLR_MASK 0xbf #define CSR_BCLR_IVAL 0x00 /* use bit field definitions for VME64 control register */ /* Function 1 ADER register */ #define CSR_F1AD_OFS 0x7ff73 #define CSR_F1AD_NWRDS 0x4 #define CSR_F1AD_MASK 0xffffffff #define CSR_F1AD_IVAL 0x00000000 /* bit fields: */ #define CSR_ADER_CMP_FLD 0xfffc0000 #define CSR_ADER_AMCODE 0x000000fc #define CSR_ADER_DFSR 0x00000002 #define CSR_ADER_XAM 0x00000001 /* Function 0 ADER register */ #define CSR_F0AD_OFS 0x7ff63 #define CSR_F0AD_NWRDS 0x4 #define CSR_F0AD_MASK 0xffffffff #define CSR_F0AD_IVAL 0x00000000 /* use bit fields defined above */ /* BPMD User CSR registers */ /* (These values are not split into seperated bytes) */ /* Interrupt ID register (16-bit rd/wr) */ #define CSR_IID_OFS 0x7fb42 #define CSR_IID_MASK 0xffff #define CSR_IID_IVAL 0x0000 #define CSR_IID_ID 0x00ff /* bit fields: serial data comprises all 32 bits */ /* SIO data register (32-bit rd/wr) */ #define CSR_SDAT_OFS 0x7fb3c #define CSR_SDAT_MASK 0xffffffff #define CSR_SDAT_IVAL 0x00000000 /* bit fields: serial data comprises all 32 bits */ /* VME64 control register (16-bit rd/wr) */ #define CSR_VCTL_OFS 0x7fb3a #define CSR_VCTL_MASK 0xffff #define CSR_VCTL_IVAL 0x0040 /* bit fields: */ #define CSR_VCTL_MOD_RST 0x0080 #define CSR_VCTL_EN_FAIL 0x0040 #define CSR_VCTL_MODFAIL 0x0020 #define CSR_VCTL_MOD_ENA 0x0010 #define CSR_VCTL_BERR 0x0008 /* Acquisition control register (16-bit rd/wr) */ #define CSR_ACQ_OFS 0x7fb36 #define CSR_ACQ_MASK 0xffff #define CSR_ACQ_IVAL 0x0000 /* bit fields: */ #define CSR_ACQ_ACQ_ARM 0x8000 #define CSR_ACQ_EN_DSP 0x4000 #define CSR_ACQ_DSP_OVRL 0x2000 #define CSR_ACQ_SHF_GAIN 0x1f00 #define CSR_ACQ_CH4_SID 0x0080 #define CSR_ACQ_CH3_SID 0x0040 #define CSR_ACQ_CH2_SID 0x0020 #define CSR_ACQ_CH1_SID 0x0010 #define CSR_ACQ_EXT_TRIG 0x0008 #define CSR_ACQ_SEL_TRG2 0x0004 #define CSR_ACQ_TRG_MODE 0x0002 #define CSR_ACQ_SW_GATE 0x0001 /* Acquisition counter preset register (16-bit rd/wr) */ #define CSR_ACP_OFS 0x7fb32 #define CSR_ACP_MASK 0xffff #define CSR_ACP_IVAL 0x0000 /* bit fields: */ #define CSR_ACP_MAX_PRS 0x3fff #define CSR_ACP_BUF_SZ 0x4000 /* Kernel length register (16-bit rd/wr) */ #define CSR_KLR_OFS 0x7fb2e #define CSR_KLR_MASK 0xffff #define CSR_KLR_IVAL 0x0000 /* bit fields: */ #define CSR_KLR_KRN_LEN 0x3fff /* Kernel offset register (16-bit rd/wr) */ #define CSR_KOF_OFS 0x7fb2a #define CSR_KOF_MASK 0xffff #define CSR_KOF_IVAL 0x0000 /* bits: */ #define CSR_KOF_KRN_OFS 0x3fff /* ADC data offset register (16-bit rd/wr) */ #define CSR_DOF_OFS 0x7fb26 #define CSR_DOF_MASK 0xffff #define CSR_DOF_IVAL 0x0000 /* bit fields: */ #define CSR_DOF_DAT_OFS 0x3fff /* Buffer aux-bits register (16-bit rd/wr) */ /* (Used in VME to ADC buffer write cycles) */ #define CSR_BAB_OFS 0x7fb22 #define CSR_BAB_MASK 0xffff #define CSR_BAB_IVAL 0x0000 /* bit fields: */ #define CSR_BAB_CH4_OVF 0x0800 #define CSR_BAB_CH3_OVF 0x0400 #define CSR_BAB_CH2_OVF 0x0200 #define CSR_BAB_CH1_OVF 0x0100 #define CSR_BAB_CH4_SID 0x0008 #define CSR_BAB_CH3_SID 0x0004 #define CSR_BAB_CH2_SID 0x0002 #define CSR_BAB_CH1_SID 0x0001 /* DAC/sync mux control register (16-bit rd/wr) */ #define CSR_DAC_OFS 0x7fb1e #define CSR_DAC_MASK 0xffff #define CSR_DAC_IVAL 0x0000 /* bit fields: */ #define CSR_DAC_ENA 0x8000 #define CSR_DAC_SYNC_SRC 0x7c00 #define CSR_DAC_CH_B_SRC 0x03e0 #define CSR_DAC_CH_A_SRC 0x001f /* Auxilary control register (16-bit rd/wr) */ #define CSR_AUX_OFS 0x7fb1a #define CSR_AUX_MASK 0xffff #define CSR_AUX_IVAL 0x0000 /* bit fields: */ #define CSR_AUX_ADC_PGA 0x8000 #define CSR_AUX_ADC_RAND 0x4000 #define CSR_AUX_ADC_DITH 0x2000 #define CSR_AUX_ADC_SHDN 0x1000 #define CSR_AUX_SER_PAR 0x0800 #define CSR_AUX_EXT_CLK 0x0400 #define CSR_AUX_ALT_FMT 0x0200 #define CSR_AUX_SW_INTRP 0x0100 #define CSR_AUX_SIO_ACTV 0x0080 #define CSR_AUX_SIO_LPBK 0x0040 #define CSR_AUX_SIO_NBIT 0x003f /* Interrupt control register (16-bit rd/wr) */ #define CSR_INT_OFS 0x7fb16 #define CSR_INT_MASK 0xffff #define CSR_INT_IVAL 0x0000 /* bit fields: */ #define CSR_INT_SW_EN 0x8000 #define CSR_INT_BERR_EN 0x4000 #define CSR_INT_BADCK_EN 0x2000 #define CSR_INT_ALIGN_EN 0x1000 #define CSR_INT_ADOVF_EN 0x0800 #define CSR_INT_AQSTR_EN 0x0400 #define CSR_INT_AQEND_EN 0x0200 #define CSR_INT_ENDSP_EN 0x0100 #define CSR_INT_GLOBL_EN 0x0080 #define CSR_INT_PRIORITY 0x0070 /* DCM-4 control register (16-bit rd/wr) */ #define CSR_D4C_OFS 0x7fb12 #define CSR_D4C_MASK 0xffff #define CSR_D4C_IVAL 0x0000 /* bit fields (applies to all DCMs): */ #define CSR_DCC_RST 0x0800 #define CSR_DCC_RETARD90 0x0400 #define CSR_DCC_BYPASS 0x0200 #define CSR_DCC_ADJ_DLY 0x0100 #define CSR_DCC_DELAY 0x00ff /* DCM-3 control register (16-bit rd/wr) */ #define CSR_D3C_OFS 0x7fb0e #define CSR_D3C_MASK 0xffff #define CSR_D3C_IVAL 0x0000 /* DCM-2 control register (16-bit rd/wr) */ #define CSR_D2C_OFS 0x7fb0a #define CSR_D2C_MASK 0xffff #define CSR_D2C_IVAL 0x0000 /* DCM-1 control register (16-bit rd/wr) */ #define CSR_D1C_OFS 0x7fb06 #define CSR_D1C_MASK 0xffff #define CSR_D1C_IVAL 0x0000 /* DCM-0 control register (16-bit rd/wr) */ #define CSR_D0C_OFS 0x7fb02 #define CSR_D0C_MASK 0xffff #define CSR_D0C_IVAL 0x0000 /* these additional bit fields are implemented in DCM-0 only: */ #define CSR_D0C_RST_ALL 0x8000 #define CSR_D0C_ADJ_ALL 0x4000 /* Acquisition status latch (16-bit read-only) */ #define CSR_ASL_OFS 0x7fa3a #define CSR_ASL_MASK 0xffff #define CSR_ASL_IVAL 0x010f /* bit fields ( _L indicates latched flags): */ #define CSR_ASL_ACQ_GATE 0x8000 #define CSR_ASL_DSP_BUSY 0x4000 #define CSR_ASL_AQGATE_L 0x2000 #define CSR_ASL_DSPBSY_L 0x1000 #define CSR_ASL_SWGATE_L 0x0800 #define CSR_ASL_TRIG2_L 0x0400 #define CSR_ASL_TRIG1_L 0x0200 #define CSR_ASL_BADCLK_L 0x0100 #define CSR_ASL_OVFL4_L 0x0080 #define CSR_ASL_OVFL3_L 0x0040 #define CSR_ASL_OVFL2_L 0x0020 #define CSR_ASL_OVFL1_L 0x0010 #define CSR_ASL_ALIGN4_L 0x0008 #define CSR_ASL_ALIGN3_L 0x0004 #define CSR_ASL_ALIGN2_L 0x0002 #define CSR_ASL_ALIGN1_L 0x0001 /* End count status register (16-bit read-only) */ #define CSR_ECS_OFS 0x7fa36 #define CSR_ECS_MASK 0xffff #define CSR_ECS_IVAL 0x0000 /* bit fields: */ #define CSR_ECS_END_CNT 0x3fff /* Interrupt status register (16-bit read-only) */ /* Reading clears this register */ #define CSR_ISR_OFS 0x7fa32 #define CSR_ISR_MASK 0xffff #define CSR_ISR_IVAL 0x0033 /* bit fields: */ #define CSR_ISR_SW_INTRP 0x0080 #define CSR_ISR_BUS_ERR 0x0040 #define CSR_ISR_BAD_CLK 0x0020 #define CSR_ISR_ALIGN 0x0010 #define CSR_ISR_ADC_OVFL 0x0008 #define CSR_ISR_ACQ_STRT 0x0004 #define CSR_ISR_ACQ_END 0x0002 #define CSR_ISR_END_DSP 0x0001 /* Serial number register (16-bit read-only) */ #define CSR_SNR_OFS 0x7fa2e /* DCM-4 status register (16-bit read-only) */ #define CSR_D4S_OFS 0x7fa2a #define CSR_D4S_MASK 0xffff #define CSR_D4S_IVAL 0x0007 /* bit fields (applies to all DCMs): */ #define CSR_DCS_NO_FBCLK 0x0020 #define CSR_DCS_NO_FXCLK 0x0010 #define CSR_DCS_NO_INCLK 0x0008 #define CSR_DCS_LOCKED 0x0004 #define CSR_DCS_AT_LIMIT 0x0002 #define CSR_DCS_ADJ_DONE 0x0001 /* DCM-3 status register (16-bit read-only) */ #define CSR_D3S_OFS 0x7fa26 #define CSR_D3S_MASK 0xffff #define CSR_D3S_IVAL 0x0007 /* DCM-2 status register (16-bit read-only) */ #define CSR_D2S_OFS 0x7fa22 #define CSR_D2S_MASK 0xffff #define CSR_D2S_IVAL 0x0007 /* DCM-1 status register (16-bit read-only) */ #define CSR_D1S_OFS 0x7fa1e #define CSR_D1S_MASK 0xffff #define CSR_D1S_IVAL 0x0007 /* DCM-0 status register (16-bit read-only) */ #define CSR_D0S_OFS 0x7fa1a #define CSR_D0S_MASK 0xffff #define CSR_D0S_IVAL 0x0007 /* this additional bit field is implemented in DCM-0 only: */ #define CSR_D0S_BUSY_ALL 0x8000 /* DSP status register (16-bit read-only) */ #define CSR_DSP_OFS 0x7fa16 #define CSR_DSP_MASK 0xffff #define CSR_DSP_IVAL 0x0000 /* bit fields: */ #define CSR_DSP_MAG4_OVF 0x0080 #define CSR_DSP_MAG3_OVF 0x0040 #define CSR_DSP_MAG2_OVF 0x0020 #define CSR_DSP_MAG1_OVF 0x0010 #define CSR_DSP_SMP4_OVF 0x0008 #define CSR_DSP_SMP3_OVF 0x0004 #define CSR_DSP_SMP2_OVF 0x0002 #define CSR_DSP_SMP1_OVF 0x0001 /* DSP exponents register (32-bit read-only) */ #define CSR_EXP_OFS 0x7fa10 #define CSR_EXP_MASK 0xffffffff #define CSR_EXP_IVAL 0x00000000 /* bit fields: */ #define CSR_EXP_MAG4_SQ 0xff000000 #define CSR_EXP_MAG3_SQ 0x00ff0000 #define CSR_EXP_MAG2_SQ 0x0000ff00 #define CSR_EXP_MAG1_SQ 0x000000ff /* CH-4 magn-squared result register (32-bit read-only) */ #define CSR_MS4_OFS 0x7fa0c #define CSR_MS4_MASK 0xffffffff #define CSR_MS4_IVAL 0x00000000 /* CH-3 magn-squared result register (32-bit read-only) */ #define CSR_MS3_OFS 0x7fa08 #define CSR_MS3_MASK 0xffffffff #define CSR_MS3_IVAL 0x00000000 /* CH-2 magn-squared result register (32-bit read-only) */ #define CSR_MS2_OFS 0x7fa04 #define CSR_MS2_MASK 0xffffffff #define CSR_MS2_IVAL 0x00000000 /* CH-1 magn-squared result register (32-bit read-only) */ #define CSR_MS1_OFS 0x7fa00 #define CSR_MS1_MASK 0xffffffff #define CSR_MS1_IVAL 0x00000000 /* BPMD VME Function-0 Memory Space */ /* (A32, D32, D16,or D8(EO)), single cycle read/write */ /* (data, supervisory or non-priveledged */ #define F0_AM_CODE_SUPV 0x0d #define F0_AM_CODE_NPRV 0x09 /* Data memory (for ADC samples) */ /* (Sequence for 32-bit words: [Ch4,Ch3],[Ch2,Ch1],[Ch4,Ch3],...) */ #define F0_DMEM_C4C3_OFS 0x00000000 #define F0_DMEM_C2C1_OFS 0x00000004 #define DMEM_BYTE_LEN 0x00020000 #define DMEM_DWRD_LEN 0x00008000 /* bit fields (direct format mode): */ #define F0_DMEM_C4C2_MSK 0xffff0000 #define F0_DMEM_C3C1_MSK 0x0000ffff /* bit fields (alternate format mode) */ /* (with sequence ID bit and overflow bit): */ #define F0_DMEM_C4C2_ALT 0xfffc0000 #define F0_DMEM_C4C2_SID 0x00020000 #define F0_DMEM_C4C2_OVF 0x00010000 #define F0_DMEM_C3C1_ALT 0x0000fffc #define F0_DMEM_C3C1_SID 0x00000002 #define F0_DMEM_C3C1_OVF 0x00000001 /* Kernal memory (for I and Q kernal vectors) */ /* (Sequence for 32-bit words: [I,(0)],[Q,(0)],[I,(0)],...) */ #define F0_KMEM_I_OFS 0x00020000 #define F0_KMEM_Q_OFS 0x00020004 #define KMEM_BYTE_LEN 0x00020000 #define KMEM_DWRD_LEN 0x00008000 /* bit fields: */ #define F0_KMEM_IQ_MASK 0xffff0000 /* BPMD VME Function-1 Memory Space */ /* (A32, D64, MBLT (multiplexed block transfer) */ /* (data, supervisory or non-priveledged */ #define F1_AM_CODE_SUPV 0x0c #define F1_AM_CODE_NPRV 0x08 /* Data memory */ /* (Sequence for 64-bit words: [Ch4,Ch3,Ch2,Ch1],[Ch4,Ch3,Ch2,Ch1],...) */ #define F1_DMEM_OFS 0x00000000 /* bit fields (direct format mode): */ #define F1_DMEM_C4_MSK 0xffff000000000000 #define F1_DMEM_C3_MSK 0x0000ffff00000000 #define F1_DMEM_C2_MSK 0x00000000ffff0000 #define F1_DMEM_C1_MSK 0x000000000000ffff /* bit fields (alternate format mode) */ /* (with sequence ID bit and overflow bit): */ #define F0_DMEM_C4_ALT 0xfffc000000000000 #define F0_DMEM_C4_SID 0x0002000000000000 #define F0_DMEM_C4_OVF 0x0001000000000000 #define F0_DMEM_C3_ALT 0x0000fffc00000000 #define F0_DMEM_C3_SID 0x0000000200000000 #define F0_DMEM_C3_OVF 0x0000000100000000 #define F0_DMEM_C2_ALT 0x00000000fffc0000 #define F0_DMEM_C2_SID 0x0000000000020000 #define F0_DMEM_C2_OVF 0x0000000000010000 #define F0_DMEM_C1_ALT 0x000000000000fffc #define F0_DMEM_C1_SID 0x0000000000000002 #define F0_DMEM_C1_OVF 0x0000000000000001 /* Kernal memory (for I and Q kernal vectors)*/ /* (Sequence for 64-bit words: [I,(0),Q,(0)],[I,(0),Q,(0)],...) */ #define F1_KMEM_OFS 0x00020000 /* bit fields: */ #define F1_KMEM_I_MASK 0xffff000000000000 #define F1_KMEM_Q_MASK 0x00000000ffff0000 #endif