summaryrefslogtreecommitdiff
path: root/common/port80.c
diff options
context:
space:
mode:
authorKevin K Wong <kevin.k.wong@intel.com>2015-04-20 17:48:21 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-04-27 23:29:30 +0000
commit5a18413ff528331a229fe8734c6bca932e5478e1 (patch)
treeed2469096bf0612fc16fde5e8b4a13fb24b1db80 /common/port80.c
parentb35e4d47fc55a8ad1e1aa3f9818576176510008d (diff)
downloadchrome-ec-5a18413ff528331a229fe8734c6bca932e5478e1.tar.gz
mec1322: Added task-based Port80 POST code support.
With mec1322's EMI set to decode IO 0x800, it does not have any other interfaces to support POST code via IO 0x80. This change is to enable Port80 POST code support via polling method. Limitation: - POST Code 0xFF will be ignored. - POST Code frequency is greater than 1 msec. BUG=chrome-os-partner:39386 TEST=Verified Port80 POST code is captured in EC console. Verified "port80 task" console command will disable/enable Port80 task. Verified "port80 poll" will get the last Port80 POST code. BRANCH=none Change-Id: I27e53e84b5be1fd98464a44407dd58b93d8c798d Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com> Reviewed-on: https://chromium-review.googlesource.com/266783 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'common/port80.c')
-rw-r--r--common/port80.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/common/port80.c b/common/port80.c
index 9f6136cf5d..f857540727 100644
--- a/common/port80.c
+++ b/common/port80.c
@@ -9,17 +9,24 @@
#include "console.h"
#include "host_command.h"
#include "port80.h"
+#include "task.h"
+#include "timer.h"
#include "util.h"
#define CPRINTF(format, args...) cprintf(CC_PORT80, format, ## args)
#define HISTORY_LEN 256
+#define PORT80_POLL_PERIOD MSEC
static uint16_t history[HISTORY_LEN];
static int writes; /* Number of port 80 writes so far */
static int last_boot; /* Last code from previous boot */
static int scroll;
static int print_in_int = 1;
+#ifdef HAS_TASK_PORT80
+static int task_en; /* Port 80 task control */
+static int task_timeout = -1;
+#endif
void port_80_write(int data)
{
@@ -43,6 +50,30 @@ void port_80_write(int data)
writes++;
}
+#ifdef HAS_TASK_PORT80
+/*
+ * Port80 POST code polling limitation:
+ * - POST code 0xFF is ignored.
+ * - POST code frequency is greater than 1 msec.
+ */
+void port80_task(void)
+{
+#ifdef CONFIG_PORT80_TASK_EN
+ task_en = 1;
+ task_timeout = PORT80_POLL_PERIOD;
+#endif
+
+ while (1) {
+ int data = port_80_read();
+
+ if (data != PORT_80_IGNORE)
+ port_80_write(data);
+
+ task_wait_event(task_timeout);
+ }
+}
+#endif
+
/*****************************************************************************/
/* Console commands */
@@ -69,6 +100,22 @@ static int command_port80(int argc, char **argv)
} else if (!strcasecmp(argv[1], "flush")) {
writes = 0;
return EC_SUCCESS;
+#ifdef HAS_TASK_PORT80
+ } else if (!strcasecmp(argv[1], "task")) {
+ task_en = !task_en;
+ ccprintf("task %sabled\n", task_en ? "en" : "dis");
+ if (task_en) {
+ task_timeout = PORT80_POLL_PERIOD;
+ task_wake(TASK_ID_PORT80);
+ } else
+ task_timeout = -1;
+ return EC_SUCCESS;
+ } else if (!strcasecmp(argv[1], "poll")) {
+ i = port_80_read();
+ if (i != PORT_80_IGNORE)
+ port_80_write(i);
+ /* continue on to print the port 80 history */
+#endif
} else {
return EC_ERROR_PARAM1;
}