mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
boards/arm/samv7: reorganize code to common folder
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
committed by
Xiang Xiao
parent
c56c58020a
commit
f32ce9d930
@@ -11,6 +11,35 @@ config BOARD_SAMV7_COMMON
|
|||||||
|
|
||||||
if BOARD_SAMV7_COMMON
|
if BOARD_SAMV7_COMMON
|
||||||
|
|
||||||
|
config SAMV7_HSMCI0_AUTOMOUNT
|
||||||
|
bool "HSMCI0 automounter"
|
||||||
|
default n
|
||||||
|
depends on FS_AUTOMOUNTER && SAMV7_HSMCI0
|
||||||
|
|
||||||
|
if SAMV7_HSMCI0_AUTOMOUNT
|
||||||
|
|
||||||
|
config SAMV7_HSMCI0_AUTOMOUNT_FSTYPE
|
||||||
|
string "HSMCI0 file system type"
|
||||||
|
default "vfat"
|
||||||
|
|
||||||
|
config SAMV7_HSMCI0_AUTOMOUNT_BLKDEV
|
||||||
|
string "HSMCI0 block device"
|
||||||
|
default "/dev/mmcsd0"
|
||||||
|
|
||||||
|
config SAMV7_HSMCI0_AUTOMOUNT_MOUNTPOINT
|
||||||
|
string "HSMCI0 mount point"
|
||||||
|
default "/mnt/sdcard0"
|
||||||
|
|
||||||
|
config SAMV7_HSMCI0_AUTOMOUNT_DDELAY
|
||||||
|
int "HSMCI0 debounce delay (milliseconds)"
|
||||||
|
default 1000
|
||||||
|
|
||||||
|
config SAMV7_HSMCI0_AUTOMOUNT_UDELAY
|
||||||
|
int "HSMCI0 unmount retry delay (milliseconds)"
|
||||||
|
default 2000
|
||||||
|
|
||||||
|
endif # SAMV7_HSMCI0_AUTOMOUNT
|
||||||
|
|
||||||
config SAMV7_PROGMEM_OTA_PARTITION
|
config SAMV7_PROGMEM_OTA_PARTITION
|
||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/samv7/common/include/sam_automount.h
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __BOARDS_ARM_SAMV7_COMMON_INCLUDE_SAM_AUTOMOUNT_H
|
||||||
|
#define __BOARDS_ARM_SAMV7_COMMON_INCLUDE_SAM_AUTOMOUNT_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT
|
||||||
|
/* HSMCI0 Automounter defaults */
|
||||||
|
|
||||||
|
# ifndef CONFIG_SAMV7_HSMCI0_AUTOMOUNT_FSTYPE
|
||||||
|
# define CONFIG_SAMV7_HSMCI0_AUTOMOUNT_FSTYPE "vfat"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef CONFIG_SAMV7_HSMCI0_AUTOMOUNT_BLKDEV
|
||||||
|
# define CONFIG_SAMV7_HSMCI0_AUTOMOUNT_BLKDEV "/dev/mmcds0"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef CONFIG_SAMV7_HSMCI0_AUTOMOUNT_MOUNTPOINT
|
||||||
|
# define CONFIG_SAMV7_HSMCI0_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard0"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef CONFIG_SAMV7_HSMCI0_AUTOMOUNT_DDELAY
|
||||||
|
# define CONFIG_SAMV7_HSMCI0_AUTOMOUNT_DDELAY 1000
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef CONFIG_SAMV7_HSMCI0_AUTOMOUNT_UDELAY
|
||||||
|
# define CONFIG_SAMV7_HSMCI0_AUTOMOUNT_UDELAY 2000
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void sam_automount_event(int slotno, bool inserted);
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __ASSEMBLY__ */
|
||||||
|
#endif /* __BOARDS_ARM_SAMV7_COMMON_INCLUDE_SAM_AUTOMOUNT_H */
|
||||||
@@ -18,16 +18,25 @@
|
|||||||
#
|
#
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_BOARDCTL),y)
|
||||||
|
CSRCS += sam_progmem.c
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_BOARDCTL_RESET),y)
|
||||||
|
CSRCS += sam_reset.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_BOARDCTL_BOOT_IMAGE),y)
|
ifeq ($(CONFIG_BOARDCTL_BOOT_IMAGE),y)
|
||||||
CSRCS += sam_boot_image.c
|
CSRCS += sam_boot_image.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_BOARDCTL),y)
|
|
||||||
CSRCS += sam_progmem.c
|
|
||||||
else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y)
|
else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y)
|
||||||
CSRCS += sam_progmem.c
|
CSRCS += sam_progmem.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_FS_AUTOMOUNTER),y)
|
||||||
|
CSRCS += sam_automount.c
|
||||||
|
endif
|
||||||
|
|
||||||
DEPPATH += --dep-path src
|
DEPPATH += --dep-path src
|
||||||
VPATH += :src
|
VPATH += :src
|
||||||
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
|
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
|
||||||
|
|||||||
+10
-22
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* boards/arm/samv7/samv71-xult/src/sam_automount.c
|
* boards/arm/samv7/common/src/sam_automount.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -35,22 +35,12 @@
|
|||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
#include <nuttx/fs/automount.h>
|
#include <nuttx/fs/automount.h>
|
||||||
|
|
||||||
#include "samv71-xult.h"
|
#include "sam_automount.h"
|
||||||
|
|
||||||
#ifdef HAVE_AUTOMOUNTER
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef NULL
|
|
||||||
# define NULL (FAR void *)0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef OK
|
|
||||||
# define OK 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -92,17 +82,17 @@ static bool sam_inserted(FAR const struct automount_lower_s *lower);
|
|||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT
|
#ifdef CONFIG_SAMV7_HSMCI0_AUTOMOUNT
|
||||||
static struct sam_automount_state_s g_hsmci0state;
|
static struct sam_automount_state_s g_hsmci0state;
|
||||||
static const struct sam_automount_config_s g_hsmci0config =
|
static const struct sam_automount_config_s g_hsmci0config =
|
||||||
{
|
{
|
||||||
.lower =
|
.lower =
|
||||||
{
|
{
|
||||||
.fstype = CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_FSTYPE,
|
.fstype = CONFIG_SAMV7_HSMCI0_AUTOMOUNT_FSTYPE,
|
||||||
.blockdev = CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_BLKDEV,
|
.blockdev = CONFIG_SAMV7_HSMCI0_AUTOMOUNT_BLKDEV,
|
||||||
.mountpoint = CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_MOUNTPOINT,
|
.mountpoint = CONFIG_SAMV7_HSMCI0_AUTOMOUNT_MOUNTPOINT,
|
||||||
.ddelay = MSEC2TICK(CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_DDELAY),
|
.ddelay = MSEC2TICK(CONFIG_SAMV7_HSMCI0_AUTOMOUNT_DDELAY),
|
||||||
.udelay = MSEC2TICK(CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_UDELAY),
|
.udelay = MSEC2TICK(CONFIG_SAMV7_HSMCI0_AUTOMOUNT_UDELAY),
|
||||||
.attach = sam_attach,
|
.attach = sam_attach,
|
||||||
.enable = sam_enable,
|
.enable = sam_enable,
|
||||||
.inserted = sam_inserted
|
.inserted = sam_inserted
|
||||||
@@ -256,7 +246,7 @@ void sam_automount_initialize(void)
|
|||||||
|
|
||||||
finfo("Initializing automounter(s)\n");
|
finfo("Initializing automounter(s)\n");
|
||||||
|
|
||||||
#ifdef CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT
|
#ifdef CONFIG_SAMV7_HSMCI0_AUTOMOUNT
|
||||||
/* Initialize the HSMCI0 auto-mounter */
|
/* Initialize the HSMCI0 auto-mounter */
|
||||||
|
|
||||||
handle = automount_initialize(&g_hsmci0config.lower);
|
handle = automount_initialize(&g_hsmci0config.lower);
|
||||||
@@ -298,7 +288,7 @@ void sam_automount_event(int slotno, bool inserted)
|
|||||||
FAR const struct sam_automount_config_s *config;
|
FAR const struct sam_automount_config_s *config;
|
||||||
FAR struct sam_automount_state_s *state;
|
FAR struct sam_automount_state_s *state;
|
||||||
|
|
||||||
#ifdef CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT
|
#ifdef CONFIG_SAMV7_HSMCI0_AUTOMOUNT
|
||||||
/* Is this a change in the HSMCI0 insertion state? */
|
/* Is this a change in the HSMCI0 insertion state? */
|
||||||
|
|
||||||
if (slotno == HSMCI0_SLOTNO)
|
if (slotno == HSMCI0_SLOTNO)
|
||||||
@@ -337,5 +327,3 @@ void sam_automount_event(int slotno, bool inserted)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_AUTOMOUNTER */
|
|
||||||
@@ -36,6 +36,8 @@
|
|||||||
#include "arm_arch.h"
|
#include "arm_arch.h"
|
||||||
#include "barriers.h"
|
#include "barriers.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_BOARDCTL_BOOT_IMAGE
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -184,3 +186,5 @@ int board_boot_image(FAR const char *path, uint32_t hdr_size)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_BOARDCTL_BOOT_IMAGE */
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* boards/arm/samv7/samv71-xult/src/sam_reset.c
|
* boards/arm/samv7/common/src/sam_reset.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -5,33 +5,4 @@
|
|||||||
|
|
||||||
if ARCH_BOARD_SAME70_QMTECH
|
if ARCH_BOARD_SAME70_QMTECH
|
||||||
|
|
||||||
config SAME70QMTECH_HSMCI0_AUTOMOUNT
|
|
||||||
bool "HSMCI0 automounter"
|
|
||||||
default n
|
|
||||||
depends on FS_AUTOMOUNTER && SAMV7_HSMCI0
|
|
||||||
|
|
||||||
if SAME70QMTECH_HSMCI0_AUTOMOUNT
|
|
||||||
|
|
||||||
config SAME70QMTECH_HSMCI0_AUTOMOUNT_FSTYPE
|
|
||||||
string "HSMCI0 file system type"
|
|
||||||
default "vfat"
|
|
||||||
|
|
||||||
config SAME70QMTECH_HSMCI0_AUTOMOUNT_BLKDEV
|
|
||||||
string "HSMCI0 block device"
|
|
||||||
default "/dev/mmcsd0"
|
|
||||||
|
|
||||||
config SAME70QMTECH_HSMCI0_AUTOMOUNT_MOUNTPOINT
|
|
||||||
string "HSMCI0 mount point"
|
|
||||||
default "/mnt/sdcard0"
|
|
||||||
|
|
||||||
config SAME70QMTECH_HSMCI0_AUTOMOUNT_DDELAY
|
|
||||||
int "HSMCI0 debounce delay (milliseconds)"
|
|
||||||
default 1000
|
|
||||||
|
|
||||||
config SAME70QMTECH_HSMCI0_AUTOMOUNT_UDELAY
|
|
||||||
int "HSMCI0 unmount retry delay (milliseconds)"
|
|
||||||
default 2000
|
|
||||||
|
|
||||||
endif # SAME70QMTECH_HSMCI0_AUTOMOUNT
|
|
||||||
|
|
||||||
endif # ARCH_BOARD_SAME70_QMTECH
|
endif # ARCH_BOARD_SAME70_QMTECH
|
||||||
|
|||||||
@@ -173,12 +173,12 @@ Auto-Mounter
|
|||||||
CONFIG_FS_AUTOMOUNTER=y
|
CONFIG_FS_AUTOMOUNTER=y
|
||||||
|
|
||||||
Board-Specific Options
|
Board-Specific Options
|
||||||
CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT=y
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT=y
|
||||||
CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_FSTYPE="vfat"
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_FSTYPE="vfat"
|
||||||
CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_BLKDEV="/dev/mmcsd0"
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_BLKDEV="/dev/mmcsd0"
|
||||||
CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_MOUNTPOINT="/mnt/sdcard"
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_MOUNTPOINT="/mnt/sdcard"
|
||||||
CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_DDELAY=1000
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_DDELAY=1000
|
||||||
CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_UDELAY=2000
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_UDELAY=2000
|
||||||
|
|
||||||
WARNING: SD cards should never be removed without first unmounting
|
WARNING: SD cards should never be removed without first unmounting
|
||||||
them. This is to avoid data and possible corruption of the file
|
them. This is to avoid data and possible corruption of the file
|
||||||
|
|||||||
@@ -24,9 +24,6 @@ CSRCS = sam_boot.c
|
|||||||
|
|
||||||
ifeq ($(CONFIG_BOARDCTL),y)
|
ifeq ($(CONFIG_BOARDCTL),y)
|
||||||
CSRCS += sam_appinit.c sam_bringup.c
|
CSRCS += sam_appinit.c sam_bringup.c
|
||||||
ifeq ($(CONFIG_BOARDCTL_RESET),y)
|
|
||||||
CSRCS += sam_reset.c
|
|
||||||
endif
|
|
||||||
else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y)
|
else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y)
|
||||||
CSRCS += sam_bringup.c
|
CSRCS += sam_bringup.c
|
||||||
endif
|
endif
|
||||||
@@ -45,10 +42,6 @@ ifeq ($(CONFIG_SAMV7_HSMCI0),y)
|
|||||||
CSRCS += sam_hsmci.c
|
CSRCS += sam_hsmci.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_FS_AUTOMOUNTER),y)
|
|
||||||
CSRCS += sam_automount.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_SAMV7_SPI),y)
|
ifeq ($(CONFIG_SAMV7_SPI),y)
|
||||||
CSRCS += sam_spi.c
|
CSRCS += sam_spi.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -1,341 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* boards/arm/samv7/same70-qmtech/src/sam_automount.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#if defined(CONFIG_FS_AUTOMOUNTER_DEBUG) && !defined(CONFIG_DEBUG_FS)
|
|
||||||
# define CONFIG_DEBUG_FS 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
|
||||||
#include <nuttx/clock.h>
|
|
||||||
#include <nuttx/fs/automount.h>
|
|
||||||
|
|
||||||
#include "same70-qmtech.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_SAME70QMTECH_HSMCI0_AUTOMOUNT
|
|
||||||
static struct sam_automount_state_s g_hsmci0state;
|
|
||||||
static const struct sam_automount_config_s g_hsmci0config =
|
|
||||||
{
|
|
||||||
.lower =
|
|
||||||
{
|
|
||||||
.fstype = CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_FSTYPE,
|
|
||||||
.blockdev = CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_BLKDEV,
|
|
||||||
.mountpoint = CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_MOUNTPOINT,
|
|
||||||
.ddelay = MSEC2TICK(CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_DDELAY),
|
|
||||||
.udelay = MSEC2TICK(CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_UDELAY),
|
|
||||||
.attach = sam_attach,
|
|
||||||
.enable = sam_enable,
|
|
||||||
.inserted = sam_inserted
|
|
||||||
},
|
|
||||||
.hsmci = HSMCI0_SLOTNO,
|
|
||||||
.state = &g_hsmci0state
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: sam_attach
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Attach a new HSMCI event handler
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* lower - An instance of the auto-mounter lower half state structure
|
|
||||||
* isr - The new event handler to be attach
|
|
||||||
* arg - Client data to be provided when the event handler is invoked.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* Always returns OK
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
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_enable
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Enable card insertion/removal event detection
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* lower - An instance of the auto-mounter lower half state structure
|
|
||||||
* enable - True: enable event detection; False: disable
|
|
||||||
*
|
|
||||||
* 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 = enter_critical_section();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
leave_critical_section(flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: sam_inserted
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Check if a card is inserted into the slot.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* lower - An instance of the auto-mounter lower half state structure
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* True if the card is inserted; False otherwise
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
finfo("Initializing automounter(s)\n");
|
|
||||||
|
|
||||||
#ifdef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT
|
|
||||||
/* Initialize the HSMCI0 auto-mounter */
|
|
||||||
|
|
||||||
handle = automount_initialize(&g_hsmci0config.lower);
|
|
||||||
if (!handle)
|
|
||||||
{
|
|
||||||
ferr("ERROR: Failed to initialize auto-mounter for HSMCI0\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_SAME70QMTECH_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
|
|
||||||
{
|
|
||||||
ferr("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 that 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 */
|
|
||||||
@@ -39,14 +39,18 @@
|
|||||||
|
|
||||||
#include "same70-qmtech.h"
|
#include "same70-qmtech.h"
|
||||||
|
|
||||||
#ifdef HAVE_PROGMEM_CHARDEV
|
#ifdef HAVE_AUTOMOUNTER
|
||||||
# include "board_progmem.h"
|
# include "sam_automount.h"
|
||||||
#endif
|
#endif /* HAVE_AUTOMOUNTER */
|
||||||
|
|
||||||
#ifdef HAVE_ROMFS
|
#ifdef HAVE_ROMFS
|
||||||
# include <arch/board/boot_romfsimg.h>
|
# include <arch/board/boot_romfsimg.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_PROGMEM_CHARDEV
|
||||||
|
# include "board_progmem.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -55,6 +55,10 @@
|
|||||||
|
|
||||||
#include "same70-qmtech.h"
|
#include "same70-qmtech.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_AUTOMOUNTER
|
||||||
|
# include "sam_automount.h"
|
||||||
|
#endif /* HAVE_AUTOMOUNTER */
|
||||||
|
|
||||||
#ifdef HAVE_HSMCI
|
#ifdef HAVE_HSMCI
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -161,7 +165,7 @@ static int sam_hsmci0_cardetect(int irq, void *regs, FAR void *arg)
|
|||||||
|
|
||||||
ret = sam_hsmci_cardetect(&g_hsmci0);
|
ret = sam_hsmci_cardetect(&g_hsmci0);
|
||||||
|
|
||||||
#ifdef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT
|
#if defined(CONFIG_SAMV7_HSMCI0_AUTOMOUNT)
|
||||||
/* Let the automounter know about the insertion event */
|
/* Let the automounter know about the insertion event */
|
||||||
|
|
||||||
sam_automount_event(HSMCI0_SLOTNO, sam_cardinserted(HSMCI0_SLOTNO));
|
sam_automount_event(HSMCI0_SLOTNO, sam_cardinserted(HSMCI0_SLOTNO));
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* boards/arm/samv7/same70-qmtech/src/sam_reset.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/board.h>
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARDCTL_RESET
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: board_reset
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Reset board. Support for this function is required by board-level
|
|
||||||
* logic if CONFIG_BOARDCTL_RESET is selected.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* status - Status information provided with the reset event. This
|
|
||||||
* meaning of this status information is board-specific. If not
|
|
||||||
* used by a board, the value zero may be provided in calls to
|
|
||||||
* board_reset().
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* If this function returns, then it was not possible to power-off the
|
|
||||||
* board due to some constraints. The return value int this case is a
|
|
||||||
* board-specific reason for the failure to shutdown.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int board_reset(int status)
|
|
||||||
{
|
|
||||||
up_systemreset();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* CONFIG_BOARDCTL_RESET */
|
|
||||||
@@ -88,39 +88,13 @@
|
|||||||
|
|
||||||
#if !defined(CONFIG_FS_AUTOMOUNTER) || !defined(HAVE_HSMCI)
|
#if !defined(CONFIG_FS_AUTOMOUNTER) || !defined(HAVE_HSMCI)
|
||||||
# undef HAVE_AUTOMOUNTER
|
# undef HAVE_AUTOMOUNTER
|
||||||
# undef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT
|
# undef CONFIG_SAMV7_HSMCI0_AUTOMOUNT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT
|
#ifndef CONFIG_SAMV7_HSMCI0_AUTOMOUNT
|
||||||
# undef HAVE_AUTOMOUNTER
|
# undef HAVE_AUTOMOUNTER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_AUTOMOUNTER
|
|
||||||
# ifdef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT
|
|
||||||
/* HSMCI0 Automounter defaults */
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_FSTYPE
|
|
||||||
# define CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_FSTYPE "vfat"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_BLKDEV
|
|
||||||
# define CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_BLKDEV "/dev/mmcds0"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_MOUNTPOINT
|
|
||||||
# define CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard0"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_DDELAY
|
|
||||||
# define CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_DDELAY 1000
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_UDELAY
|
|
||||||
# define CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT_UDELAY 2000
|
|
||||||
# endif
|
|
||||||
# endif /* CONFIG_SAME70QMTECH_HSMCI0_AUTOMOUNT */
|
|
||||||
#endif /* HAVE_AUTOMOUNTER */
|
|
||||||
|
|
||||||
/* On-chip Programming Memory */
|
/* On-chip Programming Memory */
|
||||||
|
|
||||||
#if !defined(CONFIG_SAMV7_PROGMEM) || !defined(CONFIG_MTD_PROGMEM)
|
#if !defined(CONFIG_SAMV7_PROGMEM) || !defined(CONFIG_MTD_PROGMEM)
|
||||||
@@ -306,52 +280,6 @@ bool sam_cardinserted(int slotno);
|
|||||||
bool sam_writeprotected(int slotno);
|
bool sam_writeprotected(int slotno);
|
||||||
#endif
|
#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
|
* Name: sam_writeprotected
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -61,33 +61,4 @@ config SAME70XPLAINED_MB2_XBEE
|
|||||||
|
|
||||||
endchoice # mikroBUS2 Click
|
endchoice # mikroBUS2 Click
|
||||||
|
|
||||||
config SAME70XPLAINED_HSMCI0_AUTOMOUNT
|
|
||||||
bool "HSMCI0 automounter"
|
|
||||||
default n
|
|
||||||
depends on FS_AUTOMOUNTER && SAMV7_HSMCI0
|
|
||||||
|
|
||||||
if SAME70XPLAINED_HSMCI0_AUTOMOUNT
|
|
||||||
|
|
||||||
config SAME70XPLAINED_HSMCI0_AUTOMOUNT_FSTYPE
|
|
||||||
string "HSMCI0 file system type"
|
|
||||||
default "vfat"
|
|
||||||
|
|
||||||
config SAME70XPLAINED_HSMCI0_AUTOMOUNT_BLKDEV
|
|
||||||
string "HSMCI0 block device"
|
|
||||||
default "/dev/mmcsd0"
|
|
||||||
|
|
||||||
config SAME70XPLAINED_HSMCI0_AUTOMOUNT_MOUNTPOINT
|
|
||||||
string "HSMCI0 mount point"
|
|
||||||
default "/mnt/sdcard0"
|
|
||||||
|
|
||||||
config SAME70XPLAINED_HSMCI0_AUTOMOUNT_DDELAY
|
|
||||||
int "HSMCI0 debounce delay (milliseconds)"
|
|
||||||
default 1000
|
|
||||||
|
|
||||||
config SAME70XPLAINED_HSMCI0_AUTOMOUNT_UDELAY
|
|
||||||
int "HSMCI0 unmount retry delay (milliseconds)"
|
|
||||||
default 2000
|
|
||||||
|
|
||||||
endif # SAME70XPLAINED_HSMCI0_AUTOMOUNT
|
|
||||||
|
|
||||||
endif # ARCH_BOARD_SAME70_XPLAINED
|
endif # ARCH_BOARD_SAME70_XPLAINED
|
||||||
|
|||||||
@@ -236,12 +236,12 @@ Auto-Mounter
|
|||||||
CONFIG_FS_AUTOMOUNTER=y
|
CONFIG_FS_AUTOMOUNTER=y
|
||||||
|
|
||||||
Board-Specific Options
|
Board-Specific Options
|
||||||
CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT=y
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT=y
|
||||||
CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_FSTYPE="vfat"
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_FSTYPE="vfat"
|
||||||
CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_BLKDEV="/dev/mmcsd0"
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_BLKDEV="/dev/mmcsd0"
|
||||||
CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_MOUNTPOINT="/mnt/sdcard"
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_MOUNTPOINT="/mnt/sdcard"
|
||||||
CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_DDELAY=1000
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_DDELAY=1000
|
||||||
CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_UDELAY=2000
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_UDELAY=2000
|
||||||
|
|
||||||
WARNING: SD cards should never be removed without first unmounting
|
WARNING: SD cards should never be removed without first unmounting
|
||||||
them. This is to avoid data and possible corruption of the file
|
them. This is to avoid data and possible corruption of the file
|
||||||
|
|||||||
@@ -28,9 +28,6 @@ endif
|
|||||||
|
|
||||||
ifeq ($(CONFIG_BOARDCTL),y)
|
ifeq ($(CONFIG_BOARDCTL),y)
|
||||||
CSRCS += sam_appinit.c sam_bringup.c
|
CSRCS += sam_appinit.c sam_bringup.c
|
||||||
ifeq ($(CONFIG_BOARDCTL_RESET),y)
|
|
||||||
CSRCS += sam_reset.c
|
|
||||||
endif
|
|
||||||
else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y)
|
else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y)
|
||||||
CSRCS += sam_bringup.c
|
CSRCS += sam_bringup.c
|
||||||
endif
|
endif
|
||||||
@@ -49,10 +46,6 @@ ifeq ($(CONFIG_SAMV7_HSMCI0),y)
|
|||||||
CSRCS += sam_hsmci.c
|
CSRCS += sam_hsmci.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_FS_AUTOMOUNTER),y)
|
|
||||||
CSRCS += sam_automount.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_SAMV7_EMAC),y)
|
ifeq ($(CONFIG_SAMV7_EMAC),y)
|
||||||
CSRCS += sam_ethernet.c
|
CSRCS += sam_ethernet.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -1,341 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* boards/arm/samv7/same70-xplained/src/sam_automount.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#if defined(CONFIG_FS_AUTOMOUNTER_DEBUG) && !defined(CONFIG_DEBUG_FS)
|
|
||||||
# define CONFIG_DEBUG_FS 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
|
||||||
#include <nuttx/clock.h>
|
|
||||||
#include <nuttx/fs/automount.h>
|
|
||||||
|
|
||||||
#include "same70-xplained.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_SAME70XPLAINED_HSMCI0_AUTOMOUNT
|
|
||||||
static struct sam_automount_state_s g_hsmci0state;
|
|
||||||
static const struct sam_automount_config_s g_hsmci0config =
|
|
||||||
{
|
|
||||||
.lower =
|
|
||||||
{
|
|
||||||
.fstype = CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_FSTYPE,
|
|
||||||
.blockdev = CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_BLKDEV,
|
|
||||||
.mountpoint = CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_MOUNTPOINT,
|
|
||||||
.ddelay = MSEC2TICK(CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_DDELAY),
|
|
||||||
.udelay = MSEC2TICK(CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_UDELAY),
|
|
||||||
.attach = sam_attach,
|
|
||||||
.enable = sam_enable,
|
|
||||||
.inserted = sam_inserted
|
|
||||||
},
|
|
||||||
.hsmci = HSMCI0_SLOTNO,
|
|
||||||
.state = &g_hsmci0state
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: sam_attach
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Attach a new HSMCI event handler
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* lower - An instance of the auto-mounter lower half state structure
|
|
||||||
* isr - The new event handler to be attach
|
|
||||||
* arg - Client data to be provided when the event handler is invoked.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* Always returns OK
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
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_enable
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Enable card insertion/removal event detection
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* lower - An instance of the auto-mounter lower half state structure
|
|
||||||
* enable - True: enable event detection; False: disable
|
|
||||||
*
|
|
||||||
* 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 = enter_critical_section();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
leave_critical_section(flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: sam_inserted
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Check if a card is inserted into the slot.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* lower - An instance of the auto-mounter lower half state structure
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* True if the card is inserted; False otherwise
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
finfo("Initializing automounter(s)\n");
|
|
||||||
|
|
||||||
#ifdef CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT
|
|
||||||
/* Initialize the HSMCI0 auto-mounter */
|
|
||||||
|
|
||||||
handle = automount_initialize(&g_hsmci0config.lower);
|
|
||||||
if (!handle)
|
|
||||||
{
|
|
||||||
ferr("ERROR: Failed to initialize auto-mounter for HSMCI0\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_SAME70XPLAINED_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
|
|
||||||
{
|
|
||||||
ferr("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 that 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 */
|
|
||||||
@@ -45,14 +45,18 @@
|
|||||||
#include "sam_twihs.h"
|
#include "sam_twihs.h"
|
||||||
#include "same70-xplained.h"
|
#include "same70-xplained.h"
|
||||||
|
|
||||||
#ifdef HAVE_PROGMEM_CHARDEV
|
#ifdef HAVE_AUTOMOUNTER
|
||||||
# include "board_progmem.h"
|
# include "sam_automount.h"
|
||||||
#endif
|
#endif /* HAVE_AUTOMOUNTER */
|
||||||
|
|
||||||
#ifdef HAVE_ROMFS
|
#ifdef HAVE_ROMFS
|
||||||
# include <arch/board/boot_romfsimg.h>
|
# include <arch/board/boot_romfsimg.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_PROGMEM_CHARDEV
|
||||||
|
# include "board_progmem.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -55,6 +55,10 @@
|
|||||||
|
|
||||||
#include "same70-xplained.h"
|
#include "same70-xplained.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_AUTOMOUNTER
|
||||||
|
# include "sam_automount.h"
|
||||||
|
#endif /* HAVE_AUTOMOUNTER */
|
||||||
|
|
||||||
#ifdef HAVE_HSMCI
|
#ifdef HAVE_HSMCI
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -161,7 +165,7 @@ static int sam_hsmci0_cardetect(int irq, void *regs, FAR void *arg)
|
|||||||
|
|
||||||
ret = sam_hsmci_cardetect(&g_hsmci0);
|
ret = sam_hsmci_cardetect(&g_hsmci0);
|
||||||
|
|
||||||
#ifdef CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT
|
#if defined(CONFIG_SAMV7_HSMCI0_AUTOMOUNT)
|
||||||
/* Let the automounter know about the insertion event */
|
/* Let the automounter know about the insertion event */
|
||||||
|
|
||||||
sam_automount_event(HSMCI0_SLOTNO, sam_cardinserted(HSMCI0_SLOTNO));
|
sam_automount_event(HSMCI0_SLOTNO, sam_cardinserted(HSMCI0_SLOTNO));
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* boards/arm/samv7/same70-xplained/src/sam_reset.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/board.h>
|
|
||||||
|
|
||||||
#ifdef CONFIG_BOARDCTL_RESET
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: board_reset
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Reset board. Support for this function is required by board-level
|
|
||||||
* logic if CONFIG_BOARDCTL_RESET is selected.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* status - Status information provided with the reset event. This
|
|
||||||
* meaning of this status information is board-specific. If not
|
|
||||||
* used by a board, the value zero may be provided in calls to
|
|
||||||
* board_reset().
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* If this function returns, then it was not possible to power-off the
|
|
||||||
* board due to some constraints. The return value int this case is a
|
|
||||||
* board-specific reason for the failure to shutdown.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int board_reset(int status)
|
|
||||||
{
|
|
||||||
up_systemreset();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* CONFIG_BOARDCTL_RESET */
|
|
||||||
@@ -97,39 +97,13 @@
|
|||||||
|
|
||||||
#if !defined(CONFIG_FS_AUTOMOUNTER) || !defined(HAVE_HSMCI)
|
#if !defined(CONFIG_FS_AUTOMOUNTER) || !defined(HAVE_HSMCI)
|
||||||
# undef HAVE_AUTOMOUNTER
|
# undef HAVE_AUTOMOUNTER
|
||||||
# undef CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT
|
# undef CONFIG_SAMV7_HSMCI0_AUTOMOUNT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT
|
#ifndef CONFIG_SAMV7_HSMCI0_AUTOMOUNT
|
||||||
# undef HAVE_AUTOMOUNTER
|
# undef HAVE_AUTOMOUNTER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_AUTOMOUNTER
|
|
||||||
# ifdef CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT
|
|
||||||
/* HSMCI0 Automounter defaults */
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_FSTYPE
|
|
||||||
# define CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_FSTYPE "vfat"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_BLKDEV
|
|
||||||
# define CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_BLKDEV "/dev/mmcds0"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_MOUNTPOINT
|
|
||||||
# define CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard0"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_DDELAY
|
|
||||||
# define CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_DDELAY 1000
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_UDELAY
|
|
||||||
# define CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT_UDELAY 2000
|
|
||||||
# endif
|
|
||||||
# endif /* CONFIG_SAME70XPLAINED_HSMCI0_AUTOMOUNT */
|
|
||||||
#endif /* HAVE_AUTOMOUNTER */
|
|
||||||
|
|
||||||
/* USB Device */
|
/* USB Device */
|
||||||
|
|
||||||
/* CONFIG_SAMV7_UDP and CONFIG_USBDEV must be defined, or there is no USB
|
/* CONFIG_SAMV7_UDP and CONFIG_USBDEV must be defined, or there is no USB
|
||||||
@@ -576,52 +550,6 @@ bool sam_cardinserted(int slotno);
|
|||||||
bool sam_writeprotected(int slotno);
|
bool sam_writeprotected(int slotno);
|
||||||
#endif
|
#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
|
* Name: sam_writeprotected
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -89,35 +89,6 @@ endif # LCD
|
|||||||
|
|
||||||
endif # SAMV71XULT_MXTXPLND
|
endif # SAMV71XULT_MXTXPLND
|
||||||
|
|
||||||
config SAMV71XULT_HSMCI0_AUTOMOUNT
|
|
||||||
bool "HSMCI0 automounter"
|
|
||||||
default n
|
|
||||||
depends on FS_AUTOMOUNTER && SAMV7_HSMCI0
|
|
||||||
|
|
||||||
if SAMV71XULT_HSMCI0_AUTOMOUNT
|
|
||||||
|
|
||||||
config SAMV71XULT_HSMCI0_AUTOMOUNT_FSTYPE
|
|
||||||
string "HSMCI0 file system type"
|
|
||||||
default "vfat"
|
|
||||||
|
|
||||||
config SAMV71XULT_HSMCI0_AUTOMOUNT_BLKDEV
|
|
||||||
string "HSMCI0 block device"
|
|
||||||
default "/dev/mmcsd0"
|
|
||||||
|
|
||||||
config SAMV71XULT_HSMCI0_AUTOMOUNT_MOUNTPOINT
|
|
||||||
string "HSMCI0 mount point"
|
|
||||||
default "/mnt/sdcard0"
|
|
||||||
|
|
||||||
config SAMV71XULT_HSMCI0_AUTOMOUNT_DDELAY
|
|
||||||
int "HSMCI0 debounce delay (milliseconds)"
|
|
||||||
default 1000
|
|
||||||
|
|
||||||
config SAMV71XULT_HSMCI0_AUTOMOUNT_UDELAY
|
|
||||||
int "HSMCI0 unmount retry delay (milliseconds)"
|
|
||||||
default 2000
|
|
||||||
|
|
||||||
endif # SAMV71XULT_HSMCI0_AUTOMOUNT
|
|
||||||
|
|
||||||
if AUDIO_WM8904
|
if AUDIO_WM8904
|
||||||
|
|
||||||
config SAMV71XULT_WM8904_I2CFREQUENCY
|
config SAMV71XULT_WM8904_I2CFREQUENCY
|
||||||
|
|||||||
@@ -349,12 +349,12 @@ Auto-Mounter
|
|||||||
CONFIG_FS_AUTOMOUNTER=y
|
CONFIG_FS_AUTOMOUNTER=y
|
||||||
|
|
||||||
Board-Specific Options
|
Board-Specific Options
|
||||||
CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT=y
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT=y
|
||||||
CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_FSTYPE="vfat"
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_FSTYPE="vfat"
|
||||||
CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_BLKDEV="/dev/mmcsd0"
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_BLKDEV="/dev/mmcsd0"
|
||||||
CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_MOUNTPOINT="/mnt/sdcard"
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_MOUNTPOINT="/mnt/sdcard"
|
||||||
CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_DDELAY=1000
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_DDELAY=1000
|
||||||
CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_UDELAY=2000
|
CONFIG_SAMV7_HSMCI0_AUTOMOUNT_UDELAY=2000
|
||||||
|
|
||||||
WARNING: SD cards should never be removed without first unmounting
|
WARNING: SD cards should never be removed without first unmounting
|
||||||
them. This is to avoid data and possible corruption of the file
|
them. This is to avoid data and possible corruption of the file
|
||||||
|
|||||||
@@ -28,9 +28,6 @@ endif
|
|||||||
|
|
||||||
ifeq ($(CONFIG_BOARDCTL),y)
|
ifeq ($(CONFIG_BOARDCTL),y)
|
||||||
CSRCS += sam_appinit.c sam_bringup.c
|
CSRCS += sam_appinit.c sam_bringup.c
|
||||||
ifeq ($(CONFIG_BOARDCTL_RESET),y)
|
|
||||||
CSRCS += sam_reset.c
|
|
||||||
endif
|
|
||||||
else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y)
|
else ifeq ($(CONFIG_BOARD_LATE_INITIALIZE),y)
|
||||||
CSRCS += sam_bringup.c
|
CSRCS += sam_bringup.c
|
||||||
endif
|
endif
|
||||||
@@ -49,10 +46,6 @@ ifeq ($(CONFIG_SAMV7_HSMCI0),y)
|
|||||||
CSRCS += sam_hsmci.c
|
CSRCS += sam_hsmci.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_FS_AUTOMOUNTER),y)
|
|
||||||
CSRCS += sam_automount.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_SAMV7_EMAC),y)
|
ifeq ($(CONFIG_SAMV7_EMAC),y)
|
||||||
CSRCS += sam_ethernet.c
|
CSRCS += sam_ethernet.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -60,10 +60,6 @@
|
|||||||
# include <nuttx/leds/userled.h>
|
# include <nuttx/leds/userled.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_PROGMEM_CHARDEV
|
|
||||||
# include "board_progmem.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(HAVE_RTC_DSXXXX) || defined(HAVE_RTC_PCF85263)
|
#if defined(HAVE_RTC_DSXXXX) || defined(HAVE_RTC_PCF85263)
|
||||||
# include <nuttx/clock.h>
|
# include <nuttx/clock.h>
|
||||||
# include <nuttx/i2c/i2c_master.h>
|
# include <nuttx/i2c/i2c_master.h>
|
||||||
@@ -75,10 +71,18 @@
|
|||||||
# include "sam_twihs.h"
|
# include "sam_twihs.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_AUTOMOUNTER
|
||||||
|
# include "sam_automount.h"
|
||||||
|
#endif /* HAVE_AUTOMOUNTER */
|
||||||
|
|
||||||
#ifdef HAVE_ROMFS
|
#ifdef HAVE_ROMFS
|
||||||
# include <arch/board/boot_romfsimg.h>
|
# include <arch/board/boot_romfsimg.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_PROGMEM_CHARDEV
|
||||||
|
# include "board_progmem.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -55,6 +55,10 @@
|
|||||||
|
|
||||||
#include "samv71-xult.h"
|
#include "samv71-xult.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_AUTOMOUNTER
|
||||||
|
# include "sam_automount.h"
|
||||||
|
#endif /* HAVE_AUTOMOUNTER */
|
||||||
|
|
||||||
#ifdef HAVE_HSMCI
|
#ifdef HAVE_HSMCI
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -161,7 +165,7 @@ static int sam_hsmci0_cardetect(int irq, void *regs, FAR void *arg)
|
|||||||
|
|
||||||
ret = sam_hsmci_cardetect(&g_hsmci0);
|
ret = sam_hsmci_cardetect(&g_hsmci0);
|
||||||
|
|
||||||
#ifdef CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT
|
#if defined(CONFIG_SAMV7_HSMCI0_AUTOMOUNT)
|
||||||
/* Let the automounter know about the insertion event */
|
/* Let the automounter know about the insertion event */
|
||||||
|
|
||||||
sam_automount_event(HSMCI0_SLOTNO, sam_cardinserted(HSMCI0_SLOTNO));
|
sam_automount_event(HSMCI0_SLOTNO, sam_cardinserted(HSMCI0_SLOTNO));
|
||||||
|
|||||||
@@ -105,39 +105,13 @@
|
|||||||
|
|
||||||
#if !defined(CONFIG_FS_AUTOMOUNTER) || !defined(HAVE_HSMCI)
|
#if !defined(CONFIG_FS_AUTOMOUNTER) || !defined(HAVE_HSMCI)
|
||||||
# undef HAVE_AUTOMOUNTER
|
# undef HAVE_AUTOMOUNTER
|
||||||
# undef CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT
|
# undef CONFIG_SAMV7_HSMCI0_AUTOMOUNT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT
|
#ifndef CONFIG_SAMV7_HSMCI0_AUTOMOUNT
|
||||||
# undef HAVE_AUTOMOUNTER
|
# undef HAVE_AUTOMOUNTER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_AUTOMOUNTER
|
|
||||||
# ifdef CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT
|
|
||||||
/* HSMCI0 Automounter defaults */
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_FSTYPE
|
|
||||||
# define CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_FSTYPE "vfat"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_BLKDEV
|
|
||||||
# define CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_BLKDEV "/dev/mmcds0"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_MOUNTPOINT
|
|
||||||
# define CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_MOUNTPOINT "/mnt/sdcard0"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_DDELAY
|
|
||||||
# define CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_DDELAY 1000
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_UDELAY
|
|
||||||
# define CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT_UDELAY 2000
|
|
||||||
# endif
|
|
||||||
# endif /* CONFIG_SAMV71XULT_HSMCI0_AUTOMOUNT */
|
|
||||||
#endif /* HAVE_AUTOMOUNTER */
|
|
||||||
|
|
||||||
/* USB Device */
|
/* USB Device */
|
||||||
|
|
||||||
/* CONFIG_SAMV7_UDP and CONFIG_USBDEV must be defined, or there is no USB
|
/* CONFIG_SAMV7_UDP and CONFIG_USBDEV must be defined, or there is no USB
|
||||||
@@ -784,53 +758,6 @@ bool sam_cardinserted(int slotno);
|
|||||||
bool sam_writeprotected(int slotno);
|
bool sam_writeprotected(int slotno);
|
||||||
#endif
|
#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
|
* Name: sam_writeprotected
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user