source: rtems/bsps/bfin/TLL6527M/start/bspstart.c @ 9964895

5
Last change on this file since 9964895 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: 4.4 KB
Line 
1/*  bspstart.c for TLL6527M
2 *
3 *  This routine does the bulk of the system initialization.
4 */
5
6/*
7 * COPYRIGHT (c) 2010 by ECE Northeastern University.
8 *
9 * The license and distribution terms for this file may be
10 * found in the file LICENSE in this distribution or at
11 * http://www.rtems.org/license
12 */
13
14#include <bsp.h>
15#include <bsp/bootcard.h>
16#include <cplb.h>
17#include <bsp/interrupt.h>
18#include <libcpu/ebiuRegs.h>
19#include <rtems/sysinit.h>
20
21const unsigned int dcplbs_table[16][2] = { 
22  { 0xFFA00000, (PAGE_SIZE_1MB | CPLB_D_PAGE_MGMT | CPLB_WT) },
23  { 0xFF900000, (PAGE_SIZE_1MB | CPLB_D_PAGE_MGMT | CPLB_WT) },/* L1 Data B */
24  { 0xFF800000, (PAGE_SIZE_1MB | CPLB_D_PAGE_MGMT | CPLB_WT) },/* L1 Data A */
25  { 0xFFB00000, (PAGE_SIZE_1MB | CPLB_DNOCACHE) },
26
27  { 0x20300000, (PAGE_SIZE_1MB | CPLB_DNOCACHE) },/* Async Memory Bank 3 */
28  { 0x20200000, (PAGE_SIZE_1MB | CPLB_DNOCACHE) },/* Async Memory Bank 2  */
29  { 0x20100000, (PAGE_SIZE_1MB | CPLB_DNOCACHE) },/* Async Memory Bank 1 */
30  { 0x20000000, (PAGE_SIZE_1MB | CPLB_DNOCACHE) }, /* Async Memory Bank 0 */
31
32  { 0x02400000, (PAGE_SIZE_4MB | CPLB_DNOCACHE) },
33  { 0x02000000, (PAGE_SIZE_4MB | CPLB_DNOCACHE) },
34  { 0x00C00000, (PAGE_SIZE_4MB | CPLB_DNOCACHE) },
35  { 0x00800000, (PAGE_SIZE_4MB | CPLB_DNOCACHE) },
36  { 0x00400000, (PAGE_SIZE_4MB | CPLB_DNOCACHE) },
37  { 0x00000000, (PAGE_SIZE_4MB | CPLB_DNOCACHE) },
38
39  { 0xffffffff, 0xffffffff }/* end of section - termination */
40};
41
42
43const unsigned int _icplbs_table[16][2] = {
44  { 0xFFA00000, (PAGE_SIZE_1MB | CPLB_I_PAGE_MGMT | CPLB_I_PAGE_MGMT | 0x4) },
45  /* L1 Code */
46  { 0xEF000000, (PAGE_SIZE_1MB | CPLB_INOCACHE) }, /* AREA DE BOOT */
47  { 0xFFB00000, (PAGE_SIZE_1MB | CPLB_INOCACHE) },
48
49  { 0x20300000, (PAGE_SIZE_1MB | CPLB_INOCACHE) },/* Async Memory Bank 3 */
50  { 0x20200000, (PAGE_SIZE_1MB | CPLB_INOCACHE) },/* Async Bank 2 (Secnd) */
51  { 0x20100000, (PAGE_SIZE_1MB | CPLB_INOCACHE) },/* Async Bank 1 (Prim B) */
52  { 0x20000000, (PAGE_SIZE_1MB | CPLB_INOCACHE) },/* Async Bank 0 (Prim A) */
53
54  { 0x02400000, (PAGE_SIZE_4MB | CPLB_INOCACHE) },
55  { 0x02000000, (PAGE_SIZE_4MB | CPLB_INOCACHE) },
56  { 0x00C00000, (PAGE_SIZE_4MB | CPLB_INOCACHE) },
57  { 0x00800000, (PAGE_SIZE_4MB | CPLB_INOCACHE) },
58  { 0x00400000, (PAGE_SIZE_4MB | CPLB_INOCACHE) },
59  { 0x00000000, (PAGE_SIZE_4MB | CPLB_INOCACHE) },
60
61  { 0xffffffff, 0xffffffff }/* end of section - termination */
62};
63
64/*
65 * Init_PLL
66 *
67 * Routine to initialize the PLL. The TLL6527M uses a 25 Mhz XTAL.
68 */
69static void Init_PLL (void)
70{
71  unsigned short msel = 0;
72  unsigned short ssel = 0;
73
74  msel = (unsigned short)( (float)CCLK/(float)CLKIN );
75  ssel = (unsigned short)( (float)(CLKIN*msel)/(float)SCLK);
76 
77  asm("cli r0;");
78
79  *((uint32_t*)SIC_IWR) = 0x1;
80
81  /* Configure PLL registers */
82  *((uint16_t*)PLL_DIV) = ssel;
83  msel = msel<<9;
84  *((uint16_t*)PLL_CTL) = msel;
85
86  /* Commands to set PLL values */
87  asm("idle;");
88  asm("sti r0;");
89}
90
91/*
92 * Init_EBIU
93 *
94 * Configure extern memory
95 */
96static void Init_EBIU (void)
97{
98  /* Check if SDRAM is already enabled */
99  if ( 0 != (*(uint16_t *)EBIU_SDSTAT & EBIU_SDSTAT_SDRS) ){
100    asm("ssync;");
101    /* RDIV = (100MHz*64ms)/8192-(6+3)=0x406 cycles */
102    *(uint16_t *)EBIU_SDRRC  = 0x3F6; /* SHould have been 0x306*/
103    *(uint16_t *)EBIU_SDBCTL = EBIU_SDBCTL_EBCAW_10 | EBIU_SDBCTL_EBSZ_64M |
104        EBIU_SDBCTL_EBE;
105    *(uint32_t *)EBIU_SDGCTL = 0x8491998d;
106    asm("ssync;");
107  } else {
108    /* SDRAm is already programmed */
109  }
110}
111
112/*
113 * Init_Flags
114 *
115 * Enable LEDs port
116 */
117static void Init_Flags(void)
118{
119  *((uint16_t*)PORTH_FER)    = 0x0;
120  *((uint16_t*)PORTH_MUX)    = 0x0;
121  *((uint16_t*)PORTHIO_DIR)  = 0x1<<15;
122  *((uint16_t*)PORTHIO_SET)  = 0x1<<15;
123}
124
125RTEMS_SYSINIT_ITEM(
126  bfin_interrupt_init,
127  RTEMS_SYSINIT_BSP_PRE_DRIVERS,
128  RTEMS_SYSINIT_ORDER_MIDDLE
129);
130
131void bsp_start( void )
132{
133  int i;
134
135  /* BSP Hardware Initialization*/
136  Init_RTC();   /* Blackfin Real Time Clock initialization */
137  Init_PLL();   /* PLL initialization */
138  Init_EBIU();  /* EBIU initialization */
139  Init_Flags(); /* GPIO initialization */
140
141  /*
142   *  Allocate the memory for the RTEMS Work Space.  This can come from
143   *  a variety of places: hard coded address, malloc'ed from outside
144   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
145   *  typically done by stock BSPs) by subtracting the required amount
146   *  of work space from the last physical address on the CPU board.
147   */
148  for (i=5;i<16;i++) {
149    set_vector((rtems_isr_entry)bfin_null_isr, i, 1);
150  }
151
152}
Note: See TracBrowser for help on using the repository browser.