| 1 | // $Id: vme_rcc_driver.h,v 1.13 2007/09/28 15:18:25 joos Exp $
|
|---|
| 2 | /************************************************************************/
|
|---|
| 3 | /* */
|
|---|
| 4 | /* File: vme_rcc_driver.h */
|
|---|
| 5 | /* */
|
|---|
| 6 | /* This is the private header file for RCC VMEbus driver */
|
|---|
| 7 | /* */
|
|---|
| 8 | /* 26. Oct. 01 MAJO created */
|
|---|
| 9 | /* 02. Nov. 01 JOP interrupts */
|
|---|
| 10 | /* 26. Nov. 01 JOP bus errors */
|
|---|
| 11 | /* 17. Apr. 02 JOP RORA */
|
|---|
| 12 | /* */
|
|---|
| 13 | /************ C 2005 - The software with that certain something *********/
|
|---|
| 14 |
|
|---|
| 15 | #ifndef _VME_RCC_DRIVER_H
|
|---|
| 16 | #define _VME_RCC_DRIVER_H
|
|---|
| 17 |
|
|---|
| 18 | #include <linux/types.h>
|
|---|
| 19 | #include "vme_rcc_common.h"
|
|---|
| 20 |
|
|---|
| 21 | #define VME_VCTSIZE 256
|
|---|
| 22 | #define VME_DMADONESIZE 64 //max. number of completed DMA transactions
|
|---|
| 23 | #define MAX_PROC_TEXT_SIZE 0x10000 //The output of "more /proc/vme_rcc" must not generate more characters than that
|
|---|
| 24 | #define BAR0 0
|
|---|
| 25 |
|
|---|
| 26 | // I/O registers
|
|---|
| 27 | #define CMOSA 0x70
|
|---|
| 28 | #define CMOSD 0x71
|
|---|
| 29 | #define BID1 0x35
|
|---|
| 30 | #define BID2 0x36
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | /********/
|
|---|
| 34 | /*Macros*/
|
|---|
| 35 | /********/
|
|---|
| 36 | #ifdef DRIVER_DEBUG
|
|---|
| 37 | #define kdebug(x) {if (debug) printk x;}
|
|---|
| 38 | #else
|
|---|
| 39 | #define kdebug(x)
|
|---|
| 40 | #endif
|
|---|
| 41 |
|
|---|
| 42 | #ifdef DRIVER_ERROR
|
|---|
| 43 | #define kerror(x) {if (errorlog) printk x;}
|
|---|
| 44 | #else
|
|---|
| 45 | #define kerror(x)
|
|---|
| 46 | #endif
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | /******************/
|
|---|
| 50 | /*Type definitions*/
|
|---|
| 51 | /******************/
|
|---|
| 52 | typedef struct
|
|---|
| 53 | {
|
|---|
| 54 | u_int vbase;
|
|---|
| 55 | u_int vtop;
|
|---|
| 56 | u_int pbase;
|
|---|
| 57 | u_int ptop;
|
|---|
| 58 | u_int am;
|
|---|
| 59 | u_int enab;
|
|---|
| 60 | u_int wp;
|
|---|
| 61 | u_int rp;
|
|---|
| 62 | u_int space;
|
|---|
| 63 | u_int options;
|
|---|
| 64 | } mstslvmap_t;
|
|---|
| 65 |
|
|---|
| 66 | typedef struct
|
|---|
| 67 | {
|
|---|
| 68 | mstslvmap_t master[8];
|
|---|
| 69 | mstslvmap_t slave[8];
|
|---|
| 70 | } all_mstslvmap_t;
|
|---|
| 71 |
|
|---|
| 72 | // a link between an interrupt and a program is described by a LINK DESCRIPTOR
|
|---|
| 73 | typedef struct
|
|---|
| 74 | {
|
|---|
| 75 | int pid; // pid of linked process, 0 if not linked
|
|---|
| 76 | u_int vct; // vector #
|
|---|
| 77 | u_int lvl; // level
|
|---|
| 78 | u_int type; // type
|
|---|
| 79 | u_int pending; // interrupt pending
|
|---|
| 80 | u_int total_count; // total # interrupts with this vector (after LINK)
|
|---|
| 81 | VME_IntHandle_t* group_ptr; // pointer to the structure of vectors with same handle
|
|---|
| 82 | struct semaphore sem; // its semaphore
|
|---|
| 83 | int sig; // its signal
|
|---|
| 84 | } link_dsc_t;
|
|---|
| 85 |
|
|---|
| 86 | typedef struct
|
|---|
| 87 | {
|
|---|
| 88 | link_dsc_t link_dsc[VME_VCTSIZE];
|
|---|
| 89 | struct semaphore link_dsc_sem;
|
|---|
| 90 | } link_dsc_table_t;
|
|---|
| 91 |
|
|---|
| 92 | // a link between BERR and a program is described by a BERR LINK DESCRIPTOR
|
|---|
| 93 | typedef struct
|
|---|
| 94 | {
|
|---|
| 95 | int pid; // pid of linked process, 0 if not linked
|
|---|
| 96 | int sig; // its signal
|
|---|
| 97 | } berr_link_dsc_t;
|
|---|
| 98 |
|
|---|
| 99 | typedef struct
|
|---|
| 100 | {
|
|---|
| 101 | berr_link_dsc_t berr_link_dsc[VME_MAX_BERR_PROCS];
|
|---|
| 102 | struct semaphore proc_sem;
|
|---|
| 103 | } berr_proc_table_t;
|
|---|
| 104 |
|
|---|
| 105 | // holds info about the bus errors - filled by the BERR ISR
|
|---|
| 106 | typedef struct
|
|---|
| 107 | {
|
|---|
| 108 | u_int vmeadd; // last latched VMEbus address
|
|---|
| 109 | u_int am; // and its AM code
|
|---|
| 110 | u_int iack; // indicates BERR for IACK cycle
|
|---|
| 111 | u_int lword; // Only for VP-100 & VP-110
|
|---|
| 112 | u_int ds0; // Only for VP-100 & VP-110
|
|---|
| 113 | u_int ds1; // Only for VP-100 & VP-110
|
|---|
| 114 | u_int wr; // Only for VP-100 & VP-110
|
|---|
| 115 | int multiple;
|
|---|
| 116 | int flag;
|
|---|
| 117 | } berr_dsc_t;
|
|---|
| 118 |
|
|---|
| 119 | typedef struct
|
|---|
| 120 | {
|
|---|
| 121 | int pid; // pid of linked process, 0 if not linked
|
|---|
| 122 | int sig; // the signal (0 if semaphore used)
|
|---|
| 123 | u_int num; // number of interrupts received
|
|---|
| 124 | struct semaphore sem; // external semaphore
|
|---|
| 125 | struct semaphore proc_sem; // internal semaphore
|
|---|
| 126 | } sysfail_link_dsc_t;
|
|---|
| 127 |
|
|---|
| 128 | typedef struct
|
|---|
| 129 | {
|
|---|
| 130 | int pid; // pid of process owning the master mapping
|
|---|
| 131 | u_int vaddr; // address returned by ioremap
|
|---|
| 132 | } master_map_dsc_t;
|
|---|
| 133 |
|
|---|
| 134 | typedef struct
|
|---|
| 135 | {
|
|---|
| 136 | master_map_dsc_t map[VME_MAX_MASTERMAP];
|
|---|
| 137 | struct semaphore sem;
|
|---|
| 138 | } master_map_t;
|
|---|
| 139 |
|
|---|
| 140 | typedef struct
|
|---|
| 141 | {
|
|---|
| 142 | u_int berr_dsc_flag[VME_MAX_BERR_PROCS];
|
|---|
| 143 | u_int link_dsc_flag[VME_VCTSIZE];
|
|---|
| 144 | u_int sysfail_dsc_flag;
|
|---|
| 145 | u_int dma[VME_DMADONESIZE];
|
|---|
| 146 | u_int mastermap[VME_MAX_MASTERMAP];
|
|---|
| 147 | VME_BusErrorInfo_t VME_BerrInfo;
|
|---|
| 148 | VME_IntHandle_t VME_int_handle2;
|
|---|
| 149 | VME_IntEnable_t VME_IntEnable;
|
|---|
| 150 | } private_data_t;
|
|---|
| 151 |
|
|---|
| 152 | typedef struct InterruptCounters_t
|
|---|
| 153 | {
|
|---|
| 154 | u_int acfail;
|
|---|
| 155 | u_int sysfail;
|
|---|
| 156 | u_int sw_int;
|
|---|
| 157 | u_int sw_iack;
|
|---|
| 158 | u_int verr;
|
|---|
| 159 | u_int lerr;
|
|---|
| 160 | u_int dma;
|
|---|
| 161 | u_int virq[7];
|
|---|
| 162 | u_int vown;
|
|---|
| 163 | } InterruptCounters_t;
|
|---|
| 164 |
|
|---|
| 165 | struct vme_proc_data_t
|
|---|
| 166 | {
|
|---|
| 167 | char name[10];
|
|---|
| 168 | char value[100];
|
|---|
| 169 | };
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 | /******************************/
|
|---|
| 173 | /*Standard function prototypes*/
|
|---|
| 174 | /******************************/
|
|---|
| 175 | static int vme_rcc_open(struct inode *ino, struct file *filep);
|
|---|
| 176 | static int vme_rcc_release(struct inode *ino, struct file *filep);
|
|---|
| 177 | static int vme_rcc_ioctl(struct inode *inode, struct file *file, u_int cmd, u_long arg);
|
|---|
| 178 | static int vme_rcc_mmap(struct file *file, struct vm_area_struct *vma);
|
|---|
| 179 | static int vme_rcc_write_procmem(struct file *file, const char *buffer, u_long count, void *data);
|
|---|
| 180 | static int vme_rcc_read_procmem(char *buf, char **start, off_t offset, int count, int *eof, void *data);
|
|---|
| 181 | static void vme_rcc_vmaClose(struct vm_area_struct *vma);
|
|---|
| 182 |
|
|---|
| 183 | /*****************************/
|
|---|
| 184 | /*Special function prototypes*/
|
|---|
| 185 | /*****************************/
|
|---|
| 186 | static int berr_check(u_int *addr, u_int *multi, u_int *am);
|
|---|
| 187 | static int cct_berrInt(void);
|
|---|
| 188 | static void fill_mstmap(u_int d1, u_int d2, u_int d3, u_int d4, mstslvmap_t *mstslvmap);
|
|---|
| 189 | static void fill_slvmap(u_int d1, u_int d2, u_int d3, u_int d4, mstslvmap_t *mstslvmap);
|
|---|
| 190 | static void vme_dmaTimeout(u_long arg);
|
|---|
| 191 | static void vme_intTimeout(u_long arg);
|
|---|
| 192 | static void vme_intSysfailTimeout(u_long arg);
|
|---|
| 193 | static void vme_dma_handler(void);
|
|---|
| 194 | static void vme_irq_handler(int level);
|
|---|
| 195 | static void init_cct_berr(void);
|
|---|
| 196 | static void mask_cct_berr(void);
|
|---|
| 197 | static void send_berr_signals(void);
|
|---|
| 198 | static void read_berr_capture(void);
|
|---|
| 199 |
|
|---|
| 200 | #endif
|
|---|