diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2015-07-24 17:20:13 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-08-14 21:04:38 +0000 |
commit | 6386c37379284390ed53a7146116947b49576fac (patch) | |
tree | 46014a5345b8310b79f338737aa09628cadb4e02 | |
parent | 73a8098d79d84292ff56674f843f73753520fcbd (diff) | |
download | chrome-ec-6386c37379284390ed53a7146116947b49576fac.tar.gz |
cr50: introduce tpm task skeleton
TPM command processing should not be happening on the interrupt
context.
This patch adds a skeleton of the task which handles TPM functions. It
initializes the TPM and then enters endless loop waiting for an event
trigger from interrupt, which happens when a valid FIFO message is
received.
BRANCH=none
BUG=chrome-os-partner:43025
TEST=none yet
Change-Id: I63dce2762cc07370a05bf00bdf144c5d9eb6019b
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/289332
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r-- | board/cr50/ec.tasklist | 3 | ||||
-rw-r--r-- | chip/g/sps_tpm.c | 2 | ||||
-rw-r--r-- | common/tpm_registers.c | 21 | ||||
-rw-r--r-- | include/tpm_registers.h | 3 |
4 files changed, 23 insertions, 6 deletions
diff --git a/board/cr50/ec.tasklist b/board/cr50/ec.tasklist index 98404b339a..fb7dbbf8ea 100644 --- a/board/cr50/ec.tasklist +++ b/board/cr50/ec.tasklist @@ -19,5 +19,6 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(BLOB, blob_task, NULL, TASK_STACK_SIZE) \ - TASK_NOTEST(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \ + TASK_NOTEST(TPM, tpm_task, NULL, CONFIG_STACK_SIZE) \ + TASK_NOTEST(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE) diff --git a/chip/g/sps_tpm.c b/chip/g/sps_tpm.c index 0dea0ce4ed..634dd33b97 100644 --- a/chip/g/sps_tpm.c +++ b/chip/g/sps_tpm.c @@ -248,7 +248,7 @@ static void tpm_rx_handler(uint8_t *data, size_t data_size, int cs_disabled) init_new_cycle(); } -static void sps_tpm_enable(void) +void sps_tpm_enable(void) { /* * Let's make sure we get an interrupt as soon as the header is diff --git a/common/tpm_registers.c b/common/tpm_registers.c index ba6b4f7492..f4babe8d5f 100644 --- a/common/tpm_registers.c +++ b/common/tpm_registers.c @@ -12,6 +12,7 @@ #include "common.h" #include "console.h" #include "hooks.h" +#include "task.h" #include "tpm_registers.h" #include "util.h" @@ -198,9 +199,11 @@ static void sts_reg_write_tg(void) case tpm_state_ready: break; /* Ignore setting this bit in these states. */ case tpm_state_receiving_cmd: - if (!(tpm_.state & expect)) + if (!(tpm_.state & expect)) { /* This should trigger actual command execution. */ tpm_.state = tpm_state_executing_cmd; + task_set_event(TASK_ID_TPM, TASK_EVENT_WAKE, 0); + } break; } } @@ -312,8 +315,6 @@ static void fifo_reg_write(const uint8_t *data, uint32_t data_size) /* All data has been receved, Ready for the 'go' command. */ tpm_.regs.sts &= ~expect; - CPRINTF("%s: received fifo command 0x%04x\n", - __func__, be32_to_cpu(tpm_.regs.data_fifo + 6)); } void tpm_register_put(uint32_t regaddr, const uint8_t *data, uint32_t data_size) @@ -373,4 +374,16 @@ static void tpm_init(void) (64 << burst_count_shift); } -DECLARE_HOOK(HOOK_INIT, tpm_init, HOOK_PRIO_DEFAULT); +void tpm_task(void) +{ + tpm_init(); + sps_tpm_enable(); + while (1) { + /* Wait for the next command event */ + task_wait_event(-1); + CPRINTF("%s: received fifo command 0x%04x\n", + __func__, be32_to_cpu(tpm_.regs.data_fifo + 6)); + + } +} + diff --git a/include/tpm_registers.h b/include/tpm_registers.h index cdf8410a51..2bdd87bc25 100644 --- a/include/tpm_registers.h +++ b/include/tpm_registers.h @@ -21,4 +21,7 @@ void tpm_register_put(uint32_t regaddr, /* The SPI master is reading data from a TPM register. */ void tpm_register_get(uint32_t regaddr, uint8_t *dest, uint32_t data_size); +/* Enable SPS TPM driver. */ +void sps_tpm_enable(void); + #endif /* __CROS_EC_TPM_REGISTERS_H */ |