xref: /OK3568_Linux_fs/kernel/drivers/rapidio/rio.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * RapidIO interconnect services
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright 2005 MontaVista Software, Inc.
6*4882a593Smuzhiyun  * Matt Porter <mporter@kernel.crashing.org>
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include <linux/device.h>
10*4882a593Smuzhiyun #include <linux/list.h>
11*4882a593Smuzhiyun #include <linux/rio.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #define RIO_MAX_CHK_RETRY	3
14*4882a593Smuzhiyun #define RIO_MPORT_ANY		(-1)
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun /* Functions internal to the RIO core code */
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun extern u32 rio_mport_get_feature(struct rio_mport *mport, int local, u16 destid,
19*4882a593Smuzhiyun 				 u8 hopcount, int ftr);
20*4882a593Smuzhiyun extern u32 rio_mport_get_physefb(struct rio_mport *port, int local,
21*4882a593Smuzhiyun 				 u16 destid, u8 hopcount, u32 *rmap);
22*4882a593Smuzhiyun extern u32 rio_mport_get_efb(struct rio_mport *port, int local, u16 destid,
23*4882a593Smuzhiyun 			     u8 hopcount, u32 from);
24*4882a593Smuzhiyun extern int rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid,
25*4882a593Smuzhiyun 				    u8 hopcount);
26*4882a593Smuzhiyun extern int rio_lock_device(struct rio_mport *port, u16 destid,
27*4882a593Smuzhiyun 			u8 hopcount, int wait_ms);
28*4882a593Smuzhiyun extern int rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount);
29*4882a593Smuzhiyun extern int rio_route_add_entry(struct rio_dev *rdev,
30*4882a593Smuzhiyun 			u16 table, u16 route_destid, u8 route_port, int lock);
31*4882a593Smuzhiyun extern int rio_route_get_entry(struct rio_dev *rdev, u16 table,
32*4882a593Smuzhiyun 			u16 route_destid, u8 *route_port, int lock);
33*4882a593Smuzhiyun extern int rio_route_clr_table(struct rio_dev *rdev, u16 table, int lock);
34*4882a593Smuzhiyun extern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock);
35*4882a593Smuzhiyun extern struct rio_dev *rio_get_comptag(u32 comp_tag, struct rio_dev *from);
36*4882a593Smuzhiyun extern struct rio_net *rio_alloc_net(struct rio_mport *mport);
37*4882a593Smuzhiyun extern int rio_add_net(struct rio_net *net);
38*4882a593Smuzhiyun extern void rio_free_net(struct rio_net *net);
39*4882a593Smuzhiyun extern int rio_add_device(struct rio_dev *rdev);
40*4882a593Smuzhiyun extern void rio_del_device(struct rio_dev *rdev, enum rio_device_state state);
41*4882a593Smuzhiyun extern int rio_enable_rx_tx_port(struct rio_mport *port, int local, u16 destid,
42*4882a593Smuzhiyun 				 u8 hopcount, u8 port_num);
43*4882a593Smuzhiyun extern int rio_register_scan(int mport_id, struct rio_scan *scan_ops);
44*4882a593Smuzhiyun extern int rio_unregister_scan(int mport_id, struct rio_scan *scan_ops);
45*4882a593Smuzhiyun extern void rio_attach_device(struct rio_dev *rdev);
46*4882a593Smuzhiyun extern struct rio_mport *rio_find_mport(int mport_id);
47*4882a593Smuzhiyun extern int rio_mport_scan(int mport_id);
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun /* Structures internal to the RIO core code */
50*4882a593Smuzhiyun extern const struct attribute_group *rio_dev_groups[];
51*4882a593Smuzhiyun extern const struct attribute_group *rio_bus_groups[];
52*4882a593Smuzhiyun extern const struct attribute_group *rio_mport_groups[];
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun #define RIO_GET_DID(size, x)	(size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16))
55*4882a593Smuzhiyun #define RIO_SET_DID(size, x)	(size ? (x & 0xffff) : ((x & 0x000000ff) << 16))
56