summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspreset.c
blob: 9cf21a97347d817ee8f14d303ebdab44ec7abde3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
 *
 *  embedded brains GmbH
 *  Dornierstr. 4
 *  82178 Puchheim
 *  Germany
 *  <info@embedded-brains.de>
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#include <bsp/bootcard.h>
#include <bsp/alt_reset_manager.h>
#include "socal/alt_rstmgr.h"
#include "socal/hps.h"

void bsp_reset(void)
{
  uint32_t           self_cpu  = rtems_smp_get_current_processor();
  volatile uint32_t *mpumodrst = ALT_RSTMGR_MPUMODRST_ADDR;
  
  if( self_cpu == 0 ) {
    /* Reset CPU1 */
    (*mpumodrst) |= ALT_RSTMGR_MPUMODRST_CPU1_SET_MSK;
    
    /* Simply call the reset method from alteras HWLIB */
    (void) alt_reset_cold_reset();
  } else {
    /* Keep CPU1 waiting until it gets reset by CPU0 */
    while ( true ) {
      __asm__ volatile ("wfi");
    }
  }
}