You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2021/09/18 15:18:15 UTC
[incubator-nuttx] 02/05: mpfs: emmcsd: add Kconfig/Makefile and
board files
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 812f504c1661beed5d52e7d6eafaecca1cc5b199
Author: Eero Nurkkala <ee...@offcode.fi>
AuthorDate: Mon Aug 30 12:25:21 2021 +0300
mpfs: emmcsd: add Kconfig/Makefile and board files
Add necessary Kconfig, Make.defs, Makefile and board
file changes.
Signed-off-by: Eero Nurkkala <ee...@offcode.fi>
---
arch/risc-v/src/mpfs/Kconfig | 9 +++
arch/risc-v/src/mpfs/Make.defs | 6 +-
boards/risc-v/mpfs/icicle/src/Makefile | 4 ++
boards/risc-v/mpfs/icicle/src/mpfs_bringup.c | 9 +++
.../icicle/src/{mpfs_bringup.c => mpfs_emmcsd.c} | 80 ++++++++++------------
boards/risc-v/mpfs/icicle/src/mpfsicicle.h | 1 +
6 files changed, 64 insertions(+), 45 deletions(-)
diff --git a/arch/risc-v/src/mpfs/Kconfig b/arch/risc-v/src/mpfs/Kconfig
index 287db4d..a74aaea 100755
--- a/arch/risc-v/src/mpfs/Kconfig
+++ b/arch/risc-v/src/mpfs/Kconfig
@@ -103,6 +103,15 @@ config MPFS_I2C1
select ARCH_HAVE_I2CRESET
default n
+config MPFS_EMMCSD
+ bool "EMMCSD"
+ select ARCH_HAVE_SDIO
+ select SDIO_BLOCKSETUP
+ select SDIO_DMA
+ default n
+ ---help---
+ Selects the MPFS eMMCSD driver.
+
comment "CorePWM Options"
config MPFS_HAVE_COREPWM
diff --git a/arch/risc-v/src/mpfs/Make.defs b/arch/risc-v/src/mpfs/Make.defs
index 69f5eff..22f017e 100755
--- a/arch/risc-v/src/mpfs/Make.defs
+++ b/arch/risc-v/src/mpfs/Make.defs
@@ -33,7 +33,7 @@ CMN_CSRCS += riscv_interruptcontext.c riscv_modifyreg32.c riscv_puts.c
CMN_CSRCS += riscv_releasepending.c riscv_reprioritizertr.c
CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c riscv_schedulesigaction.c
CMN_CSRCS += riscv_sigdeliver.c riscv_unblocktask.c riscv_usestack.c
-CMN_CSRCS += riscv_mdelay.c riscv_copyfullstate.c
+CMN_CSRCS += riscv_mdelay.c riscv_udelay.c riscv_copyfullstate.c
ifeq ($(CONFIG_STACK_COLORATION),y)
CMN_CSRCS += riscv_checkstack.c
@@ -74,6 +74,10 @@ ifeq ($(CONFIG_I2C),y)
CHIP_CSRCS += mpfs_i2c.c
endif
+ifeq ($(CONFIG_MPFS_EMMCSD),y)
+CHIP_CSRCS += mpfs_emmcsd.c
+endif
+
ifeq (${CONFIG_MPFS_HAVE_COREPWM},y)
CHIP_CSRCS += mpfs_corepwm.c
endif
diff --git a/boards/risc-v/mpfs/icicle/src/Makefile b/boards/risc-v/mpfs/icicle/src/Makefile
index e493ec8..1f49e0a 100755
--- a/boards/risc-v/mpfs/icicle/src/Makefile
+++ b/boards/risc-v/mpfs/icicle/src/Makefile
@@ -46,4 +46,8 @@ ifeq ($(CONFIG_MPFS_HAVE_COREPWM),y)
CSRCS += mpfs_pwm.c
endif
+ifeq ($(CONFIG_MPFS_EMMCSD),y)
+CSRCS += mpfs_emmcsd.c
+endif
+
include $(TOPDIR)/boards/Board.mk
diff --git a/boards/risc-v/mpfs/icicle/src/mpfs_bringup.c b/boards/risc-v/mpfs/icicle/src/mpfs_bringup.c
index f781afe..9018dd2 100755
--- a/boards/risc-v/mpfs/icicle/src/mpfs_bringup.c
+++ b/boards/risc-v/mpfs/icicle/src/mpfs_bringup.c
@@ -92,5 +92,14 @@ int mpfs_bringup(void)
}
#endif
+#ifdef CONFIG_MPFS_EMMCSD
+ ret = mpfs_board_emmcsd_init();
+
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "Failed to init eMMCSD driver: %d\n", ret);
+ }
+#endif
+
return ret;
}
diff --git a/boards/risc-v/mpfs/icicle/src/mpfs_bringup.c b/boards/risc-v/mpfs/icicle/src/mpfs_emmcsd.c
old mode 100755
new mode 100644
similarity index 55%
copy from boards/risc-v/mpfs/icicle/src/mpfs_bringup.c
copy to boards/risc-v/mpfs/icicle/src/mpfs_emmcsd.c
index f781afe..8b9d693
--- a/boards/risc-v/mpfs/icicle/src/mpfs_bringup.c
+++ b/boards/risc-v/mpfs/icicle/src/mpfs_emmcsd.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * boards/risc-v/mpfs/icicle/src/mpfs_bringup.c
+ * boards/risc-v/mpfs/icicle/src/mpfs_emmcsd.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -24,73 +24,65 @@
#include <nuttx/config.h>
-#include <sys/mount.h>
-#include <stdbool.h>
-#include <stdio.h>
#include <debug.h>
#include <errno.h>
+#include <nuttx/mmcsd.h>
-#include <nuttx/board.h>
-#include <nuttx/drivers/ramdisk.h>
-
+#include "mpfs_emmcsd.h"
#include "mpfsicicle.h"
-#include "mpfs_corepwm.h"
-#include "mpfs.h"
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static FAR struct sdio_dev_s *g_sdio_dev;
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
- * Name: mpfs_bringup
+ * Name: board_emmcsd_init
+ *
+ * Description:
+ * Configure the eMMCSD driver.
+ *
+ * Returned Value:
+ * Zero (OK) is returned on success; A negated errno value is returned
+ * to indicate the nature of any failure.
+ *
****************************************************************************/
-int mpfs_bringup(void)
+int mpfs_board_emmcsd_init(void)
{
- int ret = OK;
+ int ret;
-#if defined(CONFIG_I2C_DRIVER)
- /* Configure I2C peripheral interfaces */
+ /* Mount the SDIO-based MMC/SD block driver */
- ret = mpfs_board_i2c_init();
+ /* First, get an instance of the SDIO interface */
- if (ret < 0)
- {
- syslog(LOG_ERR, "Failed to initialize I2C driver: %d\n", ret);
- }
-#endif
+ finfo("Initializing SDIO slot %d\n", CONFIG_NSH_MMCSDSLOTNO);
-#ifdef CONFIG_FS_PROCFS
- /* Mount the procfs file system */
-
- ret = mount(NULL, "/proc", "procfs", 0, NULL);
- if (ret < 0)
+ g_sdio_dev = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO);
+ if (!g_sdio_dev)
{
- serr("ERROR: Failed to mount procfs at %s: %d\n", "/proc", ret);
+ ferr("ERROR: Failed to initialize SDIO slot %d\n",
+ CONFIG_NSH_MMCSDSLOTNO);
+ return -ENODEV;
}
-#endif
-#if defined(CONFIG_MPFS_SPI0) || defined(CONFIG_MPFS_SPI1)
- /* Configure SPI peripheral interfaces */
+ /* Now bind the SDIO interface to the MMC/SD driver */
- ret = mpfs_board_spi_init();
+ finfo("Bind SDIO to the MMC/SD driver, minor=%d\n", CONFIG_NSH_MMCSDMINOR);
- if (ret < 0)
+ ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, g_sdio_dev);
+ if (ret != OK)
{
- syslog(LOG_ERR, "Failed to initialize SPI driver: %d\n", ret);
+ ferr("ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
+ return ret;
}
-#endif
-
-#ifdef CONFIG_MPFS_HAVE_COREPWM
- /* Configure PWM peripheral interfaces */
- ret = mpfs_pwm_setup();
-
- if (ret < 0)
- {
- syslog(LOG_ERR, "Failed to initialize CorePWM driver: %d\n", ret);
- }
-#endif
+ sdio_mediachange(g_sdio_dev, true);
- return ret;
+ return OK;
}
diff --git a/boards/risc-v/mpfs/icicle/src/mpfsicicle.h b/boards/risc-v/mpfs/icicle/src/mpfsicicle.h
index 600e7f9..d5f851f 100755
--- a/boards/risc-v/mpfs/icicle/src/mpfsicicle.h
+++ b/boards/risc-v/mpfs/icicle/src/mpfsicicle.h
@@ -44,6 +44,7 @@
int mpfs_bringup(void);
int mpfs_board_spi_init(void);
int mpfs_board_i2c_init(void);
+int mpfs_board_emmcsd_init(void);
int mpfs_pwm_setup(void);
#endif /* __BOARDS_RISCV_ICICLE_MPFS_SRC_MPFSICICLE_H */