xref: /linux/drivers/rapidio/rio.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*2874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2394b701cSMatt Porter /*
3394b701cSMatt Porter  * RapidIO interconnect services
4394b701cSMatt Porter  *
5394b701cSMatt Porter  * Copyright 2005 MontaVista Software, Inc.
6394b701cSMatt Porter  * Matt Porter <mporter@kernel.crashing.org>
7394b701cSMatt Porter  */
8394b701cSMatt Porter 
9394b701cSMatt Porter #include <linux/device.h>
10394b701cSMatt Porter #include <linux/list.h>
11394b701cSMatt Porter #include <linux/rio.h>
12394b701cSMatt Porter 
136429cd49SAlexandre Bounine #define RIO_MAX_CHK_RETRY	3
14a11650e1SAlexandre Bounine #define RIO_MPORT_ANY		(-1)
156429cd49SAlexandre Bounine 
16394b701cSMatt Porter /* Functions internal to the RIO core code */
17394b701cSMatt Porter 
18394b701cSMatt Porter extern u32 rio_mport_get_feature(struct rio_mport *mport, int local, u16 destid,
19394b701cSMatt Porter 				 u8 hopcount, int ftr);
20e5cabeb3SAlexandre Bounine extern u32 rio_mport_get_physefb(struct rio_mport *port, int local,
211ae842deSAlexandre Bounine 				 u16 destid, u8 hopcount, u32 *rmap);
22e5cabeb3SAlexandre Bounine extern u32 rio_mport_get_efb(struct rio_mport *port, int local, u16 destid,
23e5cabeb3SAlexandre Bounine 			     u8 hopcount, u32 from);
24e274e0edSAlexandre Bounine extern int rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid,
25e274e0edSAlexandre Bounine 				    u8 hopcount);
262ec3ba69SAlexandre Bounine extern int rio_lock_device(struct rio_mport *port, u16 destid,
272ec3ba69SAlexandre Bounine 			u8 hopcount, int wait_ms);
282ec3ba69SAlexandre Bounine extern int rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount);
292ec3ba69SAlexandre Bounine extern int rio_route_add_entry(struct rio_dev *rdev,
302ec3ba69SAlexandre Bounine 			u16 table, u16 route_destid, u8 route_port, int lock);
312ec3ba69SAlexandre Bounine extern int rio_route_get_entry(struct rio_dev *rdev, u16 table,
322ec3ba69SAlexandre Bounine 			u16 route_destid, u8 *route_port, int lock);
332ec3ba69SAlexandre Bounine extern int rio_route_clr_table(struct rio_dev *rdev, u16 table, int lock);
34e5cabeb3SAlexandre Bounine extern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock);
35af84ca38SAlexandre Bounine extern struct rio_dev *rio_get_comptag(u32 comp_tag, struct rio_dev *from);
36e6b585caSAlexandre Bounine extern struct rio_net *rio_alloc_net(struct rio_mport *mport);
37e6b585caSAlexandre Bounine extern int rio_add_net(struct rio_net *net);
38e6b585caSAlexandre Bounine extern void rio_free_net(struct rio_net *net);
39a11650e1SAlexandre Bounine extern int rio_add_device(struct rio_dev *rdev);
40b77a2030SAlexandre Bounine extern void rio_del_device(struct rio_dev *rdev, enum rio_device_state state);
41a11650e1SAlexandre Bounine extern int rio_enable_rx_tx_port(struct rio_mport *port, int local, u16 destid,
42a11650e1SAlexandre Bounine 				 u8 hopcount, u8 port_num);
43a11650e1SAlexandre Bounine extern int rio_register_scan(int mport_id, struct rio_scan *scan_ops);
449edbc30bSAlexandre Bounine extern int rio_unregister_scan(int mport_id, struct rio_scan *scan_ops);
45a11650e1SAlexandre Bounine extern void rio_attach_device(struct rio_dev *rdev);
46bc8fcfeaSAlexandre Bounine extern struct rio_mport *rio_find_mport(int mport_id);
479edbc30bSAlexandre Bounine extern int rio_mport_scan(int mport_id);
48394b701cSMatt Porter 
49394b701cSMatt Porter /* Structures internal to the RIO core code */
506d39c80bSGreg Kroah-Hartman extern const struct attribute_group *rio_dev_groups[];
51ed1d2da2SGreg Kroah-Hartman extern const struct attribute_group *rio_bus_groups[];
522aaf308bSAlexandre Bounine extern const struct attribute_group *rio_mport_groups[];
53394b701cSMatt Porter 
54e0423236SZhang Wei #define RIO_GET_DID(size, x)	(size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16))
55e0423236SZhang Wei #define RIO_SET_DID(size, x)	(size ? (x & 0xffff) : ((x & 0x000000ff) << 16))
56