diff options
-rw-r--r-- | drivers/tty/Kconfig | 31 | ||||
-rw-r--r-- | drivers/tty/Makefile | 2 | ||||
-rw-r--r-- | drivers/tty/n_tracerouter.c | 243 | ||||
-rw-r--r-- | drivers/tty/n_tracesink.c | 238 | ||||
-rw-r--r-- | drivers/tty/n_tracesink.h | 36 | ||||
-rw-r--r-- | include/linux/tty.h | 2 |
6 files changed, 552 insertions, 0 deletions
diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig index 3fd7199301b6..bd7cc0527999 100644 --- a/drivers/tty/Kconfig +++ b/drivers/tty/Kconfig | |||
@@ -319,3 +319,34 @@ config N_GSM | |||
319 | This line discipline provides support for the GSM MUX protocol and | 319 | This line discipline provides support for the GSM MUX protocol and |
320 | presents the mux as a set of 61 individual tty devices. | 320 | presents the mux as a set of 61 individual tty devices. |
321 | 321 | ||
322 | config TRACE_ROUTER | ||
323 | tristate "Trace data router for MIPI P1149.7 cJTAG standard" | ||
324 | depends on TRACE_SINK | ||
325 | default n | ||
326 | help | ||
327 | The trace router uses the Linux tty line discipline framework to | ||
328 | route trace data coming from a tty port (say UART for example) to | ||
329 | the trace sink line discipline driver and to another tty port (say | ||
330 | USB). This is part of a solution for the MIPI P1149.7, compact JTAG, | ||
331 | standard, which is for debugging mobile devices. The PTI driver in | ||
332 | drivers/misc/pti.c defines the majority of this MIPI solution. | ||
333 | |||
334 | You should select this driver if the target kernel is meant for | ||
335 | a mobile device containing a modem. Then you will need to select | ||
336 | "Trace data sink for MIPI P1149.7 cJTAG standard" line discipline | ||
337 | driver. | ||
338 | |||
339 | config TRACE_SINK | ||
340 | tristate "Trace data sink for MIPI P1149.7 cJTAG standard" | ||
341 | default n | ||
342 | help | ||
343 | The trace sink uses the Linux line discipline framework to receive | ||
344 | trace data coming from the trace router line discipline driver | ||
345 | to a user-defined tty port target, like USB. | ||
346 | This is to provide a way to extract modem trace data on | ||
347 | devices that do not have a PTI HW module, or just need modem | ||
348 | trace data to come out of a different HW output port. | ||
349 | This is part of a solution for the P1149.7, compact JTAG, standard. | ||
350 | |||
351 | If you select this option, you need to select | ||
352 | "Trace data router for MIPI P1149.7 cJTAG standard". | ||
diff --git a/drivers/tty/Makefile b/drivers/tty/Makefile index 690522fcb338..ea89b0bd15fe 100644 --- a/drivers/tty/Makefile +++ b/drivers/tty/Makefile | |||
@@ -6,6 +6,8 @@ obj-$(CONFIG_AUDIT) += tty_audit.o | |||
6 | obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o | 6 | obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o |
7 | obj-$(CONFIG_N_HDLC) += n_hdlc.o | 7 | obj-$(CONFIG_N_HDLC) += n_hdlc.o |
8 | obj-$(CONFIG_N_GSM) += n_gsm.o | 8 | obj-$(CONFIG_N_GSM) += n_gsm.o |
9 | obj-$(CONFIG_TRACE_ROUTER) += n_tracerouter.o | ||
10 | obj-$(CONFIG_TRACE_SINK) += n_tracesink.o | ||
9 | obj-$(CONFIG_R3964) += n_r3964.o | 11 | obj-$(CONFIG_R3964) += n_r3964.o |
10 | 12 | ||
11 | obj-y += vt/ | 13 | obj-y += vt/ |
diff --git a/drivers/tty/n_tracerouter.c b/drivers/tty/n_tracerouter.c new file mode 100644 index 000000000000..1f063d3aa32f --- /dev/null +++ b/drivers/tty/n_tracerouter.c | |||
@@ -0,0 +1,243 @@ | |||
1 | /* | ||
2 | * n_tracerouter.c - Trace data router through tty space | ||
3 | * | ||
4 | * Copyright (C) Intel 2011 | ||
5 | * | ||
6 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 | ||
10 | * as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
18 | * | ||
19 | * This trace router uses the Linux line discipline framework to route | ||
20 | * trace data coming from a HW Modem to a PTI (Parallel Trace Module) port. | ||
21 | * The solution is not specific to a HW modem and this line disciple can | ||
22 | * be used to route any stream of data in kernel space. | ||
23 | * This is part of a solution for the P1149.7, compact JTAG, standard. | ||
24 | */ | ||
25 | |||
26 | #include <linux/init.h> | ||
27 | #include <linux/kernel.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/types.h> | ||
30 | #include <linux/ioctl.h> | ||
31 | #include <linux/tty.h> | ||
32 | #include <linux/tty_ldisc.h> | ||
33 | #include <linux/errno.h> | ||
34 | #include <linux/string.h> | ||
35 | #include <linux/mutex.h> | ||
36 | #include <linux/slab.h> | ||
37 | #include <asm-generic/bug.h> | ||
38 | #include "n_tracesink.h" | ||
39 | |||
40 | /* | ||
41 | * Other ldisc drivers use 65536 which basically means, | ||
42 | * 'I can always accept 64k' and flow control is off. | ||
43 | * This number is deemed appropriate for this driver. | ||
44 | */ | ||
45 | #define RECEIVE_ROOM 65536 | ||
46 | #define DRIVERNAME "n_tracerouter" | ||
47 | |||
48 | /* | ||
49 | * struct to hold private configuration data for this ldisc. | ||
50 | * opencalled is used to hold if this ldisc has been opened. | ||
51 | * kref_tty holds the tty reference the ldisc sits on top of. | ||
52 | */ | ||
53 | struct tracerouter_data { | ||
54 | u8 opencalled; | ||
55 | struct tty_struct *kref_tty; | ||
56 | }; | ||
57 | static struct tracerouter_data *tr_data; | ||
58 | |||
59 | /* lock for when tty reference is being used */ | ||
60 | static DEFINE_MUTEX(routelock); | ||
61 | |||
62 | /** | ||
63 | * n_tracerouter_open() - Called when a tty is opened by a SW entity. | ||
64 | * @tty: terminal device to the ldisc. | ||
65 | * | ||
66 | * Return: | ||
67 | * 0 for success. | ||
68 | * | ||
69 | * Caveats: This should only be opened one time per SW entity. | ||
70 | */ | ||
71 | static int n_tracerouter_open(struct tty_struct *tty) | ||
72 | { | ||
73 | int retval = -EEXIST; | ||
74 | |||
75 | mutex_lock(&routelock); | ||
76 | if (tr_data->opencalled == 0) { | ||
77 | |||
78 | tr_data->kref_tty = tty_kref_get(tty); | ||
79 | if (tr_data->kref_tty == NULL) { | ||
80 | retval = -EFAULT; | ||
81 | } else { | ||
82 | tr_data->opencalled = 1; | ||
83 | tty->disc_data = tr_data; | ||
84 | tty->receive_room = RECEIVE_ROOM; | ||
85 | tty_driver_flush_buffer(tty); | ||
86 | retval = 0; | ||
87 | } | ||
88 | } | ||
89 | mutex_unlock(&routelock); | ||
90 | return retval; | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * n_tracerouter_close() - close connection | ||
95 | * @tty: terminal device to the ldisc. | ||
96 | * | ||
97 | * Called when a software entity wants to close a connection. | ||
98 | */ | ||
99 | static void n_tracerouter_close(struct tty_struct *tty) | ||
100 | { | ||
101 | struct tracerouter_data *tptr = tty->disc_data; | ||
102 | |||
103 | mutex_lock(&routelock); | ||
104 | WARN_ON(tptr->kref_tty != tr_data->kref_tty); | ||
105 | tty_driver_flush_buffer(tty); | ||
106 | tty_kref_put(tr_data->kref_tty); | ||
107 | tr_data->kref_tty = NULL; | ||
108 | tr_data->opencalled = 0; | ||
109 | tty->disc_data = NULL; | ||
110 | mutex_unlock(&routelock); | ||
111 | } | ||
112 | |||
113 | /** | ||
114 | * n_tracerouter_read() - read request from user space | ||
115 | * @tty: terminal device passed into the ldisc. | ||
116 | * @file: pointer to open file object. | ||
117 | * @buf: pointer to the data buffer that gets eventually returned. | ||
118 | * @nr: number of bytes of the data buffer that is returned. | ||
119 | * | ||
120 | * function that allows read() functionality in userspace. By default if this | ||
121 | * is not implemented it returns -EIO. This module is functioning like a | ||
122 | * router via n_tracerouter_receivebuf(), and there is no real requirement | ||
123 | * to implement this function. However, an error return value other than | ||
124 | * -EIO should be used just to show that there was an intent not to have | ||
125 | * this function implemented. Return value based on read() man pages. | ||
126 | * | ||
127 | * Return: | ||
128 | * -EINVAL | ||
129 | */ | ||
130 | static ssize_t n_tracerouter_read(struct tty_struct *tty, struct file *file, | ||
131 | unsigned char __user *buf, size_t nr) { | ||
132 | return -EINVAL; | ||
133 | } | ||
134 | |||
135 | /** | ||
136 | * n_tracerouter_write() - Function that allows write() in userspace. | ||
137 | * @tty: terminal device passed into the ldisc. | ||
138 | * @file: pointer to open file object. | ||
139 | * @buf: pointer to the data buffer that gets eventually returned. | ||
140 | * @nr: number of bytes of the data buffer that is returned. | ||
141 | * | ||
142 | * By default if this is not implemented, it returns -EIO. | ||
143 | * This should not be implemented, ever, because | ||
144 | * 1. this driver is functioning like a router via | ||
145 | * n_tracerouter_receivebuf() | ||
146 | * 2. No writes to HW will ever go through this line discpline driver. | ||
147 | * However, an error return value other than -EIO should be used | ||
148 | * just to show that there was an intent not to have this function | ||
149 | * implemented. Return value based on write() man pages. | ||
150 | * | ||
151 | * Return: | ||
152 | * -EINVAL | ||
153 | */ | ||
154 | static ssize_t n_tracerouter_write(struct tty_struct *tty, struct file *file, | ||
155 | const unsigned char *buf, size_t nr) { | ||
156 | return -EINVAL; | ||
157 | } | ||
158 | |||
159 | /** | ||
160 | * n_tracerouter_receivebuf() - Routing function for driver. | ||
161 | * @tty: terminal device passed into the ldisc. It's assumed | ||
162 | * tty will never be NULL. | ||
163 | * @cp: buffer, block of characters to be eventually read by | ||
164 | * someone, somewhere (user read() call or some kernel function). | ||
165 | * @fp: flag buffer. | ||
166 | * @count: number of characters (aka, bytes) in cp. | ||
167 | * | ||
168 | * This function takes the input buffer, cp, and passes it to | ||
169 | * an external API function for processing. | ||
170 | */ | ||
171 | static void n_tracerouter_receivebuf(struct tty_struct *tty, | ||
172 | const unsigned char *cp, | ||
173 | char *fp, int count) | ||
174 | { | ||
175 | mutex_lock(&routelock); | ||
176 | n_tracesink_datadrain((u8 *) cp, count); | ||
177 | mutex_unlock(&routelock); | ||
178 | } | ||
179 | |||
180 | /* | ||
181 | * Flush buffer is not impelemented as the ldisc has no internal buffering | ||
182 | * so the tty_driver_flush_buffer() is sufficient for this driver's needs. | ||
183 | */ | ||
184 | |||
185 | static struct tty_ldisc_ops tty_ptirouter_ldisc = { | ||
186 | .owner = THIS_MODULE, | ||
187 | .magic = TTY_LDISC_MAGIC, | ||
188 | .name = DRIVERNAME, | ||
189 | .open = n_tracerouter_open, | ||
190 | .close = n_tracerouter_close, | ||
191 | .read = n_tracerouter_read, | ||
192 | .write = n_tracerouter_write, | ||
193 | .receive_buf = n_tracerouter_receivebuf | ||
194 | }; | ||
195 | |||
196 | /** | ||
197 | * n_tracerouter_init - module initialisation | ||
198 | * | ||
199 | * Registers this module as a line discipline driver. | ||
200 | * | ||
201 | * Return: | ||
202 | * 0 for success, any other value error. | ||
203 | */ | ||
204 | static int __init n_tracerouter_init(void) | ||
205 | { | ||
206 | int retval; | ||
207 | |||
208 | tr_data = kzalloc(sizeof(struct tracerouter_data), GFP_KERNEL); | ||
209 | if (tr_data == NULL) | ||
210 | return -ENOMEM; | ||
211 | |||
212 | |||
213 | /* Note N_TRACEROUTER is defined in linux/tty.h */ | ||
214 | retval = tty_register_ldisc(N_TRACEROUTER, &tty_ptirouter_ldisc); | ||
215 | if (retval < 0) { | ||
216 | pr_err("%s: Registration failed: %d\n", __func__, retval); | ||
217 | kfree(tr_data); | ||
218 | } | ||
219 | return retval; | ||
220 | } | ||
221 | |||
222 | /** | ||
223 | * n_tracerouter_exit - module unload | ||
224 | * | ||
225 | * Removes this module as a line discipline driver. | ||
226 | */ | ||
227 | static void __exit n_tracerouter_exit(void) | ||
228 | { | ||
229 | int retval = tty_unregister_ldisc(N_TRACEROUTER); | ||
230 | |||
231 | if (retval < 0) | ||
232 | pr_err("%s: Unregistration failed: %d\n", __func__, retval); | ||
233 | else | ||
234 | kfree(tr_data); | ||
235 | } | ||
236 | |||
237 | module_init(n_tracerouter_init); | ||
238 | module_exit(n_tracerouter_exit); | ||
239 | |||
240 | MODULE_LICENSE("GPL"); | ||
241 | MODULE_AUTHOR("Jay Freyensee"); | ||
242 | MODULE_ALIAS_LDISC(N_TRACEROUTER); | ||
243 | MODULE_DESCRIPTION("Trace router ldisc driver"); | ||
diff --git a/drivers/tty/n_tracesink.c b/drivers/tty/n_tracesink.c new file mode 100644 index 000000000000..ddce58b973d2 --- /dev/null +++ b/drivers/tty/n_tracesink.c | |||
@@ -0,0 +1,238 @@ | |||
1 | /* | ||
2 | * n_tracesink.c - Trace data router and sink path through tty space. | ||
3 | * | ||
4 | * Copyright (C) Intel 2011 | ||
5 | * | ||
6 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 | ||
10 | * as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
18 | * | ||
19 | * The trace sink uses the Linux line discipline framework to receive | ||
20 | * trace data coming from the PTI source line discipline driver | ||
21 | * to a user-desired tty port, like USB. | ||
22 | * This is to provide a way to extract modem trace data on | ||
23 | * devices that do not have a PTI HW module, or just need modem | ||
24 | * trace data to come out of a different HW output port. | ||
25 | * This is part of a solution for the P1149.7, compact JTAG, standard. | ||
26 | */ | ||
27 | |||
28 | #include <linux/init.h> | ||
29 | #include <linux/kernel.h> | ||
30 | #include <linux/module.h> | ||
31 | #include <linux/types.h> | ||
32 | #include <linux/ioctl.h> | ||
33 | #include <linux/tty.h> | ||
34 | #include <linux/tty_ldisc.h> | ||
35 | #include <linux/errno.h> | ||
36 | #include <linux/string.h> | ||
37 | #include <asm-generic/bug.h> | ||
38 | #include "n_tracesink.h" | ||
39 | |||
40 | /* | ||
41 | * Other ldisc drivers use 65536 which basically means, | ||
42 | * 'I can always accept 64k' and flow control is off. | ||
43 | * This number is deemed appropriate for this driver. | ||
44 | */ | ||
45 | #define RECEIVE_ROOM 65536 | ||
46 | #define DRIVERNAME "n_tracesink" | ||
47 | |||
48 | /* | ||
49 | * there is a quirk with this ldisc is he can write data | ||
50 | * to a tty from anyone calling his kernel API, which | ||
51 | * meets customer requirements in the drivers/misc/pti.c | ||
52 | * project. So he needs to know when he can and cannot write when | ||
53 | * the API is called. In theory, the API can be called | ||
54 | * after an init() but before a successful open() which | ||
55 | * would crash the system if tty is not checked. | ||
56 | */ | ||
57 | static struct tty_struct *this_tty; | ||
58 | static DEFINE_MUTEX(writelock); | ||
59 | |||
60 | /** | ||
61 | * n_tracesink_open() - Called when a tty is opened by a SW entity. | ||
62 | * @tty: terminal device to the ldisc. | ||
63 | * | ||
64 | * Return: | ||
65 | * 0 for success, | ||
66 | * -EFAULT = couldn't get a tty kref n_tracesink will sit | ||
67 | * on top of | ||
68 | * -EEXIST = open() called successfully once and it cannot | ||
69 | * be called again. | ||
70 | * | ||
71 | * Caveats: open() should only be successful the first time a | ||
72 | * SW entity calls it. | ||
73 | */ | ||
74 | static int n_tracesink_open(struct tty_struct *tty) | ||
75 | { | ||
76 | int retval = -EEXIST; | ||
77 | |||
78 | mutex_lock(&writelock); | ||
79 | if (this_tty == NULL) { | ||
80 | this_tty = tty_kref_get(tty); | ||
81 | if (this_tty == NULL) { | ||
82 | retval = -EFAULT; | ||
83 | } else { | ||
84 | tty->disc_data = this_tty; | ||
85 | tty_driver_flush_buffer(tty); | ||
86 | retval = 0; | ||
87 | } | ||
88 | } | ||
89 | mutex_unlock(&writelock); | ||
90 | |||
91 | return retval; | ||
92 | } | ||
93 | |||
94 | /** | ||
95 | * n_tracesink_close() - close connection | ||
96 | * @tty: terminal device to the ldisc. | ||
97 | * | ||
98 | * Called when a software entity wants to close a connection. | ||
99 | */ | ||
100 | static void n_tracesink_close(struct tty_struct *tty) | ||
101 | { | ||
102 | mutex_lock(&writelock); | ||
103 | tty_driver_flush_buffer(tty); | ||
104 | tty_kref_put(this_tty); | ||
105 | this_tty = NULL; | ||
106 | tty->disc_data = NULL; | ||
107 | mutex_unlock(&writelock); | ||
108 | } | ||
109 | |||
110 | /** | ||
111 | * n_tracesink_read() - read request from user space | ||
112 | * @tty: terminal device passed into the ldisc. | ||
113 | * @file: pointer to open file object. | ||
114 | * @buf: pointer to the data buffer that gets eventually returned. | ||
115 | * @nr: number of bytes of the data buffer that is returned. | ||
116 | * | ||
117 | * function that allows read() functionality in userspace. By default if this | ||
118 | * is not implemented it returns -EIO. This module is functioning like a | ||
119 | * router via n_tracesink_receivebuf(), and there is no real requirement | ||
120 | * to implement this function. However, an error return value other than | ||
121 | * -EIO should be used just to show that there was an intent not to have | ||
122 | * this function implemented. Return value based on read() man pages. | ||
123 | * | ||
124 | * Return: | ||
125 | * -EINVAL | ||
126 | */ | ||
127 | static ssize_t n_tracesink_read(struct tty_struct *tty, struct file *file, | ||
128 | unsigned char __user *buf, size_t nr) { | ||
129 | return -EINVAL; | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * n_tracesink_write() - Function that allows write() in userspace. | ||
134 | * @tty: terminal device passed into the ldisc. | ||
135 | * @file: pointer to open file object. | ||
136 | * @buf: pointer to the data buffer that gets eventually returned. | ||
137 | * @nr: number of bytes of the data buffer that is returned. | ||
138 | * | ||
139 | * By default if this is not implemented, it returns -EIO. | ||
140 | * This should not be implemented, ever, because | ||
141 | * 1. this driver is functioning like a router via | ||
142 | * n_tracesink_receivebuf() | ||
143 | * 2. No writes to HW will ever go through this line discpline driver. | ||
144 | * However, an error return value other than -EIO should be used | ||
145 | * just to show that there was an intent not to have this function | ||
146 | * implemented. Return value based on write() man pages. | ||
147 | * | ||
148 | * Return: | ||
149 | * -EINVAL | ||
150 | */ | ||
151 | static ssize_t n_tracesink_write(struct tty_struct *tty, struct file *file, | ||
152 | const unsigned char *buf, size_t nr) { | ||
153 | return -EINVAL; | ||
154 | } | ||
155 | |||
156 | /** | ||
157 | * n_tracesink_datadrain() - Kernel API function used to route | ||
158 | * trace debugging data to user-defined | ||
159 | * port like USB. | ||
160 | * | ||
161 | * @buf: Trace debuging data buffer to write to tty target | ||
162 | * port. Null value will return with no write occurring. | ||
163 | * @count: Size of buf. Value of 0 or a negative number will | ||
164 | * return with no write occuring. | ||
165 | * | ||
166 | * Caveat: If this line discipline does not set the tty it sits | ||
167 | * on top of via an open() call, this API function will not | ||
168 | * call the tty's write() call because it will have no pointer | ||
169 | * to call the write(). | ||
170 | */ | ||
171 | void n_tracesink_datadrain(u8 *buf, int count) | ||
172 | { | ||
173 | mutex_lock(&writelock); | ||
174 | |||
175 | if ((buf != NULL) && (count > 0) && (this_tty != NULL)) | ||
176 | this_tty->ops->write(this_tty, buf, count); | ||
177 | |||
178 | mutex_unlock(&writelock); | ||
179 | } | ||
180 | EXPORT_SYMBOL_GPL(n_tracesink_datadrain); | ||
181 | |||
182 | /* | ||
183 | * Flush buffer is not impelemented as the ldisc has no internal buffering | ||
184 | * so the tty_driver_flush_buffer() is sufficient for this driver's needs. | ||
185 | */ | ||
186 | |||
187 | /* | ||
188 | * tty_ldisc function operations for this driver. | ||
189 | */ | ||
190 | static struct tty_ldisc_ops tty_n_tracesink = { | ||
191 | .owner = THIS_MODULE, | ||
192 | .magic = TTY_LDISC_MAGIC, | ||
193 | .name = DRIVERNAME, | ||
194 | .open = n_tracesink_open, | ||
195 | .close = n_tracesink_close, | ||
196 | .read = n_tracesink_read, | ||
197 | .write = n_tracesink_write | ||
198 | }; | ||
199 | |||
200 | /** | ||
201 | * n_tracesink_init- module initialisation | ||
202 | * | ||
203 | * Registers this module as a line discipline driver. | ||
204 | * | ||
205 | * Return: | ||
206 | * 0 for success, any other value error. | ||
207 | */ | ||
208 | static int __init n_tracesink_init(void) | ||
209 | { | ||
210 | /* Note N_TRACESINK is defined in linux/tty.h */ | ||
211 | int retval = tty_register_ldisc(N_TRACESINK, &tty_n_tracesink); | ||
212 | |||
213 | if (retval < 0) | ||
214 | pr_err("%s: Registration failed: %d\n", __func__, retval); | ||
215 | |||
216 | return retval; | ||
217 | } | ||
218 | |||
219 | /** | ||
220 | * n_tracesink_exit - module unload | ||
221 | * | ||
222 | * Removes this module as a line discipline driver. | ||
223 | */ | ||
224 | static void __exit n_tracesink_exit(void) | ||
225 | { | ||
226 | int retval = tty_unregister_ldisc(N_TRACESINK); | ||
227 | |||
228 | if (retval < 0) | ||
229 | pr_err("%s: Unregistration failed: %d\n", __func__, retval); | ||
230 | } | ||
231 | |||
232 | module_init(n_tracesink_init); | ||
233 | module_exit(n_tracesink_exit); | ||
234 | |||
235 | MODULE_LICENSE("GPL"); | ||
236 | MODULE_AUTHOR("Jay Freyensee"); | ||
237 | MODULE_ALIAS_LDISC(N_TRACESINK); | ||
238 | MODULE_DESCRIPTION("Trace sink ldisc driver"); | ||
diff --git a/drivers/tty/n_tracesink.h b/drivers/tty/n_tracesink.h new file mode 100644 index 000000000000..a68bb44f1ef5 --- /dev/null +++ b/drivers/tty/n_tracesink.h | |||
@@ -0,0 +1,36 @@ | |||
1 | /* | ||
2 | * n_tracesink.h - Kernel driver API to route trace data in kernel space. | ||
3 | * | ||
4 | * Copyright (C) Intel 2011 | ||
5 | * | ||
6 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 | ||
10 | * as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
18 | * | ||
19 | * The PTI (Parallel Trace Interface) driver directs trace data routed from | ||
20 | * various parts in the system out through the Intel Penwell PTI port and | ||
21 | * out of the mobile device for analysis with a debugging tool | ||
22 | * (Lauterbach, Fido). This is part of a solution for the MIPI P1149.7, | ||
23 | * compact JTAG, standard. | ||
24 | * | ||
25 | * This header file is used by n_tracerouter to be able to send the | ||
26 | * data of it's tty port to the tty port this module sits. This | ||
27 | * mechanism can also be used independent of the PTI module. | ||
28 | * | ||
29 | */ | ||
30 | |||
31 | #ifndef N_TRACESINK_H_ | ||
32 | #define N_TRACESINK_H_ | ||
33 | |||
34 | void n_tracesink_datadrain(u8 *buf, int count); | ||
35 | |||
36 | #endif | ||
diff --git a/include/linux/tty.h b/include/linux/tty.h index 4db4ca79f895..d6f05292e456 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -50,6 +50,8 @@ | |||
50 | #define N_CAIF 20 /* CAIF protocol for talking to modems */ | 50 | #define N_CAIF 20 /* CAIF protocol for talking to modems */ |
51 | #define N_GSM0710 21 /* GSM 0710 Mux */ | 51 | #define N_GSM0710 21 /* GSM 0710 Mux */ |
52 | #define N_TI_WL 22 /* for TI's WL BT, FM, GPS combo chips */ | 52 | #define N_TI_WL 22 /* for TI's WL BT, FM, GPS combo chips */ |
53 | #define N_TRACESINK 23 /* Trace data routing for MIPI P1149.7 */ | ||
54 | #define N_TRACEROUTER 24 /* Trace data routing for MIPI P1149.7 */ | ||
53 | 55 | ||
54 | /* | 56 | /* |
55 | * This character is the same as _POSIX_VDISABLE: it cannot be used as | 57 | * This character is the same as _POSIX_VDISABLE: it cannot be used as |