Skip to content

Commit b265dd6

Browse files
committed
HOST_PTABLE support in, it works!
1 parent 0c27b46 commit b265dd6

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

app/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ config ZEPHYR_LOG
2121
config SCHEDULE_DMA_MULTI_CHANNEL
2222
default y if SOC_FAMILY_MTK
2323

24+
config HOST_PTABLE
25+
default y if SOC_FAMILY_MTK
26+
2427
# SOF code assumes system work queue and other system
2528
# wide threads are pinned to a single core.
2629
# CPU_MASK_PIN_ONLY must be set for all SOF builds.

src/platform/mtk/platform.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,35 @@ static void mbox_reply_fn(const struct device *mbox, void *arg)
9393
ipc_get()->is_notification_pending = false;
9494
}
9595

96+
/* "Host Page Table" support. This isn't really a page table, it's a
97+
* packed array of PPN addresses (basically a scatter/gather list)
98+
* used to configure the buffer used for dummy_dma, which is a "DMA"
99+
* driver that works by directly copying data in shared memory. And
100+
* somewhat confusingly, it's itself configured at runtime by "DMA"
101+
* over the same mechanism (instead of e.g. by a IPC command, which
102+
* would fit just fine!). All of this is degenerate with MTK anyway,
103+
* because the actual addresses being passed are in a DRAM region
104+
* dedicated for the purpose and are AFAICT guaranteed contiguous.
105+
*
106+
* Note: the 256 byte page table size is fixed by protocol in the
107+
* kernel driver, but here in SOF it's always been a platform symbol.
108+
* But it's not tunable! Don't touch it.
109+
*/
110+
static uint8_t hostbuf_ptable[256];
111+
static struct ipc_data_host_buffer mtk_host_buffer;
112+
113+
struct ipc_data_host_buffer *ipc_platform_get_host_buffer(struct ipc *ipc)
114+
{
115+
return &mtk_host_buffer;
116+
}
117+
96118
/* Called out of ipc_init(), which is called out of platform_init() below */
97119
int platform_ipc_init(struct ipc *ipc)
98120
{
121+
mtk_host_buffer.page_table = hostbuf_ptable;
122+
mtk_host_buffer.dmac = dma_get(DMA_DIR_HMEM_TO_LMEM, 0, DMA_DEV_HOST,
123+
DMA_ACCESS_SHARED);
124+
99125
schedule_task_init_edf(&ipc->ipc_task, SOF_UUID(zipc_task_uuid),
100126
&ipc_task_ops, ipc, 0, 0);
101127

@@ -118,7 +144,7 @@ void interrupt_clear_mask(uint32_t irq, uint32_t mask)
118144
{
119145
/* This is required out of dma_multi_chan_domain but nothing
120146
* defines it in Zephyr builds. Stub with a noop here,
121-
* knowing that MTK DMA devices don't have interrupts.
147+
* knowing that MTK "DMA" "devices" don't have interrupts.
122148
*/
123149
}
124150

@@ -146,8 +172,8 @@ int platform_init(struct sof *sof)
146172
{
147173
clocks_init(sof);
148174
sof->platform_timer_domain = zephyr_domain_init(PLATFORM_DEFAULT_CLOCK);
149-
ipc_init(sof);
150175
mtk_dai_init(sof);
176+
ipc_init(sof);
151177
scheduler_init_edf();
152178
scheduler_init_ll(sof->platform_timer_domain);
153179
sof->platform_dma_domain =

0 commit comments

Comments
 (0)