blob: 1dbf83c412893503eacf957d0dfa771627b4724e [file] [log] [blame]
Sudeep Duttaa27bad2013-09-05 16:42:06 -07001/*
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 Yerramreddy9c3d37c2014-07-11 14:04:24 -070032#include <linux/interrupt.h>
Siva Yerramreddya93a5242014-07-11 14:04:25 -070033#include <linux/mic_bus.h>
Sudeep Duttdd8d8d42015-04-29 05:32:39 -070034#include "../bus/scif_bus.h"
Sudeep Duttaa27bad2013-09-05 16:42:06 -070035
36/**
37 * struct mic_intr_info - Contains h/w specific interrupt sources info
38 *
39 * @num_intr: The number of irqs available
40 */
41struct mic_intr_info {
42 u32 num_intr;
43};
44
45/**
46 * struct mic_irq_info - OS specific irq information
47 *
48 * @irq_usage_count: usage count array tracking the number of sources
49 * assigned for each irq.
50 */
51struct mic_irq_info {
52 int *irq_usage_count;
53};
54
55/**
56 * struct mic_device - MIC device information.
57 *
58 * @mmio: MMIO bar information.
59 */
60struct mic_device {
61 struct mic_mw mmio;
62};
63
64/**
65 * struct mic_driver - MIC card driver information.
66 *
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.
Siva Yerramreddya93a5242014-07-11 14:04:25 -070075 * @dma_mbdev: dma device on the MIC virtual bus.
Sudeep Duttdd8d8d42015-04-29 05:32:39 -070076 * @dma_ch - Array of DMA channels
77 * @num_dma_ch - Number of DMA channels available
78 * @scdev: SCIF device on the SCIF virtual bus.
Sudeep Duttaa27bad2013-09-05 16:42:06 -070079 */
80struct mic_driver {
81 char name[20];
82 struct dentry *dbg_dir;
83 struct device *dev;
84 void __iomem *dp;
85 struct mic_device mdev;
86 struct work_struct hotplug_work;
87 struct mic_irq_info irq_info;
88 struct mic_intr_info intr_info;
Siva Yerramreddya93a5242014-07-11 14:04:25 -070089 struct mbus_device *dma_mbdev;
Sudeep Duttdd8d8d42015-04-29 05:32:39 -070090 struct dma_chan *dma_ch[MIC_MAX_DMA_CHAN];
91 int num_dma_ch;
92 struct scif_hw_dev *scdev;
Sudeep Duttaa27bad2013-09-05 16:42:06 -070093};
94
95/**
96 * struct mic_irq - opaque pointer used as cookie
97 */
98struct mic_irq;
99
100/**
101 * mic_mmio_read - read from an MMIO register.
102 * @mw: MMIO register base virtual address.
103 * @offset: register offset.
104 *
105 * RETURNS: register value.
106 */
107static inline u32 mic_mmio_read(struct mic_mw *mw, u32 offset)
108{
109 return ioread32(mw->va + offset);
110}
111
112/**
113 * mic_mmio_write - write to an MMIO register.
114 * @mw: MMIO register base virtual address.
115 * @val: the data value to put into the register
116 * @offset: register offset.
117 *
118 * RETURNS: none.
119 */
120static inline void
121mic_mmio_write(struct mic_mw *mw, u32 val, u32 offset)
122{
123 iowrite32(val, mw->va + offset);
124}
125
126int mic_driver_init(struct mic_driver *mdrv);
127void mic_driver_uninit(struct mic_driver *mdrv);
128int mic_next_card_db(void);
Siva Yerramreddya93a5242014-07-11 14:04:25 -0700129struct mic_irq *
130mic_request_card_irq(irq_handler_t handler, irq_handler_t thread_fn,
Sudeep Duttdd8d8d42015-04-29 05:32:39 -0700131 const char *name, void *data, int db);
Sudeep Duttaa27bad2013-09-05 16:42:06 -0700132void mic_free_card_irq(struct mic_irq *cookie, void *data);
133u32 mic_read_spad(struct mic_device *mdev, unsigned int idx);
134void mic_send_intr(struct mic_device *mdev, int doorbell);
Sudeep Duttdd8d8d42015-04-29 05:32:39 -0700135void mic_send_p2p_intr(int doorbell, struct mic_mw *mw);
Sudeep Duttaa27bad2013-09-05 16:42:06 -0700136int mic_db_to_irq(struct mic_driver *mdrv, int db);
137u32 mic_ack_interrupt(struct mic_device *mdev);
138void mic_hw_intr_init(struct mic_driver *mdrv);
139void __iomem *
140mic_card_map(struct mic_device *mdev, dma_addr_t addr, size_t size);
141void mic_card_unmap(struct mic_device *mdev, void __iomem *addr);
142void __init mic_create_card_debug_dir(struct mic_driver *mdrv);
143void mic_delete_card_debug_dir(struct mic_driver *mdrv);
144void __init mic_init_card_debugfs(void);
145void mic_exit_card_debugfs(void);
146#endif