blob: c14f864dea5cbf420fd247ec6d4584c89e932703 [file] [log] [blame]
Matt Porter394b7012005-11-07 01:00:15 -08001/*
2 * RapidIO interconnect services
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/device.h>
14#include <linux/list.h>
15#include <linux/rio.h>
16
Alexandre Bounine6429cd42010-10-27 15:34:32 -070017#define RIO_MAX_CHK_RETRY 3
Alexandre Bouninea11650e2013-05-24 15:55:05 -070018#define RIO_MPORT_ANY (-1)
Alexandre Bounine6429cd42010-10-27 15:34:32 -070019
Matt Porter394b7012005-11-07 01:00:15 -080020/* Functions internal to the RIO core code */
21
22extern u32 rio_mport_get_feature(struct rio_mport *mport, int local, u16 destid,
23 u8 hopcount, int ftr);
Alexandre Bouninee5cabeb2010-05-26 14:43:59 -070024extern u32 rio_mport_get_physefb(struct rio_mport *port, int local,
25 u16 destid, u8 hopcount);
26extern u32 rio_mport_get_efb(struct rio_mport *port, int local, u16 destid,
27 u8 hopcount, u32 from);
Alexandre Bouninee274e0e2010-10-27 15:34:32 -070028extern int rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid,
29 u8 hopcount);
Matt Porter394b7012005-11-07 01:00:15 -080030extern int rio_create_sysfs_dev_files(struct rio_dev *rdev);
Alexandre Bounine07590ff2010-05-26 14:43:57 -070031extern int rio_std_route_add_entry(struct rio_mport *mport, u16 destid,
32 u8 hopcount, u16 table, u16 route_destid,
33 u8 route_port);
34extern int rio_std_route_get_entry(struct rio_mport *mport, u16 destid,
35 u8 hopcount, u16 table, u16 route_destid,
36 u8 *route_port);
37extern int rio_std_route_clr_table(struct rio_mport *mport, u16 destid,
38 u8 hopcount, u16 table);
Alexandre Bouninee5cabeb2010-05-26 14:43:59 -070039extern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock);
Alexandre Bounineaf84ca32010-10-27 15:34:34 -070040extern struct rio_dev *rio_get_comptag(u32 comp_tag, struct rio_dev *from);
Alexandre Bouninea11650e2013-05-24 15:55:05 -070041extern int rio_add_device(struct rio_dev *rdev);
42extern void rio_switch_init(struct rio_dev *rdev, int do_enum);
43extern int rio_enable_rx_tx_port(struct rio_mport *port, int local, u16 destid,
44 u8 hopcount, u8 port_num);
45extern int rio_register_scan(int mport_id, struct rio_scan *scan_ops);
46extern int rio_unregister_scan(int mport_id);
47extern void rio_attach_device(struct rio_dev *rdev);
Alexandre Bouninebc8fcfe2013-05-24 15:55:06 -070048extern struct rio_mport *rio_find_mport(int mport_id);
Matt Porter394b7012005-11-07 01:00:15 -080049
50/* Structures internal to the RIO core code */
51extern struct device_attribute rio_dev_attrs[];
Alexandre Bouninebc8fcfe2013-05-24 15:55:06 -070052extern struct bus_attribute rio_bus_attrs[];
Matt Porter394b7012005-11-07 01:00:15 -080053
Alexandre Bounine058f88d62010-05-26 14:44:03 -070054extern struct rio_switch_ops __start_rio_switch_ops[];
55extern struct rio_switch_ops __end_rio_switch_ops[];
Matt Porterfa78cc52005-11-07 01:00:18 -080056
Matt Porter394b7012005-11-07 01:00:15 -080057/* Helpers internal to the RIO core code */
Alexandre Bounine058f88d62010-05-26 14:44:03 -070058#define DECLARE_RIO_SWITCH_SECTION(section, name, vid, did, init_hook) \
59 static const struct rio_switch_ops __rio_switch_##name __used \
60 __section(section) = { vid, did, init_hook };
Matt Porter394b7012005-11-07 01:00:15 -080061
62/**
Alexandre Bounine058f88d62010-05-26 14:44:03 -070063 * DECLARE_RIO_SWITCH_INIT - Registers switch initialization routine
Matt Porter394b7012005-11-07 01:00:15 -080064 * @vid: RIO vendor ID
65 * @did: RIO device ID
Alexandre Bounine058f88d62010-05-26 14:44:03 -070066 * @init_hook: Callback that performs switch-specific initialization
Matt Porter394b7012005-11-07 01:00:15 -080067 *
Alexandre Bounine058f88d62010-05-26 14:44:03 -070068 * Manipulating switch route tables and error management in RIO
69 * is switch specific. This registers a switch by vendor and device ID with
70 * initialization callback for setting up switch operations and (if required)
71 * hardware initialization. A &struct rio_switch_ops is initialized with
72 * pointer to the init routine and placed into a RIO-specific kernel section.
Matt Porter394b7012005-11-07 01:00:15 -080073 */
Alexandre Bounine058f88d62010-05-26 14:44:03 -070074#define DECLARE_RIO_SWITCH_INIT(vid, did, init_hook) \
75 DECLARE_RIO_SWITCH_SECTION(.rio_switch_ops, vid##did, \
76 vid, did, init_hook)
Matt Porter394b7012005-11-07 01:00:15 -080077
Zhang Weie0423232008-04-18 13:33:42 -070078#define RIO_GET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16))
79#define RIO_SET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x000000ff) << 16))