Intel MIC Host Driver Interrupt/SMPT support.
[deliverable/linux.git] / drivers / misc / mic / host / 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 * Intel MIC Host driver.
19 *
20 */
21 #ifndef _MIC_DEVICE_H_
22 #define _MIC_DEVICE_H_
23
24 #include <linux/idr.h>
25
26 #include "mic_intr.h"
27
28 /* The maximum number of MIC devices supported in a single host system. */
29 #define MIC_MAX_NUM_DEVS 256
30
31 /**
32 * enum mic_hw_family - The hardware family to which a device belongs.
33 */
34 enum mic_hw_family {
35 MIC_FAMILY_X100 = 0,
36 MIC_FAMILY_UNKNOWN
37 };
38
39 /**
40 * enum mic_stepping - MIC stepping ids.
41 */
42 enum mic_stepping {
43 MIC_A0_STEP = 0x0,
44 MIC_B0_STEP = 0x10,
45 MIC_B1_STEP = 0x11,
46 MIC_C0_STEP = 0x20,
47 };
48
49 /**
50 * struct mic_device - MIC device information for each card.
51 *
52 * @mmio: MMIO bar information.
53 * @aper: Aperture bar information.
54 * @family: The MIC family to which this device belongs.
55 * @ops: MIC HW specific operations.
56 * @id: The unique device id for this MIC device.
57 * @stepping: Stepping ID.
58 * @attr_group: Pointer to list of sysfs attribute groups.
59 * @sdev: Device for sysfs entries.
60 * @mic_mutex: Mutex for synchronizing access to mic_device.
61 * @intr_ops: HW specific interrupt operations.
62 * @smpt_ops: Hardware specific SMPT operations.
63 * @smpt: MIC SMPT information.
64 * @intr_info: H/W specific interrupt information.
65 * @irq_info: The OS specific irq information
66 */
67 struct mic_device {
68 struct mic_mw mmio;
69 struct mic_mw aper;
70 enum mic_hw_family family;
71 struct mic_hw_ops *ops;
72 int id;
73 enum mic_stepping stepping;
74 const struct attribute_group **attr_group;
75 struct device *sdev;
76 struct mutex mic_mutex;
77 struct mic_hw_intr_ops *intr_ops;
78 struct mic_smpt_ops *smpt_ops;
79 struct mic_smpt_info *smpt;
80 struct mic_intr_info *intr_info;
81 struct mic_irq_info irq_info;
82 };
83
84 /**
85 * struct mic_hw_ops - MIC HW specific operations.
86 * @aper_bar: Aperture bar resource number.
87 * @mmio_bar: MMIO bar resource number.
88 * @read_spad: Read from scratch pad register.
89 * @write_spad: Write to scratch pad register.
90 * @send_intr: Send an interrupt for a particular doorbell on the card.
91 * @ack_interrupt: Hardware specific operations to ack the h/w on
92 * receipt of an interrupt.
93 */
94 struct mic_hw_ops {
95 u8 aper_bar;
96 u8 mmio_bar;
97 u32 (*read_spad)(struct mic_device *mdev, unsigned int idx);
98 void (*write_spad)(struct mic_device *mdev, unsigned int idx, u32 val);
99 void (*send_intr)(struct mic_device *mdev, int doorbell);
100 u32 (*ack_interrupt)(struct mic_device *mdev);
101 };
102
103 /**
104 * mic_mmio_read - read from an MMIO register.
105 * @mw: MMIO register base virtual address.
106 * @offset: register offset.
107 *
108 * RETURNS: register value.
109 */
110 static inline u32 mic_mmio_read(struct mic_mw *mw, u32 offset)
111 {
112 return ioread32(mw->va + offset);
113 }
114
115 /**
116 * mic_mmio_write - write to an MMIO register.
117 * @mw: MMIO register base virtual address.
118 * @val: the data value to put into the register
119 * @offset: register offset.
120 *
121 * RETURNS: none.
122 */
123 static inline void
124 mic_mmio_write(struct mic_mw *mw, u32 val, u32 offset)
125 {
126 iowrite32(val, mw->va + offset);
127 }
128
129 void mic_sysfs_init(struct mic_device *mdev);
130 #endif
This page took 0.035027 seconds and 5 git commands to generate.