1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Intel MIC Platform Software Stack (MPSS)
5 * Copyright(c) 2014 Intel Corporation.
7 * Intel Symmetric Communications Interface Bus driver.
12 * Everything a scif driver needs to work with any particular scif
13 * hardware abstraction layer.
15 #include <linux/dma-mapping.h>
17 #include <linux/mic_common.h>
18 #include "../common/mic_dev.h"
20 struct scif_hw_dev_id
{
25 #define MIC_SCIF_DEV 1
26 #define SCIF_DEV_ANY_ID 0xffffffff
29 * scif_hw_dev - representation of a hardware device abstracted for scif
30 * @hw_ops: the hardware ops supported by this device
31 * @id: the device type identification (used to match it with a driver)
32 * @mmio: MMIO memory window
33 * @aper: Aperture memory window
34 * @dev: underlying device
35 * @dnode - The destination node which this device will communicate with.
36 * @snode - The source node for this device.
37 * @dp - Self device page
38 * @rdp - Remote device page
39 * @dma_ch - Array of DMA channels
40 * @num_dma_ch - Number of DMA channels available
41 * @card_rel_da - Set to true if DMA addresses programmed in the DMA engine
42 * are relative to the card point of view
45 struct scif_hw_ops
*hw_ops
;
46 struct scif_hw_dev_id id
;
54 struct dma_chan
**dma_ch
;
60 * scif_driver - operations for a scif I/O driver
61 * @driver: underlying device driver (populate name and owner).
62 * @id_table: the ids serviced by this driver.
63 * @probe: the function to call when a device is found. Returns 0 or -errno.
64 * @remove: the function to call when a device is removed.
67 struct device_driver driver
;
68 const struct scif_hw_dev_id
*id_table
;
69 int (*probe
)(struct scif_hw_dev
*dev
);
70 void (*remove
)(struct scif_hw_dev
*dev
);
74 * scif_hw_ops - Hardware operations for accessing a SCIF device on the SCIF bus.
76 * @next_db: Obtain the next available doorbell.
77 * @request_irq: Request an interrupt on a particular doorbell.
78 * @free_irq: Free an interrupt requested previously.
79 * @ack_interrupt: acknowledge an interrupt in the ISR.
80 * @send_intr: Send an interrupt to the remote node on a specified doorbell.
81 * @send_p2p_intr: Send an interrupt to the peer node on a specified doorbell
82 * which is specifically targeted for a peer to peer node.
83 * @remap: Map a buffer with the specified physical address and length.
84 * @unmap: Unmap a buffer previously mapped.
87 int (*next_db
)(struct scif_hw_dev
*sdev
);
88 struct mic_irq
* (*request_irq
)(struct scif_hw_dev
*sdev
,
89 irqreturn_t (*func
)(int irq
,
91 const char *name
, void *data
,
93 void (*free_irq
)(struct scif_hw_dev
*sdev
,
94 struct mic_irq
*cookie
, void *data
);
95 void (*ack_interrupt
)(struct scif_hw_dev
*sdev
, int num
);
96 void (*send_intr
)(struct scif_hw_dev
*sdev
, int db
);
97 void (*send_p2p_intr
)(struct scif_hw_dev
*sdev
, int db
,
99 void __iomem
* (*remap
)(struct scif_hw_dev
*sdev
,
100 phys_addr_t pa
, size_t len
);
101 void (*unmap
)(struct scif_hw_dev
*sdev
, void __iomem
*va
);
104 int scif_register_driver(struct scif_driver
*driver
);
105 void scif_unregister_driver(struct scif_driver
*driver
);
107 scif_register_device(struct device
*pdev
, int id
,
108 const struct dma_map_ops
*dma_ops
,
109 struct scif_hw_ops
*hw_ops
, u8 dnode
, u8 snode
,
110 struct mic_mw
*mmio
, struct mic_mw
*aper
,
111 void *dp
, void __iomem
*rdp
,
112 struct dma_chan
**chan
, int num_chan
,
114 void scif_unregister_device(struct scif_hw_dev
*sdev
);
116 static inline struct scif_hw_dev
*dev_to_scif(struct device
*dev
)
118 return container_of(dev
, struct scif_hw_dev
, dev
);
121 static inline struct scif_driver
*drv_to_scif(struct device_driver
*drv
)
123 return container_of(drv
, struct scif_driver
, driver
);
125 #endif /* _SCIF_BUS_H */