1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /*
3  * Copyright(c) 2021 MediaTek. All rights reserved.
4  *
5  * Author: YC Hung <yc.hung@mediatek.com>
6  */
7 
8 #ifdef __SOF_PLATFORM_H__
9 
10 #ifndef __PLATFORM_PLATFORM_H__
11 #define __PLATFORM_PLATFORM_H__
12 
13 #if !defined(__ASSEMBLER__) && !defined(LINKER)
14 
15 #include <sof/lib/mailbox.h>
16 #include <stddef.h>
17 #include <stdint.h>
18 
19 struct ll_schedule_domain;
20 struct timer;
21 
22 #define PLATFORM_DEFAULT_CLOCK CLK_CPU(0)
23 #define LPSRAM_SIZE 16384
24 
25 /*MTK_TODO : use correct ipc interrupt , mailbox int group 16 bit 0*/
26 /* IPC Interrupt */
27 #define PLATFORM_IPC_INTERRUPT IRQ_MASK_GROUP16
28 #define PLATFORM_IPC_INTERRUPT_NAME NULL
29 
30 /* Host page size */
31 #define HOST_PAGE_SIZE 4096
32 #define PLATFORM_PAGE_TABLE_SIZE 256
33 
34 /* pipeline IRQ */
35 #define PLATFORM_SCHEDULE_IRQ IRQ_NUM_SOFTWARE0
36 #define PLATFORM_SCHEDULE_IRQ_NAME NULL
37 
38 /* Platform stream capabilities */
39 #define PLATFORM_MAX_CHANNELS 4
40 #define PLATFORM_MAX_STREAMS 5
41 
42 /* local buffer size of DMA tracing */
43 #define DMA_TRACE_LOCAL_SIZE HOST_PAGE_SIZE
44 
45 /* trace bytes flushed during panic */
46 #define DMA_FLUSH_TRACE_SIZE (MAILBOX_TRACE_SIZE >> 2)
47 
48 /* the interval of DMA trace copying */
49 #define DMA_TRACE_PERIOD 500000
50 
51 /*
52  * the interval of reschedule DMA trace copying in special case like half
53  * fullness of local DMA trace buffer
54  */
55 #define DMA_TRACE_RESCHEDULE_TIME 100
56 
57 /* DSP default delay in cycles */
58 #define PLATFORM_DEFAULT_DELAY 12
59 
60 #define SRAM_REG_FW_STATUS 0x4
61 
62 /* Platform defined panic code */
platform_panic(uint32_t p)63 static inline void platform_panic(uint32_t p)
64 {
65 	/* Store the error code in the debug box so the
66 	 * application processor can pick it up. Takes up 4 bytes
67 	 * from the debug box.
68 	 */
69 	mailbox_sw_reg_write(SRAM_REG_FW_STATUS, p);
70 
71 	/* Notify application processor */
72 	trigger_irq_to_host_req();
73 }
74 
75 /**
76  * \brief Platform specific CPU entering idle.
77  * May be power-optimized using platform specific capabilities.
78  * @param level Interrupt level.
79  */
80 void platform_wait_for_interrupt(int level);
81 
82 extern intptr_t _module_init_start;
83 extern intptr_t _module_init_end;
84 #endif
85 
86 #endif /* __PLATFORM_PLATFORM_H__ */
87 
88 #else
89 
90 #error "This file shouldn't be included from outside of sof/platform.h"
91 
92 #endif /* __SOF_PLATFORM_H__ */
93