Merged in alinjerpelea/nuttx (pull request #907)

arch: arm: cxd56xx: add UID support

* arch: arm: cxd56xx: add UID support

    Add support to be able to read the HW UID

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

* configs: spresense: enable USERLEDS

    add USERLED 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-06-17 22:02:19 +00:00 committed by Gregory Nutt
parent 0e8863cc61
commit f50080b251
7 changed files with 250 additions and 1 deletions

View File

@ -86,6 +86,7 @@ endif
CHIP_ASRCS += cxd56_farapistub.S
CHIP_CSRCS = cxd56_allocateheap.c cxd56_idle.c
CHIP_CSRCS += cxd56_uid.c
CHIP_CSRCS += cxd56_serial.c cxd56_uart.c cxd56_irq.c
CHIP_CSRCS += cxd56_start.c
CHIP_CSRCS += cxd56_timerisr.c

View File

@ -0,0 +1,61 @@
/****************************************************************************
* arch/arm/src/cxd56xx/cxd56_uid.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 "chip.h"
#include "up_arch.h"
#include "cxd56_uid.h"
#include "hardware/cxd5602_topreg.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void cxd56_get_uniqueid(uint8_t uniqueid[])
{
uint32_t cuid0 = getreg32(CXD56_TOPREG_CUID0);
uint32_t cuid1 = getreg32(CXD56_TOPREG_CUID1);
uniqueid[0] = (uint8_t)((cuid1 >> 0) & 0xff);
uniqueid[1] = (uint8_t)((cuid0 >> 24) & 0xff);
uniqueid[2] = (uint8_t)((cuid0 >> 16) & 0xff);
uniqueid[3] = (uint8_t)((cuid0 >> 8) & 0xff);
uniqueid[4] = (uint8_t)((cuid0 >> 0) & 0xff);
}

View File

@ -0,0 +1,53 @@
/****************************************************************************
* arch/arm/src/cxd56xx/cxd56_uid.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 __ARCH_ARM_SRC_CXD56XX_CXD56_UID_H
#define __ARCH_ARM_SRC_CXD56XX_CXD56_UID_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
/****************************************************************************
* Public Functions
****************************************************************************/
void cxd56_get_uniqueid(uint8_t uniqueid[]);
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_UID_H */

View File

@ -119,12 +119,16 @@
#define BOARD_LED1 (0)
#define BOARD_LED2 (1)
#define BOARD_NLEDS (2)
#define BOARD_LED3 (2)
#define BOARD_LED4 (3)
#define BOARD_NLEDS (4)
/* LED bits for use with board_userled_all() */
#define BOARD_LED1_BIT (1 << BOARD_LED1)
#define BOARD_LED2_BIT (1 << BOARD_LED2)
#define BOARD_LED3_BIT (1 << BOARD_LED3)
#define BOARD_LED4_BIT (1 << BOARD_LED4)
/* LED pattern for use with board_autoled_on() and board_autoled_off()
* ON OFF

View File

@ -58,6 +58,10 @@ endif
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += cxd56_leds.c
else
ifeq ($(CONFIG_USERLED),y)
CSRCS += cxd56_userleds.c
endif
endif
ifeq ($(CONFIG_CXD56_PWM),y)

View File

@ -268,6 +268,14 @@ int cxd56_bringup(void)
}
#endif
#ifdef CONFIG_USERLED_LOWER
ret = userled_lower_initialize("/dev/userleds");
if (ret < 0)
{
_err("ERROR: Failed to initialze led. \n");
}
#endif
#ifdef CONFIG_CXD56_SFC
ret = board_flash_initialize();
if (ret < 0)

View File

@ -0,0 +1,118 @@
/****************************************************************************
* configs/spresense/src/cxd56_userleds.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 <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <arch/board/board.h>
#ifdef CONFIG_USERLED_LOWER
#include <nuttx/leds/userled.h>
#endif
#include "cxd56_gpio.h"
#include "cxd56_pinconfig.h"
#ifndef CONFIG_ARCH_LEDS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Check if the following are defined in the board.h */
#ifndef BOARD_LED1_BIT
#error "BOARD_LED1_BIT must be defined in board.h !!"
#endif
#ifndef BOARD_LED2_BIT
#error "BOARD_LED2_BIT must be defined in board.h !!"
#endif
#ifndef BOARD_LED3_BIT
#error "BOARD_LED3_BIT must be defined in board.h !!"
#endif
#ifndef BOARD_LED4_BIT
#error "BOARD_LED4_BIT must be defined in board.h !!"
#endif
#define GPIO_LED1 (PIN_I2S1_BCK)
#define GPIO_LED2 (PIN_I2S1_LRCK)
#define GPIO_LED3 (PIN_I2S1_DATA_IN)
#define GPIO_LED4 (PIN_I2S1_DATA_OUT)
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_userled_initialize
****************************************************************************/
void board_userled_initialize(void)
{
cxd56_gpio_write(GPIO_LED1, false);
cxd56_gpio_write(GPIO_LED2, false);
cxd56_gpio_write(GPIO_LED3, false);
cxd56_gpio_write(GPIO_LED4, false);
}
/****************************************************************************
* Name: board_userled
****************************************************************************/
void board_userled(int led, bool ledon)
{
board_gpio_write(ledcfg, ledon);
}
/****************************************************************************
* Name: board_userled_all
****************************************************************************/
void board_userled_all(uint8_t ledset)
{
cxd56_gpio_write(GPIO_LED1, (ledset & BOARD_LED1_BIT) != 0);
cxd56_gpio_write(GPIO_LED2, (ledset & BOARD_LED2_BIT) != 0);
cxd56_gpio_write(GPIO_LED3, (ledset & BOARD_LED3_BIT) != 0);
cxd56_gpio_write(GPIO_LED4, (ledset & BOARD_LED4_BIT) != 0);
}
#endif /* !CONFIG_ARCH_LEDS */