source: rtems/c/src/lib/libbsp/powerpc/mpc55xxevb/startup/early-init.c @ d922dab

4.115
Last change on this file since d922dab was d922dab, checked in by Sebastian Huber <sebastian.huber@…>, on 11/08/11 at 10:13:32

2011-11-08 Sebastian Huber <sebastian.huber@…>

  • make/custom/mpc5566evb_spe.cfg, make/custom/mpc5674fevb_spe.cfg, startup/linkcmds.mpc5566evb_spe, startup/linkcmds.mpc5674fevb_spe, startup/reset.c: New files.
  • Makefile.am, preinstall.am: Reflect changes above.
  • startup/early-init.c: Added missing section attribute.
  • configure.ac, network/smsc9218i.c: New BSP options SMSC9218I_EDMA_RX_CHANNEL and SMSC9218I_EDMA_TX_CHANNEL. Enable reset at cleanup.
  • Property mode set to 100644
File size: 3.5 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup mpc55xx
5 *
6 * @brief BSP early 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.com/license/LICENSE.
21 *
22 * $Id$
23 */
24
25#include <bsp/mpc55xx-config.h>
26#include <bsp/linker-symbols.h>
27#include <bsp/start.h>
28#include <bsp.h>
29
30#include <mpc55xx/mpc55xx.h>
31
32#include <string.h>
33
34#ifdef MPC55XX_BOOTFLAGS
35extern uint32_t mpc55xx_bootflag_0 [];
36#endif
37
38static void BSP_START_TEXT_SECTION mpc55xx_siu_init(void)
39{
40  size_t i = 0;
41
42#if defined(MPC55XX_BOARD_GWLCFM)
43  SIU.GPDO[122].B.PDO=1; /* make sure USB reset is kept high */
44  SIU.GPDO[121].B.PDO=1; /* make sure Ethernet reset is kept high */
45  SIU.GPDO[113].B.PDO=1; /* make sure MOST Companion reset is kept high */
46#endif
47
48  for (i = 0; i < mpc55xx_siu_pcr_config_count [0]; ++i) {
49     const mpc55xx_siu_pcr_config_entry *e = &mpc55xx_siu_pcr_config [i];
50     int j = e->index;
51     int n = j + e->count;
52     uint32_t pcr = e->pcr.R;
53
54     while (j < n) {
55       SIU.PCR [j].R = pcr;
56       ++j;
57     }
58  }
59}
60
61static void BSP_START_TEXT_SECTION mpc55xx_ebi_chip_select_init(void)
62{
63  size_t i = 0;
64
65  for (i = 0; i < mpc55xx_ebi_cs_config_count [0]; ++i) {
66     EBI.CS [i] = mpc55xx_ebi_cs_config [i];
67  }
68
69  for (i = 0; i < mpc55xx_ebi_cal_cs_config_count [0]; ++i) {
70     EBI.CAL_CS [i] = mpc55xx_ebi_cal_cs_config [i];
71  }
72}
73
74static void BSP_START_TEXT_SECTION mpc55xx_ebi_init(void)
75{
76#if defined(MPC55XX_BOARD_GWLCFM)
77        /*
78         * init EBI for Muxed AD bus
79         */
80        EBI.MCR.B.DBM = 1;
81        EBI.MCR.B.AD_MUX = 1; /* use multiplexed bus */
82        EBI.MCR.B.D16_31 = 1; /* use lower AD bus    */
83
84        SIU.ECCR.B.EBDF = 3;  /* use CLK/4 as bus clock */
85#elif defined(MPC55XX_BOARD_MPC5674FEVB)
86  struct EBI_tag ebi = {
87    .MCR = {
88      .B = {
89        .ACGE = 0,
90        .MDIS = 0,
91        .D16_31 = 0,
92        .AD_MUX = 0,
93        .DBM = 0
94      }
95    }
96  };
97
98  EBI.MCR.R = ebi.MCR.R;
99#endif
100}
101
102static void BSP_START_TEXT_SECTION mpc55xx_mmu_init(void)
103{
104#ifdef MPC55XX_BOOTFLAGS
105  /* If the low bit of bootflag 0 is clear don't change the MMU.  */
106  bool do_mmu_init = (mpc55xx_bootflag_0 [0] & 1) != 0;
107#else
108  bool do_mmu_init = true;
109#endif
110
111  if (do_mmu_init) {
112    size_t i = 0;
113
114    for (i = 0; i < mpc55xx_mmu_config_count [0]; ++i) {
115      const struct MMU_tag *tag = &mpc55xx_mmu_config [i];
116      PPC_SET_SPECIAL_PURPOSE_REGISTER( FSL_EIS_MAS0, tag->MAS0.R);
117      PPC_SET_SPECIAL_PURPOSE_REGISTER( FSL_EIS_MAS1, tag->MAS1.R);
118      PPC_SET_SPECIAL_PURPOSE_REGISTER( FSL_EIS_MAS2, tag->MAS2.R);
119      PPC_SET_SPECIAL_PURPOSE_REGISTER( FSL_EIS_MAS3, tag->MAS3.R);
120      __asm__ volatile ("tlbwe");
121    }
122  }
123}
124
125static void BSP_START_TEXT_SECTION mpc55xx_load_section(
126  void *dst,
127  const void *src,
128  size_t n
129)
130{
131  if (dst != src) {
132    memcpy(dst, src, n);
133  }
134}
135
136void BSP_START_TEXT_SECTION mpc55xx_early_init(void)
137{
138  mpc55xx_load_section(
139    &bsp_section_fast_text_begin [0],
140    &bsp_section_fast_text_load_begin [0],
141    (size_t) bsp_section_fast_text_size
142  );
143  mpc55xx_load_section(
144    &bsp_section_fast_data_begin [0],
145    &bsp_section_fast_data_load_begin [0],
146    (size_t) bsp_section_fast_data_size
147  );
148  mpc55xx_load_section(
149    &bsp_section_data_begin [0],
150    &bsp_section_data_load_begin [0],
151    (size_t) bsp_section_data_size
152  );
153  mpc55xx_siu_init();
154  mpc55xx_ebi_chip_select_init();
155  mpc55xx_ebi_init();
156  mpc55xx_mmu_init();
157}
Note: See TracBrowser for help on using the repository browser.