Subversion Repositories f9daq

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
86 f9daq 1
//****************************************************************************
2
// Copyright (C) 2000-2004  ARW Elektronik Germany
3
//
4
//
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2 of the License, or
8
// (at your option) any later version.
9
//
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
// GNU General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
//
19
// This product is not authorized for use as critical component in 
20
// life support systems without the express written approval of 
21
// ARW Elektronik Germany.
22
//  
23
// Please announce changes and hints to ARW Elektronik
24
//
25
// Maintainer(s): Klaus Hitschler (klaus.hitschler@gmx.de)
26
//
27
//****************************************************************************
28
 
29
//****************************************************************************
30
//
31
// plxbug.c -- plx 9050 bug fix code the PCICC32 PCI to CAMAC Interface
32
//
33
// $Log: plxbug.c,v $
34
// Revision 1.7  2004/08/12 19:59:19  klaus
35
// conversion to kernel-version 2.6, released version 6.0
36
//
37
// Revision 1.6  2003/05/11 11:12:03  klaus
38
// matched to kernel 2.4 PCI handling, debug messages improved
39
//
40
// Revision 1.5  2002/10/08 18:01:46  klaus
41
// corrections mainly for use with kernel 2.2.19
42
//
43
// Revision 1.4  2001/11/20 20:12:50  klaus
44
// included new header and CVS log
45
//
46
//
47
// first steps                                                 AR   18.02.2000
48
// MODVERSIONS included                                        AR   24.04.2000
49
//
50
//****************************************************************************
51
 
52
#include "common.h"  /* must be the first include */
53
 
54
#include <linux/kernel.h> /* printk() */
55
#include <asm/types.h>
56
#include "plxbug.h"
57
 
58
/*-------------------------------------------------------------------------
59
// DEFINES
60
*/
61
#define PCR_MEMORY_BUG  0x00       // 1st PCR index of potential bug
62
#define PCR_IO_BUG      0x01       // 2nd PCR index of potential bug
63
#define PCR_MEMORY_OK   0x04       // 1st PCR index of no bug 
64
#define PCR_IO_OK       0x05       // 2nd PCR index of no bug
65
 
66
/*-------------------------------------------------------------------------
67
// EXTERNALS
68
*/
69
 
70
/*---------------------------------------------------------------
71
// function to call for bug fix
72
*/
73
 
74
/* fixes address of LCR through change in address windows - updates PCIConfigHeader
75
*/
76
void PLX9050BugFix(PCIConfigHeader *pHeader)
77
{
78
  __u32 dwDataBug;
79
  __u32 dwDataOK;  
80
  int ret = 0;
81
 
82
  DPRINTK(KERN_DEBUG "pcicc32 : PLX9050BugFix()\n");
83
 
84
  if (pHeader->desc[PCR_MEMORY_BUG].base_address & 0x80)
85
  {
86
      if ((ret  = pci_read_config_dword(pHeader->PCI_dev,  PCI_BASE_ADDRESS_0, &dwDataBug)))
87
        goto label;
88
      if ((ret  = pci_read_config_dword(pHeader->PCI_dev,  PCI_BASE_ADDRESS_4, &dwDataOK)))
89
        goto label;
90
 
91
      if ((ret  = pci_write_config_dword(pHeader->PCI_dev, PCI_BASE_ADDRESS_0, dwDataOK)))
92
        goto label;
93
      if ((ret  = pci_write_config_dword(pHeader->PCI_dev, PCI_BASE_ADDRESS_4, dwDataBug)))
94
        goto label;
95
 
96
      dwDataBug = pHeader->desc[PCR_MEMORY_BUG].base_address;
97
      dwDataOK  = pHeader->desc[PCR_MEMORY_OK].base_address;
98
 
99
      pHeader->desc[PCR_MEMORY_BUG].base_address = dwDataOK;
100
      pHeader->desc[PCR_MEMORY_OK].base_address  = dwDataBug;
101
  }
102
 
103
  if (pHeader->desc[PCR_IO_BUG].base_address & 0x80)
104
  {
105
      if ((ret = pci_read_config_dword(pHeader->PCI_dev,  PCI_BASE_ADDRESS_1, &dwDataBug)))
106
        goto label;
107
      if ((ret = pci_read_config_dword(pHeader->PCI_dev,  PCI_BASE_ADDRESS_5, &dwDataOK)))
108
        goto label;
109
 
110
      if ((ret = pci_write_config_dword(pHeader->PCI_dev, PCI_BASE_ADDRESS_1, dwDataOK)))
111
        goto label;
112
      if ((ret = pci_write_config_dword(pHeader->PCI_dev, PCI_BASE_ADDRESS_5, dwDataBug)))
113
        goto label;
114
 
115
      dwDataBug = pHeader->desc[PCR_IO_BUG].base_address;
116
      dwDataOK  = pHeader->desc[PCR_IO_OK].base_address;
117
 
118
      pHeader->desc[PCR_IO_BUG].base_address = dwDataOK;
119
      pHeader->desc[PCR_IO_OK].base_address  = dwDataBug;
120
  }
121
 
122
  return;
123
 
124
  label:
125
  printk(KERN_ERR "pcicc32 : PLX9050BugFix() : PCI-error %d!\n", ret);
126
  return;
127
}
128