2005-11-07 17:00:16 +08:00
|
|
|
/*
|
|
|
|
* RapidIO interconnect services
|
|
|
|
* (RapidIO Interconnect Specification, http://www.rapidio.org)
|
|
|
|
*
|
|
|
|
* Copyright 2005 MontaVista Software, Inc.
|
|
|
|
* Matt Porter <mporter@kernel.crashing.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
|
|
|
#define RIO_NO_HOPCOUNT -1
|
2007-02-10 17:46:47 +08:00
|
|
|
#define RIO_INVALID_DESTID 0xffff
|
2005-11-07 17:00:16 +08:00
|
|
|
|
|
|
|
#define RIO_MAX_MPORT_RESOURCES 16
|
|
|
|
#define RIO_MAX_DEV_RESOURCES 16
|
|
|
|
|
|
|
|
#define RIO_GLOBAL_TABLE 0xff /* Indicates access of a switch's
|
|
|
|
global routing table if it
|
|
|
|
has multiple (or per port)
|
|
|
|
tables */
|
|
|
|
|
|
|
|
#define RIO_INVALID_ROUTE 0xff /* Indicates that a route table
|
|
|
|
entry is invalid (no route
|
|
|
|
exists for the device ID) */
|
|
|
|
|
2008-04-19 04:33:42 +08:00
|
|
|
#define RIO_MAX_ROUTE_ENTRIES(size) (size ? (1 << 16) : (1 << 8))
|
|
|
|
#define RIO_ANY_DESTID(size) (size ? 0xffff : 0xff)
|
2005-11-07 17:00:16 +08:00
|
|
|
|
|
|
|
#define RIO_MAX_MBOX 4
|
|
|
|
#define RIO_MAX_MSG_SIZE 0x1000
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Error values that may be returned by RIO functions.
|
|
|
|
*/
|
|
|
|
#define RIO_SUCCESSFUL 0x00
|
|
|
|
#define RIO_BAD_SIZE 0x81
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
* 1 RapidIO outbound mailboxes
|
|
|
|
*/
|
|
|
|
#define RIO_DOORBELL_RESOURCE 0
|
|
|
|
#define RIO_INB_MBOX_RESOURCE 1
|
|
|
|
#define RIO_OUTB_MBOX_RESOURCE 2
|
|
|
|
|
2010-05-27 05:43:59 +08:00
|
|
|
#define RIO_PW_MSG_SIZE 64
|
|
|
|
|
2005-11-07 17:00:16 +08:00
|
|
|
extern struct bus_type rio_bus_type;
|
2010-10-28 06:34:26 +08:00
|
|
|
extern struct device rio_bus;
|
2005-11-07 17:00:16 +08:00
|
|
|
extern struct list_head rio_devices; /* list of all devices */
|
|
|
|
|
|
|
|
struct rio_mport;
|
2010-05-27 05:43:59 +08:00
|
|
|
union rio_pw_msg;
|
2005-11-07 17:00:16 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* @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
|
2010-05-29 06:08:08 +08:00
|
|
|
* @comp_tag: RIO component tag
|
|
|
|
* @phys_efptr: RIO device extended features pointer
|
|
|
|
* @em_efptr: RIO Error Management features pointer
|
2005-11-07 17:00:18 +08:00
|
|
|
* @dma_mask: Mask of bits of RIO address this device implements
|
2005-11-07 17:00:16 +08:00
|
|
|
* @rswitch: Pointer to &struct rio_switch if valid for this device
|
|
|
|
* @driver: Driver claiming this device
|
|
|
|
* @dev: Device model device
|
|
|
|
* @riores: RIO resources this device owns
|
2010-05-29 06:08:08 +08:00
|
|
|
* @pwcback: port-write callback function for this device
|
2005-11-07 17:00:16 +08:00
|
|
|
* @destid: Network destination ID
|
2010-10-28 06:34:29 +08:00
|
|
|
* @prev: Previous RIO device connected to the current one
|
2005-11-07 17:00:16 +08:00
|
|
|
*/
|
|
|
|
struct rio_dev {
|
|
|
|
struct list_head global_list; /* node in list of all RIO devices */
|
|
|
|
struct list_head net_list; /* node in per net list */
|
|
|
|
struct rio_net *net; /* RIO net this device resides in */
|
|
|
|
u16 did;
|
|
|
|
u16 vid;
|
|
|
|
u32 device_rev;
|
|
|
|
u16 asm_did;
|
|
|
|
u16 asm_vid;
|
|
|
|
u16 asm_rev;
|
|
|
|
u16 efptr;
|
|
|
|
u32 pef;
|
2010-10-28 06:34:29 +08:00
|
|
|
u32 swpinfo;
|
2005-11-07 17:00:16 +08:00
|
|
|
u32 src_ops;
|
|
|
|
u32 dst_ops;
|
2010-05-27 05:43:59 +08:00
|
|
|
u32 comp_tag;
|
|
|
|
u32 phys_efptr;
|
|
|
|
u32 em_efptr;
|
2005-11-07 17:00:18 +08:00
|
|
|
u64 dma_mask;
|
2005-11-07 17:00:16 +08:00
|
|
|
struct rio_switch *rswitch; /* RIO switch info */
|
|
|
|
struct rio_driver *driver; /* RIO driver claiming this device */
|
|
|
|
struct device dev; /* LDM device structure */
|
|
|
|
struct resource riores[RIO_MAX_DEV_RESOURCES];
|
2010-05-27 05:43:59 +08:00
|
|
|
int (*pwcback) (struct rio_dev *rdev, union rio_pw_msg *msg, int step);
|
2005-11-07 17:00:16 +08:00
|
|
|
u16 destid;
|
2010-10-28 06:34:29 +08:00
|
|
|
struct rio_dev *prev;
|
2005-11-07 17:00:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define rio_dev_g(n) list_entry(n, struct rio_dev, global_list)
|
|
|
|
#define rio_dev_f(n) list_entry(n, struct rio_dev, net_list)
|
|
|
|
#define to_rio_dev(n) container_of(n, struct rio_dev, dev)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct rio_msg - RIO message event
|
|
|
|
* @res: Mailbox resource
|
|
|
|
* @mcback: Message event callback
|
|
|
|
*/
|
|
|
|
struct rio_msg {
|
|
|
|
struct resource *res;
|
2005-11-07 17:00:20 +08:00
|
|
|
void (*mcback) (struct rio_mport * mport, void *dev_id, int mbox, int slot);
|
2005-11-07 17:00:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct rio_dbell - RIO doorbell event
|
|
|
|
* @node: Node in list of doorbell events
|
|
|
|
* @res: Doorbell resource
|
|
|
|
* @dinb: Doorbell event callback
|
2005-11-07 17:00:20 +08:00
|
|
|
* @dev_id: Device specific pointer to pass on event
|
2005-11-07 17:00:16 +08:00
|
|
|
*/
|
|
|
|
struct rio_dbell {
|
|
|
|
struct list_head node;
|
|
|
|
struct resource *res;
|
2005-11-07 17:00:20 +08:00
|
|
|
void (*dinb) (struct rio_mport *mport, void *dev_id, u16 src, u16 dst, u16 info);
|
|
|
|
void *dev_id;
|
2005-11-07 17:00:16 +08:00
|
|
|
};
|
|
|
|
|
2008-04-19 04:33:44 +08:00
|
|
|
enum rio_phy_type {
|
|
|
|
RIO_PHY_PARALLEL,
|
|
|
|
RIO_PHY_SERIAL,
|
|
|
|
};
|
|
|
|
|
2005-11-07 17:00:16 +08:00
|
|
|
/**
|
|
|
|
* struct rio_mport - RIO master port info
|
|
|
|
* @dbells: List of doorbell events
|
|
|
|
* @node: Node in global list of master ports
|
|
|
|
* @nnode: Node in network list of master ports
|
|
|
|
* @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
|
2008-05-01 07:45:58 +08:00
|
|
|
* @sys_size: RapidIO common transport system size
|
|
|
|
* @phy_type: RapidIO phy type
|
2005-11-07 17:00:16 +08:00
|
|
|
* @name: Port name string
|
2008-04-19 04:33:41 +08:00
|
|
|
* @priv: Master port private data
|
2005-11-07 17:00:16 +08:00
|
|
|
*/
|
|
|
|
struct rio_mport {
|
|
|
|
struct list_head dbells; /* list of doorbell events */
|
|
|
|
struct list_head node; /* node in global list of ports */
|
|
|
|
struct list_head nnode; /* node in net list of ports */
|
|
|
|
struct resource iores;
|
|
|
|
struct resource riores[RIO_MAX_MPORT_RESOURCES];
|
|
|
|
struct rio_msg inb_msg[RIO_MAX_MBOX];
|
|
|
|
struct rio_msg outb_msg[RIO_MAX_MBOX];
|
|
|
|
int host_deviceid; /* Host device ID */
|
|
|
|
struct rio_ops *ops; /* maintenance transaction functions */
|
|
|
|
unsigned char id; /* port ID, unique among all ports */
|
|
|
|
unsigned char index; /* port index, unique among all port
|
|
|
|
interfaces of the same type */
|
2008-04-19 04:33:42 +08:00
|
|
|
unsigned int sys_size; /* RapidIO common transport system size.
|
|
|
|
* 0 - Small size. 256 devices.
|
|
|
|
* 1 - Large size, 65536 devices.
|
|
|
|
*/
|
2008-04-19 04:33:44 +08:00
|
|
|
enum rio_phy_type phy_type; /* RapidIO phy type */
|
2005-11-07 17:00:16 +08:00
|
|
|
unsigned char name[40];
|
2008-04-19 04:33:41 +08:00
|
|
|
void *priv; /* Master port private data */
|
2005-11-07 17:00:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct rio_net - RIO network info
|
|
|
|
* @node: Node in global list of RIO networks
|
|
|
|
* @devices: List of devices in this network
|
|
|
|
* @mports: List of master ports accessing this network
|
|
|
|
* @hport: Default port for accessing this network
|
|
|
|
* @id: RIO network ID
|
|
|
|
*/
|
|
|
|
struct rio_net {
|
|
|
|
struct list_head node; /* node in list of networks */
|
|
|
|
struct list_head devices; /* list of devices in this net */
|
|
|
|
struct list_head mports; /* list of ports accessing net */
|
|
|
|
struct rio_mport *hport; /* primary port for accessing net */
|
|
|
|
unsigned char id; /* RIO network ID */
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct rio_switch - RIO switch info
|
|
|
|
* @node: Node in global list of switches
|
2010-10-28 06:34:29 +08:00
|
|
|
* @rdev: Associated RIO device structure
|
2005-11-07 17:00:16 +08:00
|
|
|
* @switchid: Switch ID that is unique across a network
|
|
|
|
* @hopcount: Hopcount to this switch
|
|
|
|
* @destid: Associated destid in the path
|
|
|
|
* @route_table: Copy of switch routing table
|
2010-05-27 05:43:59 +08:00
|
|
|
* @port_ok: Status of each port (one bit per port) - OK=1 or UNINIT=0
|
2005-11-07 17:00:16 +08:00
|
|
|
* @add_entry: Callback for switch-specific route add function
|
|
|
|
* @get_entry: Callback for switch-specific route get function
|
2010-05-27 05:43:57 +08:00
|
|
|
* @clr_table: Callback for switch-specific clear route table function
|
2010-05-29 06:08:08 +08:00
|
|
|
* @set_domain: Callback for switch-specific domain setting function
|
|
|
|
* @get_domain: Callback for switch-specific domain get function
|
2010-05-27 05:43:59 +08:00
|
|
|
* @em_init: Callback for switch-specific error management initialization function
|
|
|
|
* @em_handle: Callback for switch-specific error management handler function
|
2010-10-28 06:34:29 +08:00
|
|
|
* @nextdev: Array of per-port pointers to the next attached device
|
2005-11-07 17:00:16 +08:00
|
|
|
*/
|
|
|
|
struct rio_switch {
|
|
|
|
struct list_head node;
|
2010-10-28 06:34:29 +08:00
|
|
|
struct rio_dev *rdev;
|
2005-11-07 17:00:16 +08:00
|
|
|
u16 switchid;
|
|
|
|
u16 hopcount;
|
|
|
|
u16 destid;
|
2008-04-19 04:33:42 +08:00
|
|
|
u8 *route_table;
|
2010-05-27 05:43:59 +08:00
|
|
|
u32 port_ok;
|
2005-11-07 17:00:16 +08:00
|
|
|
int (*add_entry) (struct rio_mport * mport, u16 destid, u8 hopcount,
|
|
|
|
u16 table, u16 route_destid, u8 route_port);
|
|
|
|
int (*get_entry) (struct rio_mport * mport, u16 destid, u8 hopcount,
|
|
|
|
u16 table, u16 route_destid, u8 * route_port);
|
2010-05-27 05:43:57 +08:00
|
|
|
int (*clr_table) (struct rio_mport *mport, u16 destid, u8 hopcount,
|
|
|
|
u16 table);
|
2010-05-27 05:44:04 +08:00
|
|
|
int (*set_domain) (struct rio_mport *mport, u16 destid, u8 hopcount,
|
|
|
|
u8 sw_domain);
|
|
|
|
int (*get_domain) (struct rio_mport *mport, u16 destid, u8 hopcount,
|
|
|
|
u8 *sw_domain);
|
2010-05-27 05:43:59 +08:00
|
|
|
int (*em_init) (struct rio_dev *dev);
|
|
|
|
int (*em_handle) (struct rio_dev *dev, u8 swport);
|
2010-10-28 06:34:29 +08:00
|
|
|
struct rio_dev *nextdev[0];
|
2005-11-07 17:00:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* 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.
|
2010-05-27 05:43:59 +08:00
|
|
|
* @pwenable: Callback to enable/disable port-write message handling.
|
2005-11-07 17:00:16 +08:00
|
|
|
*/
|
|
|
|
struct rio_ops {
|
2008-04-19 04:33:41 +08:00
|
|
|
int (*lcread) (struct rio_mport *mport, int index, u32 offset, int len,
|
|
|
|
u32 *data);
|
|
|
|
int (*lcwrite) (struct rio_mport *mport, int index, u32 offset, int len,
|
|
|
|
u32 data);
|
|
|
|
int (*cread) (struct rio_mport *mport, int index, u16 destid,
|
|
|
|
u8 hopcount, u32 offset, int len, u32 *data);
|
|
|
|
int (*cwrite) (struct rio_mport *mport, int index, u16 destid,
|
|
|
|
u8 hopcount, u32 offset, int len, u32 data);
|
|
|
|
int (*dsend) (struct rio_mport *mport, int index, u16 destid, u16 data);
|
2010-05-27 05:43:59 +08:00
|
|
|
int (*pwenable) (struct rio_mport *mport, int enable);
|
2005-11-07 17:00:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define RIO_RESOURCE_MEM 0x00000100
|
|
|
|
#define RIO_RESOURCE_DOORBELL 0x00000200
|
|
|
|
#define RIO_RESOURCE_MAILBOX 0x00000400
|
|
|
|
|
|
|
|
#define RIO_RESOURCE_CACHEABLE 0x00010000
|
|
|
|
#define RIO_RESOURCE_PCI 0x00020000
|
|
|
|
|
|
|
|
#define RIO_RESOURCE_BUSY 0x80000000
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* @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 {
|
|
|
|
struct list_head node;
|
|
|
|
char *name;
|
|
|
|
const struct rio_device_id *id_table;
|
|
|
|
int (*probe) (struct rio_dev * dev, const struct rio_device_id * id);
|
|
|
|
void (*remove) (struct rio_dev * dev);
|
|
|
|
int (*suspend) (struct rio_dev * dev, u32 state);
|
|
|
|
int (*resume) (struct rio_dev * dev);
|
|
|
|
int (*enable_wake) (struct rio_dev * dev, u32 state, int enable);
|
|
|
|
struct device_driver driver;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define to_rio_driver(drv) container_of(drv,struct rio_driver, driver)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct rio_device_id - RIO device identifier
|
|
|
|
* @did: RIO device ID
|
|
|
|
* @vid: RIO vendor ID
|
|
|
|
* @asm_did: RIO assembly device ID
|
|
|
|
* @asm_vid: RIO assembly vendor ID
|
|
|
|
*
|
|
|
|
* Identifies a RIO device based on both the device/vendor IDs and
|
|
|
|
* the assembly device/vendor IDs.
|
|
|
|
*/
|
|
|
|
struct rio_device_id {
|
|
|
|
u16 did, vid;
|
|
|
|
u16 asm_did, asm_vid;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2010-05-27 05:44:03 +08:00
|
|
|
* struct rio_switch_ops - Per-switch operations
|
2005-11-07 17:00:16 +08:00
|
|
|
* @vid: RIO vendor ID
|
|
|
|
* @did: RIO device ID
|
2010-05-27 05:44:03 +08:00
|
|
|
* @init_hook: Callback that performs switch device initialization
|
2005-11-07 17:00:16 +08:00
|
|
|
*
|
2010-05-27 05:44:03 +08:00
|
|
|
* Defines the operations that are necessary to initialize/control
|
|
|
|
* a particular RIO switch device.
|
2005-11-07 17:00:16 +08:00
|
|
|
*/
|
2010-05-27 05:44:03 +08:00
|
|
|
struct rio_switch_ops {
|
2005-11-07 17:00:16 +08:00
|
|
|
u16 vid, did;
|
2010-05-27 05:44:03 +08:00
|
|
|
int (*init_hook) (struct rio_dev *rdev, int do_enum);
|
2010-05-27 05:43:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
union rio_pw_msg {
|
|
|
|
struct {
|
|
|
|
u32 comptag; /* Component Tag CSR */
|
|
|
|
u32 errdetect; /* Port N Error Detect CSR */
|
|
|
|
u32 is_port; /* Implementation specific + PortID */
|
|
|
|
u32 ltlerrdet; /* LTL Error Detect CSR */
|
|
|
|
u32 padding[12];
|
|
|
|
} em;
|
|
|
|
u32 raw[RIO_PW_MSG_SIZE/sizeof(u32)];
|
|
|
|
};
|
|
|
|
|
2005-11-07 17:00:16 +08:00
|
|
|
/* Architecture and hardware-specific functions */
|
|
|
|
extern int rio_init_mports(void);
|
|
|
|
extern void rio_register_mport(struct rio_mport *);
|
|
|
|
extern int rio_hw_add_outb_message(struct rio_mport *, struct rio_dev *, int,
|
|
|
|
void *, size_t);
|
|
|
|
extern int rio_hw_add_inb_buffer(struct rio_mport *, int, void *);
|
|
|
|
extern void *rio_hw_get_inb_message(struct rio_mport *, int);
|
2005-11-07 17:00:20 +08:00
|
|
|
extern int rio_open_inb_mbox(struct rio_mport *, void *, int, int);
|
2005-11-07 17:00:16 +08:00
|
|
|
extern void rio_close_inb_mbox(struct rio_mport *, int);
|
2005-11-07 17:00:20 +08:00
|
|
|
extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int);
|
2005-11-07 17:00:16 +08:00
|
|
|
extern void rio_close_outb_mbox(struct rio_mport *, int);
|
|
|
|
|
|
|
|
#endif /* LINUX_RIO_H */
|