Skip to content

Commit

Permalink
mediatek: mt7622: add DDR initialization support
Browse files Browse the repository at this point in the history
Add DDR initialization support for mt7622

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
  • Loading branch information
hackpascal committed Aug 31, 2022
1 parent d5432bd commit 1b01a0f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plat/mediatek/mt7622/bl2_plat_setup.c
Expand Up @@ -9,6 +9,7 @@
#include <drivers/io/io_block.h>
#include <drivers/io/io_fip.h>
#include <hsuart.h>
#include <emi.h>
#include <lib/mmio.h>
#include <pinctrl.h>
#include <plat/common/common_def.h>
Expand Down Expand Up @@ -282,6 +283,7 @@ void bl2_platform_setup(void)
#endif
mtk_pwrap_init();
mtk_pmic_init();
mtk_mem_init();

This comment has been minimized.

Copy link
@dangowrt

dangowrt Sep 6, 2022

@hackpascal When operating the CPU at 300 MHz @ 0.9 V at the time of reboot the system still hangs here:

root@OpenWrt:/# cd /sys/devices/system/cpu/cpufreq/policy0/
root@OpenWrt:/sys/devices/system/cpu/cpufreq/policy0# echo userspace > scaling_governor 
root@OpenWrt:/sys/devices/system/cpu/cpufreq/policy0# echo 300000 > scaling_setspeed 
root@OpenWrt:/sys/devices/system/cpu/cpufreq/policy0# cat scaling_cur_freq 
300000
root@OpenWrt:/sys/devices/system/cpu/cpufreq/policy0# reboot
[   69.182444] br-lan: port 4(lan4) entered disabled state
[   69.193696] device lan1 left promiscuous mode
[   69.198325] br-lan: port 1(lan1) entered disabled state
[   69.258958] device lan2 left promiscuous mode
[   69.263552] br-lan: port 2(lan2) entered disabled state
[   69.328540] device lan3 left promiscuous mode
[   69.333126] br-lan: port 3(lan3) entered disabled state
[   69.398408] device lan4 left promiscuous mode
[   69.403008] br-lan: port 4(lan4) entered disabled state
[   69.466739] mt7530 mdio-bus:00 lan4: Link is Down
[   69.649621] device eth0 left promiscuous mode
[   69.663175] mtk_soc_eth 1b100000.ethernet eth0: Link is Down
[   73.844748] reboot: Restarting system

F0: 102B 0000
F6: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000
BP: 0400 0041 [0000]
G0: 1190 0000
T0: 0000 02CA [000F]
Jump to BL

NOTICE:  BL2: v2.7(release):OpenWrt v2022-08-31-75393484-1 (mt7622-snand-1ddr)
NOTICE:  BL2: Built : 16:39:01, Sep  5 2022
*** and there it hangs for ever ***

This issue has been present also in earlier versions of TF-A published here and it would be great to find a fix for it (such as setting CPU voltage to 1.0 V early in bl2 before calling mtk_mem_init().

This comment has been minimized.

Copy link
@hackpascal

hackpascal Sep 9, 2022

Author Collaborator

I remembered that we have discussed this one or two years ago, and the conclusion is that the cpu opp defined in dts files are not tested at all. Only the normal cpu freq 1.35GHz is tested and guaranteed stable. Since now mt7622 is in maintaining state, we have no resource for this chip's development. It's not likely that this would get a fix.

mtk_wdt_init();

mtk_io_setup();
Expand Down
13 changes: 13 additions & 0 deletions plat/mediatek/mt7622/drivers/dram/emi.h
@@ -0,0 +1,13 @@

/*
* Copyright (C) 2021 MediaTek Inc. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _MT_EMI_H_
#define _MT_EMI_H_

void mtk_mem_init(void);

#endif /* _MT_EMI_H_ */

Binary file not shown.
Binary file not shown.
20 changes: 20 additions & 0 deletions plat/mediatek/mt7622/platform.mk
Expand Up @@ -13,6 +13,7 @@ PLAT_INCLUDES := -I${MTK_PLAT}/common/ \
-I${MTK_PLAT}/common/drivers/uart \
-Iinclude/plat/arm/common \
-Iinclude/plat/arm/common/aarch64 \
-I${MTK_PLAT_SOC}/drivers/dram/ \
-I${MTK_PLAT_SOC}/drivers/pinctrl/ \
-I${MTK_PLAT_SOC}/drivers/pmic/ \
-I${MTK_PLAT_SOC}/drivers/pll/ \
Expand Down Expand Up @@ -51,6 +52,21 @@ BL2_SOURCES := common/desc_image_load.c \
${MTK_PLAT_SOC}/drivers/spm/mtcmos.c \
${MTK_PLAT_SOC}/drivers/timer/cpuxgpt.c

HAVE_DRAM_OBJ_FILE := $(shell test -f ${MTK_PLAT_SOC}/drivers/dram/release/dram.o && echo yes)
ifeq ($(HAVE_DRAM_OBJ_FILE),yes)
ifeq ($(DDR3_FLYBY), 1)
PREBUILT_LIBS += ${MTK_PLAT_SOC}/drivers/dram/release/dram-flyby.o
else
PREBUILT_LIBS += ${MTK_PLAT_SOC}/drivers/dram/release/dram.o
endif
else
BL2_SOURCES += ${MTK_PLAT_SOC}/drivers/dram/dramc_calib.c \
${MTK_PLAT_SOC}/drivers/dram/dramc_dqs_gw.c \
${MTK_PLAT_SOC}/drivers/dram/emi.c \
${MTK_PLAT_SOC}/drivers/dram/memory.c \
${MTK_PLAT_SOC}/drivers/dram/reserve_mode.c
endif

ifndef BOOT_DEVICE
$(error You must specify the boot device by provide BOOT_DEVICE= to \
make parameter. Avaliable values: nor emmc sdmmc snand)
Expand Down Expand Up @@ -124,6 +140,10 @@ $(error BOOT_DEVICE has invalid value. Please re-check.)
endif
endif

ifeq ($(DDR3_FLYBY), 1)
CPPFLAGS += -DDDR3_FLYBY
endif

BL31_SOURCES += drivers/arm/cci/cci.c \
drivers/arm/gic/common/gic_common.c \
drivers/arm/gic/v2/gicv2_main.c \
Expand Down

0 comments on commit 1b01a0f

Please sign in to comment.