diff --git a/boards/arm/sama5/sama5d2-xult/Kconfig b/boards/arm/sama5/sama5d2-xult/Kconfig index 83f06e1e286c9..77fb047c6f6fd 100644 --- a/boards/arm/sama5/sama5d2-xult/Kconfig +++ b/boards/arm/sama5/sama5d2-xult/Kconfig @@ -127,4 +127,18 @@ config SAMA5_SDMMC1_WIDTH_D1_D4 default y depends on SAMA5_SDMMC1 +config SAMA5_QSPI0_SIZE + int "QSPI0 memory size in bytes" + default 1073741824 + depends on SAMA5_QSPI0 + ---help--- + Size of QSPI0 memory mapped area in bytes. Default: 1GB + +config SAMA5_QSPI1_SIZE + int "QSPI1 memory size in bytes" + default 1073741824 + depends on SAMA5_QSPI1 + ---help--- + Size of QSPI1 memory mapped area in bytes. Default: 1GB + endif # ARCH_BOARD_SAMA5D2_XULT diff --git a/boards/arm/sama5/sama5d2-xult/src/sam_bringup.c b/boards/arm/sama5/sama5d2-xult/src/sam_bringup.c index 3bb43e5686137..bab347a7af99b 100644 --- a/boards/arm/sama5/sama5d2-xult/src/sam_bringup.c +++ b/boards/arm/sama5/sama5d2-xult/src/sam_bringup.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "sama5d2-xult.h" @@ -61,6 +62,15 @@ # include "sam_sdmmc.h" #endif +#ifdef HAVE_MX25RXX +# include "sam_qspi.h" +# include +#endif + +#ifdef HAVE_MX25RXX_NXFFS +# include +#endif + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -242,6 +252,10 @@ static int nsh_sdmmc_initialize(void) int sam_bringup(void) { +#ifdef HAVE_MX25RXX + struct qspi_dev_s *qspi; + struct mtd_dev_s *mtd; +#endif int ret; /* Register I2C drivers on behalf of the I2C tool */ @@ -458,6 +472,42 @@ int sam_bringup(void) } #endif +#ifdef HAVE_MX25RXX + qspi = sam_qspi_initialize(0); + if (!qspi) + { + syslog(LOG_ERR, "ERROR: sam_qspi_initialize failed\n"); + } + else + { + mtd = mx25rxx_initialize(qspi, true); + if (!mtd) + { + syslog(LOG_ERR, "ERROR: mx25rxx_initialize failed\n"); + } + +#if HAVE_MX25RXX_NXFFS + /* Initialize to provide NXFFS on the mx25rxx MTD interface */ + + ret = nxffs_initialize(mtd); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: NXFFS initialization failed: %d\n", ret); + } + + /* Mount the file system at /mnt/mx25 */ + + ret = nx_mount(NULL, "/mnt/mx25", "nxffs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount the NXFFS volume: %d\n", + ret); + return ret; + } +#endif + } +#endif /* HAVE_MX25RXX */ + /* If we got here then perhaps not all initialization was successful, but * at least enough succeeded to bring-up NSH with perhaps reduced * capabilities. diff --git a/boards/arm/sama5/sama5d2-xult/src/sama5d2-xult.h b/boards/arm/sama5/sama5d2-xult/src/sama5d2-xult.h index 0a281731c21dd..6944fe91ee1cc 100644 --- a/boards/arm/sama5/sama5d2-xult/src/sama5d2-xult.h +++ b/boards/arm/sama5/sama5d2-xult/src/sama5d2-xult.h @@ -42,13 +42,15 @@ /* Configuration ************************************************************/ -#define HAVE_SDMMC 1 -#define HAVE_AT25 1 -#define HAVE_NAND 1 -#define HAVE_USBHOST 1 -#define HAVE_USBDEV 1 -#define HAVE_USBMONITOR 1 -#define HAVE_NETWORK 1 +#define HAVE_SDMMC 1 +#define HAVE_AT25 1 +#define HAVE_NAND 1 +#define HAVE_USBHOST 1 +#define HAVE_USBDEV 1 +#define HAVE_USBMONITOR 1 +#define HAVE_NETWORK 1 +#define HAVE_MX25RXX 1 +#define HAVE_MX25RXX_NXFFS 1 /* SDMMC */ @@ -169,6 +171,17 @@ # define AT25_MINOR _AT25_MINOR #endif +/* MX25RXX QuadSPI flash */ + +#if !defined(CONFIG_MTD_MX25RXX) || !defined(CONFIG_SAMA5_QSPI0) +# undef HAVE_MX25RXX +# undef HAVE_MX25RXX_NXFFS +#endif + +#ifndef CONFIG_FS_NXFFS +# undef HAVE_MX25RXX_NXFFS +#endif + /* MMC/SD minor numbers: The NSH device minor extended is extended to * support two devices. If CONFIG_NSH_MMCSDMINOR is zero, these will be: * /dev/mmcsd0 and /dev/mmcsd1.