Blame view

drivers/vme/vme_bridge.h 5.08 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
a17a75e26   Martyn Welch   Staging: VME Fram...
2
3
  #ifndef _VME_BRIDGE_H_
  #define _VME_BRIDGE_H_
ad1bfe410   Dmitry Kalinkin   vme: 8-bit status...
4
  #include <linux/vme.h>
a17a75e26   Martyn Welch   Staging: VME Fram...
5
  #define VME_CRCSR_BUF_SIZE (508*1024)
a17a75e26   Martyn Welch   Staging: VME Fram...
6
7
8
9
10
11
12
13
  /*
   * Resource structures
   */
  struct vme_master_resource {
  	struct list_head list;
  	struct vme_bridge *parent;
  	/*
  	 * We are likely to need to access the VME bus in interrupt context, so
400822fec   Martyn Welch   Staging: Use prop...
14
  	 * protect master routines with a spinlock rather than a mutex.
a17a75e26   Martyn Welch   Staging: VME Fram...
15
16
17
18
  	 */
  	spinlock_t lock;
  	int locked;
  	int number;
6af04b065   Martyn Welch   Staging: VME: Rem...
19
20
21
  	u32 address_attr;
  	u32 cycle_attr;
  	u32 width_attr;
8fafb4763   Martyn Welch   Staging: vme: Mak...
22
  	struct resource bus_resource;
059972679   Emilio G. Cota   staging: vme: mar...
23
  	void __iomem *kern_base;
a17a75e26   Martyn Welch   Staging: VME Fram...
24
25
26
27
28
  };
  
  struct vme_slave_resource {
  	struct list_head list;
  	struct vme_bridge *parent;
400822fec   Martyn Welch   Staging: Use prop...
29
  	struct mutex mtx;
a17a75e26   Martyn Welch   Staging: VME Fram...
30
31
  	int locked;
  	int number;
6af04b065   Martyn Welch   Staging: VME: Rem...
32
33
  	u32 address_attr;
  	u32 cycle_attr;
a17a75e26   Martyn Welch   Staging: VME Fram...
34
35
36
37
  };
  
  struct vme_dma_pattern {
  	u32 pattern;
6af04b065   Martyn Welch   Staging: VME: Rem...
38
  	u32 type;
a17a75e26   Martyn Welch   Staging: VME Fram...
39
40
41
42
43
44
45
46
  };
  
  struct vme_dma_pci {
  	dma_addr_t address;
  };
  
  struct vme_dma_vme {
  	unsigned long long address;
6af04b065   Martyn Welch   Staging: VME: Rem...
47
48
49
  	u32 aspace;
  	u32 cycle;
  	u32 dwidth;
a17a75e26   Martyn Welch   Staging: VME Fram...
50
51
52
53
54
55
  };
  
  struct vme_dma_list {
  	struct list_head list;
  	struct vme_dma_resource *parent;
  	struct list_head entries;
400822fec   Martyn Welch   Staging: Use prop...
56
  	struct mutex mtx;
a17a75e26   Martyn Welch   Staging: VME Fram...
57
58
59
60
61
  };
  
  struct vme_dma_resource {
  	struct list_head list;
  	struct vme_bridge *parent;
400822fec   Martyn Welch   Staging: Use prop...
62
  	struct mutex mtx;
a17a75e26   Martyn Welch   Staging: VME Fram...
63
64
65
66
  	int locked;
  	int number;
  	struct list_head pending;
  	struct list_head running;
6af04b065   Martyn Welch   Staging: VME: Rem...
67
  	u32 route_attr;
a17a75e26   Martyn Welch   Staging: VME Fram...
68
  };
42fb50312   Martyn Welch   Staging: vme: add...
69
70
71
72
73
74
75
76
  struct vme_lm_resource {
  	struct list_head list;
  	struct vme_bridge *parent;
  	struct mutex mtx;
  	int locked;
  	int number;
  	int monitors;
  };
0b0496625   Dmitry Kalinkin   vme: change bus e...
77
  struct vme_error_handler {
a17a75e26   Martyn Welch   Staging: VME Fram...
78
  	struct list_head list;
0b0496625   Dmitry Kalinkin   vme: change bus e...
79
80
81
82
83
  	unsigned long long start;	/* Beginning of error window */
  	unsigned long long end;		/* End of error window */
  	unsigned long long first_error;	/* Address of the first error */
  	u32 aspace;			/* Address space of error window*/
  	unsigned num_errors;		/* Number of errors */
a17a75e26   Martyn Welch   Staging: VME Fram...
84
85
86
87
88
89
90
91
92
  };
  
  struct vme_callback {
  	void (*func)(int, int, void*);
  	void *priv_data;
  };
  
  struct vme_irq {
  	int count;
ad1bfe410   Dmitry Kalinkin   vme: 8-bit status...
93
  	struct vme_callback callback[VME_NUM_STATUSID];
a17a75e26   Martyn Welch   Staging: VME Fram...
94
95
96
97
98
99
100
101
  };
  
  /* Allow 16 characters for name (including null character) */
  #define VMENAMSIZ 16
  
  /* This structure stores all the information about one bridge
   * The structure should be dynamically allocated by the driver and one instance
   * of the structure should be present for each VME chip present in the system.
a17a75e26   Martyn Welch   Staging: VME Fram...
102
103
   */
  struct vme_bridge {
ead1f3e30   Martyn Welch   Staging: vme: Fix...
104
  	char name[VMENAMSIZ];
a17a75e26   Martyn Welch   Staging: VME Fram...
105
106
107
108
  	int num;
  	struct list_head master_resources;
  	struct list_head slave_resources;
  	struct list_head dma_resources;
42fb50312   Martyn Welch   Staging: vme: add...
109
  	struct list_head lm_resources;
a17a75e26   Martyn Welch   Staging: VME Fram...
110

0b0496625   Dmitry Kalinkin   vme: change bus e...
111
112
113
114
  	/* List for registered errors handlers */
  	struct list_head vme_error_handlers;
  	/* List of devices on this bridge */
  	struct list_head devices;
a17a75e26   Martyn Welch   Staging: VME Fram...
115
116
  
  	/* Bridge Info - XXX Move to private structure? */
7f58f0255   Manohar Vanga   staging: vme: mak...
117
  	struct device *parent;	/* Parent device (eg. pdev->dev for PCI) */
29848ac9f   Martyn Welch   Staging: vme: Ena...
118
  	void *driver_priv;	/* Private pointer for the bridge driver */
733e3ef0d   Manohar Vanga   staging: vme: kee...
119
  	struct list_head bus_list; /* list of VME buses */
a17a75e26   Martyn Welch   Staging: VME Fram...
120

a17a75e26   Martyn Welch   Staging: VME Fram...
121
122
  	/* Interrupt callbacks */
  	struct vme_irq irq[7];
c813f592a   Martyn Welch   Staging: vme: Pul...
123
124
  	/* Locking for VME irq callback configuration */
  	struct mutex irq_mtx;
a17a75e26   Martyn Welch   Staging: VME Fram...
125
126
127
128
  
  	/* Slave Functions */
  	int (*slave_get) (struct vme_slave_resource *, int *,
  		unsigned long long *, unsigned long long *, dma_addr_t *,
6af04b065   Martyn Welch   Staging: VME: Rem...
129
  		u32 *, u32 *);
a17a75e26   Martyn Welch   Staging: VME Fram...
130
  	int (*slave_set) (struct vme_slave_resource *, int, unsigned long long,
6af04b065   Martyn Welch   Staging: VME: Rem...
131
  		unsigned long long, dma_addr_t, u32, u32);
a17a75e26   Martyn Welch   Staging: VME Fram...
132
133
134
  
  	/* Master Functions */
  	int (*master_get) (struct vme_master_resource *, int *,
6af04b065   Martyn Welch   Staging: VME: Rem...
135
136
  		unsigned long long *, unsigned long long *, u32 *, u32 *,
  		u32 *);
a17a75e26   Martyn Welch   Staging: VME Fram...
137
  	int (*master_set) (struct vme_master_resource *, int,
6af04b065   Martyn Welch   Staging: VME: Rem...
138
  		unsigned long long, unsigned long long,  u32, u32, u32);
a17a75e26   Martyn Welch   Staging: VME Fram...
139
140
141
142
143
144
145
146
147
148
149
150
151
152
  	ssize_t (*master_read) (struct vme_master_resource *, void *, size_t,
  		loff_t);
  	ssize_t (*master_write) (struct vme_master_resource *, void *, size_t,
  		loff_t);
  	unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int,
  		unsigned int, unsigned int, loff_t);
  
  	/* DMA Functions */
  	int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *,
  		struct vme_dma_attr *, size_t);
  	int (*dma_list_exec) (struct vme_dma_list *);
  	int (*dma_list_empty) (struct vme_dma_list *);
  
  	/* Interrupt Functions */
29848ac9f   Martyn Welch   Staging: vme: Ena...
153
154
  	void (*irq_set) (struct vme_bridge *, int, int, int);
  	int (*irq_generate) (struct vme_bridge *, int, int);
a17a75e26   Martyn Welch   Staging: VME Fram...
155
156
  
  	/* Location monitor functions */
6af04b065   Martyn Welch   Staging: VME: Rem...
157
158
159
  	int (*lm_set) (struct vme_lm_resource *, unsigned long long, u32, u32);
  	int (*lm_get) (struct vme_lm_resource *, unsigned long long *, u32 *,
  		u32 *);
fa54b3268   Aaron Sierra   vme: change LM ca...
160
161
  	int (*lm_attach)(struct vme_lm_resource *, int,
  			 void (*callback)(void *), void *);
42fb50312   Martyn Welch   Staging: vme: add...
162
  	int (*lm_detach) (struct vme_lm_resource *, int);
a17a75e26   Martyn Welch   Staging: VME Fram...
163
164
  
  	/* CR/CSR space functions */
29848ac9f   Martyn Welch   Staging: vme: Ena...
165
  	int (*slot_get) (struct vme_bridge *);
7f58f0255   Manohar Vanga   staging: vme: mak...
166
167
168
169
170
171
  
  	/* Bridge parent interface */
  	void *(*alloc_consistent)(struct device *dev, size_t size,
  		dma_addr_t *dma);
  	void (*free_consistent)(struct device *dev, size_t size,
  		void *vaddr, dma_addr_t dma);
a17a75e26   Martyn Welch   Staging: VME Fram...
172
  };
e2c6393fd   Dmitry Kalinkin   vme: move tsi148 ...
173
  void vme_bus_error_handler(struct vme_bridge *bridge,
472f16f33   Dmitry Kalinkin   vme: include addr...
174
  			   unsigned long long address, int am);
c813f592a   Martyn Welch   Staging: vme: Pul...
175
  void vme_irq_handler(struct vme_bridge *, int, int);
326071b3c   Aaron Sierra   vme: add vme_init...
176
  struct vme_bridge *vme_init_bridge(struct vme_bridge *);
ead1f3e30   Martyn Welch   Staging: vme: Fix...
177
178
  int vme_register_bridge(struct vme_bridge *);
  void vme_unregister_bridge(struct vme_bridge *);
0b0496625   Dmitry Kalinkin   vme: change bus e...
179
180
181
182
  struct vme_error_handler *vme_register_error_handler(
  	struct vme_bridge *bridge, u32 aspace,
  	unsigned long long address, size_t len);
  void vme_unregister_error_handler(struct vme_error_handler *handler);
a17a75e26   Martyn Welch   Staging: VME Fram...
183
184
  
  #endif /* _VME_BRIDGE_H_ */