blob: a3ef63b336e44384f0a1a7621482c4ccc2624388 [file] [log] [blame]
Martyn Welcha17a75e2009-07-31 09:28:17 +01001#ifndef _VME_BRIDGE_H_
2#define _VME_BRIDGE_H_
3
Dmitry Kalinkinad1bfe42015-10-11 01:00:58 +03004#include <linux/vme.h>
5
Martyn Welcha17a75e2009-07-31 09:28:17 +01006#define VME_CRCSR_BUF_SIZE (508*1024)
Martyn Welcha17a75e2009-07-31 09:28:17 +01007/*
8 * Resource structures
9 */
10struct vme_master_resource {
11 struct list_head list;
12 struct vme_bridge *parent;
13 /*
14 * We are likely to need to access the VME bus in interrupt context, so
Martyn Welch400822f2009-08-11 16:20:22 +010015 * protect master routines with a spinlock rather than a mutex.
Martyn Welcha17a75e2009-07-31 09:28:17 +010016 */
17 spinlock_t lock;
18 int locked;
19 int number;
Martyn Welch6af04b02011-12-01 17:06:29 +000020 u32 address_attr;
21 u32 cycle_attr;
22 u32 width_attr;
Martyn Welch8fafb472010-02-18 15:13:12 +000023 struct resource bus_resource;
Emilio G. Cota05997262010-11-12 11:15:40 +000024 void __iomem *kern_base;
Martyn Welcha17a75e2009-07-31 09:28:17 +010025};
26
27struct vme_slave_resource {
28 struct list_head list;
29 struct vme_bridge *parent;
Martyn Welch400822f2009-08-11 16:20:22 +010030 struct mutex mtx;
Martyn Welcha17a75e2009-07-31 09:28:17 +010031 int locked;
32 int number;
Martyn Welch6af04b02011-12-01 17:06:29 +000033 u32 address_attr;
34 u32 cycle_attr;
Martyn Welcha17a75e2009-07-31 09:28:17 +010035};
36
37struct vme_dma_pattern {
38 u32 pattern;
Martyn Welch6af04b02011-12-01 17:06:29 +000039 u32 type;
Martyn Welcha17a75e2009-07-31 09:28:17 +010040};
41
42struct vme_dma_pci {
43 dma_addr_t address;
44};
45
46struct vme_dma_vme {
47 unsigned long long address;
Martyn Welch6af04b02011-12-01 17:06:29 +000048 u32 aspace;
49 u32 cycle;
50 u32 dwidth;
Martyn Welcha17a75e2009-07-31 09:28:17 +010051};
52
53struct vme_dma_list {
54 struct list_head list;
55 struct vme_dma_resource *parent;
56 struct list_head entries;
Martyn Welch400822f2009-08-11 16:20:22 +010057 struct mutex mtx;
Martyn Welcha17a75e2009-07-31 09:28:17 +010058};
59
60struct vme_dma_resource {
61 struct list_head list;
62 struct vme_bridge *parent;
Martyn Welch400822f2009-08-11 16:20:22 +010063 struct mutex mtx;
Martyn Welcha17a75e2009-07-31 09:28:17 +010064 int locked;
65 int number;
66 struct list_head pending;
67 struct list_head running;
Martyn Welch6af04b02011-12-01 17:06:29 +000068 u32 route_attr;
Martyn Welcha17a75e2009-07-31 09:28:17 +010069};
70
Martyn Welch42fb5032009-08-11 17:44:56 +010071struct vme_lm_resource {
72 struct list_head list;
73 struct vme_bridge *parent;
74 struct mutex mtx;
75 int locked;
76 int number;
77 int monitors;
78};
79
Martyn Welcha17a75e2009-07-31 09:28:17 +010080struct vme_bus_error {
81 struct list_head list;
82 unsigned long long address;
83 u32 attributes;
84};
85
86struct vme_callback {
87 void (*func)(int, int, void*);
88 void *priv_data;
89};
90
91struct vme_irq {
92 int count;
Dmitry Kalinkinad1bfe42015-10-11 01:00:58 +030093 struct vme_callback callback[VME_NUM_STATUSID];
Martyn Welcha17a75e2009-07-31 09:28:17 +010094};
95
96/* Allow 16 characters for name (including null character) */
97#define VMENAMSIZ 16
98
99/* This structure stores all the information about one bridge
100 * The structure should be dynamically allocated by the driver and one instance
101 * of the structure should be present for each VME chip present in the system.
Martyn Welcha17a75e2009-07-31 09:28:17 +0100102 */
103struct vme_bridge {
Martyn Welchead1f3e2009-12-15 08:43:02 +0000104 char name[VMENAMSIZ];
Martyn Welcha17a75e2009-07-31 09:28:17 +0100105 int num;
106 struct list_head master_resources;
107 struct list_head slave_resources;
108 struct list_head dma_resources;
Martyn Welch42fb5032009-08-11 17:44:56 +0100109 struct list_head lm_resources;
Martyn Welcha17a75e2009-07-31 09:28:17 +0100110
111 struct list_head vme_errors; /* List for errors generated on VME */
Manohar Vanga5d6abf32011-09-26 11:27:16 +0200112 struct list_head devices; /* List of devices on this bridge */
Martyn Welcha17a75e2009-07-31 09:28:17 +0100113
114 /* Bridge Info - XXX Move to private structure? */
Manohar Vanga7f58f022011-08-10 11:33:46 +0200115 struct device *parent; /* Parent device (eg. pdev->dev for PCI) */
Martyn Welch29848ac2010-02-18 15:13:05 +0000116 void *driver_priv; /* Private pointer for the bridge driver */
Manohar Vanga733e3ef2011-08-12 12:30:48 +0200117 struct list_head bus_list; /* list of VME buses */
Martyn Welcha17a75e2009-07-31 09:28:17 +0100118
Martyn Welcha17a75e2009-07-31 09:28:17 +0100119 /* Interrupt callbacks */
120 struct vme_irq irq[7];
Martyn Welchc813f592009-10-29 16:34:54 +0000121 /* Locking for VME irq callback configuration */
122 struct mutex irq_mtx;
Martyn Welcha17a75e2009-07-31 09:28:17 +0100123
124 /* Slave Functions */
125 int (*slave_get) (struct vme_slave_resource *, int *,
126 unsigned long long *, unsigned long long *, dma_addr_t *,
Martyn Welch6af04b02011-12-01 17:06:29 +0000127 u32 *, u32 *);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100128 int (*slave_set) (struct vme_slave_resource *, int, unsigned long long,
Martyn Welch6af04b02011-12-01 17:06:29 +0000129 unsigned long long, dma_addr_t, u32, u32);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100130
131 /* Master Functions */
132 int (*master_get) (struct vme_master_resource *, int *,
Martyn Welch6af04b02011-12-01 17:06:29 +0000133 unsigned long long *, unsigned long long *, u32 *, u32 *,
134 u32 *);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100135 int (*master_set) (struct vme_master_resource *, int,
Martyn Welch6af04b02011-12-01 17:06:29 +0000136 unsigned long long, unsigned long long, u32, u32, u32);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100137 ssize_t (*master_read) (struct vme_master_resource *, void *, size_t,
138 loff_t);
139 ssize_t (*master_write) (struct vme_master_resource *, void *, size_t,
140 loff_t);
141 unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int,
142 unsigned int, unsigned int, loff_t);
143
144 /* DMA Functions */
145 int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *,
146 struct vme_dma_attr *, size_t);
147 int (*dma_list_exec) (struct vme_dma_list *);
148 int (*dma_list_empty) (struct vme_dma_list *);
149
150 /* Interrupt Functions */
Martyn Welch29848ac2010-02-18 15:13:05 +0000151 void (*irq_set) (struct vme_bridge *, int, int, int);
152 int (*irq_generate) (struct vme_bridge *, int, int);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100153
154 /* Location monitor functions */
Martyn Welch6af04b02011-12-01 17:06:29 +0000155 int (*lm_set) (struct vme_lm_resource *, unsigned long long, u32, u32);
156 int (*lm_get) (struct vme_lm_resource *, unsigned long long *, u32 *,
157 u32 *);
Martyn Welch42fb5032009-08-11 17:44:56 +0100158 int (*lm_attach) (struct vme_lm_resource *, int, void (*callback)(int));
159 int (*lm_detach) (struct vme_lm_resource *, int);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100160
161 /* CR/CSR space functions */
Martyn Welch29848ac2010-02-18 15:13:05 +0000162 int (*slot_get) (struct vme_bridge *);
Manohar Vanga7f58f022011-08-10 11:33:46 +0200163
164 /* Bridge parent interface */
165 void *(*alloc_consistent)(struct device *dev, size_t size,
166 dma_addr_t *dma);
167 void (*free_consistent)(struct device *dev, size_t size,
168 void *vaddr, dma_addr_t dma);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100169};
170
Martyn Welchc813f592009-10-29 16:34:54 +0000171void vme_irq_handler(struct vme_bridge *, int, int);
172
Martyn Welchead1f3e2009-12-15 08:43:02 +0000173int vme_register_bridge(struct vme_bridge *);
174void vme_unregister_bridge(struct vme_bridge *);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100175
176#endif /* _VME_BRIDGE_H_ */