diff options
author | Shelley Chen <shchen@google.com> | 2023-01-11 15:52:20 -0800 |
---|---|---|
committer | Eric Lai <eric_lai@quanta.corp-partner.google.com> | 2023-01-16 00:33:11 +0000 |
commit | 419cf93502320584c834e8980f2477b1514cbeaa (patch) | |
tree | bca7572609363e62b06fede30aaeeb2db512d1f1 /src/soc/mediatek | |
parent | 8ef2f7c77cfc04805861cd36a28d710afb53dfd7 (diff) |
commonlib/storage: Add common eMMC functions
Now that multiple platforms are trying to initialize eMMC in coreboot
instead of depthcharge, lets move common functionality into commonlib
instead of copying the same functionality between multiple platforms.
Note for consistency, changed name of set_early_mmc_wake_status() to
mmc_set_early_wake_status(). Also adding an mmc_send_cmd1() function
for retrieving the Operating Conditions Register (OCR) contents.
BUG=b:218406702
BRANCH=None
TEST=emerge-herobrine coreboot chromeos-bootimage
flash onto villager device and make sure still boots ChromeOS
Change-Id: Id00535b05bbd379081712601ef10e762c1831747
Signed-off-by: Shelley Chen <shchen@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/71827
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
Diffstat (limited to 'src/soc/mediatek')
-rw-r--r-- | src/soc/mediatek/common/msdc.c | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/src/soc/mediatek/common/msdc.c b/src/soc/mediatek/common/msdc.c index c6f77abc5c..0d1dbb5049 100644 --- a/src/soc/mediatek/common/msdc.c +++ b/src/soc/mediatek/common/msdc.c @@ -3,7 +3,6 @@ * MTK MSDC Host Controller interface specific code */ #include <assert.h> -#include <cbmem.h> #include <commonlib/bsd/helpers.h> #include <commonlib/storage/sd_mmc.h> #include <console/console.h> @@ -437,27 +436,9 @@ static void msdc_controller_init(struct msdc_ctrlr *host, void *base, void *top_ add_msdc(host); } -static void set_early_mmc_wake_status(int32_t status) -{ - int32_t *ms_cbmem; - - ms_cbmem = cbmem_add(CBMEM_ID_MMC_STATUS, sizeof(status)); - - if (!ms_cbmem) { - printk(BIOS_ERR, - "%s: Failed to add early mmc wake status to cbmem!\n", - __func__); - return; - } - - printk(BIOS_DEBUG, "Early init status = %d\n", status); - *ms_cbmem = status; -} - int mtk_emmc_early_init(void *base, void *top_base) { struct storage_media media = { 0 }; - int err; struct msdc_ctrlr msdc_host; struct sd_mmc_ctrlr *mmc_ctrlr = &msdc_host.sd_mmc_ctrlr; @@ -468,26 +449,6 @@ int mtk_emmc_early_init(void *base, void *top_base) SET_CLOCK(mmc_ctrlr, 400 * 1000); SET_BUS_WIDTH(mmc_ctrlr, 1); - /* Reset emmc, send CMD0 */ - if (sd_mmc_go_idle(&media)) - goto out_err; - /* Send CMD1 */ - err = mmc_send_op_cond(&media); - if (err == 0) { - if (media.op_cond_response & OCR_HCS) - set_early_mmc_wake_status(MMC_STATUS_CMD1_READY_HCS); - else - set_early_mmc_wake_status(MMC_STATUS_CMD1_READY); - } else if (err == CARD_IN_PROGRESS) { - set_early_mmc_wake_status(MMC_STATUS_CMD1_IN_PROGRESS); - } else { - goto out_err; - } - - return 0; - -out_err: - set_early_mmc_wake_status(MMC_STATUS_NEED_RESET); - return -1; + return mmc_send_cmd1(&media); } |