Subversion Repositories f9daq

Rev

Blame | Last modification | View Log | RSS feed

//****************************************************************************
// Copyright (C) 2000-2004  ARW Elektronik Germany
//
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// This product is not authorized for use as critical component in
// life support systems without the express written approval of
// ARW Elektronik Germany.
//  
// Please announce changes and hints to ARW Elektronik
//
// Maintainer(s): Klaus Hitschler (klaus.hitschler@gmx.de)
//
//****************************************************************************

//****************************************************************************
//
// plxbug.c -- plx 9050 bug fix code the PCICC32 PCI to CAMAC Interface
//
// $Log: plxbug.c,v $
// Revision 1.7  2004/08/12 19:59:19  klaus
// conversion to kernel-version 2.6, released version 6.0
//
// Revision 1.6  2003/05/11 11:12:03  klaus
// matched to kernel 2.4 PCI handling, debug messages improved
//
// Revision 1.5  2002/10/08 18:01:46  klaus
// corrections mainly for use with kernel 2.2.19
//
// Revision 1.4  2001/11/20 20:12:50  klaus
// included new header and CVS log
//
//
// first steps                                                 AR   18.02.2000
// MODVERSIONS included                                        AR   24.04.2000
//
//****************************************************************************

#include "common.h"  /* must be the first include */

#include <linux/kernel.h> /* printk() */
#include <asm/types.h>
#include "plxbug.h"

/*-------------------------------------------------------------------------
// DEFINES
*/

#define PCR_MEMORY_BUG  0x00       // 1st PCR index of potential bug
#define PCR_IO_BUG      0x01       // 2nd PCR index of potential bug
#define PCR_MEMORY_OK   0x04       // 1st PCR index of no bug
#define PCR_IO_OK       0x05       // 2nd PCR index of no bug

/*-------------------------------------------------------------------------
// EXTERNALS
*/


/*---------------------------------------------------------------
// function to call for bug fix
*/

                       
/* fixes address of LCR through change in address windows - updates PCIConfigHeader
*/

void PLX9050BugFix(PCIConfigHeader *pHeader)
{
  __u32 dwDataBug;
  __u32 dwDataOK;  
  int ret = 0;
 
  DPRINTK(KERN_DEBUG "pcicc32 : PLX9050BugFix()\n");
       
  if (pHeader->desc[PCR_MEMORY_BUG].base_address & 0x80)
  {
      if ((ret  = pci_read_config_dword(pHeader->PCI_dev,  PCI_BASE_ADDRESS_0, &dwDataBug)))
        goto label;
      if ((ret  = pci_read_config_dword(pHeader->PCI_dev,  PCI_BASE_ADDRESS_4, &dwDataOK)))
        goto label;
           
      if ((ret  = pci_write_config_dword(pHeader->PCI_dev, PCI_BASE_ADDRESS_0, dwDataOK)))
        goto label;
      if ((ret  = pci_write_config_dword(pHeader->PCI_dev, PCI_BASE_ADDRESS_4, dwDataBug)))
        goto label;
           
      dwDataBug = pHeader->desc[PCR_MEMORY_BUG].base_address;
      dwDataOK  = pHeader->desc[PCR_MEMORY_OK].base_address;
     
      pHeader->desc[PCR_MEMORY_BUG].base_address = dwDataOK;
      pHeader->desc[PCR_MEMORY_OK].base_address  = dwDataBug;
  }

  if (pHeader->desc[PCR_IO_BUG].base_address & 0x80)
  {
      if ((ret = pci_read_config_dword(pHeader->PCI_dev,  PCI_BASE_ADDRESS_1, &dwDataBug)))
        goto label;
      if ((ret = pci_read_config_dword(pHeader->PCI_dev,  PCI_BASE_ADDRESS_5, &dwDataOK)))
        goto label;
     
      if ((ret = pci_write_config_dword(pHeader->PCI_dev, PCI_BASE_ADDRESS_1, dwDataOK)))
        goto label;
      if ((ret = pci_write_config_dword(pHeader->PCI_dev, PCI_BASE_ADDRESS_5, dwDataBug)))
        goto label;
     
      dwDataBug = pHeader->desc[PCR_IO_BUG].base_address;
      dwDataOK  = pHeader->desc[PCR_IO_OK].base_address;
     
      pHeader->desc[PCR_IO_BUG].base_address = dwDataOK;
      pHeader->desc[PCR_IO_OK].base_address  = dwDataBug;
  }
 
  return;
 
  label:
  printk(KERN_ERR "pcicc32 : PLX9050BugFix() : PCI-error %d!\n", ret);
  return;
}