]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/misc/mic/bus/scif_bus.h
Merge branch 'for-4.3/gembird' into for-linus
[karo-tx-linux.git] / drivers / misc / mic / bus / scif_bus.h
1 /*
2  * Intel MIC Platform Software Stack (MPSS)
3  *
4  * Copyright(c) 2014 Intel Corporation.
5  *
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.
9  *
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.
14  *
15  * Intel Symmetric Communications Interface Bus driver.
16  */
17 #ifndef _SCIF_BUS_H_
18 #define _SCIF_BUS_H_
19 /*
20  * Everything a scif driver needs to work with any particular scif
21  * hardware abstraction layer.
22  */
23 #include <linux/dma-mapping.h>
24
25 #include <linux/mic_common.h>
26 #include "../common/mic_dev.h"
27
28 struct scif_hw_dev_id {
29         u32 device;
30         u32 vendor;
31 };
32
33 #define MIC_SCIF_DEV 1
34 #define SCIF_DEV_ANY_ID 0xffffffff
35
36 /**
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  */
50 struct scif_hw_dev {
51         struct scif_hw_ops *hw_ops;
52         struct scif_hw_dev_id id;
53         struct mic_mw *mmio;
54         struct mic_mw *aper;
55         struct device dev;
56         u8 dnode;
57         u8 snode;
58         void *dp;
59         void __iomem *rdp;
60         struct dma_chan **dma_ch;
61         int num_dma_ch;
62 };
63
64 /**
65  * scif_driver - operations for a scif I/O driver
66  * @driver: underlying device driver (populate name and owner).
67  * @id_table: the ids serviced by this driver.
68  * @probe: the function to call when a device is found.  Returns 0 or -errno.
69  * @remove: the function to call when a device is removed.
70  */
71 struct scif_driver {
72         struct device_driver driver;
73         const struct scif_hw_dev_id *id_table;
74         int (*probe)(struct scif_hw_dev *dev);
75         void (*remove)(struct scif_hw_dev *dev);
76 };
77
78 /**
79  * scif_hw_ops - Hardware operations for accessing a SCIF device on the SCIF bus.
80  *
81  * @next_db: Obtain the next available doorbell.
82  * @request_irq: Request an interrupt on a particular doorbell.
83  * @free_irq: Free an interrupt requested previously.
84  * @ack_interrupt: acknowledge an interrupt in the ISR.
85  * @send_intr: Send an interrupt to the remote node on a specified doorbell.
86  * @send_p2p_intr: Send an interrupt to the peer node on a specified doorbell
87  * which is specifically targeted for a peer to peer node.
88  * @ioremap: Map a buffer with the specified physical address and length.
89  * @iounmap: Unmap a buffer previously mapped.
90  */
91 struct scif_hw_ops {
92         int (*next_db)(struct scif_hw_dev *sdev);
93         struct mic_irq * (*request_irq)(struct scif_hw_dev *sdev,
94                                         irqreturn_t (*func)(int irq,
95                                                             void *data),
96                                         const char *name, void *data,
97                                         int db);
98         void (*free_irq)(struct scif_hw_dev *sdev,
99                          struct mic_irq *cookie, void *data);
100         void (*ack_interrupt)(struct scif_hw_dev *sdev, int num);
101         void (*send_intr)(struct scif_hw_dev *sdev, int db);
102         void (*send_p2p_intr)(struct scif_hw_dev *sdev, int db,
103                               struct mic_mw *mw);
104         void __iomem * (*ioremap)(struct scif_hw_dev *sdev,
105                                   phys_addr_t pa, size_t len);
106         void (*iounmap)(struct scif_hw_dev *sdev, void __iomem *va);
107 };
108
109 int scif_register_driver(struct scif_driver *driver);
110 void scif_unregister_driver(struct scif_driver *driver);
111 struct scif_hw_dev *
112 scif_register_device(struct device *pdev, int id,
113                      struct dma_map_ops *dma_ops,
114                      struct scif_hw_ops *hw_ops, u8 dnode, u8 snode,
115                      struct mic_mw *mmio, struct mic_mw *aper,
116                      void *dp, void __iomem *rdp,
117                      struct dma_chan **chan, int num_chan);
118 void scif_unregister_device(struct scif_hw_dev *sdev);
119
120 static inline struct scif_hw_dev *dev_to_scif(struct device *dev)
121 {
122         return container_of(dev, struct scif_hw_dev, dev);
123 }
124
125 static inline struct scif_driver *drv_to_scif(struct device_driver *drv)
126 {
127         return container_of(drv, struct scif_driver, driver);
128 }
129 #endif /* _SCIF_BUS_H */