mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
configs/bambino-200e: Add LPC43 SDMMC board support to Bambino-200E and fix errors/warns
This commit is contained in:
committed by
Gregory Nutt
parent
f0d36ebf1f
commit
fa234a7026
@@ -65,6 +65,7 @@
|
||||
|
||||
#include "up_arch.h"
|
||||
|
||||
#include "chip/lpc43_pinconfig.h"
|
||||
#include "lpc43_cgu.h"
|
||||
#include "lpc43_ccu.h"
|
||||
#include "lpc43_gpio.h"
|
||||
|
||||
@@ -141,6 +141,8 @@
|
||||
|
||||
#endif
|
||||
|
||||
#define BOARD_MAIN_CLK BOARD_FCCO_FREQUENCY /* Main clock frequency */
|
||||
|
||||
/* This is the clock setup we configure for:
|
||||
*
|
||||
* SYSCLK = BOARD_OSCCLK_FREQUENCY = 12MHz -> Select Main oscillator for source
|
||||
@@ -179,6 +181,10 @@
|
||||
#define BOARD_SSP1_CLKSRC BASE_SSP1_CLKSEL_IDIVA
|
||||
#define BOARD_SSP1_BASEFREQ BOARD_IDIVA_FREQUENCY
|
||||
|
||||
/* SDIO Clocking */
|
||||
|
||||
#define BOARD_SDIO_CLKSRC BASE_SDIO_CLKSEL_PLL1
|
||||
|
||||
/* USB0 ********************************************************************/
|
||||
/* Settings needed in lpc43_cpu.c */
|
||||
|
||||
@@ -218,6 +224,41 @@
|
||||
# define BOARD_SPIFI_FREQUENCY (102000000) /* 204MHz / 14 = 14.57MHz */
|
||||
#endif
|
||||
|
||||
/* SD/MMC or SDIO interface
|
||||
*
|
||||
* NOTE: The SDIO function clock to the interface can be up to 50 MHZ.
|
||||
* Example: BOARD_MAIN_CLK=220MHz, CLKDIV=5, Finput=44MHz.
|
||||
*/
|
||||
|
||||
#define BOARD_SDMMC_MAXFREQ 50000000
|
||||
#define BOARD_SDMMC_CEIL(a,b) (((a) + (b) - 1) / (b))
|
||||
|
||||
#define BOARD_SDMMC_CLKDIV BOARD_SDMMC_CEIL(BOARD_MAIN_CLK, BOARD_SDMMC_MAXFREQ)
|
||||
#define BOARD_SDMMC_FREQUENCY (BOARD_MAIN_CLK / BOARD_SDMMC_CLKDIV)
|
||||
|
||||
/* Mode-dependent function clock division
|
||||
*
|
||||
* Example: BOARD_SDMMC_FREQUENCY=44MHz
|
||||
* BOARD_CLKDIV_INIT=110, Fsdmmc=400KHz (400KHz max)
|
||||
* BOARD_CLKDIV_MMCXFR=4[3], Fsdmmc=11Mhz (20MHz max) See NOTE:
|
||||
* BOARD_CLKDIV_SDWIDEXFR=2, Fsdmmc=22MHz (25MHz max)
|
||||
* BOARD_CLKDIV_SDXFR=2, Fsdmmc=22MHz (25MHz max)
|
||||
*
|
||||
* NOTE: *lock division is 2*n. For example, value of 0 means divide by
|
||||
* 2 * 0 = 0 (no division, bypass), value of 1 means divide by 2 * 1 = 2, value
|
||||
* of 255 means divide by 2 * 255 = 510, and so on.
|
||||
*
|
||||
* SD/MMC logic will write the value ((clkdiv + 1) >> 1) as the divisor. So an
|
||||
* odd value calculated below will be moved up to next higher divider value. So
|
||||
* the value 3 will cause 2 to be written as the divider value and the effective
|
||||
* divider will be 4.
|
||||
*/
|
||||
|
||||
#define BOARD_CLKDIV_INIT BOARD_SDMMC_CEIL(BOARD_SDMMC_FREQUENCY, 400000)
|
||||
#define BOARD_CLKDIV_MMCXFR BOARD_SDMMC_CEIL(BOARD_SDMMC_FREQUENCY, 20000000)
|
||||
#define BOARD_CLKDIV_SDWIDEXFR BOARD_SDMMC_CEIL(BOARD_SDMMC_FREQUENCY, 25000000)
|
||||
#define BOARD_CLKDIV_SDXFR BOARD_SDMMC_CEIL(BOARD_SDMMC_FREQUENCY, 25000000)
|
||||
|
||||
/* UART clocking ***********************************************************/
|
||||
/* Configure all U[S]ARTs to use the XTAL input frequency */
|
||||
|
||||
@@ -315,4 +356,14 @@
|
||||
#define GPIO_ENET_RESET (GPIO_MODE_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN4)
|
||||
#define PINCONF_ENET_MDC PINCONF_ENET_MDC_3
|
||||
|
||||
/* SD/MMC pinout */
|
||||
|
||||
#define GPIO_SD_CARD_DET_N PINCONF_SD_CD_1
|
||||
#define GPIO_SD_D0 PINCONF_SD_DAT0_1
|
||||
#define GPIO_SD_D1 PINCONF_SD_DAT1_1
|
||||
#define GPIO_SD_D2 PINCONF_SD_DAT2_1
|
||||
#define GPIO_SD_D3 PINCONF_SD_DAT3_1
|
||||
#define GPIO_SD_CMD PINCONF_SD_CMD_1
|
||||
#define GPIO_SD_CLK CLKCONF_SD_CLK_2
|
||||
|
||||
#endif /* __CONFIG_BAMBINO_200E_INCLUDE_BOARD_H */
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define HAVE_MMCSD 1
|
||||
|
||||
/****************************************************************************
|
||||
* LEDs GPIO PIN SIGNAL NAME
|
||||
* -------------------------------- ------- --------------
|
||||
@@ -99,6 +101,36 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* MMC/SD support */
|
||||
|
||||
#ifdef CONFIG_LPC43_SDMMC
|
||||
|
||||
# ifndef CONFIG_MMCSD
|
||||
# warning MMC/SD support requires CONFIG_MMCSD
|
||||
# undef HAVE_MMCSD
|
||||
# endif
|
||||
|
||||
# ifndef CONFIG_MMCSD_SDIO
|
||||
# warning MMC/SD support requires CONFIG_MMCSD_SDIO
|
||||
# undef HAVE_MMCSD
|
||||
# endif
|
||||
|
||||
# ifdef CONFIG_DISABLE_MOUNTPOINT
|
||||
# warning MMC/SD cannot be supported with CONFIG_DISABLE_MOUNTPOINT
|
||||
# undef HAVE_MMCSD
|
||||
# endif
|
||||
|
||||
# ifdef CONFIG_NSH_MMCSDMINOR
|
||||
# define MMCSD_MINOR CONFIG_NSH_MMCSDMINOR
|
||||
# else
|
||||
# define MMCSD_MINOR 0
|
||||
# endif
|
||||
|
||||
#else
|
||||
# undef HAVE_MMCSD
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
@@ -58,6 +58,12 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LPC43_SDMMC
|
||||
# include <nuttx/sdio.h>
|
||||
# include <nuttx/mmcsd.h>
|
||||
# include "lpc43_sdmmc.h"
|
||||
#endif
|
||||
|
||||
#include "bambino-200e.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -162,15 +168,42 @@ static int nsh_spifi_initialize(void)
|
||||
|
||||
int board_app_initialize(uintptr_t arg)
|
||||
{
|
||||
#ifdef HAVE_MMCSD
|
||||
struct sdio_dev_s *sdmmc;
|
||||
#endif
|
||||
int ret = 0;
|
||||
|
||||
/* Initialize the SPIFI block device */
|
||||
|
||||
(void)nsh_spifi_initialize();
|
||||
|
||||
#ifdef HAVE_MMCSD
|
||||
/* Get an instance of the SDIO interface */
|
||||
|
||||
sdmmc = lpc43_sdmmc_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(MMCSD_MINOR, sdmmc);
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n",
|
||||
ret);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
/* Registers the timers */
|
||||
|
||||
lpc43_timerinitialize();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user