nuttx/arch/arm/src/tms570/tms570_esm.c

161 lines
5.0 KiB
C
Raw Normal View History

2015-12-27 14:54:43 +01:00
/****************************************************************************
* 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 <assert.h>
2015-12-27 15:34:14 +01:00
#include <debug.h>
2015-12-27 14:54:43 +01:00
2015-12-27 15:34:14 +01:00
#include <arch/irq.h>
#include "arm_internal.h"
#include "hardware/tms570_esm.h"
2015-12-27 14:54:43 +01:00
#include "tms570_esm.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);
}
2015-12-27 15:34:14 +01:00
/* Clear interrupt level. All channels set to low level interrupt. */
2015-12-27 14:54:43 +01:00
putreg32(0xffffffff, TMS570_ESM_ILCR1);
putreg32(0xffffffff, TMS570_ESM_ILCR4);
2015-12-27 15:34:14 +01:00
/* Set interrupt level (Writing zero does nothing) */
2015-12-27 14:54:43 +01:00
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;
}
2015-12-27 15:34:14 +01:00
/****************************************************************************
* Name: tms570_esm_interrupt
*
* Description:
* ESM interrupt handler
*
****************************************************************************/
int tms570_esm_interrupt(int irq, void *context, void *arg)
2015-12-27 15:34:14 +01:00
{
/* Save the saved processor context in CURRENT_REGS where it can be
* accessed for register dumps and possibly context switching.
2015-12-27 15:34:14 +01:00
*/
CURRENT_REGS = (uint32_t *)context;
2015-12-27 15:34:14 +01:00
/* Crash -- possibly showing diagnostic debug information. */
_err("ERROR: ESM Interrupt. PC: %08" PRIx32 "\n", CURRENT_REGS[REG_PC]);
2015-12-27 15:34:14 +01:00
PANIC();
return OK; /* To keep the compiler happy */
}