source: rtems/c/src/lib/libbsp/powerpc/score603e/PCI_bus/PCI.c @ 31a5ec8

4.9
Last change on this file since 31a5ec8 was 31a5ec8, checked in by Jennifer Averett <Jennifer.Averett@…>, on 05/05/09 at 16:18:06

2009-05-05 Jennifer Averett <jennifer.averett@…>

  • Makefile.am, README, configure.ac, preinstall.am, PCI_bus/PCI.c, PCI_bus/PCI.h, PCI_bus/flash.c, PCI_bus/universe.c, console/85c30.c, console/85c30.h, console/console.c, console/consolebsp.h, console/tbl85c30.c, include/bsp.h, include/coverhd.h, include/gen2.h, include/irq-config.h, include/tm27.h, irq/FPGA.c, irq/irq.h, irq/irq_init.c, start/start.S, startup/Hwr_init.c, startup/bspstart.c, timer/timer.c, tod/tod.c: Updated and tested with the latest powerpc isr source
  • irq/no_pic.c: New file.
  • irq/irq.c, startup/genpvec.c, startup/setvec.c, startup/vmeintr.c: Removed.
  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *
3 *  COPYRIGHT (c) 1989-2009.
4 *  On-Line Applications Research Corporation (OAR).
5 *
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *  http://www.rtems.com/license/LICENSE.
9 *
10 * $Id$
11 */
12
13#include <rtems.h>
14#include <assert.h>
15#include <stdio.h>
16
17#include <bsp.h>
18
19/*
20 * Forced delay to get around timing problems with the UNIVERSE chip.  The
21 * two nops are used so that the delay works for varying clock frequencies,
22 * up to 66 Mhz, with margin.  Each nop averages about 1 1/2 clock ticks,
23 * and since there are 2 nops, this routine takes about 3 clock ticks,
24 * which on a worst case 66 Mhz board, is 45 nanosecond. This time period
25 * is sufficient to guarantee a work-around to the UNIVERSE chip timing
26 * problem.  The problem is that when there are two successive accesses to
27 * an UNIVERSE register, without sufficient delay, the second access will
28 * not work correctly.
29 */
30void PCI_bus_delay ()
31{
32  asm(" nop");
33  asm(" nop");
34}
35
36/*
37 * PCI_bus_write
38 */
39void PCI_bus_write(
40  volatile uint32_t         * _addr,                  /* IN */
41  uint32_t         _data                              /* IN */
42)
43{
44  _data = Convert_Endian_32( _data );
45  *_addr = _data;
46}
47
48uint32_t         PCI_bus_read(
49  volatile uint32_t         *  _addr                  /* IN */
50)
51{
52  uint32_t         data;
53
54  data = *_addr;
55  data = Convert_Endian_32( data );
56  return data;
57}
58/*
59 * PCI Configuration Cycle Read/Write Access which is used to access all of
60 * devices registers on the PCI bus.  i.e.: Universe, Ethernet & PMC.
61 */
62
63uint32_t         Read_pci_device_register(
64  uint32_t         address
65)
66{
67  uint32_t         data;
68
69  /*
70   * Write the PCI configuration address
71   */
72   PCI_bus_write( (volatile uint32_t*)SCORE603E_PCI_IO_CFG_ADDR, address );
73
74  /*
75   *  Delay needed when running out of DRAM
76   */
77   PCI_bus_delay ();
78
79  /*
80   * read data
81   */
82  data = PCI_bus_read( (volatile uint32_t*)SCORE603E_PCI_IO_CFG_DATA );
83
84  return data;
85}
86
87void  Write_pci_device_register(
88  uint32_t         address,
89  uint32_t         data
90)
91{
92  /*
93   * Write the PCI configuration address
94   */
95   PCI_bus_write( (volatile uint32_t*)SCORE603E_PCI_IO_CFG_ADDR, address );
96
97  /*
98   *  Delay needed when running out of DRAM
99   */
100   PCI_bus_delay ();
101
102  /*
103   * write data
104   */
105  PCI_bus_write( (volatile uint32_t*)SCORE603E_PCI_IO_CFG_DATA, data );
106}
Note: See TracBrowser for help on using the repository browser.