1 /* 2 * boot_mode.c 3 * 4 * Boot media related. 5 * 6 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 7 * 8 * This program is free software; you can redistribute it and/or modify it 9 * under the terms of the GNU General Public License as published by the 10 * Free Software Foundation; either version 2 of the License, or (at your 11 * option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 20 * 21 */ 22 #include <common.h> 23 #include <asm/io.h> 24 #include <asm/arch/platform.h> 25 get_boot_media(void)26int get_boot_media(void) 27 { 28 unsigned int reg_val, boot_mode, spi_device_mode; 29 int boot_media; 30 31 reg_val = readl(SYS_CTRL_REG_BASE + REG_SYSSTAT); 32 boot_mode = get_sys_boot_mode(reg_val); 33 34 switch (boot_mode) { 35 case BOOT_FROM_SPI: 36 spi_device_mode = get_spi_device_type(reg_val); 37 if (spi_device_mode) 38 boot_media = BOOT_MEDIA_NAND; 39 else 40 boot_media = BOOT_MEDIA_SPIFLASH; 41 break; 42 case BOOT_FROM_EMMC: 43 boot_media = BOOT_MEDIA_EMMC; 44 break; 45 default: 46 boot_media = BOOT_MEDIA_UNKNOWN; 47 break; 48 } 49 50 return boot_media; 51 } 52 53