Commit | Line | Data |
---|---|---|
800f879a AT |
1 | /* |
2 | * Copyright 2010-2017 Intel Corporation. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License, version 2, | |
6 | * as published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
11 | * General Public License for more details. | |
12 | * | |
13 | * Disclaimer: The codes contained in these modules may be specific to | |
14 | * the Intel Software Development Platform codenamed Knights Ferry, | |
15 | * and the Intel product codenamed Knights Corner, and are not backward | |
16 | * compatible with other Intel products. Additionally, Intel will NOT | |
17 | * support the codes or instruction set in future products. | |
18 | * | |
19 | * Intel offers no warranty of any kind regarding the code. This code is | |
20 | * licensed on an "AS IS" basis and Intel is not obligated to provide | |
21 | * any support, assistance, installation, training, or other services | |
22 | * of any kind. Intel is also not obligated to provide any updates, | |
23 | * enhancements or extensions. Intel specifically disclaims any warranty | |
24 | * of merchantability, non-infringement, fitness for any particular | |
25 | * purpose, and any other warranty. | |
26 | * | |
27 | * Further, Intel disclaims all liability of any kind, including but | |
28 | * not limited to liability for infringement of any proprietary rights, | |
29 | * relating to the use of the code, even if Intel is notified of the | |
30 | * possibility of such liability. Except as expressly stated in an Intel | |
31 | * license agreement provided with this code and agreed upon with Intel, | |
32 | * no license, express or implied, by estoppel or otherwise, to any | |
33 | * intellectual property rights is granted herein. | |
34 | */ | |
35 | ||
36 | #ifndef MICVCONS_H | |
37 | #define MICVCONS_H | |
38 | ||
39 | #include <linux/tty.h> | |
40 | #include <linux/tty_flip.h> | |
41 | ||
42 | #include <linux/errno.h> | |
43 | #include <linux/hardirq.h> | |
44 | #include <linux/types.h> | |
45 | #include <linux/capability.h> | |
46 | #include <linux/slab.h> | |
47 | #include <linux/string.h> | |
48 | #include <linux/gfp.h> | |
49 | #include <linux/vmalloc.h> | |
50 | #include <asm/io.h> | |
51 | #include <linux/kernel.h> | |
52 | #include <linux/mm_types.h> | |
53 | #include <linux/jiffies.h> | |
54 | #include <linux/timer.h> | |
55 | #include <linux/irqflags.h> | |
56 | #include <linux/time.h> | |
57 | #include <linux/spinlock.h> | |
58 | #include <linux/mutex.h> | |
59 | #include <linux/semaphore.h> | |
60 | #include <linux/kthread.h> | |
61 | #include <linux/sched.h> | |
62 | #include <linux/delay.h> | |
63 | #include <linux/wait.h> | |
64 | #include <asm/bug.h> | |
65 | #include <linux/pci.h> | |
66 | #include <linux/device.h> | |
67 | #include <linux/fs.h> | |
68 | #include <linux/list.h> | |
69 | #include <linux/workqueue.h> | |
70 | #include <linux/interrupt.h> | |
71 | #include <asm/atomic.h> | |
72 | #include <linux/netdevice.h> | |
73 | #include <linux/debugfs.h> | |
74 | #include <mic/micscif.h> | |
75 | #include <mic/micscif_nm.h> | |
76 | ||
77 | #define MICVCONS_DEVICE_NAME "ttyMIC" | |
78 | ||
79 | #define MICVCONS_BUF_SIZE PAGE_SIZE | |
80 | #define MICDCONS_MAX_OUTPUT_BYTES 64 | |
81 | #define MICVCONS_SHORT_TIMEOUT 100 | |
82 | #define MICVCONS_MAX_TIMEOUT 500 | |
83 | ||
84 | #define MIC_VCONS_READY 0xc0de | |
85 | #define MIC_VCONS_SLEEPING 0xd00d | |
86 | #define MIC_VCONS_WAKINGUP 0xd12d | |
87 | #define MIC_HOST_VCONS_READY 0xbad0 | |
88 | #define MIC_VCONS_HOST_OPEN 0xbad1 | |
89 | #define MIC_VCONS_RB_VER_ERR 0xbad2 | |
90 | ||
91 | #define MICVCONS_TIMER_RESTART 1 | |
92 | #define MICVCONS_TIMER_SHUTDOWN 0 | |
93 | ||
94 | typedef struct micvcons { | |
95 | int dc_enabled; | |
96 | void *dc_hdr_virt; | |
97 | void *dc_buf_virt; | |
98 | dma_addr_t dc_hdr_dma_addr; | |
99 | dma_addr_t dc_dma_addr; | |
100 | uint32_t dc_size; | |
101 | } micvcons_t; | |
102 | ||
103 | typedef struct micvcons_port { | |
104 | struct board_info *dp_bdinfo; | |
105 | struct micvcons *dp_vcons; | |
106 | struct micscif_rb *dp_in; | |
107 | struct micscif_rb *dp_out; | |
108 | struct tty_struct *dp_tty; | |
109 | struct list_head list_member; | |
110 | /* | |
111 | * work queue to schedule work that wakes up a sleeping card | |
112 | * and read the data from the buffer. | |
113 | */ | |
114 | struct workqueue_struct *dp_wq; | |
115 | struct work_struct dp_wakeup_read_buf; | |
116 | ||
117 | spinlock_t dp_lock; | |
118 | struct mutex dp_mutex; | |
119 | ||
120 | volatile int dp_bytes; | |
121 | volatile uint32_t dp_canread; | |
122 | ||
123 | volatile struct file *dp_reader; | |
124 | volatile struct file *dp_writer; | |
125 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) | |
126 | struct tty_port port; | |
127 | #endif | |
128 | } micvcons_port_t; | |
129 | ||
130 | /* vcons IPC layout */ | |
131 | struct vcons_buf | |
132 | { | |
133 | uint32_t host_magic; | |
134 | uint32_t mic_magic; | |
135 | ||
136 | uint16_t host_rb_ver; | |
137 | uint16_t mic_rb_ver; | |
138 | ||
139 | /* mic o/p buffer */ | |
140 | dma_addr_t o_buf_dma_addr; /* host buf dma addr*/ | |
141 | uint32_t o_wr; | |
142 | uint32_t o_size; | |
143 | ||
144 | /* mic i/p buffer */ | |
145 | uint64_t i_hdr_addr; /* mic hdr addr */ | |
146 | uint64_t i_buf_addr; /* mic buf addr */ | |
147 | uint32_t i_rd; | |
148 | uint32_t i_size; | |
149 | }; | |
150 | ||
151 | struct vcons_mic_header | |
152 | { | |
153 | uint32_t o_rd; | |
154 | uint32_t i_wr; | |
155 | uint32_t host_status; | |
156 | }; | |
157 | ||
158 | int micvcons_start(struct _mic_ctx_t *mic_ctx); | |
159 | int micvcons_port_write(struct micvcons_port *port, const unsigned char *buf, | |
160 | int count); | |
161 | struct _mic_ctx_t; | |
162 | void micvcons_stop(struct _mic_ctx_t *mic_ctx); | |
163 | int micvcons_pm_disconnect_node(uint8_t *node_bitmask, enum disconn_type type); | |
164 | #endif /* MICVCONS_H */ |