staging: vme: add struct vme_dev for VME devices
[deliverable/linux.git] / drivers / staging / vme / vme_bridge.h
CommitLineData
a17a75e2
MW
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 */
9struct 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
400822fe 14 * protect master routines with a spinlock rather than a mutex.
a17a75e2
MW
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;
8fafb476 22 struct resource bus_resource;
05997267 23 void __iomem *kern_base;
a17a75e2
MW
24};
25
26struct vme_slave_resource {
27 struct list_head list;
28 struct vme_bridge *parent;
400822fe 29 struct mutex mtx;
a17a75e2
MW
30 int locked;
31 int number;
32 vme_address_t address_attr;
33 vme_cycle_t cycle_attr;
34};
35
36struct vme_dma_pattern {
37 u32 pattern;
38 vme_pattern_t type;
39};
40
41struct vme_dma_pci {
42 dma_addr_t address;
43};
44
45struct 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
52struct vme_dma_list {
53 struct list_head list;
54 struct vme_dma_resource *parent;
55 struct list_head entries;
400822fe 56 struct mutex mtx;
a17a75e2
MW
57};
58
59struct vme_dma_resource {
60 struct list_head list;
61 struct vme_bridge *parent;
400822fe 62 struct mutex mtx;
a17a75e2
MW
63 int locked;
64 int number;
65 struct list_head pending;
66 struct list_head running;
4f723df4 67 vme_dma_route_t route_attr;
a17a75e2
MW
68};
69
42fb5031
MW
70struct 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
a17a75e2
MW
79struct vme_bus_error {
80 struct list_head list;
81 unsigned long long address;
82 u32 attributes;
83};
84
85struct vme_callback {
86 void (*func)(int, int, void*);
87 void *priv_data;
88};
89
90struct 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.
a17a75e2
MW
101 */
102struct vme_bridge {
ead1f3e3 103 char name[VMENAMSIZ];
a17a75e2
MW
104 int num;
105 struct list_head master_resources;
106 struct list_head slave_resources;
107 struct list_head dma_resources;
42fb5031 108 struct list_head lm_resources;
a17a75e2
MW
109
110 struct list_head vme_errors; /* List for errors generated on VME */
111
112 /* Bridge Info - XXX Move to private structure? */
7f58f025 113 struct device *parent; /* Parent device (eg. pdev->dev for PCI) */
29848ac9 114 void *driver_priv; /* Private pointer for the bridge driver */
733e3ef0 115 struct list_head bus_list; /* list of VME buses */
a17a75e2 116
8f966dc4
MV
117 struct vme_dev *dev[VME_SLOTS_MAX]; /* Device registered
118 * on VME bus */
a17a75e2
MW
119
120 /* Interrupt callbacks */
121 struct vme_irq irq[7];
c813f592
MW
122 /* Locking for VME irq callback configuration */
123 struct mutex irq_mtx;
a17a75e2
MW
124
125 /* Slave Functions */
126 int (*slave_get) (struct vme_slave_resource *, int *,
127 unsigned long long *, unsigned long long *, dma_addr_t *,
128 vme_address_t *, vme_cycle_t *);
129 int (*slave_set) (struct vme_slave_resource *, int, unsigned long long,
130 unsigned long long, dma_addr_t, vme_address_t, vme_cycle_t);
131
132 /* Master Functions */
133 int (*master_get) (struct vme_master_resource *, int *,
134 unsigned long long *, unsigned long long *, vme_address_t *,
135 vme_cycle_t *, vme_width_t *);
136 int (*master_set) (struct vme_master_resource *, int,
137 unsigned long long, unsigned long long, vme_address_t,
138 vme_cycle_t, vme_width_t);
139 ssize_t (*master_read) (struct vme_master_resource *, void *, size_t,
140 loff_t);
141 ssize_t (*master_write) (struct vme_master_resource *, void *, size_t,
142 loff_t);
143 unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int,
144 unsigned int, unsigned int, loff_t);
145
146 /* DMA Functions */
147 int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *,
148 struct vme_dma_attr *, size_t);
149 int (*dma_list_exec) (struct vme_dma_list *);
150 int (*dma_list_empty) (struct vme_dma_list *);
151
152 /* Interrupt Functions */
29848ac9
MW
153 void (*irq_set) (struct vme_bridge *, int, int, int);
154 int (*irq_generate) (struct vme_bridge *, int, int);
a17a75e2
MW
155
156 /* Location monitor functions */
42fb5031
MW
157 int (*lm_set) (struct vme_lm_resource *, unsigned long long,
158 vme_address_t, vme_cycle_t);
159 int (*lm_get) (struct vme_lm_resource *, unsigned long long *,
160 vme_address_t *, vme_cycle_t *);
161 int (*lm_attach) (struct vme_lm_resource *, int, void (*callback)(int));
162 int (*lm_detach) (struct vme_lm_resource *, int);
a17a75e2
MW
163
164 /* CR/CSR space functions */
29848ac9 165 int (*slot_get) (struct vme_bridge *);
7f58f025
MV
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);
a17a75e2
MW
172};
173
c813f592
MW
174void vme_irq_handler(struct vme_bridge *, int, int);
175
ead1f3e3
MW
176int vme_register_bridge(struct vme_bridge *);
177void vme_unregister_bridge(struct vme_bridge *);
a17a75e2
MW
178
179#endif /* _VME_BRIDGE_H_ */
This page took 0.211812 seconds and 5 git commands to generate.