source: rtems/c/src/lib/libbsp/sh/gensh2/startup/hw_init.c @ c939d5e

4.104.114.84.95
Last change on this file since c939d5e was 8cf4fac5, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/31/04 at 04:24:29

2004-03-31 Ralf Corsepius <ralf_corsepius@…>

  • include/bsp.h, startup/bspstart.c, startup/hw_init.c: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*
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.rtems.com/license/LICENSE.
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 *  $Id$
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 */
50extern void bsp_hw_init (void);
51extern void early_hw_init (void);
52
53/*  called from 'start.S' on "#ifdef START_HW_INIT" */
54void 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' */
77void bsp_hw_init (void)
78{
79  uint16_t   temp16;
80
81#ifdef STANDALONE_EVB
82  /* STANDALONE_EVB: sets up PFC */
83  /* no STANDALONE_EVB: accepts defaults, adds RESET */
84
85  /* FIXME: replace 'magic numbers' */
86       
87  write16(0x5000, PFC_PACRH);  /* Pin function controller - WRHH, WRHL */
88  write16(0x1550, PFC_PACRL1); /* Pin fun. controller - WRH,WRL,RD,CS1 */
89  write16(0x0000, PFC_PBCR1);  /* Pin function controller - default */
90  write16(0x2005, PFC_PBCR2);  /* Pin fcn. controller - A18,A17,A16 */
91  write16(0xFFFF, PFC_PCCR);   /* Pin function controller - A15-A0  */
92  write16(0x5555, PFC_PDCRH1); /* Pin function controller - D31-D24 */
93  write16(0x5555, PFC_PDCRH2); /* Pin function controller - D23-D16 */
94  write16(0xFFFF, PFC_PDCRL);  /* Pin function controller - D15-D0  */
95  write16(0x0000, PFC_IFCR);   /* Pin function controller - default */
96  write16(0x0000, PFC_PACRL2); /* default disconnects all I/O pins;*/
97                               /*  [re-connected by DEVICE_open()] */
98#endif
99
100  /* default hardware setup for SH7045F EVB */
101
102  /* PFC: General I/O except pin 13 (reset): */
103  temp16 = read16(PFC_PECR1);
104  temp16 |= 0x0800;
105  write16(temp16, PFC_PECR1);
106
107  /* All I/O lines bits 7-0: */
108  write16(0x00, PFC_PECR2);
109
110  /* P5 (LED) out, all other pins in: */
111  temp16 = read16(PFC_PEIOR);
112  temp16 |= 0x0020;
113  write16(temp16, PFC_PEIOR);
114
115}
Note: See TracBrowser for help on using the repository browser.