Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux...
[cascardo/linux.git] / drivers / misc / mic / card / mic_device.h
1 /*
2  * Intel MIC Platform Software Stack (MPSS)
3  *
4  * Copyright(c) 2013 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  * Disclaimer: The codes contained in these modules may be specific to
19  * the Intel Software Development Platform codenamed: Knights Ferry, and
20  * the Intel product codenamed: Knights Corner, and are not backward
21  * compatible with other Intel products. Additionally, Intel will NOT
22  * support the codes or instruction set in future products.
23  *
24  * Intel MIC Card driver.
25  *
26  */
27 #ifndef _MIC_CARD_DEVICE_H_
28 #define _MIC_CARD_DEVICE_H_
29
30 #include <linux/workqueue.h>
31 #include <linux/io.h>
32
33 /**
34  * struct mic_intr_info - Contains h/w specific interrupt sources info
35  *
36  * @num_intr: The number of irqs available
37  */
38 struct mic_intr_info {
39         u32 num_intr;
40 };
41
42 /**
43  * struct mic_irq_info - OS specific irq information
44  *
45  * @irq_usage_count: usage count array tracking the number of sources
46  * assigned for each irq.
47  */
48 struct mic_irq_info {
49         int *irq_usage_count;
50 };
51
52 /**
53  * struct mic_device -  MIC device information.
54  *
55  * @mmio: MMIO bar information.
56  */
57 struct mic_device {
58         struct mic_mw mmio;
59 };
60
61 /**
62  * struct mic_driver - MIC card driver information.
63  *
64  * @name: Name for MIC driver.
65  * @dbg_dir: debugfs directory of this MIC device.
66  * @dev: The device backing this MIC.
67  * @dp: The pointer to the virtio device page.
68  * @mdev: MIC device information for the host.
69  * @hotplug_work: Hot plug work for adding/removing virtio devices.
70  * @irq_info: The OS specific irq information
71  * @intr_info: H/W specific interrupt information.
72  */
73 struct mic_driver {
74         char name[20];
75         struct dentry *dbg_dir;
76         struct device *dev;
77         void __iomem *dp;
78         struct mic_device mdev;
79         struct work_struct hotplug_work;
80         struct mic_irq_info irq_info;
81         struct mic_intr_info intr_info;
82 };
83
84 /**
85  * struct mic_irq - opaque pointer used as cookie
86  */
87 struct mic_irq;
88
89 /**
90  * mic_mmio_read - read from an MMIO register.
91  * @mw: MMIO register base virtual address.
92  * @offset: register offset.
93  *
94  * RETURNS: register value.
95  */
96 static inline u32 mic_mmio_read(struct mic_mw *mw, u32 offset)
97 {
98         return ioread32(mw->va + offset);
99 }
100
101 /**
102  * mic_mmio_write - write to an MMIO register.
103  * @mw: MMIO register base virtual address.
104  * @val: the data value to put into the register
105  * @offset: register offset.
106  *
107  * RETURNS: none.
108  */
109 static inline void
110 mic_mmio_write(struct mic_mw *mw, u32 val, u32 offset)
111 {
112         iowrite32(val, mw->va + offset);
113 }
114
115 int mic_driver_init(struct mic_driver *mdrv);
116 void mic_driver_uninit(struct mic_driver *mdrv);
117 int mic_next_card_db(void);
118 struct mic_irq *mic_request_card_irq(irqreturn_t (*func)(int irq, void *data),
119         const char *name, void *data, int intr_src);
120 void mic_free_card_irq(struct mic_irq *cookie, void *data);
121 u32 mic_read_spad(struct mic_device *mdev, unsigned int idx);
122 void mic_send_intr(struct mic_device *mdev, int doorbell);
123 int mic_db_to_irq(struct mic_driver *mdrv, int db);
124 u32 mic_ack_interrupt(struct mic_device *mdev);
125 void mic_hw_intr_init(struct mic_driver *mdrv);
126 void __iomem *
127 mic_card_map(struct mic_device *mdev, dma_addr_t addr, size_t size);
128 void mic_card_unmap(struct mic_device *mdev, void __iomem *addr);
129 void __init mic_create_card_debug_dir(struct mic_driver *mdrv);
130 void mic_delete_card_debug_dir(struct mic_driver *mdrv);
131 void __init mic_init_card_debugfs(void);
132 void mic_exit_card_debugfs(void);
133 #endif