Commit f3d2750a authored by Vyacheslav Yurkov's avatar Vyacheslav Yurkov
Browse files

feat(drivers/st): manage boot part in io_mmc



Use dedicated read function for boot partition
Signed-off-by: default avatarVyacheslav Yurkov <uvv.mail@gmail.com>
Change-Id: If75df7691fce0797205365736fc6e4e3429efdca
parent 5014b52d
/* /*
* Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2018-2021, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -29,6 +29,7 @@ static int mmc_dev_close(io_dev_info_t *dev_info); ...@@ -29,6 +29,7 @@ static int mmc_dev_close(io_dev_info_t *dev_info);
static io_type_t device_type_mmc(void); static io_type_t device_type_mmc(void);
static signed long long seek_offset; static signed long long seek_offset;
static size_t (*_read_blocks)(int lba, uintptr_t buf, size_t size);
static const io_dev_connector_t mmc_dev_connector = { static const io_dev_connector_t mmc_dev_connector = {
.dev_open = mmc_dev_open .dev_open = mmc_dev_open
...@@ -60,9 +61,15 @@ static io_type_t device_type_mmc(void) ...@@ -60,9 +61,15 @@ static io_type_t device_type_mmc(void)
/* Open a connection to the mmc device */ /* Open a connection to the mmc device */
static int mmc_dev_open(const uintptr_t init_params, io_dev_info_t **dev_info) static int mmc_dev_open(const uintptr_t init_params, io_dev_info_t **dev_info)
{ {
struct io_mmc_dev_spec *device_spec =
(struct io_mmc_dev_spec *)init_params;
assert(dev_info != NULL); assert(dev_info != NULL);
*dev_info = (io_dev_info_t *)&mmc_dev_info; *dev_info = (io_dev_info_t *)&mmc_dev_info;
_read_blocks = !device_spec->use_boot_part ?
mmc_read_blocks : mmc_boot_part_read_blocks;
return 0; return 0;
} }
...@@ -100,8 +107,8 @@ static int mmc_block_read(io_entity_t *entity, uintptr_t buffer, ...@@ -100,8 +107,8 @@ static int mmc_block_read(io_entity_t *entity, uintptr_t buffer,
uint8_t retries; uint8_t retries;
for (retries = 0U; retries < 3U; retries++) { for (retries = 0U; retries < 3U; retries++) {
*length_read = mmc_read_blocks(seek_offset / MMC_BLOCK_SIZE, *length_read = _read_blocks(seek_offset / MMC_BLOCK_SIZE,
buffer, length); buffer, length);
if (*length_read == length) { if (*length_read == length) {
return 0; return 0;
......
/* /*
* Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2021, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
#include <drivers/io/io_driver.h> #include <drivers/io/io_driver.h>
struct io_mmc_dev_spec {
bool use_boot_part;
};
int register_io_dev_mmc(const io_dev_connector_t **dev_con); int register_io_dev_mmc(const io_dev_connector_t **dev_con);
#endif /* IO_MMC_H */ #endif /* IO_MMC_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment