1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Copyright (C) 2016 Socionext Inc. 3*4882a593Smuzhiyun * Author: Masahiro Yamada <yamada.masahiro@socionext.com> 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * SPDX-License-Identifier: GPL-2.0+ 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun #include <common.h> 9*4882a593Smuzhiyun #include <mmc.h> 10*4882a593Smuzhiyun #include <spl.h> 11*4882a593Smuzhiyun spl_boot_mode(const u32 boot_device)12*4882a593Smuzhiyunu32 spl_boot_mode(const u32 boot_device) 13*4882a593Smuzhiyun { 14*4882a593Smuzhiyun struct mmc *mmc; 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun /* 17*4882a593Smuzhiyun * work around a bug in the Boot ROM of LD4, Pro4, and sLD8: 18*4882a593Smuzhiyun * 19*4882a593Smuzhiyun * The boot ROM in these SoCs breaks the PARTITION_CONFIG [179] of 20*4882a593Smuzhiyun * Extended CSD register; when switching to the Boot Partition 1, the 21*4882a593Smuzhiyun * Boot ROM should issue the SWITCH command (CMD6) with Set Bits for 22*4882a593Smuzhiyun * the Access Bits, but in fact it uses Write Byte for the Access Bits. 23*4882a593Smuzhiyun * As a result, the BOOT_PARTITION_ENABLE field of the PARTITION_CONFIG 24*4882a593Smuzhiyun * is lost. This bug was fixed for PH1-Pro5 and later SoCs. 25*4882a593Smuzhiyun * 26*4882a593Smuzhiyun * Fixup mmc->part_config here because it is used to determine the 27*4882a593Smuzhiyun * partition which the U-Boot image is read from. 28*4882a593Smuzhiyun */ 29*4882a593Smuzhiyun mmc = find_mmc_device(0); 30*4882a593Smuzhiyun mmc->part_config &= ~EXT_CSD_BOOT_PART_NUM(PART_ACCESS_MASK); 31*4882a593Smuzhiyun mmc->part_config |= EXT_CSD_BOOT_PARTITION_ENABLE; 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun return MMCSD_MODE_EMMCBOOT; 34*4882a593Smuzhiyun } 35