From 96da997b234cd12d5c5391a8a1cd01710bf89386 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 1 Mar 2023 14:29:03 +0900 Subject: [PATCH] boards: spresense: Add board function for eMMC finalization - Un-mount the FAT filesystem for eMMC - Un-initialize eMMC driver - Turn off the eMMC device --- boards/arm/cxd56xx/common/src/cxd56_emmcdev.c | 43 +++++++++++++++++++ .../cxd56xx/spresense/include/cxd56_emmcdev.h | 1 + 2 files changed, 44 insertions(+) diff --git a/boards/arm/cxd56xx/common/src/cxd56_emmcdev.c b/boards/arm/cxd56xx/common/src/cxd56_emmcdev.c index 03925c5b2a..28acb2fe97 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_emmcdev.c +++ b/boards/arm/cxd56xx/common/src/cxd56_emmcdev.c @@ -24,6 +24,8 @@ #include +#include + #include #include #include @@ -84,3 +86,44 @@ int board_emmc_initialize(void) return ret; } + +/**************************************************************************** + * Name: board_emmc_finalize + * + * Description: + * Finalize the eMMC device and umount the file system. + * + ****************************************************************************/ + +int board_emmc_finalize(void) +{ + int ret; + + /* Un-mount the eMMC device */ + + ret = nx_umount2("/mnt/emmc", MNT_DETACH); + if (ret < 0) + { + ferr("ERROR: Failed to umount the eMMC. %d\n", ret); + return ret; + } + + /* Uninitialize the eMMC device */ + + ret = cxd56_emmcuninitialize(); + if (ret < 0) + { + ferr("ERROR: Failed to uninitialize eMMC. %d\n", ret); + return ret; + } + + /* Power off the eMMC device */ + + ret = board_power_control(POWER_EMMC, false); + if (ret) + { + ferr("ERROR: Failed to power off eMMC. %d\n", ret); + } + + return ret; +} diff --git a/boards/arm/cxd56xx/spresense/include/cxd56_emmcdev.h b/boards/arm/cxd56xx/spresense/include/cxd56_emmcdev.h index f0f24f1a2b..a5d3ebf311 100644 --- a/boards/arm/cxd56xx/spresense/include/cxd56_emmcdev.h +++ b/boards/arm/cxd56xx/spresense/include/cxd56_emmcdev.h @@ -60,6 +60,7 @@ extern "C" #ifdef CONFIG_CXD56_EMMC int board_emmc_initialize(void); +int board_emmc_finalize(void); #endif #undef EXTERN