Linux 4.6-rc6
[cris-mirror.git] / include / linux / mic_bus.h
blob27d7c95fd0da0cf88ecb0d7c7a03c0b5c96e0fe4
1 /*
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 * The full GNU General Public License is included in this distribution in
16 * the file called "COPYING".
18 * Intel MIC Bus driver.
20 * This implementation is very similar to the the virtio bus driver
21 * implementation @ include/linux/virtio.h.
23 #ifndef _MIC_BUS_H_
24 #define _MIC_BUS_H_
26 * Everything a mbus driver needs to work with any particular mbus
27 * implementation.
29 #include <linux/interrupt.h>
30 #include <linux/dma-mapping.h>
32 struct mbus_device_id {
33 __u32 device;
34 __u32 vendor;
37 #define MBUS_DEV_DMA_HOST 2
38 #define MBUS_DEV_DMA_MIC 3
39 #define MBUS_DEV_ANY_ID 0xffffffff
41 /**
42 * mbus_device - representation of a device using mbus
43 * @mmio_va: virtual address of mmio space
44 * @hw_ops: the hardware ops supported by this device.
45 * @id: the device type identification (used to match it with a driver).
46 * @dev: underlying device.
47 * be used to communicate with.
48 * @index: unique position on the mbus bus
50 struct mbus_device {
51 void __iomem *mmio_va;
52 struct mbus_hw_ops *hw_ops;
53 struct mbus_device_id id;
54 struct device dev;
55 int index;
58 /**
59 * mbus_driver - operations for a mbus I/O driver
60 * @driver: underlying device driver (populate name and owner).
61 * @id_table: the ids serviced by this driver.
62 * @probe: the function to call when a device is found. Returns 0 or -errno.
63 * @remove: the function to call when a device is removed.
65 struct mbus_driver {
66 struct device_driver driver;
67 const struct mbus_device_id *id_table;
68 int (*probe)(struct mbus_device *dev);
69 void (*scan)(struct mbus_device *dev);
70 void (*remove)(struct mbus_device *dev);
73 /**
74 * struct mic_irq - opaque pointer used as cookie
76 struct mic_irq;
78 /**
79 * mbus_hw_ops - Hardware operations for accessing a MIC device on the MIC bus.
81 struct mbus_hw_ops {
82 struct mic_irq* (*request_threaded_irq)(struct mbus_device *mbdev,
83 irq_handler_t handler,
84 irq_handler_t thread_fn,
85 const char *name, void *data,
86 int intr_src);
87 void (*free_irq)(struct mbus_device *mbdev,
88 struct mic_irq *cookie, void *data);
89 void (*ack_interrupt)(struct mbus_device *mbdev, int num);
92 struct mbus_device *
93 mbus_register_device(struct device *pdev, int id, struct dma_map_ops *dma_ops,
94 struct mbus_hw_ops *hw_ops, int index,
95 void __iomem *mmio_va);
96 void mbus_unregister_device(struct mbus_device *mbdev);
98 int mbus_register_driver(struct mbus_driver *drv);
99 void mbus_unregister_driver(struct mbus_driver *drv);
101 static inline struct mbus_device *dev_to_mbus(struct device *_dev)
103 return container_of(_dev, struct mbus_device, dev);
106 static inline struct mbus_driver *drv_to_mbus(struct device_driver *drv)
108 return container_of(drv, struct mbus_driver, driver);
111 #endif /* _MIC_BUS_H */