Merge tag 'chrome-platform-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.git] / include / linux / mic_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 * The full GNU General Public License is included in this distribution in
16 * the file called "COPYING".
17 *
18 * Intel MIC Bus driver.
19 *
20 * This implementation is very similar to the the virtio bus driver
21 * implementation @ include/linux/virtio.h.
22 */
23 #ifndef _MIC_BUS_H_
24 #define _MIC_BUS_H_
25 /*
26 * Everything a mbus driver needs to work with any particular mbus
27 * implementation.
28 */
29 #include <linux/interrupt.h>
30 #include <linux/dma-mapping.h>
31
32 struct mbus_device_id {
33 __u32 device;
34 __u32 vendor;
35 };
36
37 #define MBUS_DEV_DMA_HOST 2
38 #define MBUS_DEV_DMA_MIC 3
39 #define MBUS_DEV_ANY_ID 0xffffffff
40
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
49 */
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;
56 };
57
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.
64 */
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);
71 };
72
73 /**
74 * struct mic_irq - opaque pointer used as cookie
75 */
76 struct mic_irq;
77
78 /**
79 * mbus_hw_ops - Hardware operations for accessing a MIC device on the MIC bus.
80 */
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);
90 };
91
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);
97
98 int mbus_register_driver(struct mbus_driver *drv);
99 void mbus_unregister_driver(struct mbus_driver *drv);
100
101 static inline struct mbus_device *dev_to_mbus(struct device *_dev)
102 {
103 return container_of(_dev, struct mbus_device, dev);
104 }
105
106 static inline struct mbus_driver *drv_to_mbus(struct device_driver *drv)
107 {
108 return container_of(drv, struct mbus_driver, driver);
109 }
110
111 #endif /* _MIC_BUS_H */
This page took 0.046022 seconds and 6 git commands to generate.