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 * 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.
24 * Intel MIC Card driver.
27 #ifndef _MIC_CARD_DEVICE_H_
28 #define _MIC_CARD_DEVICE_H_
30 #include <linux/workqueue.h>
32 #include <linux/irqreturn.h>
33 #include <linux/interrupt.h>
34 #include <linux/mic_bus.h>
37 * struct mic_intr_info - Contains h/w specific interrupt sources info
39 * @num_intr: The number of irqs available
41 struct mic_intr_info
{
46 * struct mic_irq_info - OS specific irq information
48 * @irq_usage_count: usage count array tracking the number of sources
49 * assigned for each irq.
56 * struct mic_device - MIC device information.
58 * @mmio: MMIO bar information.
65 * struct mic_driver - MIC card driver information.
67 * @name: Name for MIC driver.
68 * @dbg_dir: debugfs directory of this MIC device.
69 * @dev: The device backing this MIC.
70 * @dp: The pointer to the virtio device page.
71 * @mdev: MIC device information for the host.
72 * @hotplug_work: Hot plug work for adding/removing virtio devices.
73 * @irq_info: The OS specific irq information
74 * @intr_info: H/W specific interrupt information.
75 * @dma_mbdev: dma device on the MIC virtual bus.
79 struct dentry
*dbg_dir
;
82 struct mic_device mdev
;
83 struct work_struct hotplug_work
;
84 struct mic_irq_info irq_info
;
85 struct mic_intr_info intr_info
;
86 struct mbus_device
*dma_mbdev
;
90 * struct mic_irq - opaque pointer used as cookie
95 * mic_mmio_read - read from an MMIO register.
96 * @mw: MMIO register base virtual address.
97 * @offset: register offset.
99 * RETURNS: register value.
101 static inline u32
mic_mmio_read(struct mic_mw
*mw
, u32 offset
)
103 return ioread32(mw
->va
+ offset
);
107 * mic_mmio_write - write to an MMIO register.
108 * @mw: MMIO register base virtual address.
109 * @val: the data value to put into the register
110 * @offset: register offset.
115 mic_mmio_write(struct mic_mw
*mw
, u32 val
, u32 offset
)
117 iowrite32(val
, mw
->va
+ offset
);
120 int mic_driver_init(struct mic_driver
*mdrv
);
121 void mic_driver_uninit(struct mic_driver
*mdrv
);
122 int mic_next_card_db(void);
124 mic_request_card_irq(irq_handler_t handler
, irq_handler_t thread_fn
,
125 const char *name
, void *data
, int intr_src
);
126 void mic_free_card_irq(struct mic_irq
*cookie
, void *data
);
127 u32
mic_read_spad(struct mic_device
*mdev
, unsigned int idx
);
128 void mic_send_intr(struct mic_device
*mdev
, int doorbell
);
129 int mic_db_to_irq(struct mic_driver
*mdrv
, int db
);
130 u32
mic_ack_interrupt(struct mic_device
*mdev
);
131 void mic_hw_intr_init(struct mic_driver
*mdrv
);
133 mic_card_map(struct mic_device
*mdev
, dma_addr_t addr
, size_t size
);
134 void mic_card_unmap(struct mic_device
*mdev
, void __iomem
*addr
);
135 void __init
mic_create_card_debug_dir(struct mic_driver
*mdrv
);
136 void mic_delete_card_debug_dir(struct mic_driver
*mdrv
);
137 void __init
mic_init_card_debugfs(void);
138 void mic_exit_card_debugfs(void);