From 350193684430b379d1ad76220683de8956e89286 Mon Sep 17 00:00:00 2001 From: Bibby Hsieh Date: Fri, 26 Apr 2019 10:21:47 +0800 Subject: mtk_isp: Add the service for p2 driver BUG=b:139269434 TEST=build kukui_scp pass & check DIP_SERVICE is available BRANCH=none Change-Id: I86500068d77700e13e909b5085ca07d1170138c1 Signed-off-by: Bibby Hsieh Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1584182 Reviewed-by: Nicolas Boichat Tested-by: Nicolas Boichat Commit-Queue: Nicolas Boichat --- board/kukui_scp/board.h | 3 +- board/kukui_scp/build.mk | 2 ++ board/kukui_scp/ec.tasklist | 1 + board/kukui_scp/isp_p2_srv.c | 80 ++++++++++++++++++++++++++++++++++++++++++++ board/kukui_scp/isp_p2_srv.h | 21 ++++++++++++ 5 files changed, 106 insertions(+), 1 deletion(-) create mode 100755 board/kukui_scp/isp_p2_srv.c create mode 100644 board/kukui_scp/isp_p2_srv.h diff --git a/board/kukui_scp/board.h b/board/kukui_scp/board.h index aed3ccb145..c00922a41a 100644 --- a/board/kukui_scp/board.h +++ b/board/kukui_scp/board.h @@ -14,6 +14,7 @@ #define CONFIG_MKBP_EVENT /* Sent MKBP event via IPI. */ #define CONFIG_MKBP_USE_CUSTOM +#define CONFIG_FPU /* * RW only, no flash @@ -31,7 +32,7 @@ */ #define ICACHE_BASE 0x7C000 #define CONFIG_ROM_BASE 0x0 -#define CONFIG_RAM_BASE 0x20000 +#define CONFIG_RAM_BASE 0x30000 #define CONFIG_ROM_SIZE (CONFIG_RAM_BASE - CONFIG_ROM_BASE) #define CONFIG_RAM_SIZE (CONFIG_IPC_SHARED_OBJ_ADDR - CONFIG_RAM_BASE) #define CONFIG_CODE_RAM_SIZE CONFIG_RAM_BASE diff --git a/board/kukui_scp/build.mk b/board/kukui_scp/build.mk index b8e1866600..17411fcb55 100644 --- a/board/kukui_scp/build.mk +++ b/board/kukui_scp/build.mk @@ -17,3 +17,5 @@ board-$(HAS_TASK_ISP_SERVICE)+=isp_p1_srv.o # FD board-$(HAS_TASK_FD_SERVICE)+=fd.o +# ISP P2 +board-$(HAS_TASK_DIP_SERVICE)+=isp_p2_srv.o diff --git a/board/kukui_scp/ec.tasklist b/board/kukui_scp/ec.tasklist index 574a24cc34..70a23fd8ae 100644 --- a/board/kukui_scp/ec.tasklist +++ b/board/kukui_scp/ec.tasklist @@ -18,6 +18,7 @@ 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(DIP_SERVICE, dip_service_task, NULL, 6400) \ TASK_ALWAYS(ISP_SERVICE, isp_service_task, NULL, 880) #define CONFIG_TASK_LIST \ diff --git a/board/kukui_scp/isp_p2_srv.c b/board/kukui_scp/isp_p2_srv.c new file mode 100755 index 0000000000..5acb81ae0f --- /dev/null +++ b/board/kukui_scp/isp_p2_srv.c @@ -0,0 +1,80 @@ +/* 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 "isp_p2_srv.h" +#include "chip/mt_scp/ipi_chip.h" +#include "chip/mt_scp/registers.h" +#include "queue_policies.h" +#include "console.h" +#include "hooks.h" +#include "task.h" +#include "util.h" +#include "queue.h" + +#define CPRINTS(format, args...) cprints(CC_IPI, format, ##args) + +/* Forwad declaration. */ +static struct consumer const event_dip_consumer; +static void event_dip_written(struct consumer const *consumer, size_t count); + +static struct queue const event_dip_queue = QUEUE_DIRECT(4, + struct dip_msg_service, null_producer, event_dip_consumer); + +static struct consumer const event_dip_consumer = { + .queue = &event_dip_queue, + .ops = &((struct consumer_ops const) { + .written = event_dip_written, + }), +}; + +/* Stub functions only provided by private overlays. */ +#ifndef HAVE_PRIVATE_MT8183 +void dip_msg_handler(void *data) {} +#endif + +static void event_dip_written(struct consumer const *consumer, size_t count) +{ + task_wake(TASK_ID_DIP_SERVICE); +} + +static void dip_scp_ipi_handler(int id, void *data, uint32_t len) +{ + struct dip_msg_service rsv_msg; + + if (!len) + return; + rsv_msg.id = id; + 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(&event_dip_queue, &rsv_msg)) + CPRINTS("Could not send dip %d to the queue.", id); +} +DECLARE_IPI(IPI_DIP, dip_scp_ipi_handler, 0); + +/* This function renames from dip_service_entry. */ +void dip_service_task(void *u) +{ + struct dip_msg_service 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(&event_dip_queue, &rsv_msg); + ipi_enable_irq(SCP_IRQ_IPC0); + + if (!size) + task_wait_event(-1); + else + dip_msg_handler(&rsv_msg); + } +} diff --git a/board/kukui_scp/isp_p2_srv.h b/board/kukui_scp/isp_p2_srv.h new file mode 100644 index 0000000000..196de3e092 --- /dev/null +++ b/board/kukui_scp/isp_p2_srv.h @@ -0,0 +1,21 @@ +/* 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_ISP_P2_SRV_H +#define __CROS_EC_ISP_P2_SRV_H + +#include "chip/mt_scp/ipi_chip.h" + +struct dip_msg_service { + unsigned char id; + unsigned char msg[288]; +}; + +BUILD_ASSERT(member_size(struct dip_msg_service, msg) <= CONFIG_IPC_SHARED_OBJ_BUF_SIZE); + +/* Functions provided by private overlay. */ +void dip_msg_handler(void *data); + +#endif /* __CROS_EC_ISP_P2_SRV_H */ -- cgit v1.2.1