Skip to content

Commit edbd963

Browse files
andrew-mtklgirdwood
authored andcommitted
platform: mtk: Add support for mt8365 platform
mt8365 platform integrates a single-core HIFI4 DSP. The highest DSP operation frequency is 600MHz which requires 0.75v working voltage. otherwise, it should switch to 13M which can operate at the lowest working voltage 0.55v. Signed-off-by: Andrew Perepech <andrew.perepech@mediatek.com>
1 parent b4cbe48 commit edbd963

15 files changed

Lines changed: 1505 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause */
2+
/*
3+
* Copyright(c) 2024 MediaTek. All rights reserved.
4+
*
5+
* Author: Andrew Perepech <andrew.perepech@mediatek.com>
6+
*/
7+
8+
#if defined(__XTOS_RTOS_IDC_H__) || defined(__ZEPHYR_RTOS_IDC_H__)
9+
10+
#ifndef __PLATFORM_DRIVERS_IDC_H__
11+
#define __PLATFORM_DRIVERS_IDC_H__
12+
13+
#include <stdint.h>
14+
15+
struct idc_msg;
16+
17+
static inline int idc_send_msg(struct idc_msg *msg, uint32_t mode)
18+
{
19+
return 0;
20+
}
21+
22+
static inline int idc_init(void)
23+
{
24+
return 0;
25+
}
26+
27+
#endif /* __PLATFORM_DRIVERS_IDC_H__ */
28+
29+
#else
30+
31+
#error "This file shouldn't be included from outside of Zephyr/XTOS's rtos/idc.h"
32+
33+
#endif
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause */
2+
/*
3+
* Copyright(c) 2024 MediaTek. All rights reserved.
4+
*
5+
* Author: Andrew Perepech <andrew.perepech@mediatek.com>
6+
*/
7+
8+
#ifdef __SOF_LIB_CLK_H__
9+
10+
#ifndef __PLATFORM_LIB_CLK_H__
11+
#define __PLATFORM_LIB_CLK_H__
12+
13+
#include <stdint.h>
14+
15+
struct sof;
16+
17+
#define CPU_DEFAULT_IDX 4
18+
19+
#define CLK_CPU(x) (x)
20+
#define CLK_DEFAULT_CPU_HZ 600000000
21+
#define CLK_MAX_CPU_HZ 600000000
22+
#define CLK_SUSPEND_CPU_HZ 26000000
23+
#define NUM_CLOCKS 1
24+
#define NUM_CPU_FREQ 5
25+
26+
void platform_clock_init(struct sof *sof);
27+
28+
#define REG_APMIXDSYS_BASE 0x1000C000
29+
#define REG_TOPCKGEN_BASE 0x10000000
30+
31+
#define DSPPLL_CON0 (REG_APMIXDSYS_BASE + 0x390)
32+
#define DSPPLL_CON1 (REG_APMIXDSYS_BASE + 0x394)
33+
#define DSPPLL_CON2 (REG_APMIXDSYS_BASE + 0x398)
34+
#define DSPPLL_CON3 (REG_APMIXDSYS_BASE + 0x39C)
35+
36+
#define ULPLL_CON0 (REG_APMIXDSYS_BASE + 0x3B0)
37+
#define ULPLL_CON1 (REG_APMIXDSYS_BASE + 0x3B4)
38+
39+
#define PLL_BASE_EN BIT(0)
40+
#define PLL_PWR_ON BIT(0)
41+
#define PLL_ISO_EN BIT(1)
42+
43+
#define DSPPLL_312MHZ 0
44+
#define DSPPLL_400MHZ 1
45+
#define DSPPLL_600MHZ 2
46+
47+
#define CLK_MODE (REG_TOPCKGEN_BASE + 0x0)
48+
#define CLK_CFG_UPDATE1 (REG_TOPCKGEN_BASE + 0x8)
49+
#define CLK_CFG_8 (REG_TOPCKGEN_BASE + 0xC0)
50+
#define CLK_CFG_8_SET (REG_TOPCKGEN_BASE + 0xC4)
51+
#define CLK_CFG_8_CLR (REG_TOPCKGEN_BASE + 0xC8)
52+
53+
#define CLK_SCP_CFG_1 (REG_TOPCKGEN_BASE + 0x204)
54+
55+
#define CLK_DSP_SEL_26M 0
56+
#define CLK_DSP_SEL_26M_D_2 1
57+
#define CLK_DSP_SEL_DSPPLL 2
58+
#define CLK_DSP_SEL_DSPPLL_D_2 3
59+
#define CLK_DSP_SEL_DSPPLL_D_4 4
60+
#define CLK_DSP_SEL_DSPPLL_D_8 5
61+
62+
#define CLK_TOPCKGEN_SEL_PLLGP_26M 1
63+
#define CLK_TOPCKGEN_SEL_ULPLL_26M 2
64+
#define CLK_TOPCKGEN_SEL_GPIO_26M 4
65+
66+
enum mux_id_t {
67+
MUX_CLK_DSP_SEL = 0,
68+
MUX_CLK_TOPCKGEN_26M_SEL,
69+
HIFI4DSP_MUX_NUM,
70+
};
71+
72+
enum mux_26m_t {
73+
DCXO_26 = 0,
74+
ULPLL_26M,
75+
};
76+
77+
enum DSP_HW_DSP_CLK {
78+
DSP_CLK_13M = 0,
79+
DSP_CLK_26M,
80+
DSP_CLK_PLL_312M,
81+
DSP_CLK_PLL_400M,
82+
DSP_CLK_PLL_600M,
83+
};
84+
#endif /* __PLATFORM_LIB_CLK_H__ */
85+
86+
#else
87+
88+
#error "This file shouldn't be included from outside of sof/lib/clk.h"
89+
90+
#endif /* __SOF_LIB_CLK_H__ */
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause */
2+
/*
3+
* Copyright(c) 2024 MediaTek. All rights reserved.
4+
*
5+
* Author: Andrew Perepech <andrew.perepech@mediatek.com>
6+
*/
7+
8+
#ifdef __SOF_LIB_CPU_H__
9+
10+
#ifndef __PLATFORM_LIB_CPU_H__
11+
#define __PLATFORM_LIB_CPU_H__
12+
13+
/** \brief Id of primary DSP core */
14+
#define PLATFORM_PRIMARY_CORE_ID 0
15+
16+
#endif /* __PLATFORM_LIB_CPU_H__ */
17+
18+
#else
19+
20+
#error "This file shouldn't be included from outside of sof/lib/cpu.h"
21+
22+
#endif /* __SOF_LIB_CPU_H__ */
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause */
2+
/*
3+
* Copyright(c) 2024 MediaTek. All rights reserved.
4+
*
5+
* Author: Andrew Perepech <andrew.perepech@mediatek.com>
6+
*/
7+
8+
#ifdef __SOF_LIB_DAI_H__
9+
10+
#ifndef __PLATFORM_LIB_DAI_H__
11+
#define __PLATFORM_LIB_DAI_H__
12+
13+
#endif /* __PLATFORM_LIB_DAI_H__ */
14+
15+
#else
16+
17+
#error "This file shouldn't be included from outside of sof/lib/dai.h"
18+
19+
#endif /* __SOF_LIB_DAI_H__ */
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause */
2+
/*
3+
* Copyright(c) 2024 MediaTek. All rights reserved.
4+
*
5+
* Author: Andrew Perepech <andrew.perepech@mediatek.com>
6+
*/
7+
8+
#ifdef __SOF_LIB_DMA_H__
9+
10+
#ifndef __PLATFORM_LIB_DMA_H__
11+
#define __PLATFORM_LIB_DMA_H__
12+
13+
#define PLATFORM_NUM_DMACS 2
14+
15+
/* max number of supported DMA channels */
16+
#define PLATFORM_MAX_DMA_CHAN 32
17+
18+
#define DMA_ID_AFE_MEMIF 0
19+
#define DMA_ID_HOST 1
20+
21+
#define dma_chan_irq(dma, chan) dma_irq(dma)
22+
#define dma_chan_irq_name(dma, chan) dma_irq_name(dma)
23+
24+
#endif /* __PLATFORM_LIB_DMA_H__ */
25+
26+
#else
27+
28+
#error "This file shouldn't be included from outside of sof/lib/dma.h"
29+
30+
#endif /* __SOF_LIB_DMA_H__ */
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause */
2+
/*
3+
* Copyright(c) 2024 MediaTek. All rights reserved.
4+
*
5+
* Author: Andrew Perepech <andrew.perepech@mediatek.com>
6+
*/
7+
8+
#ifdef __SOF_LIB_MAILBOX_H__
9+
10+
#ifndef __PLATFORM_LIB_MAILBOX_H__
11+
#define __PLATFORM_LIB_MAILBOX_H__
12+
13+
#include <sof/lib/memory.h>
14+
#include <stddef.h>
15+
#include <stdint.h>
16+
17+
/*
18+
* The Window Region on MT8365 SRAM is organised like this :-
19+
* +--------------------------------------------------------------------------+
20+
* | Offset | Region | Size |
21+
* +---------------------+----------------+-----------------------------------+
22+
* | SRAM_TRACE_BASE | Trace Buffer | SRAM_TRACE_SIZE |
23+
* +---------------------+----------------+-----------------------------------+
24+
* | SRAM_DEBUG_BASE | Debug data | SRAM_DEBUG_SIZE |
25+
* +---------------------+----------------+-----------------------------------+
26+
* | SRAM_INBOX_BASE | Inbox | SRAM_INBOX_SIZE |
27+
* +---------------------+----------------+-----------------------------------+
28+
* | SRAM_OUTBOX_BASE | Outbox | SRAM_MAILBOX_SIZE |
29+
* +---------------------+----------------+-----------------------------------+
30+
*/
31+
32+
#define MAILBOX_DSPBOX_SIZE SRAM_OUTBOX_SIZE
33+
#define MAILBOX_DSPBOX_BASE SRAM_OUTBOX_BASE
34+
#define MAILBOX_DSPBOX_OFFSET SRAM_OUTBOX_OFFSET
35+
36+
#define MAILBOX_HOSTBOX_SIZE SRAM_INBOX_SIZE
37+
#define MAILBOX_HOSTBOX_BASE SRAM_INBOX_BASE
38+
#define MAILBOX_HOSTBOX_OFFSET SRAM_INBOX_OFFSET
39+
40+
#define MAILBOX_DEBUG_SIZE SRAM_DEBUG_SIZE
41+
#define MAILBOX_DEBUG_BASE SRAM_DEBUG_BASE
42+
#define MAILBOX_DEBUG_OFFSET SRAM_DEBUG_OFFSET
43+
44+
#define MAILBOX_TRACE_SIZE SRAM_TRACE_SIZE
45+
#define MAILBOX_TRACE_BASE SRAM_TRACE_BASE
46+
#define MAILBOX_TRACE_OFFSET SRAM_TRACE_OFFSET
47+
48+
#define MAILBOX_EXCEPTION_SIZE SRAM_EXCEPT_SIZE
49+
#define MAILBOX_EXCEPTION_BASE SRAM_EXCEPT_BASE
50+
#define MAILBOX_EXCEPTION_OFFSET SRAM_EXCEPT_OFFSET
51+
52+
#define MAILBOX_STREAM_SIZE SRAM_STREAM_SIZE
53+
#define MAILBOX_STREAM_BASE SRAM_STREAM_BASE
54+
#define MAILBOX_STREAM_OFFSET SRAM_STREAM_OFFSET
55+
56+
static inline void mailbox_sw_reg_write(size_t offset, uint32_t src)
57+
{
58+
volatile uint32_t *ptr;
59+
60+
ptr = (volatile uint32_t *)(MAILBOX_DEBUG_BASE + offset);
61+
*ptr = src;
62+
}
63+
64+
static inline uint32_t mailbox_sw_reg_read(size_t offset)
65+
{
66+
volatile uint32_t *ptr;
67+
68+
ptr = (volatile uint32_t *)(MAILBOX_DEBUG_BASE + offset);
69+
70+
return *ptr;
71+
}
72+
73+
#define ADSP_IPI_OP_REQ 0x1
74+
#define ADSP_IPI_OP_RSP 0x2
75+
void trigger_irq_to_host_req(void);
76+
void trigger_irq_to_host_rsp(void);
77+
78+
#endif /* __PLATFORM_LIB_MAILBOX_H__ */
79+
80+
#else
81+
82+
#error "This file shouldn't be included from outside of sof/lib/mailbox.h"
83+
84+
#endif /* __SOF_LIB_MAILBOX_H__ */
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause */
2+
/*
3+
* Copyright(c) 2024 MediaTek. All rights reserved.
4+
*
5+
* Author: Andrew Perepech <andrew.perepech@mediatek.com>
6+
*/
7+
8+
#ifdef __SOF_LIB_PM_RUNTIME_H__
9+
10+
#ifndef __PLATFORM_LIB_PM_RUNTIME_H__
11+
#define __PLATFORM_LIB_PM_RUNTIME_H__
12+
13+
#include <stdint.h>
14+
15+
struct pm_runtime_data;
16+
17+
/**
18+
* \brief Initializes platform specific runtime power management.
19+
* \param[in,out] prd Runtime power management data.
20+
*/
21+
static inline void platform_pm_runtime_init(struct pm_runtime_data *prd)
22+
{
23+
}
24+
25+
/**
26+
* \brief Retrieves platform specific power management resource.
27+
*
28+
* \param[in] context Type of power management context.
29+
* \param[in] index Index of the device.
30+
* \param[in] flags Flags, set of RPM_...
31+
*/
32+
static inline void platform_pm_runtime_get(uint32_t context, uint32_t index, uint32_t flags)
33+
{
34+
}
35+
36+
/**
37+
* \brief Releases platform specific power management resource.
38+
*
39+
* \param[in] context Type of power management context.
40+
* \param[in] index Index of the device.
41+
* \param[in] flags Flags, set of RPM_...
42+
*/
43+
static inline void platform_pm_runtime_put(uint32_t context, uint32_t index, uint32_t flags)
44+
{
45+
}
46+
47+
static inline void platform_pm_runtime_enable(uint32_t context, uint32_t index)
48+
{
49+
}
50+
51+
static inline void platform_pm_runtime_disable(uint32_t context, uint32_t index)
52+
{
53+
}
54+
55+
static inline bool platform_pm_runtime_is_active(uint32_t context, uint32_t index)
56+
{
57+
return false;
58+
}
59+
60+
#endif /* __PLATFORM_LIB_PM_RUNTIME_H__ */
61+
62+
#else
63+
64+
#error "This file shouldn't be included from outside of sof/lib/pm_runtime.h"
65+
66+
#endif /* __SOF_LIB_PM_RUNTIME_H__ */

0 commit comments

Comments
 (0)