Merged in alinjerpelea/nuttx (pull request #1031)

boards: spresense: add isx012 camera initialization and config

* boards: spresense: add isx012 camera initialization

    Add the initialization for the isx012 camera sensor.

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

* boards: spresense: add camera defconfig

    For easy configuration add camera defconfig for 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-09-17 16:58:09 +00:00 committed by Gregory Nutt
parent ebc6f51641
commit b55c518a1a
5 changed files with 510 additions and 0 deletions

View File

@ -138,6 +138,10 @@ ifeq ($(CONFIG_CXD56_I2C_DRIVER),y)
CSRCS += cxd56_i2cdev.c
endif
ifeq ($(CONFIG_VIDEO_ISX012),y)
CSRCS += cxd56_isx012.c
endif
DEPPATH += --dep-path src
VPATH += :src
CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)

View File

@ -0,0 +1,252 @@
/****************************************************************************
* boards/arm/cxd56xx/common/src/cxd56_isx012.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 <stdio.h>
#include <debug.h>
#include <errno.h>
#include "cxd56_gpio.h"
#include "cxd56_pinconfig.h"
#include "cxd56_i2c.h"
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Check if the following are defined in the board.h */
#ifndef IMAGER_RST
# error "IMAGER_RST must be defined in board.h !!"
#endif
#ifndef IMAGER_SLEEP
# error "IMAGER_SLEEP must be defined in board.h !!"
#endif
#define STANDBY_TIME (600*1000) /* TODO: (max100ms/30fps)*/
#define DEVICE_STARTUP_TIME (6*1000) /* ms */
#define SLEEP_CANCEL_TIME (13*1000) /* ms */
#define POWER_CHECK_TIME (1*1000) /* ms */
#define ALL_POWERON (7)
#define ALL_POWEROFF (0)
#define POWER_CHECK_RETRY (10)
/****************************************************************************
* Private Data
****************************************************************************/
FAR struct i2c_master_s *i2c;
/****************************************************************************
* Public Functions
****************************************************************************/
int board_isx012_power_on(void)
{
int ret;
uint32_t stat;
int i;
/* 'POWER_IMAGE_SENSOR==PMIC_GPO(4/5/7)' */
ret = board_power_control(POWER_IMAGE_SENSOR, true);
if (ret)
{
_err("ERROR: Failed to power on ImageSensor. %d\n", ret);
return -ENODEV;
}
ret = -ETIMEDOUT;
for (i = 0; i < POWER_CHECK_RETRY; i++)
{
stat = 0;
stat |= (uint32_t)board_power_monitor(PMIC_GPO(4)) << 0;
stat |= (uint32_t)board_power_monitor(PMIC_GPO(5)) << 1;
stat |= (uint32_t)board_power_monitor(PMIC_GPO(7)) << 2;
if (stat == ALL_POWERON)
{
ret = OK;
break;
}
usleep(POWER_CHECK_TIME);
}
return ret;
}
int board_isx012_power_off(void)
{
int ret;
uint32_t stat;
int i;
/* POWER_IMAGE_SENSOR==PMIC_GPO(4/5/7) */
ret = board_power_control(POWER_IMAGE_SENSOR, false);
if (ret)
{
_err("ERROR: Failed to power off ImageSensor. %d\n", ret);
return -ENODEV;
}
ret = -ETIMEDOUT;
for (i = 0; i < POWER_CHECK_RETRY; i++)
{
stat = 0;
stat |= (uint32_t)board_power_monitor(PMIC_GPO(4)) << 0;
stat |= (uint32_t)board_power_monitor(PMIC_GPO(5)) << 1;
stat |= (uint32_t)board_power_monitor(PMIC_GPO(7)) << 2;
if (stat == ALL_POWEROFF)
{
ret = OK;
break;
}
usleep(POWER_CHECK_TIME);
}
return ret;
}
void board_isx012_set_reset(void)
{
cxd56_gpio_write(IMAGER_RST, false);
}
void board_isx012_release_reset(void)
{
cxd56_gpio_write(IMAGER_RST, true);
}
void board_isx012_set_sleep(int kind)
{
cxd56_gpio_write(IMAGER_SLEEP, false);
if (kind == 0)
{
/* PowerON -> sleep */
usleep(DEVICE_STARTUP_TIME);
}
else
{
/* active -> sleep */
usleep(STANDBY_TIME);
}
}
void board_isx012_release_sleep(void)
{
cxd56_gpio_write(IMAGER_SLEEP, true);
usleep(SLEEP_CANCEL_TIME);
}
int isx012_register(FAR struct i2c_master_s *i2c);
int isx012_unregister(void);
int board_isx012_initialize(int i2c_bus_num)
{
int ret;
_info("Initializing ISX012...\n");
#ifdef IMAGER_ALERT
cxd56_gpio_config(IMAGER_ALERT, true);
#endif
cxd56_gpio_config(IMAGER_SLEEP, false);
cxd56_gpio_config(IMAGER_RST, false);
board_isx012_set_reset();
cxd56_gpio_write(IMAGER_SLEEP, false);
CXD56_PIN_CONFIGS(PINCONFS_IS);
/* Initialize i2c deivce */
i2c = cxd56_i2cbus_initialize(i2c_bus_num);
if (!i2c)
{
return -ENODEV;
}
ret = isx012_register(i2c);
if (ret < 0)
{
_err("Error registering ISX012.\n");
}
return ret;
}
int board_isx012_uninitialize(void)
{
int ret;
_info("Uninitializing ISX012...\n");
/* Initialize i2c deivce */
ret = isx012_unregister();
if (ret < 0)
{
_err("Error unregistering ISX012.\n");
}
if (!i2c)
{
_err("Error uninitialize ISX012.\n");
return -ENODEV;
}
else
{
ret = cxd56_i2cbus_uninitialize(i2c);
if (ret < 0)
{
_err("Error uninitialize I2C BUS.\n");
return -EPERM;
}
}
return ret;
}

View File

@ -0,0 +1,91 @@
#
# 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_CXD56_I2C0_SCUSEQ is not set
# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set
# CONFIG_MMCSD_SPI is not set
# CONFIG_MTD_SMART_WEAR_LEVEL 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"
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_BINARY=y
CONFIG_CXD56_CISIF=y
CONFIG_CXD56_I2C0=y
CONFIG_CXD56_I2C2=y
CONFIG_CXD56_I2C=y
CONFIG_CXD56_SDIO=y
CONFIG_CXD56_SPI4=y
CONFIG_CXD56_SPI5=y
CONFIG_CXD56_SPI=y
CONFIG_CXD56_USBDEV=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DRIVERS_VIDEO=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_FS_SMARTFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MMCSD=y
CONFIG_MMCSD_SDIO=y
CONFIG_MTD_BYTE_WRITE=y
CONFIG_MTD_PARTITION=y
CONFIG_MTD_SMART=y
CONFIG_MTD_SMART_ENABLE_CRC=y
CONFIG_MTD_SMART_SECTOR_SIZE=4096
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_READLINE_CMD_HISTORY=y
CONFIG_RR_INTERVAL=200
CONFIG_RTC=y
CONFIG_RTC_DRIVER=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_SMARTFS_ALIGNED_ACCESS=y
CONFIG_SMARTFS_MAXNAMLEN=30
CONFIG_SMARTFS_MULTI_ROOT_DIRS=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="spresense_main"
CONFIG_VIDEO_ISX012=y
CONFIG_VIDEO_STREAM=y

View File

@ -70,6 +70,8 @@
#include "cxd56_rpr0521rs.h"
#include "cxd56_sensors.h"
#include "cxd56_isx012.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -257,6 +259,13 @@ enum board_power_device
#define SENSOR_I2C 0
#define SENSOR_SPI 3
/* Imager device pin definitions *******************************************/
#define IMAGER_RST PIN_SDIO_DIR1_3
#define IMAGER_SLEEP PIN_SDIO_DIR0
#define IMAGER_I2C 2
/* Set signal id for notify USB device connection status and
* supply current value.
* signal returns "usbdev_notify_s" struct pointer in sival_ptr.

View File

@ -0,0 +1,154 @@
/****************************************************************************
* boards/arm/cxd56xx/spresense/include/cxd56_isx012.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 __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_ISX012_H
#define __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_ISX012_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_isx012_power_on
*
* Description:
* Power on ISX012
*
****************************************************************************/
int board_isx012_power_on(void);
/****************************************************************************
* Name: board_isx012_power_off
*
* Description:
* Power off ISX012
*
****************************************************************************/
int board_isx012_power_off(void);
/****************************************************************************
* Name: board_isx012_set_reset
*
* Description:
* Set reset ISX012
*
****************************************************************************/
void board_isx012_set_reset(void);
/****************************************************************************
* Name: board_isx012_release_reset
*
* Description:
* Release reset ISX012
*
****************************************************************************/
void board_isx012_release_reset(void);
/****************************************************************************
* Name: board_isx012_set_sleep
*
* Description:
* Set sleep ISX012
*
****************************************************************************/
void board_isx012_set_sleep(int kind);
/****************************************************************************
* Name: board_isx012_release_sleep
*
* Description:
* Release sleep ISX012
*
****************************************************************************/
void board_isx012_release_sleep(void);
/****************************************************************************
* Name: board_isx012_initialize
*
* Description:
* Initialize ISX012 i2c driver and register the ISX012 device.
*
****************************************************************************/
int board_isx012_initialize(int i2c_bus_num);
/****************************************************************************
* Name: board_isx012_uninitialize
*
* Description:
* Uninitialize ISX012 i2c driver and register the ISX012 device.
*
****************************************************************************/
int board_isx012_uninitialize(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_ISX012_H */