From e969a3df87a3c32513fa65676612664c89bad64b Mon Sep 17 00:00:00 2001 From: Jarried Lin Date: Thu, 12 Dec 2024 14:13:43 +0800 Subject: [PATCH] soc/mediatek/mt8196: Add SD card configurations Rauru reference design has SD card interfaces, so we have to configure it in ramstage. Implement msdc.c (memory and SD Card controller) to place the SD card drivers. This implementation is based on chapter 10.3 in MT8196 Functional Specification. TEST=Build pass BUG=b:317009620 Change-Id: Ibb6a075d0f1b5a647e93a58b3ea1029b7676c765 Signed-off-by: Andy-ld Lu Reviewed-on: https://review.coreboot.org/c/coreboot/+/85564 Reviewed-by: Yidi Lin Reviewed-by: Yu-Ping Wu Tested-by: build bot (Jenkins) --- src/soc/mediatek/mt8196/Makefile.mk | 1 + src/soc/mediatek/mt8196/msdc.c | 36 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/soc/mediatek/mt8196/msdc.c diff --git a/src/soc/mediatek/mt8196/Makefile.mk b/src/soc/mediatek/mt8196/Makefile.mk index 2af541f417..2e78e1ad07 100644 --- a/src/soc/mediatek/mt8196/Makefile.mk +++ b/src/soc/mediatek/mt8196/Makefile.mk @@ -47,6 +47,7 @@ ramstage-y += l2c_ops.c ramstage-y += ../common/mcu.c ramstage-y += ../common/mmu_operations.c ../common/mmu_cmops.c ramstage-$(CONFIG_PCI) += ../common/pcie.c pcie.c +ramstage-$(CONFIG_COMMONLIB_STORAGE_MMC) += msdc.c ramstage-y += ../common/mt6363.c mt6363.c ramstage-y += ../common/mt6363_sdmadc.c ramstage-y += ../common/mt6373.c mt6373.c diff --git a/src/soc/mediatek/mt8196/msdc.c b/src/soc/mediatek/mt8196/msdc.c new file mode 100644 index 0000000000..f7873741b0 --- /dev/null +++ b/src/soc/mediatek/mt8196/msdc.c @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ + +/* + * This file is created based on MT8196 Functional Specification + * Chapter number: 10.3 + */ + +#include +#include +#include + +static const struct pad_func sdcard_pins[] = { + PAD_FUNC_DOWN(MSDC1_CLK, MSDC1_CLK), + PAD_FUNC_UP(MSDC1_CMD, MSDC1_CMD), + PAD_FUNC_UP(MSDC1_DAT0, MSDC1_DAT0), + PAD_FUNC_UP(MSDC1_DAT1, MSDC1_DAT1), + PAD_FUNC_UP(MSDC1_DAT2, MSDC1_DAT2), + PAD_FUNC_UP(MSDC1_DAT3, MSDC1_DAT3), +}; + +void mtk_msdc_configure_sdcard(void) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(sdcard_pins); i++) { + gpio_set_mode(sdcard_pins[i].gpio, sdcard_pins[i].func); + gpio_set_pull(sdcard_pins[i].gpio, GPIO_PULL_ENABLE, sdcard_pins[i].select); + gpio_set_driving(sdcard_pins[i].gpio, GPIO_DRV_6_MA); + } + + /* enable SD card power */ + mainboard_enable_regulator(MTK_REGULATOR_VMCH, true); + mainboard_enable_regulator(MTK_REGULATOR_VMC, true); + mainboard_set_regulator_voltage(MTK_REGULATOR_VMCH, 3000000); + mainboard_set_regulator_voltage(MTK_REGULATOR_VMC, 3000000); +}