Ignore:
Timestamp:
Jun 12, 2000, 3:00:15 PM (21 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
edeed26
Parents:
0ab65474
Message:

Merged from 4.5.0-beta3a

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sh/gensh2/startup/hw_init.c

    r0ab65474 rdf49c60  
    44 *             target is Hitachi SH7045F EVB ("lcevb")
    55 *
     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 *
    612 *  Author: John M. Mills (jmills@tga.com)
    7  *  COPYRIGHT(c) 1999, TGA Technologies, Inc
     13 *  COPYRIGHT(c) 2000, TGA Technologies, Inc
    814 *                     Norcross, GA 30071 U.S.A
    915 *
     
    4147#include <rtems/score/iosh7045.h>
    4248
    43 /* exported entry */
    44 extern void hw_initialize (void);
     49/* exported entries */
     50extern void bsp_hw_init (void);
     51extern void early_hw_init (void);
    4552
    46 /* STANDALONE_EVB sets up bus, DRAM, PFC, and SCI0 */
    47 /* no STANDALONE_EVB accepts defaults, adds RESET, SCI1, WDT */
     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 */
    4859
    49 /***************************************************/
    50 /*      Inline function to access CPU features     */
    51 /*      from C.  This makes use of GNU extensions. */
    52 /***************************************************/
     60  /* FIXME: replace 'magic numbers' with logical names */
    5361
    54 __inline__ void set_interrupt_mask(unsigned char mask)
     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)
    5578{
    56   asm("mov.l r0,@-r15");
    57   asm("mov %0,r0"::"r"(mask)); 
    58   asm("and #0xF,r0");
    59   asm("rotl r0");
    60   asm("rotl r0");
    61   asm("rotl r0");
    62   asm("rotl r0");
    63   asm("ldc r0,sr");
    64   asm("mov.l @r15+,r0");
    65 }
    66 
    67 void hw_initialize (void)
    68 {
    69         int a;
    70         unsigned8 temp8;
    71         unsigned16 temp16;
     79  int a;
     80  unsigned8 temp8;
     81  unsigned16 temp16;
    7282
    7383#ifdef STANDALONE_EVB
    74         /* FIXME: replace 'magic numbers' */
     84  /* STANDALONE_EVB: sets up PFC */
     85  /* no STANDALONE_EVB: accepts defaults, adds RESET */
    7586
    76         write16(0x2020, BSC_BCR1);  /* Bus width access - 32-bit on CS1 */
    77         write16(0xF3DD, BSC_BCR2);  /* Idle cycles CS3-CS0 - 0 idle cycles*/
    78         write16(0xFF3F, BSC_WCR1);  /* Waits for CS3-CS0 - 3 waits on CS1 */
    79         write16(0x000F, BSC_WCR2);  /* Waits for DRAM/DMA access - default */
    80         write16(0x0000, BSC_DCR);   /* DRAM control - default */
    81         write16(0x0000, BSC_RTCSR); /* DRAM refresh - default */
    82         write16(0x0000, BSC_RTCNT); /* DRAM refresh counter - default*/
    83         write16(0x0000, BSC_RTCOR); /* DRAM refresh compare match - default */
     87  /* FIXME: replace 'magic numbers' */
    8488       
    85         write16(0x5000, PFC_PACRH); /* Pin function controller - WRHH, WRHL */
    86         write16(0x1550, PFC_PACRL1); /* Pin fun. controller - WRH,WRL,RD,CS1 */
    87         write16(0x0000, PFC_PBCR1); /* Pin function controller - default */
    88         write16(0x2005, PFC_PBCR2); /* Pin function controller - A18,A17,A16 */
    89         write16(0xFFFF, PFC_PCCR);  /* Pin function controller - A15-A0  */
    90         write16(0x5555, PFC_PDCRH1; /* Pin function controller - D31-D24 */
    91         write16(0x5555, PFC_PDCRH2); /* Pin function controller - D23-D16 */
    92         write16(0xFFFF, PFC_PDCRL); /* Pin function controller - D15-D0  */
    93         write16(0x0000, PFC_IFCR);  /* Pin function controller - default */
    94         write16(0x0005, PFC_PACRL2); /* Pin function controller - Tx0, Rx0 */
    95 
    96         write16(0x00, PFC_PACRL2); /* default disconnects all I/O */
    97                                    /* pins; connected by DEVICE_open() */
     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()] */
    98100#endif
    99101
    100         /* default hardware setup for SH7045F EVB */
     102  /* default hardware setup for SH7045F EVB */
    101103
    102         /* PFC: General I/O except pin 13 (reset): */
    103         temp16 = read16(PFC_PECR1) | 0x0800;
    104         write16(temp16, PFC_PECR1);
     104  /* PFC: General I/O except pin 13 (reset): */
     105  temp16 = read16(PFC_PECR1);
     106  temp16 |= 0x0800;
     107  write16(temp16, PFC_PECR1);
    105108
    106         /* All I/O lines bits 7-0: */
    107         write16(0x00, PFC_PECR2);
     109  /* All I/O lines bits 7-0: */
     110  write16(0x00, PFC_PECR2);
    108111
    109         /* P5 (LED) out, all other pins in: */
    110         temp16 = read16(PFC_PEIOR) | 0x0020;
    111         write16(temp16, PFC_PEIOR);
     112  /* P5 (LED) out, all other pins in: */
     113  temp16 = read16(PFC_PEIOR);
     114  temp16 |= 0x0020;
     115  write16(temp16, PFC_PEIOR);
    112116
    113117}
Note: See TracChangeset for help on using the changeset viewer.