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 <andy-ld.lu@mediatek.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/85564
Reviewed-by: Yidi Lin <yidilin@google.com>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Jarried Lin 2024-12-12 14:13:43 +08:00 committed by Yidi Lin
commit e969a3df87
2 changed files with 37 additions and 0 deletions

View file

@ -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

View file

@ -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 <gpio.h>
#include <soc/msdc.h>
#include <soc/regulator.h>
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);
}