source: rtems/c/src/lib/libbsp/bfin/TLL6527M/startup/bspstart.c @ afe87e1a

5
Last change on this file since afe87e1a was afe87e1a, checked in by Sebastian Huber <sebastian.huber@…>, on 12/09/15 at 10:28:52

bsps/bfin: Use default bsp_pretasking_hook()

Rename BSP-specific bsp_pretasking_hook() to bsp_predriver_hook().

Update #2408.

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