source: rtems/c/src/lib/libbsp/powerpc/score603e/PCI_bus/flash.c @ c499856

4.115
Last change on this file since c499856 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.6 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#include <inttypes.h>
15
16#include <bsp.h>
17#include <bsp/irq.h>
18#include "PCI.h"
19
20/*PAGE
21 *
22 *  SCORE603e_FLASH_Disable
23 */
24
25unsigned int SCORE603e_FLASH_Disable(
26  uint32_t                       area                           /* IN  */
27)
28{
29  uint8_t         value;
30
31  value = *SCORE603E_BOARD_CTRL_REG;
32  value = value | (~SCORE603E_BRD_FLASH_DISABLE_MASK);
33  *SCORE603E_BOARD_CTRL_REG = value;
34
35  return RTEMS_SUCCESSFUL;
36}
37
38unsigned int SCORE603e_FLASH_verify_enable( void )
39{
40  volatile uint8_t         *Ctrl_Status_Register =
41           (void *)SCORE603E_BOARD_CTRL_REG;
42  uint8_t          ctrl_value;
43  uint32_t         pci_value;
44
45  ctrl_value = *Ctrl_Status_Register;
46  if ( ctrl_value & SCORE603E_BRD_FLASH_DISABLE_MASK ) {
47    printf ("Flash Writes Disabled by board control register %x\n",
48            ctrl_value );
49    assert( 0x0 );
50  }
51
52  pci_value = Read_pci_device_register( 0x800000A8 );
53  if (( pci_value & 0x00001000 ) == 0) {
54    printf("Error PCI A8 \n");
55    assert( 0x0 );
56  }
57
58  pci_value = Read_pci_device_register( 0x800000AC );
59  if ( pci_value & 0x02000000) {
60    printf("Error PCI AC \n");
61    assert( 0x0 );
62  }
63  return RTEMS_SUCCESSFUL;
64}
65
66unsigned int SCORE603e_FLASH_pci_reset_reg(
67  uint8_t          reg,
68  uint32_t         cmask,
69  uint32_t         mask
70)
71{
72  uint32_t         pci_value;
73  uint32_t         value;
74
75  pci_value = Read_pci_device_register( reg );
76  pci_value &= cmask;
77  pci_value |= mask;
78  Write_pci_device_register( reg, pci_value );
79  value = Read_pci_device_register(  reg );
80  if (value != pci_value) {
81    printf("Error PCI 0x%2"PRIX8" wrote 0x%8"PRIX32" read %8"PRIX32"\n", reg, pci_value, value);
82  }
83  return RTEMS_SUCCESSFUL;
84}
85
86/*PAGE
87 *
88 *  SCORE603e_FLASH_Enable_writes
89 */
90unsigned int SCORE603e_FLASH_Enable_writes(
91  uint32_t                       area                           /* IN  */
92)
93{
94  uint8_t          ctrl_value;
95  uint32_t         pci_value;
96
97  ctrl_value = *SCORE603E_BOARD_CTRL_REG;
98  ctrl_value = ctrl_value & 0xbf;
99  *SCORE603E_BOARD_CTRL_REG = ctrl_value;
100
101  pci_value = Read_pci_device_register( 0x800000A8 );
102  pci_value |= 0x00001000;
103  Write_pci_device_register( 0x800000A8, pci_value );
104
105  pci_value = Read_pci_device_register( 0x800000AC );
106  pci_value &=  (~0x02000000);
107  Write_pci_device_register( 0x000000AC, pci_value );
108
109  return RTEMS_SUCCESSFUL;
110}
Note: See TracBrowser for help on using the repository browser.