source: rtems/c/src/lib/libbsp/powerpc/score603e/PCI_bus/PCI.c @ 1004c3c1

4.104.115
Last change on this file since 1004c3c1 was 1004c3c1, checked in by Joel Sherrill <joel.sherrill@…>, on 10/02/08 at 14:26:17

2008-10-02 Joel Sherrill <joel.sherrill@…>

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