diff --git a/configs/sam4e-ek/Kconfig b/configs/sam4e-ek/Kconfig index 34a7e1897d..90052291a8 100644 --- a/configs/sam4e-ek/Kconfig +++ b/configs/sam4e-ek/Kconfig @@ -17,7 +17,7 @@ config SAM4EEK_120MHZ endchoice # CPU Frequency -config SAM4EEK_AT25_AUTOMOUNT +config SAM4EEK_AT25_BLOCKMOUNT bool "AT25 serial FLASH auto-mount" default n depends on SAM34_SPI0 && MTD_AT25 @@ -27,7 +27,7 @@ config SAM4EEK_AT25_AUTOMOUNT choice prompt "AT25 serial FLASH configuration" default SAM4EEK_AT25_FTL - depends on SAM4EEK_AT25_AUTOMOUNT + depends on SAM4EEK_AT25_BLOCKMOUNT config SAM4EEK_AT25_FTL bool "Create AT25 Serial FLASH block driver" diff --git a/configs/sam4e-ek/README.txt b/configs/sam4e-ek/README.txt index 14680c0df9..6704039de8 100644 --- a/configs/sam4e-ek/README.txt +++ b/configs/sam4e-ek/README.txt @@ -572,7 +572,7 @@ AT25 Serial FLASH CONFIG_NSH_ARCHINIT=y : NSH board-initialization Board Selection - CONFIG_SAM4EEK_AT25_AUTOMOUNT=y : Mounts AT25 for NSH + CONFIG_SAM4EEK_AT25_BLOCKMOUNT=y : Mounts AT25 for NSH CONFIG_SAM4EEK_AT25_FTL=y : Create block driver for FAT You can then format the AT25 FLASH for a FAT file system and mount the diff --git a/configs/sam4e-ek/nsh/defconfig b/configs/sam4e-ek/nsh/defconfig index 31c916433d..69c54dac59 100644 --- a/configs/sam4e-ek/nsh/defconfig +++ b/configs/sam4e-ek/nsh/defconfig @@ -331,7 +331,7 @@ CONFIG_NSH_MMCSDMINOR=0 # # CONFIG_SAM4EEK_96MHZ is not set CONFIG_SAM4EEK_120MHZ=y -CONFIG_SAM4EEK_AT25_AUTOMOUNT=y +CONFIG_SAM4EEK_AT25_BLOCKMOUNT=y CONFIG_SAM4EEK_AT25_FTL=y # diff --git a/configs/sam4e-ek/src/sam4e-ek.h b/configs/sam4e-ek/src/sam4e-ek.h index fb52b39216..c485632b03 100644 --- a/configs/sam4e-ek/src/sam4e-ek.h +++ b/configs/sam4e-ek/src/sam4e-ek.h @@ -92,7 +92,7 @@ * asked to mount the AT25 part */ -#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAM4EEK_AT25_AUTOMOUNT) +#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAM4EEK_AT25_BLOCKMOUNT) # undef HAVE_AT25 #endif diff --git a/configs/sam4e-ek/usbnsh/defconfig b/configs/sam4e-ek/usbnsh/defconfig index aac602b659..935dacfae6 100644 --- a/configs/sam4e-ek/usbnsh/defconfig +++ b/configs/sam4e-ek/usbnsh/defconfig @@ -336,7 +336,7 @@ CONFIG_NSH_MMCSDMINOR=0 # # CONFIG_SAM4EEK_96MHZ is not set CONFIG_SAM4EEK_120MHZ=y -CONFIG_SAM4EEK_AT25_AUTOMOUNT=y +CONFIG_SAM4EEK_AT25_BLOCKMOUNT=y CONFIG_SAM4EEK_AT25_FTL=y # diff --git a/configs/sama5d3-xplained/Kconfig b/configs/sama5d3-xplained/Kconfig index 242eb0c8a5..27139b53e8 100644 --- a/configs/sama5d3-xplained/Kconfig +++ b/configs/sama5d3-xplained/Kconfig @@ -37,7 +37,7 @@ config SAMA5D3XPLAINED_MT47H64M16HR endchoice # SAMA5D3-Xplained DRAM Type -config SAMA5D3XPLAINED_NAND_AUTOMOUNT +config SAMA5D3XPLAINED_NAND_BLOCKMOUNT bool "NAND FLASH auto-mount" default n depends on NSH_ARCHINIT && SAMA5_EBICS3_NAND @@ -47,7 +47,7 @@ config SAMA5D3XPLAINED_NAND_AUTOMOUNT choice prompt "NAND FLASH configuration" default SAMA5D3XPLAINED_NAND_NXFFS - depends on SAMA5D3XPLAINED_NAND_AUTOMOUNT + depends on SAMA5D3XPLAINED_NAND_BLOCKMOUNT config SAMA5D3XPLAINED_NAND_FTL bool "Create NAND FLASH block driver" diff --git a/configs/sama5d3-xplained/README.txt b/configs/sama5d3-xplained/README.txt index 47d1f79614..3209a3040f 100644 --- a/configs/sama5d3-xplained/README.txt +++ b/configs/sama5d3-xplained/README.txt @@ -1636,8 +1636,8 @@ NAND Support to enable SDRAM as described above. Board Selection - CONFIG_SAMA5D3XPLAINED_NAND_AUTOMOUNT=y : Enable FS support on NAND - CONFIG_SAMA5D3XPLAINED_NAND_NXFFS=y : Use the NXFFS file system + CONFIG_SAMA5D3XPLAINED_NAND_BLOCKMOUNT=y : Enable FS support on NAND + CONFIG_SAMA5D3XPLAINED_NAND_NXFFS=y : Use the NXFFS file system Other file systems are not recommended because only NXFFS can handle bad blocks and only NXFFS performs wear-levelling. @@ -1660,8 +1660,8 @@ NAND Support Defaults for all other NXFFS settings should be okay. Board Selection - CONFIG_SAMA5D3XPLAINED_NAND_AUTOMOUNT=y : Enable FS support on NAND - CONFIG_SAMA5D3XPLAINED_NAND_FTL=y : Use an flash translation layer + CONFIG_SAMA5D3XPLAINED_NAND_BLOCKMOUNT=y : Enable FS support on NAND + CONFIG_SAMA5D3XPLAINED_NAND_FTL=y : Use an flash translation layer NOTE: FTL will require some significant buffering because of the large size of the NAND flash blocks. You will also need @@ -1678,7 +1678,7 @@ NAND Support Using NAND with NXFFS --------------------- - With the options CONFIG_SAMA5D3XPLAINED_NAND_AUTOMOUNT=y and + With the options CONFIG_SAMA5D3XPLAINED_NAND_BLOCKMOUNT=y and CONFIG_SAMA5D3XPLAINED_NAND_NXFFS=y, the NAND FLASH will be mounted in the NSH start-up logic before the NSH prompt appears. There is no feedback as to whether or not the mount was successful. You can, however, see the diff --git a/configs/sama5d3-xplained/src/sama5d3-xplained.h b/configs/sama5d3-xplained/src/sama5d3-xplained.h index bc32ec8d84..94a63dfff8 100644 --- a/configs/sama5d3-xplained/src/sama5d3-xplained.h +++ b/configs/sama5d3-xplained/src/sama5d3-xplained.h @@ -95,7 +95,7 @@ * asked to mount the NAND part */ -#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3XPLAINED_NAND_AUTOMOUNT) +#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3XPLAINED_NAND_BLOCKMOUNT) # undef HAVE_NAND #endif diff --git a/configs/sama5d3x-ek/Kconfig b/configs/sama5d3x-ek/Kconfig index 2a16ef9fbe..321d84d499 100644 --- a/configs/sama5d3x-ek/Kconfig +++ b/configs/sama5d3x-ek/Kconfig @@ -68,7 +68,7 @@ config SAMA5D3xEK_NOR_START option: If SAMA5D3xEK_NOR_START is defined, then it will not wait but will, instead, immediately start the program in NOR FLASH. -config SAMA5_NAND_AUTOMOUNT +config SAMA5D3XEK_NAND_BLOCKMOUNT bool "NAND FLASH auto-mount" default n depends on NSH_ARCHINIT && SAMA5_EBICS3_NAND @@ -78,7 +78,7 @@ config SAMA5_NAND_AUTOMOUNT choice prompt "NAND FLASH configuration" default SAMA5D3xEK_NAND_NXFFS - depends on SAMA5_NAND_AUTOMOUNT + depends on SAMA5D3XEK_NAND_BLOCKMOUNT config SAMA5D3xEK_NAND_FTL bool "Create NAND FLASH block driver" @@ -107,7 +107,7 @@ config SAMA5D3xEK_NAND_NXFFS endchoice # NAND FLASH configuration -config SAMA5D3xEK_AT25_AUTOMOUNT +config SAMA5D3xEK_AT25_BLOCKMOUNT bool "AT25 serial FLASH auto-mount" default n depends on NSH_ARCHINIT && SAMA5_SPI0 && MTD_AT25 @@ -117,7 +117,7 @@ config SAMA5D3xEK_AT25_AUTOMOUNT choice prompt "AT25 serial FLASH configuration" default SAMA5D3xEK_AT25_FTL - depends on SAMA5D3xEK_AT25_AUTOMOUNT + depends on SAMA5D3xEK_AT25_BLOCKMOUNT config SAMA5D3xEK_AT25_FTL bool "Create AT25 Serial FLASH block driver" @@ -137,7 +137,7 @@ config SAMA5D3xEK_AT25_NXFFS endchoice # AT25 serial FLASH configuration -config SAMA5D3xEK_AT24_AUTOMOUNT +config SAMA5D3xEK_AT24_BLOCKMOUNT bool "AT24 Serial EEPROM auto-mount" default n depends on NSH_ARCHINIT && SAMA5_TWI0 && MTD_AT24XX @@ -158,7 +158,7 @@ config SAMA5D3xEK_AT24_AUTOMOUNT choice prompt "AT24 serial EPPROM configuration" default SAMA5D3xEK_AT24_FTL - depends on SAMA5D3xEK_AT24_AUTOMOUNT + depends on SAMA5D3xEK_AT24_BLOCKMOUNT config SAMA5D3xEK_AT24_FTL bool "Create AT24 block driver" diff --git a/configs/sama5d3x-ek/README.txt b/configs/sama5d3x-ek/README.txt index 21c3b94806..e24a3e057e 100644 --- a/configs/sama5d3x-ek/README.txt +++ b/configs/sama5d3x-ek/README.txt @@ -1115,7 +1115,7 @@ AT25 Serial FLASH CONFIG_NSH_ARCHINIT=y : NSH board-initialization Board Selection - CONFIG_SAMA5D3xEK_AT25_AUTOMOUNT=y : Mounts AT25 for NSH + CONFIG_SAMA5D3xEK_AT25_BLOCKMOUNT=y : Mounts AT25 for NSH CONFIG_SAMA5D3xEK_AT25_FTL=y : Create block driver for FAT NOTE that you must close JP1 on the Embest/Ronetix board in order to @@ -1832,8 +1832,8 @@ NAND Support to enable SDRAM as described above. Board Selection - CONFIG_SAMA5_NAND_AUTOMOUNT=y : Enable FS support on NAND - CONFIG_SAMA5D3xEK_NAND_NXFFS=y : Use the NXFFS file system + CONFIG_SAMA5D3XEK_NAND_BLOCKMOUNT=y : Enable FS support on NAND + CONFIG_SAMA5D3xEK_NAND_NXFFS=y : Use the NXFFS file system Other file systems are not recommended because only NXFFS can handle bad blocks and only NXFFS performs wear-levelling. @@ -1856,8 +1856,8 @@ NAND Support Defaults for all other NXFFS settings should be okay. Board Selection - CONFIG_SAMA5_NAND_AUTOMOUNT=y : Enable FS support on NAND - CONFIG_SAMA5D3xEK_NAND_FTL=y : Use an flash translation layer + CONFIG_SAMA5D3XEK_NAND_BLOCKMOUNT=y : Enable FS support on NAND + CONFIG_SAMA5D3xEK_NAND_FTL=y : Use an flash translation layer NOTE: FTL will require some significant buffering because of the large size of the NAND flash blocks. You will also need @@ -1874,7 +1874,7 @@ NAND Support Using NAND with NXFFS --------------------- - With the options CONFIG_SAMA5_NAND_AUTOMOUNT=y and + With the options CONFIG_SAMA5D3XEK_NAND_BLOCKMOUNT=y and CONFIG_SAMA5D3xEK_NAND_NXFFS=y, the NAND FLASH will be mounted in the NSH start-up logic before the NSH prompt appears. There is no feedback as to whether or not the mount was successful. You can, however, see the @@ -2097,7 +2097,7 @@ AT24 Serial EEPROM : Other defaults are probably OK Board Selection - CONFIG_SAMA5D3xEK_AT24_AUTOMOUNT=y : Mounts AT24 for NSH + CONFIG_SAMA5D3xEK_AT24_BLOCKMOUNT=y : Mounts AT24 for NSH CONFIG_SAMA5D3xEK_AT24_NXFFS=y : Mount the AT24 using NXFFS You can then format the AT24 EEPROM for a FAT file system and mount the diff --git a/configs/sama5d3x-ek/demo/defconfig b/configs/sama5d3x-ek/demo/defconfig index 7c8e365612..a0ca86aef9 100644 --- a/configs/sama5d3x-ek/demo/defconfig +++ b/configs/sama5d3x-ek/demo/defconfig @@ -360,7 +360,7 @@ CONFIG_SAMA5D3xEK_396MHZ=y CONFIG_SAMA5D3xEK_MT47H128M16RT=y # CONFIG_SAMA5D3xEK_MT47H64M16HR is not set # CONFIG_SAMA5D3xEK_NOREDLED is not set -CONFIG_SAMA5D3xEK_AT25_AUTOMOUNT=y +CONFIG_SAMA5D3xEK_AT25_BLOCKMOUNT=y CONFIG_SAMA5D3xEK_AT25_FTL=y # diff --git a/configs/sama5d3x-ek/src/sama5d3x-ek.h b/configs/sama5d3x-ek/src/sama5d3x-ek.h index 3bbc1cbc9e..feebec328d 100644 --- a/configs/sama5d3x-ek/src/sama5d3x-ek.h +++ b/configs/sama5d3x-ek/src/sama5d3x-ek.h @@ -97,7 +97,7 @@ * asked to mount the NAND part */ -#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5_NAND_AUTOMOUNT) +#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3XEK_NAND_BLOCKMOUNT) # undef HAVE_NAND #endif @@ -142,7 +142,7 @@ * asked to mount the AT25 part */ -#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3xEK_AT25_AUTOMOUNT) +#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3xEK_AT25_BLOCKMOUNT) # undef HAVE_AT25 #endif @@ -192,7 +192,7 @@ * asked to mount the AT25 part */ -#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3xEK_AT24_AUTOMOUNT) +#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D3xEK_AT24_BLOCKMOUNT) # undef HAVE_AT24 #endif diff --git a/configs/sama5d4-ek/Kconfig b/configs/sama5d4-ek/Kconfig index 500b8f8255..ad8ac79365 100644 --- a/configs/sama5d4-ek/Kconfig +++ b/configs/sama5d4-ek/Kconfig @@ -106,7 +106,7 @@ config SAMA5D4EK_DRAM_BOOT will simply origin your program at 0x2000:0000 as required by the sdram_main bootloader (vs. 0x2000:8000 as required by U-Boot). -config SAMA5D4EK_NAND_AUTOMOUNT +config SAMA5D4EK_NAND_BLOCKMOUNT bool "NAND FLASH auto-mount" default n depends on NSH_ARCHINIT && SAMA5_EBICS3_NAND @@ -116,7 +116,7 @@ config SAMA5D4EK_NAND_AUTOMOUNT choice prompt "NAND FLASH configuration" default SAMA5D4EK_NAND_NXFFS - depends on SAMA5D4EK_NAND_AUTOMOUNT + depends on SAMA5D4EK_NAND_BLOCKMOUNT config SAMA5D4EK_NAND_FTL bool "Create NAND FLASH block driver" @@ -145,7 +145,7 @@ config SAMA5D4EK_NAND_NXFFS endchoice # NAND FLASH configuration -config SAMA5D4EK_AT25_AUTOMOUNT +config SAMA5D4EK_AT25_BLOCKMOUNT bool "AT25 serial FLASH auto-mount" default n depends on (NSH_ARCHINIT || SAMA5D4EK_AT25_MAIN) && SAMA5_SPI0 && MTD_AT25 @@ -155,7 +155,7 @@ config SAMA5D4EK_AT25_AUTOMOUNT choice prompt "AT25 serial FLASH configuration" default SAMA5D4EK_AT25_FTL - depends on SAMA5D4EK_AT25_AUTOMOUNT + depends on SAMA5D4EK_AT25_BLOCKMOUNT config SAMA5D4EK_AT25_FTL bool "Create AT25 Serial FLASH block driver" @@ -183,6 +183,67 @@ config SAMA5D4EK_AT25_NXFFS endchoice # AT25 serial FLASH configuration +if FS_AUTOMOUNTER + +config SAMA5D4EK_HSMCI0_AUTOMOUNT + bool "HSMCI0 automounter" + default n + depends on SAMA5_HSMCI0 + +if SAMA5D4EK_HSMCI0_AUTOMOUNT + +config SAMA5D4EK_HSMCI0_AUTOMOUNT_FSTYPE + string "HSMCI0 file system type" + default "vfat" + +config SAMA5D4EK_HSMCI0_AUTOMOUNT_BLKDEV + string "HSMCI0 block device" + default "/dev/mmcds0" + +config SAMA5D4EK_HSMCI0_AUTOMOUNT_MOUNTPOINT + string "HSMCI0 mount point" + default "/mnt/sdcard0" + +config SAMA5D4EK_HSMCI0_AUTOMOUNT_DDELAY + int "HSMCI0 debounce delay (milliseconds)" + default 1000 + +config SAMA5D4EK_HSMCI0_AUTOMOUNT_UDELAY + int "HSMCI0 unmount retry delay (milliseconds)" + default 2000 + +endif # SAMA5D4EK_HSMCI0_AUTOMOUNT + +config SAMA5D4EK_HSMCI1_AUTOMOUNT + bool "HSMCI1 automounter" + default n + depends on SAMA5_HSMCI1 + +if SAMA5D4EK_HSMCI1_AUTOMOUNT + +config SAMA5D4EK_HSMCI1_AUTOMOUNT_FSTYPE + string "HSMCI1 file system type" + default "vfat" + +config SAMA5D4EK_HSMCI1_AUTOMOUNT_BLKDEV + string "HSMCI1 block device" + default "/dev/mmcds0" + +config SAMA5D4EK_HSMCI1_AUTOMOUNT_MOUNTPOINT + string "HSMCI1 mount point" + default "/mnt/sdcard0" + +config SAMA5D4EK_HSMCI1_AUTOMOUNT_DDELAY + int "HSMCI1 debounce delay (milliseconds)" + default 1000 + +config SAMA5D4EK_HSMCI1_AUTOMOUNT_UDELAY + int "HSMCI1 unmount retry delay (milliseconds)" + default 2000 + +endif # SAMA5D4EK_HSMCI1_AUTOMOUNT +endif # FS_AUTOMOUNTER + if INPUT_MXT config SAMA5D4EK_MXT_I2CFREQUENCY diff --git a/configs/sama5d4-ek/README.txt b/configs/sama5d4-ek/README.txt index 4b7a9b968f..3271a703e8 100644 --- a/configs/sama5d4-ek/README.txt +++ b/configs/sama5d4-ek/README.txt @@ -1434,8 +1434,8 @@ AT25 Serial FLASH CONFIG_NSH_ARCHINIT=y : NSH board-initialization Board Selection - CONFIG_SAMA5D4EK_AT25_AUTOMOUNT=y : Mounts AT25 for NSH - CONFIG_SAMA5D4EK_AT25_FTL=y : Create block driver for FAT + CONFIG_SAMA5D4EK_AT25_BLOCKMOUNT=y : Mounts AT25 for NSH + CONFIG_SAMA5D4EK_AT25_FTL=y : Create block driver for FAT NOTE: that you must close JP6 in order to enable the AT25 FLASH chip select. @@ -2119,8 +2119,8 @@ NAND Support to enable SDRAM as described above. Board Selection - CONFIG_SAMA5D4EK_NAND_AUTOMOUNT=y : Enable FS support on NAND - CONFIG_SAMA5D4EK_NAND_NXFFS=y : Use the NXFFS file system + CONFIG_SAMA5D4EK_NAND_BLOCKMOUNT=y : Enable FS support on NAND + CONFIG_SAMA5D4EK_NAND_NXFFS=y : Use the NXFFS file system Other file systems are not recommended because only NXFFS can handle bad blocks and only NXFFS performs wear-levelling. @@ -2143,8 +2143,8 @@ NAND Support Defaults for all other NXFFS settings should be okay. Board Selection - CONFIG_SAMA5D4EK_NAND_AUTOMOUNT=y : Enable FS support on NAND - CONFIG_SAMA5D4EK_NAND_FTL=y : Use an flash translation layer + CONFIG_SAMA5D4EK_NAND_BLOCKOMOUNT=y : Enable FS support on NAND + CONFIG_SAMA5D4EK_NAND_FTL=y : Use an flash translation layer NOTE: FTL will require some significant buffering because of the large size of the NAND flash blocks. You will also need @@ -2161,7 +2161,7 @@ NAND Support Using NAND with NXFFS --------------------- - With the options CONFIG_SAMA5D4EK_NAND_AUTOMOUNT=y and + With the options CONFIG_SAMA5D4EK_NAND_BLOCKMOUNT=y and CONFIG_SAMA5D4EK_NAND_NXFFS=y, the NAND FLASH will be mounted in the NSH start-up logic before the NSH prompt appears. There is no feedback as to whether or not the mount was successful. You can, however, see the diff --git a/configs/sama5d4-ek/at25boot/defconfig b/configs/sama5d4-ek/at25boot/defconfig index 27ed38383b..4f923e7f44 100644 --- a/configs/sama5d4-ek/at25boot/defconfig +++ b/configs/sama5d4-ek/at25boot/defconfig @@ -322,7 +322,7 @@ CONFIG_SAMA5D4EK_MT47H128M16RT=y # CONFIG_SAMA5D4EK_DRAM_MAIN is not set CONFIG_SAMA5D4EK_AT25_MAIN=y CONFIG_SAMA5D4EK_AT25_PROGSIZE=131072 -CONFIG_SAMA5D4EK_AT25_AUTOMOUNT=y +CONFIG_SAMA5D4EK_AT25_BLOCKMOUNT=y # CONFIG_SAMA5D4EK_AT25_FTL is not set CONFIG_SAMA5D4EK_AT25_CHARDEV=y diff --git a/configs/sama5d4-ek/src/Makefile b/configs/sama5d4-ek/src/Makefile index 46e2969611..4ede758715 100644 --- a/configs/sama5d4-ek/src/Makefile +++ b/configs/sama5d4-ek/src/Makefile @@ -76,6 +76,10 @@ CSRCS += sam_at25.c endif endif +ifeq ($(CONFIG_FS_AUTOMOUNTER),y) +CSRCS += sam_automount.c +endif + ifeq ($(CONFIG_AUDIO_WM8904),y) ifeq ($(CONFIG_SAMA5_TWI0),y) ifeq ($(CONFIG_SAMA5_SSC0),y) diff --git a/configs/sama5d4-ek/src/at25_main.c b/configs/sama5d4-ek/src/at25_main.c index 25e694e065..2a9259ab14 100644 --- a/configs/sama5d4-ek/src/at25_main.c +++ b/configs/sama5d4-ek/src/at25_main.c @@ -63,8 +63,8 @@ # error The AT25 Serial FLASH is not available #endif -#ifndef CONFIG_SAMA5D4EK_AT25_AUTOMOUNT -# error CONFIG_SAMA5D4EK_AT25_AUTOMOUNT must be selected +#ifndef CONFIG_SAMA5D4EK_AT25_BLOCKMOUNT +# error CONFIG_SAMA5D4EK_AT25_BLOCKMOUNT must be selected #endif #ifndef CONFIG_SAMA5D4EK_AT25_CHARDEV diff --git a/configs/sama5d4-ek/src/sam_automount.c b/configs/sama5d4-ek/src/sam_automount.c new file mode 100644 index 0000000000..8da4d6f86f --- /dev/null +++ b/configs/sama5d4-ek/src/sam_automount.c @@ -0,0 +1,390 @@ +/************************************************************************************ + * configs/sama5d4-ek/src/sam_automount.c + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#if defined(CONFIG_FS_AUTOMOUNTER_DEBUG) && !defined(CONFIG_DEBUG_FS) +# define CONFIG_DEBUG_FS 1 +#endif + +#include + +#include +#include +#include + +#include "sama5d4-ek.h" + +#ifdef HAVE_AUTOMOUNTER + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +#ifndef NULL +# define NULL (FAR void *)0 +#endif + +#ifndef OK +# define OK 0 +#endif + +/************************************************************************************ + * Private Types + ************************************************************************************/ +/* This structure represents the changeable state of the automounter */ + +struct sam_automount_state_s +{ + volatile automount_handler_t handler; /* Upper half handler */ + FAR void *arg; /* Handler argument */ + bool enable; /* Fake interrupt enable */ + bool pending; /* Set if there an event while disabled */ +}; + +/* This structure represents the static configuration of an automounter */ + +struct sam_automount_config_s +{ + /* This must be first thing in structure so that we can simply cast from struct + * automount_lower_s to struct sam_automount_config_s + */ + + struct automount_lower_s lower; /* Publicly visible part */ + uint8_t hsmci; /* HSMCI0_SLOTNO or HSMCI1_SLOTNO */ + FAR struct sam_automount_state_s *state; /* Changeable state */ +}; + +/************************************************************************************ + * Private Function Prototypes + ************************************************************************************/ + +static int sam_attach(FAR const struct automount_lower_s *lower, + automount_handler_t isr, FAR void *arg); +static void sam_enable(FAR const struct automount_lower_s *lower, bool enable); +static bool sam_inserted(FAR const struct automount_lower_s *lower); + +/************************************************************************************ + * Private Data + ************************************************************************************/ + +#ifdef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT +static struct sam_automount_state_s g_hsmci0state; +static const struct sam_automount_config_s g_hsmci0config = +{ + .lower = + { + .fstype = CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_FSTYPE, + .blockdev = CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_BLKDEV, + .mountpoint = CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_MOUNTPOINT, + .ddelay = MSEC2TICK(CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_DDELAY), + .udelay = MSEC2TICK(CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_UDELAY), + .attach = sam_attach, + .enable = sam_enable, + .inserted = sam_inserted + }, + .hsmci = HSMCI0_SLOTNO, + .state = &g_hsmci0state +}; +#endif + +#ifdef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT +static struct sam_automount_state_s g_hsmci1state; +static const struct sam_automount_config_s g_hsmci1config = +{ + .lower = + { + .fstype = CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_FSTYPE, + .blockdev = CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_BLKDEV, + .mountpoint = CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_MOUNTPOINT, + .ddelay = MSEC2TICK(CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_DDELAY), + .udelay = MSEC2TICK(CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_UDELAY), + .attach = sam_attach, + .enable = sam_enable, + .inserted = sam_inserted + }, + .hsmci = HSMCI1_SLOTNO, + .state = &g_hsmci1state +}; +#endif + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: sam_automount_initialize + * + * Description: + * Configure auto-mounters for each enable and so configured HSMCI + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ************************************************************************************/ + +static int sam_attach(FAR const struct automount_lower_s *lower, + automount_handler_t isr, FAR void *arg) +{ + FAR const struct sam_automount_config_s *config; + FAR struct sam_automount_state_s *state; + + /* Recover references to our structure */ + + config = (FAR struct sam_automount_config_s *)lower; + DEBUGASSERT(config && config->state); + + state = config->state; + + /* Save the new handler info (clearing the handler first to eliminate race + * conditions. + */ + + state->handler = NULL; + state->pending = false; + state->arg = arg; + state->handler = isr; + return OK; +} + +/************************************************************************************ + * Name: sam_automount_initialize + * + * Description: + * Configure auto-mounters for each enable and so configured HSMCI + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ************************************************************************************/ + +static void sam_enable(FAR const struct automount_lower_s *lower, bool enable) +{ + FAR const struct sam_automount_config_s *config; + FAR struct sam_automount_state_s *state; + irqstate_t flags; + + /* Recover references to our structure */ + + config = (FAR struct sam_automount_config_s *)lower; + DEBUGASSERT(config && config->state); + + state = config->state; + + /* Save the fake enable setting */ + + flags = irqsave(); + state->enable = enable; + + /* Did an interrupt occur while interrupts were disabled? */ + + if (enable && state->pending) + { + /* Yes.. perform the fake interrupt if the interrutp is attached */ + + if (state->handler) + { + bool inserted = sam_cardinserted(config->hsmci); + (void)state->handler(&config->lower, state->arg, inserted); + } + + state->pending = false; + } + + irqrestore(flags); +} + +/************************************************************************************ + * Name: sam_automount_initialize + * + * Description: + * Configure auto-mounters for each enable and so configured HSMCI + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ************************************************************************************/ + +static bool sam_inserted(FAR const struct automount_lower_s *lower) +{ + FAR const struct sam_automount_config_s *config; + + config = (FAR struct sam_automount_config_s *)lower; + DEBUGASSERT(config && config->state); + + return sam_cardinserted(config->hsmci); +} + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: sam_automount_initialize + * + * Description: + * Configure auto-mounters for each enable and so configured HSMCI + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ************************************************************************************/ + +void sam_automount_initialize(void) +{ + FAR void *handle; + + fvdbg("Initializing automounter(s)\n"); + +#ifdef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT + /* Initialize the HSMCI0 auto-mounter */ + + handle = automount_initialize(&g_hsmci0config.lower); + if (!handle) + { + fdbg("ERROR: Failed to initialize auto-mounter for HSMCI0\n"); + } +#endif + +#ifdef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT + /* Initialize the HSMCI1 auto-mounter */ + + handle = automount_initialize(&g_hsmci1config.lower); + if (!handle) + { + fdbg("ERROR: Failed to initialize auto-mounter for HSMCI1\n"); + } +#endif +} + +/************************************************************************************ + * Name: sam_automount_event + * + * Description: + * The HSMCI card detection logic has detected an insertion or removal event. It + * has already scheduled the MMC/SD block driver operations. Now we need to + * schedule the auto-mount event which will occur with a substantial delay to make + * sure that everything has settle down. + * + * Input Parameters: + * slotno - Identifies the HSMCI0 slot: HSMCI0_SLOTNO or HSMCI1_SLOTNO. There is a + * terminology problem here: Each HSMCI supports two slots, slot A and slot B. + * Only slot A is used. So this is not a really a slot, but an HSCMI peripheral + * number. + * inserted - True if the card is inserted in the slot. False otherwise. + * + * Returned Value: + * None + * + * Assumptions: + * Interrupts are disabled. + * + ************************************************************************************/ + +void sam_automount_event(int slotno, bool inserted) +{ + FAR const struct sam_automount_config_s *config; + FAR struct sam_automount_state_s *state; + +#ifdef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT + /* Is this a change in the HSMCI0 insertion state? */ + + if (slotno == HSMCI0_SLOTNO) + { + /* Yes.. Select the HSMCI0 automounter */ + + config = &g_hsmci0config; + state = &g_hsmci0state; + } + else +#endif + +#ifdef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT + /* Is this a change in the HSMCI1 insertion state? */ + + if (slotno == HSMCI1_SLOTNO) + { + /* Yes.. Select the HSMCI1 automounter */ + + config = &g_hsmci1config; + state = &g_hsmci1state; + } + else +#endif + { + fdbg("ERROR: Unsupported HSCMI%d\n", slotno); + return; + } + + /* Is the auto-mounter interrupt attached? */ + + if (state->handler) + { + /* Yes.. Have we been asked to hold off interrupts? */ + + if (!state->enable) + { + /* Yes.. just remember the there is a pending interrupt. We will + * deliver the interrupt when interrupts are "re-enabled." + */ + + state->pending = true; + } + else + { + /* No.. forward the event to the handler */ + + (void)state->handler(&config->lower, state->arg, inserted); + } + } +} + +#endif /* HAVE_AUTOMOUNTER */ diff --git a/configs/sama5d4-ek/src/sam_hsmci.c b/configs/sama5d4-ek/src/sam_hsmci.c index b36d976927..a6ab1439c2 100644 --- a/configs/sama5d4-ek/src/sam_hsmci.c +++ b/configs/sama5d4-ek/src/sam_hsmci.c @@ -204,14 +204,42 @@ static int sam_hsmci_cardetect(struct sam_hsmci_state_s *state) #ifdef CONFIG_SAMA5_HSMCI0 static int sam_hsmci0_cardetect(int irq, void *regs) { - return sam_hsmci_cardetect(&g_hsmci0); + int ret; + + /* Handle the card detect interrupt. The interrupt level logic will + * kick of the driver-level operations to initialize the MMC/SD block + * device. + */ + + ret = sam_hsmci_cardetect(&g_hsmci0); + +#ifdef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT + /* Let the automounter know about the insertion event */ + + sam_automount_event(HSMCI0_SLOTNO, sam_cardinserted(HSMCI0_SLOTNO)); +#endif + + return ret; } #endif #ifdef CONFIG_SAMA5_HSMCI1 static int sam_hsmci1_cardetect(int irq, void *regs) { - return sam_hsmci_cardetect(&g_hsmci1); + int ret; + + /* Handle the card detect interrupt. The interrupt level logic will + * kick of the driver-level operations to initialize the MMC/SD block + * device. + */ + + ret = sam_hsmci_cardetect(&g_hsmci1); + +#ifdef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT + /* Let the automounter know about the insertion event */ + + sam_automount_event(HSMCI1_SLOTNO, sam_cardinserted(HSMCI1_SLOTNO)); +#endif } #endif diff --git a/configs/sama5d4-ek/src/sam_nsh.c b/configs/sama5d4-ek/src/sam_nsh.c index 1c44d273cf..45fda54ca5 100644 --- a/configs/sama5d4-ek/src/sam_nsh.c +++ b/configs/sama5d4-ek/src/sam_nsh.c @@ -135,6 +135,12 @@ int nsh_archinitialize(void) #endif #endif +#ifdef HAVE_AUTOMOUNTER + /* Initialize the automounter */ + + sam_automount_initialize(); +#endif + #ifdef HAVE_USBHOST /* Initialize USB host operation. sam_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. diff --git a/configs/sama5d4-ek/src/sama5d4-ek.h b/configs/sama5d4-ek/src/sama5d4-ek.h index f974a393fe..91fd6fddc5 100644 --- a/configs/sama5d4-ek/src/sama5d4-ek.h +++ b/configs/sama5d4-ek/src/sama5d4-ek.h @@ -55,18 +55,19 @@ ************************************************************************************/ /* Configuration ************************************************************/ -#define HAVE_HSMCI 1 -#define HAVE_AT25 1 -#define HAVE_NAND 1 -#define HAVE_USBHOST 1 -#define HAVE_USBDEV 1 -#define HAVE_USBOVCUR 1 -#define HAVE_USBMONITOR 1 -#define HAVE_NETWORK 1 -#define HAVE_MAXTOUCH 1 -#define HAVE_WM8904 1 -#define HAVE_AUDIO_NULL 1 -#define HAVE_PMIC 1 +#define HAVE_HSMCI 1 +#define HAVE_AT25 1 +#define HAVE_NAND 1 +#define HAVE_AUTOMOUNTER 1 +#define HAVE_USBHOST 1 +#define HAVE_USBDEV 1 +#define HAVE_USBOVCUR 1 +#define HAVE_USBMONITOR 1 +#define HAVE_NETWORK 1 +#define HAVE_MAXTOUCH 1 +#define HAVE_WM8904 1 +#define HAVE_AUDIO_NULL 1 +#define HAVE_PMIC 1 /* HSMCI */ /* Can't support MMC/SD if the card interface(s) are not enable */ @@ -100,7 +101,7 @@ * asked to mount the NAND part */ -#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D4EK_NAND_AUTOMOUNT) +#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D4EK_NAND_BLOCKMOUNT) # undef HAVE_NAND #endif @@ -145,7 +146,7 @@ * asked to mount the AT25 part */ -#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D4EK_AT25_AUTOMOUNT) +#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_SAMA5D4EK_AT25_BLOCKMOUNT) # undef HAVE_AT25 #endif @@ -220,6 +221,75 @@ #else #endif +/* Automounter. Currently only works with HSMCI. */ + +#if !defined(CONFIG_FS_AUTOMOUNTER) || !defined(HAVE_HSMCI) +# undef HAVE_AUTOMOUNTER +#endif + +#ifndef CONFIG_SAMA5_HSMCI0 +# undef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT +#endif + +#ifndef CONFIG_SAMA5_HSMCI1 +# undef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT +#endif + +#if !defined(CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT) && \ + !defined(CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT) +# undef HAVE_AUTOMOUNTER +#endif + +#ifdef HAVE_AUTOMOUNTER +# ifdef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT + /* HSMCI0 Automounter defaults */ + +# ifndef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_FSTYPE +# define CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_FSTYPE "vfat" +# endif + +# ifndef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_BLKDEV +# define CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_BLKDEV "/dev/mmcds0" +# endif + +# ifndef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_MOUNTPOINT +# define CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard0" +# endif + +# ifndef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_DDELAY +# define CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_DDELAY 1000 +# endif + +# ifndef CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_UDELAY +# define CONFIG_SAMA5D4EK_HSMCI0_AUTOMOUNT_UDELAY 2000 +# endif +# endif + +# ifdef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT + /* HSMCI1 Automounter defaults */ + +# ifndef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_FSTYPE +# define CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_FSTYPE "vfat" +# endif + +# ifndef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_BLKDEV +# define CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_BLKDEV "/dev/mmcds0" +# endif + +# ifndef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_MOUNTPOINT +# define CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard0" +# endif + +# ifndef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_DDELAY +# define CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_DDELAY 1000 +# endif + +# ifndef CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_UDELAY +# define CONFIG_SAMA5D4EK_HSMCI1_AUTOMOUNT_UDELAY 2000 +# endif +# endif +#endif + /* USB Host / USB Device */ /* Either CONFIG_SAMA5_UHPHS or CONFIG_SAMA5_UDPHS must be defined, or there is * no USB of any kind. @@ -858,6 +928,52 @@ int sam_hsmci_initialize(int slotno, int minor); bool sam_cardinserted(int slotno); #endif +/************************************************************************************ + * Name: sam_automount_initialize + * + * Description: + * Configure auto-mounters for each enable and so configured HSMCI + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ************************************************************************************/ + +#ifdef HAVE_AUTOMOUNTER +void sam_automount_initialize(void); +#endif + +/************************************************************************************ + * Name: sam_automount_event + * + * Description: + * The HSMCI card detection logic has detected an insertion or removal event. It + * has already scheduled the MMC/SD block driver operations. Now we need to + * schedule the auto-mount event which will occur with a substantial delay to make + * sure that everything has settle down. + * + * Input Parameters: + * slotno - Identifies the HSMCI0 slot: HSMCI0 or HSMCI1_SLOTNO. There is a + * terminology problem here: Each HSMCI supports two slots, slot A and slot B. + * Only slot A is used. So this is not a really a slot, but an HSCMI peripheral + * number. + * inserted - True if the card is inserted in the slot. False otherwise. + * + * Returned Value: + * None + * + * Assumptions: + * Interrupts are disabled. + * + ************************************************************************************/ + +#ifdef HAVE_AUTOMOUNTER +void sam_automount_event(int slotno, bool inserted); +#endif + /************************************************************************************ * Name: sam_writeprotected *