Sudeep Dutt | aa27bad | 2013-09-05 16:42:06 -0700 | [diff] [blame] | 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> |
Siva Yerramreddy | 9c3d37c | 2014-07-11 14:04:24 -0700 | [diff] [blame] | 32 | #include <linux/interrupt.h> |
Siva Yerramreddy | a93a524 | 2014-07-11 14:04:25 -0700 | [diff] [blame] | 33 | #include <linux/mic_bus.h> |
Sudeep Dutt | dd8d8d4 | 2015-04-29 05:32:39 -0700 | [diff] [blame] | 34 | #include "../bus/scif_bus.h" |
Sudeep Dutt | c74c931 | 2016-02-08 15:48:18 -0800 | [diff] [blame] | 35 | #include "../bus/vop_bus.h" |
Sudeep Dutt | aa27bad | 2013-09-05 16:42:06 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * struct mic_intr_info - Contains h/w specific interrupt sources info |
| 39 | * |
| 40 | * @num_intr: The number of irqs available |
| 41 | */ |
| 42 | struct mic_intr_info { |
| 43 | u32 num_intr; |
| 44 | }; |
| 45 | |
| 46 | /** |
| 47 | * struct mic_irq_info - OS specific irq information |
| 48 | * |
| 49 | * @irq_usage_count: usage count array tracking the number of sources |
| 50 | * assigned for each irq. |
| 51 | */ |
| 52 | struct mic_irq_info { |
| 53 | int *irq_usage_count; |
| 54 | }; |
| 55 | |
| 56 | /** |
| 57 | * struct mic_device - MIC device information. |
| 58 | * |
| 59 | * @mmio: MMIO bar information. |
| 60 | */ |
| 61 | struct mic_device { |
| 62 | struct mic_mw mmio; |
| 63 | }; |
| 64 | |
| 65 | /** |
| 66 | * struct mic_driver - MIC card driver information. |
| 67 | * |
| 68 | * @name: Name for MIC driver. |
| 69 | * @dbg_dir: debugfs directory of this MIC device. |
| 70 | * @dev: The device backing this MIC. |
| 71 | * @dp: The pointer to the virtio device page. |
| 72 | * @mdev: MIC device information for the host. |
| 73 | * @hotplug_work: Hot plug work for adding/removing virtio devices. |
| 74 | * @irq_info: The OS specific irq information |
| 75 | * @intr_info: H/W specific interrupt information. |
Siva Yerramreddy | a93a524 | 2014-07-11 14:04:25 -0700 | [diff] [blame] | 76 | * @dma_mbdev: dma device on the MIC virtual bus. |
Sudeep Dutt | dd8d8d4 | 2015-04-29 05:32:39 -0700 | [diff] [blame] | 77 | * @dma_ch - Array of DMA channels |
| 78 | * @num_dma_ch - Number of DMA channels available |
| 79 | * @scdev: SCIF device on the SCIF virtual bus. |
Sudeep Dutt | c74c931 | 2016-02-08 15:48:18 -0800 | [diff] [blame] | 80 | * @vpdev: Virtio over PCIe device on the VOP virtual bus. |
Sudeep Dutt | aa27bad | 2013-09-05 16:42:06 -0700 | [diff] [blame] | 81 | */ |
| 82 | struct mic_driver { |
| 83 | char name[20]; |
| 84 | struct dentry *dbg_dir; |
| 85 | struct device *dev; |
| 86 | void __iomem *dp; |
| 87 | struct mic_device mdev; |
| 88 | struct work_struct hotplug_work; |
| 89 | struct mic_irq_info irq_info; |
| 90 | struct mic_intr_info intr_info; |
Siva Yerramreddy | a93a524 | 2014-07-11 14:04:25 -0700 | [diff] [blame] | 91 | struct mbus_device *dma_mbdev; |
Sudeep Dutt | dd8d8d4 | 2015-04-29 05:32:39 -0700 | [diff] [blame] | 92 | struct dma_chan *dma_ch[MIC_MAX_DMA_CHAN]; |
| 93 | int num_dma_ch; |
| 94 | struct scif_hw_dev *scdev; |
Sudeep Dutt | c74c931 | 2016-02-08 15:48:18 -0800 | [diff] [blame] | 95 | struct vop_device *vpdev; |
Sudeep Dutt | aa27bad | 2013-09-05 16:42:06 -0700 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | /** |
| 99 | * struct mic_irq - opaque pointer used as cookie |
| 100 | */ |
| 101 | struct mic_irq; |
| 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 | int mic_driver_init(struct mic_driver *mdrv); |
| 130 | void mic_driver_uninit(struct mic_driver *mdrv); |
| 131 | int mic_next_card_db(void); |
Siva Yerramreddy | a93a524 | 2014-07-11 14:04:25 -0700 | [diff] [blame] | 132 | struct mic_irq * |
| 133 | mic_request_card_irq(irq_handler_t handler, irq_handler_t thread_fn, |
Sudeep Dutt | dd8d8d4 | 2015-04-29 05:32:39 -0700 | [diff] [blame] | 134 | const char *name, void *data, int db); |
Sudeep Dutt | aa27bad | 2013-09-05 16:42:06 -0700 | [diff] [blame] | 135 | void mic_free_card_irq(struct mic_irq *cookie, void *data); |
| 136 | u32 mic_read_spad(struct mic_device *mdev, unsigned int idx); |
| 137 | void mic_send_intr(struct mic_device *mdev, int doorbell); |
Sudeep Dutt | dd8d8d4 | 2015-04-29 05:32:39 -0700 | [diff] [blame] | 138 | void mic_send_p2p_intr(int doorbell, struct mic_mw *mw); |
Sudeep Dutt | aa27bad | 2013-09-05 16:42:06 -0700 | [diff] [blame] | 139 | int mic_db_to_irq(struct mic_driver *mdrv, int db); |
| 140 | u32 mic_ack_interrupt(struct mic_device *mdev); |
| 141 | void mic_hw_intr_init(struct mic_driver *mdrv); |
| 142 | void __iomem * |
| 143 | mic_card_map(struct mic_device *mdev, dma_addr_t addr, size_t size); |
| 144 | void mic_card_unmap(struct mic_device *mdev, void __iomem *addr); |
| 145 | void __init mic_create_card_debug_dir(struct mic_driver *mdrv); |
| 146 | void mic_delete_card_debug_dir(struct mic_driver *mdrv); |
| 147 | void __init mic_init_card_debugfs(void); |
| 148 | void mic_exit_card_debugfs(void); |
| 149 | #endif |