diff options
-rw-r--r-- | board/kukui_scp/board.h | 4 | ||||
-rw-r--r-- | board/kukui_scp/build.mk | 2 | ||||
-rw-r--r-- | board/kukui_scp/ec.tasklist | 1 | ||||
-rw-r--r-- | board/kukui_scp/mdp_ipi_message.c | 82 | ||||
-rw-r--r-- | board/kukui_scp/mdp_ipi_message.h | 19 |
5 files changed, 106 insertions, 2 deletions
diff --git a/board/kukui_scp/board.h b/board/kukui_scp/board.h index c00922a41a..38149af625 100644 --- a/board/kukui_scp/board.h +++ b/board/kukui_scp/board.h @@ -8,7 +8,7 @@ #ifndef __CROS_EC_BOARD_H #define __CROS_EC_BOARD_H -#define CONFIG_FLASH_SIZE 0x40000 /* Image file size: 256KB */ +#define CONFIG_FLASH_SIZE 0x58000 /* Image file size: 256KB */ #undef CONFIG_LID_SWITCH #undef CONFIG_FW_INCLUDE_RO #define CONFIG_MKBP_EVENT @@ -32,7 +32,7 @@ */ #define ICACHE_BASE 0x7C000 #define CONFIG_ROM_BASE 0x0 -#define CONFIG_RAM_BASE 0x30000 +#define CONFIG_RAM_BASE 0x58000 #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 17411fcb55..19355b5af5 100644 --- a/board/kukui_scp/build.mk +++ b/board/kukui_scp/build.mk @@ -19,3 +19,5 @@ board-$(HAS_TASK_FD_SERVICE)+=fd.o # ISP P2 board-$(HAS_TASK_DIP_SERVICE)+=isp_p2_srv.o +# MDP3 +board-$(HAS_TASK_MDP_SERVICE)+=mdp_ipi_message.o diff --git a/board/kukui_scp/ec.tasklist b/board/kukui_scp/ec.tasklist index 70a23fd8ae..e87a58195a 100644 --- a/board/kukui_scp/ec.tasklist +++ b/board/kukui_scp/ec.tasklist @@ -19,6 +19,7 @@ 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(MDP_SERVICE, mdp_service_task, NULL, 1800) \ TASK_ALWAYS(ISP_SERVICE, isp_service_task, NULL, 880) #define CONFIG_TASK_LIST \ diff --git a/board/kukui_scp/mdp_ipi_message.c b/board/kukui_scp/mdp_ipi_message.c new file mode 100644 index 0000000000..a33048821f --- /dev/null +++ b/board/kukui_scp/mdp_ipi_message.c @@ -0,0 +1,82 @@ +/* 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 "console.h" +#include "queue_policies.h" +#include "task.h" +#include "util.h" + +#include "chip/mt_scp/ipi_chip.h" +#include "chip/mt_scp/registers.h" +#include "mdp_ipi_message.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_mdp_consumer; +static void event_mdp_written(struct consumer const *consumer, size_t count); + +static struct queue const event_mdp_queue = QUEUE_DIRECT(4, + struct mdp_msg_service, null_producer, event_mdp_consumer); +static struct consumer const event_mdp_consumer = { + .queue = &event_mdp_queue, + .ops = &((struct consumer_ops const) { + .written = event_mdp_written, + }), +}; + +/* Stub functions only provided by private overlays. */ +#ifndef HAVE_PRIVATE_MT8183 +void mdp_common_init(void) {} +void mdp_ipi_task_handler(void *pvParameters) {} +#endif + +static void event_mdp_written(struct consumer const *consumer, size_t count) +{ + task_wake(TASK_ID_MDP_SERVICE); +} + +static void mdp_ipi_handler(int id, void *data, unsigned int len) +{ + struct mdp_msg_service cmd; + + cmd.id = id; + memcpy(cmd.msg, data, MIN(len, sizeof(cmd.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_mdp_queue, &cmd)) + CPRINTS("Could not send mdp id: %d to the queue.", id); +} +DECLARE_IPI(IPI_MDP_INIT, mdp_ipi_handler, 0); +DECLARE_IPI(IPI_MDP_FRAME, mdp_ipi_handler, 0); +DECLARE_IPI(IPI_MDP_DEINIT, mdp_ipi_handler, 0); + +/* This function renames from mdp_service_entry. */ +void mdp_service_task(void *u) +{ + struct mdp_msg_service rsv_msg; + size_t size; + + mdp_common_init(); + + 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_mdp_queue, &rsv_msg); + ipi_enable_irq(SCP_IRQ_IPC0); + + if (!size) + task_wait_event(-1); + else + mdp_ipi_task_handler(&rsv_msg); + } +} diff --git a/board/kukui_scp/mdp_ipi_message.h b/board/kukui_scp/mdp_ipi_message.h new file mode 100644 index 0000000000..bcedb58504 --- /dev/null +++ b/board/kukui_scp/mdp_ipi_message.h @@ -0,0 +1,19 @@ +/* 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 _MDP_IPI_MESSAGE_H +#define _MDP_IPI_MESSAGE_H + +struct mdp_msg_service { + int id; + unsigned char msg[20]; +}; + +BUILD_ASSERT(member_size(struct mdp_msg_service, msg) <= CONFIG_IPC_SHARED_OBJ_BUF_SIZE); + +void mdp_common_init(void); +void mdp_ipi_task_handler(void *pvParameters); + +#endif // _MDP_IPI_MESSAGE_H |