aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ Freyensee <james_p_freyensee@linux.intel.com>2010-12-08 10:57:43 +0000
committerAlan Cox <alan@linux.intel.com>2010-12-08 10:57:43 +0000
commit0753ba66d824c89a1a174cb74190208f05d4e46b (patch)
treea82b3c370e86422d18291104c09c67d09b2d3c09
parent5f251e92d16b5b46b9d54b69dfe9b4af0d598c7e (diff)
downloadmrst-s0i3-test-0753ba66d824c89a1a174cb74190208f05d4e46b.tar.gz
mrst-s0i3-test-0753ba66d824c89a1a174cb74190208f05d4e46b.tar.xz
mrst-s0i3-test-0753ba66d824c89a1a174cb74190208f05d4e46b.zip
Modem trace capture solution for mobile platforms.
This gives the ability to capture modem trace data on multiple MID platforms that do not necessarily have PTI HW on the platform. It allows the ability to route modem trace data from one tty (where the modem trace debug data is coming) to another tty (output port) for later analysis in lab or on a product in the field. Since these are line discipline drivers, it relies on a userspace application to configure the drivers to the desired tty ports. This is a re-submisison. It is believed this patch was acceptable (due to lack of feedback from the last submission) but was not applied due to the missing ptirouter_ldisc->n_tracerouter rename patch. This patch needs this rename patch which was re-submitted. Signed-off-by: J Freyensee <james_p_freyensee@linux.intel.com>
-rw-r--r--drivers/char/Kconfig36
-rw-r--r--drivers/tty/Makefile1
-rw-r--r--drivers/tty/n_tracerouter.c230
-rw-r--r--drivers/tty/n_tracesink.c265
-rw-r--r--include/linux/pti.h7
-rw-r--r--include/linux/tty.h1
6 files changed, 516 insertions, 24 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 19a8bd940df..a5ca20bf4f6 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -112,16 +112,34 @@ config BFIN_JTAG_COMM_CONSOLE
config TRACE_ROUTER
tristate "Trace data router for MIPI P1149.7 cJTAG standard"
- depends on INTEL_MID_PTI
+
+ ---help---
+ The trace router uses the Linux tty line discipline framework to route
+ trace data coming from a HW Modem to a PTI (Parallel Trace Inferface)
+ port. This is part of a solution for the MIPI P1149.7, compact JTAG,
+ standard, which is for debugging mobile devices. A PTI
+ driver is also needed for this solution.
+
+ You should select this driver if the target kernel is meant for
+ a mobile device containing a modem. Then you will need to select
+ "Trace data sink for MIPI P1149.7 cJTAG standard" line discipline
+ driver and/or "Parallel Trace Interface for MIPI P1149.7 cJTAG standard"
+ HW driver implementation.
+
+config TRACE_SINK
+ tristate "Trace data sink for MIPI P1149.7 cJTAG standard"
+
---help---
- The PTI router uses the Linux tty line discipline framework to route
- trace data coming from a HW Modem to a PTI (Parallel Trace Inferface)
- port. This is part of a solution for the MIPI P1149.7, compact JTAG,
- standard, which is for debugging mobile devices. A PTI
- driver is also needed for this solution.
-
- You should select this driver if the target kernel is meant for
- a mobile device containing a MIPI P1149.7 standard implementation.
+ The trace sink uses the Linux line discipline framework to receive
+ trace data coming from the trace router line discipline driver
+ to a user-defined tty port target, like USB.
+ This is to provide a way to extract modem trace data on
+ devices that do not have a PTI HW module, or just need modem
+ trace data to come out of a different HW output port.
+ This is part of a solution for the P1149.7, compact JTAG, standard.
+
+ If you select this option, you need to select
+ "Trace data router for MIPI P1149.7 cJTAG standard".
config SERIAL_NONSTANDARD
bool "Non-standard serial port support"
diff --git a/drivers/tty/Makefile b/drivers/tty/Makefile
index e5a3a270d92..2753f213701 100644
--- a/drivers/tty/Makefile
+++ b/drivers/tty/Makefile
@@ -8,5 +8,6 @@ obj-$(CONFIG_N_HDLC) += n_hdlc.o
obj-$(CONFIG_N_GSM) += n_gsm.o
obj-$(CONFIG_R3964) += n_r3964.o
obj-$(CONFIG_TRACE_ROUTER) += n_tracerouter.o
+obj-$(CONFIG_TRACE_SINK) += n_tracesink.o
obj-y += vt/
diff --git a/drivers/tty/n_tracerouter.c b/drivers/tty/n_tracerouter.c
index dbf1be006f2..8b2e43258f5 100644
--- a/drivers/tty/n_tracerouter.c
+++ b/drivers/tty/n_tracerouter.c
@@ -21,8 +21,10 @@
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
- * The PTI router uses the Linux line discipline framework to route
+ * This trace router uses the Linux line discipline framework to route
* trace data coming from a HW Modem to a PTI (Parallel Trace Module) port.
+ * The solution is not specific to a HW modem and this line disciple can
+ * be used to route any stream of data in kernel space.
* This is part of a solution for the P1149.7, compact JTAG, standard.
*
*/
@@ -36,7 +38,7 @@
#include <linux/tty_ldisc.h>
#include <linux/errno.h>
#include <linux/string.h>
-#include <linux/signal.h>
+#include <linux/mutex.h>
#include <linux/slab.h>
#include <asm-generic/bug.h>
#include <linux/pti.h>
@@ -49,19 +51,102 @@
#define RECEIVE_ROOM 65536
#define DRIVERNAME "n_tracerouter"
+/* FIXME: ioctl stuff to specifically set PTI HW; it's being assumed
+ * the default and more common extraction case is to route
+ * data to an output port like USB. This feature is needed
+ * now to meet requests; however, once a second tty is added
+ * to the PTI driver and the right write aperture is assigned to
+ * that tty then this can be removed.
+ */
+#define PTIHW_SETCONF _IOW('J', 0, int)
+
+/* struct to hold private configuration data for this ldisc.
+ * routedata() used to hold the function to call to route the data.
+ * routedata_ptihw is used as switch a user app tells the ldisc where
+ * to route.
+ */
+struct tracerouter_data {
+ void (*routedata)(struct masterchannel *mc, u8 *cp, int count);
+ u8 routedata_ptihw;
+ u8 opencalled;
+ struct tty_struct *kref_tty;
+};
+static struct tracerouter_data *tr_data;
+
+/* lock for ioctl() setting of tracerouter_data values */
+static DEFINE_MUTEX(routelock);
+
+/**
+ * tracerouter_reset
+ *
+ * Provides an initial state to route data.
+ *
+ * @param ptr expects an existing ptr to be passed in
+ * to set the parameters involved in actually routing
+ * the data (routedata, routedata_ptihw, opencalled).
+ */
+static void tracerouter_resetroute(struct tracerouter_data *ptr)
+{
+ ptr->routedata = mipi_pti_sinkdata;
+ ptr->routedata_ptihw = 0;
+ ptr->opencalled = 0;
+}
+
+/**
+ * tracerouter_alloc
+ *
+ * Allocates the structure needed for this ldisc.
+ */
+static struct tracerouter_data *tracerouter_alloc(void)
+{
+ struct tracerouter_data *tptr = kzalloc(
+ sizeof(struct tracerouter_data),
+ GFP_KERNEL);
+ if (tptr == NULL)
+ return NULL;
+
+ /* default to shifting data out to the USB and specifically configure
+ * it to shift out to PTI. This is because it will probably be possible
+ * in the field to shift out data to USB, but the PTI HW may not be
+ * available 'in the field'.
+ */
+ tracerouter_resetroute(tptr);
+ return tptr;
+}
+
/**
* n_tracerouter_open() - Called when a tty is opened by a SW entity.
* @tty: terminal device to the ldisc.
*
* Return:
- * 0 for success.
+ * 0 for success.
+ *
+ * Caveats: This should only be opened one time per SW entity.
*/
-
static int n_tracerouter_open(struct tty_struct *tty)
{
- tty->receive_room = RECEIVE_ROOM;
- tty_driver_flush_buffer(tty);
- return 0;
+ int retval = -EEXIST;
+
+ mutex_lock(&routelock);
+ if (tr_data->opencalled == 0) {
+
+ tr_data->kref_tty = tty_kref_get(tty);
+ if (tr_data->kref_tty == NULL)
+ retval = -EFAULT;
+ else {
+ tr_data->opencalled = 1;
+ tty->disc_data = tr_data;
+ tty->receive_room = RECEIVE_ROOM;
+ tty_driver_flush_buffer(tty);
+ retval = 0;
+ }
+ }
+ mutex_unlock(&routelock);
+
+ pr_debug("%s(%s): called. Return value %d\n",
+ __FILE__, __func__, retval);
+
+ return retval;
}
/**
@@ -72,7 +157,19 @@ static int n_tracerouter_open(struct tty_struct *tty)
*/
static void n_tracerouter_close(struct tty_struct *tty)
{
+ struct tracerouter_data *tptr = tty->disc_data;
+
+ WARN_ON(tptr->kref_tty != tr_data->kref_tty);
tty_driver_flush_buffer(tty);
+ mutex_lock(&routelock);
+ tty_kref_put(tr_data->kref_tty);
+ tr_data->kref_tty = NULL;
+ tracerouter_resetroute(tr_data);
+ tty->disc_data = NULL;
+ mutex_unlock(&routelock);
+
+ pr_debug("%s(%s): called.\n",
+ __FILE__, __func__);
}
/**
@@ -92,8 +189,8 @@ static void n_tracerouter_close(struct tty_struct *tty)
* Return:
* -EINVAL
*/
-ssize_t n_tracerouter_read(struct tty_struct *tty, struct file *file,
- unsigned char *buf, size_t nr) {
+static ssize_t n_tracerouter_read(struct tty_struct *tty, struct file *file,
+ unsigned char *buf, size_t nr) {
return -EINVAL;
}
@@ -116,12 +213,105 @@ ssize_t n_tracerouter_read(struct tty_struct *tty, struct file *file,
* Return:
* -EINVAL
*/
-ssize_t n_tracerouter_write(struct tty_struct *tty, struct file *file,
- const unsigned char *buf, size_t nr) {
+static ssize_t n_tracerouter_write(struct tty_struct *tty, struct file *file,
+ const unsigned char *buf, size_t nr) {
return -EINVAL;
}
/**
+ * FIXME: This whole routine is part of the FIXME ioctl() at the
+ * begining and can be removed when the PTI driver gets a 2nd
+ * tty port and is validated both ports can handle continuous
+ * simultaneous constant writes. n_tracerouter will then
+ * always route to n_tracesink and whatever tty n_tracesink sits
+ * on top of is where trace data winds up going. The
+ * combination n_tracerouter and n_tracesink will then make up a
+ * generic solution of being able to route any data (not just
+ * for capturing modem debug data) to any tty port a user-app
+ * configures.
+ *
+ * n_tracerouter_ioctl()
+ * - Defined for custom behavior for the PTI trace router.
+ *
+ * @tty: the tty device the ldisc sits on top of.
+ * @file: File descriptor
+ * @cmd: The defined ioctl. The custom ioctl defined is
+ * PTIHW_SETCONF, which sets if trace data should go
+ * to the PTI HW that is on the system.
+ * @arg: A pointer to the thing in userspace. If it's 0, the
+ * router will route tot he n_ptisink driver. Otherwise, it
+ * will send the data to the PTI modem.
+ *
+ * Return:
+ * 0 for success, anything else error
+ *
+ * Caveats:
+ * This function winds up being a NOP when the PTI device
+ * driver, misc/pti.c is not compiled with the kernel.
+ */
+static int n_tracerouter_ioctl(struct tty_struct *tty, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ u8 copy_tmp = 0;
+ int retval = 0;
+ struct tracerouter_data *tptr = tty->disc_data;
+
+ pr_debug("%s(%s): called\n", __FILE__, __func__);
+
+ switch (cmd) {
+ case PTIHW_SETCONF:
+
+ mutex_lock(&routelock);
+
+ /* with the #ifdef below, this ioctl() basically is
+ * (and should be a harmless) NOP in the case a
+ * target system has not configured
+ * the PTI driver. alloc() makes sure routing to n_tracesink
+ * is default case, and this if() makes sure that in
+ * the event PTI driver is configured into a Linux
+ * solution that trace data can be routed to the
+ * n_tracesink if the PTI driver is first selected.
+ */
+ if (access_ok(VERIFY_READ, (void *) arg, sizeof(int))) {
+ if (get_user(copy_tmp, (int __user *) arg))
+ retval = -EFAULT;
+ }
+ pr_debug("%s(%s): after access_ok() ioctl. Return value %d\n",
+ __FILE__, __func__, retval);
+ pr_debug("%s(%s): after access_ok() ioctl. copy_tmp %d\n",
+ __FILE__, __func__, copy_tmp);
+ tptr->routedata_ptihw = copy_tmp;
+ if (tptr->routedata_ptihw == 0)
+ tptr->routedata = mipi_pti_sinkdata;
+
+ /* in case someone does not configure misc/pti.c
+ * into the kernel build (like the build is
+ * targeted for a HW solution without PTI HW),
+ * this will prevent an
+ * 'undefined reference' warning. For this
+ * system, it is perfectly acceptable for a kernel
+ * user to not configure the PTI HW into the
+ * kernel because it may not be on the HW platform, but
+ * to use this trace router and the trace sink
+ * for a given system's trace route needs.
+ */
+#ifdef CONFIG_INTEL_MID_PTI
+ else {
+ tptr->routedata = mipi_pti_writedata;
+ pr_debug("%s(%s): writedata set. Return value %d\n",
+ __FILE__, __func__, retval);
+ }
+#endif
+ mutex_unlock(&routelock);
+ return retval;
+
+ default:
+ retval = n_tty_ioctl_helper(tty, file, cmd, arg);
+ return retval;
+ }
+}
+
+/**
* n_tracerouter_receivebuf() - Routing function for driver.
* @tty: terminal device passed into the ldisc. It's assumed
* tty will never be NULL.
@@ -137,10 +327,16 @@ static void n_tracerouter_receivebuf(struct tty_struct *tty,
const unsigned char *cp,
char *fp, int count)
{
+ struct tracerouter_data *tptr = tty->disc_data;
+
/* 71 is the master ID for modem messages */
/* Only channel 0 for now */
static struct masterchannel mc = {.master = 71, .channel = 0 };
- mipi_pti_writedata((void *) &mc, (u8 *)cp, count);
+
+ pr_debug("%s(%s): calling routedata()\n", __FILE__, __func__);
+ mutex_lock(&routelock);
+ tptr->routedata((void *) &mc, (u8 *)cp, count);
+ mutex_unlock(&routelock);
}
/* Flush buffer is not impelemented as the ldisc has no internal buffering
@@ -155,6 +351,7 @@ static struct tty_ldisc_ops tty_ptirouter_ldisc = {
.close = n_tracerouter_close,
.read = n_tracerouter_read,
.write = n_tracerouter_write,
+ .ioctl = n_tracerouter_ioctl,
.receive_buf = n_tracerouter_receivebuf
};
@@ -170,11 +367,17 @@ static int __init n_tracerouter_init(void)
{
int retval;
+ tr_data = tracerouter_alloc();
+ if (tr_data == NULL)
+ return -ENOMEM;
+
/* Note N_TRACEROUTER is defined in linux/tty.h */
retval = tty_register_ldisc(N_TRACEROUTER, &tty_ptirouter_ldisc);
- if (retval < 0)
+ if (retval < 0) {
pr_err("%s: Registration failed: %d\n",
__func__, retval);
+ kfree(tr_data);
+ }
return retval;
}
@@ -187,6 +390,7 @@ static void __exit n_tracerouter_exit(void)
{
int retval;
+ kfree(tr_data);
retval = tty_unregister_ldisc(N_TRACEROUTER);
if (retval < 0)
pr_err("%s: Unregistration failed: %d\n",
diff --git a/drivers/tty/n_tracesink.c b/drivers/tty/n_tracesink.c
new file mode 100644
index 00000000000..1815c52f492
--- /dev/null
+++ b/drivers/tty/n_tracesink.c
@@ -0,0 +1,265 @@
+/*
+ * n_tracesink.c - PTI data router for JTAG data extration
+ *
+ * Copyright (C) Intel 2010
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * The trace sink uses the Linux line discipline framework to receive
+ * trace data coming from the PTI source line discipline driver
+ * to a user-desired tty port, like USB.
+ * This is to provide a way to extract modem trace data on
+ * devices that do not have a PTI HW module, or just need modem
+ * trace data to come out of a different HW output port.
+ * This is part of a solution for the P1149.7, compact JTAG, standard.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/ioctl.h>
+#include <linux/tty.h>
+#include <linux/tty_ldisc.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <asm-generic/bug.h>
+#include <linux/pti.h>
+
+/* Other ldisc drivers use 65536 which basically means,
+ * 'I can always accept 64k' and flow control is off.
+ * This number is deemed appropriate for this driver.
+ */
+#define RECEIVE_ROOM 65536
+#define DRIVERNAME "n_tracesink"
+
+/* there is a quirk with this ldisc is he can write data
+ * to a tty from anyone calling his kernel API, to keep
+ * it along the same theme with drivers/misc/pti.c
+ * whose requirements were defined by customers. So he
+ * needs to know when he can and cannot write when the
+ * API is called. In theory, the API can be called
+ * after an init() but before a successful open() which
+ * would crash the system if tty is not checked.
+ */
+static struct tty_struct *this_tty;
+static DEFINE_MUTEX(writelock);
+
+/**
+ * n_tracesink_open() - Called when a tty is opened by a SW entity.
+ * @tty: terminal device to the ldisc.
+ *
+ * Return:
+ * 0 for success,
+ * -EFAULT = couldn't get a tty kref n_tracesink will sit
+ * on top of
+ * -EEXIST = open() called successfully once and it cannot
+ * be called again.
+ *
+ * Caveats: open() should only be successful the first time a
+ * SW entity calls it.
+ */
+static int n_tracesink_open(struct tty_struct *tty)
+{
+ int retval = -EEXIST;
+
+ mutex_lock(&writelock);
+ if (this_tty == NULL) {
+
+ this_tty = tty_kref_get(tty);
+
+ if (this_tty == NULL)
+ retval = -EFAULT;
+ else {
+ tty->disc_data = this_tty;
+ tty_driver_flush_buffer(tty);
+ retval = 0;
+ }
+ }
+ mutex_unlock(&writelock);
+
+ pr_debug("%s(%s): called, return value %d\n",
+ __FILE__, __func__, retval);
+
+ return retval;
+}
+
+/**
+ * n_tracesink_close() - close connection
+ * @tty: terminal device to the ldisc.
+ *
+ * Called when a software entity wants to close a connection.
+ */
+static void n_tracesink_close(struct tty_struct *tty)
+{
+
+ tty_driver_flush_buffer(tty);
+
+ mutex_lock(&writelock);
+ tty_kref_put(this_tty);
+ this_tty = NULL;
+ mutex_unlock(&writelock);
+
+ tty->disc_data = NULL;
+
+ pr_debug("%s(%s): called\n", __FILE__, __func__);
+}
+
+/**
+ * n_tracesink_read() - read request from user space
+ * @tty: terminal device passed into the ldisc.
+ * @file: pointer to open file object.
+ * @buf: pointer to the data buffer that gets eventually returned.
+ * @nr: number of bytes of the data buffer that is returned.
+ *
+ * function that allows read() functionality in userspace. By default if this
+ * is not implemented it returns -EIO. This module is functioning like a
+ * router via n_tracesink_receivebuf(), and there is no real requirement
+ * to implement this function. However, an error return value other than
+ * -EIO should be used just to show that there was an intent not to have
+ * this function implemented. Return value based on read() man pages.
+ *
+ * Return:
+ * -EINVAL
+ */
+static ssize_t n_tracesink_read(struct tty_struct *tty, struct file *file,
+ unsigned char *buf, size_t nr) {
+ return -EINVAL;
+}
+
+/**
+ * n_tracesink_write() - Function that allows write() in userspace.
+ * @tty: terminal device passed into the ldisc.
+ * @file: pointer to open file object.
+ * @buf: pointer to the data buffer that gets eventually returned.
+ * @nr: number of bytes of the data buffer that is returned.
+ *
+ * By default if this is not implemented, it returns -EIO.
+ * This should not be implemented, ever, because
+ * 1. this driver is functioning like a router via
+ * n_tracesink_receivebuf()
+ * 2. No writes to HW will ever go through this line discpline driver.
+ * However, an error return value other than -EIO should be used
+ * just to show that there was an intent not to have this function
+ * implemented. Return value based on write() man pages.
+ *
+ * Return:
+ * -EINVAL
+ */
+static ssize_t n_tracesink_write(struct tty_struct *tty, struct file *file,
+ const unsigned char *buf, size_t nr) {
+ return -EINVAL;
+}
+
+/**
+ * mipi_pti_sinkdata() - Kernel API function used to route
+ * trace debugging data to user-defined
+ * port like USB.
+ *
+ * @mc: Not used. Null can be passed. Needed to keep
+ * conformance with mipi_pti_writedata().
+ * @buf: Trace debuging data to write to the PTI HW.
+ * Null value will return with no write occurring.
+ * @count: Size of buf. Value of 0 or a negative number will
+ * return with no write occuring.
+ *
+ * Caveat: If this line discipline does not set the tty it sits
+ * on top of via an open() call, this API function will not
+ * call the tty's write() call because it will have no pointer
+ * to call the write().
+ */
+
+void mipi_pti_sinkdata(struct masterchannel *mc, u8 *cp, int count)
+{
+ pr_debug("%s(%s): called\n", __FILE__, __func__);
+
+ mutex_lock(&writelock);
+
+ if ((cp != NULL) && (count > 0) && (this_tty != NULL))
+ this_tty->ops->write(this_tty, cp, count);
+
+ mutex_unlock(&writelock);
+}
+EXPORT_SYMBOL_GPL(mipi_pti_sinkdata);
+
+/* Flush buffer is not impelemented as the ldisc has no internal buffering
+ * so the tty_driver_flush_buffer() is sufficient for this driver's needs.
+ */
+
+/*
+ * tty_ldisc function operations for this driver.
+ */
+static struct tty_ldisc_ops tty_n_tracesink = {
+ .owner = THIS_MODULE,
+ .magic = TTY_LDISC_MAGIC,
+ .name = DRIVERNAME,
+ .open = n_tracesink_open,
+ .close = n_tracesink_close,
+ .read = n_tracesink_read,
+ .write = n_tracesink_write
+};
+
+/**
+ * n_tracesink_init- module initialisation
+ *
+ * Registers this module as a line discipline driver.
+ *
+ * Return:
+ * 0 for success, any other value error.
+ */
+static int __init n_tracesink_init(void)
+{
+ int retval;
+
+ pr_debug("%s(%s): called\n", __FILE__, __func__);
+
+ /* Note N_TRACESINK is defined in linux/tty.h */
+ retval = tty_register_ldisc(N_TRACESINK, &tty_n_tracesink);
+
+ if (retval < 0)
+ pr_err("%s: Registration failed: %d\n",
+ __func__, retval);
+
+ return retval;
+}
+
+/**
+ * n_tracesink_exit - module unload
+ *
+ * Removes this module as a line discipline driver.
+ */
+static void __exit n_tracesink_exit(void)
+{
+ int retval;
+
+ retval = tty_unregister_ldisc(N_TRACESINK);
+
+ if (retval < 0)
+ pr_err("%s: Unregistration failed: %d\n",
+ __func__, retval);
+}
+
+module_init(n_tracesink_init);
+module_exit(n_tracesink_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Jay Freyensee");
+MODULE_ALIAS_LDISC(N_TRACESINK);
+MODULE_DESCRIPTION("Trace sink ldisc driver");
diff --git a/include/linux/pti.h b/include/linux/pti.h
index 07c73b70529..5ca3fa94c26 100644
--- a/include/linux/pti.h
+++ b/include/linux/pti.h
@@ -21,17 +21,20 @@
#ifndef PTI_H_
#define PTI_H_
-
+/* basic structure used as a write address to the PTI HW */
struct masterchannel {
u8 master;
u8 channel;
};
-
+/* the following functions are defined in misc/pti.c */
void mipi_pti_writedata(struct masterchannel *mc, u8 *cp, int count);
struct masterchannel *mipi_request_masterchannel(u8 kerneluser);
void mipi_release_masterchannel(struct masterchannel *mc);
+/* the following function is defined in char/n_tracesink.c */
+void mipi_pti_sinkdata(struct masterchannel *mc, u8 *cp, int count);
+
#define APERTURE_14 0x3800000
#define APERTURE_LEN 0x400000
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 8c3be65bc5e..1ebceca9a3d 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -51,6 +51,7 @@
#define N_GSM0710 21 /* GSM 0710 Mux */
#define N_TI_WL 22 /* for TI's WL BT, FM, GPS combo chips */
#define N_TRACEROUTER 23 /* Trace data routing for MIPI P1149.7 */
+#define N_TRACESINK 23 /* Trace data routing for MIPI P1149.7 */
/*
* This character is the same as _POSIX_VDISABLE: it cannot be used as