boards: spresense: Add board function for eMMC finalization

- Un-mount the FAT filesystem for eMMC
- Un-initialize eMMC driver
- Turn off the eMMC device
This commit is contained in:
SPRESENSE 2023-03-01 14:29:03 +09:00 committed by Alin Jerpelea
parent 5b3496fb7b
commit 96da997b23
2 changed files with 44 additions and 0 deletions

View File

@ -24,6 +24,8 @@
#include <nuttx/config.h>
#include <sys/mount.h>
#include <stdio.h>
#include <errno.h>
#include <debug.h>
@ -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;
}

View File

@ -60,6 +60,7 @@ extern "C"
#ifdef CONFIG_CXD56_EMMC
int board_emmc_initialize(void);
int board_emmc_finalize(void);
#endif
#undef EXTERN