1 /* SPDX-License-Identifier: GPL-2.0 */
7 #define VME_CRCSR_BUF_SIZE (508*1024)
11 struct vme_master_resource
{
12 struct list_head list
;
13 struct vme_bridge
*parent
;
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.
24 struct resource bus_resource
;
25 void __iomem
*kern_base
;
28 struct vme_slave_resource
{
29 struct list_head list
;
30 struct vme_bridge
*parent
;
38 struct vme_dma_pattern
{
48 unsigned long long address
;
55 struct list_head list
;
56 struct vme_dma_resource
*parent
;
57 struct list_head entries
;
61 struct vme_dma_resource
{
62 struct list_head list
;
63 struct vme_bridge
*parent
;
67 struct list_head pending
;
68 struct list_head running
;
72 struct vme_lm_resource
{
73 struct list_head list
;
74 struct vme_bridge
*parent
;
81 struct 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 */
91 void (*func
)(int, int, void*);
97 struct vme_callback callback
[VME_NUM_STATUSID
];
100 /* Allow 16 characters for name (including null character) */
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.
108 char name
[VMENAMSIZ
];
110 struct list_head master_resources
;
111 struct list_head slave_resources
;
112 struct list_head dma_resources
;
113 struct list_head lm_resources
;
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
;
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 */
125 /* Interrupt callbacks */
126 struct vme_irq irq
[7];
127 /* Locking for VME irq callback configuration */
128 struct mutex irq_mtx
;
130 /* Slave Functions */
131 int (*slave_get
) (struct vme_slave_resource
*, int *,
132 unsigned long long *, unsigned long long *, dma_addr_t
*,
134 int (*slave_set
) (struct vme_slave_resource
*, int, unsigned long long,
135 unsigned long long, dma_addr_t
, u32
, u32
);
137 /* Master Functions */
138 int (*master_get
) (struct vme_master_resource
*, int *,
139 unsigned long long *, unsigned long long *, u32
*, 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,
145 ssize_t (*master_write
) (struct vme_master_resource
*, void *, size_t,
147 unsigned int (*master_rmw
) (struct vme_master_resource
*, unsigned int,
148 unsigned int, unsigned int, loff_t
);
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
*);
156 /* Interrupt Functions */
157 void (*irq_set
) (struct vme_bridge
*, int, int, int);
158 int (*irq_generate
) (struct vme_bridge
*, int, int);
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
*,
164 int (*lm_attach
)(struct vme_lm_resource
*, int,
165 void (*callback
)(void *), void *);
166 int (*lm_detach
) (struct vme_lm_resource
*, int);
168 /* CR/CSR space functions */
169 int (*slot_get
) (struct vme_bridge
*);
171 /* Bridge parent interface */
172 void *(*alloc_consistent
)(struct device
*dev
, size_t size
,
174 void (*free_consistent
)(struct device
*dev
, size_t size
,
175 void *vaddr
, dma_addr_t dma
);
178 void vme_bus_error_handler(struct vme_bridge
*bridge
,
179 unsigned long long address
, int am
);
180 void vme_irq_handler(struct vme_bridge
*, int, int);
182 struct vme_bridge
*vme_init_bridge(struct vme_bridge
*);
183 int vme_register_bridge(struct vme_bridge
*);
184 void vme_unregister_bridge(struct vme_bridge
*);
185 struct vme_error_handler
*vme_register_error_handler(
186 struct vme_bridge
*bridge
, u32 aspace
,
187 unsigned long long address
, size_t len
);
188 void vme_unregister_error_handler(struct vme_error_handler
*handler
);
190 #endif /* _VME_BRIDGE_H_ */