linux/include/linux/rio.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * RapidIO interconnect services
 * (RapidIO Interconnect Specification, http://www.rapidio.org)
 *
 * Copyright 2005 MontaVista Software, Inc.
 * Matt Porter <[email protected]>
 */

#ifndef LINUX_RIO_H
#define LINUX_RIO_H

#include <linux/types.h>
#include <linux/ioport.h>
#include <linux/list.h>
#include <linux/errno.h>
#include <linux/device.h>
#include <linux/rio_regs.h>
#include <linux/mod_devicetable.h>
#ifdef CONFIG_RAPIDIO_DMA_ENGINE
#include <linux/dmaengine.h>
#endif

#define RIO_NO_HOPCOUNT
#define RIO_INVALID_DESTID

#define RIO_MAX_MPORTS
#define RIO_MAX_MPORT_RESOURCES
#define RIO_MAX_DEV_RESOURCES
#define RIO_MAX_MPORT_NAME

#define RIO_GLOBAL_TABLE

#define RIO_INVALID_ROUTE

#define RIO_MAX_ROUTE_ENTRIES(size)
#define RIO_ANY_DESTID(size)

#define RIO_MAX_MBOX
#define RIO_MAX_MSG_SIZE

/*
 * Error values that may be returned by RIO functions.
 */
#define RIO_SUCCESSFUL
#define RIO_BAD_SIZE

/*
 * For RIO devices, the region numbers are assigned this way:
 *
 *	0	RapidIO outbound doorbells
 *      1-15	RapidIO memory regions
 *
 * For RIO master ports, the region number are assigned this way:
 *
 *	0	RapidIO inbound doorbells
 *	1	RapidIO inbound mailboxes
 *	2	RapidIO outbound mailboxes
 */
#define RIO_DOORBELL_RESOURCE
#define RIO_INB_MBOX_RESOURCE
#define RIO_OUTB_MBOX_RESOURCE

#define RIO_PW_MSG_SIZE

/*
 * A component tag value (stored in the component tag CSR) is used as device's
 * unique identifier assigned during enumeration. Besides being used for
 * identifying switches (which do not have device ID register), it also is used
 * by error management notification and therefore has to be assigned
 * to endpoints as well.
 */
#define RIO_CTAG_RESRVD
#define RIO_CTAG_UDEVID

extern struct bus_type rio_bus_type;
extern struct class rio_mport_class;

struct rio_mport;
struct rio_dev;
rio_pw_msg;

/**
 * struct rio_switch - RIO switch info
 * @node: Node in global list of switches
 * @route_table: Copy of switch routing table
 * @port_ok: Status of each port (one bit per port) - OK=1 or UNINIT=0
 * @ops: pointer to switch-specific operations
 * @lock: lock to serialize operations updates
 * @nextdev: Array of per-port pointers to the next attached device
 */
struct rio_switch {};

/**
 * struct rio_switch_ops - Per-switch operations
 * @owner: The module owner of this structure
 * @add_entry: Callback for switch-specific route add function
 * @get_entry: Callback for switch-specific route get function
 * @clr_table: Callback for switch-specific clear route table function
 * @set_domain: Callback for switch-specific domain setting function
 * @get_domain: Callback for switch-specific domain get function
 * @em_init: Callback for switch-specific error management init function
 * @em_handle: Callback for switch-specific error management handler function
 *
 * Defines the operations that are necessary to initialize/control
 * a particular RIO switch device.
 */
struct rio_switch_ops {};

enum rio_device_state {};

/**
 * struct rio_dev - RIO device info
 * @global_list: Node in list of all RIO devices
 * @net_list: Node in list of RIO devices in a network
 * @net: Network this device is a part of
 * @do_enum: Enumeration flag
 * @did: Device ID
 * @vid: Vendor ID
 * @device_rev: Device revision
 * @asm_did: Assembly device ID
 * @asm_vid: Assembly vendor ID
 * @asm_rev: Assembly revision
 * @efptr: Extended feature pointer
 * @pef: Processing element features
 * @swpinfo: Switch port info
 * @src_ops: Source operation capabilities
 * @dst_ops: Destination operation capabilities
 * @comp_tag: RIO component tag
 * @phys_efptr: RIO device extended features pointer
 * @phys_rmap: LP-Serial Register Map Type (1 or 2)
 * @em_efptr: RIO Error Management features pointer
 * @dma_mask: Mask of bits of RIO address this device implements
 * @driver: Driver claiming this device
 * @dev: Device model device
 * @riores: RIO resources this device owns
 * @pwcback: port-write callback function for this device
 * @destid: Network destination ID (or associated destid for switch)
 * @hopcount: Hopcount to this device
 * @prev: Previous RIO device connected to the current one
 * @state: device state
 * @rswitch: struct rio_switch (if valid for this device)
 */
struct rio_dev {};

#define rio_dev_g(n)
#define rio_dev_f(n)
#define to_rio_dev(n)
#define sw_to_rio_dev(n)
#define to_rio_mport(n)
#define to_rio_net(n)

/**
 * struct rio_msg - RIO message event
 * @res: Mailbox resource
 * @mcback: Message event callback
 */
struct rio_msg {};

/**
 * struct rio_dbell - RIO doorbell event
 * @node: Node in list of doorbell events
 * @res: Doorbell resource
 * @dinb: Doorbell event callback
 * @dev_id: Device specific pointer to pass on event
 */
struct rio_dbell {};

/**
 * struct rio_mport - RIO master port info
 * @dbells: List of doorbell events
 * @pwrites: List of portwrite events
 * @node: Node in global list of master ports
 * @nnode: Node in network list of master ports
 * @net: RIO net this mport is attached to
 * @lock: lock to synchronize lists manipulations
 * @iores: I/O mem resource that this master port interface owns
 * @riores: RIO resources that this master port interfaces owns
 * @inb_msg: RIO inbound message event descriptors
 * @outb_msg: RIO outbound message event descriptors
 * @host_deviceid: Host device ID associated with this master port
 * @ops: configuration space functions
 * @id: Port ID, unique among all ports
 * @index: Port index, unique among all port interfaces of the same type
 * @sys_size: RapidIO common transport system size
 * @phys_efptr: RIO port extended features pointer
 * @phys_rmap: LP-Serial EFB Register Mapping type (1 or 2).
 * @name: Port name string
 * @dev: device structure associated with an mport
 * @priv: Master port private data
 * @dma: DMA device associated with mport
 * @nscan: RapidIO network enumeration/discovery operations
 * @state: mport device state
 * @pwe_refcnt: port-write enable ref counter to track enable/disable requests
 */
struct rio_mport {};

static inline int rio_mport_is_running(struct rio_mport *mport)
{}

/*
 * Enumeration/discovery control flags
 */
#define RIO_SCAN_ENUM_NO_WAIT

/**
 * struct rio_net - RIO network info
 * @node: Node in global list of RIO networks
 * @devices: List of devices in this network
 * @switches: List of switches in this network
 * @mports: List of master ports accessing this network
 * @hport: Default port for accessing this network
 * @id: RIO network ID
 * @dev: Device object
 * @enum_data: private data specific to a network enumerator
 * @release: enumerator-specific release callback
 */
struct rio_net {};

enum rio_link_speed {};

enum rio_link_width {};

enum rio_mport_flags {};

/**
 * struct rio_mport_attr - RIO mport device attributes
 * @flags: mport device capability flags
 * @link_speed: SRIO link speed value (as defined by RapidIO specification)
 * @link_width:	SRIO link width value (as defined by RapidIO specification)
 * @dma_max_sge: number of SG list entries that can be handled by DMA channel(s)
 * @dma_max_size: max number of bytes in single DMA transfer (SG entry)
 * @dma_align: alignment shift for DMA operations (as for other DMA operations)
 */
struct rio_mport_attr {};

/* Low-level architecture-dependent routines */

/**
 * struct rio_ops - Low-level RIO configuration space operations
 * @lcread: Callback to perform local (master port) read of config space.
 * @lcwrite: Callback to perform local (master port) write of config space.
 * @cread: Callback to perform network read of config space.
 * @cwrite: Callback to perform network write of config space.
 * @dsend: Callback to send a doorbell message.
 * @pwenable: Callback to enable/disable port-write message handling.
 * @open_outb_mbox: Callback to initialize outbound mailbox.
 * @close_outb_mbox: Callback to shut down outbound mailbox.
 * @open_inb_mbox: Callback to initialize inbound mailbox.
 * @close_inb_mbox: Callback to	shut down inbound mailbox.
 * @add_outb_message: Callback to add a message to an outbound mailbox queue.
 * @add_inb_buffer: Callback to	add a buffer to an inbound mailbox queue.
 * @get_inb_message: Callback to get a message from an inbound mailbox queue.
 * @map_inb: Callback to map RapidIO address region into local memory space.
 * @unmap_inb: Callback to unmap RapidIO address region mapped with map_inb().
 * @query_mport: Callback to query mport device attributes.
 * @map_outb: Callback to map outbound address region into local memory space.
 * @unmap_outb: Callback to unmap outbound RapidIO address region.
 */
struct rio_ops {};

#define RIO_RESOURCE_MEM
#define RIO_RESOURCE_DOORBELL
#define RIO_RESOURCE_MAILBOX

#define RIO_RESOURCE_CACHEABLE
#define RIO_RESOURCE_PCI

#define RIO_RESOURCE_BUSY

/**
 * struct rio_driver - RIO driver info
 * @node: Node in list of drivers
 * @name: RIO driver name
 * @id_table: RIO device ids to be associated with this driver
 * @probe: RIO device inserted
 * @remove: RIO device removed
 * @shutdown: shutdown notification callback
 * @suspend: RIO device suspended
 * @resume: RIO device awakened
 * @enable_wake: RIO device enable wake event
 * @driver: LDM driver struct
 *
 * Provides info on a RIO device driver for insertion/removal and
 * power management purposes.
 */
struct rio_driver {};

#define to_rio_driver(drv)

rio_pw_msg;

#ifdef CONFIG_RAPIDIO_DMA_ENGINE

/*
 * enum rio_write_type - RIO write transaction types used in DMA transfers
 *
 * Note: RapidIO specification defines write (NWRITE) and
 * write-with-response (NWRITE_R) data transfer operations.
 * Existing DMA controllers that service RapidIO may use one of these operations
 * for entire data transfer or their combination with only the last data packet
 * requires response.
 */
enum rio_write_type {};

struct rio_dma_ext {};

struct rio_dma_data {};

static inline struct rio_mport *dma_to_mport(struct dma_device *ddev)
{}
#endif /* CONFIG_RAPIDIO_DMA_ENGINE */

/**
 * struct rio_scan - RIO enumeration and discovery operations
 * @owner: The module owner of this structure
 * @enumerate: Callback to perform RapidIO fabric enumeration.
 * @discover: Callback to perform RapidIO fabric discovery.
 */
struct rio_scan {};

/**
 * struct rio_scan_node - list node to register RapidIO enumeration and
 * discovery methods with RapidIO core.
 * @mport_id: ID of an mport (net) serviced by this enumerator
 * @node: node in global list of registered enumerators
 * @ops: RIO enumeration and discovery operations
 */
struct rio_scan_node {};

/* Architecture and hardware-specific functions */
extern int rio_mport_initialize(struct rio_mport *);
extern int rio_register_mport(struct rio_mport *);
extern int rio_unregister_mport(struct rio_mport *);
extern int rio_open_inb_mbox(struct rio_mport *, void *, int, int);
extern void rio_close_inb_mbox(struct rio_mport *, int);
extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int);
extern void rio_close_outb_mbox(struct rio_mport *, int);
extern int rio_query_mport(struct rio_mport *port,
			   struct rio_mport_attr *mport_attr);

#endif				/* LINUX_RIO_H */