162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * RapidIO interconnect services
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright 2005 MontaVista Software, Inc.
662306a36Sopenharmony_ci * Matt Porter <mporter@kernel.crashing.org>
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include <linux/device.h>
1062306a36Sopenharmony_ci#include <linux/list.h>
1162306a36Sopenharmony_ci#include <linux/rio.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#define RIO_MAX_CHK_RETRY	3
1462306a36Sopenharmony_ci#define RIO_MPORT_ANY		(-1)
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci/* Functions internal to the RIO core code */
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ciextern u32 rio_mport_get_feature(struct rio_mport *mport, int local, u16 destid,
1962306a36Sopenharmony_ci				 u8 hopcount, int ftr);
2062306a36Sopenharmony_ciextern u32 rio_mport_get_physefb(struct rio_mport *port, int local,
2162306a36Sopenharmony_ci				 u16 destid, u8 hopcount, u32 *rmap);
2262306a36Sopenharmony_ciextern u32 rio_mport_get_efb(struct rio_mport *port, int local, u16 destid,
2362306a36Sopenharmony_ci			     u8 hopcount, u32 from);
2462306a36Sopenharmony_ciextern int rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid,
2562306a36Sopenharmony_ci				    u8 hopcount);
2662306a36Sopenharmony_ciextern int rio_lock_device(struct rio_mport *port, u16 destid,
2762306a36Sopenharmony_ci			u8 hopcount, int wait_ms);
2862306a36Sopenharmony_ciextern int rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount);
2962306a36Sopenharmony_ciextern int rio_route_add_entry(struct rio_dev *rdev,
3062306a36Sopenharmony_ci			u16 table, u16 route_destid, u8 route_port, int lock);
3162306a36Sopenharmony_ciextern int rio_route_get_entry(struct rio_dev *rdev, u16 table,
3262306a36Sopenharmony_ci			u16 route_destid, u8 *route_port, int lock);
3362306a36Sopenharmony_ciextern int rio_route_clr_table(struct rio_dev *rdev, u16 table, int lock);
3462306a36Sopenharmony_ciextern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock);
3562306a36Sopenharmony_ciextern struct rio_dev *rio_get_comptag(u32 comp_tag, struct rio_dev *from);
3662306a36Sopenharmony_ciextern struct rio_net *rio_alloc_net(struct rio_mport *mport);
3762306a36Sopenharmony_ciextern int rio_add_net(struct rio_net *net);
3862306a36Sopenharmony_ciextern void rio_free_net(struct rio_net *net);
3962306a36Sopenharmony_ciextern int rio_add_device(struct rio_dev *rdev);
4062306a36Sopenharmony_ciextern void rio_del_device(struct rio_dev *rdev, enum rio_device_state state);
4162306a36Sopenharmony_ciextern int rio_enable_rx_tx_port(struct rio_mport *port, int local, u16 destid,
4262306a36Sopenharmony_ci				 u8 hopcount, u8 port_num);
4362306a36Sopenharmony_ciextern int rio_register_scan(int mport_id, struct rio_scan *scan_ops);
4462306a36Sopenharmony_ciextern int rio_unregister_scan(int mport_id, struct rio_scan *scan_ops);
4562306a36Sopenharmony_ciextern void rio_attach_device(struct rio_dev *rdev);
4662306a36Sopenharmony_ciextern struct rio_mport *rio_find_mport(int mport_id);
4762306a36Sopenharmony_ciextern int rio_mport_scan(int mport_id);
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci/* Structures internal to the RIO core code */
5062306a36Sopenharmony_ciextern const struct attribute_group *rio_dev_groups[];
5162306a36Sopenharmony_ciextern const struct attribute_group *rio_bus_groups[];
5262306a36Sopenharmony_ciextern const struct attribute_group *rio_mport_groups[];
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#define RIO_GET_DID(size, x)	(size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16))
5562306a36Sopenharmony_ci#define RIO_SET_DID(size, x)	(size ? (x & 0xffff) : ((x & 0x000000ff) << 16))
56