Merged in alinjerpelea/nuttx (pull request #892)

Spresense board updates

* configs: spresense: Code style fix

    There is no functional change

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

* configs: spresense: initialize CPU

    we are using the framework to initialize the CPU

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

* configs: spresense: enable power manager

    Enable PowerManager on spresense board

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

* configs: spresense: initialize the UART interfaces

    initialize the UART interfaces

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

* configs: spresense: enable clock management

    enable clock management using the cxd56 framework

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

* configs: spresense: enable spresense timer

    Use timerisr on the spresense board

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

* configs: spresense: enable USBDEV

    Enable USBDEV on Spresense board

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

* configs: spresense: enable SD Card Support

    Enable SD Card support on spresense board

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

* configs: spresense: enable Mass Storage

    Enable Mass Storage on Spresense board

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
Alin Jerpelea 2019-06-12 13:23:39 +00:00 committed by Gregory Nutt
parent aaa173dd37
commit da4e3271f8
16 changed files with 1905 additions and 37 deletions

View File

@ -5,4 +5,27 @@
if ARCH_BOARD_SPRESENSE
config SDCARD_TXS02612
bool "SD Card TXS02612 port expander with voltage level translation"
default y
---help---
Enable TXS02612 Dual Voltage Level Translator for SD-Card interface.
This device is used in SPD-003C board.
if SDCARD_TXS02612
choice
prompt "TXS02612 port"
default SDCARD_TXS02612_PORT0
config SDCARD_TXS02612_PORT0
bool "Port 0"
config SDCARD_TXS02612_PORT1
bool "Port 1"
endchoice # "TXS02612 port"
endif # SDCARD_TXS02612
endif

View File

@ -45,6 +45,10 @@
#include <sys/boardctl.h>
#include <stdbool.h>
#include "cxd56_clock.h"
#include "cxd56_power.h"
#include "cxd56_sdcard.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

View File

@ -0,0 +1,86 @@
/****************************************************************************
* configs/spresense/include/cxd56_clock.h
*
* Copyright 2019 Sony Semiconductor Solutions Corporation
*
* 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 of Sony Semiconductor Solutions Corporation 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.
*
****************************************************************************/
#ifndef __BOARD_COMMON_INCLUDE_CXD56_CLOCK_H
#define __BOARD_COMMON_INCLUDE_CXD56_CLOCK_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: board_clock_initialize
*
* Description:
* Initialize clock control.
* If this API is called and is returned, the clock mode is the highest
* clock mode. For example, CPU frequency is 156MHz.
*
****************************************************************************/
void board_clock_initialize(void);
/****************************************************************************
* Name: board_clock_enable
*
* Description:
* Enable dynamic clock control.
* If this API is called and is returned, the clock mode is the lowest
* clock mode. Later, you can control the clock mode dynamically by calling
* up_pm_acquire_freqlock() or up_pm_release_freqlock.
*
****************************************************************************/
void board_clock_enable(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __BOARD_COMMON_INCLUDE_CXD56_CLOCK_H */

View File

@ -0,0 +1,202 @@
/****************************************************************************
* configs/spresense/include/cxd56_power.h
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* 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 of Sony Semiconductor Solutions Corporation 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.
*
****************************************************************************/
#ifndef __BOARD_COMMON_INCLUDE_CXD56_POWER_H
#define __BOARD_COMMON_INCLUDE_CXD56_POWER_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define PMIC_NONE (0)
#define PMIC_TYPE_LSW (1u << 8)
#define PMIC_TYPE_GPO (1u << 9)
#define PMIC_TYPE_DDCLDO (1u << 10)
#define PMIC_GET_TYPE(v) ((v) & 0xff00)
#define PMIC_GET_CH(v) ((v) & 0x00ff)
#define PMIC_LSW(n) (PMIC_TYPE_LSW | (1u << (n)))
#define PMIC_GPO(n) (PMIC_TYPE_GPO | (1u << (n)))
#define PMIC_DDCLDO(n) (PMIC_TYPE_DDCLDO | (1u << (n)))
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: board_pmic_read
*
* Description:
* Read the value from the specified sub address
*
* Input Parameter:
* addr - sub address
* buf - pointer to read buffer
* size - byte count of read
*
* Returned Value:
* Return 0 on success. Otherwise, return a negated errno.
*
****************************************************************************/
int board_pmic_read(uint8_t addr, void *buf, uint32_t size);
/****************************************************************************
* Name: board_pmic_write
*
* Description:
* Write the value to the specified sub address
*
* Input Parameter:
* addr - sub address
* buf - pointer to write buffer
* size - byte count of write
*
* Returned Value:
* Return 0 on success. Otherwise, return a negated errno.
*
****************************************************************************/
int board_pmic_write(uint8_t addr, void *buf, uint32_t size);
/****************************************************************************
* Name: board_power_setup
*
* Description:
* Initial setup for board-specific power control
*
****************************************************************************/
int board_power_setup(int status);
/****************************************************************************
* Name: board_power_control
*
* Description:
* Power on/off the device on the board.
*
****************************************************************************/
int board_power_control(int target, bool en);
/****************************************************************************
* Name: board_power_monitor
*
* Description:
* Get status of Power on/off the device on the board.
*
****************************************************************************/
bool board_power_monitor(int target);
/****************************************************************************
* Name: board_flash_power_control
*
* Description:
* Power on/off the flash device on the board.
*
****************************************************************************/
int board_flash_power_control(bool en);
/****************************************************************************
* Name: board_flash_power_monitor
*
* Description:
* Get status of Power on/off the flash device on the board.
*
****************************************************************************/
bool board_flash_power_monitor(void);
/****************************************************************************
* Name: board_xtal_power_control
*
* Description:
* Power on/off the Xtal device on the board.
*
****************************************************************************/
int board_xtal_power_control(bool en);
/****************************************************************************
* Name: board_xtal_power_monitor
*
* Description:
* Get status of Power on/off the Xtal device on the board.
*
****************************************************************************/
bool board_xtal_power_monitor(void);
/****************************************************************************
* Name: board_lna_power_control
*
* Description:
* Power on/off the LNA device on the board.
*
****************************************************************************/
int board_lna_power_control(bool en);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARD_COMMON_INCLUDE_CXD56_POWER_H */

View File

@ -0,0 +1,154 @@
/****************************************************************************
* configs/spresense/include/cxd56_sdcard.h
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* 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 of Sony Semiconductor Solutions Corporation 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.
*
****************************************************************************/
#ifndef __BOARD_COMMON_INCLUDE_CXD56_SDCARD_H
#define __BOARD_COMMON_INCLUDE_CXD56_SDCARD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: board_sdcard_initialize
*
* Description:
* Initialize SD Card on the board.
*
****************************************************************************/
int board_sdcard_initialize(void);
/****************************************************************************
* Name: board_sdcard_pin_initialize
*
* Description:
* Initialize SD Card pins on the board.
*
****************************************************************************/
void board_sdcard_pin_initialize(void);
/****************************************************************************
* Name: board_sdcard_pin_finalize
*
* Description:
* Finalize SD Card pins on the board.
*
****************************************************************************/
void board_sdcard_pin_finalize(void);
/****************************************************************************
* Name: board_sdcard_pin_configuraton
*
* Description:
* Configure SD Card pins on the board.
*
****************************************************************************/
void board_sdcard_pin_configuraton(void);
/****************************************************************************
* Name: board_sdcard_pin_enable
*
* Description:
* Enable SD Card pins on the board.
*
****************************************************************************/
void board_sdcard_pin_enable(void);
/****************************************************************************
* Name: board_sdcard_pin_disable
*
* Description:
* Disable SD Card pins on the board.
*
****************************************************************************/
void board_sdcard_pin_disable(void);
/****************************************************************************
* Name: board_sdcard_set_high_voltage
*
* Description:
* Set SD Card IO voltage to 3.3V
*
****************************************************************************/
void board_sdcard_set_high_voltage(void);
/****************************************************************************
* Name: board_sdcard_set_low_voltage
*
* Description:
* Set SD Card IO voltage to 1.8V
*
****************************************************************************/
void board_sdcard_set_low_voltage(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARD_COMMON_INCLUDE_CXD56_SDCARD_H */

View File

@ -1,5 +1,5 @@
############################################################################
# configs/cxd56evb/nsh/Make.defs
# configs/spresense/nsh/Make.defs
#
# Copyright (C) 2014 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -1,5 +1,5 @@
/****************************************************************************
* configs/cxd56evb/scripts/ramconfig.ld
* configs/spresense/scripts/ramconfig.ld
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*

View File

@ -37,10 +37,15 @@
DEPPATH = --dep-path .
ASRCS =
CSRCS = cxd56_boot.c cxd56_bringup.c
CSRCS =
CSRCS += cxd56_boot.c
CSRCS += cxd56_clock.c
CSRCS += cxd56_bringup.c
ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += cxd56_appinit.c
CSRCS += cxd56_power.c
endif
ifeq ($(CONFIG_BOARDCTL_IOCTL),y)
@ -55,4 +60,12 @@ ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += cxd56_leds.c
endif
ifeq ($(CONFIG_CXD56_SDIO),y)
CSRCS += cxd56_sdcard.c
endif
ifeq ($(CONFIG_USBMSC),y)
CSRCS += cxd56_usbmsc.c
endif
include $(TOPDIR)/configs/Board.mk

View File

@ -47,8 +47,6 @@
#include "up_arch.h"
#include "up_internal.h"
#include "spresense.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -71,26 +69,3 @@
void cxd56_boardinitialize(void)
{
}
/****************************************************************************
* Name: board_late_initialize
*
* Description:
* If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional
* initialization call will be performed in the boot-up sequence to a
* function called board_late_initialize(). board_late_initialize() will be
* called immediately after up_initialize() is called and just before the
* initial application is started. This additional initialization phase
* may be used, for example, to initialize board-specific device drivers.
*
****************************************************************************/
#ifdef CONFIG_BOARD_LATE_INITIALIZE
void board_late_initialize(void)
{
/* Perform board-specific initialization */
(void)cxd56_bringup();
}
#endif

View File

@ -44,6 +44,36 @@
#include <errno.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include <arch/chip/pm.h>
#include "chip.h"
#include "cxd56_sysctl.h"
#include "cxd56_powermgr.h"
#include "cxd56_uart.h"
#include "cxd56_timerisr.h"
#include "cxd56_gpio.h"
#include "cxd56_pinconfig.h"
#ifdef CONFIG_CXD56_CPUFIFO
#include "cxd56_cpufifo.h"
#endif
#ifdef CONFIG_CXD56_ICC
#include "cxd56_icc.h"
#endif
#ifdef CONFIG_CXD56_FARAPI
#include "cxd56_farapi.h"
#endif
#ifdef CONFIG_USBDEV
#include "cxd56_usbdev.h"
#endif
#include "spresense.h"
/****************************************************************************
@ -55,11 +85,37 @@
/* procfs File System */
#ifdef CONFIG_FS_PROCFS
# ifdef CONFIG_NSH_PROC_MOUNTPOINT
# define CXD56_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT
# else
# define CXD56_PROCFS_MOUNTPOINT "/proc"
# endif
#ifdef CONFIG_NSH_PROC_MOUNTPOINT
#define CXD56_PROCFS_MOUNTPOINT CONFIG_NSH_PROC_MOUNTPOINT
#else
#define CXD56_PROCFS_MOUNTPOINT "/proc"
#endif
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
#ifdef CONFIG_CXD56_CPUFIFO
static int nsh_cpucom_initialize(void)
{
int ret = OK;
cxd56_cfinitialize();
#ifdef CONFIG_CXD56_ICC
cxd56_iccinitialize();
#endif
#ifdef CONFIG_CXD56_FARAPI
cxd56_farapiinitialize();
#endif
cxd56_sysctlinitialize();
return ret;
}
#else
# define nsh_cpucom_initialize() (OK)
#endif
/****************************************************************************
@ -82,11 +138,56 @@
int cxd56_bringup(void)
{
struct pm_cpu_wakelock_s wlock;
int ret;
(void) ret;
ret = nsh_cpucom_initialize();
if (ret < 0)
{
_err("ERROR: Failed to initialize cpucom.\n");
}
ret = cxd56_pm_initialize();
if (ret < 0)
{
_err("ERROR: Failed to initialize powermgr.\n");
}
wlock.info = PM_CPUWAKELOCK_TAG('C', 'A', 0);
wlock.count = 0;
up_pm_acquire_wakelock(&wlock);
cxd56_uart_initialize();
cxd56_timerisr_initialize();
#ifdef CONFIG_CXD56_CPUFIFO
ret = cxd56_pm_bootup();
if (ret < 0)
{
_err("ERROR: Failed to powermgr bootup.\n");
}
#endif
/* Initialize CPU clock to max frequency */
board_clock_initialize();
/* Setup the power of external device */
board_power_setup(0);
#ifdef CONFIG_FS_PROCFS
#ifdef CONFIG_FS_PROCFS_REGISTER
/* register usbdev procfs */
ret = cxd56_usbdev_procfs_register();
if (ret < 0)
{
_err("ERROR: Failed to register usbdev.\n");
}
#endif
ret = mount(NULL, CXD56_PROCFS_MOUNTPOINT, "procfs", 0, NULL);
if (ret < 0)
{
@ -94,5 +195,44 @@ int cxd56_bringup(void)
}
#endif
return OK;
/* In order to prevent Hi-Z from being input to the SD Card controller,
* Initialize SDIO pins to GPIO low output with internal pull-down.
*/
CXD56_PIN_CONFIGS(PINCONFS_SDIOA_GPIO);
cxd56_gpio_write(PIN_SDIO_CLK, false);
cxd56_gpio_write(PIN_SDIO_CMD, false);
cxd56_gpio_write(PIN_SDIO_DATA0, false);
cxd56_gpio_write(PIN_SDIO_DATA1, false);
cxd56_gpio_write(PIN_SDIO_DATA2, false);
cxd56_gpio_write(PIN_SDIO_DATA3, false);
#if defined(CONFIG_CXD56_SDIO) && !defined(CONFIG_CXD56_SPISD)
ret = board_sdcard_initialize();
if (ret < 0)
{
_err("ERROR: Failed to initialze sdhci. \n");
}
#endif
#ifdef CONFIG_CXD56_SPISD
/* Mount the SPI-based MMC/SD block driver */
ret = board_spisd_initialize(0, 4);
if (ret < 0)
{
ferr("ERROR: Failed to initialize SPI device to MMC/SD: %d\n",
ret);
}
#endif
#ifdef CONFIG_CPUFREQ_RELEASE_LOCK
/* Enable dynamic clock control and CPU clock down for power saving */
board_clock_enable();
#endif
up_pm_release_wakelock(&wlock);
return 0;
}

View File

@ -0,0 +1,77 @@
/****************************************************************************
* configs/spresense/src/cxd56_clock.c
*
* Copyright 2019 Sony Semiconductor Solutions Corporation
*
* 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 of Sony Semiconductor Solutions Corporation 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 <nuttx/config.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include <arch/chip/pm.h>
/****************************************************************************
* Private Data
****************************************************************************/
static struct pm_cpu_freqlock_s g_hv_lock =
PM_CPUFREQLOCK_INIT(PM_CPUFREQLOCK_TAG('C','P',0), PM_CPUFREQLOCK_FLAG_HV);
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_clock_initialize
****************************************************************************/
void board_clock_initialize(void)
{
up_pm_acquire_freqlock(&g_hv_lock);
}
/****************************************************************************
* Name: board_clock_enable
****************************************************************************/
void board_clock_enable(void)
{
up_pm_release_freqlock(&g_hv_lock);
}

View File

@ -86,8 +86,7 @@
int board_ioctl(unsigned int cmd, uintptr_t arg)
{
int ret = -ENOTTY; /* The correct return for the case of an unrecognized
* command. */
int ret = -ENOTTY; /* The correct return for the case of an unrecognized command */
switch (cmd)
{

View File

@ -0,0 +1,524 @@
/****************************************************************************
* configs/spresense/src/cxd56_power.c
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* 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 of Sony Semiconductor Solutions Corporation 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 <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <semaphore.h>
#include <nuttx/arch.h>
#include "chip.h"
#include "up_arch.h"
#include <arch/chip/pm.h>
#include <arch/board/board.h>
#include "cxd56_pmic.h"
#include "cxd56_pinconfig.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
static sem_t g_ltsem = SEM_INITIALIZER(1);
static bool g_used_lna = true;
static bool g_used_tcxo = true;
#ifdef CONFIG_BOARDCTL_RESET
static struct pm_cpu_freqlock_s g_hv_lock =
PM_CPUFREQLOCK_INIT(PM_CPUFREQLOCK_TAG('B','P',0), PM_CPUFREQLOCK_FLAG_HV);
#endif
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_pmic_read
*
* Description:
* Read the value from the specified sub address
*
* Input Parameter:
* addr - sub address
* buf - pointer to read buffer
* size - byte count of read
*
* Returned Value:
* Return 0 on success. Otherwise, return a negated errno.
*
****************************************************************************/
int board_pmic_read(uint8_t addr, void *buf, uint32_t size)
{
return cxd56_pmic_read(addr, buf, size);
}
/****************************************************************************
* Name: board_pmic_write
*
* Description:
* Write the value to the specified sub address
*
* Input Parameter:
* addr - sub address
* buf - pointer to write buffer
* size - byte count of write
*
* Returned Value:
* Return 0 on success. Otherwise, return a negated errno.
*
****************************************************************************/
int board_pmic_write(uint8_t addr, void *buf, uint32_t size)
{
return cxd56_pmic_write(addr, buf, size);
}
/****************************************************************************
* Name: board_power_setup
*
* Description:
* Initial setup for board-specific power control
*
****************************************************************************/
int board_power_setup(int status)
{
#ifdef CONFIG_BOARD_USB_DISABLE_IN_DEEP_SLEEPING
uint8_t val;
uint32_t bootcause;
/* Enable USB after wakeup from deep sleeping */
bootcause = up_pm_get_bootcause();
switch (bootcause)
{
case PM_BOOT_DEEP_WKUPL:
case PM_BOOT_DEEP_WKUPS:
case PM_BOOT_DEEP_RTC:
case PM_BOOT_DEEP_OTHERS:
cxd56_pmic_read(PMIC_REG_CNT_USB2, &val, sizeof(val));
if (val & PMIC_SET_CHGOFF)
{
val &= ~PMIC_SET_CHGOFF;
cxd56_pmic_write(PMIC_REG_CNT_USB2, &val, sizeof(val));
}
break;
default:
break;
}
#endif
/* Disable unused DDC/LDO permanently */
board_power_control(POWER_DDC_ANA | POWER_LDO_PERI, false);
/* Disable unnecessary load switch in boot-up stage */
board_power_control(POWER_AUDIO_DVDD, false);
/* Power off all of GPO switches (except for GPO0) in boot-up stage */
board_power_control(PMIC_GPO(1) | PMIC_GPO(2) | PMIC_GPO(3) | PMIC_GPO(4) |
PMIC_GPO(5) | PMIC_GPO(6) | PMIC_GPO(7), false);
/* Set GPO0 to Hi-Z */
cxd56_pmic_set_gpo_hiz(PMIC_GET_CH(PMIC_GPO(0)));
return 0;
}
/****************************************************************************
* Name: board_power_control
*
* Description:
* Power on/off the device on the board.
*
****************************************************************************/
int board_power_control(int target, bool en)
{
int ret = 0;
int (*pfunc)(uint8_t chset, bool en) = NULL;
switch (PMIC_GET_TYPE(target))
{
#ifdef CONFIG_CXD56_PMIC
case PMIC_TYPE_LSW:
pfunc = cxd56_pmic_set_loadswitch;
break;
case PMIC_TYPE_GPO:
pfunc = cxd56_pmic_set_gpo;
break;
case PMIC_TYPE_DDCLDO:
pfunc = cxd56_pmic_set_ddc_ldo;
break;
#endif /* CONFIG_CXD56_PMIC */
default:
break;
}
if (pfunc)
{
ret = pfunc(PMIC_GET_CH(target), en);
}
return ret;
}
/****************************************************************************
* Name: board_power_monitor
*
* Description:
* Get status of Power on/off the device on the board.
*
****************************************************************************/
bool board_power_monitor(int target)
{
bool ret = false;
bool (*pfunc)(uint8_t chset) = NULL;
switch (PMIC_GET_TYPE(target))
{
#ifdef CONFIG_CXD56_PMIC
case PMIC_TYPE_LSW:
pfunc = cxd56_pmic_get_loadswitch;
break;
case PMIC_TYPE_GPO:
pfunc = cxd56_pmic_get_gpo;
break;
case PMIC_TYPE_DDCLDO:
pfunc = cxd56_pmic_get_ddc_ldo;
break;
#endif /* CONFIG_CXD56_PMIC */
default:
break;
}
if (pfunc)
{
ret = pfunc(PMIC_GET_CH(target));
}
return ret;
}
/****************************************************************************
* Name: board_flash_power_control
*
* Description:
* Power on/off the flash device on the board.
*
****************************************************************************/
int board_flash_power_control(bool en)
{
int ret = 0;
if (en)
{
/* power on */
board_power_control(POWER_FLASH, true);
/* pin enable */
CXD56_PIN_CONFIGS(PINCONFS_SPI1);
}
else
{
/* pin disable */
CXD56_PIN_CONFIGS(PINCONFS_SPI1_GPIO);
/* power off */
board_power_control(POWER_FLASH, false);
}
return ret;
}
/****************************************************************************
* Name: board_flash_power_monitor
*
* Description:
* Get status of Power on/off the flash device on the board.
*
****************************************************************************/
bool board_flash_power_monitor(void)
{
return board_power_monitor(POWER_FLASH);
}
/****************************************************************************
* Name: board_xtal_power_control
*
* Description:
* Power on/off the Xtal device on the board.
*
****************************************************************************/
int board_xtal_power_control(bool en)
{
int ret = 0;
/* Get exclusive access to the lna / tcxo power control */
sem_wait(&g_ltsem);
if (en)
{
/* power on */
board_power_control(POWER_TCXO, true);
/* set used flag */
g_used_tcxo = true;
}
else
{
/* power off */
if (!g_used_lna)
{
board_power_control(POWER_TCXO, false);
}
/* unset used flag */
g_used_tcxo = false;
}
sem_post(&g_ltsem);
return ret;
}
/****************************************************************************
* Name: board_xtal_power_monitor
*
* Description:
* Get status of Power on/off the Xtal device on the board.
*
****************************************************************************/
bool board_xtal_power_monitor(void)
{
return board_power_monitor(POWER_TCXO);
}
/****************************************************************************
* Name: board_lna_power_control
*
* Description:
* Power on/off the LNA device on the board.
*
****************************************************************************/
int board_lna_power_control(bool en)
{
int ret = 0;
/* Get exclusive access to the lna / tcxo power control */
sem_wait(&g_ltsem);
if (en)
{
/* power on */
board_power_control(POWER_LNA, true);
/* set used flag */
g_used_lna = true;
}
else
{
/* power off */
if (!g_used_tcxo)
{
board_power_control(POWER_LNA, false);
}
/* unset used flag */
g_used_lna = false;
}
sem_post(&g_ltsem);
return ret;
}
/****************************************************************************
* Name: board_reset
*
* Description:
* Reset board. This function may or may not be supported by a
* particular board architecture.
*
* 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.
*
* Assumptions:
* Must not compile up_systemreset.c to avoid duplication symbol definition
*
****************************************************************************/
#ifdef CONFIG_BOARDCTL_RESET
int board_reset(int status)
{
/* Restore the original state for bootup after power cycle */
board_xtal_power_control(true);
board_flash_power_control(true);
up_pm_acquire_freqlock(&g_hv_lock);
/* System reboot */
up_pm_reboot(); /* this function never returns */
return 0;
}
#endif
/****************************************************************************
* Name: board_power_off
*
* Description:
* Power off the board.
*
* If this function returns, then it was not possible to power-off the
* board due to some other constraints.
*
* Input Parameters:
* status - Status information provided with the power off event.
* This status is used as the power shutdown level.
* 0= Deep Sleep, 1= Cold Sleep
*
* 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.
*
****************************************************************************/
#ifdef CONFIG_BOARDCTL_POWEROFF
int board_power_off(int status)
{
enum pm_sleepmode_e mode;
uint8_t val;
/* Power off explicitly because GPOs are kept during deep sleeping */
board_power_control(PMIC_GPO(0) | PMIC_GPO(1) | PMIC_GPO(2) | PMIC_GPO(3) |
PMIC_GPO(4) | PMIC_GPO(5) | PMIC_GPO(6) | PMIC_GPO(7),
false);
/* Set DDC_ANA output to HiZ before sleeping for power saving */
val = PMIC_PM_HIZ | PMIC_IOST_DEF | PMIC_IOMAX_DEF;
cxd56_pmic_write(PMIC_REG_DDC_ANA1, &val, sizeof(val));
if (BOARD_POWEROFF_COLD == status)
{
/* Flash power off */
board_flash_power_control(false);
/* Enter cold sleep mode */
mode = PM_SLEEP_COLD;
}
else
{
#ifdef CONFIG_BOARD_USB_DISABLE_IN_DEEP_SLEEPING
/* Disable USB detection to enter deep sleep with USB attached */
val = PMIC_SET_CHGOFF;
cxd56_pmic_write(PMIC_REG_CNT_USB2, &val, sizeof(val));
#endif
/* Enter deep sleep mode */
mode = PM_SLEEP_DEEP;
}
/* this function never returns */
up_pm_sleep(mode);
return 0;
}
#endif

View File

@ -0,0 +1,528 @@
/****************************************************************************
* configs/spresense/src/cxd56_sdcard.c
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* 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 of Sony Semiconductor Solutions Corporation 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 <nuttx/config.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/mmcsd.h>
#include <nuttx/sdio.h>
#include <nuttx/wqueue.h>
#include "chip.h"
#include "up_arch.h"
#include <arch/board/board.h>
#include <arch/chip/pin.h>
#include <arch/chip/pm.h>
#include "cxd56_gpio.h"
#include "cxd56_pinconfig.h"
#include "cxd56_sdhci.h"
#include "hardware/cxd5602_topreg.h"
#ifdef CONFIG_MMCSD_HAVE_CARDDETECT
# include "cxd56_gpioint.h"
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* TXS02612RTWR: SDIO port expander with voltage level translation */
#define SDCARD_TXS02612_SEL PIN_AP_CLK
/****************************************************************************
* Private Types
****************************************************************************/
struct cxd56_sdhci_state_s
{
struct sdio_dev_s *sdhci; /* R/W device handle */
bool initialized; /* TRUE: SDHCI block driver is initialized */
bool inserted; /* TRUE: card is inserted */
};
/****************************************************************************
* Private Data
****************************************************************************/
static struct cxd56_sdhci_state_s g_sdhci;
#ifdef CONFIG_MMCSD_HAVE_CARDDETECT
static struct work_s g_sdcard_work;
#endif
static struct pm_cpu_freqlock_s g_hv_lock =
PM_CPUFREQLOCK_INIT(PM_CPUFREQLOCK_TAG('S','D',0), PM_CPUFREQLOCK_FLAG_HV);
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: board_sdcard_enable
*
* Description:
* Enable SD Card on the board.
*
****************************************************************************/
static void board_sdcard_enable(FAR void *arg)
{
struct stat stat_sdio;
int ret = OK;
/* Acquire frequency lock */
up_pm_acquire_freqlock(&g_hv_lock);
if (!g_sdhci.initialized)
{
/* Mount the SDHC-based MMC/SD block driver
* This should be used with 3.3V
* First, get an instance of the SDHC interface
*/
finfo("Initializing SDHC slot 0\n");
g_sdhci.sdhci = cxd56_sdhci_initialize(0);
if (!g_sdhci.sdhci)
{
_err("ERROR: Failed to initialize SDHC slot 0\n");
goto release_frequency_lock;
}
/* If not initialize SD slot */
if (!stat("/dev/mmcsd0", &stat_sdio) == 0)
{
/* Now bind the SDHC interface to the MMC/SD driver */
finfo("Bind SDHC to the MMC/SD driver, minor=0\n");
ret = mmcsd_slotinitialize(0, g_sdhci.sdhci);
if (ret != OK)
{
_err("ERROR: Failed to bind SDHC to the MMC/SD driver: %d\n",
ret);
goto release_frequency_lock;
}
finfo("Successfully bound SDHC to the MMC/SD driver\n");
}
/* Handle the initial card state */
cxd56_sdhci_mediachange(g_sdhci.sdhci);
if (stat("/dev/mmcsd0", &stat_sdio) == 0)
{
if (S_ISBLK(stat_sdio.st_mode))
{
ret = mount("/dev/mmcsd0", "/mnt/sd0", "vfat", 0, NULL);
if (ret == 0)
{
finfo("Successfully mount a SDCARD via the MMC/SD driver\n");
}
else
{
_err("ERROR: Failed to mount the SDCARD. %d\n", errno);
}
}
}
g_sdhci.initialized = true;
}
release_frequency_lock:
/* Release frequency lock */
up_pm_release_freqlock(&g_hv_lock);
}
/****************************************************************************
* Name: board_sdcard_disable
*
* Description:
* Disable SD Card on the board.
*
****************************************************************************/
static void board_sdcard_disable(FAR void *arg)
{
int ret;
if (g_sdhci.initialized)
{
/* un-mount */
ret = umount("/mnt/sd0");
if (ret < 0)
{
ferr("ERROR: Failed to unmount the SD Card: %d\n", errno);
}
/* Report the new state to the SDIO driver */
cxd56_sdhci_mediachange(g_sdhci.sdhci);
cxd56_sdhci_finalize(0);
g_sdhci.initialized = false;
}
}
#ifdef CONFIG_MMCSD_HAVE_CARDDETECT
/****************************************************************************
* Name: board_sdcard_inserted
*
* Description:
* Check if a card is inserted into the selected SDHCI slot
*
****************************************************************************/
static bool board_sdcard_inserted(int slotno)
{
bool removed;
/* Get the state of the GPIO pin */
removed = cxd56_gpio_read(PIN_SDIO_CD);
finfo("Slot %d inserted: %s\n", slotno, removed ? "NO" : "YES");
return !removed;
}
/****************************************************************************
* Name: board_sdcard_detect_int
*
* Description:
* Card detect interrupt handler
*
* TODO: Any way to automatically moun/unmount filesystem based on card
* detect status? Yes... send a message or signal to an application.
*
****************************************************************************/
static int board_sdcard_detect_int(int irq, FAR void *context, FAR void *arg)
{
bool inserted;
/* Get the state of the GPIO pin */
inserted = board_sdcard_inserted(0);
/* Has the card detect state changed? */
if (inserted != g_sdhci.inserted)
{
/* Yes... remember that new state and inform the SDHCI driver */
g_sdhci.inserted = inserted;
if (inserted)
{
/* Card Detect = Present, Write Protect = disable */
putreg32(0, CXD56_TOPREG_IOFIX_APP);
}
else
{
/* Card Detect = Not present, Write Protect = disable */
putreg32(1, CXD56_TOPREG_IOFIX_APP);
}
/* Check context */
if (up_interrupt_context())
{
DEBUGASSERT(work_available(&g_sdcard_work));
if (inserted)
{
work_queue(HPWORK, &g_sdcard_work, board_sdcard_enable,
NULL, 0);
}
else
{
work_queue(HPWORK, &g_sdcard_work, board_sdcard_disable,
NULL, 0);
}
}
else
{
if (inserted)
{
board_sdcard_enable(NULL);
}
else
{
board_sdcard_disable(NULL);
}
}
/* Re-configure Interrupt pin */
cxd56_gpioint_config(PIN_SDIO_CD,
inserted ?
GPIOINT_PSEUDO_EDGE_RISE :
GPIOINT_PSEUDO_EDGE_FALL,
board_sdcard_detect_int);
}
return OK;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_sdcard_initialize
*
* Description:
* Initialize SD Card on the board.
*
****************************************************************************/
int board_sdcard_initialize(void)
{
int ret = OK;
cxd56_gpio_config(SDCARD_TXS02612_SEL, false);
#ifdef CONFIG_SDCARD_TXS02612_PORT0
/* Select port0 for SD-Card */
cxd56_gpio_write(SDCARD_TXS02612_SEL, false);
#else
/* Select port1 for SDIO other than SD-Card */
cxd56_gpio_write(SDCARD_TXS02612_SEL, true);
#endif
#ifdef CONFIG_MMCSD_HAVE_CARDDETECT
/* Initialize Card insert status */
g_sdhci.inserted = false;
/* Configure Interrupt pin with internal pull-up */
cxd56_pin_config(PINCONF_SDIO_CD_GPIO);
ret = cxd56_gpioint_config(PIN_SDIO_CD,
GPIOINT_PSEUDO_EDGE_FALL,
board_sdcard_detect_int);
if (ret < 0)
{
_err("ERROR: Failed to configure GPIO int. \n");
}
/* Enabling Interrupt */
cxd56_gpioint_enable(PIN_SDIO_CD);
#else
/* Initialize Card insert status */
g_sdhci.inserted = true;
/* Enable SDC */
board_sdcard_enable(NULL);
#endif
return ret;
}
/****************************************************************************
* Name: board_sdcard_finalize
*
* Description:
* Finalize SD Card on the board.
*
****************************************************************************/
int board_sdcard_finalize(void)
{
int ret = OK;
/* At first, Disable interrupt of the card detection */
if (g_sdhci.inserted)
{
board_sdcard_disable(NULL);
}
g_sdhci.inserted = false;
#ifdef CONFIG_MMCSD_HAVE_CARDDETECT
/* Disabling Interrupt */
cxd56_gpioint_disable(PIN_SDIO_CD);
#endif
/* Disable SDIO pin configuration */
CXD56_PIN_CONFIGS(PINCONFS_SDIOA_GPIO);
/* Set GPIO pin to initial state */
cxd56_gpio_write(PIN_SDIO_CLK, false);
cxd56_gpio_write(PIN_SDIO_CMD, false);
cxd56_gpio_write(PIN_SDIO_DATA0, false);
cxd56_gpio_write(PIN_SDIO_DATA1, false);
cxd56_gpio_write(PIN_SDIO_DATA2, false);
cxd56_gpio_write(PIN_SDIO_DATA3, false);
cxd56_gpio_write_hiz(SDCARD_TXS02612_SEL);
return ret;
}
/****************************************************************************
* Name: board_sdcard_pin_initialize
*
* Description:
* Initialize SD Card pins on the board.
*
****************************************************************************/
void board_sdcard_pin_initialize(void)
{
}
/****************************************************************************
* Name: board_sdcard_pin_finalize
*
* Description:
* Finalize SD Card pins on the board.
*
****************************************************************************/
void board_sdcard_pin_finalize(void)
{
}
/****************************************************************************
* Name: board_sdcard_pin_configuraton
*
* Description:
* Configure SD Card pins on the board.
* This is called when SDHCI is used.
*
****************************************************************************/
void board_sdcard_pin_configuraton(void)
{
/* SDIO configuration */
modifyreg32(CXD56_SDHCI_USERDEF1CTL, SDHCI_UDEF1_SDCLKI_SEL,
SDHCI_UDEF1_SDCLKI_SEL_INT);
modifyreg32(CXD56_SDHCI_USERDEF2CTL, SDHCI_UDEF2_CMD_SEL,
SDHCI_UDEF2_CMD_SEL_INT);
/* Disable GPIO output */
cxd56_gpio_write_hiz(PIN_SDIO_CLK);
cxd56_gpio_write_hiz(PIN_SDIO_CMD);
cxd56_gpio_write_hiz(PIN_SDIO_DATA0);
cxd56_gpio_write_hiz(PIN_SDIO_DATA1);
cxd56_gpio_write_hiz(PIN_SDIO_DATA2);
cxd56_gpio_write_hiz(PIN_SDIO_DATA3);
/* SDIO pin configuration */
CXD56_PIN_CONFIGS(PINCONFS_SDIOA_SDIO);
}
/****************************************************************************
* Name: board_sdcard_pin_enable
*
* Description:
* Enable SD Card on the board.
*
****************************************************************************/
void board_sdcard_pin_enable(void)
{
}
/****************************************************************************
* Name: board_sdcard_pin_disable
*
* Description:
* Disable SD Card pins on the board.
*
****************************************************************************/
void board_sdcard_pin_disable(void)
{
}
/****************************************************************************
* Name: board_sdcard_set_high_voltage
*
* Description:
* Set SD Card IO voltage to 3.3V
*
****************************************************************************/
void board_sdcard_set_high_voltage(void)
{
}
/****************************************************************************
* Name: board_sdcard_set_low_voltage
*
* Description:
* Set SD Card IO voltage to 1.8V
*
****************************************************************************/
void board_sdcard_set_low_voltage(void)
{
}

View File

@ -0,0 +1,76 @@
/****************************************************************************
* configs/spresense/src/cxd56_usbmsc.c
*
* Copyright (C) 2009, 2011, 2013, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* 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 <nuttx/config.h>
#include <stdio.h>
#include <syslog.h>
#include <errno.h>
#include <nuttx/board.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_usbmsc_initialize
*
* Description:
* Perform architecture specific initialization as needed to establish
* the mass storage device that will be exported by the USB MSC device.
*
****************************************************************************/
int board_usbmsc_initialize(int port)
{
/* If system/usbmsc is built as an NSH command, then SD slot should
* already have been initialized in board_app_initialize() (see stm32_appinit.c).
* In this case, there is nothing further to be done here.
*/
return OK;
}

View File

@ -0,0 +1,67 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set
# CONFIG_MMCSD_SPI is not set
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="spresense"
CONFIG_ARCH_BOARD_SPRESENSE=y
CONFIG_ARCH_CHIP_CXD56XX=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_USEBASEPRI=y
CONFIG_BOARD_LOOPSPERMSEC=5434
CONFIG_BOOT_RUNFROMISRAM=y
CONFIG_BUILTIN=y
CONFIG_CLOCK_MONOTONIC=y
CONFIG_CXD56_SDIO=y
CONFIG_CXD56_USBDEV=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FAT_MAXFNAME=64
CONFIG_FS_FAT=y
CONFIG_FS_PROCFS=y
CONFIG_FS_PROCFS_REGISTER=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_I2C=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MMCSD=y
CONFIG_MMCSD_SDIO=y
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_PREALLOC_TIMERS=4
CONFIG_PREALLOC_WDOGS=16
CONFIG_RAM_SIZE=1572864
CONFIG_RAM_START=0x0d000000
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_SPI=y
CONFIG_START_DAY=6
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_SYSTEM_CLE=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_NSH_CXXINITIALIZE=y
CONFIG_SYSTEM_USBMSC=y
CONFIG_UART1_SERIAL_CONSOLE=y
CONFIG_USBDEV=y
CONFIG_USBDEV_DMA=y
CONFIG_USBDEV_DUALSPEED=y
CONFIG_USBMSC=y
CONFIG_USBMSC_EPBULKIN=1
CONFIG_USBMSC_REMOVABLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"