arm: refactor clearing of exception faults to common code
A number of SoCs clear out the Mem/Bus/Usage and Hard Fault exceptions during init. Lets refactor that into a common function so we don't have to keep duplicating it over and over. Change-Id: Ida908a9092db37447abcf3c9872f36937982f729 Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
2d881d6539
commit
f16cefea9f
8 changed files with 36 additions and 43 deletions
|
@ -90,6 +90,28 @@ static ALWAYS_INLINE void _ExcSetup(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clear Fault exceptions
|
||||||
|
*
|
||||||
|
* Clear out exceptions for Mem, Bus, Usage and Hard Faults
|
||||||
|
*
|
||||||
|
* @return N/A
|
||||||
|
*/
|
||||||
|
static ALWAYS_INLINE void _ClearFaults(void)
|
||||||
|
{
|
||||||
|
#if defined(CONFIG_ARMV6_M)
|
||||||
|
#elif defined(CONFIG_ARMV7_M)
|
||||||
|
/* Reset all faults */
|
||||||
|
_ScbMemFaultAllFaultsReset();
|
||||||
|
_ScbBusFaultAllFaultsReset();
|
||||||
|
_ScbUsageFaultAllFaultsReset();
|
||||||
|
|
||||||
|
_ScbHardFaultAllFaultsReset();
|
||||||
|
#else
|
||||||
|
#error Unknown ARM architecture
|
||||||
|
#endif /* CONFIG_ARMV6_M */
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _ASMLANGUAGE */
|
#endif /* _ASMLANGUAGE */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
|
#include <cortex_m/exc.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Setup various clock on SoC.
|
* @brief Setup various clock on SoC.
|
||||||
|
@ -162,12 +163,7 @@ static int atmel_sam3_init(struct device *arg)
|
||||||
__EEFC0->fmr = 0x00000400;
|
__EEFC0->fmr = 0x00000400;
|
||||||
__EEFC1->fmr = 0x00000400;
|
__EEFC1->fmr = 0x00000400;
|
||||||
|
|
||||||
/* Clear all faults */
|
_ClearFaults();
|
||||||
_ScbMemFaultAllFaultsReset();
|
|
||||||
_ScbBusFaultAllFaultsReset();
|
|
||||||
_ScbUsageFaultAllFaultsReset();
|
|
||||||
|
|
||||||
_ScbHardFaultAllFaultsReset();
|
|
||||||
|
|
||||||
/* Setup master clock */
|
/* Setup master clock */
|
||||||
clock_init();
|
clock_init();
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
#include <cortex_m/exc.h>
|
||||||
|
|
||||||
#ifdef CONFIG_RUNTIME_NMI
|
#ifdef CONFIG_RUNTIME_NMI
|
||||||
extern void _NmiInit(void);
|
extern void _NmiInit(void);
|
||||||
|
@ -377,12 +378,7 @@ static int nordicsemi_nrf52_init(struct device *arg)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reset all faults */
|
_ClearFaults();
|
||||||
_ScbMemFaultAllFaultsReset();
|
|
||||||
_ScbBusFaultAllFaultsReset();
|
|
||||||
_ScbUsageFaultAllFaultsReset();
|
|
||||||
|
|
||||||
_ScbHardFaultAllFaultsReset();
|
|
||||||
|
|
||||||
/* Setup master clock */
|
/* Setup master clock */
|
||||||
clock_init();
|
clock_init();
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <fsl_common.h>
|
#include <fsl_common.h>
|
||||||
#include <fsl_clock.h>
|
#include <fsl_clock.h>
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
|
#include <cortex_m/exc.h>
|
||||||
|
|
||||||
#define PLLFLLSEL_MCGFLLCLK (0)
|
#define PLLFLLSEL_MCGFLLCLK (0)
|
||||||
#define PLLFLLSEL_MCGPLLCLK (1)
|
#define PLLFLLSEL_MCGPLLCLK (1)
|
||||||
|
@ -171,13 +172,7 @@ static int fsl_frdm_k64f_init(struct device *arg)
|
||||||
temp_reg |= MPU_CESR_SPERR_MASK;
|
temp_reg |= MPU_CESR_SPERR_MASK;
|
||||||
MPU->CESR = temp_reg;
|
MPU->CESR = temp_reg;
|
||||||
|
|
||||||
/* clear all faults */
|
_ClearFaults();
|
||||||
|
|
||||||
_ScbMemFaultAllFaultsReset();
|
|
||||||
_ScbBusFaultAllFaultsReset();
|
|
||||||
_ScbUsageFaultAllFaultsReset();
|
|
||||||
|
|
||||||
_ScbHardFaultAllFaultsReset();
|
|
||||||
|
|
||||||
/* Initialize PLL/system clock to 120 MHz */
|
/* Initialize PLL/system clock to 120 MHz */
|
||||||
clkInit();
|
clkInit();
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
|
#include <cortex_m/exc.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Perform basic hardware initialization at boot.
|
* @brief Perform basic hardware initialization at boot.
|
||||||
|
@ -31,12 +32,7 @@ static int stm32f1_init(struct device *arg)
|
||||||
|
|
||||||
key = irq_lock();
|
key = irq_lock();
|
||||||
|
|
||||||
/* Clear all faults */
|
_ClearFaults();
|
||||||
_ScbMemFaultAllFaultsReset();
|
|
||||||
_ScbBusFaultAllFaultsReset();
|
|
||||||
_ScbUsageFaultAllFaultsReset();
|
|
||||||
|
|
||||||
_ScbHardFaultAllFaultsReset();
|
|
||||||
|
|
||||||
/* Install default handler that simply resets the CPU
|
/* Install default handler that simply resets the CPU
|
||||||
* if configured in the kernel, NOP otherwise
|
* if configured in the kernel, NOP otherwise
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
|
#include <cortex_m/exc.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Perform basic hardware initialization at boot.
|
* @brief Perform basic hardware initialization at boot.
|
||||||
|
@ -31,12 +32,7 @@ static int stm32f3_init(struct device *arg)
|
||||||
|
|
||||||
key = irq_lock();
|
key = irq_lock();
|
||||||
|
|
||||||
/* Clear all faults */
|
_ClearFaults();
|
||||||
_ScbMemFaultAllFaultsReset();
|
|
||||||
_ScbBusFaultAllFaultsReset();
|
|
||||||
_ScbUsageFaultAllFaultsReset();
|
|
||||||
|
|
||||||
_ScbHardFaultAllFaultsReset();
|
|
||||||
|
|
||||||
/* Install default handler that simply resets the CPU
|
/* Install default handler that simply resets the CPU
|
||||||
* if configured in the kernel, NOP otherwise
|
* if configured in the kernel, NOP otherwise
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
|
#include <cortex_m/exc.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Perform basic hardware initialization at boot.
|
* @brief Perform basic hardware initialization at boot.
|
||||||
|
@ -32,12 +33,7 @@ static int st_stm32f4_init(struct device *arg)
|
||||||
|
|
||||||
key = irq_lock();
|
key = irq_lock();
|
||||||
|
|
||||||
/* Clear all faults */
|
_ClearFaults();
|
||||||
_ScbMemFaultAllFaultsReset();
|
|
||||||
_ScbBusFaultAllFaultsReset();
|
|
||||||
_ScbUsageFaultAllFaultsReset();
|
|
||||||
|
|
||||||
_ScbHardFaultAllFaultsReset();
|
|
||||||
|
|
||||||
/* Install default handler that simply resets the CPU
|
/* Install default handler that simply resets the CPU
|
||||||
* if configured in the kernel, NOP otherwise
|
* if configured in the kernel, NOP otherwise
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
|
#include <cortex_m/exc.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Perform basic hardware initialization at boot.
|
* @brief Perform basic hardware initialization at boot.
|
||||||
|
@ -32,12 +33,7 @@ static int stm32l4_init(struct device *arg)
|
||||||
|
|
||||||
key = irq_lock();
|
key = irq_lock();
|
||||||
|
|
||||||
/* Clear all faults */
|
_ClearFaults();
|
||||||
_ScbMemFaultAllFaultsReset();
|
|
||||||
_ScbBusFaultAllFaultsReset();
|
|
||||||
_ScbUsageFaultAllFaultsReset();
|
|
||||||
|
|
||||||
_ScbHardFaultAllFaultsReset();
|
|
||||||
|
|
||||||
/* Install default handler that simply resets the CPU
|
/* Install default handler that simply resets the CPU
|
||||||
* if configured in the kernel, NOP otherwise
|
* if configured in the kernel, NOP otherwise
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue