Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _VME_BRIDGE_H_
3#define _VME_BRIDGE_H_
4
5#include <linux/vme.h>
6
7#define VME_CRCSR_BUF_SIZE (508*1024)
8/*
9 * Resource structures
10 */
11struct vme_master_resource {
12 struct list_head list;
13 struct vme_bridge *parent;
14 /*
15 * We are likely to need to access the VME bus in interrupt context, so
16 * protect master routines with a spinlock rather than a mutex.
17 */
18 spinlock_t lock;
19 int locked;
20 int number;
21 u32 address_attr;
22 u32 cycle_attr;
23 u32 width_attr;
24 struct resource bus_resource;
25 void __iomem *kern_base;
26};
27
28struct vme_slave_resource {
29 struct list_head list;
30 struct vme_bridge *parent;
31 struct mutex mtx;
32 int locked;
33 int number;
34 u32 address_attr;
35 u32 cycle_attr;
36};
37
38struct vme_dma_pattern {
39 u32 pattern;
40 u32 type;
41};
42
43struct vme_dma_pci {
44 dma_addr_t address;
45};
46
47struct vme_dma_vme {
48 unsigned long long address;
49 u32 aspace;
50 u32 cycle;
51 u32 dwidth;
52};
53
54struct vme_dma_list {
55 struct list_head list;
56 struct vme_dma_resource *parent;
57 struct list_head entries;
58 struct mutex mtx;
59};
60
61struct vme_dma_resource {
62 struct list_head list;
63 struct vme_bridge *parent;
64 struct mutex mtx;
65 int locked;
66 int number;
67 struct list_head pending;
68 struct list_head running;
69 u32 route_attr;
70};
71
72struct vme_lm_resource {
73 struct list_head list;
74 struct vme_bridge *parent;
75 struct mutex mtx;
76 int locked;
77 int number;
78 int monitors;
79};
80
81struct vme_error_handler {
82 struct list_head list;
83 unsigned long long start; /* Beginning of error window */
84 unsigned long long end; /* End of error window */
85 unsigned long long first_error; /* Address of the first error */
86 u32 aspace; /* Address space of error window*/
87 unsigned num_errors; /* Number of errors */
88};
89
90struct vme_callback {
91 void (*func)(int, int, void*);
92 void *priv_data;
93};
94
95struct vme_irq {
96 int count;
97 struct vme_callback callback[VME_NUM_STATUSID];
98};
99
100/* Allow 16 characters for name (including null character) */
101#define VMENAMSIZ 16
102
103/* This structure stores all the information about one bridge
104 * The structure should be dynamically allocated by the driver and one instance
105 * of the structure should be present for each VME chip present in the system.
106 */
107struct vme_bridge {
108 char name[VMENAMSIZ];
109 int num;
110 struct list_head master_resources;
111 struct list_head slave_resources;
112 struct list_head dma_resources;
113 struct list_head lm_resources;
114
115 /* List for registered errors handlers */
116 struct list_head vme_error_handlers;
117 /* List of devices on this bridge */
118 struct list_head devices;
119
120 /* Bridge Info - XXX Move to private structure? */
121 struct device *parent; /* Parent device (eg. pdev->dev for PCI) */
122 void *driver_priv; /* Private pointer for the bridge driver */
123 struct list_head bus_list; /* list of VME buses */
124
125 /* Interrupt callbacks */
126 struct vme_irq irq[7];
127 /* Locking for VME irq callback configuration */
128 struct mutex irq_mtx;
129
130 /* Slave Functions */
131 int (*slave_get) (struct vme_slave_resource *, int *,
132 unsigned long long *, unsigned long long *, dma_addr_t *,
133 u32 *, u32 *);
134 int (*slave_set) (struct vme_slave_resource *, int, unsigned long long,
135 unsigned long long, dma_addr_t, u32, u32);
136
137 /* Master Functions */
138 int (*master_get) (struct vme_master_resource *, int *,
139 unsigned long long *, unsigned long long *, u32 *, u32 *,
140 u32 *);
141 int (*master_set) (struct vme_master_resource *, int,
142 unsigned long long, unsigned long long, u32, u32, u32);
143 ssize_t (*master_read) (struct vme_master_resource *, void *, size_t,
144 loff_t);
145 ssize_t (*master_write) (struct vme_master_resource *, void *, size_t,
146 loff_t);
147 unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int,
148 unsigned int, unsigned int, loff_t);
149
150 /* DMA Functions */
151 int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *,
152 struct vme_dma_attr *, size_t);
153 int (*dma_list_exec) (struct vme_dma_list *);
154 int (*dma_list_empty) (struct vme_dma_list *);
155
156 /* Interrupt Functions */
157 void (*irq_set) (struct vme_bridge *, int, int, int);
158 int (*irq_generate) (struct vme_bridge *, int, int);
159
160 /* Location monitor functions */
161 int (*lm_set) (struct vme_lm_resource *, unsigned long long, u32, u32);
162 int (*lm_get) (struct vme_lm_resource *, unsigned long long *, u32 *,
163 u32 *);
164 int (*lm_attach)(struct vme_lm_resource *, int,
165 void (*callback)(void *), void *);
166 int (*lm_detach) (struct vme_lm_resource *, int);
167
168 /* CR/CSR space functions */
169 int (*slot_get) (struct vme_bridge *);
170
171 /* Bridge parent interface */
172 void *(*alloc_consistent)(struct device *dev, size_t size,
173 dma_addr_t *dma);
174 void (*free_consistent)(struct device *dev, size_t size,
175 void *vaddr, dma_addr_t dma);
176};
177
178void vme_bus_error_handler(struct vme_bridge *bridge,
179 unsigned long long address, int am);
180void vme_irq_handler(struct vme_bridge *, int, int);
181
182struct vme_bridge *vme_init_bridge(struct vme_bridge *);
183int vme_register_bridge(struct vme_bridge *);
184void vme_unregister_bridge(struct vme_bridge *);
185struct vme_error_handler *vme_register_error_handler(
186 struct vme_bridge *bridge, u32 aspace,
187 unsigned long long address, size_t len);
188void vme_unregister_error_handler(struct vme_error_handler *handler);
189
190#endif /* _VME_BRIDGE_H_ */
1#ifndef _VME_BRIDGE_H_
2#define _VME_BRIDGE_H_
3
4#include <linux/vme.h>
5
6#define VME_CRCSR_BUF_SIZE (508*1024)
7/*
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
15 * protect master routines with a spinlock rather than a mutex.
16 */
17 spinlock_t lock;
18 int locked;
19 int number;
20 u32 address_attr;
21 u32 cycle_attr;
22 u32 width_attr;
23 struct resource bus_resource;
24 void __iomem *kern_base;
25};
26
27struct vme_slave_resource {
28 struct list_head list;
29 struct vme_bridge *parent;
30 struct mutex mtx;
31 int locked;
32 int number;
33 u32 address_attr;
34 u32 cycle_attr;
35};
36
37struct vme_dma_pattern {
38 u32 pattern;
39 u32 type;
40};
41
42struct vme_dma_pci {
43 dma_addr_t address;
44};
45
46struct vme_dma_vme {
47 unsigned long long address;
48 u32 aspace;
49 u32 cycle;
50 u32 dwidth;
51};
52
53struct vme_dma_list {
54 struct list_head list;
55 struct vme_dma_resource *parent;
56 struct list_head entries;
57 struct mutex mtx;
58};
59
60struct vme_dma_resource {
61 struct list_head list;
62 struct vme_bridge *parent;
63 struct mutex mtx;
64 int locked;
65 int number;
66 struct list_head pending;
67 struct list_head running;
68 u32 route_attr;
69};
70
71struct 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
80struct vme_error_handler {
81 struct list_head list;
82 unsigned long long start; /* Beginning of error window */
83 unsigned long long end; /* End of error window */
84 unsigned long long first_error; /* Address of the first error */
85 u32 aspace; /* Address space of error window*/
86 unsigned num_errors; /* Number of errors */
87};
88
89struct vme_callback {
90 void (*func)(int, int, void*);
91 void *priv_data;
92};
93
94struct vme_irq {
95 int count;
96 struct vme_callback callback[VME_NUM_STATUSID];
97};
98
99/* Allow 16 characters for name (including null character) */
100#define VMENAMSIZ 16
101
102/* This structure stores all the information about one bridge
103 * The structure should be dynamically allocated by the driver and one instance
104 * of the structure should be present for each VME chip present in the system.
105 */
106struct vme_bridge {
107 char name[VMENAMSIZ];
108 int num;
109 struct list_head master_resources;
110 struct list_head slave_resources;
111 struct list_head dma_resources;
112 struct list_head lm_resources;
113
114 /* List for registered errors handlers */
115 struct list_head vme_error_handlers;
116 /* List of devices on this bridge */
117 struct list_head devices;
118
119 /* Bridge Info - XXX Move to private structure? */
120 struct device *parent; /* Parent device (eg. pdev->dev for PCI) */
121 void *driver_priv; /* Private pointer for the bridge driver */
122 struct list_head bus_list; /* list of VME buses */
123
124 /* Interrupt callbacks */
125 struct vme_irq irq[7];
126 /* Locking for VME irq callback configuration */
127 struct mutex irq_mtx;
128
129 /* Slave Functions */
130 int (*slave_get) (struct vme_slave_resource *, int *,
131 unsigned long long *, unsigned long long *, dma_addr_t *,
132 u32 *, u32 *);
133 int (*slave_set) (struct vme_slave_resource *, int, unsigned long long,
134 unsigned long long, dma_addr_t, u32, u32);
135
136 /* Master Functions */
137 int (*master_get) (struct vme_master_resource *, int *,
138 unsigned long long *, unsigned long long *, u32 *, u32 *,
139 u32 *);
140 int (*master_set) (struct vme_master_resource *, int,
141 unsigned long long, unsigned long long, u32, u32, u32);
142 ssize_t (*master_read) (struct vme_master_resource *, void *, size_t,
143 loff_t);
144 ssize_t (*master_write) (struct vme_master_resource *, void *, size_t,
145 loff_t);
146 unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int,
147 unsigned int, unsigned int, loff_t);
148
149 /* DMA Functions */
150 int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *,
151 struct vme_dma_attr *, size_t);
152 int (*dma_list_exec) (struct vme_dma_list *);
153 int (*dma_list_empty) (struct vme_dma_list *);
154
155 /* Interrupt Functions */
156 void (*irq_set) (struct vme_bridge *, int, int, int);
157 int (*irq_generate) (struct vme_bridge *, int, int);
158
159 /* Location monitor functions */
160 int (*lm_set) (struct vme_lm_resource *, unsigned long long, u32, u32);
161 int (*lm_get) (struct vme_lm_resource *, unsigned long long *, u32 *,
162 u32 *);
163 int (*lm_attach) (struct vme_lm_resource *, int, void (*callback)(int));
164 int (*lm_detach) (struct vme_lm_resource *, int);
165
166 /* CR/CSR space functions */
167 int (*slot_get) (struct vme_bridge *);
168
169 /* Bridge parent interface */
170 void *(*alloc_consistent)(struct device *dev, size_t size,
171 dma_addr_t *dma);
172 void (*free_consistent)(struct device *dev, size_t size,
173 void *vaddr, dma_addr_t dma);
174};
175
176void vme_bus_error_handler(struct vme_bridge *bridge,
177 unsigned long long address, int am);
178void vme_irq_handler(struct vme_bridge *, int, int);
179
180int vme_register_bridge(struct vme_bridge *);
181void vme_unregister_bridge(struct vme_bridge *);
182struct vme_error_handler *vme_register_error_handler(
183 struct vme_bridge *bridge, u32 aspace,
184 unsigned long long address, size_t len);
185void vme_unregister_error_handler(struct vme_error_handler *handler);
186
187#endif /* _VME_BRIDGE_H_ */