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) |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 5 | /* |
| 6 | * Resource structures |
| 7 | */ |
| 8 | struct vme_master_resource { |
| 9 | struct list_head list; |
| 10 | struct vme_bridge *parent; |
| 11 | /* |
| 12 | * 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] | 13 | * protect master routines with a spinlock rather than a mutex. |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 14 | */ |
| 15 | spinlock_t lock; |
| 16 | int locked; |
| 17 | int number; |
Martyn Welch | 6af04b0 | 2011-12-01 17:06:29 +0000 | [diff] [blame] | 18 | u32 address_attr; |
| 19 | u32 cycle_attr; |
| 20 | u32 width_attr; |
Martyn Welch | 8fafb47 | 2010-02-18 15:13:12 +0000 | [diff] [blame] | 21 | struct resource bus_resource; |
Emilio G. Cota | 0599726 | 2010-11-12 11:15:40 +0000 | [diff] [blame] | 22 | void __iomem *kern_base; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | struct vme_slave_resource { |
| 26 | struct list_head list; |
| 27 | struct vme_bridge *parent; |
Martyn Welch | 400822f | 2009-08-11 16:20:22 +0100 | [diff] [blame] | 28 | struct mutex mtx; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 29 | int locked; |
| 30 | int number; |
Martyn Welch | 6af04b0 | 2011-12-01 17:06:29 +0000 | [diff] [blame] | 31 | u32 address_attr; |
| 32 | u32 cycle_attr; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | struct vme_dma_pattern { |
| 36 | u32 pattern; |
Martyn Welch | 6af04b0 | 2011-12-01 17:06:29 +0000 | [diff] [blame] | 37 | u32 type; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | struct vme_dma_pci { |
| 41 | dma_addr_t address; |
| 42 | }; |
| 43 | |
| 44 | struct vme_dma_vme { |
| 45 | unsigned long long address; |
Martyn Welch | 6af04b0 | 2011-12-01 17:06:29 +0000 | [diff] [blame] | 46 | u32 aspace; |
| 47 | u32 cycle; |
| 48 | u32 dwidth; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | struct vme_dma_list { |
| 52 | struct list_head list; |
| 53 | struct vme_dma_resource *parent; |
| 54 | struct list_head entries; |
Martyn Welch | 400822f | 2009-08-11 16:20:22 +0100 | [diff] [blame] | 55 | struct mutex mtx; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | struct vme_dma_resource { |
| 59 | struct list_head list; |
| 60 | struct vme_bridge *parent; |
Martyn Welch | 400822f | 2009-08-11 16:20:22 +0100 | [diff] [blame] | 61 | struct mutex mtx; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 62 | int locked; |
| 63 | int number; |
| 64 | struct list_head pending; |
| 65 | struct list_head running; |
Martyn Welch | 6af04b0 | 2011-12-01 17:06:29 +0000 | [diff] [blame] | 66 | u32 route_attr; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 67 | }; |
| 68 | |
Martyn Welch | 42fb503 | 2009-08-11 17:44:56 +0100 | [diff] [blame] | 69 | struct vme_lm_resource { |
| 70 | struct list_head list; |
| 71 | struct vme_bridge *parent; |
| 72 | struct mutex mtx; |
| 73 | int locked; |
| 74 | int number; |
| 75 | int monitors; |
| 76 | }; |
| 77 | |
Dmitry Kalinkin | 0b04966 | 2015-09-18 02:01:44 +0300 | [diff] [blame] | 78 | struct vme_error_handler { |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 79 | struct list_head list; |
Dmitry Kalinkin | 0b04966 | 2015-09-18 02:01:44 +0300 | [diff] [blame] | 80 | unsigned long long start; /* Beginning of error window */ |
| 81 | unsigned long long end; /* End of error window */ |
| 82 | unsigned long long first_error; /* Address of the first error */ |
| 83 | u32 aspace; /* Address space of error window*/ |
| 84 | unsigned num_errors; /* Number of errors */ |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | struct vme_callback { |
| 88 | void (*func)(int, int, void*); |
| 89 | void *priv_data; |
| 90 | }; |
| 91 | |
| 92 | struct vme_irq { |
| 93 | int count; |
| 94 | struct vme_callback callback[255]; |
| 95 | }; |
| 96 | |
| 97 | /* Allow 16 characters for name (including null character) */ |
| 98 | #define VMENAMSIZ 16 |
| 99 | |
| 100 | /* This structure stores all the information about one bridge |
| 101 | * The structure should be dynamically allocated by the driver and one instance |
| 102 | * of the structure should be present for each VME chip present in the system. |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 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 | |
Dmitry Kalinkin | 0b04966 | 2015-09-18 02:01:44 +0300 | [diff] [blame] | 112 | /* List for registered errors handlers */ |
| 113 | struct list_head vme_error_handlers; |
| 114 | /* List of devices on this bridge */ |
| 115 | struct list_head devices; |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 116 | |
| 117 | /* Bridge Info - XXX Move to private structure? */ |
Manohar Vanga | 7f58f02 | 2011-08-10 11:33:46 +0200 | [diff] [blame] | 118 | struct device *parent; /* Parent device (eg. pdev->dev for PCI) */ |
Martyn Welch | 29848ac | 2010-02-18 15:13:05 +0000 | [diff] [blame] | 119 | void *driver_priv; /* Private pointer for the bridge driver */ |
Manohar Vanga | 733e3ef | 2011-08-12 12:30:48 +0200 | [diff] [blame] | 120 | struct list_head bus_list; /* list of VME buses */ |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 121 | |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 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 *, |
Martyn Welch | 6af04b0 | 2011-12-01 17:06:29 +0000 | [diff] [blame] | 130 | u32 *, u32 *); |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 131 | int (*slave_set) (struct vme_slave_resource *, int, unsigned long long, |
Martyn Welch | 6af04b0 | 2011-12-01 17:06:29 +0000 | [diff] [blame] | 132 | unsigned long long, dma_addr_t, u32, u32); |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 133 | |
| 134 | /* Master Functions */ |
| 135 | int (*master_get) (struct vme_master_resource *, int *, |
Martyn Welch | 6af04b0 | 2011-12-01 17:06:29 +0000 | [diff] [blame] | 136 | unsigned long long *, unsigned long long *, u32 *, u32 *, |
| 137 | u32 *); |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 138 | int (*master_set) (struct vme_master_resource *, int, |
Martyn Welch | 6af04b0 | 2011-12-01 17:06:29 +0000 | [diff] [blame] | 139 | unsigned long long, unsigned long long, u32, u32, u32); |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 140 | ssize_t (*master_read) (struct vme_master_resource *, void *, size_t, |
| 141 | loff_t); |
| 142 | ssize_t (*master_write) (struct vme_master_resource *, void *, size_t, |
| 143 | loff_t); |
| 144 | unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int, |
| 145 | unsigned int, unsigned int, loff_t); |
| 146 | |
| 147 | /* DMA Functions */ |
| 148 | int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *, |
| 149 | struct vme_dma_attr *, size_t); |
| 150 | int (*dma_list_exec) (struct vme_dma_list *); |
| 151 | int (*dma_list_empty) (struct vme_dma_list *); |
| 152 | |
| 153 | /* Interrupt Functions */ |
Martyn Welch | 29848ac | 2010-02-18 15:13:05 +0000 | [diff] [blame] | 154 | void (*irq_set) (struct vme_bridge *, int, int, int); |
| 155 | int (*irq_generate) (struct vme_bridge *, int, int); |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 156 | |
| 157 | /* Location monitor functions */ |
Martyn Welch | 6af04b0 | 2011-12-01 17:06:29 +0000 | [diff] [blame] | 158 | int (*lm_set) (struct vme_lm_resource *, unsigned long long, u32, u32); |
| 159 | int (*lm_get) (struct vme_lm_resource *, unsigned long long *, u32 *, |
| 160 | u32 *); |
Martyn Welch | 42fb503 | 2009-08-11 17:44:56 +0100 | [diff] [blame] | 161 | int (*lm_attach) (struct vme_lm_resource *, int, void (*callback)(int)); |
| 162 | int (*lm_detach) (struct vme_lm_resource *, int); |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 163 | |
| 164 | /* CR/CSR space functions */ |
Martyn Welch | 29848ac | 2010-02-18 15:13:05 +0000 | [diff] [blame] | 165 | int (*slot_get) (struct vme_bridge *); |
Manohar Vanga | 7f58f02 | 2011-08-10 11:33:46 +0200 | [diff] [blame] | 166 | |
| 167 | /* Bridge parent interface */ |
| 168 | void *(*alloc_consistent)(struct device *dev, size_t size, |
| 169 | dma_addr_t *dma); |
| 170 | void (*free_consistent)(struct device *dev, size_t size, |
| 171 | void *vaddr, dma_addr_t dma); |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 172 | }; |
| 173 | |
Dmitry Kalinkin | e2c6393 | 2015-09-18 02:01:42 +0300 | [diff] [blame] | 174 | void vme_bus_error_handler(struct vme_bridge *bridge, |
Dmitry Kalinkin | 472f16f | 2015-09-18 02:01:43 +0300 | [diff] [blame] | 175 | unsigned long long address, int am); |
Martyn Welch | c813f59 | 2009-10-29 16:34:54 +0000 | [diff] [blame] | 176 | void vme_irq_handler(struct vme_bridge *, int, int); |
| 177 | |
Martyn Welch | ead1f3e | 2009-12-15 08:43:02 +0000 | [diff] [blame] | 178 | int vme_register_bridge(struct vme_bridge *); |
| 179 | void vme_unregister_bridge(struct vme_bridge *); |
Dmitry Kalinkin | 0b04966 | 2015-09-18 02:01:44 +0300 | [diff] [blame] | 180 | struct vme_error_handler *vme_register_error_handler( |
| 181 | struct vme_bridge *bridge, u32 aspace, |
| 182 | unsigned long long address, size_t len); |
| 183 | void vme_unregister_error_handler(struct vme_error_handler *handler); |
Martyn Welch | a17a75e | 2009-07-31 09:28:17 +0100 | [diff] [blame] | 184 | |
| 185 | #endif /* _VME_BRIDGE_H_ */ |