Commit graph

1,021 commits

Author SHA1 Message Date
Bincai Liu
f864a192e3 soc/mediatek/mt8196: Support 512 bytes EDID
Refine dptx_get_edid function to read extension edid to bring up 2.8k
120hz OLED panel.

BRANCH=rauru
BUG=b:392040003
TEST=check edp training pass and show log:
EQ training pass

Change-Id: If35782950ae02d892ea697580fa4991595c21533
Signed-off-by: Bincai Liu <bincai.liu@mediatek.corp-partner.google.com>
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86779
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-03-12 12:45:48 +00:00
Yidi Lin
2b131cc744 soc/mediatek/mt8196: Eliminate mt6685_hw.h and mt6685_rtc_hw.h
Utilize the constants in rtc_reg_common.h and rtc_common.h.

1. Maintain minimum defines in mt6685_rtc.h.
2. Remove mt6685_hw.h and mt6685_rtc_hw.h.
3. Remove redundant definitions.

The constains in mt6685_rtc.h are determined by below command,

aarch64-cros-linux-gnu-gcc -E src/soc/mediatek/mt8196/mt6685_rtc.c \
-I src/commonlib/bsd/include/ -I src/include/ \
-I src/commonlib/include/ -I src/soc/mediatek/mt8196/include/ \
-I src/soc/mediatek/common/include/ -I src/arch/arm64/include/armv8/ \
-I ./src/arch/arm64/include/

BRANCH=rauru
BUG=b:391067089
TEST=compare macro expansion result before and after applying the patch
TEST=boot to kernel without RTC error

Change-Id: I69ee165df6a1c9ea5853173f46f0aafc382153c1
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86264
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-03-10 04:04:59 +00:00
Zhaoqing Jiu
1faea7389c soc/mediatek/mt8196: Save HW protect temperature to SRAM
It will restore the HW protection settings based on the data saved in
the SRAM, after the system suspends and resumes.

BRANCH=rauru
BUG=b:389026545
TEST=Boot up and check temperature in coreboot log:
[INFO ]  [LVTS_MSR] ts0 msr_all=141d0, msr_temp=16848, temp=41086
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 0 ts_name 0 temp 41086 rg_temp 41073(42059)
[INFO ]  [LVTS_MSR] ts1 msr_all=141e3, msr_temp=16867, temp=41540
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 1 ts_name 1 temp 41540 rg_temp 41526(42523)
[INFO ]  [LVTS_MSR] ts2 msr_all=14199, msr_temp=16793, temp=39772[0m
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 2 ts_name 2 temp 39772 rg_temp 39760(40715)
[INFO ]  [LVTS_MSR] ts3 msr_all=141c2, msr_temp=16834, temp=40751
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 3 ts_name 3 temp 40751 rg_temp 40739(41717)
[INFO ]  [LVTS_MSR] ts4 msr_all=141d0, msr_temp=16848, temp=41086
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 0 ts_name 4 temp 41086 rg_temp 41073(42059)
[INFO ]  [LVTS_MSR] ts5 msr_all=141b3, msr_temp=16819, temp=40393
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 1 ts_name 5 temp 40393 rg_temp 40380(41350)
[INFO ]  [LVTS_MSR] ts6 msr_all=14194, msr_temp=16788, temp=39652
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 2 ts_name 6 temp 39652 rg_temp 39641(40593)
[INFO ]  [LVTS_MSR] ts7 msr_all=14186, msr_temp=16774, temp=39318
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 3 ts_name 7 temp 39318 rg_temp 39307(40251)

Signed-off-by: Zhaoqing Jiu <zhaoqing.jiu@mediatek.corp-partner.google.com>
Change-Id: Ib714c297871132907e286536c4b3aea1532f3869
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86551
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-03-08 01:51:21 +00:00
Zhaoqing Jiu
1b7e1adc90 soc/mediatek/mt8196: Remove unused LVTS controllers
Controller2 and controller3 are disabled, so remove them from source
code.

BRANCH=rauru
BUG=b:389026545
TEST=Boot up to kernel

Signed-off-by: Zhaoqing Jiu <zhaoqing.jiu@mediatek.corp-partner.google.com>
Change-Id: I69c1e76e7de544fd4e24e8e94e4f676de783e205
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86687
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-03-07 10:05:21 +00:00
Zhaoqing Jiu
1633ae8378 soc/mediatek/mt8196: Adjust thermal trip point parameters
Adjust thermal trip point parameters so the thermal can trigger the
interrupt at the expected trip point.

BRANCH=rauru
BUG=b:389026545
TEST=Boot up and check temperature in coreboot log:
[INFO ]  [LVTS_MSR] ts0 msr_all=141d0, msr_temp=16848, temp=41086
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 0 ts_name 0 temp 41086 rg_temp 41073(42059)
[INFO ]  [LVTS_MSR] ts1 msr_all=141e3, msr_temp=16867, temp=41540
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 1 ts_name 1 temp 41540 rg_temp 41526(42523)
[INFO ]  [LVTS_MSR] ts2 msr_all=14199, msr_temp=16793, temp=39772[0m
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 2 ts_name 2 temp 39772 rg_temp 39760(40715)
[INFO ]  [LVTS_MSR] ts3 msr_all=141c2, msr_temp=16834, temp=40751
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 3 ts_name 3 temp 40751 rg_temp 40739(41717)
[INFO ]  [LVTS_MSR] ts4 msr_all=141d0, msr_temp=16848, temp=41086
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 0 ts_name 4 temp 41086 rg_temp 41073(42059)
[INFO ]  [LVTS_MSR] ts5 msr_all=141b3, msr_temp=16819, temp=40393
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 1 ts_name 5 temp 40393 rg_temp 40380(41350)
[INFO ]  [LVTS_MSR] ts6 msr_all=14194, msr_temp=16788, temp=39652
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 2 ts_name 6 temp 39652 rg_temp 39641(40593)
[INFO ]  [LVTS_MSR] ts7 msr_all=14186, msr_temp=16774, temp=39318
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 3 ts_name 7 temp 39318 rg_temp 39307(40251)

Signed-off-by: Zhaoqing Jiu <zhaoqing.jiu@mediatek.corp-partner.google.com>
Change-Id: Ia7361edd7f75b82fff4241ec94488ed1ef07346f
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86552
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-02-28 13:04:43 +00:00
Guangjie Song
024a23e478 soc/mediatek/mt8196: Disable HWRot's clocks
HWRot (Hardware Root of trust) is not used, so we disable its clocks to
save power. This patch is a subitem of Vcore power consumption
improvement. The whole work improves SoC power consumption from 120mW to
90mW in suspend.

BRANCH=rauru
BUG=b:377628718
TEST=Bootup OK & Suspend/Resume passed

Signed-off-by: Guangjie Song <guangjie.song@mediatek.com>
Change-Id: I25e607e8e8b2d52608d279e1862f423ca50aab6a
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86553
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-02-25 11:22:30 +00:00
Vince Liu
ac80241fc9 soc/mediatek/mt8189: Reduce bootblock size by separating SPI NOR GPIOs
In the bootblock stage, only SPI NOR related GPIOs are used. To optimize the code size, separate the SPI NOR GPIO driving information. This modification reduces the bootblock code size by 1KB.

BUG=b:379008996
BRANCH=none
TEST=booted successfully

Signed-off-by: Vince Liu <vince-wl.liu@mediatek.corp-partner.google.com>
Change-Id: If7e8e5c7db59b5f181db14f6e66df2f333dbb6d4
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86538
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-02-22 00:57:59 +00:00
Vince Liu
61f7e5a6cf soc/mediatek/mt8196: Move common functions to gpio_eint_v2.c
Move gpio_get_eint_reg() and gpio_calc_eint_pos_bit() to common code
to avoid redundant definitions for other platforms such as MT8189.

BUG=b:379008996
BRANCH=none
TEST=build passed.

Signed-off-by: Vince Liu <vince-wl.liu@mediatek.corp-partner.google.com>
Change-Id: Id21f627a49f730f3a0db786a148f81806aeba287
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86541
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-02-21 14:12:23 +00:00
Lu Tang
f21969acb2 soc/mediatek/mt8196: Set MT6316 deglitch time from 2ns to 4ns
To fix the SPMI-P glitch, set the mt6316 deglitch time from 2ns to 4ns.
Additionally, a hardware solution of SPMI damping to 0 ohm is needed.

BRANCH=rauru
TEST=Build passed and booted successfully. 10 platforms have passed CPU
stress tests over multiple iterations.
BUG=b:386438329

Signed-off-by: Lu Tang <lu.tang@mediatek.corp-partner.google.com>
Change-Id: I77bd50cc6c25d6dcded57d9d65d92a0dd19c3c86
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86371
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Knox Chiou <knoxchiou@google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-02-13 14:48:19 +00:00
Shunxi Zhang
d669736841 soc/mediatek/mt8196: Fix RTC recovery by disabling external XTAL
Configure PMIC register 0x50c bit0 which decides whether to use external
xtal. This bit of mt6685 should be set to 1, to disable external xtal.

BRANCH=rauru
BUG=b:395485005
TEST=emerge-rauru coreboot chromeos-bootimage, remove battery and
charger, then insert battery and charge, RTC boots normally.

Signed-off-by: Shunxi Zhang <ot_shunxi.zhang@mediatek.com>
Change-Id: Iea44f13af030f24c02993dd43a35a9d8b4f72179
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86353
Reviewed-by: Shunxi Zhang <ot_shunxi.zhang@mediatek.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-02-12 09:18:00 +00:00
Guangjie Song
5e14f1f525 soc/mediatek/mt8196: Remove tvdpll3 disable/enable
The tvdpll3 cannot be disabled during suspend because of the enable
operation, so we remove the enable operation. Hardware can now
automatically enable and disable tvdpll3 based on the clock demand of
its downstream.

BRANCH=rauru
BUG=b:377628718
TEST=Bootup OK, Suspend/Resume OK and FW screen shown OK, with MMinfra
kernel/vcp patch, mminfra can be turned off to reduce power consumption.

Signed-off-by: Guangjie Song <guangjie.song@mediatek.com>
Change-Id: Ib9c72a1602c1f76dc94cca5c4a61a542a853560b
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86343
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-02-12 09:17:50 +00:00
Yu-Ping Wu
c0506ad1e0 soc/mediatek/mt8196: Require mtk_fsp_*.elf to exist
As MT8196 won't be able to boot up without mtk_fsp_romstage.elf and
mtk_fsp_ramstage.elf, ensure their presence in build time.

Change-Id: I668319ae1f63818e324002e7ae4d888479edb9cf
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86355
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-02-12 09:09:17 +00:00
Guangjie Song
93cef8791b soc/mediatek/mt8196: Correct MMinfra vote register
Correct MMinfra vote register to fix MMinfra power off failure during
suspend.

BRANCH=rauru
BUG=b:377628718
TEST=Bootup OK and Suspend/Resume OK, with MMinfra kernel/vcp patch,
mminfra can be turned off to reduce power consumption by 50mW.

Signed-off-by: Guangjie Song <guangjie.song@mediatek.com>
Change-Id: I7c23c3c53c68b0de85d8b6189b685de7f8398e8b
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86342
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-02-11 14:09:56 +00:00
Lu Tang
9c5496ecb0 soc/mediatek/mt8196: Set the driving strength of SPMI-P to maximum
To fix the SPMI-P glitch, the driving strength of SPMI-P needs to be set
to a maximum value of 16mA. Additionally, a hardware solution of
external pull-down is also required.

BRANCH=rauru
TEST=Build passed and booted successfully. The platform remained idle
for approximately 20 hours without hang.
BUG=b:383634290

Signed-off-by: Lu Tang <lu.tang@mediatek.corp-partner.google.com>
Change-Id: I131fd04c0313c7ed64bbd123f61d9a6849c8def4
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86341
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-02-11 14:09:47 +00:00
Yidi Lin
04ccbbc464 soc/mediatek/common: Measure mtk_fsp_load_and_run() execution time
Measure mtk_fsp_load_and_run() execution time. This info helps AP boot
time analysis. The logs show as below.

[INFO ]  mtk_fsp_load_and_run: run fallback/mtk_fsp_romstage at phase 0x30 in 0 msecs
[INFO ]  mtk_fsp_load_and_run: run fallback/mtk_fsp_ramstage at phase 0x50 in 41 msecs

BUG=none
BRANCH=rauru
TEST=cbmem -1|grep "mtk_fsp_load_and_run"

Change-Id: I61706952bef4590c5bfd09707a08a4f1a25fbda2
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86325
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-02-09 20:40:11 +00:00
Yidi Lin
8deb8e94ad soc/mediatek/mt8196: Correct assert conditions
Correct the assert conditions in dptx_hal_setswing_preemphasis() and
dptx_hal_phy_set_swing_preemphasis().

BRANCH=rauru
BUG=b:376357839
TEST=Verify FW screen with a 4 lanes panel on Hylia

Change-Id: I8830b05c976ea2ba987de6333b93e2394d3403ba
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86302
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-02-07 12:43:26 +00:00
Gavin Liu
2fdfa50437 soc/mediatek/mt8196: Specify MTKLIB_PATH for building BL31
Add BL31 static library path to BL31 build argument.

BRANCH=rauru
BUG=b:317009620
TEST=Build pass with and without static library. boot ok.

Change-Id: I858686ede3730fb70f71565ca3593e7eb4c460d2
Signed-off-by: Gavin Liu <gavin.liu@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86252
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-02-05 09:10:30 +00:00
Jarried Lin
5411e1a6cf soc/mediatek/mt8196: Add pi_img loader in ramstage
This patch includes loading pi_img through CBFS and passing parameters
of pi_img to mtk_fsp for parsing.

BUG=b:373797027
TEST=Build pass. boot ok.
Locd pi_img with following logs:
CBFS: Found 'pi_img.img' @0xb2340 size 0x9620 in mcache @0xfffdd440
read SPI 0x4b43a0 0x9620: 2946 us, 13045 KB/s, 104.360 Mbps
VB2:vb2_digest_init() 38432 bytes, hash algo 2, HW acceleration enabled
mtk_init_mcu: Loaded (and reset) pi_img.img in 3 msecs (180421 bytes)

Change-Id: I571243c3115f5cd005fac88eb740c643e936fca9
Signed-off-by: Jarried Lin <jarried.lin@mediatek.corp-partner.google.com>
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86161
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-01-27 23:58:02 +00:00
Yidi Lin
864a7e2d03 soc/mediatek/common: Update fsp_status enum type
Sync the enum values from mtk-fsp private repo.

TEST=build pass.
BUG=b:373797027

Change-Id: I8a1cb107f1ff8a65962997e861e8e670cd9582a2
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86160
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-01-27 23:57:51 +00:00
Jarried Lin
c5b528ee1c soc/mediatek/commmon: Set mcupm mcufw_reserved region to non-cacheable
Set mcufw_reserved region to non-cacheable and remove cache operation in
dvfs.c.

TEST=Build pass, boot ok.
Check MMU List by CVD (Codeviser):
0x00113000--0x00123FFF  = I:non-cacheable O:non-cacheable
BUG=b:390334489

Change-Id: I886effd59006e5ad4bfe5bdbc14f057520304835
Signed-off-by: Jarried Lin <jarried.lin@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86159
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-01-27 23:57:42 +00:00
Jarried Lin
05e4a7b8c5 soc/mediatek/mt8196: Correct SPM firmware file suffix to .bin
Correct SPM firmware file suffix from .pm to .bin in Kconfig.

coreboot log:
mtk_init_mcu: Loaded (and reset) spm_firmware.bin in 3 msecs (30114 bytes)
SPM: spm_init done in 3 msecs, spm pc = 0x1430

TEST=Build pass, boot successful.
BUG=b:348147674

Change-Id: I053e08c9665d434e4fc9a01bca52101218b2c634
Signed-off-by: Jarried Lin <jarried.lin@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86156
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-01-27 23:57:25 +00:00
Jarried Lin
eccbf5186d soc/mediatek/mt8196: Initialize mt6685 PMIF for RTC read/write API
RTC read/write API requires mt6685 PMIF initialization to prevent
assertion from rtc_get().

BUG=b:382351678
TEST=Build pass, boot successfully, boot log show:
[INFO ]  [mt6685_init_pmif_arb]CHIP ID = 0x85

Change-Id: I4b0298e71c2c270e0c48723755319348928ac1af
Signed-off-by: Jarried Lin <jarried.lin@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86155
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-01-26 08:02:00 +00:00
Jarried Lin
4224d59d0e soc/mediatek/mt8196: Correct the region size for mcufw_reserved
Adjust the allocated region size for mcufw_reserved from 52K to 68K.

TEST=Build pass.
BUG=b:390334489

Change-Id: I1c17c1492d5568f4d51ff45e1fb90e067eae5cb1
Signed-off-by: Jarried Lin <jarried.lin@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86108
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-01-24 02:20:41 +00:00
Jarried Lin
3076404ff6 soc/mediatek/mt8196: Add RTC driver
Add RTC drivers for MT6685.

TEST=build pass.
BUG=b:317009620

Change-Id: I3dd337eaa3eed3012ddea300f7e04f2b63fb2daa
Signed-off-by: Shunxi Zhang <ot_shunxi.zhang@mediatek.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85978
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Shunxi Zhang <ot_shunxi.zhang@mediatek.corp-partner.google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-01-23 06:03:46 +00:00
Jarried Lin
097376c150 soc/mediatek/mt8196: Add vcore DVFS settings
Add vcore settings, so that other tinysys (such as mcupm, spm, etc.)
will reference these value during initialization.

BUG=b:343878736
TEST=Build pass, boot successful. Check log with:
[INFO]	Vcore DVFS settings done

Change-Id: I0d3e1d6ea648af938d41a5c9461cdd2972371177
Signed-off-by: Kunlong Wang <kunlong.wang@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86070
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-01-22 15:43:02 +00:00
Yu-Ping Wu
7b6bbb7ef5 soc/mediatek: Fix register access for EINT
We should be writing to the address of reg[i], instead of the address
whose value is reg[i].

Change-Id: I4fb78f974155725a91aad3a5450733d24b57af15
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86073
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-01-22 04:01:27 +00:00
Jarried Lin
905684a945 soc/mediatek/mt8196: Fix issue with incomplete modem disable
If the modem is not completely disabled, it will cause issues with
suspend to RAM. Update the condition check in MD1_PWR_STA and increased
the MAX_RETRY_COUNT from 200 to 4000 to make sure that the modem has
sufficient time to completely disable before proceeding.

TEST=Measure the power and ensure that the DRAM enters self-refresh
mode.
BUG=b:377628718

Change-Id: I6e915d26e5b3caee36f4726bc2fc1c53cfc17bfc
Signed-off-by: Jarried Lin <jarried.lin@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86069
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-01-21 14:18:48 +00:00
Nancy Lin
fb2655d06a soc/mediatek/mt8196: Add DDP driver
Add DDP (display data pipe) driver that supports main path to eDP panel.

TEST=build pass and firmware display ok
BUG=b:343351631
Signed-off-by: Nancy Lin <nancy.lin@mediatek.corp-partner.google.com>
Change-Id: I006911e83d940c1eec7135a6a0c36fbfa2aad466
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85950
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-01-21 14:16:25 +00:00
Jarried Lin
f825971a56 soc/mediatek/mt8196: Add eDP driver
Add eDP driver to adjust training flow and turn off PHY power before PHY
configuration to prevent potential link training failures.

DISP_DVO is a highly advanced variant of DP_INTF block for eDP or HDMI
or simply digital video output. DISP represents “display”, while DVO is
the abbreviation of “digital video output”. This version of DISP_DVO is
mainly designed for eDP1.5 protocol.

TEST=check edp training pass and show log:
EQ training pass
BUG=b:343351631

Change-Id: Iccba53f6c6181ca84624c216f9641a2ae9041671
Signed-off-by: Bincai Liu <bincai.liu@mediatek.corp-partner.google.com>
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85949
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-01-21 14:16:17 +00:00
Jarried Lin
93b6b2e463 soc/mediatek/mt8196: Add DVFS driver
Add the initialization code for CPU Dynamic Voltage and Frequency
Scaling (DVFS) for MCUPM.

TEST=Build pass.
BUG=b:317009620

Change-Id: I92b7c57ad8c3d9e9954f02a08954939f45c5e2c2
Signed-off-by: Jarried Lin <jarried.lin@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86041
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-01-21 14:15:38 +00:00
Jarried Lin
c0f0be625b soc/mediatek/mt8196: Add thermal driver
Add thermal driver to support LVTS (Low Voltage Thermal Sensor).

BUG=b:317009620
TEST=Check temperatures read from each sensors.
[INFO ]  [LVTS_MSR] ts0 msr_all=14104, msr_temp=16644, temp=35694
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 0 ts_name 0 temp 35694 rg_temp 35697(36554)
[INFO ]  [LVTS_MSR] ts1 msr_all=14116, msr_temp=16662, temp=36088
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 1 ts_name 1 temp 36088 rg_temp 36091(36958)
[INFO ]  [LVTS_MSR] ts2 msr_all=140f6, msr_temp=16630, temp=35387
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 2 ts_name 2 temp 35387 rg_temp 35390(36240)
[INFO ]  [LVTS_MSR] ts3 msr_all=14105, msr_temp=16645, temp=35716
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 3 ts_name 3 temp 35716 rg_temp 35718(36576)
[INFO ]  [LVTS_MSR] ts4 msr_all=14129, msr_temp=16681, temp=36504
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 0 ts_name 4 temp 36504 rg_temp 36507(37384)
[INFO ]  [LVTS_MSR] ts5 msr_all=1412d, msr_temp=16685, temp=36592
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 1 ts_name 5 temp 36592 rg_temp 36595(37474)
[INFO ]  [LVTS_MSR] ts6 msr_all=140eb, msr_temp=16619, temp=35146
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 2 ts_name 6 temp 35146 rg_temp 35149(35993)
[INFO ]  [LVTS_MSR] ts7 msr_all=14126, msr_temp=16678, temp=36438
[INFO ]  lvts_tscpu_thermal_read_tc_temp order 3 ts_name 7 temp 36438 rg_temp 36442(37317)

Signed-off-by: Zhaoqing Jiu <zhaoqing.jiu@mediatek.corp-partner.google.com>
Change-Id: Ieef94a6909e4da82461351bcb9292e9d01db3362
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86017
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-01-21 09:09:34 +00:00
Yu-Ping Wu
75574f67f6 soc/mediatek/mt8196: Rename mtk_pwrsel.* to pwrsel.*
As the mtk_pwrsel.{c,h} files are already under the soc/mediatek
directory, drop the file name prefix "mtk_" from them.

BUG=b:317009620
TEST=none

Change-Id: I28131d44067c33b5d8682a85cc8a73fc42604de3
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86059
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-01-21 04:13:05 +00:00
Jarried Lin
0b1779718e soc/mediatek/mt8196: Add unmask eint event for bootblock
EINT event mask register is used to mask EINT wakeup source. All wakeup
sources are masked by default. Since most MediaTek SoCs do not have this
design, we can't modify the kernel EINT upstream driver to solve the
issue "Can't wake using power button (cros_ec) or touchpad". So we add a
driver here to unmask all wakeup sources.

TEST=write eint data successfully.
BUG=b:317009620

Change-Id: I4bf3820a89172186b8f51591f8760787affbb7a3
Signed-off-by: Chhao Chang <ot_chhao.chang@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/84025
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-01-20 02:27:03 +00:00
Lu Tang
3eb39a1a33 soc/mediatek/common: Fix wrong write API for protect_key_setting
When writing key_protect_setting to PMIC, PMIC expects receiving 1 byte
per write. PMIC would receive unexpected zero byte if using
mt6685_write16. Fix the write operation by using mt6685_write8.

TEST=Build pass.
BUG=b:388666377

Signed-off-by: Lu Tang <lu.tang@mediatek.corp-partner.google.com>
Change-Id: Ib6e79642e813e7a1f0d38243e9c4db5a699cc9e3
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86035
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-01-19 07:59:19 +00:00
Jarried Lin
b9a1e64538 soc/mediatek/common: Fix wrong write API for protect_key_setting
Fix the issue where the DUT cannot power on during S5. When writing
key_protect_setting to PMIC, PMIC expects receiving 1 byte per write.
PMIC would receive unexpected zero byte if using mt6363_write16. Fix the
write operation by using mt6363_write8.

TEST=Build pass, DUT can power on during S5.
BUG=b:388666377

Change-Id: I0a7c0d2fa1f93a55731b4b58923d6f80a4c4be89
Signed-off-by: Jarried Lin <jarried.lin@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86034
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-01-19 07:59:10 +00:00
Jason-jh Lin
0dbef76544 soc/mediatek/mt8196: Add GCE ddren sel control to mminfra
MMINFRA_GCE_DDREN_SEL is a setting for switching the DRAM transaction
ACK from SPM: 0, non-SPM: 0x1.

In MT8196, SPM has masked all the DDR requests, so this setting should
be set to non-SPM whenever mminfra is powering on. Otherwise, GCE will
hang when accessing DRAM.

BUG=b:379039600
TEST=boot up ok, GCE can access DRAM continuously

Change-Id: I30309b0426f803e28858eb15652a649927f94c7e
Signed-off-by: Jason-jh Lin <jason-jh.lin@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86027
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-01-19 07:59:01 +00:00
Jarried Lin
e299b5171a soc/mediatek: Correct value's data type to u8 in dptx
TEST=build pass
BUG=b:343351631

Change-Id: I60bbb2c37811655692a5a8cd9f942fed4ead8abb
Signed-off-by: Bincai Liu <bincai.liu@mediatek.corp-partner.google.com>
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85948
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-01-18 15:10:40 +00:00
Yu-Ping Wu
1ad4474141 soc/mediatek: Introduce mtk_edp_enable() to fix eDP init flow
In the current eDP initialization flow, eDP is configured and enabled
before display data pipe (DDP) initialization. The init flow is wrong,
because eDP should be enabled only after DDP is correctly set up. The
wrong flow may lead to garbage display between enabling eDP and
configuring DDP.

To fix the problem, the dptx_video_enable(true) call needs to be moved
after mtk_ddp_mode_set(). Introduce a new API mtk_edp_enable() for eDP
enablement, to be separated from the existing mtk_edp_init(). The fixed
eDP init flow is: mtk_edp_init -> mtk_ddp_mode_set -> mtk_edp_enable.

Change-Id: Ief847320caca1af1c6deb242dc224e7698a6603c
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86028
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-01-18 15:10:10 +00:00
Jarried Lin
194d0c45de soc/mediatek/mt8196: Add mtk-fsp loader in romstage
Reserve 64KB memory at 0x02140000 for mtk_fsp_romstage.elf.

BUG=b:373797027
TEST=build pass

Signed-off-by: Jarried Lin <jarried.lin@mediatek.corp-partner.google.com>
Change-Id: I73710227e6d9e3f0c717e17db0cc798265eb1f72
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86014
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-01-18 13:11:09 +00:00
Jarried Lin
69c2d75d52 soc/mediatek/mt8196: Add mtk-fsp loader in ramstage
MediaTek firmware support package (mtk-fsp) contains romstage and
ramstage blobs. Add support for the ramstage blob, which includes:
- UFS mphy settings.
- DPAC (Device Access Permission Control) settings.
- MMinfra (Multimedia Infrastrucutre) settings.
- SMPU (Security Memory Protection Unit) settings.
- Advanced CPU frequency control.

BUG=b:373797027
TEST=build pass, boot ok.
Load and run mtk_fsp with following logs:
[INFO ] CBFS: Found 'fallback/mtk_fsp_ramstage' @0xfca00 size 0x263d in
        mcache @0xfffdd5a0
[DEBUG] read SPI 0x4fea88 0x263d: 773 us, 12663 KB/s, 101.304 Mbps
[INFO ] VB2:vb2_digest_init() 9789 bytes, hash algo 2, HW acceleration
        enabled
[INFO ] _start: MediaTek FSP_RAMSTAGE interface version: 1.0
[INFO ] mtk_fsp_load_and_run: run fallback/mtk_fsp_ramstage at phase
        0x50 done

Change-Id: Ia73d241694ca9a4686bf4b0533c51a663a765c21
Signed-off-by: Jarried Lin <jarried.lin@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86013
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-01-18 13:10:56 +00:00
Yu-Ping Wu
b229c120f7 soc/mediatek: Allow specifying multiple EINT base registers
Unlike MT8186/MT8188/MT8192/MT8195, MT8196 has 5 EINT base registers,
each with a different number of EINT bits. In preparation for the
upcoming MT8196 EINT unmasking support, replace the `eint_event_reg`
struct (which has a hardcoded register number) with an array
`eint_event` to specify the EINT base register(s).

BUG=none
TEST=emerge-geralt coreboot
BRANCH=none

Change-Id: I86fd3109c9ff72f33b9fea45587d012b003a34ba
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86033
Reviewed-by: Yidi Lin <yidilin@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-01-18 13:09:40 +00:00
Agogo Huang
c5f6daba81 soc/mediatek/mt8196: Initialize MCUPM
Load MCUPM firmware and boot up MCUPM in ramstage.

It takes 54 ms to load mcupm.bin.

coreboot logs:
CBFS: Found 'mcupm.bin' @0x37a80 size 0xdbda in mcache @0xfffdd308
mtk_init_mcu: Loaded (and reset) mcupm.bin in 54 msecs (486931 bytes)

TEST=Build pass and we can see the mcupm logs after reset releases.
BUG=b:317009620

Change-Id: I223f245d384f32d54f6170a28b29573638f77296
Signed-off-by: Agogo Huang <agogo.huang@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85888
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-01-18 04:32:13 +00:00
Yidi Lin
a81e09612b soc/mediatek/mt8196: Initialize PMIF for SD Card
mt6373_init_pmif_arb() needs to be initialized for SD card to control
the regulator.

TEST=emrege-rauru coreboot
TEST=The assertion is gone on Rauru during normal boot.

Change-Id: I7e3265bb62a6c78d44e2c756be9a020a49a03056
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85969
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-01-15 10:58:31 +00:00
Yidi Lin
f51c279d7c soc/mediatek: Rename is_pmif_init_done to check_init_done
TEST=emerge-geralt coreboot && emerge-rauru coreboot

Change-Id: Ib4b9a7969f5af6e001c5b491ec09a43e1289a6ae
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85968
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-01-15 10:58:23 +00:00
Yidi Lin
cb4c52d620 soc/mediatek: Skip duplicate pmif_arb->is_pmif_init_done() call
Return to the caller immediately if pmif_arb has been initiailized. In
this way, we can skip unnecessary check and reduce the access to the
PMIF register.

TEST=emerge-geralt coreboot && emerge-rauru coreboot

Change-Id: Id1d11f8b238855edb393d77151159792e7716d22
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85967
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
2025-01-15 10:58:17 +00:00
Yu-Ping Wu
589b9841b7 soc/mediatek/mt8186/rtc: Remove unused variable "sw"
The function rtc_get_frequency_meter() already uses the wait_us() macro,
so the stopwatch variable "sw" is not needed.

Change-Id: I7e282b6ce881f4e8f9d5e1c92803fda363fe28d7
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85921
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-01-11 07:11:36 +00:00
ot_song fan
61f46fa7c0 soc/mediatek/mt8196: Add srclken_rc drivers
MT8196 uses new RC mode with clk_buf driver, and needs srclken_rc to
send PMRC_EN. PMRC_EN will collect the requirements of all users,
such as MD, GPS, PCIE, NFC.

TEST=Build pass.
BUG=b:317009620

Signed-off-by: ot_song fan <ot_song.fan@mediatek.corp-partner.google.com>
Change-Id: I40f8d2b12027955e6bd57b666e9f04c0116a0a93
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85842
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-01-11 07:10:59 +00:00
ot_song fan
cbb244a291 soc/mediatek/mt8196: Add clk_buf drivers
MT8196 uses MT6685 clk_buf, and will use new RC mode with srclken_rc.
The clk_buf will provide several 26M clocks, and these clocks can be
independently turned on. RC mode will determine which clocks to be
turned on based on users' requests, which is collected into PMRC_EN
register by srclken_rc.

TEST=Build pass.
BUG=b:317009620

Signed-off-by: ot_song fan <ot_song.fan@mediatek.corp-partner.google.com>
Change-Id: Ie18bfbb2f3354ba3645799857061dc20de7f6d84
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85841
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
2025-01-11 07:10:50 +00:00
Yidi Lin
36b0822a9d soc/mediatek/common/dp: Use assert to check read/write API params
With CB:85918 and CB:85930, we can clean up the TODO in mtk_dp_mask.
Follow DP Phy APIs to use `assert` for the param examination.

TEST=verified on Ciri and Navi

Change-Id: I94e6ad36d190d773876cbb43eb4ebe17164f3c92
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85931
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-01-11 07:10:24 +00:00
Yidi Lin
7a8a40c887 soc/mediatek/common/dp: Correct the settings in dptx_hal_set_msa
Correct the settings according to Linux kernel driver. The related
settings can be found in [1]:

[1]: https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/mediatek/mtk_dp.c#L473

TEST=emerge-rauru coreboot; check FW screen on Ciri and Navi

Change-Id: I4ba7da74ce6394240513c482b19ec879b1a0a619
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85930
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-01-11 07:10:14 +00:00