OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [powerpc/] [score603e/] [PCI_bus/] [PCI.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *
3
 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994, 1997.
4
 *  On-Line Applications Research Corporation (OAR).
5
 *  All rights assigned to U.S. Government, 1994.
6
 *
7
 *  This material may be reproduced by or for the U.S. Government pursuant
8
 *  to the copyright license under the clause at DFARS 252.227-7013.  This
9
 *  notice must appear in all copies of this file and its derivatives.
10
 *
11
 * $ld:
12
 */
13
 
14
#include <rtems.h>
15
#include <assert.h>
16
#include <stdio.h>
17
 
18
#include <bsp.h>
19
 
20
/*
21
 * Forced delay to get around timing problems with the UNIVERSE chip.  The
22
 * two nops are used so that the delay works for varying clock frequencies,
23
 * up to 66 Mhz, with margin.  Each nop averages about 1 1/2 clock ticks,
24
 * and since there are 2 nops, this routine takes about 3 clock ticks,
25
 * which on a worst case 66 Mhz board, is 45 nanosecond. This time period
26
 * is sufficient to guarantee a work-around to the UNIVERSE chip timing
27
 * problem.  The problem is that when there are two successive accesses to
28
 * an UNIVERSE register, without sufficient delay, the second access will
29
 * not work correctly.
30
 */
31
void PCI_bus_delay ()
32
{
33
  asm(" nop");
34
  asm(" nop");
35
}
36
 
37
 
38
 
39
/*
40
 * PCI_bus_write
41
 */
42
void PCI_bus_write(
43
  volatile rtems_unsigned32 * _addr,                  /* IN */
44
  rtems_unsigned32 _data                              /* IN */
45
)
46
{
47
  _data = Convert_Endian_32( _data );
48
  *_addr = _data;
49
}
50
 
51
rtems_unsigned32 PCI_bus_read(
52
  volatile rtems_unsigned32 *  _addr                  /* IN */
53
)
54
{
55
  rtems_unsigned32 data;
56
 
57
  data = *_addr;
58
  data = Convert_Endian_32( data );
59
  return data;
60
}
61
/*
62
 * PCI Configuration Cycle Read/Write Access which is used to access all of
63
 * devices registers on the PCI bus.  i.e.: Universe, Ethernet & PMC.
64
 */
65
 
66
rtems_unsigned32 Read_pci_device_register(
67
  rtems_unsigned32 address
68
)
69
{
70
  rtems_unsigned32 data;
71
 
72
  /*
73
   * Write the PCI configuration address
74
   */
75
   PCI_bus_write( (volatile rtems_unsigned32 *)SCORE603E_PCI_IO_CFG_ADDR, address );
76
 
77
  /*
78
   *  Delay needed when running out of DRAM
79
   */
80
   PCI_bus_delay ();
81
 
82
  /*
83
   * read data
84
   */
85
  data = PCI_bus_read( (volatile rtems_unsigned32 *)SCORE603E_PCI_IO_CFG_DATA );
86
 
87
  return data;
88
}
89
 
90
void  Write_pci_device_register(
91
  rtems_unsigned32 address,
92
  rtems_unsigned32 data
93
)
94
{
95
  /*
96
   * Write the PCI configuration address
97
   */
98
   PCI_bus_write( (volatile rtems_unsigned32 *)SCORE603E_PCI_IO_CFG_ADDR, address );
99
 
100
  /*
101
   *  Delay needed when running out of DRAM
102
   */
103
   PCI_bus_delay ();
104
 
105
  /*
106
   * write data
107
   */
108
  PCI_bus_write( (volatile rtems_unsigned32 *)SCORE603E_PCI_IO_CFG_DATA, data );
109
}
110
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.