Blame view

include/linux/rio.h 19.2 KB
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  /*
   * RapidIO interconnect services
   * (RapidIO Interconnect Specification, http://www.rapidio.org)
   *
   * Copyright 2005 MontaVista Software, Inc.
   * Matt Porter <mporter@kernel.crashing.org>
   *
   * This program is free software; you can redistribute  it and/or modify it
   * under  the terms of  the GNU General  Public License as published by the
   * Free Software Foundation;  either version 2 of the  License, or (at your
   * option) any later version.
   */
  
  #ifndef LINUX_RIO_H
  #define LINUX_RIO_H
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
16
  #include <linux/types.h>
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
17
18
19
20
21
  #include <linux/ioport.h>
  #include <linux/list.h>
  #include <linux/errno.h>
  #include <linux/device.h>
  #include <linux/rio_regs.h>
3bdbb62fe   Alexandre Bounine   rapidio: add udev...
22
  #include <linux/mod_devicetable.h>
e42d98ebe   Alexandre Bounine   rapidio: add DMA ...
23
24
25
  #ifdef CONFIG_RAPIDIO_DMA_ENGINE
  #include <linux/dmaengine.h>
  #endif
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
26

70a50ebd9   Matt Porter   [PATCH] RapidIO s...
27
  #define RIO_NO_HOPCOUNT		-1
c70555b05   Alexandre Bounine   [PATCH] rapidio: ...
28
  #define RIO_INVALID_DESTID	0xffff
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
29

569fccb6b   Alexandre Bounine   rapidio: modify m...
30
  #define RIO_MAX_MPORTS		8
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
31
32
  #define RIO_MAX_MPORT_RESOURCES	16
  #define RIO_MAX_DEV_RESOURCES	16
ed43f44f8   Alexandre Bounine   rapidio/tsi721: m...
33
  #define RIO_MAX_MPORT_NAME	40
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
34
35
36
37
38
39
40
41
42
  
  #define RIO_GLOBAL_TABLE	0xff	/* Indicates access of a switch's
  					   global routing table if it
  					   has multiple (or per port)
  					   tables */
  
  #define RIO_INVALID_ROUTE	0xff	/* Indicates that a route table
  					   entry is invalid (no route
  					   exists for the device ID) */
e04232360   Zhang Wei   [RAPIDIO] Auto-pr...
43
44
  #define RIO_MAX_ROUTE_ENTRIES(size)	(size ? (1 << 16) : (1 << 8))
  #define RIO_ANY_DESTID(size)		(size ? 0xffff : 0xff)
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  
  #define RIO_MAX_MBOX		4
  #define RIO_MAX_MSG_SIZE	0x1000
  
  /*
   * Error values that may be returned by RIO functions.
   */
  #define RIO_SUCCESSFUL			0x00
  #define RIO_BAD_SIZE			0x81
  
  /*
   * For RIO devices, the region numbers are assigned this way:
   *
   *	0	RapidIO outbound doorbells
   *      1-15	RapidIO memory regions
   *
   * For RIO master ports, the region number are assigned this way:
   *
   *	0	RapidIO inbound doorbells
   *	1	RapidIO inbound mailboxes
fdb8d561e   Chad Reese   rapidio: fix comment
65
   *	2	RapidIO outbound mailboxes
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
66
67
68
69
   */
  #define RIO_DOORBELL_RESOURCE	0
  #define RIO_INB_MBOX_RESOURCE	1
  #define RIO_OUTB_MBOX_RESOURCE	2
e5cabeb3d   Alexandre Bounine   rapidio: add Port...
70
  #define RIO_PW_MSG_SIZE		64
e6536927e   Alexandre Bounine   rapidio: add defi...
71
72
73
74
75
76
77
78
79
  /*
   * A component tag value (stored in the component tag CSR) is used as device's
   * unique identifier assigned during enumeration. Besides being used for
   * identifying switches (which do not have device ID register), it also is used
   * by error management notification and therefore has to be assigned
   * to endpoints as well.
   */
  #define RIO_CTAG_RESRVD	0xfffe0000 /* Reserved */
  #define RIO_CTAG_UDEVID	0x0001ffff /* Unique device identifier */
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
80
  extern struct bus_type rio_bus_type;
2aaf308b9   Alexandre Bounine   rapidio: rework d...
81
  extern struct class rio_mport_class;
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
82
83
  
  struct rio_mport;
ded057827   Alexandre Bounine   rapidio: integrat...
84
  struct rio_dev;
e5cabeb3d   Alexandre Bounine   rapidio: add Port...
85
  union rio_pw_msg;
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
86
87
  
  /**
ded057827   Alexandre Bounine   rapidio: integrat...
88
89
   * struct rio_switch - RIO switch info
   * @node: Node in global list of switches
ded057827   Alexandre Bounine   rapidio: integrat...
90
91
   * @route_table: Copy of switch routing table
   * @port_ok: Status of each port (one bit per port) - OK=1 or UNINIT=0
2ec3ba69f   Alexandre Bounine   rapidio: convert ...
92
93
94
95
96
97
   * @ops: pointer to switch-specific operations
   * @lock: lock to serialize operations updates
   * @nextdev: Array of per-port pointers to the next attached device
   */
  struct rio_switch {
  	struct list_head node;
2ec3ba69f   Alexandre Bounine   rapidio: convert ...
98
99
100
101
102
103
104
105
106
107
  	u8 *route_table;
  	u32 port_ok;
  	struct rio_switch_ops *ops;
  	spinlock_t lock;
  	struct rio_dev *nextdev[0];
  };
  
  /**
   * struct rio_switch_ops - Per-switch operations
   * @owner: The module owner of this structure
ded057827   Alexandre Bounine   rapidio: integrat...
108
109
110
111
112
113
114
   * @add_entry: Callback for switch-specific route add function
   * @get_entry: Callback for switch-specific route get function
   * @clr_table: Callback for switch-specific clear route table function
   * @set_domain: Callback for switch-specific domain setting function
   * @get_domain: Callback for switch-specific domain get function
   * @em_init: Callback for switch-specific error management init function
   * @em_handle: Callback for switch-specific error management handler function
2ec3ba69f   Alexandre Bounine   rapidio: convert ...
115
116
117
   *
   * Defines the operations that are necessary to initialize/control
   * a particular RIO switch device.
ded057827   Alexandre Bounine   rapidio: integrat...
118
   */
2ec3ba69f   Alexandre Bounine   rapidio: convert ...
119
120
  struct rio_switch_ops {
  	struct module *owner;
ded057827   Alexandre Bounine   rapidio: integrat...
121
122
123
124
125
126
127
128
129
130
131
132
  	int (*add_entry) (struct rio_mport *mport, u16 destid, u8 hopcount,
  			  u16 table, u16 route_destid, u8 route_port);
  	int (*get_entry) (struct rio_mport *mport, u16 destid, u8 hopcount,
  			  u16 table, u16 route_destid, u8 *route_port);
  	int (*clr_table) (struct rio_mport *mport, u16 destid, u8 hopcount,
  			  u16 table);
  	int (*set_domain) (struct rio_mport *mport, u16 destid, u8 hopcount,
  			   u8 sw_domain);
  	int (*get_domain) (struct rio_mport *mport, u16 destid, u8 hopcount,
  			   u8 *sw_domain);
  	int (*em_init) (struct rio_dev *dev);
  	int (*em_handle) (struct rio_dev *dev, u8 swport);
ded057827   Alexandre Bounine   rapidio: integrat...
133
  };
b77a2030d   Alexandre Bounine   rapidio: add core...
134
135
136
137
138
139
  enum rio_device_state {
  	RIO_DEVICE_INITIALIZING,
  	RIO_DEVICE_RUNNING,
  	RIO_DEVICE_GONE,
  	RIO_DEVICE_SHUTDOWN,
  };
ded057827   Alexandre Bounine   rapidio: integrat...
140
  /**
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
141
142
143
144
   * struct rio_dev - RIO device info
   * @global_list: Node in list of all RIO devices
   * @net_list: Node in list of RIO devices in a network
   * @net: Network this device is a part of
2ec3ba69f   Alexandre Bounine   rapidio: convert ...
145
   * @do_enum: Enumeration flag
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
146
147
148
149
150
151
152
153
154
155
156
   * @did: Device ID
   * @vid: Vendor ID
   * @device_rev: Device revision
   * @asm_did: Assembly device ID
   * @asm_vid: Assembly vendor ID
   * @asm_rev: Assembly revision
   * @efptr: Extended feature pointer
   * @pef: Processing element features
   * @swpinfo: Switch port info
   * @src_ops: Source operation capabilities
   * @dst_ops: Destination operation capabilities
97ef6f744   Randy Dunlap   rapidio: fix new ...
157
158
   * @comp_tag: RIO component tag
   * @phys_efptr: RIO device extended features pointer
1ae842de1   Alexandre Bounine   rapidio: modify f...
159
   * @phys_rmap: LP-Serial Register Map Type (1 or 2)
97ef6f744   Randy Dunlap   rapidio: fix new ...
160
   * @em_efptr: RIO Error Management features pointer
fa78cc517   Matt Porter   [PATCH] rapidio: ...
161
   * @dma_mask: Mask of bits of RIO address this device implements
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
162
163
164
   * @driver: Driver claiming this device
   * @dev: Device model device
   * @riores: RIO resources this device owns
97ef6f744   Randy Dunlap   rapidio: fix new ...
165
   * @pwcback: port-write callback function for this device
a93192a5d   Alexandre Bounine   rapidio: use comm...
166
167
   * @destid: Network destination ID (or associated destid for switch)
   * @hopcount: Hopcount to this device
68fe4df5d   Alexandre Bounine   rapidio: add rela...
168
   * @prev: Previous RIO device connected to the current one
b77a2030d   Alexandre Bounine   rapidio: add core...
169
   * @state: device state
ded057827   Alexandre Bounine   rapidio: integrat...
170
   * @rswitch: struct rio_switch (if valid for this device)
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
171
172
173
174
175
   */
  struct rio_dev {
  	struct list_head global_list;	/* node in list of all RIO devices */
  	struct list_head net_list;	/* node in per net list */
  	struct rio_net *net;	/* RIO net this device resides in */
2ec3ba69f   Alexandre Bounine   rapidio: convert ...
176
  	bool do_enum;
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
177
178
179
180
181
182
183
184
  	u16 did;
  	u16 vid;
  	u32 device_rev;
  	u16 asm_did;
  	u16 asm_vid;
  	u16 asm_rev;
  	u16 efptr;
  	u32 pef;
ae05cbd5a   Alexandre Bounine   rapidio: use stor...
185
  	u32 swpinfo;
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
186
187
  	u32 src_ops;
  	u32 dst_ops;
e5cabeb3d   Alexandre Bounine   rapidio: add Port...
188
189
  	u32 comp_tag;
  	u32 phys_efptr;
1ae842de1   Alexandre Bounine   rapidio: modify f...
190
  	u32 phys_rmap;
e5cabeb3d   Alexandre Bounine   rapidio: add Port...
191
  	u32 em_efptr;
fa78cc517   Matt Porter   [PATCH] rapidio: ...
192
  	u64 dma_mask;
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
193
194
195
  	struct rio_driver *driver;	/* RIO driver claiming this device */
  	struct device dev;	/* LDM device structure */
  	struct resource riores[RIO_MAX_DEV_RESOURCES];
e5cabeb3d   Alexandre Bounine   rapidio: add Port...
196
  	int (*pwcback) (struct rio_dev *rdev, union rio_pw_msg *msg, int step);
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
197
  	u16 destid;
a93192a5d   Alexandre Bounine   rapidio: use comm...
198
  	u8 hopcount;
68fe4df5d   Alexandre Bounine   rapidio: add rela...
199
  	struct rio_dev *prev;
b77a2030d   Alexandre Bounine   rapidio: add core...
200
  	atomic_t state;
ded057827   Alexandre Bounine   rapidio: integrat...
201
  	struct rio_switch rswitch[0];	/* RIO switch info */
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
202
203
204
205
206
  };
  
  #define rio_dev_g(n) list_entry(n, struct rio_dev, global_list)
  #define rio_dev_f(n) list_entry(n, struct rio_dev, net_list)
  #define	to_rio_dev(n) container_of(n, struct rio_dev, dev)
ded057827   Alexandre Bounine   rapidio: integrat...
207
  #define sw_to_rio_dev(n) container_of(n, struct rio_dev, rswitch[0])
2aaf308b9   Alexandre Bounine   rapidio: rework d...
208
  #define	to_rio_mport(n) container_of(n, struct rio_mport, dev)
e6b585ca6   Alexandre Bounine   rapidio: move net...
209
  #define	to_rio_net(n) container_of(n, struct rio_net, dev)
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
210
211
212
213
214
215
216
217
  
  /**
   * struct rio_msg - RIO message event
   * @res: Mailbox resource
   * @mcback: Message event callback
   */
  struct rio_msg {
  	struct resource *res;
6978bbc09   Matt Porter   [PATCH] rapidio: ...
218
  	void (*mcback) (struct rio_mport * mport, void *dev_id, int mbox, int slot);
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
219
220
221
222
223
224
225
  };
  
  /**
   * struct rio_dbell - RIO doorbell event
   * @node: Node in list of doorbell events
   * @res: Doorbell resource
   * @dinb: Doorbell event callback
6978bbc09   Matt Porter   [PATCH] rapidio: ...
226
   * @dev_id: Device specific pointer to pass on event
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
227
228
229
230
   */
  struct rio_dbell {
  	struct list_head node;
  	struct resource *res;
6978bbc09   Matt Porter   [PATCH] rapidio: ...
231
232
  	void (*dinb) (struct rio_mport *mport, void *dev_id, u16 src, u16 dst, u16 info);
  	void *dev_id;
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
233
234
235
236
237
  };
  
  /**
   * struct rio_mport - RIO master port info
   * @dbells: List of doorbell events
9a0b06274   Alexandre Bounine   rapidio: add glob...
238
   * @pwrites: List of portwrite events
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
239
240
   * @node: Node in global list of master ports
   * @nnode: Node in network list of master ports
e6b585ca6   Alexandre Bounine   rapidio: move net...
241
   * @net: RIO net this mport is attached to
a7b4c636d   Alexandre Bounine   rapidio: add lock...
242
   * @lock: lock to synchronize lists manipulations
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
243
244
245
246
247
248
249
250
   * @iores: I/O mem resource that this master port interface owns
   * @riores: RIO resources that this master port interfaces owns
   * @inb_msg: RIO inbound message event descriptors
   * @outb_msg: RIO outbound message event descriptors
   * @host_deviceid: Host device ID associated with this master port
   * @ops: configuration space functions
   * @id: Port ID, unique among all ports
   * @index: Port index, unique among all port interfaces of the same type
9941d945f   Randy Dunlap   [RAPIDIO] fix cur...
251
   * @sys_size: RapidIO common transport system size
af84ca38a   Alexandre Bounine   rapidio: add hand...
252
   * @phys_efptr: RIO port extended features pointer
1ae842de1   Alexandre Bounine   rapidio: modify f...
253
   * @phys_rmap: LP-Serial EFB Register Mapping type (1 or 2).
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
254
   * @name: Port name string
2aaf308b9   Alexandre Bounine   rapidio: rework d...
255
   * @dev: device structure associated with an mport
ad1e9380b   Zhang Wei   [RAPIDIO] Add Rap...
256
   * @priv: Master port private data
fe50c927d   Alexandre Bounine   rapidio: fix kern...
257
   * @dma: DMA device associated with mport
a11650e11   Alexandre Bounine   rapidio: make enu...
258
   * @nscan: RapidIO network enumeration/discovery operations
b77a2030d   Alexandre Bounine   rapidio: add core...
259
   * @state: mport device state
b6cb95e8e   Alexandre Bounine   rapidio: move rio...
260
   * @pwe_refcnt: port-write enable ref counter to track enable/disable requests
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
261
262
263
   */
  struct rio_mport {
  	struct list_head dbells;	/* list of doorbell events */
9a0b06274   Alexandre Bounine   rapidio: add glob...
264
  	struct list_head pwrites;	/* list of portwrite events */
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
265
266
  	struct list_head node;	/* node in global list of ports */
  	struct list_head nnode;	/* node in net list of ports */
e6b585ca6   Alexandre Bounine   rapidio: move net...
267
  	struct rio_net *net;	/* RIO net this mport is attached to */
a7b4c636d   Alexandre Bounine   rapidio: add lock...
268
  	struct mutex lock;
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
269
270
271
272
273
  	struct resource iores;
  	struct resource riores[RIO_MAX_MPORT_RESOURCES];
  	struct rio_msg inb_msg[RIO_MAX_MBOX];
  	struct rio_msg outb_msg[RIO_MAX_MBOX];
  	int host_deviceid;	/* Host device ID */
f8f062698   Alexandre Bounine   rapidio: add arch...
274
  	struct rio_ops *ops;	/* low-level architecture-dependent routines */
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
275
276
277
  	unsigned char id;	/* port ID, unique among all ports */
  	unsigned char index;	/* port index, unique among all port
  				   interfaces of the same type */
e04232360   Zhang Wei   [RAPIDIO] Auto-pr...
278
279
280
281
  	unsigned int sys_size;	/* RapidIO common transport system size.
  				 * 0 - Small size. 256 devices.
  				 * 1 - Large size, 65536 devices.
  				 */
af84ca38a   Alexandre Bounine   rapidio: add hand...
282
  	u32 phys_efptr;
1ae842de1   Alexandre Bounine   rapidio: modify f...
283
  	u32 phys_rmap;
ed43f44f8   Alexandre Bounine   rapidio/tsi721: m...
284
  	unsigned char name[RIO_MAX_MPORT_NAME];
2aaf308b9   Alexandre Bounine   rapidio: rework d...
285
  	struct device dev;
ad1e9380b   Zhang Wei   [RAPIDIO] Add Rap...
286
  	void *priv;		/* Master port private data */
e42d98ebe   Alexandre Bounine   rapidio: add DMA ...
287
288
289
  #ifdef CONFIG_RAPIDIO_DMA_ENGINE
  	struct dma_device	dma;
  #endif
a11650e11   Alexandre Bounine   rapidio: make enu...
290
  	struct rio_scan *nscan;
b77a2030d   Alexandre Bounine   rapidio: add core...
291
  	atomic_t state;
b6cb95e8e   Alexandre Bounine   rapidio: move rio...
292
  	unsigned int pwe_refcnt;
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
293
  };
b77a2030d   Alexandre Bounine   rapidio: add core...
294
295
296
297
  static inline int rio_mport_is_running(struct rio_mport *mport)
  {
  	return atomic_read(&mport->state) == RIO_DEVICE_RUNNING;
  }
bc8fcfea1   Alexandre Bounine   rapidio: add enum...
298
299
300
301
  /*
   * Enumeration/discovery control flags
   */
  #define RIO_SCAN_ENUM_NO_WAIT	0x00000001 /* Do not wait for enum completed */
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
302
303
304
305
  /**
   * struct rio_net - RIO network info
   * @node: Node in global list of RIO networks
   * @devices: List of devices in this network
766792860   Masanari Iida   rapidio: Fix kern...
306
   * @switches: List of switches in this network
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
307
308
309
   * @mports: List of master ports accessing this network
   * @hport: Default port for accessing this network
   * @id: RIO network ID
e6b585ca6   Alexandre Bounine   rapidio: move net...
310
311
312
   * @dev: Device object
   * @enum_data: private data specific to a network enumerator
   * @release: enumerator-specific release callback
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
313
314
315
316
   */
  struct rio_net {
  	struct list_head node;	/* node in list of networks */
  	struct list_head devices;	/* list of devices in this net */
a7071efc2   Alexandre Bounine   rapidio: use devi...
317
  	struct list_head switches;	/* list of switches in this net */
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
318
319
320
  	struct list_head mports;	/* list of ports accessing net */
  	struct rio_mport *hport;	/* primary port for accessing net */
  	unsigned char id;	/* RIO network ID */
e6b585ca6   Alexandre Bounine   rapidio: move net...
321
322
323
  	struct device dev;
  	void *enum_data;	/* private data for enumerator of the network */
  	void (*release)(struct rio_net *net);
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
324
  };
8b189fdbc   Alexandre Bounine   rapidio: add quer...
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
  enum rio_link_speed {
  	RIO_LINK_DOWN = 0, /* SRIO Link not initialized */
  	RIO_LINK_125 = 1, /* 1.25 GBaud  */
  	RIO_LINK_250 = 2, /* 2.5 GBaud   */
  	RIO_LINK_312 = 3, /* 3.125 GBaud */
  	RIO_LINK_500 = 4, /* 5.0 GBaud   */
  	RIO_LINK_625 = 5  /* 6.25 GBaud  */
  };
  
  enum rio_link_width {
  	RIO_LINK_1X  = 0,
  	RIO_LINK_1XR = 1,
  	RIO_LINK_2X  = 3,
  	RIO_LINK_4X  = 2,
  	RIO_LINK_8X  = 4,
  	RIO_LINK_16X = 5
  };
  
  enum rio_mport_flags {
  	RIO_MPORT_DMA	 = (1 << 0), /* supports DMA data transfers */
  	RIO_MPORT_DMA_SG = (1 << 1), /* DMA supports HW SG mode */
  	RIO_MPORT_IBSG	 = (1 << 2), /* inbound mapping supports SG */
  };
  
  /**
   * struct rio_mport_attr - RIO mport device attributes
   * @flags: mport device capability flags
   * @link_speed: SRIO link speed value (as defined by RapidIO specification)
   * @link_width:	SRIO link width value (as defined by RapidIO specification)
   * @dma_max_sge: number of SG list entries that can be handled by DMA channel(s)
   * @dma_max_size: max number of bytes in single DMA transfer (SG entry)
   * @dma_align: alignment shift for DMA operations (as for other DMA operations)
   */
  struct rio_mport_attr {
  	int flags;
  	int link_speed;
  	int link_width;
  
  	/* DMA capability info: valid only if RIO_MPORT_DMA flag is set */
  	int dma_max_sge;
  	int dma_max_size;
  	int dma_align;
  };
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
368
369
370
371
372
373
374
375
376
  /* Low-level architecture-dependent routines */
  
  /**
   * struct rio_ops - Low-level RIO configuration space operations
   * @lcread: Callback to perform local (master port) read of config space.
   * @lcwrite: Callback to perform local (master port) write of config space.
   * @cread: Callback to perform network read of config space.
   * @cwrite: Callback to perform network write of config space.
   * @dsend: Callback to send a doorbell message.
e5cabeb3d   Alexandre Bounine   rapidio: add Port...
377
   * @pwenable: Callback to enable/disable port-write message handling.
f8f062698   Alexandre Bounine   rapidio: add arch...
378
379
380
381
382
383
384
   * @open_outb_mbox: Callback to initialize outbound mailbox.
   * @close_outb_mbox: Callback to shut down outbound mailbox.
   * @open_inb_mbox: Callback to initialize inbound mailbox.
   * @close_inb_mbox: Callback to	shut down inbound mailbox.
   * @add_outb_message: Callback to add a message to an outbound mailbox queue.
   * @add_inb_buffer: Callback to	add a buffer to an inbound mailbox queue.
   * @get_inb_message: Callback to get a message from an inbound mailbox queue.
da1589f07   Alexandre Bounine   rapidio: add inbo...
385
386
   * @map_inb: Callback to map RapidIO address region into local memory space.
   * @unmap_inb: Callback to unmap RapidIO address region mapped with map_inb().
8b189fdbc   Alexandre Bounine   rapidio: add quer...
387
   * @query_mport: Callback to query mport device attributes.
93bdaca50   Alexandre Bounine   rapidio: add outb...
388
389
   * @map_outb: Callback to map outbound address region into local memory space.
   * @unmap_outb: Callback to unmap outbound RapidIO address region.
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
390
391
   */
  struct rio_ops {
ad1e9380b   Zhang Wei   [RAPIDIO] Add Rap...
392
393
394
395
396
397
398
399
400
  	int (*lcread) (struct rio_mport *mport, int index, u32 offset, int len,
  			u32 *data);
  	int (*lcwrite) (struct rio_mport *mport, int index, u32 offset, int len,
  			u32 data);
  	int (*cread) (struct rio_mport *mport, int index, u16 destid,
  			u8 hopcount, u32 offset, int len, u32 *data);
  	int (*cwrite) (struct rio_mport *mport, int index, u16 destid,
  			u8 hopcount, u32 offset, int len, u32 data);
  	int (*dsend) (struct rio_mport *mport, int index, u16 destid, u16 data);
e5cabeb3d   Alexandre Bounine   rapidio: add Port...
401
  	int (*pwenable) (struct rio_mport *mport, int enable);
f8f062698   Alexandre Bounine   rapidio: add arch...
402
403
404
405
406
407
408
409
410
411
  	int (*open_outb_mbox)(struct rio_mport *mport, void *dev_id,
  			      int mbox, int entries);
  	void (*close_outb_mbox)(struct rio_mport *mport, int mbox);
  	int  (*open_inb_mbox)(struct rio_mport *mport, void *dev_id,
  			     int mbox, int entries);
  	void (*close_inb_mbox)(struct rio_mport *mport, int mbox);
  	int  (*add_outb_message)(struct rio_mport *mport, struct rio_dev *rdev,
  				 int mbox, void *buffer, size_t len);
  	int (*add_inb_buffer)(struct rio_mport *mport, int mbox, void *buf);
  	void *(*get_inb_message)(struct rio_mport *mport, int mbox);
da1589f07   Alexandre Bounine   rapidio: add inbo...
412
  	int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
a057a52e9   Alexandre Bounine   rapidio: change i...
413
  			u64 rstart, u64 size, u32 flags);
da1589f07   Alexandre Bounine   rapidio: add inbo...
414
  	void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
8b189fdbc   Alexandre Bounine   rapidio: add quer...
415
416
  	int (*query_mport)(struct rio_mport *mport,
  			   struct rio_mport_attr *attr);
93bdaca50   Alexandre Bounine   rapidio: add outb...
417
418
419
  	int (*map_outb)(struct rio_mport *mport, u16 destid, u64 rstart,
  			u32 size, u32 flags, dma_addr_t *laddr);
  	void (*unmap_outb)(struct rio_mport *mport, u16 destid, u64 rstart);
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
  };
  
  #define RIO_RESOURCE_MEM	0x00000100
  #define RIO_RESOURCE_DOORBELL	0x00000200
  #define RIO_RESOURCE_MAILBOX	0x00000400
  
  #define RIO_RESOURCE_CACHEABLE	0x00010000
  #define RIO_RESOURCE_PCI	0x00020000
  
  #define RIO_RESOURCE_BUSY	0x80000000
  
  /**
   * struct rio_driver - RIO driver info
   * @node: Node in list of drivers
   * @name: RIO driver name
   * @id_table: RIO device ids to be associated with this driver
   * @probe: RIO device inserted
   * @remove: RIO device removed
83dc2cbc1   Alexandre Bounine   rapidio: add shut...
438
   * @shutdown: shutdown notification callback
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
439
440
441
442
443
444
445
446
447
448
449
450
451
452
   * @suspend: RIO device suspended
   * @resume: RIO device awakened
   * @enable_wake: RIO device enable wake event
   * @driver: LDM driver struct
   *
   * Provides info on a RIO device driver for insertion/removal and
   * power management purposes.
   */
  struct rio_driver {
  	struct list_head node;
  	char *name;
  	const struct rio_device_id *id_table;
  	int (*probe) (struct rio_dev * dev, const struct rio_device_id * id);
  	void (*remove) (struct rio_dev * dev);
83dc2cbc1   Alexandre Bounine   rapidio: add shut...
453
  	void (*shutdown)(struct rio_dev *dev);
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
454
455
456
457
458
459
460
  	int (*suspend) (struct rio_dev * dev, u32 state);
  	int (*resume) (struct rio_dev * dev);
  	int (*enable_wake) (struct rio_dev * dev, u32 state, int enable);
  	struct device_driver driver;
  };
  
  #define	to_rio_driver(drv) container_of(drv,struct rio_driver, driver)
e5cabeb3d   Alexandre Bounine   rapidio: add Port...
461
462
463
464
465
466
467
468
469
470
  union rio_pw_msg {
  	struct {
  		u32 comptag;	/* Component Tag CSR */
  		u32 errdetect;	/* Port N Error Detect CSR */
  		u32 is_port;	/* Implementation specific + PortID */
  		u32 ltlerrdet;	/* LTL Error Detect CSR */
  		u32 padding[12];
  	} em;
  	u32 raw[RIO_PW_MSG_SIZE/sizeof(u32)];
  };
e42d98ebe   Alexandre Bounine   rapidio: add DMA ...
471
  #ifdef CONFIG_RAPIDIO_DMA_ENGINE
fe50c927d   Alexandre Bounine   rapidio: fix kern...
472
  /*
e42d98ebe   Alexandre Bounine   rapidio: add DMA ...
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
   * enum rio_write_type - RIO write transaction types used in DMA transfers
   *
   * Note: RapidIO specification defines write (NWRITE) and
   * write-with-response (NWRITE_R) data transfer operations.
   * Existing DMA controllers that service RapidIO may use one of these operations
   * for entire data transfer or their combination with only the last data packet
   * requires response.
   */
  enum rio_write_type {
  	RDW_DEFAULT,		/* default method used by DMA driver */
  	RDW_ALL_NWRITE,		/* all packets use NWRITE */
  	RDW_ALL_NWRITE_R,	/* all packets use NWRITE_R */
  	RDW_LAST_NWRITE_R,	/* last packet uses NWRITE_R, others - NWRITE */
  };
  
  struct rio_dma_ext {
  	u16 destid;
  	u64 rio_addr;	/* low 64-bits of 66-bit RapidIO address */
  	u8  rio_addr_u;  /* upper 2-bits of 66-bit RapidIO address */
  	enum rio_write_type wr_type; /* preferred RIO write operation type */
  };
  
  struct rio_dma_data {
  	/* Local data (as scatterlist) */
  	struct scatterlist	*sg;	/* I/O scatter list */
  	unsigned int		sg_len;	/* size of scatter list */
  	/* Remote device address (flat buffer) */
  	u64 rio_addr;	/* low 64-bits of 66-bit RapidIO address */
  	u8  rio_addr_u;  /* upper 2-bits of 66-bit RapidIO address */
  	enum rio_write_type wr_type; /* preferred RIO write operation type */
  };
  
  static inline struct rio_mport *dma_to_mport(struct dma_device *ddev)
  {
  	return container_of(ddev, struct rio_mport, dma);
  }
  #endif /* CONFIG_RAPIDIO_DMA_ENGINE */
a11650e11   Alexandre Bounine   rapidio: make enu...
510
511
  /**
   * struct rio_scan - RIO enumeration and discovery operations
9edbc30b4   Alexandre Bounine   rapidio: update e...
512
   * @owner: The module owner of this structure
a11650e11   Alexandre Bounine   rapidio: make enu...
513
514
515
516
   * @enumerate: Callback to perform RapidIO fabric enumeration.
   * @discover: Callback to perform RapidIO fabric discovery.
   */
  struct rio_scan {
9edbc30b4   Alexandre Bounine   rapidio: update e...
517
  	struct module *owner;
bc8fcfea1   Alexandre Bounine   rapidio: add enum...
518
519
  	int (*enumerate)(struct rio_mport *mport, u32 flags);
  	int (*discover)(struct rio_mport *mport, u32 flags);
a11650e11   Alexandre Bounine   rapidio: make enu...
520
  };
9edbc30b4   Alexandre Bounine   rapidio: update e...
521
522
523
524
525
526
527
528
529
530
531
532
  /**
   * struct rio_scan_node - list node to register RapidIO enumeration and
   * discovery methods with RapidIO core.
   * @mport_id: ID of an mport (net) serviced by this enumerator
   * @node: node in global list of registered enumerators
   * @ops: RIO enumeration and discovery operations
   */
  struct rio_scan_node {
  	int mport_id;
  	struct list_head node;
  	struct rio_scan *ops;
  };
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
533
  /* Architecture and hardware-specific functions */
b77a2030d   Alexandre Bounine   rapidio: add core...
534
  extern int rio_mport_initialize(struct rio_mport *);
59f999655   Alexandre Bounine   RapidIO/mpc85xx: ...
535
  extern int rio_register_mport(struct rio_mport *);
b77a2030d   Alexandre Bounine   rapidio: add core...
536
  extern int rio_unregister_mport(struct rio_mport *);
6978bbc09   Matt Porter   [PATCH] rapidio: ...
537
  extern int rio_open_inb_mbox(struct rio_mport *, void *, int, int);
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
538
  extern void rio_close_inb_mbox(struct rio_mport *, int);
6978bbc09   Matt Porter   [PATCH] rapidio: ...
539
  extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int);
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
540
  extern void rio_close_outb_mbox(struct rio_mport *, int);
8b189fdbc   Alexandre Bounine   rapidio: add quer...
541
542
  extern int rio_query_mport(struct rio_mport *port,
  			   struct rio_mport_attr *mport_attr);
70a50ebd9   Matt Porter   [PATCH] RapidIO s...
543

70a50ebd9   Matt Porter   [PATCH] RapidIO s...
544
  #endif				/* LINUX_RIO_H */