Merged in masayuki2009/nuttx.nuttx/spresense_with_gs2200m (pull request #910)

configs/spresense: Add support for Tilt GS2200M Wi-Fi module

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
Masayuki Ishikawa 2019-06-18 21:21:19 +00:00 committed by Gregory Nutt
parent 4bfa6fe511
commit 3e29e9306f
6 changed files with 443 additions and 0 deletions

View File

@ -48,6 +48,7 @@
#include "cxd56_clock.h"
#include "cxd56_power.h"
#include "cxd56_flash.h"
#include "cxd56_gs2200m.h"
#include "cxd56_sdcard.h"
#include "cxd56_wdt.h"

View File

@ -0,0 +1,87 @@
/****************************************************************************
* configs/spresense/include/cxd56_gs2200m.h
*
* Copyright 2019 Sony Home Entertainment & Sound Products Inc.
* Author: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
*
* 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 __CONFIGS_SPRESENSE_INCLUDE_CXD56_GS2200M_H
#define __CONFIGS_SPRESENSE_INCLUDE_CXD56_GS2200M_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_gs2200m_initialize
*
* Description:
* Initialize Tilt GS2200M board
*
****************************************************************************/
int board_gs2200m_initialize(FAR const char *devpath, int bus);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_SPRESENSE_INCLUDE_CXD56_GS2200M_H */

View File

@ -88,4 +88,8 @@ ifeq ($(CONFIG_NETDEVICES),y)
CSRCS += cxd56_netinit.c
endif
ifeq ($(CONFIG_WL_GS2200M),y)
CSRCS += cxd56_gs2200m.c
endif
include $(TOPDIR)/configs/Board.mk

View File

@ -338,5 +338,13 @@ int cxd56_bringup(void)
usbdev_rndis_initialize(mac);
#endif
#ifdef CONFIG_WL_GS2200M
ret = board_gs2200m_initialize("/dev/gs2200m", 5);
if (ret < 0)
{
_err("ERROR: Failed to initialze GS2200M. \n");
}
#endif
return 0;
}

View File

@ -0,0 +1,248 @@
/****************************************************************************
* configs/spresense/src/cxd56_gs2200m.c
*
* Copyright 2019 Sony Home Entertainment & Sound Products Inc.
* Author: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
*
* 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 <debug.h>
#include <nuttx/arch.h>
#include <nuttx/config.h>
#include <nuttx/board.h>
#include <nuttx/spi/spi.h>
#include <nuttx/irq.h>
#include <nuttx/wireless/gs2200m.h>
#include <arch/chip/pin.h>
#include "cxd56_pinconfig.h"
#include "cxd56_spi.h"
#include "cxd56_gpio.h"
#include "cxd56_gpioint.h"
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int gs2200m_irq_attach(xcpt_t, FAR void *);
static void gs2200m_irq_enable(void);
static void gs2200m_irq_disable(void);
static uint32_t gs2200m_dready(int *);
/****************************************************************************
* Private Data
****************************************************************************/
static const struct gs2200m_lower_s g_wifi_lower =
{
.attach = gs2200m_irq_attach,
.enable = gs2200m_irq_enable,
.disable = gs2200m_irq_disable,
.dready = gs2200m_dready,
};
static FAR void *g_devhandle = NULL;
static volatile int32_t _enable_count = 0;
static volatile uint32_t _n_called;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: gs2200m_irq_attach
****************************************************************************/
static int gs2200m_irq_attach(xcpt_t handler, FAR void *arg)
{
(void)cxd56_gpioint_config(PIN_UART2_CTS,
GPIOINT_LEVEL_HIGH,
handler,
arg);
return 0;
}
/****************************************************************************
* Name: gs2200m_irq_enable
****************************************************************************/
static void gs2200m_irq_enable(void)
{
irqstate_t flags = spin_lock_irqsave();
wlinfo("== ec:%d called=%d \n", _enable_count, _n_called++);
if (1 == _enable_count)
{
/* NOTE: This would happen if we received an event */
return;
}
_enable_count++;
if (1 == _enable_count)
{
cxd56_gpioint_enable(PIN_UART2_CTS);
}
spin_unlock_irqrestore(flags);
}
/****************************************************************************
* Name: gs2200m_irq_disable
****************************************************************************/
static void gs2200m_irq_disable(void)
{
irqstate_t flags = spin_lock_irqsave();
wlinfo("== ec:%d called=%d \n", _enable_count, _n_called++);
_enable_count--;
if (0 == _enable_count)
{
cxd56_gpioint_disable(PIN_UART2_CTS);
}
spin_unlock_irqrestore(flags);
}
/****************************************************************************
* Name: gs2200m_disable
****************************************************************************/
static uint32_t gs2200m_dready(int *ec)
{
irqstate_t flags = spin_lock_irqsave();
uint32_t r = cxd56_gpio_read(PIN_UART2_CTS);
if (ec)
{
/* Copy enable count (just for debug) */
*ec = _enable_count;
}
spin_unlock_irqrestore(flags);
return r;
}
/****************************************************************************
* Name: spi_pincontrol
*
* Description:
* Configure the SPI pin
*
* Input Parameter:
* on - true: enable pin, false: disable pin
****************************************************************************/
static void spi_pincontrol(int bus, bool on)
{
if (bus == 5)
{
#ifdef CONFIG_CXD56_SPI5_PINMAP_EMMC
if (on)
{
CXD56_PIN_CONFIGS(PINCONFS_EMMCA_SPI5);
}
else
{
CXD56_PIN_CONFIGS(PINCONFS_EMMCA_GPIO);
}
#endif
#ifdef CONFIG_CXD56_SPI5_PINMAP_SDIO
if (on)
{
CXD56_PIN_CONFIGS(PINCONFS_SDIOA_SPI5);
}
else
{
CXD56_PIN_CONFIGS(PINCONFS_SDIOA_GPIO);
}
#endif
}
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_gs2200m_initialize
****************************************************************************/
int board_gs2200m_initialize(FAR const char *devpath, int bus)
{
FAR struct spi_dev_s *spi;
wlinfo("Initializing GS2200M..\n");
if (!g_devhandle)
{
/* Change UART2 to GPIO */
CXD56_PIN_CONFIGS(PINCONFS_UART2_GPIO);
(void)cxd56_gpio_config(PIN_UART2_CTS, true);
/* Initialize spi deivce */
spi = cxd56_spibus_initialize(bus);
if (!spi)
{
wlerr("ERROR: Failed to initialize spi%d.\n", bus);
return -ENODEV;
}
/* Enable SPI5 */
spi_pincontrol(5, true);
g_devhandle = gs2200m_register(devpath, spi, &g_wifi_lower);
if (!g_devhandle)
{
wlerr("ERROR: Failed to register gs2200m driver.\n");
return -ENODEV;
}
}
return OK;
}

View File

@ -0,0 +1,95 @@
#
# 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_BOARDCTL_RESET=y
CONFIG_BOARD_LOOPSPERMSEC=5434
CONFIG_BOOT_RUNFROMISRAM=y
CONFIG_BUILTIN=y
CONFIG_CLOCK_MONOTONIC=y
CONFIG_CODECS_HASH_MD5=y
CONFIG_CXD56_SDIO=y
CONFIG_CXD56_SPI5=y
CONFIG_CXD56_SPI=y
CONFIG_CXD56_USBDEV=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DRIVERS_WIRELESS=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_EXAMPLES_WEBSERVER=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_WDOGPARMS=2
CONFIG_MMCSD=y
CONFIG_MMCSD_SDIO=y
CONFIG_NET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDEVICES=y
CONFIG_NETINIT_NETLOCAL=y
CONFIG_NETUTILS_CODECS=y
CONFIG_NETUTILS_FTPC=y
CONFIG_NETUTILS_TELNETD=y
CONFIG_NETUTILS_WEBCLIENT=y
CONFIG_NETUTILS_WEBSERVER=y
CONFIG_NET_ICMP=y
CONFIG_NET_LOCAL=y
CONFIG_NET_TCP_NO_STACK=y
CONFIG_NET_UDP_NO_STACK=y
CONFIG_NET_USRSOCK=y
CONFIG_NET_USRSOCK_CONNS=16
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_DISABLE_ARP=y
CONFIG_NSH_DISABLE_IFUPDOWN=y
CONFIG_NSH_DISABLE_NSLOOKUP=y
CONFIG_NSH_READLINE=y
CONFIG_NSH_WGET_USERAGENT="NuttX/7.2x.x (; http://www.nuttx.org/)"
CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_PREALLOC_TIMERS=4
CONFIG_PREALLOC_WDOGS=16
CONFIG_RAM_SIZE=1572864
CONFIG_RAM_START=0x0d000000
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_LPWORKPRIORITY=30
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_STACK_COLORATION=y
CONFIG_START_DAY=6
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_SYSTEM_GS2200M=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"
CONFIG_WL_GS2200M=y