blob: 934949abd7457c8072c47844f7ea555c05e5bb4e [file] [log] [blame]
Martyn Welcha17a75e2009-07-31 09:28:17 +01001#ifndef _VME_BRIDGE_H_
2#define _VME_BRIDGE_H_
3
4#define VME_CRCSR_BUF_SIZE (508*1024)
Martyn Welcha17a75e2009-07-31 09:28:17 +01005/*
6 * Resource structures
7 */
8struct 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 Welch400822f2009-08-11 16:20:22 +010013 * protect master routines with a spinlock rather than a mutex.
Martyn Welcha17a75e2009-07-31 09:28:17 +010014 */
15 spinlock_t lock;
16 int locked;
17 int number;
Martyn Welch6af04b02011-12-01 17:06:29 +000018 u32 address_attr;
19 u32 cycle_attr;
20 u32 width_attr;
Martyn Welch8fafb472010-02-18 15:13:12 +000021 struct resource bus_resource;
Emilio G. Cota05997262010-11-12 11:15:40 +000022 void __iomem *kern_base;
Martyn Welcha17a75e2009-07-31 09:28:17 +010023};
24
25struct vme_slave_resource {
26 struct list_head list;
27 struct vme_bridge *parent;
Martyn Welch400822f2009-08-11 16:20:22 +010028 struct mutex mtx;
Martyn Welcha17a75e2009-07-31 09:28:17 +010029 int locked;
30 int number;
Martyn Welch6af04b02011-12-01 17:06:29 +000031 u32 address_attr;
32 u32 cycle_attr;
Martyn Welcha17a75e2009-07-31 09:28:17 +010033};
34
35struct vme_dma_pattern {
36 u32 pattern;
Martyn Welch6af04b02011-12-01 17:06:29 +000037 u32 type;
Martyn Welcha17a75e2009-07-31 09:28:17 +010038};
39
40struct vme_dma_pci {
41 dma_addr_t address;
42};
43
44struct vme_dma_vme {
45 unsigned long long address;
Martyn Welch6af04b02011-12-01 17:06:29 +000046 u32 aspace;
47 u32 cycle;
48 u32 dwidth;
Martyn Welcha17a75e2009-07-31 09:28:17 +010049};
50
51struct vme_dma_list {
52 struct list_head list;
53 struct vme_dma_resource *parent;
54 struct list_head entries;
Martyn Welch400822f2009-08-11 16:20:22 +010055 struct mutex mtx;
Martyn Welcha17a75e2009-07-31 09:28:17 +010056};
57
58struct vme_dma_resource {
59 struct list_head list;
60 struct vme_bridge *parent;
Martyn Welch400822f2009-08-11 16:20:22 +010061 struct mutex mtx;
Martyn Welcha17a75e2009-07-31 09:28:17 +010062 int locked;
63 int number;
64 struct list_head pending;
65 struct list_head running;
Martyn Welch6af04b02011-12-01 17:06:29 +000066 u32 route_attr;
Martyn Welcha17a75e2009-07-31 09:28:17 +010067};
68
Martyn Welch42fb5032009-08-11 17:44:56 +010069struct 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
Martyn Welcha17a75e2009-07-31 09:28:17 +010078struct vme_bus_error {
79 struct list_head list;
80 unsigned long long address;
81 u32 attributes;
82};
83
84struct vme_callback {
85 void (*func)(int, int, void*);
86 void *priv_data;
87};
88
89struct vme_irq {
90 int count;
91 struct vme_callback callback[255];
92};
93
94/* Allow 16 characters for name (including null character) */
95#define VMENAMSIZ 16
96
97/* This structure stores all the information about one bridge
98 * The structure should be dynamically allocated by the driver and one instance
99 * of the structure should be present for each VME chip present in the system.
Martyn Welcha17a75e2009-07-31 09:28:17 +0100100 */
101struct vme_bridge {
Martyn Welchead1f3e2009-12-15 08:43:02 +0000102 char name[VMENAMSIZ];
Martyn Welcha17a75e2009-07-31 09:28:17 +0100103 int num;
104 struct list_head master_resources;
105 struct list_head slave_resources;
106 struct list_head dma_resources;
Martyn Welch42fb5032009-08-11 17:44:56 +0100107 struct list_head lm_resources;
Martyn Welcha17a75e2009-07-31 09:28:17 +0100108
109 struct list_head vme_errors; /* List for errors generated on VME */
Manohar Vanga5d6abf32011-09-26 11:27:16 +0200110 struct list_head devices; /* List of devices on this bridge */
Martyn Welcha17a75e2009-07-31 09:28:17 +0100111
112 /* Bridge Info - XXX Move to private structure? */
Manohar Vanga7f58f022011-08-10 11:33:46 +0200113 struct device *parent; /* Parent device (eg. pdev->dev for PCI) */
Martyn Welch29848ac2010-02-18 15:13:05 +0000114 void *driver_priv; /* Private pointer for the bridge driver */
Manohar Vanga733e3ef2011-08-12 12:30:48 +0200115 struct list_head bus_list; /* list of VME buses */
Martyn Welcha17a75e2009-07-31 09:28:17 +0100116
Martyn Welcha17a75e2009-07-31 09:28:17 +0100117 /* Interrupt callbacks */
118 struct vme_irq irq[7];
Martyn Welchc813f592009-10-29 16:34:54 +0000119 /* Locking for VME irq callback configuration */
120 struct mutex irq_mtx;
Martyn Welcha17a75e2009-07-31 09:28:17 +0100121
122 /* Slave Functions */
123 int (*slave_get) (struct vme_slave_resource *, int *,
124 unsigned long long *, unsigned long long *, dma_addr_t *,
Martyn Welch6af04b02011-12-01 17:06:29 +0000125 u32 *, u32 *);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100126 int (*slave_set) (struct vme_slave_resource *, int, unsigned long long,
Martyn Welch6af04b02011-12-01 17:06:29 +0000127 unsigned long long, dma_addr_t, u32, u32);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100128
129 /* Master Functions */
130 int (*master_get) (struct vme_master_resource *, int *,
Martyn Welch6af04b02011-12-01 17:06:29 +0000131 unsigned long long *, unsigned long long *, u32 *, u32 *,
132 u32 *);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100133 int (*master_set) (struct vme_master_resource *, int,
Martyn Welch6af04b02011-12-01 17:06:29 +0000134 unsigned long long, unsigned long long, u32, u32, u32);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100135 ssize_t (*master_read) (struct vme_master_resource *, void *, size_t,
136 loff_t);
137 ssize_t (*master_write) (struct vme_master_resource *, void *, size_t,
138 loff_t);
139 unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int,
140 unsigned int, unsigned int, loff_t);
141
142 /* DMA Functions */
143 int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *,
144 struct vme_dma_attr *, size_t);
145 int (*dma_list_exec) (struct vme_dma_list *);
146 int (*dma_list_empty) (struct vme_dma_list *);
147
148 /* Interrupt Functions */
Martyn Welch29848ac2010-02-18 15:13:05 +0000149 void (*irq_set) (struct vme_bridge *, int, int, int);
150 int (*irq_generate) (struct vme_bridge *, int, int);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100151
152 /* Location monitor functions */
Martyn Welch6af04b02011-12-01 17:06:29 +0000153 int (*lm_set) (struct vme_lm_resource *, unsigned long long, u32, u32);
154 int (*lm_get) (struct vme_lm_resource *, unsigned long long *, u32 *,
155 u32 *);
Martyn Welch42fb5032009-08-11 17:44:56 +0100156 int (*lm_attach) (struct vme_lm_resource *, int, void (*callback)(int));
157 int (*lm_detach) (struct vme_lm_resource *, int);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100158
159 /* CR/CSR space functions */
Martyn Welch29848ac2010-02-18 15:13:05 +0000160 int (*slot_get) (struct vme_bridge *);
Manohar Vanga7f58f022011-08-10 11:33:46 +0200161
162 /* Bridge parent interface */
163 void *(*alloc_consistent)(struct device *dev, size_t size,
164 dma_addr_t *dma);
165 void (*free_consistent)(struct device *dev, size_t size,
166 void *vaddr, dma_addr_t dma);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100167};
168
Martyn Welchc813f592009-10-29 16:34:54 +0000169void vme_irq_handler(struct vme_bridge *, int, int);
170
Martyn Welchead1f3e2009-12-15 08:43:02 +0000171int vme_register_bridge(struct vme_bridge *);
172void vme_unregister_bridge(struct vme_bridge *);
Martyn Welcha17a75e2009-07-31 09:28:17 +0100173
174#endif /* _VME_BRIDGE_H_ */