xref: /openbmc/linux/drivers/rapidio/rio.h (revision e274e0ed0a2ac31d5eaf7c891e4e1d99197517b2)
1394b701cSMatt Porter /*
2394b701cSMatt Porter  * RapidIO interconnect services
3394b701cSMatt Porter  *
4394b701cSMatt Porter  * Copyright 2005 MontaVista Software, Inc.
5394b701cSMatt Porter  * Matt Porter <mporter@kernel.crashing.org>
6394b701cSMatt Porter  *
7394b701cSMatt Porter  * This program is free software; you can redistribute  it and/or modify it
8394b701cSMatt Porter  * under  the terms of  the GNU General  Public License as published by the
9394b701cSMatt Porter  * Free Software Foundation;  either version 2 of the  License, or (at your
10394b701cSMatt Porter  * option) any later version.
11394b701cSMatt Porter  */
12394b701cSMatt Porter 
13394b701cSMatt Porter #include <linux/device.h>
14394b701cSMatt Porter #include <linux/list.h>
15394b701cSMatt Porter #include <linux/rio.h>
16394b701cSMatt Porter 
176429cd49SAlexandre Bounine #define RIO_MAX_CHK_RETRY	3
186429cd49SAlexandre Bounine 
19394b701cSMatt Porter /* Functions internal to the RIO core code */
20394b701cSMatt Porter 
21394b701cSMatt Porter extern u32 rio_mport_get_feature(struct rio_mport *mport, int local, u16 destid,
22394b701cSMatt Porter 				 u8 hopcount, int ftr);
23e5cabeb3SAlexandre Bounine extern u32 rio_mport_get_physefb(struct rio_mport *port, int local,
24e5cabeb3SAlexandre Bounine 				 u16 destid, u8 hopcount);
25e5cabeb3SAlexandre Bounine extern u32 rio_mport_get_efb(struct rio_mport *port, int local, u16 destid,
26e5cabeb3SAlexandre Bounine 			     u8 hopcount, u32 from);
27*e274e0edSAlexandre Bounine extern int rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid,
28*e274e0edSAlexandre Bounine 				    u8 hopcount);
29394b701cSMatt Porter extern int rio_create_sysfs_dev_files(struct rio_dev *rdev);
30394b701cSMatt Porter extern int rio_enum_mport(struct rio_mport *mport);
31394b701cSMatt Porter extern int rio_disc_mport(struct rio_mport *mport);
3207590ff0SAlexandre Bounine extern int rio_std_route_add_entry(struct rio_mport *mport, u16 destid,
3307590ff0SAlexandre Bounine 				   u8 hopcount, u16 table, u16 route_destid,
3407590ff0SAlexandre Bounine 				   u8 route_port);
3507590ff0SAlexandre Bounine extern int rio_std_route_get_entry(struct rio_mport *mport, u16 destid,
3607590ff0SAlexandre Bounine 				   u8 hopcount, u16 table, u16 route_destid,
3707590ff0SAlexandre Bounine 				   u8 *route_port);
3807590ff0SAlexandre Bounine extern int rio_std_route_clr_table(struct rio_mport *mport, u16 destid,
3907590ff0SAlexandre Bounine 				   u8 hopcount, u16 table);
40e5cabeb3SAlexandre Bounine extern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock);
41394b701cSMatt Porter 
42394b701cSMatt Porter /* Structures internal to the RIO core code */
43394b701cSMatt Porter extern struct device_attribute rio_dev_attrs[];
44394b701cSMatt Porter extern spinlock_t rio_global_list_lock;
45394b701cSMatt Porter 
46058f88d6SAlexandre Bounine extern struct rio_switch_ops __start_rio_switch_ops[];
47058f88d6SAlexandre Bounine extern struct rio_switch_ops __end_rio_switch_ops[];
48fa78cc51SMatt Porter 
49394b701cSMatt Porter /* Helpers internal to the RIO core code */
50058f88d6SAlexandre Bounine #define DECLARE_RIO_SWITCH_SECTION(section, name, vid, did, init_hook) \
51058f88d6SAlexandre Bounine 	static const struct rio_switch_ops __rio_switch_##name __used \
52058f88d6SAlexandre Bounine 	__section(section) = { vid, did, init_hook };
53394b701cSMatt Porter 
54394b701cSMatt Porter /**
55058f88d6SAlexandre Bounine  * DECLARE_RIO_SWITCH_INIT - Registers switch initialization routine
56394b701cSMatt Porter  * @vid: RIO vendor ID
57394b701cSMatt Porter  * @did: RIO device ID
58058f88d6SAlexandre Bounine  * @init_hook: Callback that performs switch-specific initialization
59394b701cSMatt Porter  *
60058f88d6SAlexandre Bounine  * Manipulating switch route tables and error management in RIO
61058f88d6SAlexandre Bounine  * is switch specific. This registers a switch by vendor and device ID with
62058f88d6SAlexandre Bounine  * initialization callback for setting up switch operations and (if required)
63058f88d6SAlexandre Bounine  * hardware initialization. A &struct rio_switch_ops is initialized with
64058f88d6SAlexandre Bounine  * pointer to the init routine and placed into a RIO-specific kernel section.
65394b701cSMatt Porter  */
66058f88d6SAlexandre Bounine #define DECLARE_RIO_SWITCH_INIT(vid, did, init_hook)		\
67058f88d6SAlexandre Bounine 	DECLARE_RIO_SWITCH_SECTION(.rio_switch_ops, vid##did, \
68058f88d6SAlexandre Bounine 			vid, did, init_hook)
69394b701cSMatt Porter 
70e0423236SZhang Wei #define RIO_GET_DID(size, x)	(size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16))
71e0423236SZhang Wei #define RIO_SET_DID(size, x)	(size ? (x & 0xffff) : ((x & 0x000000ff) << 16))
72