source: rtems/bsps/powerpc/mpc55xxevb/start/start-clock.c @ 762fa62

5
Last change on this file since 762fa62 was 9964895, checked in by Sebastian Huber <sebastian.huber@…>, on 04/20/18 at 08:35:35

bsps: Move startup files to bsps

Adjust build support files to new directory layout.

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup mpc55xx
5 *
6 * @brief Clock and FMPLL initialization code.
7 */
8
9/*
10 * Copyright (c) 2008-2011 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#include <bsp.h>
24#include <bsp/fatal.h>
25#include <bsp/start.h>
26#include <bsp/bootcard.h>
27#include <bsp/mpc55xx-config.h>
28
29#ifdef MPC55XX_NEEDS_LOW_LEVEL_INIT
30  #if defined(MPC55XX_HAS_FMPLL) || defined(MPC55XX_HAS_FMPLL_ENHANCED)
31    static BSP_START_TEXT_SECTION void fmpll_wait_for_lock(void)
32    {
33      int i = 0;
34      bool lock = false;
35
36      while (!lock && i < 6000) {
37        lock = FMPLL.SYNSR.B.LOCK != 0;
38        ++i;
39      }
40
41      if (!lock) {
42        bsp_fatal(MPC55XX_FATAL_FMPLL_LOCK);
43      }
44    }
45  #endif
46#endif
47
48BSP_START_TEXT_SECTION void mpc55xx_start_clock(void)
49{
50  #ifdef MPC55XX_NEEDS_LOW_LEVEL_INIT
51    const mpc55xx_clock_config *cfg = mpc55xx_start_config_clock;
52
53    #ifdef MPC55XX_HAS_FMPLL
54      volatile struct FMPLL_tag *fmpll = &FMPLL;
55
56      fmpll->SYNCR.R = cfg->syncr_tmp.R;
57      fmpll->SYNCR.R;
58      fmpll_wait_for_lock();
59
60      fmpll->SYNCR.R = cfg->syncr_final.R;
61      fmpll->SYNCR.R;
62      fmpll_wait_for_lock();
63    #endif
64
65    #ifdef MPC55XX_HAS_FMPLL_ENHANCED
66      volatile struct FMPLL_tag *fmpll = &FMPLL;
67
68      fmpll->ESYNCR2.R = cfg->esyncr2_tmp.R;
69      fmpll->ESYNCR2.R;
70      fmpll->ESYNCR1.R = cfg->esyncr1_final.R;
71      fmpll->ESYNCR1.R;
72      fmpll_wait_for_lock();
73
74      fmpll->ESYNCR2.R = cfg->esyncr2_final.R;
75      fmpll->ESYNCR2.R;
76      fmpll_wait_for_lock();
77
78      #if MPC55XX_CHIP_FAMILY == 551 || MPC55XX_CHIP_FAMILY == 566
79        /* System clock supplied by PLL */
80        SIU.SYSCLK.B.SYSCLKSEL = 2;
81      #endif
82    #endif
83
84    #ifdef MPC55XX_HAS_MODE_CONTROL
85      volatile CGM_tag *cgm = &CGM;
86      size_t fmpll_count = sizeof(cfg->fmpll) / sizeof(cfg->fmpll [0]);
87      size_t auxclk_count = sizeof(cfg->auxclk) / sizeof(cfg->auxclk [0]);
88      size_t i = 0;
89
90      for (i = 0; i < auxclk_count; ++i) {
91        cgm->AUXCLK [i].AC_SC.R = cfg->auxclk [i].AC_SC.R;
92        cgm->AUXCLK [i].AC_DC0_3.R = cfg->auxclk [i].AC_DC0_3.R;
93      }
94
95      for (i = 0; i < fmpll_count; ++i) {
96        cgm->FMPLL [i].CR.R = cfg->fmpll [i].cr.R;
97        cgm->FMPLL [i].MR.R = cfg->fmpll [i].mr.R;
98      }
99
100      cgm->OC_EN.R = cfg->oc_en.R;
101      cgm->OCDS_SC.R = cfg->ocds_sc.R;
102    #endif
103  #endif
104}
Note: See TracBrowser for help on using the repository browser.