Skip to content

Commit fe5c11d

Browse files
andyrosskartben
authored andcommitted
boards/mediatek: Add mt8196_adsp
Add Zephyr support for the Audio DSP on the MT8196 SOC. This is a very similar device to previous designs. Most of this patch is just DTS. The biggest delta is the more complicated second level interrupt controller, though it is still able to be represented using some vaguely clever DTS config over the older intc_mtk_adsp driver. Also the memory layout is slightly different, requiring a little indirection to set the initial boot stack address and log output buffer. And the timer "irq_ack" register bits moved. Signed-off-by: Andy Ross <[email protected]>
1 parent e35de00 commit fe5c11d

File tree

13 files changed

+235
-6
lines changed

13 files changed

+235
-6
lines changed

boards/mediatek/mt8196/Kconfig.mt8196

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright 2024 The ChromiumOS Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_MT8196
5+
select SOC_MT8196

boards/mediatek/mt8196/board.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
boards:
2+
- name: mt8196
3+
vendor: mediatek
4+
socs:
5+
- name: mt8196
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/* Copyright 2024 The ChromiumOS Authors
2+
* SPDX-License-Identifier: Apache-2.0
3+
*/
4+
#include <mem.h>
5+
6+
/dts-v1/;
7+
/ {
8+
9+
#address-cells = <1>;
10+
#size-cells = <1>;
11+
12+
sram0: memory@4e100000 {
13+
device_type = "memory";
14+
compatible = "mmio-sram";
15+
reg = <0x4e100000 DT_SIZE_K(512)>;
16+
};
17+
18+
dram0: memory@90000000 {
19+
device_type = "memory";
20+
compatible = "mmio-sram";
21+
reg = <0x90000000 DT_SIZE_M(6)>;
22+
};
23+
24+
dram1: memory@90700000 {
25+
device_type = "memory";
26+
compatible = "mmio-sram";
27+
reg = <0x90700000 DT_SIZE_M(1)>;
28+
};
29+
30+
soc {
31+
#address-cells = <1>;
32+
#size-cells = <1>;
33+
34+
core_intc: core_intc@0 {
35+
compatible = "cdns,xtensa-core-intc";
36+
reg = <0 4>;
37+
interrupt-controller;
38+
#interrupt-cells = <3>;
39+
};
40+
41+
/* The 8196 interrupt controller is actually more complicated
42+
* than the driver here supports. There are 64 total
43+
* interrupt inputs, each of which is a associated with one of
44+
* 16 "groups", each of which is wired to a separate Xtensa
45+
* architectural interrupt. (Whether the mapping of external
46+
* interrupts to groups is mutable is an open question, the
47+
* values here appear to be hardware defaults). We represent
48+
* each group (strictly each of the high and low 32 interrupts
49+
* of each group) as a separate adsp_intc controller, pointing
50+
* at the same status and enable registers, but with disjoint
51+
* masks. Note that this disallows configurations where a
52+
* single controller needs to manage interrupts in both the
53+
* high and low 32 bits of the set, but no current drivers
54+
* rely on such a configuration.
55+
*/
56+
57+
intc_g1: intc_g1@1a014010 {
58+
compatible = "mediatek,adsp_intc";
59+
interrupt-controller;
60+
#interrupt-cells = <3>;
61+
reg = <0x1a014010 4>;
62+
status-reg = <0x1a014008>;
63+
mask = <0x00007f3f>;
64+
interrupts = <1 0 0>;
65+
interrupt-parent = <&core_intc>;
66+
};
67+
68+
intc_g2: intc_g2@1a014010 {
69+
compatible = "mediatek,adsp_intc";
70+
interrupt-controller;
71+
#interrupt-cells = <3>;
72+
reg = <0x1a014010 4>;
73+
status-reg = <0x1a014008>;
74+
mask = <0x000000c0>;
75+
interrupts = <2 0 0>;
76+
interrupt-parent = <&core_intc>;
77+
};
78+
79+
ostimer64: ostimer64@1a00b080 {
80+
compatible = "mediatek,ostimer64";
81+
reg = <0x1a00b080 28>;
82+
};
83+
84+
ostimer0: ostimer@1a00b000 {
85+
compatible = "mediatek,ostimer";
86+
reg = <0x1a00b000 16>;
87+
interrupt-parent = <&intc_g1>;
88+
interrupts = <8 0 0>;
89+
};
90+
91+
mbox0: mbox@1a360100 {
92+
compatible = "mediatek,mbox";
93+
reg = <0x1a360100 16>;
94+
interrupt-parent = <&intc_g2>;
95+
interrupts = <6 0 0>;
96+
};
97+
98+
mbox1: mbox@1a370100 {
99+
compatible = "mediatek,mbox";
100+
reg = <0x1a370100 16>;
101+
interrupt-parent = <&intc_g2>;
102+
interrupts = <7 0 0>;
103+
};
104+
}; /* soc */
105+
106+
chosen { };
107+
aliases { };
108+
109+
};

boards/mediatek/twister.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ variants:
1414
name: MediaTek MT8188 Audio DSP
1515
mt8186/mt8186/adsp:
1616
name: MediaTek MT8186 Audio DSP
17+
mt8196/mt8196/adsp:
18+
name: MediaTek MT8196 Audio DSP

drivers/timer/mtk_adsp_timer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@ struct mtk_ostimer64 {
5656
#define OSTIMER_CON_CLKSRC_BCLK 0x20 /* CPU speed, 720 MHz */
5757
#define OSTIMER_CON_CLKSRC_PCLK 0x30 /* ~312 MHz experimentally */
5858

59+
#ifndef CONFIG_SOC_MT8196
5960
#define OSTIMER_IRQ_ACK_ENABLE BIT(4) /* read = status, write = enable */
6061
#define OSTIMER_IRQ_ACK_CLEAR BIT(5)
62+
#else
63+
#define OSTIMER_IRQ_ACK_ENABLE BIT(0)
64+
#define OSTIMER_IRQ_ACK_CLEAR BIT(5)
65+
#endif
6166

6267
#define OST64_HZ 13000000U
6368
#define OST_HZ 26000000U

soc/mediatek/mt8xxx/Kconfig.soc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ config SOC_SERIES_MT818X
1616
help
1717
Mediatek MT818x Audio DSPs
1818

19+
config SOC_SERIES_MT8196
20+
bool
21+
select SOC_FAMILY_MTK
22+
help
23+
Mediatek MT8196 Audio DSPs
24+
1925
config SOC_MT8195
2026
bool
2127
select SOC_SERIES_MT8195
@@ -28,7 +34,12 @@ config SOC_MT8188
2834
bool
2935
select SOC_SERIES_MT818X
3036

37+
config SOC_MT8196
38+
bool
39+
select SOC_SERIES_MT8196
40+
3141
config SOC
3242
default "mt8195" if SOC_MT8195
3343
default "mt8186" if SOC_MT8186
3444
default "mt8188" if SOC_MT8188
45+
default "mt8196" if SOC_MT8196

soc/mediatek/mt8xxx/irq.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ static const struct device *irq_dev(unsigned int *irq_inout)
2525
__ASSERT_NO_MSG((*irq_inout & 0xff) == 23);
2626
*irq_inout = (*irq_inout >> 8) - 1;
2727
return DEVICE_DT_GET(DT_INST(1, mediatek_adsp_intc));
28+
#elif defined(CONFIG_SOC_SERIES_MT8196)
29+
/* Two subcontrollers on core IRQs 1 and 2 */
30+
uint32_t lvl1 = *irq_inout & 0xff;
31+
32+
*irq_inout = (*irq_inout >> 8) - 1;
33+
if (lvl1 == 1) {
34+
return DEVICE_DT_GET(DT_INST(0, mediatek_adsp_intc));
35+
}
36+
__ASSERT_NO_MSG(lvl1 == 2);
37+
return DEVICE_DT_GET(DT_INST(1, mediatek_adsp_intc));
2838
#else
2939
/* Only one on 818x */
3040
return DEVICE_DT_GET(DT_INST(0, mediatek_adsp_intc));
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2024 The ChromiumOS Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if SOC_MT8196
5+
6+
config LEGACY_MULTI_LEVEL_TABLE_GENERATION
7+
default n
8+
9+
config NUM_2ND_LEVEL_AGGREGATORS
10+
default 2
11+
12+
config 2ND_LVL_INTR_00_OFFSET
13+
default 1
14+
15+
config 2ND_LVL_INTR_01_OFFSET
16+
default 2
17+
18+
endif

soc/mediatek/mt8xxx/mt8196/linker.ld

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* Copyright 2024 The ChromiumOS Authors
2+
* SPDX-License-Identifier: Apache-2.0
3+
*/
4+
5+
#include "../linker.ld"

soc/mediatek/mt8xxx/mt8196/soc.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* Copyright 2024 The ChromiumOS Authors
2+
* SPDX-License-Identifier: Apache-2.0
3+
*/
4+
5+
#ifndef ZEPHYR_SOC_MT8196_SOC_H
6+
#define ZEPHYR_SOC_MT8196_SOC_H
7+
8+
#include "../soc.h"
9+
10+
#endif /* ZEPHYR_SOC_MT8196_SOC_H */

0 commit comments

Comments
 (0)