forked from xuos/xiuos
Merge pull request 'move nsh_sdmmc_initialize to imxrt_mmcsd.c for xidatong' (#35) from ok1052 into prepare_for_master
ok
This commit is contained in:
commit
72effb4915
|
@ -70,8 +70,12 @@ ifeq ($(CONFIG_USBHOST),y)
|
|||
CSRCS += imxrt_usbhost.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_IMXRT_USDHC),y)
|
||||
CSRCS += imxrt_mmcsd.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_XIDATONG_SDIO_AUTOMOUNT),y)
|
||||
CSRCS += imxrt_sdhc_automount.c
|
||||
CSRCS += imxrt_mmcsd_automount.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/boards/Board.mk
|
||||
|
|
|
@ -43,10 +43,6 @@
|
|||
#include <imxrt_lpi2c.h>
|
||||
#include <imxrt_lpspi.h>
|
||||
|
||||
#ifdef CONFIG_IMXRT_USDHC
|
||||
# include "imxrt_usdhc.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBMONITOR
|
||||
# include <nuttx/usb/usbmonitor.h>
|
||||
#endif
|
||||
|
@ -94,45 +90,6 @@ static void imxrt_i2c_register(int bus)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_IMXRT_USDHC
|
||||
static int nsh_sdmmc_initialize(void)
|
||||
{
|
||||
struct sdio_dev_s *sdmmc;
|
||||
int ret = 0;
|
||||
|
||||
/* Get an instance of the SDIO interface */
|
||||
|
||||
sdmmc = imxrt_usdhc_initialize(0);
|
||||
if (!sdmmc)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize SD/MMC\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Bind the SDIO interface to the MMC/SD driver */
|
||||
|
||||
ret = mmcsd_slotinitialize(0, sdmmc);
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n",
|
||||
ret);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_XIDATONG_SDIO_AUTOMOUNT
|
||||
imxrt_automount_initialize();
|
||||
imxrt_usdhc_set_sdio_card_isr(sdmmc, imxrt_sdhc_automount_event, NULL);
|
||||
#else
|
||||
imxrt_usdhc_set_sdio_card_isr(sdmmc, NULL, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
#else
|
||||
# define nsh_sdmmc_initialize() (OK)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file imxrt_sdhc_automount.c
|
||||
* @brief imxrt board sd card automount
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2022.04.12
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "xidatong.h"
|
||||
|
||||
#ifdef CONFIG_IMXRT_USDHC
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This structure holds static information unique to one SDHC peripheral */
|
||||
|
||||
struct imxrt_sdhc_state_s
|
||||
{
|
||||
struct sdio_dev_s *sdhc; /* R/W device handle */
|
||||
bool inserted; /* true: card is inserted */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* device state */
|
||||
|
||||
static struct imxrt_sdhc_state_s g_sdhc;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_sdmmc_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the SDHC SD card slot
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nsh_sdmmc_initialize(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* Get an instance of the SDIO interface */
|
||||
|
||||
g_sdhc.sdhc = imxrt_usdhc_initialize(0);
|
||||
if (!g_sdhc.sdhc)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize SD/MMC\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Bind the SDIO interface to the MMC/SD driver */
|
||||
|
||||
ret = mmcsd_slotinitialize(0, g_sdhc.sdhc);
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_XIDATONG_SDIO_AUTOMOUNT
|
||||
imxrt_automount_initialize();
|
||||
imxrt_usdhc_set_sdio_card_isr(g_sdhc.sdhc, imxrt_sdhc_automount_event, NULL);
|
||||
#else
|
||||
imxrt_usdhc_set_sdio_card_isr(g_sdhc.sdhc, NULL, NULL);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
|
@ -208,6 +208,12 @@ int imxrt_usbhost_initialize(void);
|
|||
int imxrt_mmcsd_initialize(void);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_IMXRT_USDHC
|
||||
int nsh_sdmmc_initialize(void);
|
||||
#else
|
||||
# define nsh_sdmmc_initialize() (OK)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_XIDATONG_SDIO_AUTOMOUNT
|
||||
int imxrt_sdhc_automount_event(void *arg);
|
||||
void imxrt_automount_initialize(void);
|
||||
|
|
Loading…
Reference in New Issue