aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/misc/Kconfig16
-rw-r--r--drivers/misc/pti.c72
2 files changed, 33 insertions, 55 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 8ce395f22df..e208ae6a56c 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -453,16 +453,16 @@ config PCH_PHUB
be called pch_phub.
config INTEL_MID_PTI
- tristate "Parallel Trace Interface for MIPI P1149.7 cJTAG standard"
- help
- The PTI (Parallel Trace Interface) driver directs
+ bool "Parallel Trace Interface for MIPI P1149.7 cJTAG standard"
+ help
+ The PTI (Parallel Trace Interface) driver directs
trace data routed from various parts in the system out
- through an Intel Penwell PTI port and out of the mobile
- device for analysis with a debugging tool (Lauterbach or Fido).
+ through an Intel Penwell PTI port and out of the mobile
+ device for analysis with a debugging tool (Lauterbach or Fido).
- You should select this driver if the target kernel is meant for
- an Intel Atom (non-netbook) mobile device containing a MIPI
- P1149.7 standard implementation.
+ You should select this driver if the target kernel is meant for
+ an Intel Atom (non-netbook) mobile device containing a MIPI
+ P1149.7 standard implementation.
source "drivers/misc/c2port/Kconfig"
source "drivers/misc/eeprom/Kconfig"
diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c
index 807a42889f3..9c31aefe4e8 100644
--- a/drivers/misc/pti.c
+++ b/drivers/misc/pti.c
@@ -29,6 +29,7 @@
#include <linux/init.h>
#include <linux/sched.h>
+#include <linux/interrupt.h>
#include <linux/console.h>
#include <linux/kernel.h>
#include <linux/module.h>
@@ -49,6 +50,7 @@
#define CONSOLE_ID 73 /* console master ID address */
#define OS_BASE_ID 74 /* base OS master ID address */
#define APP_BASE_ID 80 /* base App master ID address */
+#define CONTROL_FRAME_LEN 32 /* PTI control frame maximum size */
#define USER_COPY_SIZE 8192 /* 8Kb buffer to copy data from user space */
struct pti_tty {
@@ -101,10 +103,7 @@ static unsigned int pti_control_channel;
static void pti_write_to_aperture(struct masterchannel *mc, u8 *buf, int len)
{
int dwordcnt, final, i;
- union {
- u32 val;
- u8 c[4];
- } ptiword;
+ u32 ptiword;
u8 *p;
u32 __iomem *aperture;
@@ -124,44 +123,27 @@ static void pti_write_to_aperture(struct masterchannel *mc, u8 *buf, int len)
dwordcnt--;
}
- /*
- FIXME: This algorithm builds the dword from the input buffer.
- This algorithm does work correctly with the PTI HW
- and Fido debugging HW. However, this got flagged in upstream
- review not conforming to proper endian practices.
- u32 ptiword = cpu_to_le32(*(u32 *)p);
- was tried but was incorrect endianess. Then the Fido
- HW used to test this code broke. The goal is to submit
- something known to work and then fix this when it can be tested.
- */
for (i = 0; i < dwordcnt; i++) {
- ptiword.c[3] = *p++;
- ptiword.c[2] = *p++;
- ptiword.c[1] = *p++;
- ptiword.c[0] = *p++;
+ ptiword = be32_to_cpu(*(u32 *)p);
+ p += 4;
pr_debug("%s(%d): PTI aperture: master(%d), channel(%d)\n",
__func__, __LINE__, mc->master, mc->channel);
pr_debug("%s(%d): PTI double word: %#x\n\n",
- __func__, __LINE__, ptiword.val);
- iowrite32(ptiword.val, aperture);
+ __func__, __LINE__, ptiword);
+ iowrite32(ptiword, aperture);
}
aperture += DTS; /* adding DTS signals that is EOM */
- ptiword.val = 0;
- /*
- FIXME: This has the same issue as stated in other FIXME.
- u32 ptiword |= *p++ << (8 * i); was tried and had the
- same character-swapping endianess problem.
- */
+
+ ptiword = 0;
for (i = 0; i < final; i++)
- ptiword.c[3-i] = *p++;
+ ptiword |= *p++ << (24-(8*i));
pr_debug("%s(%d): PTI aperture: master(%d), channel(%d)\n",
__func__, __LINE__, mc->master, mc->channel);
pr_debug("%s(%d): Final PTI double word: %#x\n\n",
- __func__, __LINE__, ptiword.val);
- iowrite32(ptiword.val, aperture);
-
+ __func__, __LINE__, ptiword);
+ iowrite32(ptiword, aperture);
return;
}
@@ -177,30 +159,29 @@ static void pti_write_to_aperture(struct masterchannel *mc, u8 *buf, int len)
* The overhead is only 32 bytes since the driver only writes to HW
* in 32 byte chunks.
*/
+
static void pti_control_frame_built_and_sent(struct masterchannel *mc)
{
struct masterchannel mccontrol = {.master = CONTROL_ID, .channel = 0};
- struct thread_info *thread;
-
const char *control_format = "%3d %3d %s";
- int control_len = 32;
- char *comm;
- u8 control_frame[32];
+ char comm[sizeof(current->comm) + 1];
+ u8 control_frame[CONTROL_FRAME_LEN];
- thread = current_thread_info();
- comm = (char *)(struct task_struct *)(thread->task)->comm;
+ if (!in_interrupt())
+ get_task_comm(comm, current);
+ else
+ strcpy(comm, "Interrupt");
+
+ /* Ensure our buffer is zero terminated */
+ comm[sizeof(current->comm)] = 0;
mccontrol.channel = pti_control_channel;
pti_control_channel = (pti_control_channel + 1) & 0x7f;
- if (strlen(comm) < 23)
- control_len = 9 + strlen(comm);
-
- snprintf(control_frame, control_len, control_format, mc->master,
+ snprintf(control_frame, CONTROL_FRAME_LEN, control_format, mc->master,
mc->channel, comm);
-
- pti_write_to_aperture(&mccontrol, control_frame, control_len);
+ pti_write_to_aperture(&mccontrol, control_frame, strlen(control_frame));
}
/**
@@ -464,8 +445,6 @@ static int pti_tty_install(struct tty_driver *driver, struct tty_struct *tty)
struct pti_tty *pti_tty_data;
int ret = tty_init_termios(tty);
- pr_debug("%s(%d): Called.\n", __func__, __LINE__);
-
if (ret == 0) {
tty_driver_kref_get(driver);
tty->count++;
@@ -573,8 +552,7 @@ int pti_char_release(struct inode *inode, struct file *filp)
* @param data: trace data to be written.
* @param len: # of byte to write.
* @param ppose: Not used in this function implementation.
- * @return int : # of bytes written, or error. -EMSGSIZE is
- * returned if length is beyond 8k.
+ * @return int : # of bytes written, or error.
*/
ssize_t pti_char_write(struct file *filp, const char *data, size_t len,
loff_t *ppose)