2 * Intel MIC Platform Software Stack (MPSS)
4 * Copyright(c) 2014 Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 2, as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * Intel Symmetric Communications Interface Bus driver.
20 * Everything a scif driver needs to work with any particular scif
21 * hardware abstraction layer.
23 #include <linux/dma-mapping.h>
25 #include <linux/mic_common.h>
26 #include "../common/mic_dev.h"
28 struct scif_hw_dev_id
{
33 #define MIC_SCIF_DEV 1
34 #define SCIF_DEV_ANY_ID 0xffffffff
37 * scif_hw_dev - representation of a hardware device abstracted for scif
38 * @hw_ops: the hardware ops supported by this device
39 * @id: the device type identification (used to match it with a driver)
40 * @mmio: MMIO memory window
41 * @aper: Aperture memory window
42 * @dev: underlying device
43 * @dnode - The destination node which this device will communicate with.
44 * @snode - The source node for this device.
45 * @dp - Self device page
46 * @rdp - Remote device page
47 * @dma_ch - Array of DMA channels
48 * @num_dma_ch - Number of DMA channels available
49 * @card_rel_da - Set to true if DMA addresses programmed in the DMA engine
50 * are relative to the card point of view
53 struct scif_hw_ops
*hw_ops
;
54 struct scif_hw_dev_id id
;
62 struct dma_chan
**dma_ch
;
68 * scif_driver - operations for a scif I/O driver
69 * @driver: underlying device driver (populate name and owner).
70 * @id_table: the ids serviced by this driver.
71 * @probe: the function to call when a device is found. Returns 0 or -errno.
72 * @remove: the function to call when a device is removed.
75 struct device_driver driver
;
76 const struct scif_hw_dev_id
*id_table
;
77 int (*probe
)(struct scif_hw_dev
*dev
);
78 void (*remove
)(struct scif_hw_dev
*dev
);
82 * scif_hw_ops - Hardware operations for accessing a SCIF device on the SCIF bus.
84 * @next_db: Obtain the next available doorbell.
85 * @request_irq: Request an interrupt on a particular doorbell.
86 * @free_irq: Free an interrupt requested previously.
87 * @ack_interrupt: acknowledge an interrupt in the ISR.
88 * @send_intr: Send an interrupt to the remote node on a specified doorbell.
89 * @send_p2p_intr: Send an interrupt to the peer node on a specified doorbell
90 * which is specifically targeted for a peer to peer node.
91 * @remap: Map a buffer with the specified physical address and length.
92 * @unmap: Unmap a buffer previously mapped.
95 int (*next_db
)(struct scif_hw_dev
*sdev
);
96 struct mic_irq
* (*request_irq
)(struct scif_hw_dev
*sdev
,
97 irqreturn_t (*func
)(int irq
,
99 const char *name
, void *data
,
101 void (*free_irq
)(struct scif_hw_dev
*sdev
,
102 struct mic_irq
*cookie
, void *data
);
103 void (*ack_interrupt
)(struct scif_hw_dev
*sdev
, int num
);
104 void (*send_intr
)(struct scif_hw_dev
*sdev
, int db
);
105 void (*send_p2p_intr
)(struct scif_hw_dev
*sdev
, int db
,
107 void __iomem
* (*remap
)(struct scif_hw_dev
*sdev
,
108 phys_addr_t pa
, size_t len
);
109 void (*unmap
)(struct scif_hw_dev
*sdev
, void __iomem
*va
);
112 int scif_register_driver(struct scif_driver
*driver
);
113 void scif_unregister_driver(struct scif_driver
*driver
);
115 scif_register_device(struct device
*pdev
, int id
,
116 const struct dma_map_ops
*dma_ops
,
117 struct scif_hw_ops
*hw_ops
, u8 dnode
, u8 snode
,
118 struct mic_mw
*mmio
, struct mic_mw
*aper
,
119 void *dp
, void __iomem
*rdp
,
120 struct dma_chan
**chan
, int num_chan
,
122 void scif_unregister_device(struct scif_hw_dev
*sdev
);
124 static inline struct scif_hw_dev
*dev_to_scif(struct device
*dev
)
126 return container_of(dev
, struct scif_hw_dev
, dev
);
129 static inline struct scif_driver
*drv_to_scif(struct device_driver
*drv
)
131 return container_of(drv
, struct scif_driver
, driver
);
133 #endif /* _SCIF_BUS_H */