luckfox-pico-sdk/sysdrv/source/uboot/u-boot/common/spl/spl_ufs.c
luckfox-eng29 8f34c2760d project:build.sh: Added fastboot support; custom modifications to U-Boot and kernel implemented using patches.
project:cfg:BoardConfig_IPC: Added fastboot BoardConfig file and firmware post-scripts, distinguishing between
the BoardConfigs for Luckfox Pico Pro and Luckfox Pico Max. project:app: Added fastboot_client and rk_smart_door
for quick boot applications; updated rkipc app to adapt to the latest media library. media:samples: Added more
usage examples. media:rockit: Fixed bugs; removed support for retrieving data frames from VPSS. media:isp:
Updated rkaiq library and related tools to support connection to RKISP_Tuner. sysdrv:Makefile: Added support for
compiling drv_ko on Luckfox Pico Ultra W using Ubuntu; added support for custom root filesystem.
sysdrv:tools:board: Updated Buildroot optional mirror sources, updated some software versions, and stored device
tree files and configuration files that undergo multiple modifications for U-Boot and kernel separately.
sysdrv:source:mcu: Used RISC-V MCU SDK with RT-Thread system, mainly for initializing camera AE during quick
boot. sysdrv:source:uboot: Added support for fastboot; added high baud rate DDR bin for serial firmware upgrades.
sysdrv:source:kernel: Upgraded to version 5.10.160; increased NPU frequency for RV1106G3; added support for
fastboot.

Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
2024-10-14 09:47:04 +08:00

79 lines
1.8 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Rockchip UFS Host Controller driver
*
* Copyright (C) 2024 Rockchip Electronics Co.Ltd.
*/
#include <common.h>
#include <asm/u-boot.h>
#include <blk.h>
#include <boot_rkimg.h>
#include <errno.h>
#include <image.h>
#include <part.h>
#include <scsi.h>
#include <ufs.h>
#include <spl.h>
DECLARE_GLOBAL_DATA_PTR;
static ulong h_spl_load_read(struct spl_load_info *load, ulong sector,
ulong count, void *buf)
{
return blk_dread(load->dev, sector, count, buf);
}
static int spl_ufs_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
lbaint_t image_sector = CONFIG_SYS_UFS_RAW_MODE_U_BOOT_SECTOR;
int ret;
struct blk_desc *desc;
struct image_header *header;
struct spl_load_info load;
/* try to recognize storage devices immediately */
ufs_probe();
scsi_scan(true);
desc = blk_get_devnum_by_type(IF_TYPE_SCSI, 0);
if (!desc)
return -ENODEV;
load.dev = desc;
load.priv = NULL;
load.filename = NULL;
load.bl_len = desc->blksz;
load.read = h_spl_load_read;
#ifdef CONFIG_SPL_LIBDISK_SUPPORT
disk_partition_t info;
ret = part_get_info_by_name(desc, PART_UBOOT, &info);
if (ret > 0)
image_sector = info.start;
#endif
if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
sizeof(struct image_header));
ret = blk_dread(desc, image_sector, 1, header);
if (ret != 1)
return -ENODEV;
#ifdef CONFIG_SPL_FIT_IMAGE_MULTIPLE
if (image_get_magic(header) == FDT_MAGIC ||
CONFIG_SPL_FIT_IMAGE_MULTIPLE > 1) {
#else
if (image_get_magic(header) == FDT_MAGIC) {
#endif
ret = spl_load_simple_fit(spl_image, &load,
image_sector,
header);
}
}
return ret;
}
SPL_LOAD_IMAGE_METHOD("UFS", 0, BOOT_DEVICE_UFS, spl_ufs_load_image);