xref: /openbmc/linux/include/linux/rio_drv.h (revision 5c7b3280)
12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
270a50ebdSMatt Porter /*
370a50ebdSMatt Porter  * RapidIO driver services
470a50ebdSMatt Porter  *
570a50ebdSMatt Porter  * Copyright 2005 MontaVista Software, Inc.
670a50ebdSMatt Porter  * Matt Porter <mporter@kernel.crashing.org>
770a50ebdSMatt Porter  */
870a50ebdSMatt Porter 
970a50ebdSMatt Porter #ifndef LINUX_RIO_DRV_H
1070a50ebdSMatt Porter #define LINUX_RIO_DRV_H
1170a50ebdSMatt Porter 
1270a50ebdSMatt Porter #include <linux/types.h>
1370a50ebdSMatt Porter #include <linux/ioport.h>
1470a50ebdSMatt Porter #include <linux/list.h>
1570a50ebdSMatt Porter #include <linux/errno.h>
16de25968cSTim Schmielau #include <linux/string.h>
1770a50ebdSMatt Porter #include <linux/rio.h>
1870a50ebdSMatt Porter 
1970a50ebdSMatt Porter extern int __rio_local_read_config_32(struct rio_mport *port, u32 offset,
2070a50ebdSMatt Porter 				      u32 * data);
2170a50ebdSMatt Porter extern int __rio_local_write_config_32(struct rio_mport *port, u32 offset,
2270a50ebdSMatt Porter 				       u32 data);
2370a50ebdSMatt Porter extern int __rio_local_read_config_16(struct rio_mport *port, u32 offset,
2470a50ebdSMatt Porter 				      u16 * data);
2570a50ebdSMatt Porter extern int __rio_local_write_config_16(struct rio_mport *port, u32 offset,
2670a50ebdSMatt Porter 				       u16 data);
2770a50ebdSMatt Porter extern int __rio_local_read_config_8(struct rio_mport *port, u32 offset,
2870a50ebdSMatt Porter 				     u8 * data);
2970a50ebdSMatt Porter extern int __rio_local_write_config_8(struct rio_mport *port, u32 offset,
3070a50ebdSMatt Porter 				      u8 data);
3170a50ebdSMatt Porter 
3270a50ebdSMatt Porter extern int rio_mport_read_config_32(struct rio_mport *port, u16 destid,
3370a50ebdSMatt Porter 				    u8 hopcount, u32 offset, u32 * data);
3470a50ebdSMatt Porter extern int rio_mport_write_config_32(struct rio_mport *port, u16 destid,
3570a50ebdSMatt Porter 				     u8 hopcount, u32 offset, u32 data);
3670a50ebdSMatt Porter extern int rio_mport_read_config_16(struct rio_mport *port, u16 destid,
3770a50ebdSMatt Porter 				    u8 hopcount, u32 offset, u16 * data);
3870a50ebdSMatt Porter extern int rio_mport_write_config_16(struct rio_mport *port, u16 destid,
3970a50ebdSMatt Porter 				     u8 hopcount, u32 offset, u16 data);
4070a50ebdSMatt Porter extern int rio_mport_read_config_8(struct rio_mport *port, u16 destid,
4170a50ebdSMatt Porter 				   u8 hopcount, u32 offset, u8 * data);
4270a50ebdSMatt Porter extern int rio_mport_write_config_8(struct rio_mport *port, u16 destid,
4370a50ebdSMatt Porter 				    u8 hopcount, u32 offset, u8 data);
4470a50ebdSMatt Porter 
4570a50ebdSMatt Porter /**
4670a50ebdSMatt Porter  * rio_local_read_config_32 - Read 32 bits from local configuration space
4770a50ebdSMatt Porter  * @port: Master port
4870a50ebdSMatt Porter  * @offset: Offset into local configuration space
4970a50ebdSMatt Porter  * @data: Pointer to read data into
5070a50ebdSMatt Porter  *
5170a50ebdSMatt Porter  * Reads 32 bits of data from the specified offset within the local
5270a50ebdSMatt Porter  * device's configuration space.
5370a50ebdSMatt Porter  */
rio_local_read_config_32(struct rio_mport * port,u32 offset,u32 * data)5470a50ebdSMatt Porter static inline int rio_local_read_config_32(struct rio_mport *port, u32 offset,
5570a50ebdSMatt Porter 					   u32 * data)
5670a50ebdSMatt Porter {
5770a50ebdSMatt Porter 	return __rio_local_read_config_32(port, offset, data);
5870a50ebdSMatt Porter }
5970a50ebdSMatt Porter 
6070a50ebdSMatt Porter /**
6170a50ebdSMatt Porter  * rio_local_write_config_32 - Write 32 bits to local configuration space
6270a50ebdSMatt Porter  * @port: Master port
6370a50ebdSMatt Porter  * @offset: Offset into local configuration space
6470a50ebdSMatt Porter  * @data: Data to be written
6570a50ebdSMatt Porter  *
6670a50ebdSMatt Porter  * Writes 32 bits of data to the specified offset within the local
6770a50ebdSMatt Porter  * device's configuration space.
6870a50ebdSMatt Porter  */
rio_local_write_config_32(struct rio_mport * port,u32 offset,u32 data)6970a50ebdSMatt Porter static inline int rio_local_write_config_32(struct rio_mport *port, u32 offset,
7070a50ebdSMatt Porter 					    u32 data)
7170a50ebdSMatt Porter {
7270a50ebdSMatt Porter 	return __rio_local_write_config_32(port, offset, data);
7370a50ebdSMatt Porter }
7470a50ebdSMatt Porter 
7570a50ebdSMatt Porter /**
7670a50ebdSMatt Porter  * rio_local_read_config_16 - Read 16 bits from local configuration space
7770a50ebdSMatt Porter  * @port: Master port
7870a50ebdSMatt Porter  * @offset: Offset into local configuration space
7970a50ebdSMatt Porter  * @data: Pointer to read data into
8070a50ebdSMatt Porter  *
8170a50ebdSMatt Porter  * Reads 16 bits of data from the specified offset within the local
8270a50ebdSMatt Porter  * device's configuration space.
8370a50ebdSMatt Porter  */
rio_local_read_config_16(struct rio_mport * port,u32 offset,u16 * data)8470a50ebdSMatt Porter static inline int rio_local_read_config_16(struct rio_mport *port, u32 offset,
8570a50ebdSMatt Porter 					   u16 * data)
8670a50ebdSMatt Porter {
8770a50ebdSMatt Porter 	return __rio_local_read_config_16(port, offset, data);
8870a50ebdSMatt Porter }
8970a50ebdSMatt Porter 
9070a50ebdSMatt Porter /**
9170a50ebdSMatt Porter  * rio_local_write_config_16 - Write 16 bits to local configuration space
9270a50ebdSMatt Porter  * @port: Master port
9370a50ebdSMatt Porter  * @offset: Offset into local configuration space
9470a50ebdSMatt Porter  * @data: Data to be written
9570a50ebdSMatt Porter  *
9670a50ebdSMatt Porter  * Writes 16 bits of data to the specified offset within the local
9770a50ebdSMatt Porter  * device's configuration space.
9870a50ebdSMatt Porter  */
9970a50ebdSMatt Porter 
rio_local_write_config_16(struct rio_mport * port,u32 offset,u16 data)10070a50ebdSMatt Porter static inline int rio_local_write_config_16(struct rio_mport *port, u32 offset,
10170a50ebdSMatt Porter 					    u16 data)
10270a50ebdSMatt Porter {
10370a50ebdSMatt Porter 	return __rio_local_write_config_16(port, offset, data);
10470a50ebdSMatt Porter }
10570a50ebdSMatt Porter 
10670a50ebdSMatt Porter /**
10770a50ebdSMatt Porter  * rio_local_read_config_8 - Read 8 bits from local configuration space
10870a50ebdSMatt Porter  * @port: Master port
10970a50ebdSMatt Porter  * @offset: Offset into local configuration space
11070a50ebdSMatt Porter  * @data: Pointer to read data into
11170a50ebdSMatt Porter  *
11270a50ebdSMatt Porter  * Reads 8 bits of data from the specified offset within the local
11370a50ebdSMatt Porter  * device's configuration space.
11470a50ebdSMatt Porter  */
rio_local_read_config_8(struct rio_mport * port,u32 offset,u8 * data)11570a50ebdSMatt Porter static inline int rio_local_read_config_8(struct rio_mport *port, u32 offset,
11670a50ebdSMatt Porter 					  u8 * data)
11770a50ebdSMatt Porter {
11870a50ebdSMatt Porter 	return __rio_local_read_config_8(port, offset, data);
11970a50ebdSMatt Porter }
12070a50ebdSMatt Porter 
12170a50ebdSMatt Porter /**
12270a50ebdSMatt Porter  * rio_local_write_config_8 - Write 8 bits to local configuration space
12370a50ebdSMatt Porter  * @port: Master port
12470a50ebdSMatt Porter  * @offset: Offset into local configuration space
12570a50ebdSMatt Porter  * @data: Data to be written
12670a50ebdSMatt Porter  *
12770a50ebdSMatt Porter  * Writes 8 bits of data to the specified offset within the local
12870a50ebdSMatt Porter  * device's configuration space.
12970a50ebdSMatt Porter  */
rio_local_write_config_8(struct rio_mport * port,u32 offset,u8 data)13070a50ebdSMatt Porter static inline int rio_local_write_config_8(struct rio_mport *port, u32 offset,
13170a50ebdSMatt Porter 					   u8 data)
13270a50ebdSMatt Porter {
13370a50ebdSMatt Porter 	return __rio_local_write_config_8(port, offset, data);
13470a50ebdSMatt Porter }
13570a50ebdSMatt Porter 
13670a50ebdSMatt Porter /**
13770a50ebdSMatt Porter  * rio_read_config_32 - Read 32 bits from configuration space
13870a50ebdSMatt Porter  * @rdev: RIO device
13970a50ebdSMatt Porter  * @offset: Offset into device configuration space
14070a50ebdSMatt Porter  * @data: Pointer to read data into
14170a50ebdSMatt Porter  *
14270a50ebdSMatt Porter  * Reads 32 bits of data from the specified offset within the
14370a50ebdSMatt Porter  * RIO device's configuration space.
14470a50ebdSMatt Porter  */
rio_read_config_32(struct rio_dev * rdev,u32 offset,u32 * data)14570a50ebdSMatt Porter static inline int rio_read_config_32(struct rio_dev *rdev, u32 offset,
14670a50ebdSMatt Porter 				     u32 * data)
14770a50ebdSMatt Porter {
148a93192a5SAlexandre Bounine 	return rio_mport_read_config_32(rdev->net->hport, rdev->destid,
149a93192a5SAlexandre Bounine 					rdev->hopcount, offset, data);
15070a50ebdSMatt Porter };
15170a50ebdSMatt Porter 
15270a50ebdSMatt Porter /**
15370a50ebdSMatt Porter  * rio_write_config_32 - Write 32 bits to configuration space
15470a50ebdSMatt Porter  * @rdev: RIO device
15570a50ebdSMatt Porter  * @offset: Offset into device configuration space
15670a50ebdSMatt Porter  * @data: Data to be written
15770a50ebdSMatt Porter  *
15870a50ebdSMatt Porter  * Writes 32 bits of data to the specified offset within the
15970a50ebdSMatt Porter  * RIO device's configuration space.
16070a50ebdSMatt Porter  */
rio_write_config_32(struct rio_dev * rdev,u32 offset,u32 data)16170a50ebdSMatt Porter static inline int rio_write_config_32(struct rio_dev *rdev, u32 offset,
16270a50ebdSMatt Porter 				      u32 data)
16370a50ebdSMatt Porter {
164a93192a5SAlexandre Bounine 	return rio_mport_write_config_32(rdev->net->hport, rdev->destid,
165a93192a5SAlexandre Bounine 					 rdev->hopcount, offset, data);
16670a50ebdSMatt Porter };
16770a50ebdSMatt Porter 
16870a50ebdSMatt Porter /**
16970a50ebdSMatt Porter  * rio_read_config_16 - Read 16 bits from configuration space
17070a50ebdSMatt Porter  * @rdev: RIO device
17170a50ebdSMatt Porter  * @offset: Offset into device configuration space
17270a50ebdSMatt Porter  * @data: Pointer to read data into
17370a50ebdSMatt Porter  *
17470a50ebdSMatt Porter  * Reads 16 bits of data from the specified offset within the
17570a50ebdSMatt Porter  * RIO device's configuration space.
17670a50ebdSMatt Porter  */
rio_read_config_16(struct rio_dev * rdev,u32 offset,u16 * data)17770a50ebdSMatt Porter static inline int rio_read_config_16(struct rio_dev *rdev, u32 offset,
17870a50ebdSMatt Porter 				     u16 * data)
17970a50ebdSMatt Porter {
180a93192a5SAlexandre Bounine 	return rio_mport_read_config_16(rdev->net->hport, rdev->destid,
181a93192a5SAlexandre Bounine 					rdev->hopcount, offset, data);
18270a50ebdSMatt Porter };
18370a50ebdSMatt Porter 
18470a50ebdSMatt Porter /**
18570a50ebdSMatt Porter  * rio_write_config_16 - Write 16 bits to configuration space
18670a50ebdSMatt Porter  * @rdev: RIO device
18770a50ebdSMatt Porter  * @offset: Offset into device configuration space
18870a50ebdSMatt Porter  * @data: Data to be written
18970a50ebdSMatt Porter  *
19070a50ebdSMatt Porter  * Writes 16 bits of data to the specified offset within the
19170a50ebdSMatt Porter  * RIO device's configuration space.
19270a50ebdSMatt Porter  */
rio_write_config_16(struct rio_dev * rdev,u32 offset,u16 data)19370a50ebdSMatt Porter static inline int rio_write_config_16(struct rio_dev *rdev, u32 offset,
19470a50ebdSMatt Porter 				      u16 data)
19570a50ebdSMatt Porter {
196a93192a5SAlexandre Bounine 	return rio_mport_write_config_16(rdev->net->hport, rdev->destid,
197a93192a5SAlexandre Bounine 					 rdev->hopcount, offset, data);
19870a50ebdSMatt Porter };
19970a50ebdSMatt Porter 
20070a50ebdSMatt Porter /**
20170a50ebdSMatt Porter  * rio_read_config_8 - Read 8 bits from configuration space
20270a50ebdSMatt Porter  * @rdev: RIO device
20370a50ebdSMatt Porter  * @offset: Offset into device configuration space
20470a50ebdSMatt Porter  * @data: Pointer to read data into
20570a50ebdSMatt Porter  *
20670a50ebdSMatt Porter  * Reads 8 bits of data from the specified offset within the
20770a50ebdSMatt Porter  * RIO device's configuration space.
20870a50ebdSMatt Porter  */
rio_read_config_8(struct rio_dev * rdev,u32 offset,u8 * data)20970a50ebdSMatt Porter static inline int rio_read_config_8(struct rio_dev *rdev, u32 offset, u8 * data)
21070a50ebdSMatt Porter {
211a93192a5SAlexandre Bounine 	return rio_mport_read_config_8(rdev->net->hport, rdev->destid,
212a93192a5SAlexandre Bounine 				       rdev->hopcount, offset, data);
21370a50ebdSMatt Porter };
21470a50ebdSMatt Porter 
21570a50ebdSMatt Porter /**
21670a50ebdSMatt Porter  * rio_write_config_8 - Write 8 bits to configuration space
21770a50ebdSMatt Porter  * @rdev: RIO device
21870a50ebdSMatt Porter  * @offset: Offset into device configuration space
21970a50ebdSMatt Porter  * @data: Data to be written
22070a50ebdSMatt Porter  *
22170a50ebdSMatt Porter  * Writes 8 bits of data to the specified offset within the
22270a50ebdSMatt Porter  * RIO device's configuration space.
22370a50ebdSMatt Porter  */
rio_write_config_8(struct rio_dev * rdev,u32 offset,u8 data)22470a50ebdSMatt Porter static inline int rio_write_config_8(struct rio_dev *rdev, u32 offset, u8 data)
22570a50ebdSMatt Porter {
226a93192a5SAlexandre Bounine 	return rio_mport_write_config_8(rdev->net->hport, rdev->destid,
227a93192a5SAlexandre Bounine 					rdev->hopcount, offset, data);
22870a50ebdSMatt Porter };
22970a50ebdSMatt Porter 
23070a50ebdSMatt Porter extern int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid,
23170a50ebdSMatt Porter 				   u16 data);
23270a50ebdSMatt Porter 
23370a50ebdSMatt Porter /**
23470a50ebdSMatt Porter  * rio_send_doorbell - Send a doorbell message to a device
23570a50ebdSMatt Porter  * @rdev: RIO device
23670a50ebdSMatt Porter  * @data: Doorbell message data
23770a50ebdSMatt Porter  *
23870a50ebdSMatt Porter  * Send a doorbell message to a RIO device. The doorbell message
23970a50ebdSMatt Porter  * has a 16-bit info field provided by the @data argument.
24070a50ebdSMatt Porter  */
rio_send_doorbell(struct rio_dev * rdev,u16 data)24170a50ebdSMatt Porter static inline int rio_send_doorbell(struct rio_dev *rdev, u16 data)
24270a50ebdSMatt Porter {
24370a50ebdSMatt Porter 	return rio_mport_send_doorbell(rdev->net->hport, rdev->destid, data);
24470a50ebdSMatt Porter };
24570a50ebdSMatt Porter 
24670a50ebdSMatt Porter /**
24770a50ebdSMatt Porter  * rio_init_mbox_res - Initialize a RIO mailbox resource
24870a50ebdSMatt Porter  * @res: resource struct
24970a50ebdSMatt Porter  * @start: start of mailbox range
25070a50ebdSMatt Porter  * @end: end of mailbox range
25170a50ebdSMatt Porter  *
25270a50ebdSMatt Porter  * This function is used to initialize the fields of a resource
25370a50ebdSMatt Porter  * for use as a mailbox resource.  It initializes a range of
25470a50ebdSMatt Porter  * mailboxes using the start and end arguments.
25570a50ebdSMatt Porter  */
rio_init_mbox_res(struct resource * res,int start,int end)25670a50ebdSMatt Porter static inline void rio_init_mbox_res(struct resource *res, int start, int end)
25770a50ebdSMatt Porter {
25870a50ebdSMatt Porter 	memset(res, 0, sizeof(struct resource));
25970a50ebdSMatt Porter 	res->start = start;
26070a50ebdSMatt Porter 	res->end = end;
26170a50ebdSMatt Porter 	res->flags = RIO_RESOURCE_MAILBOX;
26270a50ebdSMatt Porter }
26370a50ebdSMatt Porter 
26470a50ebdSMatt Porter /**
26570a50ebdSMatt Porter  * rio_init_dbell_res - Initialize a RIO doorbell resource
26670a50ebdSMatt Porter  * @res: resource struct
26770a50ebdSMatt Porter  * @start: start of doorbell range
26870a50ebdSMatt Porter  * @end: end of doorbell range
26970a50ebdSMatt Porter  *
27070a50ebdSMatt Porter  * This function is used to initialize the fields of a resource
27170a50ebdSMatt Porter  * for use as a doorbell resource.  It initializes a range of
27270a50ebdSMatt Porter  * doorbell messages using the start and end arguments.
27370a50ebdSMatt Porter  */
rio_init_dbell_res(struct resource * res,u16 start,u16 end)27470a50ebdSMatt Porter static inline void rio_init_dbell_res(struct resource *res, u16 start, u16 end)
27570a50ebdSMatt Porter {
27670a50ebdSMatt Porter 	memset(res, 0, sizeof(struct resource));
27770a50ebdSMatt Porter 	res->start = start;
27870a50ebdSMatt Porter 	res->end = end;
27970a50ebdSMatt Porter 	res->flags = RIO_RESOURCE_DOORBELL;
28070a50ebdSMatt Porter }
28170a50ebdSMatt Porter 
28270a50ebdSMatt Porter /**
28370a50ebdSMatt Porter  * RIO_DEVICE - macro used to describe a specific RIO device
2840863afb3SMartin Waitz  * @dev: the 16 bit RIO device ID
2850863afb3SMartin Waitz  * @ven: the 16 bit RIO vendor ID
28670a50ebdSMatt Porter  *
28770a50ebdSMatt Porter  * This macro is used to create a struct rio_device_id that matches a
28870a50ebdSMatt Porter  * specific device.  The assembly vendor and assembly device fields
28970a50ebdSMatt Porter  * will be set to %RIO_ANY_ID.
29070a50ebdSMatt Porter  */
29170a50ebdSMatt Porter #define RIO_DEVICE(dev,ven) \
29270a50ebdSMatt Porter 	.did = (dev), .vid = (ven), \
29370a50ebdSMatt Porter 	.asm_did = RIO_ANY_ID, .asm_vid = RIO_ANY_ID
29470a50ebdSMatt Porter 
29570a50ebdSMatt Porter /* Mailbox management */
2966978bbc0SMatt Porter extern int rio_request_outb_mbox(struct rio_mport *, void *, int, int,
2976978bbc0SMatt Porter 				 void (*)(struct rio_mport *, void *,int, int));
29870a50ebdSMatt Porter extern int rio_release_outb_mbox(struct rio_mport *, int);
29970a50ebdSMatt Porter 
30070a50ebdSMatt Porter /**
30170a50ebdSMatt Porter  * rio_add_outb_message - Add RIO message to an outbound mailbox queue
30270a50ebdSMatt Porter  * @mport: RIO master port containing the outbound queue
30370a50ebdSMatt Porter  * @rdev: RIO device the message is be sent to
30470a50ebdSMatt Porter  * @mbox: The outbound mailbox queue
30570a50ebdSMatt Porter  * @buffer: Pointer to the message buffer
30670a50ebdSMatt Porter  * @len: Length of the message buffer
30770a50ebdSMatt Porter  *
30870a50ebdSMatt Porter  * Adds a RIO message buffer to an outbound mailbox queue for
30970a50ebdSMatt Porter  * transmission. Returns 0 on success.
31070a50ebdSMatt Porter  */
rio_add_outb_message(struct rio_mport * mport,struct rio_dev * rdev,int mbox,void * buffer,size_t len)31170a50ebdSMatt Porter static inline int rio_add_outb_message(struct rio_mport *mport,
31270a50ebdSMatt Porter 				       struct rio_dev *rdev, int mbox,
31370a50ebdSMatt Porter 				       void *buffer, size_t len)
31470a50ebdSMatt Porter {
315f8f06269SAlexandre Bounine 	return mport->ops->add_outb_message(mport, rdev, mbox,
316f8f06269SAlexandre Bounine 						   buffer, len);
31770a50ebdSMatt Porter }
31870a50ebdSMatt Porter 
3196978bbc0SMatt Porter extern int rio_request_inb_mbox(struct rio_mport *, void *, int, int,
3206978bbc0SMatt Porter 				void (*)(struct rio_mport *, void *, int, int));
32170a50ebdSMatt Porter extern int rio_release_inb_mbox(struct rio_mport *, int);
32270a50ebdSMatt Porter 
32370a50ebdSMatt Porter /**
32470a50ebdSMatt Porter  * rio_add_inb_buffer - Add buffer to an inbound mailbox queue
32570a50ebdSMatt Porter  * @mport: Master port containing the inbound mailbox
32670a50ebdSMatt Porter  * @mbox: The inbound mailbox number
32770a50ebdSMatt Porter  * @buffer: Pointer to the message buffer
32870a50ebdSMatt Porter  *
32970a50ebdSMatt Porter  * Adds a buffer to an inbound mailbox queue for reception. Returns
33070a50ebdSMatt Porter  * 0 on success.
33170a50ebdSMatt Porter  */
rio_add_inb_buffer(struct rio_mport * mport,int mbox,void * buffer)33270a50ebdSMatt Porter static inline int rio_add_inb_buffer(struct rio_mport *mport, int mbox,
33370a50ebdSMatt Porter 				     void *buffer)
33470a50ebdSMatt Porter {
335f8f06269SAlexandre Bounine 	return mport->ops->add_inb_buffer(mport, mbox, buffer);
33670a50ebdSMatt Porter }
33770a50ebdSMatt Porter 
33870a50ebdSMatt Porter /**
33970a50ebdSMatt Porter  * rio_get_inb_message - Get A RIO message from an inbound mailbox queue
34070a50ebdSMatt Porter  * @mport: Master port containing the inbound mailbox
34170a50ebdSMatt Porter  * @mbox: The inbound mailbox number
34270a50ebdSMatt Porter  *
34370a50ebdSMatt Porter  * Get a RIO message from an inbound mailbox queue. Returns 0 on success.
34470a50ebdSMatt Porter  */
rio_get_inb_message(struct rio_mport * mport,int mbox)34570a50ebdSMatt Porter static inline void *rio_get_inb_message(struct rio_mport *mport, int mbox)
34670a50ebdSMatt Porter {
347f8f06269SAlexandre Bounine 	return mport->ops->get_inb_message(mport, mbox);
34870a50ebdSMatt Porter }
34970a50ebdSMatt Porter 
35070a50ebdSMatt Porter /* Doorbell management */
3516978bbc0SMatt Porter extern int rio_request_inb_dbell(struct rio_mport *, void *, u16, u16,
3526978bbc0SMatt Porter 				 void (*)(struct rio_mport *, void *, u16, u16, u16));
35370a50ebdSMatt Porter extern int rio_release_inb_dbell(struct rio_mport *, u16, u16);
35470a50ebdSMatt Porter extern struct resource *rio_request_outb_dbell(struct rio_dev *, u16, u16);
35570a50ebdSMatt Porter extern int rio_release_outb_dbell(struct rio_dev *, struct resource *);
35670a50ebdSMatt Porter 
35770a50ebdSMatt Porter /* Memory region management */
35870a50ebdSMatt Porter int rio_claim_resource(struct rio_dev *, int);
35970a50ebdSMatt Porter int rio_request_regions(struct rio_dev *, char *);
36070a50ebdSMatt Porter void rio_release_regions(struct rio_dev *);
36170a50ebdSMatt Porter int rio_request_region(struct rio_dev *, int, char *);
36270a50ebdSMatt Porter void rio_release_region(struct rio_dev *, int);
36370a50ebdSMatt Porter 
364da1589f0SAlexandre Bounine /* Memory mapping functions */
365da1589f0SAlexandre Bounine extern int rio_map_inb_region(struct rio_mport *mport, dma_addr_t local,
366da1589f0SAlexandre Bounine 			u64 rbase, u32 size, u32 rflags);
367da1589f0SAlexandre Bounine extern void rio_unmap_inb_region(struct rio_mport *mport, dma_addr_t lstart);
36893bdaca5SAlexandre Bounine extern int rio_map_outb_region(struct rio_mport *mport, u16 destid, u64 rbase,
36993bdaca5SAlexandre Bounine 			u32 size, u32 rflags, dma_addr_t *local);
37093bdaca5SAlexandre Bounine extern void rio_unmap_outb_region(struct rio_mport *mport,
37193bdaca5SAlexandre Bounine 				  u16 destid, u64 rstart);
372da1589f0SAlexandre Bounine 
373e5cabeb3SAlexandre Bounine /* Port-Write management */
374e5cabeb3SAlexandre Bounine extern int rio_request_inb_pwrite(struct rio_dev *,
375e5cabeb3SAlexandre Bounine 			int (*)(struct rio_dev *, union rio_pw_msg*, int));
376e5cabeb3SAlexandre Bounine extern int rio_release_inb_pwrite(struct rio_dev *);
3779a0b0627SAlexandre Bounine extern int rio_add_mport_pw_handler(struct rio_mport *mport, void *dev_id,
3789a0b0627SAlexandre Bounine 			int (*pwcback)(struct rio_mport *mport, void *dev_id,
3799a0b0627SAlexandre Bounine 			union rio_pw_msg *msg, int step));
3809a0b0627SAlexandre Bounine extern int rio_del_mport_pw_handler(struct rio_mport *mport, void *dev_id,
3819a0b0627SAlexandre Bounine 			int (*pwcback)(struct rio_mport *mport, void *dev_id,
3829a0b0627SAlexandre Bounine 			union rio_pw_msg *msg, int step));
3839a0b0627SAlexandre Bounine extern int rio_inb_pwrite_handler(struct rio_mport *mport,
3849a0b0627SAlexandre Bounine 				  union rio_pw_msg *pw_msg);
385b6cb95e8SAlexandre Bounine extern void rio_pw_enable(struct rio_mport *mport, int enable);
386e5cabeb3SAlexandre Bounine 
38770a50ebdSMatt Porter /* LDM support */
38870a50ebdSMatt Porter int rio_register_driver(struct rio_driver *);
38970a50ebdSMatt Porter void rio_unregister_driver(struct rio_driver *);
39070a50ebdSMatt Porter struct rio_dev *rio_dev_get(struct rio_dev *);
39170a50ebdSMatt Porter void rio_dev_put(struct rio_dev *);
39270a50ebdSMatt Porter 
393e42d98ebSAlexandre Bounine #ifdef CONFIG_RAPIDIO_DMA_ENGINE
394e42d98ebSAlexandre Bounine extern struct dma_chan *rio_request_dma(struct rio_dev *rdev);
3954aff1ce7SAlexandre Bounine extern struct dma_chan *rio_request_mport_dma(struct rio_mport *mport);
396e42d98ebSAlexandre Bounine extern void rio_release_dma(struct dma_chan *dchan);
397e42d98ebSAlexandre Bounine extern struct dma_async_tx_descriptor *rio_dma_prep_slave_sg(
398e42d98ebSAlexandre Bounine 		struct rio_dev *rdev, struct dma_chan *dchan,
399e42d98ebSAlexandre Bounine 		struct rio_dma_data *data,
400e42d98ebSAlexandre Bounine 		enum dma_transfer_direction direction, unsigned long flags);
4014aff1ce7SAlexandre Bounine extern struct dma_async_tx_descriptor *rio_dma_prep_xfer(
4024aff1ce7SAlexandre Bounine 		struct dma_chan *dchan,	u16 destid,
4034aff1ce7SAlexandre Bounine 		struct rio_dma_data *data,
4044aff1ce7SAlexandre Bounine 		enum dma_transfer_direction direction, unsigned long flags);
405e42d98ebSAlexandre Bounine #endif
406e42d98ebSAlexandre Bounine 
40770a50ebdSMatt Porter /**
40870a50ebdSMatt Porter  * rio_name - Get the unique RIO device identifier
40970a50ebdSMatt Porter  * @rdev: RIO device
41070a50ebdSMatt Porter  *
41170a50ebdSMatt Porter  * Get the unique RIO device identifier. Returns the device
41270a50ebdSMatt Porter  * identifier string.
41370a50ebdSMatt Porter  */
rio_name(struct rio_dev * rdev)414b53c7583SKay Sievers static inline const char *rio_name(struct rio_dev *rdev)
41570a50ebdSMatt Porter {
416b53c7583SKay Sievers 	return dev_name(&rdev->dev);
41770a50ebdSMatt Porter }
41870a50ebdSMatt Porter 
41970a50ebdSMatt Porter /**
42070a50ebdSMatt Porter  * rio_get_drvdata - Get RIO driver specific data
42170a50ebdSMatt Porter  * @rdev: RIO device
42270a50ebdSMatt Porter  *
42370a50ebdSMatt Porter  * Get RIO driver specific data. Returns a pointer to the
42470a50ebdSMatt Porter  * driver specific data.
42570a50ebdSMatt Porter  */
rio_get_drvdata(struct rio_dev * rdev)42670a50ebdSMatt Porter static inline void *rio_get_drvdata(struct rio_dev *rdev)
42770a50ebdSMatt Porter {
42870a50ebdSMatt Porter 	return dev_get_drvdata(&rdev->dev);
42970a50ebdSMatt Porter }
43070a50ebdSMatt Porter 
43170a50ebdSMatt Porter /**
43270a50ebdSMatt Porter  * rio_set_drvdata - Set RIO driver specific data
43370a50ebdSMatt Porter  * @rdev: RIO device
43470a50ebdSMatt Porter  * @data: Pointer to driver specific data
43570a50ebdSMatt Porter  *
43670a50ebdSMatt Porter  * Set RIO driver specific data. device struct driver data pointer
43770a50ebdSMatt Porter  * is set to the @data argument.
43870a50ebdSMatt Porter  */
rio_set_drvdata(struct rio_dev * rdev,void * data)43970a50ebdSMatt Porter static inline void rio_set_drvdata(struct rio_dev *rdev, void *data)
44070a50ebdSMatt Porter {
44170a50ebdSMatt Porter 	dev_set_drvdata(&rdev->dev, data);
44270a50ebdSMatt Porter }
44370a50ebdSMatt Porter 
44470a50ebdSMatt Porter /* Misc driver helpers */
44570a50ebdSMatt Porter extern u16 rio_local_get_device_id(struct rio_mport *port);
4465024622fSAlexandre Bounine extern void rio_local_set_device_id(struct rio_mport *port, u16 did);
447a11650e1SAlexandre Bounine extern int rio_init_mports(void);
44870a50ebdSMatt Porter 
44970a50ebdSMatt Porter #endif				/* LINUX_RIO_DRV_H */
450