summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry-ch Chen <jerry-ch.chen@mediatek.com>2019-04-03 21:29:37 +0800
committerCommit Bot <commit-bot@chromium.org>2019-08-26 15:37:49 +0000
commit92291e9214b1a4d108a47ebe156f2f5748824f06 (patch)
tree70e8846b33c0b92ab5c2ea65c521e91aa5bb949f
parent82ac51f46213eb1853db970a3e530e9a8db4d9af (diff)
downloadchrome-ec-92291e9214b1a4d108a47ebe156f2f5748824f06.tar.gz
mtk_isp: Add the service for fd driver
v2: Fix review comments Task Ready Name Events Time (s) StkUsed 5 FD_SERVICE 00000000 0.056489 568/640 v1: Add new EC task to support FD driver service. The real fd_msg_handler is implemented in the private-8183 repo. Task Ready Name Events Time (s) StkUsed 6 FD_SERVICE 00000000 0.067458 504/640 BRANCH=none BUG=b:139269434 TEST=build kukui_scp pass & check FD_SERVICE is available Change-Id: I1d1734bf9d944fc79d6bd3b170ad69a17a32aa6a Signed-off-by: Jerry-ch Chen <jerry-ch.chen@mediatek.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1577498 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Commit-Queue: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r--board/kukui_scp/build.mk3
-rw-r--r--board/kukui_scp/ec.tasklist1
-rw-r--r--board/kukui_scp/fd.c83
-rw-r--r--board/kukui_scp/fd.h35
4 files changed, 122 insertions, 0 deletions
diff --git a/board/kukui_scp/build.mk b/board/kukui_scp/build.mk
index 37e63282e2..b8e1866600 100644
--- a/board/kukui_scp/build.mk
+++ b/board/kukui_scp/build.mk
@@ -14,3 +14,6 @@ board-$(HAS_TASK_VENC_SERVICE)+=venc.o
# ISP P1
board-$(HAS_TASK_ISP_SERVICE)+=isp_p1_srv.o
+# FD
+board-$(HAS_TASK_FD_SERVICE)+=fd.o
+
diff --git a/board/kukui_scp/ec.tasklist b/board/kukui_scp/ec.tasklist
index c500396468..914832ab89 100644
--- a/board/kukui_scp/ec.tasklist
+++ b/board/kukui_scp/ec.tasklist
@@ -20,5 +20,6 @@
TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(VDEC_SERVICE, vdec_service_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(VENC_SERVICE, venc_service_task, NULL, LARGER_TASK_STACK_SIZE) \
+ TASK_ALWAYS(FD_SERVICE, fd_service_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(ISP_SERVICE, isp_service_task, NULL, 880) \
TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE)
diff --git a/board/kukui_scp/fd.c b/board/kukui_scp/fd.c
new file mode 100644
index 0000000000..11f27cf945
--- /dev/null
+++ b/board/kukui_scp/fd.c
@@ -0,0 +1,83 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "chip/mt_scp/ipi_chip.h"
+#include "chip/mt_scp/registers.h"
+#include "console.h"
+#include "hooks.h"
+#include "task.h"
+#include "util.h"
+#include "fd.h"
+#include "queue.h"
+#include "queue_policies.h"
+
+#define CPRINTF(format, args...) cprintf(CC_IPI, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_IPI, format, ##args)
+
+/* Forwad declaration. */
+static struct consumer const event_fd_consumer;
+static void event_fd_written(struct consumer const *consumer, size_t count);
+
+static struct queue const fd_queue = QUEUE_DIRECT(4, struct fd_msg,
+ null_producer,
+ event_fd_consumer);
+static struct consumer const event_fd_consumer = {
+ .queue = &fd_queue,
+ .ops = &((struct consumer_ops const) {
+ .written = event_fd_written,
+ }),
+};
+
+/* Stub functions only provided by private overlays. */
+// Jerry TODO implement private part and remove this
+#ifndef HAVE_PRIVATE_MT8183
+void fd_ipi_msg_handler(void *data) {}
+#endif
+
+static void event_fd_written(struct consumer const *consumer, size_t count)
+{
+ task_wake(TASK_ID_FD_SERVICE);
+}
+
+static void fd_ipi_handler(int id, void *data, uint32_t len)
+{
+ struct fd_msg rsv_msg;
+
+ if (!len)
+ return;
+
+ rsv_msg.type = IPI_FD_CMD;
+ memcpy(rsv_msg.msg, data, MIN(len, sizeof(rsv_msg.msg)));
+
+ /*
+ * If there is no other IPI handler touch this queue, we don't need to
+ * interrupt_disable() or task_disable_irq().
+ */
+ if (!queue_add_unit(&fd_queue, &rsv_msg))
+ CPRINTS("Could not send fd %d to the queue.", rsv_msg.type);
+}
+DECLARE_IPI(IPI_FD_CMD, fd_ipi_handler, 0);
+
+/* This function renames from fd_service_entry. */
+void fd_service_task(void *u)
+{
+ struct fd_msg rsv_msg;
+ size_t size;
+
+ while (1) {
+ /*
+ * Queue unit is added in IPI handler, which is in ISR context.
+ * Disable IRQ to prevent a clobbered queue.
+ */
+ ipi_disable_irq(SCP_IRQ_IPC0);
+ size = queue_remove_unit(&fd_queue, &rsv_msg);
+ ipi_enable_irq(SCP_IRQ_IPC0);
+
+ if (!size)
+ task_wait_event(-1);
+ else
+ fd_ipi_msg_handler(rsv_msg.msg);
+ }
+}
diff --git a/board/kukui_scp/fd.h b/board/kukui_scp/fd.h
new file mode 100644
index 0000000000..d46d5d5b56
--- /dev/null
+++ b/board/kukui_scp/fd.h
@@ -0,0 +1,35 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __CROS_EC_SCP_FD_H
+#define __CROS_EC_SCP_FD_H
+
+#include "chip/mt_scp/registers.h"
+#include "queue.h"
+#include "compile_time_macros.h"
+
+enum fd_msg_type {
+ FD_IPI_MSG,
+ FD_MAX,
+};
+
+enum fd_cmd_type {
+ FD_CMD_INIT,
+ FD_CMD_ENQ,
+ FD_CMD_EXIT,
+};
+
+typedef void (*fd_msg_handler)(void *msg);
+
+struct fd_msg {
+ enum fd_msg_type type;
+ unsigned char msg[64];
+};
+BUILD_ASSERT(member_size(struct fd_msg, msg) <= CONFIG_IPC_SHARED_OBJ_BUF_SIZE);
+
+/* Functions provided by private overlay. */
+void fd_ipi_msg_handler(void *data);
+
+#endif /* __CROS_EC_SCP_FD_H */