1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
From 60bb8e915a1e55c5a562e59e694d37559d62de92 Mon Sep 17 00:00:00 2001
From: Sreenidhi Gurudatt <sreenidhi.b.gurudatt@intel.com>
Date: Mon, 3 Aug 2009 14:46:37 +0530
Subject: [PATCH 073/104] IPC Host driver for MRSTN. It is disabled by default. This driver implements basic ioctls to support testing of IPC driver from user space. It supports Device firmware upgrade feature to be invoked by user-space application.
modified: drivers/misc/Kconfig
modified: drivers/misc/Makefile
new file: drivers/misc/mrst_test_ipc/Makefile
new file: drivers/misc/mrst_test_ipc/ipc_module.c
Signed-off-by: Sreenidhi Gurudatt <sreenidhi.b.gurudatt@intel.com>
---
drivers/misc/Kconfig | 9 ++
drivers/misc/Makefile | 1 +
drivers/misc/mrst_test_ipc/Makefile | 5 +
drivers/misc/mrst_test_ipc/ipc_module.c | 196 +++++++++++++++++++++++++++++++
4 files changed, 211 insertions(+), 0 deletions(-)
create mode 100644 drivers/misc/mrst_test_ipc/Makefile
create mode 100644 drivers/misc/mrst_test_ipc/ipc_module.c
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index feb9cd9..5a7c342 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -260,6 +260,15 @@ config MRST_RAR_HANDLER
If unsure, say N.
+config MRST_IPC_TEST
+ tristate "IPC driver for testing IPC on Moorestown platform"
+ depends on X86
+ ---help---
+ IPC test driver for Intel Moorestown platform
+ Intel Moorestown platform.
+
+ If unsure, say N.
+
config MRST_VIB
tristate "vibrator driver for Intel Moorestown platform"
help
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 0c24f0f..bce8396 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_TIFM_CORE) += tifm_core.o
obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o
obj-$(CONFIG_PHANTOM) += phantom.o
obj-$(CONFIG_SGI_IOC4) += ioc4.o
+obj-$(CONFIG_MRST_IPC_TEST) += mrst_test_ipc/
obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o
obj-$(CONFIG_KGDB_TESTS) += kgdbts.o
obj-$(CONFIG_SGI_XP) += sgi-xp/
diff --git a/drivers/misc/mrst_test_ipc/Makefile b/drivers/misc/mrst_test_ipc/Makefile
new file mode 100644
index 0000000..047d7db
--- /dev/null
+++ b/drivers/misc/mrst_test_ipc/Makefile
@@ -0,0 +1,5 @@
+
+obj-$(CONFIG_MRST_IPC_TEST) := test_ipc_mrst.o
+
+test_ipc_mrst-y := ipc_module.o \
+
diff --git a/drivers/misc/mrst_test_ipc/ipc_module.c b/drivers/misc/mrst_test_ipc/ipc_module.c
new file mode 100644
index 0000000..51ef8de
--- /dev/null
+++ b/drivers/misc/mrst_test_ipc/ipc_module.c
@@ -0,0 +1,196 @@
+/*
+ * ipc_module.c - Interface for IPC driver funtions exported by IPC driver
+ * interfaces for Moorsetown platform.
+ *
+ * Copyright (C) 2009 Intel Corp
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * This driver provides IOCTL interfaces to call IPC driver module for
+ * Moorestown platform.
+ *
+ * Author: Sreenidhi Gurudatt <sreenidhi.b.gurudatt@intel.com>
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+
+#include <linux/slab.h>
+#include <linux/fs.h>
+#include <linux/errno.h>
+#include <linux/types.h>
+#include <linux/proc_fs.h>
+#include <linux/fcntl.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/sched.h>
+#include <linux/ioport.h>
+
+#include <linux/io.h>
+#include <linux/uaccess.h>
+#include <linux/time.h>
+
+#include <asm/ipc_defs.h>
+
+static u32 major;
+#define MAX_FW_SIZE 264192
+
+int init_ipc_driver(void);
+int ipc_ioctl(struct inode *inode, struct file *filp, u32 cmd,
+ unsigned long arg);
+const struct file_operations ipc_fops = {
+ioctl:ipc_ioctl,
+};
+
+
+int ipc_ioctl(struct inode *inode, struct file *filp, u32 cmd,
+ unsigned long arg)
+{
+ u32 upper = 0;
+ struct ipc_pmic_reg_data p_read_reg_data = { 0 };
+ struct ipc_pmic_mod_reg_data p_read_mod_reg_data = { 0 };
+ struct ipc_pmic_reg_data p_write_reg_data = { 0 };
+ u8 ipc_blocking_flag = TRUE;
+
+ int ret_val;
+ /*Device FW upgrade support*/
+ u8 *fw_buf = NULL ;
+
+ switch (cmd) {
+ case IPC_PMIC_REGISTER_READ:
+ {
+ printk(KERN_INFO
+ "ipc_driver IPC_PMIC_REGISTER_READ received\n");
+ ret_val =
+ copy_from_user(&p_read_reg_data,
+ (struct ipc_pmic_reg_data *)arg,
+ sizeof(struct ipc_pmic_reg_data));
+ if (ret_val < 0) {
+ printk(KERN_DEBUG
+ "copy_from_user FAILED!! <%s> function\
+ in <%s> file at <%d> line no\n",\
+ __func__, __FILE__, __LINE__);
+ return E_READ_USER_DATA;
+ }
+
+ ipc_pmic_register_read(&p_read_reg_data);
+ ret_val =
+ copy_to_user((struct ipc_pmic_reg_data *)arg,
+ &p_read_reg_data,
+ sizeof(struct ipc_pmic_reg_data));
+ break;
+ }
+ case IPC_PMIC_REGISTER_READ_MODIFY:
+ {
+ printk(KERN_INFO "ioctl\
+ IPC_PMIC_REGISTER_READ_MODIFY received\n");
+ ret_val =
+ copy_from_user(&p_read_mod_reg_data,
+ (struct ipc_pmic_mod_reg_data *)arg,
+ sizeof(struct ipc_pmic_mod_reg_data));
+ if (ret_val < 0) {
+ printk(KERN_DEBUG
+ "copy_from_user FAILED!! <%s> function\
+ in <%s> file at <%d> line no\n",\
+ __func__, __FILE__, __LINE__);
+ return E_READ_USER_DATA;
+ }
+ ipc_pmic_register_read_modify(&p_read_mod_reg_data);
+ ret_val =
+ copy_to_user((struct ipc_pmic_mod_reg_data *)arg,
+ &p_read_mod_reg_data,
+ sizeof(struct ipc_pmic_mod_reg_data));
+ break;
+ }
+ case IPC_PMIC_REGISTER_WRITE:
+ {
+ ret_val =
+ copy_from_user(&p_write_reg_data,
+ (struct ipc_pmic_reg_data *)arg,
+ sizeof(struct ipc_pmic_reg_data));
+ if (ret_val < 0) {
+ printk(KERN_DEBUG
+ "copy_from_user FAILED!! <%s> function\
+ in <%s> file at <%d> line no\n",\
+ __func__, __FILE__, __LINE__);
+ return E_WRITE_USER_DATA;
+ }
+ ipc_pmic_register_write(&p_write_reg_data,
+ ipc_blocking_flag);
+ ret_val =
+ copy_to_user((struct ipc_pmic_reg_data *)arg,
+ &p_write_reg_data,
+ sizeof(struct ipc_pmic_reg_data));
+ break;
+ }
+ case DEVICE_FW_UPGRADE:
+ {
+ printk(KERN_INFO "ioctl DEVICE_FW_UPGRADE received\n");
+ fw_buf = kmalloc(MAX_FW_SIZE, GFP_KERNEL);
+ if (fw_buf == NULL) {
+ printk(KERN_ERR "ipc_test: kmalloc failed! \n");
+ return -EBUSY;
+ }
+ ret_val = copy_from_user(fw_buf, (u8 *)arg,
+ MAX_FW_SIZE);
+ if (ret_val < 0) {
+ printk(KERN_DEBUG
+ "copy_from_user FAILED!! <%s> function\
+ in <%s> file at <%d> line no\n",\
+ __func__, __FILE__, __LINE__);
+ return -EINVAL;
+ }
+ ipc_device_fw_upgrade(fw_buf, MAX_FW_SIZE);
+ break;
+ }
+ default:
+ {
+ printk(KERN_INFO
+ "ioctl <UNRECOGNIZED> received\n");
+ break;
+ }
+ }
+ return upper;
+}
+
+static int __init ipc_module_init(void)
+{
+ printk(KERN_INFO "Init ipc_module\n");
+
+ major = register_chrdev(0, "mid_ipc", &ipc_fops);
+ if (major < 0) {
+ printk(KERN_ERR "ipc_test : failed to get major\n");
+ return major;
+ }
+
+ init_ipc_driver ( ) ;
+ return SUCCESS;
+
+}
+
+static void __exit ipc_module_exit(void)
+{
+ unregister_chrdev(major, "mid_ipc");
+}
+
+module_init(ipc_module_init);
+module_exit(ipc_module_exit);
+
+MODULE_LICENSE("GPL V2");
+MODULE_DESCRIPTION("Test Driver for MRST IPC driver");
+MODULE_AUTHOR("Sreenidhi Gurudatt")
+
--
1.6.2.5
|