TMS570: Add ESM initialization logic

This commit is contained in:
Gregory Nutt 2015-12-27 07:54:43 -06:00
parent 6d0650349a
commit e1b1f80237
5 changed files with 235 additions and 4 deletions

View File

@ -104,8 +104,8 @@ CHIP_ASRCS =
# SAMA5-specific C source files
CHIP_CSRCS = tms570_boot.c tms570_clockconfig.c tms570_gio.c tms570_irq.c
CHIP_CSRCS += tms570_lowputc.c tms570_serial.c
CHIP_CSRCS = tms570_boot.c tms570_clockconfig.c tms570_esm.c tms570_gio.c
CHIP_CSRCS += tms570_irq.c tms570_lowputc.c tms570_serial.c
# Configuration dependent C and assembly language files

View File

@ -65,7 +65,7 @@
#define TMS570_ESM_IECR1_OFFSET 0x000c /* ESM Interrupt Enable Clear/Status Register 1 */
#define TMS570_ESM_ILSR1_OFFSET 0x0010 /* Interrupt Level Set/Status Register 1 */
#define TMS570_ESM_ILCR1_OFFSET 0x0014 /* Interrupt Level Clear/Status Register 1 */
#define TMS570_ESM_SR_OFFSET(n) (0x0018 + ((n) << 2)) /* n=0, 1, 2 */
#define TMS570_ESM_SRA_OFFSET(n) (0x0018 + ((n) << 2)) /* n=0, 1, 2 */
# define TMS570_ESM_SR1_OFFSET 0x0018 /* ESM Status Register for group 1 */
# define TMS570_ESM_SR2_OFFSET 0x001c /* ESM Status Register for group 2 */
# define TMS570_ESM_SR3_OFFSET 0x0020 /* ESM Status Register for group 3 */
@ -83,6 +83,11 @@
#define TMS570_ESM_ILSR4_OFFSET 0x0050 /* Interrupt Level Set/Status Register 4 */
#define TMS570_ESM_ILCR4_OFFSET 0x0054 /* Interrupt Level Clear/Status Register 4 */
#define TMS570_ESM_SR4_OFFSET 0x0058 /* ESM Status Register 4 */
#define TMS570_ESM_SRB_OFFSET(n) (0x0058 + (((n)-4) << 2)) /* n=4, 5, 6 */
# define TMS570_ESM_SR4_OFFSET 0x0058 /* ESM Status Register for group 4 */
# define TMS570_ESM_SR5_OFFSET 0x005c /* ESM Status Register for group 5 */
# define TMS570_ESM_SR6_OFFSET 0x0060 /* ESM Status Register for group 6 */
#define TMS570_ESM_SSR5_OFFSET 0x0064 /* ESM Status Shadow Register 5 */
/* Register Addresses *******************************************************************************/
@ -92,7 +97,7 @@
#define TMS570_ESM_IECR1 (TMS570_ESM_BASE+TMS570_ESM_IECR1_OFFSET)
#define TMS570_ESM_ILSR1 (TMS570_ESM_BASE+TMS570_ESM_ILSR1_OFFSET)
#define TMS570_ESM_ILCR1 (TMS570_ESM_BASE+TMS570_ESM_ILCR1_OFFSET)
#define TMS570_ESM_SR(n) (TMS570_ESM_BASE+TMS570_ESM_SR_OFFSET(n))
#define TMS570_ESM_SRA(n) (TMS570_ESM_BASE+TMS570_ESM_SRA_OFFSET(n))
# define TMS570_ESM_SR1 (TMS570_ESM_BASE+TMS570_ESM_SR1_OFFSET)
# define TMS570_ESM_SR2 (TMS570_ESM_BASE+TMS570_ESM_SR2_OFFSET)
# define TMS570_ESM_SR3 (TMS570_ESM_BASE+TMS570_ESM_SR3_OFFSET)
@ -110,6 +115,11 @@
#define TMS570_ESM_ILSR4 (TMS570_ESM_BASE+TMS570_ESM_ILSR4_OFFSET)
#define TMS570_ESM_ILCR4 (TMS570_ESM_BASE+TMS570_ESM_ILCR4_OFFSET)
#define TMS570_ESM_SR4 (TMS570_ESM_BASE+TMS570_ESM_SR4_OFFSET)
#define TMS570_ESM_SRB(n) (TMS570_ESM_BASE+TMS570_ESM_SRB_OFFSET(n))
# define TMS570_ESM_SR4 (TMS570_ESM_BASE+TMS570_ESM_SR4_OFFSET)
# define TMS570_ESM_SR5 (TMS570_ESM_BASE+TMS570_ESM_SR5_OFFSET)
# define TMS570_ESM_SR6 (TMS570_ESM_BASE+TMS570_ESM_SR6_OFFSET)
#define TMS570_ESM_SSR5 (TMS570_ESM_BASE+TMS570_ESM_SSR5_OFFSET)
/* Register Bit-Field Definitions *******************************************************************/

View File

@ -66,6 +66,7 @@
#include "tms570_clockconfig.h"
#include "tms570_selftest.h"
#include "tms570_gio.h"
#include "tms570_esm.h"
#include "tms570_boot.h"
/****************************************************************************
@ -310,6 +311,10 @@ void arm_boot(void)
#endif
);
/* Configure system response to error conditions */
tms570_esm_initialize();
#ifdef CONFIG_ARCH_FPU
/* Initialize the FPU */

View File

@ -0,0 +1,136 @@
/****************************************************************************
* arch/arm/src/tms570/tms570_esm.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Derives from the TI "Project0" sample code which has a compatible 3-
* clause BSD license:
*
* Copyright (c) 2012, Texas Instruments Incorporated
* All rights reserved.
*
* 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, Texas Instruments Incorporated, 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 "up_arch.h"
#include "chip/tms570_esm.h"
#include "tms570_esm.h"
#include <arch/board/board.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: tms570_esm_initialize
*
* Description:
* Initialize the ESM.
*
****************************************************************************/
int tms570_esm_initialize(void)
{
uint32_t regval;
/* Disable error pin channels */
putreg32(0xffffffff, TMS570_ESM_DEPAPR1);
putreg32(0xffffffff, TMS570_ESM_IEPCR4);
/* Disable interrupts */
putreg32(0xffffffff, TMS570_ESM_IECR1);
putreg32(0xffffffff, TMS570_ESM_IECR4);
/* Clear error status flags */
putreg32(0xffffffff, TMS570_ESM_SR1);
putreg32(0xffffffff, TMS570_ESM_SR2);
putreg32(0xffffffff, TMS570_ESM_SSR2);
putreg32(0xffffffff, TMS570_ESM_SR3);
putreg32(0xffffffff, TMS570_ESM_SR4);
putreg32(0xffffffff, TMS570_ESM_SR5);
putreg32(0xffffffff, TMS570_ESM_SSR5);
putreg32(0xffffffff, TMS570_ESM_SR6);
/* Setup LPC preload */
putreg32(16384 - 1, TMS570_ESM_LTCPR);
/* Reset error pin */
regval = getreg32(TMS570_ESM_EPSR);
if (regval == 0)
{
putreg32(5, TMS570_ESM_EKR);
}
else
{
putreg32(0, TMS570_ESM_EKR);
}
/* Clear interrupt level */
putreg32(0xffffffff, TMS570_ESM_ILCR1);
putreg32(0xffffffff, TMS570_ESM_ILCR4);
/* Set interrupt level */
putreg32(0, TMS570_ESM_ILSR1);
putreg32(0, TMS570_ESM_ILSR4);
/* Enable error pin channels */
putreg32(0, TMS570_ESM_EEPAPR1);
putreg32(0, TMS570_ESM_IEPSR4);
/* Enable interrupts */
putreg32(0, TMS570_ESM_IESR1);
putreg32(0, TMS570_ESM_IESR4);
return OK;
}

View File

@ -0,0 +1,80 @@
/****************************************************************************
* arch/arm/src/tms570/tms570_esm.h
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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.
*
****************************************************************************/
#ifndef __ARCH_ARM_SRC_TMS570_TMS570_ESM_H
#define __ARCH_ARM_SRC_TMS570_TMS570_ESM_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: tms570_esm_initialize
*
* Description:
* Initialize the ESM.
*
****************************************************************************/
int tms570_esm_initialize(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_TMS570_TMS570_ESM_H */