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

Last change on this file since e560ee85 was e560ee85, checked in by Joel Sherrill <joel@…>, on 03/01/22 at 21:38:55

bsps/powerpc/: Scripted embedded brains header file clean up

Updates #4625.

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