Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 1 | #ifndef _VME_BRIDGE_H_ |
| 2 | #define _VME_BRIDGE_H_ |
| 3 | |
| 4 | #define VME_CRCSR_BUF_SIZE (508*1024) |
| 5 | #define VME_SLOTS_MAX 32 |
| 6 | /* |
| 7 | * Resource structures |
| 8 | */ |
| 9 | struct vme_master_resource { |
| 10 | struct list_head list; |
| 11 | struct vme_bridge *parent; |
| 12 | /* |
| 13 | * We are likely to need to access the VME bus in interrupt context, so |
Martyn Welch | 400822f | 2009-08-11 16:20:22 +0100 | [diff] [blame] | 14 | * protect master routines with a spinlock rather than a mutex. |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 15 | */ |
| 16 | spinlock_t lock; |
| 17 | int locked; |
| 18 | int number; |
| 19 | vme_address_t address_attr; |
| 20 | vme_cycle_t cycle_attr; |
| 21 | vme_width_t width_attr; |
| 22 | struct resource pci_resource; /* XXX Rename to be bus agnostic */ |
| 23 | void *kern_base; |
| 24 | }; |
| 25 | |
| 26 | struct vme_slave_resource { |
| 27 | struct list_head list; |
| 28 | struct vme_bridge *parent; |
Martyn Welch | 400822f | 2009-08-11 16:20:22 +0100 | [diff] [blame] | 29 | struct mutex mtx; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 30 | int locked; |
| 31 | int number; |
| 32 | vme_address_t address_attr; |
| 33 | vme_cycle_t cycle_attr; |
| 34 | }; |
| 35 | |
| 36 | struct vme_dma_pattern { |
| 37 | u32 pattern; |
| 38 | vme_pattern_t type; |
| 39 | }; |
| 40 | |
| 41 | struct vme_dma_pci { |
| 42 | dma_addr_t address; |
| 43 | }; |
| 44 | |
| 45 | struct vme_dma_vme { |
| 46 | unsigned long long address; |
| 47 | vme_address_t aspace; |
| 48 | vme_cycle_t cycle; |
| 49 | vme_width_t dwidth; |
| 50 | }; |
| 51 | |
| 52 | struct vme_dma_list { |
| 53 | struct list_head list; |
| 54 | struct vme_dma_resource *parent; |
| 55 | struct list_head entries; |
Martyn Welch | 400822f | 2009-08-11 16:20:22 +0100 | [diff] [blame] | 56 | struct mutex mtx; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | struct vme_dma_resource { |
| 60 | struct list_head list; |
| 61 | struct vme_bridge *parent; |
Martyn Welch | 400822f | 2009-08-11 16:20:22 +0100 | [diff] [blame] | 62 | struct mutex mtx; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 63 | int locked; |
| 64 | int number; |
| 65 | struct list_head pending; |
| 66 | struct list_head running; |
Martyn Welch | 4f723df | 2010-02-18 15:12:58 +0000 | [diff] [blame^] | 67 | vme_dma_route_t route_attr; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
Martyn Welch | 42fb503 | 2009-08-11 17:44:56 +0100 | [diff] [blame] | 70 | struct vme_lm_resource { |
| 71 | struct list_head list; |
| 72 | struct vme_bridge *parent; |
| 73 | struct mutex mtx; |
| 74 | int locked; |
| 75 | int number; |
| 76 | int monitors; |
| 77 | }; |
| 78 | |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 79 | struct vme_bus_error { |
| 80 | struct list_head list; |
| 81 | unsigned long long address; |
| 82 | u32 attributes; |
| 83 | }; |
| 84 | |
| 85 | struct vme_callback { |
| 86 | void (*func)(int, int, void*); |
| 87 | void *priv_data; |
| 88 | }; |
| 89 | |
| 90 | struct vme_irq { |
| 91 | int count; |
| 92 | struct vme_callback callback[255]; |
| 93 | }; |
| 94 | |
| 95 | /* Allow 16 characters for name (including null character) */ |
| 96 | #define VMENAMSIZ 16 |
| 97 | |
| 98 | /* This structure stores all the information about one bridge |
| 99 | * The structure should be dynamically allocated by the driver and one instance |
| 100 | * of the structure should be present for each VME chip present in the system. |
| 101 | * |
| 102 | * Currently we assume that all chips are PCI-based |
| 103 | */ |
| 104 | struct vme_bridge { |
Martyn Welch | ead1f3e | 2009-12-15 08:43:02 +0000 | [diff] [blame] | 105 | char name[VMENAMSIZ]; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 106 | int num; |
| 107 | struct list_head master_resources; |
| 108 | struct list_head slave_resources; |
| 109 | struct list_head dma_resources; |
Martyn Welch | 42fb503 | 2009-08-11 17:44:56 +0100 | [diff] [blame] | 110 | struct list_head lm_resources; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 111 | |
| 112 | struct list_head vme_errors; /* List for errors generated on VME */ |
| 113 | |
| 114 | /* Bridge Info - XXX Move to private structure? */ |
| 115 | struct device *parent; /* Generic device struct (pdev->dev for PCI) */ |
Martyn Welch | ead1f3e | 2009-12-15 08:43:02 +0000 | [diff] [blame] | 116 | void *base; /* Base Address of device registers */ |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 117 | |
| 118 | struct device dev[VME_SLOTS_MAX]; /* Device registered with |
| 119 | * device model on VME bus |
| 120 | */ |
| 121 | |
| 122 | /* Interrupt callbacks */ |
| 123 | struct vme_irq irq[7]; |
Martyn Welch | c813f59 | 2009-10-29 16:34:54 +0000 | [diff] [blame] | 124 | /* Locking for VME irq callback configuration */ |
| 125 | struct mutex irq_mtx; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 126 | |
| 127 | /* Slave Functions */ |
| 128 | int (*slave_get) (struct vme_slave_resource *, int *, |
| 129 | unsigned long long *, unsigned long long *, dma_addr_t *, |
| 130 | vme_address_t *, vme_cycle_t *); |
| 131 | int (*slave_set) (struct vme_slave_resource *, int, unsigned long long, |
| 132 | unsigned long long, dma_addr_t, vme_address_t, vme_cycle_t); |
| 133 | |
| 134 | /* Master Functions */ |
| 135 | int (*master_get) (struct vme_master_resource *, int *, |
| 136 | unsigned long long *, unsigned long long *, vme_address_t *, |
| 137 | vme_cycle_t *, vme_width_t *); |
| 138 | int (*master_set) (struct vme_master_resource *, int, |
| 139 | unsigned long long, unsigned long long, vme_address_t, |
| 140 | vme_cycle_t, vme_width_t); |
| 141 | ssize_t (*master_read) (struct vme_master_resource *, void *, size_t, |
| 142 | loff_t); |
| 143 | ssize_t (*master_write) (struct vme_master_resource *, void *, size_t, |
| 144 | loff_t); |
| 145 | unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int, |
| 146 | unsigned int, unsigned int, loff_t); |
| 147 | |
| 148 | /* DMA Functions */ |
| 149 | int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *, |
| 150 | struct vme_dma_attr *, size_t); |
| 151 | int (*dma_list_exec) (struct vme_dma_list *); |
| 152 | int (*dma_list_empty) (struct vme_dma_list *); |
| 153 | |
| 154 | /* Interrupt Functions */ |
Martyn Welch | c813f59 | 2009-10-29 16:34:54 +0000 | [diff] [blame] | 155 | void (*irq_set) (int, int, int); |
| 156 | int (*irq_generate) (int, int); |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 157 | |
| 158 | /* Location monitor functions */ |
Martyn Welch | 42fb503 | 2009-08-11 17:44:56 +0100 | [diff] [blame] | 159 | int (*lm_set) (struct vme_lm_resource *, unsigned long long, |
| 160 | vme_address_t, vme_cycle_t); |
| 161 | int (*lm_get) (struct vme_lm_resource *, unsigned long long *, |
| 162 | vme_address_t *, vme_cycle_t *); |
| 163 | int (*lm_attach) (struct vme_lm_resource *, int, void (*callback)(int)); |
| 164 | int (*lm_detach) (struct vme_lm_resource *, int); |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 165 | |
| 166 | /* CR/CSR space functions */ |
| 167 | int (*slot_get) (void); |
| 168 | /* Use standard master read and write functions to access CR/CSR */ |
| 169 | |
| 170 | #if 0 |
| 171 | int (*set_prefetch) (void); |
| 172 | int (*get_prefetch) (void); |
| 173 | int (*set_arbiter) (void); |
| 174 | int (*get_arbiter) (void); |
| 175 | int (*set_requestor) (void); |
| 176 | int (*get_requestor) (void); |
| 177 | #endif |
| 178 | }; |
| 179 | |
Martyn Welch | c813f59 | 2009-10-29 16:34:54 +0000 | [diff] [blame] | 180 | void vme_irq_handler(struct vme_bridge *, int, int); |
| 181 | |
Martyn Welch | ead1f3e | 2009-12-15 08:43:02 +0000 | [diff] [blame] | 182 | int vme_register_bridge(struct vme_bridge *); |
| 183 | void vme_unregister_bridge(struct vme_bridge *); |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 184 | |
| 185 | #endif /* _VME_BRIDGE_H_ */ |
| 186 | |
| 187 | #if 0 |
| 188 | /* |
| 189 | * VMEbus GET INFO Arg Structure |
| 190 | */ |
| 191 | struct vmeInfoCfg { |
| 192 | int vmeSlotNum; /* VME slot number of interest */ |
| 193 | int boardResponded; /* Board responded */ |
| 194 | char sysConFlag; /* System controller flag */ |
| 195 | int vmeControllerID; /* Vendor/device ID of VME bridge */ |
| 196 | int vmeControllerRev; /* Revision of VME bridge */ |
| 197 | char osName[8]; /* Name of OS e.g. "Linux" */ |
| 198 | int vmeSharedDataValid; /* Validity of data struct */ |
| 199 | int vmeDriverRev; /* Revision of VME driver */ |
| 200 | unsigned int vmeAddrHi[8]; /* Address on VME bus */ |
| 201 | unsigned int vmeAddrLo[8]; /* Address on VME bus */ |
| 202 | unsigned int vmeSize[8]; /* Size on VME bus */ |
| 203 | unsigned int vmeAm[8]; /* Address modifier on VME bus */ |
| 204 | int reserved; /* For future use */ |
| 205 | }; |
| 206 | typedef struct vmeInfoCfg vmeInfoCfg_t; |
| 207 | |
| 208 | /* |
| 209 | * VMEbus Requester Arg Structure |
| 210 | */ |
| 211 | struct vmeRequesterCfg { |
| 212 | int requestLevel; /* Requester Bus Request Level */ |
| 213 | char fairMode; /* Requester Fairness Mode Indicator */ |
| 214 | int releaseMode; /* Requester Bus Release Mode */ |
| 215 | int timeonTimeoutTimer; /* Master Time-on Time-out Timer */ |
| 216 | int timeoffTimeoutTimer; /* Master Time-off Time-out Timer */ |
| 217 | int reserved; /* For future use */ |
| 218 | }; |
| 219 | typedef struct vmeRequesterCfg vmeRequesterCfg_t; |
| 220 | |
| 221 | /* |
| 222 | * VMEbus Arbiter Arg Structure |
| 223 | */ |
| 224 | struct vmeArbiterCfg { |
| 225 | vme_arbitration_t arbiterMode; /* Arbitration Scheduling Algorithm */ |
| 226 | char arbiterTimeoutFlag; /* Arbiter Time-out Timer Indicator */ |
| 227 | int globalTimeoutTimer; /* VMEbus Global Time-out Timer */ |
| 228 | char noEarlyReleaseFlag; /* No Early Release on BBUSY */ |
| 229 | int reserved; /* For future use */ |
| 230 | }; |
| 231 | typedef struct vmeArbiterCfg vmeArbiterCfg_t; |
| 232 | |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 233 | #endif |