source: rtems/c/src/lib/libbsp/powerpc/score603e/PCI_bus/PCI.c @ 0626dba

4.115
Last change on this file since 0626dba was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • 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.org/license/LICENSE.
9 */
10
11#include <rtems.h>
12#include <assert.h>
13#include <stdio.h>
14
15#include <bsp.h>
16
17/*
18 * Forced delay to get around timing problems with the UNIVERSE chip.  The
19 * two nops are used so that the delay works for varying clock frequencies,
20 * up to 66 Mhz, with margin.  Each nop averages about 1 1/2 clock ticks,
21 * and since there are 2 nops, this routine takes about 3 clock ticks,
22 * which on a worst case 66 Mhz board, is 45 nanosecond. This time period
23 * is sufficient to guarantee a work-around to the UNIVERSE chip timing
24 * problem.  The problem is that when there are two successive accesses to
25 * an UNIVERSE register, without sufficient delay, the second access will
26 * not work correctly.
27 */
28void PCI_bus_delay (void)
29{
30  __asm__ ("    nop");
31  __asm__ (" nop");
32}
33
34/*
35 * PCI_bus_write
36 */
37void PCI_bus_write(
38  volatile uint32_t         * _addr,                  /* IN */
39  uint32_t         _data                              /* IN */
40)
41{
42  _data = Convert_Endian_32( _data );
43  *_addr = _data;
44}
45
46uint32_t         PCI_bus_read(
47  volatile uint32_t         *  _addr                  /* IN */
48)
49{
50  uint32_t         data;
51
52  data = *_addr;
53  data = Convert_Endian_32( data );
54  return data;
55}
56/*
57 * PCI Configuration Cycle Read/Write Access which is used to access all of
58 * devices registers on the PCI bus.  i.e.: Universe, Ethernet & PMC.
59 */
60
61uint32_t         Read_pci_device_register(
62  uint32_t         address
63)
64{
65  uint32_t         data;
66
67  /*
68   * Write the PCI configuration address
69   */
70   PCI_bus_write( (volatile uint32_t*)SCORE603E_PCI_IO_CFG_ADDR, address );
71
72  /*
73   *  Delay needed when running out of DRAM
74   */
75   PCI_bus_delay ();
76
77  /*
78   * read data
79   */
80  data = PCI_bus_read( (volatile uint32_t*)SCORE603E_PCI_IO_CFG_DATA );
81
82  return data;
83}
84
85void  Write_pci_device_register(
86  uint32_t         address,
87  uint32_t         data
88)
89{
90  /*
91   * Write the PCI configuration address
92   */
93   PCI_bus_write( (volatile uint32_t*)SCORE603E_PCI_IO_CFG_ADDR, address );
94
95  /*
96   *  Delay needed when running out of DRAM
97   */
98   PCI_bus_delay ();
99
100  /*
101   * write data
102   */
103  PCI_bus_write( (volatile uint32_t*)SCORE603E_PCI_IO_CFG_DATA, data );
104}
Note: See TracBrowser for help on using the repository browser.