Merge branch 'r6040-next'
[linux/fpc-iii.git] / drivers / misc / mic / host / mic_intr.h
blobcce28824db8a7fd8bbcf841978c1c1e9eba42de4
1 /*
2 * Intel MIC Platform Software Stack (MPSS)
4 * Copyright(c) 2013 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 Host driver.
21 #ifndef _MIC_INTR_H_
22 #define _MIC_INTR_H_
24 #include <linux/bitops.h>
25 #include <linux/interrupt.h>
27 * The minimum number of msix vectors required for normal operation.
28 * 3 for virtio network, console and block devices.
29 * 1 for card shutdown notifications.
30 * 4 for host owned DMA channels.
31 * 1 for SCIF
33 #define MIC_MIN_MSIX 9
34 #define MIC_NUM_OFFSETS 32
36 /**
37 * mic_intr_source - The type of source that will generate
38 * the interrupt.The number of types needs to be in sync with
39 * MIC_NUM_INTR_TYPES
41 * MIC_INTR_DB: The source is a doorbell
42 * MIC_INTR_DMA: The source is a DMA channel
43 * MIC_INTR_ERR: The source is an error interrupt e.g. SBOX ERR
44 * MIC_NUM_INTR_TYPES: Total number of interrupt sources.
46 enum mic_intr_type {
47 MIC_INTR_DB = 0,
48 MIC_INTR_DMA,
49 MIC_INTR_ERR,
50 MIC_NUM_INTR_TYPES
53 /**
54 * struct mic_intr_info - Contains h/w specific interrupt sources
55 * information.
57 * @intr_start_idx: Contains the starting indexes of the
58 * interrupt types.
59 * @intr_len: Contains the length of the interrupt types.
61 struct mic_intr_info {
62 u16 intr_start_idx[MIC_NUM_INTR_TYPES];
63 u16 intr_len[MIC_NUM_INTR_TYPES];
66 /**
67 * struct mic_irq_info - OS specific irq information
69 * @next_avail_src: next available doorbell that can be assigned.
70 * @msix_entries: msix entries allocated while setting up MSI-x
71 * @mic_msi_map: The MSI/MSI-x mapping information.
72 * @num_vectors: The number of MSI/MSI-x vectors that have been allocated.
73 * @cb_ida: callback ID allocator to track the callbacks registered.
74 * @mic_intr_lock: spinlock to protect the interrupt callback list.
75 * @mic_thread_lock: spinlock to protect the thread callback list.
76 * This lock is used to protect against thread_fn while
77 * mic_intr_lock is used to protect against interrupt handler.
78 * @cb_list: Array of callback lists one for each source.
79 * @mask: Mask used by the main thread fn to call the underlying thread fns.
81 struct mic_irq_info {
82 int next_avail_src;
83 struct msix_entry *msix_entries;
84 u32 *mic_msi_map;
85 u16 num_vectors;
86 struct ida cb_ida;
87 spinlock_t mic_intr_lock;
88 spinlock_t mic_thread_lock;
89 struct list_head *cb_list;
90 unsigned long mask;
93 /**
94 * struct mic_intr_cb - Interrupt callback structure.
96 * @handler: The callback function
97 * @thread_fn: The thread_fn.
98 * @data: Private data of the requester.
99 * @cb_id: The callback id. Identifies this callback.
100 * @list: list head pointing to the next callback structure.
102 struct mic_intr_cb {
103 irq_handler_t handler;
104 irq_handler_t thread_fn;
105 void *data;
106 int cb_id;
107 struct list_head list;
111 * struct mic_irq - opaque pointer used as cookie
113 struct mic_irq;
115 /* Forward declaration */
116 struct mic_device;
119 * struct mic_hw_intr_ops: MIC HW specific interrupt operations
120 * @intr_init: Initialize H/W specific interrupt information.
121 * @enable_interrupts: Enable interrupts from the hardware.
122 * @disable_interrupts: Disable interrupts from the hardware.
123 * @program_msi_to_src_map: Update MSI mapping registers with
124 * irq information.
125 * @read_msi_to_src_map: Read MSI mapping registers containing
126 * irq information.
128 struct mic_hw_intr_ops {
129 void (*intr_init)(struct mic_device *mdev);
130 void (*enable_interrupts)(struct mic_device *mdev);
131 void (*disable_interrupts)(struct mic_device *mdev);
132 void (*program_msi_to_src_map) (struct mic_device *mdev,
133 int idx, int intr_src, bool set);
134 u32 (*read_msi_to_src_map) (struct mic_device *mdev,
135 int idx);
138 int mic_next_db(struct mic_device *mdev);
139 struct mic_irq *
140 mic_request_threaded_irq(struct mic_device *mdev,
141 irq_handler_t handler, irq_handler_t thread_fn,
142 const char *name, void *data, int intr_src,
143 enum mic_intr_type type);
144 void mic_free_irq(struct mic_device *mdev,
145 struct mic_irq *cookie, void *data);
146 int mic_setup_interrupts(struct mic_device *mdev, struct pci_dev *pdev);
147 void mic_free_interrupts(struct mic_device *mdev, struct pci_dev *pdev);
148 void mic_intr_restore(struct mic_device *mdev);
149 #endif