1 |
1026 |
ivang |
/*
|
2 |
|
|
* hw_init.c: set up sh7045F internal subunits
|
3 |
|
|
* Pin and memory assignments assume
|
4 |
|
|
* target is Hitachi SH7045F EVB ("lcevb")
|
5 |
|
|
*
|
6 |
|
|
* Provides two initialization routines:
|
7 |
|
|
* A. 'void early_hw_init(void)' for 'start.S'
|
8 |
|
|
* sets up hw needed for early RTEMS boot, and
|
9 |
|
|
* B. 'void bsp_hw_init(void)' for 'bspstart.c'
|
10 |
|
|
* sets up hardware used by this BSP.
|
11 |
|
|
*
|
12 |
|
|
* Author: John M. Mills (jmills@tga.com)
|
13 |
|
|
* COPYRIGHT(c) 2000, TGA Technologies, Inc
|
14 |
|
|
* Norcross, GA 30071 U.S.A
|
15 |
|
|
*
|
16 |
|
|
* This program is distributed in the hope that it will be useful,
|
17 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
19 |
|
|
*
|
20 |
|
|
*
|
21 |
|
|
* The license and distribution terms for this file may be
|
22 |
|
|
* found in the file LICENSE in this distribution or at
|
23 |
|
|
* http://www.OARcorp.com/rtems/license.html.
|
24 |
|
|
*
|
25 |
|
|
* Adapted from Hitachi EVB7045F tutorial files by:
|
26 |
|
|
* John M. Mills (jmills@tga.com)
|
27 |
|
|
* TGA Technologies, Inc.
|
28 |
|
|
* 100 Pinnacle Way, Suite 140
|
29 |
|
|
* Norcross, GA 30071 U.S.A.
|
30 |
|
|
*
|
31 |
|
|
*
|
32 |
|
|
* This file may be copied and distributed in accordance
|
33 |
|
|
* the above-referenced license. It is provided for critique and
|
34 |
|
|
* developmental purposes without any warranty nor representation
|
35 |
|
|
* by the authors or by TGA Technologies.
|
36 |
|
|
*
|
37 |
|
|
* hw_init.c,v 1.3 2000/06/12 14:59:51 joel Exp
|
38 |
|
|
*/
|
39 |
|
|
|
40 |
|
|
#include <bsp.h>
|
41 |
|
|
|
42 |
|
|
#include <stdlib.h>
|
43 |
|
|
|
44 |
|
|
#include <rtems/libio.h>
|
45 |
|
|
#include <iosupp.h>
|
46 |
|
|
#include <rtems/score/sh_io.h>
|
47 |
|
|
#include <rtems/score/iosh7045.h>
|
48 |
|
|
|
49 |
|
|
/* exported entries */
|
50 |
|
|
extern void bsp_hw_init (void);
|
51 |
|
|
extern void early_hw_init (void);
|
52 |
|
|
|
53 |
|
|
/* called from 'start.S' on "#ifdef START_HW_INIT" */
|
54 |
|
|
void early_hw_init (void)
|
55 |
|
|
{
|
56 |
|
|
#ifdef STANDALONE_EVB
|
57 |
|
|
/* STANDALONE_EVB minimally sets up bus and DRAM here */
|
58 |
|
|
/* no STANDALONE_EVB accepts defaults from debug monitor */
|
59 |
|
|
|
60 |
|
|
/* FIXME: replace 'magic numbers' with logical names */
|
61 |
|
|
|
62 |
|
|
write16(0x2020, BSC_BCR1); /* Bus width access - 32-bit on CS1 */
|
63 |
|
|
write16(0xF3DD, BSC_BCR2); /* Idle cycles CS3-CS0 - 0 idle cycles*/
|
64 |
|
|
write16(0xFF3F, BSC_WCR1); /* Waits for CS3-CS0 - 3 waits on CS1 */
|
65 |
|
|
write16(0x000F, BSC_WCR2); /* Waits for DRAM/DMA access - default */
|
66 |
|
|
write16(0x0000, BSC_DCR); /* DRAM control - default */
|
67 |
|
|
write16(0x0000, BSC_RTCSR); /* DRAM refresh - default */
|
68 |
|
|
write16(0x0000, BSC_RTCNT); /* DRAM refresh counter - default*/
|
69 |
|
|
write16(0x0000, BSC_RTCOR); /* DRAM refresh compare match - default */
|
70 |
|
|
#endif
|
71 |
|
|
|
72 |
|
|
/* add early-init functions here */
|
73 |
|
|
|
74 |
|
|
};
|
75 |
|
|
|
76 |
|
|
/* to be called from 'bspstart.c' */
|
77 |
|
|
void bsp_hw_init (void)
|
78 |
|
|
{
|
79 |
|
|
int a;
|
80 |
|
|
unsigned8 temp8;
|
81 |
|
|
unsigned16 temp16;
|
82 |
|
|
|
83 |
|
|
#ifdef STANDALONE_EVB
|
84 |
|
|
/* STANDALONE_EVB: sets up PFC */
|
85 |
|
|
/* no STANDALONE_EVB: accepts defaults, adds RESET */
|
86 |
|
|
|
87 |
|
|
/* FIXME: replace 'magic numbers' */
|
88 |
|
|
|
89 |
|
|
write16(0x5000, PFC_PACRH); /* Pin function controller - WRHH, WRHL */
|
90 |
|
|
write16(0x1550, PFC_PACRL1); /* Pin fun. controller - WRH,WRL,RD,CS1 */
|
91 |
|
|
write16(0x0000, PFC_PBCR1); /* Pin function controller - default */
|
92 |
|
|
write16(0x2005, PFC_PBCR2); /* Pin fcn. controller - A18,A17,A16 */
|
93 |
|
|
write16(0xFFFF, PFC_PCCR); /* Pin function controller - A15-A0 */
|
94 |
|
|
write16(0x5555, PFC_PDCRH1); /* Pin function controller - D31-D24 */
|
95 |
|
|
write16(0x5555, PFC_PDCRH2); /* Pin function controller - D23-D16 */
|
96 |
|
|
write16(0xFFFF, PFC_PDCRL); /* Pin function controller - D15-D0 */
|
97 |
|
|
write16(0x0000, PFC_IFCR); /* Pin function controller - default */
|
98 |
|
|
write16(0x0000, PFC_PACRL2); /* default disconnects all I/O pins;*/
|
99 |
|
|
/* [re-connected by DEVICE_open()] */
|
100 |
|
|
#endif
|
101 |
|
|
|
102 |
|
|
/* default hardware setup for SH7045F EVB */
|
103 |
|
|
|
104 |
|
|
/* PFC: General I/O except pin 13 (reset): */
|
105 |
|
|
temp16 = read16(PFC_PECR1);
|
106 |
|
|
temp16 |= 0x0800;
|
107 |
|
|
write16(temp16, PFC_PECR1);
|
108 |
|
|
|
109 |
|
|
/* All I/O lines bits 7-0: */
|
110 |
|
|
write16(0x00, PFC_PECR2);
|
111 |
|
|
|
112 |
|
|
/* P5 (LED) out, all other pins in: */
|
113 |
|
|
temp16 = read16(PFC_PEIOR);
|
114 |
|
|
temp16 |= 0x0020;
|
115 |
|
|
write16(temp16, PFC_PEIOR);
|
116 |
|
|
|
117 |
|
|
}
|