Merge tag 'topic/drm-misc-2016-05-04' of git://anongit.freedesktop.org/drm-intel...
[deliverable/linux.git] / include / linux / rio.h
index 8996a629a32189df2c5852dc204b36986a878cbe..aa2323893e8d68b8156fa6b9422ac12b20dc96a6 100644 (file)
@@ -137,6 +137,13 @@ struct rio_switch_ops {
        int (*em_handle) (struct rio_dev *dev, u8 swport);
 };
 
+enum rio_device_state {
+       RIO_DEVICE_INITIALIZING,
+       RIO_DEVICE_RUNNING,
+       RIO_DEVICE_GONE,
+       RIO_DEVICE_SHUTDOWN,
+};
+
 /**
  * struct rio_dev - RIO device info
  * @global_list: Node in list of all RIO devices
@@ -165,6 +172,7 @@ struct rio_switch_ops {
  * @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 {
@@ -194,6 +202,7 @@ struct rio_dev {
        u16 destid;
        u8 hopcount;
        struct rio_dev *prev;
+       atomic_t state;
        struct rio_switch rswitch[0];   /* RIO switch info */
 };
 
@@ -202,6 +211,7 @@ struct rio_dev {
 #define        to_rio_dev(n) container_of(n, struct rio_dev, dev)
 #define sw_to_rio_dev(n) container_of(n, struct rio_dev, rswitch[0])
 #define        to_rio_mport(n) container_of(n, struct rio_mport, dev)
+#define        to_rio_net(n) container_of(n, struct rio_net, dev)
 
 /**
  * struct rio_msg - RIO message event
@@ -235,8 +245,11 @@ enum rio_phy_type {
 /**
  * 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
@@ -253,11 +266,16 @@ enum rio_phy_type {
  * @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 {
        struct list_head dbells;        /* list of doorbell events */
+       struct list_head pwrites;       /* list of portwrite events */
        struct list_head node;  /* node in global list of ports */
        struct list_head nnode; /* node in net list of ports */
+       struct rio_net *net;    /* RIO net this mport is attached to */
+       struct mutex lock;
        struct resource iores;
        struct resource riores[RIO_MAX_MPORT_RESOURCES];
        struct rio_msg inb_msg[RIO_MAX_MBOX];
@@ -280,20 +298,20 @@ struct rio_mport {
        struct dma_device       dma;
 #endif
        struct rio_scan *nscan;
+       atomic_t state;
+       unsigned int pwe_refcnt;
 };
 
+static inline int rio_mport_is_running(struct rio_mport *mport)
+{
+       return atomic_read(&mport->state) == RIO_DEVICE_RUNNING;
+}
+
 /*
  * Enumeration/discovery control flags
  */
 #define RIO_SCAN_ENUM_NO_WAIT  0x00000001 /* Do not wait for enum completed */
 
-struct rio_id_table {
-       u16 start;      /* logical minimal id */
-       u32 max;        /* max number of IDs in table */
-       spinlock_t lock;
-       unsigned long *table;
-};
-
 /**
  * struct rio_net - RIO network info
  * @node: Node in global list of RIO networks
@@ -302,7 +320,9 @@ struct rio_id_table {
  * @mports: List of master ports accessing this network
  * @hport: Default port for accessing this network
  * @id: RIO network ID
- * @destid_table: destID allocation table
+ * @dev: Device object
+ * @enum_data: private data specific to a network enumerator
+ * @release: enumerator-specific release callback
  */
 struct rio_net {
        struct list_head node;  /* node in list of networks */
@@ -311,7 +331,9 @@ struct rio_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_id_table destid_table;  /* destID allocation table */
+       struct device dev;
+       void *enum_data;        /* private data for enumerator of the network */
+       void (*release)(struct rio_net *net);
 };
 
 enum rio_link_speed {
@@ -378,6 +400,8 @@ struct rio_mport_attr {
  * @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 {
        int (*lcread) (struct rio_mport *mport, int index, u32 offset, int len,
@@ -405,6 +429,9 @@ struct rio_ops {
        void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
        int (*query_mport)(struct rio_mport *mport,
                           struct rio_mport_attr *attr);
+       int (*map_outb)(struct rio_mport *mport, u16 destid, u64 rstart,
+                       u32 size, u32 flags, dma_addr_t *laddr);
+       void (*unmap_outb)(struct rio_mport *mport, u16 destid, u64 rstart);
 };
 
 #define RIO_RESOURCE_MEM       0x00000100
@@ -423,6 +450,7 @@ struct rio_ops {
  * @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
@@ -437,6 +465,7 @@ struct rio_driver {
        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);
+       void (*shutdown)(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);
@@ -523,7 +552,9 @@ 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);
This page took 0.029228 seconds and 5 git commands to generate.